From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1281D1FA0 for ; Tue, 15 Nov 2022 11:48:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CDE2C433C1; Tue, 15 Nov 2022 11:48:45 +0000 (UTC) Date: Tue, 15 Nov 2022 11:48:41 +0000 From: Catalin Marinas To: Isaac Manjarres Cc: Linus Torvalds , Arnd Bergmann , Christoph Hellwig , Greg Kroah-Hartman , Will Deacon , Marc Zyngier , Andrew Morton , Herbert Xu , Ard Biesheuvel , Saravana Kannan , Alasdair Kergon , Daniel Vetter , Joerg Roedel , Mark Brown , Mike Snitzer , "Rafael J. Wysocki" , Robin Murphy , linux-mm@kvack.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3 03/13] iommu/dma: Force bouncing of the size is not cacheline-aligned Message-ID: References: <20221106220143.2129263-1-catalin.marinas@arm.com> <20221106220143.2129263-4-catalin.marinas@arm.com> Precedence: bulk X-Mailing-List: iommu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Nov 14, 2022 at 03:23:54PM -0800, Isaac Manjarres wrote: > On Sun, Nov 06, 2022 at 10:01:33PM +0000, Catalin Marinas wrote: > > @@ -1202,7 +1203,10 @@ static int iommu_dma_map_sg(struct device *dev, struct scatterlist *sg, > > goto out; > > } > > > > - if (dev_use_swiotlb(dev)) > > + if (dma_sg_kmalloc_needs_bounce(dev, sg, nents, dir)) > > + sg_dma_mark_bounced(sg); > > + > > + if (dev_use_swiotlb(dev) || sg_is_dma_bounced(sg)) > > return iommu_dma_map_sg_swiotlb(dev, sg, nents, dir, attrs); > > Shouldn't you add a similar check in the iommu_dma_unmap_sg() path to > free any SWIOTLB memory that may have been allocated to bounce a scatter gather > list? Good point, not sure how I missed this. The sync'ing works fine as iommu_dma_sync_sg_for_cpu() has the check but the swiotlb buffer won't be freed. Thanks. -- Catalin