Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c30fdd75 authored by Lloyd Atkinson's avatar Lloyd Atkinson
Browse files

drm/msm: hold struct_mutex during gem import



Take the struct mutex during msm_gem_import before calling
msm_gem_new_impl which expects to be called with the struct
mutex held. The mutex is required to protect the device private
inactive_list, and other paths that modify the list hold the
mutex.

Change-Id: If951b689f4899ece5239d1c6c559e20d149a6e2c
Signed-off-by: default avatarLloyd Atkinson <latkinso@codeaurora.org>
parent 84a47e8c
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -913,6 +913,8 @@ static int msm_gem_new_impl(struct drm_device *dev,
		return -EINVAL;
	}

	WARN_ON(!mutex_is_locked(&dev->struct_mutex));

	if (!iommu_present(&platform_bus_type))
		use_vram = true;
	else if ((flags & MSM_BO_STOLEN) && priv->vram.size)
@@ -987,7 +989,7 @@ struct drm_gem_object *msm_gem_import(struct drm_device *dev,
		struct dma_buf *dmabuf, struct sg_table *sgt)
{
	struct msm_gem_object *msm_obj;
	struct drm_gem_object *obj;
	struct drm_gem_object *obj = NULL;
	uint32_t size;
	int ret, npages;

@@ -999,7 +1001,12 @@ struct drm_gem_object *msm_gem_import(struct drm_device *dev,

	size = PAGE_ALIGN(dmabuf->size);

	ret = mutex_lock_interruptible(&dev->struct_mutex);
	if (ret)
		return ERR_PTR(ret);

	ret = msm_gem_new_impl(dev, size, MSM_BO_WC, dmabuf->resv, &obj);
	mutex_unlock(&dev->struct_mutex);
	if (ret)
		goto fail;