From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 E97CF3D3D18 for ; Wed, 3 Jun 2026 12:27:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780489679; cv=none; b=Azwm4/8XY4t89C9NnpFAh5z/bas5jVURVQjTMnMVGqRMn072HG+jCjNkjfPcZSXWj/0rtkiRt1pllFVgFd9Q8Z5SK7EADre/MVZVgEZGRuNMLLtRPySD3Xw52ve63JXfsjchAU54shJobFnj/6nVYRYQP1G5a0pYdHWsMMuDtUo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780489679; c=relaxed/simple; bh=Z8WEobvrnIWmdBO16HLYWWxFnuBSHrox4E/Za2ywMZ4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=P97IzQ7vmtFVOBMIddRVHpaVGPc+XhDAU1BqaDRQQ8I7yY4p7m2tOj9o0EFSKcvRUYUjqQTiejW0Wc8a++keaR44Q8Sg84OU1HHMA1Z1O4ub/HlBNlLF/yuH5HpsvCifxULUpLXi695Lg1uXIHOTVjvYAo4zeOu2umFUxKJxXoU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YniE05VO; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YniE05VO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF2791F00893; Wed, 3 Jun 2026 12:27:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780489678; bh=M7RbkRN3yZb2Hlv6o9dZUygfpvfrIaKIiCXYFA2pOLM=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=YniE05VOnZmg4pkXpu+yYNZSZ9ryY0GDjoSkbpJxvAE9HMQ1BBwOHejqcBxA+5NmU Ruyxs7iBaTJe8yp/1QOmY7IoG1mepkhGvHdLkgLnJDD9gv3p8UO2BJBtJVUCfVhVOf roAYR6dwN7YeppTly/aOCckZKRGHDne9gFnah+mDrgtIJ9kYx9JyxbTlHWvf2RMxBA u3l2sEgVOZA2Xy9mgIRfvEdiT8+vXnjnv4JwbrQn/GSlNELQKFW8K4gXKshgfYBgKc 28bU34XIYLXU6jZ5SStyJ/2n6FynFlCiieTBepNrcbmIH8WdtSV8nXPfKNj/n+nY7F GZHfk2l+GIAow== Date: Wed, 3 Jun 2026 15:27:52 +0300 From: Mike Rapoport To: Mostafa Saleh Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, catalin.marinas@arm.com, will@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> Hi, 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) { Can realm_world() coexist with limited_addressing? Then the size adjustment is still required. I'd also make this more explicit: if (max_pfn > PFN_DOWN(arm64_dma_phys_limit)) > /* > * If no bouncing needed for ZONE_DMA, reduce the swiotlb > * buffer for kmalloc() bouncing to 1MB per 1GB of RAM. > */ > unsigned long size = > DIV_ROUND_UP(memblock_phys_mem_size(), 1024); > + > swiotlb_adjust_size(min(swiotlb_size_or_default(), size)); > - swiotlb = true; > } > > - swiotlb_init(swiotlb, flags); > + swiotlb_init(true, flags); > > /* > * Check boundaries twice: Some fundamental inconsistencies can be > -- > 2.54.0.1032.g2f8565e1d1-goog > -- Sincerely yours, Mike.