2019-08-27 09:59:36

by Neil Armstrong

[permalink] [raw]
Subject: [PATCH 0/2] drm/meson: add resume/suspend hooks

This serie adds the resume/suspend hooks in the Amlogic Meson VPU main driver
and the DW-HDMI Glue driver to correctly save state and disable HW before
suspend, and succesfully re-init the HW to recover functionnal display
after resume.

This serie has been tested on Amlogic G12A based SEI510 board, using
the newly accepted VRTC driver and the rtcwake utility.

Neil Armstrong (2):
drm/meson: dw_hdmi: add resume/suspend hooks
drm/meson: add resume/suspend hooks

drivers/gpu/drm/meson/meson_drv.c | 32 ++++++++
drivers/gpu/drm/meson/meson_dw_hdmi.c | 110 ++++++++++++++++++--------
2 files changed, 108 insertions(+), 34 deletions(-)

--
2.22.0


2019-08-27 10:00:15

by Neil Armstrong

[permalink] [raw]
Subject: [PATCH 2/2] drm/meson: add resume/suspend hooks

Add the suspend and resume hooks to:
- save and disable the entire DRM driver on suspend
- re-init the entire VPU subsystem on resume, to recover CRTC and pixel
generator functionnal usage after DDR suspend, then recover DRM driver
state

Signed-off-by: Neil Armstrong <[email protected]>
---
drivers/gpu/drm/meson/meson_drv.c | 32 +++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)

diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
index 2310c96fff46..dc573ffd1f4c 100644
--- a/drivers/gpu/drm/meson/meson_drv.c
+++ b/drivers/gpu/drm/meson/meson_drv.c
@@ -361,6 +361,33 @@ static const struct component_master_ops meson_drv_master_ops = {
.unbind = meson_drv_unbind,
};

+static int __maybe_unused meson_drv_pm_suspend(struct device *dev)
+{
+ struct meson_drm *priv = dev_get_drvdata(dev);
+
+ if (!priv)
+ return 0;
+
+ return drm_mode_config_helper_suspend(priv->drm);
+}
+
+static int __maybe_unused meson_drv_pm_resume(struct device *dev)
+{
+ struct meson_drm *priv = dev_get_drvdata(dev);
+
+ if (!priv)
+ return 0;
+
+ meson_vpu_init(priv);
+ meson_venc_init(priv);
+ meson_vpp_init(priv);
+ meson_viu_init(priv);
+
+ drm_mode_config_helper_resume(priv->drm);
+
+ return 0;
+}
+
static int compare_of(struct device *dev, void *data)
{
DRM_DEBUG_DRIVER("Comparing of node %pOF with %pOF\n",
@@ -452,11 +479,16 @@ static const struct of_device_id dt_match[] = {
};
MODULE_DEVICE_TABLE(of, dt_match);

+static const struct dev_pm_ops meson_drv_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(meson_drv_pm_suspend, meson_drv_pm_resume)
+};
+
static struct platform_driver meson_drm_platform_driver = {
.probe = meson_drv_probe,
.driver = {
.name = "meson-drm",
.of_match_table = dt_match,
+ .pm = &meson_drv_pm_ops,
},
};

--
2.22.0

2019-08-27 10:01:28

by Neil Armstrong

[permalink] [raw]
Subject: [PATCH 1/2] drm/meson: dw_hdmi: add resume/suspend hooks

Add the suspens and resume hooks to:
- reset the whole HDMI glue and HDMI controller on suspend
- re-init the HDMI glue and HDMI controller on resume

The HDMI glue init is refactored to be re-used from the resume hook.

It makes usage of dw_hdmi_resume() to recover a functionnal DDC bus.

Signed-off-by: Neil Armstrong <[email protected]>
---
drivers/gpu/drm/meson/meson_dw_hdmi.c | 110 ++++++++++++++++++--------
1 file changed, 76 insertions(+), 34 deletions(-)

diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c
index df3f9ddd2234..a722ddbfbede 100644
--- a/drivers/gpu/drm/meson/meson_dw_hdmi.c
+++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c
@@ -799,6 +799,47 @@ static bool meson_hdmi_connector_is_available(struct device *dev)
return false;
}

