drm: Do delayed switcheroo in drm_lastclose()
authorThomas Zimmermann <tzimmermann@suse.de>
Mon, 12 Aug 2024 08:28:22 +0000 (10:28 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Tue, 13 Aug 2024 14:21:07 +0000 (16:21 +0200)
Amdgpu and nouveau call vga_switcheroo_process_delayed_switch() from
their lastclose callbacks. Call it from drm_lastclose(), so that the
driver functions can finally be removed. Only PCI devices with enabled
switcheroo do the delayed switching. The call has no effect on other
hardware.

v2:
- move change to drm_lastclose() (Sima)
- update docs for vga_switcheroo_process_delayed_switch()

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240812083000.337744-2-tzimmermann@suse.de
drivers/gpu/drm/drm_file.c
drivers/gpu/vga/vga_switcheroo.c

index 714e42b05108007e26eb08eb0eaf11d74761a83f..513bef816ae9f6c157fe1eafacaf5f7b4b73734f 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/pci.h>
 #include <linux/poll.h>
 #include <linux/slab.h>
+#include <linux/vga_switcheroo.h>
 
 #include <drm/drm_client.h>
 #include <drm/drm_drv.h>
@@ -404,6 +405,9 @@ void drm_lastclose(struct drm_device * dev)
        drm_dbg_core(dev, "driver lastclose completed\n");
 
        drm_client_dev_restore(dev);
+
+       if (dev_is_pci(dev->dev))
+               vga_switcheroo_process_delayed_switch();
 }
 
 /**
index 365e6ddbe90fe73b89043c9fdfa06bb0fd9eb41a..18f2c92beff8edeb1638852b9820f1f6e41b14ab 100644 (file)
@@ -926,8 +926,7 @@ static void vga_switcheroo_debugfs_init(struct vgasr_priv *priv)
 /**
  * vga_switcheroo_process_delayed_switch() - helper for delayed switching
  *
- * Process a delayed switch if one is pending. DRM drivers should call this
- * from their ->lastclose callback.
+ * Process a delayed switch if one is pending.
  *
  * Return: 0 on success. -EINVAL if no delayed switch is pending, if the client
  * has unregistered in the meantime or if there are other clients blocking the