Bug 83341

Summary: Failure to check return value leads to missed -EDEADLK and a kernel warning printout
Product: Drivers Reporter: Thomas Hellstrom (thellstrom)
Component: Video(DRI - non Intel)Assignee: drivers_video-dri
Status: NEW ---    
Severity: normal    
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.16 and above Subsystem:
Regression: No Bisected commit-id:

Description Thomas Hellstrom 2014-08-27 14:23:16 UTC
Please see 

https://bugzilla.redhat.com/show_bug.cgi?id=1114160

The error is in the following lines, where no error checking takes place on drm_modeset_lock().

	drm_modeset_lock_all(dev);
	drm_modeset_lock_init(&crtc->mutex);
	/* dropped by _unlock_all(): */
	drm_modeset_lock(&crtc->mutex, config->acquire_ctx);

This is probably under the assumption that the lock is just initialized and will therefore always succeed. However, the ww_mutex subsystem has a fault injection option and when that kicks in, that lock may fail.

Fixing this turns out to be a little involved. Personally I think a trylock() would be in order here, but that would mean extending the drm_modeset_lock() API.

The error message copied from Redhat Bugzilla:

[    5.082609] ------------[ cut here ]------------
[    5.083548] WARNING: CPU: 0 PID: 369 at drivers/gpu/drm/drm_modeset_lock.c:91 drm_modeset_drop_locks+0x71/0x80 [drm]()
[    5.084483] Modules linked in: vmwgfx(+) drm_kms_helper ttm drm mptspi scsi_transport_spi e1000 mptscsih mptbase i2c_core ata_generic pata_acpi
[    5.085536] CPU: 0 PID: 369 Comm: systemd-udevd Not tainted 3.16.0-0.rc2.git3.1.fc21.x86_64 #1
[    5.086689] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 07/31/2013
[    5.088693]  0000000000000000 0000000054dc8e0c ffff880036e27910 ffffffff81807c4c
[    5.090714]  0000000000000000 ffff880036e27948 ffffffff8109b3ed ffff880039073000
[    5.091584]  ffff8800391ee900 ffff8800391ee900 ffff88003890fe00 ffff880000400000
[    5.092662] Call Trace:
[    5.093311]  [<ffffffff81807c4c>] dump_stack+0x4d/0x66
[    5.093867]  [<ffffffff8109b3ed>] warn_slowpath_common+0x7d/0xa0
[    5.094562]  [<ffffffff8109b51a>] warn_slowpath_null+0x1a/0x20
[    5.095241]  [<ffffffffa00a8eb1>] drm_modeset_drop_locks+0x71/0x80 [drm]
[    5.095773]  [<ffffffffa009996e>] drm_modeset_unlock_all+0x2e/0x70 [drm]
[    5.096196]  [<ffffffffa009b557>] drm_crtc_init_with_planes+0xa7/0x110 [drm]
[    5.096659]  [<ffffffffa00d7343>] drm_crtc_init+0x33/0x40 [drm_kms_helper]
[    5.097050]  [<ffffffffa01135b9>] vmw_kms_init_screen_object_display+0x1a9/0x260 [vmwgfx]
[    5.098174]  [<ffffffffa0105b69>] vmw_kms_init+0x59/0x70 [vmwgfx]
[    5.098725]  [<ffffffffa0107dd0>] vmw_driver_load+0x8d0/0xda0 [vmwgfx]
[    5.099129]  [<ffffffffa009424d>] drm_dev_register+0xad/0x100 [drm]
[    5.099486]  [<ffffffffa009707d>] drm_get_pci_dev+0x8d/0x200 [drm]
[    5.099900]  [<ffffffffa0106b25>] vmw_probe+0x15/0x20 [vmwgfx]
[    5.100274]  [<ffffffff8142fee5>] local_pci_probe+0x45/0xa0
[    5.100626]  [<ffffffff814311c5>] ? pci_match_device+0xe5/0x110
[    5.100959]  [<ffffffff81431329>] pci_device_probe+0xf9/0x150
[    5.101286]  [<ffffffff8151fba3>] driver_probe_device+0xa3/0x400
[    5.101589]  [<ffffffff8151ffcb>] __driver_attach+0x8b/0x90
[    5.101934]  [<ffffffff8151ff40>] ? __device_attach+0x40/0x40
[    5.102242]  [<ffffffff8151d823>] bus_for_each_dev+0x73/0xc0
[    5.102545]  [<ffffffff8151f5fe>] driver_attach+0x1e/0x20
[    5.102808]  [<ffffffff8151f1c8>] bus_add_driver+0x188/0x260
[    5.103075]  [<ffffffff81520aa4>] driver_register+0x64/0xf0
[    5.103352]  [<ffffffff8142f790>] __pci_register_driver+0x60/0x70
[    5.103616]  [<ffffffffa00972fa>] drm_pci_init+0x10a/0x140 [drm]
[    5.103913]  [<ffffffffa012e000>] ? 0xffffffffa012dfff
[    5.104176]  [<ffffffffa012e018>] vmwgfx_init+0x18/0x1000 [vmwgfx]
[    5.104482]  [<ffffffff81002148>] do_one_initcall+0xd8/0x210
[    5.104745]  [<ffffffff81206e8a>] ? __vunmap+0xba/0x120
[    5.105015]  [<ffffffff8113aff0>] load_module+0x2110/0x2740
[    5.105275]  [<ffffffff81136260>] ? store_uevent+0x70/0x70
[    5.105551]  [<ffffffff810fc23f>] ? lock_release_holdtime.part.28+0xf/0x200
[    5.105951]  [<ffffffff811025e6>] ? lock_release_non_nested+0x3c6/0x3d0
[    5.106357]  [<ffffffff8113b707>] SyS_init_module+0xe7/0x140
[    5.106849]  [<ffffffff81811869>] system_call_fastpath+0x16/0x1b
[    5.107162] ---[ end trace 225f20829bb0d8e8 ]---