2022-02-28 20:02:31

by Melissa Wen

[permalink] [raw]
Subject: [PATCH] drm/v3d: centralize error handling when init scheduler fails

Remove redundant error message (since now it is very similar to what
we do in drm_sched_init) and centralize all error handling in a
unique place, as we follow the same steps in any case of failure.

Signed-off-by: Melissa Wen <[email protected]>
---
drivers/gpu/drm/v3d/v3d_sched.c | 40 +++++++++++----------------------
1 file changed, 13 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/v3d/v3d_sched.c b/drivers/gpu/drm/v3d/v3d_sched.c
index 39459ae96f30..06238e6d7f5c 100644
--- a/drivers/gpu/drm/v3d/v3d_sched.c
+++ b/drivers/gpu/drm/v3d/v3d_sched.c
@@ -392,34 +392,24 @@ v3d_sched_init(struct v3d_dev *v3d)
hw_jobs_limit, job_hang_limit,
msecs_to_jiffies(hang_limit_ms), NULL,
NULL, "v3d_bin", v3d->drm.dev);
- if (ret) {
- dev_err(v3d->drm.dev, "Failed to create bin scheduler: %d.", ret);
+ if (ret)
return ret;
- }

ret = drm_sched_init(&v3d->queue[V3D_RENDER].sched,
&v3d_render_sched_ops,
hw_jobs_limit, job_hang_limit,
msecs_to_jiffies(hang_limit_ms), NULL,
NULL, "v3d_render", v3d->drm.dev);
- if (ret) {
- dev_err(v3d->drm.dev, "Failed to create render scheduler: %d.",
- ret);
- v3d_sched_fini(v3d);
- return ret;
- }
+ if (ret)
+ goto fail;

ret = drm_sched_init(&v3d->queue[V3D_TFU].sched,
&v3d_tfu_sched_ops,
hw_jobs_limit, job_hang_limit,
msecs_to_jiffies(hang_limit_ms), NULL,
NULL, "v3d_tfu", v3d->drm.dev);
- if (ret) {
- dev_err(v3d->drm.dev, "Failed to create TFU scheduler: %d.",
- ret);
- v3d_sched_fini(v3d);
- return ret;
- }
+ if (ret)
+ goto fail;

if (v3d_has_csd(v3d)) {
ret = drm_sched_init(&v3d->queue[V3D_CSD].sched,
@@ -427,27 +417,23 @@ v3d_sched_init(struct v3d_dev *v3d)
hw_jobs_limit, job_hang_limit,
msecs_to_jiffies(hang_limit_ms), NULL,
NULL, "v3d_csd", v3d->drm.dev);
- if (ret) {
- dev_err(v3d->drm.dev, "Failed to create CSD scheduler: %d.",
- ret);
- v3d_sched_fini(v3d);
- return ret;
- }
+ if (ret)
+ goto fail;

ret = drm_sched_init(&v3d->queue[V3D_CACHE_CLEAN].sched,
&v3d_cache_clean_sched_ops,
hw_jobs_limit, job_hang_limit,
msecs_to_jiffies(hang_limit_ms), NULL,
NULL, "v3d_cache_clean", v3d->drm.dev);
- if (ret) {
- dev_err(v3d->drm.dev, "Failed to create CACHE_CLEAN scheduler: %d.",
- ret);
- v3d_sched_fini(v3d);
- return ret;
- }
+ if (ret)
+ goto fail;
}

return 0;
+
+fail:
+ v3d_sched_fini(v3d);
+ return ret;
}

void
--
2.34.1


2022-02-28 21:30:07

by Andrey Grodzovsky

[permalink] [raw]
Subject: Re: [PATCH] drm/v3d: centralize error handling when init scheduler fails

Acked-by: Andrey Grodzovsky <[email protected]>

Andrey

