0539-drm-vc4-Use-runtime-autosuspend-to-avoid-thrashing-V.patch 2.8 KB

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