0096-drm-vc4-Drop-struct_mutex-around-CL-validation.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. From 4b137e2962b14c62089f4368391fa1ed03cac391 Mon Sep 17 00:00:00 2001
  2. From: Eric Anholt <eric@anholt.net>
  3. Date: Mon, 19 Oct 2015 08:44:35 -0700
  4. Subject: [PATCH 096/381] drm/vc4: Drop struct_mutex around CL validation.
  5. We were using it so that we could make sure that shader validation
  6. state didn't change while we were validating, but now shader
  7. validation state is immutable. The bcl/rcl generation doesn't do any
  8. other BO dereferencing, and seems to have no other global state
  9. dependency not covered by job_lock / bo_lock. We only need to hold
  10. struct_mutex for object unreferencing.
  11. Fixes a lock order reversal between mmap_sem and struct_mutex.
  12. Signed-off-by: Eric Anholt <eric@anholt.net>
  13. ---
  14. drivers/gpu/drm/vc4/vc4_gem.c | 13 ++++++-------
  15. 1 file changed, 6 insertions(+), 7 deletions(-)
  16. --- a/drivers/gpu/drm/vc4/vc4_gem.c
  17. +++ b/drivers/gpu/drm/vc4/vc4_gem.c
  18. @@ -439,10 +439,12 @@ fail:
  19. }
  20. static void
  21. -vc4_complete_exec(struct vc4_exec_info *exec)
  22. +vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec)
  23. {
  24. unsigned i;
  25. + /* Need the struct lock for drm_gem_object_unreference(). */
  26. + mutex_lock(&dev->struct_mutex);
  27. if (exec->bo) {
  28. for (i = 0; i < exec->bo_count; i++)
  29. drm_gem_object_unreference(&exec->bo[i].bo->base);
  30. @@ -455,6 +457,7 @@ vc4_complete_exec(struct vc4_exec_info *
  31. list_del(&bo->unref_head);
  32. drm_gem_object_unreference(&bo->base.base);
  33. }
  34. + mutex_unlock(&dev->struct_mutex);
  35. kfree(exec);
  36. }
  37. @@ -473,7 +476,7 @@ vc4_job_handle_completed(struct vc4_dev
  38. list_del(&exec->head);
  39. spin_unlock_irqrestore(&vc4->job_lock, irqflags);
  40. - vc4_complete_exec(exec);
  41. + vc4_complete_exec(vc4->dev, exec);
  42. spin_lock_irqsave(&vc4->job_lock, irqflags);
  43. }
  44. @@ -525,12 +528,8 @@ vc4_job_done_work(struct work_struct *wo
  45. {
  46. struct vc4_dev *vc4 =
  47. container_of(work, struct vc4_dev, job_done_work);
  48. - struct drm_device *dev = vc4->dev;
  49. - /* Need the struct lock for drm_gem_object_unreference(). */
  50. - mutex_lock(&dev->struct_mutex);
  51. vc4_job_handle_completed(vc4);
  52. - mutex_unlock(&dev->struct_mutex);
  53. }
  54. static int
  55. @@ -639,7 +638,7 @@ vc4_submit_cl_ioctl(struct drm_device *d
  56. return 0;
  57. fail:
  58. - vc4_complete_exec(exec);
  59. + vc4_complete_exec(vc4->dev, exec);
  60. return ret;
  61. }