0093-drm-vc4-bo-cache-locking-cleanup.patch 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. From 2520f46f0d6e44f5ecfa534fb5a5f1a11302c83c Mon Sep 17 00:00:00 2001
  2. From: Eric Anholt <eric@anholt.net>
  3. Date: Mon, 19 Oct 2015 08:29:41 -0700
  4. Subject: [PATCH 093/381] drm/vc4: bo cache locking cleanup.
  5. Signed-off-by: Eric Anholt <eric@anholt.net>
  6. ---
  7. drivers/gpu/drm/vc4/vc4_bo.c | 22 +++++++++-------------
  8. 1 file changed, 9 insertions(+), 13 deletions(-)
  9. --- a/drivers/gpu/drm/vc4/vc4_bo.c
  10. +++ b/drivers/gpu/drm/vc4/vc4_bo.c
  11. @@ -215,7 +215,6 @@ vc4_bo_cache_free_old(struct drm_device
  12. struct vc4_dev *vc4 = to_vc4_dev(dev);
  13. unsigned long expire_time = jiffies - msecs_to_jiffies(1000);
  14. - mutex_lock(&vc4->bo_lock);
  15. while (!list_empty(&vc4->bo_cache.time_list)) {
  16. struct vc4_bo *bo = list_last_entry(&vc4->bo_cache.time_list,
  17. struct vc4_bo, unref_head);
  18. @@ -223,14 +222,12 @@ vc4_bo_cache_free_old(struct drm_device
  19. mod_timer(&vc4->bo_cache.time_timer,
  20. round_jiffies_up(jiffies +
  21. msecs_to_jiffies(1000)));
  22. - mutex_unlock(&vc4->bo_lock);
  23. return;
  24. }
  25. vc4_bo_remove_from_cache(bo);
  26. vc4_bo_destroy(bo);
  27. }
  28. - mutex_unlock(&vc4->bo_lock);
  29. }
  30. /* Called on the last userspace/kernel unreference of the BO. Returns
  31. @@ -245,29 +242,24 @@ void vc4_free_object(struct drm_gem_obje
  32. struct vc4_bo *bo = to_vc4_bo(gem_bo);
  33. struct list_head *cache_list;
  34. + mutex_lock(&vc4->bo_lock);
  35. /* If the object references someone else's memory, we can't cache it.
  36. */
  37. if (gem_bo->import_attach) {
  38. - mutex_lock(&vc4->bo_lock);
  39. vc4_bo_destroy(bo);
  40. - mutex_unlock(&vc4->bo_lock);
  41. - return;
  42. + goto out;
  43. }
  44. /* Don't cache if it was publicly named. */
  45. if (gem_bo->name) {
  46. - mutex_lock(&vc4->bo_lock);
  47. vc4_bo_destroy(bo);
  48. - mutex_unlock(&vc4->bo_lock);
  49. - return;
  50. + goto out;
  51. }
  52. - mutex_lock(&vc4->bo_lock);
  53. cache_list = vc4_get_cache_list_for_size(dev, gem_bo->size);
  54. if (!cache_list) {
  55. vc4_bo_destroy(bo);
  56. - mutex_unlock(&vc4->bo_lock);
  57. - return;
  58. + goto out;
  59. }
  60. if (bo->validated_shader) {
  61. @@ -282,9 +274,11 @@ void vc4_free_object(struct drm_gem_obje
  62. vc4->bo_stats.num_cached++;
  63. vc4->bo_stats.size_cached += gem_bo->size;
  64. - mutex_unlock(&vc4->bo_lock);
  65. vc4_bo_cache_free_old(dev);
  66. +
  67. +out:
  68. + mutex_unlock(&vc4->bo_lock);
  69. }
  70. static void vc4_bo_cache_time_work(struct work_struct *work)
  71. @@ -293,7 +287,9 @@ static void vc4_bo_cache_time_work(struc
  72. container_of(work, struct vc4_dev, bo_cache.time_work);
  73. struct drm_device *dev = vc4->dev;
  74. + mutex_lock(&vc4->bo_lock);
  75. vc4_bo_cache_free_old(dev);
  76. + mutex_unlock(&vc4->bo_lock);
  77. }
  78. static void vc4_bo_cache_time_timer(unsigned long data)