Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Auld <matthew.auld@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>,
	intel-xe@lists.freedesktop.org
Subject: Re: [PATCH] drm/xe/mmio: Assert MMIO is available
Date: Thu, 28 May 2026 10:13:31 +0100	[thread overview]
Message-ID: <754ed1a5-ed12-4e0e-bafc-5775106d8e14@intel.com> (raw)
In-Reply-To: <20260527175437.22585-1-michal.wajdeczko@intel.com>

On 27/05/2026 18:54, Michal Wajdeczko wrote:
> We shouldn't access device registers after the device was unplugged.
> Instead of relying on the NPD splat due to zeroed xe.mmio.regs, which
> might be unreliable anyway as not all xe_mmio are using that directly,
> add an explicit assert during xe_mmio read/write operations to catch
> invalid accesses to MMIO after device was unplugged.
> 
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> ---
> Cc: Matthew Auld <matthew.auld@intel.com>
> ---
>   drivers/gpu/drm/xe/xe_mmio.c | 11 +++++++++++
>   1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/gpu/drm/xe/xe_mmio.c b/drivers/gpu/drm/xe/xe_mmio.c
> index 78adb303b663..b77a717f0556 100644
> --- a/drivers/gpu/drm/xe/xe_mmio.c
> +++ b/drivers/gpu/drm/xe/xe_mmio.c
> @@ -10,6 +10,7 @@
>   #include <linux/minmax.h>
>   #include <linux/pci.h>
>   
> +#include <drm/drm_drv.h>
>   #include <drm/drm_managed.h>
>   #include <drm/drm_print.h>
>   
> @@ -128,6 +129,11 @@ void xe_mmio_init(struct xe_mmio *mmio, struct xe_tile *tile, void __iomem *ptr,
>   	mmio->tile = tile;
>   }
>   
> +static void mmio_assert_available(struct xe_mmio *mmio)
> +{
> +	xe_tile_assert(mmio->tile, !drm_dev_is_unplugged(&mmio->tile->xe->drm));

Yeah, I was hopeful this would work, but as per CI the unplug=true needs 
to happen before the devm actions run, so we get a pile of false 
positives with this. I think the best we can do is NULL, or perhaps 
mmio.unplugged and check that here?

> +}
> +
>   static void mmio_flush_pending_writes(struct xe_mmio *mmio)
>   {
>   #define DUMMY_REG_OFFSET	0x130030
> @@ -146,6 +152,7 @@ u8 xe_mmio_read8(struct xe_mmio *mmio, struct xe_reg reg)
>   	u32 addr = xe_mmio_adjusted_addr(mmio, reg.addr);
>   	u8 val;
>   
> +	mmio_assert_available(mmio);
>   	mmio_flush_pending_writes(mmio);
>   
>   	val = readb(mmio->regs + addr);
> @@ -158,6 +165,7 @@ void xe_mmio_write8(struct xe_mmio *mmio, struct xe_reg reg, u8 val)
>   {
>   	u32 addr = xe_mmio_adjusted_addr(mmio, reg.addr);
>   
> +	mmio_assert_available(mmio);
>   	trace_xe_reg_rw(mmio, true, addr, val, sizeof(val));
>   
>   	writeb(val, mmio->regs + addr);
> @@ -168,6 +176,7 @@ u16 xe_mmio_read16(struct xe_mmio *mmio, struct xe_reg reg)
>   	u32 addr = xe_mmio_adjusted_addr(mmio, reg.addr);
>   	u16 val;
>   
> +	mmio_assert_available(mmio);
>   	mmio_flush_pending_writes(mmio);
>   
>   	val = readw(mmio->regs + addr);
> @@ -180,6 +189,7 @@ void xe_mmio_write32(struct xe_mmio *mmio, struct xe_reg reg, u32 val)
>   {
>   	u32 addr = xe_mmio_adjusted_addr(mmio, reg.addr);
>   
> +	mmio_assert_available(mmio);
>   	trace_xe_reg_rw(mmio, true, addr, val, sizeof(val));
>   
>   	if (!reg.vf && IS_SRIOV_VF(mmio->tile->xe))
> @@ -194,6 +204,7 @@ u32 xe_mmio_read32(struct xe_mmio *mmio, struct xe_reg reg)
>   	u32 addr = xe_mmio_adjusted_addr(mmio, reg.addr);
>   	u32 val;
>   
> +	mmio_assert_available(mmio);
>   	mmio_flush_pending_writes(mmio);
>   
>   	if (!reg.vf && IS_SRIOV_VF(mmio->tile->xe))


  parent reply	other threads:[~2026-05-28  9:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-27 17:54 [PATCH] drm/xe/mmio: Assert MMIO is available Michal Wajdeczko
2026-05-27 19:39 ` ✓ CI.KUnit: success for " Patchwork
2026-05-27 20:31 ` ✗ Xe.CI.BAT: failure " Patchwork
2026-05-28  4:40 ` ✗ Xe.CI.FULL: " Patchwork
2026-05-28  9:13 ` Matthew Auld [this message]
2026-05-28 16:16   ` [PATCH] " Michal Wajdeczko
2026-05-28 16:47     ` Matthew Auld
2026-05-28 17:34       ` Michal Wajdeczko
2026-05-28 18:06         ` Raag Jadav
2026-05-29  6:58         ` Matthew Auld
2026-05-28 17:43     ` Raag Jadav

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=754ed1a5-ed12-4e0e-bafc-5775106d8e14@intel.com \
    --to=matthew.auld@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=michal.wajdeczko@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