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 076303E92BA for ; Thu, 4 Jun 2026 08:55:22 +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=1780563324; cv=none; b=rsg6YvNC5YwSRoZMaaSKIKjyie9QBcThcH5vcaSPLqZYw3E5LFN61wQFy2xRr2QAX9Bn3ljOisIqiQoY3OBlIIwzbn+O91mrPaANWUsHVFtB6BIhoQNujtw1lkuuqj+RMcyaym9mmY74jb2vJcSJvi0Nv0aIZD3sLj3hF+N7iHw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780563324; c=relaxed/simple; bh=8Hmnf/lQmwpbocw8DYLdDeVHKyahWf8wkITK9ibHemM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=obeVxWHq8FDIQa3auQqkLaVdRp3bbf70D4bOohHkxKZHlca4fsLthYpJUwEFttjGN9uZRMfubEFUvoHpKXiiv4vFx4U3ftx9bG44mndAqWn2gErJWzCZDPjsRN1fyHl2iJZVsxCstvduiCOgnNI4XN4iox5BGmkmxI+3LNWbYYU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aPN94Myh; 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="aPN94Myh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 159E31F00893; Thu, 4 Jun 2026 08:55:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780563322; bh=5KsNES3quG6UyKXy/WSJmh5Tfdqu82vp795Q4GewzKg=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=aPN94Myhtu9FE7edJToCisv6hjR9UpZEQ4OZFASRPQntvLR4IuZbZYE62R3GHgNNp WBGJg3LT4wVHbyCDW2WIPWyee1y328MS/2elNJqA/7w3Ewcb+ZHapwHyJFslHja/lO hhliXBqG2iUC2tGCpLA2WT1Aka/BfyKUrTryM2Vpznrv2HO3lvWsBP71mMARHI16iA vG247/vz1mAZSGRJfWcaBUHW/40VUQkcVs69dCfoe8x4SjAtcT9meswFw3sDdmWGOR DaGlwaPpsOOn/U1gWMzbqMEaOK11/23xjG7OW8cxN1E68CBZOgk+wtyFUy5mYM1+wW tdWiBrC1+ZzQw== X-Mailer: emacs 30.2 (via feedmail 11-beta-1 I) From: Aneesh Kumar K.V To: Mostafa Saleh , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, catalin.marinas@arm.com, will@kernel.org, rppt@kernel.org, maz@kernel.org, Mostafa Saleh Subject: Re: [PATCH 1/3] arm64/mm: Simplify SWIOTLB setup in arch_mm_preinit() In-Reply-To: <20260603110522.3331819-2-smostafa@google.com> References: <20260603110522.3331819-1-smostafa@google.com> <20260603110522.3331819-2-smostafa@google.com> Date: Thu, 04 Jun 2026 14:25:16 +0530 Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Mostafa Saleh writes: > 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. > Reviewed-by: Aneesh Kumar K.V (Arm) > 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) { > /* > * 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