xhci fixes for usb-linus
Subsystems (3)
Mathias Nyman
maintainercover xhci fixes for usb-linus
Hi Greg
Some xhci fixes for usb-linus, mostly tuning quirks, but also fixing one linked list issue.
Thanks
Mathias
Jens Glathe (1):
usb: xhci: add XHCI_SPURIOUS_SUCCESS to ASM1042 despite being a V0.96
controller
Mario Limonciello (1):
xhci-pci: Set runtime PM as default policy on all xHC 1.2 or later
devices
Mathias Nyman (2):
xhci: Add quirk to reset host back to default state at shutdown
xhci: Remove device endpoints from bandwidth list when freeing the
device
drivers/usb/host/xhci-mem.c | 20 ++++++++++------- drivers/usb/host/xhci-pci.c | 44 +++++++++++++------------------------ drivers/usb/host/xhci.c | 10 +++++++-- drivers/usb/host/xhci.h | 1 + 4 files changed, 36 insertions(+), 39 deletions(-)
Signature · 1 line
2.25.1
Mathias Nyman
maintainerPATCH 1/4 usb: xhci: add XHCI_SPURIOUS_SUCCESS to ASM1042 despite being a V0.96 controller
From: Jens Glathe <[email protected]>
This appears to fix the error:
"xhci_hcd <address>; ERROR Transfer event TRB DMA ptr not part of current TD ep_index 2 comp_code 13" that appear spuriously (or pretty often) when using a r8152 USB3 ethernet adapter with integrated hub.
ASM1042 reports as a 0.96 controller, but appears to behave more like 1.0
Inspired by this email thread: https://markmail.org/thread/7vzqbe7t6du6qsw3
--- drivers/usb/host/xhci-pci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/host/xhci-pci.c +7 -1
@@ -306,8 +306,14 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) }if (pdev->vendor ==PCI_VENDOR_ID_ASMEDIA && - pdev->device ==PCI_DEVICE_ID_ASMEDIA_1042_XHCI ) + pdev->device ==PCI_DEVICE_ID_ASMEDIA_1042_XHCI ) { +/* +* try to tame the ASMedia 1042 controller which reports 0.96 +* but appears to behave more like 1.0 +*/ + xhci->quirks |=XHCI_SPURIOUS_SUCCESS ; xhci->quirks |=XHCI_BROKEN_STREAMS ; + }if (pdev->vendor ==PCI_VENDOR_ID_ASMEDIA && pdev->device ==PCI_DEVICE_ID_ASMEDIA_1042A_XHCI ) { xhci->quirks |=XHCI_TRUST_TX_LENGTH ;
Signature · 1 line
2.25.1
Mathias Nyman
maintainerPATCH 2/4 xhci: Add quirk to reset host back to default state at shutdown
In reply to Mathias NymanFrom: Mathias Nyman <[email protected]>
Systems based on Alder Lake P see significant boot time delay if boot firmware tries to control usb ports in unexpected link states.
This is seen with self-powered usb devices that survive in U3 link suspended state over S5.
A more generic solution to power off ports at shutdown was attempted in commit 83810f84ecf1 ("xhci: turn off port power in shutdown") but it caused regression.
Add host specific XHCI_RESET_TO_DEFAULT quirk which will reset host and ports back to default state in shutdown.
--- drivers/usb/host/xhci-pci.c | 4 ++++ drivers/usb/host/xhci.c | 10 ++++++++-- drivers/usb/host/xhci.h | 1 + 3 files changed, 13 insertions(+), 2 deletions(-)
drivers/usb/host/xhci-pci.c +4 -0
@@ -257,6 +257,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) pdev->device == PCI_DEVICE_ID_INTEL_DNV_XHCI)) xhci->quirks |= XHCI_MISSING_CAS; +if (pdev->vendor ==PCI_VENDOR_ID_INTEL && + pdev->device ==PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI ) + xhci->quirks |=XHCI_RESET_TO_DEFAULT ; + if (pdev->vendor == PCI_VENDOR_ID_INTEL && (pdev->device == PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_2C_XHCI || pdev->device == PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_4C_XHCI ||
drivers/usb/host/xhci.c +8 -2
@@ -810,9 +810,15 @@ void xhci_shutdown(struct usb_hcd *hcd)spin_lock_irq (&xhci->lock);xhci_halt (xhci); -/* Workaround for spurious wakeups at shutdown with HSW */ -if (xhci->quirks &XHCI_SPURIOUS_WAKEUP ) + +/* +* Workaround for spurious wakeps at shutdown with HSW, and for boot +* firmware delay in ADL-P PCH if port are left in U3 at shutdown +*/ +if (xhci->quirks &XHCI_SPURIOUS_WAKEUP || + xhci->quirks &XHCI_RESET_TO_DEFAULT )xhci_reset (xhci,XHCI_RESET_SHORT_USEC ); +spin_unlock_irq (&xhci->lock);xhci_cleanup_msix (xhci);
drivers/usb/host/xhci.h +1 -0
@@ -1897,6 +1897,7 @@ struct xhci_hcd {#define XHCI_BROKEN_D3COLD BIT_ULL(41)#define XHCI_EP_CTX_BROKEN_DCS BIT_ULL(42)#define XHCI_SUSPEND_RESUME_CLKS BIT_ULL(43) +#define XHCI_RESET_TO_DEFAULT BIT_ULL(44)unsigned int num_active_eps;unsigned int limit_active_eps;
Signature · 1 line
2.25.1
Re: [PATCH 2/4] xhci: Add quirk to reset host back to default state at shutdown
Quoted 29 lines · Mathias Nyman
From: Mathias Nyman <[email protected]>
Systems based on Alder Lake P see significant boot time delay if boot firmware tries to control usb ports in unexpected link states.
This is seen with self-powered usb devices that survive in U3 link suspended state over S5.
A more generic solution to power off ports at shutdown was attempted in commit
83810f84ecf1("xhci: turn off port power in shutdown") but it caused regression.Add host specific
XHCI_RESET_TO_DEFAULTquirk which will reset host and ports back to default state in shutdown.Signed-off-by Mathias Nyman <[email protected]>--- drivers/usb/host/xhci-pci.c | 4 ++++ drivers/usb/host/xhci.c | 10 ++++++++-- drivers/usb/host/xhci.h | 1 + 3 files changed, 13 insertions(+), 2 deletions(-)drivers/usb/host/xhci-pci.c +0
-0
drivers/usb/host/xhci-pci.c static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) · line 261
Quoted 5 lines
drivers/usb/host/xhci-pci.c +2
-0@@ -257,6 +257,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) pdev->device == PCI_DEVICE_ID_INTEL_DNV_XHCI)) xhci->quirks |=XHCI_MISSING_CAS ; +if (pdev->vendor ==PCI_VENDOR_ID_INTEL && + pdev->device ==PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI )
We need this quirk for ADL-N too (device ID 0x54ed). Would you mind updating the patch? Or I can send a separate patch if you prefer.
Quoted 42 lines
drivers/usb/host/xhci-pci.c +2
-0+ xhci->quirks |=XHCI_RESET_TO_DEFAULT ; + if (pdev->vendor == PCI_VENDOR_ID_INTEL && (pdev->device == PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_2C_XHCI || pdev->device == PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_4C_XHCI ||drivers/usb/host/xhci.c +8
-2@@ -810,9 +810,15 @@ void xhci_shutdown(struct usb_hcd *hcd)spin_lock_irq (&xhci->lock);xhci_halt (xhci); -/* Workaround for spurious wakeups at shutdown with HSW */ -if (xhci->quirks &XHCI_SPURIOUS_WAKEUP ) + +/* +* Workaround for spurious wakeps at shutdown with HSW, and for boot +* firmware delay in ADL-P PCH if port are left in U3 at shutdown +*/ +if (xhci->quirks &XHCI_SPURIOUS_WAKEUP || + xhci->quirks &XHCI_RESET_TO_DEFAULT )xhci_reset (xhci,XHCI_RESET_SHORT_USEC ); +spin_unlock_irq (&xhci->lock);xhci_cleanup_msix (xhci);drivers/usb/host/xhci.h +1
-1@@ -1897,6 +1897,7 @@ struct xhci_hcd {#define XHCI_BROKEN_D3COLD BIT_ULL(41)#define XHCI_EP_CTX_BROKEN_DCS BIT_ULL(42)#define XHCI_SUSPEND_RESUME_CLKS BIT_ULL(43) +#define XHCI_RESET_TO_DEFAULT BIT_ULL(44)unsigned int num_active_eps;unsigned int limit_active_eps; --2.25.1
Greg KH
maintainerRe: [PATCH 2/4] xhci: Add quirk to reset host back to default state at shutdown
Quoted 33 lines · Reka Norman
Quoted 32 lines · Mathias Nyman
From: Mathias Nyman <[email protected]>
Systems based on Alder Lake P see significant boot time delay if boot firmware tries to control usb ports in unexpected link states.
This is seen with self-powered usb devices that survive in U3 link suspended state over S5.
A more generic solution to power off ports at shutdown was attempted in commit
83810f84ecf1("xhci: turn off port power in shutdown") but it caused regression.Add host specific
XHCI_RESET_TO_DEFAULTquirk which will reset host and ports back to default state in shutdown.Signed-off-by Mathias Nyman <[email protected]>--- drivers/usb/host/xhci-pci.c | 4 ++++ drivers/usb/host/xhci.c | 10 ++++++++-- drivers/usb/host/xhci.h | 1 + 3 files changed, 13 insertions(+), 2 deletions(-)drivers/usb/host/xhci-pci.c +0
-0@@ -257,6 +257,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) pdev->device == PCI_DEVICE_ID_INTEL_DNV_XHCI)) xhci->quirks |=XHCI_MISSING_CAS ;
Quoted 5 lines
drivers/usb/host/xhci-pci.c static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) · line 261
Quoted 2 lines
drivers/usb/host/xhci-pci.c +2
-0+if (pdev->vendor ==PCI_VENDOR_ID_INTEL && + pdev->device ==PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI )We need this quirk for ADL-N too (device ID
0x54ed). Would you mind updating the patch? Or I can send a separate patch if you prefer.
A separate patch is required, please submit it.
thanks,
greg k-h
Re: [PATCH 2/4] xhci: Add quirk to reset host back to default state at shutdown
Quoted 35 lines · Greg KH
Quoted 33 lines · Reka Norman
Quoted 32 lines · Mathias Nyman
From: Mathias Nyman <[email protected]>
Systems based on Alder Lake P see significant boot time delay if boot firmware tries to control usb ports in unexpected link states.
This is seen with self-powered usb devices that survive in U3 link suspended state over S5.
A more generic solution to power off ports at shutdown was attempted in commit
83810f84ecf1("xhci: turn off port power in shutdown") but it caused regression.Add host specific
XHCI_RESET_TO_DEFAULTquirk which will reset host and ports back to default state in shutdown.Signed-off-by Mathias Nyman <[email protected]>--- drivers/usb/host/xhci-pci.c | 4 ++++ drivers/usb/host/xhci.c | 10 ++++++++-- drivers/usb/host/xhci.h | 1 + 3 files changed, 13 insertions(+), 2 deletions(-)drivers/usb/host/xhci-pci.c +0
-0@@ -257,6 +257,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) pdev->device == PCI_DEVICE_ID_INTEL_DNV_XHCI)) xhci->quirks |=XHCI_MISSING_CAS ;
Quoted 7 lines
Quoted 5 lines
drivers/usb/host/xhci-pci.c static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) · line 261
Quoted 2 lines
drivers/usb/host/xhci-pci.c +2
-0+if (pdev->vendor ==PCI_VENDOR_ID_INTEL && + pdev->device ==PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI )We need this quirk for ADL-N too (device ID
0x54ed). Would you mind updating the patch? Or I can send a separate patch if you prefer.A separate patch is required, please submit it.
Done, thanks.
https://lore.kernel.org/linux-usb/[email protected]
Quoted 4 lines
thanks,
greg k-h
Mathias Nyman
maintainerPATCH 3/4 xhci-pci: Set runtime PM as default policy on all xHC 1.2 or later devices
In reply to Mathias NymanFrom: Mario Limonciello <[email protected]>
For optimal power consumption of USB4 routers the XHCI PCIe endpoint used for tunneling must be in D3. Historically this is accomplished by a long list of PCIe IDs that correspond to these endpoints because the xhci_hcd driver will not default to allowing runtime PM for all devices.
As both AMD and Intel have released new products with new XHCI controllers this list continues to grow. In reviewing the XHCI specification v1.2 on page 607 there is already a requirement that the PCI power management states D3hot and D3cold must be supported.
In the quirk list, use this to indicate that runtime PM should be allowed on XHCI controllers. The following controllers are known to be xHC 1.2 and dropped explicitly:
* AMD Yellow Carp
* Intel Alder Lake
* Intel Meteor Lake
* Intel Raptor Lake
--- drivers/usb/host/xhci-pci.c | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-)
drivers/usb/host/xhci-pci.c +4 -28
@@ -58,25 +58,13 @@#define PCI_DEVICE_ID_INTEL_CML_XHCI 0xa3af#define PCI_DEVICE_ID_INTEL_TIGER_LAKE_XHCI 0x9a13#define PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_XHCI 0x1138 -#define PCI_DEVICE_ID_INTEL_ALDER_LAKE_XHCI 0x461e -#define PCI_DEVICE_ID_INTEL_ALDER_LAKE_N_XHCI 0x464e -#define PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI 0x51ed -#define PCI_DEVICE_ID_INTEL_RAPTOR_LAKE_XHCI 0xa71e -#define PCI_DEVICE_ID_INTEL_METEOR_LAKE_XHCI 0x7ec0 +#define PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI 0x51ed#define PCI_DEVICE_ID_AMD_RENOIR_XHCI 0x1639#define PCI_DEVICE_ID_AMD_PROMONTORYA_4 0x43b9#define PCI_DEVICE_ID_AMD_PROMONTORYA_3 0x43ba#define PCI_DEVICE_ID_AMD_PROMONTORYA_2 0x43bb#define PCI_DEVICE_ID_AMD_PROMONTORYA_1 0x43bc -#define PCI_DEVICE_ID_AMD_YELLOW_CARP_XHCI_1 0x161a -#define PCI_DEVICE_ID_AMD_YELLOW_CARP_XHCI_2 0x161b -#define PCI_DEVICE_ID_AMD_YELLOW_CARP_XHCI_3 0x161d -#define PCI_DEVICE_ID_AMD_YELLOW_CARP_XHCI_4 0x161e -#define PCI_DEVICE_ID_AMD_YELLOW_CARP_XHCI_5 0x15d6 -#define PCI_DEVICE_ID_AMD_YELLOW_CARP_XHCI_6 0x15d7 -#define PCI_DEVICE_ID_AMD_YELLOW_CARP_XHCI_7 0x161c -#define PCI_DEVICE_ID_AMD_YELLOW_CARP_XHCI_8 0x161f#define PCI_DEVICE_ID_ASMEDIA_1042_XHCI 0x1042#define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI 0x1142
@@ -272,12 +260,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) pdev->device ==PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_XHCI || pdev->device ==PCI_DEVICE_ID_INTEL_ICE_LAKE_XHCI || pdev->device ==PCI_DEVICE_ID_INTEL_TIGER_LAKE_XHCI || - pdev->device ==PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_XHCI || - pdev->device ==PCI_DEVICE_ID_INTEL_ALDER_LAKE_XHCI || - pdev->device ==PCI_DEVICE_ID_INTEL_ALDER_LAKE_N_XHCI || - pdev->device ==PCI_DEVICE_ID_INTEL_ALDER_LAKE_PCH_XHCI || - pdev->device ==PCI_DEVICE_ID_INTEL_RAPTOR_LAKE_XHCI || - pdev->device == PCI_DEVICE_ID_INTEL_METEOR_LAKE_XHCI)) + pdev->device == PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_XHCI)) xhci->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW; if (pdev->vendor == PCI_VENDOR_ID_ETRON &&
@@ -346,15 +329,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_4)) xhci->quirks |= XHCI_NO_SOFT_RETRY; -if (pdev->vendor ==PCI_VENDOR_ID_AMD && - (pdev->device ==PCI_DEVICE_ID_AMD_YELLOW_CARP_XHCI_1 || - pdev->device ==PCI_DEVICE_ID_AMD_YELLOW_CARP_XHCI_2 || - pdev->device ==PCI_DEVICE_ID_AMD_YELLOW_CARP_XHCI_3 || - pdev->device ==PCI_DEVICE_ID_AMD_YELLOW_CARP_XHCI_4 || - pdev->device ==PCI_DEVICE_ID_AMD_YELLOW_CARP_XHCI_5 || - pdev->device ==PCI_DEVICE_ID_AMD_YELLOW_CARP_XHCI_6 || - pdev->device ==PCI_DEVICE_ID_AMD_YELLOW_CARP_XHCI_7 || - pdev->device ==PCI_DEVICE_ID_AMD_YELLOW_CARP_XHCI_8 )) +/* xHC spec requires PCI devices to support D3hot and D3cold */ +if (xhci->hci_version >=0x120 ) xhci->quirks |=XHCI_DEFAULT_PM_RUNTIME_ALLOW ;if (xhci->quirks &XHCI_RESET_ON_RESUME )
Signature · 1 line
2.25.1
Mathias Nyman
maintainerPATCH 4/4 xhci: Remove device endpoints from bandwidth list when freeing the device
In reply to Mathias NymanFrom: Mathias Nyman <[email protected]>
Endpoints are normally deleted from the bandwidth list when they are dropped, before the virt device is freed.
If xHC host is dying or being removed then the endpoints aren't dropped cleanly due to functions returning early to avoid interacting with a non-accessible host controller.
So check and delete endpoints that are still on the bandwidth list when freeing the virt device.
Solves a list_del corruption kernel crash when unbinding xhci-pci, caused by xhci_mem_cleanup() when it later tried to delete already freed endpoints from the bandwidth list.
This only affects hosts that use software bandwidth checking, which currenty is only the xHC in intel Panther Point PCH (Ivy Bridge)
--- drivers/usb/host/xhci-mem.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/usb/host/xhci-mem.c +12 -8
@@ -889,15 +889,19 @@ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id)if (dev->eps[i].stream_info)xhci_free_stream_info (xhci, dev->eps[i].stream_info); -/* Endpoints on the TT/root port lists should have been removed -* when usb_disable_device() was called for the device. -* We can't drop them anyway, because the udev might have gone -* away by this point, and we can't tell what speed it was. +/* +* Endpoints are normally deleted from the bandwidth list when +* endpoints are dropped, before device is freed. +* If host is dying or being removed then endpoints aren't +* dropped cleanly, so delete the endpoint from list here. +* Only applicable for hosts with software bandwidth checking. */ -if (!list_empty (&dev->eps[i].bw_endpoint_list)) -xhci_warn (xhci,"Slot %u endpoint %u " -"not removed from BW list!\n" , - slot_id, i); + +if (!list_empty (&dev->eps[i].bw_endpoint_list)) { +list_del_init (&dev->eps[i].bw_endpoint_list); +xhci_dbg (xhci,"Slot %u endpoint %u not removed from BW list!\n" , + slot_id, i); + } }/* If this is a hub, free the TT(s) from the TT list */ xhci_free_tt_info (xhci, dev, slot_id);
Signature · 1 line
2.25.1