Skip to contentSkip to conversation

drm/msm/dpu: ensure device suspend happens during PM sleep

PATCH Superseded Kalyan Thota 2 participants 2 messages Jun 4, 2020

Subsystems (3)

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v6 1/1 drm/msm/dpu: ensure device suspend happens during PM sleep

"The PM core always increments the runtime usage counter before calling the ->suspend() callback and decrements it after calling the ->resume() callback"

DPU and DSI are managed as runtime devices. When suspend is triggered, PM core adds a refcount on all the devices and calls device suspend, since usage count is already incremented, runtime suspend was not getting called and it kept the clocks on which resulted in target not entering into XO shutdown.

Add changes to force suspend on runtime devices during pm sleep.

Changes in v1:
- Remove unnecessary checks in the function
_dpu_kms_disable_dpu (Rob Clark).

Changes in v2:
- Avoid using suspend_late to reset the usagecount as suspend_late might not be called during suspend call failures (Doug).

Changes in v3:
- Use force suspend instead of managing device usage_count via runtime put and get API's to trigger callbacks (Doug).

Changes in v4:
- Check the return values of pm_runtime_force_suspend and pm_runtime_force_resume API's and pass appropriately (Doug).

Changes in v5:
- With v4 patch, test cycle has uncovered issues in device resume.

On bubs: cmd tx failures were seen as SW is sending panel off commands when the dsi resources are turned off.

Upon suspend, DRM driver will issue a NULL composition to the dpu, followed by turning off all the HW blocks.

v5 changes will serialize the NULL commit and resource unwinding by handling them under PM prepare and PM complete phases there by ensuring that clks are on when panel off commands are being processed.

Changes in v6:
- Use drm_mode_config_helper_suspend/resume() instead of legacy API drm_atomic_helper_suspend/resume() (Doug).

Trigger runtime callbacks from the suspend/resume call to turn off the resources.

---
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c |  2 +
 drivers/gpu/drm/msm/dsi/dsi.c           |  2 +
 drivers/gpu/drm/msm/msm_drv.c           | 67 ++++++++++++++++-----------------
 3 files changed, 37 insertions(+), 34 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +2 -0
index ce19f1d..b886d9d 100644
@@ -1123,6 +1123,8 @@ static int __maybe_unused dpu_runtime_resume(struct device *dev)
 
 static const struct dev_pm_ops dpu_pm_ops = {
 	SET_RUNTIME_PM_OPS(dpu_runtime_suspend, dpu_runtime_resume, NULL)
+	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
+				pm_runtime_force_resume)
 };
 
 static const struct of_device_id dpu_dt_match[] = {
drivers/gpu/drm/msm/dsi/dsi.c +2 -0
index 55ea4bc2..62704885 100644
@@ -161,6 +161,8 @@ static int dsi_dev_remove(struct platform_device *pdev)
 
 static const struct dev_pm_ops dsi_pm_ops = {
 	SET_RUNTIME_PM_OPS(msm_dsi_runtime_suspend, msm_dsi_runtime_resume, NULL)
+	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
+				pm_runtime_force_resume)
 };
 
 static struct platform_driver dsi_driver = {
drivers/gpu/drm/msm/msm_drv.c +33 -34

108 lines not on this page · raw message

Signature · 1 line
1.9.1
#1 lore raw

Hi,

drivers/gpu/drm/msm/msm_drv.c static int msm_ioctl_submitqueue_close(struct drm_device *dev, void *data, · line 1079

Quoted 10 lines · Kalyan Thota
drivers/gpu/drm/msm/msm_drv.c +2 -5
-#ifdef CONFIG_PM
-static int msm_runtime_suspend(struct device *dev)
+#ifdef CONFIG_PM_SLEEP
+static int msm_pm_suspend(struct device *dev)
 {
-       struct drm_device *ddev = dev_get_drvdata(dev);
-       struct msm_drm_private *priv = ddev->dev_private;
-       struct msm_mdss *mdss = priv->mdss;

nit: remove blank line at the start of this function

drivers/gpu/drm/msm/msm_drv.c static int msm_ioctl_submitqueue_close(struct drm_device *dev, void *data, · line 1105

Quoted 5 lines

static const struct dev_pm_ops msm_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(msm_pm_suspend, msm_pm_resume) SET_RUNTIME_PM_OPS(msm_runtime_suspend, msm_runtime_resume, NULL)

drivers/gpu/drm/msm/msm_drv.c +2 -0
+       .prepare = msm_pm_prepare,
+       .complete = msm_pm_complete,

Presumably you will get a compile failure if someone compiles without CONFIG_PM_SLEEP since msm_pm_prepare() and msm_pm_complete() won't be defined but you refer to them unconditionally. Probably the best solution is to just add "__maybe_unused" to your prepare/complete function and then always define them.

I can't say I've thought through every corner case but at least this change no longer raises alarm bells in my mind when I look at it. ;-)
If it works for you and nobody else has objections then it seems good
enough and we can always make more improvements later. Feel free to add my Reviewed-by tag when my nit is fixed and you make sure it compiles even if CONFIG_PM_SLEEP isn't defined.

-Doug