summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/include
diff options
context:
space:
mode:
authorSourab Gupta <sourabg@nvidia.com>2018-05-04 02:13:33 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-05-18 02:34:32 -0400
commitfc3ac7d2ae2c7cb856fff58af77bb8d453ff5473 (patch)
tree412d3ebe84b7ba469b6ff4d49936c4d4b8920c18 /drivers/gpu/nvgpu/include
parent6a43e51ee362bbf61ca35cda75f31ed3f01862ed (diff)
gpu: nvgpu: move clk_arb.c to common code
Now that clk_arb.c is free of Linux'isms, move it to the clk/ directory. Jira VQRM-741 Change-Id: I53298c76f834322aa586781cdfd2e6031f4826a1 Signed-off-by: Sourab Gupta <sourabg@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1709651 GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/include')
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/clk_arb.h120
1 files changed, 120 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/clk_arb.h b/drivers/gpu/nvgpu/include/nvgpu/clk_arb.h
index a5f8a7d5..c9a32cf1 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/clk_arb.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/clk_arb.h
@@ -151,6 +151,126 @@ struct nvgpu_clk_arb_target {
151 u32 pstate; 151 u32 pstate;
152}; 152};
153 153
154enum clk_arb_work_item_type {
155 CLK_ARB_WORK_UPDATE_VF_TABLE,
156 CLK_ARB_WORK_UPDATE_ARB
157};
158
159struct nvgpu_clk_arb_work_item {
160 enum clk_arb_work_item_type item_type;
161 struct nvgpu_clk_arb *arb;
162 struct nvgpu_list_node worker_item;
163};
164
165struct nvgpu_clk_arb {
166 struct nvgpu_spinlock sessions_lock;
167 struct nvgpu_spinlock users_lock;
168 struct nvgpu_spinlock requests_lock;
169
170 struct nvgpu_mutex pstate_lock;
171 struct nvgpu_list_node users;
172 struct nvgpu_list_node sessions;
173 struct nvgpu_list_node requests;
174
175 struct gk20a *g;
176 int status;
177
178 struct nvgpu_clk_arb_target actual_pool[2];
179 struct nvgpu_clk_arb_target *actual;
180
181 u16 gpc2clk_default_mhz;
182 u16 mclk_default_mhz;
183 u32 voltuv_actual;
184
185 u16 gpc2clk_min, gpc2clk_max;
186 u16 mclk_min, mclk_max;
187
188 struct nvgpu_clk_arb_work_item update_vf_table_work_item;
189 struct nvgpu_clk_arb_work_item update_arb_work_item;
190
191 struct nvgpu_cond request_wq;
192
193 struct nvgpu_clk_vf_table *current_vf_table;
194 struct nvgpu_clk_vf_table vf_table_pool[2];
195 u32 vf_table_index;
196
197 u16 *mclk_f_points;
198 nvgpu_atomic_t req_nr;
199
200 u32 mclk_f_numpoints;
201 u16 *gpc2clk_f_points;
202 u32 gpc2clk_f_numpoints;
203
204 nvgpu_atomic64_t alarm_mask;
205 struct nvgpu_clk_notification_queue notification_queue;
206
207#ifdef CONFIG_DEBUG_FS
208 struct nvgpu_clk_arb_debug debug_pool[2];
209 struct nvgpu_clk_arb_debug *debug;
210 bool debugfs_set;
211#endif
212};
213
214struct nvgpu_clk_dev {
215 struct nvgpu_clk_session *session;
216 union {
217 struct nvgpu_list_node link;
218 struct nvgpu_list_node node;
219 };
220 struct nvgpu_cond readout_wq;
221 nvgpu_atomic_t poll_mask;
222 u16 gpc2clk_target_mhz;
223 u16 mclk_target_mhz;
224 u32 alarms_reported;
225 nvgpu_atomic_t enabled_mask;
226 struct nvgpu_clk_notification_queue queue;
227 u32 arb_queue_head;
228 struct nvgpu_ref refcount;
229};
230
231struct nvgpu_clk_session {
232 bool zombie;
233 struct gk20a *g;
234 struct nvgpu_ref refcount;
235 struct nvgpu_list_node link;
236 struct nvgpu_list_node targets;
237
238 struct nvgpu_spinlock session_lock;
239 struct nvgpu_clk_arb_target target_pool[2];
240 struct nvgpu_clk_arb_target *target;
241};
242
243static inline struct nvgpu_clk_session *
244nvgpu_clk_session_from_link(struct nvgpu_list_node *node)
245{
246 return (struct nvgpu_clk_session *)
247 ((uintptr_t)node - offsetof(struct nvgpu_clk_session, link));
248};
249
250static inline struct nvgpu_clk_dev *
251nvgpu_clk_dev_from_node(struct nvgpu_list_node *node)
252{
253 return (struct nvgpu_clk_dev *)
254 ((uintptr_t)node - offsetof(struct nvgpu_clk_dev, node));
255};
256
257static inline struct nvgpu_clk_dev *
258nvgpu_clk_dev_from_link(struct nvgpu_list_node *node)
259{
260 return (struct nvgpu_clk_dev *)
261 ((uintptr_t)node - offsetof(struct nvgpu_clk_dev, link));
262};
263
264static inline struct nvgpu_clk_arb_work_item *
265nvgpu_clk_arb_work_item_from_worker_item(struct nvgpu_list_node *node)
266{
267 return (struct nvgpu_clk_arb_work_item *)
268 ((uintptr_t)node - offsetof(struct nvgpu_clk_arb_work_item, worker_item));
269};
270
271void nvgpu_clk_arb_worker_enqueue(struct gk20a *g,
272 struct nvgpu_clk_arb_work_item *work_item);
273
154int nvgpu_clk_arb_init_arbiter(struct gk20a *g); 274int nvgpu_clk_arb_init_arbiter(struct gk20a *g);
155 275
156int nvgpu_clk_arb_get_arbiter_clk_range(struct gk20a *g, u32 api_domain, 276int nvgpu_clk_arb_get_arbiter_clk_range(struct gk20a *g, u32 api_domain,