Skip to contentSkip to conversation

drm/i915/de: Nuke uncore

PATCH New Ville Syrjala 2 participants 9 messages Nov 26

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

cover drm/i915/de: Nuke uncore

From: Ville Syrjälä <[email protected]>

Eliminate uncore from intel_de.c:
- add a display specific intel_reg_rw tracepoint
- implement mmio via raw readl()/writel()/etc
- add a new parent interface to get the pointer to the memory mapped registers

Ville Syrjälä (7):
drm/i915/de: Move the register tracepoint to display drm/i915/de: Pimp the intel_reg_rw tracepoint printf format drm/i915/de: Convert intel_de_read_fw() into a vfunc drm/i915/de: Use raw readl()/writel()/etc for register access in
display
drm/i915/de: Add intel_parent_mmio_regs() interface drm/xe: Nuke the compat uncore stuff
drm/i915/de: Document intel_de_write8()'s usage restrictions

 drivers/gpu/drm/i915/display/intel_de.c       | 119 ++++++++++++++----
 drivers/gpu/drm/i915/display/intel_de.h       |   6 +-
 .../gpu/drm/i915/display/intel_display_core.h |   3 +-
 .../drm/i915/display/intel_display_trace.h    |  25 ++++
 drivers/gpu/drm/i915/display/intel_parent.c   |   5 +
 drivers/gpu/drm/i915/display/intel_parent.h   |   1 +
 drivers/gpu/drm/i915/i915_driver.c            |   6 +
 .../drm/xe/compat-i915-headers/intel_uncore.h |  66 ----------
 drivers/gpu/drm/xe/display/xe_display.c       |  11 +-
 drivers/gpu/drm/xe/xe_device_types.h          |  13 --
 include/drm/intel/display_parent_interface.h  |   3 +
 11 files changed, 151 insertions(+), 107 deletions(-)
 delete mode 100644 drivers/gpu/drm/xe/compat-i915-headers/intel_uncore.h
Signature · 1 line
2.56.1
#1 lore raw

PATCH 1/7 drm/i915/de: Move the register tracepoint to display

From: Ville Syrjälä <[email protected]>

Implement the register read/write tracepoint directly in display code. The goal is to eliminate the uncore stuff completely and this is one step towards it.

Having a display exclusive tracepoint does mean that one has to enable both the core xe/i915 tracepoint and the display tracepoint to get a full view of the system (ignoring all the completely untraced exceptions in i915). But in general I think this is an improvement for pure display work as you no longer have to filter out all kinds of irrelevant registers. The only thing I might end up missing from the core side is the top level interrupt registers. With just the display tracepoint enabled you'll not catch those.

Until we eliminate the remaining uncore usage you will see double traces for display registers on xe if you have both tracepoints enabled. i915 does not trace the _fw() stuff (which we use to implement the display register accessors) so on i915 you will get just the display traces for display registers.

Support for 64bit register values is dropped since we don't use those in the display. The few 64bit registers that we have in display are accessed as a pair of 32bit registers.

The display code always passed 'true' as the condition to the i915 tracpoint, so there is no point in making the new tracepoint conditional.

---
 drivers/gpu/drm/i915/display/intel_de.c       | 21 ++++++++++++----
 .../drm/i915/display/intel_display_trace.h    | 24 +++++++++++++++++++
 2 files changed, 40 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/display/intel_de.c +16 -5
index bb008e1ee8fd..fe77e8769c9b 100644
@@ -10,8 +10,8 @@
 #include "intel_de.h"
 #include "intel_display_regs.h"
 #include "intel_display_rpm.h"
+#include "intel_display_trace.h"
 #include "intel_uncore.h"
