0095-drm-vc4-Drop-struct_mutex-around-CL-validation.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. From e619bff96bd0dab8ecf1c8df64ce3d605784fa57 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 095/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.
  10. Fixes a lock order reversal between mmap_sem and struct_mutex.
  11. Signed-off-by: Eric Anholt <eric@anholt.net>
  12. ---
  13. drivers/gpu/drm/vc4/vc4_gem.c | 12 ++++--------
  14. 1 file changed, 4 insertions(+), 8 deletions(-)
  15. --- a/drivers/gpu/drm/vc4/vc4_gem.c
  16. +++ b/drivers/gpu/drm/vc4/vc4_gem.c
  17. @@ -244,13 +244,15 @@ static void
  18. vc4_queue_submit(struct drm_device *dev, struct vc4_exec_info *exec)
  19. {
  20. struct vc4_dev *vc4 = to_vc4_dev(dev);
  21. - uint64_t seqno = ++vc4->emit_seqno;
  22. + uint64_t seqno;
  23. unsigned long irqflags;
  24. + spin_lock_irqsave(&vc4->job_lock, irqflags);
  25. +
  26. + seqno = ++vc4->emit_seqno;
  27. exec->seqno = seqno;
  28. vc4_update_bo_seqnos(exec, seqno);
  29. - spin_lock_irqsave(&vc4->job_lock, irqflags);
  30. list_add_tail(&exec->head, &vc4->job_list);
  31. /* If no job was executing, kick ours off. Otherwise, it'll
  32. @@ -608,8 +610,6 @@ vc4_submit_cl_ioctl(struct drm_device *d
  33. exec->args = args;
  34. INIT_LIST_HEAD(&exec->unref_list);
  35. - mutex_lock(&dev->struct_mutex);
  36. -
  37. ret = vc4_cl_lookup_bos(dev, file_priv, exec);
  38. if (ret)
  39. goto fail;
  40. @@ -636,15 +636,11 @@ vc4_submit_cl_ioctl(struct drm_device *d
  41. /* Return the seqno for our job. */
  42. args->seqno = vc4->emit_seqno;
  43. - mutex_unlock(&dev->struct_mutex);
  44. -
  45. return 0;
  46. fail:
  47. vc4_complete_exec(exec);
  48. - mutex_unlock(&dev->struct_mutex);
  49. -
  50. return ret;
  51. }