From patchwork Wed Jan 16 00:32:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Przemyslaw Sobon X-Patchwork-Id: 1025566 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="Ide8dWf8"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=amazon.com header.i=@amazon.com header.b="MbK1h63Z"; 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 43fSpy3lHPz9sDn for ; Wed, 16 Jan 2019 11:32: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: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=FM/t/IlhwKTlMcCbUHHynwBNjCcBRvq+YE1/JfFI6HE=; b=Ide8dWf8gtOmu8 BLCgkec3MtB6e3hknIyrCEtaPseNUhMPvf8IRKCMKeniHECNWPQtLMUc3cQtgF/kl2y5DyU0Vqy82 miLHkjYUdem8vaP3vzrm3JbRrlBf+WUOo2vVAMoiAEP+JcMrzxydl0x0UEoeVQ9n8Ls4Lkl7PB1xD F0hqxdDhYgESURxUdM2gEqtbd/Susc8rfLO/CPaomMA8S9fOGhpbyPSh6quowFxTZS6iPBlbZDhMn wi3e4RMrtDfyc94t8W0idb2N7dFPkPOatQjVOszifgI+FDSuUrvqi57k8CTGgfU8e6AJJfbz8pOrd ag6tj3e1dbg2oC9MTowQ==; 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 1gjZ8P-0001F3-5X; Wed, 16 Jan 2019 00:32:45 +0000 Received: from smtp-fw-9101.amazon.com ([207.171.184.25]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gjZ8M-0001EZ-0D for linux-mtd@lists.infradead.org; Wed, 16 Jan 2019 00:32:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1547598761; x=1579134761; h=date:from:to:cc:subject:message-id:mime-version; bh=3jKBI1uip2uFeh+DXV3f2WZdDdDwxyDWfSk3VPMjKBE=; b=MbK1h63ZwiJcvgyQgi5KydKxQN/7rfg001JUKpCEZF0E1W16cBsGyJwD wB6LUvl/q1y4RuPajV8kTIkMe6ZVZvHNLgmAdnihHkp98wSCwOnMZO1il XlRQiCJNVwDQZ+J4lO/zYDvwILd1Gwpcd7TNI6tiVbWga6G3/J3WG9T2y 0=; X-IronPort-AV: E=Sophos;i="5.56,253,1539648000"; d="scan'208";a="781664947" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1a-821c648d.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 16 Jan 2019 00:32:17 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-821c648d.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id x0G0W8r9058143 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Wed, 16 Jan 2019 00:32:12 GMT Received: from EX13D07UWB003.ant.amazon.com (10.43.161.66) by EX13MTAUWB001.ant.amazon.com (10.43.161.207) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 16 Jan 2019 00:32:12 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX13D07UWB003.ant.amazon.com (10.43.161.66) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 16 Jan 2019 00:32:11 +0000 Received: from dev-dsk-psobon-2c-1dd9f399.us-west-2.amazon.com (172.22.49.115) by mail-relay.amazon.com (10.43.161.249) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Wed, 16 Jan 2019 00:32:11 +0000 Received: by dev-dsk-psobon-2c-1dd9f399.us-west-2.amazon.com (Postfix, from userid 5078557) id E94EC4741C; Wed, 16 Jan 2019 00:32:11 +0000 (UTC) Date: Wed, 16 Jan 2019 00:32:11 +0000 From: Przemyslaw Sobon To: David Woodhouse , Brian Norris , Marek Vasut , "Richard Weinberger" , Subject: [PATCH] mtd: cfi: Fixed endless loop problem in CFI when value was written but corrupted. Message-ID: <20190116003211.GA57460@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-20190115_163242_111396_A94F18E5 X-CRM114-Status: GOOD ( 14.32 ) X-Spam-Score: -13.5 (-------------) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-13.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [207.171.184.25 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_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 -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.8 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 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 --- 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