xref: /openbmc/linux/drivers/gpu/drm/i915/gt/intel_rps.h (revision e847c767)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2019 Intel Corporation
4  */
5 
6 #ifndef INTEL_RPS_H
7 #define INTEL_RPS_H
8 
9 #include "intel_rps_types.h"
10 #include "i915_reg_defs.h"
11 
12 struct i915_request;
13 struct drm_printer;
14 
15 #define GT_FREQUENCY_MULTIPLIER 50
16 #define GEN9_FREQ_SCALER 3
17 
18 void intel_rps_init_early(struct intel_rps *rps);
19 void intel_rps_init(struct intel_rps *rps);
20 void intel_rps_sanitize(struct intel_rps *rps);
21 
22 void intel_rps_driver_register(struct intel_rps *rps);
23 void intel_rps_driver_unregister(struct intel_rps *rps);
24 
25 void intel_rps_enable(struct intel_rps *rps);
26 void intel_rps_disable(struct intel_rps *rps);
27 
28 void intel_rps_park(struct intel_rps *rps);
29 void intel_rps_unpark(struct intel_rps *rps);
30 void intel_rps_boost(struct i915_request *rq);
31 void intel_rps_dec_waiters(struct intel_rps *rps);
32 u32 intel_rps_get_boost_frequency(struct intel_rps *rps);
33 int intel_rps_set_boost_frequency(struct intel_rps *rps, u32 freq);
34 
35 int intel_rps_set(struct intel_rps *rps, u8 val);
36 void intel_rps_mark_interactive(struct intel_rps *rps, bool interactive);
37 
38 int intel_gpu_freq(struct intel_rps *rps, int val);
39 int intel_freq_opcode(struct intel_rps *rps, int val);
40 u32 intel_rps_read_actual_frequency(struct intel_rps *rps);
41 u32 intel_rps_read_actual_frequency_fw(struct intel_rps *rps);
42 u32 intel_rps_get_requested_frequency(struct intel_rps *rps);
43 u32 intel_rps_get_min_frequency(struct intel_rps *rps);
44 u32 intel_rps_get_min_raw_freq(struct intel_rps *rps);
45 int intel_rps_set_min_frequency(struct intel_rps *rps, u32 val);
46 u32 intel_rps_get_max_frequency(struct intel_rps *rps);
47 u32 intel_rps_get_max_raw_freq(struct intel_rps *rps);
48 int intel_rps_set_max_frequency(struct intel_rps *rps, u32 val);
49 u32 intel_rps_get_rp0_frequency(struct intel_rps *rps);
50 u32 intel_rps_get_rp1_frequency(struct intel_rps *rps);
51 u32 intel_rps_get_rpn_frequency(struct intel_rps *rps);
52 u32 intel_rps_read_punit_req_frequency(struct intel_rps *rps);
53 u32 intel_rps_read_rpstat(struct intel_rps *rps);
54 void gen6_rps_get_freq_caps(struct intel_rps *rps, struct intel_rps_freq_caps *caps);
55 void intel_rps_raise_unslice(struct intel_rps *rps);
56 void intel_rps_lower_unslice(struct intel_rps *rps);
57 
58 u32 intel_rps_read_throttle_reason(struct intel_rps *rps);
59 bool rps_read_mask_mmio(struct intel_rps *rps, i915_reg_t reg32, u32 mask);
60 
61 void gen6_rps_frequency_dump(struct intel_rps *rps, struct drm_printer *p);
62 
63 void gen5_rps_irq_handler(struct intel_rps *rps);
64 void gen6_rps_irq_handler(struct intel_rps *rps, u32 pm_iir);
65 void gen11_rps_irq_handler(struct intel_rps *rps, u32 pm_iir);
66 
67 static inline bool intel_rps_is_enabled(const struct intel_rps *rps)
68 {
69 	return test_bit(INTEL_RPS_ENABLED, &rps->flags);
70 }
71 
72 static inline void intel_rps_set_enabled(struct intel_rps *rps)
73 {
74 	set_bit(INTEL_RPS_ENABLED, &rps->flags);
75 }
76 
77 static inline void intel_rps_clear_enabled(struct intel_rps *rps)
78 {
79 	clear_bit(INTEL_RPS_ENABLED, &rps->flags);
80 }
81 
82 static inline bool intel_rps_is_active(const struct intel_rps *rps)
83 {
84 	return test_bit(INTEL_RPS_ACTIVE, &rps->flags);
85 }
86 
87 static inline void intel_rps_set_active(struct intel_rps *rps)
88 {
89 	set_bit(INTEL_RPS_ACTIVE, &rps->flags);
90 }
91 
92 static inline bool intel_rps_clear_active(struct intel_rps *rps)
93 {
94 	return test_and_clear_bit(INTEL_RPS_ACTIVE, &rps->flags);
95 }
96 
97 static inline bool intel_rps_has_interrupts(const struct intel_rps *rps)
98 {
99 	return test_bit(INTEL_RPS_INTERRUPTS, &rps->flags);
100 }
101 
102 static inline void intel_rps_set_interrupts(struct intel_rps *rps)
103 {
104 	set_bit(INTEL_RPS_INTERRUPTS, &rps->flags);
105 }
106 
107 static inline void intel_rps_clear_interrupts(struct intel_rps *rps)
108 {
109 	clear_bit(INTEL_RPS_INTERRUPTS, &rps->flags);
110 }
111 
112 static inline bool intel_rps_uses_timer(const struct intel_rps *rps)
113 {
114 	return test_bit(INTEL_RPS_TIMER, &rps->flags);
115 }
116 
117 static inline void intel_rps_set_timer(struct intel_rps *rps)
118 {
119 	set_bit(INTEL_RPS_TIMER, &rps->flags);
120 }
121 
122 static inline void intel_rps_clear_timer(struct intel_rps *rps)
123 {
124 	clear_bit(INTEL_RPS_TIMER, &rps->flags);
125 }
126 
127 #endif /* INTEL_RPS_H */
128