devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Michael Walle" <michael@walle.cc>,
	"Rafał Miłecki" <rafal@milecki.pl>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Frank Rowand" <frowand.list@gmail.com>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Robert Marko" <robert.marko@sartura.hr>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Luka Perkov" <luka.perkov@sartura.hr>,
	"Randy Dunlap" <rdunlap@infradead.org>,
	"Chen-Yu Tsai" <wenst@chromium.org>,
	"Daniel Golle" <daniel@makrotopia.org>
Subject: Re: [PATCH v12 5/7] nvmem: core: Rework layouts to become regular devices
Date: Wed, 11 Oct 2023 11:02:29 +0100	[thread overview]
Message-ID: <04112100-026c-b010-6e8c-730049d43e47@linaro.org> (raw)
In-Reply-To: <20231011093843.49831a75@xps-13>

Hi Miquel,

On 11/10/2023 08:38, Miquel Raynal wrote:
> Hi Srinivas,
> 
> srinivas.kandagatla@linaro.org wrote on Mon, 9 Oct 2023 10:44:45 +0100:
> 
>> On 05/10/2023 16:59, Miquel Raynal wrote:
>>> Current layout support was initially written without modules support in
>>> mind. When the requirement for module support rose, the existing base
>>> was improved to adopt modularization support, but kind of a design flaw
>>> was introduced. With the existing implementation, when a storage device
>>> registers into NVMEM, the core tries to hook a layout (if any) and
>>> populates its cells immediately. This means, if the hardware description
>>> expects a layout to be hooked up, but no driver was provided for that,
>>> the storage medium will fail to probe and try later from
>>> scratch. Technically, the layouts are more like a "plus" and, even we
>>
>> This is not true, As layouts are kind of resources for nvmem providers, Ideally the provider driver should defer if there is no matching layout available.
> 
> That is not possible as layouts are now devices, the device will be
> populated but you cannot know when it will be actually probed?
> 
>> Expressing this as a weak dependency is going to be an issue,
>>
>> 1. With creating the sysfs entries and user notifications
> 
> For me, this is not an issue. Greg?
> 
>> 2. nvmem consumers will be in a confused state with provider registered but without cells added yet.
> 
> Wow, I feel like we are moving backwards.
> 
> Consumers don't know about the nvmem devices, they just care about a
> cell. If the cell isn't there, the consumer decides what it wants
> to do with that.
> 
> We initially discussed that we would not EPROBE_DEFER if the layouts
> were not yet available because the NVMEM device may be created from a
> device that is the main storage and while you don't have your rootfs,

Does it not sound like we are not expressing the dependencies between 
nvmem provider and layout drivers correctly?


> you don't have access to your modules. And anyway it's probably a bad
> idea to allow endless probe deferrals on your main storage device.
> 
> If the cells are not available at that time, it's not a huge deal? The
> consumers will have to wait a bit more (or take any other action, this
> is device dependent).

In this case the nvmem consumers will get an -ENOENT error, which is 
very confusing TBH.


thanks,
Srini

> 
>> --srini
>>> consider that the hardware description shall be correct, we could still
>>> probe the storage device (especially if it contains the rootfs).
>>>
>>> One way to overcome this situation is to consider the layouts as
>>> devices, and leverage the existing notifier mechanism. When a new NVMEM
>>> device is registered, we can:
>>> - populate its nvmem-layout child, if any
>>> - try to modprobe the relevant driver, if relevant
>>> - try to hook the NVMEM device with a layout in the notifier
>>> And when a new layout is registered:
>>> - try to hook all the existing NVMEM devices which are not yet hooked to
>>>     a layout with the new layout
>>> This way, there is no strong order to enforce, any NVMEM device creation
>>> or NVMEM layout driver insertion will be observed as a new event which
>>> may lead to the creation of additional cells, without disturbing the
>>> probes with costly (and sometimes endless) deferrals.
>>>
>>> In order to achieve that goal we need:
>>> * To keep track of all nvmem devices
>>> * To create a new bus for the nvmem-layouts with minimal logic to match
>>>     nvmem-layout devices with nvmem-layout drivers.
>>> All this infrastructure code is created in the layouts.c file.
>>>
>>> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
>>> Tested-by: Rafał Miłecki <rafal@milecki.pl>
>>> ---
> 
> Thanks,
> Miquèl

  reply	other threads:[~2023-10-11 10:02 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-05 15:59 [PATCH v12 0/7] NVMEM cells in sysfs Miquel Raynal
2023-10-05 15:59 ` [PATCH v12 1/7] of: device: Export of_device_make_bus_id() Miquel Raynal
2023-10-06 17:02   ` Rob Herring
2023-10-05 15:59 ` [PATCH v12 2/7] nvmem: Clarify the situation when there is no DT node available Miquel Raynal
2023-10-06 11:41   ` Rafał Miłecki
2023-10-06 16:32     ` Miquel Raynal
2023-10-07 16:09       ` Rafał Miłecki
2023-10-08 13:39         ` Miquel Raynal
2023-10-09  9:44       ` Srinivas Kandagatla
2023-10-05 15:59 ` [PATCH v12 3/7] nvmem: Move of_nvmem_layout_get_container() in another header Miquel Raynal
2023-10-05 15:59 ` [PATCH v12 4/7] nvmem: Create a header for internal sharing Miquel Raynal
2023-10-05 15:59 ` [PATCH v12 5/7] nvmem: core: Rework layouts to become regular devices Miquel Raynal
2023-10-06 11:49   ` Rafał Miłecki
2023-10-06 16:33     ` Miquel Raynal
2023-10-07 16:31   ` Greg Kroah-Hartman
2023-10-11 10:33     ` Miquel Raynal
2023-10-08 13:42   ` kernel test robot
2023-10-09  9:44   ` Srinivas Kandagatla
2023-10-11  7:38     ` Miquel Raynal
2023-10-11 10:02       ` Srinivas Kandagatla [this message]
2023-10-11 10:58         ` Miquel Raynal
2023-10-05 15:59 ` [PATCH v12 6/7] ABI: sysfs-nvmem-cells: Expose cells through sysfs Miquel Raynal
2023-10-05 15:59 ` [PATCH v12 7/7] nvmem: core: " Miquel Raynal
2023-10-09  9:48   ` Srinivas Kandagatla
2023-10-11  7:15     ` Miquel Raynal
2023-10-11  8:27       ` Srinivas Kandagatla
2023-10-11  8:33         ` Miquel Raynal
2023-10-11  8:45           ` Srinivas Kandagatla
2023-10-11  8:58             ` Miquel Raynal
2023-10-11  9:26               ` Srinivas Kandagatla
2023-10-11  9:44                 ` Miquel Raynal
2023-10-11 10:02                   ` Srinivas Kandagatla
2023-10-11 11:09                     ` Miquel Raynal
2023-10-11 13:56                       ` Srinivas Kandagatla
2023-10-11 14:02                         ` Miquel Raynal

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=04112100-026c-b010-6e8c-730049d43e47@linaro.org \
    --to=srinivas.kandagatla@linaro.org \
    --cc=daniel@makrotopia.org \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luka.perkov@sartura.hr \
    --cc=michael@walle.cc \
    --cc=miquel.raynal@bootlin.com \
    --cc=rafal@milecki.pl \
    --cc=rdunlap@infradead.org \
    --cc=robert.marko@sartura.hr \
    --cc=robh+dt@kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=wenst@chromium.org \
    /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;
as well as URLs for NNTP newsgroup(s).