From patchwork Thu Feb 7 23:58:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Przemyslaw Sobon X-Patchwork-Id: 1038395 X-Patchwork-Delegate: vigneshr@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HFijk4Al"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=amazon.com header.i=@amazon.com header.b="cYRZ0v5d"; 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 43wZyM0VYQz9sML for ; Fri, 8 Feb 2019 10:58:18 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=6jYExiYiXFpoE+17tLkDnzF6H6rsFLnhDOenTc5tv5Y=; b=HFijk4Ald5aq6e Cx2myvF/NRix0hHHhXls8H8NuSnV4cRlMQFH6QhJFvO32JQn2VhqG2oK/8WkEl4LzzS3Yhb69Rwjb DfCyVID8/TM7tAtnVPbPwrvAuPrH0FeDQLSFu9BPTwvfXZNmSr7m9mambAAM613nM3nha+b8dS4g9 u0epfzrc7Yo0T8X/SW/kVtgWle7/5FDxGEIhges8ISTuexKJlTwow9YWpBnoWx6krypEx/vExBaI1 ZXtEjJ9gmoXj8j7k1DS9Xd3KzghkIrH4W9Ob3XdjDPw1NqvZNwhpAo9lBkprINw5PyjwLG63Q4PXI 3TLvGtGztl94EWYLqfRA==; 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 1grtYc-0006Uo-RI; Thu, 07 Feb 2019 23:58:14 +0000 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1grtYZ-0006UN-9z for linux-mtd@lists.infradead.org; Thu, 07 Feb 2019 23:58:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1549583891; x=1581119891; h=date:from:to:cc:subject:message-id:mime-version; bh=mnyf8p+HNXO+HAyAnTN+Ruco2QnGclwwxib3/x2rngQ=; b=cYRZ0v5dfvS7GOEqLLF64udIuzfHetMDGTRPPhhfoOXrDNNvlpx+jbyD PlN5Pra0SuEME0qSfqRYWvn+oUDnehpoTS5YdiI5MvhZRqFe0/AdCMOnB C8/M7WMGovO8/WPLBpZGIbEwPkr9htiJ8Lh63bBgboClktXgUyHINiIaP A=; X-IronPort-AV: E=Sophos;i="5.58,345,1544486400"; d="scan'208";a="781582587" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-2c-87a10be6.us-west-2.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 07 Feb 2019 23:58:09 +0000 Received: from EX13MTAUWB001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-2c-87a10be6.us-west-2.amazon.com (Postfix) with ESMTPS id B82C4A231D; Thu, 7 Feb 2019 23:58:08 +0000 (UTC) Received: from EX13D07UWB002.ant.amazon.com (10.43.161.131) by EX13MTAUWB001.ant.amazon.com (10.43.161.207) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 7 Feb 2019 23:58:08 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) by EX13D07UWB002.ant.amazon.com (10.43.161.131) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 7 Feb 2019 23:58:07 +0000 Received: from dev-dsk-psobon-2c-1dd9f399.us-west-2.amazon.com (172.22.49.115) by mail-relay.amazon.com (10.43.61.243) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 7 Feb 2019 23:58:06 +0000 Received: by dev-dsk-psobon-2c-1dd9f399.us-west-2.amazon.com (Postfix, from userid 5078557) id DAD1547151; Thu, 7 Feb 2019 23:58:06 +0000 (UTC) Date: Thu, 7 Feb 2019 23:58:06 +0000 From: Przemyslaw Sobon To: , , , , , , Subject: [PATCH] mtd: cfi: Fixed endless loop problem in CFI when value was written but corrupted. Message-ID: <20190207235806.GA39580@dev-dsk-psobon-2c-1dd9f399.us-west-2.amazon.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: Bulk X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190207_155811_410829_90D07F67 X-CRM114-Status: GOOD ( 11.86 ) X-Spam-Score: -10.0 (----------) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-10.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [207.171.190.10 listed in list.dnswl.org] -7.5 USER_IN_DEF_SPF_WL From: address is in the default SPF white-list -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_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: psobon@amazon.com Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Fixes: dfeae1073583(mtd: cfi_cmdset_0002: Change write buffer to check correct value) There was an endless loop in CFI Flash driver when a value was written incorrectly. In such case chip_ready returns true but chip_good returns false and we never get out of the loop. The solution was to break the loop in 2 cases, either device is ready or device is not ready and timeout elapsed. The correctness of the write is checked after the loop ended. That way we ensure the loop always ends. Signed-off-by: Przemyslaw Sobon Tested-by: Mark Tomlinson --- drivers/mtd/chips/cfi_cmdset_0002.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index 72428b6bfc47..6cc31d2057e9 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1879,15 +1879,18 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, 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 (chip_ready(map, adr)) + break; /* Latency issues. Drop the lock, wait a while and retry */ UDELAY(map, chip, adr, 1); } + if (chip_good(map, adr, datum)) { + xip_enable(map, chip, adr); + goto op_done; + } + /* * Recovery from write-buffer programming failures requires * the write-to-buffer-reset sequence. Since the last part