All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/2] drm/bridge: analogix_dp: Grab runtime PM reference for DP-AUX
@ 2022-02-17 22:41 ` Brian Norris
  0 siblings, 0 replies; 15+ messages in thread
From: Brian Norris @ 2022-02-17 22:41 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong
  Cc: linux-kernel, linux-rockchip, Doug Anderson, Sean Paul,
	Jernej Skrabec, dri-devel, Laurent Pinchart, Jonas Karlman,
	Brian Norris, stable, Tomeu Vizoso

If the display is not enable()d, then we aren't holding a runtime PM
reference here. Thus, it's easy to accidentally cause a hang, if user
space is poking around at /dev/drm_dp_aux0 at the "wrong" time.

Let's get a runtime PM reference, and check that we "see" the panel.
Don't force any panel power-up, etc., because that can be intrusive, and
that's not what other drivers do (see
drivers/gpu/drm/bridge/ti-sn65dsi86.c and
drivers/gpu/drm/bridge/parade-ps8640.c.)

Fixes: 0d97ad03f422 ("drm/bridge: analogix_dp: Remove duplicated code")
Cc: <stable@vger.kernel.org>
Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: Brian Norris <briannorris@chromium.org>
---

Changes in v3:
- Avoid panel power-up; just check for HPD state, and let the rest
  happen "as-is" (e.g., time out, if the caller hasn't prepared things
  properly)

Changes in v2:
- Fix spelling in Subject
- DRM_DEV_ERROR() -> drm_err()
- Propagate errors from un-analogix_dp_prepare_panel()

 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index b7d2e4449cfa..16be279aed2c 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -1632,8 +1632,19 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux,
 				       struct drm_dp_aux_msg *msg)
 {
 	struct analogix_dp_device *dp = to_dp(aux);
+	int ret;
+
+	pm_runtime_get_sync(dp->dev);
+
+	ret = analogix_dp_detect_hpd(dp);
+	if (ret)
+		goto out;
 
-	return analogix_dp_transfer(dp, msg);
+	ret = analogix_dp_transfer(dp, msg);
+out:
+	pm_runtime_put(dp->dev);
+
+	return ret;
 }
 
 struct analogix_dp_device *
-- 
2.35.1.265.g69c8d7142f-goog


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

* [PATCH v3 1/2] drm/bridge: analogix_dp: Grab runtime PM reference for DP-AUX
@ 2022-02-17 22:41 ` Brian Norris
  0 siblings, 0 replies; 15+ messages in thread
From: Brian Norris @ 2022-02-17 22:41 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong
  Cc: linux-kernel, linux-rockchip, Doug Anderson, Sean Paul,
	Jernej Skrabec, dri-devel, Laurent Pinchart, Jonas Karlman,
	Brian Norris, stable, Tomeu Vizoso

If the display is not enable()d, then we aren't holding a runtime PM
reference here. Thus, it's easy to accidentally cause a hang, if user
space is poking around at /dev/drm_dp_aux0 at the "wrong" time.

Let's get a runtime PM reference, and check that we "see" the panel.
Don't force any panel power-up, etc., because that can be intrusive, and
that's not what other drivers do (see
drivers/gpu/drm/bridge/ti-sn65dsi86.c and
drivers/gpu/drm/bridge/parade-ps8640.c.)

Fixes: 0d97ad03f422 ("drm/bridge: analogix_dp: Remove duplicated code")
Cc: <stable@vger.kernel.org>
Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: Brian Norris <briannorris@chromium.org>
---

Changes in v3:
- Avoid panel power-up; just check for HPD state, and let the rest
  happen "as-is" (e.g., time out, if the caller hasn't prepared things
  properly)

Changes in v2:
- Fix spelling in Subject
- DRM_DEV_ERROR() -> drm_err()
- Propagate errors from un-analogix_dp_prepare_panel()

 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index b7d2e4449cfa..16be279aed2c 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -1632,8 +1632,19 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux,
 				       struct drm_dp_aux_msg *msg)
 {
 	struct analogix_dp_device *dp = to_dp(aux);
+	int ret;
+
+	pm_runtime_get_sync(dp->dev);
+
+	ret = analogix_dp_detect_hpd(dp);
+	if (ret)
+		goto out;
 
-	return analogix_dp_transfer(dp, msg);
+	ret = analogix_dp_transfer(dp, msg);
+out:
+	pm_runtime_put(dp->dev);
+
+	return ret;
 }
 
 struct analogix_dp_device *
-- 
2.35.1.265.g69c8d7142f-goog


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* [PATCH v3 1/2] drm/bridge: analogix_dp: Grab runtime PM reference for DP-AUX
@ 2022-02-17 22:41 ` Brian Norris
  0 siblings, 0 replies; 15+ messages in thread
From: Brian Norris @ 2022-02-17 22:41 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong
  Cc: Tomeu Vizoso, Jonas Karlman, Brian Norris, linux-kernel,
	dri-devel, Doug Anderson, linux-rockchip, Jernej Skrabec, stable,
	Sean Paul, Laurent Pinchart

If the display is not enable()d, then we aren't holding a runtime PM
reference here. Thus, it's easy to accidentally cause a hang, if user
space is poking around at /dev/drm_dp_aux0 at the "wrong" time.

Let's get a runtime PM reference, and check that we "see" the panel.
Don't force any panel power-up, etc., because that can be intrusive, and
that's not what other drivers do (see
drivers/gpu/drm/bridge/ti-sn65dsi86.c and
drivers/gpu/drm/bridge/parade-ps8640.c.)

Fixes: 0d97ad03f422 ("drm/bridge: analogix_dp: Remove duplicated code")
Cc: <stable@vger.kernel.org>
Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: Brian Norris <briannorris@chromium.org>
---

Changes in v3:
- Avoid panel power-up; just check for HPD state, and let the rest
  happen "as-is" (e.g., time out, if the caller hasn't prepared things
  properly)

Changes in v2:
- Fix spelling in Subject
- DRM_DEV_ERROR() -> drm_err()
- Propagate errors from un-analogix_dp_prepare_panel()

 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index b7d2e4449cfa..16be279aed2c 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -1632,8 +1632,19 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux,
 				       struct drm_dp_aux_msg *msg)
 {
 	struct analogix_dp_device *dp = to_dp(aux);
+	int ret;
+
+	pm_runtime_get_sync(dp->dev);
+
+	ret = analogix_dp_detect_hpd(dp);
+	if (ret)
+		goto out;
 
-	return analogix_dp_transfer(dp, msg);
+	ret = analogix_dp_transfer(dp, msg);
+out:
+	pm_runtime_put(dp->dev);
+
+	return ret;
 }
 
 struct analogix_dp_device *
-- 
2.35.1.265.g69c8d7142f-goog


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

* [PATCH v3 2/2] drm/bridge: analogix_dp: Enable autosuspend
  2022-02-17 22:41 ` Brian Norris
  (?)
@ 2022-02-17 22:41   ` Brian Norris
  -1 siblings, 0 replies; 15+ messages in thread
From: Brian Norris @ 2022-02-17 22:41 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong
  Cc: linux-kernel, linux-rockchip, Doug Anderson, Sean Paul,
	Jernej Skrabec, dri-devel, Laurent Pinchart, Jonas Karlman,
	Brian Norris

DP AUX transactions can consist of many short operations. There's no
need to power things up/down in short intervals.

I pick an arbitrary 100ms; for the systems I'm testing (Rockchip
RK3399), runtime-PM transitions only take a few microseconds.

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

Changes in v3:
 - New in v3

 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 16be279aed2c..d82a4ddf44e7 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -1121,7 +1121,7 @@ static int analogix_dp_get_modes(struct drm_connector *connector)
 
 		pm_runtime_get_sync(dp->dev);
 		edid = drm_get_edid(connector, &dp->aux.ddc);
-		pm_runtime_put(dp->dev);
+		pm_runtime_put_autosuspend(dp->dev);
 		if (edid) {
 			drm_connector_update_edid_property(&dp->connector,
 							   edid);
@@ -1642,7 +1642,7 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux,
 
 	ret = analogix_dp_transfer(dp, msg);
 out:
-	pm_runtime_put(dp->dev);
+	pm_runtime_put_autosuspend(dp->dev);
 
 	return ret;
 }
@@ -1775,6 +1775,8 @@ int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev)
 	if (ret)
 		return ret;
 
+	pm_runtime_use_autosuspend(dp->dev);
+	pm_runtime_set_autosuspend_delay(dp->dev, 100);
 	pm_runtime_enable(dp->dev);
 
 	ret = analogix_dp_create_bridge(drm_dev, dp);
-- 
2.35.1.265.g69c8d7142f-goog


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

* [PATCH v3 2/2] drm/bridge: analogix_dp: Enable autosuspend
@ 2022-02-17 22:41   ` Brian Norris
  0 siblings, 0 replies; 15+ messages in thread
From: Brian Norris @ 2022-02-17 22:41 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong
  Cc: linux-kernel, linux-rockchip, Doug Anderson, Sean Paul,
	Jernej Skrabec, dri-devel, Laurent Pinchart, Jonas Karlman,
	Brian Norris

DP AUX transactions can consist of many short operations. There's no
need to power things up/down in short intervals.

I pick an arbitrary 100ms; for the systems I'm testing (Rockchip
RK3399), runtime-PM transitions only take a few microseconds.

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

Changes in v3:
 - New in v3

 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 16be279aed2c..d82a4ddf44e7 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -1121,7 +1121,7 @@ static int analogix_dp_get_modes(struct drm_connector *connector)
 
 		pm_runtime_get_sync(dp->dev);
 		edid = drm_get_edid(connector, &dp->aux.ddc);
-		pm_runtime_put(dp->dev);
+		pm_runtime_put_autosuspend(dp->dev);
 		if (edid) {
 			drm_connector_update_edid_property(&dp->connector,
 							   edid);
@@ -1642,7 +1642,7 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux,
 
 	ret = analogix_dp_transfer(dp, msg);
 out:
-	pm_runtime_put(dp->dev);
+	pm_runtime_put_autosuspend(dp->dev);
 
 	return ret;
 }
@@ -1775,6 +1775,8 @@ int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev)
 	if (ret)
 		return ret;
 
+	pm_runtime_use_autosuspend(dp->dev);
+	pm_runtime_set_autosuspend_delay(dp->dev, 100);
 	pm_runtime_enable(dp->dev);
 
 	ret = analogix_dp_create_bridge(drm_dev, dp);
-- 
2.35.1.265.g69c8d7142f-goog


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* [PATCH v3 2/2] drm/bridge: analogix_dp: Enable autosuspend
@ 2022-02-17 22:41   ` Brian Norris
  0 siblings, 0 replies; 15+ messages in thread
From: Brian Norris @ 2022-02-17 22:41 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong
  Cc: Jonas Karlman, Brian Norris, linux-kernel, dri-devel,
	Doug Anderson, linux-rockchip, Jernej Skrabec, Sean Paul,
	Laurent Pinchart

DP AUX transactions can consist of many short operations. There's no
need to power things up/down in short intervals.

I pick an arbitrary 100ms; for the systems I'm testing (Rockchip
RK3399), runtime-PM transitions only take a few microseconds.

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

Changes in v3:
 - New in v3

 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 16be279aed2c..d82a4ddf44e7 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -1121,7 +1121,7 @@ static int analogix_dp_get_modes(struct drm_connector *connector)
 
 		pm_runtime_get_sync(dp->dev);
 		edid = drm_get_edid(connector, &dp->aux.ddc);
-		pm_runtime_put(dp->dev);
+		pm_runtime_put_autosuspend(dp->dev);
 		if (edid) {
 			drm_connector_update_edid_property(&dp->connector,
 							   edid);
@@ -1642,7 +1642,7 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux,
 
 	ret = analogix_dp_transfer(dp, msg);
 out:
-	pm_runtime_put(dp->dev);
+	pm_runtime_put_autosuspend(dp->dev);
 
 	return ret;
 }
@@ -1775,6 +1775,8 @@ int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev)
 	if (ret)
 		return ret;
 
+	pm_runtime_use_autosuspend(dp->dev);
+	pm_runtime_set_autosuspend_delay(dp->dev, 100);
 	pm_runtime_enable(dp->dev);
 
 	ret = analogix_dp_create_bridge(drm_dev, dp);
-- 
2.35.1.265.g69c8d7142f-goog


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

* Re: [PATCH v3 2/2] drm/bridge: analogix_dp: Enable autosuspend
  2022-02-17 22:41   ` Brian Norris
  (?)
@ 2022-02-22 22:09     ` Doug Anderson
  -1 siblings, 0 replies; 15+ messages in thread
From: Doug Anderson @ 2022-02-22 22:09 UTC (permalink / raw)
  To: Brian Norris
  Cc: Andrzej Hajda, Neil Armstrong, LKML,
	open list:ARM/Rockchip SoC...,
	Sean Paul, Jernej Skrabec, dri-devel, Laurent Pinchart,
	Jonas Karlman

Hi,

On Thu, Feb 17, 2022 at 2:42 PM Brian Norris <briannorris@chromium.org> wrote:
>
> DP AUX transactions can consist of many short operations. There's no
> need to power things up/down in short intervals.
>
> I pick an arbitrary 100ms; for the systems I'm testing (Rockchip
> RK3399), runtime-PM transitions only take a few microseconds.
>
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> ---
>
> Changes in v3:
>  - New in v3
>
>  drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> index 16be279aed2c..d82a4ddf44e7 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> @@ -1121,7 +1121,7 @@ static int analogix_dp_get_modes(struct drm_connector *connector)
>
>                 pm_runtime_get_sync(dp->dev);
>                 edid = drm_get_edid(connector, &dp->aux.ddc);
> -               pm_runtime_put(dp->dev);
> +               pm_runtime_put_autosuspend(dp->dev);

So I think you can fully get rid of these ones now and rely on the
ones in the aux transfer, right?


>                 if (edid) {
>                         drm_connector_update_edid_property(&dp->connector,
>                                                            edid);
> @@ -1642,7 +1642,7 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux,
>
>         ret = analogix_dp_transfer(dp, msg);
>  out:
> -       pm_runtime_put(dp->dev);
> +       pm_runtime_put_autosuspend(dp->dev);
>
>         return ret;
>  }
> @@ -1775,6 +1775,8 @@ int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev)
>         if (ret)
>                 return ret;
>
> +       pm_runtime_use_autosuspend(dp->dev);
> +       pm_runtime_set_autosuspend_delay(dp->dev, 100);

It's explicitly listed in the Documentation that you need the
corresponding pm_runtime_dont_use_autosuspend(). Specifically, it
says:

> Drivers in ->remove() callback should undo the runtime PM changes done
> in ->probe(). Usually this means calling pm_runtime_disable(),
> pm_runtime_dont_use_autosuspend() etc.

Not that it's very common to see anyone actually get it right, but I
seem to remember running into an issue when I didn't do it. I think
ti-sn65dsi86 still has it wrong since I found out about this later.
Need to write a patch up for that... Basically you want to put it
right before the two calls in your driver to pm_runtime_disable().

-Doug

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

* Re: [PATCH v3 2/2] drm/bridge: analogix_dp: Enable autosuspend
@ 2022-02-22 22:09     ` Doug Anderson
  0 siblings, 0 replies; 15+ messages in thread
From: Doug Anderson @ 2022-02-22 22:09 UTC (permalink / raw)
  To: Brian Norris
  Cc: Andrzej Hajda, Neil Armstrong, LKML,
	open list:ARM/Rockchip SoC...,
	Sean Paul, Jernej Skrabec, dri-devel, Laurent Pinchart,
	Jonas Karlman

Hi,

On Thu, Feb 17, 2022 at 2:42 PM Brian Norris <briannorris@chromium.org> wrote:
>
> DP AUX transactions can consist of many short operations. There's no
> need to power things up/down in short intervals.
>
> I pick an arbitrary 100ms; for the systems I'm testing (Rockchip
> RK3399), runtime-PM transitions only take a few microseconds.
>
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> ---
>
> Changes in v3:
>  - New in v3
>
>  drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> index 16be279aed2c..d82a4ddf44e7 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> @@ -1121,7 +1121,7 @@ static int analogix_dp_get_modes(struct drm_connector *connector)
>
>                 pm_runtime_get_sync(dp->dev);
>                 edid = drm_get_edid(connector, &dp->aux.ddc);
> -               pm_runtime_put(dp->dev);
> +               pm_runtime_put_autosuspend(dp->dev);

So I think you can fully get rid of these ones now and rely on the
ones in the aux transfer, right?


>                 if (edid) {
>                         drm_connector_update_edid_property(&dp->connector,
>                                                            edid);
> @@ -1642,7 +1642,7 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux,
>
>         ret = analogix_dp_transfer(dp, msg);
>  out:
> -       pm_runtime_put(dp->dev);
> +       pm_runtime_put_autosuspend(dp->dev);
>
>         return ret;
>  }
> @@ -1775,6 +1775,8 @@ int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev)
>         if (ret)
>                 return ret;
>
> +       pm_runtime_use_autosuspend(dp->dev);
> +       pm_runtime_set_autosuspend_delay(dp->dev, 100);

It's explicitly listed in the Documentation that you need the
corresponding pm_runtime_dont_use_autosuspend(). Specifically, it
says:

> Drivers in ->remove() callback should undo the runtime PM changes done
> in ->probe(). Usually this means calling pm_runtime_disable(),
> pm_runtime_dont_use_autosuspend() etc.

Not that it's very common to see anyone actually get it right, but I
seem to remember running into an issue when I didn't do it. I think
ti-sn65dsi86 still has it wrong since I found out about this later.
Need to write a patch up for that... Basically you want to put it
right before the two calls in your driver to pm_runtime_disable().

-Doug

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* Re: [PATCH v3 2/2] drm/bridge: analogix_dp: Enable autosuspend
@ 2022-02-22 22:09     ` Doug Anderson
  0 siblings, 0 replies; 15+ messages in thread
From: Doug Anderson @ 2022-02-22 22:09 UTC (permalink / raw)
  To: Brian Norris
  Cc: Neil Armstrong, Jonas Karlman, LKML, Jernej Skrabec,
	open list:ARM/Rockchip SoC...,
	dri-devel, Andrzej Hajda, Sean Paul, Laurent Pinchart

Hi,

On Thu, Feb 17, 2022 at 2:42 PM Brian Norris <briannorris@chromium.org> wrote:
>
> DP AUX transactions can consist of many short operations. There's no
> need to power things up/down in short intervals.
>
> I pick an arbitrary 100ms; for the systems I'm testing (Rockchip
> RK3399), runtime-PM transitions only take a few microseconds.
>
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> ---
>
> Changes in v3:
>  - New in v3
>
>  drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> index 16be279aed2c..d82a4ddf44e7 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> @@ -1121,7 +1121,7 @@ static int analogix_dp_get_modes(struct drm_connector *connector)
>
>                 pm_runtime_get_sync(dp->dev);
>                 edid = drm_get_edid(connector, &dp->aux.ddc);
> -               pm_runtime_put(dp->dev);
> +               pm_runtime_put_autosuspend(dp->dev);

So I think you can fully get rid of these ones now and rely on the
ones in the aux transfer, right?


>                 if (edid) {
>                         drm_connector_update_edid_property(&dp->connector,
>                                                            edid);
> @@ -1642,7 +1642,7 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux,
>
>         ret = analogix_dp_transfer(dp, msg);
>  out:
> -       pm_runtime_put(dp->dev);
> +       pm_runtime_put_autosuspend(dp->dev);
>
>         return ret;
>  }
> @@ -1775,6 +1775,8 @@ int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev)
>         if (ret)
>                 return ret;
>
> +       pm_runtime_use_autosuspend(dp->dev);
> +       pm_runtime_set_autosuspend_delay(dp->dev, 100);

It's explicitly listed in the Documentation that you need the
corresponding pm_runtime_dont_use_autosuspend(). Specifically, it
says:

> Drivers in ->remove() callback should undo the runtime PM changes done
> in ->probe(). Usually this means calling pm_runtime_disable(),
> pm_runtime_dont_use_autosuspend() etc.

Not that it's very common to see anyone actually get it right, but I
seem to remember running into an issue when I didn't do it. I think
ti-sn65dsi86 still has it wrong since I found out about this later.
Need to write a patch up for that... Basically you want to put it
right before the two calls in your driver to pm_runtime_disable().

-Doug

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

* Re: [PATCH v3 1/2] drm/bridge: analogix_dp: Grab runtime PM reference for DP-AUX
  2022-02-17 22:41 ` Brian Norris
  (?)
@ 2022-02-22 22:10   ` Doug Anderson
  -1 siblings, 0 replies; 15+ messages in thread
From: Doug Anderson @ 2022-02-22 22:10 UTC (permalink / raw)
  To: Brian Norris
  Cc: Andrzej Hajda, Neil Armstrong, LKML,
	open list:ARM/Rockchip SoC...,
	Sean Paul, Jernej Skrabec, dri-devel, Laurent Pinchart,
	Jonas Karlman, # 4.0+,
	Tomeu Vizoso

Hi,

On Thu, Feb 17, 2022 at 2:42 PM Brian Norris <briannorris@chromium.org> wrote:
>
> If the display is not enable()d, then we aren't holding a runtime PM
> reference here. Thus, it's easy to accidentally cause a hang, if user
> space is poking around at /dev/drm_dp_aux0 at the "wrong" time.
>
> Let's get a runtime PM reference, and check that we "see" the panel.
> Don't force any panel power-up, etc., because that can be intrusive, and
> that's not what other drivers do (see
> drivers/gpu/drm/bridge/ti-sn65dsi86.c and
> drivers/gpu/drm/bridge/parade-ps8640.c.)
>
> Fixes: 0d97ad03f422 ("drm/bridge: analogix_dp: Remove duplicated code")
> Cc: <stable@vger.kernel.org>
> Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> ---
>
> Changes in v3:
> - Avoid panel power-up; just check for HPD state, and let the rest
>   happen "as-is" (e.g., time out, if the caller hasn't prepared things
>   properly)
>
> Changes in v2:
> - Fix spelling in Subject
> - DRM_DEV_ERROR() -> drm_err()
> - Propagate errors from un-analogix_dp_prepare_panel()
>
>  drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)

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


-Doug

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

* Re: [PATCH v3 1/2] drm/bridge: analogix_dp: Grab runtime PM reference for DP-AUX
@ 2022-02-22 22:10   ` Doug Anderson
  0 siblings, 0 replies; 15+ messages in thread
From: Doug Anderson @ 2022-02-22 22:10 UTC (permalink / raw)
  To: Brian Norris
  Cc: Andrzej Hajda, Neil Armstrong, LKML,
	open list:ARM/Rockchip SoC...,
	Sean Paul, Jernej Skrabec, dri-devel, Laurent Pinchart,
	Jonas Karlman, # 4.0+,
	Tomeu Vizoso

Hi,

On Thu, Feb 17, 2022 at 2:42 PM Brian Norris <briannorris@chromium.org> wrote:
>
> If the display is not enable()d, then we aren't holding a runtime PM
> reference here. Thus, it's easy to accidentally cause a hang, if user
> space is poking around at /dev/drm_dp_aux0 at the "wrong" time.
>
> Let's get a runtime PM reference, and check that we "see" the panel.
> Don't force any panel power-up, etc., because that can be intrusive, and
> that's not what other drivers do (see
> drivers/gpu/drm/bridge/ti-sn65dsi86.c and
> drivers/gpu/drm/bridge/parade-ps8640.c.)
>
> Fixes: 0d97ad03f422 ("drm/bridge: analogix_dp: Remove duplicated code")
> Cc: <stable@vger.kernel.org>
> Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> ---
>
> Changes in v3:
> - Avoid panel power-up; just check for HPD state, and let the rest
>   happen "as-is" (e.g., time out, if the caller hasn't prepared things
>   properly)
>
> Changes in v2:
> - Fix spelling in Subject
> - DRM_DEV_ERROR() -> drm_err()
> - Propagate errors from un-analogix_dp_prepare_panel()
>
>  drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)

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


-Doug

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* Re: [PATCH v3 1/2] drm/bridge: analogix_dp: Grab runtime PM reference for DP-AUX
@ 2022-02-22 22:10   ` Doug Anderson
  0 siblings, 0 replies; 15+ messages in thread
From: Doug Anderson @ 2022-02-22 22:10 UTC (permalink / raw)
  To: Brian Norris
  Cc: Tomeu Vizoso, Neil Armstrong, Jonas Karlman, LKML,
	Jernej Skrabec, open list:ARM/Rockchip SoC...,
	dri-devel, Andrzej Hajda, # 4.0+,
	Sean Paul, Laurent Pinchart

Hi,

On Thu, Feb 17, 2022 at 2:42 PM Brian Norris <briannorris@chromium.org> wrote:
>
> If the display is not enable()d, then we aren't holding a runtime PM
> reference here. Thus, it's easy to accidentally cause a hang, if user
> space is poking around at /dev/drm_dp_aux0 at the "wrong" time.
>
> Let's get a runtime PM reference, and check that we "see" the panel.
> Don't force any panel power-up, etc., because that can be intrusive, and
> that's not what other drivers do (see
> drivers/gpu/drm/bridge/ti-sn65dsi86.c and
> drivers/gpu/drm/bridge/parade-ps8640.c.)
>
> Fixes: 0d97ad03f422 ("drm/bridge: analogix_dp: Remove duplicated code")
> Cc: <stable@vger.kernel.org>
> Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> ---
>
> Changes in v3:
> - Avoid panel power-up; just check for HPD state, and let the rest
>   happen "as-is" (e.g., time out, if the caller hasn't prepared things
>   properly)
>
> Changes in v2:
> - Fix spelling in Subject
> - DRM_DEV_ERROR() -> drm_err()
> - Propagate errors from un-analogix_dp_prepare_panel()
>
>  drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)

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


-Doug

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

* Re: [PATCH v3 2/2] drm/bridge: analogix_dp: Enable autosuspend
  2022-02-22 22:09     ` Doug Anderson
  (?)
