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 v3 5/8] drm/xe: apply debug page-size allocation policy to user BOs
Date: Sun, 12 Jul 2026 16:45:14 +0530 [thread overview]
Message-ID: <20260712111517.1956177-6-naresh.kumar.g@intel.com> (raw)
In-Reply-To: <20260712111517.1956177-1-naresh.kumar.g@intel.com>
Apply the debug page-size allocation policy during user BO creation.
When page-size allocation control is enabled, override the user BO
page-size selection flags based on the selected debug mode and round the
requested size up to the corresponding granularity:
- 2M mode selects 2M handling
- 1G mode selects 1G handling
- mixed mode selects the page size from the current mixed-mode index
This is intended for internal debug and validation flows. When the
control mode is left at the default setting, the normal user BO creation
path is unchanged.
v2
- ensure debug page-size allocation does not
affect the default path (sashiko)
- rework synchronization for concurrent access (sashiko)
- refactor commit message for readability
v3
- update user BO size alignment based on debug policy mode
- reword commit message
- ensure normal user flow is unchanged when debug policy is disabled
Signed-off-by: Nareshkumar Gollakoti <naresh.kumar.g@intel.com>
---
drivers/gpu/drm/xe/xe_bo.c | 79 ++++++++++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)
diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index 9dbf59fad421..75de27aa1770 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -2612,6 +2612,83 @@ static struct xe_bo *xe_bo_create_novm(struct xe_device *xe, struct xe_tile *til
return ret ? ERR_PTR(ret) : bo;
}
+static u32 get_flag_from_cur_index_in_mixed_mode(struct xe_device *xe, size_t *align_size)
+{
+ static const u32 map[4] = {
+ 0, //default mode 4K
+ XE_BO_FLAG_NEEDS_64K,
+ XE_BO_FLAG_NEEDS_2M,
+ XE_BO_FLAG_NEEDS_1G,
+ };
+ u32 idx;
+
+ idx = xe->page_size_alloc_ctrl.cur_index++ % ARRAY_SIZE(map);
+
+ if (!map[idx])
+ return 0;
+
+ if (map[idx] == XE_BO_FLAG_NEEDS_64K) {
+ *align_size = ALIGN(*align_size, SZ_64K);
+ return map[idx];
+ }
+
+ if (map[idx] == XE_BO_FLAG_NEEDS_2M) {
+ *align_size = ALIGN(*align_size, SZ_2M);
+ return map[idx];
+ }
+
+ if (map[idx] == XE_BO_FLAG_NEEDS_1G) {
+ *align_size = ALIGN(*align_size, SZ_1G);
+ return map[idx];
+ }
+
+ return 0;
+}
+
+static void xe_bo_apply_debug_page_size_policy(struct xe_device *xe,
+ u32 *bo_flags,
+ size_t *size)
+{
+ enum xe_page_size_alloc_ctrl_mode mode;
+ u32 want = 0;
+ size_t align_size = *size;
+
+ mutex_lock(&xe->page_size_alloc_ctrl.lock);
+
+ mode = xe->page_size_alloc_ctrl.mode;
+
+ /* No action if default mode */
+ if (!mode) {
+ mutex_unlock(&xe->page_size_alloc_ctrl.lock);
+ return;
+ }
+
+ if (mode == XE_PAGE_SIZE_ALLOC_CTRL_MODE_ONLY_2M) {
+ want = XE_BO_FLAG_NEEDS_2M;
+ align_size = ALIGN(align_size, SZ_2M);
+ } else if (mode == XE_PAGE_SIZE_ALLOC_CTRL_MODE_ONLY_1G) {
+ want = XE_BO_FLAG_NEEDS_1G;
+ align_size = ALIGN(align_size, SZ_1G);
+ } else if (mode == XE_PAGE_SIZE_ALLOC_CTRL_MODE_MIXED) {
+ want = get_flag_from_cur_index_in_mixed_mode(xe, &align_size);
+ } else {
+ mutex_unlock(&xe->page_size_alloc_ctrl.lock);
+ return;
+ }
+
+ mutex_unlock(&xe->page_size_alloc_ctrl.lock);
+
+ *bo_flags &= ~(XE_BO_FLAG_NEEDS_64K |
+ XE_BO_FLAG_NEEDS_2M |
+ XE_BO_FLAG_NEEDS_1G);
+ *bo_flags |= want;
+ /*
+ * Apply the debug page-size policy by rounding the user BO size up to
+ * the selected granularity.
+ */
+ *size = align_size;
+}
+
/**
* xe_bo_create_user() - Create a user BO
* @xe: The xe device.
@@ -2635,6 +2712,8 @@ struct xe_bo *xe_bo_create_user(struct xe_device *xe,
flags |= XE_BO_FLAG_USER;
+ xe_bo_apply_debug_page_size_policy(xe, &flags, &size);
+
if (vm || exec) {
xe_assert(xe, exec);
bo = __xe_bo_create_locked(xe, NULL, vm, size, 0, ~0ULL,
--
2.43.0
next prev parent reply other threads:[~2026-07-12 11:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-12 11:15 [PATCH v3 0/8] drm/xe:add page size allocation mode control and coverage Nareshkumar Gollakoti
2026-07-12 11:15 ` [PATCH v3 1/8] drm/xe: add page size allocation control state to xe_device Nareshkumar Gollakoti
2026-07-12 11:15 ` [PATCH v3 2/8] drm/xe/debugfs: add page-size allocation mode knob Nareshkumar Gollakoti
2026-07-12 11:15 ` [PATCH v3 3/8] drm/xe: add Kconfig option for debug page-size allocation control Nareshkumar Gollakoti
2026-07-12 11:15 ` [PATCH v3 4/8] drm/xe: add XE_BO_FLAG_NEEDS_1G for minimum page-size sizing Nareshkumar Gollakoti
2026-07-12 11:15 ` Nareshkumar Gollakoti [this message]
2026-07-12 11:15 ` [PATCH v3 6/8] drm/xe/vm: propagate BO page-size requirements to VMA map flags Nareshkumar Gollakoti
2026-07-12 11:15 ` [PATCH v3 7/8] drm/xe/pt: allow selecting the bind leaf PTE level Nareshkumar Gollakoti
2026-07-12 11:15 ` [PATCH v3 8/8] drm/xe/tests: add live KUnit coverage for BO page-size allocation modes Nareshkumar Gollakoti
2026-07-12 11:21 ` ✗ CI.checkpatch: warning for drm/xe:add page size allocation mode control and coverage Patchwork
2026-07-12 11:22 ` ✓ CI.KUnit: success " Patchwork
2026-07-13 4:46 ` [PATCH v3 0/8] " Simon Richter
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=20260712111517.1956177-6-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