Skip to contentSkip to conversation

drm/i915: Clean up display pipe register accesses

PATCH In review Antti Koskipaa 2 participants 3 messages Jan 15, 2014 – Jan 24, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: Clean up display pipe register accesses

RFCv2: Reorganize array indexing so that full offsets can be used as is. It makes grepping for registers in i915_reg.h much easier. Also move offset arrays to intel_device_info.

PATCHv1: Fixed offsets for VLV, proper eDP handling

Upcoming hardware will not have the various display pipe register ranges evenly spaced in memory. Change register address calculations into array lookups.

Tested on SNB, VLV, IVB and HSW w/eDP.

I left the UMS cruft untouched.

---
 drivers/gpu/drm/i915/i915_drv.c |  44 +++++++++
 drivers/gpu/drm/i915/i915_drv.h |  11 ++-
 drivers/gpu/drm/i915/i915_reg.h | 191 +++++++++++++++++++++++-----------------
 3 files changed, 164 insertions(+), 82 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +44 -0
index 62c0f16..3ac2ad2 100644
@@ -157,16 +157,35 @@ MODULE_PARM_DESC(prefault_disable,
 
 static struct drm_driver driver;
 
+#define GEN_DEFAULT_PIPEOFFSETS \
+	.pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, PIPE_C_OFFSET }, \
+	.trans_offsets = { TRANSCODER_A_OFFSET, TRANSCODER_B_OFFSET, \
+			   TRANSCODER_C_OFFSET, \
+			   TRANSCODER_EDP_OFFSET }, \
+	.dpll_offsets = { DPLL_A_OFFSET, DPLL_B_OFFSET }, \
+	.dpll_md_offsets = { DPLL_A_MD_OFFSET, DPLL_B_MD_OFFSET }, \
+	.palette_offsets = { PALETTE_A_OFFSET, PALETTE_B_OFFSET }, \
+	.trans_ddi_func_offsets = { TRANS_DDI_FUNC_CTL_A, \
+				    TRANS_DDI_FUNC_CTL_B, \
+				    TRANS_DDI_FUNC_CTL_C, \
+				    TRANS_DDI_FUNC_CTL_EDP }, \
+	.trans_msa_misc_offsets = { TRANSA_MSA_MISC, TRANSB_MSA_MISC, \
+				    TRANSC_MSA_MISC, TRANS_EDP_MSA_MISC },
+
+
+
 static const struct intel_device_info intel_i830_info = {
 	.gen = 2, .is_mobile = 1, .cursor_needs_physical = 1, .num_pipes = 2,
 	.has_overlay = 1, .overlay_needs_physical = 1,
 	.ring_mask = RENDER_RING,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_845g_info = {
 	.gen = 2, .num_pipes = 1,
 	.has_overlay = 1, .overlay_needs_physical = 1,
 	.ring_mask = RENDER_RING,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_i85x_info = {
@@ -175,18 +194,21 @@ static const struct intel_device_info intel_i85x_info = {
 	.has_overlay = 1, .overlay_needs_physical = 1,
 	.has_fbc = 1,
 	.ring_mask = RENDER_RING,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_i865g_info = {
 	.gen = 2, .num_pipes = 1,
 	.has_overlay = 1, .overlay_needs_physical = 1,
 	.ring_mask = RENDER_RING,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_i915g_info = {
 	.gen = 3, .is_i915g = 1, .cursor_needs_physical = 1, .num_pipes = 2,
 	.has_overlay = 1, .overlay_needs_physical = 1,
 	.ring_mask = RENDER_RING,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 static const struct intel_device_info intel_i915gm_info = {
 	.gen = 3, .is_mobile = 1, .num_pipes = 2,
@@ -195,11 +217,13 @@ static const struct intel_device_info intel_i915gm_info = {
 	.supports_tv = 1,
 	.has_fbc = 1,
 	.ring_mask = RENDER_RING,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 static const struct intel_device_info intel_i945g_info = {
 	.gen = 3, .has_hotplug = 1, .cursor_needs_physical = 1, .num_pipes = 2,
 	.has_overlay = 1, .overlay_needs_physical = 1,
 	.ring_mask = RENDER_RING,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 static const struct intel_device_info intel_i945gm_info = {
 	.gen = 3, .is_i945gm = 1, .is_mobile = 1, .num_pipes = 2,
@@ -208,6 +232,7 @@ static const struct intel_device_info intel_i945gm_info = {
 	.supports_tv = 1,
 	.has_fbc = 1,
 	.ring_mask = RENDER_RING,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_i965g_info = {
@@ -215,6 +240,7 @@ static const struct intel_device_info intel_i965g_info = {
 	.has_hotplug = 1,
 	.has_overlay = 1,
 	.ring_mask = RENDER_RING,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_i965gm_info = {
@@ -223,6 +249,7 @@ static const struct intel_device_info intel_i965gm_info = {
 	.has_overlay = 1,
 	.supports_tv = 1,
 	.ring_mask = RENDER_RING,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_g33_info = {
@@ -230,12 +257,14 @@ static const struct intel_device_info intel_g33_info = {
 	.need_gfx_hws = 1, .has_hotplug = 1,
 	.has_overlay = 1,
 	.ring_mask = RENDER_RING,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_g45_info = {
 	.gen = 4, .is_g4x = 1, .need_gfx_hws = 1, .num_pipes = 2,
 	.has_pipe_cxsr = 1, .has_hotplug = 1,
 	.ring_mask = RENDER_RING | BSD_RING,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_gm45_info = {
@@ -244,18 +273,21 @@ static const struct intel_device_info intel_gm45_info = {
 	.has_pipe_cxsr = 1, .has_hotplug = 1,
 	.supports_tv = 1,
 	.ring_mask = RENDER_RING | BSD_RING,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_pineview_info = {
 	.gen = 3, .is_g33 = 1, .is_pineview = 1, .is_mobile = 1, .num_pipes = 2,
 	.need_gfx_hws = 1, .has_hotplug = 1,
 	.has_overlay = 1,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_ironlake_d_info = {
 	.gen = 5, .num_pipes = 2,
 	.need_gfx_hws = 1, .has_hotplug = 1,
 	.ring_mask = RENDER_RING | BSD_RING,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_ironlake_m_info = {
@@ -263,6 +295,7 @@ static const struct intel_device_info intel_ironlake_m_info = {
 	.need_gfx_hws = 1, .has_hotplug = 1,
 	.has_fbc = 1,
 	.ring_mask = RENDER_RING | BSD_RING,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_sandybridge_d_info = {
@@ -271,6 +304,7 @@ static const struct intel_device_info intel_sandybridge_d_info = {
 	.has_fbc = 1,
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING,
 	.has_llc = 1,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_sandybridge_m_info = {
@@ -279,6 +313,7 @@ static const struct intel_device_info intel_sandybridge_m_info = {
 	.has_fbc = 1,
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING,
 	.has_llc = 1,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 #define GEN7_FEATURES  \
@@ -291,18 +326,21 @@ static const struct intel_device_info intel_sandybridge_m_info = {
 static const struct intel_device_info intel_ivybridge_d_info = {
 	GEN7_FEATURES,
 	.is_ivybridge = 1,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_ivybridge_m_info = {
 	GEN7_FEATURES,
 	.is_ivybridge = 1,
 	.is_mobile = 1,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_ivybridge_q_info = {
 	GEN7_FEATURES,
 	.is_ivybridge = 1,
 	.num_pipes = 0, /* legal, last one wins */
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_valleyview_m_info = {
@@ -313,6 +351,7 @@ static const struct intel_device_info intel_valleyview_m_info = {
 	.display_mmio_offset = VLV_DISPLAY_BASE,
 	.has_fbc = 0, /* legal, last one wins */
 	.has_llc = 0, /* legal, last one wins */
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_valleyview_d_info = {
@@ -322,6 +361,7 @@ static const struct intel_device_info intel_valleyview_d_info = {
 	.display_mmio_offset = VLV_DISPLAY_BASE,
 	.has_fbc = 0, /* legal, last one wins */
 	.has_llc = 0, /* legal, last one wins */
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_haswell_d_info = {
@@ -330,6 +370,7 @@ static const struct intel_device_info intel_haswell_d_info = {
 	.has_ddi = 1,
 	.has_fpga_dbg = 1,
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_haswell_m_info = {
@@ -339,6 +380,7 @@ static const struct intel_device_info intel_haswell_m_info = {
 	.has_ddi = 1,
 	.has_fpga_dbg = 1,
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_broadwell_d_info = {
@@ -347,6 +389,7 @@ static const struct intel_device_info intel_broadwell_d_info = {
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
 	.has_llc = 1,
 	.has_ddi = 1,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 static const struct intel_device_info intel_broadwell_m_info = {
@@ -355,6 +398,7 @@ static const struct intel_device_info intel_broadwell_m_info = {
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
 	.has_llc = 1,
 	.has_ddi = 1,
+	GEN_DEFAULT_PIPEOFFSETS
 };
 
 /*
drivers/gpu/drm/i915/i915_drv.h +10 -1
index 29e1e86..1bb70a0 100644
@@ -66,7 +66,8 @@ enum transcoder {
 	TRANSCODER_A = 0,
 	TRANSCODER_B,
 	TRANSCODER_C,
-	TRANSCODER_EDP = 0xF,
+	TRANSCODER_EDP,
+	I915_MAX_TRANSCODERS
 };
 #define transcoder_name(t) ((t) + 'A')
 
@@ -506,6 +507,14 @@ struct intel_device_info {
 	u8 gen;
 	u8 ring_mask; /* Rings supported by the HW */
 	DEV_INFO_FOR_EACH_FLAG(DEFINE_FLAG, SEP_SEMICOLON);
+	/* Register offsets for the various display pipes and transcoders */
+	int pipe_offsets[I915_MAX_PIPES];
+	int trans_offsets[I915_MAX_TRANSCODERS];
+	int dpll_offsets[I915_MAX_PIPES];
+	int dpll_md_offsets[I915_MAX_PIPES];
+	int palette_offsets[I915_MAX_PIPES];
+	int trans_ddi_func_offsets[I915_MAX_TRANSCODERS];
+	int trans_msa_misc_offsets[I915_MAX_TRANSCODERS];
 };
 
 #undef DEFINE_FLAG
drivers/gpu/drm/i915/i915_reg.h +110 -81

291 lines not on this page · raw message

Signature · 1 line
1.8.1.5
#1 lore raw
Quoted 34 lines

-----Original Message-----
From: [email protected] [mailto:intel-gfx- [email protected]] On Behalf Of Antti Koskipaa
Sent: Wednesday, January 15, 2014 5:26 AM
To: [email protected]
Subject: [Intel-gfx] [PATCH] drm/i915: Clean up display pipe register accesses

RFCv2: Reorganize array indexing so that full offsets can be used as is. It makes grepping for registers in i915_reg.h much easier. Also move offset arrays to intel_device_info.

PATCHv1: Fixed offsets for VLV, proper eDP handling

Upcoming hardware will not have the various display pipe register ranges evenly spaced in memory. Change register address calculations into array lookups.

Tested on SNB, VLV, IVB and HSW w/eDP.

I left the UMS cruft untouched.

---
 drivers/gpu/drm/i915/i915_drv.c |  44 +++++++++
 drivers/gpu/drm/i915/i915_drv.h |  11 ++-
 drivers/gpu/drm/i915/i915_reg.h | 191 +++++++++++++++++++++++--------
---------
 3 files changed, 164 insertions(+), 82 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +0 -0
index 62c0f16..3ac2ad2 100644

[snip]

Quoted 17 lines
drivers/gpu/drm/i915/i915_drv.c +16 -0
+#define _HTOTAL_B	0x61000
+#define _HBLANK_B	0x61004
+#define _HSYNC_B	0x61008
+#define _VTOTAL_B	0x6100c
+#define _VBLANK_B	0x61010
+#define _VSYNC_B	0x61014
+#define _PIPEBSRC	0x6101c
+#define _BCLRPAT_B	0x61020
+#define _VSYNCSHIFT_B	0x61028
+
+#define TRANSCODER_A_OFFSET 0x60000
+#define TRANSCODER_B_OFFSET 0x61000
+#define TRANSCODER_C_OFFSET 0x62000
+#define TRANSCODER_EDP_OFFSET 0x6f000
+
+#define _TRANSCODER2(pipe, reg) (dev_priv->info->trans_offsets[(pipe)] -

\

drivers/gpu/drm/i915/i915_drv.c

Quoted 10 lines
drivers/gpu/drm/i915/i915_drv.c +10 -0
+	dev_priv->info->trans_offsets[TRANSCODER_A] + (reg) + \
+	dev_priv->info->display_mmio_offset)
+
+#define HTOTAL(trans) _TRANSCODER2(trans, _HTOTAL_A)
+#define HBLANK(trans) _TRANSCODER2(trans, _HBLANK_A)
+#define HSYNC(trans) _TRANSCODER2(trans, _HSYNC_A)
+#define VTOTAL(trans) _TRANSCODER2(trans, _VTOTAL_A)
+#define VBLANK(trans) _TRANSCODER2(trans, _VBLANK_A)
+#define VSYNC(trans) _TRANSCODER2(trans, _VSYNC_A)
+#define BCLRPAT(pipe) _PIPE2(pipe, _BCLRPAT_A)

BCLRPAT is in the transcoder, not the pipe.

Quoted 42 lines

+#define VSYNCSHIFT(trans) _TRANSCODER2(trans, _VSYNCSHIFT_A)

/* HSW+ eDP PSR registers */
#define EDP_PSR_BASE(dev) (IS_HASWELL(dev) ? 0x64800 :
0x6f800)

drivers/gpu/drm/i915/i915_drv.c +2 -2
@@ -3173,10 +3186,10 @@
 /* Display & cursor control */
 
 /* Pipe A */
-#define _PIPEADSL		(dev_priv->info->display_mmio_offset +
 0x70000)
+#define _PIPEADSL		0x70000
 #define   DSL_LINEMASK_GEN2	0x00000fff
 #define   DSL_LINEMASK_GEN3	0x00001fff
-#define _PIPEACONF		(dev_priv->info->display_mmio_offset +
 0x70008)
+#define _PIPEACONF		0x70008
 #define   PIPECONF_ENABLE	(1<<31)

#define PIPECONF_DISABLE 0
#define PIPECONF_DOUBLE_WIDE (1<<30)

drivers/gpu/drm/i915/i915_drv.c +1 -1
@@ -3219,7 +3232,7 @@
 #define   PIPECONF_DITHER_TYPE_ST1 (1<<2)
 #define   PIPECONF_DITHER_TYPE_ST2 (2<<2)
 #define   PIPECONF_DITHER_TYPE_TEMP (3<<2)
-#define _PIPEASTAT		(dev_priv->info->display_mmio_offset +
 0x70024)
+#define _PIPEASTAT		0x70024
 #define   PIPE_FIFO_UNDERRUN_STATUS		(1UL<<31)
 #define   SPRITE1_FLIPDONE_INT_EN_VLV		(1UL<<30)

#define PIPE_CRC_ERROR_ENABLE (1UL<<29)

drivers/gpu/drm/i915/i915_drv.c +0 -6
@@ -3257,12 +3270,21 @@
 #define   PIPE_VBLANK_INTERRUPT_STATUS		(1UL<<1)
 #define   PIPE_OVERLAY_UPDATED_STATUS		(1UL<<0)
 
-#define PIPESRC(pipe) _PIPE(pipe, _PIPEASRC, _PIPEBSRC)
-#define PIPECONF(tran) _TRANSCODER(tran, _PIPEACONF, _PIPEBCONF)
-#define PIPEDSL(pipe)  _PIPE(pipe, _PIPEADSL, _PIPEBDSL)
-#define PIPEFRAME(pipe) _PIPE(pipe, _PIPEAFRAMEHIGH,
 _PIPEBFRAMEHIGH)
-#define PIPEFRAMEPIXEL(pipe)  _PIPE(pipe, _PIPEAFRAMEPIXEL,
 _PIPEBFRAMEPIXEL)
-#define PIPESTAT(pipe) _PIPE(pipe, _PIPEASTAT, _PIPEBSTAT)

drivers/gpu/drm/i915/i915_drv.c line 3284

Quoted 10 lines
drivers/gpu/drm/i915/i915_drv.c +10 -0
+#define PIPE_A_OFFSET	0x70000
+#define PIPE_B_OFFSET	0x71000
+#define PIPE_C_OFFSET	0x72000
+#define PIPE_EDP_OFFSET	0x7f000
+
+#define _PIPE2(pipe, reg) (dev_priv->info->pipe_offsets[pipe] - \
+	dev_priv->info->pipe_offsets[PIPE_A] + (reg) + \
+	dev_priv->info->display_mmio_offset)
+
+#define PIPESRC(pipe) _PIPE2(pipe, _PIPEASRC)

PIPERSRC is in the transcoder not in the pipe.

drivers/gpu/drm/i915/i915_drv.c line 3285

Quoted 1 line
drivers/gpu/drm/i915/i915_drv.c +1 -0
+#define PIPECONF(tran) _TRANSCODER2(tran, _PIPEACONF)

PIPECONF is in the pipe not the transcoder.

drivers/gpu/drm/i915/i915_drv.c line 3290

Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.c +4 -0
+#define PIPEDSL(pipe)  _PIPE2(pipe, _PIPEADSL)
+#define PIPEFRAME(pipe) _PIPE2(pipe, _PIPEAFRAMEHIGH)
+#define PIPEFRAMEPIXEL(pipe)  _PIPE2(pipe, _PIPEAFRAMEPIXEL)
+#define PIPESTAT(pipe) _PIPE2(pipe, _PIPEASTAT)
 

[snip]

Missing from that patch is also all the DSP* registers (DSPCNTR,DSPADDR, etc...) those should use the new _PIPE2 macro.

Thanks,
Rafael

#2 lore raw
Quoted 7 lines · Rafael

BCLRPAT is in the transcoder, not the pipe.

PIPERSRC is in the transcoder not in the pipe.

PIPECONF is in the pipe not the transcoder.

Missing from that patch is also all the DSP* registers (DSPCNTR,DSPADDR, etc...) those should use the new _PIPE2 macro.

Yes, you are correct. Seems that some of the original macros were wrong. V2 coming up.

Signature · 1 line
- Antti