Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1657863pxy; Mon, 2 Aug 2021 07:14:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/GJRAJvv5N6GsVwrbAGNdfnx7snGNbjxn36AlwXRg339gwhRs73iNU5SQxSJS183GO622 X-Received: by 2002:a17:906:d20a:: with SMTP id w10mr16248067ejz.426.1627913642252; Mon, 02 Aug 2021 07:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627913642; cv=none; d=google.com; s=arc-20160816; b=yi3mn6usyfpADOGoufJMllNH08vFhMHnEN70rus2lpErgGA6pTOMYuV3wZkLnZcDD5 VI4wWENTn/zfB3ZqJYkl4EIyn0Cfeh/B7ViFI6tbnV8UELcVkr3DqSqDBMt13NqcuG4R 9K5cT8AiRFn+LDPWTjas4EGkLdBRLiggPm7GZbkgfrAx5hrxCoIzru6vMbPXObrgyfIe A+V9MvfB8NvFg9kj1r1x8A5dlJ8rYOuybmFSPZbAGlUhiBLOGfAq+aw7r66PQslY8rPi 5QJolzl6m/UErzLoR+LZuWSqXs+rwWfUG11pe9GcMOedf3jI+eGlXr0JUNStKW3Sp6ku C6gg== 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=CIideqHnxApKdBpu2mcHrnEAugCY9mPUMPsK62w+tU4=; b=GvZ8LD08br29/5dtZW/tJuXO1PreLPlyhTMUtbq2BVYa0tldBM4lQgPJ4RNdDbYYqs MvTqJ81K3CZO6iv28+yyad4Wg/hkjV3xjjbXu1nTpFme2lixscttt6utnp8DhU+3CrPL CufixLZ0zTK7r8A1p76e2IGleL96u3E0sBDM1oFm2RERiSobZLbnDEJA0n6ekCRSity2 Y5TemYDk6dkDY0HUMhyjFen104ytJzQgvy0DSEHedBywS9umsS70CqdDbpJkx5hbLt6s vlhLLV3buny5jQVLOROB3QZz4aR2TLhMqXtLUZ2AwYpN6e3pFcUkxE2GSR3pTAmArq5L BRmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VtSmunYU; 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 h25si11186310edq.396.2021.08.02.07.13.36; Mon, 02 Aug 2021 07:14:02 -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=VtSmunYU; 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 S237198AbhHBOEn (ORCPT + 99 others); Mon, 2 Aug 2021 10:04:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:41966 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235619AbhHBN5T (ORCPT ); Mon, 2 Aug 2021 09:57:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9D13161155; Mon, 2 Aug 2021 13:54:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627912490; bh=ffsZcqleS2Msj4hKWIBmJ4DPBk3NI1GngO6NeU0SeTU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VtSmunYUXbIIrXS3l/nVkmZXkowH6vo/7g7EKVHyGGAP/bs4NpsweEv1bYURFTDYP hPZkudv6Q+a1gVJLvSugGrJCXJGILZJXjQzxFBTiIxO+EwtizHV5Ph4vUtdeyue8i9 dkMBvitTmr3l0I5+q7p3nWeLK1b9uacCWjCeefWIm0rWNNa/2bRiT4DpgiNkpZkaKH uAJrliut8ve2C7rQIIMqyP5sSiyd+sOv9LtAQruboXcyd32Tn6PLVeBXRY3Ob2RSc8 n/n92HXPgxrkA9a9JptQmeZKFf4CSCofpomOhAAx+xF4xqHHhJZHAVliePCKrTO2Nf 6KwI1rx3CS2ag== Date: Mon, 2 Aug 2021 14:54:46 +0100 From: Will Deacon To: David Stevens Cc: Robin Murphy , Joerg Roedel , Lu Baolu , Tom Murphy , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/4] dma-iommu: pass SKIP_CPU_SYNC to swiotlb unmap Message-ID: <20210802135446.GE28547@willie-the-truck> References: <20210709033502.3545820-1-stevensd@google.com> <20210709033502.3545820-4-stevensd@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210709033502.3545820-4-stevensd@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(). Will