diff mbox series

[v2] usb: xhci: do not perform Soft Retry for some xHCI hosts

Message ID 20210210081254.33734-1-stf_xl@wp.pl (mailing list archive)
State New, archived
Headers show
Series [v2] usb: xhci: do not perform Soft Retry for some xHCI hosts | expand

Commit Message

Stanislaw Gruszka Feb. 10, 2021, 8:12 a.m. UTC
From: Stanislaw Gruszka <stf_xl@wp.pl>

Since f8f80be501aa ("xhci: Use soft retry to recover faster from
transaction errors") on some systems rt2800usb and mt7601u devices
are unable to operate. Possible reason is that some xHCI hardware
can not perform Soft Retry for those devices correctly.

To avoid the problem add xhci->quirks flag that restore pre f8f80be501aa
xhci behaviour for affected xHCI controllers. Currently those are
AMD_PROMONTORYA_4 and AMD_PROMONTORYA_2, since it was confirmed
by the users: on those xHCI hosts issue happen and is gone after
disabling Soft Retry.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=202541
Fixes: f8f80be501aa ("xhci: Use soft retry to recover faster from transaction errors")
Reported-and-tested-by: Bernhard <bernhard.gebetsberger@gmx.at>
Bisected-by: Bernhard <bernhard.gebetsberger@gmx.at>
Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
v1 -> v2:
compared to previous patch:
https://lore.kernel.org/linux-usb/20210122104342.12451-1-stf_xl@wp.pl/t/#u
now we use xhci->quirks to disable Soft Retry (I also changed topic
to reflect the change).

 drivers/usb/host/xhci-pci.c  | 5 +++++
 drivers/usb/host/xhci-ring.c | 3 ++-
 drivers/usb/host/xhci.h      | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)

Comments

Mathias Nyman Feb. 10, 2021, 12:53 p.m. UTC | #1
On 10.2.2021 10.12, stf_xl@wp.pl wrote:
> From: Stanislaw Gruszka <stf_xl@wp.pl>
> 
> Since f8f80be501aa ("xhci: Use soft retry to recover faster from
> transaction errors") on some systems rt2800usb and mt7601u devices
> are unable to operate. Possible reason is that some xHCI hardware
> can not perform Soft Retry for those devices correctly.
> 
> To avoid the problem add xhci->quirks flag that restore pre f8f80be501aa
> xhci behaviour for affected xHCI controllers. Currently those are
> AMD_PROMONTORYA_4 and AMD_PROMONTORYA_2, since it was confirmed
> by the users: on those xHCI hosts issue happen and is gone after
> disabling Soft Retry.
> 
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=202541
> Fixes: f8f80be501aa ("xhci: Use soft retry to recover faster from transaction errors")
> Reported-and-tested-by: Bernhard <bernhard.gebetsberger@gmx.at>
> Bisected-by: Bernhard <bernhard.gebetsberger@gmx.at>
> Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
> ---
> v1 -> v2:
> compared to previous patch:
> https://lore.kernel.org/linux-usb/20210122104342.12451-1-stf_xl@wp.pl/t/#u
> now we use xhci->quirks to disable Soft Retry (I also changed topic
> to reflect the change).
> 
>  drivers/usb/host/xhci-pci.c  | 5 +++++
>  drivers/usb/host/xhci-ring.c | 3 ++-
>  drivers/usb/host/xhci.h      | 1 +
>  3 files changed, 8 insertions(+), 1 deletion(-)
> 


Thanks.

Checkpatch complains about some minor things, I'll fix those while applying.
Will send forward after 5.12-rc1 is out, and add stable tag.

-Mathias
diff mbox series

Patch

diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 84da8406d5b4..1f989a49c8c6 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -295,6 +295,11 @@  static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
 	     pdev->device == 0x9026)
 		xhci->quirks |= XHCI_RESET_PLL_ON_DISCONNECT;
 
+	if (pdev->vendor == PCI_VENDOR_ID_AMD &&
+	    (pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_2 ||
+	     pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_4))
+		xhci->quirks |= XHCI_NO_SOFT_RETRY;
+
 	if (xhci->quirks & XHCI_RESET_ON_RESUME)
 		xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
 				"QUIRK: Resetting on resume");
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 5677b81c0915..12d2ff2550b2 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2302,7 +2302,8 @@  static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td,
 		remaining	= 0;
 		break;
 	case COMP_USB_TRANSACTION_ERROR:
-		if ((ep_ring->err_count++ > MAX_SOFT_RETRY) ||
+		if (xhci->quirks & XHCI_NO_SOFT_RETRY ||
+		    (ep_ring->err_count++ > MAX_SOFT_RETRY) ||
 		    le32_to_cpu(slot_ctx->tt_info) & TT_SLOT)
 			break;
 		*status = 0;
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 25e57bc9c3cc..0ddfde2780c9 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1883,6 +1883,7 @@  struct xhci_hcd {
 #define XHCI_SKIP_PHY_INIT	BIT_ULL(37)
 #define XHCI_DISABLE_SPARSE	BIT_ULL(38)
 #define XHCI_SG_TRB_CACHE_SIZE_QUIRK	BIT_ULL(39)
+#define XHCI_NO_SOFT_RETRY	BIT_ULL(40)
 
 	unsigned int		num_active_eps;
 	unsigned int		limit_active_eps;