devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saravana Kannan <saravanak@google.com>
To: Michael Pratt <mcpratt@pm.me>
Cc: devicetree@vger.kernel.org, gregkh@linuxfoundation.org,
	 linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org,
	 abel.vesa@linaro.org, alexander.stein@ew.tq-group.com,
	 andriy.shevchenko@linux.intel.com, bigunclemax@gmail.com,
	brgl@bgdev.pl,  colin.foster@in-advantage.com,
	djrscally@gmail.com,  dmitry.baryshkov@linaro.org,
	festevam@gmail.com, fido_max@inbox.ru,  frowand.list@gmail.com,
	geert@linux-m68k.org, heikki.krogerus@linux.intel.com,
	 kernel@pengutronix.de, linus.walleij@linaro.org,
	linux@roeck-us.net,  luca.weiss@fairphone.com,
	magnus.damm@gmail.com, martin.kepplinger@puri.sm,
	 miquel.raynal@bootlin.com, rafal@milecki.pl,
	ansuelsmth@gmail.com,  richard@nod.at,
	sakari.ailus@linux.intel.com, sudeep.holla@arm.com,
	 tglx@linutronix.de, tony@atomide.com, vigneshr@ti.com,
	dianders@chromium.org,  jpb@kernel.org, rafael@kernel.org,
	 Android Kernel Team <kernel-team@android.com>
Subject: Re: [PATCH v1 1/4] driver core: fw_devlink: Use driver to determine probe ability
Date: Tue, 13 Feb 2024 19:18:03 -0800	[thread overview]
Message-ID: <CAGETcx-udSMDLEmwynQMxEnaHb5TR=nD+YJysAx7Jc73UVKdZA@mail.gmail.com> (raw)
In-Reply-To: <20240123014517.5787-2-mcpratt@pm.me>

Hi Michael,

Thanks for reporting this and being willing to work on a fix.

On Mon, Jan 22, 2024 at 5:46 PM Michael Pratt <mcpratt@pm.me> wrote:
>
> The function __fw_devlink_pickup_dangling_consumers()
> intends to ignore suppliers that are already capable of probing,

fw_devlink isn't trying to figure out if a fwnode is "already capable"
of probing. It's trying to figure out if a fwnode will NEVER probe. If
it's just looking at "right now" or "already capable", it becomes
kinda useless.

> but uses whether or not a bus struct is defined in the device struct.

Because if you don't need a class of devices to probe, you add them to
a "class" not a "bus".

> There are some cases where a firmware child node
> can be address translatable but not able to probe
> (e.g. the use of of_platform_populate() for MTD partitions),
> so whether or not a driver is present is a more accurate way
> to guess whether a fwnode represents a real probing device here.

No, checking for the driver is not a "more accurate way" for the
reasons mentioned above.

> This also serves as a preparation step for further changes
> to fw_devlink including making the contents of this function
> less strict in order to compensate for more cases being passed into
> the rest of the function because the return case is now more strict.

This change itself is a definite Nack, but I'll look at your other
patches to see what you are trying to do.

> "Hey! Who's driving the bus?"

The driver isn't here yet. He'll be here in a while. But at least this
is a mode of transportation and not a football stadium :)

See more below.

