[PATCH 02/12] drm/vmwgfx: Use devm aperture helpers for sysfb restore on probe failure
From: Zack Rusin
Date: Mon Dec 29 2025 - 16:59:28 EST
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.
Signed-off-by: Zack Rusin <zack.rusin@xxxxxxxxxxxx>
Cc: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx>
Cc: Maxime Ripard <mripard@xxxxxxxxxx>
Cc: Thomas Zimmermann <tzimmermann@xxxxxxx>
Cc: David Airlie <airlied@xxxxxxxxx>
Cc: Simona Vetter <simona@xxxxxxxx>
Cc: dri-devel@xxxxxxxxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
---
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 599052d07ae8..1b0fc4f9d4af 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -1622,7 +1622,12 @@ static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
struct vmw_private *vmw;
int ret;
- ret = aperture_remove_conflicting_pci_devices(pdev, 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, driver.name);
if (ret)
goto out_error;
@@ -1647,6 +1652,12 @@ static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (ret)
goto out_unload;
+ /*
+ * Probe succeeded - cancel the automatic sysfb restore action.
+ * We're now responsible for display output.
+ */
+ devm_aperture_remove_conflicting_pci_devices_done(pdev);
+
vmw_fifo_resource_inc(vmw);
vmw_svga_enable(vmw);
drm_client_setup(&vmw->drm, NULL);
--
2.48.1