[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9cbe49ae-6612-491d-8ac6-6a99a08d73e2@arm.com>
Date: Thu, 8 Jan 2026 10:50:23 +0000
From: Robin Murphy <robin.murphy@....com>
To: "Aneesh Kumar K.V (Arm)" <aneesh.kumar@...nel.org>,
iommu@...ts.linux.dev, linux-kernel@...r.kernel.org
Cc: Marek Szyprowski <m.szyprowski@...sung.com>,
Arnd Bergmann <arnd@...nel.org>, Linus Walleij <linusw@...nel.org>,
Matthew Wilcox <willy@...radead.org>,
Suzuki K Poulose <suzuki.poulose@....com>
Subject: Re: [PATCH] dma-direct: Skip cache prep for HighMem coherent
allocations
On 2026-01-02 3:51 pm, 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.
This is assuming that caches are always cleaned when unmapping highmem,
and no still-mapped highmem pages are dirty - how is that guaranteed?
The fact that they're not in the linear map doesn't mean they don't
necessarily have kernel aliases in either vmalloc pagetables or caches.
Thanks,
Robin.
> Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@...nel.org>
> ---
> 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,
Powered by blists - more mailing lists