-#include "intel_uncore_trace.h"
 
 static inline struct intel_uncore *__to_uncore(struct intel_display *display)
 {
@@ -151,25 +151,36 @@ int intel_de_wait_for_clear_ms(struct intel_display *display, intel_reg_t reg,
 
 u8 intel_de_read8(struct intel_display *display, intel_reg_t reg)
 {
+	u8 val;
+
 	/* this is only used on VGA registers (possible on pre-g4x) */
 	drm_WARN_ON(display->drm, DISPLAY_VER(display) >= 5 || display->platform.g4x);
 
-	return intel_uncore_read8(__to_uncore(display), reg);
+	val = intel_uncore_read8(__to_uncore(display), reg);
+	trace_intel_reg_rw(false, reg, val, sizeof(val));
+
+	return val;
 }
 
 void intel_de_write8(struct intel_display *display, intel_reg_t reg, u8 val)
 {
 	drm_WARN_ON(display->drm, DISPLAY_VER(display) >= 5 || display->platform.g4x);
 
+	trace_intel_reg_rw(true, reg, val, sizeof(val));
 	intel_uncore_write8(__to_uncore(display), reg, val);
 }
 
 u16 intel_de_read16(struct intel_display *display, intel_reg_t reg)
 {
+	u16 val;
+
 	/* this is only used on MCHBAR registers on pre-SNB */
 	drm_WARN_ON(display->drm, DISPLAY_VER(display) >= 6);
 
-	return intel_uncore_read16(__to_uncore(display), reg);
+	val = intel_uncore_read16(__to_uncore(display), reg);
+	trace_intel_reg_rw(false, reg, val, sizeof(val));
+
+	return val;
 }
 
 static __always_inline u32
@@ -178,7 +189,7 @@ __intel_de_read_fw(struct intel_display *display, intel_reg_t reg)
 	u32 val;
 
 	val = intel_uncore_read_fw(__to_uncore(display), reg);
-	trace_i915_reg_rw(false, reg, val, sizeof(val), true);
+	trace_intel_reg_rw(false, reg, val, sizeof(val));
 
 	return val;
 }
@@ -186,7 +197,7 @@ __intel_de_read_fw(struct intel_display *display, intel_reg_t reg)
 static __always_inline void
 __intel_de_write_fw(struct intel_display *display, intel_reg_t reg, u32 val)
 {
-	trace_i915_reg_rw(true, reg, val, sizeof(val), true);
+	trace_intel_reg_rw(true, reg, val, sizeof(val));
 	intel_uncore_write_fw(__to_uncore(display), reg, val);
 }
 
drivers/gpu/drm/i915/display/intel_display_trace.h +24 -0
index 98ba7e20ca30..fe69d203549b 100644
@@ -959,6 +959,30 @@ TRACE_EVENT(intel_frontbuffer_flush,
 		      __get_str(dev), __entry->frontbuffer_bits, __entry->origin)
 );
 
+TRACE_EVENT(intel_reg_rw,
+	TP_PROTO(bool write, intel_reg_t reg, u32 val, int len),
+
+	TP_ARGS(write, reg, val, len),
+
+	TP_STRUCT__entry(
+		__field(u32, val)
+		__field(u32, reg)
+		__field(u16, write)
+		__field(u16, len)
+		),
+
+	TP_fast_assign(
+		__entry->val = val;
+		__entry->reg = intel_reg_offset(reg);
+		__entry->write = write;
+		__entry->len = len;
+		),
+
+	TP_printk("%s reg=0x%x, len=%d, val=0x%x",
+		__entry->write ? "write" : "read",
+		__entry->reg, __entry->len, __entry->val)
+);
+
 #endif /* __INTEL_DISPLAY_TRACE_H__ */
 
 /* This part must be outside protection */
Signature · 1 line
2.56.1
#2 lore raw

PATCH 2/7 drm/i915/de: Pimp the intel_reg_rw tracepoint printf format

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

Make the intel_reg_rw tracepoint prints a bit more pleasant:
- Make the "read" vs. "write" field the same width so the following columns all line up when reading+writing the same registers
- Zero pad the value to the full register width. Counting hex digits to figure out if I'm looking at bit 26 or bit 22 isn't particularly fun.

I was also considering making the register offset field a constant width so things wouldn't shift around when the register offsets are in different ranges. But I don't really want to zero pad that as it makes it harder to see which register it is, and all the other options would add extra whitespace gaps into the string which doesn't seem like a good idea either. I guess most of our register offsets are in the five hex digit range anyway so this probably doesn't matter all that much.

---
 drivers/gpu/drm/i915/display/intel_display_trace.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/display/intel_display_trace.h +4 -3
index fe69d203549b..0cd1eed0bccf 100644
@@ -978,9 +978,10 @@ TRACE_EVENT(intel_reg_rw,
 		__entry->len = len;
 		),
 
-	TP_printk("%s reg=0x%x, len=%d, val=0x%x",
-		__entry->write ? "write" : "read",
-		__entry->reg, __entry->len, __entry->val)
+	TP_printk("%5s reg=0x%x, len=%d, val=0x%0*x",
+		  __entry->write ? "write" : "read",
+		  __entry->reg, __entry->len,
+		  __entry->len * 2, __entry->val)
 );
 
 #endif /* __INTEL_DISPLAY_TRACE_H__ */
Signature · 1 line
2.56.1
#3 lore raw

PATCH 3/7 drm/i915/de: Convert intel_de_read_fw() into a vfunc

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

When we eventually implement the display MMIO stuff using raw readl()/writel()/etc we'll need to implement the LNL read vs. write reordering workaround in intel_de_read_fw(). To avoid runtime platform checks convert intel_de_read_fw() into a vfunc. For now everyone implements this the same way, and the LNL w/a is still handled in the underlying xe_mmio code.

