diff --git a/msm/msm_drv.c b/msm/msm_drv.c index 0ab04da6b7..ce7a41d5ec 100644 --- a/msm/msm_drv.c +++ b/msm/msm_drv.c @@ -104,6 +104,24 @@ static void msm_fb_output_poll_changed(struct drm_device *dev) drm_fb_helper_hotplug_event(priv->fbdev); } +static void msm_drm_display_thread_priority_worker(struct kthread_work *work) +{ + int ret = 0; + struct sched_param param = { 0 }; + struct task_struct *task = current->group_leader; + + /** + * this priority was found during empiric testing to have appropriate + * realtime scheduling to process display updates and interact with + * other real time and normal priority task + */ + param.sched_priority = 16; + ret = sched_setscheduler(task, SCHED_FIFO, ¶m); + if (ret) + pr_warn("pid:%d name:%s priority update failed: %d\n", + current->tgid, task->comm, ret); +} + /** * msm_atomic_helper_check - validate state object * @dev: DRM device @@ -575,20 +593,13 @@ static int msm_component_bind_all(struct device *dev, } #endif -static int msm_drm_display_thread_create(struct sched_param param, - struct msm_drm_private *priv, struct drm_device *ddev, +static int msm_drm_display_thread_create(struct msm_drm_private *priv, struct drm_device *ddev, struct device *dev) { int i, ret = 0; - /** - * this priority was found during empiric testing to have appropriate - * realtime scheduling to process display updates and interact with - * other real time and normal priority task - */ - param.sched_priority = 16; + kthread_init_work(&priv->thread_priority_work, msm_drm_display_thread_priority_worker); for (i = 0; i < priv->num_crtcs; i++) { - /* initialize display thread */ priv->disp_thread[i].crtc_id = priv->crtcs[i]->base.id; kthread_init_worker(&priv->disp_thread[i].worker); @@ -597,11 +608,7 @@ static int msm_drm_display_thread_create(struct sched_param param, 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); + kthread_queue_work(&priv->disp_thread[i].worker, &priv->thread_priority_work); if (IS_ERR(priv->disp_thread[i].thread)) { dev_err(dev, "failed to create crtc_commit kthread\n"); @@ -623,11 +630,7 @@ static int msm_drm_display_thread_create(struct sched_param param, * frame_pending counters beyond 2. This can lead to commit * failure at crtc commit level. */ - ret = sched_setscheduler(priv->event_thread[i].thread, - SCHED_FIFO, ¶m); - if (ret) - pr_warn("display event thread priority update failed: %d\n", - ret); + kthread_queue_work(&priv->event_thread[i].worker, &priv->thread_priority_work); if (IS_ERR(priv->event_thread[i].thread)) { dev_err(dev, "failed to create crtc_event kthread\n"); @@ -662,12 +665,7 @@ static int msm_drm_display_thread_create(struct sched_param param, kthread_init_worker(&priv->pp_event_worker); priv->pp_event_thread = kthread_run(kthread_worker_fn, &priv->pp_event_worker, "pp_event"); - - ret = sched_setscheduler(priv->pp_event_thread, - SCHED_FIFO, ¶m); - if (ret) - pr_warn("pp_event thread priority update failed: %d\n", - ret); + kthread_queue_work(&priv->pp_event_worker, &priv->thread_priority_work); if (IS_ERR(priv->pp_event_thread)) { dev_err(dev, "failed to create pp_event kthread\n"); @@ -677,8 +675,8 @@ static int msm_drm_display_thread_create(struct sched_param param, } return 0; - } + static struct msm_kms *_msm_drm_component_init_helper( struct msm_drm_private *priv, struct drm_device *ddev, struct device *dev, @@ -803,7 +801,6 @@ static int msm_drm_component_init(struct device *dev) struct msm_drm_private *priv = ddev->dev_private; struct msm_kms *kms = NULL; int ret; - struct sched_param param = { 0 }; struct drm_crtc *crtc; ret = msm_mdss_init(ddev); @@ -842,7 +839,7 @@ static int msm_drm_component_init(struct device *dev) sde_rotator_register(); sde_rotator_smmu_driver_register(); - ret = msm_drm_display_thread_create(param, priv, ddev, dev); + ret = msm_drm_display_thread_create(priv, ddev, dev); if (ret) { dev_err(dev, "msm_drm_display_thread_create failed\n"); goto fail; diff --git a/msm/msm_drv.h b/msm/msm_drv.h index 89130a093c..635a45bc9d 100644 --- a/msm/msm_drv.h +++ b/msm/msm_drv.h @@ -976,6 +976,8 @@ struct msm_drm_private { struct task_struct *pp_event_thread; struct kthread_worker pp_event_worker; + struct kthread_work thread_priority_work; + unsigned int num_encoders; struct drm_encoder *encoders[MAX_ENCODERS];