2014-11-07 13:54:19

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH v2 0/2] DRM: Add runtime PM to Exynos DSI

Hi,

Changes since v1
================
1. Replace patch 1 changing PM core with fix only for DRM exynos driver.

Description
===========
The goal of the patch 2 is to add runtime PM to the Exynos DSI driver.
This allows LCD power domain to be turned off.

However after adding this patch an interesing issue came in. The DSI
driver could not runtime resume during sustem resume because power
domain was not allowed to power on.

The issue is solved by patch 1.

Tested on Trats2 board.

Comments are welcomed.

Best regards,
Krzysztof


Krzysztof Kozlowski (2):
drm/exynos: Fix DSI resuming fail because power domain being off
drm/exynos/dsi: Add runtime PM so LCD power domain could be turned off

drivers/gpu/drm/exynos/exynos_drm_drv.c | 2 --
drivers/gpu/drm/exynos/exynos_drm_dsi.c | 9 +++++++++
2 files changed, 9 insertions(+), 2 deletions(-)

--
1.9.1


2014-11-07 13:54:33

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH v2 2/2] drm/exynos/dsi: Add runtime PM so LCD power domain could be turned off

Add runtime Power Management to the Exynos DSI driver so the LCD power
domain could be turned off.

This slightly reduces the energy consumption when screen is completely
turned off. On Trats2 board when the system was idle the energy
consumption dropped by 1% (from 92.2 mA to 91.1 mA).

Before the patch:
$ cat cat /sys/kernel/debug/pm_genpd/pm_genpd_summary
lcd0-power-domain on
/devices/11c00000.fimd suspended
/devices/11c80000.dsi unsupported

After applying the patch:
lcd0-power-domain off
/devices/11c00000.fimd suspended
/devices/11c80000.dsi suspended

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/gpu/drm/exynos/exynos_drm_dsi.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
index 24741d8758e8..19ed36d2d557 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
@@ -21,6 +21,7 @@
#include <linux/of_device.h>
#include <linux/of_gpio.h>
#include <linux/phy/phy.h>
+#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>
#include <linux/component.h>

@@ -1356,6 +1357,8 @@ static int exynos_dsi_enable(struct exynos_dsi *dsi)
if (dsi->state & DSIM_STATE_ENABLED)
return 0;

+ pm_runtime_get_sync(dsi->dev);
+
ret = exynos_dsi_poweron(dsi);
if (ret < 0)
return ret;
@@ -1392,6 +1395,8 @@ static void exynos_dsi_disable(struct exynos_dsi *dsi)
drm_panel_unprepare(dsi->panel);
exynos_dsi_poweroff(dsi);

+ pm_runtime_put_sync(dsi->dev);
+
dsi->state &= ~DSIM_STATE_ENABLED;
}

@@ -1772,6 +1777,8 @@ static int exynos_dsi_probe(struct platform_device *pdev)
if (ret)
goto err_del_component;

+ pm_runtime_enable(&pdev->dev);
+
return ret;

err_del_component:
@@ -1781,6 +1788,8 @@ err_del_component:

static int exynos_dsi_remove(struct platform_device *pdev)
{
+ pm_runtime_disable(&pdev->dev);
+
component_del(&pdev->dev, &exynos_dsi_component_ops);
exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR);

--
1.9.1

2014-11-07 13:54:31

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH v2 1/2] drm/exynos: Fix DSI resuming fail because power domain being off

During system resume from suspend to RAM the Exynos DRM driver forced
CRTC mode thus turning display on (DPMS_ON). This lead to runtime resuming
of DSI which failed because whole LCD power domain was off and it was
not allowed to turn on because of system resume in progress.

Forcing mode should not be needed and removing it solves this particular
problem.

This necessary fix for following scenario reproduced on Exynos DRM:
1. Power domain is off before suspending the system.
2. System is suspended to RAM.
3. Resuming starts. The Exynos DRM driver resume callback is called.
4. The Exynos DRM driver calls drm_helper_resume_force_mode() which turns
on the screen by calling exynos_dsi_dpms with DRM_MODE_DPMS_ON.
5. The Exynos DSI driver calls pm_runtime_get. The driver runtime
resumes and this should turn LCD power domain on.
6. Unfortunately the domain cannot be turned on because system resume is
in progress and genpd->prepared_count is positive.

Steps to reproduce:
1. Add runtime PM to Exynos DSI driver.
2. Build Exynos DRM/FB without FRAMEBUFFER_CONSOLE.
3. Enable the connector and screen (e.g. with modeset-vsync).
4. echo 3 > /sys/devices/platform/exynos-drm/graphics/fb0/blank
5. echo mem > /sys/power/state
6. Resume.
[ 77.712469] PM: early resume of devices complete after 3.854 msecs
[ 77.712739] exynos-dsi 11c80000.dsi: pm_genpd_resume()
[ 77.712758] exynos4-fimc 11800000.fimc: pm_genpd_resume()
[ 77.712774] exynos4-fimc 11810000.fimc: pm_genpd_resume()
[ 77.712787] exynos-drm-fimc 11820000.fimc: pm_genpd_resume()
[ 77.712802] exynos-drm-fimc 11830000.fimc: pm_genpd_resume()
[ 77.712815] s5p-mipi-csis 11880000.csis: pm_genpd_resume()
[ 77.712829] s5p-mipi-csis 11890000.csis: pm_genpd_resume()
[ 77.712843] exynos-fimc-lite 12390000.fimc-lite: pm_genpd_resume()
[ 77.712856] exynos-fimc-lite 123a0000.fimc-lite: pm_genpd_resume()
[ 77.713788] exynos4-fb 11c00000.fimd: pm_genpd_resume()
[ 77.713912] wake disabled for irq 184
[ 77.713923] wake disabled for irq 185
[ 77.714082] wake disabled for irq 173
[ 77.715676] wake disabled for irq 176
[ 77.718540] exynos4-fb 11c00000.fimd: pm_genpd_runtime_resume()
[ 77.718567] exynos4-fb 11c00000.fimd: state restore latency exceeded, new value 1708 ns
[ 77.718636] exynos-dsi 11c80000.dsi: pm_genpd_runtime_resume()
[ 77.892366] exynos-dsi 11c80000.dsi: PLL failed to stabilize
[ 77.892377] exynos-dsi 11c80000.dsi: failed to configure DSI PLL
[ 78.192168] exynos-dsi 11c80000.dsi: timeout waiting for reset
[ 78.211578] exynos-dsi 11c80000.dsi: waiting for bus lanes timed out
[ 78.307173] exynos-dsi 11c80000.dsi: xfer timed out: d1 00 (null)
[ 78.307190] panel_s6e8aa0 11c80000.dsi.0: error -110 reading dcs seq(0xd1)
[ 78.307199] panel_s6e8aa0 11c80000.dsi.0: read id failed

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/gpu/drm/exynos/exynos_drm_drv.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index d32165a7f862..8f7110c9d21f 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -200,8 +200,6 @@ static int exynos_drm_resume(struct drm_device *dev)
}
drm_modeset_unlock_all(dev);

- drm_helper_resume_force_mode(dev);
-
return 0;
}

--
1.9.1

Subject: Re: [PATCH v2 2/2] drm/exynos/dsi: Add runtime PM so LCD power domain could be turned off

On 2014년 11월 07일 22:53, Krzysztof Kozlowski wrote:
> Add runtime Power Management to the Exynos DSI driver so the LCD power
> domain could be turned off.
>
> This slightly reduces the energy consumption when screen is completely
> turned off. On Trats2 board when the system was idle the energy
> consumption dropped by 1% (from 92.2 mA to 91.1 mA).
>
> Before the patch:
> $ cat cat /sys/kernel/debug/pm_genpd/pm_genpd_summary
> lcd0-power-domain on
> /devices/11c00000.fimd suspended
> /devices/11c80000.dsi unsupported
>
> After applying the patch:
> lcd0-power-domain off
> /devices/11c00000.fimd suspended
> /devices/11c80000.dsi suspended

