2 * SPDX-License-Identifier: MIT
4 * Copyright © 2017-2018 Intel Corporation
10 #include <linux/hrtimer.h>
11 #include <linux/perf_event.h>
12 #include <linux/spinlock_types.h>
13 #include <uapi/drm/i915_drm.h>
15 struct drm_i915_private
;
18 __I915_SAMPLE_FREQ_ACT
= 0,
19 __I915_SAMPLE_FREQ_REQ
,
21 __I915_SAMPLE_RC6_LAST_REPORTED
,
22 __I915_NUM_PMU_SAMPLERS
26 * How many different events we track in the global PMU mask.
28 * It is also used to know to needed number of event reference counters.
30 #define I915_PMU_MASK_BITS \
31 ((1 << I915_PMU_SAMPLE_BITS) + \
32 (I915_PMU_LAST + 1 - __I915_PMU_OTHER(0)))
34 #define I915_ENGINE_SAMPLE_COUNT (I915_SAMPLE_SEMA + 1)
36 struct i915_pmu_sample
{
42 * @cpuhp: Struct used for CPU hotplug handling.
45 struct hlist_node node
;
46 enum cpuhp_state slot
;
53 * @name: Name as registered with perf core.
57 * @lock: Lock protecting enable mask and ref count handling.
61 * @timer: Timer for internal i915 PMU sampling.
65 * @enable: Bitmask of all currently enabled events.
67 * Bits are derived from uAPI event numbers in a way that low 16 bits
68 * correspond to engine event _sample_ _type_ (I915_SAMPLE_QUEUED is
69 * bit 0), and higher bits correspond to other events (for instance
70 * I915_PMU_ACTUAL_FREQUENCY is bit 16 etc).
72 * In other words, low 16 bits are not per engine but per engine
73 * sampler type, while the upper bits are directly mapped to other
81 * Timestmap of the previous timer invocation.
86 * @enable_count: Reference counts for the enabled events.
88 * Array indices are mapped in the same way as bits in the @enable field
89 * and they are used to control sampling on/off when multiple clients
90 * are using the PMU API.
92 unsigned int enable_count
[I915_PMU_MASK_BITS
];
94 * @timer_enabled: Should the internal sampling timer be running.
98 * @sample: Current and previous (raw) counters for sampling events.
100 * These counters are updated from the i915 PMU sampling timer.
102 * Only global counters are held here, while the per-engine ones are in
103 * struct intel_engine_cs.
105 struct i915_pmu_sample sample
[__I915_NUM_PMU_SAMPLERS
];
107 * @sleep_last: Last time GT parked for RC6 estimation.
111 * @events_attr_group: Device events attribute group.
113 struct attribute_group events_attr_group
;
115 * @i915_attr: Memory block holding device attributes.
119 * @pmu_attr: Memory block holding device attributes.
124 #ifdef CONFIG_PERF_EVENTS
125 void i915_pmu_register(struct drm_i915_private
*i915
);
126 void i915_pmu_unregister(struct drm_i915_private
*i915
);
127 void i915_pmu_gt_parked(struct drm_i915_private
*i915
);
128 void i915_pmu_gt_unparked(struct drm_i915_private
*i915
);
130 static inline void i915_pmu_register(struct drm_i915_private
*i915
) {}
131 static inline void i915_pmu_unregister(struct drm_i915_private
*i915
) {}
132 static inline void i915_pmu_gt_parked(struct drm_i915_private
*i915
) {}
133 static inline void i915_pmu_gt_unparked(struct drm_i915_private
*i915
) {}