From: Jani Nikula <jani.nikula@linux.intel.com>
To: Ville Syrjala <ville.syrjala@linux.intel.com>,
intel-gfx@lists.freedesktop.org
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 4/7] drm/i915/de: Use raw readl()/writel()/etc for register access in display
Date: Fri, 27 Nov 2026 16:54:45 +0200 [thread overview]
Message-ID: <97447e88b68267506474159bf895a591dd2c28ca@intel.com> (raw)
In-Reply-To: <20261126212728.9034-5-ville.syrjala@linux.intel.com>
On Thu, 26 Nov 2026, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> 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.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> 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(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_de.c b/drivers/gpu/drm/i915/display/intel_de.c
> index 658380cb8973..f02df9be3807 100644
> --- a/drivers/gpu/drm/i915/display/intel_de.c
> +++ b/drivers/gpu/drm/i915/display/intel_de.c
> @@ -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);
> +
Nitpick, feels like this should be named
__mmio_something_something_pre() like the others. But meh.
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> 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;
> diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h b/drivers/gpu/drm/i915/display/intel_display_core.h
> index b422d24e21b2..99fda50b0d1f 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_core.h
> +++ b/drivers/gpu/drm/i915/display/intel_display_core.h
> @@ -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;
>
> /*
--
Jani Nikula, Intel
next prev parent reply other threads:[~2026-11-27 14:55 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 21:27 [PATCH 0/7] drm/i915/de: Nuke uncore Ville Syrjala
2026-11-26 21:27 ` [PATCH 1/7] drm/i915/de: Move the register tracepoint to display Ville Syrjala
2026-11-27 14:32 ` Jani Nikula
2026-11-26 21:27 ` [PATCH 2/7] drm/i915/de: Pimp the intel_reg_rw tracepoint printf format Ville Syrjala
2026-11-27 14:36 ` Jani Nikula
2026-11-26 21:27 ` [PATCH 3/7] drm/i915/de: Convert intel_de_read_fw() into a vfunc Ville Syrjala
2026-11-27 14:38 ` Jani Nikula
2026-11-26 21:27 ` [PATCH 4/7] drm/i915/de: Use raw readl()/writel()/etc for register access in display Ville Syrjala
2026-11-27 14:54 ` Jani Nikula [this message]
2026-11-26 21:27 ` [PATCH 5/7] drm/i915/de: Add intel_parent_mmio_regs() interface Ville Syrjala
2026-11-27 14:56 ` Jani Nikula
2026-11-26 21:27 ` [PATCH 6/7] drm/xe: Nuke the compat uncore stuff Ville Syrjala
2026-11-27 15:14 ` Jani Nikula
2026-11-27 15:34 ` Ville Syrjälä
2026-11-26 21:27 ` [PATCH 7/7] drm/i915/de: Document intel_de_write8()'s usage restrictions Ville Syrjala
2026-11-27 15:15 ` Jani Nikula
2026-11-26 22:27 ` ✓ i915.CI.BAT: success for drm/i915/de: Nuke uncore Patchwork
2026-11-26 23:43 ` ✗ CI.checkpatch: warning " Patchwork
2026-11-26 23:46 ` ✓ CI.KUnit: success " Patchwork
2026-11-27 0:24 ` ✓ Xe.CI.BAT: " Patchwork
2026-11-27 12:20 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-11-28 3:25 ` ✓ i915.CI.Full: success " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=97447e88b68267506474159bf895a591dd2c28ca@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=ville.syrjala@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.