usb: core: acpi: Rely on the sysdev pointer
Subsystems (2)
v2 cover usb: core: acpi: Rely on the sysdev pointer
Hi,
I've added a comment in the first patch explaining that the sysdev pointer is the host controller from firmware perspective like requested by Andy. But please note that I did not make any comments about the location of the sysdev ACPI companion in ACPI namespace on purpose. We don't need to, and we actually can't make any assumptions about that.
original cover letter:
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 | 7 +++++-- drivers/usb/dwc3/host.c | 2 -- 2 files changed, 5 insertions(+), 4 deletions(-)
Signature · 1 line
2.35.1
PATCH v2 1/2 usb: core: acpi: Use the sysdev pointer instead of controller device
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.
--- drivers/usb/core/usb-acpi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/usb/core/usb-acpi.c +5 -2
@@ -205,8 +205,11 @@ usb_acpi_find_companion_for_device(struct usb_device *udev)struct usb_hub *hub;if (!udev->parent) { -/* root hub is only child (_ADR=0) under its parent, the HC */ - adev =ACPI_COMPANION (udev->dev.parent); +/* +* root hub is only child (_ADR=0) under its parent, the HC. +* sysdev pointer is the HC as seen from firmware. +*/ + adev =ACPI_COMPANION (udev->bus->sysdev);return acpi_find_child_device (adev,0 , false); }
Signature · 1 line
2.35.1
PATCH v2 2/2 usb: dwc3: host: Stop setting the ACPI companion
In reply to Heikki KrogerusIt 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.
--- drivers/usb/dwc3/host.c | 2 -- 1 file changed, 2 deletions(-)
drivers/usb/dwc3/host.c +0 -2
@@ -7,7 +7,6 @@* Authors: Felipe Balbi <[email protected]>, */ -#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;
Signature · 1 line
2.35.1