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

drm/xe/debugfs: Improve .show() helper for GT-based attributes

Like we did for tile-based attributes, introduce separate show()
helper that implicitly takes an RPM reference prior to the call
to the actual print() function. This translates into some savings.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://lore.kernel.org/r/20250919160430.573-3-michal.wajdeczko@intel.com

+46 -71
+45 -71
drivers/gpu/drm/xe/xe_gt_debugfs.c
··· 35 35 #include "xe_uc_debugfs.h" 36 36 #include "xe_wa.h" 37 37 38 + static struct xe_gt *node_to_gt(struct drm_info_node *node) 39 + { 40 + return node->dent->d_parent->d_inode->i_private; 41 + } 42 + 38 43 /** 39 44 * xe_gt_debugfs_simple_show - A show callback for struct drm_info_list 40 45 * @m: the &seq_file ··· 82 77 { 83 78 struct drm_printer p = drm_seq_file_printer(m); 84 79 struct drm_info_node *node = m->private; 85 - struct dentry *parent = node->dent->d_parent; 86 - struct xe_gt *gt = parent->d_inode->i_private; 80 + struct xe_gt *gt = node_to_gt(node); 87 81 int (*print)(struct xe_gt *, struct drm_printer *) = node->info_ent->data; 88 82 89 83 if (WARN_ON(!print)) ··· 91 87 return print(gt, &p); 92 88 } 93 89 90 + /** 91 + * xe_gt_debugfs_show_with_rpm - A show callback for struct drm_info_list 92 + * @m: the &seq_file 93 + * @data: data used by the drm debugfs helpers 94 + * 95 + * Similar to xe_gt_debugfs_simple_show() but implicitly takes a RPM ref. 96 + * 97 + * Return: 0 on success or a negative error code on failure. 98 + */ 99 + int xe_gt_debugfs_show_with_rpm(struct seq_file *m, void *data) 100 + { 101 + struct drm_info_node *node = m->private; 102 + struct xe_gt *gt = node_to_gt(node); 103 + struct xe_device *xe = gt_to_xe(gt); 104 + int ret; 105 + 106 + xe_pm_runtime_get(xe); 107 + ret = xe_gt_debugfs_simple_show(m, data); 108 + xe_pm_runtime_put(xe); 109 + 110 + return ret; 111 + } 112 + 94 113 static int hw_engines(struct xe_gt *gt, struct drm_printer *p) 95 114 { 96 - struct xe_device *xe = gt_to_xe(gt); 97 115 struct xe_hw_engine *hwe; 98 116 enum xe_hw_engine_id id; 99 117 unsigned int fw_ref; 100 118 int ret = 0; 101 119 102 - xe_pm_runtime_get(xe); 103 120 fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL); 104 121 if (!xe_force_wake_ref_has_domain(fw_ref, XE_FORCEWAKE_ALL)) { 105 122 ret = -ETIMEDOUT; ··· 132 107 133 108 fw_put: 134 109 xe_force_wake_put(gt_to_fw(gt), fw_ref); 135 - xe_pm_runtime_put(xe); 136 - 137 - return ret; 138 - } 139 - 140 - static int powergate_info(struct xe_gt *gt, struct drm_printer *p) 141 - { 142 - int ret; 143 - 144 - xe_pm_runtime_get(gt_to_xe(gt)); 145 - ret = xe_gt_idle_pg_print(gt, p); 146 - xe_pm_runtime_put(gt_to_xe(gt)); 147 110 148 111 return ret; 149 112 } 150 113 151 114 static int topology(struct xe_gt *gt, struct drm_printer *p) 152 115 { 153 - xe_pm_runtime_get(gt_to_xe(gt)); 154 116 xe_gt_topology_dump(gt, p); 155 - xe_pm_runtime_put(gt_to_xe(gt)); 156 - 157 117 return 0; 158 118 } 159 119 160 120 static int steering(struct xe_gt *gt, struct drm_printer *p) 161 121 { 162 - xe_pm_runtime_get(gt_to_xe(gt)); 163 122 xe_gt_mcr_steering_dump(gt, p); 164 - xe_pm_runtime_put(gt_to_xe(gt)); 165 - 166 123 return 0; 167 124 } 168 125 ··· 152 145 { 153 146 struct xe_hw_engine *hwe; 154 147 enum xe_hw_engine_id id; 155 - 156 - xe_pm_runtime_get(gt_to_xe(gt)); 157 148 158 149 xe_reg_sr_dump(&gt->reg_sr, p); 159 150 drm_printf(p, "\n"); ··· 170 165 for_each_hw_engine(hwe, gt, id) 171 166 xe_reg_whitelist_dump(&hwe->reg_whitelist, p); 172 167 173 - xe_pm_runtime_put(gt_to_xe(gt)); 174 - 175 168 return 0; 176 169 } 177 170 178 171 static int workarounds(struct xe_gt *gt, struct drm_printer *p) 179 172 { 180 - xe_pm_runtime_get(gt_to_xe(gt)); 181 173 xe_wa_dump(gt, p); 182 - xe_pm_runtime_put(gt_to_xe(gt)); 183 - 184 174 return 0; 185 175 } 186 176 187 177 static int tunings(struct xe_gt *gt, struct drm_printer *p) 188 178 { 189 - xe_pm_runtime_get(gt_to_xe(gt)); 190 179 xe_tuning_dump(gt, p); 191 - xe_pm_runtime_put(gt_to_xe(gt)); 192 - 193 180 return 0; 194 181 } 195 182 196 183 static int pat(struct xe_gt *gt, struct drm_printer *p) 197 184 { 198 - xe_pm_runtime_get(gt_to_xe(gt)); 199 185 xe_pat_dump(gt, p); 200 - xe_pm_runtime_put(gt_to_xe(gt)); 201 - 202 186 return 0; 203 187 } 204 188 205 189 static int mocs(struct xe_gt *gt, struct drm_printer *p) 206 190 { 207 - xe_pm_runtime_get(gt_to_xe(gt)); 208 191 xe_mocs_dump(gt, p); 209 - xe_pm_runtime_put(gt_to_xe(gt)); 210 - 211 192 return 0; 212 193 } 213 194 214 195 static int rcs_default_lrc(struct xe_gt *gt, struct drm_printer *p) 215 196 { 216 - xe_pm_runtime_get(gt_to_xe(gt)); 217 197 xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_RENDER); 218 - xe_pm_runtime_put(gt_to_xe(gt)); 219 - 220 198 return 0; 221 199 } 222 200 223 201 static int ccs_default_lrc(struct xe_gt *gt, struct drm_printer *p) 224 202 { 225 - xe_pm_runtime_get(gt_to_xe(gt)); 226 203 xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_COMPUTE); 227 - xe_pm_runtime_put(gt_to_xe(gt)); 228 - 229 204 return 0; 230 205 } 231 206 232 207 static int bcs_default_lrc(struct xe_gt *gt, struct drm_printer *p) 233 208 { 234 - xe_pm_runtime_get(gt_to_xe(gt)); 235 209 xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_COPY); 236 - xe_pm_runtime_put(gt_to_xe(gt)); 237 - 238 210 return 0; 239 211 } 240 212 241 213 static int vcs_default_lrc(struct xe_gt *gt, struct drm_printer *p) 242 214 { 243 - xe_pm_runtime_get(gt_to_xe(gt)); 244 215 xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_VIDEO_DECODE); 245 - xe_pm_runtime_put(gt_to_xe(gt)); 246 - 247 216 return 0; 248 217 } 249 218 250 219 static int vecs_default_lrc(struct xe_gt *gt, struct drm_printer *p) 251 220 { 252 - xe_pm_runtime_get(gt_to_xe(gt)); 253 221 xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_VIDEO_ENHANCE); 254 - xe_pm_runtime_put(gt_to_xe(gt)); 255 - 256 222 return 0; 257 223 } 258 224 259 225 static int hwconfig(struct xe_gt *gt, struct drm_printer *p) 260 226 { 261 - xe_pm_runtime_get(gt_to_xe(gt)); 262 227 xe_guc_hwconfig_dump(&gt->uc.guc, p); 263 - xe_pm_runtime_put(gt_to_xe(gt)); 264 - 265 228 return 0; 266 229 } 267 230 ··· 239 266 * - without access to the PF specific data 240 267 */ 241 268 static const struct drm_info_list vf_safe_debugfs_list[] = { 242 - {"topology", .show = xe_gt_debugfs_simple_show, .data = topology}, 243 - {"register-save-restore", .show = xe_gt_debugfs_simple_show, .data = register_save_restore}, 244 - {"workarounds", .show = xe_gt_debugfs_simple_show, .data = workarounds}, 245 - {"tunings", .show = xe_gt_debugfs_simple_show, .data = tunings}, 246 - {"default_lrc_rcs", .show = xe_gt_debugfs_simple_show, .data = rcs_default_lrc}, 247 - {"default_lrc_ccs", .show = xe_gt_debugfs_simple_show, .data = ccs_default_lrc}, 248 - {"default_lrc_bcs", .show = xe_gt_debugfs_simple_show, .data = bcs_default_lrc}, 249 - {"default_lrc_vcs", .show = xe_gt_debugfs_simple_show, .data = vcs_default_lrc}, 250 - {"default_lrc_vecs", .show = xe_gt_debugfs_simple_show, .data = vecs_default_lrc}, 251 - {"hwconfig", .show = xe_gt_debugfs_simple_show, .data = hwconfig}, 269 + { "topology", .show = xe_gt_debugfs_show_with_rpm, .data = topology }, 270 + { "register-save-restore", 271 + .show = xe_gt_debugfs_show_with_rpm, .data = register_save_restore }, 272 + { "workarounds", .show = xe_gt_debugfs_show_with_rpm, .data = workarounds }, 273 + { "tunings", .show = xe_gt_debugfs_show_with_rpm, .data = tunings }, 274 + { "default_lrc_rcs", .show = xe_gt_debugfs_show_with_rpm, .data = rcs_default_lrc }, 275 + { "default_lrc_ccs", .show = xe_gt_debugfs_show_with_rpm, .data = ccs_default_lrc }, 276 + { "default_lrc_bcs", .show = xe_gt_debugfs_show_with_rpm, .data = bcs_default_lrc }, 277 + { "default_lrc_vcs", .show = xe_gt_debugfs_show_with_rpm, .data = vcs_default_lrc }, 278 + { "default_lrc_vecs", .show = xe_gt_debugfs_show_with_rpm, .data = vecs_default_lrc }, 279 + { "hwconfig", .show = xe_gt_debugfs_show_with_rpm, .data = hwconfig }, 252 280 }; 253 281 254 282 /* everything else should be added here */ 255 283 static const struct drm_info_list pf_only_debugfs_list[] = { 256 - {"hw_engines", .show = xe_gt_debugfs_simple_show, .data = hw_engines}, 257 - {"mocs", .show = xe_gt_debugfs_simple_show, .data = mocs}, 258 - {"pat", .show = xe_gt_debugfs_simple_show, .data = pat}, 259 - {"powergate_info", .show = xe_gt_debugfs_simple_show, .data = powergate_info}, 260 - {"steering", .show = xe_gt_debugfs_simple_show, .data = steering}, 284 + { "hw_engines", .show = xe_gt_debugfs_show_with_rpm, .data = hw_engines }, 285 + { "mocs", .show = xe_gt_debugfs_show_with_rpm, .data = mocs }, 286 + { "pat", .show = xe_gt_debugfs_show_with_rpm, .data = pat }, 287 + { "powergate_info", .show = xe_gt_debugfs_show_with_rpm, .data = xe_gt_idle_pg_print }, 288 + { "steering", .show = xe_gt_debugfs_show_with_rpm, .data = steering }, 261 289 }; 262 290 263 291 static ssize_t write_to_gt_call(const char __user *userbuf, size_t count, loff_t *ppos,
+1
drivers/gpu/drm/xe/xe_gt_debugfs.h
··· 11 11 12 12 void xe_gt_debugfs_register(struct xe_gt *gt); 13 13 int xe_gt_debugfs_simple_show(struct seq_file *m, void *data); 14 + int xe_gt_debugfs_show_with_rpm(struct seq_file *m, void *data); 14 15 15 16 #endif