From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) (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 CE8CBD51D for ; Mon, 7 Nov 2022 14:38:55 +0000 (UTC) Received: by verein.lst.de (Postfix, from userid 2407) id 0FC9867373; Mon, 7 Nov 2022 15:38:50 +0100 (CET) Date: Mon, 7 Nov 2022 15:38:49 +0100 From: Christoph Hellwig To: Robin Murphy Cc: Catalin Marinas , 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 v3 13/13] dma: arm64: Add CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC and enable it for arm64 Message-ID: <20221107143849.GA27946@lst.de> References: <20221106220143.2129263-1-catalin.marinas@arm.com> <20221106220143.2129263-14-catalin.marinas@arm.com> <6e846f75-b330-9523-4356-41d5f9e48f12@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: <6e846f75-b330-9523-4356-41d5f9e48f12@arm.com> User-Agent: Mutt/1.5.17 (2007-11-01) On Mon, Nov 07, 2022 at 01:03:31PM +0000, Robin Murphy wrote: > On 2022-11-06 22:01, Catalin Marinas wrote: >> With all the infrastructure in place for bouncing small kmalloc() >> buffers, add the corresponding Kconfig entry and select it for arm64. > > AFAICS we're missing the crucial part to ensure that SWIOTLB is available > even when max_pfn <= arm64_dma_phys_limit, which is very likely to be true > on low-memory systems that care most about kmalloc wastage. The only way to > override that currently is with "swiotlb=force", but bouncing *everything* > is not desirable either. FYI, one of the reasons for the swiotlb_init refactor that passes flags and a boolean a while ago is that we can trivially just either pass another flag or check a condition in swiotlb_init to allocate the buffer. There's actually another case for which we need the unconditional allocation, and that is the bouncing for untrusted external devices with dma-iommu. 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 E7D24C4332F for ; Mon, 7 Nov 2022 14:55:38 +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=6T70iYNn21ioKri5ysDT5jDavhQDN6ttH2xtrvunRqk=; b=xo2iLndFmZNNFF HaQadreIy9ZkgiNUmmlAlKYgXTQYnWso4K/umitL9eooE6yAf1mfFTU+xQjsg/plYpQ9uIAVEDfT4 TFdwBS/tImaKy0YllXH3QI3Gti2lFG5QEJhGYWF1P/NjESpVUXrOknEQ1dGu/uocLtuyQ8E8EhwO4 uu9tlbOqfF9oh7w+aCtUCoLWHmZbjPuxLGXFWNGigTpW/ENoaTdqzKnfdserX+lc3aivfOcmc88Qd oKQNHdMTSr0SEXimLyJeYK0pmqO8ASvIArHQ5fZ6sLJHrEibsoi+zR9dAXm5383BGaT4Sg2f27N2B kulLGV02B8aCg0X1SF0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1os3W4-00FPe0-G3; Mon, 07 Nov 2022 14:54:24 +0000 Received: from verein.lst.de ([213.95.11.211]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1os3H8-00FI1b-Iu for linux-arm-kernel@lists.infradead.org; Mon, 07 Nov 2022 14:39:00 +0000 Received: by verein.lst.de (Postfix, from userid 2407) id 0FC9867373; Mon, 7 Nov 2022 15:38:50 +0100 (CET) Date: Mon, 7 Nov 2022 15:38:49 +0100 From: Christoph Hellwig To: Robin Murphy Cc: Catalin Marinas , 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 v3 13/13] dma: arm64: Add CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC and enable it for arm64 Message-ID: <20221107143849.GA27946@lst.de> References: <20221106220143.2129263-1-catalin.marinas@arm.com> <20221106220143.2129263-14-catalin.marinas@arm.com> <6e846f75-b330-9523-4356-41d5f9e48f12@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <6e846f75-b330-9523-4356-41d5f9e48f12@arm.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221107_063858_801361_111F6103 X-CRM114-Status: GOOD ( 16.62 ) 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 07, 2022 at 01:03:31PM +0000, Robin Murphy wrote: > On 2022-11-06 22:01, Catalin Marinas wrote: >> With all the infrastructure in place for bouncing small kmalloc() >> buffers, add the corresponding Kconfig entry and select it for arm64. > > AFAICS we're missing the crucial part to ensure that SWIOTLB is available > even when max_pfn <= arm64_dma_phys_limit, which is very likely to be true > on low-memory systems that care most about kmalloc wastage. The only way to > override that currently is with "swiotlb=force", but bouncing *everything* > is not desirable either. FYI, one of the reasons for the swiotlb_init refactor that passes flags and a boolean a while ago is that we can trivially just either pass another flag or check a condition in swiotlb_init to allocate the buffer. There's actually another case for which we need the unconditional allocation, and that is the bouncing for untrusted external devices with dma-iommu. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel