Re: [PATCH 1/2] gpu: nova-core: declare unlimited DMA max segment size
From: Alexandre Courbot
Date: Sun Sep 06 2026 - 22:15:24 EST
On Tue Sep 1, 2026 at 8:32 AM JST, Matteo Kloiber wrote:
> The PCI default max_seg_size is 64 KiB. nova-core never raises it, so
> mapping the GSP firmware image (~60 MiB) as a scatter-gather table
> triggers a DMA-API debug warning when contiguous pages coalesce into
> segments that exceed the default:
>
> DMA-API: nova-core 0000:00:03.0: mapping sg segment longer than
> device claims to support [len=62914560] [max=65536]
>
> CONFIG_DMA_API_DEBUG=y is required to see this warning.
>
> Signed-off-by: Matteo Kloiber <kernel@xxxxxxxxxxx>
> Assisted-by: Claude:claude-opus-4-8
Note: new kernel policy [1] asks that the specific model is not named, so
this should just be `Assisted-by: LLM`.
(also should be placed before your `Signed-off-by`)
[1] https://docs.kernel.org/process/coding-assistants.html
> ---
> drivers/gpu/nova-core/gpu.rs | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs
> index fd1414004dd0..233ef2dc9688 100644
> --- a/drivers/gpu/nova-core/gpu.rs
> +++ b/drivers/gpu/nova-core/gpu.rs
> @@ -343,6 +343,13 @@ pub(crate) fn new<'a>(
> // still constructing it, so no concurrent DMA allocations can exist.
> unsafe { pdev.dma_set_mask_and_coherent(dma_mask)? };
>
> + // Nova re-decomposes SG segments into 4 KiB page-table entries, so it
> + // has no upper bound on segment length; declare that to the DMA layer.
> + //
> + // SAFETY: same invariant as above -- still constructing, no concurrent
> + // DMA mapping can exist.
> + unsafe { pdev.dma_set_max_seg_size(u32::MAX) };
Thanks, this patch looks correct and I would like to merge it early, but
one thing about the comment: it carries way more context than needed and
reads heavily, as is often the case when AI-generated. For instance,
"declare that to the DMA layer" is obvious from the method we are
calling. Make sure to give a human pass to such comments as they can
make the code tedious when they accumulate.
Conversely, `as above` is risky because the above in question might
change and we then lose the reference, so here it's actually better to
state the invariant in a self-contained way. Copy-pasting is ok. For
instance:
// Nova walks SG segments to build page tables, so their length is
// irrelevant to the device.
//
// SAFETY: `Gpu` owns all DMA allocations for this device, and we are
// still constructing it, so no concurrent DMA allocations can exist.
Since this seems to be your first patch, this is a good opportunity to
practice sending a v2. :)