]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe: Add debugfs support for page reclamation
authorBrian Nguyen <brian3.nguyen@intel.com>
Fri, 12 Dec 2025 21:32:36 +0000 (05:32 +0800)
committerMatthew Brost <matthew.brost@intel.com>
Sat, 13 Dec 2025 00:59:10 +0000 (16:59 -0800)
Allow for runtime modification to page reclamation feature through
debugfs configuration. This parameter will only take effect if the
platform supports the page reclamation feature by default.

v2:
 - Minor comment tweaks. (Shuicheng)
 - Convert to kstrtobool_from_user. (Michal)
 - Only expose page reclaim file if page reclaim flag
   initially supported and with that, remove
   xe_match_desc usage. (Michal)

Signed-off-by: Brian Nguyen <brian3.nguyen@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Shuicheng Lin <shuicheng.lin@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patch.msgid.link/20251212213225.3564537-22-brian3.nguyen@intel.com
drivers/gpu/drm/xe/xe_debugfs.c

index 4fa423a82bea86334c7e1a5c33fe7eaa3bfb4cef..ad070055cef14a2ac51c28899437133e3c060f3b 100644 (file)
@@ -293,6 +293,39 @@ static const struct file_operations wedged_mode_fops = {
        .write = wedged_mode_set,
 };
 
+static ssize_t page_reclaim_hw_assist_show(struct file *f, char __user *ubuf,
+                                          size_t size, loff_t *pos)
+{
+       struct xe_device *xe = file_inode(f)->i_private;
+       char buf[8];
+       int len;
+
+       len = scnprintf(buf, sizeof(buf), "%d\n", xe->info.has_page_reclaim_hw_assist);
+       return simple_read_from_buffer(ubuf, size, pos, buf, len);
+}
+
+static ssize_t page_reclaim_hw_assist_set(struct file *f, const char __user *ubuf,
+                                         size_t size, loff_t *pos)
+{
+       struct xe_device *xe = file_inode(f)->i_private;
+       bool val;
+       ssize_t ret;
+
+       ret = kstrtobool_from_user(ubuf, size, &val);
+       if (ret)
+               return ret;
+
+       xe->info.has_page_reclaim_hw_assist = val;
+
+       return size;
+}
+
+static const struct file_operations page_reclaim_hw_assist_fops = {
+       .owner = THIS_MODULE,
+       .read = page_reclaim_hw_assist_show,
+       .write = page_reclaim_hw_assist_set,
+};
+
 static ssize_t atomic_svm_timeslice_ms_show(struct file *f, char __user *ubuf,
                                            size_t size, loff_t *pos)
 {
@@ -398,6 +431,14 @@ void xe_debugfs_register(struct xe_device *xe)
        debugfs_create_file("disable_late_binding", 0600, root, xe,
                            &disable_late_binding_fops);
 
+       /*
+        * Don't expose page reclaim configuration file if not supported by the
+        * hardware initially.
+        */
+       if (xe->info.has_page_reclaim_hw_assist)
+               debugfs_create_file("page_reclaim_hw_assist", 0600, root, xe,
+                                   &page_reclaim_hw_assist_fops);
+
        man = ttm_manager_type(bdev, XE_PL_TT);
        ttm_resource_manager_create_debugfs(man, root, "gtt_mm");