Use devm_aperture_remove_conflicting_pci_devices() instead of the
non-devm variant to automatically restore the system framebuffer
(efifb/simpledrm) if the driver's probe fails after removing the
firmware framebuffer.

Call devm_aperture_remove_conflicting_pci_devices_done() after
successful probe to cancel the automatic restore, as the driver
is now responsible for display output.

This ensures users don't lose display output if the nouveau driver
fails to probe after removing the firmware framebuffer.

Signed-off-by: Zack Rusin <[email protected]>
Cc: Lyude Paul <[email protected]>
Cc: Danilo Krummrich <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 1527b801f013..7211ec6cdcc9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -871,8 +871,13 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
        if (ret)
                return ret;
 
-       /* Remove conflicting drivers (vesafb, efifb etc). */
-       ret = aperture_remove_conflicting_pci_devices(pdev, driver_pci.name);
+       /*
+        * Remove conflicting drivers (vesafb, efifb etc). Use devm variant
+        * to automatically restore sysfb if probe fails. This ensures the
+        * user doesn't lose display if our probe fails after removing the
+        * firmware framebuffer (efifb/simpledrm).
+        */
+       ret = devm_aperture_remove_conflicting_pci_devices(pdev, 
driver_pci.name);
        if (ret)
                return ret;
 
@@ -903,6 +908,13 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
        drm_client_setup(drm->dev, format);
 
        quirk_broken_nv_runpm(pdev);
+
+       /*
+        * Probe succeeded - cancel the automatic sysfb restore action.
+        * We're now responsible for display output.
+        */
+       devm_aperture_remove_conflicting_pci_devices_done(pdev);
+
        return 0;
 
 fail_pci:
-- 
2.48.1

Reply via email to