All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/bridge: anx7625: Make hpd workqueue freezable
@ 2021-06-15  3:29 ` Pi-Hsun Shih
  0 siblings, 0 replies; 6+ messages in thread
From: Pi-Hsun Shih @ 2021-06-15  3:29 UTC (permalink / raw)
  Cc: Pi-Hsun Shih, Tzung-Bi Shih, Andrzej Hajda, Neil Armstrong,
	Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	David Airlie, Daniel Vetter, Xin Ji, Hsin-Yi Wang,
	open list:DRM DRIVERS, open list

There were still a race condition between hpd work and suspend, since
the workqueue work can still be run after anx7625 had powered off in
suspend.

Since we never want hpd work to run while suspending, and there's no
harm to delay them to be run after resume, mark the workqueue as
WQ_FREEZABLE so all works won't run while suspending.

Fixes: 409776fa3c42 ("drm/bridge: anx7625: add suspend / resume hooks")

Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org>
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 7519b7a0f29d..e165be5a2067 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -1730,7 +1730,6 @@ static int __maybe_unused anx7625_suspend(struct device *dev)
 	if (!pm_runtime_enabled(dev) || !pm_runtime_suspended(dev)) {
 		anx7625_runtime_pm_suspend(dev);
 		disable_irq(ctx->pdata.intp_irq);
-		flush_workqueue(ctx->workqueue);
 	}
 
 	return 0;
@@ -1790,7 +1789,8 @@ static int anx7625_i2c_probe(struct i2c_client *client,
 	platform->pdata.intp_irq = client->irq;
 	if (platform->pdata.intp_irq) {
 		INIT_WORK(&platform->work, anx7625_work_func);
-		platform->workqueue = create_workqueue("anx7625_work");
+		platform->workqueue = alloc_workqueue(
+			"anx7625_work", WQ_FREEZABLE | WQ_MEM_RECLAIM, 1);
 		if (!platform->workqueue) {
 			DRM_DEV_ERROR(dev, "fail to create work queue\n");
 			ret = -ENOMEM;

base-commit: 25fe90f43fa312213b653dc1f12fd2d80f855883
-- 
2.32.0.272.g935e593368-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] drm/bridge: anx7625: Make hpd workqueue freezable
@ 2021-06-15  3:29 ` Pi-Hsun Shih
  0 siblings, 0 replies; 6+ messages in thread
From: Pi-Hsun Shih @ 2021-06-15  3:29 UTC (permalink / raw)
  Cc: Jernej Skrabec, Neil Armstrong, David Airlie,
	open list:DRM DRIVERS, Jonas Karlman, open list, Robert Foss,
	Andrzej Hajda, Tzung-Bi Shih, Laurent Pinchart, Pi-Hsun Shih,
	Hsin-Yi Wang, Xin Ji

There were still a race condition between hpd work and suspend, since
the workqueue work can still be run after anx7625 had powered off in
suspend.

Since we never want hpd work to run while suspending, and there's no
harm to delay them to be run after resume, mark the workqueue as
WQ_FREEZABLE so all works won't run while suspending.

Fixes: 409776fa3c42 ("drm/bridge: anx7625: add suspend / resume hooks")

Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org>
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 7519b7a0f29d..e165be5a2067 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -1730,7 +1730,6 @@ static int __maybe_unused anx7625_suspend(struct device *dev)
 	if (!pm_runtime_enabled(dev) || !pm_runtime_suspended(dev)) {
 		anx7625_runtime_pm_suspend(dev);
 		disable_irq(ctx->pdata.intp_irq);
-		flush_workqueue(ctx->workqueue);
 	}
 
 	return 0;
