Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Michael J. Ruhl" <michael.j.ruhl@intel.com>,
	intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v16 13/17] drm/xe/vsec: Support late bind fw information
Date: Mon, 16 Nov 2026 15:39:44 +0000	[thread overview]
Message-ID: <sashiko-outbox-217312@kernel.org> (raw)
In-Reply-To: <20261116150649.368686-32-michael.j.ruhl@intel.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/xe/vsec: lock inversion holding pmt.lock in
  cri_late_bind_probe()
- [Medium] drm/xe/vsec: missing pmt.lock during CRI discovery in
  xe_vsec_init()
--

commit 32874c6df8ff2b93eb16e544520f64211460d328
Author: Michael J. Ruhl <michael.j.ruhl@intel.com>

drm/xe/vsec: Support late bind fw information

This commit adds delayed-work polling and synchronous readiness waits so
Crescent Island PMT registration and telemetry or crashlog accesses wait
for the OOBMSM firmware to finish initializing.

> diff --git a/drivers/gpu/drm/xe/xe_vsec.c b/drivers/gpu/drm/xe/xe_vsec.c
> index 4ca41a5ef5027..fe3d8338cfc98 100644
> --- a/drivers/gpu/drm/xe/xe_vsec.c
> +++ b/drivers/gpu/drm/xe/xe_vsec.c

[ ... ]

> @@ -476,6 +549,28 @@ static enum xe_vsec get_platform_info(struct xe_device *xe)
>  	return vsec_platforms[xe->info.platform];
>  }
>  
> +static void cri_late_bind_probe(struct xe_device *xe)
> +{
> +	struct intel_vsec_platform_info *info;
> +	struct device *dev = xe->drm.dev;
> +	enum xe_vsec platform;
> +
> +	platform = get_platform_info(xe);
> +	if (platform != XE_VSEC_CRI)
> +		return;
> +
> +	info = &xe_vsec_info[platform];
> +	if (!info->headers)
> +		return;
> +
> +	guard(mutex)(&xe->pmt.lock);
> +
> +	info->priv_data = &xe_cri_pmt_cb;
> +	xe->soc_remapper.set_telem_region(xe, CRI_IDX_TELEM_DISCOVERY);
> +
> +	intel_vsec_register(dev, info);
> +}

[Severity: Medium]
Does holding xe->pmt.lock across intel_vsec_register() introduce a circular
locking dependency and potential ABBA deadlock with PMT sysfs attributes?

intel_vsec_register() adds the auxiliary device under device_lock(&auxdev->dev)
and synchronously runs pmt_telem_probe(), which acquires ep_lock and creates
sysfs attributes for each discovery entry.  Reading those attributes enters
intel_pmt_read() -> xe_pmt_telem_read() under the kernfs active reference
(kn->dep_map) and takes xe->pmt.lock, while unbinding or rolling back on a
later entry's probe failure drains kn->dep_map under &auxdev->dev.mutex and
ep_lock:

CPU0                              CPU1
----                              ----
lock(&xe->pmt.lock)
  lock(&auxdev->dev.mutex)
    lock(&ep_lock)
                                  lock(kn->dep_map)
                                    lock(&xe->pmt.lock)
      lock(kn->dep_map)

 *** DEADLOCK ***

CPU0: cri_late_bind_probe() -> intel_vsec_register() -> ... ->
      pmt_telem_probe() -> pmt_telem_remove() -> sysfs_remove_bin_file()
CPU1: kernfs_fop_read_iter() -> intel_pmt_read() -> xe_pmt_telem_read()

>  
>  /**
>   * xe_vsec_init - Initialize resources and add intel_vsec auxiliary
>   * interface
> @@ -503,12 +598,24 @@ void xe_vsec_init(struct xe_device *xe)
>  
>  	case XE_VSEC_CRI:
>  		xe->pmt.base_offset = CRI_PMT_OFFSET;
> +
> +		xe->pmt.retry_count = 0;
> +		INIT_DELAYED_WORK(&xe->pmt.work, cri_late_bind_probe_work);
> +
> +		xe_pm_runtime_get_noresume(xe);
> +		if (!xe_sysctrl_is_oobmsm_fw_ready(xe)) {
> +			queue_delayed_work(system_freezable_wq, &xe->pmt.work,
> +					   msecs_to_jiffies(VSEC_LATE_BIND_DELAY_MSEC));
> +			return;
> +		}
> +
>  		info->priv_data = &xe_cri_pmt_cb;
>  		xe->soc_remapper.set_telem_region(xe, CRI_IDX_TELEM_DISCOVERY);
>  		break;
>  
>  	default:
> -		break;
> +		drm_err(&xe->drm, "Unsupported platform: %u\n", platform);
> +		return;
>  	}
>  
>  	/*
> @@ -516,5 +623,22 @@ void xe_vsec_init(struct xe_device *xe)
>  	 * resources.
>  	 */
>  	intel_vsec_register(dev, info);

