32 #include <drm/i915_drm.h>
56 u32 invalidate_domains,
73 intel_ring_emit(ring, cmd);
82 u32 invalidate_domains,
118 if ((invalidate_domains|flush_domains) & I915_GEM_DOMAIN_RENDER)
131 intel_ring_emit(ring, cmd);
132 intel_ring_emit(ring,
MI_NOOP);
191 intel_ring_emit(ring, 0);
192 intel_ring_emit(ring, 0);
193 intel_ring_emit(ring,
MI_NOOP);
203 intel_ring_emit(ring, 0);
204 intel_ring_emit(ring, 0);
205 intel_ring_emit(ring,
MI_NOOP);
213 u32 invalidate_domains,
u32 flush_domains)
221 ret = intel_emit_post_sync_nonzero_flush(ring);
238 if (invalidate_domains) {
256 intel_ring_emit(ring, flags);
258 intel_ring_emit(ring, 0);
276 intel_ring_emit(ring, 0);
277 intel_ring_emit(ring, 0);
285 u32 invalidate_domains,
u32 flush_domains)
310 if (invalidate_domains) {
325 gen7_render_ring_cs_stall_wa(ring);
333 intel_ring_emit(ring, flags);
335 intel_ring_emit(ring, 0);
377 DRM_DEBUG_KMS(
"%s head not reset to zero "
378 "ctl %08x head %08x tail %08x start %08x\n",
388 DRM_ERROR(
"failed to set %s head to zero "
389 "ctl %08x head %08x tail %08x start %08x\n",
411 DRM_ERROR(
"%s initialization failed "
412 "ctl %08x head %08x tail %08x start %08x\n",
422 if (!drm_core_check_feature(ring->
dev, DRIVER_MODESET))
427 ring->
space = ring_space(ring);
454 DRM_ERROR(
"Failed to allocate seqno page\n");
477 drm_gem_object_unreference(&obj->
base);
496 drm_gem_object_unreference(&obj->
base);
506 int ret = init_ring_common(ring);
517 ret = init_pipe_control(ring);
553 cleanup_pipe_control(ring);
565 intel_ring_emit(ring, seqno);
566 intel_ring_emit(ring, mmio_offset);
595 update_mboxes(ring, *seqno, mbox1_reg);
596 update_mboxes(ring, *seqno, mbox2_reg);
599 intel_ring_emit(ring, *seqno);
636 intel_ring_emit(waiter,
638 intel_ring_emit(waiter, seqno);
639 intel_ring_emit(waiter, 0);
640 intel_ring_emit(waiter,
MI_NOOP);
646 #define PIPE_CONTROL_FLUSH(ring__, addr__) \
648 intel_ring_emit(ring__, GFX_OP_PIPE_CONTROL(4) | PIPE_CONTROL_QW_WRITE | \
649 PIPE_CONTROL_DEPTH_STALL); \
650 intel_ring_emit(ring__, (addr__) | PIPE_CONTROL_GLOBAL_GTT); \
651 intel_ring_emit(ring__, 0); \
652 intel_ring_emit(ring__, 0); \
680 intel_ring_emit(ring, seqno);
681 intel_ring_emit(ring, 0);
699 intel_ring_emit(ring, seqno);
700 intel_ring_emit(ring, 0);
738 if (!dev->irq_enabled)
747 spin_unlock_irqrestore(&dev_priv->
irq_lock, flags);
765 spin_unlock_irqrestore(&dev_priv->
irq_lock, flags);
775 if (!dev->irq_enabled)
784 spin_unlock_irqrestore(&dev_priv->
irq_lock, flags);
802 spin_unlock_irqrestore(&dev_priv->
irq_lock, flags);
812 if (!dev->irq_enabled)
821 spin_unlock_irqrestore(&dev_priv->
irq_lock, flags);
839 spin_unlock_irqrestore(&dev_priv->
irq_lock, flags);
875 u32 invalidate_domains,
885 intel_ring_emit(ring,
MI_NOOP);
905 intel_ring_emit(ring, seqno);
920 if (!dev->irq_enabled)
939 spin_unlock_irqrestore(&dev_priv->
irq_lock, flags);
961 spin_unlock_irqrestore(&dev_priv->
irq_lock, flags);
975 intel_ring_emit(ring,
979 intel_ring_emit(ring, offset);
997 intel_ring_emit(ring, offset + len - 8);
998 intel_ring_emit(ring, 0);
1031 drm_gem_object_unreference(&obj->
base);
1043 DRM_ERROR(
"Failed to allocate status page\n");
1065 DRM_DEBUG_DRIVER(
"%s hws offset: 0x%08x\n",
1073 drm_gem_object_unreference(&obj->
base);
1078 static int intel_init_ring_buffer(
struct drm_device *dev,
1093 ret = init_status_page(ring);
1100 DRM_ERROR(
"Failed to allocate ringbuffer\n");
1119 DRM_ERROR(
"Failed to map ringbuffer.\n");
1124 ret = ring->
init(ring);
1143 drm_gem_object_unreference(&obj->
base);
1146 cleanup_status_page(ring);
1159 dev_priv = ring->
dev->dev_private;
1160 ret = intel_wait_ring_idle(ring);
1162 DRM_ERROR(
"failed to quiesce %s whilst cleaning up: %d\n",
1170 drm_gem_object_unreference(&ring->
obj->base);
1176 cleanup_status_page(ring);
1184 if (ring->
space < rem) {
1196 ring->
space = ring_space(ring);
1223 ring->
space = ring_space(ring);
1224 if (ring->
space >= n)
1231 if (request->
tail == -1)
1234 space = request->
tail - (ring->
tail + 8);
1236 space += ring->
size;
1238 seqno = request->
seqno;
1253 ret = intel_ring_wait_seqno(ring, seqno);
1262 ring->
space = ring_space(ring);
1276 ret = intel_ring_wait_request(ring, n);
1280 trace_i915_ring_wait_begin(ring);
1290 ring->
space = ring_space(ring);
1291 if (ring->
space >= n) {
1292 trace_i915_ring_wait_end(ring);
1296 if (dev->primary->master) {
1308 trace_i915_ring_wait_end(ring);
1316 int n = 4*num_dwords;
1324 ret = intel_wrap_ring_buffer(ring);
1344 if (dev_priv->
stop_rings & intel_ring_flag(ring))
1370 DRM_ERROR(
"timed out waiting for the BSD ring to wake up\n");
1384 u32 invalidate,
u32 flush)
1396 intel_ring_emit(ring, cmd);
1397 intel_ring_emit(ring, 0);
1398 intel_ring_emit(ring, 0);
1399 intel_ring_emit(ring,
MI_NOOP);
1416 intel_ring_emit(ring, offset);
1425 u32 invalidate,
u32 flush)
1435 if (invalidate & I915_GEM_DOMAIN_RENDER)
1437 intel_ring_emit(ring, cmd);
1438 intel_ring_emit(ring, 0);
1439 intel_ring_emit(ring, 0);
1440 intel_ring_emit(ring,
MI_NOOP);
1450 ring->
name =
"render ring";
1456 ring->
flush = gen7_render_ring_flush;
1458 ring->
flush = gen6_render_ring_flush;
1459 ring->
irq_get = gen6_ring_get_irq;
1460 ring->
irq_put = gen6_ring_put_irq;
1463 ring->
sync_to = gen6_ring_sync;
1471 ring->
flush = gen4_render_ring_flush;
1473 ring->
irq_get = gen5_ring_get_irq;
1474 ring->
irq_put = gen5_ring_put_irq;
1479 ring->
flush = gen2_render_ring_flush;
1481 ring->
flush = gen4_render_ring_flush;
1484 ring->
irq_get = i8xx_ring_get_irq;
1485 ring->
irq_put = i8xx_ring_put_irq;
1487 ring->
irq_get = i9xx_ring_get_irq;
1488 ring->
irq_put = i9xx_ring_put_irq;
1501 ring->
init = init_render_ring;
1502 ring->
cleanup = render_ring_cleanup;
1510 return intel_init_ring_buffer(dev, ring);
1518 ring->
name =
"render ring";
1532 ring->
flush = gen2_render_ring_flush;
1534 ring->
flush = gen4_render_ring_flush;
1537 ring->
irq_get = i8xx_ring_get_irq;
1538 ring->
irq_put = i8xx_ring_put_irq;
1540 ring->
irq_get = i9xx_ring_get_irq;
1541 ring->
irq_put = i9xx_ring_put_irq;
1551 ring->
init = init_render_ring;
1552 ring->
cleanup = render_ring_cleanup;
1568 DRM_ERROR(
"can not ioremap virtual address for"
1581 ring->
name =
"bsd ring";
1590 ring->
flush = gen6_ring_flush;
1594 ring->
irq_get = gen6_ring_get_irq;
1595 ring->
irq_put = gen6_ring_put_irq;
1597 ring->
sync_to = gen6_ring_sync;
1605 ring->
flush = bsd_ring_flush;
1610 ring->
irq_get = gen5_ring_get_irq;
1611 ring->
irq_put = gen5_ring_put_irq;
1614 ring->
irq_get = i9xx_ring_get_irq;
1615 ring->
irq_put = i9xx_ring_put_irq;
1619 ring->
init = init_ring_common;
1622 return intel_init_ring_buffer(dev, ring);
1630 ring->
name =
"blitter ring";
1635 ring->
flush = blt_ring_flush;
1639 ring->
irq_get = gen6_ring_get_irq;
1640 ring->
irq_put = gen6_ring_put_irq;
1642 ring->
sync_to = gen6_ring_sync;
1648 ring->
init = init_ring_common;
1650 return intel_init_ring_buffer(dev, ring);