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

drm/xe: Make read_perf_limit_reasons globally accessible

Other driver code beyond the sysfs interface wants to know about
throttling. So make the query function globally accessible.

v2: Revert include order change (review feedback from Lucas)
v3: Remove '_sysfs' from throttle file names and keep limit query in
the same file rather than moving elsewhere (review feedback from
Rodrigo).
v4: Correct #include while renaming header file (review feedback
from Lucas).

Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240518043700.3264362-2-John.C.Harrison@Intel.com

+33 -29
+1 -1
drivers/gpu/drm/xe/Makefile
··· 89 89 xe_gt_mcr.o \ 90 90 xe_gt_pagefault.o \ 91 91 xe_gt_sysfs.o \ 92 - xe_gt_throttle_sysfs.o \ 92 + xe_gt_throttle.o \ 93 93 xe_gt_tlb_invalidation.o \ 94 94 xe_gt_topology.o \ 95 95 xe_guc.o \
+2 -2
drivers/gpu/drm/xe/xe_gt_freq.c
··· 13 13 14 14 #include "xe_device_types.h" 15 15 #include "xe_gt_sysfs.h" 16 - #include "xe_gt_throttle_sysfs.h" 16 + #include "xe_gt_throttle.h" 17 17 #include "xe_guc_pc.h" 18 18 #include "xe_pm.h" 19 19 ··· 245 245 if (err) 246 246 return err; 247 247 248 - return xe_gt_throttle_sysfs_init(gt); 248 + return xe_gt_throttle_init(gt); 249 249 }
+17
drivers/gpu/drm/xe/xe_gt_throttle.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* 3 + * Copyright © 2023 Intel Corporation 4 + */ 5 + 6 + #ifndef _XE_GT_THROTTLE_H_ 7 + #define _XE_GT_THROTTLE_H_ 8 + 9 + #include <linux/types.h> 10 + 11 + struct xe_gt; 12 + 13 + int xe_gt_throttle_init(struct xe_gt *gt); 14 + 15 + u32 xe_gt_throttle_get_limit_reasons(struct xe_gt *gt); 16 + 17 + #endif /* _XE_GT_THROTTLE_H_ */
+13 -13
drivers/gpu/drm/xe/xe_gt_throttle_sysfs.c drivers/gpu/drm/xe/xe_gt_throttle.c
··· 9 9 #include "xe_device.h" 10 10 #include "xe_gt.h" 11 11 #include "xe_gt_sysfs.h" 12 - #include "xe_gt_throttle_sysfs.h" 12 + #include "xe_gt_throttle.h" 13 13 #include "xe_mmio.h" 14 14 #include "xe_pm.h" 15 15 16 16 /** 17 17 * DOC: Xe GT Throttle 18 18 * 19 - * Provides sysfs entries for frequency throttle reasons in GT 19 + * Provides sysfs entries and other helpers for frequency throttle reasons in GT 20 20 * 21 21 * device/gt#/freq0/throttle/status - Overall status 22 22 * device/gt#/freq0/throttle/reason_pl1 - Frequency throttle due to PL1 ··· 35 35 return kobj_to_gt(dev->kobj.parent); 36 36 } 37 37 38 - static u32 read_perf_limit_reasons(struct xe_gt *gt) 38 + u32 xe_gt_throttle_get_limit_reasons(struct xe_gt *gt) 39 39 { 40 40 u32 reg; 41 41 ··· 51 51 52 52 static u32 read_status(struct xe_gt *gt) 53 53 { 54 - u32 status = read_perf_limit_reasons(gt) & GT0_PERF_LIMIT_REASONS_MASK; 54 + u32 status = xe_gt_throttle_get_limit_reasons(gt) & GT0_PERF_LIMIT_REASONS_MASK; 55 55 56 56 return status; 57 57 } 58 58 59 59 static u32 read_reason_pl1(struct xe_gt *gt) 60 60 { 61 - u32 pl1 = read_perf_limit_reasons(gt) & POWER_LIMIT_1_MASK; 61 + u32 pl1 = xe_gt_throttle_get_limit_reasons(gt) & POWER_LIMIT_1_MASK; 62 62 63 63 return pl1; 64 64 } 65 65 66 66 static u32 read_reason_pl2(struct xe_gt *gt) 67 67 { 68 - u32 pl2 = read_perf_limit_reasons(gt) & POWER_LIMIT_2_MASK; 68 + u32 pl2 = xe_gt_throttle_get_limit_reasons(gt) & POWER_LIMIT_2_MASK; 69 69 70 70 return pl2; 71 71 } 72 72 73 73 static u32 read_reason_pl4(struct xe_gt *gt) 74 74 { 75 - u32 pl4 = read_perf_limit_reasons(gt) & POWER_LIMIT_4_MASK; 75 + u32 pl4 = xe_gt_throttle_get_limit_reasons(gt) & POWER_LIMIT_4_MASK; 76 76 77 77 return pl4; 78 78 } 79 79 80 80 static u32 read_reason_thermal(struct xe_gt *gt) 81 81 { 82 - u32 thermal = read_perf_limit_reasons(gt) & THERMAL_LIMIT_MASK; 82 + u32 thermal = xe_gt_throttle_get_limit_reasons(gt) & THERMAL_LIMIT_MASK; 83 83 84 84 return thermal; 85 85 } 86 86 87 87 static u32 read_reason_prochot(struct xe_gt *gt) 88 88 { 89 - u32 prochot = read_perf_limit_reasons(gt) & PROCHOT_MASK; 89 + u32 prochot = xe_gt_throttle_get_limit_reasons(gt) & PROCHOT_MASK; 90 90 91 91 return prochot; 92 92 } 93 93 94 94 static u32 read_reason_ratl(struct xe_gt *gt) 95 95 { 96 - u32 ratl = read_perf_limit_reasons(gt) & RATL_MASK; 96 + u32 ratl = xe_gt_throttle_get_limit_reasons(gt) & RATL_MASK; 97 97 98 98 return ratl; 99 99 } 100 100 101 101 static u32 read_reason_vr_thermalert(struct xe_gt *gt) 102 102 { 103 - u32 thermalert = read_perf_limit_reasons(gt) & VR_THERMALERT_MASK; 103 + u32 thermalert = xe_gt_throttle_get_limit_reasons(gt) & VR_THERMALERT_MASK; 104 104 105 105 return thermalert; 106 106 } 107 107 108 108 static u32 read_reason_vr_tdc(struct xe_gt *gt) 109 109 { 110 - u32 tdc = read_perf_limit_reasons(gt) & VR_TDC_MASK; 110 + u32 tdc = xe_gt_throttle_get_limit_reasons(gt) & VR_TDC_MASK; 111 111 112 112 return tdc; 113 113 } ··· 236 236 sysfs_remove_group(gt->freq, &throttle_group_attrs); 237 237 } 238 238 239 - int xe_gt_throttle_sysfs_init(struct xe_gt *gt) 239 + int xe_gt_throttle_init(struct xe_gt *gt) 240 240 { 241 241 struct xe_device *xe = gt_to_xe(gt); 242 242 int err;
-13
drivers/gpu/drm/xe/xe_gt_throttle_sysfs.h
··· 1 - /* SPDX-License-Identifier: MIT */ 2 - /* 3 - * Copyright © 2023 Intel Corporation 4 - */ 5 - 6 - #ifndef _XE_GT_THROTTLE_SYSFS_H_ 7 - #define _XE_GT_THROTTLE_SYSFS_H_ 8 - 9 - struct xe_gt; 10 - 11 - int xe_gt_throttle_sysfs_init(struct xe_gt *gt); 12 - 13 - #endif