Re: [PATCH v2 3/7] MIPS: mm: handle highmem pages in arch_dma_prep_coherent()

From: Thomas Bogendoerfer

Date: Mon Nov 16 2026 - 14:10:28 EST


On Tue, Nov 10, 2026 at 10:48:23AM +0100, Marek Szyprowski wrote:
> arch_dma_prep_coherent() performs the cache maintenance on the address
> returned by page_address(). On 32-bit MIPS with CONFIG_HIGHMEM the kernel
> uses HASHED_PAGE_VIRTUAL, so page_address() returns NULL for a highmem
> page that is not kmapped, and dma_cache_wback_inv() then operates on
> the virtual range starting at 0 instead of the buffer, leaving any dirty
> cache lines of the buffer in place.
>
> Highmem pages do reach this function: dma_alloc_contiguous() can return
> a highmem CMA page, which dma_direct_alloc() handles by forcing the remap
> path and calling arch_dma_prep_coherent() on that page before creating
> the uncached mapping. Since commit f5ff79fddf0e ("dma-mapping: remove
> CONFIG_DMA_REMAP") this path is available on all MMU architectures,
> including MIPS, which previously rejected highmem CMA pages.
>
> Fix this by reusing dma_sync_phys(), which already handles highmem pages
> by mapping them one page at a time with kmap_atomic(). For lowmem pages
> it does a single dma_cache_wback_inv() over the whole range, so the
> behaviour is unchanged there.
>
> Fixes: f5ff79fddf0e ("dma-mapping: remove CONFIG_DMA_REMAP")
> Signed-off-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
> ---
> arch/mips/mm/dma-noncoherent.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)

Acked-by: Thomas Bogendoerfer <tsbogend@xxxxxxxxxxxxxxxx>

--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]