Message ID | 1543485920-28037-1-git-send-email-smasetty@codeaurora.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] drm/scheduler: Set sched->thread to NULL on failure | expand |
Am 29.11.18 um 11:05 schrieb Sharat Masetty: > In cases where the scheduler instance is used as a base object of another > driver object, it's not clear if the driver can call scheduler cleanup on the > fail path. So, Set the sched->thread to NULL, so that the driver can safely > call drm_sched_fini() during cleanup. > > Signed-off-by: Sharat Masetty <smasetty@codeaurora.org> Reviewed-by: Christian König <christian.koenig@amd.com> > --- > drivers/gpu/drm/scheduler/sched_main.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c > index 44fe587..c993d10 100644 > --- a/drivers/gpu/drm/scheduler/sched_main.c > +++ b/drivers/gpu/drm/scheduler/sched_main.c > @@ -594,7 +594,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched, > long timeout, > const char *name) > { > - int i; > + int i, ret; > sched->ops = ops; > sched->hw_submission_limit = hw_submission; > sched->name = name; > @@ -615,8 +615,10 @@ int drm_sched_init(struct drm_gpu_scheduler *sched, > /* Each scheduler will run on a seperate kernel thread */ > sched->thread = kthread_run(drm_sched_main, sched, sched->name); > if (IS_ERR(sched->thread)) { > + ret = PTR_ERR(sched->thread); > + sched->thread = NULL; > DRM_ERROR("Failed to create scheduler for %s.\n", name); > - return PTR_ERR(sched->thread); > + return ret; > } > > return 0;
diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index 44fe587..c993d10 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -594,7 +594,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched, long timeout, const char *name) { - int i; + int i, ret; sched->ops = ops; sched->hw_submission_limit = hw_submission; sched->name = name; @@ -615,8 +615,10 @@ int drm_sched_init(struct drm_gpu_scheduler *sched, /* Each scheduler will run on a seperate kernel thread */ sched->thread = kthread_run(drm_sched_main, sched, sched->name); if (IS_ERR(sched->thread)) { + ret = PTR_ERR(sched->thread); + sched->thread = NULL; DRM_ERROR("Failed to create scheduler for %s.\n", name); - return PTR_ERR(sched->thread); + return ret; } return 0;
In cases where the scheduler instance is used as a base object of another driver object, it's not clear if the driver can call scheduler cleanup on the fail path. So, Set the sched->thread to NULL, so that the driver can safely call drm_sched_fini() during cleanup. Signed-off-by: Sharat Masetty <smasetty@codeaurora.org> --- drivers/gpu/drm/scheduler/sched_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)