From patchwork Tue Jul 21 01:33:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernard Zhao X-Patchwork-Id: 11674853 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5C0DC913 for ; Tue, 21 Jul 2020 01:43:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49C48207DD for ; Tue, 21 Jul 2020 01:43:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728296AbgGUBn0 (ORCPT ); Mon, 20 Jul 2020 21:43:26 -0400 Received: from m176150.mail.qiye.163.com ([59.111.176.150]:2099 "EHLO m176150.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726330AbgGUBn0 (ORCPT ); Mon, 20 Jul 2020 21:43:26 -0400 Received: from vivo.com (wm-10.qy.internal [127.0.0.1]) by m176150.mail.qiye.163.com (Hmail) with ESMTP id 083D01A2142; Tue, 21 Jul 2020 09:33:03 +0800 (CST) Message-ID: To: Rob Clark , Sean Paul , David Airlie , Daniel Vetter , Drew Davenport , Bernard Zhao , Hongbo Yao , Thomas Zimmermann , Kalyan Thota , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com Subject: =?utf-8?q?=5BResend=5D=5BPATCH=5D_drm/msm=3A_use_kthread=5Fcreate?= =?utf-8?q?=5Fworker_instead_of_kthread=5Frun?= X-Priority: 3 X-Mailer: HMail Webmail Server V2.0 Copyright (c) 2016-163.com X-Originating-IP: 14.29.82.33 MIME-Version: 1.0 Received: from bernard@vivo.com( [14.29.82.33) ] by ajax-webmail ( [127.0.0.1] ) ; Tue, 21 Jul 2020 09:33:03 +0800 (GMT+08:00) From: Bernard Date: Tue, 21 Jul 2020 09:33:03 +0800 (GMT+08:00) X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZSE8ZQh5CQ05OSU8eVkpOQk5JQk5KQ0hKT0tVEwETFhoSFyQUDg9ZV1kWGg8SFR0UWU FZT0tIVUpKS0hKTFVKS0tZBg++ X-HM-Sender-Digest: e1kMHhlZQQ8JDh5XWRIfHhUPWUFZRzo#SToRKjkdPy0DFyI1Ajk9Qg5R CE8JC1VKVUpOQk5JQk5KQ0hOSENVMxYaEhdVGR4JFRoJHzsNEg0UVRgUFkVZV1kSC1lBWUpPVUlC VUNJVUhIWVdZCAFZQU1OTk83Bg++ X-HM-Tid: 0a736f00b0cd93b4kuws083d01a2142 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 --- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 2 +- drivers/gpu/drm/msm/msm_drv.c | 18 ++++++------------ drivers/gpu/drm/msm/msm_drv.h | 3 +-- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c index e15b42a780e0..c959c959021d 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c @@ -396,7 +396,7 @@ static void dpu_crtc_frame_event_cb(void *data, u32 event) fevent->event = event; fevent->crtc = crtc; 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) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index f6ce40bf3699..82e79b82a594 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -238,10 +238,8 @@ static int msm_drm_uninit(struct device *dev) /* clean up event worker threads */ for (i = 0; i < priv->num_crtcs; i++) { - if (priv->event_thread[i].thread) { - kthread_destroy_worker(&priv->event_thread[i].worker); - priv->event_thread[i].thread = NULL; - } + if (priv->event_thread[i].worker) + kthread_destroy_worker(priv->event_thread[i].worker); } msm_gem_shrinker_cleanup(ddev); @@ -504,19 +502,15 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) for (i = 0; i < priv->num_crtcs; i++) { /* initialize event thread */ 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].thread = - 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)) { + priv->event_thread[i].worker = kthread_create_worker(0, + "crtc_event:%d", priv->event_thread[i].crtc_id); + if (IS_ERR(priv->event_thread[i].worker)) { DRM_DEV_ERROR(dev, "failed to create crtc_event kthread\n"); - priv->event_thread[i].thread = NULL; goto err_msm_uninit; } - ret = sched_setscheduler(priv->event_thread[i].thread, + ret = sched_setscheduler(priv->event_thread[i].worker->task, SCHED_FIFO, ¶m); if (ret) dev_warn(dev, "event_thread set priority failed:%d\n", diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index e2d6a6056418..daf2f4e5548c 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -129,9 +129,8 @@ struct msm_display_info { /* Commit/Event thread specific structure */ struct msm_drm_thread { struct drm_device *dev; - struct task_struct *thread; unsigned int crtc_id; - struct kthread_worker worker; + struct kthread_worker *worker; }; struct msm_drm_private {