---
 drivers/gpu/drm/i915/display/intel_de.c | 16 +++++++++++-----
 drivers/gpu/drm/i915/display/intel_de.h |  6 +++++-
 2 files changed, 16 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/display/intel_de.c +11 -5
index fe77e8769c9b..658380cb8973 100644
@@ -201,11 +201,6 @@ __intel_de_write_fw(struct intel_display *display, intel_reg_t reg, u32 val)
 	intel_uncore_write_fw(__to_uncore(display), reg, val);
 }
 
-u32 intel_de_read_fw(struct intel_display *display, intel_reg_t reg)
-{
-	return __intel_de_read_fw(display, reg);
-}
-
 void intel_de_write_fw(struct intel_display *display, intel_reg_t reg, u32 val)
 {
 	__intel_de_write_fw(display, reg, val);
@@ -429,6 +424,11 @@ __intel_de_write(struct intel_display *display, intel_reg_t reg, u32 val,
 
 #define I9XX_MMIO_FLAGS 0
 
+static u32 i9xx_mmio_read_fw(struct intel_display *display, intel_reg_t reg)
+{
+	return __intel_de_read_fw(display, reg);
+}
+
 static u32 i9xx_mmio_read(struct intel_display *display, intel_reg_t reg)
 {
 	return __intel_de_read(display, reg, I9XX_MMIO_FLAGS);
@@ -442,6 +442,7 @@ static void i9xx_mmio_write(struct intel_display *display, intel_reg_t reg, u32
 #undef I9XX_MMIO_FLAGS
 
 static const struct intel_mmio_funcs i9xx_mmio_funcs = {
+	.read_fw = i9xx_mmio_read_fw,
 	.read = i9xx_mmio_read,
 	.write = i9xx_mmio_write,
 };
@@ -461,6 +462,7 @@ static void snb_mmio_write(struct intel_display *display, intel_reg_t reg, u32 v
 #undef SNB_MMIO_FLAGS
 
 static const struct intel_mmio_funcs snb_mmio_funcs = {
+	.read_fw = i9xx_mmio_read_fw,
 	.read = snb_mmio_read,
 	.write = snb_mmio_write,
 };
@@ -480,6 +482,7 @@ static void hsw_mmio_write(struct intel_display *display, intel_reg_t reg, u32 v
 #undef HSW_MMIO_FLAGS
 
 static const struct intel_mmio_funcs hsw_mmio_funcs = {
+	.read_fw = i9xx_mmio_read_fw,
 	.read = hsw_mmio_read,
 	.write = hsw_mmio_write,
 	.check_for_unclaimed_mmio = hsw_check_for_unclaimed_mmio,
@@ -487,6 +490,7 @@ static const struct intel_mmio_funcs hsw_mmio_funcs = {
 };
 
 static const struct intel_mmio_funcs vlv_mmio_funcs = {
+	.read_fw = i9xx_mmio_read_fw,
 	.read = hsw_mmio_read,
 	.write = hsw_mmio_write,
 	.check_for_unclaimed_mmio = vlv_check_for_unclaimed_mmio,
@@ -508,6 +512,7 @@ static void tgl_mmio_write(struct intel_display *display, intel_reg_t reg, u32 v
 #undef TGL_MMIO_FLAGS
 
 static const struct intel_mmio_funcs tgl_mmio_funcs = {
+	.read_fw = i9xx_mmio_read_fw,
 	.read = tgl_mmio_read,
 	.write = tgl_mmio_write,
 	.check_for_unclaimed_mmio = hsw_check_for_unclaimed_mmio,
@@ -528,6 +533,7 @@ static void lnl_mmio_write(struct intel_display *display, intel_reg_t reg, u32 v
 #undef LNL_MMIO_FLAGS
 
 static const struct intel_mmio_funcs lnl_mmio_funcs = {
+	.read_fw = i9xx_mmio_read_fw,
 	.read = lnl_mmio_read,
 	.write = lnl_mmio_write,
 };
drivers/gpu/drm/i915/display/intel_de.h +5 -1
index c21fff7be748..10b66de460be 100644
@@ -10,6 +10,7 @@
 #include "intel_dsb.h"
 
 struct intel_mmio_funcs {
+	u32 (*read_fw)(struct intel_display *display, intel_reg_t reg);
 	u32 (*read)(struct intel_display *display, intel_reg_t reg);
 	void (*write)(struct intel_display *display, intel_reg_t reg, u32 val);
 	bool (*check_for_unclaimed_mmio)(struct intel_display *display);
@@ -102,7 +103,10 @@ int intel_de_wait_for_clear_ms(struct intel_display *display, intel_reg_t reg,
  *
  * These will also skip the mmio_debug unclaimed register detection.
  */
-u32 intel_de_read_fw(struct intel_display *display, intel_reg_t reg);
+static inline u32 intel_de_read_fw(struct intel_display *display, intel_reg_t reg)
+{
+	return display->mmio.funcs->read_fw(display, reg);
+}
 void intel_de_write_fw(struct intel_display *display, intel_reg_t reg, u32 val);
 
 static inline u32
Signature · 1 line
2.56.1
#4 lore raw

PATCH 4/7 drm/i915/de: Use raw readl()/writel()/etc for register access in display

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

Eliminate the remaining intel_uncore_{read,write}*() usage from the display code by implementing the MMIO accessors directly with readl()/writel()/etc. The one remaining i915 vs. xe uncore ifdef will be dealt with shortly.

This also eliminates the extra function call step on xe (due to xe_mmio_read32() being a real function). And all the runtime checks inside xe_mmio_read32() we don't need are gone as well of course. So perhaps this is marginally faster as well.

On i915 we now skip the pointless runtime gsi_offset handling. Otherwise the i915 _fw() stuff was already a thin wrapper around readl()/writel()/etc.

The one slightly annoying thing is that we have to implement the LNL posted write flush workaround 15015404425 as well. Otherwise we could risk non-posted reads jumping ahead of posted writes already in the queue.

The LNL issue doesn't seem to be super easy to hit, but I did confirm that it's real by writing and reading the same register in a tight loop and verifying the read gets back the same value that was written. IIRC it took about 15 minutes to get the first failure. I also double checked MTL and PTL using the same test, just to be sure it really is limited to LNL, and looks like that is indeed the case.

---
 drivers/gpu/drm/i915/display/intel_de.c       | 89 ++++++++++++++++---
 .../gpu/drm/i915/display/intel_display_core.h |  3 +-
 2 files changed, 76 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/display/intel_de.c +75 -14
index 658380cb8973..f02df9be3807 100644
@@ -13,11 +13,6 @@
 #include "intel_display_trace.h"
 #include "intel_uncore.h"
 
-static inline struct intel_uncore *__to_uncore(struct intel_display *display)
-{
-	return display->mmio.uncore;
-}
-
 static int intel_de_wait_for_register(struct intel_display *display,
 				      intel_reg_t reg, u32 mask, u32 value,
 				      unsigned int timeout_us,
@@ -149,6 +144,12 @@ int intel_de_wait_for_clear_ms(struct intel_display *display, intel_reg_t reg,
 	return intel_de_wait_ms(display, reg, mask, 0, timeout_ms, NULL);
 }
 
+static __always_inline void __iomem *
+__intel_de_mmio_for_reg(struct intel_display *display, intel_reg_t reg)
+{
+	return display->mmio.regs + intel_reg_offset(reg);
+}
+
 u8 intel_de_read8(struct intel_display *display, intel_reg_t reg)
 {
 	u8 val;
@@ -156,7 +157,7 @@ u8 intel_de_read8(struct intel_display *display, intel_reg_t reg)
 	/* this is only used on VGA registers (possible on pre-g4x) */
 	drm_WARN_ON(display->drm, DISPLAY_VER(display) >= 5 || display->platform.g4x);
 
-	val = intel_uncore_read8(__to_uncore(display), reg);
+	val = readb(__intel_de_mmio_for_reg(display, reg));
 	trace_intel_reg_rw(false, reg, val, sizeof(val));
 
 	return val;
@@ -167,7 +168,7 @@ void intel_de_write8(struct intel_display *display, intel_reg_t reg, u8 val)
 	drm_WARN_ON(display->drm, DISPLAY_VER(display) >= 5 || display->platform.g4x);
 
 	trace_intel_reg_rw(true, reg, val, sizeof(val));
-	intel_uncore_write8(__to_uncore(display), reg, val);
+	writeb(val, __intel_de_mmio_for_reg(display, reg));
 }
 
 u16 intel_de_read16(struct intel_display *display, intel_reg_t reg)
@@ -177,7 +178,7 @@ u16 intel_de_read16(struct intel_display *display, intel_reg_t reg)
 	/* this is only used on MCHBAR registers on pre-SNB */
 	drm_WARN_ON(display->drm, DISPLAY_VER(display) >= 6);
 
-	val = intel_uncore_read16(__to_uncore(display), reg);
+	val = readw(__intel_de_mmio_for_reg(display, reg));
 	trace_intel_reg_rw(false, reg, val, sizeof(val));
 
 	return val;
@@ -188,7 +189,7 @@ __intel_de_read_fw(struct intel_display *display, intel_reg_t reg)
 {
 	u32 val;
 
-	val = intel_uncore_read_fw(__to_uncore(display), reg);
+	val = readl(__intel_de_mmio_for_reg(display, reg));
 	trace_intel_reg_rw(false, reg, val, sizeof(val));
 
 	return val;
@@ -198,7 +199,7 @@ static __always_inline void
 __intel_de_write_fw(struct intel_display *display, intel_reg_t reg, u32 val)
 {
 	trace_intel_reg_rw(true, reg, val, sizeof(val));
-	intel_uncore_write_fw(__to_uncore(display), reg, val);
+	writel(val, __intel_de_mmio_for_reg(display, reg));
 }
 
 void intel_de_write_fw(struct intel_display *display, intel_reg_t reg, u32 val)
@@ -316,6 +317,7 @@ bool intel_de_arm_unclaimed_mmio_detection(struct intel_display *display)
 #define __MMIO_WAKELOCK		BIT(0)
 #define __MMIO_LOCK		BIT(1)
 #define __MMIO_UNCLAIMED	BIT(2)
+#define __MMIO_READ_AFTER_WRITE_WA	BIT(3)
 
 static __always_inline void
 __mmio_wakelock_pre(struct intel_display *display, intel_reg_t reg,
@@ -375,6 +377,30 @@ __mmio_unclaimed_post(struct intel_display *display, intel_reg_t reg,
 		check_unclaimed_mmio_post(display, reg, write);
 }
 
+static __always_inline void
+__mmio_read_after_write_wa(struct intel_display *display,
+			   const unsigned int mmio_flags)
+{
+#define DUMMY_REG _MMIO(0x130030)
+	if (mmio_flags & __MMIO_READ_AFTER_WRITE_WA) {
+		void __iomem *dummy = __intel_de_mmio_for_reg(display, DUMMY_REG);
+
+		/*
+		 * w/a 15015404425
+		 *
+		 * Non-posted reads may incorrectly overtake posted
+		 * writes in the queue. Flush the real writes out
+		 * from the queue with four dummy writes so that
+		 * the read cannot overtake any real writes.
+		 */
+		writel(0, dummy);
+		writel(0, dummy);
+		writel(0, dummy);
+		writel(0, dummy);
+	}
+#undef DUMMY_REG
+}
+
 static __always_inline u32
 __intel_de_read(struct intel_display *display, intel_reg_t reg,
 		const unsigned int mmio_flags)
@@ -390,6 +416,8 @@ __intel_de_read(struct intel_display *display, intel_reg_t reg,
 	__mmio_unclaimed_pre(display, reg, false,
 			     mmio_debug_is_enabled, mmio_flags);
 
+	__mmio_read_after_write_wa(display, mmio_flags);
+
 	val = __intel_de_read_fw(display, reg);
 
 	__mmio_unclaimed_post(display, reg, false,
@@ -518,7 +546,14 @@ static const struct intel_mmio_funcs tgl_mmio_funcs = {
 	.check_for_unclaimed_mmio = hsw_check_for_unclaimed_mmio,
 };
 
-#define LNL_MMIO_FLAGS __MMIO_WAKELOCK
+#define LNL_MMIO_FLAGS (__MMIO_WAKELOCK | __MMIO_READ_AFTER_WRITE_WA)
+
+static u32 lnl_mmio_read_fw(struct intel_display *display, intel_reg_t reg)
+{
+	__mmio_read_after_write_wa(display, LNL_MMIO_FLAGS);
+
+	return __intel_de_read_fw(display, reg);
+}
 
 static u32 lnl_mmio_read(struct intel_display *display, intel_reg_t reg)
 {
@@ -533,11 +568,31 @@ static void lnl_mmio_write(struct intel_display *display, intel_reg_t reg, u32 v
 #undef LNL_MMIO_FLAGS
 
 static const struct intel_mmio_funcs lnl_mmio_funcs = {
-	.read_fw = i9xx_mmio_read_fw,
+	.read_fw = lnl_mmio_read_fw,
 	.read = lnl_mmio_read,
 	.write = lnl_mmio_write,
 };
 
+#define PTL_MMIO_FLAGS __MMIO_WAKELOCK
+
+static u32 ptl_mmio_read(struct intel_display *display, intel_reg_t reg)
+{
+	return __intel_de_read(display, reg, PTL_MMIO_FLAGS);
+}
+
+static void ptl_mmio_write(struct intel_display *display, intel_reg_t reg, u32 val)
+{
+	__intel_de_write(display, reg, val, PTL_MMIO_FLAGS);
+}
+
+#undef PTL_MMIO_FLAGS
+
+static const struct intel_mmio_funcs ptl_mmio_funcs = {
+	.read_fw = i9xx_mmio_read_fw,
+	.read = ptl_mmio_read,
+	.write = ptl_mmio_write,
+};
+
 static bool driver_is_i915(void)
 {
 #ifdef I915
@@ -549,7 +604,11 @@ static bool driver_is_i915(void)
 
 void intel_de_init(struct intel_display *display)
 {
-	display->mmio.uncore = to_intel_uncore(display->drm);
+#ifdef I915
+	display->mmio.regs = to_intel_uncore(display->drm)->regs;
+#else
+	display->mmio.regs = __compat_uncore_to_mmio(to_intel_uncore(display->drm))->regs;
+#endif
 
 	spin_lock_init(&display->mmio.lock);
 
@@ -571,7 +630,9 @@ void intel_de_init(struct intel_display *display)
 		else
 			display->mmio.funcs = &i9xx_mmio_funcs;
 	} else {
-		if (DISPLAY_VER(display) >= 20)
+		if (DISPLAY_VER(display) >= 30)
+			display->mmio.funcs = &ptl_mmio_funcs;
+		else if (DISPLAY_VER(display) >= 20)
 			display->mmio.funcs = &lnl_mmio_funcs;
 		else
 			display->mmio.funcs = &i9xx_mmio_funcs;
drivers/gpu/drm/i915/display/intel_display_core.h +1 -2
index b422d24e21b2..99fda50b0d1f 100644
@@ -52,7 +52,6 @@ struct intel_initial_plane_config;
 struct intel_mmio_funcs;
 struct intel_opregion;
 struct intel_overlay;
-struct intel_uncore;
 struct task_struct;
 
 /* Amount of SAGV/QGV points, BSpec precisely defines this */
@@ -542,7 +541,7 @@ struct intel_display {
 		 */
 		spinlock_t lock;
 
-		struct intel_uncore *uncore;
+		void __iomem *regs;
 		const struct intel_mmio_funcs *funcs;
 
 		/*
Signature · 1 line
2.56.1
#5 lore raw

PATCH 5/7 drm/i915/de: Add intel_parent_mmio_regs() interface

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

Eliminate the last uncore usage (to get the pointer to the memory mapped registers) in intel_de.c with a new intel_parent_mmio_regs() interface.

---
 drivers/gpu/drm/i915/display/intel_de.c      | 8 ++------
 drivers/gpu/drm/i915/display/intel_parent.c  | 5 +++++
 drivers/gpu/drm/i915/display/intel_parent.h  | 1 +
 drivers/gpu/drm/i915/i915_driver.c           | 6 ++++++
 drivers/gpu/drm/xe/display/xe_display.c      | 8 ++++++++
 include/drm/intel/display_parent_interface.h | 3 +++
 6 files changed, 25 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/display/intel_de.c +2 -6
index f02df9be3807..6d34a03d243a 100644
@@ -11,7 +11,7 @@
 #include "intel_display_regs.h"
 #include "intel_display_rpm.h"
 #include "intel_display_trace.h"
-#include "intel_uncore.h"
+#include "intel_parent.h"
 
 static int intel_de_wait_for_register(struct intel_display *display,
 				      intel_reg_t reg, u32 mask, u32 value,
@@ -604,11 +604,7 @@ static bool driver_is_i915(void)
 
 void intel_de_init(struct intel_display *display)
 {
-#ifdef I915
-	display->mmio.regs = to_intel_uncore(display->drm)->regs;
-#else
-	display->mmio.regs = __compat_uncore_to_mmio(to_intel_uncore(display->drm))->regs;
-#endif
+	display->mmio.regs = intel_parent_mmio_regs(display);
 
 	spin_lock_init(&display->mmio.lock);
 
drivers/gpu/drm/i915/display/intel_parent.c +5 -0
index ed3e21b0a927..24daf61542a1 100644
@@ -451,6 +451,11 @@ bool intel_parent_has_fenced_regions(struct intel_display *display)
 	return display->parent->has_fenced_regions && display->parent->has_fenced_regions(display->drm);
 }
 
+void __iomem *intel_parent_mmio_regs(struct intel_display *display)
+{
+	return display->parent->mmio_regs(display->drm);
+}
+
 void intel_parent_transient_data_flush(struct intel_display *display)
 {
 	if (display->parent->transient_data_flush)
drivers/gpu/drm/i915/display/intel_parent.h +1 -0
index 923cb6464a98..28c1196a260f 100644
@@ -155,6 +155,7 @@ int intel_parent_vlv_iosf_write(struct intel_display *display, enum vlv_iosf_sb_
 /* generic */
 bool intel_parent_has_auxccs(struct intel_display *display);
 bool intel_parent_has_fenced_regions(struct intel_display *display);
+void __iomem *intel_parent_mmio_regs(struct intel_display *display);
 void intel_parent_transient_data_flush(struct intel_display *display);
 bool intel_parent_vgpu_active(struct intel_display *display);
 void intel_parent_fence_priority_display(struct intel_display *display, struct dma_fence *fence);
drivers/gpu/drm/i915/i915_driver.c +6 -0
index 923b239714b7..017871b9aaa2 100644
@@ -737,6 +737,11 @@ static bool has_fenced_regions(struct drm_device *drm)
 	return intel_gt_support_legacy_fencing(to_gt(to_i915(drm)));
 }
 
+static void __iomem *mmio_regs(struct drm_device *drm)
+{
+	return to_intel_uncore(drm)->regs;
+}
+
 static bool vgpu_active(struct drm_device *drm)
 {
 	return intel_vgpu_active(to_i915(drm));
@@ -763,6 +768,7 @@ static const struct intel_display_parent_interface parent = {
 	.fence_priority_display = fence_priority_display,
 	.has_auxccs = has_auxccs,
 	.has_fenced_regions = has_fenced_regions,
+	.mmio_regs = mmio_regs,
 	.vgpu_active = vgpu_active,
 };
 
drivers/gpu/drm/xe/display/xe_display.c +8 -0
index 0236f69a0f88..5ace8295b498 100644
@@ -447,6 +447,13 @@ static bool has_auxccs(struct drm_device *drm)
 	return xe->info.platform == XE_ALDERLAKE_P;
 }
 
+static void __iomem *mmio_regs(struct drm_device *drm)
+{
+	struct xe_device *xe = to_xe_device(drm);
+
+	return xe->mmio.regs;
+}
+
 /*
  * TDF (Transient-Data-Flush) is needed for Xe2+ where special L3:XD caching can
  * be enabled through various PAT index modes. Idea is to use this caching mode
@@ -475,6 +482,7 @@ static const struct intel_display_parent_interface parent = {
 	.stolen = &xe_display_stolen_interface,
 	.wa = &xe_display_wa_interface,
 	.has_auxccs = has_auxccs,
+	.mmio_regs = mmio_regs,
 	.transient_data_flush = transient_data_flush,
 };
 
include/drm/intel/display_parent_interface.h +3 -0
index fd799980c941..8dbce1790821 100644
@@ -314,6 +314,9 @@ struct intel_display_parent_interface {
 		/** @has_fenced_regions: Support legacy fencing? Optional. */
 		bool (*has_fenced_regions)(struct drm_device *drm);
 
+		/** @mmio_regs: Return the pointer to the memory mapped registers. */
+		void __iomem *(*mmio_regs)(struct drm_device *drm);
+
 		/** @transient_data_flush: Transient data flush. Optional. */
 		void (*transient_data_flush)(struct drm_device *drm);
 
Signature · 1 line
2.56.1
#6 lore raw

PATCH 6/7 drm/xe: Nuke the compat uncore stuff

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

The display code no longer uses any uncore stuff, so nuke the compatibility layer from xe.

---
 .../drm/xe/compat-i915-headers/intel_uncore.h | 66 -------------------
 drivers/gpu/drm/xe/display/xe_display.c       |  3 -
 drivers/gpu/drm/xe/xe_device_types.h          | 13 ----
 3 files changed, 82 deletions(-)
 delete mode 100644 drivers/gpu/drm/xe/compat-i915-headers/intel_uncore.h
drivers/gpu/drm/xe/compat-i915-headers/intel_uncore.h deleted +0 -66
deleted file mode 100644
index 707f7ad0378d..000000000000
@@ -1,66 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-/*
- * Copyright © 2023 Intel Corporation
- */
-
-#ifndef __INTEL_UNCORE_H__
-#define __INTEL_UNCORE_H__
-
-#include "i915_reg_defs.h"
-#include "xe_device.h"
-#include "xe_device_types.h"
-#include "xe_mmio.h"
-
-static inline struct intel_uncore *to_intel_uncore(struct drm_device *drm)
-{
-	return &to_xe_device(drm)->uncore;
-}
-
-static inline struct xe_mmio *__compat_uncore_to_mmio(struct intel_uncore *uncore)
-{
-	struct xe_device *xe = container_of(uncore, struct xe_device, uncore);
-
-	return xe_root_tile_mmio(xe);
-}
-
-static inline u8 intel_uncore_read8(struct intel_uncore *uncore,
-				    i915_reg_t i915_reg)
-{
-	struct xe_reg reg = XE_REG(i915_mmio_reg_offset(i915_reg));
-
-	return xe_mmio_read8(__compat_uncore_to_mmio(uncore), reg);
-}
-
-static inline void intel_uncore_write8(struct intel_uncore *uncore,
-				       i915_reg_t i915_reg, u8 val)
-{
-	struct xe_reg reg = XE_REG(i915_mmio_reg_offset(i915_reg));
-
-	xe_mmio_write8(__compat_uncore_to_mmio(uncore), reg, val);
-}
-
-static inline u16 intel_uncore_read16(struct intel_uncore *uncore,
-				      i915_reg_t i915_reg)
-{
-	struct xe_reg reg = XE_REG(i915_mmio_reg_offset(i915_reg));
-
-	return xe_mmio_read16(__compat_uncore_to_mmio(uncore), reg);
-}
-
-static inline u32 intel_uncore_read_fw(struct intel_uncore *uncore,
-				       i915_reg_t i915_reg)
-{
-	struct xe_reg reg = XE_REG(i915_mmio_reg_offset(i915_reg));
-
-	return xe_mmio_read32(__compat_uncore_to_mmio(uncore), reg);
-}
-
-static inline void intel_uncore_write_fw(struct intel_uncore *uncore,
-					 i915_reg_t i915_reg, u32 val)
-{
-	struct xe_reg reg = XE_REG(i915_mmio_reg_offset(i915_reg));
-
-	xe_mmio_write32(__compat_uncore_to_mmio(uncore), reg, val);
-}
-
-#endif /* __INTEL_UNCORE_H__ */
drivers/gpu/drm/xe/display/xe_display.c +0 -3
index 5ace8295b498..6a179d0683e5 100644
@@ -85,9 +85,6 @@ int xe_display_init_early(struct xe_device *xe)
 	if (!xe->info.probe_display)
 		return 0;
 
-	/* Fake uncore lock */
-	spin_lock_init(&xe->uncore.lock);
-
 	intel_display_driver_early_probe(display);
 
 	intel_display_device_info_runtime_init(display);
drivers/gpu/drm/xe/xe_device_types.h +0 -13
index 9e0d7d3d07d5..abc70c949b2c 100644
@@ -649,19 +649,6 @@ struct xe_device {
 #endif
 
 	/* private: */
-
-#if IS_ENABLED(CONFIG_DRM_XE_DISPLAY)
-	/*
-	 * Any fields below this point are the ones used by display.
-	 * They are temporarily added here so xe_device can be desguised as
-	 * drm_i915_private during build. After cleanup these should go away,
-	 * migrating to the right sub-structs
-	 */
-
-	struct intel_uncore {
-		spinlock_t lock;
-	} uncore;
-#endif
 };
 
 /**
Signature · 1 line
2.56.1
#7 lore raw

PATCH 7/7 drm/i915/de: Document intel_de_write8()'s usage restrictions

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

intel_de_read8() has a comment explaining the WARN and why the function doesn't need to do anything exotic beyond the raw readb(). Add a similar comment to intel_de_write8().

---
 drivers/gpu/drm/i915/display/intel_de.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/display/intel_de.c +1 -0
index 6d34a03d243a..fb86abe0301d 100644
@@ -165,6 +165,7 @@ u8 intel_de_read8(struct intel_display *display, intel_reg_t reg)
 
 void intel_de_write8(struct intel_display *display, intel_reg_t reg, u8 val)
 {
+	/* this is only used on VGA registers (possible on pre-g4x) */
 	drm_WARN_ON(display->drm, DISPLAY_VER(display) >= 5 || display->platform.g4x);
 
 	trace_intel_reg_rw(true, reg, val, sizeof(val));
Signature · 1 line
2.56.1
#8 lore raw

✓ i915.CI.BAT: success for drm/i915/de: Nuke uncore

In reply to Ville Syrjala
== Series Details ==

== Series Details ==

Series: drm/i915/de: Nuke uncore
URL : https://patchwork.freedesktop.org/series/179801/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_19618 -> Patchwork_179801v1
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_179801v1/index.html

Participating hosts (40 -> 39)
------------------------------

Missing (1): bat-dg2-13

Known issues
------------

Here are the changes found in Patchwork_179801v1 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@vgem_basic@unload:
- bat-rpls-4: [PASS][1] -> [DMESG-WARN][2] ([i915#13400])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_19618/bat-rpls-4/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_179801v1/bat-rpls-4/igt@[email protected]

[i915#13400]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/13400

Build changes
-------------

* Linux: CI_DRM_19618 -> Patchwork_179801v1

CI-20190529: 20190529
CI_DRM_19618: 436eec0ef1b65f139fa2f3c42aea97c29da57c8c @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_9204: 52e9317c945f97f29fbec75be29280fc7b00cf32 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_179801v1: 436eec0ef1b65f139fa2f3c42aea97c29da57c8c @ git://anongit.freedesktop.org/gfx-ci/linux

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_179801v1/index.html