[PATCH v2 1/2] drm/i915/gvt: Fix possible recursive locking issue

Zhenyu Wang zhenyuw at linux.intel.com
Fri Jun 23 03:31:53 UTC 2017


On 2017.06.21 10:29:57 +0800, Chuanxiao Dong wrote:
> @@ -197,26 +199,52 @@ static void __gvt_cache_remove_entry(struct intel_vgpu *vgpu,
>  	kfree(entry);
>  }
>  
> -static void gvt_cache_remove(struct intel_vgpu *vgpu, gfn_t gfn)
> +static void intel_vgpu_unpin_work(struct work_struct *work)
>  {
> +	struct intel_vgpu *vgpu = container_of(work, struct intel_vgpu,
> +					       vdev.unpin_work);
>  	struct device *dev = mdev_dev(vgpu->vdev.mdev);
>  	struct gvt_dma *this;
> -	unsigned long g1;
> -	int rc;
> +	unsigned long gfn;
> +
> +	for (;;) {
> +		spin_lock(&vgpu->vdev.unpin_lock);
> +		if (list_empty(&vgpu->vdev.unpin_list)) {
> +			spin_unlock(&vgpu->vdev.unpin_lock);
> +			break;
> +		}
> +		this = list_first_entry(&vgpu->vdev.unpin_list,
> +					struct gvt_dma, list);
> +		list_del(&this->list);
> +		spin_unlock(&vgpu->vdev.unpin_lock);
> +
> +		gfn = this->gfn;
> +		vfio_unpin_pages(dev, &gfn, 1);
> +		kfree(this);
> +	}

Just list_for_each_entry_safe()?

> +}
> +
> +static bool gvt_cache_mark(struct intel_vgpu *vgpu, gfn_t gfn)
> +{

gvt_cache_mark_remove(...)


-- 
Open Source Technology Center, Intel ltd.

$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/intel-gvt-dev/attachments/20170623/e0f99d0e/attachment.sig>


More information about the intel-gvt-dev mailing list