From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95E87C4338F for ; Fri, 6 Aug 2021 11:38:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F1E36108D for ; Fri, 6 Aug 2021 11:38:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245546AbhHFLiY (ORCPT ); Fri, 6 Aug 2021 07:38:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:40324 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240755AbhHFLiW (ORCPT ); Fri, 6 Aug 2021 07:38:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1B7BA60FE7; Fri, 6 Aug 2021 11:38:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628249887; bh=gHwP7vxb5aRgHKwYrdHY0/RGdX7tYBYUp42oKa4+bYI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WoTDQAO0+/zi9/aizS09IIFliQeV+6tU9IobFZ+lG40KODR6cRZS1jk73SC9Yjrqi FDUIn189PKaOrWsjrPW3finDOIGYSq/U/tj6Kj5OXdXIKjCn8wexT1JWj+dln1xglZ AoDCUvUSM/hwSLtgJ0KbZKdtT8RPJfpaNE7KTbVLIQvPscJSDNiqRgcUe/kH641bKU qzwjXIy3Dfn4c+J99FH54/8OX4RUP3IUF3dfVEYVs6idNkSYySvJ3h3H/blmyK8mVo mym2OuwwaH2Glq8paHP3oDWi28eQCfrQJaxxOfBXnjgASlxVImC8X7C+5/MCyFFpkg q/KqDKZIXErAQ== Date: Fri, 6 Aug 2021 12:38:02 +0100 From: Will Deacon To: David Stevens Cc: Robin Murphy , Joerg Roedel , Lu Baolu , Tom Murphy , iommu@lists.linux-foundation.org, open list Subject: Re: [PATCH v2 3/4] dma-iommu: pass SKIP_CPU_SYNC to swiotlb unmap Message-ID: <20210806113802.GB2531@willie-the-truck> References: <20210709033502.3545820-1-stevensd@google.com> <20210709033502.3545820-4-stevensd@google.com> <20210802135446.GE28547@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 05, 2021 at 02:26:10PM +0900, David Stevens wrote: > On Mon, Aug 2, 2021 at 10:54 PM Will Deacon wrote: > > > > On Fri, Jul 09, 2021 at 12:35:01PM +0900, David Stevens wrote: > > > From: David Stevens > > > > > > If SKIP_CPU_SYNC isn't already set, then iommu_dma_unmap_(page|sg) has > > > already called iommu_dma_sync_(single|sg)_for_cpu, so there is no need > > > to copy from the bounce buffer again. > > > > > > Signed-off-by: David Stevens > > > --- > > > drivers/iommu/dma-iommu.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c > > > index e79e274d2dc5..0a9a9a343e64 100644 > > > --- a/drivers/iommu/dma-iommu.c > > > +++ b/drivers/iommu/dma-iommu.c > > > @@ -505,7 +505,8 @@ static void __iommu_dma_unmap_swiotlb(struct device *dev, dma_addr_t dma_addr, > > > __iommu_dma_unmap(dev, dma_addr, size); > > > > > > if (unlikely(is_swiotlb_buffer(phys))) > > > - swiotlb_tbl_unmap_single(dev, phys, size, dir, attrs); > > > + swiotlb_tbl_unmap_single(dev, phys, size, dir, > > > + attrs | DMA_ATTR_SKIP_CPU_SYNC); > > > } > > > > I think it would be cleaner to drop DMA_ATTR_SKIP_CPU_SYNC in the callers > > once they've called iommu_dma_sync_*_for_cpu(). > > Dropping that flag in iommu_dma_unmap_* would result in always copying > from the swiotlb here, which is the opposite direction of what this > patch is trying to do. Sorry, probably poor wording on my part. What I mean is, rather than add DMA_ATTR_SKIP_CPU_SYNC here, how about having the callers include it in attrs instead, since they're the ones doing the initial sync? Will From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53F04C432BE for ; Fri, 6 Aug 2021 11:38:12 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F15336113B for ; Fri, 6 Aug 2021 11:38:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F15336113B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id BAA9983B98; Fri, 6 Aug 2021 11:38:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id e25a84s4Zm27; Fri, 6 Aug 2021 11:38:11 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 9755783B64; Fri, 6 Aug 2021 11:38:10 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 61F6EC0010; Fri, 6 Aug 2021 11:38:10 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4C0BAC000E for ; Fri, 6 Aug 2021 11:38:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 24464400CA for ; Fri, 6 Aug 2021 11:38:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9Y-uvMUhHvmw for ; Fri, 6 Aug 2021 11:38:07 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp2.osuosl.org (Postfix) with ESMTPS id E468A402F6 for ; Fri, 6 Aug 2021 11:38:07 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 1B7BA60FE7; Fri, 6 Aug 2021 11:38:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628249887; bh=gHwP7vxb5aRgHKwYrdHY0/RGdX7tYBYUp42oKa4+bYI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WoTDQAO0+/zi9/aizS09IIFliQeV+6tU9IobFZ+lG40KODR6cRZS1jk73SC9Yjrqi FDUIn189PKaOrWsjrPW3finDOIGYSq/U/tj6Kj5OXdXIKjCn8wexT1JWj+dln1xglZ AoDCUvUSM/hwSLtgJ0KbZKdtT8RPJfpaNE7KTbVLIQvPscJSDNiqRgcUe/kH641bKU qzwjXIy3Dfn4c+J99FH54/8OX4RUP3IUF3dfVEYVs6idNkSYySvJ3h3H/blmyK8mVo mym2OuwwaH2Glq8paHP3oDWi28eQCfrQJaxxOfBXnjgASlxVImC8X7C+5/MCyFFpkg q/KqDKZIXErAQ== Date: Fri, 6 Aug 2021 12:38:02 +0100 From: Will Deacon To: David Stevens Subject: Re: [PATCH v2 3/4] dma-iommu: pass SKIP_CPU_SYNC to swiotlb unmap Message-ID: <20210806113802.GB2531@willie-the-truck> References: <20210709033502.3545820-1-stevensd@google.com> <20210709033502.3545820-4-stevensd@google.com> <20210802135446.GE28547@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Cc: open list , Tom Murphy , iommu@lists.linux-foundation.org, Robin Murphy X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On Thu, Aug 05, 2021 at 02:26:10PM +0900, David Stevens wrote: > On Mon, Aug 2, 2021 at 10:54 PM Will Deacon wrote: > > > > On Fri, Jul 09, 2021 at 12:35:01PM +0900, David Stevens wrote: > > > From: David Stevens > > > > > > If SKIP_CPU_SYNC isn't already set, then iommu_dma_unmap_(page|sg) has > > > already called iommu_dma_sync_(single|sg)_for_cpu, so there is no need > > > to copy from the bounce buffer again. > > > > > > Signed-off-by: David Stevens > > > --- > > > drivers/iommu/dma-iommu.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c > > > index e79e274d2dc5..0a9a9a343e64 100644 > > > --- a/drivers/iommu/dma-iommu.c > > > +++ b/drivers/iommu/dma-iommu.c > > > @@ -505,7 +505,8 @@ static void __iommu_dma_unmap_swiotlb(struct device *dev, dma_addr_t dma_addr, > > > __iommu_dma_unmap(dev, dma_addr, size); > > > > > > if (unlikely(is_swiotlb_buffer(phys))) > > > - swiotlb_tbl_unmap_single(dev, phys, size, dir, attrs); > > > + swiotlb_tbl_unmap_single(dev, phys, size, dir, > > > + attrs | DMA_ATTR_SKIP_CPU_SYNC); > > > } > > > > I think it would be cleaner to drop DMA_ATTR_SKIP_CPU_SYNC in the callers > > once they've called iommu_dma_sync_*_for_cpu(). > > Dropping that flag in iommu_dma_unmap_* would result in always copying > from the swiotlb here, which is the opposite direction of what this > patch is trying to do. Sorry, probably poor wording on my part. What I mean is, rather than add DMA_ATTR_SKIP_CPU_SYNC here, how about having the callers include it in attrs instead, since they're the ones doing the initial sync? Will _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu