Re: [PATCH v2 01/10] gpu: nova-core: Set correct DMA mask
From: Boqun Feng
Date: Mon Sep 22 2025 - 11:25:05 EST
On Mon, Sep 22, 2025 at 09:30:17PM +1000, Alistair Popple wrote:
> Set the correct DMA mask. Without this DMA will fail on some setups.
>
> Signed-off-by: Alistair Popple <apopple@xxxxxxxxxx>
>
> ---
>
> Changes for v2:
>
> - Update DMA mask to correct value for Ampere/Turing (47 bits)
> ---
> drivers/gpu/nova-core/driver.rs | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/nova-core/driver.rs b/drivers/gpu/nova-core/driver.rs
> index 1380b47617f7..ccc97340206e 100644
> --- a/drivers/gpu/nova-core/driver.rs
> +++ b/drivers/gpu/nova-core/driver.rs
> @@ -1,6 +1,9 @@
> // SPDX-License-Identifier: GPL-2.0
>
> -use kernel::{auxiliary, bindings, c_str, device::Core, pci, prelude::*, sizes::SZ_16M, sync::Arc};
> +use kernel::{
> + auxiliary, bindings, c_str, device::Core, dma::Device, dma::DmaMask, pci, prelude::*,
> + sizes::SZ_16M, sync::Arc,
> +};
>
> use crate::gpu::Gpu;
>
> @@ -34,6 +37,9 @@ fn probe(pdev: &pci::Device<Core>, _info: &Self::IdInfo) -> Result<Pin<KBox<Self
> pdev.enable_device_mem()?;
> pdev.set_master();
>
> + // SAFETY: No DMA allocations have been made yet
> + unsafe { pdev.dma_set_mask_and_coherent(DmaMask::new::<47>())? };
Any chance you give it this a const name? Otherwise 6 months later it
becomes a magic number ;-)
Otherwise than this,
Reviewed-by: Boqun Feng <boqun.feng@xxxxxxxxx>
Regards,
Boqun
> +
> let devres_bar = Arc::pin_init(
> pdev.iomap_region_sized::<BAR0_SIZE>(0, c_str!("nova-core/bar0")),
> GFP_KERNEL,
> --
> 2.50.1
>