0094-drm-vc4-Use-job_lock-to-protect-seqno_cb_list.patch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. From e7530cfb655bb473d5c99e27bb44a15f1c921441 Mon Sep 17 00:00:00 2001
  2. From: Eric Anholt <eric@anholt.net>
  3. Date: Mon, 19 Oct 2015 08:32:24 -0700
  4. Subject: [PATCH 094/381] drm/vc4: Use job_lock to protect seqno_cb_list.
  5. We're (mostly) not supposed to be using struct_mutex in drivers these
  6. days.
  7. Signed-off-by: Eric Anholt <eric@anholt.net>
  8. ---
  9. drivers/gpu/drm/vc4/vc4_gem.c | 8 +++++---
  10. 1 file changed, 5 insertions(+), 3 deletions(-)
  11. --- a/drivers/gpu/drm/vc4/vc4_gem.c
  12. +++ b/drivers/gpu/drm/vc4/vc4_gem.c
  13. @@ -474,7 +474,6 @@ vc4_job_handle_completed(struct vc4_dev
  14. vc4_complete_exec(exec);
  15. spin_lock_irqsave(&vc4->job_lock, irqflags);
  16. }
  17. - spin_unlock_irqrestore(&vc4->job_lock, irqflags);
  18. list_for_each_entry_safe(cb, cb_temp, &vc4->seqno_cb_list, work.entry) {
  19. if (cb->seqno <= vc4->finished_seqno) {
  20. @@ -482,6 +481,8 @@ vc4_job_handle_completed(struct vc4_dev
  21. schedule_work(&cb->work);
  22. }
  23. }
  24. +
  25. + spin_unlock_irqrestore(&vc4->job_lock, irqflags);
  26. }
  27. static void vc4_seqno_cb_work(struct work_struct *work)
  28. @@ -496,18 +497,19 @@ int vc4_queue_seqno_cb(struct drm_device
  29. {
  30. struct vc4_dev *vc4 = to_vc4_dev(dev);
  31. int ret = 0;
  32. + unsigned long irqflags;
  33. cb->func = func;
  34. INIT_WORK(&cb->work, vc4_seqno_cb_work);
  35. - mutex_lock(&dev->struct_mutex);
  36. + spin_lock_irqsave(&vc4->job_lock, irqflags);
  37. if (seqno > vc4->finished_seqno) {
  38. cb->seqno = seqno;
  39. list_add_tail(&cb->work.entry, &vc4->seqno_cb_list);
  40. } else {
  41. schedule_work(&cb->work);
  42. }
  43. - mutex_unlock(&dev->struct_mutex);
  44. + spin_unlock_irqrestore(&vc4->job_lock, irqflags);
  45. return ret;
  46. }