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 2DE31C678D5 for ; Wed, 8 Mar 2023 18:13:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230085AbjCHSNE (ORCPT ); Wed, 8 Mar 2023 13:13:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230033AbjCHSMz (ORCPT ); Wed, 8 Mar 2023 13:12:55 -0500 Received: from 16.mo561.mail-out.ovh.net (16.mo561.mail-out.ovh.net [188.165.56.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CCD1CE96F for ; Wed, 8 Mar 2023 10:12:40 -0800 (PST) Received: from director8.ghost.mail-out.ovh.net (unknown [10.108.4.98]) by mo561.mail-out.ovh.net (Postfix) with ESMTP id D1E83206F5 for ; Wed, 8 Mar 2023 18:12:38 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-cqldr (unknown [10.110.115.240]) by director8.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 1EF4D1FDE9; Wed, 8 Mar 2023 18:12:33 +0000 (UTC) Received: from RCM-web1.webmail.mail.ovh.net ([176.31.238.120]) by ghost-submission-6684bf9d7b-cqldr with ESMTPSA id NAwlBhHQCGQKAhoAZIOUGg (envelope-from ); Wed, 08 Mar 2023 18:12:33 +0000 MIME-Version: 1.0 Date: Wed, 08 Mar 2023 19:12:32 +0100 From: =?UTF-8?Q?Rafa=C5=82_Mi=C5=82ecki?= To: Miquel Raynal Cc: =?UTF-8?Q?Rafa=C5=82_Mi=C5=82ecki?= , Srinivas Kandagatla , Richard Weinberger , Vignesh Raghavendra , Hector Martin , Sven Peter , Alyssa Rosenzweig , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Claudiu Beznea , Matthias Brugger , AngeloGioacchino Del Regno , Andy Gross , Bjorn Andersson , Konrad Dybcio , Heiko Stuebner , Orson Zhai , Baolin Wang , Chunyan Zhang , Maxime Coquelin , Alexandre Torgue , Vincent Shih , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Kunihiko Hayashi , Masami Hiramatsu , Michal Simek , Alessandro Zummo , Alexandre Belloni , Evgeniy Polyakov , 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 Subject: Re: [PATCH V2] nvmem: add explicit config option to read OF fixed cells In-Reply-To: <20230308190636.7fabab9c@xps-13> References: <20230224072903.20945-1-zajec5@gmail.com> <20230308173256.3837b87b@xps-13> <91ff425b4c901648b1faf34c784f20ad@milecki.pl> <20230308190636.7fabab9c@xps-13> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <5974d28426057975e701c4a8454b5a13@milecki.pl> X-Sender: rafal@milecki.pl X-Originating-IP: 194.187.74.233 X-Webmail-UserID: rafal@milecki.pl Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 14994172011305216839 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrvddufedgieduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepggffhffvvefujghffgfkgihitgfgsehtkehjtddtreejnecuhfhrohhmpeftrghfrghlucfoihhlvggtkhhiuceorhgrfhgrlhesmhhilhgvtghkihdrphhlqeenucggtffrrghtthgvrhhnpeejvdelgfeutdfhfeelheegfedtleduleeuvdfgfeefvefhvedtheetjeetfeehgeenucfkphepuddvjedrtddrtddruddpudelgedrudekjedrjeegrddvfeefpddujeeirdefuddrvdefkedruddvtdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepoehrrghfrghlsehmihhlvggtkhhirdhplheqpdhnsggprhgtphhtthhopedupdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdfovfetjfhoshhtpehmohehiedupdhmohguvgepshhmthhpohhuth Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023-03-08 19:06, Miquel Raynal wrote: > Hi Rafał, > > rafal@milecki.pl wrote on Wed, 08 Mar 2023 17:55:46 +0100: > >> On 2023-03-08 17:34, Miquel Raynal wrote: >> > Hi Rafał, >> > >> > zajec5@gmail.com wrote on Fri, 24 Feb 2023 08:29:03 +0100: >> > >> >> From: Rafał Miłecki >> >> >> 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. >> >> From what I understood all new NVMEM bindings should have cells >> defined >> in the nvmem-layout { } node. That's what I mean by saying they should >> not be defined in device node (but its "nvmem-layout" instead). > > Layouts are just another possibility, either you user the nvmem-cells > compatible and produce nvmem cells with fixed OF nodes, or you use the > nvmem-layout container. I don't think all new bindings should have > cells in layouts. It depends if the content is static or not. > >> >> 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 >> >> [for drivers/nvmem/meson-{efuse,mx-efuse}.c] >> >> Acked-by: Martin Blumenstingl >> >> --- >> >> 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? >> >> This isn't mtd specific. Please check this patch for all occurrences >> of >> the: >> use_fixed_of_cells = true >> >> The very first one: drivers/nvmem/apple-efuses.c driver for the >> "apple,efuses" binding. That binding supports fixed OF cells, see: >> Documentation/devicetree/bindings/nvmem/apple,efuses.yaml > > I'm saying: based on what has been enforced so far, I would expect all > fixed cell providers to come with nvmem-cells as compatible, no? > > If that's the case we could use that as a common denominator? Sorry, I don't get it. Have you checked Documentation/devicetree/bindings/nvmem/apple,efuses.yaml ? It's a NVMEM provied binding with fixed cells that doesn't use nvmem-cells as compatible. There are many more.