From patchwork Thu Oct 6 03:14:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikhail Kshevetskiy X-Patchwork-Id: 1686790 X-Patchwork-Delegate: dario.binacchi@amarulasolutions.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=iopsys.eu header.i=@iopsys.eu header.a=rsa-sha256 header.s=selector1 header.b=ObfsufjN; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Mjpnq5v9qz1yqm for ; Thu, 6 Oct 2022 22:17:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6D9F684C35; Thu, 6 Oct 2022 13:17:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=iopsys.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=iopsys.eu header.i=@iopsys.eu header.b="ObfsufjN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 01D1584D87; Thu, 6 Oct 2022 05:15:19 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2058.outbound.protection.outlook.com [40.107.22.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E4D4E84D8B for ; Thu, 6 Oct 2022 05:15:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=iopsys.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mikhail.kshevetskiy@iopsys.eu ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AAm6UAsE8KBLskFaIQ0YMasTfr+9NHRe4BJBVVTYHGjb4IO/4DFzbTbVdMN2inmEo2f7ZeGbmxOvS8c2S1nyVyVh0HE9rzkRpjiB2WBp2wBVOmYYsRQmIYEjkR9nj2Impr3QUEWTehlI4SLSI0ObgogGHoadioERYkPNJyc1AEngHRqYcpOpMbHs8SlXwufsJmFBGaxVsYP77/sNCGMkKdakdbnjEjtGiXoNi7GPxr5qaCyNIrwh2gpXHQwsph64pBjpygI9yZG++cceOIr5VrFy/l/8Ll8BKS/31+1Aite3lSYn6HejlxqKmen3mJU2uZuf7MokFwuMphjL+CxH8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JZrUwZIM8JvdShJdEWml7yc4aYYFtHocc9ju9EMeSvs=; b=JMv97YOc2giOYSIZ+FGzQwy75RVDgAT0eUxXpR22cpkFJ/W32d3vvsLxOnJJwu1vBH54R4hN2oVEDSw4ENRl5usUGfvh9BXX8Dh+01kjfJYQFeMpfRPsZHdVcNM87y42IAMw0Ioh8cFYK1xlHXIOUQO0WVoawxJCJAjBTADp4RttZu3dIUMbQYmu3py4P+vf2H7+hB9bH8JUBE2zsms44Pm6Yevx7yAtFH5M0Wy9cQjROpo5j7+COTlZxAam6lQzDrmyjlN8UFK8Cc2nNa4FY9aIKXS8/8R12AVLybSo4JlCnY0fejIcIx4Y/Z5Y0hT7Zbqwex9w9JOvnabpBL2MYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=iopsys.eu; dmarc=pass action=none header.from=iopsys.eu; dkim=pass header.d=iopsys.eu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iopsys.eu; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JZrUwZIM8JvdShJdEWml7yc4aYYFtHocc9ju9EMeSvs=; b=ObfsufjNfhUtbd/e719GGaCniAH3hbmsALh9p5G5wre8QKgXsZlgHsv2zs/NHm/31Vk2SxHoLFky0otonBIqtcJ3dw4ddfrdgjYvPEYu3F/sYuo/HHyaK/WwFRnMSpe9ajeWxPLgIz/NC+iyhvJqgGZeAKrJ2xqHCX1j9Lzc3PA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=iopsys.eu; Received: from PAXPR08MB6494.eurprd08.prod.outlook.com (2603:10a6:102:154::16) by DBBPR08MB6314.eurprd08.prod.outlook.com (2603:10a6:10:20f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24; Thu, 6 Oct 2022 03:15:11 +0000 Received: from PAXPR08MB6494.eurprd08.prod.outlook.com ([fe80::3c25:b934:e13d:d6bd]) by PAXPR08MB6494.eurprd08.prod.outlook.com ([fe80::3c25:b934:e13d:d6bd%5]) with mapi id 15.20.5676.032; Thu, 6 Oct 2022 03:15:11 +0000 From: mikhail.kshevetskiy@iopsys.eu To: u-boot@lists.denx.de Cc: Dario Binacchi , Michael Trimarchi , Stefan Roese , mikhail.kshevetskiy@iopsys.eu, agnau@iopsys.eu Subject: [PATCH 2/7] mtd/nand: try to erase bad blocks only if scrub flag is provided Date: Thu, 6 Oct 2022 06:14:57 +0300 Message-Id: <20221006031501.110290-2-mikhail.kshevetskiy@iopsys.eu> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221006031501.110290-1-mikhail.kshevetskiy@iopsys.eu> References: <20221006031501.110290-1-mikhail.kshevetskiy@iopsys.eu> X-ClientProxiedBy: GVX0EPF000013E1.SWEP280.PROD.OUTLOOK.COM (2603:10a6:144:1::22) To PAXPR08MB6494.eurprd08.prod.outlook.com (2603:10a6:102:154::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR08MB6494:EE_|DBBPR08MB6314:EE_ X-MS-Office365-Filtering-Correlation-Id: 939d5fd5-c8ac-4a30-735d-08daa748fa6f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QWF1VovRBXLDL/a6ddydET9ZKNnesyRwl1oboHqOS1kvI/1MO974kVMgIL+pKTjaqPCCuoatlxv7J/AhOm/n8oW9/dhInpyPd9yCOkuwOwL0KfDbWKo82Q/q3UJk4tZN50Txc6joNFAFwk5QRqN7lAs8fM7mMgQDaz83VarHHNOPsbm9yWDGLiiBpW+7jnPAgOkkxaSeipXOU3lpW4IppQuA8faakaMVNzTrqK27tWG5Ys3hMeWN8z/ejsO8FtO+Gj/+eKuvukA8Jjw23szVrbMZwLL6iIx8hfvzoBuvsi+JuAFwZRKmO9CbyekkAZNTK0naYMguLb61s8TWXzZKtG0nqh+hrVBBvA7qfV7oOjfkykcuRQ3v3svVBoRDi5jKuL3nyll+/86UK7UDaGDVAi2jgBorA6ccScTr/CgZEUKp0uLnDmruzUZbAAikhUdwFNL4pmcvXfNleu5ciVItl29Ki7y2Yx6Mga1IunFNHMjfKpRNTdhhP/GbuCvqnYe9tmARxpb0VTvu7JtCxW0n4COX7CJ3Xcl6o4KT9/c51muQ+Np7k9+5mhgkbIDv4830vS7UsuC+M2xoP7MLCN2/UV4COzYdn1FIgP22MHbVNsRVXF79mGxYzC2yIdu58YRrdlF7aA3kNDy9xM3JR/5zSnh2GBGANwBaxqvQlAr8f589vd7/hjxuUMP8QzMSzsVxqIkNzwgPP2XcQS041aD1f7Ti58QDwI/1t0T+T3hy8RgYDHg7fbHTaFQLwOYRYYCUF1sPvQzfbmV6I3iaLEs2cg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR08MB6494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(39840400004)(346002)(366004)(376002)(396003)(136003)(451199015)(6916009)(36756003)(54906003)(8936002)(41300700001)(66556008)(66946007)(316002)(66476007)(8676002)(86362001)(2906002)(4326008)(83380400001)(6666004)(107886003)(6486002)(5660300002)(186003)(52116002)(6506007)(26005)(1076003)(2616005)(478600001)(38100700002)(38350700002)(9686003)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Sa4hkLkLvlcrpxx9bQwlUqrzWB5w6nZev2pWtA66at9+0Q13l/hxNlCiJt3IPUm9iGBPcnlnGMhOYdlyB1RfYBPSMJatKUleNTal9P1YSlz3v5J8l06viGaCNMW9Z9+eEU7s+RjA1kZz0ova6ezWRQkLiNSBQnDr/AcWFNq1GGQQUsvD47ab43WqzpatUxyMKm8zFdPr76hNC1eppzUgphgrif5sMXMkz5Yeu15BBZ/xD6vCP74q/mpt2hpsq5a5Bq295AHcuP4ij7leq0tnV8HMwyb3Vn9JE7WCl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wxTyqKbm9rfSDQLU5Rb0jtNQl/F7kkj6yW9JMnZ+V4ueirrREIaIELgiAihV0Av286l9NHc6eKtH9hFvdjAirbaJ8pFPBJBPgPrAUkbhm8pknmFce9ByVFRwAdG2k+cmQLJTppIPUV3iIxd8cbOcGFzH60UtPdJmzR5O2GylnH3GHZqK3+1eP92/vpp9gVxhjS9W2v3/9AkvxYLAlrys4R0ctKp0v9JP3zLjUnJFEeYLil7pjyWDg== X-OriginatorOrg: iopsys.eu X-MS-Exchange-CrossTenant-Network-Message-Id: 939d5fd5-c8ac-4a30-735d-08daa748fa6f X-MS-Exchange-CrossTenant-AuthSource: PAXPR08MB6494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2022 03:15:10.9952 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 7ff78d65-2de4-40f5-8675-0569e5c7a65d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4wJZ6AI6cfQrjvdzLTO6b20ZNlUEa7ycvJLcNKo91lfPh4a916vI+z5VTM/stUTDAk3pShcqRw0iFg+iyfuCVuRkU32szPltDvFk3LSjYTo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB6314 X-Mailman-Approved-At: Thu, 06 Oct 2022 13:17:22 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean From: Mikhail Kshevetskiy 'mtd erase' command should not erase bad blocks. To force bad block erasing there is 'mtd erase.dontskipbad' command (this command sets 'scrub' flag to true in the erase_info structure). Unfortunately nand layer ignore scrub flag and try to erases bad blocks unconditionally. This is wrong. Add checks to allow bad block erasing only if scrub flag is set. Signed-off-by: Mikhail Kshevetskiy --- drivers/mtd/nand/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/core.c b/drivers/mtd/nand/core.c index 99c29670c7..a4fb7602c9 100644 --- a/drivers/mtd/nand/core.c +++ b/drivers/mtd/nand/core.c @@ -174,7 +174,10 @@ int nanddev_mtd_erase(struct mtd_info *mtd, struct erase_info *einfo) nanddev_offs_to_pos(nand, einfo->addr + einfo->len - 1, &last); while (nanddev_pos_cmp(&pos, &last) <= 0) { schedule(); - ret = nanddev_erase(nand, &pos); + if (!einfo->scrub && nanddev_isbad(nand, &pos)) + ret = -EIO; + else + ret = nanddev_erase(nand, &pos); if (ret) { einfo->fail_addr = nanddev_pos_to_offs(nand, &pos);