Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp218850pxb; Mon, 11 Apr 2022 23:36:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywFzV6N9sY1xhL4Qk6ZSRIuCbc7/odC8LP9OQY/YClc+CVL8EFHWFVhm6LVvMOGDOGyDeB X-Received: by 2002:a17:90a:aa98:b0:1b8:5adb:e35f with SMTP id l24-20020a17090aaa9800b001b85adbe35fmr3305700pjq.192.1649745410187; Mon, 11 Apr 2022 23:36:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649745410; cv=none; d=google.com; s=arc-20160816; b=m8ctRlMRg5p99u609Z6fP4Ec4Gjko8wpONgcuEf887vNuMEEIM0FMePgBe3Ki2LUcQ VnrMPgk0eF+mwkKG8WZ2mbphcZjmeZ6tgNkagdiQFSg626m+/YWnwF7RCfTmbxkB2Q4f a2MDf08YVpWIZC27eKHqZJPi0boC1mWPQ1DZWXhNK57dV8v/v9E8/4YRJcJTHfho5t6X PHhE9AdvegRMBEXA41GFmHHats0VIrc44ej7k9VzABAW+02RtqPuxr6zX5lRaT6+GUtF sDswAuR1AMPMtE86Dkt1XQ8U0W5rOm/w/tuE3lizdz0VamQ04LpQ8NWMkU+Weu8C2OY7 pNbA== 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=yOjAWbY0UR7Bw7D+6dLajU1Gt4KJ9I9tTJQx5yeuMKM=; b=RS+2S4vaEOvGpxzRdiJdEMdC5WQSd1eyHD6WAvrovD03VKxoC93jgYunnBmehCg9m/ C6MpnnI854O9Bb+h35Tyin2W57UXBqMvX+OKhEQslyHlNfJTUYlaHtpCgYdLD98ZAQ5Q peJQV4cj2vhmEYXKJvbWNbwMVpVrQHkIIc7tPTa4Kjvah9IuyyyEG1pGgrLoXG1NP3yb 7610+04UPHMXnHhALwzQoAQsEMJjAemsQIAQ4c7qFheyW3urBlF+LoTJtSGnnz4wfbPq JujZMqOmpNnFidMGBHDqiv0vrEAm+twXiU2CdR4/hUV07GliveOEGgkWGCSNgLMvY7bV 7LvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nTYdC2mO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b17-20020a170902e95100b00153b2d16654si9851886pll.604.2022.04.11.23.36.37; Mon, 11 Apr 2022 23:36:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nTYdC2mO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240983AbiDLAZU (ORCPT + 99 others); Mon, 11 Apr 2022 20:25:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237623AbiDLAZS (ORCPT ); Mon, 11 Apr 2022 20:25:18 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 516A91A398 for ; Mon, 11 Apr 2022 17:23:02 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id h14so24332185lfl.2 for ; Mon, 11 Apr 2022 17:23:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=yOjAWbY0UR7Bw7D+6dLajU1Gt4KJ9I9tTJQx5yeuMKM=; b=nTYdC2mOxTqAVDPAfm4M/DKJTAtGPexyIeFczb44uM99vLJi4+KMXs5FlGtBz/LlSc /S4Lc8OMJTOuSpsm0k1d4AWMldDw/rEsArXH2/TL9c+HMaVhv6Vs6oOcpHb0Jrnaapd7 bhya9Ip74FhxLoeiNWaYvv9/PXSR6DK4GaJe6/xViUD/SoQn68Q/EEXWN6dY6ThjPtm4 2kRjmQcCANcGWxt9xJXFIVJYC+FAASLF3Ej9Fvbd7lh6tLdrnCOGLCFBei4rf8IspoJk 4ftS/KIdUJjuRRMrzNZVEu+ymRmdvp2mBX+x+D0MWmY4JBt9YAriWegqdSTnT47tAtED 3Uvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=yOjAWbY0UR7Bw7D+6dLajU1Gt4KJ9I9tTJQx5yeuMKM=; b=ypAU4A8Ct0wrKaEjIPZO868nPeqCBIe/Dl+jj81uu0gERXjp3UbXBcc9tJ0RJ1hjKP eaQvZKCOZHNk2SDR953g95tsGa8pvCUXiY8YlITOPz06NkVYVeH+d0AksIEKdTD5wtyc o5wc/7t34Aj3hcxVW7+2Mg8NjrwdxfhCZ/ZEB0Uu1XS2lizweGb0ktyAFS81jXuPV9j9 UUIlL9ho+rUmMBETqKRCEfX+LiAhTRIjbQoAPw5qt+y1sh4SvvnayD6Kdjjfk4lJCwra dWamAsIPWOf/tooSwVqHFKtMd/tp9kd8UPyM3nsUFd7+609UlFe575SrtZq2KyJ9iuuQ gg/A== X-Gm-Message-State: AOAM531uU7mLUeYEChks3GxpSDqVd5ImBm1hi0FNoylERc34+BhuNTxF vF4rEWmu/7krKP5xfZOD1HSJN9W3cRxCKw== X-Received: by 2002:ac2:4194:0:b0:442:ed9e:4a25 with SMTP id z20-20020ac24194000000b00442ed9e4a25mr22394740lfh.629.1649722980575; Mon, 11 Apr 2022 17:23:00 -0700 (PDT) Received: from [192.168.1.211] ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id f3-20020a056512228300b0044a0e0a609bsm3455478lfu.38.2022.04.11.17.22.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 Apr 2022 17:22:59 -0700 (PDT) Message-ID: <7529d921-0b12-d162-416d-3542933a0aed@linaro.org> Date: Tue, 12 Apr 2022 03:22:59 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] drm/msm/dp: stop event kernel thread when DP unbind Content-Language: en-GB To: Stephen Boyd , Kuogee Hsieh , agross@kernel.org, airlied@linux.ie, bjorn.andersson@linaro.org, daniel@ffwll.ch, robdclark@gmail.com, sean@poorly.run, vkoul@kernel.org Cc: quic_abhinavk@quicinc.com, quic_aravindh@quicinc.com, quic_sbillaka@quicinc.com, freedreno@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org References: <1649722129-12542-1-git-send-email-quic_khsieh@quicinc.com> From: Dmitry Baryshkov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 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. > >> +} >> + >> +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; >> } >> -- With best wishes Dmitry