diff mbox series

xhci: handle stop ep on invalid CStream

Message ID 1542091732-23951-1-git-send-email-henryl@nvidia.com (mailing list archive)
State New, archived
Headers show
Series xhci: handle stop ep on invalid CStream | expand

Commit Message

Henry Lin Nov. 13, 2018, 6:48 a.m. UTC
Below Note in xHCI spec 6.4.2.1 describes a Transfer Event is generated
for Stop Endpoint Command on invalid CStream:

CStream is not valid until a Streams endpoint transitions to the Start
Stream state for the first time. A Transfer Event generated by a Stop
Endpoint Command shall report '0' in the TRB Pointer and TRB Length fields
if the command is executed and CStream is invalid. Refer to section 4.12.1.

But, current implementation will output below error messages once driver
receives the Transfer Event for invalid CStream:

[  133.184633] xhci_hcd 0000:01:00.2: ERROR Transfer event for unknown stream ring slot 1 ep 2
[  133.184635] xhci_hcd 0000:01:00.2: @000000046044a420 00000000 00000000 1b000000 01038001

This issue can be observed while uas driver is handling SCSI command that
connected UAS device doesn't support. UAS device rejects the unsupported
command and causes Data-In stream for SCSI command data stopped when
CStream is invalid.

This patch handles the transfer event to remove false error messages.

Signed-off-by: Henry Lin <henryl@nvidia.com>
---
 drivers/usb/host/xhci-ring.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Mathias Nyman Nov. 14, 2018, 9:22 a.m. UTC | #1
Hi

On 13.11.2018 08:48, Henry Lin wrote:
> Below Note in xHCI spec 6.4.2.1 describes a Transfer Event is generated
> for Stop Endpoint Command on invalid CStream:
> 
> CStream is not valid until a Streams endpoint transitions to the Start
> Stream state for the first time. A Transfer Event generated by a Stop
> Endpoint Command shall report '0' in the TRB Pointer and TRB Length fields
> if the command is executed and CStream is invalid. Refer to section 4.12.1.
> 
> But, current implementation will output below error messages once driver
> receives the Transfer Event for invalid CStream:
> 
> [  133.184633] xhci_hcd 0000:01:00.2: ERROR Transfer event for unknown stream ring slot 1 ep 2
> [  133.184635] xhci_hcd 0000:01:00.2: @000000046044a420 00000000 00000000 1b000000 01038001
> 
> This issue can be observed while uas driver is handling SCSI command that
> connected UAS device doesn't support. UAS device rejects the unsupported
> command and causes Data-In stream for SCSI command data stopped when
> CStream is invalid.
> 
> This patch handles the transfer event to remove false error messages.
> 

A patch by Sandeep Singh that takes care of the same COMP_STOPPED_LENGTH_INVALID
case with zero TRB pointer just got applied, so this should now be taken care of.

https://marc.info/?l=linux-usb&m=153753620603125&w=2

It's in Greg's usb-linus branch:
d9193ef xhci: Add check for invalid byte size error when UAS devices are connected.

-Mathias
diff mbox series

Patch

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index a8d92c9..8ae658e 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2267,6 +2267,11 @@  static int handle_tx_event(struct xhci_hcd *xhci,
 		case COMP_RING_UNDERRUN:
 		case COMP_RING_OVERRUN:
 			goto cleanup;
+		case COMP_STOPPED_LENGTH_INVALID:
+			if ((ep->ep_state & EP_HAS_STREAMS) &&
+					(event->buffer == 0))
+				goto cleanup;
+			/* else fall through */
 		default:
 			xhci_err(xhci, "ERROR Transfer event for unknown stream ring slot %u ep %u\n",
 				 slot_id, ep_index);