drm/i915: Add functions to emit register offsets to the ring
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 4 Nov 2015 21:20:07 +0000 (23:20 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 18 Nov 2015 12:35:24 +0000 (14:35 +0200)
When register type safety happens, we can't just try to emit the
register itself to the ring. Instead we'll need to extract the
offset from it first. Add some convenience functions that will do
that.

v2: Convert MOCS setup too

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1446672017-24497-20-git-send-email-ville.syrjala@linux.intel.com
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_gem_context.c
drivers/gpu/drm/i915/i915_gem_execbuffer.c
drivers/gpu/drm/i915/i915_gem_gtt.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_lrc.c
drivers/gpu/drm/i915/intel_lrc.h
drivers/gpu/drm/i915/intel_mocs.c
drivers/gpu/drm/i915/intel_ringbuffer.c
drivers/gpu/drm/i915/intel_ringbuffer.h

index 001c47693fec3436cf633ec19f0c1aa8e7ce6f8a..44d8b9e9d2588107093b0764ded57fb40c33edfc 100644 (file)
@@ -4591,7 +4591,7 @@ int i915_gem_l3_remap(struct drm_i915_gem_request *req, int slice)
         */
        for (i = 0; i < GEN7_L3LOG_SIZE / 4; i++) {
                intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1));
-               intel_ring_emit(ring, GEN7_L3LOG(slice, i));
+               intel_ring_emit_reg(ring, GEN7_L3LOG(slice, i));
                intel_ring_emit(ring, remap_info[i]);
        }
 
index 204dc7c0b2d631116eb15fa1f8658c9e8c7de95e..4b9400402aa3ed6aafdc0986b006cb8cad1fd924 100644 (file)
@@ -556,7 +556,7 @@ mi_set_context(struct drm_i915_gem_request *req, u32 hw_flags)
                                if (signaller == ring)
                                        continue;
 
-                               intel_ring_emit(ring, RING_PSMI_CTL(signaller->mmio_base));
+                               intel_ring_emit_reg(ring, RING_PSMI_CTL(signaller->mmio_base));
                                intel_ring_emit(ring, _MASKED_BIT_ENABLE(GEN6_PSMI_SLEEP_MSG_DISABLE));
                        }
                }
@@ -581,7 +581,7 @@ mi_set_context(struct drm_i915_gem_request *req, u32 hw_flags)
                                if (signaller == ring)
                                        continue;
 
-                               intel_ring_emit(ring, RING_PSMI_CTL(signaller->mmio_base));
+                               intel_ring_emit_reg(ring, RING_PSMI_CTL(signaller->mmio_base));
                                intel_ring_emit(ring, _MASKED_BIT_DISABLE(GEN6_PSMI_SLEEP_MSG_DISABLE));
                        }
                }
index 6ed7d63a0688384830894f4a455463bd7e9e060c..a4c243cec4aa018e88dbe9146f1318c3766fc80f 100644 (file)
@@ -1114,7 +1114,7 @@ i915_reset_gen7_sol_offsets(struct drm_device *dev,
 
        for (i = 0; i < 4; i++) {
                intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1));
-               intel_ring_emit(ring, GEN7_SO_WRITE_OFFSET(i));
+               intel_ring_emit_reg(ring, GEN7_SO_WRITE_OFFSET(i));
                intel_ring_emit(ring, 0);
        }
 
@@ -1241,7 +1241,7 @@ i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
 
                intel_ring_emit(ring, MI_NOOP);
                intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1));
-               intel_ring_emit(ring, INSTPM);
+               intel_ring_emit_reg(ring, INSTPM);
                intel_ring_emit(ring, instp_mask << 16 | instp_mode);
                intel_ring_advance(ring);
 
index 4d357e18e5d12cdd2ea1ef684586187d7e6a76e4..1e3dd1060e51778f28b519a5e87d28916db5b541 100644 (file)
@@ -667,10 +667,10 @@ static int gen8_write_pdp(struct drm_i915_gem_request *req,
                return ret;
 
        intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1));
-       intel_ring_emit(ring, GEN8_RING_PDP_UDW(ring, entry));
+       intel_ring_emit_reg(ring, GEN8_RING_PDP_UDW(ring, entry));
        intel_ring_emit(ring, upper_32_bits(addr));
        intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1));
-       intel_ring_emit(ring, GEN8_RING_PDP_LDW(ring, entry));
+       intel_ring_emit_reg(ring, GEN8_RING_PDP_LDW(ring, entry));
        intel_ring_emit(ring, lower_32_bits(addr));
        intel_ring_advance(ring);
 
@@ -1668,9 +1668,9 @@ static int hsw_mm_switch(struct i915_hw_ppgtt *ppgtt,
                return ret;
 
        intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(2));
-       intel_ring_emit(ring, RING_PP_DIR_DCLV(ring));
+       intel_ring_emit_reg(ring, RING_PP_DIR_DCLV(ring));
        intel_ring_emit(ring, PP_DIR_DCLV_2G);
-       intel_ring_emit(ring, RING_PP_DIR_BASE(ring));
+       intel_ring_emit_reg(ring, RING_PP_DIR_BASE(ring));
        intel_ring_emit(ring, get_pd_offset(ppgtt));
        intel_ring_emit(ring, MI_NOOP);
        intel_ring_advance(ring);
@@ -1705,9 +1705,9 @@ static int gen7_mm_switch(struct i915_hw_ppgtt *ppgtt,
                return ret;
 
        intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(2));
-       intel_ring_emit(ring, RING_PP_DIR_DCLV(ring));
+       intel_ring_emit_reg(ring, RING_PP_DIR_DCLV(ring));
        intel_ring_emit(ring, PP_DIR_DCLV_2G);
-       intel_ring_emit(ring, RING_PP_DIR_BASE(ring));
+       intel_ring_emit_reg(ring, RING_PP_DIR_BASE(ring));
        intel_ring_emit(ring, get_pd_offset(ppgtt));
        intel_ring_emit(ring, MI_NOOP);
        intel_ring_advance(ring);
index 9a0a5b9a039ff2041c3f3e74b7bad0b34715ade8..789c526a486803511883cb2cd541618df74d2b5e 100644 (file)
@@ -11110,7 +11110,7 @@ static int intel_gen7_queue_flip(struct drm_device *dev,
         */
        if (ring->id == RCS) {
                intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1));
-               intel_ring_emit(ring, DERRMR);
+               intel_ring_emit_reg(ring, DERRMR);
                intel_ring_emit(ring, ~(DERRMR_PIPEA_PRI_FLIP_DONE |
                                        DERRMR_PIPEB_PRI_FLIP_DONE |
                                        DERRMR_PIPEC_PRI_FLIP_DONE));
@@ -11120,7 +11120,7 @@ static int intel_gen7_queue_flip(struct drm_device *dev,
                else
                        intel_ring_emit(ring, MI_STORE_REGISTER_MEM |
                                              MI_SRM_LRM_GLOBAL_GTT);
-               intel_ring_emit(ring, DERRMR);
+               intel_ring_emit_reg(ring, DERRMR);
                intel_ring_emit(ring, ring->scratch.gtt_offset + 256);
                if (IS_GEN8(dev)) {
                        intel_ring_emit(ring, 0);
index 28b1b74f76740722d7620a3f0f0f062843bc8fd6..c12db1aa20b0fe8221faffb622355c6c1446832d 100644 (file)
@@ -919,7 +919,7 @@ int intel_execlists_submission(struct i915_execbuffer_params *params,
 
                intel_logical_ring_emit(ringbuf, MI_NOOP);
                intel_logical_ring_emit(ringbuf, MI_LOAD_REGISTER_IMM(1));
-               intel_logical_ring_emit(ringbuf, INSTPM);
+               intel_logical_ring_emit_reg(ringbuf, INSTPM);
                intel_logical_ring_emit(ringbuf, instp_mask << 16 | instp_mode);
                intel_logical_ring_advance(ringbuf);
 
@@ -1094,7 +1094,7 @@ static int intel_logical_ring_workarounds_emit(struct drm_i915_gem_request *req)
 
        intel_logical_ring_emit(ringbuf, MI_LOAD_REGISTER_IMM(w->count));
        for (i = 0; i < w->count; i++) {
-               intel_logical_ring_emit(ringbuf, w->reg[i].addr);
+               intel_logical_ring_emit_reg(ringbuf, w->reg[i].addr);
                intel_logical_ring_emit(ringbuf, w->reg[i].value);
        }
        intel_logical_ring_emit(ringbuf, MI_NOOP);
@@ -1537,9 +1537,9 @@ static int intel_logical_ring_emit_pdps(struct drm_i915_gem_request *req)
        for (i = GEN8_LEGACY_PDPES - 1; i >= 0; i--) {
                const dma_addr_t pd_daddr = i915_page_dir_dma_addr(ppgtt, i);
 
-               intel_logical_ring_emit(ringbuf, GEN8_RING_PDP_UDW(ring, i));
+               intel_logical_ring_emit_reg(ringbuf, GEN8_RING_PDP_UDW(ring, i));
                intel_logical_ring_emit(ringbuf, upper_32_bits(pd_daddr));
-               intel_logical_ring_emit(ringbuf, GEN8_RING_PDP_LDW(ring, i));
+               intel_logical_ring_emit_reg(ringbuf, GEN8_RING_PDP_LDW(ring, i));
                intel_logical_ring_emit(ringbuf, lower_32_bits(pd_daddr));
        }
 
index 8a08a278032158ce5704c6c76f19ff16db0edd33..93668f8bfebcff31155d2beb565178cde7cd2d9c 100644 (file)
@@ -68,6 +68,11 @@ static inline void intel_logical_ring_emit(struct intel_ringbuffer *ringbuf,
        iowrite32(data, ringbuf->virtual_start + ringbuf->tail);
        ringbuf->tail += 4;
 }
+static inline void intel_logical_ring_emit_reg(struct intel_ringbuffer *ringbuf,
+                                              u32 reg)
+{
+       intel_logical_ring_emit(ringbuf, reg);
+}
 
 /* Logical Ring Contexts */
 
index d5463191308c718e185eb4830d88dc347f61fdff..85b51bebd46ba9aae559b12c54f0e524055ac64e 100644 (file)
@@ -210,7 +210,7 @@ static int emit_mocs_control_table(struct drm_i915_gem_request *req,
                                MI_LOAD_REGISTER_IMM(GEN9_NUM_MOCS_ENTRIES));
 
        for (index = 0; index < table->size; index++) {
-               intel_logical_ring_emit(ringbuf, mocs_register(ring, index));
+               intel_logical_ring_emit_reg(ringbuf, mocs_register(ring, index));
                intel_logical_ring_emit(ringbuf,
                                        table->table[index].control_value);
        }
@@ -224,7 +224,7 @@ static int emit_mocs_control_table(struct drm_i915_gem_request *req,
         * that value to all the used entries.
         */
        for (; index < GEN9_NUM_MOCS_ENTRIES; index++) {
-               intel_logical_ring_emit(ringbuf, mocs_register(ring, index));
+               intel_logical_ring_emit_reg(ringbuf, mocs_register(ring, index));
                intel_logical_ring_emit(ringbuf, table->table[0].control_value);
        }
 
@@ -272,7 +272,7 @@ static int emit_mocs_l3cc_table(struct drm_i915_gem_request *req,
                value = (table->table[count].l3cc_value & 0xffff) |
                        ((table->table[count + 1].l3cc_value & 0xffff) << 16);
 
-               intel_logical_ring_emit(ringbuf, GEN9_LNCFCMOCS(i));
+               intel_logical_ring_emit_reg(ringbuf, GEN9_LNCFCMOCS(i));
                intel_logical_ring_emit(ringbuf, value);
        }
 
@@ -289,7 +289,7 @@ static int emit_mocs_l3cc_table(struct drm_i915_gem_request *req,
         * they are reserved by the hardware.
         */
        for (; i < GEN9_NUM_MOCS_ENTRIES / 2; i++) {
-               intel_logical_ring_emit(ringbuf, GEN9_LNCFCMOCS(i));
+               intel_logical_ring_emit_reg(ringbuf, GEN9_LNCFCMOCS(i));
                intel_logical_ring_emit(ringbuf, value);
 
                value = filler;
index e0c527732606ae7dd3f8ef6a76281e203c73aa95..75f29d81af1620e5b975c8213ee844174d4b97ae 100644 (file)
@@ -731,7 +731,7 @@ static int intel_ring_workarounds_emit(struct drm_i915_gem_request *req)
 
        intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(w->count));
        for (i = 0; i < w->count; i++) {
-               intel_ring_emit(ring, w->reg[i].addr);
+               intel_ring_emit_reg(ring, w->reg[i].addr);
                intel_ring_emit(ring, w->reg[i].value);
        }
        intel_ring_emit(ring, MI_NOOP);
@@ -1313,7 +1313,7 @@ static int gen6_signal(struct drm_i915_gem_request *signaller_req,
                if (mbox_reg != GEN6_NOSYNC) {
                        u32 seqno = i915_gem_request_get_seqno(signaller_req);
                        intel_ring_emit(signaller, MI_LOAD_REGISTER_IMM(1));
-                       intel_ring_emit(signaller, mbox_reg);
+                       intel_ring_emit_reg(signaller, mbox_reg);
                        intel_ring_emit(signaller, seqno);
                }
        }
index 58b1976a7d0ae86054a2b2ae6821a63f867bc2f5..1ab5cb8e05f87ac90bc92de2746665555373fb0b 100644 (file)
@@ -443,6 +443,11 @@ static inline void intel_ring_emit(struct intel_engine_cs *ring,
        iowrite32(data, ringbuf->virtual_start + ringbuf->tail);
        ringbuf->tail += 4;
 }
+static inline void intel_ring_emit_reg(struct intel_engine_cs *ring,
+                                      u32 reg)
+{
+       intel_ring_emit(ring, reg);
+}
 static inline void intel_ring_advance(struct intel_engine_cs *ring)
 {
        struct intel_ringbuffer *ringbuf = ring->buffer;