On Mon Oct 26, 2026 at 4:50 AM CET, Dave Airlie via B4 Relay wrote:
> @@ -135,7 +139,12 @@ fn probe<'bound>(
>                  // SAFETY: `bar` is initialized above, pinned, and outlives 
> `gpu`.
>                  unsafe { &*core::ptr::from_ref(bar) },
>                  // SAFETY: `bar1` is initialized above, pinned, and outlives 
> `gpu`.
> -                unsafe { &*core::ptr::from_ref(bar1) },
> +                unsafe {
> +                    match bar1 {
> +                        None => None,
> +                        Some(bar1) => Some(&*core::ptr::from_ref(bar1)),
> +                    }
> +                },

This can just be

        bar1.as_ref().map(|b| unsafe { &*core::ptr::from_ref(b) })

> +    /// BAR1 user interface for CPU access to GPU virtual memory, if the 
> device has BAR1.
> +    bar_user: Option<Pin<KBox<BarUser<'gpu>>>>,

Can we please add a TODO to replace this, once we can get rid of the extra
allocation?

> +            bar_user: match bar1 {
> +                None => None,
> +                Some(bar1) => Some({
> +                    let pdb_addr = 
> VramAddress::from_raw(gsp_static_info.bar1_pde_base);
> +                    let bar1_idx = crate::driver::bar1_resource_index(pdev)?;
> +                    let bar1_size = pdev.resource_len(bar1_idx)?;
> +
> +                    KBox::pin_init(
> +                        BarUser::new(
> +                            pdb_addr,
> +                            gsp_resources.spec.chipset,
> +                            bar1_size,
> +                            bar1,
> +                        ),
> +                        GFP_KERNEL,
> +                    )?
> +                }),

I think this could also use map().

Reply via email to