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 5A612C77B7A for ; Fri, 19 May 2023 15:47:08 +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=VMvbCxkFsuOYDzNde1CdDi3iHEBxwCi15lkuemeV8fU=; b=efjL1wx4zEXtrQ n7h8kp5YAsB3UfYC2GTwnEvve90H4EcaKVbux6J+OTbJ01MYQb+izX4O+0OlTODAGBuGW0nZPhleu 9es7X6xIb6VIlQefUgZp0LpjaGUzcXM/tWFsVeOINxtDnyy/5UwFMGuHH7MrahQ938MSA4G8K3n+S 6m9JTYTkp+sCsuCS2VGNi7IJS/g1GcIvhuLMnfvsvZC8kQypXvrq34gVkIqKeoTjKmkOVscRtw/Kr svXn3ONXk2eclXNPULazSVDJJfQRNUpNjrTQVlMCTlpX35LPE5isqCQVhVGPjGmsO5eC8+PTRrsbG 7KyB9LpWOHhqFWBxX2qA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q02JZ-00GdSA-2O; Fri, 19 May 2023 15:46:45 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q02JW-00GdRd-2C for linux-arm-kernel@lists.infradead.org; Fri, 19 May 2023 15:46:43 +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 F2519643CF; Fri, 19 May 2023 15:46:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 247B1C433D2; Fri, 19 May 2023 15:46:37 +0000 (UTC) Date: Fri, 19 May 2023 16:46:35 +0100 From: Catalin Marinas To: Robin Murphy Cc: Linus Torvalds , Arnd Bergmann , Christoph Hellwig , Greg Kroah-Hartman , Will Deacon , Marc Zyngier , Andrew Morton , Herbert Xu , Ard Biesheuvel , Isaac Manjarres , Saravana Kannan , Alasdair Kergon , Daniel Vetter , Joerg Roedel , Mark Brown , Mike Snitzer , "Rafael J. Wysocki" , linux-mm@kvack.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v4 13/15] iommu/dma: Force bouncing if the size is not cacheline-aligned Message-ID: References: <20230518173403.1150549-1-catalin.marinas@arm.com> <20230518173403.1150549-14-catalin.marinas@arm.com> <9dc3e036-75cd-debf-7093-177ef6c7a3ae@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-20230519_084642_761935_3EE94FB5 X-CRM114-Status: GOOD ( 21.37 ) 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 Fri, May 19, 2023 at 03:02:24PM +0100, Catalin Marinas wrote: > On Fri, May 19, 2023 at 01:29:38PM +0100, Robin Murphy wrote: > > On 2023-05-18 18:34, Catalin Marinas wrote: > > > + sg_dma_mark_bounced(sg); > > > > I'd prefer to have iommu_dma_map_sg_swiotlb() mark the segments, since > > that's in charge of the actual bouncing. Then we can fold the alignment > > check into dev_use_swiotlb() (with the dev_is_untrusted() condition taking > > priority), and sync/unmap can simply rely on sg_is_dma_bounced() alone. > > With this patch we only set the SG_DMA_BOUNCED on the first element of > the sglist. Do you want to set this flag only on individual elements > being bounced? It makes some sense in principle but the > iommu_dma_unmap_sg() path would need to scan the list again to decide > whether to go the swiotlb path. > > If we keep the SG_DMA_BOUNCED flag only on the first element, I can > change it to your suggestion, assuming I understood it. Can one call: iommu_dma_map_sg(sg, nents); ... iommu_dma_unmap_sg(sg + n, nents - n); (i.e. unmap it in multiple steps) If yes, setting SG_DMA_BOUNCED on the first element only won't work. I don't find this an unlikely scenario, so we maybe we do have to walk the list again in unmap to search for the flag. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel