Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751907AbbLUMrI (ORCPT ); Mon, 21 Dec 2015 07:47:08 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:51492 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751416AbbLUMrG (ORCPT ); Mon, 21 Dec 2015 07:47:06 -0500 X-AuditID: cbfee68d-f79646d000001355-da-5677f4c760f1 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 18:16:08 +0530 Message-id: <1450701968-5195-1-git-send-email-vikas.bansal@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBLMWRmVeSWpSXmKPExsWyRsSkVvf4l/Iwg81PFC2aF69ns7i8aw6b xaJlrcwWzZumsFq07fnBYvHs+Uw2BzaPxXteMnnsn7uG3aNvyypGj8+b5AJYorhsUlJzMstS i/TtErgybi/rYCy4xVPxbF5WA+Ncri5GTg4JAROJCyd/skLYYhIX7q1n62Lk4hASWMEo0dY1 jR2m6Pe7mYwgtpDALEaJC/eVIIq+M0qcfvCFGSTBJqArseb4NyYQW0SgSOL6vHVgDcwCLhJn ri8HiwsLeEj82rUezGYRUJVomd8BtoBXwF3i+dv9UMvkJE4em8wKskBC4DObxPGzW1khGgQk vk0+xNLFyAGUkJXYdIAZol5S4uCKGywTGAUXMDKsYhRNLUguKE5KLzLUK07MLS7NS9dLzs/d xAgM0NP/nvXuYLx9wPoQowAHoxIP70vt8jAh1sSy4srcQ4ymQBsmMkuJJucD4yCvJN7Q2MzI wtTE1NjI3NJMSZxXUepnsJBAemJJanZqakFqUXxRaU5q8SFGJg5OqQbGTV22G+X6GP8syzgb qbpNYOpT9U/eZ/Tdp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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1830 Lines: 46 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..7363dee 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -3110,7 +3110,9 @@ 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/