Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754727AbbEKPUt (ORCPT ); Mon, 11 May 2015 11:20:49 -0400 Received: from skprod3.natinst.com ([130.164.80.24]:59667 "EHLO ni.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754582AbbEKPUo (ORCPT ); Mon, 11 May 2015 11:20:44 -0400 From: Ben Shelton To: dwmw2@infradead.org, computersforpeace@gmail.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, dedekind1@gmail.com, richard@nod.at Cc: Jeff Westfahl Subject: [PATCH 3/3] mtd: ubi: use 'max_bad_blocks' to compute bad_peb_limit Date: Mon, 11 May 2015 10:19:56 -0500 Message-Id: <1431357596-29959-4-git-send-email-ben.shelton@ni.com> X-Mailer: git-send-email 2.4.0 In-Reply-To: <1431357596-29959-1-git-send-email-ben.shelton@ni.com> References: <1431357596-29959-1-git-send-email-ben.shelton@ni.com> X-MIMETrack: Itemize by SMTP Server on US-AUS-MGWOut2/AUS/H/NIC(Release 8.5.3FP6|November 21, 2013) at 05/11/2015 10:20:10 AM, Serialize by Router on US-AUS-MGWOut2/AUS/H/NIC(Release 8.5.3FP6|November 21, 2013) at 05/11/2015 10:20:10 AM, Serialize complete at 05/11/2015 10:20:10 AM X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2015-05-11_03:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1525 Lines: 45 From: Jeff Westfahl Use the MTD function 'max_bad_blocks' to compute the UBI bad_peb_limit, if the function is implemented for an MTD and doesn't return an error. Currently, the UBIFS code computes the bad PEB limit based on the worst-case assumption that all the bad blocks could be in a single partition. However, there are cases in which this is too pessimistic, such as the case of an ONFI-compliant NAND device that specifies the maximum number of bad blocks per LUN. Signed-off-by: Jeff Westfahl --- drivers/mtd/ubi/build.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index b7f824d..eca8ca6 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -597,6 +597,16 @@ static int get_bad_peb_limit(const struct ubi_device *ubi, int max_beb_per1024) int limit, device_pebs; uint64_t device_size; + /* + * If the MTD provides a max_bad_blocks function, use that value. Fall + * back to max_beb_per1024 if that function returns an error. + */ + if (ubi->mtd->_max_bad_blocks) { + limit = ubi->mtd->_max_bad_blocks(ubi->mtd, 0, ubi->mtd->size); + if (limit > 0) + return limit; + } + if (!max_beb_per1024) return 0; -- 2.4.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/