Re: [PATCH] dma: swiotlb: Allocate the restricted DMA pool slot array with kvzalloc()

From: Marek Szyprowski

Date: Fri Nov 20 2026 - 09:18:48 EST


On 20.11.2026 14:11, yzddMr6 via B4 Relay wrote:
> From: yzddMr6 <yzddmr6@xxxxxxxxx>
>
> rmem_swiotlb_device_init() allocates one struct io_tlb_slot per 2 KiB
> slot of a restricted DMA pool with kzalloc(). The struct is 24 bytes on
> 64-bit, so with 4 KiB pages and the default MAX_PAGE_ORDER of 10 the
> array is larger than KMALLOC_MAX_SIZE (4 MiB) for any pool above about
> 341 MiB. For such a pool kzalloc() refuses the request with a
> WARN_ON_ONCE() in ___kmalloc_large_node(), the pool is not set up, and
> of_dma_set_restricted_buffer() warns that it failed to initialise the
> pool. The devices assigned to it then lose the restriction without
> their probe failing, and use the default DMA path.
>
> The slot array is only accessed by the CPU and does not need to be
> physically contiguous. Allocate it with kvzalloc_objs() and free it with
> kvfree(). The other pools are not affected: the slot array of the
> default pool comes from memblock, and the buffers of late and dynamic
> pools are limited to MAX_PAGE_ORDER, which keeps their slot arrays
> small.
>
> Pools of this size are needed when large buffers go through the pool
> for their whole lifetime: this was hit with an arm64 Gunyah protected
> VM whose virtio-gpu resources stay mapped in the pool, and a desktop at
> 3392x2400 needed more than 341 MiB.
>
> The problem was analysed and this change written with the help of an
> AI coding assistant.
>
> Fixes: 0b84e4f8b793 ("swiotlb: Add restricted DMA pool initialization")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: yzddMr6 <yzddmr6@xxxxxxxxx>

The change looks fine, but according to kernel rules, the patch must be
signed with a real developer name. 'yzddMr6' doesn't look like a real name.


> ...

Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland