public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] USB: Fix xhci ERDP update issue
@ 2022-03-14  7:25 WeitaoWang-oc
  2022-03-14  7:39 ` Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: WeitaoWang-oc @ 2022-03-14  7:25 UTC (permalink / raw)
  To: mathias.nyman, gregkh, stern, linux-usb, linux-kernel
  Cc: CobeChen, TimGuo, tonywwang, weitaowang

On some situations, software handles TRB events slower than adding TRBs,
xhci_irq will not exit until all events are handled. If xhci_irq just
handles 256 TRBs and exit, the temp variable(event_ring_deq) driver 
records in xhci irq is equal to driver current dequeue pointer. It will 
cause driver not update ERDP and software dequeue pointer lost sync with 
ERDP. On the next xhci_irq, the event ring is full but driver will not 
update ERDP as software dequeue pointer is equal to ERDP.

[  536.377115] xhci_hcd 0000:00:12.0: ERROR unknown event type 37
[  566.933173] sd 8:0:0:0: [sdb] tag#27 uas_eh_abort_handler 0 uas-tag 7 
inflight: CMD OUT
[  566.933181] sd 8:0:0:0: [sdb] tag#27 CDB: Write(10) 2a 00 17 71 e6 78 
00 00 08 00
[  572.041186] xhci_hcd On some situataions,the0000:00:12.0: xHCI host 
not responding to stop endpoint command.
[  572.057193] xhci_hcd 0000:00:12.0: Host halt failed, -110
[  572.057196] xhci_hcd 0000:00:12.0: xHCI host controller not 
responding, assume dead
[  572.057236] sd 8:0:0:0: [sdb] tag#26 uas_eh_abort_handler 0 uas-tag 6 
inflight: CMD
[  572.057240] sd 8:0:0:0: [sdb] tag#26 CDB: Write(10) 2a 00 38 eb cc d8 
00 00 08 00
[  572.057244] sd 8:0:0:0: [sdb] tag#25 uas_eh_abort_handler 0 uas-tag 5 
inflight: CMD

Fixed this issue by update software record temp variable when handles 
128 TRB events.

Signed-off-by: Weitao Wang <WeitaoWang-oc@zhaoxin.com>
---
  drivers/usb/host/xhci-ring.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index d0b6806..f970799 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -3141,6 +3141,7 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd)
                 if (event_loop++ < TRBS_PER_SEGMENT / 2)
                         continue;
                 xhci_update_erst_dequeue(xhci, event_ring_deq);
+               event_ring_deq = xhci->event_ring->dequeue;

                 /* ring is half-full, force isoc trbs to interrupt more 
often */
                 if (xhci->isoc_bei_interval > AVOID_BEI_INTERVAL_MIN)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [PATCH] USB: Fix xhci ERDP update issue
@ 2022-03-18  7:32 WeitaoWang-oc
  2022-03-18  7:45 ` Greg KH
  0 siblings, 1 reply; 15+ messages in thread
From: WeitaoWang-oc @ 2022-03-18  7:32 UTC (permalink / raw)
  To: mathias.nyman, hzpeterchen, gregkh, linux-usb, linux-kernel
  Cc: TonyWWang-oc, weitaowang, CobeChen, TimGuo

On some situations, software handles TRB events slower than adding TRBs.
If the number of TRB events to be processed in a given interrupt is 256.
The local variable "event_ring_deq" that records in interrupt handler
is equal to software_dequeue. It will cause driver not update ERDP,then
software dequeue pointer is out of sync with ERDP on interrupt exit.
On the next interrupt, the event ring may full but driver will not
update ERDP as software_dequeue is equal to ERDP.

[  536.377115] xhci_hcd 0000:00:12.0: ERROR unknown event type 37
[  566.933173] sd 8:0:0:0: [sdb] tag#27 uas_eh_abort_handler 0 uas-tag 7 
inflight: CMD OUT
[  566.933181] sd 8:0:0:0: [sdb] tag#27 CDB: Write(10) 2a 00 17 71 e6 78 
00 00 08 00
[  572.041186] xhci_hcd On some situataions,the0000:00:12.0: xHCI host 
not responding to stop endpoint command.
[  572.057193] xhci_hcd 0000:00:12.0: Host halt failed, -110
[  572.057196] xhci_hcd 0000:00:12.0: xHCI host controller not 
responding, assume dead
[  572.057236] sd 8:0:0:0: [sdb] tag#26 uas_eh_abort_handler 0 uas-tag 6 
inflight: CMD
[  572.057240] sd 8:0:0:0: [sdb] tag#26 CDB: Write(10) 2a 00 38 eb cc d8 
00 00 08 00
[  572.057244] sd 8:0:0:0: [sdb] tag#25 uas_eh_abort_handler 0 uas-tag 5 
inflight: CMD

Fixed this issue by update software record local variable when handles 
128 TRB events.

Signed-off-by: Weitao Wang <WeitaoWang-oc@zhaoxin.com>
---
  drivers/usb/host/xhci-ring.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index d0b6806..f970799 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -3141,6 +3141,7 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd)
  		if (event_loop++ < TRBS_PER_SEGMENT / 2)
  			continue;
  		xhci_update_erst_dequeue(xhci, event_ring_deq);
+		event_ring_deq = xhci->event_ring->dequeue;

  		/* ring is half-full, force isoc trbs to interrupt more often */
  		if (xhci->isoc_bei_interval > AVOID_BEI_INTERVAL_MIN)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [PATCH] USB: Fix xhci ERDP update issue
@ 2022-03-18 12:17 WeitaoWang-oc
  2022-03-18 12:34 ` Greg KH
  0 siblings, 1 reply; 15+ messages in thread
From: WeitaoWang-oc @ 2022-03-18 12:17 UTC (permalink / raw)
  To: mathias.nyman, gregkh, hzpeterchen, linux-usb, linux-kernel
  Cc: tonywwang, weitaowang

On some situations, software handles TRB events slower than adding TRBs.
If the number of TRB events to be processed in a given interrupt is 256.
The local variable "event_ring_deq" that records in interrupt handler
is equal to software_dequeue. It will cause driver not update ERDP,then
software dequeue pointer is out of sync with ERDP on interrupt exit.
On the next interrupt, the event ring may full but driver will not
update ERDP as software_dequeue is equal to ERDP.

[  536.377115] xhci_hcd 0000:00:12.0: ERROR unknown event type 37
[  566.933173] sd 8:0:0:0: [sdb] tag#27 uas_eh_abort_handler 0 uas-tag 7
inflight: CMD OUT
[  566.933181] sd 8:0:0:0: [sdb] tag#27 CDB: Write(10) 2a 00 17 71 e6 78
00 00 08 00
[  572.041186] xhci_hcd On some situataions,the0000:00:12.0: xHCI host
not responding to stop endpoint command.
[  572.057193] xhci_hcd 0000:00:12.0: Host halt failed, -110
[  572.057196] xhci_hcd 0000:00:12.0: xHCI host controller not
responding, assume dead
[  572.057236] sd 8:0:0:0: [sdb] tag#26 uas_eh_abort_handler 0 uas-tag 6
inflight: CMD
[  572.057240] sd 8:0:0:0: [sdb] tag#26 CDB: Write(10) 2a 00 38 eb cc d8
00 00 08 00
[  572.057244] sd 8:0:0:0: [sdb] tag#25 uas_eh_abort_handler 0 uas-tag 5
inflight: CMD

To avoid this issue by update software record local variable when
handles 128 TRB events.

Fixes: dc0ffbea5729 ("usb: host: xhci: update event ring dequeue pointer on purpose")
Signed-off-by: Weitao Wang <WeitaoWang-oc@zhaoxin.com>
---
  drivers/usb/host/xhci-ring.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index d0b6806275e0..f9707997969d 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -3141,6 +3141,7 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd)
  		if (event_loop++ < TRBS_PER_SEGMENT / 2)
  			continue;
  		xhci_update_erst_dequeue(xhci, event_ring_deq);
+		event_ring_deq = xhci->event_ring->dequeue;

  		/* ring is half-full, force isoc trbs to interrupt more often */
  		if (xhci->isoc_bei_interval > AVOID_BEI_INTERVAL_MIN)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2022-03-18 12:35 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-14  7:25 [PATCH] USB: Fix xhci ERDP update issue WeitaoWang-oc
2022-03-14  7:39 ` Greg KH
2022-03-16 11:57   ` Peter Chen
2022-03-16 12:45     ` Mathias Nyman
2022-03-17  1:51       ` Peter Chen
2022-03-16 12:47     ` WeitaoWang-oc
2022-03-15  8:08 ` Mathias Nyman
2022-03-15 12:44   ` WeitaoWang-oc
2022-03-16 13:20     ` Mathias Nyman
2022-03-17  2:43       ` WeitaoWang-oc
2022-03-17  1:56 ` Peter Chen
  -- strict thread matches above, loose matches on Subject: below --
2022-03-18  7:32 WeitaoWang-oc
2022-03-18  7:45 ` Greg KH
2022-03-18 12:17 WeitaoWang-oc
2022-03-18 12:34 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox