Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751424AbbLUSXl (ORCPT ); Mon, 21 Dec 2015 13:23:41 -0500 Received: from mail-lf0-f51.google.com ([209.85.215.51]:35274 "EHLO mail-lf0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750914AbbLUSXj (ORCPT ); Mon, 21 Dec 2015 13:23:39 -0500 Subject: Re: [PATCH] BugFix in XHCI controller driver for scatter gather DMA To: Vikas Bansal , mathias.nyman@intel.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org References: <1450701968-5195-1-git-send-email-vikas.bansal@samsung.com> Cc: sumit.batra@samsung.com From: Sergei Shtylyov Organization: Cogent Embedded Message-ID: <567843A7.5070104@cogentembedded.com> Date: Mon, 21 Dec 2015 21:23:35 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1450701968-5195-1-git-send-email-vikas.bansal@samsung.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2091 Lines: 57 Hello. On 12/21/2015 03:46 PM, Vikas Bansal wrote: > 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) Indent with 2 extra tabs ISO 1 please -- it'll be easier on the eyes (blends with the next statement otherwise). > + field |= TRB_CHAIN; > } else { > /* FIXME - add check for ZERO_PACKET flag before this */ > td->last_trb = ep_ring->enqueue; MBR, Sergei -- 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/