From: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
To: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
Robin Murphy <robin.murphy@arm.com>,
Christoph Hellwig <hch@infradead.org>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
"Christophe Leroy (CS GROUP)" <chleroy@kernel.org>,
"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
Shrikanth Hegde <sshegde@linux.ibm.com>,
Chris Zankel <chris@zankel.net>,
Max Filippov <jcmvbkbc@gmail.com>
Subject: Re: [PATCH v2 3/7] MIPS: mm: handle highmem pages in arch_dma_prep_coherent()
Date: Mon, 16 Nov 2026 20:07:39 +0100 [thread overview]
Message-ID: <avtUe_ryNhYYGz4A@alpha.franken.de> (raw)
In-Reply-To: <20261110094830.2081847-4-m.szyprowski@samsung.com>
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@samsung.com>
> ---
> arch/mips/mm/dma-noncoherent.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
Acked-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
next prev parent reply other threads:[~2026-11-16 19:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20261110094846eucas1p140d5ebfe71b47d4e4b5e2162ba051c51@eucas1p1.samsung.com>
2026-11-10 9:48 ` [PATCH v2 0/7] dma-mapping: DMA_ATTR_NO_KERNEL_MAPPING related fixes Marek Szyprowski
2026-11-10 9:48 ` [PATCH v2 1/7] xtensa: write back dirty lines in arch_dma_prep_coherent() Marek Szyprowski
2026-11-10 12:40 ` Max Filippov
2026-11-10 9:48 ` [PATCH v2 2/7] xtensa: handle highmem pages " Marek Szyprowski
2026-11-10 12:42 ` Max Filippov
2026-11-10 9:48 ` [PATCH v2 3/7] MIPS: mm: " Marek Szyprowski
2026-11-16 19:07 ` Thomas Bogendoerfer [this message]
2026-11-10 9:48 ` [PATCH v2 4/7] powerpc/mm: " Marek Szyprowski
2026-11-10 9:48 ` [PATCH v2 5/7] dma-mapping: document that arch_dma_prep_coherent() must handle highmem Marek Szyprowski
2026-11-10 9:48 ` [PATCH v2 6/7] dma-direct: do not skip cache maintenance for highmem pages in no-mapping allocations Marek Szyprowski
2026-11-10 9:48 ` [PATCH v2 7/7] dma-direct: zero memory allocated with DMA_ATTR_NO_KERNEL_MAPPING Marek Szyprowski
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=avtUe_ryNhYYGz4A@alpha.franken.de \
--to=tsbogend@alpha.franken.de \
--cc=chleroy@kernel.org \
--cc=chris@zankel.net \
--cc=hch@infradead.org \
--cc=iommu@lists.linux.dev \
--cc=jcmvbkbc@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=m.szyprowski@samsung.com \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=ritesh.list@gmail.com \
--cc=robin.murphy@arm.com \
--cc=sshegde@linux.ibm.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