usb: xhci: fix bulk tx with trb ent

On Rockchip platforms, we use TRB_ENT for bulk Tx TRB.
However, the TRB_ENT can only be enabled for TRB if
the transfer length of the TRB is an integer multiple
of the EP maxpacket. The current code only check the
transfer length of the first TRB, it's not enough.

Without this patch, the xHCI fail to do Read(10) command
with the U3 Disk used VFAT filesystem on RK3566 Box board
(2 + 4)G DDR, the error log like this:

[   23.165539] usb 2-1: new SuperSpeed Gen 1 USB device number 2 using xhci-hcd
[   23.183342] usb 2-1: New USB device found, idVendor=0781, idProduct=55a3, bcdDevice= 1.00
[   23.183418] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   23.183434] usb 2-1: Product: Ultra Luxe
[   23.183447] usb 2-1: Manufacturer: SanDisk
...
[   23.186615] usb-storage 2-1:1.0: USB Mass Storage device detected
[   23.189013] scsi host0: usb-storage 2-1:1.0
[   24.217186] scsi 0:0:0:0: Direct-Access     SanDisk  Ultra Luxe       1.00 PQ: 0 ANSI: 6
[   24.219712] sd 0:0:0:0: [sda] 120127488 512-byte logical blocks: (61.5 GB/57.3 GiB)
[   24.221263] sd 0:0:0:0: Attached scsi generic sg0 type 0
[   24.221301] sd 0:0:0:0: [sda] Write Protect is off
[   24.222162] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[   24.243346] sd 0:0:0:0: [sda] Attached SCSI removable disk
[   24.642325] FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[   25.862084] usb 2-1: reset SuperSpeed Gen 1 USB device number 2 using xhci-hcd
[   25.882974] sd 0:0:0:0: [sda] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK
[   25.883003] sd 0:0:0:0: [sda] tag#0 CDB: Read(10) 28 00 00 50 28 01 00 00 3f 00
[   28.349195] usb 2-1: reset SuperSpeed Gen 1 USB device number 2 using xhci-hcd
[   28.366763] sd 0:0:0:0: [sda] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK
[   28.366823] sd 0:0:0:0: [sda] tag#0 CDB: Read(10) 28 00 01 15 4b 81 00 00 3f 00

Fixes: 0f580acb01 ("usb: xhci: add support for xhci trb ent quirk")
Signed-off-by: William Wu <william.wu@rock-chips.com>
Change-Id: Iaa8f87eba3146c09fda858704c96644da40f5859
This commit is contained in:
William Wu
2021-03-29 16:46:49 +08:00
committed by Tao Huang
parent 51f0473d7f
commit 78181a93d1

View File

@@ -3291,16 +3291,18 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
first_trb = false;
if (start_cycle == 0)
field |= TRB_CYCLE;
/*
* Don't enable the ENT flag in the TRB if the
* transfer length of the first TRB isn't an
* integer multiple of the EP maxpacket.
*/
if (trb_buff_len % usb_endpoint_maxp(&urb->ep->desc))
en_trb_ent = false;
} else
field |= ring->cycle_state;
/*
* Don't enable the ENT flag in the TRB if the
* transfer length of the TRB isn't an integer
* multiple of the EP maxpacket.
*/
if (en_trb_ent &&
(trb_buff_len % usb_endpoint_maxp(&urb->ep->desc)))
en_trb_ent = false;
/* Chain all the TRBs together; clear the chain bit in the last
* TRB to indicate it's the last TRB in the chain.
*/