All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "Pali Rohár" <pali@kernel.org>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Bjorn Helgaas" <bhelgaas@google.com>
Subject: Re: [PATCH v1 1/1] PCI: of: Propagate firmware node
Date: Fri, 14 Apr 2023 13:55:45 -0500	[thread overview]
Message-ID: <20230414185545.GA206084@bhelgaas> (raw)
In-Reply-To: <ZDgnGuycE5S6rlZk@smile.fi.intel.com>

On Thu, Apr 13, 2023 at 07:00:26PM +0300, Andy Shevchenko wrote:
> On Wed, Apr 12, 2023 at 11:02:53AM -0500, Bjorn Helgaas wrote:
> > On Wed, Apr 12, 2023 at 04:15:20PM +0300, Andy Shevchenko wrote:
> > > Propagate firmware node by using a specific API call, i.e. device_set_node().
> > 
> > Can you add a line or two about *why* we should do this, e.g., is this
> > headed toward some goal?
> 
> Because dereferencing the fwnode in struct device is preventing us from
> modifications of how fwnode looks like in the future.

How do you want to express this in the commit log?  Something like
this?

  Insulate pci_set_of_node() and pci_set_bus_of_node() from possible
  changes to fwnode_handle implementation by using device_set_node()
  instead of open-coding dev->dev.fwnode assignments.

> > Is it a simplification that's 100%
> > equivalent (doesn't seem so, see below)?
> 
> To me it's an equivalent, I'll explain below.
> 
> > Seems like there's an underlying long-term effort to unify things from
> > OF and ACPI, which seems like a good thing, but at the moment it's a
> > little confusing to follow.  For instance pci_set_of_node() seems like
> > it ought to be sort of analogous to pci_set_acpi_fwnode(), but they
> > look nothing alike.
> 
> Unification to some extent, but here is not a point of this change.
> 
> ...
> 
> > > +	struct device_node *node;
> > > +
> > >  	if (!dev->bus->dev.of_node)
> > >  		return;
> > > -	dev->dev.of_node = of_pci_find_child_device(dev->bus->dev.of_node,
> > > -						    dev->devfn);
> > > -	if (dev->dev.of_node)
> > > -		dev->dev.fwnode = &dev->dev.of_node->fwnode;
> > > +	node = of_pci_find_child_device(dev->bus->dev.of_node, dev->devfn);
> > > +	device_set_node(&dev->dev, of_fwnode_handle(node));
> > 
> > This doesn't seem 100% equivalent.  If of_pci_find_child_device()
> > returns NULL, the previous code doesn't set dev->dev.fwnode, but the
> > new code does.
> 
> Yes and this is not a problem. We create device with pci_alloc_dev() in both
> callers of the pci_setup_device() and the field is NULL anyway. So, the last
> condition there is a simple micro-optimisation.

OK, makes sense, thanks.

Bjorn

  reply	other threads:[~2023-04-14 18:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-12 13:15 [PATCH v1 1/1] PCI: of: Propagate firmware node Andy Shevchenko
2023-04-12 16:02 ` Bjorn Helgaas
2023-04-13 16:00   ` Andy Shevchenko
2023-04-14 18:55     ` Bjorn Helgaas [this message]
2023-04-17 10:45       ` Andy Shevchenko

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=20230414185545.GA206084@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=pali@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.