Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp246686iob; Mon, 2 May 2022 18:25:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzshBwzdGHYZTB4BZ1QcWlRLtsS8NqsRywk6PVwb7ndnv6CyRKgJEoKzq34DPk4SxpukJCt X-Received: by 2002:a17:902:da8c:b0:15d:3a9e:e89f with SMTP id j12-20020a170902da8c00b0015d3a9ee89fmr14693972plx.120.1651541126588; Mon, 02 May 2022 18:25:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651541126; cv=none; d=google.com; s=arc-20160816; b=vqw67sjPrGxo9lmpRjNNHZ9z9ljyMn5jdys546+LoDivPHaYlJOylW96eEAWdR8lrG pAADQ2I67FAvEaTEgBXIssqBrYGvWNyOGU4vav7w1F0gb5K6hfA/i8mKKB095KomzdgZ 3CsGW5JnqNft5PFJD5yQPso7XGgdqzYnmv6/RQFuEOHylpvciiIIfsbbvPU30ZsIzINm dQvPGIfNjHFUpfEBUr0W3ktsYqnrYjWJK8F/ePSY4ZJyXkI1zwQ6hK3E6hvdmFKWzBsQ q1htEdJpac4A+Y9gjLTLZu2yhCsys7ixKKPQdcrlhgnT9qxuSjZW7kQ8IVX0PEo7rpH2 qyqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=ckEAP8ApiIt+mqi1MEQVL+jvWJidDY78/Cy+N1HYKmE=; b=BU2Q5WJPVP+69P/t3QD8MebKTNVuI3rBaOGbfyzHOK709bCvL2o7EJD9rHHFmqll4X dI0JpSX7XwJXsz+Xvg5qs2/4Gl9rjEofDyUT0iN7uDQ9x3Q00EuguNNzodaRDIimb+dL kFhfVWb1yR6iq1YbAHHbL02hQEvj7kSLTT1e3LuMWGEWxtJui6ucBnZFQ0I6LxnYZmlr 1L33Qws4iyMvqPTt56Q5+NKdvWyBf3dPcIAzOpWJ/oLk0YJqXjBGKqp8HTcQJA2O024O zP0n261kJAW5YvNBi45t12ZQUIWXnfUyCYr2KTEXCeYISIboLWeMg8O3YqtN/G21ppoZ GLAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=aCdkhN3R; 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=quicinc.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b12-20020a17090aa58c00b001dc2322c29csi674455pjq.149.2022.05.02.18.25.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 18:25:26 -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=@quicinc.com header.s=qcdkim header.b=aCdkhN3R; 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=quicinc.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6793A56FBC; Mon, 2 May 2022 18:04:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232024AbiEBXIK (ORCPT + 99 others); Mon, 2 May 2022 19:08:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231575AbiEBXII (ORCPT ); Mon, 2 May 2022 19:08:08 -0400 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98D8C2DD46; Mon, 2 May 2022 16:04:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1651532678; x=1683068678; h=from:to:cc:subject:date:message-id:mime-version; bh=ckEAP8ApiIt+mqi1MEQVL+jvWJidDY78/Cy+N1HYKmE=; b=aCdkhN3RakadWyfYTbLwAZRGhWid1IG0b7WMbwbGHB7mN1xX2s42yAXt bOivAAPapZSoHMzSoenPBy/JRKq7vHe/hw8r85fxULhj3PLowjJX1toee yoBhPdoX6JmAkO9sCagAI+g/ycN25QnfBSeB+EUBGK64B4j4sVK441qXv c=; Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by alexa-out-sd-02.qualcomm.com with ESMTP; 02 May 2022 16:04:38 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg02-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2022 16:04:35 -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, 2 May 2022 16:04:37 -0700 Received: from khsieh-linux1.qualcomm.com (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, 2 May 2022 16:04:36 -0700 From: Kuogee Hsieh To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v2] drm/msm/dp: fix event thread stuck in wait_event after kthread_stop() Date: Mon, 2 May 2022 16:04:28 -0700 Message-ID: <1651532668-18873-1-git-send-email-quic_khsieh@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,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=no 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 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) || + 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) || + kthread_should_stop())); } + + if(kthread_should_stop()) + break; + spin_lock_irqsave(&dp_priv->event_lock, flag); todo = &dp_priv->event_list[dp_priv->event_gndx]; if (todo->delay) { -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project