On 2022-02-28 13:16, Melissa Wen wrote:
> Remove redundant error message (since now it is very similar to what
> we do in drm_sched_init) and centralize all error handling in a
> unique place, as we follow the same steps in any case of failure.
>
> Signed-off-by: Melissa Wen <[email protected]>
> ---
> drivers/gpu/drm/v3d/v3d_sched.c | 40 +++++++++++----------------------
> 1 file changed, 13 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/gpu/drm/v3d/v3d_sched.c b/drivers/gpu/drm/v3d/v3d_sched.c
> index 39459ae96f30..06238e6d7f5c 100644
> --- a/drivers/gpu/drm/v3d/v3d_sched.c
> +++ b/drivers/gpu/drm/v3d/v3d_sched.c
> @@ -392,34 +392,24 @@ v3d_sched_init(struct v3d_dev *v3d)
> hw_jobs_limit, job_hang_limit,
> msecs_to_jiffies(hang_limit_ms), NULL,
> NULL, "v3d_bin", v3d->drm.dev);
> - if (ret) {
> - dev_err(v3d->drm.dev, "Failed to create bin scheduler: %d.", ret);
> + if (ret)
> return ret;
> - }
>
> ret = drm_sched_init(&v3d->queue[V3D_RENDER].sched,
> &v3d_render_sched_ops,
> hw_jobs_limit, job_hang_limit,
> msecs_to_jiffies(hang_limit_ms), NULL,
> NULL, "v3d_render", v3d->drm.dev);
> - if (ret) {
> - dev_err(v3d->drm.dev, "Failed to create render scheduler: %d.",
> - ret);
> - v3d_sched_fini(v3d);
> - return ret;
> - }
> + if (ret)
> + goto fail;
>
> ret = drm_sched_init(&v3d->queue[V3D_TFU].sched,
> &v3d_tfu_sched_ops,
> hw_jobs_limit, job_hang_limit,
> msecs_to_jiffies(hang_limit_ms), NULL,
> NULL, "v3d_tfu", v3d->drm.dev);
> - if (ret) {
> - dev_err(v3d->drm.dev, "Failed to create TFU scheduler: %d.",
> - ret);
> - v3d_sched_fini(v3d);
> - return ret;
> - }
> + if (ret)
> + goto fail;
>
> if (v3d_has_csd(v3d)) {
> ret = drm_sched_init(&v3d->queue[V3D_CSD].sched,
> @@ -427,27 +417,23 @@ v3d_sched_init(struct v3d_dev *v3d)
> hw_jobs_limit, job_hang_limit,
> msecs_to_jiffies(hang_limit_ms), NULL,
> NULL, "v3d_csd", v3d->drm.dev);
> - if (ret) {
> - dev_err(v3d->drm.dev, "Failed to create CSD scheduler: %d.",
> - ret);
> - v3d_sched_fini(v3d);
> - return ret;
> - }
> + if (ret)
> + goto fail;
>
> ret = drm_sched_init(&v3d->queue[V3D_CACHE_CLEAN].sched,
> &v3d_cache_clean_sched_ops,
> hw_jobs_limit, job_hang_limit,
> msecs_to_jiffies(hang_limit_ms), NULL,
> NULL, "v3d_cache_clean", v3d->drm.dev);
> - if (ret) {
> - dev_err(v3d->drm.dev, "Failed to create CACHE_CLEAN scheduler: %d.",
> - ret);
> - v3d_sched_fini(v3d);
> - return ret;
> - }
> + if (ret)
> + goto fail;
> }
>
> return 0;
> +
> +fail:
> + v3d_sched_fini(v3d);
> + return ret;
> }
>
> void

2022-03-02 10:26:38

by Melissa Wen

[permalink] [raw]
Subject: Re: [PATCH] drm/v3d: centralize error handling when init scheduler fails

On Mon, Feb 28, 2022 at 8:21 PM Andrey Grodzovsky
<[email protected]> wrote:
>
> Acked-by: Andrey Grodzovsky <[email protected]>
>
> Andrey
Thanks. Applied to drm-misc-next.

