Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934385AbbLWL7I (ORCPT ); Wed, 23 Dec 2015 06:59:08 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:50369 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934365AbbLWL7E (ORCPT ); Wed, 23 Dec 2015 06:59:04 -0500 X-AuditID: cbfee68f-f793a6d000001364-a1-567a8c8581d3 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: Wed, 23 Dec 2015 17:28:28 +0530 Message-id: <1450871908-4035-1-git-send-email-vikas.bansal@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBLMWRmVeSWpSXmKPExsWyRsSkVre1pyrMYEersUXz4vVsFpd3zWGz WLSsldmiedMUVou2PT9YLJ49n8nmwOaxeM9LJo/9c9ewe/RtWcXo8XmTXABLFJdNSmpOZllq kb5dAlfGsw8/2Qtu81Q8m5fVwDiXq4uRk0NCwERi2aRJbBC2mMSFe+uBbC4OIYEVjBKbt6xl hSk6dKmRESIxi1FiwpQuqKrvjBK/dtxmAqliE9CVWHP8G5gtIlAkcX3eOkYQm1nAReLM9eVg cWEBD4lfu9aD2SwCqhJnWm4B1XBw8Aq4S8x9FgqxTE7i5LHJrCDzJQTes0k0LjzOBlEvIPFt 8iEWkHoJAVmJTQeYIeolJQ6uuMEygVFwASPDKkbR1ILkguKk9CJjveLE3OLSvHS95PzcTYzA AD3971n/Dsa7B6wPMQpwMCrx8Dq0VYYJsSaWFVfmHmI0BdowkVlKNDkfGAd5JfGGxmZGFqYm psZG5pZmSuK8C6V+BgsJpCeWpGanphakFsUXleakFh9iZOLglGpgrP04c8empEulEl5/P1b+ /Pqd50GRW89Ho4TedUsZAxafq36ru8Vp4W+P0mT+x79fv7guz3tLPG3Z7utRfZzfIpR+3Zo3 d1t2QNveK4Wf1x0XKlunVDhl6fzzfzO1Fm1nvx90UWFKv4jbUsX513tud6ztExHfVx+qx3Qi dP1j6x0OFSzTfteXlCmxFGckGmoxFxUnAgAtsmNmSwIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmplkeLIzCtJLcpLzFFi42I5/e+xoG5rT1WYwea7WhbNi9ezWVzeNYfN YtGyVmaL5k1TWC3a9vxgsXj2fCabA5vH4j0vmTz2z13D7tG3ZRWjx+dNcgEsUQ2MNhmpiSmp RQqpecn5KZl56bZK3sHxzvGmZgaGuoaWFuZKCnmJuam2Si4+AbpumTlA25UUyhJzSoFCAYnF xUr6dpgmhIa46VrANEbo+oYEwfUYGaCBhDWMGc8+/GQvuM1T8WxeVgPjXK4uRk4OCQETiUOX GhkhbDGJC/fWs3UxcnEICcxilJgwpQvK+c4o8WvHbSaQKjYBXYk1x7+B2SICRRLX560D62YW cJE4c305WFxYwEPi1671YDaLgKrEmZZbQDUcHLwC7hJzn4VCLJOTOHlsMusERu4FjAyrGCVS C5ILipPSc43yUsv1ihNzi0vz0vWS83M3MYKj4Jn0DsbDu9wPMQpwMCrx8Dq0VYYJsSaWFVfm HmKU4GBWEuFNfwcU4k1JrKxKLcqPLyrNSS0+xGgKtH8is5Rocj4wQvNK4g2NTcxNjU0tTSxM zCyVxHn3XYoMExJITyxJzU5NLUgtgulj4uCUamBcx71p14EvEl+5I+5tmeAhtcC0hXfuXtM6 yxMiqeK/Pp5LfOvIX5Vz1+/CY5kHgeeU7in+CHQtmLBNT//ivQtnr26QT/n8u+sXz+lZMafe PVtaJ+Eu37SbL8Hs2BQN3mlrJi9Nify0cepMu/ssNT/XGaXypl3hTeta33bKYEbVultay63E yyapKrEUZyQaajEXFScCAP/zSt+YAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1831 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/