All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI/ACPI: Don't reset a fwnode set by OF
@ 2021-09-13 17:23 Jean-Philippe Brucker
  2021-09-13 19:28 ` Bjorn Helgaas
  0 siblings, 1 reply; 3+ messages in thread
From: Jean-Philippe Brucker @ 2021-09-13 17:23 UTC (permalink / raw)
  To: rafael, lenb, bhelgaas
  Cc: linux-acpi, linux-pci, sdonthineni, Jean-Philippe Brucker

Commit 375553a93201 ("PCI: Setup ACPI fwnode early and at the same time
with OF") added a call to pci_set_acpi_fwnode() in pci_setup_device(),
which unconditionally clears any fwnode previously set by
pci_set_of_node().

pci_set_acpi_fwnode() looks for ACPI_COMPANION(), which only returns the
existing fwnode if it was set by ACPI_COMPANION_SET(). If it was set by
OF instead, ACPI_COMPANION() returns NULL and pci_set_acpi_fwnode()
accidentally clears the fwnode. To fix this, look for any fwnode instead
of just ACPI companions.

Fixes: 375553a93201 ("PCI: Setup ACPI fwnode early and at the same time with OF")
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
This fixes boot of virtio-iommu under OF on v5.15-rc1
---
 drivers/pci/pci-acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index a1b1e2a01632..483a9e50f6ca 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -937,7 +937,7 @@ static struct acpi_device *acpi_pci_find_companion(struct device *dev);
 
 void pci_set_acpi_fwnode(struct pci_dev *dev)
 {
-	if (!ACPI_COMPANION(&dev->dev) && !pci_dev_is_added(dev))
+	if (!dev->dev.fwnode && !pci_dev_is_added(dev))
 		ACPI_COMPANION_SET(&dev->dev,
 				   acpi_pci_find_companion(&dev->dev));
 }
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI/ACPI: Don't reset a fwnode set by OF
  2021-09-13 17:23 [PATCH] PCI/ACPI: Don't reset a fwnode set by OF Jean-Philippe Brucker
@ 2021-09-13 19:28 ` Bjorn Helgaas
  2021-09-13 20:06   ` Rob Herring
  0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Helgaas @ 2021-09-13 19:28 UTC (permalink / raw)
  To: Jean-Philippe Brucker
  Cc: rafael, lenb, bhelgaas, linux-acpi, linux-pci,
	Shanker Donthineni, Rob Herring

[+cc Rob]

On Mon, Sep 13, 2021 at 06:23:59PM +0100, Jean-Philippe Brucker wrote:
> Commit 375553a93201 ("PCI: Setup ACPI fwnode early and at the same time
> with OF") added a call to pci_set_acpi_fwnode() in pci_setup_device(),
> which unconditionally clears any fwnode previously set by
> pci_set_of_node().
> 
> pci_set_acpi_fwnode() looks for ACPI_COMPANION(), which only returns the
> existing fwnode if it was set by ACPI_COMPANION_SET(). If it was set by
> OF instead, ACPI_COMPANION() returns NULL and pci_set_acpi_fwnode()
> accidentally clears the fwnode. To fix this, look for any fwnode instead
> of just ACPI companions.
> 
> Fixes: 375553a93201 ("PCI: Setup ACPI fwnode early and at the same time with OF")
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
> ---
> This fixes boot of virtio-iommu under OF on v5.15-rc1
> ---
>  drivers/pci/pci-acpi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
> index a1b1e2a01632..483a9e50f6ca 100644
> --- a/drivers/pci/pci-acpi.c
> +++ b/drivers/pci/pci-acpi.c
> @@ -937,7 +937,7 @@ static struct acpi_device *acpi_pci_find_companion(struct device *dev);
>  
>  void pci_set_acpi_fwnode(struct pci_dev *dev)
>  {
> -	if (!ACPI_COMPANION(&dev->dev) && !pci_dev_is_added(dev))
> +	if (!dev->dev.fwnode && !pci_dev_is_added(dev))

I don't doubt that this is correct, but it seems excessively subtle,
like we're violating some layering or something.

Rafael, Rob, is there anything better we can do here?

>  		ACPI_COMPANION_SET(&dev->dev,
>  				   acpi_pci_find_companion(&dev->dev));
>  }
> -- 
> 2.33.0
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI/ACPI: Don't reset a fwnode set by OF
  2021-09-13 19:28 ` Bjorn Helgaas
@ 2021-09-13 20:06   ` Rob Herring
  0 siblings, 0 replies; 3+ messages in thread
From: Rob Herring @ 2021-09-13 20:06 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jean-Philippe Brucker, Rafael J. Wysocki, Len Brown,
	Bjorn Helgaas, open list:ACPI FOR ARM64 (ACPI/arm64),
	PCI, Shanker Donthineni

On Mon, Sep 13, 2021 at 2:28 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
>
> [+cc Rob]
>
> On Mon, Sep 13, 2021 at 06:23:59PM +0100, Jean-Philippe Brucker wrote:
> > Commit 375553a93201 ("PCI: Setup ACPI fwnode early and at the same time
> > with OF") added a call to pci_set_acpi_fwnode() in pci_setup_device(),
> > which unconditionally clears any fwnode previously set by
> > pci_set_of_node().
> >
> > pci_set_acpi_fwnode() looks for ACPI_COMPANION(), which only returns the
> > existing fwnode if it was set by ACPI_COMPANION_SET(). If it was set by
> > OF instead, ACPI_COMPANION() returns NULL and pci_set_acpi_fwnode()
> > accidentally clears the fwnode. To fix this, look for any fwnode instead
> > of just ACPI companions.
> >
> > Fixes: 375553a93201 ("PCI: Setup ACPI fwnode early and at the same time with OF")
> > Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
> > ---
> > This fixes boot of virtio-iommu under OF on v5.15-rc1
> > ---
> >  drivers/pci/pci-acpi.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
> > index a1b1e2a01632..483a9e50f6ca 100644
> > --- a/drivers/pci/pci-acpi.c
> > +++ b/drivers/pci/pci-acpi.c
> > @@ -937,7 +937,7 @@ static struct acpi_device *acpi_pci_find_companion(struct device *dev);
> >
> >  void pci_set_acpi_fwnode(struct pci_dev *dev)
> >  {
> > -     if (!ACPI_COMPANION(&dev->dev) && !pci_dev_is_added(dev))
> > +     if (!dev->dev.fwnode && !pci_dev_is_added(dev))
>
> I don't doubt that this is correct, but it seems excessively subtle,
> like we're violating some layering or something.

That stems from DT and ACPI node handle handling being asymmetric in
struct device. DT has its own node pointer plus the fwnode handle
while ACPI only uses fwnode handle. It's that way because who is going
to replace all the dev->of_node occurrences? Only ~7500 of them based
on a quick grep.

> Rafael, Rob, is there anything better we can do here?

I don't think so. Using dev_fwnode() would be slightly better than
direct access.

Rob

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-13 20:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-13 17:23 [PATCH] PCI/ACPI: Don't reset a fwnode set by OF Jean-Philippe Brucker
2021-09-13 19:28 ` Bjorn Helgaas
2021-09-13 20:06   ` Rob Herring

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.