dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] drm/bridge: Add missing clk_disable_unprepare() in analogix_dp_resume()
@ 2022-08-16  6:42 Zhang Zekun
  2022-08-17 20:34 ` Brian Norris
  2022-08-17 20:53 ` Doug Anderson
  0 siblings, 2 replies; 5+ messages in thread
From: Zhang Zekun @ 2022-08-16  6:42 UTC (permalink / raw)
  To: andrzej.hajda, narmstrong, robert.foss, Laurent.pinchart, jonas,
	jernej.skrabec, airlied, daniel, dianders, briannorris,
	dri-devel, linux-kernel
  Cc: xuqiang36

Add the missing clk_disable_unprepare() before return from
analogix_dp_resume() in the error handling case.

Fixes: 211f276ed3d9 ("drm: bridge: analogix/dp: add panel prepare/unprepare in suspend/resume time")
Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
---
 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 8aadcc0aa90b..a0fd652547f5 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -1887,6 +1887,7 @@ int analogix_dp_resume(struct analogix_dp_device *dp)
 	if (dp->plat_data->panel) {
 		if (drm_panel_prepare(dp->plat_data->panel)) {
 			DRM_ERROR("failed to setup the panel\n");
+			clk_disable_unprepare(dp->clock);
 			return -EBUSY;
 		}
 	}
-- 
2.17.1


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

* Re: [PATCH -next] drm/bridge: Add missing clk_disable_unprepare() in analogix_dp_resume()
  2022-08-16  6:42 [PATCH -next] drm/bridge: Add missing clk_disable_unprepare() in analogix_dp_resume() Zhang Zekun
@ 2022-08-17 20:34 ` Brian Norris
  2022-08-18  0:05   ` Brian Norris
  2022-08-17 20:53 ` Doug Anderson
  1 sibling, 1 reply; 5+ messages in thread
From: Brian Norris @ 2022-08-17 20:34 UTC (permalink / raw)
  To: Zhang Zekun
  Cc: Jonas Karlman, David Airlie, Robert Foss, dri-devel,
	Neil Armstrong, Doug Anderson, Jernej Skrabec, Linux Kernel,
	xuqiang36, Laurent Pinchart, Andrzej Hajda

On Mon, Aug 15, 2022 at 11:46 PM Zhang Zekun <zhangzekun11@huawei.com> wrote:
>
> Add the missing clk_disable_unprepare() before return from
> analogix_dp_resume() in the error handling case.
>
> Fixes: 211f276ed3d9 ("drm: bridge: analogix/dp: add panel prepare/unprepare in suspend/resume time")
> Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>

Reviewed-by: Brian Norris <briannorris@chromium.org>

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

* Re: [PATCH -next] drm/bridge: Add missing clk_disable_unprepare() in analogix_dp_resume()
  2022-08-16  6:42 [PATCH -next] drm/bridge: Add missing clk_disable_unprepare() in analogix_dp_resume() Zhang Zekun
  2022-08-17 20:34 ` Brian Norris
@ 2022-08-17 20:53 ` Doug Anderson
  1 sibling, 0 replies; 5+ messages in thread
From: Doug Anderson @ 2022-08-17 20:53 UTC (permalink / raw)
  To: Zhang Zekun
  Cc: Brian Norris, Jonas Karlman, David Airlie, Robert Foss,
	dri-devel, Neil Armstrong, LKML, Jernej Skrabec, xuqiang36,
	Laurent Pinchart, Andrzej Hajda

Hi,

On Mon, Aug 15, 2022 at 11:45 PM Zhang Zekun <zhangzekun11@huawei.com> wrote:
>
> Add the missing clk_disable_unprepare() before return from
> analogix_dp_resume() in the error handling case.
>
> Fixes: 211f276ed3d9 ("drm: bridge: analogix/dp: add panel prepare/unprepare in suspend/resume time")
> Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
> ---
>  drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Douglas Anderson <dianders@chromium.org>

I'll snooze this and check back in approx 1 week. If someone else
hasn't already applied it I'll plan to apply it to drm-misc-fixes.

-Doug

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

* Re: [PATCH -next] drm/bridge: Add missing clk_disable_unprepare() in analogix_dp_resume()
  2022-08-17 20:34 ` Brian Norris
@ 2022-08-18  0:05   ` Brian Norris
  2022-08-23  1:15     ` Brian Norris
  0 siblings, 1 reply; 5+ messages in thread
