From: Nareshkumar Gollakoti <naresh.kumar.g@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: himal.prasad.ghimiray@intel.com, naresh.kumar.g@intel.com
Subject: [PATCH v4 3/8] drm/xe/debugfs: add page-size allocation mode knob
Date: Mon, 13 Jul 2026 07:55:36 +0530 [thread overview]
Message-ID: <20260713022541.2581814-4-naresh.kumar.g@intel.com> (raw)
In-Reply-To: <20260713022541.2581814-1-naresh.kumar.g@intel.com>
Expose a debugfs control to override the page-size allocation mode used
for user BOs.
The interface allows switching between the default allocation policy,
forced 2M, forced 1G, and mixed allocation modes at runtime. This
provides a simple way to validate behavior and debug page-size-dependent
allocation flows.
The debugfs entry is built only when CONFIG_DRM_XE_DEBUG_PAGE_SIZE is
enabled.
v2
- update changelog to match mutex-based cur_index handling
- reset cur_index when switching to mixed mode (sashiko)
v3
- add CONFIG guard for page-size allocation debugfs support (Himal)
- create debugfs entry under CONFIG_DRM_XE_DEBUG_PAGE_SIZE
v4
- reorderd this patch with kconfig patch to ensure patch builds
- Gurding this debug knob for only discrete graphics
Signed-off-by: Nareshkumar Gollakoti <naresh.kumar.g@intel.com>
---
drivers/gpu/drm/xe/xe_debugfs.c | 62 +++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/drivers/gpu/drm/xe/xe_debugfs.c b/drivers/gpu/drm/xe/xe_debugfs.c
index 8c391c7b017a..6ab2d51033f8 100644
--- a/drivers/gpu/drm/xe/xe_debugfs.c
+++ b/drivers/gpu/drm/xe/xe_debugfs.c
@@ -564,6 +564,56 @@ static const struct file_operations disable_late_binding_fops = {
.write = disable_late_binding_set,
};
+#if IS_ENABLED(CONFIG_DRM_XE_DEBUG_PAGE_SIZE)
+static ssize_t page_size_alloc_mode_show(struct file *f, char __user *ubuf,
+ size_t size, loff_t *pos)
+{
+ struct xe_device *xe = file_inode(f)->i_private;
+ char buf[32];
+ int len;
+
+ mutex_lock(&xe->page_size_alloc_ctrl.lock);
+
+ len = scnprintf(buf, sizeof(buf), "%u\n",
+ xe->page_size_alloc_ctrl.mode);
+ mutex_unlock(&xe->page_size_alloc_ctrl.lock);
+
+ return simple_read_from_buffer(ubuf, size, pos, buf, len);
+}
+
+static ssize_t page_size_alloc_mode_set(struct file *f, const char __user *ubuf,
+ size_t size, loff_t *pos)
+{
+ struct xe_device *xe = file_inode(f)->i_private;
+ unsigned int val;
+ int ret;
+
+ ret = kstrtouint_from_user(ubuf, size, 0, &val);
+ if (ret)
+ return ret;
+
+ if (val > XE_PAGE_SIZE_ALLOC_CTRL_MODE_MIXED)
+ return -EINVAL;
+
+ mutex_lock(&xe->page_size_alloc_ctrl.lock);
+
+ if (val == XE_PAGE_SIZE_ALLOC_CTRL_MODE_MIXED)
+ xe->page_size_alloc_ctrl.cur_index = 0;
+
+ xe->page_size_alloc_ctrl.mode = (enum xe_page_size_alloc_ctrl_mode)val;
+
+ mutex_unlock(&xe->page_size_alloc_ctrl.lock);
+
+ return size;
+}
+
+static const struct file_operations page_size_alloc_mode_fops = {
+ .owner = THIS_MODULE,
+ .read = page_size_alloc_mode_show,
+ .write = page_size_alloc_mode_set,
+};
+#endif
+
void xe_debugfs_register(struct xe_device *xe)
{
struct ttm_device *bdev = &xe->ttm;
@@ -616,6 +666,18 @@ void xe_debugfs_register(struct xe_device *xe)
debugfs_create_file("disable_late_binding", 0600, root, xe,
&disable_late_binding_fops);
+#if IS_ENABLED(CONFIG_DRM_XE_DEBUG_PAGE_SIZE)
+ /*
+ * Expose a debugfs knob to control user BO page-size allocation:
+ * 0 - default behavior
+ * 1 - force 2M page allocations
+ * 2 - force 1G page allocations
+ * 3 - mixed mode: select 4K, 64K, 2M, and 1G in round-robin order
+ */
+ if (IS_DGFX(xe))
+ debugfs_create_file("page_size_alloc_mode", 0600, root, xe,
+ &page_size_alloc_mode_fops);
+#endif
/*
* Don't expose page reclaim configuration file if not supported by the
--
2.43.0
next prev parent reply other threads:[~2026-07-13 2:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 2:25 [PATCH v4 0/8] drm/xe: add page size allocation mode control and coverage Nareshkumar Gollakoti
2026-07-13 2:25 ` [PATCH v4 1/8] drm/xe: add page size allocation control state to xe_device Nareshkumar Gollakoti
2026-07-13 2:25 ` [PATCH v4 2/8] drm/xe: add Kconfig option for debug page-size allocation control Nareshkumar Gollakoti
2026-07-13 2:25 ` Nareshkumar Gollakoti [this message]
2026-07-13 2:25 ` [PATCH v4 4/8] drm/xe: add XE_BO_FLAG_NEEDS_1G for minimum page-size sizing Nareshkumar Gollakoti
2026-07-13 2:25 ` [PATCH v4 5/8] drm/xe: apply debug page-size allocation policy to user BOs Nareshkumar Gollakoti
2026-07-13 2:25 ` [PATCH v4 6/8] drm/xe/vm: propagate BO page-size requirements to VMA map flags Nareshkumar Gollakoti
2026-07-13 2:25 ` [PATCH v4 7/8] drm/xe/pt: allow selecting the bind leaf PTE level Nareshkumar Gollakoti
2026-07-13 2:25 ` [PATCH v4 8/8] drm/xe/tests: add live KUnit coverage for BO page-size allocation modes Nareshkumar Gollakoti
2026-07-13 2:33 ` ✗ CI.checkpatch: warning for drm/xe: add page size allocation mode control and coverage (rev2) Patchwork
2026-07-13 2:35 ` ✓ CI.KUnit: 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=20260713022541.2581814-4-naresh.kumar.g@intel.com \
--to=naresh.kumar.g@intel.com \
--cc=himal.prasad.ghimiray@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox