All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] usb: core: acpi: Rely on the sysdev pointer
@ 2022-04-25 12:13 Heikki Krogerus
  2022-04-25 12:13 ` [PATCH v1 1/2] usb: core: acpi: Use the sysdev pointer instead of controller device Heikki Krogerus
  2022-04-25 12:13 ` [PATCH v1 2/2] usb: dwc3: host: Stop setting the ACPI companion Heikki Krogerus
  0 siblings, 2 replies; 5+ messages in thread
From: Heikki Krogerus @ 2022-04-25 12:13 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Felipe Balbi, Rafael J. Wysocki, Mathias Nyman, Andy Shevchenko,
	linux-usb, linux-kernel

Hi,

Since we have that sysdev pointer, we need to use it also when
assigning the ACPI companion for the root hub. That should remove the
need to "manually" assign the ACPI companion to the controller device
in the xhci glue drivers like dwc3-host.c.

Assigning the ACPI companion in those glue drivers is very
problematic, because it screws up the fwnode->secondary pointer. But
as said, since we have that sysdev pointer, there is no need to
manually set it. sysdev pointer should always point to the correct
physical device from firmware PoW.

thanks,

Heikki Krogerus (2):
  usb: core: acpi: Use the sysdev pointer instead of controller device
  usb: dwc3: host: Stop setting the ACPI companion

 drivers/usb/core/usb-acpi.c | 2 +-
 drivers/usb/dwc3/host.c     | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)

-- 
2.35.1


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

* [PATCH v1 1/2] usb: core: acpi: Use the sysdev pointer instead of controller device
  2022-04-25 12:13 [PATCH v1 0/2] usb: core: acpi: Rely on the sysdev pointer Heikki Krogerus
@ 2022-04-25 12:13 ` Heikki Krogerus
  2022-04-26 10:18   ` Andy Shevchenko
  2022-04-25 12:13 ` [PATCH v1 2/2] usb: dwc3: host: Stop setting the ACPI companion Heikki Krogerus
  1 sibling, 1 reply; 5+ messages in thread
From: Heikki Krogerus @ 2022-04-25 12:13 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Felipe Balbi, Rafael J. Wysocki, Mathias Nyman, Andy Shevchenko,
	linux-usb, linux-kernel

The controller device (hcd) does not always have the ACPI
companion assigned to it at all. We can not rely on it when
finding the ACPI companion for the root hub. Instead we need
to use the sysdev pointer here.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/usb/core/usb-acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index bb1da35eb891e..fbaf5045507bb 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -206,7 +206,7 @@ usb_acpi_find_companion_for_device(struct usb_device *udev)
 
 	if (!udev->parent) {
 		/* root hub is only child (_ADR=0) under its parent, the HC */
-		adev = ACPI_COMPANION(udev->dev.parent);
+		adev = ACPI_COMPANION(udev->bus->sysdev);
 		return acpi_find_child_device(adev, 0, false);
 	}
 
-- 
2.35.1


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

* [PATCH v1 2/2] usb: dwc3: host: Stop setting the ACPI companion
  2022-04-25 12:13 [PATCH v1 0/2] usb: core: acpi: Rely on the sysdev pointer Heikki Krogerus
  2022-04-25 12:13 ` [PATCH v1 1/2] usb: core: acpi: Use the sysdev pointer instead of controller device Heikki Krogerus
