]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: host: Disable pm runtime late
authorArto Merilainen <amerilainen@nvidia.com>
Mon, 12 May 2014 13:17:17 +0000 (16:17 +0300)
committerRiham Haidar <rhaidar@nvidia.com>
Tue, 13 May 2014 20:39:56 +0000 (13:39 -0700)
Currently pm runtime is disabled for host1x right after we start
suspending. However, many devices (dc, avp, gk20a) depend on host1x
functionality and thereby they try to turn on host1x during suspend.

This patch modifies host1x suspend sequence to:
- Suspend late and resume early. This ensures that "normal" devices can
handle host1x properly.
- Re-enable host1x pm runtime immediately after genpd has disabled it.
This allows other devices to use pm runtime to enable host1x.
- Disable pm runtime in complete event. genpd will re-enable it
immediately after this has happened

Bug 200001342

Change-Id: Ic40cc3e257f9bde8e28eec27bb1a2ca939987ca7
Signed-off-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-on: http://git-master/r/408238
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Thomas Cherry <tcherry@nvidia.com>
Reviewed-by: Amey Asgaonkar <aasgaonkar@nvidia.com>
Tested-by: Amey Asgaonkar <aasgaonkar@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
drivers/video/tegra/host/host1x/host1x.c

index 7f34b36e97cfd6ab91a12613d6c26b189dba6ab6..68365b34944e88f200821f22c5ba2e4279de1278 100644 (file)
@@ -763,7 +763,6 @@ static int nvhost_probe(struct platform_device *dev)
 #ifdef CONFIG_PM_GENERIC_DOMAINS
        pdata->pd.name = "tegra-host1x";
        err = nvhost_module_add_domain(&pdata->pd, dev);
-
 #endif
 
        nvhost_module_busy(dev);
@@ -809,6 +808,30 @@ static int __exit nvhost_remove(struct platform_device *dev)
 }
 
 #ifdef CONFIG_PM
+
+/*
+ * FIXME: Genpd disables the runtime pm while preparing for system
+ * suspend. As host1x clients may need host1x in suspend sequence
+ * for register reads/writes or syncpoint increments, we need to
+ * re-enable pm_runtime. As we *must* balance pm_runtime counter,
+ * we drop the reference in suspend complete callback, right before
+ * the genpd re-enables runtime pm.
+ *
+ * We should revisit the power code as this is hacky and
+ * caused by the way we use power domains.
+ */
+
+static int nvhost_suspend_prepare(struct device *dev)
+{
+       pm_runtime_enable(dev);
+       return 0;
+}
+
+static void nvhost_suspend_complete(struct device *dev)
+{
+       __pm_runtime_disable(dev, false);
+}
+
 static int nvhost_suspend(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
@@ -838,8 +861,10 @@ static int nvhost_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops host1x_pm_ops = {
-       .suspend = nvhost_suspend,
-       .resume = nvhost_resume,
+       .prepare = nvhost_suspend_prepare,
+       .complete = nvhost_suspend_complete,
+       .suspend_late = nvhost_suspend,
+       .resume_early = nvhost_resume,
 };
 #endif /* CONFIG_PM */