lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251103143452.080c3503@bootlin.com>
Date: Mon, 3 Nov 2025 14:34:52 +0100
From: Herve Codina <herve.codina@...tlin.com>
To: Andi Shyti <andi.shyti@...nel.org>
Cc: Andrew Lunn <andrew@...n.ch>, Rob Herring <robh@...nel.org>, Krzysztof
 Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>, Greg
 Kroah-Hartman <gregkh@...uxfoundation.org>, "Rafael J. Wysocki"
 <rafael@...nel.org>, Danilo Krummrich <dakr@...nel.org>, Shawn Guo
 <shawnguo@...nel.org>, Sascha Hauer <s.hauer@...gutronix.de>, Pengutronix
 Kernel Team <kernel@...gutronix.de>, Fabio Estevam <festevam@...il.com>,
 Michael Turquette <mturquette@...libre.com>, Stephen Boyd
 <sboyd@...nel.org>, Wolfram Sang <wsa+renesas@...g-engineering.com>, Peter
 Rosin <peda@...ntia.se>, Arnd Bergmann <arnd@...db.de>, Saravana Kannan
 <saravanak@...gle.com>, Bjorn Helgaas <bhelgaas@...gle.com>, Charles Keepax
 <ckeepax@...nsource.cirrus.com>, Richard Fitzgerald
 <rf@...nsource.cirrus.com>, David Rhodes <david.rhodes@...rus.com>, Linus
 Walleij <linus.walleij@...aro.org>, Ulf Hansson <ulf.hansson@...aro.org>,
 Mark Brown <broonie@...nel.org>, Andy Shevchenko
 <andriy.shevchenko@...ux.intel.com>, Daniel Scally <djrscally@...il.com>,
 Heikki Krogerus <heikki.krogerus@...ux.intel.com>, Sakari Ailus
 <sakari.ailus@...ux.intel.com>, Len Brown <lenb@...nel.org>, Davidlohr
 Bueso <dave@...olabs.net>, Jonathan Cameron <jonathan.cameron@...wei.com>,
 Dave Jiang <dave.jiang@...el.com>, Alison Schofield
 <alison.schofield@...el.com>, Vishal Verma <vishal.l.verma@...el.com>, Ira
 Weiny <ira.weiny@...el.com>, Dan Williams <dan.j.williams@...el.com>, Geert
 Uytterhoeven <geert+renesas@...der.be>, Wolfram Sang <wsa@...nel.org>,
 devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
 imx@...ts.linux.dev, linux-arm-kernel@...ts.infradead.org,
 linux-clk@...r.kernel.org, linux-i2c@...r.kernel.org,
 linux-pci@...r.kernel.org, linux-sound@...r.kernel.org,
 patches@...nsource.cirrus.com, linux-gpio@...r.kernel.org,
 linux-pm@...r.kernel.org, linux-spi@...r.kernel.org,
 linux-acpi@...r.kernel.org, linux-cxl@...r.kernel.org, Allan Nielsen
 <allan.nielsen@...rochip.com>, Horatiu Vultur
 <horatiu.vultur@...rochip.com>, Steen Hegelund
 <steen.hegelund@...rochip.com>, Luca Ceresoli <luca.ceresoli@...tlin.com>,
 Thomas Petazzoni <thomas.petazzoni@...tlin.com>
Subject: Re: [PATCH v4 18/29] i2c: mux: Create missing devlink between mux
 and adapter physical device

Hi Andi,

On Thu, 30 Oct 2025 16:23:24 +0100
Andi Shyti <andi.shyti@...nel.org> wrote:

> Hi Herve,
> 
> ...
> 
> > When an i2c mux is involved in an i2c path, the struct dev topology is
> > the following:  
> 
> supernitpick: I'd leave blank line here.

Will be added.

> 
> >     +----------------+                +-------------------+
> >     | i2c controller |                |      i2c mux      |
> >     |     device     |                |      device       |
> >     |       ^        |                |                   |
> >     |       |        |                |                   |
> >     |  dev's parent  |                |                   |
> >     |       |        |                |                   |
> >     |   i2c adapter  |                | i2c adapter chanX |
> >     |     device  <---- dev's parent ------  device       |
> >     |   (no driver)  |                |    (no driver)    |
> >     +----------------+                +-------------------+
> >   
> 
> ...
> 
> > No relationship exists between the i2c mux device itself and the i2c
> > controller device (physical device) in order to have the i2c mux device
> > calling i2c_del_adapter() to remove its downtream adapters and so,  
> 
> /downtream/downstream/

Will be fixed

> 
> > release references taken to the upstream adapter.  
> 
> ...
> 
> > +	/*
> > +	 * There is no relationship set between the mux device and the physical
> > +	 * device handling the parent adapter. Create this missing relationship
> > +	 * in order to remove the i2c mux device (consumer) and so the dowstream
> > +	 * channel adapters before removing the physical device (supplier) which
> > +	 * handles the i2c mux upstream adapter.
> > +	 */
> > +	parent_physdev = i2c_get_adapter_physdev(parent);
> > +	if (!parent_physdev) {
> > +		dev_err(muxc->dev, "failed to get the parent physical device\n");
> > +		ret = -EINVAL;  
> 
> -ENODEV?

Yes, -ENODEV makes sense here. Will be changed in the next iteration.

> 
> > +		goto err_free_priv;
> > +	}
> > +	dl = device_link_add(muxc->dev, parent_physdev, DL_FLAG_AUTOREMOVE_CONSUMER);  
> 
> Not to call twice put_device, I would add it once here and then
> check for !dl.

As Andy already mentioned, we cannot do that. Indeed, dev_name(parent_physdev)
is called in the error path and so the device reference has to be kept.

> 
> > +	if (!dl) {
> > +		dev_err(muxc->dev, "failed to create device link to %s\n",
> > +			dev_name(parent_physdev));
> > +		put_device(parent_physdev);
> > +		ret = -EINVAL;  
> 
> same here, should this be -ENODEV?

For this one, I am not so sure.

The failure is related to the device link creation and probably due to some
devlink invalid internal flags or state instead of a missing device.

That's said, if you really want the -ENODEV here, let me know.

Best regards,
Hervé

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