brcm2708: update linux 4.9 patches to latest version
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.9 / 0164-drm-vc4-Use-runtime-autosuspend-to-avoid-thrashing-V.patch
1 From 936dc8b00ccd5072c5d610b97199402275bfdf26 Mon Sep 17 00:00:00 2001
2 From: Eric Anholt <eric@anholt.net>
3 Date: Fri, 4 Nov 2016 15:58:38 -0700
4 Subject: [PATCH] drm/vc4: Use runtime autosuspend to avoid thrashing V3D power
5 state.
6
7 The pm_runtime_put() we were using immediately released power on the
8 device, which meant that we were generally turning the device off and
9 on once per frame. In many profiles I've looked at, that added up to
10 about 1% of CPU time, but this could get worse in the case of frequent
11 rendering and readback (as may happen in X rendering). By keeping the
12 device on until we've been idle for a couple of frames, we drop the
13 overhead of runtime PM down to sub-.1%.
14
15 Signed-off-by: Eric Anholt <eric@anholt.net>
16 (cherry picked from commit 3a62234680d86efa0239665ed8a0e908f1aef147)
17 ---
18 drivers/gpu/drm/vc4/vc4_drv.c | 9 ++++++---
19 drivers/gpu/drm/vc4/vc4_gem.c | 6 ++++--
20 drivers/gpu/drm/vc4/vc4_v3d.c | 2 ++
21 3 files changed, 12 insertions(+), 5 deletions(-)
22
23 --- a/drivers/gpu/drm/vc4/vc4_drv.c
24 +++ b/drivers/gpu/drm/vc4/vc4_drv.c
25 @@ -61,21 +61,24 @@ static int vc4_get_param_ioctl(struct dr
26 if (ret < 0)
27 return ret;
28 args->value = V3D_READ(V3D_IDENT0);
29 - pm_runtime_put(&vc4->v3d->pdev->dev);
30 + pm_runtime_mark_last_busy(&vc4->v3d->pdev->dev);
31 + pm_runtime_put_autosuspend(&vc4->v3d->pdev->dev);
32 break;
33 case DRM_VC4_PARAM_V3D_IDENT1:
34 ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev);
35 if (ret < 0)
36 return ret;
37 args->value = V3D_READ(V3D_IDENT1);
38 - pm_runtime_put(&vc4->v3d->pdev->dev);
39 + pm_runtime_mark_last_busy(&vc4->v3d->pdev->dev);
40 + pm_runtime_put_autosuspend(&vc4->v3d->pdev->dev);
41 break;
42 case DRM_VC4_PARAM_V3D_IDENT2:
43 ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev);
44 if (ret < 0)
45 return ret;
46 args->value = V3D_READ(V3D_IDENT2);
47 - pm_runtime_put(&vc4->v3d->pdev->dev);
48 + pm_runtime_mark_last_busy(&vc4->v3d->pdev->dev);
49 + pm_runtime_put_autosuspend(&vc4->v3d->pdev->dev);
50 break;
51 case DRM_VC4_PARAM_SUPPORTS_BRANCHES:
52 case DRM_VC4_PARAM_SUPPORTS_ETC1:
53 --- a/drivers/gpu/drm/vc4/vc4_gem.c
54 +++ b/drivers/gpu/drm/vc4/vc4_gem.c
55 @@ -711,8 +711,10 @@ vc4_complete_exec(struct drm_device *dev
56 }
57
58 mutex_lock(&vc4->power_lock);
59 - if (--vc4->power_refcount == 0)
60 - pm_runtime_put(&vc4->v3d->pdev->dev);
61 + if (--vc4->power_refcount == 0) {
62 + pm_runtime_mark_last_busy(&vc4->v3d->pdev->dev);
63 + pm_runtime_put_autosuspend(&vc4->v3d->pdev->dev);
64 + }
65 mutex_unlock(&vc4->power_lock);
66
67 kfree(exec);
68 --- a/drivers/gpu/drm/vc4/vc4_v3d.c
69 +++ b/drivers/gpu/drm/vc4/vc4_v3d.c
70 @@ -222,6 +222,8 @@ static int vc4_v3d_bind(struct device *d
71 return ret;
72 }
73
74 + pm_runtime_use_autosuspend(dev);
75 + pm_runtime_set_autosuspend_delay(dev, 40); /* a little over 2 frames. */
76 pm_runtime_enable(dev);
77
78 return 0;