From: Miquel Raynal <miquel.raynal@bootlin.com>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: "Srinivas Kandagatla" <srinivas.kandagatla@linaro.org>,
"Richard Weinberger" <richard@nod.at>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
"Hector Martin" <marcan@marcan.st>,
"Sven Peter" <sven@svenpeter.dev>,
"Alyssa Rosenzweig" <alyssa@rosenzweig.io>,
"Shawn Guo" <shawnguo@kernel.org>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Fabio Estevam" <festevam@gmail.com>,
"NXP Linux Team" <linux-imx@nxp.com>,
"Neil Armstrong" <neil.armstrong@linaro.org>,
"Kevin Hilman" <khilman@baylibre.com>,
"Jerome Brunet" <jbrunet@baylibre.com>,
"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>,
"Claudiu Beznea" <claudiu.beznea@microchip.com>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"Andy Gross" <agross@kernel.org>,
"Bjorn Andersson" <andersson@kernel.org>,
"Konrad Dybcio" <konrad.dybcio@linaro.org>,
"Heiko Stuebner" <heiko@sntech.de>,
"Orson Zhai" <orsonzhai@gmail.com>,
"Baolin Wang" <baolin.wang@linux.alibaba.com>,
"Chunyan Zhang" <zhang.lyra@gmail.com>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
"Vincent Shih" <vincent.sunplus@gmail.com>,
"Chen-Yu Tsai" <wens@csie.org>,
"Jernej Skrabec" <jernej.skrabec@gmail.com>,
"Samuel Holland" <samuel@sholland.org>,
"Kunihiko Hayashi" <hayashi.kunihiko@socionext.com>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
"Michal Simek" <michal.simek@xilinx.com>,
"Alessandro Zummo" <a.zummo@towertech.it>,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
"Evgeniy Polyakov" <zbr@ioremap.net>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-amlogic@lists.infradead.org,
linux-mediatek@lists.infradead.org,
linux-arm-msm@vger.kernel.org,
linux-rockchip@lists.infradead.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-sunxi@lists.linux.dev, linux-rtc@vger.kernel.org,
"Rafał Miłecki" <rafal@milecki.pl>
Subject: Re: [PATCH V2] nvmem: add explicit config option to read OF fixed cells
Date: Wed, 8 Mar 2023 17:34:53 +0100 [thread overview]
Message-ID: <20230308173256.3837b87b@xps-13> (raw)
In-Reply-To: <20230224072903.20945-1-zajec5@gmail.com>
Hi Rafał,
zajec5@gmail.com wrote on Fri, 24 Feb 2023 08:29:03 +0100:
> From: Rafał Miłecki <rafal@milecki.pl>
>
> NVMEM subsystem looks for fixed NVMEM cells (specified in DT) by
> default. This behaviour made sense in early days before adding support
> for dynamic cells.
>
> With every new supported NVMEM device with dynamic cells current
> behaviour becomes non-optimal. It results in unneeded iterating over DT
> nodes and may result in false discovery of cells (depending on used DT
> properties).
>
> This behaviour has actually caused a problem already with the MTD
> subsystem. MTD subpartitions were incorrectly treated as NVMEM cells.
That's true, but I expect this to be really MTD specific.
A concrete proposal below.
> Also with upcoming support for NVMEM layouts no new binding or driver
> should support fixed cells defined in device node.
I'm not sure I agree with this statement. We are not preventing new
binding/driver to use fixed cells, or...? We offer a new way to expose
nvmem cells with another way than "fixed-offset" and "fixed-size" OF
nodes.
> Solve this by modifying drivers for bindings that support specifying
> fixed NVMEM cells in DT. Make them explicitly tell NVMEM subsystem to
> read cells from DT.
>
> It wasn't clear (to me) if rtc and w1 code actually uses fixed cells. I
> enabled them to don't risk any breakage.
>
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> [for drivers/nvmem/meson-{efuse,mx-efuse}.c]
> Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---
> V2: Fix stm32-romem.c typo breaking its compilation
> Pick Martin's Acked-by
> Add paragraph about layouts deprecating use_fixed_of_cells
> ---
> drivers/mtd/mtdcore.c | 2 ++
> drivers/nvmem/apple-efuses.c | 1 +
> drivers/nvmem/core.c | 8 +++++---
> drivers/nvmem/imx-ocotp-scu.c | 1 +
> drivers/nvmem/imx-ocotp.c | 1 +
> drivers/nvmem/meson-efuse.c | 1 +
> drivers/nvmem/meson-mx-efuse.c | 1 +
> drivers/nvmem/microchip-otpc.c | 1 +
> drivers/nvmem/mtk-efuse.c | 1 +
> drivers/nvmem/qcom-spmi-sdam.c | 1 +
> drivers/nvmem/qfprom.c | 1 +
> drivers/nvmem/rave-sp-eeprom.c | 1 +
> drivers/nvmem/rockchip-efuse.c | 1 +
> drivers/nvmem/sc27xx-efuse.c | 1 +
> drivers/nvmem/sprd-efuse.c | 1 +
> drivers/nvmem/stm32-romem.c | 1 +
> drivers/nvmem/sunplus-ocotp.c | 1 +
> drivers/nvmem/sunxi_sid.c | 1 +
> drivers/nvmem/uniphier-efuse.c | 1 +
> drivers/nvmem/zynqmp_nvmem.c | 1 +
> drivers/rtc/nvmem.c | 1 +
> drivers/w1/slaves/w1_ds250x.c | 1 +
> include/linux/nvmem-provider.h | 2 ++
> 23 files changed, 29 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index 0feacb9fbdac..1bb479c0f758 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -523,6 +523,7 @@ static int mtd_nvmem_add(struct mtd_info *mtd)
> config.dev = &mtd->dev;
> config.name = dev_name(&mtd->dev);
> config.owner = THIS_MODULE;
> + config.use_fixed_of_cells = of_device_is_compatible(node, "nvmem-cells");
I am wondering how mtd specific this is? For me all OF nodes containing
the nvmem-cells compatible should be treated as cells providers and
populate nvmem cells as for each children.
Why don't we just check for this compatible to be present? in
nvmem_add_cells_from_of() ? And if not we just skip the operation.
This way we still follow the bindings (even though using nvmem-cells in
the compatible property to require cells population was a mistake in
the first place, as discussed in the devlink thread recently) but there
is no need for a per-driver config option?
> config.reg_read = mtd_nvmem_reg_read;
> config.size = mtd->size;
> config.word_size = 1;
> @@ -891,6 +892,7 @@ static struct nvmem_device *mtd_otp_nvmem_register(struct mtd_info *mtd,
> config.name = kasprintf(GFP_KERNEL, "%s-%s", dev_name(&mtd->dev), compatible);
> config.id = NVMEM_DEVID_NONE;
> config.owner = THIS_MODULE;
> + config.use_fixed_of_cells = true;
> config.type = NVMEM_TYPE_OTP;
> config.root_only = true;
> config.ignore_wp = true;
> diff --git a/drivers/nvmem/apple-efuses.c b/drivers/nvmem/apple-efuses.c
> index 9b7c87102104..0119bac43b2c 100644
> --- a/drivers/nvmem/apple-efuses.c
> +++ b/drivers/nvmem/apple-efuses.c
> @@ -36,6 +36,7 @@ static int apple_efuses_probe(struct platform_device *pdev)
> struct resource *res;
> struct nvmem_config config = {
> .dev = &pdev->dev,
> + .use_fixed_of_cells = true,
> .read_only = true,
> .reg_read = apple_efuses_read,
> .stride = sizeof(u32),
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index 174ef3574e07..6783cd8478d7 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -844,9 +844,11 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
> if (rval)
> goto err_remove_cells;
>
> - rval = nvmem_add_cells_from_of(nvmem);
> - if (rval)
> - goto err_remove_cells;
> + if (config->use_fixed_of_cells) {
> + rval = nvmem_add_cells_from_of(nvmem);
> + if (rval)
> + goto err_remove_cells;
> + }
>
> dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->name);
>
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2023-03-08 16:35 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-24 7:29 [PATCH V2] nvmem: add explicit config option to read OF fixed cells Rafał Miłecki
2023-02-24 13:13 ` AngeloGioacchino Del Regno
2023-02-24 16:31 ` Claudiu.Beznea
2023-03-08 16:34 ` Miquel Raynal [this message]
2023-03-08 16:55 ` Rafał Miłecki
2023-03-08 18:06 ` Miquel Raynal
2023-03-08 18:12 ` Rafał Miłecki
2023-03-08 18:31 ` Miquel Raynal
2023-03-09 6:56 ` Rafał Miłecki
2023-03-09 8:34 ` Miquel Raynal
2023-03-09 8:39 ` Rafał Miłecki
2023-03-09 8:56 ` Miquel Raynal
2023-03-09 9:37 ` Srinivas Kandagatla
2023-03-09 9:40 ` Michael Walle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230308173256.3837b87b@xps-13 \
--to=miquel.raynal@bootlin.com \
--cc=a.zummo@towertech.it \
--cc=agross@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=alexandre.torgue@foss.st.com \
--cc=alyssa@rosenzweig.io \
--cc=andersson@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=asahi@lists.linux.dev \
--cc=baolin.wang@linux.alibaba.com \
--cc=claudiu.beznea@microchip.com \
--cc=festevam@gmail.com \
--cc=hayashi.kunihiko@socionext.com \
--cc=heiko@sntech.de \
--cc=jbrunet@baylibre.com \
--cc=jernej.skrabec@gmail.com \
--cc=kernel@pengutronix.de \
--cc=khilman@baylibre.com \
--cc=konrad.dybcio@linaro.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-rtc@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux-sunxi@lists.linux.dev \
--cc=marcan@marcan.st \
--cc=martin.blumenstingl@googlemail.com \
--cc=matthias.bgg@gmail.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=mhiramat@kernel.org \
--cc=michal.simek@xilinx.com \
--cc=neil.armstrong@linaro.org \
--cc=orsonzhai@gmail.com \
--cc=rafal@milecki.pl \
--cc=richard@nod.at \
--cc=s.hauer@pengutronix.de \
--cc=samuel@sholland.org \
--cc=shawnguo@kernel.org \
--cc=srinivas.kandagatla@linaro.org \
--cc=sven@svenpeter.dev \
--cc=vigneshr@ti.com \
--cc=vincent.sunplus@gmail.com \
--cc=wens@csie.org \
--cc=zajec5@gmail.com \
--cc=zbr@ioremap.net \
--cc=zhang.lyra@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox