Re: [PATCH v4 2/7] nvme: assign of_node to nvme device

Rob Herring
2024-08-13T20:04:09Z

On Mon, Aug 12, 2024 at 03:31:28PM +0200, Christoph Hellwig wrote:
> On Mon, Aug 12, 2024 at 02:10:28PM +0200, Christian Marangi wrote:
> > The chosen name was arbritrary just to follow eMMC ones. Can totally
> > change if problematic.

The purpose of those eMMC nodes was to describe various non-standard
stuff you get when discoverable devices get soldered on a board. Power
rails, reset GPIOs, etc. It was not to put partition info there, but I
suppose having the node opens it to such abuse.

>
> NVMe namespaces are dynamic and can be created and deleted at will
> at runtime. I just don't see how they would even fit into OF
> concepts.
>
> There is a huge impedance mismatch here, to the point where I completely
> fail to understand what you are trying to do.
>
> > But support of OF for PCIe is already a thing for a long time. (it all
> > works by setting the compatible of the PCIe ID card) and used in wifi
> > card at assign MAC address, calibration data, disable frequency.
>
> Please point to a document describing how, but more importantly why
> this is done. I've worked with and maintained Linux PCI(e) drivers for
> about 20 years and never seen it. And the concept simply doesn't make
> sense in terms of a dynamically probed bus.

With OpenFirmware systems, the firmware will probe PCI and populate
nodes with what it discovered and with how it configured things. IBM
PSeries uses DT for PCI hotplug as well, AIUI.

For Flattened DT, PCI devices are typically only present if there are
extra non-discoverable things (again, happens when devices are soldered
down and not in standard slots). Another example is a NIC where they
cheaped out and didn't put an EEPROM to store the MAC address, so you
store it in the DT. Now we're starting to see non-discoverable things
sitting behind PCI devices, so we need the PCI device in DT to describe
those downstream devices.

> > Not having this well organized and consistent schema in DT will result
> > in additional condition in the drivers...
>
> NVMe Controllers are PCI functions (or virtual entities over the network).
> Defining them in a static DT scheme does not make sense. NVMe Namespaces
> which are what contains the block data are dynamically discoverred and
> can be created and deleted at runtime, so refering to them in DT is even
> more broken. I really don't see how any of this could remotely work.
>
> > If these 2 patch are problematic I can totally drop from the series but
> > it was really to add consistency in NVMe and eMMC. The real important
> > part is eMMC that is becoming the de-facto replacement for NAND/NOR on
> > high tier devices (mostly wifi6/7 consumer router)
>
> If you aren't dealing with raw(ish) NAND don't use mtd. MTD is designed
> to deal with the nitty gritty details of NOR and NAND flash. If you
> already have an FTL running in the device there is absolutely no reason
> to use it.

Yes, agreed.

Rob