Netdev List
 help / color / mirror / Atom feed
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Lee Jones <lee@kernel.org>
Cc: netdev@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 07/15] mfd: core: add ability for cells to probe on a custom parent OF node
Date: Thu, 15 Jan 2026 20:57:59 +0200	[thread overview]
Message-ID: <20260115185759.femufww2b6ar27lz@skbuf> (raw)
In-Reply-To: <20260115161407.GI2842980@google.com> <20260115161407.GI2842980@google.com>

On Thu, Jan 15, 2026 at 04:14:07PM +0000, Lee Jones wrote:
> > > My plan, when and if I manage to find a few spare cycles, is to remove
> > > MFD use from outside drivers/mfd.  That's been my rule since forever.
> > > Having this in place ensures that the other rules are kept and (mild)
> > > chaos doesn't ensue.  The MFD API is trivial to abuse.  You wouldn't
> > > believe some of things I've seen over the years.  Each value I have is
> > > there for a historical reason.
> > 
> > If you're also of the opinion that MFD is a Linux-specific
> > implementation detail and a figment of our imagination as developers,
> > then I certainly don't understand why Documentation/devicetree/bindings/mfd/
> > exists for this separate device class that is MFD, and why you don't
> > liberalize access to mfd_add_devices() instead.
> 
> The first point is a good one.  It mostly exists for historical
> reasons and for want of a better place to locate the documentation.
> 
> I've explained why liberalising the mfd_*() API is a bad idea.  "Clever"
> developers like to do some pretty crazy stuff involving the use of
> multiple device registration APIs simultaneously.  I've also seen some
> bonkers methods of dynamically populating MFD cells [*ahem* Patch 8
> =;-)] and various other things.  Keeping the API in-house allows me to
> keep things simple, easily readable and maintainable.

The only thing that's crazy to me is how the MFD documentation (+ my
intuition as engineer to fill in the gaps where the documentation was
lacking, aka in a lot of places) could be so far off from what you lay
out as your maintainer expectations here.

> > > I had to go and remind myself of your DT:
> > > 
> > >         ethernet-switch@0 {
> > >                 compatible = "nxp,sja1110a";
> > > 
> > >                 mdios {
> > >                         mdio@0 {
> > >                                 compatible = "nxp,sja1110-base-t1-mdio";
> > >                         };
> > > 
> > >                         mdio@1 {
> > >                                 compatible = "nxp,sja1110-base-tx-mdio";
> > >                         };
> > >                 };
> > >         };
> > > 
> > > To my untrained eye, this looks like two instances of a MDIO device.
> > > 
> > > Are they truly different enough to be classified for "Multi"?
> > 
> > Careful about terms, these are MDIO "buses" and not MDIO "devices"
> > (children of those buses).
> 
> Noted.  But then isn't it odd to see the bus mentioned in the compatible
> string.  Don't we usually only see this in the controller's compatibles?

???
bus == controller.
The "nxp,sja1110-base-t1-mdio" and "nxp,sja1110-base-tx-mdio" are MDIO
buses/controllers following the Documentation/devicetree/bindings/net/mdio.yaml
schema.
There are plenty of other devices which have "$ref: mdio.yaml#" and
which have "mdio" in their compatible string: "ti,davinci_mdio",
"qcom,ipq8064-mdio"... This is the same thing.

The "MDIO bus" / "MDIO device" terminology distinction is no different
than "SPI bus" / "SPI device", if that helps you better understand why I
said "buses, not devices".

