Re: [PATCH v3 07/28] drm/etnaviv: switch to drm_*_get(), drm_*_put() helpers
From: Lucas Stach
Date: Fri Aug 11 2017 - 10:43:17 EST
Am Freitag, den 11.08.2017, 15:32 +0300 schrieb Cihangir Akturk:
> Use drm_*_get() and drm_*_put() helpers instead of drm_*_reference()
> and drm_*_unreference() helpers.
>
> drm_*_reference() and drm_*_unreference() functions are just
> compatibility alias for drm_*_get() and drm_*_put() and should not be
> used by new code. So convert all users of compatibility functions to
> use the new APIs.
>
> Generated by: scripts/coccinelle/api/drm-get-put.cocci
>
> Signed-off-by: Cihangir Akturk <cakturk@xxxxxxxxx>
I have already applied v1 of this patch to the etnaviv tree.
Regards,
Lucas
> ---
> drivers/gpu/drm/etnaviv/etnaviv_drv.c | 8 ++++----
> drivers/gpu/drm/etnaviv/etnaviv_gem.c | 20 ++++++++++----------
> drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c | 2 +-
> drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 4 ++--
> 4 files changed, 17 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> index 91e17ae..2cb4773 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> @@ -316,7 +316,7 @@ static int etnaviv_ioctl_gem_cpu_prep(struct drm_device *dev, void *data,
>
> ret = etnaviv_gem_cpu_prep(obj, args->op, &TS(args->timeout));
>
> - drm_gem_object_unreference_unlocked(obj);
> + drm_gem_object_put_unlocked(obj);
>
> return ret;
> }
> @@ -337,7 +337,7 @@ static int etnaviv_ioctl_gem_cpu_fini(struct drm_device *dev, void *data,
>
> ret = etnaviv_gem_cpu_fini(obj);
>
> - drm_gem_object_unreference_unlocked(obj);
> + drm_gem_object_put_unlocked(obj);
>
> return ret;
> }
> @@ -357,7 +357,7 @@ static int etnaviv_ioctl_gem_info(struct drm_device *dev, void *data,
> return -ENOENT;
>
> ret = etnaviv_gem_mmap_offset(obj, &args->offset);
> - drm_gem_object_unreference_unlocked(obj);
> + drm_gem_object_put_unlocked(obj);
>
> return ret;
> }
> @@ -446,7 +446,7 @@ static int etnaviv_ioctl_gem_wait(struct drm_device *dev, void *data,
>
> ret = etnaviv_gem_wait_bo(gpu, obj, timeout);
>
> - drm_gem_object_unreference_unlocked(obj);
> + drm_gem_object_put_unlocked(obj);
>
> return ret;
> }
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> index 9a3bea7..e36fbb9 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> @@ -265,7 +265,7 @@ void etnaviv_gem_mapping_reference(struct etnaviv_vram_mapping *mapping)
> {
> struct etnaviv_gem_object *etnaviv_obj = mapping->object;
>
> - drm_gem_object_reference(&etnaviv_obj->base);
> + drm_gem_object_get(&etnaviv_obj->base);
>
> mutex_lock(&etnaviv_obj->lock);
> WARN_ON(mapping->use == 0);
> @@ -282,7 +282,7 @@ void etnaviv_gem_mapping_unreference(struct etnaviv_vram_mapping *mapping)
> mapping->use -= 1;
> mutex_unlock(&etnaviv_obj->lock);
>
> - drm_gem_object_unreference_unlocked(&etnaviv_obj->base);
> + drm_gem_object_put_unlocked(&etnaviv_obj->base);
> }
>
> struct etnaviv_vram_mapping *etnaviv_gem_mapping_get(
> @@ -358,7 +358,7 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get(
> return ERR_PTR(ret);
>
> /* Take a reference on the object */
> - drm_gem_object_reference(obj);
> + drm_gem_object_get(obj);
> return mapping;
> }
>
> @@ -671,7 +671,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev,
> return obj;
>
> fail:
> - drm_gem_object_unreference_unlocked(obj);
> + drm_gem_object_put_unlocked(obj);
> return ERR_PTR(ret);
> }
>
> @@ -688,14 +688,14 @@ int etnaviv_gem_new_handle(struct drm_device *dev, struct drm_file *file,
>
> ret = etnaviv_gem_obj_add(dev, obj);
> if (ret < 0) {
> - drm_gem_object_unreference_unlocked(obj);
> + drm_gem_object_put_unlocked(obj);
> return ret;
> }
>
> ret = drm_gem_handle_create(file, obj, handle);
>
> /* drop reference from allocate - handle holds it now */
> - drm_gem_object_unreference_unlocked(obj);
> + drm_gem_object_put_unlocked(obj);
>
> return ret;
> }
> @@ -712,7 +712,7 @@ struct drm_gem_object *etnaviv_gem_new(struct drm_device *dev,
>
> ret = etnaviv_gem_obj_add(dev, obj);
> if (ret < 0) {
> - drm_gem_object_unreference_unlocked(obj);
> + drm_gem_object_put_unlocked(obj);
> return ERR_PTR(ret);
> }
>
> @@ -800,7 +800,7 @@ static void __etnaviv_gem_userptr_get_pages(struct work_struct *_work)
> }
>
> mutex_unlock(&etnaviv_obj->lock);
> - drm_gem_object_unreference_unlocked(&etnaviv_obj->base);
> + drm_gem_object_put_unlocked(&etnaviv_obj->base);
>
> mmput(work->mm);
> put_task_struct(work->task);
> @@ -858,7 +858,7 @@ static int etnaviv_gem_userptr_get_pages(struct etnaviv_gem_object *etnaviv_obj)
> }
>
> get_task_struct(current);
> - drm_gem_object_reference(&etnaviv_obj->base);
> + drm_gem_object_get(&etnaviv_obj->base);
>
> work->mm = mm;
> work->task = current;
> @@ -924,6 +924,6 @@ int etnaviv_gem_new_userptr(struct drm_device *dev, struct drm_file *file,
> ret = drm_gem_handle_create(file, &etnaviv_obj->base, handle);
> unreference:
> /* drop reference from allocate - handle holds it now */
> - drm_gem_object_unreference_unlocked(&etnaviv_obj->base);
> + drm_gem_object_put_unlocked(&etnaviv_obj->base);
> return ret;
> }
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
> index e5da4f23..ae88472 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
> @@ -146,7 +146,7 @@ struct drm_gem_object *etnaviv_gem_prime_import_sg_table(struct drm_device *dev,
> return &etnaviv_obj->base;
>
> fail:
> - drm_gem_object_unreference_unlocked(&etnaviv_obj->base);
> + drm_gem_object_put_unlocked(&etnaviv_obj->base);
>
> return ERR_PTR(ret);
> }
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> index 5bd9316..d456a6b 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> @@ -88,7 +88,7 @@ static int submit_lookup_objects(struct etnaviv_gem_submit *submit,
> * Take a refcount on the object. The file table lock
> * prevents the object_idr's refcount on this being dropped.
> */
> - drm_gem_object_reference(obj);
> + drm_gem_object_get(obj);
>
> submit->bos[i].obj = to_etnaviv_bo(obj);
> }
> @@ -291,7 +291,7 @@ static void submit_cleanup(struct etnaviv_gem_submit *submit)
> struct etnaviv_gem_object *etnaviv_obj = submit->bos[i].obj;
>
> submit_unlock_object(submit, i);
> - drm_gem_object_unreference_unlocked(&etnaviv_obj->base);
> + drm_gem_object_put_unlocked(&etnaviv_obj->base);
> }
>
> ww_acquire_fini(&submit->ticket);