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

drm/xe/guc: Make creation of SLPC debugfs files conditional

Platforms that do not support SLPC are exempted from the GuC PC support.
The GuC PC does not get initialized, and neither do its BOs get created.

This causes a problem because the GuC PC debugfs file is still being
created. Whenever the file is attempted to read, it causes a NULL
pointer dereference on the supposed BO of the GuC PC.

So, make the creation of SLPC debugfs files conditional to when SLPC
features are supported.

Fixes: aaab5404b16f ("drm/xe: Introduce GuC PC debugfs")
Suggested-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
Reviewed-by: Stuart Summers <stuart.summers@intel.com>
Signed-off-by: Aradhya Bhatia <aradhya.bhatia@intel.com>
Link: https://lore.kernel.org/r/20250516141902.5614-1-aradhya.bhatia@intel.com
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
(cherry picked from commit 17486cf3df5320752cc67ee8bcb2379d1b9de76c)
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>

authored by

Aradhya Bhatia and committed by
Thomas Hellström
e22d7acf 1faeeb31

+14 -3
+14 -3
drivers/gpu/drm/xe/xe_guc_debugfs.c
··· 113 113 { "guc_ctb", .show = guc_debugfs_show, .data = guc_ctb }, 114 114 }; 115 115 116 + /* For GuC debugfs files that require the SLPC support */ 117 + static const struct drm_info_list slpc_debugfs_list[] = { 118 + { "guc_pc", .show = guc_debugfs_show, .data = guc_pc }, 119 + }; 120 + 116 121 /* everything else should be added here */ 117 122 static const struct drm_info_list pf_only_debugfs_list[] = { 118 123 { "guc_log", .show = guc_debugfs_show, .data = guc_log }, 119 124 { "guc_log_dmesg", .show = guc_debugfs_show, .data = guc_log_dmesg }, 120 - { "guc_pc", .show = guc_debugfs_show, .data = guc_pc }, 121 125 }; 122 126 123 127 void xe_guc_debugfs_register(struct xe_guc *guc, struct dentry *parent) 124 128 { 125 - struct drm_minor *minor = guc_to_xe(guc)->drm.primary; 129 + struct xe_device *xe = guc_to_xe(guc); 130 + struct drm_minor *minor = xe->drm.primary; 126 131 127 132 drm_debugfs_create_files(vf_safe_debugfs_list, 128 133 ARRAY_SIZE(vf_safe_debugfs_list), 129 134 parent, minor); 130 135 131 - if (!IS_SRIOV_VF(guc_to_xe(guc))) 136 + if (!IS_SRIOV_VF(xe)) { 132 137 drm_debugfs_create_files(pf_only_debugfs_list, 133 138 ARRAY_SIZE(pf_only_debugfs_list), 134 139 parent, minor); 140 + 141 + if (!xe->info.skip_guc_pc) 142 + drm_debugfs_create_files(slpc_debugfs_list, 143 + ARRAY_SIZE(slpc_debugfs_list), 144 + parent, minor); 145 + } 135 146 }