From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74D333DA5B8 for ; Thu, 9 Jul 2026 09:08:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783588105; cv=none; b=J6bTg4yjvpMqXNTLAtv4f3ItiFV7Yk+VHNjA+N1709g3CfpbD5eOV9sxjVQJiwhzehVShEA+P0nHh1xXY8qYYFKfAi5Jd00v/cuI7qc7mnzHZjp1myev+/rFtusu2BWqsdjSOGLNbfeRQKCH754C/JTrbORYbGlOXpWBAZAzXdE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783588105; c=relaxed/simple; bh=d5BvzN3MfufyvQVrVAt/h8a8nHtc61wj1/+yZBdDRrM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VTb8xb46iWBJvdyccpqe9unT4P75/+5jNnlHEcC2T3LTzCPQ36HzZoBJgI6tIwkEA/ry89tWKUq/36X0xMehLO27f0O3QVA7WVepq5Cak/XsVk5gjscExM7un7tOqtpJreFI9dRnGpXhAp21Lj8rR+2/2GbNyuWfon+jSPlX4g4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=XSlK0Aow; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="XSlK0Aow" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4B6253569; Thu, 9 Jul 2026 02:08:18 -0700 (PDT) Received: from arm.com (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 873013F66F; Thu, 9 Jul 2026 02:08:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1783588102; bh=d5BvzN3MfufyvQVrVAt/h8a8nHtc61wj1/+yZBdDRrM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XSlK0AowdDo+6xAFhpXJK7l0Vv+3NGFmBgg8pxsKDst4190Fxt1eIe1SIJK+xORgq LY/ghwUgINI1+y2TN75ycigsQOzr6y+yxSyaag1CAM9Ci3eVFes9Z1/Y1/c3URt+ZA Tlj8vHkQ4NP/rVfmLXjtM4g6prlftGxiawNzjnsI= Date: Thu, 9 Jul 2026 10:08:19 +0100 From: Catalin Marinas To: Mostafa Saleh Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, will@kernel.org, rppt@kernel.org, maz@kernel.org, aneesh.kumar@kernel.org Subject: Re: [PATCH 1/3] arm64/mm: Simplify SWIOTLB setup in arch_mm_preinit() Message-ID: References: <20260603110522.3331819-1-smostafa@google.com> <20260603110522.3331819-2-smostafa@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260603110522.3331819-2-smostafa@google.com> On Wed, Jun 03, 2026 at 11:05:20AM +0000, Mostafa Saleh wrote: > At the moment, arch_mm_preinit() checks if the system has limited > addressing or is running under CCA to enable SWIOTLB, only after to > be forced to true anyway if it was false due to > CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC being unconditionally true for > arm64. > > Simplify this logic, by making it clear that SWIOTLB is always used > but its size depends on the address layout of the system. > > Signed-off-by: Mostafa Saleh > --- > arch/arm64/mm/init.c | 11 ++++------- > 1 file changed, 4 insertions(+), 7 deletions(-) > > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > index 97987f850a33..fcc9c05a8fe6 100644 > --- a/arch/arm64/mm/init.c > +++ b/arch/arm64/mm/init.c > @@ -336,25 +336,22 @@ void __init arch_setup_zero_pages(void) > void __init arch_mm_preinit(void) > { > unsigned int flags = SWIOTLB_VERBOSE; > - bool swiotlb = max_pfn > PFN_DOWN(arm64_dma_phys_limit); > + bool limited_addressing = max_pfn > PFN_DOWN(arm64_dma_phys_limit); > > if (is_realm_world()) { > - swiotlb = true; > flags |= SWIOTLB_FORCE; > - } > - > - if (IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC) && !swiotlb) { > + } else if (!limited_addressing) { I'm fine with implementing Mike's comment on doing the check inline. I recall some people still comment out the dma kmalloc bounce option: https://github.com/raspberrypi/linux/commit/a07564753639fe5ffb3f59d7364f14e6e68e3e9e (there was no way I could convince them it's worse memory wastage without the option) So happy to make it slightly harder for them ;). Reviewed-by: Catalin Marinas