From patchwork Tue Nov 6 22:36:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeykumar Sankaran X-Patchwork-Id: 10671571 X-Patchwork-Delegate: agross@codeaurora.org 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 1319913A4 for ; Tue, 6 Nov 2018 22:36:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 038322AE1C for ; Tue, 6 Nov 2018 22:36:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E8C162AE17; Tue, 6 Nov 2018 22:36:37 +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 81BD92AE17 for ; Tue, 6 Nov 2018 22:36:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726462AbeKGIEF (ORCPT ); Wed, 7 Nov 2018 03:04:05 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:34740 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726138AbeKGIEF (ORCPT ); Wed, 7 Nov 2018 03:04:05 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 763FB60271; Tue, 6 Nov 2018 22:36:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1541543795; bh=WkGKxJ072eAitJEg2mqf3hYDZwleTb7PGkGdbGOIgUo=; h=From:To:Cc:Subject:Date:From; b=MP0qbP76g0sNkbyx5kqNzjoBlpIFh0a3GqSKRlmbCKkDH2ToHLwYGt+mjV5DCr4UD 1juKHZXywBzi+BEEt7UTmX4mj1O8440YCqUebfTk69/gsJja2IJ3MrwSMKcliIzLKG gQevNq1/vjgyal1lSHaRvah8x7u+jwOt271D7LQQ= 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 3FF3260271; Tue, 6 Nov 2018 22:36:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1541543794; bh=WkGKxJ072eAitJEg2mqf3hYDZwleTb7PGkGdbGOIgUo=; h=From:To:Cc:Subject:Date:From; b=DSXnKe7VfO0YUiq2uEtL+4YkKEwyDz0dQVwJ330fR1x8a/9pGnYqJyTBxqdgmLmHX pkZ/dLrvvC932eXcici7KPOAJcmqIje2KLIH561eHiub690P/4q6gope169xDvWqYB jQWOuwdXQAWG6PQXPHgO5pHTRJ7Ehq5hphnNqH54= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3FF3260271 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, jcrouse@codeaurora.org Subject: [PATCH v2 1/5] drm/msm: destroy msm threads after config cleanup Date: Tue, 6 Nov 2018 14:36:26 -0800 Message-Id: <1541543790-748-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 To avoid any possible work queues to msm threads, clean up the threads after the CRTC objects are released in config cleanup. changes in v2: - fix race condition before kthread flush and stop (Sean Paul) - use kthread_destroy_worker for cleaning up kthread (Sean Paul) Signed-off-by: Jeykumar Sankaran --- drivers/gpu/drm/msm/msm_drv.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 9c9f7ff..e913059 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -278,6 +278,21 @@ static int msm_drm_uninit(struct device *dev) * work before drm_irq_uninstall() to avoid work re-enabling an * irq after uninstall has disabled it. */ + msm_gem_shrinker_cleanup(ddev); + + drm_kms_helper_poll_fini(ddev); + + drm_dev_unregister(ddev); + + msm_perf_debugfs_cleanup(priv); + msm_rd_debugfs_cleanup(priv); + +#ifdef CONFIG_DRM_FBDEV_EMULATION + if (fbdev && priv->fbdev) + msm_fbdev_free(ddev); +#endif + drm_mode_config_cleanup(ddev); + kthread_flush_work(&vbl_ctrl->work); list_for_each_entry_safe(vbl_ev, tmp, &vbl_ctrl->event_list, node) { list_del(&vbl_ev->node); @@ -287,33 +302,16 @@ static int msm_drm_uninit(struct device *dev) /* 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); + kthread_destroy_worker(&priv->disp_thread[i].worker); 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); + kthread_destroy_worker(&priv->event_thread[i].worker); priv->event_thread[i].thread = NULL; } } - msm_gem_shrinker_cleanup(ddev); - - drm_kms_helper_poll_fini(ddev); - - drm_dev_unregister(ddev); - - msm_perf_debugfs_cleanup(priv); - msm_rd_debugfs_cleanup(priv); - -#ifdef CONFIG_DRM_FBDEV_EMULATION - if (fbdev && priv->fbdev) - msm_fbdev_free(ddev); -#endif - drm_mode_config_cleanup(ddev); - pm_runtime_get_sync(dev); drm_irq_uninstall(ddev); pm_runtime_put_sync(dev);