Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp213491iob; Mon, 2 May 2022 17:24:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRf28MthAaSfL05mpwTRNl4BIY0HRAI45XUbSM4s7UsFbKaEm1keM0+MC3czDcX+36mKQm X-Received: by 2002:a17:90b:4f8d:b0:1dc:6cca:1d96 with SMTP id qe13-20020a17090b4f8d00b001dc6cca1d96mr1921078pjb.135.1651537476843; Mon, 02 May 2022 17:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651537476; cv=none; d=google.com; s=arc-20160816; b=IVW3NauPpttBEnY3xabwsxghd5xKmDn6rz0j8y9mFyVvpJhgXbhvL6G1BW7v0Do+z5 euTl8aeL0TIw2nI3Y9EuAlgGjZ4uAFB5z2qBlLvsKi/sjYyKxsO2kCZ2IKFjZlndcD3W z/ewHLrHJzZR6B5k0jFvIaTdV/Ldfkw2XTaQtJwDnuZdHlvV3yfI3VLm4TxEiOqVFt7G 848OVulAz67ytxAmxwnJEpP4nsjwNvWtA9+Ku1UkYdTW5NeugFcMVt5S4NzBuKZNdNwN 183zhmjbALg0RuTu6nUuDWnDvhCD+ZW7cJZNEBycycZa4KJnz6PtnTSfi9hX9wqLSxMd AR3A== 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=8eNPmbau/4LfoRHP9yxK2IXwC14LYshXbF7oIlGvJMI=; b=Ha3r6olOt9qN9XLYHXjrNy/OWc7EC//BqUqsVskYC5hIFFOYv6AdQDxuV4r1h0Sn1z kSgcWm6cqgx0RIXCqTPVJleYUU19dsXkR+KmFRqzG8f1in5UyCZnjxxy1bkDpgF9xJHa hrjWkZYa94W6o4ErY8Kil/Rya7VOofEycuge3TieBTyQrZkAIg89rcXraYHappV7rhZE eaBNa1l/0EgWcNO71HQrSW8zRNI16l91tCFDH5oDu7E83IJ4AXtOot3kyUNbI4Yd0PCh WgXEl47fhvOCDywW4WqK9MlfiroUTSNPWI3KJP6USst3cRJTZlW5l/I83PJQjhT2Vfgp jwqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=sGSZlUtp; 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 q37-20020a17090a1b2800b001cb133b45f3si623097pjq.143.2022.05.02.17.24.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 17:24:36 -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=sGSZlUtp; 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 D0FB83CFF8; Mon, 2 May 2022 17:20:18 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387791AbiEBVyO (ORCPT + 99 others); Mon, 2 May 2022 17:54:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387779AbiEBVyF (ORCPT ); Mon, 2 May 2022 17:54:05 -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 E7422B06; Mon, 2 May 2022 14:50:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1651528234; x=1683064234; h=from:to:cc:subject:date:message-id:mime-version; bh=8eNPmbau/4LfoRHP9yxK2IXwC14LYshXbF7oIlGvJMI=; b=sGSZlUtpo95ESwOCEV1lf/BZF2HjugALSrqoMz0O1Er51MDYjM8wNXFh 1Stq9FHWy8ADwhmTHX4208Z0U9EUxfOynpcu6k3KIuthvhHzG9eD2hl+a Qf6QF1CrgyldDDCg+3UvtZVmQxX+dPlo5rmPg4QhMicF/J9qiaXScCZ1h o=; Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-02.qualcomm.com with ESMTP; 02 May 2022 14:50:34 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg-SD-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2022 14:50:34 -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 14:50:34 -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 14:50:33 -0700 From: Kuogee Hsieh To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH] drm/msm/dp: fix event thread stuck in wait_event after kthread_sop() Date: Mon, 2 May 2022 14:50:23 -0700 Message-ID: <1651528223-882-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(). 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