From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E2D1449EB0 for ; Wed, 3 Jun 2026 13:13:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780492438; cv=none; b=ePPTAYn+oP3nfO/9m6jHg71Kgf+BVeCMdSh3tLr4wvK0vPBvDsAkBxcF5O+CZpI+iA/RO2/2wzK8S5prFzowL6ylHmKz2vojmUiDX6I2JldMLXGbjzEQ1iJn6yBHxMZy519KNSI/QCays2EbqwHmLXRq4x9EIzP1lOpFX/3ro3A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780492438; c=relaxed/simple; bh=OiVw/RnN2yJl+xs7mFGqAjHmQWT9ycPos04jBCLVqsQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iWKAnHw+ekt/NX+UubeufdMk92+4mLpmTaZLWn6ABnYrSEkh5cMp/eayM4Q35/lXyihu102tEo6NFfRkL1LWr6ZwuIffKuKabowUr9//1o82EDsNVUkCJtWkZJJ4gRW8RG5ehaGg3C7OnWcUvh3lv6ek6NptR4SwwB+VJ3puR0g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=F4uB47X6; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="F4uB47X6" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4891b4934ffso70785e9.0 for ; Wed, 03 Jun 2026 06:13:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780492435; x=1781097235; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=X2jL+y7AofTEiRmizQge3p1N6/KWPXHpy6eo/h7vnb4=; b=F4uB47X65QwBX6fEXrRhHjYGApgW4mD1ckEkblyieWl0sGSwbe8KLOL6yMgEs2jAyU 45bbsP/ry/JwnvhL4Q+uJjvlvLS5VCsxLlX8TLMYGP03lUPEDn2kT6DS2XC8chw3cVnj 7iD6WDOWMV/Jif0GC93gf7BxY+08o0MRhdY10SiVF8B8US8pjtJ6encSeixey/56uZMP 5mla18cNsYF0nslGCzFC+DKv7mNSy09/Mo/MjFfTuzDhgAfVry+z2IENth1oolUp4TWO ykx+FnOCsPvAQEiGzCTKog2DvvsYP7WPtLBtmh9Bnr6r+LCDmQJh/WsvvyHBgsOtlse4 d8Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780492435; x=1781097235; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X2jL+y7AofTEiRmizQge3p1N6/KWPXHpy6eo/h7vnb4=; b=fMAwWjDGdH/Py+MV7en0hvGbs1GJax5NOQEbsG0dlRTruX7NTzKJlVTxEsw2ND17Zm 0x3H/hP9U2yulcR0Kia3jkuSaGDPFikOadEGGGckzXyx6x0q5HEch+H74w27anFGX/FW +CudyBWqJFedyoKlWmCquphs60axEM4PhuysPdHFJwT18DZrjENdy8VInuwIyfnEPjwe jBKD9CKC+DWUs6XVvFRYOcuGKyDexwxshnKRMdW4QlJ951rlfktznGebRT8wcYrHKvpY yzq28A6P+ZaYQ7airQhLaG80tH/Jz6FzSJCipl0ow3MTpVsK4B2/EGbt5N+cuYe7Jk74 xA4w== X-Forwarded-Encrypted: i=1; AFNElJ8pwDJx4P90k5nN6pzpFwuN+9jt1DMrI2EHwlOh6lM1W05MlYuXXUWSYC775ml91sBwxQnZQS9/gEZ+92Y=@vger.kernel.org X-Gm-Message-State: AOJu0Yys8Q3ccLLqybot5Q34WTKyfxixM2t2seg+/dQn/4+PPRzODuJr wDFDQp89Ogieu7eDpW0IakRnKbIKQbrOVKcEJO7j5cYP+mZkFeifTTiRx4ZI0M2Jfw== X-Gm-Gg: Acq92OED+2ImMgKWJDMH57ZGQE3akLGAriTGVbnMzk2vGBYxhwfGjXvbZ7G9spTIFPM UxmElBJdeonwMLDwpD5hUdZWNdLhvbwGIgLd0+rz8GUUeVbODQ7FGj/pzeXlbLhwuoLiIxJs5+0 FMz3EivadFQ9jrBO+VaUx/TAd47RhULEufpFpyJKazJ2iwoeYmtifueqbX8m354gtebn8yuvqmb pepvodhsSwfCH6ksKCe2+CHKRuSgMy5sjxvFsigtTyGNulsE7cJlE8EgTQHUTSPCfEHzMTvb8kZ s1GNerzWpE3vWneoMA8sn1JhuCK3P/JQkkDV4KJYMJxrtY8aeZ1UsAKtNX980/y5GXGhJmM0xhd mtwvvk6RQY3m+MpE5oG4GU8E994BTqjzUHV5caNb249ftUCYyGoZY0orLzHHZ9qNOW6t7FpmNvm /3kH5Vi/f7mLMatajoudq1Q6qHAx5TZo2qC7FtfLGzrB3kQTDChg6TMXNH0nhSlz17VO7QAEMt X-Received: by 2002:a05:600d:2:b0:490:b2ae:44e1 with SMTP id 5b1f17b1804b1-490b8ed04bamr811475e9.5.1780492434644; Wed, 03 Jun 2026 06:13:54 -0700 (PDT) Received: from google.com (203.80.140.34.bc.googleusercontent.com. [34.140.80.203]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f2e4b18sm5706360f8f.10.2026.06.03.06.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 06:13:53 -0700 (PDT) Date: Wed, 3 Jun 2026 13:13:49 +0000 From: Mostafa Saleh To: Mike Rapoport 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: Hi Mike, On Wed, Jun 03, 2026 at 03:27:52PM +0300, Mike Rapoport wrote: > 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. My guess would be no, my understanding is that CCA guests have niche hardware. However, the check for limited_addressing is negated, we adjust the SWIOTLB to be smaller if no bouncing is needed. So, if this is a realm world, address space layout is irrelevant as we keep the original size which is larger. Otherwise, this alters the current behaviour. > > I'd also make this more explicit: > > if (max_pfn > PFN_DOWN(arm64_dma_phys_limit)) Sure, I can drop the bool. Thanks, Mostafa > > > /* > > * 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.