From: Brian Norris @ 2022-08-18  0:05 UTC (permalink / raw)
  To: Zhang Zekun
  Cc: Jonas Karlman, David Airlie, Robert Foss, dri-devel,
	Neil Armstrong, Doug Anderson, Jernej Skrabec, Linux Kernel,
	xuqiang36, Laurent Pinchart, Andrzej Hajda

On Wed, Aug 17, 2022 at 01:34:13PM -0700, Brian Norris wrote:
> On Mon, Aug 15, 2022 at 11:46 PM Zhang Zekun <zhangzekun11@huawei.com> wrote:
> >
> > Add the missing clk_disable_unprepare() before return from
> > analogix_dp_resume() in the error handling case.
> >
> > Fixes: 211f276ed3d9 ("drm: bridge: analogix/dp: add panel prepare/unprepare in suspend/resume time")
> > Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
> 
> Reviewed-by: Brian Norris <briannorris@chromium.org>

Hmm, actually I'm going to have to retract that now that I've given it
some more testing locally. I happen to have a system where I commonly
hit this error case, and I'm thinking commit 211f276ed3d9 is actually
wrong, and so we shouldn't be "fixing" its error handling -- we should
be reverting it.

In particular, drm_panel_prepare()/drm_panel_unprepare() are *not*
reference-counted APIs, and this is already managed by
analogix_dp_bridge_disable(), which is called by the core DRM helpers
during suspend. Thus, analogix_dp_suspend()/analogix_dp_resume() is
serving to be an unwanted *second* client trying to {un,}prepare the
panel.

The panel drivers tend to handle this OK to some extent, as they (e.g.,
panel-edp.c) guard against redundant operations, but *we* don't --
notice that analogix_dp_suspend() ignores drm_panel_unprepare() errors
for one.

Also, I don't believe device management really handles resume() failures
quite right; in the end, this patch ends up un-balancing the clk count
on the RK3399 Gru-Bob systems I'm testing.

(Side note: every other bridge driver seems to ignore
drm_panel_prepare() failures.)

It's possible this was correct (or at least, not terribly broken) back
when it was written, but then, the DRM core frameworks have evolved
since then. Today, I think we do not need to manage the panel state
directly in suspend()/resume().

All in all:

Nacked-by: Brian Norris <briannorris@chromium.org>
Tested-and-failed-by: Brian Norris <briannorris@chromium.org>

Now separately, I have to figure out why I'm hitting this error case in
the first place...

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

* Re: [PATCH -next] drm/bridge: Add missing clk_disable_unprepare() in analogix_dp_resume()
  2022-08-18  0:05   ` Brian Norris
@ 2022-08-23  1:15     ` Brian Norris
  0 siblings, 0 replies; 5+ messages in thread
From: Brian Norris @ 2022-08-23  1:15 UTC (permalink / raw)
  To: Zhang Zekun
  Cc: Jonas Karlman, David Airlie, Robert Foss, dri-devel,
	Neil Armstrong, Doug Anderson, Jernej Skrabec, Linux Kernel,
	xuqiang36, Laurent Pinchart, Andrzej Hajda

Hi,

On Wed, Aug 17, 2022 at 05:05:25PM -0700, Brian Norris wrote:
> Hmm, actually I'm going to have to retract that now that I've given it
> some more testing locally. I happen to have a system where I commonly
> hit this error case, and I'm thinking commit 211f276ed3d9 is actually
> wrong, and so we shouldn't be "fixing" its error handling -- we should
> be reverting it.

I've submitted that for review here:
https://lore.kernel.org/all/20220822180729.1.I8ac5abe3a4c1c6fd5c061686c6e883c22f69022c@changeid/
[PATCH] Revert "drm: bridge: analogix/dp: add panel prepare/unprepare in suspend/resume time"

I'd appreciate your review/testing.

(NB: I failed to honor the .mailmap for Andrzej Hajda.)

> Now separately, I have to figure out why I'm hitting this error case in
> the first place...

FWIW, I captured the reason in point 3 on the above Revert. The
pm_runtime_*() handling in the panel driver fails (-EACCES) because the
bridge driver is resuming before the panel. (The DRM suspend/resume
helpers handle things in the correct order.)

This problem is also resolved by simply reverting.

Brian

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

end of thread, other threads:[~2022-08-24 18:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-16  6:42 [PATCH -next] drm/bridge: Add missing clk_disable_unprepare() in analogix_dp_resume() Zhang Zekun
2022-08-17 20:34 ` Brian Norris
2022-08-18  0:05   ` Brian Norris
2022-08-23  1:15     ` Brian Norris
2022-08-17 20:53 ` Doug Anderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).