drm/msm: use kthread_create_worker instead of kthread_run

Use kthread_create_worker to simplify the code and optimise
the manager struct: msm_drm_thread. With this change, we
could remove struct element (struct task_struct *thread &
struct kthread_worker worker), instead, use one point (struct
kthread_worker *worker).

Signed-off-by: Bernard Zhao <bernard@vivo.com>
Signed-off-by: Rob Clark <robdclark@chromium.org>
This commit is contained in:
Bernard 2020-07-21 09:33:03 +08:00 committed by Rob Clark
parent 974b7115a7
commit 1041dee217
3 changed files with 8 additions and 15 deletions

View File

@ -396,7 +396,7 @@ static void dpu_crtc_frame_event_cb(void *data, u32 event)
fevent->event = event; fevent->event = event;
fevent->crtc = crtc; fevent->crtc = crtc;
fevent->ts = ktime_get(); fevent->ts = ktime_get();
kthread_queue_work(&priv->event_thread[crtc_id].worker, &fevent->work); kthread_queue_work(priv->event_thread[crtc_id].worker, &fevent->work);
} }
void dpu_crtc_complete_commit(struct drm_crtc *crtc) void dpu_crtc_complete_commit(struct drm_crtc *crtc)

View File

@ -252,10 +252,8 @@ static int msm_drm_uninit(struct device *dev)
/* clean up event worker threads */ /* clean up event worker threads */
for (i = 0; i < priv->num_crtcs; i++) { for (i = 0; i < priv->num_crtcs; i++) {
if (priv->event_thread[i].thread) { if (priv->event_thread[i].worker)
kthread_destroy_worker(&priv->event_thread[i].worker); kthread_destroy_worker(priv->event_thread[i].worker);
priv->event_thread[i].thread = NULL;
}
} }
msm_gem_shrinker_cleanup(ddev); msm_gem_shrinker_cleanup(ddev);
@ -518,19 +516,15 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)
for (i = 0; i < priv->num_crtcs; i++) { for (i = 0; i < priv->num_crtcs; i++) {
/* initialize event thread */ /* initialize event thread */
priv->event_thread[i].crtc_id = priv->crtcs[i]->base.id; priv->event_thread[i].crtc_id = priv->crtcs[i]->base.id;
kthread_init_worker(&priv->event_thread[i].worker);
priv->event_thread[i].dev = ddev; priv->event_thread[i].dev = ddev;
priv->event_thread[i].thread = priv->event_thread[i].worker = kthread_create_worker(0,
kthread_run(kthread_worker_fn, "crtc_event:%d", priv->event_thread[i].crtc_id);
&priv->event_thread[i].worker, if (IS_ERR(priv->event_thread[i].worker)) {
"crtc_event:%d", priv->event_thread[i].crtc_id);
if (IS_ERR(priv->event_thread[i].thread)) {
DRM_DEV_ERROR(dev, "failed to create crtc_event kthread\n"); DRM_DEV_ERROR(dev, "failed to create crtc_event kthread\n");
priv->event_thread[i].thread = NULL;
goto err_msm_uninit; goto err_msm_uninit;
} }
ret = sched_setscheduler(priv->event_thread[i].thread, ret = sched_setscheduler(priv->event_thread[i].worker->task,
SCHED_FIFO, &param); SCHED_FIFO, &param);
if (ret) if (ret)
dev_warn(dev, "event_thread set priority failed:%d\n", dev_warn(dev, "event_thread set priority failed:%d\n",

View File

@ -129,9 +129,8 @@ struct msm_display_info {
/* Commit/Event thread specific structure */ /* Commit/Event thread specific structure */
struct msm_drm_thread { struct msm_drm_thread {
struct drm_device *dev; struct drm_device *dev;
struct task_struct *thread;
unsigned int crtc_id; unsigned int crtc_id;
struct kthread_worker worker; struct kthread_worker *worker;
}; };
struct msm_drm_private { struct msm_drm_private {