Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751598AbbLUMQU (ORCPT ); Mon, 21 Dec 2015 07:16:20 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:53543 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751199AbbLUMQT (ORCPT ); Mon, 21 Dec 2015 07:16:19 -0500 X-AuditID: cbfee68e-f793c6d00000136c-a2-5677ed91b7ab From: Vikas Bansal To: mathias.nyman@intel.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: sumit.batra@samsung.com, Vikas Bansal Subject: [PATCH] BugFix in XHCI controller driver for scatter gather DMA Date: Mon, 21 Dec 2015 17:45:41 +0530 Message-id: <1450700141-4798-1-git-send-email-vikas.bansal@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJLMWRmVeSWpSXmKPExsWyRsSkRnfi2/Iwgy0vJC2aF69ns7i8aw6b xaJlrcwWzZumsFq07fnBYvHs+Uw2BzaPxXteMnnsn7uG3aNvyypGj8+b5AJYorhsUlJzMstS i/TtErgy9t37z1ZwnKei/eJi1gbGOVxdjJwcEgImEr1P3jNC2GISF+6tZwOxhQRWMEpcfSoK U7O7pZe5i5ELKD6LUeLbzTlQzndGifYff5hAqtgEdCXWHP8GZosIFElcn7cObCqzgIvEmevL weLCAh4Sv3atB7NZBFQlVj74CGbzCrhLbLizBuoKOYmTxyazgiyQEPjMJvH7OIgD0iAg8W3y IZYuRg6ghKzEpgPMEPWSEgdX3GCZwCi4gJFhFaNoakFyQXFSepGRXnFibnFpXrpecn7uJkZg iJ7+96xvB+PNA9aHGAU4GJV4eD88LwsTYk0sK67MPcRoCrRhIrOUaHI+MBLySuINjc2MLExN TI2NzC3NlMR5E6R+BgsJpCeWpGanphakFsUXleakFh9iZOLglGpgZPi63N76StMbg+Kjzop+ zW0OrM/8j29+PfnyvOavujVryt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@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1818 Lines: 39 From: Sumit Batra Pre-Condition URB with Scatter Gather list is queued to bulk OUT endpoint. Every buffer in scatter gather list is not a multiple of maximum packet size for that endpoint(short packet). CHAIN bit is set for all TRBs in a TD so that the DMA happens to all of them at once. Issue DMA operation copies all the CHAINED TRBs at contiguous device memory. But since the original packet was a short packet, so the actual data is re-aligned after this DMA operation. At device end this re-aligned data causes data integrity issue with applications like ICMP ping. Solution Don't set the CHAINED bit for these TRBs, if their buffers are not a multiple of maximum packet size. This will reduce the benefit in throughput as required from a scatter gather implementation, but this reduces the CPU utilization. And solves the data integrity issue on Device End Signed-off-by: Sumit Batra Signed-off-by: Vikas Bansal diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 7d34cbf..862d7cd 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -3110,7 +3110,8 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, * TRB to indicate it's the last TRB in the chain. */ if (num_trbs > 1) { - field |= TRB_CHAIN; + if(this_sg_len % usb_endpoint_maxp(&urb->ep->desc) == 0) + field |= TRB_CHAIN; } else { /* FIXME - add check for ZERO_PACKET flag before this */ td->last_trb = ep_ring->enqueue; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/