[Intel-gfx] [PATCH] drm/i915: Fix module unloading with DRM_I915_UMS=n

Chris Wilson chris at chris-wilson.co.uk
Fri Nov 15 21:58:12 CET 2013


On Fri, Nov 15, 2013 at 05:16:33PM +0100, Daniel Vetter wrote:
> Oops, makes testing early boot failures in i915.ko a bit more pain, so
> let's fix it.
> 
> v2: We already have a bit of static storage to track this (Chris).
> 
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>

How about just fixing the core not to die?

diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index f00d7a9..3b9c7ce 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -375,13 +375,13 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
 
        DRM_DEBUG("\n");
 
+       if (driver->driver_features & DRIVER_MODESET)
+               return pci_register_driver(pdriver);
+
        INIT_LIST_HEAD(&driver->device_list);
        driver->kdriver.pci = pdriver;
        driver->bus = &drm_pci_bus;
 
-       if (driver->driver_features & DRIVER_MODESET)
-               return pci_register_driver(pdriver);
-
        /* If not using KMS, fall back to stealth mode manual scanning. */
        for (i = 0; pdriver->id_table[i].vendor != 0; i++) {
                pid = &pdriver->id_table[i];
@@ -462,6 +462,11 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
        struct drm_device *dev, *tmp;
        DRM_DEBUG("\n");
 
+       if (!driver->kdriver.pci)
+               return;
+
+       WARN_ON(driver->kdriver.pci != pdriver);
+
        if (driver->driver_features & DRIVER_MODESET) {
                pci_unregister_driver(pdriver);
        } else {

We can drop the redundant pdriver later.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre



More information about the Intel-gfx mailing list