From patchwork Fri Jun 30 05:46:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 106669 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1904822qge; Thu, 29 Jun 2017 22:47:29 -0700 (PDT) X-Received: by 10.99.95.70 with SMTP id t67mr19109601pgb.104.1498801649746; Thu, 29 Jun 2017 22:47:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498801649; cv=none; d=google.com; s=arc-20160816; b=puJ+ph8u7zrxpbfDOhue6Nt6w3gfsaAxJSrwpKHb9lD6jMEUUhrN99no5w6dANBAgQ FoFYKJWnAXhalsuNMJGlOUAUTB+BQlxcW9vVNxEcDRoQVIlnYafbh6rWwGbeoK41XcuK ekvZXaRNFoqZJ9bVCm/ZYVh0fxAl+y8fTBt93B5meH+V/ln/wJHKC/T5FE3FZcDemPCM aPNI/RXWMHsq2fZPryzCz0uHnFHRLBcEpqChbhPE+LxureNzeDVbVbR9zAtnu6b+ft1J fdRuQZvAePsu44OFg2QQoKOMPRl/AzeOFXgwyMEsI2vyAt6h+1Dkbb7311O92+yQcfH6 syjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=wicEyYw9JzmNpQanabgN3sSxgPtIrxn7Ux9/TFdua4U=; b=rqscQll8sq4oi6Um2PDmIEcqTSTxmR4gW7k50E2Fkap4ahO8k0k22L+PsfaB9MoHi3 2ghx6mlnAfVsAyQKwjojWnGEvFVZSSonPr61K8WV+Ux1JzrzfuyPAnM0xCxNMNmzvoir tjOFDuA4Y7EIvc+Kt2uNrhvInetaZegAZEpxA5zhfegGRjdtP0/JA+qe9eBaji1YXYPi PbLthCRW1jeKp/X8OJBHBQ/doHFeQ6A+r82WU6Ox9V3NFPSqHRjZTJ/Qd61TnKXLa4ni /r2L5+Ky8yMj5AOkvOftGXrby4ke5BV0yOQtWvwkaEEVY4OHiGvLjFRBuQUIimXVLqRd Lxdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=KqpLIiII; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m5si4519277pgj.463.2017.06.29.22.47.29; Thu, 29 Jun 2017 22:47:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=KqpLIiII; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751918AbdF3FrW (ORCPT + 6 others); Fri, 30 Jun 2017 01:47:22 -0400 Received: from mail-pg0-f50.google.com ([74.125.83.50]:36155 "EHLO mail-pg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752071AbdF3FrV (ORCPT ); Fri, 30 Jun 2017 01:47:21 -0400 Received: by mail-pg0-f50.google.com with SMTP id u62so58465658pgb.3 for ; Thu, 29 Jun 2017 22:47:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wicEyYw9JzmNpQanabgN3sSxgPtIrxn7Ux9/TFdua4U=; b=KqpLIiIIcP+AiNCmcUw4jLNJvvJRjuWpeQg5EoPunfQSwoVohD+gsbwJxqbDl1RUw8 NIBbCi7NVTgEasAqAK7lNayHLAPxHuxhkcEqEEsjo9+st6TFkQH+0JdoRSSF3/WhkaS/ iQNukXSItaq69cc7BRpzSXi7tPtNfYxp6GGik= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wicEyYw9JzmNpQanabgN3sSxgPtIrxn7Ux9/TFdua4U=; b=q6HjiCUxxjsQBSbQjGlxCJTyIdwOCBC5XDyqsPHAUokMXtzNukK7nXw57E3+q06Vhn +5m9MuYICzIzAfqZIMOen+h8LDgUupOOhAni6174Hx+F0M9jAHLIoNbHcjvyZMtg/4Wy QMIqfpZA9EpczSCqyBTzR5d/ur9K0wbuBmzGXAUPuyu9xPleP2lGUmGCIrj44LJhLZoy 4i6vbIrZ9w9EBrt7WqcsqOxavoaCxFfLiupn05IbUyTU55F6kjG/XT7emrSp4zOrcRh+ 6W9rW/jYLesOjFTL1001GqWRMgpYcXInfvnzuh0hhZFlOR7AxJYwGweFhH3AtcLe+MX7 QvFQ== X-Gm-Message-State: AKS2vOxv4o0G69kxCOQIpk2GkUOAOYZz8fLusr5lrrMtkFL7VCpzQz4v yRMPc68JGyRfJI2m X-Received: by 10.84.225.4 with SMTP id t4mr22806553plj.274.1498801640451; Thu, 29 Jun 2017 22:47:20 -0700 (PDT) Received: from localhost.localdomain ([106.51.129.233]) by smtp.gmail.com with ESMTPSA id a187sm11405550pgc.37.2017.06.29.22.47.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jun 2017 22:47:19 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Brian Norris Subject: [PATCH for-4.4 11/16] mtd: bcm47xxpart: don't fail because of bit-flips Date: Fri, 30 Jun 2017 11:16:35 +0530 Message-Id: <1498801600-20896-12-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498801600-20896-1-git-send-email-amit.pundir@linaro.org> References: <1498801600-20896-1-git-send-email-amit.pundir@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Rafał Miłecki commit 36bcc0c9c2bc8f56569cd735ba531a51358d7c2b upstream. Bit-flip errors may occur on NAND flashes and are harmless. Handle them gracefully as read content is still reliable and can be parsed. Signed-off-by: Rafał Miłecki Signed-off-by: Brian Norris Signed-off-by: Amit Pundir --- drivers/mtd/bcm47xxpart.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) -- 2.7.4 diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c index 546170a77466..9190057535e6 100644 --- a/drivers/mtd/bcm47xxpart.c +++ b/drivers/mtd/bcm47xxpart.c @@ -66,11 +66,13 @@ static const char *bcm47xxpart_trx_data_part_name(struct mtd_info *master, { uint32_t buf; size_t bytes_read; + int err; - if (mtd_read(master, offset, sizeof(buf), &bytes_read, - (uint8_t *)&buf) < 0) { - pr_err("mtd_read error while parsing (offset: 0x%X)!\n", - offset); + err = mtd_read(master, offset, sizeof(buf), &bytes_read, + (uint8_t *)&buf); + if (err && !mtd_is_bitflip(err)) { + pr_err("mtd_read error while parsing (offset: 0x%X): %d\n", + offset, err); goto out_default; } @@ -95,6 +97,7 @@ static int bcm47xxpart_parse(struct mtd_info *master, int trx_part = -1; int last_trx_part = -1; int possible_nvram_sizes[] = { 0x8000, 0xF000, 0x10000, }; + int err; /* * Some really old flashes (like AT45DB*) had smaller erasesize-s, but @@ -128,10 +131,11 @@ static int bcm47xxpart_parse(struct mtd_info *master, } /* Read beginning of the block */ - if (mtd_read(master, offset, BCM47XXPART_BYTES_TO_READ, - &bytes_read, (uint8_t *)buf) < 0) { - pr_err("mtd_read error while parsing (offset: 0x%X)!\n", - offset); + err = mtd_read(master, offset, BCM47XXPART_BYTES_TO_READ, + &bytes_read, (uint8_t *)buf); + if (err && !mtd_is_bitflip(err)) { + pr_err("mtd_read error while parsing (offset: 0x%X): %d\n", + offset, err); continue; } @@ -252,10 +256,11 @@ static int bcm47xxpart_parse(struct mtd_info *master, } /* Read middle of the block */ - if (mtd_read(master, offset + 0x8000, 0x4, - &bytes_read, (uint8_t *)buf) < 0) { - pr_err("mtd_read error while parsing (offset: 0x%X)!\n", - offset); + err = mtd_read(master, offset + 0x8000, 0x4, &bytes_read, + (uint8_t *)buf); + if (err && !mtd_is_bitflip(err)) { + pr_err("mtd_read error while parsing (offset: 0x%X): %d\n", + offset, err); continue; } @@ -275,10 +280,11 @@ static int bcm47xxpart_parse(struct mtd_info *master, } offset = master->size - possible_nvram_sizes[i]; - if (mtd_read(master, offset, 0x4, &bytes_read, - (uint8_t *)buf) < 0) { - pr_err("mtd_read error while reading at offset 0x%X!\n", - offset); + err = mtd_read(master, offset, 0x4, &bytes_read, + (uint8_t *)buf); + if (err && !mtd_is_bitflip(err)) { + pr_err("mtd_read error while reading (offset 0x%X): %d\n", + offset, err); continue; }