From patchwork Tue Feb 5 14:07:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tokunori Ikegami X-Patchwork-Id: 1036771 X-Patchwork-Delegate: vigneshr@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=yahoo.co.jp Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="EXVxUCZr"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="nowuFcCC"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43v60J3Fhcz9s4Z for ; Wed, 6 Feb 2019 01:09:52 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=hdVw3jpy4VueZhNHOXQRWlAmUYM4mJrwvnQ+ztfHGS8=; b=EXVxUCZrZCcyqw/FZucvgBTnGq 92yg9J6u5honCd5xIkpC9lMahAYlQyPJVuCG+XbpAczq+brrk4NZsIEqJSmXLjGyWp01dpbe0GVbT t2/yJ0BMXdgyxS3C75KCbfaTLM05R3qSZzVpLCF3gSoOhwQJstYlFceOKI/bbnTmdXL2I0odDnsIB IMVjLlgmHpmdwLlf0NniaQMPXL8AcguPDi4eovhdNQMBT9OzhgNbaZlQoimi8ZIzTb3XfV7g+XH0r SxZpWN4I6k7h6lxgdGsUlQt6oifBSGibWQZkVzPVyPB47zVlHofc0f4iZIxndhc4QNiDU8u1joOHE AcIQL5pA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1Q1-0007Oh-A1; Tue, 05 Feb 2019 14:09:45 +0000 Received: from nh503-vm6.bullet.mail.kks.yahoo.co.jp ([183.79.56.192]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1PI-0006lQ-Hf for linux-mtd@lists.infradead.org; Tue, 05 Feb 2019 14:09:04 +0000 Received: from [183.79.100.141] by nh503.bullet.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:54 -0000 Received: from [183.79.101.121] by t504.bullet.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:54 -0000 Received: from [127.0.0.1] by omp508.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:54 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 668476.79500.bm@omp508.mail.kks.yahoo.co.jp Received: (qmail 45573 invoked by alias); 5 Feb 2019 14:08:54 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549375734; bh=g8IUWPIVI8+eqErM+hfdHVesTIIEB5FfIE0lfM1MJ0E=; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=nowuFcCCXoCgqp0FMiLrNYsqw6sMGiM4nVE2VQIthwl62G0XJAd1vmpXhdVc9OgPcg2LgcmIDS4pfu+aCNpd9ft5p4AK2eoxobFouBANX6dp28oLMxfEYhSRLPUAivInzr+Ob5OuqXe/sn5Tb+uhlh54siyAxPzT7Ys/ZC+a1Jo= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=yj20110701; d=yahoo.co.jp; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=TTjVw8DbVB1IydiUf0hkUIisYLVqgWHH2YmiA7wK/4zP5IXfhJwkkSyL1wY4DT1uMMtL8AI/NqsL1a3avtYxZDclnxFHnbumtxE3tgC942Bl74h769wFhV/a80H+wz+WJrVJuVwky4vNoJIR4VweghP/q9/9IQOa39JAnGiOvY0= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp5006.mail.kks.ynwp.yahoo.co.jp with SMTP; 5 Feb 2019 14:08:54 -0000 X-YMail-JAS: yAzcHXUVM1l70vaPPPJiRSARrqFb_dkGKnmGHVREExTUoigRLv5SmqdsCLNXY1tE2NBOTSsDJNGwNgN7XT5.sSMqRRsDo4wK3uCONcoc.pSzxFD9.zOHEmIjpnmyq8lKW7munmR1bg-- X-Apparently-From: X-YMail-OSG: zJMWKLUVM1nCu.79pH0x_R75vtSm7DELz_a8L2fg8DCLM2_ 4SPohL4OHOjm35tqFAQ3L1c15s3ltt4FvsfJhWB6lPhhMBIqlFo3e.rw5SmG Y3DjBuj492PuxR8UZHbJHe8L2BaFJebJP1cfeEO6q.c45S48MQVsucE00QCZ qBB.7bbEKuPinztkQKq.bIu3pM9pvikCHNYTOpIVI1Y2SHTjretSimu6QCqN vNI6La62DiGDnBMMrOp74FnKU.RMBdtrnDsFyYJE2mf.SWHWsQSrKf8bjGuK dl3P4NHXJ5wi5z7lzZnxRINcRvO..NyQKoszfg997dDiqyWpmEzLfogknUsI meM8hgjuwP4osZG84ATg8UvqqjN961ZBd1tXGZjBdMZZ_BfoHEK18bXjM26G _49g_4XBXN7H0LCqAPzZp.PGeGVMRdoLagZSWpUl2sSaXAlZ3rONKo5KfEDK z7baeVVAC1ZLBaXiJADFfrL5y607jZof7u9dpP1REnDpe3zAOH4ngAfT2ohn bIcnw5zuNSoJNVgfQLRLAmBBcIThLSl7n_AcoR1C5skTffU.L155AXqBeYUs ee1HkOVz2jhNvNm3z6D5l50fJmHoS1bwtxYjmN1njkbYqDE7t From: Tokunori Ikegami To: Boris Brezillon Subject: [PATCH v5 01/11] mtd: cfi_cmdset_0002: Use chip_good() to retry in do_write_oneword() Date: Tue, 5 Feb 2019 23:07:49 +0900 Message-Id: <20190205140759.2360-2-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> References: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190205_060900_920266_705879AA X-CRM114-Status: GOOD ( 20.28 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [183.79.56.192 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ikegami_to[at]yahoo.co.jp) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stable@vger.kernel.org, Joakim Tjernlund , Tokunori Ikegami , linux-mtd@lists.infradead.org, Chris Packham , Felix Fietkau MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org As reported by the OpenWRT team, write requests sometimes fail on some platforms. Currently to check the state chip_ready() is used correctly as described by the flash memory S29GL256P11TFI01 datasheet. Also chip_good() is used to check if the write is succeeded and it was implemented by the commit fb4a90bfcd6d8 ("[MTD] CFI-0002 - Improve error checking"). But actually the write failure is caused on some platforms and also it can be fixed by using chip_good() to check the state and retry instead. Also it seems that it is caused after repeated about 1,000 times to retry the write one word with the reset command. By using chip_good() to check the state to be done it can be reduced the retry with reset. It is depended on the actual flash chip behavior so the root cause is unknown. Signed-off-by: Tokunori Ikegami Signed-off-by: Felix Fietkau Co-Developed-by: Hauke Mehrtens Co-Developed-by: Koen Vandeputte Reported-by: Fabio Bettoni Cc: Chris Packham Cc: Joakim Tjernlund Cc: linux-mtd@lists.infradead.org Cc: stable@vger.kernel.org --- Changes since v4: - None. Changes since v3: - Update the commit message for the comments. - Drop the addition of blanks lines around xip_enable(). - Delete unnecessary setting the ret variable to -EIO. - Change the email address of Tokunori Ikegami to ikegami_to@yahoo.co.jp. Changes since v2: - Just update the commit message for the comment. Changes since v1: - Just update the commit message. Background: This is required for OpenWrt Project to result the flash write issue as below patche. Also the original patch in OpenWRT is below. The reason to use chip_good() is that just actually fix the issue. And also in the past I had fixed the erase function also as same way by the patch below. Note: The reason for the patch for erase is same. In my understanding the chip_ready() is just checked the value twice from flash. So I think that sometimes incorrect value is read twice and it is depended on the flash device behavior but not sure.. So change to use chip_good() instead of chip_ready(). drivers/mtd/chips/cfi_cmdset_0002.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) mode change 100644 => 100755 drivers/mtd/chips/cfi_cmdset_0002.c diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c old mode 100644 new mode 100755 index 72428b6..91a491b --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1627,29 +1627,31 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, continue; } - if (time_after(jiffies, timeo) && !chip_ready(map, adr)){ + if (chip_good(map, adr, datum)) + break; + + if (time_after(jiffies, timeo)){ xip_enable(map, chip, adr); printk(KERN_WARNING "MTD %s(): software timeout\n", __func__); xip_disable(map, chip, adr); + ret = -EIO; break; } - if (chip_ready(map, adr)) - break; - /* Latency issues. Drop the lock, wait a while and retry */ UDELAY(map, chip, adr, 1); } + /* Did we succeed? */ - if (!chip_good(map, adr, datum)) { + if (ret) { /* reset on all failures. */ map_write(map, CMD(0xF0), chip->start); /* FIXME - should have reset delay before continuing */ - if (++retry_cnt <= MAX_RETRIES) + if (++retry_cnt <= MAX_RETRIES) { + ret = 0; goto retry; - - ret = -EIO; + } } xip_enable(map, chip, adr); op_done: From patchwork Tue Feb 5 14:07:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tokunori Ikegami X-Patchwork-Id: 1036768 X-Patchwork-Delegate: vigneshr@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=yahoo.co.jp Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="amcX1CQf"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="WnAjqS4c"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43v5zT4ypfz9s4Z for ; Wed, 6 Feb 2019 01:09:09 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=kZY/Ux8vd9yaDMPdShftcs3VNWun1HSMb2K1FrUyq5U=; b=amcX1CQfrXUnugNKgNLng43nPh /qM7390I1nlKG/cCxc5vCm+lu8rPGJc5bHCgE7vrUEDMzlMF9RqDqYFor5edRhxwatT7K4JpzSsgp FMRyBE6wtSwyy0rj7OI0cdStEE3ZTHq5RVydPMPopoR7glBaeQ1JHRvh1n8pkiYdD1lcW+9QFZ+Yt B04OcCe4ljVXqTV4IppmMYYhYak1ey714TMKJkPNJCE89hrrR3lzVmzNhqwM5mC/bx4RL7Ey+0QHU f0raqjREnqAsZVymB9ll+anClRJ7jzYmND5jmge+1S6OhrPUNMjFdv7uPqwaYx2/XFT7foxVfIJ58 agmRFmDw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1PL-0006np-Vj; Tue, 05 Feb 2019 14:09:03 +0000 Received: from nh603-vm5.bullet.mail.ssk.yahoo.co.jp ([182.22.90.46]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1PH-0006lS-Bj for linux-mtd@lists.infradead.org; Tue, 05 Feb 2019 14:09:02 +0000 Received: from [182.22.66.103] by nh603.bullet.mail.ssk.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:55 -0000 Received: from [182.22.91.132] by t601.bullet.mail.ssk.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:55 -0000 Received: from [127.0.0.1] by omp605.mail.ssk.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:55 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 613366.19131.bm@omp605.mail.ssk.yahoo.co.jp Received: (qmail 45588 invoked by alias); 5 Feb 2019 14:08:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549375735; bh=GWQfPqv0aZCsCVXewgkoEkzJb3RofaMP6Igg+afbTZw=; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=WnAjqS4ckGRya/hEE5WbZ/4kIswIiM484x2ij2KnKu22/MSCOirUDSzxJpS3n52PJM1ZRgBwMyRH+SdkFQ7V/YvenMexjPiheOnXsT3SFBISOHdUfKSm9Zp/IWZ8+U7+zFpAsBfijuXf83x5bF33tAgDS/4gKIvRGD5dC0YQjBk= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=yj20110701; d=yahoo.co.jp; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=QDmiixyEbFmLUQ85fVy47ch4OXropz3EjvvUvAxcs2tT9izdssGleLtSJTzX8hDgxy/h3sfUhJAc+krEFp0L8eqFhJ+wVLPdOLkJVnoqQAMqeRGx9MUIXfRiPJgcA+F4LGs2jRYK2/7dw0kuOZf4DZXC9JQE/Wz6NqFziu5lFPY= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp5006.mail.kks.ynwp.yahoo.co.jp with SMTP; 5 Feb 2019 14:08:54 -0000 X-YMail-JAS: yAzcHXUVM1l70vaPPPJiRSARrqFb_dkGKnmGHVREExTUoigRLv5SmqdsCLNXY1tE2NBOTSsDJNGwNgN7XT5.sSMqRRsDo4wK3uCONcoc.pSzxFD9.zOHEmIjpnmyq8lKW7munmR1bg-- X-Apparently-From: X-YMail-OSG: _COmcmYVM1mOnF571hC6g2MrGjsJEv7RLx8SXTm6ksEaKaH ZjLjEEbFF1W7T6536XBWYT0qsTP9b69gFrID.2AgACq4hzxamoJgK5mx4Awj d6fBbz8yoCuvBzf0.hr5i1Hq6PL_R9yof.n8TmBWDTv2CKwH6qDP0zn4vWMx G6F2ryZJ4ZD36q1kPU8Dy5LzuqMkqIVIrV3uKziiGfM30PR2geFPlaSvtT5n a6kr6Mg5z_p9EjFnkslHOonvlKqKW7EqT7Wtc1ymSFumvQINRq8GNfdl6ViG w2xIpfa6qezx7PzCfxNSODUZtDuzA2SEFa9WgVNsbW7np48tcjaY.mVL4QQR B6alDoJGCwjr.Ez3VSkahynMv7YclvxUCzk.jpsBRGrcDAhlKpFsTjk_W8KN dPUP6gvo6VgqjyHOmoa4Q2WNPIDOCVt.9jNRAnhCTcYtP..D3lGP57NkJjAm i1_CucYLQolxZRypsTA5q5UertenjtlP3Cqb.PGDv763kOE.0VoYI2f4yAiN w2p7eGq96ZGZWoLLpUVgRB3xT5mTu4tM2hKNCrlZs62Gv3jQx.HSXPcAutKK yP.EQaoHFFzSkVps2BwW3oxWOJWZoeAiIR9bfRyEcIqfYnPIt From: Tokunori Ikegami To: Boris Brezillon Subject: [PATCH v5 02/11] mtd: cfi_cmdset_0002: Remove chip_ready() from do_write_buffer() Date: Tue, 5 Feb 2019 23:07:50 +0900 Message-Id: <20190205140759.2360-3-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> References: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190205_060859_779229_D6D28BB0 X-CRM114-Status: GOOD ( 15.59 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [182.22.90.46 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ikegami_to[at]yahoo.co.jp) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stable@vger.kernel.org, Joakim Tjernlund , Tokunori Ikegami , linux-mtd@lists.infradead.org, Chris Packham , Fabio Bettoni MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org It is enough to use chip_good() only so chip_ready() is not necessary. Since chip_good() is doing the same check chip_ready() is doing plus an extra check to make sure we end up with the data we wrote. For this change the order to check timeout also will be changed at same time. The order is not a hard requirement, it's just better to avoid the case where the data update happens just after the timeout has expired. This change actually a bux that it might cause an infinite loop. Since currently the infinite loop is only exited by the conditions below. 1. Timed out and not chip_ready() 2. chip_good() So if chip_ready() and not chip_good() the loop is not exited as infinite. Signed-off-by: Tokunori Ikegami Fixes: dfeae1073583d ("mtd: cfi_cmdset_0002: Change write buffer to check correct value") Reported-by: Przemyslaw Sobon Cc: Fabio Bettoni Co: Hauke Mehrtens Co: Koen Vandeputte Cc: Chris Packham Cc: Joakim Tjernlund Cc: linux-mtd@lists.infradead.org Cc: stable@vger.kernel.org --- Changes since v4: - Update the commit message about the infinite loop problem. Changes since v3: - Update the commit message for the comment. - Change the email address of Tokunori Ikegami to ikegami_to@yahoo.co.jp. Changes since v2: - None. Changes since v1: - None. drivers/mtd/chips/cfi_cmdset_0002.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index 91a491b..ca9d5fa 100755 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1878,14 +1878,14 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, continue; } - if (time_after(jiffies, timeo) && !chip_ready(map, adr)) - break; - if (chip_good(map, adr, datum)) { xip_enable(map, chip, adr); goto op_done; } + if (time_after(jiffies, timeo)) + break; + /* Latency issues. Drop the lock, wait a while and retry */ UDELAY(map, chip, adr, 1); } From patchwork Tue Feb 5 14:07:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tokunori Ikegami X-Patchwork-Id: 1036793 X-Patchwork-Delegate: vigneshr@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=yahoo.co.jp Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XCMELbYM"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="PEyJlTc2"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43v6GZ1YTWz9s4Z for ; Wed, 6 Feb 2019 01:22:10 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=djN9ncp3t44Ff63W7LsuqSnv0gH8MxZxNN29yo1PMQg=; b=XCMELbYMCdCV9xIM2sn3+9gbAL 1kbS3wcpE5eOFiaDwxAHH5JlJzQSJUwIxS0iCBInGkh2egxU1+9WTfPscNzQ5LYWScfQEZ/J+y/qz DIsCH3CBOp8oZHv0PI3Q3uaW0udZsWBaDOegxXKGirtaHrxJIUrvUeAmP8tKL3+d1vg2ZgzctXuT3 1a51F4VZSlUYlmUxAx+Hi7HrJOmF2wTk7JJL9HfyHNpXRtZxF/TqSOX77FEqu2LgY2UI4g2P8LREV bzSzHRly1ZtVB/9qkGaAtazoaSj+PzBtTmCkf4T03PagXnLJ9S/AGrFfSnxHniCviQVdSxvWAnSm5 VFEwrtBg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1bn-0006MR-St; Tue, 05 Feb 2019 14:21:55 +0000 Received: from nh504-vm4.bullet.mail.kks.yahoo.co.jp ([183.79.57.90]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1PI-0006lW-GF for linux-mtd@lists.infradead.org; Tue, 05 Feb 2019 14:09:04 +0000 Received: from [183.79.100.138] by nh504.bullet.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:55 -0000 Received: from [183.79.101.122] by t501.bullet.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:55 -0000 Received: from [127.0.0.1] by omp509.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:55 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 969433.8028.bm@omp509.mail.kks.yahoo.co.jp Received: (qmail 45665 invoked by alias); 5 Feb 2019 14:08:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549375735; bh=NamvOjmwD6jKAny9LHfGhwSwo18zvRoxQCQNSoMAYsg=; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=PEyJlTc2x5pDXr91hygg4w1q09YRgQz4pbQPGq01xLvjfUTT+2EFJRfUHh1X4HJ8r3k4b5DDsBhmAh7lGv/WwI0bn5H8jlaRrHMlxD5glcupyxAW5USJTnzoCqutaL/t43q/xQnaASgRXLGwW5G98ZoeiKKRSnNR6WGlnzEPoo8= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=yj20110701; d=yahoo.co.jp; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=cqrneiu7o47+WzzTfh/vBlw1TrwomNkCvh9RjaqqsF27Y7mZzM5TpiAEH8CkhWilljc+49TkI3w/AS7v//wu6aGlj3Y5AIdY7tzO08X7NO6ScB4TUj7aKmeFPOpLTeIz+uYBM5vpXaQqBHu8ipWRr4iKHGv2PTmBTQ+vIA3llW4= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp5006.mail.kks.ynwp.yahoo.co.jp with SMTP; 5 Feb 2019 14:08:55 -0000 X-YMail-JAS: ELIXyV0VM1kzMnKZ2aphV5sUvj8tgX.Jv1.9ezxZ7EYrVSlEC5cqv9j8dGhA5NGhdi2PRCiNCBtOV_veOoVPcZtYwFwJQ_sXJLEK_L1cauADScOd4ABmNyBH0cyNr5SlMepTAFU_NQ-- X-Apparently-From: X-YMail-OSG: kR6SXWUVM1khdvKdh_4C2hKoUURinqg60AK2t7R0l05FhO0 PuB1EPqqVpDTRZBIjy7TcaPohe0DhSEP1cD8aS.6x0jnUr9eGpxZCXyLj4h7 mO5cpQhM8T5AjMo4Q3qmaxj68pi8FkLNcFLmiWy.RQ.AJhlssUnmonyjyC7T Io0yUFaqVT192nTE5mUsdYynKRfDJMXsSZhd.OB3q.2UpFH2yZNbeRHPrunO p42TQLEh9mffGYaEqQmpvITArlVU7Iqwf.cN26UlURijTDquCJBw.7rZOevK CpIZxOx1v1d.pTxIj_4L0.otuFyD8GyU.no10D0RyyHJ1EHUuONwpgk9ViqC ljRe7XWHc4MOmqf.h22Beh1MJGdXa0ppyWY6sUnRPQjcCbp7ohCrexh8Zrva J9i81SBPYn4uTCgVya4u592dLwq586PbgbeyPje1sQ9AcuJac_BCbfhz5LuI LFJ5apXF4ZUhoDSpxEdLS6hIAQByXs1Lr.6Z2p5wyo26fFKlrU01NK12gadL sfzBrvZGI8RMdpWrEcVBFpop4NEp6mht3yXU8.8B1NP_Q3_F4iNLCf6RpPzQ _BGMItOj3IUqt4e834DK4JCFkxraC6GaC.AjH49liY.EDHIK8 From: Tokunori Ikegami To: Boris Brezillon Subject: [PATCH v5 03/11] mtd: cfi_cmdset_0002: Remove goto statement from do_write_buffer() Date: Tue, 5 Feb 2019 23:07:51 +0900 Message-Id: <20190205140759.2360-4-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> References: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190205_060900_771404_7E269533 X-CRM114-Status: GOOD ( 13.77 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [183.79.57.90 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ikegami_to[at]yahoo.co.jp) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joakim Tjernlund , linux-mtd@lists.infradead.org, Tokunori Ikegami , Chris Packham , Fabio Bettoni MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org For a maintainability by reducing the goto statement remove it from do_write_buffer(). Signed-off-by: Tokunori Ikegami Cc: Fabio Bettoni Co: Hauke Mehrtens Co: Koen Vandeputte Cc: Chris Packham Cc: Joakim Tjernlund Cc: linux-mtd@lists.infradead.org --- Changes since v4: - None. Changes since v3: - Just change the email address of Tokunori Ikegami to ikegami_to@yahoo.co.jp. Changes since v2: - None. Changes since v1: - Split the patch v1 3/3. drivers/mtd/chips/cfi_cmdset_0002.c | 46 +++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index ca9d5fa..1aacf22 100755 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1880,38 +1880,40 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, if (chip_good(map, adr, datum)) { xip_enable(map, chip, adr); - goto op_done; + break; } - if (time_after(jiffies, timeo)) + if (time_after(jiffies, timeo)) { + ret = -EIO; break; + } /* Latency issues. Drop the lock, wait a while and retry */ UDELAY(map, chip, adr, 1); } - /* - * Recovery from write-buffer programming failures requires - * the write-to-buffer-reset sequence. Since the last part - * of the sequence also works as a normal reset, we can run - * the same commands regardless of why we are here. - * See e.g. - * http://www.spansion.com/Support/Application%20Notes/MirrorBit_Write_Buffer_Prog_Page_Buffer_Read_AN.pdf - */ - cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, - cfi->device_type, NULL); - cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, - cfi->device_type, NULL); - cfi_send_gen_cmd(0xF0, cfi->addr_unlock1, chip->start, map, cfi, - cfi->device_type, NULL); - xip_enable(map, chip, adr); - /* FIXME - should have reset delay before continuing */ + if (ret) { + /* + * Recovery from write-buffer programming failures requires + * the write-to-buffer-reset sequence. Since the last part + * of the sequence also works as a normal reset, we can run + * the same commands regardless of why we are here. + * See e.g. + * http://www.spansion.com/Support/Application%20Notes/MirrorBit_Write_Buffer_Prog_Page_Buffer_Read_AN.pdf + */ + cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, + cfi->device_type, NULL); + cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, + cfi->device_type, NULL); + cfi_send_gen_cmd(0xF0, cfi->addr_unlock1, chip->start, map, cfi, + cfi->device_type, NULL); + xip_enable(map, chip, adr); + /* FIXME - should have reset delay before continuing */ - printk(KERN_WARNING "MTD %s(): software timeout, address:0x%.8lx.\n", - __func__, adr); + printk(KERN_WARNING "MTD %s(): software timeout, address:0x%.8lx.\n", + __func__, adr); + } - ret = -EIO; - op_done: chip->state = FL_READY; DISABLE_VPP(map); put_chip(map, chip, adr); From patchwork Tue Feb 5 14:07:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tokunori Ikegami X-Patchwork-Id: 1036769 X-Patchwork-Delegate: vigneshr@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=yahoo.co.jp Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mgnkn3fp"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="Yi4BCTHC"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43v5zk00q1z9s4V for ; Wed, 6 Feb 2019 01:09:21 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=epdGrCyYBTaJryVEOvdtlTjgKvrWh5FqhdFlxypt7Nw=; b=mgnkn3fpGUg+6BEqGFoFWKMuSZ /GxCEZo1W2+KuAEoSwk6vvHRu7bahjXvEmv2eEUvSLrUJpeBXbfCm39g2zEhmApaH3dmUlaaEd/Uw nerqbS71V0xpMsKzSM04xHVm+/tCk98yEqjkOyf83ubsRmBZxX4WxfPJLQituNsHWnAHuRWRY/aWm hv3KoZc1Tl+9ZVo+z6201Tl4nGo7epCCh+OA4sXXGEVceSs/MVwn2TnC8HV4LF6LcLnkvkiMVJwgt RAOUVEMpZLsfUvIFI3iUFu01VLf2zf3pWof0bS7VYqsVGHA0OfuKUoEc+ajdwu/OgCnQKinzlIF77 D7DiO+7w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1PX-0006xX-Li; Tue, 05 Feb 2019 14:09:15 +0000 Received: from nh504-vm8.bullet.mail.kks.yahoo.co.jp ([183.79.57.94]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1PH-0006lT-Hu for linux-mtd@lists.infradead.org; Tue, 05 Feb 2019 14:09:04 +0000 Received: from [183.79.100.140] by nh504.bullet.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:56 -0000 Received: from [183.79.100.132] by t503.bullet.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:56 -0000 Received: from [127.0.0.1] by omp501.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:56 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 272255.26081.bm@omp501.mail.kks.yahoo.co.jp Received: (qmail 45678 invoked by alias); 5 Feb 2019 14:08:56 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549375736; bh=OMzmzjRyhNSx4e1SMYN9bU+iKwCwFlw5Y93urL6nTbU=; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=Yi4BCTHCNMXwJ1MPICQ5mkan5FJlL5tnQtQR9F9EyvhlcgDQ1RoX9XjfRC08Ai8/sKogWuK9OCsbjAV8d27kowjXREbCVFYAylzomYpyUJSKTTvN9ZEbGAdGwAbPcDSyYADwH2hcSp5uPRbgA5Klx9CCTy/m8D5YL0VX2fWB48g= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=yj20110701; d=yahoo.co.jp; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=KS2KRSoFofsCnNjG7RGrOdd4f1NcC79IifDqpckVa1aKqsCLoSLTty874XiPIJEkbb9GqMmeAnnYQTKu5PU3iSOzhs11BCGSkNa7/+QJm+7EKOfmO/gvVcbF3lzjGvcykjY5febwQbGBvF6EmEroTCN6CoGCRpIZ9D9UWiOOk18= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp5006.mail.kks.ynwp.yahoo.co.jp with SMTP; 5 Feb 2019 14:08:56 -0000 X-YMail-JAS: l80whe8VM1l4m9r5qx5kCZeD5W0fSKcGfG.dhbJvYEoxx5M5TDjy4PTZzYuuQ36PQGa9pDAUgD.LPw3OBcFelInD37GOK_LPQHGGsIMLHCy2iFV5oyKqty4wbDLg3GtMcRmKSARMYw-- X-Apparently-From: X-YMail-OSG: XgolY8gVM1lg2EZc2fxSjCZ5pEufKyrRethWaY.iTm3_TkR 00QBKudsnM27dU_2r6dC4whdvFRNvGF5RjL5rMreAu3dMoN8j_m7mXnLfgcC a_YhvPJAKAUgFcnNmypDsKfhI_g2bjJImj0zh8kxBjDCmJbFAJAJ6_XYDFtm .5PkBy9dRssZuuOiKDCMnRxccIs__ExVbErOCc7VqKsn_Rf4je_Up.N8IaWm at1BlBdcw8ppjJsRzoOCH76O9OE0Th5Q9ICZhy8J2PvXY4GNqi5PSf.mWKn6 hynqtkne8PmaI9SwzqYAru8GPyHmmrAp2mMfQKSzVzuBO2255sE_.fH0DQEb rIUXV1lnYx2CD5ktV9Niimevkik6syaJCp7up3wXgXDrf_pJrdsdTd5vw.RX QXk08AAi2cnD2Tt1Cuq3DagRd9lJbtf3acv9B4CVG6iiPBO0oU9m2ve8CaUO OtJWrYw8VANExHHsVWFH.yOZSt7zqOp.G6aWA_SqSl09DUIXMKS4IDTIDyRC JFyfylcibZ9_7i2aWIZkbfjTtHbZezWMNayLyInZq2G0UEYmoduoUENaeXDn ME4VR7.SH8q6GJve_Ni5euDblKa6bZsn4fwVFAruIyam.KPvI From: Tokunori Ikegami To: Boris Brezillon Subject: [PATCH v5 04/11] mtd: cfi_cmdset_0002: Call xip_enable() once only in do_write_buffer(). Date: Tue, 5 Feb 2019 23:07:52 +0900 Message-Id: <20190205140759.2360-5-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> References: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190205_060859_954991_8F44A237 X-CRM114-Status: GOOD ( 11.36 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [183.79.57.94 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ikegami_to[at]yahoo.co.jp) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joakim Tjernlund , linux-mtd@lists.infradead.org, Tokunori Ikegami , Chris Packham , Fabio Bettoni MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org By the removed goto statement it can be called xip_enable() once. Also for a maintainability refactor it to call the function only once. Signed-off-by: Tokunori Ikegami Cc: Fabio Bettoni Co: Hauke Mehrtens Co: Koen Vandeputte Cc: Chris Packham Cc: Joakim Tjernlund Cc: linux-mtd@lists.infradead.org --- Changes since v4: - None. Changes since v3: - Just change the email address of Tokunori Ikegami to ikegami_to@yahoo.co.jp. Changes since v2: - None. Changes since v1: - Split from the patch v1 3/3. drivers/mtd/chips/cfi_cmdset_0002.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index 1aacf22..92d3e82 100755 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1878,10 +1878,8 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, continue; } - if (chip_good(map, adr, datum)) { - xip_enable(map, chip, adr); + if (chip_good(map, adr, datum)) break; - } if (time_after(jiffies, timeo)) { ret = -EIO; @@ -1907,13 +1905,14 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, cfi->device_type, NULL); cfi_send_gen_cmd(0xF0, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); - xip_enable(map, chip, adr); /* FIXME - should have reset delay before continuing */ printk(KERN_WARNING "MTD %s(): software timeout, address:0x%.8lx.\n", __func__, adr); } + xip_enable(map, chip, adr); + chip->state = FL_READY; DISABLE_VPP(map); put_chip(map, chip, adr); From patchwork Tue Feb 5 14:07:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tokunori Ikegami X-Patchwork-Id: 1036770 X-Patchwork-Delegate: vigneshr@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=yahoo.co.jp Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="DsLJ+bOJ"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="IdNpvFhH"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43v6012RJTz9s4V for ; Wed, 6 Feb 2019 01:09:37 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=qio+lBKBI0UBo0xvoPnQfPLCOm0QUXO0ZifmyjEuHuw=; b=DsLJ+bOJ+y75eeT2xuioV2OUVV CowHAxfJ7Xc5xhNZAYEWnSuZzk635/xsItA/TPbo9DwgkG1p3DkiVZioiN51zLUuXp3ZItARIOK1n GfMQhFGwE9viZOxTk3wB/G+18Q6IfUkEBRezRJPJ/+ah4dYRR9j9kkam5S0Rb37EwcPX1sgoONtcz zlCBxE/UVlg6+v/MqZmseAX5bta2dkZPKxFHNx5a+xJSegYu3+wv9qA/60MnwDo9yuP4mvRMWKuXW q7bORz+WvGwp/ScmyKRyvT4nq4gz4u22gwC8QAprP3hGg28DEah+cU4d3h/Xsfv/l/DsVHhZ/6Eaw gakRKyTg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1Pn-0007D2-8Y; Tue, 05 Feb 2019 14:09:31 +0000 Received: from nh503-vm4.bullet.mail.kks.yahoo.co.jp ([183.79.56.190]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1PI-0006lV-Ix for linux-mtd@lists.infradead.org; Tue, 05 Feb 2019 14:09:04 +0000 Received: from [183.79.100.140] by nh503.bullet.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:57 -0000 Received: from [183.79.101.120] by t503.bullet.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:57 -0000 Received: from [127.0.0.1] by omp507.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:57 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 408139.19935.bm@omp507.mail.kks.yahoo.co.jp Received: (qmail 45703 invoked by alias); 5 Feb 2019 14:08:57 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549375737; bh=HjpJs3bdlyLLTPHWvab8XDGrkndoAnTeJGTuXQEwJLg=; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=IdNpvFhHaLu4HhdBtk6GW+Q3s8E7z5RFNJ015UhNTmbmtHiHyL6AwLWjYzGOaammzz8i+FcC5ti1ip+p4cdoJdTaSJKZNu3a+z48kJN61Ly9ezxU6qyT2Kje3Aqae7v2MnkwI6nGsF2ckiVZ+UoF8KSKp6JpRoRs5QMP5VSpcL8= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=yj20110701; d=yahoo.co.jp; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=J/yS1J8FAXIhVqUTwtToGhqXOSfegOebCP3Wd+vo8yMVnvjJtwlJeyLc1t/Npwj3OY0rwzytV2dg5Zg5G+6ABpL9SoxliLJOReJXAeybw0yGrxl4Ff3fn/98Kf8fCGMBCBip3l8Lsr1C+7wQqfwnPvPY8q83RKM1qSMVImPQSIU= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp5006.mail.kks.ynwp.yahoo.co.jp with SMTP; 5 Feb 2019 14:08:56 -0000 X-YMail-JAS: l80whe8VM1l4m9r5qx5kCZeD5W0fSKcGfG.dhbJvYEoxx5M5TDjy4PTZzYuuQ36PQGa9pDAUgD.LPw3OBcFelInD37GOK_LPQHGGsIMLHCy2iFV5oyKqty4wbDLg3GtMcRmKSARMYw-- X-Apparently-From: X-YMail-OSG: ZUd8DUUVM1l7JkrgkxsnQMeNMRbG3o7Hamm66vboRqkdQgH 4l6yx1DeiXQBGeAKL6PfAIiR2DxKcCTt_UWnkGkQchZSWGDKiikIVk4YbUmy DZFuyHH_JBtZocKYAJ2Y5PfIVi8yHUDvgDgK8lW_sMcaAAsnvFPVN4AY5fMY NMgd.p9ePyV7Rc7jm.JjMv0P.AEDPvJD8ENxMhM2aHDpe6uiQuhfN.yqYr0Q By9__aTMH26QN_3Tm28nDAs2tsOeJ2JBCyFqeB4Ppp7KOV15e9jdrW_EVex0 IKPlfS7EeXFujBdBxlMcu0kWWxoqZSgpTK431GYvLQD1S04W0kIP008jlc.h UsH6CX65umFc54tsKvLYsfsTtJwsXq5YQBSWGbBoVknVIAmJROfFSZ2l5Gcx wvrSA.XAqmnbPcpmyFB5oOZ3BrE3Bt1qg9IxyRy7fuSN1BPU_xxfv9cPNKWZ h9ble1MJKk8KzQiDkxDNeonwcVOYnjm6Hazg8Jw5eIl9tmIClGrFeH61OELU i_Yxepdnh.IZxty8cck913HVt3zMMRPkRBQJ2SBDc2I7jQ_T6R0.LqhKaAxU dak6AO0zbAJiVOcCw1RcOemkrnizmBaY6ULe1fywZ5psDI.4- From: Tokunori Ikegami To: Boris Brezillon Subject: [PATCH v5 05/11] mtd: cfi_cmdset_0002: Split do_write_oneword() to reduce function size Date: Tue, 5 Feb 2019 23:07:53 +0900 Message-Id: <20190205140759.2360-6-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> References: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190205_060900_950027_19097E5C X-CRM114-Status: GOOD ( 16.21 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [183.79.56.190 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ikegami_to[at]yahoo.co.jp) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joakim Tjernlund , Tokunori Ikegami , linux-mtd@lists.infradead.org, Fabio Bettoni MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Reduce the size of do_write_oneword() by extracting a helper function for the hardware access. Signed-off-by: Tokunori Ikegami Reviewed-by: Chris Packham Cc: Fabio Bettoni Co: Hauke Mehrtens Co: Koen Vandeputte Cc: Joakim Tjernlund Cc: linux-mtd@lists.infradead.org --- Changes since v4: - None. Changes since v3: - Drop the unnecessary comment and blank line. - Change the email address of Tokunori Ikegami to ikegami_to@yahoo.co.jp. Changes since v2: - Just update the commit message for the comment - Add Reviewed-by tag. Changes since v1: - Add the patch. drivers/mtd/chips/cfi_cmdset_0002.c | 89 ++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index 92d3e82..6393af4 100755 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1547,11 +1547,10 @@ static int cfi_amdstd_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, do_otp_lock, 1); } -static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, - unsigned long adr, map_word datum, - int mode) +static int __xipram do_write_oneword_once(struct map_info *map, struct flchip *chip, + unsigned long adr, map_word datum, + int mode, struct cfi_private *cfi) { - struct cfi_private *cfi = map->fldrv_priv; unsigned long timeo = jiffies + HZ; /* * We use a 1ms + 1 jiffies generic timeout for writes (most devices @@ -1564,42 +1563,7 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, */ unsigned long uWriteTimeout = (HZ / 1000) + 1; int ret = 0; - map_word oldd; - int retry_cnt = 0; - - adr += chip->start; - - mutex_lock(&chip->mutex); - ret = get_chip(map, chip, adr, mode); - if (ret) { - mutex_unlock(&chip->mutex); - return ret; - } - pr_debug("MTD %s(): WRITE 0x%.8lx(0x%.8lx)\n", - __func__, adr, datum.x[0]); - - if (mode == FL_OTP_WRITE) - otp_enter(map, chip, adr, map_bankwidth(map)); - - /* - * Check for a NOP for the case when the datum to write is already - * present - it saves time and works around buggy chips that corrupt - * data at other locations when 0xff is written to a location that - * already contains 0xff. - */ - oldd = map_read(map, adr); - if (map_word_equal(map, oldd, datum)) { - pr_debug("MTD %s(): NOP\n", - __func__); - goto op_done; - } - - XIP_INVAL_CACHED_RANGE(map, adr, map_bankwidth(map)); - ENABLE_VPP(map); - xip_disable(map, chip, adr); - - retry: cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL); cfi_send_gen_cmd(0xA0, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); @@ -1642,7 +1606,52 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, UDELAY(map, chip, adr, 1); } - /* Did we succeed? */ + return ret; +} + +static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, + unsigned long adr, map_word datum, + int mode) +{ + struct cfi_private *cfi = map->fldrv_priv; + int ret = 0; + map_word oldd; + int retry_cnt = 0; + + adr += chip->start; + + mutex_lock(&chip->mutex); + ret = get_chip(map, chip, adr, mode); + if (ret) { + mutex_unlock(&chip->mutex); + return ret; + } + + pr_debug("MTD %s(): WRITE 0x%.8lx(0x%.8lx)\n", + __func__, adr, datum.x[0]); + + if (mode == FL_OTP_WRITE) + otp_enter(map, chip, adr, map_bankwidth(map)); + + /* + * Check for a NOP for the case when the datum to write is already + * present - it saves time and works around buggy chips that corrupt + * data at other locations when 0xff is written to a location that + * already contains 0xff. + */ + oldd = map_read(map, adr); + if (map_word_equal(map, oldd, datum)) { + pr_debug("MTD %s(): NOP\n", + __func__); + goto op_done; + } + + XIP_INVAL_CACHED_RANGE(map, adr, map_bankwidth(map)); + ENABLE_VPP(map); + xip_disable(map, chip, adr); + + retry: + ret = do_write_oneword_once(map, chip, adr, datum, mode, cfi); if (ret) { /* reset on all failures. */ map_write(map, CMD(0xF0), chip->start); From patchwork Tue Feb 5 14:07:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tokunori Ikegami X-Patchwork-Id: 1036772 X-Patchwork-Delegate: vigneshr@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=yahoo.co.jp Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="YIvoaIJC"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="DVelCMQr"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43v60b4djlz9s4V for ; Wed, 6 Feb 2019 01:10:07 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=trsNLUuAoMDq+yasTGe6TsiZbuUfnlahUL+pzrqdPK8=; b=YIvoaIJCF5QidveSb/dVO0I4wa As6ic6V9Judv7AMpvIOUjhYx4xyimogmt3CIMpU5i8IEz6bcXb1qNS4+lNS/RmW8XyJVVhWHWeP7Y Rfc5A8xftQrfbn1Ro0vJbVJ8cQr/ARLRgTS0LER04Oaf269XW/hUF9l+lwzE+etl5PCKH1iVC5KQq y/t5kiDFbgAytlaGRT5NYxhbnL5gn8xdNWw5c5xh7QTFNaO2bzt4E07ZD9t6so6HlfkbAveIp1grw BR5+1yJsOnpx07T2HSuacOEfeFjrQ4Q8eU/bVsoSHSoxoDN8CzHBUqLnBnO+cOfsUBWMbqnb8eL5y 5QS9pSNQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1QG-0007cs-6p; Tue, 05 Feb 2019 14:10:00 +0000 Received: from nh502-vm6.bullet.mail.kks.yahoo.co.jp ([183.79.56.151]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1PI-0006lU-HL for linux-mtd@lists.infradead.org; Tue, 05 Feb 2019 14:09:04 +0000 Received: from [183.79.100.138] by nh502.bullet.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:57 -0000 Received: from [183.79.100.134] by t501.bullet.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:57 -0000 Received: from [127.0.0.1] by omp503.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:57 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 930266.66757.bm@omp503.mail.kks.yahoo.co.jp Received: (qmail 45781 invoked by alias); 5 Feb 2019 14:08:57 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549375737; bh=p3qpCJkf9xce3tgqcI5sGAyVPPQd/vJ/y16L+YYxk7I=; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=DVelCMQrUl5OGQgKqHxY2XVUiDhg6Q1Vcc7EuY4sftNSLRm+bm6nNivHbOl3ud+MqH1E86fKpgpiB7kf2ANqkm+pMtKnpQ52TAZaXcIfg5p3knuQdfwkljoCbWP1jSv7Cp6z+hbbL6LQO20jQAHtmpuI8LXsriBUzrUHtNjmrNI= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=yj20110701; d=yahoo.co.jp; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=fAbFtDJMH7zr3bzzsgScja7BCqeMP3N7Y8rWxSv3TCOTU9LFQXdjgKBeAPczk1TbpRTcWdQg88CWEZab6UVZHBogmStr4OPEpcWM29vSOHaDhU1LqwRa3Bb8vV6JgCr5CVpux2gdMjZtvHv22W7IZD8n22j6L5PpuSW66sAW/Ac= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp5006.mail.kks.ynwp.yahoo.co.jp with SMTP; 5 Feb 2019 14:08:57 -0000 X-YMail-JAS: tZ4JM4YVM1nZiBx8z6gCxo3qFCIrZFTVmn6207qwOD01Vez2CUMWmmTtwhIat_WWXj3VTqVxNgrMmxKzvdxkX9rPX.HdgRlbWwhtUZlavDabAs3oCfhSvDw3fBjz4qfXMzfbtVUV4g-- X-Apparently-From: X-YMail-OSG: 6By.53cVM1lNPmRIKKpkbSQ1t8Zqh.evcZKd2K7gKlrVWaP 8mtaxhx1Lw6fVAAEHWtLSZ7wJVLPs.fZS5KHBlPM0v.PbJzjWBqL2E8rz2_V 5RWktdMrn7f8j2CVkMay63AIhPTEeP3AXmZWBoiY9JS1y1ST2tQK5ApVjCBp 3VsieYwy_Zb_Xk3wvfVl6FIWTXlRVtuLK6U45CXQCHuHyBQK61BiPgYHrPGs Bgozk5yp.W4iNHrtQn3AY9mlKeaTE42UFPqAEdnsuz_d0Ub50ul.VjDzC1DF 4HCfhrl163kYW8MyhiCaXOGwBW4N_30Nv31hJOptdzeDE.L3VeL82CbLZ7jN e0s3e1RB4NI1IdEbHY0_d_Gv2hvPXJ50e9pUiZmfrUVjCOi7F2D88c_ssswU 3EPBH9WGll4K5zCbnF9p3jhYa2_7Kn61lTZTtNNaWQMlh9WxPYvxruFZ_gkv .ZU3GuGa9nE5TcwBxQ.zJRVfq8WVzgQDGwFx3FNkySikp0v2Xn7VnLHpAkGs yKyg9p.lnGnCy7PSzKvysLByF5ji7f_CjzKffycCKOHzB0L9uzYE3jnGBOQv GPJGVpr06Uj6HNq9lZ9IFAYLANWCMQJ5I3K8FNq_ZDM9emMTD From: Tokunori Ikegami To: Boris Brezillon Subject: [PATCH v5 06/11] mtd: cfi_cmdset_0002: Split do_write_oneword() op_done goto statement Date: Tue, 5 Feb 2019 23:07:54 +0900 Message-Id: <20190205140759.2360-7-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> References: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190205_060900_802070_A620BACD X-CRM114-Status: GOOD ( 14.61 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [183.79.56.151 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ikegami_to[at]yahoo.co.jp) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joakim Tjernlund , linux-mtd@lists.infradead.org, Tokunori Ikegami , Chris Packham , Fabio Bettoni MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org To reduce function size and remove the goto statement split the op_done goto statement part into do_write_oneword_done() created a function. Also split the start part into do_write_oneword_start() to find easier pairs. Signed-off-by: Tokunori Ikegami Cc: Fabio Bettoni Co: Hauke Mehrtens Co: Koen Vandeputte Cc: Chris Packham Cc: Joakim Tjernlund Cc: linux-mtd@lists.infradead.org --- Changes since v4: - None. Changes since v3: - Rebased on the patch v4 01/11. - Change the email address of Tokunori Ikegami to ikegami_to@yahoo.co.jp. Changes since v2: - Change to split the start part of do_write_oneword() additionally. - Fix indentation to call pr_debug(). Changes since v1: - Add the patch. drivers/mtd/chips/cfi_cmdset_0002.c | 57 ++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index 6393af4..a11dc40 100755 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1609,6 +1609,40 @@ static int __xipram do_write_oneword_once(struct map_info *map, struct flchip *c return ret; } +static int __xipram do_write_oneword_start(struct map_info *map, + struct flchip *chip, + unsigned long adr, int mode) +{ + int ret = 0; + + mutex_lock(&chip->mutex); + + ret = get_chip(map, chip, adr, mode); + if (ret) { + mutex_unlock(&chip->mutex); + return ret; + } + + if (mode == FL_OTP_WRITE) + otp_enter(map, chip, adr, map_bankwidth(map)); + + return ret; +} + +static void __xipram do_write_oneword_done(struct map_info *map, + struct flchip *chip, + unsigned long adr, int mode) +{ + if (mode == FL_OTP_WRITE) + otp_exit(map, chip, adr, map_bankwidth(map)); + + chip->state = FL_READY; + DISABLE_VPP(map); + put_chip(map, chip, adr); + + mutex_unlock(&chip->mutex); +} + static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, unsigned long adr, map_word datum, int mode) @@ -1620,19 +1654,14 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, adr += chip->start; - mutex_lock(&chip->mutex); - ret = get_chip(map, chip, adr, mode); + pr_debug("MTD %s(): WRITE 0x%.8lx(0x%.8lx)\n", __func__, adr, + datum.x[0]); + + ret = do_write_oneword_start(map, chip, adr, mode); if (ret) { - mutex_unlock(&chip->mutex); return ret; } - pr_debug("MTD %s(): WRITE 0x%.8lx(0x%.8lx)\n", - __func__, adr, datum.x[0]); - - if (mode == FL_OTP_WRITE) - otp_enter(map, chip, adr, map_bankwidth(map)); - /* * Check for a NOP for the case when the datum to write is already * present - it saves time and works around buggy chips that corrupt @@ -1641,8 +1670,7 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, */ oldd = map_read(map, adr); if (map_word_equal(map, oldd, datum)) { - pr_debug("MTD %s(): NOP\n", - __func__); + pr_debug("MTD %s(): NOP\n", __func__); goto op_done; } @@ -1664,12 +1692,7 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, } xip_enable(map, chip, adr); op_done: - if (mode == FL_OTP_WRITE) - otp_exit(map, chip, adr, map_bankwidth(map)); - chip->state = FL_READY; - DISABLE_VPP(map); - put_chip(map, chip, adr); - mutex_unlock(&chip->mutex); + do_write_oneword_done(map, chip, adr, mode); return ret; } From patchwork Tue Feb 5 14:07:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tokunori Ikegami X-Patchwork-Id: 1036774 X-Patchwork-Delegate: vigneshr@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=yahoo.co.jp Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gbMr7ECt"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="DYpCPPKh"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43v60z47tRz9s4V for ; Wed, 6 Feb 2019 01:10:27 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=KD1WXFhfL+qDXNIRlM+1al/2RbLljIH9E549IGX9np4=; b=gbMr7ECtMI/qaiCGnO6h5EP4f4 4Fb1IU+vL2f5VwmyN7o7kin6hFDEozZ2v0sQnjw/hiMfvxroMZmqX+vqIPC9l/WwBGCpvA+OzIIY2 Tz5RBzRsUe40OwnQGstZQMOHpztULeElTuLyNeGruXoBrpPAH6L0Xfz78KwQmWjRM1RF55rRw40ZB I8Zm1tCAJ3k6ef9UI8agF5cqkFuwsDXCWK+Vn4ykH05pWhqlxpPt8O2r5qhCOFQd7stx+/oVcKdZ8 TsJmlKGz8gHR+NuLt107ikkp5QqUYxGZ6ZPWG26UPYJ9azjVR4lkU4LIla4jljpT0kOmGYZi7JUFL qdlHAPlg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1Qb-0000Of-Ll; Tue, 05 Feb 2019 14:10:21 +0000 Received: from nh503-vm5.bullet.mail.kks.yahoo.co.jp ([183.79.56.191]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1PK-0006lr-3F for linux-mtd@lists.infradead.org; Tue, 05 Feb 2019 14:09:07 +0000 Received: from [183.79.100.139] by nh503.bullet.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:59 -0000 Received: from [183.79.100.137] by t502.bullet.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:59 -0000 Received: from [127.0.0.1] by omp506.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:59 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 105648.46795.bm@omp506.mail.kks.yahoo.co.jp Received: (qmail 45797 invoked by alias); 5 Feb 2019 14:08:58 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549375738; bh=y0dblB+tqhR7P8h6hfIUrboO/khcJkBtBD9SV5tOC1E=; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=DYpCPPKhBa9iO+9DH0zMQUZrWvbvB12ySk6rCLd3ah7t8sOy7oE0K6tvT6WAsq90GwVah31wA4dB9ZZK/ChZmuksfyZgZjC3tEhJHZRXodgb216qgxsly4nLQIcmvJpL5z/0HpOiAuZkSd6GncTp6PfUQeCYuG2fw4fPiEsmj0c= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=yj20110701; d=yahoo.co.jp; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=qXsqUEHm455rbO/Oho8P1sd2kPHP/ZBmu/0wlZiRpf6jzD4DCfZ1nHqmkAjiCp+FaNXh2f8uJmYIAAvgTRGaqLHNssUUMGLAbw1AhXQIZrtcZuDwwjjTTNf9t3wiv0ieSCjVul1WfmkaBMYMZSrilwLJNf6LL0WKXmHF7sLee9I= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp5006.mail.kks.ynwp.yahoo.co.jp with SMTP; 5 Feb 2019 14:08:58 -0000 X-YMail-JAS: qiw0TaEVM1m81lkxkGuki4bmOxkGWF2h2zk00XjzaU.9YJAP2xSAYSqwpd0Qzhqr2BcNzeAa_q6PN1G0FLiN0M8V9UwMLA2wi9uWMhJkzRapUI1oEn_gk008qhsaGynGp603HerqPA-- X-Apparently-From: X-YMail-OSG: WIBXlB8VM1mN50QeZzJjBMf.7WQSOQHrXm5Ke3ITCdkatrF kTG5o17wPpj.fuxlw4djobpGOhsypnq7G0PqLVQyfmkTVudxqE3A8gyaCKJp DN2aZS7N.j.AZ_60xNw2YrOtOPVXnMJwKJe6jnYISfdz1ygAXo1VmOFUD1LN rUQUupyd5EKHzvp2zF0QtA6srEGWJPVmQ9pt1bbTSC0wJmhJXXg_klwbaKCO y7HtYaEG4S7rqqdCNAhx5fm4gq2w_ZHRme_IdmLHZNhv95ZjpOoPNBCkfqvq b_EpgkcV6b9lVnUZd68UcdoJr53uLzmDt7EOly7rTQ33v0wGYsvLGll44F._ B.ZSrDskb79b2IcWuXeRXVNnK4Rq8F92LQeqf_UwoBeUXUiJN41VzB50F5OG 9gWT5lTMjfXDPbBuvXtaDGUvb.J4be6vLe1XvmjF.qY2J0ss1TJReyAoSrMh YQ.PQkaTpq6UKfv09RefhfhnBntqUyiNnvW2rNSvPpqoQdtUSQwiPI_jNyfC sy.gIepLJiPqM6A6C7Nzxm7U3vD.DcFiPr8U3BuzadNq4S4heTmfzxKbZwfq SlYClO9Kyr3xlO7Y7_hGjR7.1_vsEi.i7AbVLAdAEax8gATSW From: Tokunori Ikegami To: Boris Brezillon Subject: [PATCH v5 07/11] mtd: cfi_cmdset_0002: Remove op_done goto statement from do_write_oneword() Date: Tue, 5 Feb 2019 23:07:55 +0900 Message-Id: <20190205140759.2360-8-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> References: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190205_060902_625222_69F1FCC5 X-CRM114-Status: GOOD ( 11.21 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [183.79.56.191 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ikegami_to[at]yahoo.co.jp) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joakim Tjernlund , linux-mtd@lists.infradead.org, Tokunori Ikegami , Chris Packham , Fabio Bettoni MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This is just to refactor the function by removing the goto statement. Signed-off-by: Tokunori Ikegami Cc: Fabio Bettoni Co: Hauke Mehrtens Co: Koen Vandeputte Cc: Chris Packham Cc: Joakim Tjernlund Cc: linux-mtd@lists.infradead.org --- Changes since v4: - None. Changes since v3: - Rebased on the patch v4 01/11. - Change the email address of Tokunori Ikegami to ikegami_to@yahoo.co.jp. Changes since v2: - Just rebased. Changes since v1: - Add the patch. drivers/mtd/chips/cfi_cmdset_0002.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index a11dc40..a5513bd 100755 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1671,7 +1671,8 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, oldd = map_read(map, adr); if (map_word_equal(map, oldd, datum)) { pr_debug("MTD %s(): NOP\n", __func__); - goto op_done; + do_write_oneword_done(map, chip, adr, mode); + return ret; } XIP_INVAL_CACHED_RANGE(map, adr, map_bankwidth(map)); @@ -1691,7 +1692,7 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, } } xip_enable(map, chip, adr); - op_done: + do_write_oneword_done(map, chip, adr, mode); return ret; From patchwork Tue Feb 5 14:07:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tokunori Ikegami X-Patchwork-Id: 1036777 X-Patchwork-Delegate: vigneshr@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=yahoo.co.jp Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="YWuF4kC7"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="pKZXAn87"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43v61x1Nnrz9s4V for ; Wed, 6 Feb 2019 01:11:17 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Xd/Od9cEPn5yOGOnyivAfSgJfk2uNVZ9IrjGBWSMhLg=; b=YWuF4kC7kDDUpCA9zdkXoKnStw NRrfbwGVK0nBbPvab35Hr+fLFM53KuUbKZCS8C4p5yTH0ws7su4w3zeODqrZuOeuUkh3NNUaUDBWx ADZxPL7MU67ujl0OAMHBlf0b2tUyhMqTBThyeBjjcZ9JuDIPumdfEtZaZGd75/gsku1iAiXgwpyM3 D0ss5LSd6LLGZWHWTKszCXVFxmmE/+GDtTXtyVlN9rJczwpMmSvNSQL3+ZKywsQwT8FTe0ZoMrN7B qr1MxFs6EOdnMAK7XoSrPHoCsc8fYsPUJ2MB3AwytFV8TuK7lCS9WXyMCpbd3oFQOZAbXwoiYdZuc 5ZZE8k9Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1RL-0001X3-4r; Tue, 05 Feb 2019 14:11:07 +0000 Received: from nh605-vm0.bullet.mail.ssk.yahoo.co.jp ([182.22.90.73]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1PK-0006ly-3u for linux-mtd@lists.infradead.org; Tue, 05 Feb 2019 14:09:12 +0000 Received: from [182.22.66.106] by nh605.bullet.mail.ssk.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:59 -0000 Received: from [182.22.91.133] by t604.bullet.mail.ssk.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:59 -0000 Received: from [127.0.0.1] by omp606.mail.ssk.yahoo.co.jp with NNFMP; 05 Feb 2019 14:08:59 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 604745.86071.bm@omp606.mail.ssk.yahoo.co.jp Received: (qmail 45839 invoked by alias); 5 Feb 2019 14:08:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549375739; bh=hyJLy706ToPV3Zd7RIHvxdxFx6jR8N9N3oSoU8fY+ow=; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=pKZXAn877UK8whZYj7bywa97dunLGxWFOgaLQcAZftQAmZoaIpHiIUsspBibkbqKYVKxGdd4NqhANhpBwrcJ5MK3QkREBX1Zv/5mF6JbmOHvd337tAeY/+euusISZbO8X3JuxrB85SaFD3jiITAzGhylACtJxyXAkiA0BrrZr6Q= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=yj20110701; d=yahoo.co.jp; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=JkkeQU7iApG4Jxo3HpwDVvUNipL/SmDpE+JPTNLVLSXvcPiLZBYjlyVlIGo9rqnUEPLiN8LQnxJNZzvTFDZyU+v6mnlQe+h0V9/iJd5l3YapbnTpZ3dIdRPONyJ8vyY8NXDlIV9bJfYSBNtJwj0kK7Cc39YL8NABK5QN7+bqdsU= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp5006.mail.kks.ynwp.yahoo.co.jp with SMTP; 5 Feb 2019 14:08:59 -0000 X-YMail-JAS: MeyelX0VM1mSxBoju.h4HOdwCh_ECAwEeS5p1NJ56vNPtrfToW95ROoI9Km2LzuxYTogesiVIpxLNLbqhx2R6W3zfH0isbI4tOBZ8vGn2YjEClxglFHRATfXER4j2_yE.nnPumiSGg-- X-Apparently-From: X-YMail-OSG: k4zqR8gVM1mTwV_Oyt1C.de5FDFT_GDdzU_5Sq1pUTh36I4 mbBHRS27mSS5nCEl.tg98ngoLVoE3D8FStm0apv5Q3q_yO9K42PTtmyeFU5h bIjJhcasfy4Mu0XvUQAKHPmW_E4arZ4d9NhvoRsUoI.By64nQODmCo8Mw68Y FrBwBXPDNWmvtJ8BkmuVvzK_zdbZXcAJiEDw_jRg7BOAUN1D4SB7N6DrLuHL jSuMHo0Cd2anVNOQzI40KkJ1tdGjrJ4S7W6NWmbVlIVX3Fmtr1qcC.y.Bax7 sKsOlvGsuI8RM0dxXA4_589toobSGtV_FwZJhuRvO16VFqchDkPLQqAOh11U hLllTt6h5wHpX258D.Naqvs.f80NS8SUkbpEw25t7Tebc0N30e.XuC9izwCk CLoyJHBRdRtqgPXC.G64JITHLvsVoWHszAVXRBRAQK2p6c7ckNMQ2C0UkFh7 N71DqTaMNlJEPIVFQ1x_qGWo9S1PNlZTZMpxs4OrwUq8fkAjlxztodU9tGyt 85KQHr7PUULvpeiN.jtPMDM65e7IIu_0WXElG6P4MyKG6crHtgQNnOxASJbq LuGdNU6T3YVmZo2QtmKNHhU0Y.q_SGACF4tLgb6ebrLG1m3pj From: Tokunori Ikegami To: Boris Brezillon Subject: [PATCH v5 08/11] mtd: cfi_cmdset_0002: Remove retry goto statement from do_write_oneword() Date: Tue, 5 Feb 2019 23:07:56 +0900 Message-Id: <20190205140759.2360-9-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> References: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190205_060902_653991_741463DD X-CRM114-Status: GOOD ( 11.76 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [182.22.90.73 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ikegami_to[at]yahoo.co.jp) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joakim Tjernlund , linux-mtd@lists.infradead.org, Tokunori Ikegami , Chris Packham , Fabio Bettoni MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This is just to refactor the function by removing the goto statement. Change to use the for loop instead of the goto statement. Signed-off-by: Tokunori Ikegami Cc: Fabio Bettoni Co: Hauke Mehrtens Co: Koen Vandeputte Cc: Chris Packham Cc: Joakim Tjernlund Cc: linux-mtd@lists.infradead.org --- Changes since v4: - None. Changes since v3: - Rebased. - Change the email address of Tokunori Ikegami to ikegami_to@yahoo.co.jp. Changes since v2: - None. Changes since v1: - Add the patch. drivers/mtd/chips/cfi_cmdset_0002.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index a5513bd..81f5e5e 100755 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1679,17 +1679,15 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, ENABLE_VPP(map); xip_disable(map, chip, adr); - retry: - ret = do_write_oneword_once(map, chip, adr, datum, mode, cfi); - if (ret) { + for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) { + ret = do_write_oneword_once(map, chip, adr, datum, mode, cfi); + if (!ret) + break; + /* reset on all failures. */ map_write(map, CMD(0xF0), chip->start); - /* FIXME - should have reset delay before continuing */ - if (++retry_cnt <= MAX_RETRIES) { - ret = 0; - goto retry; - } + /* FIXME - should have reset delay before continuing */ } xip_enable(map, chip, adr); From patchwork Tue Feb 5 14:07:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tokunori Ikegami X-Patchwork-Id: 1036794 X-Patchwork-Delegate: vigneshr@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=yahoo.co.jp Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gmMRfHIT"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="MfLELlEj"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43v6GZ2gHGz9sML for ; Wed, 6 Feb 2019 01:22:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=pHORpggGU5xWGuuQKdPoVVHi4S+yWn/JyIh4u75Jy3I=; b=gmMRfHIT5Djwf4pBvBT8kIcdPW Fqe8McG/yavQQNQAqunaKEzMiQl1fAX6r4mY2UorYJ1knXIw0q6CRkHqNUBsHHKKRrpB9jStCaP4T HphmDPi7qn48jTENiPM5lHGKGC3BhLWckF1our1jH1mC+eTOKVFAmT2AgeV+y+t7cHZCdDKv9pqOt ujL6LMnK5oxurwrRdRm6v4itubbpVy2ahTWEqyiX3p+kxw0bc6GTjEQ3FlbKciiyD/r8zAwHf1R3R 93FUMa7XYSib8LhKIImmXoFJHkeTE5DxnwtfSDvD8ohvpHaMUeg2Syg9OkKWHiw/qc70y7NoeAWyI 2SDaYkJw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1bt-0006S3-NP; Tue, 05 Feb 2019 14:22:01 +0000 Received: from nh604-vm7.bullet.mail.ssk.yahoo.co.jp ([182.22.90.64]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1PK-0006me-7G for linux-mtd@lists.infradead.org; Tue, 05 Feb 2019 14:09:11 +0000 Received: from [182.22.66.103] by nh604.bullet.mail.ssk.yahoo.co.jp with NNFMP; 05 Feb 2019 14:09:00 -0000 Received: from [182.22.91.131] by t601.bullet.mail.ssk.yahoo.co.jp with NNFMP; 05 Feb 2019 14:09:00 -0000 Received: from [127.0.0.1] by omp604.mail.ssk.yahoo.co.jp with NNFMP; 05 Feb 2019 14:09:00 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 140948.93113.bm@omp604.mail.ssk.yahoo.co.jp Received: (qmail 45871 invoked by alias); 5 Feb 2019 14:08:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549375739; bh=zCEgMVlaGSDqMwIPyN9VYHHNZmjYbGspI+1FBumbMLo=; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=MfLELlEj0qw6YQFKOabGHwDwXbMg8yB5dnylyaN7eTP7/fd4yqa/joqVoMCs7DRQSmOZX15/Ji0ZCEpGbF7iSOFTJNITxSyLzt9k7NZdnBSLk9IQro9IEhpCsjmnoUcMsoY19xwW32i63vWnTtd1WW2H0535OuTtlmv/X9cbPxw= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=yj20110701; d=yahoo.co.jp; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=Y8BFJJsLKClIfBv5C2OXfBfLmCcf3ms1nSSMSzoQxIqWdkfLBYAPxOffPLfffS0mY9uCKEo+klcetOvuhuyX9BaHExtFoBHND9B+QsgmAdQ0uP5MJwNf//5zw3Top039xkuvajGZFnPk81D2XZnIYDIeB4WB6z9BRF90iZEq1+o= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp5006.mail.kks.ynwp.yahoo.co.jp with SMTP; 5 Feb 2019 14:08:59 -0000 X-YMail-JAS: MeyelX0VM1mSxBoju.h4HOdwCh_ECAwEeS5p1NJ56vNPtrfToW95ROoI9Km2LzuxYTogesiVIpxLNLbqhx2R6W3zfH0isbI4tOBZ8vGn2YjEClxglFHRATfXER4j2_yE.nnPumiSGg-- X-Apparently-From: X-YMail-OSG: 48rnaDUVM1n0tpoBGwfvEe4KTzYOzLZGP4qFXxwFEgoOnfr X6ZiyOzzwYN2ozff6RFvA5cfFgxBADiToWAQJjyNzB9A1IGcbe2F_sJuwIm6 Ujiaf80LCjwuA2TWu2qKuWoRtKsYoRgNPdphHP_Qq40kx1v.grRh0cFY4NgJ Nui9pARagFQ_6MNmSjsFvSVd0MC3HMYhN01mm67Q5bzT2tWQEf29tZUYgT5y _aDisMA1kXj.Kv.KvwSOvQqVY_I6skxbPTDG2IObSN7kkJMej8t9JzjqSu0t RU_LUfCktIZgoIikvBMiryIsHa4EYHUQslrOidsaBfb_v_525bgwhVeCh4o2 XogdsK0VJZW522mr6qrTz8Eu80sI93rziXxrRvQPbHEQYY0bNbQKusDT15LY _6.PR_OkvjUijseSzbIDIoPBZaI9MuebVp4SJY22e8w0R_PjYN6OZoTh4pxf 8Ili4g_GCBAyFTxH9p1X7Pe_qmowZbrPPb.DDFzJwuKPmq5WHfQKn3Gsohwx tdkJxUVjvCUaXCn_EtHsDBpcD1YFeYLiT7UAQH_h8WdWpXx3kBJRSrX8AWLt m81IJajFYfP8WnK13E_txF3_xmpMpdnnIU74qk81RnlubX84a From: Tokunori Ikegami To: Boris Brezillon Subject: [PATCH v5 09/11] mtd: cfi_cmdset_0002: Split write-to-buffer-reset sequence Date: Tue, 5 Feb 2019 23:07:57 +0900 Message-Id: <20190205140759.2360-10-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> References: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190205_060902_667187_CDE0EEDF X-CRM114-Status: GOOD ( 13.09 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [182.22.90.64 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ikegami_to[at]yahoo.co.jp) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joakim Tjernlund , linux-mtd@lists.infradead.org, Tokunori Ikegami , Chris Packham , Fabio Bettoni MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Just refactor to split the sequence from do_write_buffer(). Signed-off-by: Tokunori Ikegami Cc: Fabio Bettoni Co: Hauke Mehrtens Co: Koen Vandeputte Cc: Chris Packham Cc: Joakim Tjernlund Cc: linux-mtd@lists.infradead.org --- Changes since v4: - None. Changes since v3: - Just change the email address of Tokunori Ikegami to ikegami_to@yahoo.co.jp. Changes since v2: - None. Changes since v1: - Add the patch. drivers/mtd/chips/cfi_cmdset_0002.c | 38 +++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index 81f5e5e..d5954bf 100755 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1820,6 +1820,27 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len, return 0; } +static void __xipram do_write_buffer_reset(struct map_info *map, + struct flchip *chip, + struct cfi_private *cfi) +{ + /* + * Recovery from write-buffer programming failures requires + * the write-to-buffer-reset sequence. Since the last part + * of the sequence also works as a normal reset, we can run + * the same commands regardless of why we are here. + * See e.g. + * http://www.spansion.com/Support/Application%20Notes/MirrorBit_Write_Buffer_Prog_Page_Buffer_Read_AN.pdf + */ + cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, + cfi->device_type, NULL); + cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, + cfi->device_type, NULL); + cfi_send_gen_cmd(0xF0, cfi->addr_unlock1, chip->start, map, cfi, + cfi->device_type, NULL); + + /* FIXME - should have reset delay before continuing */ +} /* * FIXME: interleaved mode not tested, and probably not supported! @@ -1922,22 +1943,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, } if (ret) { - /* - * Recovery from write-buffer programming failures requires - * the write-to-buffer-reset sequence. Since the last part - * of the sequence also works as a normal reset, we can run - * the same commands regardless of why we are here. - * See e.g. - * http://www.spansion.com/Support/Application%20Notes/MirrorBit_Write_Buffer_Prog_Page_Buffer_Read_AN.pdf - */ - cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, - cfi->device_type, NULL); - cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, - cfi->device_type, NULL); - cfi_send_gen_cmd(0xF0, cfi->addr_unlock1, chip->start, map, cfi, - cfi->device_type, NULL); - /* FIXME - should have reset delay before continuing */ - + do_write_buffer_reset(map, chip, cfi); printk(KERN_WARNING "MTD %s(): software timeout, address:0x%.8lx.\n", __func__, adr); } From patchwork Tue Feb 5 14:07:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tokunori Ikegami X-Patchwork-Id: 1036775 X-Patchwork-Delegate: vigneshr@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=yahoo.co.jp Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="U3BVsQz5"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="U0/4CQiE"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43v61J2sjnz9s4V for ; Wed, 6 Feb 2019 01:10:44 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=mOgfXmPHgHrzlAx2C1NSpB71v29EkT12sAp3BTdZLT0=; b=U3BVsQz5+ivQvjc8OVIFGpP8k8 1UT33kJmx4MTG3EinzHc+PR6rZrdAdVMkQzmL6IGaD8y/hRQPUpWlNsvdovQta6V5BKNWw0W83TbJ VKLlgGPAZim1oDjsn5dy5aze8sYflH3rfMmDfe6132KSU4Gy2CNyP+jN6sAQFaClduTlcz/X4FCVw ZcnFUU9GgVkl0uMGmUo5JDv/SIMynPP2JVq4gBueL2yiSg8xDq1q3x4XY135OfQw5pllyJf5mjo+i GVIIQ/A5TzlH9GhdGtBoZdE9WAEda3ECYJ5mHyzT+SflgwdZEqfz0SQfPrYjY9q6WwrCITT5l+jZX vxqGpiqQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1Qr-000144-K0; Tue, 05 Feb 2019 14:10:37 +0000 Received: from nh502-vm6.bullet.mail.kks.yahoo.co.jp ([183.79.56.151]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1PM-0006lU-J0 for linux-mtd@lists.infradead.org; Tue, 05 Feb 2019 14:09:09 +0000 Received: from [183.79.100.138] by nh502.bullet.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:09:00 -0000 Received: from [183.79.100.135] by t501.bullet.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:09:00 -0000 Received: from [127.0.0.1] by omp504.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:09:00 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 647378.98394.bm@omp504.mail.kks.yahoo.co.jp Received: (qmail 45914 invoked by alias); 5 Feb 2019 14:09:00 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549375740; bh=Tvp6/aggrzOr9Ma4guV/srFHIw/qdJtfsXRRvjueahM=; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=U0/4CQiEc1imTLP9gtfPyjdtuKZ43UvQRxsy3QOEu8TsE3fJjdyoVbxhb66+h/ZJ+HkPcfF9QiM3cyI2ph3jXkKIkbia83CHpFSiINJpt5pup5uDvbvv8k07EfqNAeE9UlEQ/Hb+8zSzBK7dh7jPbMjOcMxWArnVqpO2tF6lmcQ= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=yj20110701; d=yahoo.co.jp; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=Zwysqz+LE//hRP63UEguPdy3zAxfH1+x21FPEwRfTek326Qc4LZiUxoNgP0dehdGTcEqhcoEEYhhsyjRe/9/QzT+20Oc+Xq5vfZnvCLbDfH7TXzHCtnmtqEp0185eADzjWc80EzJOWR/8OQN7fpn4LHIUiKXRV9HwVbCaO53TyY= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp5006.mail.kks.ynwp.yahoo.co.jp with SMTP; 5 Feb 2019 14:09:00 -0000 X-YMail-JAS: SNNUQccVM1npwa9vxpNsKUloTREtbvV8veIWL8EUt2kNv2f_kX.zlRkdyDJeYSW1iLapjF0IPEkShqEjyo18Qv4NSZ07LbJGRXsDIBe..ugczk4ISCpog53TCNJABjM7Mh1fU3ZPVQ-- X-Apparently-From: X-YMail-OSG: _OErKFcVM1moMod7n8Uw2Xx0I2zK_QsjPQJLw0mnK7n5adS yFQT_uE29edOBeZFVMQVReDvmp.Hwomf754MR4_hq3TTyMCXclPctsoPAiLD wlteHSk0v3Os4A..XINs1vTXI3SkPTQfCRWDtQOLoZUFUd.cWwa5Oc9rU71p JPcWcVzIG4BZFe4TZaUyMkDTbwzeAlXwckc7.iDF.19wJtwCUFR5gFxzUU2q kAiI6W58MuCoG__8VQqTpD.Iz9VoYEkbuKxG90PzxjkUebBkaBO7V5GfFnG7 h5CbiLtGMeXwRWJOc20gBnZ7IhnQHAKe.tXZIv0HUqbWSx8Jc5Q2xe3Znaql Do_wdbAfniKdBi2iyhF533abS2wvV9BqqNKe6h_ty5HxOaFm_TNtj8IM_cNL ZmQaZ.FwCIbBnmf.jbFTWbLLj1lbfYvR39Dgn6M5wpjEmU0s.jsh29lgx9AS GVVw3QNV5nDh8F7GUQo5mLXClIekQ__qmDLBpCI.Znn2Ld14GO7q7xxa1_BP e0hWFsGPusIKhqfdmGPhKdd5DefEYbCgORg7gNS87nUl20526tX4oLWKPZ_j BYH.NgWkz9UaCL1gdoLq2_cIGdyo.oqAIYEbTdVz3_Urxmymi From: Tokunori Ikegami To: Boris Brezillon Subject: [PATCH v5 10/11] mtd: cfi_cmdset_0002: Split to wait write buffer to check if completed Date: Tue, 5 Feb 2019 23:07:58 +0900 Message-Id: <20190205140759.2360-11-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> References: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190205_060905_385740_0DB4690A X-CRM114-Status: GOOD ( 15.34 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [183.79.56.151 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ikegami_to[at]yahoo.co.jp) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joakim Tjernlund , linux-mtd@lists.infradead.org, Tokunori Ikegami , Chris Packham , Fabio Bettoni MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Just refactor to split the wait from do_write_buffer(). Signed-off-by: Tokunori Ikegami Cc: Fabio Bettoni Co: Hauke Mehrtens Co: Koen Vandeputte Cc: Chris Packham Cc: Joakim Tjernlund Cc: linux-mtd@lists.infradead.org --- Changes since v4: - None. Changes since v3: - Just change the email address of Tokunori Ikegami to ikegami_to@yahoo.co.jp. Changes since v2: - None. Changes since v1: - Add the patch. drivers/mtd/chips/cfi_cmdset_0002.c | 81 +++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 35 deletions(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index d5954bf..da48b4c 100755 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1820,6 +1820,51 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len, return 0; } +static int __xipram do_write_buffer_wait(struct map_info *map, + struct flchip *chip, unsigned long adr, + map_word datum) +{ + unsigned long timeo; + unsigned long uWriteTimeout; + int ret = 0; + + /* + * Timeout is calculated according to CFI data, if available. + * See more comments in cfi_cmdset_0002(). + */ + uWriteTimeout = usecs_to_jiffies(chip->buffer_write_time_max); + timeo = jiffies + uWriteTimeout; + + for (;;) { + if (chip->state != FL_WRITING) { + /* Someone's suspended the write. Sleep */ + DECLARE_WAITQUEUE(wait, current); + + set_current_state(TASK_UNINTERRUPTIBLE); + add_wait_queue(&chip->wq, &wait); + mutex_unlock(&chip->mutex); + schedule(); + remove_wait_queue(&chip->wq, &wait); + timeo = jiffies + (HZ / 2); /* FIXME */ + mutex_lock(&chip->mutex); + continue; + } + + if (chip_good(map, adr, datum)) + break; + + if (time_after(jiffies, timeo)) { + ret = -EIO; + break; + } + + /* Latency issues. Drop the lock, wait a while and retry */ + UDELAY(map, chip, adr, 1); + } + + return ret; +} + static void __xipram do_write_buffer_reset(struct map_info *map, struct flchip *chip, struct cfi_private *cfi) @@ -1850,13 +1895,6 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, int len) { struct cfi_private *cfi = map->fldrv_priv; - unsigned long timeo = jiffies + HZ; - /* - * Timeout is calculated according to CFI data, if available. - * See more comments in cfi_cmdset_0002(). - */ - unsigned long uWriteTimeout = - usecs_to_jiffies(chip->buffer_write_time_max); int ret = -EIO; unsigned long cmd_adr; int z, words; @@ -1913,34 +1951,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, adr, map_bankwidth(map), chip->word_write_time); - timeo = jiffies + uWriteTimeout; - - for (;;) { - if (chip->state != FL_WRITING) { - /* Someone's suspended the write. Sleep */ - DECLARE_WAITQUEUE(wait, current); - - set_current_state(TASK_UNINTERRUPTIBLE); - add_wait_queue(&chip->wq, &wait); - mutex_unlock(&chip->mutex); - schedule(); - remove_wait_queue(&chip->wq, &wait); - timeo = jiffies + (HZ / 2); /* FIXME */ - mutex_lock(&chip->mutex); - continue; - } - - if (chip_good(map, adr, datum)) - break; - - if (time_after(jiffies, timeo)) { - ret = -EIO; - break; - } - - /* Latency issues. Drop the lock, wait a while and retry */ - UDELAY(map, chip, adr, 1); - } + ret = do_write_buffer_wait(map, chip, adr, datum); if (ret) { do_write_buffer_reset(map, chip, cfi); From patchwork Tue Feb 5 14:07:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tokunori Ikegami X-Patchwork-Id: 1036776 X-Patchwork-Delegate: vigneshr@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=yahoo.co.jp Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Rhh/3Rku"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="OlHjyGwv"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43v61c5kGPz9s4V for ; Wed, 6 Feb 2019 01:11:00 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=q98q4nKYO6LAiE1Ku7DUDroBvLOJ7VzW9/LYg/IQ7rk=; b=Rhh/3RkucrcpLzyfVfoj5O18C/ CzuznAu8fbsSMhE69i06JdZhhphlzxtDnwH27JfKwhnY5zyCi9ZTd1jAxbp6+jzgz4ai0XD11gik0 TFrl0RExuof4aBuyXWrgxadkjW9ADCDvPv8kSASkZVIByLrTiAw3mUliCGiLETCl9rHnIqRnx27fR c2VODzPSx9H6x2gfqUBw0NlHIZHC2f4BvMh5JiD8IqCQ/vxK1W47ZGX+0bWjwTQxSB5ZX8B7iYuy6 FxS/I7MfO0NarWkJTUN2tCFtwulIbjsAdC5OCI7XqslYGfLuAv1EcWKank9i9CN6xkHs/jAuGoP0h AAXCbarw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1R7-0001Id-BW; Tue, 05 Feb 2019 14:10:53 +0000 Received: from nh504-vm0.bullet.mail.kks.yahoo.co.jp ([183.79.57.86]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr1PL-0006nZ-Vm for linux-mtd@lists.infradead.org; Tue, 05 Feb 2019 14:09:09 +0000 Received: from [183.79.100.140] by nh504.bullet.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:09:01 -0000 Received: from [183.79.100.136] by t503.bullet.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:09:01 -0000 Received: from [127.0.0.1] by omp505.mail.kks.yahoo.co.jp with NNFMP; 05 Feb 2019 14:09:01 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 225684.91220.bm@omp505.mail.kks.yahoo.co.jp Received: (qmail 45959 invoked by alias); 5 Feb 2019 14:09:01 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549375741; bh=ssXy/k0clGufVlNYlWCMwNSiy7A/NdhzVFLirntOmWM=; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=OlHjyGwvCyEhgsKTgw1beaN4SBp2ftjAr4YBsfsbokG0dWffV01GOnQgcy+UTU36z9kFlBUYzdyRQs/50+H0ZtPD15IVarnaQZ9azTNSoz43XKncetuJySm8iOhTP+qAzMxrhVw8TkJgrgRX3qLJwas7+yYoLCju2LDlt3J9AoQ= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=yj20110701; d=yahoo.co.jp; h=Received:X-YMail-JAS:X-Apparently-From:X-YMail-OSG:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=X+lsqER+5nSk1QeJDv+l8e9vRtJhuV9FWl12OIjqk+McUv1FLdWLv1nb2NFZePmeVE4doEeyRNNucbsKsiQr76fmSchz4jby9JLkAswtXhs2U9uoV1/rrdfr3exzH5ITFeiTM6Ucdouo14AIlfkB/lXVcz23aNE5pxOrBlDXLOk= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp5006.mail.kks.ynwp.yahoo.co.jp with SMTP; 5 Feb 2019 14:09:00 -0000 X-YMail-JAS: SNNUQccVM1npwa9vxpNsKUloTREtbvV8veIWL8EUt2kNv2f_kX.zlRkdyDJeYSW1iLapjF0IPEkShqEjyo18Qv4NSZ07LbJGRXsDIBe..ugczk4ISCpog53TCNJABjM7Mh1fU3ZPVQ-- X-Apparently-From: X-YMail-OSG: baBQi8cVM1nwwGLsB8D_lg_HEcW1ERJLE.rp2xvpJf1bp3I BM5Vk41ASJJxpdEaGP03u0i0FeRDXhPogorYhemp3O.BA_JDTUM.qshExj2m dL.1_VPIqEwsC3JBJUP2ViDexLeNEDKZvm_WSPO0j9rpW0jdEFGd3CQvukgS inVJHOGJWkE6OKb_KAOCrVY0L7hFzEphuxAkzahbVEoSSPyO7GyzlnRKRhFE sMEJBwUdRfQi_vu5f1kparbgvCVvXbc7M3J67DTAMFuvKrnWN8P88mwLUQeA CCOm8WpshMKmcZLt8OfzE3nMLu4MOS_hpKFzDbJb89rbrgEAaMZw97J.pzh8 BsMV.OVMYfSDNtbRpQyfpwqtRSffT2E9KIuVKqZz0M4Zpb6MIz5YCdF_pm.r 3NhETXxVNTSIkQuBu8B25Wc2Gc7nminkYmvbgKJ4HX9NLLZpUGPei04X4tUp 5yIPZTK3JhL0Q088xQIwnd967M2Bx90bS_m7.mxgexb0tdvB6BDIJVvoQ5p4 lhRIqWjRmQG9AHDxZPUm3y9IeuNbavzVgoUwA.W5VGRi5tjrPTZVbVAKyLhD lNFkJx.mLonAquSeDKcrwiXk5j6c6yXTnuC4m5.r2mtyJmc9r From: Tokunori Ikegami To: Boris Brezillon Subject: [PATCH v5 11/11] mtd: cfi_cmdset_0002: Split do_write_oneword() to reduce exit paths Date: Tue, 5 Feb 2019 23:07:59 +0900 Message-Id: <20190205140759.2360-12-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> References: <20190205140759.2360-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190205_060904_652318_38711247 X-CRM114-Status: GOOD ( 14.10 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [183.79.57.86 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ikegami_to[at]yahoo.co.jp) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joakim Tjernlund , linux-mtd@lists.infradead.org, Tokunori Ikegami , Chris Packham , Fabio Bettoni MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The do_write_oneword_done() is called twice at the exit paths. By splitting the retry functionality it can be reduced to call once. Signed-off-by: Tokunori Ikegami Cc: Fabio Bettoni Co: Hauke Mehrtens Co: Koen Vandeputte Cc: Chris Packham Cc: Joakim Tjernlund Cc: linux-mtd@lists.infradead.org --- Changes since v4: - None. Changes since v3: - Just change the email address of Tokunori Ikegami to ikegami_to@yahoo.co.jp. Changes since v2: - Add the patch. drivers/mtd/chips/cfi_cmdset_0002.c | 39 ++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index da48b4c..21ba6d6 100755 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1643,25 +1643,16 @@ static void __xipram do_write_oneword_done(struct map_info *map, mutex_unlock(&chip->mutex); } -static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, - unsigned long adr, map_word datum, - int mode) +static int __xipram do_write_oneword_retry(struct map_info *map, + struct flchip *chip, + unsigned long adr, map_word datum, + int mode) { struct cfi_private *cfi = map->fldrv_priv; int ret = 0; map_word oldd; int retry_cnt = 0; - adr += chip->start; - - pr_debug("MTD %s(): WRITE 0x%.8lx(0x%.8lx)\n", __func__, adr, - datum.x[0]); - - ret = do_write_oneword_start(map, chip, adr, mode); - if (ret) { - return ret; - } - /* * Check for a NOP for the case when the datum to write is already * present - it saves time and works around buggy chips that corrupt @@ -1671,7 +1662,6 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, oldd = map_read(map, adr); if (map_word_equal(map, oldd, datum)) { pr_debug("MTD %s(): NOP\n", __func__); - do_write_oneword_done(map, chip, adr, mode); return ret; } @@ -1691,6 +1681,27 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, } xip_enable(map, chip, adr); + return ret; +} + +static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, + unsigned long adr, map_word datum, + int mode) +{ + int ret = 0; + + adr += chip->start; + + pr_debug("MTD %s(): WRITE 0x%.8lx(0x%.8lx)\n", __func__, adr, + datum.x[0]); + + ret = do_write_oneword_start(map, chip, adr, mode); + if (ret) { + return ret; + } + + ret = do_write_oneword_retry(map, chip, adr, datum, mode); + do_write_oneword_done(map, chip, adr, mode); return ret;