@ 2022-04-25 12:13 ` Heikki Krogerus
  1 sibling, 0 replies; 5+ messages in thread
From: Heikki Krogerus @ 2022-04-25 12:13 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Felipe Balbi, Rafael J. Wysocki, Mathias Nyman, Andy Shevchenko,
	linux-usb, linux-kernel

It is no longer needed. The sysdev pointer is now used when
assigning the ACPI companions to the xHCI ports and USB
devices.

Assigning the ACPI companion here resulted in the
fwnode->secondary pointer to be replaced also for the parent
dwc3 device since the primary fwnode (the ACPI companion)
was shared. That was unintentional and it created potential
side effects like resource leaks.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/usb/dwc3/host.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index eda871973d6cc..f56c30cf151e4 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -7,7 +7,6 @@
  * Authors: Felipe Balbi <balbi@ti.com>,
  */
 
-#include <linux/acpi.h>
 #include <linux/irq.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
@@ -83,7 +82,6 @@ int dwc3_host_init(struct dwc3 *dwc)
 	}
 
 	xhci->dev.parent	= dwc->dev;
-	ACPI_COMPANION_SET(&xhci->dev, ACPI_COMPANION(dwc->dev));
 
 	dwc->xhci = xhci;
 
-- 
2.35.1


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

* Re: [PATCH v1 1/2] usb: core: acpi: Use the sysdev pointer instead of controller device
  2022-04-25 12:13 ` [PATCH v1 1/2] usb: core: acpi: Use the sysdev pointer instead of controller device Heikki Krogerus
@ 2022-04-26 10:18   ` Andy Shevchenko
  2022-04-27  7:20     ` Heikki Krogerus
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2022-04-26 10:18 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: Greg Kroah-Hartman, Felipe Balbi, Rafael J. Wysocki,
	Mathias Nyman, Andy Shevchenko, USB, Linux Kernel Mailing List

On Mon, Apr 25, 2022 at 3:41 PM Heikki Krogerus
<heikki.krogerus@linux.intel.com> wrote:
>
> The controller device (hcd) does not always have the ACPI
> companion assigned to it at all. We can not rely on it when
> finding the ACPI companion for the root hub. Instead we need
> to use the sysdev pointer here.

...

>         if (!udev->parent) {
>                 /* root hub is only child (_ADR=0) under its parent, the HC */

I believe the comment can be amended now to point out that we use the
physical device representing the parent of this child, and not
(always) a direct parent of the device in terms of Linux device model.

> -               adev = ACPI_COMPANION(udev->dev.parent);
> +               adev = ACPI_COMPANION(udev->bus->sysdev);
>                 return acpi_find_child_device(adev, 0, false);
>         }


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH v1 1/2] usb: core: acpi: Use the sysdev pointer instead of controller device
  2022-04-26 10:18   ` Andy Shevchenko
@ 2022-04-27  7:20     ` Heikki Krogerus
  0 siblings, 0 replies; 5+ messages in thread
From: Heikki Krogerus @ 2022-04-27  7:20 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, Felipe Balbi, Rafael J. Wysocki,
	Mathias Nyman, Andy Shevchenko, USB, Linux Kernel Mailing List

On Tue, Apr 26, 2022 at 12:18:24PM +0200, Andy Shevchenko wrote:
> On Mon, Apr 25, 2022 at 3:41 PM Heikki Krogerus
> <heikki.krogerus@linux.intel.com> wrote:
> >
> > The controller device (hcd) does not always have the ACPI
> > companion assigned to it at all. We can not rely on it when
> > finding the ACPI companion for the root hub. Instead we need
> > to use the sysdev pointer here.
> 
> ...
> 
> >         if (!udev->parent) {
> >                 /* root hub is only child (_ADR=0) under its parent, the HC */
> 
> I believe the comment can be amended now to point out that we use the
> physical device representing the parent of this child, and not
> (always) a direct parent of the device in terms of Linux device model.

Okay, I'll try to improve the comment.

> > -               adev = ACPI_COMPANION(udev->dev.parent);
> > +               adev = ACPI_COMPANION(udev->bus->sysdev);
> >                 return acpi_find_child_device(adev, 0, false);
> >         }

thanks,

-- 
heikki

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

end of thread, other threads:[~2022-04-27  7:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-25 12:13 [PATCH v1 0/2] usb: core: acpi: Rely on the sysdev pointer Heikki Krogerus
2022-04-25 12:13 ` [PATCH v1 1/2] usb: core: acpi: Use the sysdev pointer instead of controller device Heikki Krogerus
2022-04-26 10:18   ` Andy Shevchenko
2022-04-27  7:20     ` Heikki Krogerus
2022-04-25 12:13 ` [PATCH v1 2/2] usb: dwc3: host: Stop setting the ACPI companion Heikki Krogerus

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.