Skip to content

Commit 67de798

Browse files
bnilawarlucasdemarchi
authored andcommitted
drm/xe/xe_late_bind_fw: Introduce debug fs node to disable late binding
Introduce a debug filesystem node to disable late binding fw reload during the system or runtime resume. This is intended for situations where the late binding fw needs to be loaded from user mode, perticularly for validation purpose. Note that xe kmd doesn't participate in late binding flow from user space. Binary loaded from the userspace will be lost upon entering to D3 cold hence user space app need to handle this situation. v2: - s/(uval == 1) ? true : false/!!uval/ (Daniele) v3: - Refine the commit message (Daniele) Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Signed-off-by: Badal Nilawar <badal.nilawar@intel.com> Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Link: https://lore.kernel.org/r/20250905154953.3974335-9-badal.nilawar@intel.com Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
1 parent 02f52f6 commit 67de798

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

drivers/gpu/drm/xe/xe_debugfs.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,44 @@ static const struct file_operations atomic_svm_timeslice_ms_fops = {
331331
.write = atomic_svm_timeslice_ms_set,
332332
};
333333

334+
static ssize_t disable_late_binding_show(struct file *f, char __user *ubuf,
335+
size_t size, loff_t *pos)
336+
{
337+
struct xe_device *xe = file_inode(f)->i_private;
338+
struct xe_late_bind *late_bind = &xe->late_bind;
339+
char buf[32];
340+
int len;
341+
342+
len = scnprintf(buf, sizeof(buf), "%d\n", late_bind->disable);
343+
344+
return simple_read_from_buffer(ubuf, size, pos, buf, len);
345+
}
346+
347+
static ssize_t disable_late_binding_set(struct file *f, const char __user *ubuf,
348+
size_t size, loff_t *pos)
349+
{
350+
struct xe_device *xe = file_inode(f)->i_private;
351+
struct xe_late_bind *late_bind = &xe->late_bind;
352+
u32 uval;
353+
ssize_t ret;
354+
355+
ret = kstrtouint_from_user(ubuf, size, sizeof(uval), &uval);
356+
if (ret)
357+
return ret;
358+
359+
if (uval > 1)
360+
return -EINVAL;
361+
362+
late_bind->disable = !!uval;
363+
return size;
364+
}
365+
366+
static const struct file_operations disable_late_binding_fops = {
367+
.owner = THIS_MODULE,
368+
.read = disable_late_binding_show,
369+
.write = disable_late_binding_set,
370+
};
371+
334372
void xe_debugfs_register(struct xe_device *xe)
335373
{
336374
struct ttm_device *bdev = &xe->ttm;
@@ -364,6 +402,9 @@ void xe_debugfs_register(struct xe_device *xe)
364402
debugfs_create_file("atomic_svm_timeslice_ms", 0600, root, xe,
365403
&atomic_svm_timeslice_ms_fops);
366404

405+
debugfs_create_file("disable_late_binding", 0600, root, xe,
406+
&disable_late_binding_fops);
407+
367408
for (mem_type = XE_PL_VRAM0; mem_type <= XE_PL_VRAM1; ++mem_type) {
368409
man = ttm_manager_type(bdev, mem_type);
369410

drivers/gpu/drm/xe/xe_late_bind_fw.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ int xe_late_bind_fw_load(struct xe_late_bind *late_bind)
167167
if (!late_bind->component_added)
168168
return -ENODEV;
169169

170+
if (late_bind->disable)
171+
return 0;
172+
170173
for (fw_id = 0; fw_id < XE_LB_FW_MAX_ID; fw_id++) {
171174
lbfw = &late_bind->late_bind_fw[fw_id];
172175
if (lbfw->payload) {

drivers/gpu/drm/xe/xe_late_bind_fw_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ struct xe_late_bind {
6565
struct workqueue_struct *wq;
6666
/** @component_added: whether the component has been added */
6767
bool component_added;
68+
/** @disable: to block late binding reload during pm resume flow*/
69+
bool disable;
6870
};
6971

7072
#endif

0 commit comments

Comments
 (0)