[PATCH] drm/i915/gem: Clarify seemingly unaccounted obj refcount inc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a comment why there is a obj refcount inc before installing
the vm_ops for the mmap call. Also remove the invalid older comment
as drm API(drm_gem_prime_mmap()) will hold an obj reference before
calling this driver mmap callback so we can't have 0-refcnted
object here.

Cc: Matthew Auld <matthew.auld@xxxxxxxxx>
Cc: Andi Shyti <andi.shyti@xxxxxxxxxxxxxxx>
Signed-off-by: Nirmoy Das <nirmoy.das@xxxxxxxxx>
---
 drivers/gpu/drm/i915/gem/i915_gem_mman.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
index d3c1dee16af2..0bc8c3818443 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
@@ -952,9 +952,10 @@ int i915_gem_mmap(struct file *filp, struct vm_area_struct *vma)
 						  vma_pages(vma));
 	if (node && drm_vma_node_is_allowed(node, priv)) {
 		/*
-		 * Skip 0-refcnted objects as it is in the process of being
-		 * destroyed and will be invalid when the vma manager lock
-		 * is released.
+		 * When we install vm_ops for mmap we are too late for
+		 * the vm_ops->open() which increases the ref_count of
+		 * this obj and then it gets decreased by the vm_ops->close().
+		 * To balance this increase the obj ref_count here.
 		 */
 		if (!node->driver_private) {
 			mmo = container_of(node, struct i915_mmap_offset, vma_node);
-- 
2.39.0




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux