disp: msm: move thread priority call from component bind

Move thread priority call to kernel worker thread because
component bind API may run from vendor_modeprobe process
context when all drivers probe succeed. Thread priority
update is not allowed from vendor_modeprobe process
context.

Change-Id: Iafac97ce02942d6a2134495232f3c395ba4a362f
Signed-off-by: Dhaval Patel <pdhaval@codeaurora.org>
This commit is contained in:
Dhaval Patel
2021-10-13 11:52:56 -07:00
förälder b1e561d3f5
incheckning 25c3b955c6
2 ändrade filer med 27 tillägg och 28 borttagningar

Visa fil

@@ -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, &param);
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, &param);
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, &param);
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, &param);
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;