Hi Andi,

On 3/13/2023 7:37 PM, Andi Shyti wrote:
Hi Nirmoy,

[...]

+int i915_gem_fb_mmap(struct drm_i915_gem_object *obj, struct vm_area_struct 
*vma)
+{
+       struct drm_i915_private *i915 = to_i915(obj->base.dev);
+       struct drm_device *dev = &i915->drm;
+       struct i915_mmap_offset *mmo = NULL;
+       enum i915_mmap_type mmap_type;
+       struct i915_ggtt *ggtt = to_gt(i915)->ggtt;
+
+       if (drm_dev_is_unplugged(dev))
+               return -ENODEV;
+
+       mmap_type = i915_ggtt_has_aperture(ggtt) ? I915_MMAP_TYPE_GTT : 
I915_MMAP_TYPE_WC;
+       mmo = mmap_offset_attach(obj, mmap_type, NULL);
+       if (!mmo)
+               return -ENODEV;
+
+       obj = i915_gem_object_get(mmo->obj);
Where do we decrease the refcount?


This actually needs some comment even for the existing code.


We install vm_ops for the mmap which comes with vm_ops_cpu.open() and vm_ops_cpu.close()

where we do i915_gem_object_get()  on open and i915_gem_object_put() on close.

static const struct vm_operations_struct vm_ops_cpu = {
        .fault = vm_fault_cpu,
        .access = vm_access,
        .open = vm_open,
        .close = vm_close,
};

But when we install the vm_ops we are too late for vm_ops_cpu.open() so to account for the missing we are doing a i915_gem_object_get()  in mmap call.


Regards,

Nirmoy


Andi

+       return i915_gem_object_mmap(obj, mmo, vma);
+}
+

Reply via email to