Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp673427pxt; Fri, 6 Aug 2021 10:50:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7ayRI4y+cxeNHtqp1Hx9ln+TImmxbSyfFUWLzMxU8m6lIWKG84xQv6S75Bqo1N7CPFrYJ X-Received: by 2002:a5d:96cb:: with SMTP id r11mr141884iol.53.1628272240908; Fri, 06 Aug 2021 10:50:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628272240; cv=none; d=google.com; s=arc-20160816; b=lVQJoMarWmVL9+TqeJu/gZ00ca6FKYY81nk0Eghcwf7FiN744AOyQvdV2J9Y6lZy2X rO95NVW6owe+XlsgCHsquZFdbYyatOD5OA48YKj4GGh46Aoqmi5x2/q/dRc7W2u5akwt gUtlXlagG4jBzwHSDjdIg1tjGtBfpbzISp6Xv1EE6AoAiJg13pcm+/5p/Gbl7CdqF3Eq kHOTVeTdYB7FqgtF5lj1O5CABlwxdZ3skXbSXVKh3mVv18PeXWpByA3FDaKqYOEeT3Py UHH55dGWinGDcZuDYcPiIOJJrPhcBs07Af3dC5W2WfDMWW1UZX6+sAj4X+fvfwnDtcZD C00w== 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=vg1HICBzv28tc0ppZr/en1/NXFw4rvyAkQ4/Ew+I85k=; b=b1xwkMg4J+3wtnx6YFvmScr2KjQ5zCP8F4myvtfxpYmBWm5RmkmJyhmpYNqDucAsSw 5EOTIDAnRYcEoaOcC9NbyPseFzTA2wynMlx5k9SOt/3bbTIbRgRy2/CvfzwFk5Amot6n ETgfN2dFjvpesFw552VP6czQI9ZM0zKCx0fW5spMW2iwn/xUYjcc108LoIwYO5AYe34D nRvpQhNf3Rq2mt627tMZV+RJiAxWQVAqALYl7Hb48Ll7DfMGZU/U/BbL9UpkXKgIwHfi kIA8NWhXmpmCtN41/Dx2+ZJC0F87LUZklDO1fReTIWt60BPQZyCT74z7scCqDAGSlR6V uZ8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WoTDQAO0; 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 f14si8667415jar.87.2021.08.06.10.50.28; Fri, 06 Aug 2021 10:50:40 -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=WoTDQAO0; 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 S242703AbhHFLiX (ORCPT + 99 others); Fri, 6 Aug 2021 07:38:23 -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