Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Shuicheng Lin <shuicheng.lin@intel.com>, intel-xe@lists.freedesktop.org
Cc: Shuicheng Lin <shuicheng.lin@intel.com>,
	Matt Roper <matthew.d.roper@intel.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>
Subject: Re: [PATCH v2] drm/xe/mmio: Avoid double-adjust in 64-bit reads
Date: Fri, 30 Jan 2026 11:23:03 +0200	[thread overview]
Message-ID: <59e02e754431c3ec9aa63b6b283c8f648c4262f9@intel.com> (raw)
In-Reply-To: <20260130021816.442958-2-shuicheng.lin@intel.com>

On Fri, 30 Jan 2026, Shuicheng Lin <shuicheng.lin@intel.com> wrote:
> xe_mmio_read64_2x32() was adjusting register addresses and then
> calling xe_mmio_read32(), which applies the adjustment again.
> This may shift accesses twice if adj_offset < adj_limit. There is
> no issue currently, as for media gt, adj_offset > adj_limit, so
> the 2nd adjust will be a no-op. But it may not work in future.
>
> To fix it, replace the adjusted-address comparison with a direct
> sanity check that ensures the MMIO address adjustment cutoff never
> falls within the 8-byte range of a 64-bit register. And let
> xe_mmio_read32() handle address translation.
>
> v2: rewrite the sanity check in a more natural way. (Matt)
>
> Cc: Matt Roper <matthew.d.roper@intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>

Fixes: ?

> ---
>  drivers/gpu/drm/xe/xe_mmio.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_mmio.c b/drivers/gpu/drm/xe/xe_mmio.c
> index bcb6674b7dac..a1a05c68dc7d 100644
> --- a/drivers/gpu/drm/xe/xe_mmio.c
> +++ b/drivers/gpu/drm/xe/xe_mmio.c
> @@ -256,11 +256,11 @@ u64 xe_mmio_read64_2x32(struct xe_mmio *mmio, struct xe_reg reg)
>  	struct xe_reg reg_udw = { .addr = reg.addr + 0x4 };
>  	u32 ldw, udw, oldudw, retries;
>  
> -	reg.addr = xe_mmio_adjusted_addr(mmio, reg.addr);
> -	reg_udw.addr = xe_mmio_adjusted_addr(mmio, reg_udw.addr);
> -
> -	/* we shouldn't adjust just one register address */
> -	xe_tile_assert(mmio->tile, reg_udw.addr == reg.addr + 0x4);
> +	/*
> +	 * The two dwords of a 64-bit register can never straddle the offset
> +	 * adjustment cutoff.
> +	 */
> +	xe_tile_assert(mmio->tile, !in_range(mmio->adj_limit, reg.addr + 1, 7));
>  
>  	oldudw = xe_mmio_read32(mmio, reg_udw);
>  	for (retries = 5; retries; --retries) {

-- 
Jani Nikula, Intel

  parent reply	other threads:[~2026-01-30  9:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-30  2:18 [PATCH v2] drm/xe/mmio: Avoid double-adjust in 64-bit reads Shuicheng Lin
2026-01-30  2:29 ` ✓ CI.KUnit: success for drm/xe/mmio: Avoid double-adjust in 64-bit reads (rev2) Patchwork
2026-01-30  3:15 ` ✓ Xe.CI.BAT: " Patchwork
2026-01-30  9:23 ` Jani Nikula [this message]
2026-01-30 16:49 ` [PATCH v2] drm/xe/mmio: Avoid double-adjust in 64-bit reads Matt Roper

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=59e02e754431c3ec9aa63b6b283c8f648c4262f9@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.d.roper@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=shuicheng.lin@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox