diff mbox series

[v2,04/17] drm/v3d: Simplify job refcount handling

Message ID 20231124012548.772095-5-mcanal@igalia.com (mailing list archive)
State New, archived
Headers show
Series drm/v3d: Introduce CPU jobs | expand

Commit Message

Maíra Canal Nov. 24, 2023, 12:47 a.m. UTC
From: Melissa Wen <mwen@igalia.com>

Instead of checking if the job is NULL every time we call the function,
check it inside the function.

Signed-off-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Maíra Canal <mcanal@igalia.com>
---
 drivers/gpu/drm/v3d/v3d_submit.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Comments

Iago Toral Nov. 27, 2023, 7:57 a.m. UTC | #1
El jue, 23-11-2023 a las 21:47 -0300, Maíra Canal escribió:
> From: Melissa Wen <mwen@igalia.com>
> 
> Instead of checking if the job is NULL every time we call the
> function,
> check it inside the function.
> 
> Signed-off-by: Melissa Wen <mwen@igalia.com>
> Signed-off-by: Maíra Canal <mcanal@igalia.com>
> ---
>  drivers/gpu/drm/v3d/v3d_submit.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/v3d/v3d_submit.c
> b/drivers/gpu/drm/v3d/v3d_submit.c
> index f36214002f37..e18e7c963884 100644
> --- a/drivers/gpu/drm/v3d/v3d_submit.c
> +++ b/drivers/gpu/drm/v3d/v3d_submit.c
> @@ -129,6 +129,9 @@ void v3d_job_cleanup(struct v3d_job *job)
>  
>  void v3d_job_put(struct v3d_job *job)
>  {
> +       if (!job)
> +               return;
> +
>         kref_put(&job->refcount, job->free);
>  }
>  
> @@ -517,11 +520,9 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void
> *data,
>                                                  &se,
>                                                  last_job-
> >done_fence);
>  
> -       if (bin)
> -               v3d_job_put(&bin->base);
> -       v3d_job_put(&render->base);
> -       if (clean_job)
> -               v3d_job_put(clean_job);
> +       v3d_job_put((void *)bin);
> +       v3d_job_put((void *)render);
> +       v3d_job_put((void *)clean_job);

Personally, I am not a big fan of casting to void* instead of using
&job->base for all the v3d_job_put calls in this patch.

Iago

>  
>         return 0;
>  
> @@ -621,7 +622,7 @@ v3d_submit_tfu_ioctl(struct drm_device *dev, void
> *data,
>                                                  &se,
>                                                  job-
> >base.done_fence);
>  
> -       v3d_job_put(&job->base);
> +       v3d_job_put((void *)job);
>  
>         return 0;
>  
> @@ -725,7 +726,7 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void
> *data,
>                                                  &se,
>                                                  clean_job-
> >done_fence);
>  
> -       v3d_job_put(&job->base);
> +       v3d_job_put((void *)job);
>         v3d_job_put(clean_job);
>  
>         return 0;
diff mbox series

Patch

diff --git a/drivers/gpu/drm/v3d/v3d_submit.c b/drivers/gpu/drm/v3d/v3d_submit.c
index f36214002f37..e18e7c963884 100644
--- a/drivers/gpu/drm/v3d/v3d_submit.c
+++ b/drivers/gpu/drm/v3d/v3d_submit.c
@@ -129,6 +129,9 @@  void v3d_job_cleanup(struct v3d_job *job)
 
 void v3d_job_put(struct v3d_job *job)
 {
+	if (!job)
+		return;
+
 	kref_put(&job->refcount, job->free);
 }
 
@@ -517,11 +520,9 @@  v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
 						 &se,
 						 last_job->done_fence);
 
-	if (bin)
-		v3d_job_put(&bin->base);
-	v3d_job_put(&render->base);
-	if (clean_job)
-		v3d_job_put(clean_job);
+	v3d_job_put((void *)bin);
+	v3d_job_put((void *)render);
+	v3d_job_put((void *)clean_job);
 
 	return 0;
 
@@ -621,7 +622,7 @@  v3d_submit_tfu_ioctl(struct drm_device *dev, void *data,
 						 &se,
 						 job->base.done_fence);
 
-	v3d_job_put(&job->base);
+	v3d_job_put((void *)job);
 
 	return 0;
 
@@ -725,7 +726,7 @@  v3d_submit_csd_ioctl(struct drm_device *dev, void *data,
 						 &se,
 						 clean_job->done_fence);
 
-	v3d_job_put(&job->base);
+	v3d_job_put((void *)job);
 	v3d_job_put(clean_job);
 
 	return 0;