Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2156314iof; Tue, 7 Jun 2022 21:38:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhiolpqNqvhfOnfIfL2fZwxHSsYJ0Zjn/4z9JCmR7qLjrBIvQw/I6KSpfnxpDCVoKf2aDs X-Received: by 2002:a17:902:f2ca:b0:167:8898:bad0 with SMTP id h10-20020a170902f2ca00b001678898bad0mr10085330plc.170.1654663102880; Tue, 07 Jun 2022 21:38:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654663102; cv=none; d=google.com; s=arc-20160816; b=Xp8IQy8Vz6Ko48GnapCNRiBGtAJH0BroiaEDE1tOEY6Q2t3PZ0QlYjtppnRsSawJtI AeMqfRrD7pcKX8FxfQ7/3N0jxW2fb07CBqn+EdI9N8tSKy+JEYSOMdefcDwgd+q/pSR/ Vj61S9j/lVluvVeTyjZ76OP6JbDBrcybQP1E/JNGJ+Y/RX1bGOsRJTUtTXIOtUOXC5Ha 7hu/3r4iL+lfhEJIl3zR5aZmAKoZWkPwYNngFl4pquDWOwytMNdaoRZYeo2ylRaLUsQf Lt2yawY30z4tzrOuGAHh8zTnfdUL2Pg4hWkOabY/4162zBrE/DtTAr+5+04huaJr36g/ vNvQ== 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=1O2u0CWLXIidlW0bNMcJnx1V9P6S44s70HW+NDhb0v4=; b=zjyljQgMAZ7SiS14R3cruEv9/h4KnR5ZAgxqhEgKidlNHRLhjBko64rGiYlFmZYDvE z5ZgfNw6vYEhBpcHBFoAItZ1My2eo93YBrdqB+BmBKcxWEXdDwx+zQZo1+27/odan/DV akol/cxD9wmukta+KnLqvA5nCzAJG/M/WmAzPASams5rPXh4ZkALV8V1H7TjRKDEKjdx RvAfbfVy6ioxK6TUDD3dtXZlxz8Rpiw02Fhdd3ktYf4ZotO25NDT4Ix6MNIT/WGdrg8u lRgs1gjYXcNDUZKjJ1XiopRsd4pkO/lumpaZGOgMMq4LGtl61VORhPUF6G6FGTswyKob 5qhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mWEla15L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id oj2-20020a17090b4d8200b001e33369fffasi31826123pjb.88.2022.06.07.21.38.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:38:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mWEla15L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 E0FF64346B4; Tue, 7 Jun 2022 21:08:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348627AbiFGRtv (ORCPT + 99 others); Tue, 7 Jun 2022 13:49:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347463AbiFGRap (ORCPT ); Tue, 7 Jun 2022 13:30:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 658DC111B89; Tue, 7 Jun 2022 10:26:54 -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 F0A1060DE0; Tue, 7 Jun 2022 17:26:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B855C385A5; Tue, 7 Jun 2022 17:26:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654622813; bh=jPH97mOQ/vhneuAL1PtOJd++20+ovSawJ5KDI9CKecs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mWEla15LuEirsM/oHrQXV5miJE28tYpmvWSg3gNc4Gol14cIh1iW1DM6oiDFBoI0n y3qT1DTiMr6/bkuu71Q2r41EGh2EIZwwvS9SA7i0ak1oXC364V0GnI0KBAp3wWx1Rb 6otwn2SEPQCH+NC979q+yZs29rvGv84/bzOeESzI= 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.10 191/452] drm/msm/dp: fix event thread stuck in wait_event after kthread_stop() Date: Tue, 7 Jun 2022 19:00:48 +0200 Message-Id: <20220607164914.254880956@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@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 09c8e50da68d..ebd05678a27b 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -998,15 +998,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