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 i915 driver
fails to probe after removing the firmware framebuffer.

Signed-off-by: Zack Rusin <[email protected]>
Cc: Jani Nikula <[email protected]>
Cc: Joonas Lahtinen <[email protected]>
Cc: Rodrigo Vivi <[email protected]>
Cc: Tvrtko Ursulin <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
 drivers/gpu/drm/i915/i915_driver.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_driver.c 
b/drivers/gpu/drm/i915/i915_driver.c
index c97b76771917..f9efeb825064 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -506,7 +506,12 @@ static int i915_driver_hw_probe(struct drm_i915_private 
*dev_priv)
        if (ret)
                goto err_perf;
 
-       ret = aperture_remove_conflicting_pci_devices(pdev, 
dev_priv->drm.driver->name);
+       /*
+        * 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, 
dev_priv->drm.driver->name);
        if (ret)
                goto err_ggtt;
 
@@ -866,6 +871,12 @@ int i915_driver_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 
        i915->do_release = true;
 
+       /*
+        * 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;
 
 out_cleanup_gem:
-- 
2.48.1

Reply via email to