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