drm/irq: remove check on dev->dev_private
Subsystems (2)
PATCH 1/1 drm/irq: remove check on dev->dev_private
There is no real reason to require drivers to set and use dev->dev_private. Indeed, the current recommendation, as documented in drm_device.h, is to embed struct drm_device in the per-device struct instead of using dev_private.
Remove the requirement for dev_private to have been set to indicate driver initialization.
---
Any ideas for something else drm_irq_install() could/should check to ensure "Driver must have been initialized"?
There are only a few instances of dev_private uses in i915, also to be removed, and we could stop initializing dev_private altogether. We could in fact do that without this patch too, as we don't use drm_irq_install(). But it would be cleaner to not have any checks for driver private stuff outside of drivers.
--- drivers/gpu/drm/drm_irq.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/gpu/drm/drm_irq.c +0 -4
@@ -111,10 +111,6 @@ int drm_irq_install(struct drm_device *dev, int irq)if (irq ==0 )return -EINVAL ; -/* Driver must have been initialized */ -if (!dev->dev_private) -return -EINVAL ; -if (dev->irq_enabled)return -EBUSY ; dev->irq_enabled = true;
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · Jani Nikula
There is no real reason to require drivers to set and use
dev->dev_private. Indeed, the current recommendation, as documented indrm_device.h, is to embed structdrm_devicein the per-device struct instead of usingdev_private.Remove the requirement for
dev_privateto have been set to indicate driver initialization.
Yeah this is nonsense. Also, drm_irq_install is purely optional semi-midlayer (it's not really a midlayer for the legacy drivers, but whatever, who cares about those).
Now there might be some hilarious races this papers over, but:
- Proper drivers should only call drm_dev_register once everything is set up, including this stuff here. No race possible with anything else really.
- Slightly more wobbly drivers, including the legacy ones, all use drm_global_mutex. This was the former BKL, which means that it was impossible for soeone to go through the load/unload/reload (between lastclose and firstopen) paths and also run the ioctl. But the ioctl had to be made unlocked because blocking there killed X:
commit 8f4ff2b06afcd6f151868474a432c603057eaf56 Author: Ilija Hadzic <[email protected]> Date: Mon Oct 31 17:46:18 2011 -0400 drm: do not sleep on vblank while holding a mutex
The even more legacy DRM_CONTROL ioctl stayed fully locked. But the file open/close paths are still fully locked, and that's the only place legacy drivers should call drm_irq_install/uninstall, so should all still be fully ordered and protected and happy.
Feel free to quote or not quote the above in the commit message.
Quoted 6 lines
Cc Chris Wilson <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Jani Nikula <[email protected]>---
Quoted 8 lines
Any ideas for something else
drm_irq_install()could/should check to ensure "Driver must have been initialized"?There are only a few instances of
dev_privateuses in i915, also to be removed, and we could stop initializingdev_privatealtogether. We could in fact do that without this patch too, as we don't usedrm_irq_install(). But it would be cleaner to not have any checks for driver private stuff outside of drivers.
I hope my review above answers your question here. Patch, as-is:
Quoted 22 lines
--- drivers/gpu/drm/drm_irq.c | 4 ---- 1 file changed, 4 deletions(-)drivers/gpu/drm/drm_irq.c +0
-4@@ -111,10 +111,6 @@ int drm_irq_install(struct drm_device *dev, int irq)if (irq ==0 )return -EINVAL ; -/* Driver must have been initialized */ -if (!dev->dev_private) -return -EINVAL ; -if (dev->irq_enabled)return -EBUSY ; dev->irq_enabled = true;Signature · 1 line
2.20.1
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 53 lines · Daniel Vetter
Quoted 7 lines · Jani Nikula
There is no real reason to require drivers to set and use
dev->dev_private. Indeed, the current recommendation, as documented indrm_device.h, is to embed structdrm_devicein the per-device struct instead of usingdev_private.Remove the requirement for
dev_privateto have been set to indicate driver initialization.Yeah this is nonsense. Also,
drm_irq_installis purely optional semi-midlayer (it's not really a midlayer for the legacy drivers, but whatever, who cares about those).Now there might be some hilarious races this papers over, but:
- Proper drivers should only call
drm_dev_registeronce everything is set up, including this stuff here. No race possible with anything else really.- Slightly more wobbly drivers, including the legacy ones, all use
drm_global_mutex. This was the former BKL, which means that it was impossible for soeone to go through the load/unload/reload (between lastclose and firstopen) paths and also run the ioctl. But the ioctl had to be made unlocked because blocking there killed X:commit 8f4ff2b06afcd6f151868474a432c603057eaf56 Author: Ilija Hadzic <[email protected]> Date: Mon Oct 31 17:46:18 2011 -0400 drm: do not sleep on vblank while holding a mutexThe even more legacy
DRM_CONTROLioctl stayed fully locked. But the file open/close paths are still fully locked, and that's the only place legacy drivers should call drm_irq_install/uninstall, so should all still be fully ordered and protected and happy.Feel free to quote or not quote the above in the commit message.
Quoted 6 lines
Cc Chris Wilson <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Jani Nikula <[email protected]>---
Quoted 8 lines
Any ideas for something else
drm_irq_install()could/should check to ensure "Driver must have been initialized"?There are only a few instances of
dev_privateuses in i915, also to be removed, and we could stop initializingdev_privatealtogether. We could in fact do that without this patch too, as we don't usedrm_irq_install(). But it would be cleaner to not have any checks for driver private stuff outside of drivers.
Quoted 3 lines
I hope my review above answers your question here. Patch, as-is:
Reviewed-by Daniel Vetter <[email protected]>
Many thanks, pushed to drm-misc-next with the details addded to commit message.
BR,
Jani.
Quoted 23 lines
Quoted 23 lines
--- drivers/gpu/drm/drm_irq.c | 4 ---- 1 file changed, 4 deletions(-)drivers/gpu/drm/drm_irq.c +0
-4@@ -111,10 +111,6 @@ int drm_irq_install(struct drm_device *dev, int irq)if (irq ==0 )return -EINVAL ; -/* Driver must have been initialized */ -if (!dev->dev_private) -return -EINVAL ; -if (dev->irq_enabled)return -EBUSY ; dev->irq_enabled = true;Signature · 1 line
2.20.1
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel