Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp806785pxb; Tue, 12 Apr 2022 14:00:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwy/SCgIlc7+oyYnYdWowDZ42c1axPVq4dOcQFdpxtTC0Uu2nhdNcUsqD9Son9O7DdHyTJ0 X-Received: by 2002:a17:902:7b94:b0:158:94be:c658 with SMTP id w20-20020a1709027b9400b0015894bec658mr2763805pll.36.1649797233303; Tue, 12 Apr 2022 14:00:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649797233; cv=none; d=google.com; s=arc-20160816; b=m0pGTWyJcvSSGNea7HfWgz59UvrV91GR0m9H5SuJTIdFsPIp1x5Qo1+qnu7kkpsx0E JM4Hh06w4XGbEZSQbHM1NajuDtTwehf+Nkm+X+vofAYDN9Mt1emuW7MEMLRZcRRGpAM9 043eZKvU3mE6VKdEKBrG92odIb/+ZENLPs485dQgkGJZuTyijjxLglXWg8qpPbHP3kkQ r+F0Xc+wB2im+zmxM3MzAgQK2/HBEd7Mhc3SdrEZQcdaRCu2IkOqZmC1bFitwKkNYU+X V+o60223oKBk4sfhpK+9bekMNnotDP/6K1ZMdEKJxqSnDwKwa1u63n7vFBfcW42anWPi PNrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=sTXpV5DW8lvf+IzZXjWtfGRdgfLj3MQBE9SGJw2TAZQ=; b=1GC6XvX1ir25MBV9J9RmlYBKC/aGXtElME6hxPZOylCyhcQG6Is16qOYMNY2kvCB/h ZOlPoviFqBLeY1PF/dLIj5d3JkNXFDszUfJGkH8lqifuC+Yc5nPsgWgRA1dchP0wtE3N z0HQYaZ3rlOfuQ2NJOvAj8wyTnNnm5G1C5Xbk7Fh+MkdXt4lSXmI4QqQKrtJUiMfNVJv WDI8sUxe2zmL7nmvHUdJitmLojRqpYDLveUIdomT7aPSk6ZDjaDS9dDv54PM4e5OzaQt 2qPO177rXPPkpWBNPmEj0KT7752Tfw4eFoq880uKIvnpTzoasN6VstEgaBj/1Psk8r2A P+Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b="Y/yrn0LL"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u22-20020a170902a61600b0015605a57d10si11648130plq.523.2022.04.12.14.00.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 14:00:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b="Y/yrn0LL"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 84802D3702; Tue, 12 Apr 2022 13:22:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241317AbiDLAcB (ORCPT + 99 others); Mon, 11 Apr 2022 20:32:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229874AbiDLAcA (ORCPT ); Mon, 11 Apr 2022 20:32:00 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3173223BD5; Mon, 11 Apr 2022 17:29:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1649723384; x=1681259384; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=sTXpV5DW8lvf+IzZXjWtfGRdgfLj3MQBE9SGJw2TAZQ=; b=Y/yrn0LLSx6CsqCRCOeF8pBJokYmVJA1Gi0LGH8d4oA1fchN877dnoP0 5Zptp/aUBnfuniTp+dSF/MO1XN/xf0prdP0HPvfbjcDrBylOaNq/fkL/n HIT+wcBzLPND6XGSLa4sZmQosblV1qWkcfTMyN5QxKQ0rKNMFL1TloR5S E=; Received: from ironmsg07-lv.qualcomm.com ([10.47.202.151]) by alexa-out.qualcomm.com with ESMTP; 11 Apr 2022 17:29:44 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg07-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2022 17:29:43 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Mon, 11 Apr 2022 17:29:22 -0700 Received: from [10.111.166.27] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Mon, 11 Apr 2022 17:29:19 -0700 Message-ID: Date: Mon, 11 Apr 2022 17:29:17 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Subject: Re: [PATCH] drm/msm/dp: stop event kernel thread when DP unbind Content-Language: en-US To: Dmitry Baryshkov , Stephen Boyd , Kuogee Hsieh , , , , , , , CC: , , , , , References: <1649722129-12542-1-git-send-email-quic_khsieh@quicinc.com> <7529d921-0b12-d162-416d-3542933a0aed@linaro.org> From: Abhinav Kumar In-Reply-To: <7529d921-0b12-d162-416d-3542933a0aed@linaro.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/11/2022 5:22 PM, Dmitry Baryshkov wrote: > On 12/04/2022 03:21, Stephen Boyd wrote: >> Quoting Kuogee Hsieh (2022-04-11 17:08:49) >>> Current DP driver implementation, event thread is kept running >>> after DP display is unbind. This patch fix this problem by disabling >>> DP irq and stop event thread to exit gracefully at dp_display_unbind(). >>> >>> Fixes: e91e3065a806 ("drm/msm/dp: Add DP compliance tests on >>> Snapdragon Chipsets") >>> Signed-off-by: Kuogee Hsieh >> >> Should add a Reported-by tag from Dmitry here. >> >>> --- >>>   drivers/gpu/drm/msm/dp/dp_display.c | 24 ++++++++++++++++++++++-- >>>   1 file changed, 22 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c >>> b/drivers/gpu/drm/msm/dp/dp_display.c >>> index 01453db..fa1ef8e 100644 >>> --- a/drivers/gpu/drm/msm/dp/dp_display.c >>> +++ b/drivers/gpu/drm/msm/dp/dp_display.c >>> @@ -273,6 +274,8 @@ static int dp_display_bind(struct device *dev, >>> struct device *master, >>>          return rc; >>>   } >>> >>> +static void dp_hpd_event_stop(struct dp_display_private *dp_priv); >> >> Why can't the function be defined here? >> >>> + >>>   static void dp_display_unbind(struct device *dev, struct device >>> *master, >>>                                void *data) >>>   { >>> @@ -280,6 +283,8 @@ static void dp_display_unbind(struct device *dev, >>> struct device *master, >>>          struct drm_device *drm = dev_get_drvdata(master); >>>          struct msm_drm_private *priv = drm->dev_private; >>> >>> +       disable_irq(dp->irq); >>> +       dp_hpd_event_stop(dp); >>>          dp_power_client_deinit(dp->power); >>>          dp_aux_unregister(dp->aux); >>>          priv->dp[dp->id] = NULL; >>> @@ -1054,7 +1059,7 @@ static int hpd_event_thread(void *data) >>> >>>          dp_priv = (struct dp_display_private *)data; >>> >>> -       while (1) { >>> +       while (!kthread_should_stop()) { >>>                  if (timeout_mode) { >>>                          wait_event_timeout(dp_priv->event_q, >>>                                  (dp_priv->event_pndx == >>> dp_priv->event_gndx), >>> @@ -1137,7 +1142,22 @@ static void dp_hpd_event_setup(struct >>> dp_display_private *dp_priv) >>>          init_waitqueue_head(&dp_priv->event_q); >>>          spin_lock_init(&dp_priv->event_lock); >>> >>> -       kthread_run(hpd_event_thread, dp_priv, "dp_hpd_handler"); >>> +       dp_priv->ev_tsk = kthread_run(hpd_event_thread, dp_priv, >>> "dp_hpd_handler"); >>> + >>> +       if (IS_ERR(dp_priv->ev_tsk)) >>> +               DRM_ERROR("failed to create DP event thread\n"); >> >> Why can't we error out? Why can't this kthread be started in probe? > > Just my 2c. I don't think starting it in probe is a good idea. The > driver uses components, so, in my opinion, the thread should be started > from bind and stopped in unbind. Yes, I also agree it should be started in bind and stopped in unbind. > >> >>> +} >>> + >>> +static void dp_hpd_event_stop(struct dp_display_private *dp_priv) >>> +{ >>> +       if (IS_ERR(dp_priv->ev_tsk)) >>> +               return; >>> + >>> +       kthread_stop(dp_priv->ev_tsk); >>> + >>> +       /* reset event q to empty */ >>> +       dp_priv->event_gndx = 0; >>> +       dp_priv->event_pndx = 0; >>>   } >>> > >