mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Piotr Piórkowski" <piotr.piorkowski@intel.com>
To: "Summers, Stuart" <stuart.summers@intel.com>
Cc: "Brost, Matthew" <matthew.brost@intel.com>,
	"yaolu@kylinos.cn" <yaolu@kylinos.cn>,
	"K V P, Satyanarayana" <satyanarayana.k.v.p@intel.com>,
	"Vivi, Rodrigo" <rodrigo.vivi@intel.com>,
	"thomas.hellstrom@linux.intel.com"
	<thomas.hellstrom@linux.intel.com>,
	"intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"michal.wajdeczko@intel.com" <michal.wajdeczko@intel.com>
Subject: Re: [PATCH] drm/xe/gt: Abort GT init on LMTT initialization failure
Date: Thu, 19 Nov 2026 10:50:03 +0100	[thread overview]
Message-ID: <20261119095003.reakox5n3mhp5utx@intel.com> (raw)
In-Reply-To: <54d0efa24a49e73880bdc4d6f2786b940f32fdf8.camel@intel.com>

Summers, Stuart <stuart.summers@intel.com> wrote on śro [2026-lis-18 21:03:09 +0100]:
> On Wed, 2026-11-18 at 16:54 +0800, yaolu@kylinos.cn wrote:
> > From: Lu Yao <yaolu@kylinos.cn>
> > 
> > xe_lmtt_init() can fail, but gt_init_with_gt_forcewake() ignores its
> > return value. On a PF the probe then continues with a half-
> > initialized
> > LMTT: lmtt->pd is never set (and lmtt->ops is cleared), so
> > xe_lmtt_init_hw() returns early and the VF local memory is left
> > without
> > a translation directory while the driver still reports success.
> > 
> > Return the xe_lmtt_init() error and abort GT init instead, as
> > required
> > by the documented LMTT contract ("Any LMTT initialization failure
> > should block VFs enabling").
> > 
> > Fixes: b1d204058218 ("drm/xe/pf: Introduce Local Memory Translation
> > Table")
> > Signed-off-by: Lu Yao <yaolu@kylinos.cn>
> 
> I'm not an expert in this code, but it does look like if we tried to
> allocate memory here and that failed for some reason, causing the LMTT
> init to fail, it would cause downstream issues later in the PF's LMTT
> management. But the change as-is doesn't seem like the right approach
> here IMO. I don't think we want to kill the whole driver load because
> of this, it seems better to just log the error and not enumerate the
> VFs.
> 
> But it would be good to get feedback from Piotr/Satya here.

I agree with Stuart that, since LMTT is only necessary for creating VFs, we could simply
block the creation of VFs (and all operations related to SR-IOV).
It seems that switching back to native mode at this point is already too late.
Interrupting the driver's probe is definitely too radical an approach.

We could do something like this:

--- a/drivers/gpu/drm/xe/xe_lmtt.h
+++ b/drivers/gpu/drm/xe/xe_lmtt.h
@@
 #ifdef CONFIG_PCI_IOV
 int xe_lmtt_init(struct xe_lmtt *lmtt);
+bool xe_lmtt_is_ready(struct xe_lmtt *lmtt);
 void xe_lmtt_init_hw(struct xe_gt *gt);
--- a/drivers/gpu/drm/xe/xe_lmtt.c
+++ b/drivers/gpu/drm/xe/xe_lmtt.c
@@
+/**
+ * xe_lmtt_is_ready() - Check if LMTT is ready to be used.
+ * @lmtt: the &xe_lmtt to check
+ *
+ * This function shall be called only by PF.
+ *
+ * Return: true if LMTT is not needed on this device or was successfully
+ *         initialized by xe_lmtt_init(), false otherwise.
+ */
+bool xe_lmtt_is_ready(struct xe_lmtt *lmtt)
+{
+	lmtt_assert(lmtt, IS_SRIOV_PF(lmtt_to_xe(lmtt)));
+
+	return !xe_device_has_lmtt(lmtt_to_xe(lmtt)) || lmtt->pd;
+}
--- a/drivers/gpu/drm/xe/xe_gt.c
+++ b/drivers/gpu/drm/xe/xe_gt.c
@@ static int gt_init_with_gt_forcewake(struct xe_gt *gt)
 	if (xe_gt_is_main_type(gt)) {
 		err = xe_ggtt_init(gt_to_tile(gt)->mem.ggtt);
 		if (err)
 			return err;
-		if (IS_SRIOV_PF(gt_to_xe(gt)))
-			xe_lmtt_init(&gt_to_tile(gt)->sriov.pf.lmtt);
+		if (IS_SRIOV_PF(gt_to_xe(gt))) {
+			err = xe_lmtt_init(&gt_to_tile(gt)->sriov.pf.lmtt);
+			if (err)
+				xe_gt_sriov_err(gt, "Failed to initialize LMTT (%pe), VFs will be unavailable\n",
+						ERR_PTR(err));
+		}
 	}
--- a/drivers/gpu/drm/xe/xe_sriov_pf.c
+++ b/drivers/gpu/drm/xe/xe_sriov_pf.c
@@
+static int pf_check_lmtt(struct xe_device *xe)
+{
+	struct xe_tile *tile;
+	unsigned int id;
+
+	for_each_tile(tile, xe, id)
+		if (!xe_lmtt_is_ready(&tile->sriov.pf.lmtt))
+			return -ENODEV;
+
+	return 0;
+}
+
 int xe_sriov_pf_wait_ready(struct xe_device *xe)
 {
 	struct xe_gt *gt;
 	unsigned int id;
 	int err;
 
 	if (xe_wedged(xe))
 		return -ECANCELED;
 
+	err = pf_check_lmtt(xe);
+	if (err)
+		return err;
+
 	for_each_gt(gt, xe, id) {

Thanks
Piotr

> 
> Thanks,
> Stuart
> 
> > ---
> >  drivers/gpu/drm/xe/xe_gt.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
> > index 286aee5775c0..1239cbb7c84c 100644
> > --- a/drivers/gpu/drm/xe/xe_gt.c
> > +++ b/drivers/gpu/drm/xe/xe_gt.c
> > @@ -582,10 +582,10 @@ static int gt_init_with_gt_forcewake(struct
> > xe_gt *gt)
> >  
> >         if (xe_gt_is_main_type(gt)) {
> >                 err = xe_ggtt_init(gt_to_tile(gt)->mem.ggtt);
> > +               if (!err && IS_SRIOV_PF(gt_to_xe(gt)))
> > +                       err = xe_lmtt_init(&gt_to_tile(gt)-
> > >sriov.pf.lmtt);
> >                 if (err)
> >                         return err;
> > -               if (IS_SRIOV_PF(gt_to_xe(gt)))
> > -                       xe_lmtt_init(&gt_to_tile(gt)->sriov.pf.lmtt);
> >         }
> >  
> >         /* Enable per hw engine IRQs */
> 

-- 

      reply	other threads:[~2026-11-19  9:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18  8:54 yaolu
2026-11-18 20:03 ` Summers, Stuart
2026-11-19  9:50   ` Piotr Piórkowski [this message]

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=20261119095003.reakox5n3mhp5utx@intel.com \
    --to=piotr.piorkowski@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew.brost@intel.com \
    --cc=michal.wajdeczko@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=satyanarayana.k.v.p@intel.com \
    --cc=stuart.summers@intel.com \
    --cc=thomas.hellstrom@linux.intel.com \
    --cc=yaolu@kylinos.cn \
    /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

all inboxes | Powered by JetHome®