> > Let me reframe what I think you are saying.
> > 
> > If the aesthetics of the dt-bindings of my SPI device were like this (1):
> > 
> > (...)
> > 
> > then you wouldn't have had any issue about this not being MFD, correct?
> 
> Right.  This is more in-line with what I would expect to see.
> 
> > I think this is an important base fact to establish.
> > It looks fairly similar to Colin Foster's bindings for VSC7512, save for
> > the fact that the sub-devices are slightly more varied (which is inconsequential,
> > as Andrew seems to agree).
> > 
> > However, the same physical reality is being described in these _actual_
> > dt-bindings (2):
> > 
> > (...)
> > 
> > Your issue is that, when looking at these real dt-bindings,
> > superficially the MDIO buses don't "look" like MFD.
> > 
> > To which, yes, I have no objection, they don't look like MFD because
> > they were written as additions on top of the DSA schema structure, not
> > according to the MFD schema.
> > 
> > In reality it doesn't matter much where the MDIO bus nodes are (they
> > could have been under "regs" as well, or under "mfd@0"), because DSA
> > ports get references to their children using phandles. It's just that
> > they are _already_ where they are, and moving them would be an avoidable
> > breaking change.
> 
> Right.  I think this is highly related to one of my previous comments.
> 
> I can't find it right now, but it was to the tune of; if a single driver
> provides lots of functionality that _could_ be split-up, spread across
> multiple different subsystems which all enumerate as completely
> separate device-drivers, but isn't, then it still shouldn't meet the
> criteria.

Any arbitrary set of distinct functions can be grouped into a new
monolithic driver. Are you saying that grouping them together is fine,
but never split them back up, at least not using MFD? What's the logic?

> > Exactly. DSA drivers get more developed with new each new hardware
> > generation, and you wouldn't want to see an MFD driver + its bindings
> > "just in case" new sub-devices will appear, when currently the DSA
> > switch is the only component supported by Linux (and maybe its internal
> > MDIO bus).
> 
> If only one device is currently supported, then again, it doesn't meet
> the criteria.  I've had a bunch of developers attempt to upstream
> support for a single device and insist that more sub-devices are coming
> which would make it an MFD, but that's not how it works.  Devices must
> meet the criteria _now_.  So I usually ask them go take the time to get
> at least one more device ready before attempting to upstream.

sja1105 is a multi-generational DSA driver. Gen 1 SJA1105E/T has 0
sub-devices, Gen 2 SJA1105R/S have 1 sub-device (XPCS) and Gen3 SJA1110
have 5+ sub-devices.

The driver was written for Gen 1, then was expanded for the later
generations as the silicon was released (multiple years in between these
events).

You are effectively saying:
- MAX77540 wouldn't have been accepted as MFD on its own, it was
  effectively carried in by MAX77541 support.
- A driver that doesn't have sufficiently varied subfunctions doesn't
  qualify as MFD.
- A monolithic driver whose subfunctions can be split up doesn't meet
  the MFD criteria.

So in your rule system, a multi-generational driver which evolves into
having multiple sub-devices has no chance of ever using MFD, unless it
is written after the evolution has stopped, and the old generations
become obsolete.

Unless you're of the opinion that it's my fault for not predicting the
future and waiting until the SJA1110 came out in order to write an MFD
driver, I suggest you could reconsider your rules so that they're less
focused on your comfort as maintainer, at the expense of fairness and
coherency for other developers.

> Is there any reason not to put mdio_cbt and mdio_cbt1 resources into the
> device tree

That ship has sailed and there are device trees in circulation with
existing mdio_cbtx/mdio_cbt1 bindings.

