drm/msm: validate display and event threads
PATCH v3 1/1 drm/msm: validate display and event threads
While creating display and event threads per crtc, validate them before setting their priorities.
changes in v2:
- use dev_warn (Abhinav Kumar)
changes in v3:
- fix compilation error
--- drivers/gpu/drm/msm/msm_drv.c | 49 ++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 33 deletions(-)
drivers/gpu/drm/msm/msm_drv.c +16 -33
@@ -553,17 +553,18 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)kthread_run (kthread_worker_fn, &priv->disp_thread[i].worker,"crtc_commit:%d" , priv->disp_thread[i].crtc_id); - ret =sched_setscheduler (priv->disp_thread[i].thread, -SCHED_FIFO , ¶m); -if (ret) -pr_warn ("display thread priority update failed: %d\n" , - ret); -if (IS_ERR (priv->disp_thread[i].thread)) {dev_err (dev,"failed to create crtc_commit kthread\n" ); priv->disp_thread[i].thread =NULL ; + goto err_msm_uninit; } + ret =sched_setscheduler (priv->disp_thread[i].thread, +SCHED_FIFO , ¶m); +if (ret) +dev_warn (dev,"display thread priority update failed: %d\n" , + ret); +/* initialize event thread */ priv->event_thread[i].crtc_id = priv->crtcs[i]->base.id;kthread_init_worker (&priv->event_thread[i].worker);
@@ -572,6 +573,12 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)kthread_run (kthread_worker_fn, &priv->event_thread[i].worker,"crtc_event:%d" , priv->event_thread[i].crtc_id); +if (IS_ERR (priv->event_thread[i].thread)) { +dev_err (dev,"failed to create crtc_event kthread\n" ); + priv->event_thread[i].thread =NULL ; + goto err_msm_uninit; + } +/** * event thread should also run at same priority as disp_thread * because it is handling frame_done events. A lower priority
@@ -580,34 +587,10 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)* failure at crtc commit level. */ ret =sched_setscheduler (priv->event_thread[i].thread, -SCHED_FIFO , ¶m); +SCHED_FIFO , ¶m);if (ret) -pr_warn ("display event thread priority update failed: %d\n" , - ret); - -if (IS_ERR (priv->event_thread[i].thread)) { -dev_err (dev,"failed to create crtc_event kthread\n" ); - priv->event_thread[i].thread =NULL ; - } - -if ((!priv->disp_thread[i].thread) || - !priv->event_thread[i].thread) { -/* clean up previously created threads if any */ -for ( ; i >=0 ; i--) { -if (priv->disp_thread[i].thread) { -kthread_stop ( - priv->disp_thread[i].thread); - priv->disp_thread[i].thread =NULL ; - } - -if (priv->event_thread[i].thread) { -kthread_stop ( - priv->event_thread[i].thread); - priv->event_thread[i].thread =NULL ; - } - } - goto err_msm_uninit; - } +dev_warn (dev,"display event thread priority update failed:%d\n" , + ret); } ret =drm_vblank_init (ddev, priv->num_crtcs);
Signature · 7 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 9 lines · Jeykumar Sankaran
While creating display and event threads per crtc, validate them before setting their priorities.
changes in v2:
- usedev_warn(Abhinav Kumar)
changes in v3:
- fix compilation errorChange-Id: I1dda805286df981c0f0e2b26507d089d3a21ff6c
No Change-Id's please!
FWIW, checkpatch.pl would have caught this and the nits I found below. It might be worth running patches through it before sending.
Quoted 19 lines
Signed-off-by Jeykumar Sankaran <[email protected]>--- drivers/gpu/drm/msm/msm_drv.c | 49 ++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 33 deletions(-)drivers/gpu/drm/msm/msm_drv.c +0
-6@@ -553,17 +553,18 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)kthread_run (kthread_worker_fn, &priv->disp_thread[i].worker,"crtc_commit:%d" , priv->disp_thread[i].crtc_id); - ret =sched_setscheduler (priv->disp_thread[i].thread, -SCHED_FIFO , ¶m); -if (ret) -pr_warn ("display thread priority update failed: %d\n" , - ret); -
drivers/gpu/drm/msm/msm_drv.c static int msm_drm_init(struct device *dev, struct drm_driver *drv) · line 565
Quoted 10 lines
drivers/gpu/drm/msm/msm_drv.c +5
-0if (IS_ERR (priv->disp_thread[i].thread)) {dev_err (dev,"failed to create crtc_commit kthread\n" ); priv->disp_thread[i].thread =NULL ; + goto err_msm_uninit; } + ret =sched_setscheduler (priv->disp_thread[i].thread, +SCHED_FIFO , ¶m); +if (ret) + dev_warn(dev, "display thread priority update failed: %d\n",
Although this is wrapped, the line still exceeds 80 chars. Perhaps:
dev_warn(dev, "disp_thread set priority failed %d\n",
ret);
Quoted 42 lines
drivers/gpu/drm/msm/msm_drv.c +9
-18+ ret); +/* initialize event thread */ priv->event_thread[i].crtc_id = priv->crtcs[i]->base.id;kthread_init_worker (&priv->event_thread[i].worker);@@ -572,6 +573,12 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)kthread_run (kthread_worker_fn, &priv->event_thread[i].worker,"crtc_event:%d" , priv->event_thread[i].crtc_id); +if (IS_ERR (priv->event_thread[i].thread)) { +dev_err (dev,"failed to create crtc_event kthread\n" ); + priv->event_thread[i].thread =NULL ; + goto err_msm_uninit; + } +/** * event thread should also run at same priority as disp_thread * because it is handling frame_done events. A lower priority @@ -580,34 +587,10 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)* failure at crtc commit level. */ ret =sched_setscheduler (priv->event_thread[i].thread, -SCHED_FIFO , ¶m); +SCHED_FIFO , ¶m);if (ret) -pr_warn ("display event thread priority update failed: %d\n" , - ret); - -if (IS_ERR (priv->event_thread[i].thread)) { -dev_err (dev,"failed to create crtc_event kthread\n" ); - priv->event_thread[i].thread =NULL ; - } - -if ((!priv->disp_thread[i].thread) || - !priv->event_thread[i].thread) { -/* clean up previously created threads if any */ -for ( ; i >=0 ; i--) { -if (priv->disp_thread[i].thread) { -kthread_stop ( - priv->disp_thread[i].thread); - priv->disp_thread[i].thread =NULL ; - }
drivers/gpu/drm/msm/msm_drv.c static int msm_drm_init(struct device *dev, struct drm_driver *drv) · line 592
Quoted 10 lines
drivers/gpu/drm/msm/msm_drv.c +1
-9- -if (priv->event_thread[i].thread) { -kthread_stop ( - priv->event_thread[i].thread); - priv->event_thread[i].thread =NULL ; - } - } - goto err_msm_uninit; - } + dev_warn(dev, "display event thread priority update failed:%d\n",
Same problem here,
dev_warn(dev, "event thread set priority failed %d\n",
Quoted 8 lines
drivers/gpu/drm/msm/msm_drv.c +1
-0+ ret); } ret =drm_vblank_init (ddev, priv->num_crtcs);Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
Quoted 57 lines · Sean Paul
Quoted 9 lines · Jeykumar Sankaran
While creating display and event threads per crtc, validate them before setting their priorities.
changes in v2:
- usedev_warn(Abhinav Kumar)
changes in v3:
- fix compilation errorChange-Id: I1dda805286df981c0f0e2b26507d089d3a21ff6c
No Change-Id's please!
FWIW, checkpatch.pl would have caught this and the nits I found below. It might
be worth running patches through it before sending.Quoted 3 lines
Signed-off-by Jeykumar Sankaran <[email protected]>--- drivers/gpu/drm/msm/msm_drv.c | 49++++++++++++++-----------------------------
Review
Quoted 3 lines
1 file changed, 16 insertions(+), 33 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/msm/msm_drv.cQuoted 5 lines
index 4904d0d..ab1b0a9 100644
drivers/gpu/drm/msm/msm_drv.c +0
-0@@ -553,17 +553,18 @@ static int msm_drm_init(struct device *dev,struct
drm_driver*drv)drivers/gpu/drm/msm/msm_drv.c static int msm_drm_init(struct device *dev, struct drm_driver *drv)
Quoted 3 lines
drivers/gpu/drm/msm/msm_drv.c +0
-0kthread_run(kthread_worker_fn, &priv->disp_thread[i].worker, "crtc_commit:%d",priv->disp_thread[i].crtc_id);
drivers/gpu/drm/msm/msm_drv.c
Quoted 2 lines
drivers/gpu/drm/msm/msm_drv.c +0
-2- ret = sched_setscheduler(priv->disp_thread[i].thread, - SCHED_FIFO,¶m);
drivers/gpu/drm/msm/msm_drv.c
Quoted 2 lines
drivers/gpu/drm/msm/msm_drv.c +0
-2-if (ret) - pr_warn("display thread priority update failed:%d\n",
Quoted 1 line
-
ret);
drivers/gpu/drm/msm/msm_drv.c static int msm_drm_init(struct device *dev, struct drm_driver *drv)
Quoted 3 lines
drivers/gpu/drm/msm/msm_drv.c +0
-1-if (IS_ERR (priv->disp_thread[i].thread)) { dev_err(dev, "failed to create crtc_commitkthread\n");
drivers/gpu/drm/msm/msm_drv.c static int msm_drm_init(struct device *dev, struct drm_driver *drv)
Quoted 8 lines
drivers/gpu/drm/msm/msm_drv.c +5
-0priv->disp_thread[i].thread =NULL ; + goto err_msm_uninit; } + ret =sched_setscheduler (priv->disp_thread[i].thread, +SCHED_FIFO , ¶m); +if (ret) + dev_warn(dev, "display thread priority updatefailed: %d\n",
Quoted 6 lines
Although this is wrapped, the line still exceeds 80 chars. Perhaps:
dev_warn(dev, "
disp_threadset priority failed
%d\n",ret);
I did run the checkpath.pl on this patch. Check patch usually will not complain if the >80 exceeding line is the logging string.
https://01.org/linuxgraphics/gfx-docs/drm/process/coding-style.html#breaking-long-lines-and-strings
https://gitlab.freedesktop.org/seanpaul/dpu-staging/blob/for-next/scripts/checkpatch.pl#L3058
Anyway, rewording will be a good idea to avoid nits!
Quoted 84 lines
Quoted 7 lines
drivers/gpu/drm/msm/msm_drv.c +2
-0+ ret); +/* initialize event thread */ priv->event_thread[i].crtc_id = priv->crtcs[i]->base.id;kthread_init_worker (&priv->event_thread[i].worker);@@ -572,6 +573,12 @@ static int msm_drm_init(struct device *dev,struct
drm_driver*drv)drivers/gpu/drm/msm/msm_drv.c static int msm_drm_init(struct device *dev, struct drm_driver *drv)
Quoted 3 lines
drivers/gpu/drm/msm/msm_drv.c +0
-0kthread_run(kthread_worker_fn, &priv->event_thread[i].worker, "crtc_event:%d",priv->event_thread[i].crtc_id);
drivers/gpu/drm/msm/msm_drv.c
Quoted 2 lines
drivers/gpu/drm/msm/msm_drv.c +2
-0+if (IS_ERR (priv->event_thread[i].thread)) { + dev_err(dev, "failed to create crtc_eventkthread\n");
drivers/gpu/drm/msm/msm_drv.c static int msm_drm_init(struct device *dev, struct drm_driver *drv)
Quoted 6 lines
drivers/gpu/drm/msm/msm_drv.c +4
-0+ priv->event_thread[i].thread =NULL ; + goto err_msm_uninit; + } +/** * event thread should also run at same priority as
disp_threadQuoted 1 line
* because it is handling
frame_doneevents. A lowerpriority
Quoted 2 lines
drivers/gpu/drm/msm/msm_drv.c +0
-0@@ -580,34 +587,10 @@ static int msm_drm_init(struct device *dev,struct
drm_driver*drv)drivers/gpu/drm/msm/msm_drv.c static int msm_drm_init(struct device *dev, struct drm_driver *drv)
Quoted 4 lines
drivers/gpu/drm/msm/msm_drv.c +0
-1* failure at crtc commit level. */ ret = sched_setscheduler(priv->event_thread[i].thread, - SCHED_FIFO,¶m);
drivers/gpu/drm/msm/msm_drv.c static int msm_drm_init(struct device *dev, struct drm_driver *drv)
Quoted 3 lines
drivers/gpu/drm/msm/msm_drv.c +1
-1+ SCHED_FIFO, ¶m);if (ret) - pr_warn("display event thread priority updatefailed: %d\n",
Quoted 1 line
-
ret);
drivers/gpu/drm/msm/msm_drv.c static int msm_drm_init(struct device *dev, struct drm_driver *drv)
Quoted 3 lines
drivers/gpu/drm/msm/msm_drv.c +0
-3- -if (IS_ERR (priv->event_thread[i].thread)) { - dev_err(dev, "failed to create crtc_eventkthread\n");
drivers/gpu/drm/msm/msm_drv.c static int msm_drm_init(struct device *dev, struct drm_driver *drv) · line 602
Quoted 10 lines
drivers/gpu/drm/msm/msm_drv.c +0
-10- priv->event_thread[i].thread =NULL ; - } - -if ((!priv->disp_thread[i].thread) || - !priv->event_thread[i].thread) { -/* clean up previously created threads if any */ -for ( ; i >=0 ; i--) { -if (priv->disp_thread[i].thread) { - kthread_stop( -priv->disp_thread[i].thread);
drivers/gpu/drm/msm/msm_drv.c
Quoted 1 line
drivers/gpu/drm/msm/msm_drv.c +0
-1- priv->disp_thread[i].thread =NULL;
drivers/gpu/drm/msm/msm_drv.c static int msm_drm_init(struct device *dev, struct drm_driver *drv)
Quoted 5 lines
drivers/gpu/drm/msm/msm_drv.c +0
-5- } - -if (priv->event_thread[i].thread) { - kthread_stop( -priv->event_thread[i].thread);
drivers/gpu/drm/msm/msm_drv.c
Quoted 1 line
drivers/gpu/drm/msm/msm_drv.c +0
-1- priv->event_thread[i].thread =NULL;
drivers/gpu/drm/msm/msm_drv.c static int msm_drm_init(struct device *dev, struct drm_driver *drv)
Quoted 5 lines
drivers/gpu/drm/msm/msm_drv.c +1
-4- } - } - goto err_msm_uninit; - } + dev_warn(dev, "display event thread priorityupdate failed:%d\n",
Same problem here,
dev_warn(dev, "event thread set priority failed
%d\n",Quoted 6 lines
drivers/gpu/drm/msm/msm_drv.c +1
-1+ ret); } ret =drm_vblank_init (ddev, priv->num_crtcs); --The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum,
Quoted 2 lines
a Linux Foundation Collaborative Project
Signature · 5 lines
Jeykumar S _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno