drm/i915/gvt: fix deadlock in workload_thread
authorPei Zhang <pei.zhang@intel.com>
Mon, 14 Nov 2016 10:02:57 +0000 (18:02 +0800)
committerZhenyu Wang <zhenyuw@linux.intel.com>
Mon, 14 Nov 2016 10:02:57 +0000 (18:02 +0800)
commit90d27a1b180e51ef071350a302648b41fe884ff2
tree21fda0825a57bf2fbcb817422f4bdbc6a284d9e7
parent8be8f4a9a9ce48d545512ef7299da607401f3879
drm/i915/gvt: fix deadlock in workload_thread

It's a classical abba type deadlock when using 2 mutex objects, which
are gvt.lock(a) and drm.struct_mutex(b). Deadlock happens in threads:
1. intel_gvt_create/destroy_vgpu: P(a)->P(b)
2. workload_thread: P(b)->P(a)

Fix solution is align the lock acquire sequence in both threads. This
patch choose to adjust the sequence in workload_thread function.

This fixed lockup symptom for guest-reboot stress test.

v2: adjust sequence in workload_thread based on zhenyu's suggestion.
    adjust sequence in create/destroy_vgpu function.
v3: fix to still require struct_mutex for dispatch_workload()

Signed-off-by: Pei Zhang <pei.zhang@intel.com>
[zhenyuw: fix unused variables warnings.]
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
drivers/gpu/drm/i915/gvt/scheduler.c