> or make them available somewhere else (e.g. driver.of_match_table.data)
> and use of_platform_populate() instead of mfd_add_devices() (I can't
> remember if we've suggested that before or not).

I never got of_platform_populate() to work for a pretty fundamental
reason, so I don't have enough information to know what you're on about
with making the mdio_cbtx/mdio_cbt1 resources available to it.

> Right, I think we've discussed this enough.  I've made a decision.
> 
> If the of_platform_populate() solution doesn't work for you for some
> reason (although I think it should),

Quote from the discussion on patch 8:

I did already explore of_platform_populate() on this thread which asked
for advice (to which you were also copied):
https://lore.kernel.org/lkml/20221222134844.lbzyx5hz7z5n763n@skbuf/

    It looks like of_platform_populate() would be an alternative option for
    this task, but that doesn't live up to the task either. It will assume
    that the addresses of the SoC children are in the CPU's address space
    (IORESOURCE_MEM), and attempt to translate them. It simply doesn't have
    the concept of IORESOURCE_REG. The MFD drivers which call
    of_platform_populate() (simple-mfd-i2c.c) simply don't have unit
    addresses for their children, and this is why address translation isn't
    a problem for them.

    In fact, this seems to be a rather large limitation of include/linux/of_address.h.
    Even something as simple as of_address_count() will end up trying to
    translate the address into the CPU memory space, so not even open-coding
    the resource creation in the SoC driver is as simple as it appears.

    Is there a better way than completely open-coding the parsing of the OF
    addresses when turning them into IORESOURCE_REG resources (or open-coding
    mfd_cells for each child)? Would there be a desire in creating a generic
    set of helpers which create platform devices with IORESOURCE_REG resources,
    based solely on OF addresses of children? What would be the correct
    scope for these helpers?

> given the points you've put forward, I would be content for you to
> house the child device registration (via mfd_add_devices) in
> drivers/mfd if you so wish.

Thanks! But I don't know how this helps me :)

Since your offer involves changing dt-bindings in order to separate the
MFD parent from the DSA switch (currently the DSA driver probes on the
spi_device, clashing with the MFD parent which wants the same thing), I
will have to pass.

Not because I insist on being difficult, but because I know that when I
change dt-bindings, the old ones don't just disappear and will continue
to have to be supported, likely through a separate code path that would
also increase code complexity.

> Although I still don't think modifying the core to ignore bespoke empty
> "container" nodes is acceptable.  It looks like this was merged without
> a proper DT review.  I'm surprised that this was accepted.

There was a debate when this was accepted, but we didn't come up with
anything better to fulfill the following constraints:
- As per mdio.yaml, the $nodename has to follow the pattern:
  '^mdio(-(bus|external))?(@.+|-([0-9]+))?$'
- There are two MDIO buses. So we have to choose the variant with a
  unit-address (both MDIO buses are for internal PHYs, so we can't call
  one "mdio" and the other "mdio-external").
- Nodes with a unit address can't be hierarchical neighbours with nodes
  with no unit address (concretely: "ethernet-ports" from
  Documentation/devicetree/bindings/net/ethernet-switch.yaml, the main
  schema that the DSA switch conforms to). This is because their parent
  either has #address-cells = <0>, or #address-cells = <1>. It can't
  simultaneously have two values.

Simply put, there is no good place to attach child nodes with unit
addresses to a DT node following the DSA (or the more general
ethernet-switch) schema. The "mdios" container node serves exactly that
adaptation purpose.

I am genuinely curious how you would have handled this better, so that I
also know better next time when I'm in a similar situation.

Especially since "mdios" is not the only container node with this issue.
The "regs" node proposed in patch 14 serves exactly the same purpose
(#address-cells adaptation), and needs the exact same ".parent_of_node = regs_node"
workaround in the mfd_cell.

  reply	other threads:[~2026-01-15 18:58 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-18 19:05 [PATCH net-next 00/15] Probe SJA1105 DSA children using MFD and dynamic OF nodes Vladimir Oltean
2025-11-18 19:05 ` [PATCH net-next 01/15] net: dsa: sja1105: let phylink help with the replay of link callbacks Vladimir Oltean
2025-11-18 19:05 ` [PATCH net-next 02/15] net: mdio-regmap: permit working with non-MMIO regmaps Vladimir Oltean
2025-11-20 14:35   ` Maxime Chevallier
2025-11-18 19:05 ` [PATCH net-next 03/15] net: mdio: add driver for NXP SJA1110 100BASE-T1 embedded PHYs Vladimir Oltean
2025-11-18 19:05 ` [PATCH net-next 04/15] net: mdio: add generic driver for NXP SJA1110 100BASE-TX " Vladimir Oltean
2025-11-20 17:55   ` Maxime Chevallier
2025-11-20 18:49     ` Vladimir Oltean
2025-11-18 19:05 ` [PATCH net-next 05/15] net: dsa: sja1105: prepare regmap for passing to child devices Vladimir Oltean
2025-11-18 19:05 ` [PATCH net-next 06/15] net: dsa: sja1105: include spi.h from sja1105.h Vladimir Oltean
2025-11-18 19:05 ` [PATCH net-next 07/15] mfd: core: add ability for cells to probe on a custom parent OF node Vladimir Oltean
2025-11-20 14:41   ` Lee Jones
2025-11-20 15:36     ` Vladimir Oltean
2025-11-21 12:06       ` Lee Jones
2025-11-21 17:03         ` Vladimir Oltean
2025-11-26 10:20           ` Lee Jones
2025-12-15 15:50           ` Lee Jones
2025-12-16  0:29             ` Vladimir Oltean
2025-12-16  9:18               ` Lee Jones
2025-12-16 16:24                 ` Vladimir Oltean
2026-01-09 10:31                   ` Lee Jones
2026-01-09 12:14                     ` Vladimir Oltean
2026-01-15  9:35                       ` Vladimir Oltean
2026-01-15 15:18                         ` Lee Jones
2026-01-15 16:14                       ` Lee Jones
2026-01-15 18:57                         ` Vladimir Oltean [this message]
2026-01-16  8:40                           ` Lee Jones
2026-01-16 11:38                             ` Vladimir Oltean
2026-01-16 13:23                               ` Lee Jones
2026-01-16 14:02                                 ` Vladimir Oltean
2026-01-16 14:22                                   ` Vladimir Oltean
2025-12-17  9:31                 ` Andrew Lunn
2026-01-09  9:58                   ` Lee Jones
2025-11-18 19:05 ` [PATCH net-next 08/15] net: dsa: sja1105: transition OF-based MDIO drivers to standalone Vladimir Oltean
2025-11-20 14:40   ` Lee Jones
2025-11-20 15:14     ` Vladimir Oltean
2025-11-20 16:36       ` Lee Jones
2025-11-20 19:59         ` Vladimir Oltean
2025-11-21 12:00           ` Lee Jones
2025-11-18 19:05 ` [PATCH net-next 09/15] net: dsa: sja1105: remove sja1105_mdio_private Vladimir Oltean
2025-11-18 19:05 ` [PATCH net-next 10/15] net: pcs: xpcs: introduce xpcs_create_pcs_fwnode() Vladimir Oltean
2025-11-18 19:05 ` [PATCH net-next 11/15] net: pcs: xpcs-plat: convert to regmap Vladimir Oltean
2025-11-18 19:05 ` [PATCH net-next 12/15] dt-bindings: net: dsa: sja1105: document the PCS nodes Vladimir Oltean
2025-11-20 17:30   ` Rob Herring
2025-11-18 19:05 ` [PATCH net-next 13/15] net: pcs: xpcs-plat: add NXP SJA1105/SJA1110 support Vladimir Oltean
2025-11-18 19:05 ` [PATCH net-next 14/15] net: dsa: sja1105: replace mdiobus-pcs with xpcs-plat driver Vladimir Oltean
2025-11-19  0:41   ` Jakub Kicinski
2025-11-19  9:59     ` Vladimir Oltean
2025-11-19 10:31       ` Andy Shevchenko
2025-11-19 11:25         ` Vladimir Oltean
2025-11-19 16:11           ` Jakub Kicinski
2025-11-19 16:17             ` Andy Shevchenko
2025-11-19 17:23               ` Russell King (Oracle)
2025-11-19 17:39                 ` Andy Shevchenko
2025-11-19 18:35                   ` Jakub Kicinski
2025-11-19 19:33                     ` Andy Shevchenko
2025-11-20 12:32             ` Russell King (Oracle)
2025-11-20 15:00               ` Jakub Kicinski
2025-11-19 11:19   ` kernel test robot
2025-11-19 12:01     ` Vladimir Oltean
2025-11-19 12:03       ` Russell King (Oracle)
2025-11-19 12:05         ` Russell King (Oracle)
2025-11-19 13:28           ` Vladimir Oltean
2025-11-19 12:01   ` kernel test robot
2025-11-20  0:01   ` kernel test robot
2025-11-18 19:05 ` [PATCH net-next 15/15] net: dsa: sja1105: permit finding the XPCS via pcs-handle Vladimir Oltean

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=20260115185759.femufww2b6ar27lz@skbuf \
    --to=vladimir.oltean@nxp.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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