drm: Make each driver's struct_mutex its own subclass
Subsystems (2)
PATCH 1/1 drm: Make each driver's struct_mutex its own subclass
With prime, we are running into false circular dependencies based on the order in which two drivers may lock their own struct_mutex wrt to a common lock (like the reservation->lock). Work around this by adding the lock_class_key to the struct drm_driver such that each driver can have its own subclass of struct_mutex. Circular dependencies between drivers will now be ignored, but real circular dependencies on any one mutex will still be caught. A driver creating more than one device will still need to be careful!
--- drivers/gpu/drm/drm_drv.c | 4 +++- include/drm/drm_drv.h | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_drv.c +3 -1
@@ -488,7 +488,9 @@ int drm_dev_init(struct drm_device *dev,spin_lock_init (&dev->buf_lock);spin_lock_init (&dev->event_lock); -mutex_init (&dev->struct_mutex); +__mutex_init (&dev->struct_mutex, +"&dev->struct_mutex" , + &driver->class.struct_mutex_key);mutex_init (&dev->filelist_mutex);mutex_init (&dev->ctxlist_mutex);mutex_init (&dev->master_mutex);
include/drm/drm_drv.h +6 -0
@@ -39,6 +39,10 @@ struct dma_buf_attachment;struct drm_display_mode ;struct drm_mode_create_dumb ; +struct drm_driver_class { +struct lock_class_key struct_mutex_key; +}; +/* driver capabilities and requirements mask */ #define DRIVER_USE_AGP 0x1#define DRIVER_LEGACY 0x2
@@ -64,6 +68,8 @@ struct drm_mode_create_dumb;* structure for GEM drivers. */ struct drm_driver { +struct drm_driver_class class; +int (*load) (struct drm_device *,unsigned long flags);int (*firstopen) (struct drm_device *);int (*open) (struct drm_device *,struct drm_file *);
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Patchwork
CI✗ Fi.CI.BAT: failure for drm: Make each driver's struct_mutex its own subclass
== Series Details ==
== Series Details ==
Series: drm: Make each driver's struct_mutex its own subclass
URL : https://patchwork.freedesktop.org/series/16623/
State : failure
== Summary ==
Series 16623v1 drm: Make each driver's struct_mutex its own subclass
https://patchwork.freedesktop.org/api/1.0/series/16623/revisions/1/mbox/
Test gem_sync:
Subgroup basic-store-all:
pass -> FAIL (fi-ivb-3520m)fi-bdw-5557u total:247 pass:233 dwarn:0 dfail:0 fail:0 skip:14 fi-bsw-n3050 total:247 pass:208 dwarn:0 dfail:0 fail:0 skip:39 fi-bxt-t5700 total:247 pass:220 dwarn:0 dfail:0 fail:0 skip:27 fi-byt-j1900 total:247 pass:220 dwarn:0 dfail:0 fail:0 skip:27 fi-hsw-4770 total:247 pass:228 dwarn:0 dfail:0 fail:0 skip:19 fi-hsw-4770r total:247 pass:228 dwarn:0 dfail:0 fail:0 skip:19 fi-ilk-650 total:247 pass:195 dwarn:0 dfail:0 fail:0 skip:52 fi-ivb-3520m total:247 pass:225 dwarn:0 dfail:0 fail:1 skip:21 fi-ivb-3770 total:247 pass:226 dwarn:0 dfail:0 fail:0 skip:21 fi-kbl-7500u total:247 pass:226 dwarn:0 dfail:0 fail:0 skip:21 fi-skl-6260u total:247 pass:234 dwarn:0 dfail:0 fail:0 skip:13 fi-skl-6700hq total:247 pass:227 dwarn:0 dfail:0 fail:0 skip:20 fi-skl-6700k total:247 pass:224 dwarn:3 dfail:0 fail:0 skip:20 fi-skl-6770hq total:247 pass:234 dwarn:0 dfail:0 fail:0 skip:13 fi-snb-2600 total:247 pass:215 dwarn:0 dfail:0 fail:0 skip:32
de43f4e755c6bf50ad53b4ccacedf9850f42eda4 drm-tip: 2016y-12m-09d-09h-01m-58s UTC integration manifest 98fa7b8 drm: Make each driver's struct_mutex its own subclass
== Logs ==
For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3255/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
kbuild test robot
build botAll warnings (new ones prefixed by >>):
Hi Chris,
[auto build test WARNING on drm/drm-next]
[also build test WARNING on next-20161209]
[cannot apply to v4.9-rc8]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Chris-Wilson/drm-Make-each-driver-s-struct_mutex-its-own-subclass/20161210-222233 base: git://people.freedesktop.org/~airlied/linux.git drm-next reproduce: make htmldocs
All warnings (new ones prefixed by >>):
make[3]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule. include/linux/init.h:1: warning: no structured comments found
include/linux/workqueue.h:392: warning: No description found for parameter '...' include/linux/workqueue.h:392: warning: Excess function parameter 'args' description in 'alloc_workqueue' include/linux/workqueue.h:413: warning: No description found for parameter '...' include/linux/workqueue.h:413: warning: Excess function parameter 'args' description in 'alloc_ordered_workqueue' include/linux/kthread.h:26: warning: No description found for parameter '...'
kernel/sys.c:1: warning: no structured comments found
drivers/dma-buf/seqno-fence.c:1: warning: no structured comments found include/sound/core.h:324: warning: No description found for parameter '...' include/sound/core.h:335: warning: No description found for parameter '...' include/sound/core.h:388: warning: No description found for parameter '...'
>> include/drm/drm_drv.h:415: warning: No description found for parameter 'class'
include/drm/drm_drv.h:415: warning: No description found for parameter 'load' include/drm/drm_drv.h:415: warning: No description found for parameter 'firstopen' include/drm/drm_drv.h:415: warning: No description found for parameter 'open' include/drm/drm_drv.h:415: warning: No description found for parameter 'preclose' include/drm/drm_drv.h:415: warning: No description found for parameter 'postclose' include/drm/drm_drv.h:415: warning: No description found for parameter 'lastclose' include/drm/drm_drv.h:415: warning: No description found for parameter 'unload' include/drm/drm_drv.h:415: warning: No description found for parameter 'dma_ioctl' include/drm/drm_drv.h:415: warning: No description found for parameter 'dma_quiescent' include/drm/drm_drv.h:415: warning: No description found for parameter 'context_dtor' include/drm/drm_drv.h:415: warning: No description found for parameter 'set_busid' include/drm/drm_drv.h:415: warning: No description found for parameter 'irq_handler' include/drm/drm_drv.h:415: warning: No description found for parameter 'irq_preinstall' include/drm/drm_drv.h:415: warning: No description found for parameter 'irq_postinstall' include/drm/drm_drv.h:415: warning: No description found for parameter 'irq_uninstall' include/drm/drm_drv.h:415: warning: No description found for parameter 'debugfs_init' include/drm/drm_drv.h:415: warning: No description found for parameter 'debugfs_cleanup' include/drm/drm_drv.h:415: warning: No description found for parameter 'gem_open_object' include/drm/drm_drv.h:415: warning: No description found for parameter 'gem_close_object' include/drm/drm_drv.h:415: warning: No description found for parameter 'prime_handle_to_fd' include/drm/drm_drv.h:415: warning: No description found for parameter 'prime_fd_to_handle' include/drm/drm_drv.h:415: warning: No description found for parameter 'gem_prime_export' include/drm/drm_drv.h:415: warning: No description found for parameter 'gem_prime_import' include/drm/drm_drv.h:415: warning: No description found for parameter 'gem_prime_pin' include/drm/drm_drv.h:415: warning: No description found for parameter 'gem_prime_unpin' include/drm/drm_drv.h:415: warning: No description found for parameter 'gem_prime_res_obj' include/drm/drm_drv.h:415: warning: No description found for parameter 'gem_prime_get_sg_table' include/drm/drm_drv.h:415: warning: No description found for parameter 'gem_prime_import_sg_table' include/drm/drm_drv.h:415: warning: No description found for parameter 'gem_prime_vmap' include/drm/drm_drv.h:415: warning: No description found for parameter 'gem_prime_vunmap' include/drm/drm_drv.h:415: warning: No description found for parameter 'gem_prime_mmap' include/drm/drm_drv.h:415: warning: No description found for parameter 'vgaarb_irq' include/drm/drm_drv.h:415: warning: No description found for parameter 'gem_vm_ops' include/drm/drm_drv.h:415: warning: No description found for parameter 'major' include/drm/drm_drv.h:415: warning: No description found for parameter 'minor' include/drm/drm_drv.h:415: warning: No description found for parameter 'patchlevel' include/drm/drm_drv.h:415: warning: No description found for parameter 'name' include/drm/drm_drv.h:415: warning: No description found for parameter 'desc' include/drm/drm_drv.h:415: warning: No description found for parameter 'date' include/drm/drm_drv.h:415: warning: No description found for parameter 'driver_features' include/drm/drm_drv.h:415: warning: No description found for parameter 'dev_priv_size' include/drm/drm_drv.h:415: warning: No description found for parameter 'ioctls' include/drm/drm_drv.h:415: warning: No description found for parameter 'num_ioctls' include/drm/drm_drv.h:415: warning: No description found for parameter 'fops' include/drm/drm_drv.h:415: warning: No description found for parameter 'legacy_dev_list' include/media/media-entity.h:1054: warning: No description found for parameter '...' include/net/mac80211.h:3207: ERROR: Unexpected indentation.
include/net/mac80211.h:3210: WARNING: Block quote ends without a blank line; unexpected unindent. include/net/mac80211.h:3212: ERROR: Unexpected indentation.
include/net/mac80211.h:3213: WARNING: Block quote ends without a blank line; unexpected unindent. include/net/mac80211.h:1772: ERROR: Unexpected indentation.
include/net/mac80211.h:1776: WARNING: Block quote ends without a blank line; unexpected unindent. kernel/sched/fair.c:7259: WARNING: Inline emphasis start-string without end-string. kernel/time/timer.c:1240: ERROR: Unexpected indentation.
kernel/time/timer.c:1242: ERROR: Unexpected indentation.
kernel/time/timer.c:1243: WARNING: Block quote ends without a blank line; unexpected unindent. include/linux/wait.h:121: WARNING: Block quote ends without a blank line; unexpected unindent. include/linux/wait.h:124: ERROR: Unexpected indentation.
include/linux/wait.h:126: WARNING: Block quote ends without a blank line; unexpected unindent. kernel/time/hrtimer.c:1021: WARNING: Block quote ends without a blank line; unexpected unindent. kernel/signal.c:317: WARNING: Inline literal start-string without end-string. drivers/base/firmware_class.c:1348: WARNING: Bullet list ends without a blank line; unexpected unindent. drivers/message/fusion/mptbase.c:5054: WARNING: Definition list ends without a blank line; unexpected unindent. drivers/tty/serial/serial_core.c:1893: WARNING: Definition list ends without a blank line; unexpected unindent. include/linux/spi/spi.h:369: ERROR: Unexpected indentation.
WARNING: dvipng command 'dvipng' cannot be run (needed for math display), check the imgmath_dvipng setting
vim +/class +415 include/drm/drm_drv.h
85e634bc Daniel Vetter 2016-11-14 399 int major; 85e634bc Daniel Vetter 2016-11-14 400 int minor; 85e634bc Daniel Vetter 2016-11-14 401 int patchlevel; 85e634bc Daniel Vetter 2016-11-14 402 char *name; 85e634bc Daniel Vetter 2016-11-14 403 char *desc; 85e634bc Daniel Vetter 2016-11-14 404 char *date; 85e634bc Daniel Vetter 2016-11-14 405 85e634bc Daniel Vetter 2016-11-14 406 u32 driver_features; 85e634bc Daniel Vetter 2016-11-14 407 int dev_priv_size; 85e634bc Daniel Vetter 2016-11-14 408 const struct drm_ioctl_desc *ioctls; 85e634bc Daniel Vetter 2016-11-14 409 int num_ioctls; 85e634bc Daniel Vetter 2016-11-14 410 const struct file_operations *fops; 85e634bc Daniel Vetter 2016-11-14 411 85e634bc Daniel Vetter 2016-11-14 412 /* List of devices hanging off this driver with stealth attach. */ 85e634bc Daniel Vetter 2016-11-14 413 struct list_head legacy_dev_list; 85e634bc Daniel Vetter 2016-11-14 414 }; 85e634bc Daniel Vetter 2016-11-14 @415 85e634bc Daniel Vetter 2016-11-14 416 extern __printf(6, 7) 85e634bc Daniel Vetter 2016-11-14 417 void drm_dev_printk(const struct device *dev, const char *level, 85e634bc Daniel Vetter 2016-11-14 418 unsigned int category, const char *function_name, 85e634bc Daniel Vetter 2016-11-14 419 const char *prefix, const char *format, ...); 85e634bc Daniel Vetter 2016-11-14 420 extern __printf(3, 4) 85e634bc Daniel Vetter 2016-11-14 421 void drm_printk(const char *level, unsigned int category, 85e634bc Daniel Vetter 2016-11-14 422 const char *format, ...); 85e634bc Daniel Vetter 2016-11-14 423 extern unsigned int drm_debug;
:::::: The code at line 415 was first introduced by commit :::::: 85e634bce01af582a0fa549c904154b0e3c56db5 drm: Extract drm_drv.h
:::::: TO: Daniel Vetter <[email protected]>
:::::: CC: Daniel Vetter <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 9 lines · Chris Wilson
With prime, we are running into false circular dependencies based on the order in which two drivers may lock their own
struct_mutexwrt to a common lock (like thereservation->lock). Work around this by adding thelock_class_keyto the structdrm_driversuch that each driver can have its own subclass ofstruct_mutex. Circular dependencies between drivers will now be ignored, but real circular dependencies on any one mutex will still be caught. A driver creating more than one device will still need to be careful!
Quoted 3 lines
Reported-by Tobias Klausmann <[email protected]>Reported-by Hans de Goede <[email protected]>Signed-off-by Chris Wilson <[email protected]>
Where does this even happen? i915, msm and udl are the only drivers left over that do struct_mutex, and i915 can't really share buffers with msm, and udl doesn't do reservations. How exactly does this still go boom in latest upstream?
-Daniel
Quoted 51 lines
--- drivers/gpu/drm/drm_drv.c | 4 +++- include/drm/drm_drv.h | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_drv.c +3
-1@@ -488,7 +488,9 @@ int drm_dev_init(struct drm_device *dev,spin_lock_init (&dev->buf_lock);spin_lock_init (&dev->event_lock); -mutex_init (&dev->struct_mutex); +__mutex_init (&dev->struct_mutex, +"&dev->struct_mutex" , + &driver->class.struct_mutex_key);mutex_init (&dev->filelist_mutex);mutex_init (&dev->ctxlist_mutex);mutex_init (&dev->master_mutex);include/drm/drm_drv.h +6
-0@@ -39,6 +39,10 @@ struct dma_buf_attachment;struct drm_display_mode ;struct drm_mode_create_dumb ; +struct drm_driver_class { +struct lock_class_key struct_mutex_key; +}; +/* driver capabilities and requirements mask */ #define DRIVER_USE_AGP 0x1#define DRIVER_LEGACY 0x2@@ -64,6 +68,8 @@ struct drm_mode_create_dumb;* structure for GEM drivers. */ struct drm_driver { +struct drm_driver_class class; +int (*load) (struct drm_device *,unsigned long flags);int (*firstopen) (struct drm_device *);int (*open) (struct drm_device *,struct drm_file *);Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 10 lines · Daniel Vetter
Quoted 9 lines · Chris Wilson
With prime, we are running into false circular dependencies based on the order in which two drivers may lock their own
struct_mutexwrt to a common lock (like thereservation->lock). Work around this by adding thelock_class_keyto the structdrm_driversuch that each driver can have its own subclass ofstruct_mutex. Circular dependencies between drivers will now be ignored, but real circular dependencies on any one mutex will still be caught. A driver creating more than one device will still need to be careful!
Quoted 8 lines
Quoted 3 lines
Reported-by Tobias Klausmann <[email protected]>Reported-by Hans de Goede <[email protected]>Signed-off-by Chris Wilson <[email protected]>Where does this even happen? i915, msm and udl are the only drivers left over that do
struct_mutex, and i915 can't really share buffers with msm, and udl doesn't do reservations. How exactly does this still go boom in latest upstream?
How about cc: stable?
The reports are nouveau vs i915. I was quite pleased with the drm_driver_class!
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 20 lines · Chris Wilson
Quoted 10 lines · Daniel Vetter
Quoted 9 lines · Chris Wilson
With prime, we are running into false circular dependencies based on the order in which two drivers may lock their own
struct_mutexwrt to a common lock (like thereservation->lock). Work around this by adding thelock_class_keyto the structdrm_driversuch that each driver can have its own subclass ofstruct_mutex. Circular dependencies between drivers will now be ignored, but real circular dependencies on any one mutex will still be caught. A driver creating more than one device will still need to be careful!Quoted 8 lines
Quoted 3 lines
Reported-by Tobias Klausmann <[email protected]>Reported-by Hans de Goede <[email protected]>Signed-off-by Chris Wilson <[email protected]>Where does this even happen? i915, msm and udl are the only drivers left over that do
struct_mutex, and i915 can't really share buffers with msm, and udl doesn't do reservations. How exactly does this still go boom in latest upstream?
Quoted 4 lines
How about cc: stable?
The reports are nouveau vs i915. I was quite pleased with the
drm_driver_class!
Ah, you may have removed any direct calls to struct_mutex from nouveau, but it is still using struct_mutex around its GEM bo references.
git grep drm_gem_object_unreference_unlocked -- drivers/gpu/drm/nouveau/ | wc -l 13
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 23 lines · Chris Wilson
Quoted 22 lines · Chris Wilson
Quoted 10 lines · Daniel Vetter
Quoted 9 lines · Chris Wilson
With prime, we are running into false circular dependencies based on the order in which two drivers may lock their own
struct_mutexwrt to a common lock (like thereservation->lock). Work around this by adding thelock_class_keyto the structdrm_driversuch that each driver can have its own subclass ofstruct_mutex. Circular dependencies between drivers will now be ignored, but real circular dependencies on any one mutex will still be caught. A driver creating more than one device will still need to be careful!Quoted 8 lines
Quoted 3 lines
Reported-by Tobias Klausmann <[email protected]>Reported-by Hans de Goede <[email protected]>Signed-off-by Chris Wilson <[email protected]>Where does this even happen? i915, msm and udl are the only drivers left over that do
struct_mutex, and i915 can't really share buffers with msm, and udl doesn't do reservations. How exactly does this still go boom in latest upstream?How about cc: stable?
Quoted 8 lines
Quoted 2 lines
The reports are nouveau vs i915. I was quite pleased with the
drm_driver_class!Ah, you may have removed any direct calls to
struct_mutexfrom nouveau, but it is still usingstruct_mutexaround its GEM bo references.git grep
drm_gem_object_unreference_unlocked--drivers/gpu/drm/nouveau/| wc -l 13
Either s/drm_gem_object_unreference_unlocked/__drm_gem_object_unreference/
Or
drivers/gpu/drm/drm_gem.c +6 -4
@@ -826,11 +826,13 @@ drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)return ; dev = obj->dev; -might_lock (&dev->struct_mutex); - -if (dev->driver->gem_free_object_unlocked) +if (dev->driver->gem_free_object_unlocked) {kref_put (&obj->refcount, drm_gem_object_free); -else if (kref_put_mutex (&obj->refcount, drm_gem_object_free, +return ; + } + +might_lock (&dev->struct_mutex); +if (kref_put_mutex (&obj->refcount, drm_gem_object_free, &dev->struct_mutex))mutex_unlock (&dev->struct_mutex); }
That's a false might_lock() that really should be pushed to kref_put_mutex() -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 60 lines · Chris Wilson
Quoted 23 lines · Chris Wilson
Quoted 22 lines · Chris Wilson
Quoted 10 lines · Daniel Vetter
Quoted 9 lines · Chris Wilson
With prime, we are running into false circular dependencies based on the order in which two drivers may lock their own
struct_mutexwrt to a common lock (like thereservation->lock). Work around this by adding thelock_class_keyto the structdrm_driversuch that each driver can have its own subclass ofstruct_mutex. Circular dependencies between drivers will now be ignored, but real circular dependencies on any one mutex will still be caught. A driver creating more than one device will still need to be careful!Quoted 8 lines
Quoted 3 lines
Reported-by Tobias Klausmann <[email protected]>Reported-by Hans de Goede <[email protected]>Signed-off-by Chris Wilson <[email protected]>Where does this even happen? i915, msm and udl are the only drivers left over that do
struct_mutex, and i915 can't really share buffers with msm, and udl doesn't do reservations. How exactly does this still go boom in latest upstream?How about cc: stable?
Quoted 8 lines
Quoted 2 lines
The reports are nouveau vs i915. I was quite pleased with the
drm_driver_class!Ah, you may have removed any direct calls to
struct_mutexfrom nouveau, but it is still usingstruct_mutexaround its GEM bo references.git grep
drm_gem_object_unreference_unlocked--drivers/gpu/drm/nouveau/| wc -l 13Either s/drm_gem_object_unreference_unlocked/__drm_gem_object_unreference/
Or
drivers/gpu/drm/drm_gem.c +6
-4@@ -826,11 +826,13 @@ drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)return ; dev = obj->dev; -might_lock (&dev->struct_mutex); - -if (dev->driver->gem_free_object_unlocked) +if (dev->driver->gem_free_object_unlocked) {kref_put (&obj->refcount, drm_gem_object_free); -else if (kref_put_mutex (&obj->refcount, drm_gem_object_free, +return ; + } + +might_lock (&dev->struct_mutex); +if (kref_put_mutex (&obj->refcount, drm_gem_object_free, &dev->struct_mutex))mutex_unlock (&dev->struct_mutex); }
Quoted 1 line
That's a false
might_lock()that really should be pushed tokref_put_mutex()
My thinking behind adding that might_lock was to make sure core code is still save for drivers which rely upon the struct mutex, by essentially enlisting _all_ drivers to validate this. Given that struct_mutex is indeed on its demise, or at least gem_free_object_unlocked is popular enough maybe time to change that? I.e. I like your diff here ;-)
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx