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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5181BC4332F for ; Fri, 13 May 2022 14:48:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381362AbiEMOsB (ORCPT ); Fri, 13 May 2022 10:48:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351689AbiEMOrw (ORCPT ); Fri, 13 May 2022 10:47:52 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E77C2ED6E for ; Fri, 13 May 2022 07:47:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652453271; x=1683989271; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=HbRDZLon2bEfMnJ+egiJaqJDquML3EXNdRnTwZASpHY=; b=Z/cuW2Xiz5QhIAXQNHzPPG5cHCza+oTwdRU9Hw8qMz3TtgeTWvueuJMt zZqvIlK/HL3IDglzu8hCW7CzWj/ScKVDmXfg2D9cjSiim+SIv3g2+YLNH EEMmDRHH+GeAAPUeUo6CZZv+ORjyEFL/pKdi/nM6H0X+b0JTklJpvEK+O c3cfH8T8Ba832a506qTSE+tFMgpuBD1+pz4xAQBCjHZ4XB1CZvKd9alxj EQh1+pf20qS7ccnKKwO1jmVGTDNLIr0+fMioPro/hp0iEuLMxqPYJKeAB AWZfx8GfLeqPvDYBxrRxFdAEApLYLscvpp16mm4ZjLpnp5uyFMQD+kkVa g==; X-IronPort-AV: E=McAfee;i="6400,9594,10346"; a="356748015" X-IronPort-AV: E=Sophos;i="5.91,223,1647327600"; d="scan'208";a="356748015" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 07:47:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,223,1647327600"; d="scan'208";a="896251999" Received: from lkp-server01.sh.intel.com (HELO 5056e131ad90) ([10.239.97.150]) by fmsmga005.fm.intel.com with ESMTP; 13 May 2022 07:47:48 -0700 Received: from kbuild by 5056e131ad90 with local (Exim 4.95) (envelope-from ) id 1npWa4-000LqE-80; Fri, 13 May 2022 14:47:48 +0000 Date: Fri, 13 May 2022 22:47:10 +0800 From: kernel test robot To: Michael Walle , Tudor Ambarus , Pratyush Yadav , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: kbuild-all@lists.01.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org Subject: Re: [PATCH 5/6] mtd: spi-nor: add generic flash driver Message-ID: <202205132220.uRTFaqNA-lkp@intel.com> References: <20220513133520.3945820-6-michael@walle.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220513133520.3945820-6-michael@walle.cc> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Michael, I love your patch! Perhaps something to improve: [auto build test WARNING on mtd/spi-nor/next] [also build test WARNING on next-20220513] [cannot apply to linux/master linus/master v5.18-rc6] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/intel-lab-lkp/linux/commits/Michael-Walle/mtd-spi-nor-generic-flash-driver/20220513-214238 base: https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git spi-nor/next config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20220513/202205132220.uRTFaqNA-lkp@intel.com/config) compiler: m68k-linux-gcc (GCC) 11.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/d38c0ac1528d85bea65fc5a9e7f61a10dbc051fb git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Michael-Walle/mtd-spi-nor-generic-flash-driver/20220513-214238 git checkout d38c0ac1528d85bea65fc5a9e7f61a10dbc051fb # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/mtd/spi-nor/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All warnings (new ones prefixed by >>): >> drivers/mtd/spi-nor/sfdp.c:1260: warning: expecting prototype for spi_nor_check_sfdp_header(). Prototype was for spi_nor_check_sfdp_signature() instead vim +1260 drivers/mtd/spi-nor/sfdp.c 1249 1250 /** 1251 * spi_nor_check_sfdp_header() - check for a valid SFDP header 1252 * @nor: pointer to a 'struct spi_nor' 1253 * 1254 * Used to detect if the flash supports the RDSFDP command as well as the 1255 * presence of a valid SFDP table. 1256 * 1257 * Return: 0 on success, -errno otherwise. 1258 */ 1259 int spi_nor_check_sfdp_signature(struct spi_nor *nor) > 1260 { 1261 u32 signature; 1262 int err; 1263 1264 /* Get the SFDP header. */ 1265 err = spi_nor_read_sfdp_dma_unsafe(nor, 0, sizeof(signature), 1266 &signature); 1267 if (err < 0) 1268 return err; 1269 1270 /* Check the SFDP signature. */ 1271 if (le32_to_cpu(signature) != SFDP_SIGNATURE) 1272 return -EINVAL; 1273 1274 return 0; 1275 } 1276 -- 0-DAY CI Kernel Test Service https://01.org/lkp 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 397FBC433F5 for ; Fri, 13 May 2022 14:48:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=g75yPoQhB4mrs6wzXBn2fjNBpjPZ9JkNPwT3VxKnzkI=; b=EEjmlLAR+iEVfQ CJCW6D16i9vkjgXMmfjJkFZl4RWtVOxTAf111koy2LACL7gj5E9B4JzYOFbe2c8wxKWvEzd7zv5TS YbmDCYQqx32GA5C+NXLTk2paZDjQn4AJK4SW0IV5a/3RSAqyrb6EqgdKqmWaXLzdoc/DQ8SlaQEyr ohx3ntsVQ50IUHTJcSy56J/RwgtX/4rtJmcyIHC5btuq4epyUGhcZZZSAekM5FbRVbK8H9IsZF/xp C7KDRNqMFX7n7b+lwbU10HeGkBh0oALTqC7qD2/caM2/wsQkhocbn+RcfolxbGYuTNbRubE+Nr1hS Be1buP/26EFfOku/73SQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1npWaC-00GVkF-Rb; Fri, 13 May 2022 14:47:56 +0000 Received: from mga06b.intel.com ([134.134.136.31] helo=mga06.intel.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1npWa8-00GViO-Td for linux-mtd@lists.infradead.org; Fri, 13 May 2022 14:47:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652453272; x=1683989272; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=HbRDZLon2bEfMnJ+egiJaqJDquML3EXNdRnTwZASpHY=; b=W2sKSdadY3ZIPV5vSayHY7bzNkI34NLFsKCAZgT+adf8S2peAz89GE6M WcxeVryt7IswY5dZhlwC9w1s+4WfvjZ+CfNF+Ter2oOo+4uKEH2XcLUD1 jFF+LMis0Fd0NqPeBxBhB7craOqIJBKxoB864aDyT6y2YFeL3QuKGzC8/ x5UeMnL6YWbSpTXKUChKPyrPHLlUsTXGQwhMNzc2wms2jE5e/e7d7Ckon v/Ct+A+b5qITmmof4/GSgkzJCk29AgiUPEtYp4Z9/qBQ+xESZatv/X6Xa 8qpBXiFeIn0pcTidXjcLoTpPwR3yqeLISsXY4BRUMydnZJ1n64IQl/xcM w==; X-IronPort-AV: E=McAfee;i="6400,9594,10346"; a="330918412" X-IronPort-AV: E=Sophos;i="5.91,223,1647327600"; d="scan'208";a="330918412" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 07:47:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,223,1647327600"; d="scan'208";a="896251999" Received: from lkp-server01.sh.intel.com (HELO 5056e131ad90) ([10.239.97.150]) by fmsmga005.fm.intel.com with ESMTP; 13 May 2022 07:47:48 -0700 Received: from kbuild by 5056e131ad90 with local (Exim 4.95) (envelope-from ) id 1npWa4-000LqE-80; Fri, 13 May 2022 14:47:48 +0000 Date: Fri, 13 May 2022 22:47:10 +0800 From: kernel test robot To: Michael Walle , Tudor Ambarus , Pratyush Yadav , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: kbuild-all@lists.01.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org Subject: Re: [PATCH 5/6] mtd: spi-nor: add generic flash driver Message-ID: <202205132220.uRTFaqNA-lkp@intel.com> References: <20220513133520.3945820-6-michael@walle.cc> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220513133520.3945820-6-michael@walle.cc> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220513_074753_038649_5B06E7CC X-CRM114-Status: GOOD ( 13.76 ) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org Hi Michael, I love your patch! Perhaps something to improve: [auto build test WARNING on mtd/spi-nor/next] [also build test WARNING on next-20220513] [cannot apply to linux/master linus/master v5.18-rc6] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/intel-lab-lkp/linux/commits/Michael-Walle/mtd-spi-nor-generic-flash-driver/20220513-214238 base: https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git spi-nor/next config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20220513/202205132220.uRTFaqNA-lkp@intel.com/config) compiler: m68k-linux-gcc (GCC) 11.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/d38c0ac1528d85bea65fc5a9e7f61a10dbc051fb git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Michael-Walle/mtd-spi-nor-generic-flash-driver/20220513-214238 git checkout d38c0ac1528d85bea65fc5a9e7f61a10dbc051fb # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/mtd/spi-nor/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All warnings (new ones prefixed by >>): >> drivers/mtd/spi-nor/sfdp.c:1260: warning: expecting prototype for spi_nor_check_sfdp_header(). Prototype was for spi_nor_check_sfdp_signature() instead vim +1260 drivers/mtd/spi-nor/sfdp.c 1249 1250 /** 1251 * spi_nor_check_sfdp_header() - check for a valid SFDP header 1252 * @nor: pointer to a 'struct spi_nor' 1253 * 1254 * Used to detect if the flash supports the RDSFDP command as well as the 1255 * presence of a valid SFDP table. 1256 * 1257 * Return: 0 on success, -errno otherwise. 1258 */ 1259 int spi_nor_check_sfdp_signature(struct spi_nor *nor) > 1260 { 1261 u32 signature; 1262 int err; 1263 1264 /* Get the SFDP header. */ 1265 err = spi_nor_read_sfdp_dma_unsafe(nor, 0, sizeof(signature), 1266 &signature); 1267 if (err < 0) 1268 return err; 1269 1270 /* Check the SFDP signature. */ 1271 if (le32_to_cpu(signature) != SFDP_SIGNATURE) 1272 return -EINVAL; 1273 1274 return 0; 1275 } 1276 -- 0-DAY CI Kernel Test Service https://01.org/lkp ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3BC7C433EF for ; Thu, 21 Jul 2022 09:32:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231445AbiGUJcZ (ORCPT ); Thu, 21 Jul 2022 05:32:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232478AbiGUJcX (ORCPT ); Thu, 21 Jul 2022 05:32:23 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2C96480F50 for ; Thu, 21 Jul 2022 02:32:21 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.92,289,1650898800"; d="scan'208";a="128642622" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 21 Jul 2022 18:32:20 +0900 Received: from localhost.localdomain (unknown [10.226.92.81]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 9D0CE40078D5; Thu, 21 Jul 2022 18:32:17 +0900 (JST) From: Biju Das To: michael@walle.cc Cc: linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, miquel.raynal@bootlin.com, p.yadav@ti.com, richard@nod.at, tudor.ambarus@microchip.com, vigneshr@ti.com Subject: Re: [PATCH 5/6] mtd: spi-nor: add generic flash driver Date: Thu, 21 Jul 2022 10:32:16 +0100 Message-ID: <202205132220.uRTFaqNA-lkp@intel.com> (raw) X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220513133520.3945820-6-michael@walle.cc> References: <20220513133520.3945820-6-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Message-ID: <20220721093216.rbf_y-Ob4gpbWyJlihPNl281u5DmCCeRsDeeAnSZe6Q@z> > Our SFDP is parsing is everything we need to support all basic operations of > a flash device. If the flash isn't found in our in-kernel flash database, > gracefully fall back to a driver described solely by its SFDP tables. > > It is still recommended to add the flash to the in-kernel database. > First, we get a proper partname and secondly, for all features not described > by the SFDP like OTP we need the entry anyway. > > Signed-off-by: Michael Walle > --- > drivers/mtd/spi-nor/core.c | 13 +++++++++++++ drivers/mtd/spi-nor/core.h | > 1 + drivers/mtd/spi-nor/sfdp.c | 27 +++++++++++++++++++++++++++ > 3 files changed, 41 insertions(+) > > diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index > 65cd8e668579..ee193a61310a 100644 > --- a/drivers/mtd/spi-nor/core.c > +++ b/drivers/mtd/spi-nor/core.c > @@ -1632,6 +1632,11 @@ static const struct spi_nor_manufacturer > *manufacturers[] = { > &spi_nor_xmc, > }; > > +static const struct flash_info spi_nor_generic_flash = { > + .name = "spi-nor-generic", > + .parse_sfdp = true, > +}; > + > static const struct flash_info *spi_nor_match_id(struct spi_nor *nor, > const u8 *id) > { > @@ -1670,6 +1675,14 @@ static const struct flash_info *spi_nor_detect(struct > spi_nor *nor) > return ERR_PTR(-ENOMEM); > > info = spi_nor_match_id(nor, id); > + > + /* Fallback to a generic flash described only by its SFDP data. */ > + if (!info) { > + ret = spi_nor_check_sfdp_signature(nor); > + if (!ret) > + info = &spi_nor_generic_flash; > + } May be this can be combined as if (!info && (!spi_nor_check_sfdp_signature(nor))) info = &spi_nor_generic_flash; Cheers, Biju > if (!info) { > dev_err(nor->dev, "unrecognized JEDEC id bytes: %*ph\n", > SPI_NOR_MAX_ID_LEN, id); > diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h index > 153cb4b174ee..b084cb6db401 100644 > --- a/drivers/mtd/spi-nor/core.h > +++ b/drivers/mtd/spi-nor/core.h > @@ -703,6 +703,7 @@ int spi_nor_controller_ops_read_reg(struct spi_nor *nor, > u8 opcode, int spi_nor_controller_ops_write_reg(struct spi_nor *nor, u8 > opcode, > const u8 *buf, size_t len); > > +int spi_nor_check_sfdp_signature(struct spi_nor *nor); > int spi_nor_parse_sfdp(struct spi_nor *nor); > > static inline struct spi_nor *mtd_to_spi_nor(struct mtd_info *mtd) diff -- > git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c index > a5211543d30d..9bdb3d5dc7e8 100644 > --- a/drivers/mtd/spi-nor/sfdp.c > +++ b/drivers/mtd/spi-nor/sfdp.c > @@ -1247,6 +1247,33 @@ static void spi_nor_post_sfdp_fixups(struct spi_nor > *nor) > nor->info->fixups->post_sfdp(nor); > } > > +/** > + * spi_nor_check_sfdp_header() - check for a valid SFDP header > + * @nor: pointer to a 'struct spi_nor' > + * > + * Used to detect if the flash supports the RDSFDP command as well as > +the > + * presence of a valid SFDP table. > + * > + * Return: 0 on success, -errno otherwise. > + */ > +int spi_nor_check_sfdp_signature(struct spi_nor *nor) { > + u32 signature; > + int err; > + > + /* Get the SFDP header. */ > + err = spi_nor_read_sfdp_dma_unsafe(nor, 0, sizeof(signature), > + &signature); > + if (err < 0) > + return err; > + > + /* Check the SFDP signature. */ > + if (le32_to_cpu(signature) != SFDP_SIGNATURE) > + return -EINVAL; > + > + return 0; > +} > + > /** > * spi_nor_parse_sfdp() - parse the Serial Flash Discoverable Parameters. > * @nor: pointer to a 'struct spi_nor' > -- > 2.25.1 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E998BC43334 for ; Thu, 21 Jul 2022 09:32:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PLViYYzQtnOysZvGGIwJ+Kh8ivisBs4/rE1xdwME4SA=; b=eX27OsaKkjspxJ JSnL8vtem07YOda4mXSGEEcF/L7WzCfMPTci6Moag9gW86l31IoQ9b+5lp87EiqwM8NPMurfmVqc1 AY4WwvDy54Y38y9GXXt+h8qltp35bwt2SojRZis7v7IPQOMhRmj0SrWJgkmgAxT7sFjoL+3sQpCnV iqCCly6cgOXpahlmmeZwvd7QkNkRbWzmB1YlVBnEjn9pRTJLmRSYREi3IDwzX49a5DjFrYqOIJFFy cZSDC8w4ilW5KLSBzQGiWwZFrErbcUfbiTmJ4gpu7WungQAzTZ3FEVLz4fzNfRWOWchV4bXopVsKd uYidmRBUUHbFz8l7NF9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oESXp-003N7k-75; Thu, 21 Jul 2022 09:32:33 +0000 Received: from relmlor2.renesas.com ([210.160.252.172] helo=relmlie6.idc.renesas.com) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oESXl-003Mrj-J9 for linux-mtd@lists.infradead.org; Thu, 21 Jul 2022 09:32:31 +0000 X-IronPort-AV: E=Sophos;i="5.92,289,1650898800"; d="scan'208";a="128642622" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 21 Jul 2022 18:32:20 +0900 Received: from localhost.localdomain (unknown [10.226.92.81]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 9D0CE40078D5; Thu, 21 Jul 2022 18:32:17 +0900 (JST) From: Biju Das To: michael@walle.cc Cc: linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, miquel.raynal@bootlin.com, p.yadav@ti.com, richard@nod.at, tudor.ambarus@microchip.com, vigneshr@ti.com Subject: Re: [PATCH 5/6] mtd: spi-nor: add generic flash driver Date: Thu, 21 Jul 2022 10:32:16 +0100 Message-ID: <202205132220.uRTFaqNA-lkp@intel.com> (raw) X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220513133520.3945820-6-michael@walle.cc> References: <20220513133520.3945820-6-michael@walle.cc> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220721_023229_788049_68F3D505 X-CRM114-Status: GOOD ( 25.17 ) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org Message-ID: <20220721093216.ZjX_zjDkJZMtmnR28nTDJ9N1o8EEFvo9ONrim9KYd5I@z> > Our SFDP is parsing is everything we need to support all basic operations of > a flash device. If the flash isn't found in our in-kernel flash database, > gracefully fall back to a driver described solely by its SFDP tables. > > It is still recommended to add the flash to the in-kernel database. > First, we get a proper partname and secondly, for all features not described > by the SFDP like OTP we need the entry anyway. > > Signed-off-by: Michael Walle > --- > drivers/mtd/spi-nor/core.c | 13 +++++++++++++ drivers/mtd/spi-nor/core.h | > 1 + drivers/mtd/spi-nor/sfdp.c | 27 +++++++++++++++++++++++++++ > 3 files changed, 41 insertions(+) > > diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index > 65cd8e668579..ee193a61310a 100644 > --- a/drivers/mtd/spi-nor/core.c > +++ b/drivers/mtd/spi-nor/core.c > @@ -1632,6 +1632,11 @@ static const struct spi_nor_manufacturer > *manufacturers[] = { > &spi_nor_xmc, > }; > > +static const struct flash_info spi_nor_generic_flash = { > + .name = "spi-nor-generic", > + .parse_sfdp = true, > +}; > + > static const struct flash_info *spi_nor_match_id(struct spi_nor *nor, > const u8 *id) > { > @@ -1670,6 +1675,14 @@ static const struct flash_info *spi_nor_detect(struct > spi_nor *nor) > return ERR_PTR(-ENOMEM); > > info = spi_nor_match_id(nor, id); > + > + /* Fallback to a generic flash described only by its SFDP data. */ > + if (!info) { > + ret = spi_nor_check_sfdp_signature(nor); > + if (!ret) > + info = &spi_nor_generic_flash; > + } May be this can be combined as if (!info && (!spi_nor_check_sfdp_signature(nor))) info = &spi_nor_generic_flash; Cheers, Biju > if (!info) { > dev_err(nor->dev, "unrecognized JEDEC id bytes: %*ph\n", > SPI_NOR_MAX_ID_LEN, id); > diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h index > 153cb4b174ee..b084cb6db401 100644 > --- a/drivers/mtd/spi-nor/core.h > +++ b/drivers/mtd/spi-nor/core.h > @@ -703,6 +703,7 @@ int spi_nor_controller_ops_read_reg(struct spi_nor *nor, > u8 opcode, int spi_nor_controller_ops_write_reg(struct spi_nor *nor, u8 > opcode, > const u8 *buf, size_t len); > > +int spi_nor_check_sfdp_signature(struct spi_nor *nor); > int spi_nor_parse_sfdp(struct spi_nor *nor); > > static inline struct spi_nor *mtd_to_spi_nor(struct mtd_info *mtd) diff -- > git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c index > a5211543d30d..9bdb3d5dc7e8 100644 > --- a/drivers/mtd/spi-nor/sfdp.c > +++ b/drivers/mtd/spi-nor/sfdp.c > @@ -1247,6 +1247,33 @@ static void spi_nor_post_sfdp_fixups(struct spi_nor > *nor) > nor->info->fixups->post_sfdp(nor); > } > > +/** > + * spi_nor_check_sfdp_header() - check for a valid SFDP header > + * @nor: pointer to a 'struct spi_nor' > + * > + * Used to detect if the flash supports the RDSFDP command as well as > +the > + * presence of a valid SFDP table. > + * > + * Return: 0 on success, -errno otherwise. > + */ > +int spi_nor_check_sfdp_signature(struct spi_nor *nor) { > + u32 signature; > + int err; > + > + /* Get the SFDP header. */ > + err = spi_nor_read_sfdp_dma_unsafe(nor, 0, sizeof(signature), > + &signature); > + if (err < 0) > + return err; > + > + /* Check the SFDP signature. */ > + if (le32_to_cpu(signature) != SFDP_SIGNATURE) > + return -EINVAL; > + > + return 0; > +} > + > /** > * spi_nor_parse_sfdp() - parse the Serial Flash Discoverable Parameters. > * @nor: pointer to a 'struct spi_nor' > -- > 2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/