Register a devm action on the vmbus device to restore the system framebuffer (efifb/simpledrm) if the driver's probe fails after removing the firmware framebuffer.
Unlike PCI drivers, hyperv cannot use the devm_aperture_remove_conflicting_pci_devices() helper because this is a vmbus device, not a PCI device. Instead, register the sysfb restore action on the hv device (&hdev->device) which will be released if probe fails. Cancel the action after successful probe since the driver is now responsible for display output. This ensures users don't lose display output if the hyperv driver fails to probe after removing the firmware framebuffer. Signed-off-by: Zack Rusin <[email protected]> Cc: Deepak Rawat <[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/hyperv/hyperv_drm_drv.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/gpu/drm/hyperv/hyperv_drm_drv.c b/drivers/gpu/drm/hyperv/hyperv_drm_drv.c index 06b5d96e6eaf..6d66cd243bab 100644 --- a/drivers/gpu/drm/hyperv/hyperv_drm_drv.c +++ b/drivers/gpu/drm/hyperv/hyperv_drm_drv.c @@ -8,6 +8,7 @@ #include <linux/hyperv.h> #include <linux/module.h> #include <linux/pci.h> +#include <linux/sysfb.h> #include <drm/clients/drm_client_setup.h> #include <drm/drm_atomic_helper.h> @@ -102,6 +103,11 @@ static int hyperv_setup_vram(struct hyperv_drm_device *hv, return ret; } +static void hyperv_restore_sysfb(void *unused) +{ + sysfb_restore(); +} + static int hyperv_vmbus_probe(struct hv_device *hdev, const struct hv_vmbus_device_id *dev_id) { @@ -127,6 +133,17 @@ static int hyperv_vmbus_probe(struct hv_device *hdev, aperture_remove_all_conflicting_devices(hyperv_driver.name); + /* + * Register sysfb restore on the hv device. We can't use + * devm_aperture_remove_conflicting_pci_devices() because this + * is a vmbus device, not a PCI device. Register on &hdev->device + * so it fires if our probe fails after removing firmware FB. + */ + ret = devm_add_action_or_reset(&hdev->device, hyperv_restore_sysfb, + NULL); + if (ret) + goto err_vmbus_close; + ret = hyperv_setup_vram(hv, hdev); if (ret) goto err_vmbus_close; @@ -152,6 +169,12 @@ static int hyperv_vmbus_probe(struct hv_device *hdev, drm_client_setup(dev, NULL); + /* + * Probe succeeded - cancel sysfb restore. We're now responsible + * for display output. + */ + devm_remove_action(&hdev->device, hyperv_restore_sysfb, NULL); + return 0; err_free_mmio: -- 2.48.1
