From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ED748C3DA7D for ; Thu, 5 Jan 2023 09:46:44 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D4D05855A4; Thu, 5 Jan 2023 10:46:41 +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="K91u8h9/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 55DF3855A4; Thu, 5 Jan 2023 10:46:40 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2061.outbound.protection.outlook.com [40.107.244.61]) (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 3CFD380EAF for ; Thu, 5 Jan 2023 10:46:37 +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=CmcmOsC99gUCGkp9e/jZ/wqY2sH8NyO1aha3EBe5PSrVdCNqFuUOGFqgWKso0rZ317AqgK4NLurowdyV7X+8+nLdnETBbjDNGE4wJvRTBRFK8hdlF2zw/2XHSa6ybg6bwzGRo9RnNyXM6z2Zgqh0HJbKGMNyFlPmihLZj+Z1LUle7X5Y8hk0E+yPgWZKAeWiHmf+Vw+NkdS0wByhqbhHtNfm4IwzKZGbBrs1FsyLFnpXY831RoYXHwauUP/DER1BXWe4jiLobOT7PM0dxCrqFXbmS4OhFUV0Wgz5DNXZp3JTVfi/kxgNWRJu4UGSiCYITa/oYJgsXp8Dsqd/E0GjWQ== 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=yPN2MyXpAWrGwkLYYfXDsuLunlhf6rbQvXKit1SQ7dU=; b=PzihTM/D/llzQcS1D4e7mA2CNvgWLwZ+6dlmHMkYFYqFm1+sf3ckYwKC1n16Rwg+CQvxqxfAiUWDhlak+lVWmZEkoo7kWQiHgFbyOxW2I13JdGwhKLjk6LDGZd3gotCy7O+bcWp+/AAUQyduQ6z4Mw9qV8EWqJ4E64zxiLfk3yHuxMA+KZAi/aSOXQlllBqW6mkdWdSSpjpMSGqmFM6HNYUKaNhLTKq+26iZCJNEDAD9ez4NLASvovvppKi8/XO2hLoPvyXJ2CL1c2OyMN+wIpcaPEr6ohK7HA1Y3jX/gFBCKco4aumJnmlbyb0ZBMT6Ela8F2Y9kkEUNKTFW/8y0g== 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=yPN2MyXpAWrGwkLYYfXDsuLunlhf6rbQvXKit1SQ7dU=; b=K91u8h9/ORzCNSzMoyXXTRdSRnWdJWEojfmCdgNyw4/1LefAXf1Y1gstG59b5TW3bEUKpMIUxttgk4dFsoY0XkLkv6ow3CoaS7PsE6vQSCfLSWEDR7MCJnb6Idokfa3ULFxlmc9EKBoOhJNsZRqUqSt9UHFn0fT+BOBckUj2zRE= Received: from BN9PR03CA0218.namprd03.prod.outlook.com (2603:10b6:408:f8::13) by BL3PR12MB6380.namprd12.prod.outlook.com (2603:10b6:208:3b3::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.16; Thu, 5 Jan 2023 09:46:33 +0000 Received: from BN8NAM11FT057.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f8:cafe::b4) by BN9PR03CA0218.outlook.office365.com (2603:10b6:408:f8::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.14 via Frontend Transport; Thu, 5 Jan 2023 09:46:33 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT057.mail.protection.outlook.com (10.13.177.49) 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:46:33 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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; Thu, 5 Jan 2023 03:46:33 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) 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:46:32 -0600 Received: from xhdashokred41.xilinx.com (10.180.168.240) 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 via Frontend Transport; Thu, 5 Jan 2023 03:46:30 -0600 From: Ashok Reddy Soma To: CC: , , , Ashok Reddy Soma Subject: [PATCH v2] mtd: nand: Mark reserved blocks Date: Thu, 5 Jan 2023 02:46:20 -0700 Message-ID: <20230105094620.30774-1-ashok.reddy.soma@amd.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT057:EE_|BL3PR12MB6380:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c1e955b-20e4-4f4b-6a51-08daef01baef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fXBwOAGpr5xHVtbUQ7P8G/u6FTstjA5Ld4HD3Lt8rSesb9oM1EIZYYV0sYEXE7pbxn/xlnEzbvNjmZpiGgecMTtDtknAg6CjocvCrUTma1vXlOfFRjl/W+MYLg9k5+xXU+DgEN0wq0JXET9kFQr+X8+sxQ9Fd3FtlGBdvS53vg6+9a55bxWgRffv8u/dRr9bA/SguSbNe8vauqeNixtK0mdhxN2FoOQdNP7kGx4SorGwOrW8k66/gDTpEhS8zq9gZ6b8K+UKvT3au0mLk49c1P49MoZbAvps5JrEkeucZLmRagh09nL8guI5n5Wj//+raUevnMH8jvCcZk6Oqoa68PBDYK2x3VHRHK3jy9d/CC1Ct+XzzK3OJeDt/IAjmPINc74WQoNsOCi1DpfIgQ7C8/8lymLIqb5gDYuvHdXUVWKA2O4hSeOFIIwHniD1loPD3r+vdFutHSe7altM+7AAtJeHnxdWiBQR8a07apLWC50trQcInD4ySeF1rhsIElZ37iZNOFk6Oe6sKxZUw5AFufI9WCD+/rS3RHZXO1dGUg+L3OBl0kSwCoUGoRZH3M9p1sjiZrRg7psiHgTo4hNze6z19kCp3tHKn5UKBduydxKrN8nGMA8H+20JaTRoW23UH2fPve588KFmFPXr90Lgq04hnN6m7KwiqYp6nkJpBoHpkEd81ufxGXQyJ+TRpX5B76m8YmxeE1h9GVioOI1mcqOIygLTUgJQCGdCAxSIjpM= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(396003)(346002)(376002)(136003)(39860400002)(451199015)(36840700001)(46966006)(40470700004)(103116003)(36756003)(8936002)(5660300002)(41300700001)(336012)(70206006)(36860700001)(83380400001)(47076005)(426003)(86362001)(356005)(81166007)(82740400003)(2906002)(6916009)(6666004)(8676002)(40460700003)(82310400005)(40480700001)(54906003)(70586007)(478600001)(316002)(4326008)(26005)(186003)(1076003)(2616005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 09:46:33.6136 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c1e955b-20e4-4f4b-6a51-08daef01baef 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT057.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6380 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 "bbt reserved" 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 (bbt reserved) 0xff400000 (bbt reserved) 0xff800000 (bbt reserved) 0xffc00000 (bbt reserved) 0x116800000 0x116c00000 0x1ff000000 (bbt reserved) 0x1ff400000 (bbt reserved) 0x1ff800000 (bbt reserved) 0x1ffc00000 (bbt reserved) Signed-off-by: Ashok Reddy Soma Reviewed-by: Michael Trimarchi --- Changes in v2: - Changed "Reserved for bbt" to (bbt reserved) - Updated description and the log in the description 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..b41e54ec42 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 (bbt reserved)" : ""); + } 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; } -- 2.17.1