Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 358346
b: refs/heads/master
c: 5af9f11
h: refs/heads/master
v: v3
  • Loading branch information
YoungJun Cho authored and Inki Dae committed Feb 21, 2013
1 parent 13df947 commit 489335f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e44a5c00169df634c152bdba65c7b735eb3a7a81
refs/heads/master: 5af9f116e6a0e1de675da979a19f95a74ce2aa2e
33 changes: 21 additions & 12 deletions trunk/drivers/gpu/drm/exynos/exynos_drm_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,17 +329,11 @@ static struct drm_file *exynos_drm_find_drm_file(struct drm_device *drm_dev,
{
struct drm_file *file_priv;

mutex_lock(&drm_dev->struct_mutex);

/* find current process's drm_file from filelist. */
list_for_each_entry(file_priv, &drm_dev->filelist, lhead) {
if (file_priv->filp == filp) {
mutex_unlock(&drm_dev->struct_mutex);
list_for_each_entry(file_priv, &drm_dev->filelist, lhead)
if (file_priv->filp == filp)
return file_priv;
}
}

mutex_unlock(&drm_dev->struct_mutex);
WARN_ON(1);

return ERR_PTR(-EFAULT);
Expand Down Expand Up @@ -400,9 +394,7 @@ static int exynos_drm_gem_mmap_buffer(struct file *filp,
*/
drm_gem_object_reference(obj);

mutex_lock(&drm_dev->struct_mutex);
drm_vm_open_locked(drm_dev, vma);
mutex_unlock(&drm_dev->struct_mutex);

return 0;
}
Expand Down Expand Up @@ -431,6 +423,16 @@ int exynos_drm_gem_mmap_ioctl(struct drm_device *dev, void *data,
return -EINVAL;
}

/*
* We have to use gem object and its fops for specific mmaper,
* but vm_mmap() can deliver only filp. So we have to change
* filp->f_op and filp->private_data temporarily, then restore
* again. So it is important to keep lock until restoration the
* settings to prevent others from misuse of filp->f_op or
* filp->private_data.
*/
mutex_lock(&dev->struct_mutex);

/*
* Set specific mmper's fops. And it will be restored by
* exynos_drm_gem_mmap_buffer to dev->driver->fops.
Expand All @@ -448,13 +450,20 @@ int exynos_drm_gem_mmap_ioctl(struct drm_device *dev, void *data,
addr = vm_mmap(file_priv->filp, 0, args->size,
PROT_READ | PROT_WRITE, MAP_SHARED, 0);

drm_gem_object_unreference_unlocked(obj);
drm_gem_object_unreference(obj);

if (IS_ERR((void *)addr)) {
file_priv->filp->private_data = file_priv;
/* check filp->f_op, filp->private_data are restored */
if (file_priv->filp->f_op == &exynos_drm_gem_fops) {
file_priv->filp->f_op = fops_get(dev->driver->fops);
file_priv->filp->private_data = file_priv;
}
mutex_unlock(&dev->struct_mutex);
return PTR_ERR((void *)addr);
}

mutex_unlock(&dev->struct_mutex);

args->mapped = addr;

DRM_DEBUG_KMS("mapped = 0x%lx\n", (unsigned long)args->mapped);
Expand Down

0 comments on commit 489335f

Please sign in to comment.