> Signed-off-by: Michael Pratt <mcpratt@pm.me>
> ---
>  drivers/base/core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 14d46af40f9a..c05a5f6b0641 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -214,7 +214,7 @@ static void __fwnode_links_move_consumers(struct fwnode_handle *from,
>   * @new_sup: fwnode of new supplier
>   *
>   * If the @fwnode has a corresponding struct device and the device supports
> - * probing (that is, added to a bus), then we want to let fw_devlink create
> + * probing (that is, bound to a driver), then we want to let fw_devlink create
>   * MANAGED device links to this device, so leave @fwnode and its descendant's
>   * fwnode links alone.
>   *
> @@ -225,7 +225,7 @@ static void __fw_devlink_pickup_dangling_consumers(struct fwnode_handle *fwnode,
>  {
>         struct fwnode_handle *child;
>
> -       if (fwnode->dev && fwnode->dev->bus)
> +       if (fwnode->dev && fwnode->dev->driver)

This will completely break fw_devlink when modules are enabled. Which
is where fw_devlink is also very much needed. And if modules are
loaded using udev events, this is guaranteed to break for those cases.
Also, the driver gets set AFTER a device is probed. Not before. So, I
think you are just deleting/incorrectly moving a whole bunch of device
links that would have been created.

A first level sanity test for any fw_devlink change is to take a
sufficiently complicated board/system and then compare the output of
this command before and after your changes:
ls -1 /sys/class/devlink

The diff you see should be exactly what you expect/want to happen. If
there are other unexpected diffs it's generally a bug. I've caught so
many bugs in my changes (before I send them) this way.

Also, if a device is never supposed to probe, it should not be added
to a bus anyway. That's what a "class" is for. It's for a class of
devices. Adding a device to a bus and then never probing it is such a
waste. And this device (at least for nvmem-cells) is never even
referenced -- which is an even bigger waste of memory.

I'd really prefer if someone with nvmem cells experience (hint hint
Michael hint hint :) ) can clean up the framework to not create
devices unnecessarily or at least make it a device that's added to a
class instead of a bus.

-Saravana

  reply	other threads:[~2024-02-14  3:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-23  1:45 [PATCH v1 0/4] fw_devlink: generically handle bad links to child fwnodes Michael Pratt
2024-01-23  1:46 ` [PATCH v1 1/4] driver core: fw_devlink: Use driver to determine probe ability Michael Pratt
2024-02-14  3:18   ` Saravana Kannan [this message]
2024-01-23  1:46 ` [PATCH v1 2/4] driver core: fw_devlink: Link to supplier ancestor if no device Michael Pratt
2024-02-05 15:00   ` Miquel Raynal
2024-02-25 20:16     ` Michael Pratt
2024-02-05 19:25   ` Saravana Kannan
2024-02-14  3:18     ` Saravana Kannan
2024-02-25 20:37     ` Michael Pratt
2024-01-23  1:47 ` [PATCH v1 3/4] driver core: fw_devlink: Add function device_links_fixup_suppliers() Michael Pratt
2024-01-23  1:47 ` [PATCH v1 4/4] mtd: mtdpart: Allow fwnode links to NVMEM compatible fwnodes Michael Pratt
2024-02-05 15:11   ` Miquel Raynal
2024-02-25 17:35     ` Michael Pratt
2024-02-05 20:06 ` [PATCH v1 0/4] fw_devlink: generically handle bad links to child fwnodes Saravana Kannan
2024-02-14  3:28   ` Saravana Kannan

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='CAGETcx-udSMDLEmwynQMxEnaHb5TR=nD+YJysAx7Jc73UVKdZA@mail.gmail.com' \
    --to=saravanak@google.com \
    --cc=abel.vesa@linaro.org \
    --cc=alexander.stein@ew.tq-group.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=ansuelsmth@gmail.com \
    --cc=bigunclemax@gmail.com \
    --cc=brgl@bgdev.pl \
    --cc=colin.foster@in-advantage.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dianders@chromium.org \
    --cc=djrscally@gmail.com \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=festevam@gmail.com \
    --cc=fido_max@inbox.ru \
    --cc=frowand.list@gmail.com \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jpb@kernel.org \
    --cc=kernel-team@android.com \
    --cc=kernel@pengutronix.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux@roeck-us.net \
    --cc=luca.weiss@fairphone.com \
    --cc=magnus.damm@gmail.com \
    --cc=martin.kepplinger@puri.sm \
    --cc=mcpratt@pm.me \
    --cc=miquel.raynal@bootlin.com \
    --cc=rafael@kernel.org \
    --cc=rafal@milecki.pl \
    --cc=richard@nod.at \
    --cc=sakari.ailus@linux.intel.com \
    --cc=sudeep.holla@arm.com \
    --cc=tglx@linutronix.de \
    --cc=tony@atomide.com \
    --cc=vigneshr@ti.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;
as well as URLs for NNTP newsgroup(s).