Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Badal Nilawar and committed by
Lucas De Marchi
67de7982 02f52f6d

+46
+41
drivers/gpu/drm/xe/xe_debugfs.c
··· 331 331 .write = atomic_svm_timeslice_ms_set, 332 332 }; 333 333 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 + 334 372 void xe_debugfs_register(struct xe_device *xe) 335 373 { 336 374 struct ttm_device *bdev = &xe->ttm; ··· 401 363 402 364 debugfs_create_file("atomic_svm_timeslice_ms", 0600, root, xe, 403 365 &atomic_svm_timeslice_ms_fops); 366 + 367 + debugfs_create_file("disable_late_binding", 0600, root, xe, 368 + &disable_late_binding_fops); 404 369 405 370 for (mem_type = XE_PL_VRAM0; mem_type <= XE_PL_VRAM1; ++mem_type) { 406 371 man = ttm_manager_type(bdev, mem_type);
+3
drivers/gpu/drm/xe/xe_late_bind_fw.c
··· 167 167 if (!late_bind->component_added) 168 168 return -ENODEV; 169 169 170 + if (late_bind->disable) 171 + return 0; 172 + 170 173 for (fw_id = 0; fw_id < XE_LB_FW_MAX_ID; fw_id++) { 171 174 lbfw = &late_bind->late_bind_fw[fw_id]; 172 175 if (lbfw->payload) {
+2
drivers/gpu/drm/xe/xe_late_bind_fw_types.h
··· 65 65 struct workqueue_struct *wq; 66 66 /** @component_added: whether the component has been added */ 67 67 bool component_added; 68 + /** @disable: to block late binding reload during pm resume flow*/ 69 + bool disable; 68 70 }; 69 71 70 72 #endif