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 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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B98BCC433FE for ; Tue, 15 Nov 2022 11:50:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tJ4XifTgVFHNThjmIw+WnTgcdKQ/InNg8JAPCnCw6rw=; b=IZSARgBzaWeawI Ia4bZS0g57H5K9kkmNbUNpbw/y8aCsVcdmizuKBiAqplGu6oWBBsqs8lMB0ahcf4MUrG03zeWaUqt aIOOLGxj2gAc48nYrk6APKsw8QB4o70gxYO8Kpy4Dy6I5xuthppbObV+bENa6IePpSKHnFeWwYA7j gwFUMMfSR9uXWvhhMyH5xoQb/WXd2/9MgNyHPVB4IBa8U6Oq+6RdviBJ45GKMwJQKFg2rkaDoNIFO ae72559TAzDJIae62C5mI9+1h9c822rNS7e2/ZrXbtDu9c3z3wexRdW9G5k23+jDuRdqqZ/S9aD/R We0bLQ8BLy7iUKV9+drA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ouuQy-00Aih9-O6; Tue, 15 Nov 2022 11:48:56 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ouuQu-00Aie8-NY for linux-arm-kernel@lists.infradead.org; Tue, 15 Nov 2022 11:48:54 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 515EB616DA; Tue, 15 Nov 2022 11:48:49 +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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221115_034852_868431_FBD53D7D X-CRM114-Status: GOOD ( 17.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel