]> git.baikalelectronics.ru Git - kernel.git/commit
drm/i915/gvt: Fix inconsistent locks holding sequence
authorChuanxiao Dong <chuanxiao.dong@intel.com>
Mon, 26 Jun 2017 07:20:50 +0000 (15:20 +0800)
committerZhenyu Wang <zhenyuw@linux.intel.com>
Mon, 26 Jun 2017 08:32:20 +0000 (16:32 +0800)
commitdfbc7ef9cfdfc03be7cf828e8dfe44f95d94d9eb
tree75df31481a6e25cbd00d89174bd42592e4a03478
parentb66f4137772ad303d695d7be1c99ddeafd17ec63
drm/i915/gvt: Fix inconsistent locks holding sequence

There are two kinds of locking sequence.

One is in the thread which is started by vfio ioctl to do
the iommu unmapping. The locking sequence is:
down_read(&group_lock) ----> mutex_lock(&cached_lock)

The other is in the vfio release thread which will unpin all
the cached pages. The lock sequence is:
mutex_lock(&cached_lock) ---> down_read(&group_lock)

And, the cache_lock is used to protect the rb tree of the cache
node and doing vfio unpin doesn't require this lock. Move the
vfio unpin out of the cache_lock protected region.

v2:
- use for style instead of do{}while(1). (Zhenyu)

Fixes: fd566f766c59 ("drm/i915/gvt: add KVMGT support")
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
Cc: stable@vger.kernel.org # v4.10+
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
drivers/gpu/drm/i915/gvt/kvmgt.c