[Severity: Medium]
Can a concurrent telemetry read corrupt the SoC remapper index while
intel_vsec_register() is still reading Crescent Island discovery headers?

When OOBMSM firmware is already ready in xe_vsec_init(), CRI_IDX_TELEM_DISCOVERY
is programmed and intel_vsec_register() is called without serialization
against xe_pmt_telem_read().  Because intel_vsec_register() registers three
cri_telemetry entries followed by two cri_crashlog entries, a reader can
open the first telemetry sysfs file as soon as entry 0 is created and
switch the remapper index away from CRI_IDX_TELEM_DISCOVERY while the
remaining headers are still being read from CRI_PMT_OFFSET:

CPU0                                  CPU1
xe_vsec_init()
  set_telem_region(...,
    CRI_IDX_TELEM_DISCOVERY)
  intel_vsec_register()
    pmt_telem_probe()
      intel_pmt_dev_create(entry 0)
                                      xe_pmt_telem_read()
                                        lock(&xe->pmt.lock)
                                        set_telem_region(..., mem_region)
      intel_pmt_dev_create(entry 1)
        pmt_get_headers()
          readl(disc_vaddr)  <-- reads wrong remapper region
                                        memcpy_fromio(...)
                                        set_telem_region(...,
                                          CRI_IDX_TELEM_DISCOVERY)
                                        unlock(&xe->pmt.lock)

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261116150649.368686-19-michael.j.ruhl@intel.com?part=13

  reply	other threads:[~2026-11-16 15:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 15:06 [PATCH v16 00/17] Crescent Island PMT support Michael J. Ruhl
2026-11-16 15:06 ` [PATCH v16 01/17] drm/xe/vsec: VSEC requires soc-remapper Michael J. Ruhl
2026-11-16 15:06 ` [PATCH v16 02/17] drm/xe/vsec: Do not register BMG PMT for VF Michael J. Ruhl
2026-11-16 15:06 ` [PATCH v16 03/17] drm/xe/vsec: Correct locking order Michael J. Ruhl
2026-11-16 15:06 ` [PATCH v16 04/17] drm/xe/vsec: Use correct pm state get Michael J. Ruhl
2026-11-16 15:06 ` [PATCH v16 05/17] drm/xe/vsec: Add DOC text for VSEC Michael J. Ruhl
2026-11-16 15:06 ` [PATCH v16 06/17] drm/xe/vsec: Support possible hotplug exit Michael J. Ruhl
2026-11-16 15:06 ` [PATCH v16 07/17] drm/xe/vsec: Refactor BattleMage PMT defines Michael J. Ruhl
2026-11-16 15:06 ` [PATCH v16 08/17] drm/xe/vsec: Update VSEC probe order Michael J. Ruhl
2026-11-16 15:06 ` [PATCH v16 09/17] drm/xe/vsec: Add base_offset to allow for more flexibilty Michael J. Ruhl
2026-11-16 15:06 ` [PATCH v16 10/17] drm/xe/vsec: Support Crescent Island PMT Michael J. Ruhl
2026-11-16 15:07 ` [PATCH v16 11/17] drm/xe/vsec: Crescent Island PMT decode Michael J. Ruhl
2026-11-16 15:07 ` [PATCH v16 12/17] drm/xe/vsec: Crescent Island PMT callbacks Michael J. Ruhl
2026-11-16 15:07 ` [PATCH v16 13/17] drm/xe/vsec: Support late bind fw information Michael J. Ruhl
2026-11-16 15:39   ` sashiko-bot [this message]
2026-11-16 15:07 ` [PATCH v16 14/17] drm/xe/vsec: Add PMT GUID internal access Michael J. Ruhl
2026-11-16 15:31   ` sashiko-bot
2026-11-16 15:07 ` [PATCH v16 15/17] drm/xe/vsec: Update PMT " Michael J. Ruhl
2026-11-16 15:07 ` [PATCH v16 16/17] drm/xe/vsec: Refactor platform check Michael J. Ruhl
2026-11-16 15:07 ` [PATCH v16 17/17] drm/xe/vsec: Support survivability mode for CRI Michael J. Ruhl

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=sashiko-outbox-217312@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=michael.j.ruhl@intel.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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