drm/vc4: Use runtime autosuspend to avoid thrashing V3D power state.
authorEric Anholt <eric@anholt.net>
Fri, 4 Nov 2016 22:58:38 +0000 (15:58 -0700)
committerRaspbian kernel package updater <root@raspbian.org>
Thu, 9 Mar 2017 17:52:37 +0000 (17:52 +0000)
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>
(cherry picked from commit 3a62234680d86efa0239665ed8a0e908f1aef147)

drivers/gpu/drm/vc4/vc4_drv.c
drivers/gpu/drm/vc4/vc4_gem.c
drivers/gpu/drm/vc4/vc4_v3d.c

index 157e08ab27771854ffbad101f61ce81e27001e1a..8302bd788be470fd61a7382b8c3ef16e26f6861d 100644 (file)
@@ -61,21 +61,24 @@ static int vc4_get_param_ioctl(struct drm_device *dev, void *data,
                if (ret < 0)
                        return ret;
                args->value = V3D_READ(V3D_IDENT0);
-               pm_runtime_put(&vc4->v3d->pdev->dev);
+               pm_runtime_mark_last_busy(&vc4->v3d->pdev->dev);
+               pm_runtime_put_autosuspend(&vc4->v3d->pdev->dev);
                break;
        case DRM_VC4_PARAM_V3D_IDENT1:
                ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev);
                if (ret < 0)
                        return ret;
                args->value = V3D_READ(V3D_IDENT1);
-               pm_runtime_put(&vc4->v3d->pdev->dev);
+               pm_runtime_mark_last_busy(&vc4->v3d->pdev->dev);
+               pm_runtime_put_autosuspend(&vc4->v3d->pdev->dev);
                break;
        case DRM_VC4_PARAM_V3D_IDENT2:
                ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev);
                if (ret < 0)
                        return ret;
                args->value = V3D_READ(V3D_IDENT2);
-               pm_runtime_put(&vc4->v3d->pdev->dev);
+               pm_runtime_mark_last_busy(&vc4->v3d->pdev->dev);
+               pm_runtime_put_autosuspend(&vc4->v3d->pdev->dev);
                break;
        case DRM_VC4_PARAM_SUPPORTS_BRANCHES:
        case DRM_VC4_PARAM_SUPPORTS_ETC1:
index 18e37171e9c8e2f0729ca1c582af98ccb4647e06..ab3016982466c3ca35ba479050ee107d26eb50ac 100644 (file)
@@ -711,8 +711,10 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec)
        }
 
        mutex_lock(&vc4->power_lock);
-       if (--vc4->power_refcount == 0)
-               pm_runtime_put(&vc4->v3d->pdev->dev);
+       if (--vc4->power_refcount == 0) {
+               pm_runtime_mark_last_busy(&vc4->v3d->pdev->dev);
+               pm_runtime_put_autosuspend(&vc4->v3d->pdev->dev);
+       }
        mutex_unlock(&vc4->power_lock);
 
        kfree(exec);
index e6d3c6028341e447df293cab525713ac10d8ee5e..7cc346ad9b0baed63701d1fae8f0306aa7713129 100644 (file)
@@ -222,6 +222,8 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data)
                return ret;
        }
 
+       pm_runtime_use_autosuspend(dev);
+       pm_runtime_set_autosuspend_delay(dev, 40); /* a little over 2 frames. */
        pm_runtime_enable(dev);
 
        return 0;