Reasonable but this patch incurs page flip test timeout like below,
# modetest -v -s 15@12:720x1280
trying to open device 'i915'...failed.
trying to open device 'radeon'...failed.
trying to open device 'nouveau'...failed.
trying to open device 'vmwgfx'...failed.
trying to open device 'omapdrm'...failed.
trying to open device 'exynos'...success.
setting mode 720x1280-0Hz@XR24 on connectors 15, crtc 12
select timed out or error (ret 0)

I'm not sure why this issue is incurred with this patch even through
this patch is reasonable and correct. So we need more checking.

P.S. I tested it on exynos-drm-next and m0 board.

Thanks,
Inki Dae

>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> ---
> drivers/gpu/drm/exynos/exynos_drm_dsi.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
> index 24741d8758e8..19ed36d2d557 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
> @@ -21,6 +21,7 @@
> #include <linux/of_device.h>
> #include <linux/of_gpio.h>
> #include <linux/phy/phy.h>
> +#include <linux/pm_runtime.h>
> #include <linux/regulator/consumer.h>
> #include <linux/component.h>
>
> @@ -1356,6 +1357,8 @@ static int exynos_dsi_enable(struct exynos_dsi *dsi)
> if (dsi->state & DSIM_STATE_ENABLED)
> return 0;
>
> + pm_runtime_get_sync(dsi->dev);
> +
> ret = exynos_dsi_poweron(dsi);
> if (ret < 0)
> return ret;
> @@ -1392,6 +1395,8 @@ static void exynos_dsi_disable(struct exynos_dsi *dsi)
> drm_panel_unprepare(dsi->panel);
> exynos_dsi_poweroff(dsi);
>
> + pm_runtime_put_sync(dsi->dev);
> +
> dsi->state &= ~DSIM_STATE_ENABLED;
> }
>
> @@ -1772,6 +1777,8 @@ static int exynos_dsi_probe(struct platform_device *pdev)
> if (ret)
> goto err_del_component;
>
> + pm_runtime_enable(&pdev->dev);
> +
> return ret;
>
> err_del_component:
> @@ -1781,6 +1788,8 @@ err_del_component:
>
> static int exynos_dsi_remove(struct platform_device *pdev)
> {
> + pm_runtime_disable(&pdev->dev);
> +
> component_del(&pdev->dev, &exynos_dsi_component_ops);
> exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR);
>
>

Subject: Re: [PATCH v2 1/2] drm/exynos: Fix DSI resuming fail because power domain being off

On 2014년 11월 07일 22:53, Krzysztof Kozlowski wrote:
> During system resume from suspend to RAM the Exynos DRM driver forced
> CRTC mode thus turning display on (DPMS_ON). This lead to runtime resuming
> of DSI which failed because whole LCD power domain was off and it was
> not allowed to turn on because of system resume in progress.
>
> Forcing mode should not be needed and removing it solves this particular
> problem.

only this patch, Applied.

Thanks,
Inki Dae

>
> This necessary fix for following scenario reproduced on Exynos DRM:
> 1. Power domain is off before suspending the system.
> 2. System is suspended to RAM.
> 3. Resuming starts. The Exynos DRM driver resume callback is called.
> 4. The Exynos DRM driver calls drm_helper_resume_force_mode() which turns
> on the screen by calling exynos_dsi_dpms with DRM_MODE_DPMS_ON.
> 5. The Exynos DSI driver calls pm_runtime_get. The driver runtime
> resumes and this should turn LCD power domain on.
> 6. Unfortunately the domain cannot be turned on because system resume is
> in progress and genpd->prepared_count is positive.
>
> Steps to reproduce:
> 1. Add runtime PM to Exynos DSI driver.
> 2. Build Exynos DRM/FB without FRAMEBUFFER_CONSOLE.
> 3. Enable the connector and screen (e.g. with modeset-vsync).
> 4. echo 3 > /sys/devices/platform/exynos-drm/graphics/fb0/blank
> 5. echo mem > /sys/power/state
> 6. Resume.
> [ 77.712469] PM: early resume of devices complete after 3.854 msecs
> [ 77.712739] exynos-dsi 11c80000.dsi: pm_genpd_resume()
> [ 77.712758] exynos4-fimc 11800000.fimc: pm_genpd_resume()
> [ 77.712774] exynos4-fimc 11810000.fimc: pm_genpd_resume()
> [ 77.712787] exynos-drm-fimc 11820000.fimc: pm_genpd_resume()
> [ 77.712802] exynos-drm-fimc 11830000.fimc: pm_genpd_resume()
> [ 77.712815] s5p-mipi-csis 11880000.csis: pm_genpd_resume()
> [ 77.712829] s5p-mipi-csis 11890000.csis: pm_genpd_resume()
> [ 77.712843] exynos-fimc-lite 12390000.fimc-lite: pm_genpd_resume()
> [ 77.712856] exynos-fimc-lite 123a0000.fimc-lite: pm_genpd_resume()
> [ 77.713788] exynos4-fb 11c00000.fimd: pm_genpd_resume()
> [ 77.713912] wake disabled for irq 184
> [ 77.713923] wake disabled for irq 185
> [ 77.714082] wake disabled for irq 173
> [ 77.715676] wake disabled for irq 176
> [ 77.718540] exynos4-fb 11c00000.fimd: pm_genpd_runtime_resume()
> [ 77.718567] exynos4-fb 11c00000.fimd: state restore latency exceeded, new value 1708 ns
> [ 77.718636] exynos-dsi 11c80000.dsi: pm_genpd_runtime_resume()
> [ 77.892366] exynos-dsi 11c80000.dsi: PLL failed to stabilize
> [ 77.892377] exynos-dsi 11c80000.dsi: failed to configure DSI PLL
> [ 78.192168] exynos-dsi 11c80000.dsi: timeout waiting for reset
> [ 78.211578] exynos-dsi 11c80000.dsi: waiting for bus lanes timed out
> [ 78.307173] exynos-dsi 11c80000.dsi: xfer timed out: d1 00 (null)
> [ 78.307190] panel_s6e8aa0 11c80000.dsi.0: error -110 reading dcs seq(0xd1)
> [ 78.307199] panel_s6e8aa0 11c80000.dsi.0: read id failed
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> ---
> drivers/gpu/drm/exynos/exynos_drm_drv.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> index d32165a7f862..8f7110c9d21f 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> @@ -200,8 +200,6 @@ static int exynos_drm_resume(struct drm_device *dev)
> }
> drm_modeset_unlock_all(dev);
>
> - drm_helper_resume_force_mode(dev);
> -
> return 0;
> }
>
>

2014-11-14 07:33:05

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] drm/exynos/dsi: Add runtime PM so LCD power domain could be turned off

On pią, 2014-11-14 at 11:53 +0900, Inki Dae wrote:
> On 2014년 11월 07일 22:53, Krzysztof Kozlowski wrote:
> > Add runtime Power Management to the Exynos DSI driver so the LCD power
> > domain could be turned off.
> >
> > This slightly reduces the energy consumption when screen is completely
> > turned off. On Trats2 board when the system was idle the energy
> > consumption dropped by 1% (from 92.2 mA to 91.1 mA).
> >
> > Before the patch:
> > $ cat cat /sys/kernel/debug/pm_genpd/pm_genpd_summary
> > lcd0-power-domain on
> > /devices/11c00000.fimd suspended
> > /devices/11c80000.dsi unsupported
> >
> > After applying the patch:
> > lcd0-power-domain off
> > /devices/11c00000.fimd suspended
> > /devices/11c80000.dsi suspended
>
> Reasonable but this patch incurs page flip test timeout like below,
> # modetest -v -s 15@12:720x1280
> trying to open device 'i915'...failed.
> trying to open device 'radeon'...failed.
> trying to open device 'nouveau'...failed.
> trying to open device 'vmwgfx'...failed.
> trying to open device 'omapdrm'...failed.
> trying to open device 'exynos'...success.
> setting mode 720x1280-0Hz@XR24 on connectors 15, crtc 12
> select timed out or error (ret 0)
>
> I'm not sure why this issue is incurred with this patch even through
> this patch is reasonable and correct. So we need more checking.
>
> P.S. I tested it on exynos-drm-next and m0 board.

Thanks for pointing this issue. I'll investigate it.

Best regards,
Krzysztof