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 61304C3DA7D for ; Thu, 5 Jan 2023 10:04:46 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 20AC685172; Thu, 5 Jan 2023 11:04:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=amarulasolutions.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=amarulasolutions.com header.i=@amarulasolutions.com header.b="A61/NhxR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 632558558F; Thu, 5 Jan 2023 11:04:42 +0100 (CET) Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5BD4F80EAF for ; Thu, 5 Jan 2023 11:04:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=michael@amarulasolutions.com Received: by mail-ed1-x529.google.com with SMTP id j16so19637833edw.11 for ; Thu, 05 Jan 2023 02:04:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=R48ryVpcUDkxnJk4p1Vsbdg5qxlga6ngVLJ6dBWAWBA=; b=A61/NhxR/WcfF9w9otyJifgcXNVInLx3Os07ypynRqB6xgXeNYP9uHWUXiVYetpx+a 9z982s8d+IuKaKWaboxtGxeCMYy2wQ5fWpYAHBIyM5X/F8yajN1QlMqSnpNX1gFF1nxZ /tr5ShTVKKijTRcIHd9QEHVSsXa3gQbMUpg9I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=R48ryVpcUDkxnJk4p1Vsbdg5qxlga6ngVLJ6dBWAWBA=; b=W53ff2BbOygVnKnE+8USXyBZkE/BZY3wpzonMQ66/Mp6/5UPTP9Gg0VyXp0cc09jPc dxn0kkRW3a6miKcmguZSNT4ddqbO9ZDC5BjlcJPsG6DbGeaUoVs0WUb6qr8+dmWhLty4 w6LgtQyxr/JFbMHFG5byTMUjuUKqJ4FUwYijEJub49NdEvDH9/8YAduu29weUb+UDtF2 4f5Zz0Vmb3FVnKjpdxnvey9eMtgX1NNfXYDXk6MrGkD7EtROJYGwi+4om2IwMNtd7hZk 0lRxH5e7aUaKqA6jjC4liUxs2oNbWD+WOlS+ahzR6eYhRLiA8ezMjOmAGi31R49uAWdd bz4w== X-Gm-Message-State: AFqh2kpwIFmLzoTEhOh9WKtcwk1RWNnmJ5YIhQeSUHF4Bh5SpQuV0JtZ 124+3Ykdr4X+w4q+EPrOhEupi7JpaWsk4zG9pJI+2g== X-Google-Smtp-Source: AMrXdXvyW9y4wutEpifUG71C5L4IE23YOJRpbBUKSVSi91hfMe3SFt4H3EXCehWPW4Te5ORfdbAlmjrmk8ruw57m1gE= X-Received: by 2002:a05:6402:a57:b0:480:4cdc:b976 with SMTP id bt23-20020a0564020a5700b004804cdcb976mr4413819edb.65.1672913078890; Thu, 05 Jan 2023 02:04:38 -0800 (PST) MIME-Version: 1.0 References: <20230105094620.30774-1-ashok.reddy.soma@amd.com> In-Reply-To: <20230105094620.30774-1-ashok.reddy.soma@amd.com> From: Michael Nazzareno Trimarchi Date: Thu, 5 Jan 2023 11:04:27 +0100 Message-ID: Subject: Re: [PATCH v2] mtd: nand: Mark reserved blocks To: Ashok Reddy Soma Cc: u-boot@lists.denx.de, dario.binacchi@amarulasolutions.com, sjg@chromium.org Content-Type: text/plain; charset="UTF-8" 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 Hi On Thu, Jan 5, 2023 at 10:46 AM Ashok Reddy Soma wrote: > > 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 > Acked-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..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 > -- Michael Nazzareno Trimarchi Co-Founder & Chief Executive Officer M. +39 347 913 2170 michael@amarulasolutions.com __________________________________ Amarula Solutions BV Joop Geesinkweg 125, 1114 AB, Amsterdam, NL T. +31 (0)85 111 9172 info@amarulasolutions.com www.amarulasolutions.com