@@ -940,11 +940,20 @@ static const struct attribute_group i915_pmu_cpumask_attr_group = {
940
940
.attrs = i915_cpumask_attrs ,
941
941
};
942
942
943
- #define __event (__config , __name , __unit ) \
943
+ #define __event (__counter , __name , __unit ) \
944
944
{ \
945
- .config = (__config ), \
945
+ .counter = (__counter ), \
946
946
.name = (__name), \
947
947
.unit = (__unit), \
948
+ .global = false, \
949
+ }
950
+
951
+ #define __global_event (__counter , __name , __unit ) \
952
+ { \
953
+ .counter = (__counter), \
954
+ .name = (__name), \
955
+ .unit = (__unit), \
956
+ .global = true, \
948
957
}
949
958
950
959
#define __engine_event (__sample , __name ) \
@@ -983,15 +992,16 @@ create_event_attributes(struct i915_pmu *pmu)
983
992
{
984
993
struct drm_i915_private * i915 = container_of (pmu , typeof (* i915 ), pmu );
985
994
static const struct {
986
- u64 config ;
995
+ unsigned int counter ;
987
996
const char * name ;
988
997
const char * unit ;
998
+ bool global ;
989
999
} events [] = {
990
- __event (I915_PMU_ACTUAL_FREQUENCY , "actual-frequency" , "M" ),
991
- __event (I915_PMU_REQUESTED_FREQUENCY , "requested-frequency" , "M" ),
992
- __event ( I915_PMU_INTERRUPTS , "interrupts" , NULL ),
993
- __event (I915_PMU_RC6_RESIDENCY , "rc6-residency" , "ns" ),
994
- __event (I915_PMU_SOFTWARE_GT_AWAKE_TIME , "software-gt-awake-time" , "ns" ),
1000
+ __event (0 , "actual-frequency" , "M" ),
1001
+ __event (1 , "requested-frequency" , "M" ),
1002
+ __global_event ( 2 , "interrupts" , NULL ),
1003
+ __event (3 , "rc6-residency" , "ns" ),
1004
+ __event (4 , "software-gt-awake-time" , "ns" ),
995
1005
};
996
1006
static const struct {
997
1007
enum drm_i915_pmu_engine_sample sample ;
@@ -1006,12 +1016,17 @@ create_event_attributes(struct i915_pmu *pmu)
1006
1016
struct i915_ext_attribute * i915_attr = NULL , * i915_iter ;
1007
1017
struct attribute * * attr = NULL , * * attr_iter ;
1008
1018
struct intel_engine_cs * engine ;
1009
- unsigned int i ;
1019
+ struct intel_gt * gt ;
1020
+ unsigned int i , j ;
1010
1021
1011
1022
/* Count how many counters we will be exposing. */
1012
- for (i = 0 ; i < ARRAY_SIZE (events ); i ++ ) {
1013
- if (!config_status (i915 , events [i ].config ))
1014
- count ++ ;
1023
+ for_each_gt (gt , i915 , j ) {
1024
+ for (i = 0 ; i < ARRAY_SIZE (events ); i ++ ) {
1025
+ u64 config = ___I915_PMU_OTHER (j , events [i ].counter );
1026
+
1027
+ if (!config_status (i915 , config ))
1028
+ count ++ ;
1029
+ }
1015
1030
}
1016
1031
1017
1032
for_each_uabi_engine (engine , i915 ) {
@@ -1041,26 +1056,39 @@ create_event_attributes(struct i915_pmu *pmu)
1041
1056
attr_iter = attr ;
1042
1057
1043
1058
/* Initialize supported non-engine counters. */
1044
- for (i = 0 ; i < ARRAY_SIZE (events ); i ++ ) {
1045
- char * str ;
1046
-
1047
- if (config_status (i915 , events [i ].config ))
1048
- continue ;
1049
-
1050
- str = kstrdup (events [i ].name , GFP_KERNEL );
1051
- if (!str )
1052
- goto err ;
1059
+ for_each_gt (gt , i915 , j ) {
1060
+ for (i = 0 ; i < ARRAY_SIZE (events ); i ++ ) {
1061
+ u64 config = ___I915_PMU_OTHER (j , events [i ].counter );
1062
+ char * str ;
1053
1063
1054
- * attr_iter ++ = & i915_iter -> attr . attr ;
1055
- i915_iter = add_i915_attr ( i915_iter , str , events [ i ]. config ) ;
1064
+ if ( config_status ( i915 , config ))
1065
+ continue ;
1056
1066
1057
- if (events [i ].unit ) {
1058
- str = kasprintf (GFP_KERNEL , "%s.unit" , events [i ].name );
1067
+ if (events [i ].global || !HAS_EXTRA_GT_LIST (i915 ))
1068
+ str = kstrdup (events [i ].name , GFP_KERNEL );
1069
+ else
1070
+ str = kasprintf (GFP_KERNEL , "%s-gt%u" ,
1071
+ events [i ].name , j );
1059
1072
if (!str )
1060
1073
goto err ;
1061
1074
1062
- * attr_iter ++ = & pmu_iter -> attr .attr ;
1063
- pmu_iter = add_pmu_attr (pmu_iter , str , events [i ].unit );
1075
+ * attr_iter ++ = & i915_iter -> attr .attr ;
1076
+ i915_iter = add_i915_attr (i915_iter , str , config );
1077
+
1078
+ if (events [i ].unit ) {
1079
+ if (events [i ].global || !HAS_EXTRA_GT_LIST (i915 ))
1080
+ str = kasprintf (GFP_KERNEL , "%s.unit" ,
1081
+ events [i ].name );
1082
+ else
1083
+ str = kasprintf (GFP_KERNEL , "%s-gt%u.unit" ,
1084
+ events [i ].name , j );
1085
+ if (!str )
1086
+ goto err ;
1087
+
1088
+ * attr_iter ++ = & pmu_iter -> attr .attr ;
1089
+ pmu_iter = add_pmu_attr (pmu_iter , str ,
1090
+ events [i ].unit );
1091
+ }
1064
1092
}
1065
1093
}
1066
1094
0 commit comments