Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] drm/nouveau: resource leak and stale list entry in nvkm_device_ctor() --
commit 2b74a622d800f1d2cd12ecd10013a3d94e2a156e Author: Dave Airlie <[email protected]> drm/nouveau: add option to leave GSP-capable GPUs to other drivers This commit adds a DRM_NOUVEAU_BIND_GSP Kconfig option and a bind_gsp module parameter to let nouveau skip GSP-capable (Turing and later) PCI GPUs so other drivers such as nova-core can claim them. > diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c > b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c > index a2ed8c4fe52a0..a027860fa8694 100644 > --- a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c > +++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c [ ... ] > @@ -3381,6 +3381,20 @@ nvkm_device_ctor(const struct nvkm_device_func *func, > goto done; > } > > + /* Unless nouveau is the default NVIDIA driver, leave GSP-capable > + * (Turing and later) PCI GPUs to other drivers, such as nova-core. > + * Older GPUs are always bound. > + * > + * Reject before subdevs are constructed, as that would already load > + * GSP firmware for GPUs that are not going to be used. > + */ > + if (device->func->pci && device->card_type >= TU100 && !bind_gsp) { > + nvdev_info(device, "leaving GSP-capable GPU to other drivers " > + "(bind_gsp=0)\n"); > + ret = -ENODEV; > + goto done; > + } > + > /* read strapping information */ > strap = nvkm_rd32(device, 0x101000); [Severity: High] Does rejecting a GPU here leak pdev, leave pci_dev enabled, and leave a freed or stale entry on nv_devices? Before reaching this check, nvkm_device_pci_new() calls pci_enable_device() and allocates pdev, and nvkm_device_ctor() adds &device->head to the global nv_devices list: drivers/gpu/drm/nouveau/nvkm/engine/device/base.c:nvkm_device_ctor() { ... list_add_tail(&device->head, &nv_devices); ... done: if (ret && device->pri) { iounmap(device->pri); device->pri = NULL; } mutex_unlock(&nv_devices_mutex); return ret; } When nvkm_device_ctor() returns -ENODEV, the done label only unmaps device->pri, and nvkm_device_pci_new() and nouveau_drm_probe() return ret immediately without unlinking device->head from nv_devices, calling pci_disable_device(), or freeing pdev. This leaves the PCI device's enable_cnt elevated when handing off to another driver and causes any later nouveau probe of the same device handle to fail with -EEXIST. (Note that calling nvkm_device_del() directly on this failure path would also hit an uninitialized device->intr.intr list in nvkm_intr_dtor(), since nvkm_intr_ctor() has not run yet.) -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1
