Skip to content

Commit 3a62234

Browse files
committed
drm/vc4: Use runtime autosuspend to avoid thrashing V3D power state.
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>
1 parent 7154d76 commit 3a62234

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

‎drivers/gpu/drm/vc4/vc4_drv.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,24 @@ static int vc4_get_param_ioctl(struct drm_device *dev, void *data,
6161
if (ret < 0)
6262
return ret;
6363
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);
6566
break;
6667
case DRM_VC4_PARAM_V3D_IDENT1:
6768
ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev);
6869
if (ret < 0)
6970
return ret;
7071
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);
7274
break;
7375
case DRM_VC4_PARAM_V3D_IDENT2:
7476
ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev);
7577
if (ret < 0)
7678
return ret;
7779
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);
7982
break;
8083
case DRM_VC4_PARAM_SUPPORTS_BRANCHES:
8184
case DRM_VC4_PARAM_SUPPORTS_ETC1:

‎drivers/gpu/drm/vc4/vc4_gem.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,10 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec)
709709
}
710710

711711
mutex_lock(&vc4->power_lock);
712-
if (--vc4->power_refcount == 0)
713-
pm_runtime_put(&vc4->v3d->pdev->dev);
712+
if (--vc4->power_refcount == 0) {
713+
pm_runtime_mark_last_busy(&vc4->v3d->pdev->dev);
714+
pm_runtime_put_autosuspend(&vc4->v3d->pdev->dev);
715+
}
714716
mutex_unlock(&vc4->power_lock);
715717

716718
kfree(exec);

‎drivers/gpu/drm/vc4/vc4_v3d.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data)
222222
return ret;
223223
}
224224

225+
pm_runtime_use_autosuspend(dev);
226+
pm_runtime_set_autosuspend_delay(dev, 40); /* a little over 2 frames. */
225227
pm_runtime_enable(dev);
226228

227229
return 0;

0 commit comments

Comments
 (0)