0540-drm-vc4-Use-drm_gem_object_unreference_unlocked.patch 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. From 180aed47cc2cc41b8669e9e6c61f79bf1b018fed Mon Sep 17 00:00:00 2001
  2. From: Daniel Vetter <daniel.vetter@ffwll.ch>
  3. Date: Mon, 30 May 2016 19:53:06 +0200
  4. Subject: [PATCH] drm/vc4: Use drm_gem_object_unreference_unlocked
  5. Since my last struct_mutex crusade someone escaped!
  6. This already has the advantage that for the common case when someone
  7. else holds a ref the unref won't even acquire dev->struct_mutex. And
  8. I'm working on code to allow drivers to completely opt-out of any and
  9. all dev->struct_mutex usage, but that only works if they use the
  10. _unlocked variants everywhere.
  11. v2: Drop comment too.
  12. v3: Drop the other comment too.
  13. Cc: Eric Anholt <eric@anholt.net>
  14. Reviewed-by: Eric Anholt <eric@anholt.net>
  15. Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
  16. Link: http://patchwork.freedesktop.org/patch/msgid/1464630800-30786-15-git-send-email-daniel.vetter@ffwll.ch
  17. (cherry picked from commit db3697295cf4da1356e3ec86761d464d6d013b48)
  18. ---
  19. drivers/gpu/drm/vc4/vc4_bo.c | 2 --
  20. drivers/gpu/drm/vc4/vc4_gem.c | 11 +++--------
  21. 2 files changed, 3 insertions(+), 10 deletions(-)
  22. --- a/drivers/gpu/drm/vc4/vc4_bo.c
  23. +++ b/drivers/gpu/drm/vc4/vc4_bo.c
  24. @@ -311,8 +311,6 @@ static void vc4_bo_cache_free_old(struct
  25. /* Called on the last userspace/kernel unreference of the BO. Returns
  26. * it to the BO cache if possible, otherwise frees it.
  27. - *
  28. - * Note that this is called with the struct_mutex held.
  29. */
  30. void vc4_free_object(struct drm_gem_object *gem_bo)
  31. {
  32. --- a/drivers/gpu/drm/vc4/vc4_gem.c
  33. +++ b/drivers/gpu/drm/vc4/vc4_gem.c
  34. @@ -67,10 +67,8 @@ vc4_free_hang_state(struct drm_device *d
  35. {
  36. unsigned int i;
  37. - mutex_lock(&dev->struct_mutex);
  38. for (i = 0; i < state->user_state.bo_count; i++)
  39. - drm_gem_object_unreference(state->bo[i]);
  40. - mutex_unlock(&dev->struct_mutex);
  41. + drm_gem_object_unreference_unlocked(state->bo[i]);
  42. kfree(state);
  43. }
  44. @@ -711,11 +709,9 @@ vc4_complete_exec(struct drm_device *dev
  45. struct vc4_dev *vc4 = to_vc4_dev(dev);
  46. unsigned i;
  47. - /* Need the struct lock for drm_gem_object_unreference(). */
  48. - mutex_lock(&dev->struct_mutex);
  49. if (exec->bo) {
  50. for (i = 0; i < exec->bo_count; i++)
  51. - drm_gem_object_unreference(&exec->bo[i]->base);
  52. + drm_gem_object_unreference_unlocked(&exec->bo[i]->base);
  53. kfree(exec->bo);
  54. }
  55. @@ -723,9 +719,8 @@ vc4_complete_exec(struct drm_device *dev
  56. struct vc4_bo *bo = list_first_entry(&exec->unref_list,
  57. struct vc4_bo, unref_head);
  58. list_del(&bo->unref_head);
  59. - drm_gem_object_unreference(&bo->base.base);
  60. + drm_gem_object_unreference_unlocked(&bo->base.base);
  61. }
  62. - mutex_unlock(&dev->struct_mutex);
  63. mutex_lock(&vc4->power_lock);
  64. if (--vc4->power_refcount == 0) {