From patchwork Thu Nov 1 00:19:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeykumar Sankaran X-Patchwork-Id: 10663413 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D32E3CF1 for ; Thu, 1 Nov 2018 00:19:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7896A2BB83 for ; Thu, 1 Nov 2018 00:19:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6BA822BB87; Thu, 1 Nov 2018 00:19:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8FB72BB83 for ; Thu, 1 Nov 2018 00:19:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726234AbeKAJTn (ORCPT ); Thu, 1 Nov 2018 05:19:43 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:56900 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725931AbeKAJTn (ORCPT ); Thu, 1 Nov 2018 05:19:43 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 5E7FC60591; Thu, 1 Nov 2018 00:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1541031550; bh=gKb2MTGXMCQgKBFYZZ2Fl+pfNJ5OvwRLbu3lFWV19DU=; h=From:To:Cc:Subject:Date:From; b=iNntzkU67QfOIjHEC2Spnz8nariVsnPyBLfXxQF7KEiz0gyzIdkkCMPuJvAKz8OCJ /zlnyQEEP6HRDXhkkMSx7AwoNDYzG9ohpSsNHhAe7U9U9g06yGcnUaowz/L3tEQl15 jSfw27gFJk1I9CHrEpX0XUO9fBAP71mNVzeXPIXM= Received: from jeykumar-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jsanka@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 14FC260591; Thu, 1 Nov 2018 00:19:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1541031549; bh=gKb2MTGXMCQgKBFYZZ2Fl+pfNJ5OvwRLbu3lFWV19DU=; h=From:To:Cc:Subject:Date:From; b=SiYAWcMbns4BQsH9q1EfdizBRxHCPiNha6G8kTxcRTgEJsdrh7YHwEchKZElvL5gu 5CzviqKKN4hjBqPHgcN3LJSZZ06YCRblEZqKTAzFB+a8KaYI8Q+PiVLh+uLl5EXKsI zTydLe9vfqGctKKiaA+LxRfGU353fjfOXPUZe2bQ= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 14FC260591 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jsanka@codeaurora.org From: Jeykumar Sankaran To: dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Cc: Jeykumar Sankaran , seanpaul@chromium.org, robdclark@gmail.com, hoegsberg@google.com Subject: [PATCH 1/2] drm/msm: use common display thread for dispatching vblank events Date: Wed, 31 Oct 2018 17:19:04 -0700 Message-Id: <1541031545-20520-1-git-send-email-jsanka@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP DPU was using one thread per display to dispatch async commits and vblank requests. Since clean up already happened in msm to use the common thread for all the display commits, display threads are only used to cater vblank requests. Single thread is sufficient to do the job without any performance hits. Signed-off-by: Jeykumar Sankaran --- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 6 +--- drivers/gpu/drm/msm/msm_drv.c | 50 ++++++++++++----------------- drivers/gpu/drm/msm/msm_drv.h | 2 +- 3 files changed, 23 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c index 82c55ef..aff20f5 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c @@ -753,11 +753,7 @@ static int dpu_encoder_resource_control(struct drm_encoder *drm_enc, is_vid_mode = dpu_enc->disp_info.capabilities & MSM_DISPLAY_CAP_VID_MODE; - if (drm_enc->crtc->index >= ARRAY_SIZE(priv->disp_thread)) { - DPU_ERROR("invalid crtc index\n"); - return -EINVAL; - } - disp_thread = &priv->disp_thread[drm_enc->crtc->index]; + disp_thread = &priv->disp_thread; /* * when idle_pc is not supported, process only KICKOFF, STOP and MODESET diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 9c9f7ff..1f384b3 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -257,8 +257,7 @@ static int vblank_ctrl_queue_work(struct msm_drm_private *priv, list_add_tail(&vbl_ev->node, &vbl_ctrl->event_list); spin_unlock_irqrestore(&vbl_ctrl->lock, flags); - kthread_queue_work(&priv->disp_thread[crtc_id].worker, - &vbl_ctrl->work); + kthread_queue_work(&priv->disp_thread.worker, &vbl_ctrl->work); return 0; } @@ -284,14 +283,12 @@ static int msm_drm_uninit(struct device *dev) kfree(vbl_ev); } + kthread_flush_worker(&priv->disp_thread.worker); + kthread_stop(priv->disp_thread.thread); + priv->disp_thread.thread = NULL; + /* clean up display commit/event worker threads */ for (i = 0; i < priv->num_crtcs; i++) { - if (priv->disp_thread[i].thread) { - kthread_flush_worker(&priv->disp_thread[i].worker); - kthread_stop(priv->disp_thread[i].thread); - priv->disp_thread[i].thread = NULL; - } - if (priv->event_thread[i].thread) { kthread_flush_worker(&priv->event_thread[i].worker); kthread_stop(priv->event_thread[i].thread); @@ -537,6 +534,22 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) ddev->mode_config.funcs = &mode_config_funcs; ddev->mode_config.helper_private = &mode_config_helper_funcs; + /* initialize display thread */ + kthread_init_worker(&priv->disp_thread.worker); + priv->disp_thread.dev = ddev; + priv->disp_thread.thread = kthread_run(kthread_worker_fn, + &priv->disp_thread.worker, + "disp_thread"); + if (IS_ERR(priv->disp_thread.thread)) { + DRM_DEV_ERROR(dev, "failed to create crtc_commit kthread\n"); + priv->disp_thread.thread = NULL; + goto err_msm_uninit; + } + + ret = sched_setscheduler(priv->disp_thread.thread, SCHED_FIFO, ¶m); + if (ret) + pr_warn("display thread priority update failed: %d\n", ret); + /** * this priority was found during empiric testing to have appropriate * realtime scheduling to process display updates and interact with @@ -544,27 +557,6 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) */ param.sched_priority = 16; 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); - priv->disp_thread[i].dev = ddev; - priv->disp_thread[i].thread = - kthread_run(kthread_worker_fn, - &priv->disp_thread[i].worker, - "crtc_commit:%d", priv->disp_thread[i].crtc_id); - if (IS_ERR(priv->disp_thread[i].thread)) { - DRM_DEV_ERROR(dev, "failed to create crtc_commit kthread\n"); - priv->disp_thread[i].thread = NULL; - goto err_msm_uninit; - } - - ret = sched_setscheduler(priv->disp_thread[i].thread, - SCHED_FIFO, ¶m); - if (ret) - dev_warn(dev, "disp_thread set priority failed: %d\n", - ret); - /* initialize event thread */ priv->event_thread[i].crtc_id = priv->crtcs[i]->base.id; kthread_init_worker(&priv->event_thread[i].worker); diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index 9d11f32..e81b1fa 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -197,7 +197,7 @@ struct msm_drm_private { unsigned int num_crtcs; struct drm_crtc *crtcs[MAX_CRTCS]; - struct msm_drm_thread disp_thread[MAX_CRTCS]; + struct msm_drm_thread disp_thread; struct msm_drm_thread event_thread[MAX_CRTCS]; unsigned int num_encoders; From patchwork Thu Nov 1 00:19:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeykumar Sankaran X-Patchwork-Id: 10663415 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D073214BD for ; Thu, 1 Nov 2018 00:19:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD7142BB83 for ; Thu, 1 Nov 2018 00:19:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1D672BB86; Thu, 1 Nov 2018 00:19:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35A9A2BB84 for ; Thu, 1 Nov 2018 00:19:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725931AbeKAJTn (ORCPT ); Thu, 1 Nov 2018 05:19:43 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:56970 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725970AbeKAJTn (ORCPT ); Thu, 1 Nov 2018 05:19:43 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id AB01660791; Thu, 1 Nov 2018 00:19:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1541031551; bh=+38DAR0D8QhSyQQFGVr8ATGvW1M7lhLZgoyOOv+zoMI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oeFQIDTHq89sWNEBtD77kn3HRz3CIM8hnNDVb34colg0CMzpymsAn9EnCdZwsZCqd wQOXSQyYbZXSczmrm9+XUUB71K1/p5H866FowViLjcE/QGDAWpZDJUMa/B9FQXDCsr 0+NBMR3T0r2s4sSpQAldSzudJl/c7EqQXxzLsaW4= Received: from jeykumar-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jsanka@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7109D60791; Thu, 1 Nov 2018 00:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1541031550; bh=+38DAR0D8QhSyQQFGVr8ATGvW1M7lhLZgoyOOv+zoMI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bkGAGtopiMW8bLqPgjsPdzKAPoSLO0mO/z4r5Aq7hYZpkMiYi34qHor28yVHcpsts CJKFBpL99foKzqI3efCEhnagX9xW72fZU1WMeUXEsnZ6EocqjApombg+WD/vpssav4 nOJDA0J538DHtL5f285i76GjdHxphmthggVPLIvE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7109D60791 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jsanka@codeaurora.org From: Jeykumar Sankaran To: dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Cc: Jeykumar Sankaran , seanpaul@chromium.org, robdclark@gmail.com, hoegsberg@google.com Subject: [PATCH 2/2] drm/msm: subclass work object for vblank events Date: Wed, 31 Oct 2018 17:19:05 -0700 Message-Id: <1541031545-20520-2-git-send-email-jsanka@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1541031545-20520-1-git-send-email-jsanka@codeaurora.org> References: <1541031545-20520-1-git-send-email-jsanka@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP msm maintains a separate structure to define vblank work definitions and a list to track events submitted to the display worker thread. We can avoid these redundant list and its protection mechanism, if we subclass the work object to encapsulate vblank event parameters. Signed-off-by: Jeykumar Sankaran --- drivers/gpu/drm/msm/msm_drv.c | 70 ++++++++++++------------------------------- drivers/gpu/drm/msm/msm_drv.h | 7 ----- 2 files changed, 19 insertions(+), 58 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 1f384b3..67a96ee 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -203,61 +203,44 @@ u32 msm_readl(const void __iomem *addr) return val; } -struct vblank_event { - struct list_head node; +struct msm_vblank_work { + struct kthread_work work; int crtc_id; bool enable; + struct msm_drm_private *priv; }; static void vblank_ctrl_worker(struct kthread_work *work) { - struct msm_vblank_ctrl *vbl_ctrl = container_of(work, - struct msm_vblank_ctrl, work); - struct msm_drm_private *priv = container_of(vbl_ctrl, - struct msm_drm_private, vblank_ctrl); + struct msm_vblank_work *vbl_work = container_of(work, + struct msm_vblank_work, work); + struct msm_drm_private *priv = vbl_work->priv; struct msm_kms *kms = priv->kms; - struct vblank_event *vbl_ev, *tmp; - unsigned long flags; - - spin_lock_irqsave(&vbl_ctrl->lock, flags); - list_for_each_entry_safe(vbl_ev, tmp, &vbl_ctrl->event_list, node) { - list_del(&vbl_ev->node); - spin_unlock_irqrestore(&vbl_ctrl->lock, flags); - - if (vbl_ev->enable) - kms->funcs->enable_vblank(kms, - priv->crtcs[vbl_ev->crtc_id]); - else - kms->funcs->disable_vblank(kms, - priv->crtcs[vbl_ev->crtc_id]); - kfree(vbl_ev); - - spin_lock_irqsave(&vbl_ctrl->lock, flags); - } + if (vbl_work->enable) + kms->funcs->enable_vblank(kms, priv->crtcs[vbl_work->crtc_id]); + else + kms->funcs->disable_vblank(kms, priv->crtcs[vbl_work->crtc_id]); - spin_unlock_irqrestore(&vbl_ctrl->lock, flags); + kfree(vbl_work); } static int vblank_ctrl_queue_work(struct msm_drm_private *priv, int crtc_id, bool enable) { - struct msm_vblank_ctrl *vbl_ctrl = &priv->vblank_ctrl; - struct vblank_event *vbl_ev; - unsigned long flags; + struct msm_vblank_work *vbl_work; - vbl_ev = kzalloc(sizeof(*vbl_ev), GFP_ATOMIC); - if (!vbl_ev) + vbl_work = kzalloc(sizeof(*vbl_work), GFP_ATOMIC); + if (!vbl_work) return -ENOMEM; - vbl_ev->crtc_id = crtc_id; - vbl_ev->enable = enable; + kthread_init_work(&vbl_work->work, vblank_ctrl_worker); - spin_lock_irqsave(&vbl_ctrl->lock, flags); - list_add_tail(&vbl_ev->node, &vbl_ctrl->event_list); - spin_unlock_irqrestore(&vbl_ctrl->lock, flags); + vbl_work->crtc_id = crtc_id; + vbl_work->enable = enable; + vbl_work->priv = priv; - kthread_queue_work(&priv->disp_thread.worker, &vbl_ctrl->work); + kthread_queue_work(&priv->disp_thread.worker, &vbl_work->work); return 0; } @@ -269,20 +252,8 @@ static int msm_drm_uninit(struct device *dev) struct msm_drm_private *priv = ddev->dev_private; struct msm_kms *kms = priv->kms; struct msm_mdss *mdss = priv->mdss; - struct msm_vblank_ctrl *vbl_ctrl = &priv->vblank_ctrl; - struct vblank_event *vbl_ev, *tmp; int i; - /* We must cancel and cleanup any pending vblank enable/disable - * work before drm_irq_uninstall() to avoid work re-enabling an - * irq after uninstall has disabled it. - */ - kthread_flush_work(&vbl_ctrl->work); - list_for_each_entry_safe(vbl_ev, tmp, &vbl_ctrl->event_list, node) { - list_del(&vbl_ev->node); - kfree(vbl_ev); - } - kthread_flush_worker(&priv->disp_thread.worker); kthread_stop(priv->disp_thread.thread); priv->disp_thread.thread = NULL; @@ -474,9 +445,6 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) priv->wq = alloc_ordered_workqueue("msm", 0); INIT_LIST_HEAD(&priv->inactive_list); - INIT_LIST_HEAD(&priv->vblank_ctrl.event_list); - kthread_init_work(&priv->vblank_ctrl.work, vblank_ctrl_worker); - spin_lock_init(&priv->vblank_ctrl.lock); drm_mode_config_init(ddev); diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index e81b1fa..b91e306 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -77,12 +77,6 @@ enum msm_mdp_plane_property { PLANE_PROP_MAX_NUM }; -struct msm_vblank_ctrl { - struct kthread_work work; - struct list_head event_list; - spinlock_t lock; -}; - #define MSM_GPU_MAX_RINGS 4 #define MAX_H_TILES_PER_DISPLAY 2 @@ -226,7 +220,6 @@ struct msm_drm_private { struct notifier_block vmap_notifier; struct shrinker shrinker; - struct msm_vblank_ctrl vblank_ctrl; struct drm_atomic_state *pm_state; };