Skip to content

Commit 1041dee

Browse files
Bernardrobclark
authored andcommitted
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 <[email protected]> Signed-off-by: Rob Clark <[email protected]>
1 parent 974b711 commit 1041dee

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ static void dpu_crtc_frame_event_cb(void *data, u32 event)
396396
fevent->event = event;
397397
fevent->crtc = crtc;
398398
fevent->ts = ktime_get();
399-
kthread_queue_work(&priv->event_thread[crtc_id].worker, &fevent->work);
399+
kthread_queue_work(priv->event_thread[crtc_id].worker, &fevent->work);
400400
}
401401

402402
void dpu_crtc_complete_commit(struct drm_crtc *crtc)

drivers/gpu/drm/msm/msm_drv.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,8 @@ static int msm_drm_uninit(struct device *dev)
252252

253253
/* clean up event worker threads */
254254
for (i = 0; i < priv->num_crtcs; i++) {
255-
if (priv->event_thread[i].thread) {
256-
kthread_destroy_worker(&priv->event_thread[i].worker);
257-
priv->event_thread[i].thread = NULL;
258-
}
255+
if (priv->event_thread[i].worker)
256+
kthread_destroy_worker(priv->event_thread[i].worker);
259257
}
260258

261259
msm_gem_shrinker_cleanup(ddev);
@@ -518,19 +516,15 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)
518516
for (i = 0; i < priv->num_crtcs; i++) {
519517
/* initialize event thread */
520518
priv->event_thread[i].crtc_id = priv->crtcs[i]->base.id;
521-
kthread_init_worker(&priv->event_thread[i].worker);
522519
priv->event_thread[i].dev = ddev;
523-
priv->event_thread[i].thread =
524-
kthread_run(kthread_worker_fn,
525-
&priv->event_thread[i].worker,
526-
"crtc_event:%d", priv->event_thread[i].crtc_id);
527-
if (IS_ERR(priv->event_thread[i].thread)) {
520+
priv->event_thread[i].worker = kthread_create_worker(0,
521+
"crtc_event:%d", priv->event_thread[i].crtc_id);
522+
if (IS_ERR(priv->event_thread[i].worker)) {
528523
DRM_DEV_ERROR(dev, "failed to create crtc_event kthread\n");
529-
priv->event_thread[i].thread = NULL;
530524
goto err_msm_uninit;
531525
}
532526

533-
ret = sched_setscheduler(priv->event_thread[i].thread,
527+
ret = sched_setscheduler(priv->event_thread[i].worker->task,
534528
SCHED_FIFO, &param);
535529
if (ret)
536530
dev_warn(dev, "event_thread set priority failed:%d\n",

drivers/gpu/drm/msm/msm_drv.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,8 @@ struct msm_display_info {
129129
/* Commit/Event thread specific structure */
130130
struct msm_drm_thread {
131131
struct drm_device *dev;
132-
struct task_struct *thread;
133132
unsigned int crtc_id;
134-
struct kthread_worker worker;
133+
struct kthread_worker *worker;
135134
};
136135

137136
struct msm_drm_private {

0 commit comments

Comments
 (0)