0483-drm-vc4-Fix-overflow-mem-unreferencing-when-the-binn.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. From 45d87c13cbba1dc247108ef485e4449ba2be1672 Mon Sep 17 00:00:00 2001
  2. From: Eric Anholt <eric@anholt.net>
  3. Date: Thu, 21 Jul 2016 13:39:11 -0700
  4. Subject: [PATCH] drm/vc4: Fix overflow mem unreferencing when the binner runs
  5. dry.
  6. Overflow memory handling is tricky: While it's still referenced by the
  7. BPO registers, we want to keep it from being freed. When we are
  8. putting a new set of overflow memory in the registers, we need to
  9. assign the old one to the last rendering job using it.
  10. We were looking at "what's currently running in the binner", but since
  11. the bin/render submission split, we may end up with the binner
  12. completing and having no new job while the renderer is still
  13. processing. So, if we don't find a bin job at all, look at the
  14. highest-seqno (last) render job to attach our overflow to.
  15. Signed-off-by: Eric Anholt <eric@anholt.net>
  16. Fixes: ca26d28bbaa3 ("drm/vc4: improve throughput by pipelining binning and rendering jobs")
  17. Cc: stable@vger.kernel.org
  18. ---
  19. drivers/gpu/drm/vc4/vc4_drv.h | 9 +++++++++
  20. drivers/gpu/drm/vc4/vc4_irq.c | 4 +++-
  21. 2 files changed, 12 insertions(+), 1 deletion(-)
  22. --- a/drivers/gpu/drm/vc4/vc4_drv.h
  23. +++ b/drivers/gpu/drm/vc4/vc4_drv.h
  24. @@ -329,6 +329,15 @@ vc4_first_render_job(struct vc4_dev *vc4
  25. struct vc4_exec_info, head);
  26. }
  27. +static inline struct vc4_exec_info *
  28. +vc4_last_render_job(struct vc4_dev *vc4)
  29. +{
  30. + if (list_empty(&vc4->render_job_list))
  31. + return NULL;
  32. + return list_last_entry(&vc4->render_job_list,
  33. + struct vc4_exec_info, head);
  34. +}
  35. +
  36. /**
  37. * struct vc4_texture_sample_info - saves the offsets into the UBO for texture
  38. * setup parameters.
  39. --- a/drivers/gpu/drm/vc4/vc4_irq.c
  40. +++ b/drivers/gpu/drm/vc4/vc4_irq.c
  41. @@ -83,8 +83,10 @@ vc4_overflow_mem_work(struct work_struct
  42. spin_lock_irqsave(&vc4->job_lock, irqflags);
  43. current_exec = vc4_first_bin_job(vc4);
  44. + if (!current_exec)
  45. + current_exec = vc4_last_render_job(vc4);
  46. if (current_exec) {
  47. - vc4->overflow_mem->seqno = vc4->finished_seqno + 1;
  48. + vc4->overflow_mem->seqno = current_exec->seqno;
  49. list_add_tail(&vc4->overflow_mem->unref_head,
  50. &current_exec->unref_list);
  51. vc4->overflow_mem = NULL;