@@ -1790,7 +1789,8 @@ static int anx7625_i2c_probe(struct i2c_client *client,
 	platform->pdata.intp_irq = client->irq;
 	if (platform->pdata.intp_irq) {
 		INIT_WORK(&platform->work, anx7625_work_func);
-		platform->workqueue = create_workqueue("anx7625_work");
+		platform->workqueue = alloc_workqueue(
+			"anx7625_work", WQ_FREEZABLE | WQ_MEM_RECLAIM, 1);
 		if (!platform->workqueue) {
 			DRM_DEV_ERROR(dev, "fail to create work queue\n");
 			ret = -ENOMEM;

base-commit: 25fe90f43fa312213b653dc1f12fd2d80f855883
-- 
2.32.0.272.g935e593368-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/bridge: anx7625: Make hpd workqueue freezable
  2021-06-15  3:29 ` Pi-Hsun Shih
@ 2021-06-16  3:24   ` Tzung-Bi Shih
  -1 siblings, 0 replies; 6+ messages in thread
From: Tzung-Bi Shih @ 2021-06-16  3:24 UTC (permalink / raw)
  To: Pi-Hsun Shih
  Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, David Airlie, Daniel Vetter,
	Xin Ji, Hsin-Yi Wang, open list:DRM DRIVERS, open list

On Tue, Jun 15, 2021 at 11:29 AM Pi-Hsun Shih <pihsun@chromium.org> wrote:
> Fixes: 409776fa3c42 ("drm/bridge: anx7625: add suspend / resume hooks")
>
> Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org>

Reviewed-by: Tzung-Bi Shih <tzungbi@google.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/bridge: anx7625: Make hpd workqueue freezable
@ 2021-06-16  3:24   ` Tzung-Bi Shih
  0 siblings, 0 replies; 6+ messages in thread
From: Tzung-Bi Shih @ 2021-06-16  3:24 UTC (permalink / raw)
  To: Pi-Hsun Shih
  Cc: Jonas Karlman, David Airlie, Robert Foss, open list:DRM DRIVERS,
	Neil Armstrong, open list, Jernej Skrabec, Andrzej Hajda,
	Laurent Pinchart, Hsin-Yi Wang, Xin Ji

On Tue, Jun 15, 2021 at 11:29 AM Pi-Hsun Shih <pihsun@chromium.org> wrote:
> Fixes: 409776fa3c42 ("drm/bridge: anx7625: add suspend / resume hooks")
>
> Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org>

Reviewed-by: Tzung-Bi Shih <tzungbi@google.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/bridge: anx7625: Make hpd workqueue freezable
  2021-06-16  3:24   ` Tzung-Bi Shih
@ 2021-06-18 12:25     ` Robert Foss
  -1 siblings, 0 replies; 6+ messages in thread
From: Robert Foss @ 2021-06-18 12:25 UTC (permalink / raw)
  To: Tzung-Bi Shih
  Cc: Pi-Hsun Shih, Andrzej Hajda, Neil Armstrong, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, David Airlie, Daniel Vetter,
	Xin Ji, Hsin-Yi Wang, open list:DRM DRIVERS, open list

Fixed checkpatch --strict issue and pushed to drm-misc-next.

https://cgit.freedesktop.org/drm/drm-misc/commit/?id=f03ab6629c7b410d874151cf1d8570899a65fdda

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/bridge: anx7625: Make hpd workqueue freezable
@ 2021-06-18 12:25     ` Robert Foss
  0 siblings, 0 replies; 6+ messages in thread
From: Robert Foss @ 2021-06-18 12:25 UTC (permalink / raw)
  To: Tzung-Bi Shih
  Cc: Jonas Karlman, David Airlie, open list:DRM DRIVERS,
	Neil Armstrong, open list, Jernej Skrabec, Andrzej Hajda,
	Laurent Pinchart, Pi-Hsun Shih, Hsin-Yi Wang, Xin Ji

Fixed checkpatch --strict issue and pushed to drm-misc-next.

https://cgit.freedesktop.org/drm/drm-misc/commit/?id=f03ab6629c7b410d874151cf1d8570899a65fdda

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-06-18 12:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-15  3:29 [PATCH] drm/bridge: anx7625: Make hpd workqueue freezable Pi-Hsun Shih
2021-06-15  3:29 ` Pi-Hsun Shih
2021-06-16  3:24 ` Tzung-Bi Shih
2021-06-16  3:24   ` Tzung-Bi Shih
2021-06-18 12:25   ` Robert Foss
2021-06-18 12:25     ` Robert Foss

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.