We sometimes see that the TRB math is wrong, despite the fixes in the previous patch, and we get a "Miscalculated number of TRBs, 1 left" message. This seems harmless with the NEC controller, but with the Synopsys controller it causes serious issues. So this patch is a workaround for that. --- drivers/usb/host/xhci-ring.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 71b8687..a0a68c5 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2564,7 +2564,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, /* Chain all the TRBs together; clear the chain bit in the last * TRB to indicate it's the last TRB in the chain. */ - if (num_trbs > 1) { + if (num_trbs > 1 && running_total + trb_buff_len < urb->transfer_buffer_length) { field |= TRB_CHAIN; } else { /* FIXME - add check for ZERO_PACKET flag before this */ @@ -2588,7 +2588,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, length_field = TRB_LEN(trb_buff_len) | remainder | TRB_INTR_TARGET(0); - if (num_trbs > 1) + if (num_trbs > 1 && running_total + trb_buff_len < urb->transfer_buffer_length) more_trbs_coming = true; else more_trbs_coming = false; @@ -2725,7 +2725,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, /* Chain all the TRBs together; clear the chain bit in the last * TRB to indicate it's the last TRB in the chain. */ - if (num_trbs > 1) { + if (num_trbs > 1 && running_total + trb_buff_len < urb->transfer_buffer_length) { field |= TRB_CHAIN; } else { /* FIXME - add check for ZERO_PACKET flag before this */ @@ -2737,7 +2737,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, length_field = TRB_LEN(trb_buff_len) | remainder | TRB_INTR_TARGET(0); - if (num_trbs > 1) + if (num_trbs > 1 && running_total + trb_buff_len < urb->transfer_buffer_length) more_trbs_coming = true; else more_trbs_coming = false; -- 1.6.5.1.69.g36942 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html