usb: optimize acpi companion search for usb port devices
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 26 lines · Greg KH
Quoted 25 lines · Mathias Nyman
This optimization significantly reduces xhci driver load time.
In ACPI tables the acpi companion port devices are children of the hub device. The port devices are identified by their port number returned by the ACPI
_ADRmethod._ADR0 is reserved for the root hub device.The current implementation to find a acpi companion port device loops through all acpi port devices under that parent hub, calling their
_ADRmethod each time a new port device is added.for a xHC controller with 25 ports under its roothub it will end up invoking ACPI bytecode 625 times before all ports are ready, making it really slow.
The
_ADRvalues are already read and cached earler. So instead of running the bytecode again we can check the cached_ADRvalue first, and then fall back to the old way.As one of the more significant changes, the xhci load time on Intel kabylake reduced by 70%, (28ms) from
initcallxhci_pci_init+0x0/0x49returned 0 after 39537 usecs to
initcallxhci_pci_init+0x0/0x49returned 0 after 11270 usecs
Quoted 7 lines
Quoted 4 lines
Signed-off-by Mathias Nyman <[email protected]>--- drivers/usb/core/usb-acpi.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)Why is this RFC? What's wrong with it as-is?
Last minute doubt, nothing should be wrong, but I started to wonder if there is any particular reason the ACPI part was done the way it was.
Or if maybe other drivers could benefit from checking cached _ADR value first as well, and this whole thing should be a part of drivers/acpi/glue.c instead?
(adding acpi mailing list, not just Rafael)
Thanks
-Mathias
Quoted 32 lines · Mathias Nyman
Quoted 31 lines · Greg KH
Quoted 29 lines · Mathias Nyman
This optimization significantly reduces xhci driver load time.
In ACPI tables the acpi companion port devices are children of the hub device. The port devices are identified by their port number returned by the ACPI
_ADRmethod._ADR0 is reserved for the root hub device.The current implementation to find a acpi companion port device loops through all acpi port devices under that parent hub, calling their
_ADRmethod each time a new port device is added.for a xHC controller with 25 ports under its roothub it will end up invoking ACPI bytecode 625 times before all ports are ready, making it really slow.
The
_ADRvalues are already read and cached earler. So instead of running the bytecode again we can check the cached_ADRvalue first, and then fall back to the old way.As one of the more significant changes, the xhci load time on Intel kabylake reduced by 70%, (28ms) from
initcallxhci_pci_init+0x0/0x49returned 0 after 39537 usecs to
initcallxhci_pci_init+0x0/0x49returned 0 after 11270 usecsSigned-off-by Mathias Nyman <[email protected]>--- drivers/usb/core/usb-acpi.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)
Quoted 9 lines
Quoted 2 lines
Why is this RFC? What's wrong with it as-is?
Last minute doubt, nothing should be wrong, but I started to wonder if there is any particular reason the ACPI part was done the way it was.
Or if maybe other drivers could benefit from checking cached
_ADRvalue first as well, and this whole thing should be a part ofdrivers/acpi/glue.cinstead?
That or we should just evaluate _ADR if present during the very initialization and store the value in a filed under struct acpi_device.
Thanks,
Rafael
Quoted 36 lines · Rafael J. Wysocki
Quoted 35 lines · Mathias Nyman
Quoted 33 lines · Greg KH
Quoted 25 lines · Mathias Nyman
This optimization significantly reduces xhci driver load time.
In ACPI tables the acpi companion port devices are children of the hub device. The port devices are identified by their port number returned by the ACPI
_ADRmethod._ADR0 is reserved for the root hub device.The current implementation to find a acpi companion port device loops through all acpi port devices under that parent hub, calling their
_ADRmethod each time a new port device is added.for a xHC controller with 25 ports under its roothub it will end up invoking ACPI bytecode 625 times before all ports are ready, making it really slow.
The
_ADRvalues are already read and cached earler. So instead of running the bytecode again we can check the cached_ADRvalue first, and then fall back to the old way.As one of the more significant changes, the xhci load time on Intel kabylake reduced by 70%, (28ms) from
initcallxhci_pci_init+0x0/0x49returned 0 after 39537 usecs to
initcallxhci_pci_init+0x0/0x49returned 0 after 11270 usecsQuoted 4 lines
Signed-off-by Mathias Nyman <[email protected]>--- drivers/usb/core/usb-acpi.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)Why is this RFC? What's wrong with it as-is?
Quoted 9 lines
Quoted 6 lines
Last minute doubt, nothing should be wrong, but I started to wonder if there is any particular reason the ACPI part was done the way it was.
Or if maybe other drivers could benefit from checking cached
_ADRvalue first as well, and this whole thing should be a part ofdrivers/acpi/glue.cinstead?That or we should just evaluate
_ADRif present during the very initialization and store the value in a filed under structacpi_device.
Yes, that is pretty much done, acpi_init_device_object() will end up evaluating _ADR and store it in acpi_device.pnp.bus_address
Just considering if there should be something like acpi_get_adr(acpi_device *adev) that would first check if adev->pnp.bus_address exists, if not, then it would evaluate _ADR.
But really just a thought, I think I'll send this forward as is.
Thanks
Mathias