Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2025574imm; Tue, 10 Jul 2018 11:50:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe5/JXcJDP0cP/WXkv8FczNQ9F2UCNX+WFFpZdqs+XByLSLDadI7zRN3hYv0Sh0GEU81Fs3 X-Received: by 2002:a63:62c4:: with SMTP id w187-v6mr23635373pgb.55.1531248641110; Tue, 10 Jul 2018 11:50:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531248641; cv=none; d=google.com; s=arc-20160816; b=krmmReQsrU/61AsGERO63wvazFjMcB6VJo3UBHqP/uZS1/uwMfQt4QtkPbxWy1QY5J Z85EphKbZVv2TClbplU7rCuUREBmNqvRuVUR7LZZMw+A9VFqD3wcj3GAKqaIfZa6HLpk TcDXp5s1GJmB/lWIZ3J78/OIsb5iL4Gyq/P4/omGiq1BYcBzGicWmnWGlQe93JADeaG4 QVlf5qfWsyXvL8mKWTST/5TZlGMIAiiKbNrLzsBjBg2t6KM6N77il3YZB4jZB2NcHVz6 JVZ2rtM1yJqZc8HXNNt/EtucSSznjvEUgO82utJAbcaV6lyi+6gfgrS/iGDX30YAE5/M GgVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=7a5gJRKgSnz0hxkULL2TurVnPyG1zw4zAUUucTA8XF0=; b=iHF5ndqB0YiWq5WY1vMlA0uPOq3hqES7+P6ZMhorfOxBEezNQZV+56uowAbSArKSTJ izmSZ15rSxGRmEVsW7E/Dwg1HQI+OVrRgpJMZgQ2e0JjMWdo+Y3YudYt6sBulc3akGEp 0JGP1b8GXguz8VvNgbGSUg3SUFGdqIKUf4j4RHfhs5XPMiyT5O2EDH03PfKrEGJ+zQLC FBWhdvqPdhtVJ+wUXZFW6+o99MxSB2RkJONnLpWUT/0Yvxfdv/iMHK2FXgDWycHETgPv sZqDZx2RW+rYUGDRV01Fc+pNkXLh5bgPXmAqMUISj/UHEdM5Mn2eWIHuxhAbzoVssb23 YVKg== 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 z1-v6si16772170plo.516.2018.07.10.11.50.26; Tue, 10 Jul 2018 11:50:41 -0700 (PDT) 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 S2388340AbeGJSbW (ORCPT + 99 others); Tue, 10 Jul 2018 14:31:22 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45800 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732920AbeGJSbV (ORCPT ); Tue, 10 Jul 2018 14:31:21 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id AFDB8EC6; Tue, 10 Jul 2018 18:31:08 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tokunori Ikegami , Joakim Tjernlund , Chris Packham , Brian Norris , David Woodhouse , Boris Brezillon , Marek Vasut , Richard Weinberger , Cyrille Pitchen , linux-mtd@lists.infradead.org, Boris Brezillon Subject: [PATCH 4.9 49/52] mtd: cfi_cmdset_0002: Change erase functions to retry for error Date: Tue, 10 Jul 2018 20:25:17 +0200 Message-Id: <20180710182453.921642480@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180710182449.285532226@linuxfoundation.org> References: <20180710182449.285532226@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable 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 Cc: stable@vger.kernel.org Signed-off-by: Boris Brezillon Signed-off-by: Greg Kroah-Hartman --- 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 @@ -2237,6 +2237,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; @@ -2254,6 +2255,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); @@ -2308,6 +2310,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; } @@ -2327,6 +2332,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; @@ -2344,6 +2350,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); @@ -2401,6 +2408,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; }