@ 2022-03-02  2:03       ` Brian Norris
  -1 siblings, 0 replies; 15+ messages in thread
From: Brian Norris @ 2022-03-02  2:03 UTC (permalink / raw)
  To: Doug Anderson
  Cc: Andrzej Hajda, Neil Armstrong, LKML,
	open list:ARM/Rockchip SoC...,
	Sean Paul, Jernej Skrabec, dri-devel, Laurent Pinchart,
	Jonas Karlman

On Tue, Feb 22, 2022 at 2:10 PM Doug Anderson <dianders@chromium.org> wrote:
> On Thu, Feb 17, 2022 at 2:42 PM Brian Norris <briannorris@chromium.org> wrote:
> > --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> > +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> > @@ -1121,7 +1121,7 @@ static int analogix_dp_get_modes(struct drm_connector *connector)
> >
> >                 pm_runtime_get_sync(dp->dev);
> >                 edid = drm_get_edid(connector, &dp->aux.ddc);
> > -               pm_runtime_put(dp->dev);
> > +               pm_runtime_put_autosuspend(dp->dev);
>
> So I think you can fully get rid of these ones now and rely on the
> ones in the aux transfer, right?

Yep, good catch.

> >                 if (edid) {
> >                         drm_connector_update_edid_property(&dp->connector,
> >                                                            edid);
> > @@ -1642,7 +1642,7 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux,
> >
> >         ret = analogix_dp_transfer(dp, msg);
> >  out:
> > -       pm_runtime_put(dp->dev);
> > +       pm_runtime_put_autosuspend(dp->dev);
> >
> >         return ret;
> >  }
> > @@ -1775,6 +1775,8 @@ int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev)
> >         if (ret)
> >                 return ret;
> >
> > +       pm_runtime_use_autosuspend(dp->dev);
> > +       pm_runtime_set_autosuspend_delay(dp->dev, 100);
>
> It's explicitly listed in the Documentation that you need the
> corresponding pm_runtime_dont_use_autosuspend(). Specifically, it
> says:
>
> > Drivers in ->remove() callback should undo the runtime PM changes done
> > in ->probe(). Usually this means calling pm_runtime_disable(),
> > pm_runtime_dont_use_autosuspend() etc.
>
> Not that it's very common to see anyone actually get it right, but I
> seem to remember running into an issue when I didn't do it. I think
> ti-sn65dsi86 still has it wrong since I found out about this later.
> Need to write a patch up for that... Basically you want to put it
> right before the two calls in your driver to pm_runtime_disable().

Ack.

Speaking of API misfeatures that we missed: I've failed to call
pm_runtime_mark_last_busy(). I'll add that in the next rev, for the
cases where we weren't already calling *_put_sync() (i.e., presumably
we don't really care to wait around for autosuspend).

*gripe* What a silly API. *gripe*

Brian

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

* Re: [PATCH v3 2/2] drm/bridge: analogix_dp: Enable autosuspend
@ 2022-03-02  2:03       ` Brian Norris
  0 siblings, 0 replies; 15+ messages in thread
From: Brian Norris @ 2022-03-02  2:03 UTC (permalink / raw)
  To: Doug Anderson
  Cc: Andrzej Hajda, Neil Armstrong, LKML,
	open list:ARM/Rockchip SoC...,
	Sean Paul, Jernej Skrabec, dri-devel, Laurent Pinchart,
	Jonas Karlman

On Tue, Feb 22, 2022 at 2:10 PM Doug Anderson <dianders@chromium.org> wrote:
> On Thu, Feb 17, 2022 at 2:42 PM Brian Norris <briannorris@chromium.org> wrote:
> > --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> > +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> > @@ -1121,7 +1121,7 @@ static int analogix_dp_get_modes(struct drm_connector *connector)
> >
> >                 pm_runtime_get_sync(dp->dev);
> >                 edid = drm_get_edid(connector, &dp->aux.ddc);
> > -               pm_runtime_put(dp->dev);
> > +               pm_runtime_put_autosuspend(dp->dev);
>
> So I think you can fully get rid of these ones now and rely on the
> ones in the aux transfer, right?

Yep, good catch.

> >                 if (edid) {
> >                         drm_connector_update_edid_property(&dp->connector,
> >                                                            edid);
> > @@ -1642,7 +1642,7 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux,
> >
> >         ret = analogix_dp_transfer(dp, msg);
> >  out:
> > -       pm_runtime_put(dp->dev);
> > +       pm_runtime_put_autosuspend(dp->dev);
> >
> >         return ret;
> >  }
> > @@ -1775,6 +1775,8 @@ int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev)
> >         if (ret)
> >                 return ret;
> >
> > +       pm_runtime_use_autosuspend(dp->dev);
> > +       pm_runtime_set_autosuspend_delay(dp->dev, 100);
>
> It's explicitly listed in the Documentation that you need the
> corresponding pm_runtime_dont_use_autosuspend(). Specifically, it
> says:
>
> > Drivers in ->remove() callback should undo the runtime PM changes done
> > in ->probe(). Usually this means calling pm_runtime_disable(),
> > pm_runtime_dont_use_autosuspend() etc.
>
> Not that it's very common to see anyone actually get it right, but I
> seem to remember running into an issue when I didn't do it. I think
> ti-sn65dsi86 still has it wrong since I found out about this later.
> Need to write a patch up for that... Basically you want to put it
> right before the two calls in your driver to pm_runtime_disable().