+static void meson_dw_hdmi_init(struct meson_dw_hdmi *meson_dw_hdmi)
+{
+ struct meson_drm *priv = meson_dw_hdmi->priv;
+
+ /* Enable clocks */
+ regmap_update_bits(priv->hhi, HHI_HDMI_CLK_CNTL, 0xffff, 0x100);
+
+ /* Bring HDMITX MEM output of power down */
+ regmap_update_bits(priv->hhi, HHI_MEM_PD_REG0, 0xff << 8, 0);
+
+ /* Reset HDMITX APB & TX & PHY */
+ reset_control_reset(meson_dw_hdmi->hdmitx_apb);
+ reset_control_reset(meson_dw_hdmi->hdmitx_ctrl);
+ reset_control_reset(meson_dw_hdmi->hdmitx_phy);
+
+ /* Enable APB3 fail on error */
+ if (!meson_vpu_is_compatible(priv, "amlogic,meson-g12a-vpu")) {
+ writel_bits_relaxed(BIT(15), BIT(15),
+ meson_dw_hdmi->hdmitx + HDMITX_TOP_CTRL_REG);
+ writel_bits_relaxed(BIT(15), BIT(15),
+ meson_dw_hdmi->hdmitx + HDMITX_DWC_CTRL_REG);
+ }
+
+ /* Bring out of reset */
+ meson_dw_hdmi->data->top_write(meson_dw_hdmi,
+ HDMITX_TOP_SW_RESET, 0);
+
+ msleep(20);
+
+ meson_dw_hdmi->data->top_write(meson_dw_hdmi,
+ HDMITX_TOP_CLK_CNTL, 0xff);
+
+ /* Enable HDMI-TX Interrupt */
+ meson_dw_hdmi->data->top_write(meson_dw_hdmi, HDMITX_TOP_INTR_STAT_CLR,
+ HDMITX_TOP_INTR_CORE);
+
+ meson_dw_hdmi->data->top_write(meson_dw_hdmi, HDMITX_TOP_INTR_MASKN,
+ HDMITX_TOP_INTR_CORE);
+
+}
+
static int meson_dw_hdmi_bind(struct device *dev, struct device *master,
void *data)
{
@@ -922,40 +963,7 @@ static int meson_dw_hdmi_bind(struct device *dev, struct device *master,

DRM_DEBUG_DRIVER("encoder initialized\n");

- /* Enable clocks */
- regmap_update_bits(priv->hhi, HHI_HDMI_CLK_CNTL, 0xffff, 0x100);
-
- /* Bring HDMITX MEM output of power down */
- regmap_update_bits(priv->hhi, HHI_MEM_PD_REG0, 0xff << 8, 0);
-
- /* Reset HDMITX APB & TX & PHY */
- reset_control_reset(meson_dw_hdmi->hdmitx_apb);
- reset_control_reset(meson_dw_hdmi->hdmitx_ctrl);
- reset_control_reset(meson_dw_hdmi->hdmitx_phy);
-
- /* Enable APB3 fail on error */
- if (!meson_vpu_is_compatible(priv, "amlogic,meson-g12a-vpu")) {
- writel_bits_relaxed(BIT(15), BIT(15),
- meson_dw_hdmi->hdmitx + HDMITX_TOP_CTRL_REG);
- writel_bits_relaxed(BIT(15), BIT(15),
- meson_dw_hdmi->hdmitx + HDMITX_DWC_CTRL_REG);
- }
-
- /* Bring out of reset */
- meson_dw_hdmi->data->top_write(meson_dw_hdmi,
- HDMITX_TOP_SW_RESET, 0);
-
- msleep(20);
-
- meson_dw_hdmi->data->top_write(meson_dw_hdmi,
- HDMITX_TOP_CLK_CNTL, 0xff);
-
- /* Enable HDMI-TX Interrupt */
- meson_dw_hdmi->data->top_write(meson_dw_hdmi, HDMITX_TOP_INTR_STAT_CLR,
- HDMITX_TOP_INTR_CORE);
-
- meson_dw_hdmi->data->top_write(meson_dw_hdmi, HDMITX_TOP_INTR_MASKN,
- HDMITX_TOP_INTR_CORE);
+ meson_dw_hdmi_init(meson_dw_hdmi);

/* Bridge / Connector */

@@ -991,6 +999,34 @@ static const struct component_ops meson_dw_hdmi_ops = {
.unbind = meson_dw_hdmi_unbind,
};

+static int __maybe_unused meson_dw_hdmi_pm_suspend(struct device *dev)
+{
+ struct meson_dw_hdmi *meson_dw_hdmi = dev_get_drvdata(dev);
+
+ if (!meson_dw_hdmi)
+ return 0;
+
+ /* Reset TOP */
+ meson_dw_hdmi->data->top_write(meson_dw_hdmi,
+ HDMITX_TOP_SW_RESET, 0);
+
+ return 0;
+}
+
+static int __maybe_unused meson_dw_hdmi_pm_resume(struct device *dev)
+{
+ struct meson_dw_hdmi *meson_dw_hdmi = dev_get_drvdata(dev);
+
+ if (!meson_dw_hdmi)
+ return 0;
+
+ meson_dw_hdmi_init(meson_dw_hdmi);
+
+ dw_hdmi_resume(meson_dw_hdmi->hdmi);
+
+ return 0;
+}
+
static int meson_dw_hdmi_probe(struct platform_device *pdev)
{
return component_add(&pdev->dev, &meson_dw_hdmi_ops);
@@ -1003,6 +1039,11 @@ static int meson_dw_hdmi_remove(struct platform_device *pdev)
return 0;
}

+static const struct dev_pm_ops meson_dw_hdmi_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(meson_dw_hdmi_pm_suspend,
+ meson_dw_hdmi_pm_resume)
+};
+
static const struct of_device_id meson_dw_hdmi_of_table[] = {
{ .compatible = "amlogic,meson-gxbb-dw-hdmi",
.data = &meson_dw_hdmi_gx_data },
@@ -1022,6 +1063,7 @@ static struct platform_driver meson_dw_hdmi_platform_driver = {
.driver = {
.name = DRIVER_NAME,
.of_match_table = meson_dw_hdmi_of_table,
+ .pm = &meson_dw_hdmi_pm_ops,
},
};
module_platform_driver(meson_dw_hdmi_platform_driver);
--
2.22.0

2019-08-27 16:45:26

by Daniel Vetter

[permalink] [raw]
Subject: Re: [PATCH 0/2] drm/meson: add resume/suspend hooks

On Tue, Aug 27, 2019 at 11:58:23AM +0200, Neil Armstrong wrote:
> This serie adds the resume/suspend hooks in the Amlogic Meson VPU main driver
> and the DW-HDMI Glue driver to correctly save state and disable HW before
> suspend, and succesfully re-init the HW to recover functionnal display
> after resume.
>
> This serie has been tested on Amlogic G12A based SEI510 board, using
> the newly accepted VRTC driver and the rtcwake utility.

No idea about the hw, but looks all neatly integrated into pm stuff, so on
both patches:

Acked-by: Daniel Vetter <[email protected]>
>
> Neil Armstrong (2):
> drm/meson: dw_hdmi: add resume/suspend hooks
> drm/meson: add resume/suspend hooks
>
> drivers/gpu/drm/meson/meson_drv.c | 32 ++++++++
> drivers/gpu/drm/meson/meson_dw_hdmi.c | 110 ++++++++++++++++++--------
> 2 files changed, 108 insertions(+), 34 deletions(-)
>
> --
> 2.22.0
>
> _______________________________________________
> dri-devel mailing list
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

2019-08-27 19:19:51

by Kevin Hilman

[permalink] [raw]
Subject: Re: [PATCH 0/2] drm/meson: add resume/suspend hooks

Neil Armstrong <[email protected]> writes:

> This serie adds the resume/suspend hooks in the Amlogic Meson VPU main driver
> and the DW-HDMI Glue driver to correctly save state and disable HW before
> suspend, and succesfully re-init the HW to recover functionnal display
> after resume.
>
> This serie has been tested on Amlogic G12A based SEI510 board, using
> the newly accepted VRTC driver and the rtcwake utility.

Tested-by: Kevin Hilman <[email protected]>

Tested on my G12A SEI510 board, and I verified that it fixes
suspend/resume issues previously seen.

Kevin

2019-08-28 08:08:30

by Neil Armstrong

[permalink] [raw]
Subject: Re: [PATCH 0/2] drm/meson: add resume/suspend hooks

On 27/08/2019 21:17, Kevin Hilman wrote:
> Neil Armstrong <[email protected]> writes:
>
>> This serie adds the resume/suspend hooks in the Amlogic Meson VPU main driver
>> and the DW-HDMI Glue driver to correctly save state and disable HW before
>> suspend, and succesfully re-init the HW to recover functionnal display
>> after resume.
>>
>> This serie has been tested on Amlogic G12A based SEI510 board, using
>> the newly accepted VRTC driver and the rtcwake utility.
>
> Tested-by: Kevin Hilman <[email protected]>
>
> Tested on my G12A SEI510 board, and I verified that it fixes
> suspend/resume issues previously seen.
>
> Kevin
>

Thanks,

Applying to drm-misc-next (for v5.5), with a typo fix in the first patch commit log:
s/suspens/suspend

Neil

2019-08-28 15:13:49

by Kevin Hilman

[permalink] [raw]
Subject: Re: [PATCH 0/2] drm/meson: add resume/suspend hooks

Neil Armstrong <[email protected]> writes:

> On 27/08/2019 21:17, Kevin Hilman wrote:
>> Neil Armstrong <[email protected]> writes:
>>
>>> This serie adds the resume/suspend hooks in the Amlogic Meson VPU main driver
>>> and the DW-HDMI Glue driver to correctly save state and disable HW before
>>> suspend, and succesfully re-init the HW to recover functionnal display
>>> after resume.
>>>
>>> This serie has been tested on Amlogic G12A based SEI510 board, using
>>> the newly accepted VRTC driver and the rtcwake utility.
>>
>> Tested-by: Kevin Hilman <[email protected]>
>>
>> Tested on my G12A SEI510 board, and I verified that it fixes
>> suspend/resume issues previously seen.
>>
>> Kevin
>>
>
> Thanks,
>
> Applying to drm-misc-next (for v5.5), with a typo fix in the first patch commit log:
> s/suspens/suspend

Is there any chance of getting this in a a fix for v5.4 so we have a
working suspend/resume in v5.4?

Thanks,

Kevin

2019-08-28 15:15:48

by Neil Armstrong

[permalink] [raw]
Subject: Re: [PATCH 0/2] drm/meson: add resume/suspend hooks

On 28/08/2019 17:12, Kevin Hilman wrote:
> Neil Armstrong <[email protected]> writes:
>
>> On 27/08/2019 21:17, Kevin Hilman wrote:
>>> Neil Armstrong <[email protected]> writes:
>>>
>>>> This serie adds the resume/suspend hooks in the Amlogic Meson VPU main driver
>>>> and the DW-HDMI Glue driver to correctly save state and disable HW before
>>>> suspend, and succesfully re-init the HW to recover functionnal display
>>>> after resume.
>>>>
>>>> This serie has been tested on Amlogic G12A based SEI510 board, using
>>>> the newly accepted VRTC driver and the rtcwake utility.
>>>
>>> Tested-by: Kevin Hilman <[email protected]>
>>>
>>> Tested on my G12A SEI510 board, and I verified that it fixes
>>> suspend/resume issues previously seen.
>>>
>>> Kevin
>>>
>>
>> Thanks,
>>
>> Applying to drm-misc-next (for v5.5), with a typo fix in the first patch commit log:
>> s/suspens/suspend
>
> Is there any chance of getting this in a a fix for v5.4 so we have a
> working suspend/resume in v5.4?

Nop, it's already applied to drm-misc-next and is already out of the window
for 5.4 anyway.

Neil

>
> Thanks,
>
> Kevin
>