drm/i915: Add register whitelists for mesa
authorBrad Volkin <bradley.d.volkin@intel.com>
Tue, 18 Feb 2014 18:15:50 +0000 (10:15 -0800)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 1 Apr 2014 20:58:10 +0000 (22:58 +0200)
These registers are currently used by mesa for blitting,
transform feedback extensions, and performance monitoring
extensions.

v2: REG64 macro

Signed-off-by: Brad Volkin <bradley.d.volkin@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_cmd_parser.c
drivers/gpu/drm/i915/i915_reg.h

index 7b80a84345a0527f496a004fe2cf0c06a4afe650..7249b512571d4e6acaaa3d82348897d5c9cd749c 100644 (file)
@@ -244,6 +244,45 @@ static const struct drm_i915_cmd_table hsw_blt_ring_cmds[] = {
        { hsw_blt_cmds, ARRAY_SIZE(hsw_blt_cmds) },
 };
 
+/*
+ * Register whitelists, sorted by increasing register offset.
+ *
+ * Some registers that userspace accesses are 64 bits. The register
+ * access commands only allow 32-bit accesses. Hence, we have to include
+ * entries for both halves of the 64-bit registers.
+ */
+
+/* Convenience macro for adding 64-bit registers */
+#define REG64(addr) (addr), (addr + sizeof(u32))
+
+static const u32 gen7_render_regs[] = {
+       REG64(HS_INVOCATION_COUNT),
+       REG64(DS_INVOCATION_COUNT),
+       REG64(IA_VERTICES_COUNT),
+       REG64(IA_PRIMITIVES_COUNT),
+       REG64(VS_INVOCATION_COUNT),
+       REG64(GS_INVOCATION_COUNT),
+       REG64(GS_PRIMITIVES_COUNT),
+       REG64(CL_INVOCATION_COUNT),
+       REG64(CL_PRIMITIVES_COUNT),
+       REG64(PS_INVOCATION_COUNT),
+       REG64(PS_DEPTH_COUNT),
+       REG64(GEN7_SO_NUM_PRIMS_WRITTEN(0)),
+       REG64(GEN7_SO_NUM_PRIMS_WRITTEN(1)),
+       REG64(GEN7_SO_NUM_PRIMS_WRITTEN(2)),
+       REG64(GEN7_SO_NUM_PRIMS_WRITTEN(3)),
+       GEN7_SO_WRITE_OFFSET(0),
+       GEN7_SO_WRITE_OFFSET(1),
+       GEN7_SO_WRITE_OFFSET(2),
+       GEN7_SO_WRITE_OFFSET(3),
+};
+
+static const u32 gen7_blt_regs[] = {
+       BCS_SWCTRL,
+};
+
+#undef REG64
+
 static u32 gen7_render_get_cmd_length_mask(u32 cmd_header)
 {
        u32 client = (cmd_header & INSTR_CLIENT_MASK) >> INSTR_CLIENT_SHIFT;
@@ -367,6 +406,9 @@ void i915_cmd_parser_init_ring(struct intel_ring_buffer *ring)
                        ring->cmd_table_count = ARRAY_SIZE(gen7_render_cmds);
                }
 
+               ring->reg_table = gen7_render_regs;
+               ring->reg_count = ARRAY_SIZE(gen7_render_regs);
+
                ring->get_cmd_length_mask = gen7_render_get_cmd_length_mask;
                break;
        case VCS:
@@ -383,6 +425,9 @@ void i915_cmd_parser_init_ring(struct intel_ring_buffer *ring)
                        ring->cmd_table_count = ARRAY_SIZE(gen7_blt_cmds);
                }
 
+               ring->reg_table = gen7_blt_regs;
+               ring->reg_count = ARRAY_SIZE(gen7_blt_regs);
+
                ring->get_cmd_length_mask = gen7_blt_get_cmd_length_mask;
                break;
        case VECS:
index 82ce432de7bc43e7ea0d087f01bc5991b746441d..6247843914c87d6d71c5bfd47879aba9e62508b0 100644 (file)
 #define COLOR_BLT     ((0x2<<29)|(0x40<<22))
 #define SRC_COPY_BLT  ((0x2<<29)|(0x43<<22))
 
+/*
+ * Registers used only by the command parser
+ */
+#define BCS_SWCTRL 0x22200
+
+#define HS_INVOCATION_COUNT 0x2300
+#define DS_INVOCATION_COUNT 0x2308
+#define IA_VERTICES_COUNT   0x2310
+#define IA_PRIMITIVES_COUNT 0x2318
+#define VS_INVOCATION_COUNT 0x2320
+#define GS_INVOCATION_COUNT 0x2328
+#define GS_PRIMITIVES_COUNT 0x2330
+#define CL_INVOCATION_COUNT 0x2338
+#define CL_PRIMITIVES_COUNT 0x2340
+#define PS_INVOCATION_COUNT 0x2348
+#define PS_DEPTH_COUNT      0x2350
+
+/* There are the 4 64-bit counter registers, one for each stream output */
+#define GEN7_SO_NUM_PRIMS_WRITTEN(n) (0x5200 + (n) * 8)
+
 /*
  * Reset registers
  */