From: "Dong, Zhanjun" <zhanjun.dong@intel.com>
To: <intel-xe@lists.freedesktop.org>
Cc: Matthew Brost <matthew.brost@intel.com>, <stable@vger.kernel.org>
Subject: Re: [PATCH v8 7/7] drm/xe: Open-code GGTT MMIO access protection
Date: Thu, 5 Mar 2026 10:22:13 -0500 [thread overview]
Message-ID: <dd9ab590-f8f7-4979-9bed-30a284eca0ec@intel.com> (raw)
In-Reply-To: <20260224163555.218750-8-zhanjun.dong@intel.com>
LGTM
Reviewed-by: Zhanjun Dong <zhanjun.dong@intel.com>
On 2026-02-24 11:35 a.m., Zhanjun Dong wrote:
> From: Matthew Brost <matthew.brost@intel.com>
>
> GGTT MMIO access is currently protected by hotplug (drm_dev_enter),
> which works correctly when the driver loads successfully and is later
> unbound or unloaded. However, if driver load fails, this protection is
> insufficient because drm_dev_unplug() is never called.
>
> Additionally, devm release functions cannot guarantee that all BOs with
> GGTT mappings are destroyed before the GGTT MMIO region is removed, as
> some BOs may be freed asynchronously by worker threads.
>
> To address this, introduce an open-coded flag, protected by the GGTT
> lock, that guards GGTT MMIO access. The flag is cleared during the
> dev_fini_ggtt devm release function to ensure MMIO access is disabled
> once teardown begins.
>
> Cc: stable@vger.kernel.org
> Fixes: 919bb54e989c ("drm/xe: Fix missing runtime outer protection for ggtt_remove_node")
> Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> ---
> drivers/gpu/drm/xe/xe_ggtt.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> index 79310f565fe3..cf3311f5d140 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.c
> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> @@ -66,6 +66,9 @@
> * give us the correct placement for free.
> */
>
> +#define XE_GGTT_FLAGS_64K BIT(0)
> +#define XE_GGTT_FLAGS_ONLINE BIT(1)
> +
> /**
> * struct xe_ggtt_node - A node in GGTT.
> *
> @@ -117,6 +120,8 @@ struct xe_ggtt {
> * @flags: Flags for this GGTT
> * Acceptable flags:
> * - %XE_GGTT_FLAGS_64K - if PTE size is 64K. Otherwise, regular is 4K.
> + * - %XE_GGTT_FLAGS_ONLINE - is GGTT online, protected by ggtt->lock
> + * after init
> */
> unsigned int flags;
> /** @scratch: Internal object allocation used as a scratch page */
> @@ -367,6 +372,8 @@ static void dev_fini_ggtt(void *arg)
> {
> struct xe_ggtt *ggtt = arg;
>
> + scoped_guard(mutex, &ggtt->lock)
> + ggtt->flags &= ~XE_GGTT_FLAGS_ONLINE;
> drain_workqueue(ggtt->wq);
> }
>
> @@ -437,6 +444,7 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt)
> if (err)
> return err;
>
> + ggtt->flags |= XE_GGTT_FLAGS_ONLINE;
> return devm_add_action_or_reset(xe->drm.dev, dev_fini_ggtt, ggtt);
> }
> ALLOW_ERROR_INJECTION(xe_ggtt_init_early, ERRNO); /* See xe_pci_probe() */
> @@ -465,13 +473,10 @@ static void ggtt_node_fini(struct xe_ggtt_node *node)
> static void ggtt_node_remove(struct xe_ggtt_node *node)
> {
> struct xe_ggtt *ggtt = node->ggtt;
> - struct xe_device *xe = tile_to_xe(ggtt->tile);
> bool bound;
> - int idx;
> -
> - bound = drm_dev_enter(&xe->drm, &idx);
>
> mutex_lock(&ggtt->lock);
> + bound = ggtt->flags & XE_GGTT_FLAGS_ONLINE;
> if (bound)
> xe_ggtt_clear(ggtt, xe_ggtt_node_addr(node), xe_ggtt_node_size(node));
> drm_mm_remove_node(&node->base);
> @@ -484,8 +489,6 @@ static void ggtt_node_remove(struct xe_ggtt_node *node)
> if (node->invalidate_on_remove)
> xe_ggtt_invalidate(ggtt);
>
> - drm_dev_exit(idx);
> -
> free_node:
> ggtt_node_fini(node);
> }
next prev parent reply other threads:[~2026-03-05 15:22 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 16:35 [PATCH v8 0/7] Attempt to fixup reset, wedge, unload corner cases Zhanjun Dong
2026-02-24 16:35 ` [PATCH v8 1/7] drm/xe: Always kill exec queues in xe_guc_submit_pause_abort Zhanjun Dong
2026-02-24 16:35 ` [PATCH v8 2/7] drm/xe: Forcefully tear down exec queues in GuC submit fini Zhanjun Dong
2026-02-24 16:35 ` [PATCH v8 3/7] drm/xe: Trigger queue cleanup if not in wedged mode 2 Zhanjun Dong
2026-02-24 16:35 ` [PATCH v8 4/7] drm/xe: Use XE_WEDGED_MODE_UPON_ANY_HANG_NO_RESET enum instead of magic number Zhanjun Dong
2026-02-24 16:35 ` [PATCH v8 5/7] drm/xe/guc: Ensure CT state transitions via STOP before DISABLED Zhanjun Dong
2026-02-24 16:35 ` [PATCH v8 6/7] drm/xe/uc: Drop xe_guc_sanitize in favor of managed cleanup Zhanjun Dong
2026-02-24 16:35 ` [PATCH v8 7/7] drm/xe: Open-code GGTT MMIO access protection Zhanjun Dong
2026-03-05 15:22 ` Dong, Zhanjun [this message]
2026-02-24 16:43 ` ✓ CI.KUnit: success for Attempt to fixup reset, wedge, unload corner cases Patchwork
2026-02-26 0:43 ` ✓ CI.KUnit: success for Attempt to fixup reset, wedge, unload corner cases (rev2) Patchwork
2026-02-26 1:18 ` ✓ Xe.CI.BAT: " Patchwork
2026-02-26 4:45 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-03-06 21:13 ` ✓ CI.KUnit: success for Attempt to fixup reset, wedge, unload corner cases (rev3) Patchwork
2026-03-06 21:58 ` ✓ Xe.CI.BAT: " Patchwork
2026-03-08 0:26 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-03-09 21:52 ` Dong, Zhanjun
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=dd9ab590-f8f7-4979-9bed-30a284eca0ec@intel.com \
--to=zhanjun.dong@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=stable@vger.kernel.org \
/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