From: Matthew Auld <matthew.auld@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Ilia Levi <ilia.levi@intel.com>
Subject: [PATCH v4 5/8] drm/xe/mmio_gem: cache the dummy page per object
Date: Tue, 8 Sep 2026 14:50:01 +0100 [thread overview]
Message-ID: <20260908134955.1344429-15-matthew.auld@intel.com> (raw)
In-Reply-To: <20260908134955.1344429-10-matthew.auld@intel.com>
From: Ilia Levi <ilia.levi@intel.com>
Currently, when the fault handler provides a dummy page, it
allocates a new one on every invocation and ties its lifetime to
the drm_device via drmm_add_action_or_reset(). Concurrent faults
after hot-unplug therefore accumulate pages that persist until
device teardown.
Cache a single dummy page in the xe_mmio_gem object and use dma_resv
lock to protect its allocation. Free it with the object.
v2: use dma_resv lock to protect the allocation (Matt Auld)
Assisted-by: GitHub-Copilot:claude-opus-4.6
Signed-off-by: Ilia Levi <ilia.levi@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
---
drivers/gpu/drm/xe/xe_mmio_gem.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_mmio_gem.c b/drivers/gpu/drm/xe/xe_mmio_gem.c
index 3c42d8358c7d..970b1e2f4981 100644
--- a/drivers/gpu/drm/xe/xe_mmio_gem.c
+++ b/drivers/gpu/drm/xe/xe_mmio_gem.c
@@ -5,9 +5,9 @@
#include "xe_mmio_gem.h"
+#include <linux/dma-resv.h>
#include <drm/drm_drv.h>
#include <drm/drm_gem.h>
-#include <drm/drm_managed.h>
#include "xe_device_types.h"
@@ -37,6 +37,7 @@ static vm_fault_t xe_mmio_gem_vm_fault(struct vm_fault *);
struct xe_mmio_gem {
struct drm_gem_object base;
phys_addr_t phys_addr;
+ struct page *dummy_page; /* protected by the GEM's dma_resv */
};
static int xe_mmio_gem_vm_may_split(struct vm_area_struct *area, unsigned long addr)
@@ -131,6 +132,8 @@ static void xe_mmio_gem_free(struct drm_gem_object *base)
{
struct xe_mmio_gem *obj = to_xe_mmio_gem(base);
+ if (obj->dummy_page)
+ __free_page(obj->dummy_page);
drm_gem_object_release(base);
kfree(obj);
}
@@ -169,27 +172,29 @@ static int xe_mmio_gem_mmap(struct drm_gem_object *base, struct vm_area_struct *
return 0;
}
-static void xe_mmio_gem_release_dummy_page(struct drm_device *dev, void *res)
+static int alloc_dummy_page_if_needed(struct drm_gem_object *base)
{
- __free_page((struct page *)res);
+ struct xe_mmio_gem *obj = to_xe_mmio_gem(base);
+
+ dma_resv_lock(base->resv, NULL);
+ if (!obj->dummy_page)
+ obj->dummy_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
+ dma_resv_unlock(base->resv);
+
+ return obj->dummy_page ? 0 : -ENOMEM;
}
static vm_fault_t xe_mmio_gem_vm_fault_dummy_page(struct vm_fault *vmf)
{
struct vm_area_struct *vma = vmf->vma;
struct drm_gem_object *base = vma->vm_private_data;
- struct drm_device *dev = base->dev;
- struct page *page;
+ struct xe_mmio_gem *obj = to_xe_mmio_gem(base);
unsigned long pfn;
- page = alloc_page(GFP_KERNEL | __GFP_ZERO);
- if (!page)
+ if (alloc_dummy_page_if_needed(base))
return VM_FAULT_OOM;
- if (drmm_add_action_or_reset(dev, xe_mmio_gem_release_dummy_page, page))
- return VM_FAULT_OOM;
-
- pfn = page_to_pfn(page);
+ pfn = page_to_pfn(obj->dummy_page);
return vmf_insert_pfn_prot(vma, vmf->address, pfn,
vm_get_page_prot(vma->vm_flags));
--
2.55.0
next prev parent reply other threads:[~2026-09-08 13:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 13:49 [PATCH v4 0/8] drm/xe/mmio_gem: fix fault handler and destroy path Matthew Auld
2026-09-08 13:49 ` [PATCH v4 1/8] drm/xe/mmio_gem: forbid VMA split Matthew Auld
2026-09-08 13:49 ` [PATCH v4 2/8] drm/xe/mmio_gem: use write-back mapping for dummy page Matthew Auld
2026-09-08 13:49 ` [PATCH v4 3/8] drm/xe/mmio_gem: simplify fault handler loop Matthew Auld
2026-09-08 13:50 ` [PATCH v4 4/8] drm/xe/mmio_gem: Revoke drm_vma_node on xe_mmio_gem destroy Matthew Auld
2026-09-08 13:50 ` Matthew Auld [this message]
2026-09-08 13:50 ` [PATCH v4 6/8] drm/xe/mmio_gem: fix destroy flow Matthew Auld
2026-09-08 13:50 ` [PATCH v4 7/8] drm/xe/mmio_gem: reject VM_EXEC and drop VM_DONTCOPY Matthew Auld
2026-09-08 14:57 ` Thomas Hellström
2026-09-08 13:50 ` [PATCH v4 8/8] drm/xe: convert PCI barrier mmap to use xe_mmio_gem Matthew Auld
2026-09-08 14:09 ` sashiko-bot
2026-09-08 14:21 ` Matthew Auld
2026-09-08 15:07 ` Thomas Hellström
2026-09-08 14:48 ` ✓ CI.KUnit: success for drm/xe/mmio_gem: fix fault handler and destroy path (rev4) Patchwork
2026-09-08 15:25 ` ✓ Xe.CI.BAT: " 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=20260908134955.1344429-15-matthew.auld@intel.com \
--to=matthew.auld@intel.com \
--cc=ilia.levi@intel.com \
--cc=intel-xe@lists.freedesktop.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.