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 
14 void intel_rps_init_early(struct intel_rps *rps);
15 void intel_rps_init(struct intel_rps *rps);
16 void intel_rps_sanitize(struct intel_rps *rps);
17 
18 void intel_rps_driver_register(struct intel_rps *rps);
19 void intel_rps_driver_unregister(struct intel_rps *rps);
20 
21 void intel_rps_enable(struct intel_rps *rps);
22 void intel_rps_disable(struct intel_rps *rps);
23 
24 void intel_rps_park(struct intel_rps *rps);
25 void intel_rps_unpark(struct intel_rps *rps);
26 void intel_rps_boost(struct i915_request *rq);
27 void intel_rps_dec_waiters(struct intel_rps *rps);
28 u32 intel_rps_get_boost_frequency(struct intel_rps *rps);
29 int intel_rps_set_boost_frequency(struct intel_rps *rps, u32 freq);
30 
31 int intel_rps_set(struct intel_rps *rps, u8 val);
32 void intel_rps_mark_interactive(struct intel_rps *rps, bool interactive);
33 
34 int intel_gpu_freq(struct intel_rps *rps, int val);
35 int intel_freq_opcode(struct intel_rps *rps, int val);
36 u32 intel_rps_get_cagf(struct intel_rps *rps, u32 rpstat1);
37 u32 intel_rps_read_actual_frequency(struct intel_rps *rps);
38 u32 intel_rps_get_requested_frequency(struct intel_rps *rps);
39 u32 intel_rps_get_min_frequency(struct intel_rps *rps);
40 u32 intel_rps_get_min_raw_freq(struct intel_rps *rps);
41 int intel_rps_set_min_frequency(struct intel_rps *rps, u32 val);
42 u32 intel_rps_get_max_frequency(struct intel_rps *rps);
43 u32 intel_rps_get_max_raw_freq(struct intel_rps *rps);
44 int intel_rps_set_max_frequency(struct intel_rps *rps, u32 val);
45 u32 intel_rps_get_rp0_frequency(struct intel_rps *rps);
46 u32 intel_rps_get_rp1_frequency(struct intel_rps *rps);
47 u32 intel_rps_get_rpn_frequency(struct intel_rps *rps);
48 u32 intel_rps_read_punit_req(struct intel_rps *rps);
49 u32 intel_rps_read_punit_req_frequency(struct intel_rps *rps);
50 void gen6_rps_get_freq_caps(struct intel_rps *rps, struct intel_rps_freq_caps *caps);
51 void intel_rps_raise_unslice(struct intel_rps *rps);
52 void intel_rps_lower_unslice(struct intel_rps *rps);
53 
54 u32 intel_rps_read_throttle_reason(struct intel_rps *rps);
55 bool rps_read_mask_mmio(struct intel_rps *rps, i915_reg_t reg32, u32 mask);
56 
57 void gen5_rps_irq_handler(struct intel_rps *rps);
58 void gen6_rps_irq_handler(struct intel_rps *rps, u32 pm_iir);
59 void gen11_rps_irq_handler(struct intel_rps *rps, u32 pm_iir);
60 
intel_rps_is_enabled(const struct intel_rps * rps)61 static inline bool intel_rps_is_enabled(const struct intel_rps *rps)
62 {
63 	return test_bit(INTEL_RPS_ENABLED, &rps->flags);
64 }
65 
intel_rps_set_enabled(struct intel_rps * rps)66 static inline void intel_rps_set_enabled(struct intel_rps *rps)
67 {
68 	set_bit(INTEL_RPS_ENABLED, &rps->flags);
69 }
70 
intel_rps_clear_enabled(struct intel_rps * rps)71 static inline void intel_rps_clear_enabled(struct intel_rps *rps)
72 {
73 	clear_bit(INTEL_RPS_ENABLED, &rps->flags);
74 }
75 
intel_rps_is_active(const struct intel_rps * rps)76 static inline bool intel_rps_is_active(const struct intel_rps *rps)
77 {
78 	return test_bit(INTEL_RPS_ACTIVE, &rps->flags);
79 }
80 
intel_rps_set_active(struct intel_rps * rps)81 static inline void intel_rps_set_active(struct intel_rps *rps)
82 {
83 	set_bit(INTEL_RPS_ACTIVE, &rps->flags);
84 }
85 
intel_rps_clear_active(struct intel_rps * rps)86 static inline bool intel_rps_clear_active(struct intel_rps *rps)
87 {
88 	return test_and_clear_bit(INTEL_RPS_ACTIVE, &rps->flags);
89 }
90 
intel_rps_has_interrupts(const struct intel_rps * rps)91 static inline bool intel_rps_has_interrupts(const struct intel_rps *rps)
92 {
93 	return test_bit(INTEL_RPS_INTERRUPTS, &rps->flags);
94 }
95 
intel_rps_set_interrupts(struct intel_rps * rps)96 static inline void intel_rps_set_interrupts(struct intel_rps *rps)
97 {
98 	set_bit(INTEL_RPS_INTERRUPTS, &rps->flags);
99 }
100 
intel_rps_clear_interrupts(struct intel_rps * rps)101 static inline void intel_rps_clear_interrupts(struct intel_rps *rps)
102 {
103 	clear_bit(INTEL_RPS_INTERRUPTS, &rps->flags);
104 }
105 
intel_rps_uses_timer(const struct intel_rps * rps)106 static inline bool intel_rps_uses_timer(const struct intel_rps *rps)
107 {
108 	return test_bit(INTEL_RPS_TIMER, &rps->flags);
109 }
110 
intel_rps_set_timer(struct intel_rps * rps)111 static inline void intel_rps_set_timer(struct intel_rps *rps)
112 {
113 	set_bit(INTEL_RPS_TIMER, &rps->flags);
114 }
115 
intel_rps_clear_timer(struct intel_rps * rps)116 static inline void intel_rps_clear_timer(struct intel_rps *rps)
117 {
118 	clear_bit(INTEL_RPS_TIMER, &rps->flags);
119 }
120 
121 #endif /* INTEL_RPS_H */
122