aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorRob Clark <rob@ti.com>2012-05-01 12:04:51 -0400
committerDave Airlie <airlied@redhat.com>2012-05-11 12:37:46 -0400
commitb06d66be3b0b198ee30bd9f779874ae7115570a0 (patch)
treea50e0dcb547b45f2ca3c6ff0a298bfe4b73b298f /drivers/gpu
parent62363a486019b57be1b286f5235bc0d637aa1dda (diff)
drm: pass dev to drm_vm_{open,close}_locked()
Previously these functions would assume that vma->vm_file was the drm_file. Although if in some cases if the drm driver needs to use something else for the backing file (such as the tmpfs filp) then this assumption is no longer true. But vma->vm_private_data is still the GEM object. With this change, now the drm_device comes from the GEM object rather than the drm_file so the driver is more free to play with vma->vm_file. The scenario where this comes up is for mmap'ing of cached dmabuf's for non-coherent systems, where the driver needs to use fault handling and PTE shootdown to simulate coherency. We can't use the vma->vm_file of the dmabuf, which is using anon_inode's address_space. The most straightforward thing to do is to use the GEM object's obj->filp for vma->vm_file in all cases, for which we need this patch. Signed-off-by: Rob Clark <rob@ti.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/drm_gem.c6
-rw-r--r--drivers/gpu/drm/drm_vm.c18
2 files changed, 11 insertions, 13 deletions
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index fc6ded8f318b..1ab29a7345c5 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -626,7 +626,7 @@ void drm_gem_vm_open(struct vm_area_struct *vma)
626 drm_gem_object_reference(obj); 626 drm_gem_object_reference(obj);
627 627
628 mutex_lock(&obj->dev->struct_mutex); 628 mutex_lock(&obj->dev->struct_mutex);
629 drm_vm_open_locked(vma); 629 drm_vm_open_locked(obj->dev, vma);
630 mutex_unlock(&obj->dev->struct_mutex); 630 mutex_unlock(&obj->dev->struct_mutex);
631} 631}
632EXPORT_SYMBOL(drm_gem_vm_open); 632EXPORT_SYMBOL(drm_gem_vm_open);
@@ -637,7 +637,7 @@ void drm_gem_vm_close(struct vm_area_struct *vma)
637 struct drm_device *dev = obj->dev; 637 struct drm_device *dev = obj->dev;
638 638
639 mutex_lock(&dev->struct_mutex); 639 mutex_lock(&dev->struct_mutex);
640 drm_vm_close_locked(vma); 640 drm_vm_close_locked(obj->dev, vma);
641 drm_gem_object_unreference(obj); 641 drm_gem_object_unreference(obj);
642 mutex_unlock(&dev->struct_mutex); 642 mutex_unlock(&dev->struct_mutex);
643} 643}
@@ -710,7 +710,7 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
710 */ 710 */
711 drm_gem_object_reference(obj); 711 drm_gem_object_reference(obj);
712 712
713 drm_vm_open_locked(vma); 713 drm_vm_open_locked(dev, vma);
714 714
715out_unlock: 715out_unlock:
716 mutex_unlock(&dev->struct_mutex); 716 mutex_unlock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index 149561818349..961ee08927fe 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -406,10 +406,9 @@ static const struct vm_operations_struct drm_vm_sg_ops = {
406 * Create a new drm_vma_entry structure as the \p vma private data entry and 406 * Create a new drm_vma_entry structure as the \p vma private data entry and
407 * add it to drm_device::vmalist. 407 * add it to drm_device::vmalist.
408 */ 408 */
409void drm_vm_open_locked(struct vm_area_struct *vma) 409void drm_vm_open_locked(struct drm_device *dev,
410 struct vm_area_struct *vma)
410{ 411{
411 struct drm_file *priv = vma->vm_file->private_data;
412 struct drm_device *dev = priv->minor->dev;
413 struct drm_vma_entry *vma_entry; 412 struct drm_vma_entry *vma_entry;
414 413
415 DRM_DEBUG("0x%08lx,0x%08lx\n", 414 DRM_DEBUG("0x%08lx,0x%08lx\n",
@@ -430,14 +429,13 @@ static void drm_vm_open(struct vm_area_struct *vma)
430 struct drm_device *dev = priv->minor->dev; 429 struct drm_device *dev = priv->minor->dev;
431 430
432 mutex_lock(&dev->struct_mutex); 431 mutex_lock(&dev->struct_mutex);
433 drm_vm_open_locked(vma); 432 drm_vm_open_locked(dev, vma);
434 mutex_unlock(&dev->struct_mutex); 433 mutex_unlock(&dev->struct_mutex);
435} 434}
436 435
437void drm_vm_close_locked(struct vm_area_struct *vma) 436void drm_vm_close_locked(struct drm_device *dev,
437 struct vm_area_struct *vma)
438{ 438{
439 struct drm_file *priv = vma->vm_file->private_data;
440 struct drm_device *dev = priv->minor->dev;
441 struct drm_vma_entry *pt, *temp; 439 struct drm_vma_entry *pt, *temp;
442 440
443 DRM_DEBUG("0x%08lx,0x%08lx\n", 441 DRM_DEBUG("0x%08lx,0x%08lx\n",
@@ -467,7 +465,7 @@ static void drm_vm_close(struct vm_area_struct *vma)
467 struct drm_device *dev = priv->minor->dev; 465 struct drm_device *dev = priv->minor->dev;
468 466
469 mutex_lock(&dev->struct_mutex); 467 mutex_lock(&dev->struct_mutex);
470 drm_vm_close_locked(vma); 468 drm_vm_close_locked(dev, vma);
471 mutex_unlock(&dev->struct_mutex); 469 mutex_unlock(&dev->struct_mutex);
472} 470}
473 471
@@ -519,7 +517,7 @@ static int drm_mmap_dma(struct file *filp, struct vm_area_struct *vma)
519 vma->vm_flags |= VM_RESERVED; /* Don't swap */ 517 vma->vm_flags |= VM_RESERVED; /* Don't swap */
520 vma->vm_flags |= VM_DONTEXPAND; 518 vma->vm_flags |= VM_DONTEXPAND;
521 519
522 drm_vm_open_locked(vma); 520 drm_vm_open_locked(dev, vma);
523 return 0; 521 return 0;
524} 522}
525 523
@@ -670,7 +668,7 @@ int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
670 vma->vm_flags |= VM_RESERVED; /* Don't swap */ 668 vma->vm_flags |= VM_RESERVED; /* Don't swap */
671 vma->vm_flags |= VM_DONTEXPAND; 669 vma->vm_flags |= VM_DONTEXPAND;
672 670
673 drm_vm_open_locked(vma); 671 drm_vm_open_locked(dev, vma);
674 return 0; 672 return 0;
675} 673}
676 674