Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4035289pxf; Tue, 16 Mar 2021 04:16:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1srBz/qkcaH3xK2hLWf5oLH55WXziddG1d65iyXhpqiZxPHCVOBucOXWodQMW0+AJ1xj7 X-Received: by 2002:a17:906:f44:: with SMTP id h4mr28361090ejj.204.1615893382694; Tue, 16 Mar 2021 04:16:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615893382; cv=none; d=google.com; s=arc-20160816; b=kdKl6nQKLwog/LDBc5AoBJWoZT2iXgCEEii9fipoE3V9wuTZbW3Tw+nyexMQjEueEH dV9ot5tXvim4qvXQGlVriyW5SxtssbhJexz+OoJc2GqhmSr9PRD89b1CVgpFbTcQfbp3 JWDdJppbtQM3LMgxHeNehDQr7tX8gB+8VL4R4SneUrK5qoLIVsRvW/ROhpesK4jyyjVz x3f0x8Pv+THpa/5AbGxfgtxCX0lPQALXjEvMNmNRLAOAaJi6hNlUf2DnBHcK2iEARS3o bdcFF43ImQu0LbsDKLVXqKPst3Ybd29iWEXxEC9cQEmA0cUaTculvLITrI1Lq7bidV+1 w/Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Pdsl/J8mYAnIU4+ZoR7SmN5YsHH90IQlxmRkCg0FBGc=; b=0VbFHBr+X1QXwPTHtAX6n7Zx+qN2sXE7EPhJa2+S5Yn4UXSZERkBiZW3YuGTPLbDCB KBmWPs27XIV7je7NA1ik2RMXhXOU9B+w7rLNkZfWq+0iPC3uDNTAd0e0lpi5MtshVZtm yQpjrTU+eeuSjodZYYh+TY8ynDu5vJameX9N/Fixg8xlqysG595h+T9UjZf9CUtmGOpn p4WinTzAFf6jLRVRMr6RhcdxXufuXwxBRrxG8rAYvogZ1ocZiHX24KA7n/0vXXgzt5li 6oal/9ZLF2IYcQGaRTmTP3sbcmNQfJfwNzKQqamsflFbFOwhd4NEh0nOmMzPptXOypYM 5Lyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GGGl+0vd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q16si14017633ejt.685.2021.03.16.04.16.00; Tue, 16 Mar 2021 04:16:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GGGl+0vd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232288AbhCPAeY (ORCPT + 99 others); Mon, 15 Mar 2021 20:34:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:56558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230319AbhCPAeD (ORCPT ); Mon, 15 Mar 2021 20:34:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 25B3564EE2; Tue, 16 Mar 2021 00:34:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615854842; bh=DwO2abTrTPCBV+RWz5NIUo7YvPd35VK+3GPjS72Pk2c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GGGl+0vdncBll66DBxDxVWfhi8VZEKl2Hsx6U1GEcS/g+imWRE8u5iSCvACHvy8K3 +y4W/0cBVg8kM4IBqSvqtDYwTpwT9hMeFvWxRdod8HA0MwV93WoMWIDTeKlu5uc6jC IpyqIwqfQT67QKOIe+Kb4bHcKYnI2WU1Y5yUWDMXazEBd2ctHQiNnjoSB5vxEg4ucU 13ece8s49dFXct+CynmfjXr/xJwCc1lrDzIzAsXMLNn9jeCcNGFJIFIjYY0nS7Gwya a+4AoIPMv/GSTQ+4UwYMbaLqR5dF4ytYnIe4jVMbpIq/g1/SFC0FIBDXF1U/RJjwZ7 RN+U+EsMNNarg== Date: Tue, 16 Mar 2021 08:33:57 +0800 From: Peter Chen To: Sanket Parmar Cc: Pawel Laszczak , "a-govindraju@ti.com" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Rahul Kumar , "gregkh@linuxfoundation.org" , "kishon@ti.com" Subject: Re: [PATCH 2/2] usb: cdns3: Optimize DMA request buffer allocation Message-ID: <20210316003357.GC15335@b29397-desktop> References: <1615267180-9289-1-git-send-email-sparmar@cadence.com> <1615267180-9289-2-git-send-email-sparmar@cadence.com> <20210314051048.GA30122@b29397-desktop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21-03-15 15:51:04, Sanket Parmar wrote: > > > + > > > priv_req->flags |= REQUEST_UNALIGNED; > > > trace_cdns3_prepare_aligned_request(priv_req); > > > > > > @@ -3088,11 +3113,11 @@ static void cdns3_gadget_exit(struct cdns > > *cdns) > > > struct cdns3_aligned_buf *buf; > > > > > > buf = cdns3_next_align_buf(&priv_dev->aligned_buf_list); > > > - dma_free_coherent(priv_dev->sysdev, buf->size, > > > - buf->buf, > > > - buf->dma); > > > + dma_unmap_single(priv_dev->sysdev, buf->dma, buf->size, > > > + buf->dir); > > > > It only needs to DMA unmap after DMA has completed, this buf will not be > > used, otherwise, the kfree below will cause issue. > > This part is not clear. Aligned DMA buffer is allocated and mapped in cdns3_prepare_aligned_request_buf() > and put into aligned_buf_list. While unloading the gadget, We need to undo the same if aligned_buf_list is not > empty. Am I missing something here? My point is this unmap operation is useless since there is no user for aligned buf, and it calls kfree afterwards. You could also keep it as it has no harm. > > Also, I will post v2 of this patch which uses dma_*_noncoherent APIs suggested by Christoph Hellwig. -- Thanks, Peter Chen