[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y9eyMck6rPRyfgrX@smile.fi.intel.com>
Date: Mon, 30 Jan 2023 14:04:01 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Saravana Kannan <saravanak@...gle.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Sudeep Holla <sudeep.holla@....com>,
Cristian Marussi <cristian.marussi@....com>,
Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>,
Thomas Gleixner <tglx@...utronix.de>,
Marc Zyngier <maz@...nel.org>, Shawn Guo <shawnguo@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>,
NXP Linux Team <linux-imx@....com>,
Rob Herring <robh+dt@...nel.org>,
Frank Rowand <frowand.list@...il.com>,
Geert Uytterhoeven <geert+renesas@...der.be>,
Magnus Damm <magnus.damm@...il.com>,
Len Brown <lenb@...nel.org>,
Daniel Scally <djrscally@...il.com>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Sakari Ailus <sakari.ailus@...ux.intel.com>,
Tony Lindgren <tony@...mide.com>,
Linux Kernel Functional Testing <lkft@...aro.org>,
Naresh Kamboju <naresh.kamboju@...aro.org>,
Abel Vesa <abel.vesa@...aro.org>,
Alexander Stein <alexander.stein@...tq-group.com>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
John Stultz <jstultz@...gle.com>,
Doug Anderson <dianders@...omium.org>,
Guenter Roeck <linux@...ck-us.net>,
Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
Maxim Kiselev <bigunclemax@...il.com>,
Maxim Kochetkov <fido_max@...ox.ru>,
Miquel Raynal <miquel.raynal@...tlin.com>,
Luca Weiss <luca.weiss@...rphone.com>,
Colin Foster <colin.foster@...advantage.com>,
Martin Kepplinger <martin.kepplinger@...i.sm>,
Jean-Philippe Brucker <jpb@...nel.org>,
kernel-team@...roid.com, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-gpio@...r.kernel.org,
devicetree@...r.kernel.org, linux-renesas-soc@...r.kernel.org,
linux-acpi@...r.kernel.org
Subject: Re: [PATCH v2 01/11] driver core: fw_devlink: Don't purge child
fwnode's consumer links
On Fri, Jan 27, 2023 at 11:33:28PM -0800, Saravana Kannan wrote:
> On Fri, Jan 27, 2023 at 1:22 AM Andy Shevchenko
> <andriy.shevchenko@...ux.intel.com> wrote:
> > On Thu, Jan 26, 2023 at 04:11:28PM -0800, Saravana Kannan wrote:
...
> > > static unsigned int defer_sync_state_count = 1;
> > > static DEFINE_MUTEX(fwnode_link_lock);
> > > static bool fw_devlink_is_permissive(void);
> > > +static void __fw_devlink_link_to_consumers(struct device *dev);
> > > static bool fw_devlink_drv_reg_done;
> > > static bool fw_devlink_best_effort;
> >
> > I'm wondering if may avoid adding more forward declarations...
> >
> > Perhaps it's a sign that devlink code should be split to its own
> > module?
>
> I've thought about that before, but I'm not there yet. Maybe once my
> remaining refactors and TODOs are done, it'd be a good time to revisit
> this question.
>
> But I don't think it should be done for the reason of forward
> declaration as we'd just end up moving these into base.h and we can do
> that even today.
What I meant is that the stacking up forward declarations is a good sign that
something has to be done sooner than later.
...
> > > -int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup)
> > > +static int __fwnode_link_add(struct fwnode_handle *con,
> > > + struct fwnode_handle *sup)
> >
> > I believe we tolerate a bit longer lines, so you may still have it on a single
> > line.
>
> That'd make it >80 cols. I'm going to leave it as is.
Is it a problem?
...
> > > if (dev->fwnode && dev->fwnode->dev == dev) {
> >
> > You may have above something like
> >
> > fwnode = dev_fwnode(dev);
>
> I'll leave it as-is for now. I see dev->fwnode vs dev_fwnode() don't
> always give the same results. I need to re-examine other places I use
> dev->fwnode in fw_devlink code before I start using that function. But
> in general it seems like a good idea. I'll add this to my TODOs.
Please do, the rationale is to actually move the fwnode to the proper layer,
now we have the single linked list defined in struct fwnode_handle and
dereferencing fwnode from struct device without helper adds a lot of
headache in the future. So, I really would like to see that we stopped doing
that.
> > if (fwnode && fwnode->dev == dev) {
> >
> > > struct fwnode_handle *child;
> > > fwnode_links_purge_suppliers(dev->fwnode);
> > > + mutex_lock(&fwnode_link_lock);
> > > fwnode_for_each_available_child_node(dev->fwnode, child)
> > > - fw_devlink_purge_absent_suppliers(child);
> > > + __fw_devlink_pickup_dangling_consumers(child,
> > > + dev->fwnode);
> >
> > __fw_devlink_pickup_dangling_consumers(child, fwnode);
>
> I like the dev->fwnode->dev == dev check. It makes it super clear that
> I'm checking "The device's fwnode points back to the device". If I
> just use fwnode->dev == dev, then one will have to go back and read
> what fwnode is set to, etc. Also, when reading all these function
> calls it's easier to see that I'm working on the dev's fwnode (where
> dev is the device that was just bound to a driver) instead of some
> other fwnode.
>
> So I find it more readable as is and the compiler would optimize it
> anyway. If you feel strongly about this, I can change to use fwnode
> instead of dev->fwnode.
Please, read above.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists