Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Medium] gpu: nova-core: missing PCI device cleanup in probe() [1]
--

commit 29c3fdaf952e7762e87f691bed7be2d19d9871ac
Author: Danilo Krummrich <[email protected]>

gpu: nova-core: use pin-init self-referential support

This commit replaces unsafely derived self-referential borrows in nova-core
with pin-init's self-referential support.

Link: 
https://lore.kernel.org/all/[email protected]/ 
[1]

> diff --git a/drivers/gpu/nova-core/driver.rs b/drivers/gpu/nova-core/driver.rs
> index 560a70c4f5a7d..ac5a9d9f83313 100644
> --- a/drivers/gpu/nova-core/driver.rs
> +++ b/drivers/gpu/nova-core/driver.rs

[ ... ]

> @@ -129,44 +131,25 @@ fn probe<'bound>(
>                  crate::irq::doorbell_test::run_selftest(pdev, bar, 
> spec.chipset)?;
>              },
>  
> -            // TODO: Use self-referential pin-init syntax once available.
> -            gpu <- Gpu::new(
> -                pdev,
> -                // 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) },
> -            ).pin_chain(|_gpu| {
> +            gpu <- Gpu::new(pdev, bar, bar1).pin_chain(|_gpu| {
>                  #[cfg(CONFIG_NOVA_CORE_SELFTESTS)]
>                  _gpu.run_selftests(pdev);
>                  Ok(())
>              }),

[Severity: Medium]
This problem wasn't introduced by this patch, but does NovaCoreDriver::probe()
leak the PCI device enable count and leave bus mastering active [1] if a
later step in try_pin_init!() fails or when the driver is unbound?

Earlier in the initializer block, probe() enables the device and bus mastering
without a cleanup guard or devres management:

drivers/gpu/nova-core/driver.rs:NovaCoreDriver::probe() {
    ...
        try_pin_init!(NovaCore {
            _: {
                pdev.enable_device_mem()?;
                pdev.set_master();
            },

            bar: pdev.iomap_region_sized::<BAR0_SIZE>(0, c"nova-core/bar0")?,
    ...
}

If bar mapping, Gpu::new(), or auxiliary registration fails, or when NovaCore
is dropped on unbind, nothing reverses enable_device_mem() or clears bus
mastering.

[1] https://sashiko.dev/#/bug/linux-c8fbc048-c40f-4093-b156-461f41a6e9fe

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to