public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Aneesh Kumar K.V <aneesh.kumar@kernel.org>
To: Marek Szyprowski <m.szyprowski@samsung.com>,
	Robin Murphy <robin.murphy@arm.com>,
	iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Cc: Arnd Bergmann <arnd@kernel.org>,
	Linus Walleij <linusw@kernel.org>,
	Matthew Wilcox <willy@infradead.org>,
	Suzuki K Poulose <suzuki.poulose@arm.com>
Subject: Re: [PATCH] dma-direct: Skip cache prep for HighMem coherent allocations
Date: Mon, 19 Jan 2026 09:43:50 +0530	[thread overview]
Message-ID: <yq5ams2akznl.fsf@kernel.org> (raw)
In-Reply-To: <8a872e0c-f13e-4ff1-a939-bc6814b3ec3e@samsung.com>

Marek Szyprowski <m.szyprowski@samsung.com> writes:

> On 12.01.2026 13:22, Aneesh Kumar K.V wrote:
>> Marek Szyprowski <m.szyprowski@samsung.com> writes:
>>> On 09.01.2026 04:15, Aneesh Kumar K.V wrote:
>>>> Robin Murphy <robin.murphy@arm.com> writes:
>>>>> On 2026-01-08 12:41 pm, Marek Szyprowski wrote:
>>>>>> On 08.01.2026 11:50, Robin Murphy wrote:
>>>>>>> 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.
>>>>>> Right, so it is better to keep this unconditional
>>>>>> arch_dma_prep_coherent() call. I will drop it from dma-mapping-fixes then.
>>>>> Yeah, I think the confusing thing here is that there are architectures
>>>>> with CONFIG_HIGHMEM that don't actually check for and handle it in their
>>>>> arch_dma_prep_coherent() as they seemingly should, however I'm not sure
>>>>> off-hand whether they also support/use highmem CMA in the manner that
>>>>> could end up being an issue in practice (the lack of any reports of
>>>>> crashes or DMA corruption over the last however many years suggests not...)
>>>>>
>>>> Should we then remove the PageHighMem() check with DMA_ATTR_NO_KERNEL_MAPPING?
>>> Right, this has to be unified.
>> I had a related question, how do we handle cache flushes required for
>> architectures that don't implement CONFIG_ARCH_HAS_DMA_PREP_COHERENT (arch/arm)?
>
> ARM 32bit architecture provides arch_dma_alloc(), which handles cache 
> management internally.
>

But dma_direct_alloc does the below

	if ((attrs & DMA_ATTR_NO_KERNEL_MAPPING) &&
	    !force_dma_unencrypted(dev) && !is_swiotlb_for_alloc(dev))
		return dma_direct_alloc_no_mapping(dev, size, dma_handle, gfp);

	if (!dev_is_dma_coherent(dev)) {
		if (IS_ENABLED(CONFIG_ARCH_HAS_DMA_ALLOC) &&
		    !is_swiotlb_for_alloc(dev))
			return arch_dma_alloc(dev, size, dma_handle, gfp,
					      attrs);

IIUC, this implies we won't call arch_dma_alloc for
DMA_ATTR_NO_KERNEL_MAPPING ?

-aneesh

  reply	other threads:[~2026-01-19  4:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20260102155138eucas1p1563e460256561f6974079d3de733e895@eucas1p1.samsung.com>
2026-01-02 15:51 ` [PATCH] dma-direct: Skip cache prep for HighMem coherent allocations Aneesh Kumar K.V (Arm)
2026-01-08  8:38   ` Marek Szyprowski
2026-01-08  9:55     ` Arnd Bergmann
2026-01-08 10:18       ` Marek Szyprowski
2026-01-08 10:50   ` Robin Murphy
2026-01-08 12:41     ` Marek Szyprowski
2026-01-08 12:59       ` Robin Murphy
2026-01-09  3:15         ` Aneesh Kumar K.V
2026-01-12  9:08           ` Marek Szyprowski
2026-01-12 12:22             ` Aneesh Kumar K.V
2026-01-16 10:29               ` Marek Szyprowski
2026-01-19  4:13                 ` Aneesh Kumar K.V [this message]
2026-01-19  9:18                   ` Marek Szyprowski
2026-01-20  9:49                     ` Aneesh Kumar K.V

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=yq5ams2akznl.fsf@kernel.org \
    --to=aneesh.kumar@kernel.org \
    --cc=arnd@kernel.org \
    --cc=iommu@lists.linux.dev \
    --cc=linusw@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=robin.murphy@arm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=willy@infradead.org \
    /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