intel-xe.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Matt Roper <matthew.d.roper@intel.com>
To: "Murthy, Arun R" <arun.r.murthy@intel.com>
Cc: "intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>,
	"Wajdeczko, Michal" <michal.wajdeczko@intel.com>
Subject: Re: [PATCHv2] drm/xe: Check for dead config space on reading all 1s
Date: Wed, 20 May 2026 11:07:13 -0700	[thread overview]
Message-ID: <20260520180713.GD3379914@mdroper-desk1.amr.corp.intel.com> (raw)
In-Reply-To: <IA0PR11MB7307AE528ACCF3DC54AA4072BA012@IA0PR11MB7307.namprd11.prod.outlook.com>

On Tue, May 19, 2026 at 09:42:36PM -0700, Murthy, Arun R wrote:
> 
> > -----Original Message-----
> > From: Roper, Matthew D <matthew.d.roper@intel.com>
> > Sent: Wednesday, May 20, 2026 1:56 AM
> > To: Murthy, Arun R <arun.r.murthy@intel.com>
> > Cc: intel-xe@lists.freedesktop.org; Wajdeczko, Michal
> > <michal.wajdeczko@intel.com>
> > Subject: Re: [PATCHv2] drm/xe: Check for dead config space on reading all 1s
> > 
> > On Tue, May 19, 2026 at 09:01:04AM +0530, Arun R Murthy wrote:
> > > After ioremap the BAR mapped address is read once as a sanity check
> > > and if found to be all 1s then return avoiding the driver
> > > initialization of a dead device.
> > >
> > > v2: Move the sanity check to mmio_probe_early() - Michal
> > >
> > > Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/work_items/7941
> > > Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
> > > ---
> > >  drivers/gpu/drm/xe/xe_mmio.c | 16 ++++++++++++++++
> > >  1 file changed, 16 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/xe/xe_mmio.c
> > > b/drivers/gpu/drm/xe/xe_mmio.c index 78adb303b663..d206e3720eed
> > 100644
> > > --- a/drivers/gpu/drm/xe/xe_mmio.c
> > > +++ b/drivers/gpu/drm/xe/xe_mmio.c
> > > @@ -90,6 +90,7 @@ int xe_mmio_probe_early(struct xe_device *xe)  {
> > >  	struct xe_tile *root_tile = xe_device_get_root_tile(xe);
> > >  	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
> > > +	u32 sanity = 0;
> > >
> > >  	/*
> > >  	 * Map the entire BAR.
> > > @@ -103,6 +104,21 @@ int xe_mmio_probe_early(struct xe_device *xe)
> > >  		return -EIO;
> > >  	}
> > >
> > > +	/*
> > > +	 * If the parent PCIe bridge failed to leave D3cold, or the device
> > > +	 * fell off the bus, MMIO reads return all-ones. Detect that here
> > > +	 * before any other subsystem (SR-IOV, GuC, pcode...) consumes a
> > > +	 * bogus 0xFFFFFFFF.
> > > +	 */
> > > +	sanity = readl(xe->mmio.regs);
> > > +	if (sanity == U32_MAX && !pci_device_is_present(pdev)) {
> > 
> > Was the && here intended or was that supposed to be an ||?  I think if the
> > device isn't "present" the read would _always_ be a failure and get terminated
> > with ~0?  For that matter, is this the right place to be checking this?  I guess
> > there can be surprise device removal at absolultely any time, but the most
> > common time this would come back as false would be if the device got removed
> > during a system suspend; the code you're adding here only runs on probe and
> > not on resume flows.  I think it would be pretty rare to see
> > pci_device_is_present() already return false here in the probe path if we just
> > got a successful return from pci_enable_device()?
> > 
> Sorry should have been ||
> The reason for having this check over here in early probe is to detect the dead config space and return early.
> This is the scenario that the user is observing in the issue https://gitlab.freedesktop.org/drm/xe/kernel/-/work_items/7941

In that bug, it looks like we already detected and reported the failure
to leave D3 ("xe 0000:03:00.0: Unable to change power state from D3cold
to D0, device inaccessible") so it seems like rather than re-checking
again here we should just have been handling that error and bailing out
before we even get to this point?


Matt


> 
> > I don't think any platform has a register at offset 0, so if the device is up
> > properly, the bogus read should come back as 0 (and we can recognize device
> > errors via ~0 reads), but it still might be best to read a known-extant register
> > offset just to guarantee there's no undocumented behavior.  Maybe GMD_ID
> > would be a good candidate since it should be non-zero (and non ~0) on all POR
> > platforms, zero (and tested as such) on the non-POR Xe1 platforms, and is a
> > register that we need to read early in device init anyway (so we could stash the
> > value and save ourselves the read later).
> 
> Reading the PCI_VENDOR_ID should also help in finding dead config space
> 
> Thanks and Regards,
> Arun R Murthy
> --------------------
> > 
> > 
> > Matt
> > 
> > > +		drm_err(&xe->drm,
> > > +			"MMIO reads all 1s and device not present; aborting
> > probe\n");
> > > +		pci_iounmap(pdev, xe->mmio.regs);
> > > +		xe->mmio.regs = NULL;
> > > +		return -ENODEV;
> > > +	}
> > > +
> > >  	/* Setup first tile; other tiles (if present) will be setup later. */
> > >  	xe_mmio_init(&root_tile->mmio, root_tile, xe->mmio.regs, SZ_4M);
> > >
> > > --
> > > 2.25.1
> > >
> > 
> > --
> > Matt Roper
> > Graphics Software Engineer
> > Linux GPU Platform Enablement
> > Intel Corporation

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation

  reply	other threads:[~2026-05-20 18:07 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12  6:01 [PATCH] drm/xe: Check for dead config space on reading all 1s Arun R Murthy
2026-05-12 11:12 ` ✓ CI.KUnit: success for " Patchwork
2026-05-12 11:55 ` [PATCH] " Michal Wajdeczko
2026-05-12 12:32 ` ✓ Xe.CI.BAT: success for " Patchwork
2026-05-12 22:28 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-05-19  3:31 ` [PATCHv2] " Arun R Murthy
2026-05-19 13:24   ` Raag Jadav
2026-05-20  3:52     ` Murthy, Arun R
2026-05-19 20:26   ` Matt Roper
2026-05-20  4:42     ` Murthy, Arun R
2026-05-20 18:07       ` Matt Roper [this message]
2026-05-21  4:05         ` Murthy, Arun R
2026-07-06  4:41   ` [PATCHv3] drm/xe: Check for dead config space Arun R Murthy
2026-05-19  3:39 ` ✓ CI.KUnit: success for drm/xe: Check for dead config space on reading all 1s (rev2) Patchwork
2026-05-19  4:21 ` ✓ Xe.CI.BAT: " Patchwork
2026-05-19 13:10 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-07-06  4:49 ` ✓ CI.KUnit: success for drm/xe: Check for dead config space on reading all 1s (rev3) Patchwork
2026-07-06  5:31 ` ✗ Xe.CI.BAT: failure " Patchwork
2026-07-06  7:19 ` ✓ Xe.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=20260520180713.GD3379914@mdroper-desk1.amr.corp.intel.com \
    --to=matthew.d.roper@intel.com \
    --cc=arun.r.murthy@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).