aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2016-11-04 18:58:38 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-26 07:05:56 -0400
commit2bbcbc24474e3e0726bdff893b8a586da44d9b12 (patch)
treeb76404165493a2f749f1ac7aad0c792797e422b3 /drivers/gpu
parentdd0b0e22a58875e0ea9f41fc177f2286dddc95ab (diff)
drm/vc4: Use runtime autosuspend to avoid thrashing V3D power state.
commit 3a62234680d86efa0239665ed8a0e908f1aef147 upstream. The pm_runtime_put() we were using immediately released power on the device, which meant that we were generally turning the device off and on once per frame. In many profiles I've looked at, that added up to about 1% of CPU time, but this could get worse in the case of frequent rendering and readback (as may happen in X rendering). By keeping the device on until we've been idle for a couple of frames, we drop the overhead of runtime PM down to sub-.1%. Signed-off-by: Eric Anholt <eric@anholt.net> Cc: Amit Pundir <amit.pundir@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/vc4/vc4_drv.c9
-rw-r--r--drivers/gpu/drm/vc4/vc4_gem.c6
-rw-r--r--drivers/gpu/drm/vc4/vc4_v3d.c2
3 files changed, 12 insertions, 5 deletions
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index 8703f56b7947..246d1aea87bc 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -61,21 +61,24 @@ static int vc4_get_param_ioctl(struct drm_device *dev, void *data,
61 if (ret < 0) 61 if (ret < 0)
62 return ret; 62 return ret;
63 args->value = V3D_READ(V3D_IDENT0); 63 args->value = V3D_READ(V3D_IDENT0);
64 pm_runtime_put(&vc4->v3d->pdev->dev); 64 pm_runtime_mark_last_busy(&vc4->v3d->pdev->dev);
65 pm_runtime_put_autosuspend(&vc4->v3d->pdev->dev);
65 break; 66 break;
66 case DRM_VC4_PARAM_V3D_IDENT1: 67 case DRM_VC4_PARAM_V3D_IDENT1:
67 ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev); 68 ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev);
68 if (ret < 0) 69 if (ret < 0)
69 return ret; 70 return ret;
70 args->value = V3D_READ(V3D_IDENT1); 71 args->value = V3D_READ(V3D_IDENT1);
71 pm_runtime_put(&vc4->v3d->pdev->dev); 72 pm_runtime_mark_last_busy(&vc4->v3d->pdev->dev);
73 pm_runtime_put_autosuspend(&vc4->v3d->pdev->dev);
72 break; 74 break;
73 case DRM_VC4_PARAM_V3D_IDENT2: 75 case DRM_VC4_PARAM_V3D_IDENT2:
74 ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev); 76 ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev);
75 if (ret < 0) 77 if (ret < 0)
76 return ret; 78 return ret;
77 args->value = V3D_READ(V3D_IDENT2); 79 args->value = V3D_READ(V3D_IDENT2);
78 pm_runtime_put(&vc4->v3d->pdev->dev); 80 pm_runtime_mark_last_busy(&vc4->v3d->pdev->dev);
81 pm_runtime_put_autosuspend(&vc4->v3d->pdev->dev);
79 break; 82 break;
80 case DRM_VC4_PARAM_SUPPORTS_BRANCHES: 83 case DRM_VC4_PARAM_SUPPORTS_BRANCHES:
81 args->value = true; 84 args->value = true;
diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
index 18e37171e9c8..ab3016982466 100644
--- a/drivers/gpu/drm/vc4/vc4_gem.c
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
@@ -711,8 +711,10 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec)
711 } 711 }
712 712
713 mutex_lock(&vc4->power_lock); 713 mutex_lock(&vc4->power_lock);
714 if (--vc4->power_refcount == 0) 714 if (--vc4->power_refcount == 0) {
715 pm_runtime_put(&vc4->v3d->pdev->dev); 715 pm_runtime_mark_last_busy(&vc4->v3d->pdev->dev);
716 pm_runtime_put_autosuspend(&vc4->v3d->pdev->dev);
717 }
716 mutex_unlock(&vc4->power_lock); 718 mutex_unlock(&vc4->power_lock);
717 719
718 kfree(exec); 720 kfree(exec);
diff --git a/drivers/gpu/drm/vc4/vc4_v3d.c b/drivers/gpu/drm/vc4/vc4_v3d.c
index e6d3c6028341..7cc346ad9b0b 100644
--- a/drivers/gpu/drm/vc4/vc4_v3d.c
+++ b/drivers/gpu/drm/vc4/vc4_v3d.c
@@ -222,6 +222,8 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data)
222 return ret; 222 return ret;
223 } 223 }
224 224
225 pm_runtime_use_autosuspend(dev);
226 pm_runtime_set_autosuspend_delay(dev, 40); /* a little over 2 frames. */
225 pm_runtime_enable(dev); 227 pm_runtime_enable(dev);
226 228
227 return 0; 229 return 0;