Ack.

Speaking of API misfeatures that we missed: I've failed to call
pm_runtime_mark_last_busy(). I'll add that in the next rev, for the
cases where we weren't already calling *_put_sync() (i.e., presumably
we don't really care to wait around for autosuspend).

*gripe* What a silly API. *gripe*

Brian

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* Re: [PATCH v3 2/2] drm/bridge: analogix_dp: Enable autosuspend
@ 2022-03-02  2:03       ` Brian Norris
  0 siblings, 0 replies; 15+ messages in thread
From: Brian Norris @ 2022-03-02  2:03 UTC (permalink / raw)
  To: Doug Anderson
  Cc: Neil Armstrong, Jonas Karlman, LKML, Jernej Skrabec,
	open list:ARM/Rockchip SoC...,
	dri-devel, Andrzej Hajda, Sean Paul, Laurent Pinchart

On Tue, Feb 22, 2022 at 2:10 PM Doug Anderson <dianders@chromium.org> wrote:
> On Thu, Feb 17, 2022 at 2:42 PM Brian Norris <briannorris@chromium.org> wrote:
> > --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> > +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> > @@ -1121,7 +1121,7 @@ static int analogix_dp_get_modes(struct drm_connector *connector)
> >
> >                 pm_runtime_get_sync(dp->dev);
> >                 edid = drm_get_edid(connector, &dp->aux.ddc);
> > -               pm_runtime_put(dp->dev);
> > +               pm_runtime_put_autosuspend(dp->dev);
>
> So I think you can fully get rid of these ones now and rely on the
> ones in the aux transfer, right?

Yep, good catch.

> >                 if (edid) {
> >                         drm_connector_update_edid_property(&dp->connector,
> >                                                            edid);
> > @@ -1642,7 +1642,7 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux,
> >
> >         ret = analogix_dp_transfer(dp, msg);
> >  out:
> > -       pm_runtime_put(dp->dev);
> > +       pm_runtime_put_autosuspend(dp->dev);
> >
> >         return ret;
> >  }
> > @@ -1775,6 +1775,8 @@ int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev)
> >         if (ret)
> >                 return ret;
> >
> > +       pm_runtime_use_autosuspend(dp->dev);
> > +       pm_runtime_set_autosuspend_delay(dp->dev, 100);
>
> It's explicitly listed in the Documentation that you need the
> corresponding pm_runtime_dont_use_autosuspend(). Specifically, it
> says:
>
> > Drivers in ->remove() callback should undo the runtime PM changes done
> > in ->probe(). Usually this means calling pm_runtime_disable(),
> > pm_runtime_dont_use_autosuspend() etc.
>
> Not that it's very common to see anyone actually get it right, but I
> seem to remember running into an issue when I didn't do it. I think
> ti-sn65dsi86 still has it wrong since I found out about this later.
> Need to write a patch up for that... Basically you want to put it
> right before the two calls in your driver to pm_runtime_disable().

Ack.

Speaking of API misfeatures that we missed: I've failed to call
pm_runtime_mark_last_busy(). I'll add that in the next rev, for the
cases where we weren't already calling *_put_sync() (i.e., presumably
we don't really care to wait around for autosuspend).

*gripe* What a silly API. *gripe*

Brian

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

end of thread, other threads:[~2022-03-02  2:03 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-17 22:41 [PATCH v3 1/2] drm/bridge: analogix_dp: Grab runtime PM reference for DP-AUX Brian Norris
2022-02-17 22:41 ` Brian Norris
2022-02-17 22:41 ` Brian Norris
2022-02-17 22:41 ` [PATCH v3 2/2] drm/bridge: analogix_dp: Enable autosuspend Brian Norris
2022-02-17 22:41   ` Brian Norris
2022-02-17 22:41   ` Brian Norris
2022-02-22 22:09   ` Doug Anderson
2022-02-22 22:09     ` Doug Anderson
2022-02-22 22:09     ` Doug Anderson
2022-03-02  2:03     ` Brian Norris
2022-03-02  2:03       ` Brian Norris
2022-03-02  2:03       ` Brian Norris
2022-02-22 22:10 ` [PATCH v3 1/2] drm/bridge: analogix_dp: Grab runtime PM reference for DP-AUX Doug Anderson
2022-02-22 22:10   ` Doug Anderson
2022-02-22 22:10   ` Doug Anderson

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.