Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp251386iob; Mon, 2 May 2022 18:34:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuDL869YId6PHMMLYrB4kLYhsRkEzxu1+2KK3WM9E7lyEIUihhECuJ6SGGhZUBlk+Hxaq9 X-Received: by 2002:a17:902:d48d:b0:15e:a480:78b2 with SMTP id c13-20020a170902d48d00b0015ea48078b2mr7629554plg.19.1651541688534; Mon, 02 May 2022 18:34:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651541688; cv=none; d=google.com; s=arc-20160816; b=YqWEEf8zpf1Grc+91/4NCTHR7UbC+NdxHykcv2jXYvoimEPVvNfR0W/LoQEgT4QrfG Se7Fcuj0RiED4vVMgZCyzoIH90+AhY/8g/pFyMYa1c5ngGvKb+SDQCxeU/7h7OxRH84u nE/6lkNVUJiUQTMJIL2V7gzNTp31wRMhcQTyH+HajCE/VbRHfRffTerLzXxjWmwhD2zX 2sJO5ZgB1r0wbhTxDdlpsJWalDnx8OJ9v+wuIyexQZs5XW2avBjL9xjMUx2oNszEuy7X upprFMU9morEW0mNPgNXXTcSEXUxHl/WbGab6intTHbb5meK2FfCBXkR2skKjSga5Anq NtmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:user-agent:from :references:in-reply-to:mime-version:dkim-signature; bh=qclzEzb88Rc+t48ko4XJR5J/G6hNGvffLYAtLNLjtGg=; b=F1XUbZPehe9RqrSOrMfGBA7SRAUzxeq/Hdir0iiVjX5BhAd1dbPvKkEJLbNZ77fKpV 7XbEJnWOG6Ml3ti8kkFw2TppiBRY/OIyBpaby4TYTi9jl3RsX+/M7/ZD/NXRaNM5IjmW UN2t2rQZAAXhzUJ+2EDzSM64R6LDiDrXqiukWEBCOxf+7/7uiVUz7eEEtxAWyg2lPwcp jR1h0E/B+bN+l7458HYUz/acIWzX1+GKf1Hx9Jx/E7/zJnzwA+IohViRAnY1QHkeEImr xPPe2vaT+qzitTfKA3E7gDZkjEeOYBLcHje+1EyZGZf0NJsrJqTr5ritrh7deCYAflRr UCnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=oMv1VPZr; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id n8-20020a170902e54800b001562b0bf47bsi1469768plf.58.2022.05.02.18.34.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 18:34:48 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=oMv1VPZr; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E18C052B11; Mon, 2 May 2022 18:18:35 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229997AbiECBRV (ORCPT + 99 others); Mon, 2 May 2022 21:17:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229958AbiECBRB (ORCPT ); Mon, 2 May 2022 21:17:01 -0400 Received: from mail-oa1-x2f.google.com (mail-oa1-x2f.google.com [IPv6:2001:4860:4864:20::2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 474E046B15 for ; Mon, 2 May 2022 18:13:30 -0700 (PDT) Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-e2442907a1so15927378fac.8 for ; Mon, 02 May 2022 18:13:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:user-agent:date:message-id :subject:to:cc; bh=qclzEzb88Rc+t48ko4XJR5J/G6hNGvffLYAtLNLjtGg=; b=oMv1VPZrM/ZMi0f31QB0gucXh6+DhBnn6+/swVv6D98hjF8pWpFV/xn5gE3d794mEC xObGXS8eh3MuWnUQHgWMshigJKgs98S9V0q5/CrKww50GnqZclCKCDZCXv+QI3uY6/R1 irOU7irFy7w78/DZbonvKxn9PXcauIBf0eWqY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:in-reply-to:references:from :user-agent:date:message-id:subject:to:cc; bh=qclzEzb88Rc+t48ko4XJR5J/G6hNGvffLYAtLNLjtGg=; b=F5awS4QKq3o+f2l49f+MnP0tJloU3Q2okQ/uCoZOhPitghs1m2zGap7hVda9ziXJ0x nUIafIhnfj+PPLQAz/jbpWn9dmXfEDUoGMlhC0NeTF/Ligj/xkAbVjREBZmtX5VfjpeV KBErGPxodN2GJ7umhsYVTL1CHwRbx1kMD3kKh5NxceFbU/fxznEy5k9L8BMd9J0QMAe0 M4nZSgNLbA7suQwDdvtacLPVpAEQOW2UYPncuWrAXZfR5xIMf2JyqSzUbJf3fZViJMXq O9qSsZufovtFBwAws6RdEVHwnFCmtaDoNQfg/Q6Du1lRAreHs6AUUCMYdynsXeZVOhkP zxSw== X-Gm-Message-State: AOAM531zZEBzJ/wUhzQrNOis9BmJxBL4cgjoHOWns/f/M+hEk6++Vh8O bmZqOKExAksnB++k0q6YjyO/c9WGo259JdJpQUKA6Q== X-Received: by 2002:a05:6870:40c1:b0:ed:9a12:3f95 with SMTP id l1-20020a05687040c100b000ed9a123f95mr806123oal.193.1651540409644; Mon, 02 May 2022 18:13:29 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 2 May 2022 18:13:29 -0700 MIME-Version: 1.0 In-Reply-To: <1651532668-18873-1-git-send-email-quic_khsieh@quicinc.com> References: <1651532668-18873-1-git-send-email-quic_khsieh@quicinc.com> From: Stephen Boyd User-Agent: alot/0.10 Date: Mon, 2 May 2022 18:13:29 -0700 Message-ID: Subject: Re: [PATCH v2] drm/msm/dp: fix event thread stuck in wait_event after kthread_stop() To: Kuogee Hsieh , agross@kernel.org, airlied@linux.ie, bjorn.andersson@linaro.org, daniel@ffwll.ch, dianders@chromium.org, dmitry.baryshkov@linaro.org, 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 Quoting Kuogee Hsieh (2022-05-02 16:04:28) > Event thread supposed to exit from its while loop after kthread_stop(). > However there may has possibility that event thread is pending in the > middle of wait_event due to condition checking never become true. > To make sure event thread exit its loop after kthread_stop(), this > patch OR kthread_should_stop() into wait_event's condition checking > so that event thread will exit its loop after kernal_stop(). > > Changes in v2: > -- correct spelling error at commit title > > Reported-by: Dmitry Baryshkov > Fixes: 570d3e5d28db ("drm/msm/dp: stop event kernel thread when DP unbind") > Signed-off-by: Kuogee Hsieh > --- > drivers/gpu/drm/msm/dp/dp_display.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c > index c388323..5200a58 100644 > --- a/drivers/gpu/drm/msm/dp/dp_display.c > +++ b/drivers/gpu/drm/msm/dp/dp_display.c > @@ -1106,12 +1106,17 @@ static int hpd_event_thread(void *data) > while (!kthread_should_stop()) { > if (timeout_mode) { > wait_event_timeout(dp_priv->event_q, > - (dp_priv->event_pndx == dp_priv->event_gndx), > - EVENT_TIMEOUT); > + ((dp_priv->event_pndx == dp_priv->event_gndx) || Why the parenthesis (before and after)? > + kthread_should_stop()), EVENT_TIMEOUT); > } else { > wait_event_interruptible(dp_priv->event_q, > - (dp_priv->event_pndx != dp_priv->event_gndx)); > + ((dp_priv->event_pndx != dp_priv->event_gndx) || Why the parenthesis (before and after)? > + kthread_should_stop())); > } > + > + if(kthread_should_stop()) Missing space after if > + break; Is it possible to move the wait_event to the end of the loop and always run the loop initially? That way we don't have to check for kthread_should_stop() again.