Commit 13d99b01 authored by Brian Nguyen's avatar Brian Nguyen Committed by Matthew Brost
Browse files

drm/xe: Add debugfs support for page reclamation



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: default avatarBrian Nguyen <brian3.nguyen@intel.com>
Reviewed-by: default avatarMatthew Brost <matthew.brost@intel.com>
Reviewed-by: default avatarShuicheng Lin <shuicheng.lin@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: default avatarMatthew Brost <matthew.brost@intel.com>
Link: https://patch.msgid.link/20251212213225.3564537-22-brian3.nguyen@intel.com
parent 7c52f13b
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
@@ -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");