[Intel-gfx] [PATCH v2 28/37] drm/i915: Allow i915 to manage the vma offset nodes instead of drm core
Chris Wilson
chris at chris-wilson.co.uk
Fri Jun 28 00:08:18 UTC 2019
Quoting Matthew Auld (2019-06-27 21:56:24)
> +int i915_gem_mmap(struct file *filp, struct vm_area_struct *vma)
> +{
> + struct drm_vma_offset_node *node;
> + struct drm_file *priv = filp->private_data;
> + struct drm_device *dev = priv->minor->dev;
> + struct i915_mmap_offset *mmo;
> + struct drm_gem_object *obj = NULL;
> +
> + if (drm_dev_is_unplugged(dev))
> + return -ENODEV;
> +
> + drm_vma_offset_lock_lookup(dev->vma_offset_manager);
> + node = drm_vma_offset_exact_lookup_locked(dev->vma_offset_manager,
> + vma->vm_pgoff,
> + vma_pages(vma));
> + if (likely(node)) {
> + mmo = container_of(node, struct i915_mmap_offset,
> + vma_node);
> +
> + /* Take a ref for our mmap_offset and gem objects. The reference is cleaned
/*
* Take
> + * up when the vma is closed.
> + *
> + * Skip 0-refcnted objects as it is in the process of being destroyed
> + * and will be invalid when the vma manager lock is released.
> + */
> + if (kref_get_unless_zero(&mmo->ref)) {
> + obj = &mmo->obj->base;
> + if (!kref_get_unless_zero(&obj->refcount))
> + obj = NULL;
> + }
> + }
> + drm_vma_offset_unlock_lookup(dev->vma_offset_manager);
> +
> + if (!obj)
> + return -EINVAL;
Please check the error paths for reference leaks.
-Chris
More information about the Intel-gfx
mailing list