Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3336247imu; Sun, 11 Nov 2018 12:39:18 -0800 (PST) X-Google-Smtp-Source: AJdET5dWgoPqf4Q/IZZAoccNazsSYcDmElxiX8iA/DuCclvsArO2m3OQO55LY7NEf7tGM19PRHsH X-Received: by 2002:a65:5c81:: with SMTP id a1-v6mr14864231pgt.390.1541968758634; 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=tngrilrVc0ERyQDJnTbsYrPezrWW7+UTswHQ+UDT3osmP4DnC2Lt5UYD/TtmkzOGQO wAk4Qz7NltbHkT2puliPBLvEsiDuLZbrN9vm3zo4xjtSWY4PiIGHKuQYcN2nWO8tikBn VP0IoclW5N2e1hznaYfuLdqpbLBbM+HpBPDHb1fnK5UEZOKGan8IX0EVKznUTXdNO66V 21+8xTC4E5hZvAio4DsG2qFZYcmo/VLWro6+utlruHkLP6YEONqiJrskk4fUK6MDDf2b 5Y4G6KdsYY+FSDKe7yiM7jv0dlVQYcCE4j8dV3snhrDBYOVtMwyoB9R8wGE+N37ihTj+ E3hA== 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=/IPpRYjBJwSe4/8YIFmn/Ri6RRvV3ghdTO4SKDR4t2o=; b=xxAbefCPb55V7Bv80eIXij5mFKREGCoEl/JMko4NqM6K0Mi4vdppdakcNtleGWxdX4 GxTCYKr0z3snXPkBDJUi+Qtl1776htsFGPONxQsW53wZed7Dvm63IYBdRHeo5UAjXNme lpNaBDPsdziFue6qvlF9h2XNIHWXPD7TCCa616CZrWsH0j38tDBTNWaHCdQmmKXDiEUy Ccsmf8YapfJFe2FMpwjpA/fs6S3vpmk8EZCiYP6ta64jvWoew/GvT9xrwohUJJUOMzY4 NH7caqXnAJxqG+mYQUrtssdPtYT/lbvmwb0JSujMfiHXqoOSIFg69Au60ThBY2uzp/x0 6fPQ== 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 61-v6si16148046plz.40.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 S1731596AbeKLG14 (ORCPT + 99 others); Mon, 12 Nov 2018 01:27:56 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:49612 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730013AbeKLFsJ (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-0000l5-5w; Sun, 11 Nov 2018 19:58:37 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsQ-0001Ui-LS; 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, "Cyrille Pitchen" , "Marek Vasut" , "Boris Brezillon" , "Brian Norris" , "Chris Packham" , "Tokunori Ikegami" , linux-mtd@lists.infradead.org, "Boris Brezillon" , "Richard Weinberger" , "David Woodhouse" , "Joakim Tjernlund" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 099/366] mtd: cfi_cmdset_0002: Change erase functions to check chip good only 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 79ca484b613041ca223f74b34608bb6f5221724b upstream. Currently the functions use to check both chip ready and good. But the chip ready is not enough to check the operation status. So change this to check the chip good instead of this. About the retry functions to make sure the error handling remain it. 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 [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- drivers/mtd/chips/cfi_cmdset_0002.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1955,12 +1955,13 @@ static int __xipram do_erase_chip(struct chip->erase_suspended = 0; } - if (chip_ready(map, adr)) + if (chip_good(map, adr, map_word_ff(map))) break; if (time_after(jiffies, timeo)) { printk(KERN_WARNING "MTD %s(): software timeout\n", __func__ ); + ret = -EIO; break; } @@ -1968,15 +1969,15 @@ static int __xipram do_erase_chip(struct UDELAY(map, chip, adr, 1000000/HZ); } /* Did we succeed? */ - if (!chip_good(map, adr, map_word_ff(map))) { + 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; + } } chip->state = FL_READY; @@ -2050,7 +2051,7 @@ static int __xipram do_erase_oneblock(st chip->erase_suspended = 0; } - if (chip_ready(map, adr)) { + if (chip_good(map, adr, map_word_ff(map))) { xip_enable(map, chip, adr); break; } @@ -2059,6 +2060,7 @@ static int __xipram do_erase_oneblock(st xip_enable(map, chip, adr); printk(KERN_WARNING "MTD %s(): software timeout\n", __func__ ); + ret = -EIO; break; } @@ -2066,15 +2068,15 @@ static int __xipram do_erase_oneblock(st UDELAY(map, chip, adr, 1000000/HZ); } /* Did we succeed? */ - if (!chip_good(map, adr, map_word_ff(map))) { + 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; + } } chip->state = FL_READY;