Re: [PATCH v1] riscv: make ZONE_DMA32 optional

From: Nick Kossifidis
Date: Mon Oct 07 2024 - 07:49:22 EST


On 10/7/24 09:22, Christoph Hellwig wrote:
On Mon, Oct 07, 2024 at 06:17:14AM +0000, Vladimir Kondratiev wrote:
Well, this doesn't get any more true by just irgnoring the previous
discussion and just reposting :(

Sorry, this wasn't the intention. Perhaps I messed with the message-id, I see my "patch v1" in one mail thread together with the previous discussion, but not in the other thread.

Anyway, I think making ZONE_DMA32 selection depend on NONPORTABLE answers the concern
that was raised

It doesn't at all.

For one not having ZONE_DMA32 is going to break a lot of things.
Drivers do expect 32-bit addressable memory. And because SOC designers
know this there usually is a way to provide it, e.g. by doing window
translations between cpu physical and bus physical address. Please go
back to your data sheet or talk to the designers.

And if there really is not way to provide this, the right way is just
to stop the runtime allocation that triggered you to do this if
ZONE_DMA32 is empty, not to add a non-portable option.


I agree with Christoph on this one, by the time dma_atomic_pool_init() gets called we already know the system's DRAM base for example and if we have 32bit addressable regions (or aliases / translation windows as Christoph mentioned) or not. We could use this info to skip ZONE_DMA32, or just use a command line argument like this RFC proposed:
https://lore.kernel.org/linux-arm-kernel/20230201040913.GA4959@xxxxxxxxxxxxxxxxxxxxxxxxxxx/T/

There is no reason to configure this at compile time, and completely remove support for ZONE_DMA32. Also NONPORTABLE doesn't address Alex's point on distro kernels, since distro kernels won't set NONPORTABLE.

BTW I tried reproducing this with a recent 6.10 kernel and couldn't, our system also has DRAM way above 32bits and this is also on a modified QEMU machine, here is the full log:
https://pastebin.com/9HLcphgY

You can use this script to reproduce our QEMU setup if interested:
https://github.com/CARV-ICS-FORTH/yarvt/tree/eupilot

Regards,
Nick