From patchwork Mon Feb 4 18:19: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: 1036136 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="rksqObf0"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="TvqMMk5h"; 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 43tbc051TRz9s3l for ; Tue, 5 Feb 2019 05:20:32 +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=NOXmu14kpQa3w0ScHir2muuRVnbBJNosVDy3OdNe3zI=; b=rksqObf0DS0D2NHsRGavSi8uQs Db6KxDT7IgGa5zHZbLqgN137iQs8q9FEnDA4603/x4XRtAoiI/Q4RqVBeiq/Y5c3xh4cU++TzRIh0 8jo+FJLKcfmWTjKbTi+7abyH1pqogxDyzGmpnoHyB75zsuTnFEFB9fkGJI50Yyu+MzjV/yc9bduow fAhSIZoStsriTiSzOCTqUxyDQuSebCb2aacP73hUNCj5kxOmt3Uv8Q291li3nywerTrl/r3tCBjGd 9zAx3bNKHHh2IbtDoltLeUL2gzUO0UF/itOb8CQKnYZlaGHY4TOj0AuDUl4RmD28liS1eNqMhXkRI OED982QQ==; 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 1gqir5-0005xM-1M; Mon, 04 Feb 2019 18:20:27 +0000 Received: from nh502-vm9.bullet.mail.kks.yahoo.co.jp ([183.79.56.154]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gqiqp-0005j1-Ix for linux-mtd@lists.infradead.org; Mon, 04 Feb 2019 18:20:13 +0000 Received: from [183.79.100.138] by nh502.bullet.mail.kks.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:10 -0000 Received: from [183.79.100.135] by t501.bullet.mail.kks.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:10 -0000 Received: from [127.0.0.1] by omp504.mail.kks.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:10 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 12197.72111.bm@omp504.mail.kks.yahoo.co.jp Received: (qmail 41983 invoked by alias); 4 Feb 2019 18:20:09 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549304409; bh=cT/RzRsMc7GjixAZ+Fvp5ZUAth/zmhgBWQjnxnm4Uso=; 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=TvqMMk5hJZ99pLwS04/7U/vMLJ7vDpifps3Db6eEibVD+IWfJ80VUsH6XAlvpTJSCNDfV5nQdAYBBxkeLndAcumloN1KzOQ1RkONR/mAIZBVAlBdq7zxR5IBsxA2RDyFsacPhKCtfItovQ2nFZ5RC56MWRRY4lPumG6Ke3MaXgg= 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=rztYiipjeBzP+8NIWyHG5GsSIBPqipaAWACwLajbyj5N07qIw8lTIvCSBK9hhSrR82NYwZMA8gTqOVmK0iTWYh+dG3SpEs9V6qKrQVonNSdPhDlesNMWciE19GDXRCznL/U4mkn0yYwoiggkGMANQKFl0JJLvV/5BUbVId7stjw= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp6006.mail.ssk.ynwp.yahoo.co.jp with SMTP; 4 Feb 2019 18:20:09 -0000 X-YMail-JAS: XsW4XckVM1klhOHepx7XMRmikxvgtfEt6CThK2ouEuIDbuRXKm3GjF7mVaJkwUaw8C1j2MhGcpoK4ynwOdZsAClSckPoxGsn2AFEO1BOhUmcj0JNQ_Pv.MHDgvTErmqfH9mP0rvb8w-- X-Apparently-From: X-YMail-OSG: bPuSYFYVM1kO0huKJsPSJLj5XvYAAwTfYY0rWdy_RsxH13L XmJ7Aoea4TVWGsa8h54jCg7CMHtFauQaDwj9Hx1BGfX71ZuU3HRAFtHJhsEe tIc8nuh_ymRzBgbtI3ng0xRnWrn_P6QisYFQP1T4EEdFQZaIe7lwvZDtUJ7v zbQ_pcv_dp9oH6qH59xPD63bnvjUYl2IfaS.Iyxbyd_tWwL9gQrGgiqCIfdT _I36pc3HuMBySgaD15tCLfGg5nfgsY44HQLT5s5unkjvfOtXQIjX9InqitDZ YVgoYp2XyyadjZCSICP.pNh8tl1aU7947hg_lHDaUCKBHgK9TyE0EBUombmi DyEWZkLWS1zfSyQf0TjIQZ81pNamcnIy_8u3zkFYTnHWOBQ8R6veJU.bhSTt 6ukerH9ehXUX.W5Pr6NIOCRl3eqbLn5GH9AulMNWaI9HBElmXVpnE_NLbFTu hYRrRWpkO9GVx9q6d2.A4peBG6swjqtVEQOAzIni9GtfTu2hZFchxgBV82nN .Peps7n0wd.ewk8d59PGNxMG3DL9Of5gAb2DsVMMxGL2JUlQLKryzqXkqJd2 yI6ae6Yqha7yJsvNySCaL4MVnwN2AQmGQhgj.E.HCPhdjVN5I From: Tokunori Ikegami To: Boris Brezillon Subject: [RESEND v4 01/11] mtd: cfi_cmdset_0002: Use chip_good() to retry in do_write_oneword() Date: Tue, 5 Feb 2019 03:19:54 +0900 Message-Id: <20190204182004.29894-2-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> References: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190204_102011_887060_4049825C X-CRM114-Status: GOOD ( 19.64 ) 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.154 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [183.79.56.154 listed in wl.mailspike.net] 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 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 Mon Feb 4 18:19: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: 1036137 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="FY/SIgNu"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="aURWWEGf"; 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 43tbcG1Kgmz9s3l for ; Tue, 5 Feb 2019 05:20:46 +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=l3qGRRSDEOn1KfI27nZnVyzx0RqHQX5uCrzAbJWuO7k=; b=FY/SIgNukd1y2Oy5zYvje9nIBf X0DTSAnjFku/odxpcX07zFgMv1qhoW/JbE835lx5T+JdZkib+QcfKLWFhmL1uKd7kajPtphAdKzYZ T0zTUPDarMzlWNWBmfsOAOqtnk1sU7v71OhdRiI8NZtrI5k5IlulluMjZz7L5UQAIiEzXGygo4Ah1 a7Vk/4aNifYTYOF/KQNtrMHvEsdMthjfggCAzEeH+G4w3jAtZ5FSu3u3lDKDq204cL+q+5wJSfiD0 55dCMpiWl6inUbg/42PG285LbPtn+4ReUyeNVW+ain5eul9+b933qgAgu8nKW9dAuvD5GcFSnHSSL oRiYTusA==; 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 1gqirH-0006A3-L4; Mon, 04 Feb 2019 18:20:39 +0000 Received: from nh602-vm0.bullet.mail.ssk.yahoo.co.jp ([182.22.90.25]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gqiqp-0005j0-J3 for linux-mtd@lists.infradead.org; Mon, 04 Feb 2019 18:20:15 +0000 Received: from [182.22.66.105] by nh602.bullet.mail.ssk.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:10 -0000 Received: from [182.22.91.207] by t603.bullet.mail.ssk.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:10 -0000 Received: from [127.0.0.1] by omp610.mail.ssk.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:10 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 32392.9004.bm@omp610.mail.ssk.yahoo.co.jp Received: (qmail 41994 invoked by alias); 4 Feb 2019 18:20:10 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549304409; bh=w0isZg94riL6Ijq+ghJ4zY7JTQ3KiC8fJWTxLBIEEPU=; 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=aURWWEGf2g3b2jQF7DjRLLs5LdIc+b72oWGz/WyGk7uTd8FwfMmpuGK9Yo6idiTszQgf/DIIfPjS3vZSBlRuvMAM73M1HdKjiW/tK3rtb6t6hES5JMsuV/d01UUP70d1QJ5qVxRXVgQ3RQ9k/tiqUafMtn0c8pLuIruIC0Rgeto= 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=pGMVTIf4we3JSV39DRCSMPcbec8MWRfwOfTCGNTvGy3d7A2JL6IprypZNTyPoApebno8md6TkUD7theBsMRciMomGIPyGKPDJY26FfM1sW8LymdR5utKyC3eRk0RlOA36rbByzJhS2p5WkRts7BpOG2GsRNN7NE3ULuN7gWW+jA= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp6006.mail.ssk.ynwp.yahoo.co.jp with SMTP; 4 Feb 2019 18:20:09 -0000 X-YMail-JAS: XsW4XckVM1klhOHepx7XMRmikxvgtfEt6CThK2ouEuIDbuRXKm3GjF7mVaJkwUaw8C1j2MhGcpoK4ynwOdZsAClSckPoxGsn2AFEO1BOhUmcj0JNQ_Pv.MHDgvTErmqfH9mP0rvb8w-- X-Apparently-From: X-YMail-OSG: FNCoowgVM1mXLbKpXhoaDW5p.sXjZZcPp3j4pCmtErdJj8f .aH606UORtodsAhPduCBzznoB4qyz7Y4Wvc.CpMeezxAmB7cxxsM9dAP8Rv6 1T8YpVYZy3hVe_.9Xdp73RK9vinDFGyohe_aYhtJoeZtO2w8vjop5nPxc8co y4PiJbAq3hl4iVO0aJJyx2ilF5zIhp_2s6sENluXm_TENEi4J2jVz9g4KSd9 snWEoarZeI6Fiy4.aOaFq2PFq35Eeth6vKJNmZ6XdvR5XJH7uOrVJq6HpN2G D52JL7Sp6I4r8NrUQwJiY8bRlV.VrV25V0_zxnvSwUtZcU1d44d9yBZ0Emgz yXdl2vOJ49TlR3V5JGzavGy0je1qB3Zhd.sbNUoRLSYziS1hgPGe5SmBDmYs VhnqfCKsSg.Sd1PMgPQUwWs9Jbas71hnNDbMQ3_7gN2jPpsIecvsaktqe.qV wuaClRtXmJHWGK1I.W5oSX.U5gtt.bU24JO8zwdjzTgRUu_Hx_9L36iGMjXB PMpzAM5vi4bgtvx.cP2YKoPHY5bsvWd057cqCk.HfD.sG6d6H_.oBHvXQXZR vsM5G64bycQe1SJOx7WVfGO5MkrSBK2w9FGXUnkIYBBIcczSD From: Tokunori Ikegami To: Boris Brezillon Subject: [RESEND v4 02/11] mtd: cfi_cmdset_0002: Remove chip_ready() from do_write_buffer() Date: Tue, 5 Feb 2019 03:19:55 +0900 Message-Id: <20190204182004.29894-3-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> References: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190204_102012_183322_1CE1CE38 X-CRM114-Status: GOOD ( 13.98 ) 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.25 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 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. 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 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 Mon Feb 4 18:19: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: 1036139 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="aDkzWXTJ"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="AikvGH5j"; 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 43tbcq1K7Rz9s3l for ; Tue, 5 Feb 2019 05:21:15 +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=/4El77QxAUpvoOQJTpNdY74Az6k6IZINXq1me6JtpmY=; b=aDkzWXTJupb7ez0s91wxcP7rFp /MN/+rfPOUMXiS3tkUfUph6r/qPrG5okKGdI5P6761IfdGe+jV49pOYqndp3H61clfIN8TDQ+VhSF d+yzgc8LF0AZVOuOBdB9ktbW/o6A8iRnBTCN/N1yelw/7Sn6peBVCcBO/01/qs64G6cLnTc9sGgvM OLyZhRa8iPsAmusRqxAB+vENwrWJ0NLYUyEKbOOlTSIQvh377sx3koMsndQMTSyACBJp81gIK33Tt 6xUU6rKTI/VLgS3Qq4NX08xGFD6PQTrs0i65XCAN+bgZx+YZDe3o4M/aBmCk/Teazzr758b+sw/aF UJEuvv7A==; 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 1gqirj-0006aw-57; Mon, 04 Feb 2019 18:21:07 +0000 Received: from nh604-vm11.bullet.mail.ssk.yahoo.co.jp ([182.22.90.68]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gqiqp-0005j2-Ki for linux-mtd@lists.infradead.org; Mon, 04 Feb 2019 18:20:15 +0000 Received: from [182.22.66.104] by nh604.bullet.mail.ssk.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:10 -0000 Received: from [182.22.91.206] by t602.bullet.mail.ssk.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:10 -0000 Received: from [127.0.0.1] by omp609.mail.ssk.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:10 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 347249.36526.bm@omp609.mail.ssk.yahoo.co.jp Received: (qmail 42006 invoked by alias); 4 Feb 2019 18:20:10 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549304410; bh=g/S9K3qGzvMq7Ymh1omGf40u/Wj82T32UcnvQOcMhXE=; 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=AikvGH5jnEflPhpeF3ivXr5cl9BYofTFIIM0lo8TxtpEyb1ZSQr+WqtOZZiCt/vGjTXxBVKC0l6nXlC0MOiLUBgS91hBPwKEsn9jBawhjZj0i8vaU1w5Gzxn28+1ogzcZH4oY30vXcL3JnjagCgS1VJ5GR2Qh84EeUxrsvEVxXk= 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=kUjtmApREJ/vj3Q/a+rw7dNQyxLVdlFG78sFDvzTNnrx/5wi0AYXveFXBbtlV0HGHdXqEsbj146QTX2aa3BWFXRNPOqT8MP5F1/xALcp5gm4XQGlla7JnprWUMvxPfh8ADC+pqMfcSmzz/TGgB9tZMq1yq+tMS270J8Z8AEAW20= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp6006.mail.ssk.ynwp.yahoo.co.jp with SMTP; 4 Feb 2019 18:20:10 -0000 X-YMail-JAS: RtmTJv4VM1nf4e1VQbHkp6qLbY3vmJfj2fQcSHUA6LwkhM0t8SSb3SEydt.pAJACsRifURPlY1qCnOBSvB0SgsGtVzi84vrE_PmGnKo9wUGOvfON2dnbHkpjohPTJdxxEBtG_texLw-- X-Apparently-From: X-YMail-OSG: HzYjqOgVM1kx6119mmVFl.iOechSy.85rNqJTJPW6wD.BKi GMSu5ujr1PBLnonEiKdn8bEzkYMN4ioYWGQBX.71kQLfZgsjNxt6JSHsgFvg 8RZ7uvvexqU.XXrbd6lfRRrPtzyTeMQ594XUPRUByJKo1E9tou.6PGJL38Mo ZONp3KWzOYDAQOiDm.fm3lEHvSMouBJPismWbm8bemRBtoSCoPU9W5QcZ8cX r12FUCViohrc3usI43RL6K85URyEfxcM3hiPTaJ6N8cbio_4cb3e_4eh2LoO pQQmriyOSNDq4cSqmiM7pu5znSLYWpdI.9oryWOCiOASv6d.X2ynhQ3FvREg 8S6ItsWyCUqIgoIY6T0CLA32e2ERX9D9tUYdEczCKgFpIs4TphsmHthP_UWN 5PnvKDyTOlOUYU2I26upi3ccCNr2OqIQ40Hp2G6kCjgkmSEPK3DJkfv8GaRM emnKpPHIQgaCcZ7cZV7wPS2h_R8ZrOPAeOcNCYCvZFg.XFdMQ41rXOP2IvVD Zf6dnOsePSszygOxshvH7JSVaw3aDcwDzCV25P9Qo7h86aoB0X04OPZMrlbv sX6L9njeLavqvxC0XsQthCGvY_H9DhZ0l_5WfFl90Bt9fJa68 From: Tokunori Ikegami To: Boris Brezillon Subject: [RESEND v4 03/11] mtd: cfi_cmdset_0002: Remove goto statement from do_write_buffer() Date: Tue, 5 Feb 2019 03:19:56 +0900 Message-Id: <20190204182004.29894-4-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> References: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190204_102011_913155_47774237 X-CRM114-Status: GOOD ( 13.13 ) 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.68 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [182.22.90.68 listed in wl.mailspike.net] 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 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 Mon Feb 4 18:19: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: 1036140 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="rTGXZm0S"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="ut5VW/Cf"; 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 43tbd55t3zz9s3l for ; Tue, 5 Feb 2019 05:21:29 +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=q8VR0yVhkIV4kXdHPl5bbVjO0RB9ZvlLVgpyruX8LlY=; b=rTGXZm0SofV6gs6jjOGWmtrltE XvgB0yRveJJwxb9YxE3Y6hvDdIG2gLNJc9zziIz4D+H1G7JerIA7gi0gQHCV9bla/fDjtaDGpEZq2 AlLtLn3Ok+/De2NmzztisB51H+i/qA7OGBGRBVRV4Xo8VKRyGk/J9+DqPFC4lKNuUG6ob1KH0vK1l T0ar7mAa0KW7NmOda6ovn8VIlWS+vyva8XmHpprfzhDjI5KMKxp8ZyI8NjGVESnWJC1zdFb0YGtS8 eIvwMyB198kt13RylSaEfVdYkLjM95Q255Rd5VEAAzAiI6k5Fit8ffzrnf75mzuVdeYfLIt9GveDF xuO3t8Kw==; 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 1gqirv-0006mo-QU; Mon, 04 Feb 2019 18:21:19 +0000 Received: from nh604-vm8.bullet.mail.ssk.yahoo.co.jp ([182.22.90.65]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gqiqq-0005j3-0V for linux-mtd@lists.infradead.org; Mon, 04 Feb 2019 18:20:15 +0000 Received: from [182.22.66.104] by nh604.bullet.mail.ssk.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:10 -0000 Received: from [182.22.91.128] by t602.bullet.mail.ssk.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:10 -0000 Received: from [127.0.0.1] by omp601.mail.ssk.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:10 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 594380.85735.bm@omp601.mail.ssk.yahoo.co.jp Received: (qmail 42018 invoked by alias); 4 Feb 2019 18:20:10 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549304410; bh=GiYcqEaS072E7wSbj2HhBqLUQeHAyVSQ/9KzmefoYOk=; 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=ut5VW/CfznvtVGs9dWZvumXtnKRihoozKTjzT72b3sY4Mgg5qCbxm8vXVzbo93eLif6qdQjb9oJXhbSzA+AlX+v4eg+Xm+YgZ6E/oIBYgQ7mSW4NCwCxecLuyK9no0KBUeeaK8KZjKbKjDvtyHTw1UBLiZ6PciKnXQdvFgbTn38= 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=FGGIHVEZiAoStXDJomDxg4+P+UArb1DXuGa0HWaqHDinRF74GAbnavsxMj57v99DghEsrt1qyrzkl9+w3AkcRJatDiEDnBSp+DBXB+gJ1rj5v+yHUcp/RvDA+2Vj1O7gFSgzPKzCiFIe8JwX4ipeqpPl4KowWprNve2BW0Y4cr0= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp6006.mail.ssk.ynwp.yahoo.co.jp with SMTP; 4 Feb 2019 18:20:10 -0000 X-YMail-JAS: RtmTJv4VM1nf4e1VQbHkp6qLbY3vmJfj2fQcSHUA6LwkhM0t8SSb3SEydt.pAJACsRifURPlY1qCnOBSvB0SgsGtVzi84vrE_PmGnKo9wUGOvfON2dnbHkpjohPTJdxxEBtG_texLw-- X-Apparently-From: X-YMail-OSG: Sz4wXv8VM1liwwssZtEsdir76F.t0iGqGG1AHMiV56JobjC v0be4AOHIUCMfzTyLV7svLYzN24Jt.ztFl6caFwTa6c9N4ygWViyHZuYpoVw k58p7eOOX1FMXI03ds0TVqpcU9vZ7E3aUb3n2U3UMJ_Zu5pis1Ipe_blUBej gJt1p79uKnqkYSL8VAQmNceu4501oXSDBolBCA6WnMZQbPHqmV1qLQ6Rmdey s6uHv5ysz.z3FTVpETJzw_g2VPBR_w6Ep206_EKiSO.s47dTdwNZPjXZr2Vx wySI1fPW3hqathNu86S28m1EWmUyUAGEkKWGjwjHU99C4JOquLiuwkSbh1Ua WUpPb2R9sogztXn5gKaw2P5nepSAbw6oWL1bzA8Kyr3Luopx8LMaUW..0429 DhNIlrh9MkSmQLRQs4QYGIeOQfWvd5RFNc3ExwkrMEzp2Tz5hX9GgrBoz9qh FL58QCboinkV2LKyKdZVhEtIfVQkAODj9OorPDSjFPAKyOgUvYSK9xmF1rco Hu3Zf0YyZYMPom2bMMrTfviWKsQLqvxqNV9Z8yH8eHrAyhyjD_ljONqJvbc7 3J9y666H8ROrEPeZDtCisgZsFq2p3P2pHWxFdHzsDelW5FyFd From: Tokunori Ikegami To: Boris Brezillon Subject: [RESEND v4 04/11] mtd: cfi_cmdset_0002: Call xip_enable() once only in do_write_buffer(). Date: Tue, 5 Feb 2019 03:19:57 +0900 Message-Id: <20190204182004.29894-5-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> References: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190204_102012_310717_55E8A77D X-CRM114-Status: GOOD ( 10.73 ) 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.65 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 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 Mon Feb 4 18:19: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: 1036146 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="lmRFmlm2"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="WS8Cl8BK"; 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 43tbff1BJPz9s3l for ; Tue, 5 Feb 2019 05:22:50 +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=T224RpeRB9qFGaJG+rWgIAX156w1c3xpq88avggypCM=; b=lmRFmlm24nB9S3eI37q7HGHLGX llTV4pUErivbPJXPoCAI/69B79FN7eqRdN5ytnrS+Cyhg03AaTd1EntFVGLgYe51wmf4cdAc6R80J ibTDLXGF7OwA7UKxQ4JbUPxBFN8BPrRmEbMSeKZFu2nIwpYaxwIMpqWHt+6HletF+OStrj7/k8sur 2EQsIoahMl5djaU4jmV1wt1BJGdh1fr/Yt28G4+AjvtHJfC120eqbuq0oiudXsaeO8MG0rlZeyHV2 gGlTiYF7RgIxuYVK+9Nv4vsKrCW0QSL2NqzWTuaSDs9ztDmiBYHi6qK8r5IGY4NmRvC6IMFLMjfcW REYX9cFA==; 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 1gqitI-0008A7-8A; Mon, 04 Feb 2019 18:22:44 +0000 Received: from nh503-vm8.bullet.mail.kks.yahoo.co.jp ([183.79.56.194]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gqiqq-0005jG-SU for linux-mtd@lists.infradead.org; Mon, 04 Feb 2019 18:20:24 +0000 Received: from [183.79.100.138] by nh503.bullet.mail.kks.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:11 -0000 Received: from [183.79.100.134] by t501.bullet.mail.kks.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:11 -0000 Received: from [127.0.0.1] by omp503.mail.kks.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:11 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 137341.85057.bm@omp503.mail.kks.yahoo.co.jp Received: (qmail 42048 invoked by alias); 4 Feb 2019 18:20:10 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549304410; bh=EI0eqf1hIccwOuuRqTXviSc3NLAFbx2J8Ofx9+0L2vA=; 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=WS8Cl8BKeolM7rks9D+qe2onSXDqOasI7JtLDCVf2dJAyFtxb6Pa+jOWteX/7mrS7POQ+ZVidzgKA4Pg11nUSe0ynz4PEtGHrZV7T1CUiHCrrcWwfnccPCki08ozenoFQCvmvCDgp880zhbXBf5fnucTuU8QNJpYEGolL8/AWeA= 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=Y3YXnYUuBccXNerJvZaBsNxxvt7crLhHFsucGY3R/HOs6fvT+BxCjsfIFcaibNIwSfIl0OmJzfNCEXG+eVTn+9WoWw2TfgMytGrOHBanOJAV4sgfT4lGOQHBN1OITiDH1y4oCtUHZL1WO8kelIPnJSOAKU1cTW8TqJHZmkN99r8= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp6006.mail.ssk.ynwp.yahoo.co.jp with SMTP; 4 Feb 2019 18:20:10 -0000 X-YMail-JAS: RtmTJv4VM1nf4e1VQbHkp6qLbY3vmJfj2fQcSHUA6LwkhM0t8SSb3SEydt.pAJACsRifURPlY1qCnOBSvB0SgsGtVzi84vrE_PmGnKo9wUGOvfON2dnbHkpjohPTJdxxEBtG_texLw-- X-Apparently-From: X-YMail-OSG: WsVw0DwVM1mVpiHDhhdB5.ntpejrpirs_vOzkiWjUPFQ8pa SNZ7uKUN4FWOY2IJmC25O1f9DU0EJvt4CdPngKx3l0ROMLXCz9W_jTluANtr MTrysbILBTMxk5OoTmT_txOIBalfSXmEOfx5Oh7bArot17NUw4Shzs6FRcrW 7c4vAYQPimPV6rUFqDig03h.FEQFpEH.T8xGP26Z8NHMFAMemgPYUvCeO903 dkgwVcLylrtej6XrZLrJcnuh.rbWj_m0p1zKoXxOi2y1Oh8FWR7HTfWXMGGD MyyzJh3dNx73XH.B8STUPI1KXH2eoi0JSbJwB3a.0mGPiA5qzeVkjQdc07Ib htjy6NvMp_n7p9R2ReLCk29OrJCaE7nVUgLseYo7vokP4p4iy0nD0U6WaqQU 6o2B5NXYjFTikTgVYh.i0Rqwod8kYWtNePWH_6r08EO.V2QUo_UeTTKcj8iM f_ZXhe7Lmgt4h.LmuOtFdtJkf7Yb4Z.prv8rrQ0d.yK9wpjpPLMvnTLwt5di l15y00.6wzVx9yq.8Y4XQOmP0sS.CY8x3Lc7havpkLFXzy8Xc2g7Vnx33e9x V8tpnDWdTd76xqvXsxfb2ZIJFD7PPHYf9Bxu6AcOS_nE.obM- From: Tokunori Ikegami To: Boris Brezillon Subject: [RESEND v4 05/11] mtd: cfi_cmdset_0002: Split do_write_oneword() to reduce function size Date: Tue, 5 Feb 2019 03:19:58 +0900 Message-Id: <20190204182004.29894-6-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> References: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190204_102013_195750_46BDF64F X-CRM114-Status: GOOD ( 15.56 ) 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.194 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 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 Mon Feb 4 18:19: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: 1036141 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="lxh5rBUw"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="nIoBtCia"; 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 43tbdJ2GMVz9s3l for ; Tue, 5 Feb 2019 05:21:40 +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=iHd8+8Y0rm3HJy97fFufwWHu+2stElXv+xNs+yF2bQ0=; b=lxh5rBUwxlrI5dtEfjG395Uoi9 YJfPwQL9UrDa/xXxS8DeNqaubS9nLtDGaFDVO6SbN0xp/LKl2ucKH7qMcqPzlmTuH5SxiQ5Ond/95 D6RJm9PRGDCXynOl6P1VAzmUsm2HfcK57j/oBc/oQ/57ImHuvC/eIwCVb0E4dxcwG16mfUFu/Pt+b JgiN/2wvp4rbdnq+ZIdOcfzb+G4XYOZx7O+X6xLJaOyQR/muMF6GwdDXpAtuptYv3k/kgh61J5dwO wv6msiYuQrKW/jxQ+C9kGuac0ZoRE0hkOaOuodu6hZtXgAFAwRbkjgWXZMUVwejGvhPmV9P7tp+Cz nEdpleCg==; 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 1gqisA-00070k-7b; Mon, 04 Feb 2019 18:21:34 +0000 Received: from nh604-vm4.bullet.mail.ssk.yahoo.co.jp ([182.22.90.61]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gqiqq-0005jC-Mt for linux-mtd@lists.infradead.org; Mon, 04 Feb 2019 18:20:19 +0000 Received: from [182.22.66.105] by nh604.bullet.mail.ssk.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:11 -0000 Received: from [182.22.91.205] by t603.bullet.mail.ssk.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:11 -0000 Received: from [127.0.0.1] by omp608.mail.ssk.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:11 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 233328.12694.bm@omp608.mail.ssk.yahoo.co.jp Received: (qmail 42056 invoked by alias); 4 Feb 2019 18:20:11 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549304411; bh=shtsQhD3oYmF9HMNqb67lol2o2CH8/cQt3N1PAUo3ak=; 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=nIoBtCiaX/kd0ok5VBwG3TrHxcfnax1a5GUg6nVsnmb/oBOEZLWcbmEuRzbpVqrZN6bVszSL/c9+wb65u6CGlK4EW/hcqfv6OazxgHJC6390LoIRM/293G5BDZgobD1uNdTHPLnoGlCv/dpMZ31P4UySa0Q9m3bmNulpPjWpV8I= 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=UJ1eEUWVE+5cGMvmXzBNG2PmUAxDwVBXcFWJ3DrTntcb4YY9WTd0hKGF0VSF7iMzpMDqM8yYTGAOvCUCmNEsg21MhO9LXMC0X6gC2lZrX5jEskal5DF9ESCVvo/mFssxWtM9LwXbehsZVS/6AutC2swa/H8L09EybhyCdsHmYWI= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp6006.mail.ssk.ynwp.yahoo.co.jp with SMTP; 4 Feb 2019 18:20:11 -0000 X-YMail-JAS: UzMMa0gVM1mWms_LOl6Zur2Kd7FJjO1dtmucjlx3VPnMFohZJJBpwhNNUTjtyGrQseGx1dZo8LzS7fTtRmDluG09.qhgo2f9LTFydxl.SWHc81Q70xOwwE0gppefZq0Zj2Ljfj2Mrg-- X-Apparently-From: X-YMail-OSG: sK7BeE8VM1klF_BIeam3qj.Aguu9mgfQuMc7MCrG0qMtics i85LlqMb0HvIfWAwdsbcxa6wK3YR7FiP7A8aaCZZvH9uHS4SEp1ibbCpnXiW kn0bA0ySt9ruI5jW1YT4tFuW51wxSGjJ6sL8TioHSHP_2StiiUcftwJZ8ohl eRJebL5bIB46hKF7nhEfj7C.6OA6tlJHoH7AKIUp7IF2EwRvbfvsJmaaEs03 E_zS9ioRrKMrRHUpIVj7IC5mwTagdnnO9b4U6dgZVx.GYlpb_SBOHM5PQnu_ tjO_.NlbgO3mk1phwP7niisXrQ4ytEDESMK4iDTgWHtr8ctB5xfNNFMPWPQy eDZywCojjR4V5KG31aOPldHG_q5U.oy2m5kbuKT0yNUFJl9LPO6DJbvlpxCN iOmGyLQuTDYxYWhNMjgxz_BYPMDEAg06F4VLa8nnH4ZY4JgUaADT6GqQCo41 WMT1OK.h34GyoxpqvydcA8gaqc.txkj7hYGykayM8QzJFNP.cr4Euq1Cbuke CXLqnld68I.hsFVfaPs.hf5w8IlNFAEpf_vZ_.RQNPIFK4jeV.nmYHWA8Ye0 6wMtLIiBSlPcSbeyYPf2qSrhbtp8JETTlsq0cKwmPOzkdjb1R From: Tokunori Ikegami To: Boris Brezillon Subject: [RESEND v4 06/11] mtd: cfi_cmdset_0002: Split do_write_oneword() op_done goto statement Date: Tue, 5 Feb 2019 03:19:59 +0900 Message-Id: <20190204182004.29894-7-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> References: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190204_102012_996704_C0DA1B43 X-CRM114-Status: GOOD ( 13.98 ) 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.61 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 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 Mon Feb 4 18:20:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tokunori Ikegami X-Patchwork-Id: 1036138 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="GYiojIsL"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="G9KDjWJ7"; 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 43tbcW5YT4z9s3l for ; Tue, 5 Feb 2019 05:20:59 +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=62vWV55eIaXbWwMap0aAbw/NtfqgumINyW2d5okrl/A=; b=GYiojIsLO4hqUG/QLlYMK9FsA1 FJXuwt9jthyxlr+bPnQc24oVU9OJoswmPw7OjtbkUFT28ZyAIJyRt/XZC59jzpKzAwmxIx2rJf9pk LnqPTdkkW3APZ4mILgLQs9vS2inU9XxNI7CNgoqQVhBRnwhkUgx5tsFA8QT1mXJvxjcAjYBn/Ldi1 W4jiVaeCI3vTp70UNiTH8QqYfm16VImi0KQz2M3NjLpI5EuQQmVAyV1TVDCDA7fcTt9kcZJmS4kob QvSqdaHDOZCAyl6APtzuMGQyc1y4sAERphrBLopLFBS1qXn8TRqRhP+hhf8x0TzDuFZQOWSoKmYXg OiDfo3jw==; 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 1gqirU-0006N0-V6; Mon, 04 Feb 2019 18:20:53 +0000 Received: from nh503-vm13.bullet.mail.kks.yahoo.co.jp ([183.79.56.199]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gqiqq-0005jH-BX for linux-mtd@lists.infradead.org; Mon, 04 Feb 2019 18:20:15 +0000 Received: from [183.79.100.141] by nh503.bullet.mail.kks.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:11 -0000 Received: from [183.79.101.123] by t504.bullet.mail.kks.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:11 -0000 Received: from [127.0.0.1] by omp510.mail.kks.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:11 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 614937.98491.bm@omp510.mail.kks.yahoo.co.jp Received: (qmail 42064 invoked by alias); 4 Feb 2019 18:20:11 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549304411; bh=EdCtHefv6XFBS3rj7pMB9qT5mf2Y1Nhoy3G/fIisQhY=; 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=G9KDjWJ7hO/EM6LcbE3ueHIHP0EFSxAwzEr3K1LlyoN2FY6ZndyCRj+zYt0DCMWZd0o9P6VSc/Wt/lwXLVxyKoFrr+T9nLCQxrb/7fDJW3Tj1Eh5ROcUu6zH0xffxdio0X+PmcVn2dRoT/3DA39wpcuLqQuDOe6FtYJH2kEL8J8= 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=pNOSn+LdSiAXILeRnk9p/t0o6I76jGiEF4QyC530eGpSXwbLYoQD05xZISzPKTzPeDZ6uiLhWJRJ+XgbfK/52qMTlzc7GZbQqFMQVMg8tRayORearxSxjNwt0cMmZI0aMml8ryA02EFy1wdaSQOElxEX4NVGKLAa2AbdGVYA10s= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp6006.mail.ssk.ynwp.yahoo.co.jp with SMTP; 4 Feb 2019 18:20:11 -0000 X-YMail-JAS: UzMMa0gVM1mWms_LOl6Zur2Kd7FJjO1dtmucjlx3VPnMFohZJJBpwhNNUTjtyGrQseGx1dZo8LzS7fTtRmDluG09.qhgo2f9LTFydxl.SWHc81Q70xOwwE0gppefZq0Zj2Ljfj2Mrg-- X-Apparently-From: X-YMail-OSG: VAwVneIVM1k1rjsgZo7yZ6FUsYz8_pgRltX6u2C8e3_ekK6 vIKhzaGxxdpR68T0Rvrh9hcFo0gvQtY7RX6F4.JpoLPChCDvIhNFbf62GYuG ndL2fbx0N4ijxjI_mIU5w8TBPcAXFs2ydo6mb1K4WZN6n8whUgTo_Hl.lKcq dtC3WlWMcXBSUWAf35sH5UwYU2rINNig6lE8UFfQB_OelW7vaoIhAgiBcG7m 7r11tK0wAkIly1aV8TTHYO2jejS5T85gfg8mGIftQDEMxndHDTwRrmi2fr9F aBfbX.Evu4OZrbFxgyCwylYxdS..C5kI_ad4KzoAsbHtMiqHEJoRRBca.2AK rJfL_94V.jPDTum40tsLPRkBtoRKAb9fF986bpjxpzvMzT7_LwlK_zK5hT7L Ryn2ggdElC9dusWUaDs4nPoqCaIKU0YD7ECvAqhmMCoWXB88G6l8TdPyoOcN XwOYJWDgjhkTKXTe9gfqBtQ9ttL.3TNV2nJlV4PIJcyReXfDkmiixfz4jgNr MsQB0JEIYty00eBXYKha_xMwQQS1Fhj0L.DFOtFZ4f95m078.WuqG_9VFksj SB2fccTjgkDijyASAfw.aEN9wAV_854fsVVyFGYmQ4fB2V5VP From: Tokunori Ikegami To: Boris Brezillon Subject: [RESEND v4 07/11] mtd: cfi_cmdset_0002: Remove op_done goto statement from do_write_oneword() Date: Tue, 5 Feb 2019 03:20:00 +0900 Message-Id: <20190204182004.29894-8-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> References: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190204_102012_661933_232CD8B3 X-CRM114-Status: GOOD ( 10.58 ) 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.199 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 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 Mon Feb 4 18:20:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tokunori Ikegami X-Patchwork-Id: 1036142 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="nhd1u6jI"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="PMXzDYbR"; 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 43tbdY6vCcz9s3l for ; Tue, 5 Feb 2019 05:21:53 +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=VotfOjfugFc0Sa2oWQ+RRDTPF3R54bGIPU+Z83QZTU8=; b=nhd1u6jIOKpa6fmC+KL2Wmc7AN QdUPGahXa8f1xe5v0pokqJbZK2ejOkcVbIgXrA8R+gDLkR5+l/wb0GwEmcckzeLq+6Juj0JMo3dwN xRNLXPfKdFBtOjdiWQXTW+HQNkdGYFneMxAP0fjPPcaiTB/8s7s7vAa16j6W98IdgJt/UfRv/3SgO 7suEX6nwC8MJBZJjwDqJYn8i9btJkp1bUdJkfXa19z7wqy28gQstluajg88s2uFxTbOvKxQQm30kY XanN/KvR1mJ/ZQ8nBBaOZsjThGde/ReEBCN5lRziqK7efzCNfMu4tv9OxnIRIvi6useGm7B5/jzLG Sxz8Peaw==; 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 1gqisN-0007DX-DP; Mon, 04 Feb 2019 18:21:47 +0000 Received: from nh504-vm5.bullet.mail.kks.yahoo.co.jp ([183.79.57.91]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gqiqr-0005ji-96 for linux-mtd@lists.infradead.org; Mon, 04 Feb 2019 18:20:20 +0000 Received: from [183.79.100.141] by nh504.bullet.mail.kks.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:11 -0000 Received: from [183.79.100.133] by t504.bullet.mail.kks.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:11 -0000 Received: from [127.0.0.1] by omp502.mail.kks.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:11 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 822749.50557.bm@omp502.mail.kks.yahoo.co.jp Received: (qmail 42072 invoked by alias); 4 Feb 2019 18:20:11 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549304411; bh=StDNXym23Q4WfgxqsEOFINQwiU0ybYur7zq13ywG4LQ=; 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=PMXzDYbRtNnOgDAVKQmHeemLykUuCTskoQFSFzAf4Bd8MmJdFSuSbVvfzSnT/hMn8jx/TmH1tvlLZBK9o0huAl7W1hbA0E0JJsCxzBMjaJQv2SMkoPTaisIT4ChWV3FUWfa92pa0rRvZfU9C/kETqnmFaOLujAXrIULHZP+iqLg= 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=hwkoN7Wla5f4scbPIZdCknuy57PYNB6pptoKXz4g5gLGGQpMev8mL0BmZ57saZ02+NFXpl1/pNq3R51Ix1hs2flqMS7hEu0LR/qE2sZmI14fAMGoybRjCCgScuCRBFWMc/ERzMVbXr8KcO/8L17FzY5hBCmsSmZrovVmtvL0l9I= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp6006.mail.ssk.ynwp.yahoo.co.jp with SMTP; 4 Feb 2019 18:20:11 -0000 X-YMail-JAS: UzMMa0gVM1mWms_LOl6Zur2Kd7FJjO1dtmucjlx3VPnMFohZJJBpwhNNUTjtyGrQseGx1dZo8LzS7fTtRmDluG09.qhgo2f9LTFydxl.SWHc81Q70xOwwE0gppefZq0Zj2Ljfj2Mrg-- X-Apparently-From: X-YMail-OSG: PjQbz0QVM1n6ML7JjDNhqQuBZ784vF11_HI3JlNhtmItCyK uvwbzaxJbbcsOo0F96OVj_.RiF5h.1SCYKT5lsaaJwytMz_hdFQDIpkbs7BU Agw8uSoZU5trwlf_s6XdNPi5sntJjQFPfNjxt22BdP.3Fb5WJIEO2lbOoKDb D4eMzZVrEI.efbIHpFo2touVDCbE9c9pg.IIBjWtnkYtJc.7PFglDSdxIYNy 1uQEUo7rLNylHYQ3Pz.oD5dnA7cWnBETcFq_aPtMVbGIKlSwBw4sxDj7fxGM stJj9I2DcYXPhHnRZCzzn9IuO1rOEXkIv.DgZ3n9esYtSze23dInVTdx.gxh LzmMOAT2kZ7mOfHZCXhqNBhpnIuz7dG9KLNzbBS0dvYF6tgW9Z7TNmrryi9j JZYwlyOrfXQAWom2obBGjX8UJm0u19LtNF.td7x.dEfyrVktfike3PiITsuf lI5VmP7kkMgFc8hBJJ5nfVY0_WMGFtvyvf7n2BHus5wCbhBeDoE.0egSYWUE cdnqXblLpjSjvrTK4JeR3Nw42a7wCugQG_U3QSSMPJ7Ir3t5z0ULLcv4J6v8 .Jm6L9.1oX86uI1m1tJVEZ_Rl3bIMM4S8DrNb5Im2YFEZ3yyQ From: Tokunori Ikegami To: Boris Brezillon Subject: [RESEND v4 08/11] mtd: cfi_cmdset_0002: Remove retry goto statement from do_write_oneword() Date: Tue, 5 Feb 2019 03:20:01 +0900 Message-Id: <20190204182004.29894-9-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> References: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190204_102013_791673_9D4180A7 X-CRM114-Status: GOOD ( 11.13 ) 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.91 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 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 Mon Feb 4 18:20:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tokunori Ikegami X-Patchwork-Id: 1036144 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="cmigr6Ap"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="VRzdI0Fx"; 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 43tbf75QDtz9sDr for ; Tue, 5 Feb 2019 05:22:23 +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=u8nsNlSOw2HD3YosuJSUrOkf/cxsTF8CklGdyE7DamQ=; b=cmigr6Apn0+IogI+H/E+ZhXyhL CLZdLsElNJq7zilPs7OLZtUvD/JNmWeziDzUMikshsjDaldf5UxDM6C/2ejwI1YlRjyEH81NQ1+U6 F3d6ZngehwcMhRFGgz9cF88q6/uVmec/kjfiXNhhTiqPufEIInPQvp7Hw5ia7QJHXXakUXiglktt/ rO3aiz8WukIPlIUoxIEt4EjMqv+EVBzLuSCZkEFiLrH01RLkFakyNmSwHzqVq0iEL1ZV7spwDdpyg zcsJdVFFnnaRBDesjqUPENBqt6wjGswccJ09iCl7W9ari0oqvmqc/TM8uQobrBxuNV2AZChw6DEZb 49l4fTQQ==; 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 1gqisp-0007eH-5C; Mon, 04 Feb 2019 18:22:15 +0000 Received: from nh501-vm2.bullet.mail.kks.yahoo.co.jp ([183.79.56.132]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gqiqs-0005k9-3y for linux-mtd@lists.infradead.org; Mon, 04 Feb 2019 18:20:26 +0000 Received: from [183.79.100.139] by nh501.bullet.mail.kks.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:12 -0000 Received: from [183.79.101.120] by t502.bullet.mail.kks.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:12 -0000 Received: from [127.0.0.1] by omp507.mail.kks.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:12 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 116496.18248.bm@omp507.mail.kks.yahoo.co.jp Received: (qmail 42082 invoked by alias); 4 Feb 2019 18:20:11 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549304411; bh=BadGgwCfMX3MjWz1WsInKqpgqXFex3PoMwLLq1FQe1M=; 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=VRzdI0FxjZ4ywM83J2cNrcaryuz8WhUXyMjCWAGiZ1bJvPxBHII+FqmzLf3ETSdekeQ6zuNxUJ1C2uyIEMfPr7BJ6/LDpjS2t8U3ES+y9aqdC72cjqk+8Y4zA/FMezrbmqkkife8Sguh6+91+88RmztXI5F2W0XYnlCx2k7SU7Y= 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=WVM7OTpywIh29HJiB2xCtb0Qa2gpfxnTDs5/bGZzDYerWJ1xbXqgwIHAUgD26vWuGFdd63tYOu1C8fXTHRFRQsBKBo0JbKB2jX5vZY+4OPKu0TryvHuVboODMDtmE7/aoMmwxpSJiHabF61r7x5rn6cDfyCfGpCtpBI6P5xa2fA= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp6006.mail.ssk.ynwp.yahoo.co.jp with SMTP; 4 Feb 2019 18:20:11 -0000 X-YMail-JAS: UzMMa0gVM1mWms_LOl6Zur2Kd7FJjO1dtmucjlx3VPnMFohZJJBpwhNNUTjtyGrQseGx1dZo8LzS7fTtRmDluG09.qhgo2f9LTFydxl.SWHc81Q70xOwwE0gppefZq0Zj2Ljfj2Mrg-- X-Apparently-From: X-YMail-OSG: 2go2.BEVM1lnC4.UyTpBnLrLSWgKx4570eLPxCtx1fX9Z5L EG1JJw84nykuyhhX6rhB7PmLhrsZEjldci_nR9go_74PEvd9cI6kfkTa34pH 6aElIZ60sfKYwk9uDbvZ2AMF2cjTEn_gafg62i9nxQa.WZ1cvhxDH3a1kTjk rS3knGDRKUT3QvwP91RFMOv.1rM9shrg1d3.Pel7uDfDgplWAVon0XY_9.x9 bP_DnC7XFYP7zse3HzuV4CKsgrSKpHehZK4G7FbC_zaoCWvDRifjvQu6pg6r 0ecpDqTpgwoXBLAP.R2uOTzaL7wGYvTqncdUsqhqpJDnPXbixDFKt.DSRmFa Lt6xYJv0gH_RFeKiAQDM5nRkeuyQ5wddCMVtSv7xsYTyBQp8vSm9inLpAPxZ q4IqyskrT2M6kou5xiWKiEqSQFzxSSoZG89eBURm.GkqvCDlpKyomEOx_tDO J8yXr8PbBzY74kL.Hoyi79lP_9TjWhSp9egfYTB33KyD90HFsqxXY6ikRVWy m7fRTUUWRnneTzzhffI1iZRqnU0pC0cM2a8VVEqGfPQUAsCQrKq8QHuFaoKt cXuIXI._tMxeCdAQbN4XqYCOrM9Tdx9KacFVPo5cAwaXZbWlL From: Tokunori Ikegami To: Boris Brezillon Subject: [RESEND v4 09/11] mtd: cfi_cmdset_0002: Split write-to-buffer-reset sequence Date: Tue, 5 Feb 2019 03:20:02 +0900 Message-Id: <20190204182004.29894-10-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> References: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190204_102014_620006_17DF9AFC X-CRM114-Status: GOOD ( 12.46 ) 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.132 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 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 Mon Feb 4 18:20:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tokunori Ikegami X-Patchwork-Id: 1036145 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="cI6ofGhw"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="ghpTopxh"; 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 43tbfN0Vbtz9s3l for ; Tue, 5 Feb 2019 05:22:36 +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=Y11XCwuCkftQWrw4TKpVYY4x2rNlJf2Q2zFnS0mJxCY=; b=cI6ofGhwZW688Z2G4/4wZsYeKU 7KQzziP15H0fTvsb710gxaCjRJPJtOFcqUF1Awssf5K+fxZ9rA1LN3P5PVVRgiRE4O3usCoYDYDmC UxFTo3FD/dt7b2h9Cw8s1FhYu/3ZWcAk9AwmYNo+lBFaCCJd9ZhyLzBD5nUCkLw6ghrMRQ3Kr54o4 nstTf6br+IgO7k18HkLv0uLWIiZ0uhr6pNJ11UbhnQ1KLklqoFMlpjkxXDi/TNoJrHjY6ukSuSYZy ObdBH9R5oaNQKtGnrpbeZkrd+bney14JLRdl9/l0MrRFUWOUUo31CH36w9JOBKkcTcRBtD4PsdLYq cTIGvNgg==; 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 1gqit3-0007wu-9W; Mon, 04 Feb 2019 18:22:29 +0000 Received: from nh601-vm9.bullet.mail.ssk.yahoo.co.jp ([182.22.90.18]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gqiqr-0005hJ-L0 for linux-mtd@lists.infradead.org; Mon, 04 Feb 2019 18:20:25 +0000 Received: from [182.22.66.104] by nh601.bullet.mail.ssk.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:12 -0000 Received: from [182.22.91.206] by t602.bullet.mail.ssk.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:12 -0000 Received: from [127.0.0.1] by omp609.mail.ssk.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:12 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 312292.36526.bm@omp609.mail.ssk.yahoo.co.jp Received: (qmail 42092 invoked by alias); 4 Feb 2019 18:20:12 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549304412; bh=y8HG0B/ptt1aiNktBMHs1kKs2PfbqW2y3J0jNa4aB04=; 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=ghpTopxhmCaRuiYm5oBEfL4XckIovcOsQ+fuxKo7wYNr5NPMgZfImAAJALrV9aNRZFop1rAz4BSkwtAwmdR6eNuaOhxgD8t6mP3BDyFLyrTgTxYJ+WGQnnur9ZPphIs75q5XhafxehkS7RxUco2rWASbrDM92w8Z/59HD3yqNW0= 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=Moy+A+eMMLdgvht/dT/F+hhC2358y0anQ3KgKzqpOg77zIQ8bJZ7VOp9y8EWF/0t6I80QQ5tpNwiHZeJSMBKltJq3QXjAG7j/bWGnC1yMX2A73QXpWF5lciO8L5rrqIr7rq4sIrKC3sUo1wCHJ5K4N7FycTcF7hmQxVMsWZkZMQ= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp6006.mail.ssk.ynwp.yahoo.co.jp with SMTP; 4 Feb 2019 18:20:12 -0000 X-YMail-JAS: p9oCtvkVM1kVekpC3xOvNaXPAPSgZcVmvQp71RDkr_MBJi4ZN6gY9y..AHMl.tW8uvftk.I0.GsYn_ReLCWp5oOwWlwNw4dDjgoBHSFvdQQuROuKMHwIQ_Ot3WEDX9xWBcCyoGsP0Q-- X-Apparently-From: X-YMail-OSG: ZV9aKLQVM1mwByp9QicFvqGDGqmGOW4ala8rZIgIe447_Sb RZzAw68iQHUlLofaBUM85ndIJpEPYkY2vd4L2uQRwU8O2Q3E0kYaOZb2lSU4 FqZVjZN.K4.BqxAAzbBRpesmG.bLFD3mHIVAzfwvPgAlHKFueCIly3u8Ei_X k75UUQvuDTKfd_5_NkmLyx8TDdpDTrEHwCs_wKxgrKI8Goji3653ne2mmlbe 6CtAi4zO8XeW2L5wF0bo791IRpjGwkzkFsIPssoj8JAt1GV8XFOH0yc3uq4q MhN4pEgN220Mh0NTHtSdvNmOiRpQwwP3HzuzjXJs1EWGDpU9.3K1.PTuf11I LdZNhTj8gm4UjnQJKiymK2Eiu7ER1LFwxpxQztgAhMMrpxVBykds7kIQOWOK 8Z90ye7laYFqpugyBmhA_.R9dnD.YEfXxupuHiFZH_66Eoh_WxEVp5kRWLNG vG9Xozl59AeIaMq4Dr2oqPI4NvxZO7bTAuQrYeTzjPx1irzqW7VDi0O0B5cj 5td2qcelq.RQ7mxZYpbmArwmTqL9W8yQli0nbft2du0fJDPYHhvI4C2kn7cB MIbb4lgfShSzoxwXedpNJHI9pjTXvV5CrJ1x6uTpImPuZS7WX From: Tokunori Ikegami To: Boris Brezillon Subject: [RESEND v4 10/11] mtd: cfi_cmdset_0002: Split to wait write buffer to check if completed Date: Tue, 5 Feb 2019 03:20:03 +0900 Message-Id: <20190204182004.29894-11-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> References: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190204_102014_064149_E543404E X-CRM114-Status: GOOD ( 14.70 ) 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.18 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 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 Mon Feb 4 18:20:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tokunori Ikegami X-Patchwork-Id: 1036143 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="O6e1KRYK"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo.co.jp header.i=@yahoo.co.jp header.b="VasNLSKu"; 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 43tbdp55D2z9s3l for ; Tue, 5 Feb 2019 05:22:06 +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=FN16h+sWsVo5rtW/cNJvy/m/e55hs8svdjmvvkv1Ifc=; b=O6e1KRYKr61Q/MCUFTa63PrMeT wZOMMFWueRpXhWjqDZN5wheN4GZzTrjqOL9fDDPAUhWHMhEj4bIEUIM2O/OuN6OG35ddyD31IdYSk X6JxQ8mPM5fcH33J+q8y4lBNsH+csTi+tmFnXjdLWTWKBDM3A809vNELSPm/J1AjMvhHFBDZthLD/ mm2fM9P+tK6rtLbY6jjCRUSn5WTzCifvOJUsVkBymxBynXvVBVzV4fudoWhJvcvHuEdDMsvEcD+FS /C4xRguNvelBpR39HCkOX9VnmlmZelIJjEkLqkcb12JRMaDiIS4XCqLIiKFtpZSPXrHjMFWrnPKN+ e2UonZJQ==; 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 1gqisa-0007RY-UA; Mon, 04 Feb 2019 18:22:00 +0000 Received: from nh605-vm3.bullet.mail.ssk.yahoo.co.jp ([182.22.90.76]) by bombadil.infradead.org with smtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gqiqs-0005kN-Bv for linux-mtd@lists.infradead.org; Mon, 04 Feb 2019 18:20:25 +0000 Received: from [182.22.66.104] by nh605.bullet.mail.ssk.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:12 -0000 Received: from [182.22.91.128] by t602.bullet.mail.ssk.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:12 -0000 Received: from [127.0.0.1] by omp601.mail.ssk.yahoo.co.jp with NNFMP; 04 Feb 2019 18:20:12 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 731656.85735.bm@omp601.mail.ssk.yahoo.co.jp Received: (qmail 42100 invoked by alias); 4 Feb 2019 18:20:12 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1549304412; bh=Ctocki519CGWOKTh4AZPWW5e1p4OwWUFX64A4n6E9B4=; 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=VasNLSKuB2HR1XvGTB3jpTwqVdLAmfhWcELxKMUOpJc2Lk9c6fNYcxzh9oXTN0vur1e2uE4BzOK/YUjRv22exVfGClGB7pgQT2rpkZj0WKDFuBAr7leuXvboa0SolopLBT6VAY4KM49GP0e/DKzFca56o7DhoYzRcAW7siFWetg= 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=PlNXf4N/ck3aqGCN04kgmhr/YihgbbXs5yQppuhJowolvjWu8+Nz8ZFJE3HxfTXjY3NDqv4LSHmx7Cv4gNmUW6o/J/kOqeHcTN2XL8DHsRKnlfjxdiT3iVn1omnuK+hTRQZ5RrDp34wtzXpfuf0CYdEl3SwThtulGJNRn4qlZVo= ; Received: from unknown (HELO localhost.localdomain) (106.72.39.32 with login) by smtp6006.mail.ssk.ynwp.yahoo.co.jp with SMTP; 4 Feb 2019 18:20:12 -0000 X-YMail-JAS: p9oCtvkVM1kVekpC3xOvNaXPAPSgZcVmvQp71RDkr_MBJi4ZN6gY9y..AHMl.tW8uvftk.I0.GsYn_ReLCWp5oOwWlwNw4dDjgoBHSFvdQQuROuKMHwIQ_Ot3WEDX9xWBcCyoGsP0Q-- X-Apparently-From: X-YMail-OSG: 6ElaUk8VM1nhQStATUxxsUmTsZhffUJIpRBUO6U.G.ENfS8 oS2WDskfMm9A_cCTyR2Q44YY0IsPjKHarQz8jg2cyiMyYx0AEEwVzf2pTply UL.Mt30kOH4wMwjtsRM0NC.T3DdZVWv8CQVD6YG7yMzFgf2XBJEGyldf4397 WNwhcPn0MzqfqPSvf8j3nGHh9U7XeEGiOk.7JOH34e1.t0_oq4fNCwcMxSwo orp.VIop_cYYYMungsLFkS8Hite7B.lM2BgA9TCdV.CjnuzLl7ifkeS4SGDJ JwhHahb52nWO.fifoV1lrubW9Vtpm47QUL3_GjQQ0Wq7jUTxkmaj93g.W6Hk b_IVVOevrZAMDOU5ZX51vw2c6B68r4tTFQ8ITRkkriwdr8wdND8Tf.WuvP0M psul4FPlleNQC778I4fePoVYCLq3LDWfarNxdIN2RNitrUY2BaZTOMWjjP.t tfnFtSj6rJSK2tvf8kVbTf8tvoYnLam7sT0x2VwQvtohwBZX4vXMzQkbkW9T YSD9dkNplJVczgvGyOdnG27rIvrYtMtPxwR.8VfbiT2wnRYbiYEwzAs8pp1. ldmyePklyuQKReqoCq5xauT3ZqHL61c6vddBKc36yF5exBpql From: Tokunori Ikegami To: Boris Brezillon Subject: [RESEND v4 11/11] mtd: cfi_cmdset_0002: Split do_write_oneword() to reduce exit paths Date: Tue, 5 Feb 2019 03:20:04 +0900 Message-Id: <20190204182004.29894-12-ikegami_to@yahoo.co.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> References: <20190204182004.29894-1-ikegami_to@yahoo.co.jp> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190204_102014_900056_077F7C3D X-CRM114-Status: GOOD ( 13.46 ) 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.76 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [182.22.90.76 listed in wl.mailspike.net] 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 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;