Re: [PATCH] dma-direct: Skip cache prep for HighMem coherent allocations

From: Marek Szyprowski
Date: Thu Jan 08 2026 - 04:03:27 EST


On 02.01.2026 16:51, Aneesh Kumar K.V (Arm) wrote:
> dma_direct_alloc() calls arch_dma_prep_coherent() to clean any dirty
> cache lines from the kernel linear alias before creating a coherent
> remapping.
>
> HighMem pages have no kernel alias mapping, so there are no alias cache
> lines to clean. Skip arch_dma_prep_coherent() for HighMem allocations.
>
> Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@xxxxxxxxxx>

Indeed this is an overhead to call prep for HighMem pages, but on the
other hand highmem support is being phased out according to
https://lwn.net/ml/all/20251219161559.556737-1-arnd@xxxxxxxxxx/ Does it
make sense to apply this assuming that it will be removed soon?

> ---
> kernel/dma/direct.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
> index 50c3fe2a1d55..ffa267020a1e 100644
> --- a/kernel/dma/direct.c
> +++ b/kernel/dma/direct.c
> @@ -272,7 +272,8 @@ void *dma_direct_alloc(struct device *dev, size_t size,
> prot = pgprot_decrypted(prot);
>
> /* remove any dirty cache lines on the kernel alias */
> - arch_dma_prep_coherent(page, size);
> + if (!PageHighMem(page))
> + arch_dma_prep_coherent(page, size);
>
> /* create a coherent mapping */
> ret = dma_common_contiguous_remap(page, size, prot,

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