Skip to contentSkip to conversation

drm/lima: add timeout to drm scheduler init

PATCH In review Erico Nunes 2 participants 2 messages May 20, 2019 – May 21, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/lima: add timeout to drm scheduler init

After "5918045c4ed4 drm/scheduler: rework job destruction", lima started to leak memory due to buffers not being destroyed after job execution in the drm scheduler.
This started happening because the drm scheduler only destroyed buffers after cancelling the job timeout handler, and for lima this handler was never started as lima specified a MAX_SCHEDULE_TIMEOUT timeout. Lima seems to run well in its current state with a real timeout, so to make it more aligned with the other drivers from now on, let's use a real default timeout.
This also fixes the observed memory leaks.
The 500ms value was chosen as it is the current value for all other embedded gpu drivers using drm sched.

---
 drivers/gpu/drm/lima/lima_drv.c   |  2 +-
 drivers/gpu/drm/lima/lima_sched.c | 11 ++++-------
 2 files changed, 5 insertions(+), 8 deletions(-)
drivers/gpu/drm/lima/lima_drv.c +1 -1
index f9a281a62083..b29c26cd13b2 100644
@@ -17,7 +17,7 @@
 
 int lima_sched_timeout_ms;
 
-MODULE_PARM_DESC(sched_timeout_ms, "task run timeout in ms (0 = no timeout (default))");
+MODULE_PARM_DESC(sched_timeout_ms, "task run timeout in ms");
 module_param_named(sched_timeout_ms, lima_sched_timeout_ms, int, 0444);
 
 static int lima_ioctl_get_param(struct drm_device *dev, void *data, struct drm_file *file)
drivers/gpu/drm/lima/lima_sched.c +4 -7
index 58a15479d175..4127cacac454 100644
@@ -329,19 +329,16 @@ static void lima_sched_error_work(struct work_struct *work)
 
 int lima_sched_pipe_init(struct lima_sched_pipe *pipe, const char *name)
 {
-	long timeout;
-
-	if (lima_sched_timeout_ms <= 0)
-		timeout = MAX_SCHEDULE_TIMEOUT;
-	else
-		timeout = msecs_to_jiffies(lima_sched_timeout_ms);
+	unsigned int timeout = lima_sched_timeout_ms > 0 ?
+			       lima_sched_timeout_ms : 500;
 
 	pipe->fence_context = dma_fence_context_alloc(1);
 	spin_lock_init(&pipe->fence_lock);
 
 	INIT_WORK(&pipe->error_work, lima_sched_error_work);
 
-	return drm_sched_init(&pipe->base, &lima_sched_ops, 1, 0, timeout, name);
+	return drm_sched_init(&pipe->base, &lima_sched_ops, 1, 0,
+			      msecs_to_jiffies(timeout), name);
 }
 
 void lima_sched_pipe_fini(struct lima_sched_pipe *pipe)
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer Reviewed-by on v1 1/1
#1 lore raw

Looks good for me, patch is:

I'll apply it to drm-misc-next.

Regards,
Qiang

Quoted 62 lines · Erico Nunes

After "5918045c4ed4 drm/scheduler: rework job destruction", lima started to leak memory due to buffers not being destroyed after job execution in the drm scheduler.
This started happening because the drm scheduler only destroyed buffers after cancelling the job timeout handler, and for lima this handler was never started as lima specified a MAX_SCHEDULE_TIMEOUT timeout. Lima seems to run well in its current state with a real timeout, so to make it more aligned with the other drivers from now on, let's use a real default timeout.
This also fixes the observed memory leaks.
The 500ms value was chosen as it is the current value for all other embedded gpu drivers using drm sched.

---
 drivers/gpu/drm/lima/lima_drv.c   |  2 +-
 drivers/gpu/drm/lima/lima_sched.c | 11 ++++-------
 2 files changed, 5 insertions(+), 8 deletions(-)
drivers/gpu/drm/lima/lima_drv.c +1 -1
index f9a281a62083..b29c26cd13b2 100644
@@ -17,7 +17,7 @@
 
 int lima_sched_timeout_ms;
 
-MODULE_PARM_DESC(sched_timeout_ms, "task run timeout in ms (0 = no timeout (default))");
+MODULE_PARM_DESC(sched_timeout_ms, "task run timeout in ms");
 module_param_named(sched_timeout_ms, lima_sched_timeout_ms, int, 0444);
 
 static int lima_ioctl_get_param(struct drm_device *dev, void *data, struct drm_file *file)
drivers/gpu/drm/lima/lima_sched.c +4 -8
index 58a15479d175..4127cacac454 100644
@@ -329,19 +329,16 @@ static void lima_sched_error_work(struct work_struct *work)
 
 int lima_sched_pipe_init(struct lima_sched_pipe *pipe, const char *name)
 {
-       long timeout;
-
-       if (lima_sched_timeout_ms <= 0)
-               timeout = MAX_SCHEDULE_TIMEOUT;
-       else
-               timeout = msecs_to_jiffies(lima_sched_timeout_ms);
+       unsigned int timeout = lima_sched_timeout_ms > 0 ?
+                              lima_sched_timeout_ms : 500;
 
        pipe->fence_context = dma_fence_context_alloc(1);
        spin_lock_init(&pipe->fence_lock);
 
        INIT_WORK(&pipe->error_work, lima_sched_error_work);
 
-       return drm_sched_init(&pipe->base, &lima_sched_ops, 1, 0, timeout, name);
+       return drm_sched_init(&pipe->base, &lima_sched_ops, 1, 0,
+                             msecs_to_jiffies(timeout), name);
 }
 
 void lima_sched_pipe_fini(struct lima_sched_pipe *pipe)
--
Quoted 2 lines

2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel