Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 657DDC433EF for ; Fri, 17 Sep 2021 13:53:26 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 757D761241 for ; Fri, 17 Sep 2021 13:53:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 757D761241 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 11D078322D; Fri, 17 Sep 2021 15:53:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1631886798; bh=3nWFZaTV2LjY/GeKeeLTPRdw89cz+RLujN4q7lMJ9Ts=; h=Subject:To:Cc:References:From:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=nBjH3Ez+XWA9vw3sZgWkB+aBa1MZgiluKXK2Igz0DmV7HooTaqyelKlvrG0/b8Q55 IYSekKFTpCSSVEVKohQ8bdsnt9kpeiUNiYU09cn3YAKwGvOobqKc43MS3sCxqmOEmW TGzFra7eAB/0a2ZJKEV1Q75rlpLgQyD0QjbU0gNw8Sycjbmz873kLGaxvgtSQoKC7d DzTQm32I9H9FDx2DgC8aI7OehL4lWk7HdYnE29k6zOIqe7DxKrk9n0Nuz8rx3i7VVv Bw3IhVEKqUswBg0BJlY1V7qj6K7YrFPe0N5ram+MAKwpOSuTAKSUj4cOSai0sC35pr oXVj64huWgB1w== Received: from [IPv6:::1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 6FBDB83217; Fri, 17 Sep 2021 15:53:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1631886789; bh=3nWFZaTV2LjY/GeKeeLTPRdw89cz+RLujN4q7lMJ9Ts=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=CJw6v5IP8lZdnbTLmsXHIOcNqCUnydqIqFaQks7O/xwtPr0wLKP5FXKILi418bjFj gP5di/DEJAA5i8afe1Wfm4fdTwEgocvG9iUli/2bgvru9TaQ1pO0u+K4yA6tfZhsiA mlDLb88swLBvRb0tJEivrpxvkjLkLX9OKBw2UrQMUbNEUrrE5PnVEp33KyUCHxHmBo 0x+3eNa07t9eW4Ij8Qxb5N6gvk9gsNxstcCf7658MiN+ua8XU3tsU69f+Mb0oXvSPh 8NXu6oxU+jqtCswdWQE8RFntQfpT1hFAyKXMPumr8GCeQekm5iRiz14LBY67bWchF7 FF2hyrQRsz/PQ== Subject: Re: [PATCH v3 2/2] mtd: spi: nor: force mtd name to "nor%d" To: Patrick DELAUNAY , u-boot@lists.denx.de Cc: Priyanka Jain , Heiko Schocher , Jagan Teki , Miquel Raynal , Christophe KERELLO , Patrice Chotard , =?UTF-8?Q?Pali_Roh=c3=a1r?= , =?UTF-8?Q?Marek_Beh=c3=ban?= , Vignesh R , U-Boot STM32 References: <20210916140118.874028-1-patrick.delaunay@foss.st.com> <20210916155040.v3.2.Ia461e670c7438478aa8f8939209d45c818ccd284@changeid> <5dfd98da-2efd-23e2-64db-ec41dc9b6c6a@foss.st.com> From: Marek Vasut Message-ID: <8344dd03-b847-8fef-be30-68cff2bc78a9@denx.de> Date: Fri, 17 Sep 2021 15:39:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <5dfd98da-2efd-23e2-64db-ec41dc9b6c6a@foss.st.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean On 9/17/21 3:06 PM, Patrick DELAUNAY wrote: > Hi Marek, > > > Marek VasutSept. 16, 2021, 5:27 p.m. UTC | #3 > > On 9/16/21 4:01 PM, Patrick Delaunay wrote: > > > [...] > > > > @@ -3664,6 +3666,11 @@ int spi_nor_scan(struct spi_nor *nor) > > >       struct mtd_info *mtd = &nor->mtd; > > >       struct spi_slave *spi = nor->spi; > > >       int ret; > > > +    int cfi_mtd_nb = 0; > > > + > > > +#ifdef CONFIG_SYS_MAX_FLASH_BANKS > > > +    cfi_mtd_nb = CONFIG_SYS_MAX_FLASH_BANKS; > > > +#endif > > > Are we covering all the NORs (HF and co.) with this ? > > > Yes, except if I miss something > > > any NOR (including hyperflash) wich use the CFI interface / > CONFIG_FLASH_CFI_MTD > > define the the 'nor%d' name with the calling stack: Yes > initr_flash() > > => flash_init() > > ==> cfi_flash_init_dm() > > ==> cfi_mtd_init()   "nor%d" wich use loop on CONFIG_SYS_MAX_FLASH_BANKS > > > I have only one concern today... > > > if one cfi bank is missing (not activated in DT by example) > > and CONFIG_SYS_MAX_FLASH_BANKS_DETECT is not activated > > some holes can be done in index > > > example: > > with CONFIG_SYS_MAX_FLASH_BANKS = 2 but with only one NOR on the board > > => "nor1" is absent and we have only 2 MTD device named "nor" > > - "nor0" => NOR or HF, first CFI bank > > - "nor2" => SPI-NOR (first) > > > but I don't think that it is blocking Wasn't the old behavior exactly the same anyway ? > > >       /* Reset SPI protocol for all commands. */ > > >       nor->reg_proto = SNOR_PROTO_1_1_1; > > > @@ -3715,8 +3722,10 @@ int spi_nor_scan(struct spi_nor *nor) > > >       if (ret) > > >           return ret; > > > > > > -    if (!mtd->name) > > > -        mtd->name = info->name; > > > +    if (!mtd->name) { > > > +        sprintf(nor->mtd_name, "nor%d",  cfi_mtd_nb + > dev_seq(nor->dev)); > > > +        mtd->name = nor->mtd_name; > > > +    } > > >       mtd->dev = nor->dev; > > >       mtd->priv = nor; > > >       mtd->type = MTD_NORFLASH; > > > @@ -3821,7 +3830,7 @@ int spi_nor_scan(struct spi_nor *nor) > > > > > >       nor->rdsr_dummy = params.rdsr_dummy; > > >       nor->rdsr_addr_nbytes = params.rdsr_addr_nbytes; > > > -    nor->name = mtd->name; > > > +    nor->name = info->name; > > >       nor->size = mtd->size; > > >       nor->erase_size = mtd->erasesize; > > >       nor->sector_size = mtd->erasesize; > > > diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h > > > index 7ddc4ba2bf..8c3d5032e3 100644 > > > --- a/include/linux/mtd/spi-nor.h > > > +++ b/include/linux/mtd/spi-nor.h > > > @@ -561,6 +561,7 @@ struct spi_nor { > > >       int (*ready)(struct spi_nor *nor); > > > > > >       void *priv; > > > +    char mtd_name[10]; > > > should be 14, because nor%d\0 can be up to 14 bytes long. > > normally DM_MAX_SEQ = 999 (but never used) > > but Ok with you for 14 with "nor" = 3 + "%d" = 10 for max u32 value + > "/0" = 1 > > > for cfi_mtd_names => 16 byte used with "nor%d" > >     static char cfi_mtd_names[CFI_MAX_FLASH_BANKS][16]; > > for nand => 8 bytes (./drivers/mtd/nand/raw/nand.c:59) > >     static char dev_name[CONFIG_SYS_MAX_NAND_DEVICE][8]; > > for spi-nand => 20 bytes (drivers/mtd/nand/spi/core.c:1169) > >     mtd->name = malloc(20); Maybe we need a macro for this length of DM seq string which we could use in these embedded array cases.