Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2184002iof; Tue, 7 Jun 2022 22:29:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwL0X0jBEUBEC6Nz0xCfKS9a+D0kBfMngDDWv5CYpe1e3tQoMsj6TxrtrDcxBLZwDsWuBQD X-Received: by 2002:a63:2b8b:0:b0:3fc:c510:7941 with SMTP id r133-20020a632b8b000000b003fcc5107941mr29222851pgr.47.1654666168938; Tue, 07 Jun 2022 22:29:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666168; cv=none; d=google.com; s=arc-20160816; b=K0hqfflSB88j17qEAuzGo/cNYkWKikV4oJKPRUJoPIi9NhS6oP27+ccskYmqzWDIfm p7hDyasV76q4dSkCq/2PSQ+J/+49T/X7x81IXVrGEY/urzSJQwY9WnffZuNbQir6oXce VkscXDDLKwiTa+Yb5KJLH395qNvj31hgj1gAGEygXMPuflIisVVvOWvO6447mjpCEvfz W3QS+YQekcJ7kgfz7j28kYA8ZU+EsDP34EPq0u+hzni25EoGm4pnOINJO3WhhsNXt6j2 6XkGepm/ejK5Zxmcx6xkuSTnLkL1CC2Yorwg3v82QMh7cC8/Q/7LN+4vJlXYurGbh82q EZjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VtsS1+sd/G8pZml+Gt6cQB/gJdvxSKouu70iiwyV/t8=; b=JCaTlxTXctIj03QJDkqeT+pZ+lMC8Vlhso7wYje5WW8VitJ6bxzu1ZYSqzWwmnmHHG qNGM+0BeF+mphGTIt329pi/ti2hyu9N34qF8cvE1VYWXMZCoLGnRb/OndGSvcoGSnuRZ Sopop4F99rL+kFAMQLS/xiDI6UObkEzbL40o2hhAR2wRPmJc3Dz9zadMyoILWsTfPJfx lDlxUMpvmRwYTQolRGCHk+vx0X9Qs3ftunGppelqyM9ei7ERuNR1qk+vanR5MKTRgDVM SXFGhJvuc4jWJwwKdhn78J3prFqwDvnzlrk3vTQBlrtA+RRLhlf0Kff+lChodm6g4I// Mleg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NzWubk75; 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=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id l191-20020a6388c8000000b003fe28119604si1615224pgd.270.2022.06.07.22.29.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:29:28 -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=@linuxfoundation.org header.s=korg header.b=NzWubk75; 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=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6CAFA47E415; Tue, 7 Jun 2022 21:55:20 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381646AbiFGWng (ORCPT + 99 others); Tue, 7 Jun 2022 18:43:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381015AbiFGVbd (ORCPT ); Tue, 7 Jun 2022 17:31:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F3F022CBC0; Tue, 7 Jun 2022 12:03:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1FCFE61787; Tue, 7 Jun 2022 19:03:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C0C2C385A2; Tue, 7 Jun 2022 19:03:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628631; bh=BDDoZxr1eKu5Wdw7H5zkc4+WOHk5bi0DYo1GO1cBECY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NzWubk7529KEiN54RxV6TXk8VbPr/CVbmZjoc81Sw6qC3viIWz/rRfUxKFh5Qy3VP TMFqKLTkoeI19lRJzaK76seAIeGelDr3EwLODdn5KOKKj/K1rUmw2X/mjUBvQ4oOrr RsPbgvKZGL+Q1NVcAyqjIe/KrvqId7eJ5aVv6osY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Baryshkov , Kuogee Hsieh , Stephen Boyd , Sasha Levin Subject: [PATCH 5.18 398/879] drm/msm/dp: fix event thread stuck in wait_event after kthread_stop() Date: Tue, 7 Jun 2022 18:58:36 +0200 Message-Id: <20220607165014.416736656@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 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 From: Kuogee Hsieh [ Upstream commit 2f9b5b3ae2eb625b75a898212a76f3b8c6d0d2b0 ] 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 Changes in v3: -- remove unnecessary parenthesis -- while(1) to replace while (!kthread_should_stop()) Reported-by: Dmitry Baryshkov Fixes: 570d3e5d28db ("drm/msm/dp: stop event kernel thread when DP unbind") Signed-off-by: Kuogee Hsieh Reviewed-by: Dmitry Baryshkov Reviewed-by: Stephen Boyd Patchwork: https://patchwork.freedesktop.org/patch/484576/ Link: https://lore.kernel.org/r/1651595136-24312-1-git-send-email-quic_khsieh@quicinc.com Signed-off-by: Dmitry Baryshkov Signed-off-by: Sasha Levin --- drivers/gpu/drm/msm/dp/dp_display.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index b3bfe9ac9d80..8deb92bddfde 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -1107,15 +1107,20 @@ static int hpd_event_thread(void *data) dp_priv = (struct dp_display_private *)data; - while (!kthread_should_stop()) { + while (1) { 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) { -- 2.35.1