drm/i915: Allow switching away via vga-switcheroo if uninitialized
authorjsg <jsg@openbsd.org>
Wed, 25 Jan 2023 01:55:14 +0000 (01:55 +0000)
committerjsg <jsg@openbsd.org>
Wed, 25 Jan 2023 01:55:14 +0000 (01:55 +0000)
From Thomas Zimmermann
4397bcbd729dd79af4cc53615bdca59f80e74643 in linux-6.1.y/6.1.8
a273e95721e96885971a05f1b34cb6d093904d9d in mainline linux

sys/dev/pci/drm/i915/i915_driver.c
sys/dev/pci/drm/i915/i915_switcheroo.c

index 02c0739..85a3258 100644 (file)
@@ -1226,8 +1226,7 @@ static void i915_driver_lastclose(struct drm_device *dev)
 
        intel_fbdev_restore_mode(dev);
 
-       if (HAS_DISPLAY(i915))
-               vga_switcheroo_process_delayed_switch();
+       vga_switcheroo_process_delayed_switch();
 }
 
 static void i915_driver_postclose(struct drm_device *dev, struct drm_file *file)
index b99be33..95b4800 100644 (file)
@@ -21,6 +21,10 @@ static void i915_switcheroo_set_state(struct pci_dev *pdev,
                dev_err(&pdev->dev, "DRM not initialized, aborting switch.\n");
                return;
        }
+       if (!HAS_DISPLAY(i915)) {
+               dev_err(&pdev->dev, "Device state not initialized, aborting switch.\n");
+               return;
+       }
 
        if (state == VGA_SWITCHEROO_ON) {
                drm_info(&i915->drm, "switched on\n");
@@ -46,7 +50,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
         * locking inversion with the driver load path. And the access here is
         * completely racy anyway. So don't bother with locking for now.
         */
-       return i915 && atomic_read(&i915->drm.open_count) == 0;
+       return i915 && HAS_DISPLAY(i915) && atomic_read(&i915->drm.open_count) == 0;
 }
 
 static const struct vga_switcheroo_client_ops i915_switcheroo_ops = {