Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3336237imu; Sun, 11 Nov 2018 12:39:18 -0800 (PST) X-Google-Smtp-Source: AJdET5czgDXVwfYedIprQpNBFH4IfBkHuGNb/v0I2jvWsQqxnRifD2akd30o7aizAhUroELD3eu0 X-Received: by 2002:a63:d547:: with SMTP id v7mr14848495pgi.339.1541968758243; Sun, 11 Nov 2018 12:39:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541968758; cv=none; d=google.com; s=arc-20160816; b=TWu0wXi/J3WLs3uH7LJC3/2ojk+O+FiWnjy6qMPIkQ6DxmWREreH7Z7ZNzVC6TYKXu EVLtbKFb9eHbiM4H7CeceKtYtf2oDon9yb5IolTP2A9lr6nPMhaJVAsexFNgdlfGxQzq xGZZdCLEWHM/JyXyTw+aGzt4gA9+2I+E4Mql1joVyspM9AEIXGorvFfl6SATBUkU06/q Ao8ygCT9zzhq49zZbMyG6a8dvYsNS3vtmjrnzXwatGj8Wmsvn/+SBH21qzj+9r9iJtc7 CCCYqcz3xUFkPmMrw4HlgdqFbQ9O7NjYuDBYwe4HiKZaXKCTuorAxtabsy3sgg6M+KXq NF3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=SiQpH2/+5RSSyJ+T9URpJe43Q0OjHWX5G01msjQ5LTI=; b=dQON8Id02VdEDLXH+cej/QlVJ8/X21R4LPfLTRI7Um/ZylwklxOxZmyKslliZ+R0vB 18ew2wKRAVVGUX54oYDYycucGMuUD26D6jYbfY6tgAOBMuXOQXlE01TEDkrYqSGsULpA sjc9aAmmWREEHdvuJaB3hp2MwjX75cUTqY5Cn1X7Kq18SL2QQnG84GPXwRbmujSZeu4H uqktVu3bNZh4rL22FrghCMlgYizJO07xfKCOiBd4Nt6v9vxdsFwoOmUYbVgoWvu14oEk W5IubeQRewuuJ5buMh88v8LfMWmVdOHu/dPRBvDycLO/GwMKCIJmCShONkJHD+KEGfMO 6lIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r14si4453167pgh.39.2018.11.11.12.39.03; Sun, 11 Nov 2018 12:39:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731708AbeKLG15 (ORCPT + 99 others); Mon, 12 Nov 2018 01:27:57 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:49614 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730012AbeKLFsJ (ORCPT ); Mon, 12 Nov 2018 00:48:09 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvsT-0000l4-Bp; Sun, 11 Nov 2018 19:58:37 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsQ-0001Ue-KL; Sun, 11 Nov 2018 19:58:34 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Boris Brezillon" , "Tokunori Ikegami" , linux-mtd@lists.infradead.org, "Marek Vasut" , "Boris Brezillon" , "Chris Packham" , "Brian Norris" , "Cyrille Pitchen" , "Joakim Tjernlund" , "David Woodhouse" , "Richard Weinberger" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 098/366] mtd: cfi_cmdset_0002: Change erase functions to retry for error In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Tokunori Ikegami commit 45f75b8a919a4255f52df454f1ffdee0e42443b2 upstream. For the word write functions it is retried for error. But it is not implemented to retry for the erase functions. To make sure for the erase functions change to retry as same. This is needed to prevent the flash erase error caused only once. It was caused by the error case of chip_good() in the do_erase_oneblock(). Also it was confirmed on the MACRONIX flash device MX29GL512FHT2I-11G. But the error issue behavior is not able to reproduce at this moment. The flash controller is parallel Flash interface integrated on BCM53003. Signed-off-by: Tokunori Ikegami Reviewed-by: Joakim Tjernlund Cc: Chris Packham Cc: Brian Norris Cc: David Woodhouse Cc: Boris Brezillon Cc: Marek Vasut Cc: Richard Weinberger Cc: Cyrille Pitchen Cc: linux-mtd@lists.infradead.org Signed-off-by: Boris Brezillon Signed-off-by: Ben Hutchings --- drivers/mtd/chips/cfi_cmdset_0002.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1900,6 +1900,7 @@ static int __xipram do_erase_chip(struct unsigned long int adr; DECLARE_WAITQUEUE(wait, current); int ret = 0; + int retry_cnt = 0; adr = cfi->addr_unlock1; @@ -1917,6 +1918,7 @@ static int __xipram do_erase_chip(struct 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(0x80, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); @@ -1971,6 +1973,9 @@ static int __xipram do_erase_chip(struct map_write( map, CMD(0xF0), chip->start ); /* FIXME - should have reset delay before continuing */ + if (++retry_cnt <= MAX_RETRIES) + goto retry; + ret = -EIO; } @@ -1990,6 +1995,7 @@ static int __xipram do_erase_oneblock(st unsigned long timeo = jiffies + HZ; DECLARE_WAITQUEUE(wait, current); int ret = 0; + int retry_cnt = 0; adr += chip->start; @@ -2007,6 +2013,7 @@ static int __xipram do_erase_oneblock(st 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(0x80, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); @@ -2064,6 +2071,9 @@ static int __xipram do_erase_oneblock(st map_write( map, CMD(0xF0), chip->start ); /* FIXME - should have reset delay before continuing */ + if (++retry_cnt <= MAX_RETRIES) + goto retry; + ret = -EIO; }