xhci fixup patch for usb-next
Subsystems (2)
cover xhci fixup patch for usb-next
Hi Greg
This is a fixup patch for the xhci DbC patches in usb-next.
This patch was originally part of the xhci DbC series going to 7.2-rc1, but I decided last minute to drop it to let it mature for a while. It enables runtime PM for xhci with DbC enabled.
Turns out the series going to 7.2-rc1 is flawed without this patch. It introduces a locking issue that this patch resolves.
If possible it would be nice to get this included to 7.2-rc1, or if it's too late, then to rc2.
It passed the CI test that discovered the locking issue.
Thanks
Mathias
Mathias Nyman (1):
xhci: dbc: support runtime suspend while DbC is in enabled state
.../testing/sysfs-bus-pci-drivers-xhci_hcd | 2 +- drivers/usb/host/xhci-dbgcap.c | 60 ++++++++++++++++++- drivers/usb/host/xhci-dbgcap.h | 3 + 3 files changed, 62 insertions(+), 3 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/1 xhci: dbc: support runtime suspend while DbC is in enabled state
Allow xHC to runtime suspend if DbC is in 'enabled' state for over 15 seconds without a connect.
Idea is that every time we go to 'enabled' state we make sure DbC runtime pm usage is '1' and save a timestamp. if the event loop still finds DbC in enabled state 15 seconds later then it decrease DbC runtime pm usage by calling pm_runtime_put().
Enabled state is reached either when DbC is enabled by userspace or a connected/configured DbC is disconnected.
When a connect is detected we make sure DbC usage count is 1.
If DbC has been in 'enabled' state for 15 seconds and DbC usage is decreased to 0 by pm_runtime_put, then the whole xHC controller may runtime suspends to PCI D3 state if no other devices are using it
DbC sysfs file will show 'suspended' when xHC is suspended and will wake up and enable DbC at cable connect, or when user writes 'enable' to the file.
This patch was originally part of a larger DbC series, but dropped before the series was submitted to 7.2-rc1. The series has a locking issue in commit 520058b73ba3 ("xhci: dbc: serialize enabling and disabling dbc") which is also resolved by this patch
--- .../testing/sysfs-bus-pci-drivers-xhci_hcd | 2 +- drivers/usb/host/xhci-dbgcap.c | 60 ++++++++++++++++++- drivers/usb/host/xhci-dbgcap.h | 3 + 3 files changed, 62 insertions(+), 3 deletions(-)
Documentation/ABI/testing/sysfs-bus-pci-drivers-xhci_hcd +1 -1
@@ -22,7 +22,7 @@ Description: Reading this attribute gives the state of the DbC. It can be one of the following states: disabled, enabled, - initialized, connected or configured. + initialized, connected, configured or suspended. What: /sys/bus/pci/drivers/xhci_hcd/.../dbc_idVendor Date: March 2023
drivers/usb/host/xhci-dbgcap.c +58 -2
113 lines not on this page · raw message
drivers/usb/host/xhci-dbgcap.h +3 -0
@@ -114,6 +114,8 @@ struct dbc_ep {#define DBC_POLL_INTERVAL_MAX 5000/* milliseconds */ #define DBC_XFER_INACTIVITY_TIMEOUT 10/* milliseconds */ #define DBC_ENUMERATION_TIMEOUT 2000/* milliseconds */ +#define DBC_AUTOSUSPEND_DELAY 15000/* milliseconds */ +/* * Private structure for DbC hardware state: */
@@ -166,6 +168,7 @@ struct xhci_dbc {unsigned long xfer_timestamp;unsigned long state_timestamp; unsigned resume_required:1; + unsigned pending_rpm_put:1;struct dbc_ep eps[2 ];const struct dbc_driver *driver;
Signature · 1 line
2.43.0
Greg KH
maintainerRe: [PATCH 1/1] xhci: dbc: support runtime suspend while DbC is in enabled state
Quoted 24 lines · Mathias Nyman
Allow xHC to runtime suspend if DbC is in 'enabled' state for over 15 seconds without a connect.
Idea is that every time we go to 'enabled' state we make sure DbC runtime pm usage is '1' and save a timestamp. if the event loop still finds DbC in enabled state 15 seconds later then it decrease DbC runtime pm usage by calling
pm_runtime_put().
Enabled state is reached either when DbC is enabled by userspace or a connected/configured DbC is disconnected.When a connect is detected we make sure DbC usage count is 1.
If DbC has been in 'enabled' state for 15 seconds and DbC usage is decreased to 0 by
pm_runtime_put, then the whole xHC controller may runtime suspends to PCI D3 state if no other devices are using itDbC sysfs file will show 'suspended' when xHC is suspended and will wake up and enable DbC at cable connect, or when user writes 'enable' to the file.
This patch was originally part of a larger DbC series, but dropped before the series was submitted to 7.2-rc1. The series has a locking issue in commit
520058b73ba3("xhci: dbc: serialize enabling and disabling dbc") which is also resolved by this patch
Quoted 7 lines
Fixes 520058b73ba3 ("xhci: dbc: serialize enabling and disabling dbc")Signed-off-by Mathias Nyman <[email protected]>--- .../testing/sysfs-bus-pci-drivers-xhci_hcd | 2 +- drivers/usb/host/xhci-dbgcap.c | 60 ++++++++++++++++++- drivers/usb/host/xhci-dbgcap.h | 3 + 3 files changed, 62 insertions(+), 3 deletions(-)
No "reported-by:"?
Re: [PATCH 1/1] xhci: dbc: support runtime suspend while DbC is in enabled state
Quoted 33 lines · Greg KH
Quoted 24 lines · Mathias Nyman
Allow xHC to runtime suspend if DbC is in 'enabled' state for over 15 seconds without a connect.
Idea is that every time we go to 'enabled' state we make sure DbC runtime pm usage is '1' and save a timestamp. if the event loop still finds DbC in enabled state 15 seconds later then it decrease DbC runtime pm usage by calling
pm_runtime_put().
Enabled state is reached either when DbC is enabled by userspace or a connected/configured DbC is disconnected.When a connect is detected we make sure DbC usage count is 1.
If DbC has been in 'enabled' state for 15 seconds and DbC usage is decreased to 0 by
pm_runtime_put, then the whole xHC controller may runtime suspends to PCI D3 state if no other devices are using itDbC sysfs file will show 'suspended' when xHC is suspended and will wake up and enable DbC at cable connect, or when user writes 'enable' to the file.
This patch was originally part of a larger DbC series, but dropped before the series was submitted to 7.2-rc1. The series has a locking issue in commit
520058b73ba3("xhci: dbc: serialize enabling and disabling dbc") which is also resolved by this patchQuoted 7 lines
Fixes 520058b73ba3 ("xhci: dbc: serialize enabling and disabling dbc")Signed-off-by Mathias Nyman <[email protected]>--- .../testing/sysfs-bus-pci-drivers-xhci_hcd | 2 +- drivers/usb/host/xhci-dbgcap.c | 60 ++++++++++++++++++- drivers/usb/host/xhci-dbgcap.h | 3 + 3 files changed, 62 insertions(+), 3 deletions(-)
Quoted 1 line
No "reported-by:"?
I'll send v2
-Mathias