• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2019 Intel Corporation
4  */
5 
6 #ifndef INTEL_RPS_TYPES_H
7 #define INTEL_RPS_TYPES_H
8 
9 #include <linux/atomic.h>
10 #include <linux/ktime.h>
11 #include <linux/mutex.h>
12 #include <linux/types.h>
13 #include <linux/workqueue.h>
14 
15 struct intel_ips {
16 	u64 last_count1;
17 	unsigned long last_time1;
18 	unsigned long chipset_power;
19 	u64 last_count2;
20 	u64 last_time2;
21 	unsigned long gfx_power;
22 	u8 corr;
23 
24 	int c, m;
25 };
26 
27 struct intel_rps_ei {
28 	ktime_t ktime;
29 	u32 render_c0;
30 	u32 media_c0;
31 };
32 
33 enum {
34 	INTEL_RPS_ENABLED = 0,
35 	INTEL_RPS_ACTIVE,
36 	INTEL_RPS_INTERRUPTS,
37 	INTEL_RPS_TIMER,
38 };
39 
40 struct intel_rps {
41 	struct mutex lock; /* protects enabling and the worker */
42 
43 	/*
44 	 * work, interrupts_enabled and pm_iir are protected by
45 	 * dev_priv->irq_lock
46 	 */
47 	struct timer_list timer;
48 	struct work_struct work;
49 	unsigned long flags;
50 
51 	ktime_t pm_timestamp;
52 	u32 pm_interval;
53 	u32 pm_iir;
54 
55 	/* PM interrupt bits that should never be masked */
56 	u32 pm_intrmsk_mbz;
57 	u32 pm_events;
58 
59 	/* Frequencies are stored in potentially platform dependent multiples.
60 	 * In other words, *_freq needs to be multiplied by X to be interesting.
61 	 * Soft limits are those which are used for the dynamic reclocking done
62 	 * by the driver (raise frequencies under heavy loads, and lower for
63 	 * lighter loads). Hard limits are those imposed by the hardware.
64 	 *
65 	 * A distinction is made for overclocking, which is never enabled by
66 	 * default, and is considered to be above the hard limit if it's
67 	 * possible at all.
68 	 */
69 	u8 cur_freq;		/* Current frequency (cached, may not == HW) */
70 	u8 last_freq;		/* Last SWREQ frequency */
71 	u8 min_freq_softlimit;	/* Minimum frequency permitted by the driver */
72 	u8 max_freq_softlimit;	/* Max frequency permitted by the driver */
73 	u8 max_freq;		/* Maximum frequency, RP0 if not overclocking */
74 	u8 min_freq;		/* AKA RPn. Minimum frequency */
75 	u8 boost_freq;		/* Frequency to request when wait boosting */
76 	u8 idle_freq;		/* Frequency to request when we are idle */
77 	u8 efficient_freq;	/* AKA RPe. Pre-determined balanced frequency */
78 	u8 rp1_freq;		/* "less than" RP0 power/freqency */
79 	u8 rp0_freq;		/* Non-overclocked max frequency. */
80 	u16 gpll_ref_freq;	/* vlv/chv GPLL reference frequency */
81 
82 	int last_adj;
83 
84 	struct {
85 		struct mutex mutex;
86 
87 		enum { LOW_POWER, BETWEEN, HIGH_POWER } mode;
88 		unsigned int interactive;
89 
90 		u8 up_threshold; /* Current %busy required to uplock */
91 		u8 down_threshold; /* Current %busy required to downclock */
92 	} power;
93 
94 	atomic_t num_waiters;
95 	unsigned int boosts;
96 
97 	/* manual wa residency calculations */
98 	struct intel_rps_ei ei;
99 	struct intel_ips ips;
100 };
101 
102 #endif /* INTEL_RPS_TYPES_H */
103