From: Catalin Marinas <catalin.marinas@arm.com>
To: "Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org>
Cc: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-coco@lists.linux.dev,
Robin Murphy <robin.murphy@arm.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>,
Steven Price <steven.price@arm.com>,
Suzuki K Poulose <Suzuki.Poulose@arm.com>,
Jiri Pirko <jiri@resnulli.us>, Jason Gunthorpe <jgg@ziepe.ca>,
Mostafa Saleh <smostafa@google.com>,
Petr Tesarik <ptesarik@suse.com>,
Alexey Kardashevskiy <aik@amd.com>,
Xu Yilun <yilun.xu@linux.intel.com>,
linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Christophe Leroy <chleroy@kernel.org>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
x86@kernel.org
Subject: Re: [RFC PATCH v2 1/2] dma: swiotlb: Centralize default pool initialization and sizing
Date: Fri, 14 Aug 2026 17:15:18 +0100 [thread overview]
Message-ID: <an8_FvcdI01XmVXs@arm.com> (raw)
In-Reply-To: <20260813102521.1367737-2-aneesh.kumar@kernel.org>
On Thu, Aug 13, 2026 at 03:55:20PM +0530, Aneesh Kumar K.V (Arm) wrote:
> The addressing_limited argument to swiotlb_init() no longer describes
> all the reasons why a default swiotlb pool may be needed. Confidential
> computing systems need a shared pool even without addressing limitations,
> while some systems need a smaller pool for bouncing unaligned kmalloc
> buffers.
>
> Replace the argument with SWIOTLB_INIT_ADDRESSING_LIMIT and
> SWIOTLB_INIT_CC_SHARED reason flags, and add swiotlb_should_init() to
> determine whether initialization is required for limited DMA addressing,
> confidential-computing shared DMA, unaligned kmalloc bouncing, or
> swiotlb=force.
>
> Have architectures report addressing-limit and confidential-computing
> requirements before swiotlb_init(). Mark CC pools shared before their
> memory attributes are updated, and keep both addressing-limited and
> CC-shared pools at their normal size instead of applying the reduced
> kmalloc-only sizing policy.
>
> Move the reduced kmalloc-bounce sizing policy from arm64 and RISC-V into
> the SWIOTLB core. This keeps architecture code responsible for reporting
> why a pool is needed while centralizing initialization and sizing
> decisions.
>
> Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
> ---
> arch/arm/mm/init.c | 6 +++-
> arch/arm64/mm/init.c | 18 ++++------
> arch/loongarch/kernel/setup.c | 2 +-
> arch/mips/cavium-octeon/dma-octeon.c | 2 +-
> arch/mips/loongson64/dma.c | 2 +-
> arch/mips/sibyte/common/dma.c | 2 +-
> arch/powerpc/kernel/dma-swiotlb.c | 4 ++-
> arch/powerpc/mm/mem.c | 15 +++++++-
> arch/powerpc/platforms/pseries/svm.c | 10 ------
> arch/powerpc/sysdev/fsl_pci.c | 1 +
> arch/riscv/mm/init.c | 18 +++-------
> arch/s390/mm/init.c | 2 +-
> arch/x86/include/asm/iommu.h | 2 ++
> arch/x86/kernel/amd_gart_64.c | 1 +
> arch/x86/kernel/pci-dma.c | 17 +++++----
> arch/x86/mm/mem_encrypt.c | 4 +++
> include/linux/swiotlb.h | 12 ++++---
> kernel/dma/swiotlb.c | 52 ++++++++++++++++++++++++----
> 18 files changed, 109 insertions(+), 61 deletions(-)
>
> diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
> index 0cc1bf04686d..aca97a4e5dcd 100644
> --- a/arch/arm/mm/init.c
> +++ b/arch/arm/mm/init.c
> @@ -223,7 +223,11 @@ static inline void poison_init_mem(void *s, size_t count)
> void __init arch_mm_preinit(void)
> {
> #ifdef CONFIG_ARM_LPAE
> - swiotlb_init(max_pfn > arm_dma_pfn_limit, SWIOTLB_VERBOSE);
> + unsigned int flags = SWIOTLB_VERBOSE;
> +
> + if (max_pfn > arm_dma_pfn_limit)
> + flags |= SWIOTLB_INIT_ADDRESSING_LIMIT;
> + swiotlb_init(flags);
> #endif
>
> #ifdef CONFIG_SA1111
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index e308a7cabd12..9f5b366d2086 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -338,19 +338,15 @@ void __init arch_setup_zero_pages(void)
> void __init arch_mm_preinit(void)
> {
> unsigned int flags = SWIOTLB_VERBOSE;
> + /* pKVM uses restricted-dma-pool */
> + bool cc_guest = is_realm_world();
>
> - 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));
> - }
> + if (cc_guest)
> + flags |= SWIOTLB_INIT_CC_SHARED;
> + else if (max_pfn > PFN_DOWN(arm64_dma_phys_limit))
> + flags |= SWIOTLB_INIT_ADDRESSING_LIMIT;
>
> - swiotlb_init(true, flags);
> + swiotlb_init(flags);
I like the idea of more flags than the boolean for address limit.
However, depending on when such patch would go in (presumably on top of
what's currently in -next), we may not need the SWIOTLB_INIT_CC_SHARED
at all here just to remove it in the second patch. I think we have all
the information available already.
Other than that, it looks fine to me. If you repost at -rc1, hopefully
Sashiko will manage to apply it.
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
next prev parent reply other threads:[~2026-08-14 16:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 10:25 [RFC PATCH v2 0/2] dma: swiotlb: Centralize default pool sizing Aneesh Kumar K.V (Arm)
2026-08-13 10:25 ` [RFC PATCH v2 1/2] dma: swiotlb: Centralize default pool initialization and sizing Aneesh Kumar K.V (Arm)
2026-08-14 16:15 ` Catalin Marinas [this message]
2026-08-13 10:25 ` [RFC PATCH v2 2/2] dma: swiotlb: Initialize and size shared default pools for memory encryption Aneesh Kumar K.V (Arm)
2026-08-13 16:50 ` Michael Kelley
2026-08-14 17:34 ` Catalin Marinas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=an8_FvcdI01XmVXs@arm.com \
--to=catalin.marinas@arm.com \
--cc=Suzuki.Poulose@arm.com \
--cc=agordeev@linux.ibm.com \
--cc=aik@amd.com \
--cc=aneesh.kumar@kernel.org \
--cc=borntraeger@linux.ibm.com \
--cc=chleroy@kernel.org \
--cc=gerald.schaefer@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=jiri@resnulli.us \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=m.szyprowski@samsung.com \
--cc=maddy@linux.ibm.com \
--cc=maz@kernel.org \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=ptesarik@suse.com \
--cc=robin.murphy@arm.com \
--cc=smostafa@google.com \
--cc=steven.price@arm.com \
--cc=svens@linux.ibm.com \
--cc=will@kernel.org \
--cc=x86@kernel.org \
--cc=yilun.xu@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox