drm/i915: Fix module unloading with DRM_I915_UMS=n
Subsystems (3)
PATCH 1/1 drm/i915: Fix module unloading with DRM_I915_UMS=n
Oops, makes testing early boot failures in i915.ko a bit more pain, so let's fix it.
--- drivers/gpu/drm/i915/i915_drv.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +6 -0
@@ -982,6 +982,8 @@ static struct pci_driver i915_pci_driver = { .driver.pm = &i915_pm_ops, }; +bool i915_no_driver_loaded; +static int __init i915_init (void ) { driver.num_ioctls = i915_max_ioctl;
@@ -1011,6 +1013,7 @@ static int __init i915_init(void) driver.get_vblank_timestamp =NULL ;#ifndef CONFIG_DRM_I915_UMS /* Silently fail loading to not upset userspace. */ + i915_no_driver_loaded = true;return 0 ;#endif }
@@ -1020,6 +1023,9 @@ static int __init i915_init(void) static void __exit i915_exit(void) { +if (i915_no_driver_loaded) +return ; +drm_pci_exit (&driver, &i915_pci_driver); }
Signature · 1 line
1.8.3.1
Quoted 2 lines · Daniel Vetter
Oops, makes testing early boot failures in i915.ko a bit more pain, so let's fix it.
You already have a static driver structure, why not take advantage of that here?
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
PATCH 1/1 drm/i915: Fix module unloading with DRM_I915_UMS=n
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).
--- drivers/gpu/drm/i915/i915_drv.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +5 -0
@@ -1020,6 +1020,11 @@ static int __init i915_init(void) static void __exit i915_exit(void) { +#ifndef CONFIG_DRM_I915_UMS +if (!(driver.driver_features &DRIVER_MODESET )) +return ;/* Never loaded a driver. */ +#endif +drm_pci_exit (&driver, &i915_pci_driver); }
Signature · 1 line
1.8.3.1
Quoted 7 lines · Daniel Vetter
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 <[email protected]>Signed-off-by Daniel Vetter <[email protected]>
How about just fixing the core not to die?
drivers/gpu/drm/drm_pci.c +8 -3
@@ -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
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 10 lines · Chris Wilson
Quoted 7 lines · Daniel Vetter
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 <[email protected]>Signed-off-by Daniel Vetter <[email protected]>How about just fixing the core not to die?
This is for the disabled UMS code where we silently don't register anything. So there's also nothing to clean up, i.e. we've called drm_pci_exit without drm_pci_init. I don't think this is something we should allow in the core.
-Daniel
Quoted 40 lines
drivers/gpu/drm/drm_pci.c +8
-3@@ -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.
-ChrisSignature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
2013/11/15 Daniel Vetter <[email protected]>:
Quoted 7 lines
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 <[email protected]>Signed-off-by Daniel Vetter <[email protected]>
I can reproduce the failure by booting with i915.modeset=0, then get the oops when "rmmod i915".
I also looked at Chris' patch. I think that since we take the early "return 0" inside i915_init, we never call drm_pci_init, so it doesn't make too much sense to fix the problem inside drm_pci_exit.
Quoted 27 lines
--- drivers/gpu/drm/i915/i915_drv.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/gpu/drm/i915/i915_drv.c +5
-1@@ -1020,6 +1020,11 @@ static int __init i915_init(void) static void __exit i915_exit(void) { +#ifndef CONFIG_DRM_I915_UMS +if (!(driver.driver_features &DRIVER_MODESET )) +return ;/* Never loaded a driver. */ +#endif +drm_pci_exit (&driver, &i915_pci_driver); } --1.8.3.1
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 1 line
Paulo Zanoni
Quoted 12 lines · Paulo Zanoni
2013/11/15 Daniel Vetter <[email protected]>:
Quoted 7 lines
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 <[email protected]>Signed-off-by Daniel Vetter <[email protected]>I can reproduce the failure by booting with i915.modeset=0, then get the oops when "rmmod i915".
Quoted 6 lines
Reviewed-by Paulo Zanoni <[email protected]>Tested-by Paulo Zanoni <[email protected]>I also looked at Chris' patch. I think that since we take the early "return 0" inside
i915_init, we never calldrm_pci_init, so it doesn't make too much sense to fix the problem insidedrm_pci_exit.
Thanks for review&testing, patch merged.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch