summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/linux/clk_arb_linux.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/clk_arb_linux.h')
-rw-r--r--drivers/gpu/nvgpu/common/linux/clk_arb_linux.h120
1 files changed, 120 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/clk_arb_linux.h b/drivers/gpu/nvgpu/common/linux/clk_arb_linux.h
new file mode 100644
index 00000000..b66876da
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/linux/clk_arb_linux.h
@@ -0,0 +1,120 @@
1/*
2 * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef __NVGPU_CLK_ARB_LINUX_H__
18#define __NVGPU_CLK_ARB_LINUX_H__
19
20#include <nvgpu/types.h>
21#include <nvgpu/bitops.h>
22#include <nvgpu/lock.h>
23#include <nvgpu/kmem.h>
24#include <nvgpu/atomic.h>
25#include <nvgpu/bug.h>
26#include <nvgpu/kref.h>
27#include <nvgpu/log.h>
28#include <nvgpu/barrier.h>
29#include <nvgpu/cond.h>
30
31#include "gk20a/gk20a.h"
32#include "clk/clk.h"
33#include "pstate/pstate.h"
34#include "lpwr/lpwr.h"
35#include "volt/volt.h"
36
37/*
38 * The defines here should finally move to clk_arb.h, once these are
39 * refactored to be free of Linux fields.
40 */
41struct nvgpu_clk_arb {
42 struct nvgpu_spinlock sessions_lock;
43 struct nvgpu_spinlock users_lock;
44
45 struct nvgpu_mutex pstate_lock;
46 struct list_head users;
47 struct list_head sessions;
48 struct llist_head requests;
49
50 struct gk20a *g;
51 int status;
52
53 struct nvgpu_clk_arb_target actual_pool[2];
54 struct nvgpu_clk_arb_target *actual;
55
56 u16 gpc2clk_default_mhz;
57 u16 mclk_default_mhz;
58 u32 voltuv_actual;
59
60 u16 gpc2clk_min, gpc2clk_max;
61 u16 mclk_min, mclk_max;
62
63 struct work_struct update_fn_work;
64 struct workqueue_struct *update_work_queue;
65 struct work_struct vf_table_fn_work;
66 struct workqueue_struct *vf_table_work_queue;
67
68 struct nvgpu_cond request_wq;
69
70 struct nvgpu_clk_vf_table *current_vf_table;
71 struct nvgpu_clk_vf_table vf_table_pool[2];
72 u32 vf_table_index;
73
74 u16 *mclk_f_points;
75 nvgpu_atomic_t req_nr;
76
77 u32 mclk_f_numpoints;
78 u16 *gpc2clk_f_points;
79 u32 gpc2clk_f_numpoints;
80
81 nvgpu_atomic64_t alarm_mask;
82 struct nvgpu_clk_notification_queue notification_queue;
83
84#ifdef CONFIG_DEBUG_FS
85 struct nvgpu_clk_arb_debug debug_pool[2];
86 struct nvgpu_clk_arb_debug *debug;
87 bool debugfs_set;
88#endif
89};
90
91struct nvgpu_clk_dev {
92 struct nvgpu_clk_session *session;
93 union {
94 struct list_head link;
95 struct llist_node node;
96 };
97 struct nvgpu_cond readout_wq;
98 nvgpu_atomic_t poll_mask;
99 u16 gpc2clk_target_mhz;
100 u16 mclk_target_mhz;
101 u32 alarms_reported;
102 nvgpu_atomic_t enabled_mask;
103 struct nvgpu_clk_notification_queue queue;
104 u32 arb_queue_head;
105 struct nvgpu_ref refcount;
106};
107
108struct nvgpu_clk_session {
109 bool zombie;
110 struct gk20a *g;
111 struct nvgpu_ref refcount;
112 struct list_head link;
113 struct llist_head targets;
114
115 struct nvgpu_clk_arb_target target_pool[2];
116 struct nvgpu_clk_arb_target *target;
117};
118
119#endif /* __NVGPU_CLK_ARB_LINUX_H__ */
120