From patchwork Thu Jan 5 09:28:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Reddy Soma X-Patchwork-Id: 1721721 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=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=iSfS6/M7; 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 4Nnh4V4VtMz23fC for ; Thu, 5 Jan 2023 20:29:14 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 346838559B; Thu, 5 Jan 2023 10:28:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com 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=amd.com header.i=@amd.com header.b="iSfS6/M7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DB8CD80EAF; Thu, 5 Jan 2023 10:28:50 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2082.outbound.protection.outlook.com [40.107.92.82]) (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 D5FDB85172 for ; Thu, 5 Jan 2023 10:28:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=ashok.reddy.soma@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S+IrYH1T1wWvCkhuBI2rVJBSy0C1/gu4IA3dR5FHvhtg9OgNWQ2mS7hpf1bbdRhhWRk4sGJsZtxhO/F1bYBi8xqL6Npdwf2OItVZJI34mvZOG+Tzp73Y63FMvdcIoWQSXV4xGyTtdGgsMD3g76QiuWGWladfv4LrMNDJONZmFq9/zzCF07BBz0lFdmDkR4dIp5sKqnMmd06ZobG/a5PvwLD7S60oAGzhKtoKW3BvgfJFISVmYCYmy3E1x4vWJr3IMyn6OlbSso8tNn/E+8acvafwxbzpyiDwKvVZ97IAunBD6KyKz/72vKG2ks9bLz6/ig/ruLdZaIvNiOMnrsOXCQ== 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=xT5+RCo5nW9KLNr18ZPxqJUsYAveeAKS3jBvMYaEnZY=; b=hTXvbsAMgZTBjuGhuUZu/IpY6/aq2dTfNG8QKY407YQsKWlSYToPc91Hcr/zdSymOMWFUM9noXMk2YDuqhWpWVIa9PNeFXgF6ia+q5/xzznHcisIPrmA/ZTn5EY994pgHkHZfEhN+8+tH7CGQQn6pBEBAENVEloG0rRn1+n/AJBrvyJegq6Gamp/ptBW/N/AbsRPLYMFsoenUXH/96Odpv6vtTJvUchYYT0j7zIPm5dK4Hjl7JxqeXRb7SdGj6RaAK49qbZunzg28+NAe3C1rRo0SNG6CO9Vf3NgeAiz/1K0m34CL85Ccl+MhahlY4yUkjtEwZOJVjeTNg1206m0kQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xT5+RCo5nW9KLNr18ZPxqJUsYAveeAKS3jBvMYaEnZY=; b=iSfS6/M7YayDGrLkBeZXEwd31WqclOXSQytnrqoaQGucQ1N18w/B+/PlGddqCS9HgV18I7g7Zxd9a8Uua62/+55Zg8dtfanABSDzl/HGHPed9th8pXyYlw0FXEOqfVgaJeDFKwWkJ3g5Oe0JRo1w6LiJeaoBXZ9lSwZN/sRohaQ= Received: from BN9PR03CA0550.namprd03.prod.outlook.com (2603:10b6:408:138::15) by SN7PR12MB6930.namprd12.prod.outlook.com (2603:10b6:806:262::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 09:28:43 +0000 Received: from BN8NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:408:138:cafe::1f) by BN9PR03CA0550.outlook.office365.com (2603:10b6:408:138::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.15 via Frontend Transport; Thu, 5 Jan 2023 09:28:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT025.mail.protection.outlook.com (10.13.177.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5966.17 via Frontend Transport; Thu, 5 Jan 2023 09:28:42 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 5 Jan 2023 03:28:42 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 5 Jan 2023 01:28:42 -0800 Received: from xhdashokred41.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34 via Frontend Transport; Thu, 5 Jan 2023 03:28:40 -0600 From: Ashok Reddy Soma To: CC: , , , Ashok Reddy Soma Subject: [PATCH] mtd: nand: Mark reserved blocks Date: Thu, 5 Jan 2023 02:28:30 -0700 Message-ID: <20230105092830.22088-1-ashok.reddy.soma@amd.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT025:EE_|SN7PR12MB6930:EE_ X-MS-Office365-Filtering-Correlation-Id: 28f1a2ff-9dec-4211-58e1-08daeeff3cba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pZ3nGmkVxBDLbg3tPzeJxWncS6sZNekYfMs7OdcSXy9KBT0BoqMLVci+9LHTGhYUnIfIhK7WT1OgpHIbytDmmUdFNO22g+kYxpJd9pmXURy1i0hIPJERZYo5uX0p9Zqq9X0LCtYdNpUa34jWlX1Sv9tHaxe44MM4k7gGli9uIqxMxoBDg39LrAh/46JaARHtLNzzICcARBt9sFOrX2AVV7VHc5H2PjxbGdK4L1X7Ds34w8yRWkvK5qytmndgjadGPDrXyXySnzcx3PMm6/YNO96SrjR11DRMfqk2ORiHZWqar7Vco39HZSuEwJ8D6dbUWNb4H+aloLCQOfZFuvBDa4PpQVvtERelYyG+vt7nxreqHRUJuf4/UbGvWaDwOPWHWT3juwy2V5Y+lvN19lRLx8dsd+1JlnHdIExynFWfQpaGJ1Ge90Ox7Qic1xxluwoCevUH2ugLE511acOkITyGH7BBdDDzyysf9Tc94NzdErfp/9suKFW3T1bppynhYZaU5TaykfQuzzePsYDZ2RRvlR+NyKilkQutJqLufjOanlp9TCpSSCf5DM40t6d4fAaq7qlQ7sS7GS7yf1wYghEzoUj8+CaGIXDhnGCKGOcinf/4+JMNF+qw5I1oOSMpAS++yHczWr21xKqxJ+yAu2T8sX+UbhM+Su7XDlpY5ikm5QpawZzA+IvqmgyXU7yogSct3c0RHdDwMC2vI+wP0tsq0Gp1giqUuZeg04IwWcCt4iI= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(376002)(39860400002)(396003)(136003)(346002)(451199015)(40470700004)(46966006)(36840700001)(81166007)(356005)(82740400003)(40480700001)(103116003)(36756003)(82310400005)(40460700003)(86362001)(6916009)(478600001)(2616005)(186003)(1076003)(26005)(54906003)(6666004)(70206006)(316002)(4326008)(2906002)(70586007)(36860700001)(426003)(8676002)(8936002)(83380400001)(336012)(47076005)(41300700001)(5660300002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 09:28:42.8794 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 28f1a2ff-9dec-4211-58e1-08daeeff3cba X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6930 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 Reserved blocks are used for storing bad block tables. With "nand bad" command, these reserved blocks are shown as bad blocks. This is leading to confusion when compared with Linux bad blocks. Hence, display "Reserved for bbt" when printing reserved blocks with "nand bad" command. To acheive this, return 2 which represents reserved from nand_isbad_bbt() instead of 1 in case of reserved blocks and catch it in cmd/nand.c. "nand bad" command display's hexadecimal numbers, so add "0x" prefix. Example log will show up as below. ZynqMP> nand bad Device 0 bad blocks: 0x00400000 0x16800000 0x16c00000 0x17000000 0x3d800000 0x3e400000 0xe8400000 0xff000000 <--- Reserved for bbt 0xff400000 <--- Reserved for bbt 0xff800000 <--- Reserved for bbt 0xffc00000 <--- Reserved for bbt 0x116800000 0x116c00000 0x1ff000000 <--- Reserved for bbt 0x1ff400000 <--- Reserved for bbt 0x1ff800000 <--- Reserved for bbt 0x1ffc00000 <--- Reserved for bbt Signed-off-by: Ashok Reddy Soma Reviewed-by: Michael Trimarchi --- cmd/nand.c | 9 ++++++--- drivers/mtd/nand/raw/nand_bbt.c | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/nand.c b/cmd/nand.c index 9a723f5757..feb6b0e3ec 100644 --- a/cmd/nand.c +++ b/cmd/nand.c @@ -567,9 +567,12 @@ static int do_nand(struct cmd_tbl *cmdtp, int flag, int argc, if (strcmp(cmd, "bad") == 0) { printf("\nDevice %d bad blocks:\n", dev); - for (off = 0; off < mtd->size; off += mtd->erasesize) - if (nand_block_isbad(mtd, off)) - printf(" %08llx\n", (unsigned long long)off); + for (off = 0; off < mtd->size; off += mtd->erasesize) { + ret = nand_block_isbad(mtd, off); + if (ret) + printf(" 0x%08llx%s\n", (unsigned long long)off, + ret == 2 ? "\t <--- Reserved for bbt" : ""); + } return 0; } diff --git a/drivers/mtd/nand/raw/nand_bbt.c b/drivers/mtd/nand/raw/nand_bbt.c index 911472e91e..cd451870a6 100644 --- a/drivers/mtd/nand/raw/nand_bbt.c +++ b/drivers/mtd/nand/raw/nand_bbt.c @@ -1330,6 +1330,7 @@ int nand_isreserved_bbt(struct mtd_info *mtd, loff_t offs) * @mtd: MTD device structure * @offs: offset in the device * @allowbbt: allow access to bad block table region + * Return: 0 - good block, 1- bad block, 2 - reserved block */ int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt) { @@ -1348,7 +1349,7 @@ int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt) case BBT_BLOCK_WORN: return 1; case BBT_BLOCK_RESERVED: - return allowbbt ? 0 : 1; + return allowbbt ? 0 : 2; } return 1; }