Skip to contentSkip to conversation

drm/v3d: wait for all jobs to finish before unregistering

PATCH In review Maíra Canal 2 participants 6 messages Oct 23, 2023 – Oct 30, 2023

Subsystems (3)
lore
Share & tools
lore

Maíra Canal

author maintainer
#0 lore raw

PATCH 1/2 drm/v3d: wait for all jobs to finish before unregistering

Currently, we are only warning the user if the BIN or RENDER jobs don't finish before we unregister V3D. We must wait for all jobs to finish before unregistering. Therefore, warn the user if TFU or CSD jobs are not done by the time the driver is unregistered.

---
 drivers/gpu/drm/v3d/v3d_gem.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/v3d/v3d_gem.c +2 -0
index 2e94ce788c71..afa7d170d1ff 100644
@@ -1072,6 +1072,8 @@ v3d_gem_destroy(struct drm_device *dev)
 	 */
 	WARN_ON(v3d->bin_job);
 	WARN_ON(v3d->render_job);
+	WARN_ON(v3d->tfu_job);
+	WARN_ON(v3d->csd_job);
 
 	drm_mm_takedown(&v3d->mm);
 
Signature · 1 line
2.41.0
author maintainer
#1 lore raw

PATCH 2/2 drm/v3d: assure that the job is NULL after being freed

After the job is finished and freed, we need to make sure that the job is NULL. Otherwise, we would get a warning when unloading the driver, as it would look like the job still exists. Therefore, after freeing the job, let's assign it to NULL in order to indicate that the job has finished.

---
 drivers/gpu/drm/v3d/v3d_gem.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/v3d/v3d_gem.c +1 -0
index afa7d170d1ff..61a7f36fc8e2 100644
@@ -333,6 +333,7 @@ v3d_job_free(struct kref *ref)
 		v3d_perfmon_put(job->perfmon);
 
 	kfree(job);
+	job = NULL;
 }
 
 static void

--
2.41.0

#2 lore raw
In reply to Maíra Canal
Quoted 17 lines · Maíra Canal

Currently, we are only warning the user if the BIN or RENDER jobs don't
finish before we unregister V3D. We must wait for all jobs to finish before unregistering. Therefore, warn the user if TFU or CSD jobs are not done by the time the driver is unregistered.

---
 drivers/gpu/drm/v3d/v3d_gem.c | 2 ++

 1 file changed, 2 insertions(+)
drivers/gpu/drm/v3d/v3d_gem.c +0 -0
index 2e94ce788c71..afa7d170d1ff 100644

drivers/gpu/drm/v3d/v3d_gem.c v3d_gem_destroy(struct drm_device *dev) · line 1076

Quoted 5 lines
drivers/gpu/drm/v3d/v3d_gem.c +2 -0
@@ -1072,6 +1072,8 @@ v3d_gem_destroy(struct drm_device *dev)
          */
         WARN_ON(v3d->bin_job);
         WARN_ON(v3d->render_job);
+       WARN_ON(v3d->tfu_job);
+       WARN_ON(v3d->csd_job);

I guess we should do this for cache clean jobs too, right?

Iago

Quoted 3 lines


        drm_mm_takedown(&v3d->mm);

author maintainer
#3 lore raw

Hi Iago,

Quoted 12 lines · Iago Toral
Quoted 11 lines · Maíra Canal

Currently, we are only warning the user if the BIN or RENDER jobs don't
finish before we unregister V3D. We must wait for all jobs to finish before unregistering. Therefore, warn the user if TFU or CSD jobs are not done by the time the driver is unregistered.

---
  drivers/gpu/drm/v3d/v3d_gem.c | 2 ++
  1 file changed, 2 insertions(+)
Quoted 13 lines

drivers/gpu/drm/v3d/v3d_gem.c v3d_gem_destroy(struct drm_device *dev) · line 1076

Quoted 11 lines
drivers/gpu/drm/v3d/v3d_gem.c +2 -0
index 2e94ce788c71..afa7d170d1ff 100644
@@ -1072,6 +1072,8 @@ v3d_gem_destroy(struct drm_device *dev)
          */
         WARN_ON(v3d->bin_job);
         WARN_ON(v3d->render_job);
