* [PATCH v3] drm/msm/dp: fix event thread stuck in wait_event after kthread_stop()
@ 2022-05-03 16:25 ` Kuogee Hsieh
0 siblings, 0 replies; 8+ messages in thread
From: Kuogee Hsieh @ 2022-05-03 16:25 UTC (permalink / raw)
To: robdclark, sean, swboyd, dianders, vkoul, daniel, airlied,
agross, dmitry.baryshkov, bjorn.andersson
Cc: quic_abhinavk, quic_aravindh, quic_khsieh, quic_sbillaka,
freedreno, dri-devel, linux-arm-msm, linux-kernel
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 <dmitry.baryshkov@linaro.org>
Fixes: 570d3e5d28db ("drm/msm/dp: stop event kernel thread when DP unbind")
Signed-off-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
---
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 c388323..da5c03a 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -1103,15 +1103,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) {
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3] drm/msm/dp: fix event thread stuck in wait_event after kthread_stop()
@ 2022-05-03 16:25 ` Kuogee Hsieh
0 siblings, 0 replies; 8+ messages in thread
From: Kuogee Hsieh @ 2022-05-03 16:25 UTC (permalink / raw)
To: robdclark, sean, swboyd, dianders, vkoul, daniel, airlied,
agross, dmitry.baryshkov, bjorn.andersson
Cc: quic_sbillaka, linux-arm-msm, quic_abhinavk, dri-devel,
quic_khsieh, quic_aravindh, freedreno, linux-kernel
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 <dmitry.baryshkov@linaro.org>
Fixes: 570d3e5d28db ("drm/msm/dp: stop event kernel thread when DP unbind")
Signed-off-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
---
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 c388323..da5c03a 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -1103,15 +1103,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) {
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v3] drm/msm/dp: fix event thread stuck in wait_event after kthread_stop()
2022-05-03 16:25 ` Kuogee Hsieh
@ 2022-05-04 18:26 ` Dmitry Baryshkov
-1 siblings, 0 replies; 8+ messages in thread
From: Dmitry Baryshkov @ 2022-05-04 18:26 UTC (permalink / raw)
To: Kuogee Hsieh, robdclark, sean, swboyd, dianders, vkoul, daniel,
airlied, agross, bjorn.andersson
Cc: quic_sbillaka, linux-arm-msm, quic_abhinavk, dri-devel,
linux-kernel, quic_aravindh, freedreno
On 03/05/2022 19:25, Kuogee Hsieh wrote:
> 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 <dmitry.baryshkov@linaro.org>
> Fixes: 570d3e5d28db ("drm/msm/dp: stop event kernel thread when DP unbind")
> Signed-off-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
> 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 c388323..da5c03a 100644
> --- a/drivers/gpu/drm/msm/dp/dp_display.c
> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
> @@ -1103,15 +1103,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) {
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3] drm/msm/dp: fix event thread stuck in wait_event after kthread_stop()
@ 2022-05-04 18:26 ` Dmitry Baryshkov
0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Baryshkov @ 2022-05-04 18:26 UTC (permalink / raw)
To: Kuogee Hsieh, robdclark, sean, swboyd, dianders, vkoul, daniel,
airlied, agross, bjorn.andersson
Cc: quic_abhinavk, quic_aravindh, quic_sbillaka, freedreno,
dri-devel, linux-arm-msm, linux-kernel
On 03/05/2022 19:25, Kuogee Hsieh wrote:
> 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 <dmitry.baryshkov@linaro.org>
> Fixes: 570d3e5d28db ("drm/msm/dp: stop event kernel thread when DP unbind")
> Signed-off-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
> 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 c388323..da5c03a 100644
> --- a/drivers/gpu/drm/msm/dp/dp_display.c
> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
> @@ -1103,15 +1103,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) {
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3] drm/msm/dp: fix event thread stuck in wait_event after kthread_stop()
2022-05-03 16:25 ` Kuogee Hsieh
@ 2022-05-04 18:38 ` Dmitry Baryshkov
-1 siblings, 0 replies; 8+ messages in thread
From: Dmitry Baryshkov @ 2022-05-04 18:38 UTC (permalink / raw)
To: Kuogee Hsieh, robdclark, sean, swboyd, dianders, vkoul, daniel,
airlied, agross, bjorn.andersson
Cc: quic_abhinavk, quic_aravindh, quic_sbillaka, freedreno,
dri-devel, linux-arm-msm, linux-kernel
On 03/05/2022 19:25, Kuogee Hsieh wrote:
> 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 <dmitry.baryshkov@linaro.org>
> Fixes: 570d3e5d28db ("drm/msm/dp: stop event kernel thread when DP unbind")
> Signed-off-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
Let's do it properly:
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
> 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 c388323..da5c03a 100644
> --- a/drivers/gpu/drm/msm/dp/dp_display.c
> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
> @@ -1103,15 +1103,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) {
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3] drm/msm/dp: fix event thread stuck in wait_event after kthread_stop()
@ 2022-05-04 18:38 ` Dmitry Baryshkov
0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Baryshkov @ 2022-05-04 18:38 UTC (permalink / raw)
To: Kuogee Hsieh, robdclark, sean, swboyd, dianders, vkoul, daniel,
airlied, agross, bjorn.andersson
Cc: quic_sbillaka, linux-arm-msm, quic_abhinavk, dri-devel,
linux-kernel, quic_aravindh, freedreno
On 03/05/2022 19:25, Kuogee Hsieh wrote:
> 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 <dmitry.baryshkov@linaro.org>
> Fixes: 570d3e5d28db ("drm/msm/dp: stop event kernel thread when DP unbind")
> Signed-off-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
Let's do it properly:
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
> 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 c388323..da5c03a 100644
> --- a/drivers/gpu/drm/msm/dp/dp_display.c
> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
> @@ -1103,15 +1103,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) {
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3] drm/msm/dp: fix event thread stuck in wait_event after kthread_stop()
2022-05-03 16:25 ` Kuogee Hsieh
@ 2022-05-04 18:44 ` Stephen Boyd
-1 siblings, 0 replies; 8+ messages in thread
From: Stephen Boyd @ 2022-05-04 18:44 UTC (permalink / raw)
To: Kuogee Hsieh, agross, airlied, bjorn.andersson, daniel, dianders,
dmitry.baryshkov, robdclark, sean, vkoul
Cc: quic_abhinavk, quic_aravindh, quic_sbillaka, freedreno,
dri-devel, linux-arm-msm, linux-kernel
Quoting Kuogee Hsieh (2022-05-03 09:25:36)
> 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 <dmitry.baryshkov@linaro.org>
> Fixes: 570d3e5d28db ("drm/msm/dp: stop event kernel thread when DP unbind")
> Signed-off-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
> ---
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3] drm/msm/dp: fix event thread stuck in wait_event after kthread_stop()
@ 2022-05-04 18:44 ` Stephen Boyd
0 siblings, 0 replies; 8+ messages in thread
From: Stephen Boyd @ 2022-05-04 18:44 UTC (permalink / raw)
To: Kuogee Hsieh, agross, airlied, bjorn.andersson, daniel, dianders,
dmitry.baryshkov, robdclark, sean, vkoul
Cc: quic_sbillaka, linux-arm-msm, quic_abhinavk, dri-devel,
linux-kernel, quic_aravindh, freedreno
Quoting Kuogee Hsieh (2022-05-03 09:25:36)
> 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 <dmitry.baryshkov@linaro.org>
> Fixes: 570d3e5d28db ("drm/msm/dp: stop event kernel thread when DP unbind")
> Signed-off-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
> ---
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-05-04 18:44 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-03 16:25 [PATCH v3] drm/msm/dp: fix event thread stuck in wait_event after kthread_stop() Kuogee Hsieh
2022-05-03 16:25 ` Kuogee Hsieh
2022-05-04 18:26 ` Dmitry Baryshkov
2022-05-04 18:26 ` Dmitry Baryshkov
2022-05-04 18:38 ` Dmitry Baryshkov
2022-05-04 18:38 ` Dmitry Baryshkov
2022-05-04 18:44 ` Stephen Boyd
2022-05-04 18:44 ` Stephen Boyd
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.