diff options
Diffstat (limited to 'drivers/gpu/nvgpu/pmgr/pmgrpmu.c')
-rw-r--r-- | drivers/gpu/nvgpu/pmgr/pmgrpmu.c | 524 |
1 files changed, 524 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/pmgr/pmgrpmu.c b/drivers/gpu/nvgpu/pmgr/pmgrpmu.c new file mode 100644 index 00000000..ea070060 --- /dev/null +++ b/drivers/gpu/nvgpu/pmgr/pmgrpmu.c | |||
@@ -0,0 +1,524 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | * more details. | ||
12 | */ | ||
13 | |||
14 | #include "gk20a/gk20a.h" | ||
15 | #include "pwrdev.h" | ||
16 | #include "include/bios.h" | ||
17 | #include "boardobj/boardobjgrp.h" | ||
18 | #include "boardobj/boardobjgrp_e32.h" | ||
19 | #include "pmuif/gpmuifboardobj.h" | ||
20 | #include "pmuif/gpmuifpmgr.h" | ||
21 | #include "gm206/bios_gm206.h" | ||
22 | #include "gk20a/pmu_gk20a.h" | ||
23 | #include "pmgrpmu.h" | ||
24 | |||
25 | struct pmgr_pmucmdhandler_params { | ||
26 | u32 success; | ||
27 | }; | ||
28 | |||
29 | static void pmgr_pmucmdhandler(struct gk20a *g, struct pmu_msg *msg, | ||
30 | void *param, u32 handle, u32 status) | ||
31 | { | ||
32 | struct pmgr_pmucmdhandler_params *phandlerparams = | ||
33 | (struct pmgr_pmucmdhandler_params *)param; | ||
34 | |||
35 | if ((msg->msg.pmgr.msg_type != NV_PMU_PMGR_MSG_ID_SET_OBJECT) && | ||
36 | (msg->msg.pmgr.msg_type != NV_PMU_PMGR_MSG_ID_QUERY) && | ||
37 | (msg->msg.pmgr.msg_type != NV_PMU_PMGR_MSG_ID_LOAD)) { | ||
38 | gk20a_err(dev_from_gk20a(g), | ||
39 | "unknow msg %x", | ||
40 | msg->msg.pmgr.msg_type); | ||
41 | return; | ||
42 | } | ||
43 | |||
44 | if (msg->msg.pmgr.msg_type == NV_PMU_PMGR_MSG_ID_SET_OBJECT) { | ||
45 | if ((msg->msg.pmgr.set_object.b_success != 1) || | ||
46 | (msg->msg.pmgr.set_object.flcnstatus != 0) ) { | ||
47 | gk20a_err(dev_from_gk20a(g), | ||
48 | "pmgr msg failed %x %x %x %x", | ||
49 | msg->msg.pmgr.set_object.msg_type, | ||
50 | msg->msg.pmgr.set_object.b_success, | ||
51 | msg->msg.pmgr.set_object.flcnstatus, | ||
52 | msg->msg.pmgr.set_object.object_type); | ||
53 | return; | ||
54 | } | ||
55 | } else if (msg->msg.pmgr.msg_type == NV_PMU_PMGR_MSG_ID_QUERY) { | ||
56 | if ((msg->msg.pmgr.query.b_success != 1) || | ||
57 | (msg->msg.pmgr.query.flcnstatus != 0) ) { | ||
58 | gk20a_err(dev_from_gk20a(g), | ||
59 | "pmgr msg failed %x %x %x %x", | ||
60 | msg->msg.pmgr.query.msg_type, | ||
61 | msg->msg.pmgr.query.b_success, | ||
62 | msg->msg.pmgr.query.flcnstatus, | ||
63 | msg->msg.pmgr.query.cmd_type); | ||
64 | return; | ||
65 | } | ||
66 | } else if (msg->msg.pmgr.msg_type == NV_PMU_PMGR_MSG_ID_LOAD) { | ||
67 | if ((msg->msg.pmgr.query.b_success != 1) || | ||
68 | (msg->msg.pmgr.query.flcnstatus != 0) ) { | ||
69 | gk20a_err(dev_from_gk20a(g), | ||
70 | "pmgr msg failed %x %x %x", | ||
71 | msg->msg.pmgr.load.msg_type, | ||
72 | msg->msg.pmgr.load.b_success, | ||
73 | msg->msg.pmgr.load.flcnstatus); | ||
74 | return; | ||
75 | } | ||
76 | } | ||
77 | |||
78 | phandlerparams->success = 1; | ||
79 | } | ||
80 | |||
81 | static u32 pmgr_pmu_set_object(struct gk20a *g, | ||
82 | u8 type, | ||
83 | u16 dmem_size, | ||
84 | u16 fb_size, | ||
85 | void *pobj) | ||
86 | { | ||
87 | struct pmu_cmd cmd = { {0} }; | ||
88 | struct pmu_payload payload = { {0} }; | ||
89 | struct nv_pmu_pmgr_cmd_set_object *pcmd; | ||
90 | u32 status; | ||
91 | u32 seqdesc; | ||
92 | struct pmgr_pmucmdhandler_params handlerparams = {0}; | ||
93 | |||
94 | cmd.hdr.unit_id = PMU_UNIT_PMGR; | ||
95 | cmd.hdr.size = (u32)sizeof(struct nv_pmu_pmgr_cmd_set_object) + | ||
96 | (u32)sizeof(struct pmu_hdr);; | ||
97 | |||
98 | pcmd = &cmd.cmd.pmgr.set_object; | ||
99 | pcmd->cmd_type = NV_PMU_PMGR_CMD_ID_SET_OBJECT; | ||
100 | pcmd->object_type = type; | ||
101 | |||
102 | payload.in.buf = pobj; | ||
103 | payload.in.size = dmem_size; | ||
104 | payload.in.fb_size = fb_size; | ||
105 | payload.in.offset = NV_PMU_PMGR_SET_OBJECT_ALLOC_OFFSET; | ||
106 | |||
107 | /* Setup the handler params to communicate back results.*/ | ||
108 | handlerparams.success = 0; | ||
109 | |||
110 | status = gk20a_pmu_cmd_post(g, &cmd, NULL, &payload, | ||
111 | PMU_COMMAND_QUEUE_LPQ, | ||
112 | pmgr_pmucmdhandler, | ||
113 | (void *)&handlerparams, | ||
114 | &seqdesc, ~0); | ||
115 | if (status) { | ||
116 | gk20a_err(dev_from_gk20a(g), | ||
117 | "unable to post pmgr cmd for unit %x cmd id %x obj type %x", | ||
118 | cmd.hdr.unit_id, pcmd->cmd_type, pcmd->object_type); | ||
119 | goto exit; | ||
120 | } | ||
121 | |||
122 | pmu_wait_message_cond(&g->pmu, | ||
123 | gk20a_get_gr_idle_timeout(g), | ||
124 | &handlerparams.success, 1); | ||
125 | |||
126 | if (handlerparams.success == 0) { | ||
127 | gk20a_err(dev_from_gk20a(g), "could not process cmd\n"); | ||
128 | status = -ETIMEDOUT; | ||
129 | goto exit; | ||
130 | } | ||
131 | |||
132 | exit: | ||
133 | return status; | ||
134 | } | ||
135 | |||
136 | static u32 pmgr_send_i2c_device_topology_to_pmu(struct gk20a *g) | ||
137 | { | ||
138 | struct nv_pmu_pmgr_i2c_device_desc_table i2c_desc_table; | ||
139 | u32 status = 0; | ||
140 | |||
141 | /* INA3221 I2C device info */ | ||
142 | i2c_desc_table.dev_mask = 0x01; | ||
143 | |||
144 | /* INA3221 */ | ||
145 | i2c_desc_table.devices[0].super.type = 0x4E; | ||
146 | |||
147 | i2c_desc_table.devices[0].dcb_index = 0; | ||
148 | i2c_desc_table.devices[0].i2c_address = 0x84; | ||
149 | i2c_desc_table.devices[0].i2c_flags = 0xC2F; | ||
150 | i2c_desc_table.devices[0].i2c_port = 0x2; | ||
151 | |||
152 | /* Pass the table down the PMU as an object */ | ||
153 | status = pmgr_pmu_set_object( | ||
154 | g, | ||
155 | NV_PMU_PMGR_OBJECT_I2C_DEVICE_DESC_TABLE, | ||
156 | (u16)sizeof(struct nv_pmu_pmgr_i2c_device_desc_table), | ||
157 | PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED, | ||
158 | &i2c_desc_table); | ||
159 | |||
160 | if (status) | ||
161 | gk20a_err(dev_from_gk20a(g), | ||
162 | "pmgr_pmu_set_object failed %x", | ||
163 | status); | ||
164 | |||
165 | return status; | ||
166 | } | ||
167 | |||
168 | static u32 pmgr_send_pwr_device_topology_to_pmu(struct gk20a *g) | ||
169 | { | ||
170 | struct nv_pmu_pmgr_pwr_device_desc_table pwr_desc_table; | ||
171 | struct nv_pmu_pmgr_pwr_device_desc_table_header *ppwr_desc_header; | ||
172 | u32 status = 0; | ||
173 | |||
174 | /* Set the BA-device-independent HW information */ | ||
175 | ppwr_desc_header = &(pwr_desc_table.hdr.data); | ||
176 | ppwr_desc_header->ba_info.b_initialized_and_used = false; | ||
177 | |||
178 | /* populate the table */ | ||
179 | boardobjgrpe32hdrset((struct nv_pmu_boardobjgrp *)&ppwr_desc_header->super, | ||
180 | g->pmgr_pmu.pmgr_deviceobjs.super.super.objmask); | ||
181 | |||
182 | status = boardobjgrp_pmudatainit_legacy(g, | ||
183 | &g->pmgr_pmu.pmgr_deviceobjs.super.super, | ||
184 | (struct nv_pmu_boardobjgrp_super *)&pwr_desc_table); | ||
185 | |||
186 | if (status) { | ||
187 | gk20a_err(dev_from_gk20a(g), | ||
188 | "boardobjgrp_pmudatainit_legacy failed %x", | ||
189 | status); | ||
190 | goto exit; | ||
191 | } | ||
192 | |||
193 | /* Pass the table down the PMU as an object */ | ||
194 | status = pmgr_pmu_set_object( | ||
195 | g, | ||
196 | NV_PMU_PMGR_OBJECT_PWR_DEVICE_DESC_TABLE, | ||
197 | (u16)sizeof( | ||
198 | union nv_pmu_pmgr_pwr_device_dmem_size), | ||
199 | (u16)sizeof(struct nv_pmu_pmgr_pwr_device_desc_table), | ||
200 | &pwr_desc_table); | ||
201 | |||
202 | if (status) | ||
203 | gk20a_err(dev_from_gk20a(g), | ||
204 | "pmgr_pmu_set_object failed %x", | ||
205 | status); | ||
206 | |||
207 | exit: | ||
208 | return status; | ||
209 | } | ||
210 | |||
211 | static u32 pmgr_send_pwr_mointer_to_pmu(struct gk20a *g) | ||
212 | { | ||
213 | struct nv_pmu_pmgr_pwr_monitor_pack pwr_monitor_pack; | ||
214 | struct nv_pmu_pmgr_pwr_channel_header *pwr_channel_hdr; | ||
215 | struct nv_pmu_pmgr_pwr_chrelationship_header *pwr_chrelationship_header; | ||
216 | u32 max_dmem_size; | ||
217 | u32 status = 0; | ||
218 | |||
219 | /* Copy all the global settings from the RM copy */ | ||
220 | pwr_channel_hdr = &(pwr_monitor_pack.channels.hdr.data); | ||
221 | pwr_monitor_pack = g->pmgr_pmu.pmgr_monitorobjs.pmu_data; | ||
222 | |||
223 | boardobjgrpe32hdrset((struct nv_pmu_boardobjgrp *)&pwr_channel_hdr->super, | ||
224 | g->pmgr_pmu.pmgr_monitorobjs.pwr_channels.super.objmask); | ||
225 | |||
226 | /* Copy in each channel */ | ||
227 | status = boardobjgrp_pmudatainit_legacy(g, | ||
228 | &g->pmgr_pmu.pmgr_monitorobjs.pwr_channels.super, | ||
229 | (struct nv_pmu_boardobjgrp_super *)&(pwr_monitor_pack.channels)); | ||
230 | |||
231 | if (status) { | ||
232 | gk20a_err(dev_from_gk20a(g), | ||
233 | "boardobjgrp_pmudatainit_legacy failed %x", | ||
234 | status); | ||
235 | goto exit; | ||
236 | } | ||
237 | |||
238 | /* Copy in each channel relationship */ | ||
239 | pwr_chrelationship_header = &(pwr_monitor_pack.ch_rels.hdr.data); | ||
240 | |||
241 | boardobjgrpe32hdrset((struct nv_pmu_boardobjgrp *)&pwr_chrelationship_header->super, | ||
242 | g->pmgr_pmu.pmgr_monitorobjs.pwr_ch_rels.super.objmask); | ||
243 | |||
244 | pwr_channel_hdr->physical_channel_mask = g->pmgr_pmu.pmgr_monitorobjs.physical_channel_mask; | ||
245 | pwr_channel_hdr->type = NV_PMU_PMGR_PWR_MONITOR_TYPE_NO_POLLING; | ||
246 | |||
247 | status = boardobjgrp_pmudatainit_legacy(g, | ||
248 | &g->pmgr_pmu.pmgr_monitorobjs.pwr_ch_rels.super, | ||
249 | (struct nv_pmu_boardobjgrp_super *)&(pwr_monitor_pack.ch_rels)); | ||
250 | |||
251 | if (status) { | ||
252 | gk20a_err(dev_from_gk20a(g), | ||
253 | "boardobjgrp_pmudatainit_legacy failed %x", | ||
254 | status); | ||
255 | goto exit; | ||
256 | } | ||
257 | |||
258 | /* Calculate the max Dmem buffer size */ | ||
259 | max_dmem_size = sizeof(union nv_pmu_pmgr_pwr_monitor_dmem_size); | ||
260 | |||
261 | /* Pass the table down the PMU as an object */ | ||
262 | status = pmgr_pmu_set_object( | ||
263 | g, | ||
264 | NV_PMU_PMGR_OBJECT_PWR_MONITOR, | ||
265 | (u16)max_dmem_size, | ||
266 | (u16)sizeof(struct nv_pmu_pmgr_pwr_monitor_pack), | ||
267 | &pwr_monitor_pack); | ||
268 | |||
269 | if (status) | ||
270 | gk20a_err(dev_from_gk20a(g), | ||
271 | "pmgr_pmu_set_object failed %x", | ||
272 | status); | ||
273 | |||
274 | exit: | ||
275 | return status; | ||
276 | } | ||
277 | |||
278 | u32 pmgr_send_pwr_policy_to_pmu(struct gk20a *g) | ||
279 | { | ||
280 | struct nv_pmu_pmgr_pwr_policy_pack *ppwrpack = NULL; | ||
281 | struct pwr_policy *ppolicy = NULL; | ||
282 | u32 status = 0; | ||
283 | u8 indx; | ||
284 | u32 max_dmem_size; | ||
285 | |||
286 | ppwrpack = kzalloc(sizeof(struct nv_pmu_pmgr_pwr_policy_pack), GFP_KERNEL); | ||
287 | if (!ppwrpack) { | ||
288 | gk20a_err(dev_from_gk20a(g), | ||
289 | "pwr policy alloc failed %x", | ||
290 | status); | ||
291 | status = -ENOMEM; | ||
292 | goto exit; | ||
293 | } | ||
294 | |||
295 | ppwrpack->policies.hdr.data.version = g->pmgr_pmu.pmgr_policyobjs.version; | ||
296 | ppwrpack->policies.hdr.data.b_enabled = g->pmgr_pmu.pmgr_policyobjs.b_enabled; | ||
297 | |||
298 | boardobjgrpe32hdrset((struct nv_pmu_boardobjgrp *) | ||
299 | &ppwrpack->policies.hdr.data.super, | ||
300 | g->pmgr_pmu.pmgr_policyobjs.pwr_policies.super.objmask); | ||
301 | |||
302 | memset(&ppwrpack->policies.hdr.data.reserved_pmu_policy_mask, | ||
303 | 0, | ||
304 | sizeof(ppwrpack->policies.hdr.data.reserved_pmu_policy_mask)); | ||
305 | |||
306 | ppwrpack->policies.hdr.data.base_sample_period = | ||
307 | g->pmgr_pmu.pmgr_policyobjs.base_sample_period; | ||
308 | ppwrpack->policies.hdr.data.min_client_sample_period = | ||
309 | g->pmgr_pmu.pmgr_policyobjs.min_client_sample_period; | ||
310 | ppwrpack->policies.hdr.data.low_sampling_mult = | ||
311 | g->pmgr_pmu.pmgr_policyobjs.low_sampling_mult; | ||
312 | |||
313 | memcpy(&ppwrpack->policies.hdr.data.global_ceiling, | ||
314 | &g->pmgr_pmu.pmgr_policyobjs.global_ceiling, | ||
315 | sizeof(struct nv_pmu_perf_domain_group_limits)); | ||
316 | |||
317 | memcpy(&ppwrpack->policies.hdr.data.semantic_policy_tbl, | ||
318 | &g->pmgr_pmu.pmgr_policyobjs.policy_idxs, | ||
319 | sizeof(g->pmgr_pmu.pmgr_policyobjs.policy_idxs)); | ||
320 | |||
321 | BOARDOBJGRP_FOR_EACH_INDEX_IN_MASK(32, indx, | ||
322 | ppwrpack->policies.hdr.data.super.obj_mask.super.data[0]) { | ||
323 | ppolicy = PMGR_GET_PWR_POLICY(g, indx); | ||
324 | |||
325 | status = ((struct boardobj *)ppolicy)->pmudatainit(g, (struct boardobj *)ppolicy, | ||
326 | (struct nv_pmu_boardobj *)&(ppwrpack->policies.policies[indx].data)); | ||
327 | if (status) { | ||
328 | gk20a_err(dev_from_gk20a(g), | ||
329 | "pmudatainit failed %x indx %x", | ||
330 | status, indx); | ||
331 | status = -ENOMEM; | ||
332 | goto exit; | ||
333 | } | ||
334 | } | ||
335 | BOARDOBJGRP_FOR_EACH_INDEX_IN_MASK_END; | ||
336 | |||
337 | boardobjgrpe32hdrset((struct nv_pmu_boardobjgrp *) | ||
338 | &ppwrpack->policy_rels.hdr.data.super, | ||
339 | g->pmgr_pmu.pmgr_policyobjs.pwr_policy_rels.super.objmask); | ||
340 | |||
341 | boardobjgrpe32hdrset((struct nv_pmu_boardobjgrp *) | ||
342 | &ppwrpack->violations.hdr.data.super, | ||
343 | g->pmgr_pmu.pmgr_policyobjs.pwr_violations.super.objmask); | ||
344 | |||
345 | max_dmem_size = sizeof(union nv_pmu_pmgr_pwr_policy_dmem_size); | ||
346 | |||
347 | /* Pass the table down the PMU as an object */ | ||
348 | status = pmgr_pmu_set_object( | ||
349 | g, | ||
350 | NV_PMU_PMGR_OBJECT_PWR_POLICY, | ||
351 | (u16)max_dmem_size, | ||
352 | (u16)sizeof(struct nv_pmu_pmgr_pwr_policy_pack), | ||
353 | ppwrpack); | ||
354 | |||
355 | if (status) | ||
356 | gk20a_err(dev_from_gk20a(g), | ||
357 | "pmgr_pmu_set_object failed %x", | ||
358 | status); | ||
359 | |||
360 | exit: | ||
361 | if (ppwrpack) { | ||
362 | kfree(ppwrpack); | ||
363 | } | ||
364 | |||
365 | return status; | ||
366 | } | ||
367 | |||
368 | u32 pmgr_pmu_pwr_devices_query_blocking( | ||
369 | struct gk20a *g, | ||
370 | u32 pwr_dev_mask, | ||
371 | struct nv_pmu_pmgr_pwr_devices_query_payload *ppayload) | ||
372 | { | ||
373 | struct pmu_cmd cmd = { {0} }; | ||
374 | struct pmu_payload payload = { {0} }; | ||
375 | struct nv_pmu_pmgr_cmd_pwr_devices_query *pcmd; | ||
376 | u32 status; | ||
377 | u32 seqdesc; | ||
378 | struct pmgr_pmucmdhandler_params handlerparams = {0}; | ||
379 | |||
380 | cmd.hdr.unit_id = PMU_UNIT_PMGR; | ||
381 | cmd.hdr.size = (u32)sizeof(struct nv_pmu_pmgr_cmd_pwr_devices_query) + | ||
382 | (u32)sizeof(struct pmu_hdr); | ||
383 | |||
384 | pcmd = &cmd.cmd.pmgr.pwr_dev_query; | ||
385 | pcmd->cmd_type = NV_PMU_PMGR_CMD_ID_PWR_DEVICES_QUERY; | ||
386 | pcmd->dev_mask = pwr_dev_mask; | ||
387 | |||
388 | payload.out.buf = ppayload; | ||
389 | payload.out.size = sizeof(struct nv_pmu_pmgr_pwr_devices_query_payload); | ||
390 | payload.out.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED; | ||
391 | payload.out.offset = NV_PMU_PMGR_PWR_DEVICES_QUERY_ALLOC_OFFSET; | ||
392 | |||
393 | /* Setup the handler params to communicate back results.*/ | ||
394 | handlerparams.success = 0; | ||
395 | |||
396 | status = gk20a_pmu_cmd_post(g, &cmd, NULL, &payload, | ||
397 | PMU_COMMAND_QUEUE_LPQ, | ||
398 | pmgr_pmucmdhandler, | ||
399 | (void *)&handlerparams, | ||
400 | &seqdesc, ~0); | ||
401 | if (status) { | ||
402 | gk20a_err(dev_from_gk20a(g), | ||
403 | "unable to post pmgr query cmd for unit %x cmd id %x dev mask %x", | ||
404 | cmd.hdr.unit_id, pcmd->cmd_type, pcmd->dev_mask); | ||
405 | goto exit; | ||
406 | } | ||
407 | |||
408 | pmu_wait_message_cond(&g->pmu, | ||
409 | gk20a_get_gr_idle_timeout(g), | ||
410 | &handlerparams.success, 1); | ||
411 | |||
412 | if (handlerparams.success == 0) { | ||
413 | gk20a_err(dev_from_gk20a(g), "could not process cmd\n"); | ||
414 | status = -ETIMEDOUT; | ||
415 | goto exit; | ||
416 | } | ||
417 | |||
418 | exit: | ||
419 | return status; | ||
420 | } | ||
421 | |||
422 | static u32 pmgr_pmu_load_blocking(struct gk20a *g) | ||
423 | { | ||
424 | struct pmu_cmd cmd = { {0} }; | ||
425 | struct nv_pmu_pmgr_cmd_load *pcmd; | ||
426 | u32 status; | ||
427 | u32 seqdesc; | ||
428 | struct pmgr_pmucmdhandler_params handlerparams = {0}; | ||
429 | |||
430 | cmd.hdr.unit_id = PMU_UNIT_PMGR; | ||
431 | cmd.hdr.size = (u32)sizeof(struct nv_pmu_pmgr_cmd_load) + | ||
432 | (u32)sizeof(struct pmu_hdr); | ||
433 | |||
434 | pcmd = &cmd.cmd.pmgr.load; | ||
435 | pcmd->cmd_type = NV_PMU_PMGR_CMD_ID_LOAD; | ||
436 | |||
437 | /* Setup the handler params to communicate back results.*/ | ||
438 | handlerparams.success = 0; | ||
439 | |||
440 | status = gk20a_pmu_cmd_post(g, &cmd, NULL, NULL, | ||
441 | PMU_COMMAND_QUEUE_LPQ, | ||
442 | pmgr_pmucmdhandler, | ||
443 | (void *)&handlerparams, | ||
444 | &seqdesc, ~0); | ||
445 | if (status) { | ||
446 | gk20a_err(dev_from_gk20a(g), | ||
447 | "unable to post pmgr load cmd for unit %x cmd id %x", | ||
448 | cmd.hdr.unit_id, pcmd->cmd_type); | ||
449 | goto exit; | ||
450 | } | ||
451 | |||
452 | pmu_wait_message_cond(&g->pmu, | ||
453 | gk20a_get_gr_idle_timeout(g), | ||
454 | &handlerparams.success, 1); | ||
455 | |||
456 | if (handlerparams.success == 0) { | ||
457 | gk20a_err(dev_from_gk20a(g), "could not process cmd\n"); | ||
458 | status = -ETIMEDOUT; | ||
459 | goto exit; | ||
460 | } | ||
461 | |||
462 | exit: | ||
463 | return status; | ||
464 | } | ||
465 | |||
466 | u32 pmgr_send_pmgr_tables_to_pmu(struct gk20a *g) | ||
467 | { | ||
468 | u32 status = 0; | ||
469 | |||
470 | status = pmgr_send_i2c_device_topology_to_pmu(g); | ||
471 | |||
472 | if (status) { | ||
473 | gk20a_err(dev_from_gk20a(g), | ||
474 | "pmgr_send_i2c_device_topology_to_pmu failed %x", | ||
475 | status); | ||
476 | goto exit; | ||
477 | } | ||
478 | |||
479 | if (!BOARDOBJGRP_IS_EMPTY(&g->pmgr_pmu.pmgr_deviceobjs.super.super)) { | ||
480 | status = pmgr_send_pwr_device_topology_to_pmu(g); | ||
481 | if (status) { | ||
482 | gk20a_err(dev_from_gk20a(g), | ||
483 | "pmgr_send_pwr_device_topology_to_pmu failed %x", | ||
484 | status); | ||
485 | goto exit; | ||
486 | } | ||
487 | } | ||
488 | |||
489 | if (!(BOARDOBJGRP_IS_EMPTY( | ||
490 | &g->pmgr_pmu.pmgr_monitorobjs.pwr_channels.super)) || | ||
491 | !(BOARDOBJGRP_IS_EMPTY( | ||
492 | &g->pmgr_pmu.pmgr_monitorobjs.pwr_ch_rels.super))) { | ||
493 | status = pmgr_send_pwr_mointer_to_pmu(g); | ||
494 | if (status) { | ||
495 | gk20a_err(dev_from_gk20a(g), | ||
496 | "pmgr_send_pwr_mointer_to_pmu failed %x", status); | ||
497 | goto exit; | ||
498 | } | ||
499 | } | ||
500 | |||
501 | if (!(BOARDOBJGRP_IS_EMPTY( | ||
502 | &g->pmgr_pmu.pmgr_policyobjs.pwr_policies.super)) || | ||
503 | !(BOARDOBJGRP_IS_EMPTY( | ||
504 | &g->pmgr_pmu.pmgr_policyobjs.pwr_policy_rels.super)) || | ||
505 | !(BOARDOBJGRP_IS_EMPTY( | ||
506 | &g->pmgr_pmu.pmgr_policyobjs.pwr_violations.super))) { | ||
507 | status = pmgr_send_pwr_policy_to_pmu(g); | ||
508 | if (status) { | ||
509 | gk20a_err(dev_from_gk20a(g), | ||
510 | "pmgr_send_pwr_policy_to_pmu failed %x", status); | ||
511 | goto exit; | ||
512 | } | ||
513 | } | ||
514 | |||
515 | status = pmgr_pmu_load_blocking(g); | ||
516 | if (status) { | ||
517 | gk20a_err(dev_from_gk20a(g), | ||
518 | "pmgr_send_pwr_mointer_to_pmu failed %x", status); | ||
519 | goto exit; | ||
520 | } | ||
521 | |||
522 | exit: | ||
523 | return status; | ||
524 | } | ||