Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2091629ybg; Thu, 24 Oct 2019 04:43:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzunX5hG4ZLZRmNClUZytixBco+7rKf2B8z3EZYVkn8xK4JVvlrlNyRjoeqESyMF4p3lSDk X-Received: by 2002:a05:6402:1614:: with SMTP id f20mr1604308edv.202.1571917394523; Thu, 24 Oct 2019 04:43:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571917394; cv=none; d=google.com; s=arc-20160816; b=oopfxhIvnx2QrvEGzJobjy5/m4kRN06ixXg0eBjE0Srh1NjAcAiVhYzwAd6jlhm1Eh 49evsY/L6aoEvWplCHqNMgbNnVXl9A1G35rCJm62Itq7xFyKOnXMUOqQ8UegKc+sQYzo lvjwVgusdmtJT1nShRkH2stpiKx/QMKwE9FYN8tMy87sOap5mJDYzff9pNQHvzLeOuDX 1EcMOqzLtUNmAa1yN/5lsYoh0fBvjscy2OGAJSoP69t5vPq0iw11bq4YYBU0OQzgKoTS /uTyBMJbU8svD4dKk8WFHaurvEX5SYo2BpHB1xP43EVuQSf8VtLtdYRbNCljJ7EL3SN3 2mMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:dkim-signature:dkim-signature; bh=EO9B3zgtauIvY/L7Mc6CwXWDfogF64oEp6cEBr8OFqQ=; b=nl4apr1aznPCWNOZdz5ER2VVOwOxEZ9mJBhgamDWSYUsfP6ByC+X+8SMQc4K9HudhD w7rHG9kRMsXj2sfUEiCFPDsGhxuTOCfw1SEAVwXJotaa2KCLrdKp84okcx4m5raNSvHI fqyvrkJeJL4LrsjvYNbQarLLSkvxDA5EctrbCDGN8AUWMEQHBSkPItyS22bnYT/cNsE5 F5ISLrAX2hlHVF3ybjECHbECxA4/iR1WpB22Naa9mRbpfuVaB6OJExag0zpgY1kYIXMP /3Sxt37bxkt3Tz4pZ1U+h9PPMGQtMIapRovVdlnR+XBj2nzP5cYsqpWWTVrUv/JwRyUH ir0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=edqcx+u+; dkim=pass header.i=@codeaurora.org header.s=default header.b=i0XqgQqB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b18si9082467edc.390.2019.10.24.04.42.50; Thu, 24 Oct 2019 04:43:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=edqcx+u+; dkim=pass header.i=@codeaurora.org header.s=default header.b=i0XqgQqB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726646AbfJWQ6K (ORCPT + 99 others); Wed, 23 Oct 2019 12:58:10 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:40226 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbfJWQ6K (ORCPT ); Wed, 23 Oct 2019 12:58:10 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id BE63960DB8; Wed, 23 Oct 2019 16:58:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1571849888; bh=e/wbk7W51qosh1x31nJNEuLAxvnQRx8M8ayYRV5U3eg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=edqcx+u+rlmocI2E86il4NC0lXAUiJ0VXXX3etgyxoQhitzri37iHd9IHR3m+TQR2 UfNZeqL9X0vG9KyyxRLVx74Er4dWWritg0vZkDymTzbh4eogvCPS9DKIVbqjb/l0ek 1jdStirZfReVfjq2xKODj+mbER4Ndow2NUIaIkOA= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED,SPF_NONE autolearn=no autolearn_force=no version=3.4.0 Received: from jackp-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: jackp@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 9D54960DB8; Wed, 23 Oct 2019 16:58:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1571849887; bh=e/wbk7W51qosh1x31nJNEuLAxvnQRx8M8ayYRV5U3eg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=i0XqgQqBfDxVfDQ6znF3gcx2COuTjhZ19Nb5eIKcq/bGbJHXbq5vbPqV2SOst+Ezg QbwXeTP6U403KXRPyXTAQh9kXzhHdZhRGTOHPvyXA0mwhlSZaPw8NEQ1x9f/IB+jlt OU9ynhfOTw1gvQQmNdk4JYrXtZJVqTixWAej2H1w= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 9D54960DB8 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jackp@codeaurora.org Date: Wed, 23 Oct 2019 09:58:04 -0700 From: Jack Pham To: Felipe Balbi Cc: Anurag Kumar Vulisha , Greg Kroah-Hartman , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "v.anuragkumar@gmail.com" Subject: Re: [PATCH] usb: dwc3: gadget: Correct the logic for finding last SG entry Message-ID: <20191023165804.GD9754@jackp-linux.qualcomm.com> References: <1559141985-17104-1-git-send-email-anurag.kumar.vulisha@xilinx.com> <87y32gcvc1.fsf@linux.intel.com> <87ftoldh48.fsf@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87ftoldh48.fsf@linux.intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Anurag, On Fri, Jun 07, 2019 at 09:49:59AM +0300, Felipe Balbi wrote: > Anurag Kumar Vulisha writes: > >>> The dma_map_sg() merges sg1 & sg2 memory regions into sg1- > >>>dma_address. > >>> Similarly sg3 & sg4 into sg2->dma_address, sg5 & sg6 into the > >>> sg3->dma_address and sg6 & sg8 into sg4->dma_address. Here the > >>memory > >>> regions are merged but the page_link properties like SG_END are not > >>> retained into the merged sgs. > >> > >>isn't this a bug in the scatterlist mapping code? Why doesn't it keep > >>SG_END? > >> > > > > Thanks for providing your comment. > > > > I don't think it is a bug, instead I feel some enhancement needs to be done in > > dma-mapping code. > > > > SG_END represents the last sg entry in the sglist and it is correctly getting > > set to the last sg entry. > > > > The issue happens only when 2 or more sg entry pages are merged into > > contiguous dma-able address and sg_is_last() is used to find the last sg entry > > with valid dma address. > > Right, and that's something that's bound to happen. I'm arguing that, perhaps, > dma API should move SG_END in case entries are merged. > > > I think that along with sg_is_last() a new flag (SG_DMA_END) and function > > (something like sg_dma_is_last() ) needs to be added into dma-mapping code for > > identifying the last valid sg entry with valid dma address. So that we can > > make use of that function instead of sg_is_last(). > > Sure, propose a patch to DMA API. I'm curious if this was ever resolved. I just ran into this exact issue with Android ADB which uses 16KB buffers, along with f_fs supporting S/G since 5.0, combined with our IOMMU which performs this merging behavior, so it resulted in a single TRB getting queued with CHN=1 and LST=0 and thus the transfer never completes. Your initial patch resolves the issue for me, but upon revisiting this discussion I couldn't tell if you had attempted to patch DMA API instead as per Felipe's suggestion. Thanks, Jack -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project