Melissa
>
> On 2022-02-28 13:16, Melissa Wen wrote:
> > Remove redundant error message (since now it is very similar to what
> > we do in drm_sched_init) and centralize all error handling in a
> > unique place, as we follow the same steps in any case of failure.
> >
> > Signed-off-by: Melissa Wen <[email protected]>
> > ---
> > drivers/gpu/drm/v3d/v3d_sched.c | 40 +++++++++++----------------------
> > 1 file changed, 13 insertions(+), 27 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/v3d/v3d_sched.c b/drivers/gpu/drm/v3d/v3d_sched.c
> > index 39459ae96f30..06238e6d7f5c 100644
> > --- a/drivers/gpu/drm/v3d/v3d_sched.c
> > +++ b/drivers/gpu/drm/v3d/v3d_sched.c
> > @@ -392,34 +392,24 @@ v3d_sched_init(struct v3d_dev *v3d)
> > hw_jobs_limit, job_hang_limit,
> > msecs_to_jiffies(hang_limit_ms), NULL,
> > NULL, "v3d_bin", v3d->drm.dev);
> > - if (ret) {
> > - dev_err(v3d->drm.dev, "Failed to create bin scheduler: %d.", ret);
> > + if (ret)
> > return ret;
> > - }
> >
> > ret = drm_sched_init(&v3d->queue[V3D_RENDER].sched,
> > &v3d_render_sched_ops,
> > hw_jobs_limit, job_hang_limit,
> > msecs_to_jiffies(hang_limit_ms), NULL,
> > NULL, "v3d_render", v3d->drm.dev);
> > - if (ret) {
> > - dev_err(v3d->drm.dev, "Failed to create render scheduler: %d.",
> > - ret);
> > - v3d_sched_fini(v3d);
> > - return ret;
> > - }
> > + if (ret)
> > + goto fail;
> >
> > ret = drm_sched_init(&v3d->queue[V3D_TFU].sched,
> > &v3d_tfu_sched_ops,
> > hw_jobs_limit, job_hang_limit,
> > msecs_to_jiffies(hang_limit_ms), NULL,
> > NULL, "v3d_tfu", v3d->drm.dev);
> > - if (ret) {
> > - dev_err(v3d->drm.dev, "Failed to create TFU scheduler: %d.",
> > - ret);
> > - v3d_sched_fini(v3d);
> > - return ret;
> > - }
> > + if (ret)
> > + goto fail;
> >
> > if (v3d_has_csd(v3d)) {
> > ret = drm_sched_init(&v3d->queue[V3D_CSD].sched,
> > @@ -427,27 +417,23 @@ v3d_sched_init(struct v3d_dev *v3d)
> > hw_jobs_limit, job_hang_limit,
> > msecs_to_jiffies(hang_limit_ms), NULL,
> > NULL, "v3d_csd", v3d->drm.dev);
> > - if (ret) {
> > - dev_err(v3d->drm.dev, "Failed to create CSD scheduler: %d.",
> > - ret);
> > - v3d_sched_fini(v3d);
> > - return ret;
> > - }
> > + if (ret)
> > + goto fail;
> >
> > ret = drm_sched_init(&v3d->queue[V3D_CACHE_CLEAN].sched,
> > &v3d_cache_clean_sched_ops,
> > hw_jobs_limit, job_hang_limit,
> > msecs_to_jiffies(hang_limit_ms), NULL,
> > NULL, "v3d_cache_clean", v3d->drm.dev);
> > - if (ret) {
> > - dev_err(v3d->drm.dev, "Failed to create CACHE_CLEAN scheduler: %d.",
> > - ret);
> > - v3d_sched_fini(v3d);
> > - return ret;
> > - }
> > + if (ret)
> > + goto fail;
> > }
> >
> > return 0;
> > +
> > +fail:
> > + v3d_sched_fini(v3d);
> > + return ret;
> > }
> >
> > void