diff options
author | Ben Widawsky <ben@bwidawsk.net> | 2013-05-28 22:22:18 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-05-31 14:54:08 -0400 |
commit | ad776f8b09d66e0145479fdbde2a710e5892441f (patch) | |
tree | 8fe32b87b70bc02bdad3f33efc4d1f50a86fe774 /drivers/gpu/drm/i915/intel_ringbuffer.c | |
parent | 5586181fce2b2e89a0e281d78ffbdfa103bb0dde (diff) |
drm/i915: Semaphore MBOX update generalization
This replaces the existing MBOX update code with a more generalized
calculation for emitting mbox updates. We also create a sentinel for
doing the updates so we can more abstractly deal with the rings.
When doing MBOX updates the code must be aware of the /other/ rings.
Until now the platforms which supported semaphores had a fixed number of
rings and so it made sense for the code to be very specialized
(hardcoded).
The patch does contain a functional change, but should have no
behavioral changes.
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Reviewed-by: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_ringbuffer.c')
-rw-r--r-- | drivers/gpu/drm/i915/intel_ringbuffer.c | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c index 2d2a3622639c..5df179127e8b 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.c +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c | |||
@@ -582,9 +582,16 @@ static void | |||
582 | update_mboxes(struct intel_ring_buffer *ring, | 582 | update_mboxes(struct intel_ring_buffer *ring, |
583 | u32 mmio_offset) | 583 | u32 mmio_offset) |
584 | { | 584 | { |
585 | /* NB: In order to be able to do semaphore MBOX updates for varying number | ||
586 | * of rings, it's easiest if we round up each individual update to a | ||
587 | * multiple of 2 (since ring updates must always be a multiple of 2) | ||
588 | * even though the actual update only requires 3 dwords. | ||
589 | */ | ||
590 | #define MBOX_UPDATE_DWORDS 4 | ||
585 | intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1)); | 591 | intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1)); |
586 | intel_ring_emit(ring, mmio_offset); | 592 | intel_ring_emit(ring, mmio_offset); |
587 | intel_ring_emit(ring, ring->outstanding_lazy_request); | 593 | intel_ring_emit(ring, ring->outstanding_lazy_request); |
594 | intel_ring_emit(ring, MI_NOOP); | ||
588 | } | 595 | } |
589 | 596 | ||
590 | /** | 597 | /** |
@@ -599,19 +606,24 @@ update_mboxes(struct intel_ring_buffer *ring, | |||
599 | static int | 606 | static int |
600 | gen6_add_request(struct intel_ring_buffer *ring) | 607 | gen6_add_request(struct intel_ring_buffer *ring) |
601 | { | 608 | { |
602 | u32 mbox1_reg; | 609 | struct drm_device *dev = ring->dev; |
603 | u32 mbox2_reg; | 610 | struct drm_i915_private *dev_priv = dev->dev_private; |
604 | int ret; | 611 | struct intel_ring_buffer *useless; |
612 | int i, ret; | ||
605 | 613 | ||
606 | ret = intel_ring_begin(ring, 10); | 614 | ret = intel_ring_begin(ring, ((I915_NUM_RINGS-1) * |
615 | MBOX_UPDATE_DWORDS) + | ||
616 | 4); | ||
607 | if (ret) | 617 | if (ret) |
608 | return ret; | 618 | return ret; |
619 | #undef MBOX_UPDATE_DWORDS | ||
609 | 620 | ||
610 | mbox1_reg = ring->signal_mbox[0]; | 621 | for_each_ring(useless, dev_priv, i) { |
611 | mbox2_reg = ring->signal_mbox[1]; | 622 | u32 mbox_reg = ring->signal_mbox[i]; |
623 | if (mbox_reg != GEN6_NOSYNC) | ||
624 | update_mboxes(ring, mbox_reg); | ||
625 | } | ||
612 | 626 | ||
613 | update_mboxes(ring, mbox1_reg); | ||
614 | update_mboxes(ring, mbox2_reg); | ||
615 | intel_ring_emit(ring, MI_STORE_DWORD_INDEX); | 627 | intel_ring_emit(ring, MI_STORE_DWORD_INDEX); |
616 | intel_ring_emit(ring, I915_GEM_HWS_INDEX << MI_STORE_DWORD_INDEX_SHIFT); | 628 | intel_ring_emit(ring, I915_GEM_HWS_INDEX << MI_STORE_DWORD_INDEX_SHIFT); |
617 | intel_ring_emit(ring, ring->outstanding_lazy_request); | 629 | intel_ring_emit(ring, ring->outstanding_lazy_request); |
@@ -1674,8 +1686,9 @@ int intel_init_render_ring_buffer(struct drm_device *dev) | |||
1674 | ring->semaphore_register[RCS] = MI_SEMAPHORE_SYNC_INVALID; | 1686 | ring->semaphore_register[RCS] = MI_SEMAPHORE_SYNC_INVALID; |
1675 | ring->semaphore_register[VCS] = MI_SEMAPHORE_SYNC_RV; | 1687 | ring->semaphore_register[VCS] = MI_SEMAPHORE_SYNC_RV; |
1676 | ring->semaphore_register[BCS] = MI_SEMAPHORE_SYNC_RB; | 1688 | ring->semaphore_register[BCS] = MI_SEMAPHORE_SYNC_RB; |
1677 | ring->signal_mbox[0] = GEN6_VRSYNC; | 1689 | ring->signal_mbox[RCS] = GEN6_NOSYNC; |
1678 | ring->signal_mbox[1] = GEN6_BRSYNC; | 1690 | ring->signal_mbox[VCS] = GEN6_VRSYNC; |
1691 | ring->signal_mbox[BCS] = GEN6_BRSYNC; | ||
1679 | } else if (IS_GEN5(dev)) { | 1692 | } else if (IS_GEN5(dev)) { |
1680 | ring->add_request = pc_render_add_request; | 1693 | ring->add_request = pc_render_add_request; |
1681 | ring->flush = gen4_render_ring_flush; | 1694 | ring->flush = gen4_render_ring_flush; |
@@ -1833,8 +1846,9 @@ int intel_init_bsd_ring_buffer(struct drm_device *dev) | |||
1833 | ring->semaphore_register[RCS] = MI_SEMAPHORE_SYNC_VR; | 1846 | ring->semaphore_register[RCS] = MI_SEMAPHORE_SYNC_VR; |
1834 | ring->semaphore_register[VCS] = MI_SEMAPHORE_SYNC_INVALID; | 1847 | ring->semaphore_register[VCS] = MI_SEMAPHORE_SYNC_INVALID; |
1835 | ring->semaphore_register[BCS] = MI_SEMAPHORE_SYNC_VB; | 1848 | ring->semaphore_register[BCS] = MI_SEMAPHORE_SYNC_VB; |
1836 | ring->signal_mbox[0] = GEN6_RVSYNC; | 1849 | ring->signal_mbox[RCS] = GEN6_RVSYNC; |
1837 | ring->signal_mbox[1] = GEN6_BVSYNC; | 1850 | ring->signal_mbox[VCS] = GEN6_NOSYNC; |
1851 | ring->signal_mbox[BCS] = GEN6_BVSYNC; | ||
1838 | } else { | 1852 | } else { |
1839 | ring->mmio_base = BSD_RING_BASE; | 1853 | ring->mmio_base = BSD_RING_BASE; |
1840 | ring->flush = bsd_ring_flush; | 1854 | ring->flush = bsd_ring_flush; |
@@ -1879,8 +1893,9 @@ int intel_init_blt_ring_buffer(struct drm_device *dev) | |||
1879 | ring->semaphore_register[RCS] = MI_SEMAPHORE_SYNC_BR; | 1893 | ring->semaphore_register[RCS] = MI_SEMAPHORE_SYNC_BR; |
1880 | ring->semaphore_register[VCS] = MI_SEMAPHORE_SYNC_BV; | 1894 | ring->semaphore_register[VCS] = MI_SEMAPHORE_SYNC_BV; |
1881 | ring->semaphore_register[BCS] = MI_SEMAPHORE_SYNC_INVALID; | 1895 | ring->semaphore_register[BCS] = MI_SEMAPHORE_SYNC_INVALID; |
1882 | ring->signal_mbox[0] = GEN6_RBSYNC; | 1896 | ring->signal_mbox[RCS] = GEN6_RBSYNC; |
1883 | ring->signal_mbox[1] = GEN6_VBSYNC; | 1897 | ring->signal_mbox[VCS] = GEN6_VBSYNC; |
1898 | ring->signal_mbox[BCS] = GEN6_NOSYNC; | ||
1884 | ring->init = init_ring_common; | 1899 | ring->init = init_ring_common; |
1885 | 1900 | ||
1886 | return intel_init_ring_buffer(dev, ring); | 1901 | return intel_init_ring_buffer(dev, ring); |