+       WARN_ON(v3d->tfu_job);
+       WARN_ON(v3d->csd_job);

I guess we should do this for cache clean jobs too, right?

As the cache clean jobs are synchronous, we don't keep track of the current cache clean job. When I say that the cache clean jobs are synchronous, it means that the end of the job is not determined by an interruption. Therefore, there is no need to make sure that the cache clean jobs are still running.

Best Regards,
- Maíra

Quoted 7 lines

Iago

Quoted 3 lines
drivers/gpu/drm/v3d/v3d_gem.c +0 -0
         drm_mm_takedown(&v3d->mm);
 
Reviewed-by
#4 lore raw
Quoted 30 lines · Maira Canal

Hi Iago,

Quoted 13 lines · Iago Toral
Quoted 12 lines · Maíra Canal

Currently, we are only warning the user if the BIN or RENDER jobs don't
finish before we unregister V3D. We must wait for all jobs to finish
before unregistering. Therefore, warn the user if TFU or CSD jobs are not done by the time the driver is unregistered.

---
  drivers/gpu/drm/v3d/v3d_gem.c | 2 ++

  1 file changed, 2 insertions(+)
Quoted 13 lines

drivers/gpu/drm/v3d/v3d_gem.c v3d_gem_destroy(struct drm_device *dev) · line 1076

Quoted 11 lines
drivers/gpu/drm/v3d/v3d_gem.c +2 -0
index 2e94ce788c71..afa7d170d1ff 100644
@@ -1072,6 +1072,8 @@ v3d_gem_destroy(struct drm_device *dev)
           */
          WARN_ON(v3d->bin_job);
          WARN_ON(v3d->render_job);
+       WARN_ON(v3d->tfu_job);
+       WARN_ON(v3d->csd_job);

I guess we should do this for cache clean jobs too, right?

Quoted 5 lines

As the cache clean jobs are synchronous, we don't keep track of the current cache clean job. When I say that the cache clean jobs are synchronous, it means that the end of the job is not determined by an interruption. Therefore, there is no need to make sure that the cache clean jobs are still running.

I see, thanks Maíra.

Quoted 12 lines

Best Regards,
- Maíra

Quoted 7 lines

Iago

Quoted 3 lines


         drm_mm_takedown(&v3d->mm);

author maintainer Applied
#5 lore raw

Hi Iago,

Quoted 37 lines · Iago Toral
Quoted 30 lines · Maira Canal

Hi Iago,

Quoted 13 lines · Iago Toral
Quoted 12 lines · Maíra Canal

Currently, we are only warning the user if the BIN or RENDER jobs don't
finish before we unregister V3D. We must wait for all jobs to finish
before unregistering. Therefore, warn the user if TFU or CSD jobs are not done by the time the driver is unregistered.

---
   drivers/gpu/drm/v3d/v3d_gem.c | 2 ++
   1 file changed, 2 insertions(+)
Quoted 13 lines

drivers/gpu/drm/v3d/v3d_gem.c v3d_gem_destroy(struct drm_device *dev) · line 1076

Quoted 11 lines
drivers/gpu/drm/v3d/v3d_gem.c +2 -0
index 2e94ce788c71..afa7d170d1ff 100644
@@ -1072,6 +1072,8 @@ v3d_gem_destroy(struct drm_device *dev)
           */
          WARN_ON(v3d->bin_job);
          WARN_ON(v3d->render_job);
+       WARN_ON(v3d->tfu_job);
+       WARN_ON(v3d->csd_job);

I guess we should do this for cache clean jobs too, right?

Quoted 5 lines

As the cache clean jobs are synchronous, we don't keep track of the current cache clean job. When I say that the cache clean jobs are synchronous, it means that the end of the job is not determined by an interruption. Therefore, there is no need to make sure that the cache clean jobs are still running.

Quoted 3 lines

I see, thanks Maíra.

Applied to drm-misc/drm-misc-next!

Thanks,
- Maíra

Quoted 14 lines
Quoted 13 lines

Best Regards,
- Maíra

Quoted 7 lines

Iago

Quoted 3 lines
drivers/gpu/drm/v3d/v3d_gem.c +0 -0
          drm_mm_takedown(&v3d->mm);