summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/boardobj/boardobjgrp.c
diff options
context:
space:
mode:
authorMahantesh Kumbar <mkumbar@nvidia.com>2018-02-13 02:18:58 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2018-03-08 02:27:52 -0500
commitb94770dc4d2d96b80b14b9942595d3e7fc2bbf6c (patch)
tree845bbf88392ed4014e6518c1767e9985e1840729 /drivers/gpu/nvgpu/boardobj/boardobjgrp.c
parentcc4b9f540f66abc9f60cf9f8e2217ff17349bc77 (diff)
gpu: nvgpu: boardobj update for gv10x branch
- Created ops for below boardobj methods to support gp10x & gv10x branch boardobj changes, and defined methods for gv10x with postfix _v1 with below names boardobjgrp_pmucmd_construct_impl boardobjgrp_pmuset_impl boardobjgrp_pmugetstatus_impl is_boardobjgrp_pmucmd_id_valid - These ops are assigned based on PMU version to respective chip. - Modified BOARDOBJGRP_PMU_CMD_GRP_SET_CONSTRUCT & BOARDOBJGRP_PMU_CMD_GRP_GET_STATUS_CONSTRUCT to support gp10x & gv10x branch changes - Updated struct boardobjgrp_pmu_cmd to include members needed for gv10x boardobj changes - Created "struct nv_pmu_rpc_struct_board_obj_grp_cmd" to execute BOARD_OBJ_GRP_CMD using RPC. - Defined method boardobjgrp_pmucmdsend_rpc() to send BOARD_OBJ_GRP_CMD to PMU. Change-Id: If2551bdda80e897e7b21d2966881586f3bbc7a9b Signed-off-by: Mahantesh Kumbar <mkumbar@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1656511 GVS: Gerrit_Virtual_Submit 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/boardobj/boardobjgrp.c')
-rw-r--r--drivers/gpu/nvgpu/boardobj/boardobjgrp.c259
1 files changed, 229 insertions, 30 deletions
diff --git a/drivers/gpu/nvgpu/boardobj/boardobjgrp.c b/drivers/gpu/nvgpu/boardobj/boardobjgrp.c
index caed11e9..f20b4a78 100644
--- a/drivers/gpu/nvgpu/boardobj/boardobjgrp.c
+++ b/drivers/gpu/nvgpu/boardobj/boardobjgrp.c
@@ -35,6 +35,10 @@ static boardobjgrp_pmustatusinstget boardobjgrp_pmustatusinstget_stub;
35static u32 boardobjgrp_pmucmdsend(struct gk20a *g, 35static u32 boardobjgrp_pmucmdsend(struct gk20a *g,
36 struct boardobjgrp *pboardobjgrp, 36 struct boardobjgrp *pboardobjgrp,
37 struct boardobjgrp_pmu_cmd *pcmd); 37 struct boardobjgrp_pmu_cmd *pcmd);
38static u32 boardobjgrp_pmucmdsend_rpc(struct gk20a *g,
39 struct boardobjgrp *pboardobjgrp,
40 struct boardobjgrp_pmu_cmd *pcmd,
41 bool copy_out);
38struct boardobjgrp_pmucmdhandler_params { 42struct boardobjgrp_pmucmdhandler_params {
39 /* Pointer to the BOARDOBJGRP associated with this CMD */ 43 /* Pointer to the BOARDOBJGRP associated with this CMD */
40 struct boardobjgrp *pboardobjgrp; 44 struct boardobjgrp *pboardobjgrp;
@@ -63,6 +67,8 @@ u32 boardobjgrp_construct_super(struct gk20a *g, struct boardobjgrp *pboardobjgr
63 pboardobjgrp->classid = 0; 67 pboardobjgrp->classid = 0;
64 pboardobjgrp->pmu.unitid = BOARDOBJGRP_UNIT_ID_INVALID; 68 pboardobjgrp->pmu.unitid = BOARDOBJGRP_UNIT_ID_INVALID;
65 pboardobjgrp->pmu.classid = BOARDOBJGRP_GRP_CLASS_ID_INVALID; 69 pboardobjgrp->pmu.classid = BOARDOBJGRP_GRP_CLASS_ID_INVALID;
70 pboardobjgrp->pmu.bset = false;
71 pboardobjgrp->pmu.rpc_func_id = BOARDOBJGRP_GRP_RPC_FUNC_ID_INVALID;
66 pboardobjgrp->pmu.set.id = BOARDOBJGRP_GRP_CMD_ID_INVALID; 72 pboardobjgrp->pmu.set.id = BOARDOBJGRP_GRP_CMD_ID_INVALID;
67 pboardobjgrp->pmu.getstatus.id = BOARDOBJGRP_GRP_CMD_ID_INVALID; 73 pboardobjgrp->pmu.getstatus.id = BOARDOBJGRP_GRP_CMD_ID_INVALID;
68 74
@@ -77,8 +83,10 @@ u32 boardobjgrp_construct_super(struct gk20a *g, struct boardobjgrp *pboardobjgr
77 pboardobjgrp->pmuinithandle = boardobjgrp_pmuinithandle_impl; 83 pboardobjgrp->pmuinithandle = boardobjgrp_pmuinithandle_impl;
78 pboardobjgrp->pmuhdrdatainit = boardobjgrp_pmuhdrdatainit_super; 84 pboardobjgrp->pmuhdrdatainit = boardobjgrp_pmuhdrdatainit_super;
79 pboardobjgrp->pmudatainit = boardobjgrp_pmudatainit_super; 85 pboardobjgrp->pmudatainit = boardobjgrp_pmudatainit_super;
80 pboardobjgrp->pmuset = boardobjgrp_pmuset_impl; 86 pboardobjgrp->pmuset =
81 pboardobjgrp->pmugetstatus = boardobjgrp_pmugetstatus_impl; 87 g->ops.pmu_ver.boardobj.boardobjgrp_pmuset_impl;
88 pboardobjgrp->pmugetstatus =
89 g->ops.pmu_ver.boardobj.boardobjgrp_pmugetstatus_impl;
82 90
83 pboardobjgrp->pmudatainstget = boardobjgrp_pmudatainstget_stub; 91 pboardobjgrp->pmudatainstget = boardobjgrp_pmudatainstget_stub;
84 pboardobjgrp->pmustatusinstget = boardobjgrp_pmustatusinstget_stub; 92 pboardobjgrp->pmustatusinstget = boardobjgrp_pmustatusinstget_stub;
@@ -155,7 +163,7 @@ u32 boardobjgrp_destruct_super(struct boardobjgrp *pboardobjgrp)
155 163
156u32 boardobjgrp_pmucmd_construct_impl(struct gk20a *g, struct boardobjgrp 164u32 boardobjgrp_pmucmd_construct_impl(struct gk20a *g, struct boardobjgrp
157 *pboardobjgrp, struct boardobjgrp_pmu_cmd *cmd, u8 id, u8 msgid, 165 *pboardobjgrp, struct boardobjgrp_pmu_cmd *cmd, u8 id, u8 msgid,
158 u8 hdrsize, u8 entrysize, u16 fbsize) 166 u8 hdrsize, u8 entrysize, u16 fbsize, u32 ss_offset, u8 rpc_func_id)
159{ 167{
160 gk20a_dbg_info(""); 168 gk20a_dbg_info("");
161 169
@@ -169,6 +177,22 @@ u32 boardobjgrp_pmucmd_construct_impl(struct gk20a *g, struct boardobjgrp
169 return 0; 177 return 0;
170} 178}
171 179
180u32 boardobjgrp_pmucmd_construct_impl_v1(struct gk20a *g, struct boardobjgrp
181 *pboardobjgrp, struct boardobjgrp_pmu_cmd *cmd, u8 id, u8 msgid,
182 u8 hdrsize, u8 entrysize, u16 fbsize, u32 ss_offset, u8 rpc_func_id)
183{
184 nvgpu_log_fn(g, " ");
185
186 /* Copy the parameters into the CMD*/
187 cmd->dmem_buffer_size = ((hdrsize > entrysize) ? hdrsize : entrysize);
188 cmd->super_surface_offset = ss_offset;
189 pboardobjgrp->pmu.rpc_func_id = rpc_func_id;
190 cmd->fbsize = fbsize;
191
192 nvgpu_log_fn(g, "DONE");
193 return 0;
194}
195
172u32 boardobjgrp_pmucmd_destroy_impl(struct gk20a *g, 196u32 boardobjgrp_pmucmd_destroy_impl(struct gk20a *g,
173 struct boardobjgrp_pmu_cmd *cmd) 197 struct boardobjgrp_pmu_cmd *cmd)
174{ 198{
@@ -178,6 +202,31 @@ u32 boardobjgrp_pmucmd_destroy_impl(struct gk20a *g,
178 return 0; 202 return 0;
179} 203}
180 204
205int is_boardobjgrp_pmucmd_id_valid_v0(struct gk20a *g,
206 struct boardobjgrp *pboardobjgrp,
207 struct boardobjgrp_pmu_cmd *pcmd)
208{
209 int err = 0;
210
211 if (pcmd->id == BOARDOBJGRP_GRP_CMD_ID_INVALID)
212 err = -EINVAL;
213
214 return err;
215}
216
217int is_boardobjgrp_pmucmd_id_valid_v1(struct gk20a *g,
218 struct boardobjgrp *pboardobjgrp,
219 struct boardobjgrp_pmu_cmd *cmd)
220{
221 int err = 0;
222
223 if (pboardobjgrp->pmu.rpc_func_id ==
224 BOARDOBJGRP_GRP_RPC_FUNC_ID_INVALID)
225 err = -EINVAL;
226
227 return err;
228}
229
181u32 boardobjgrp_pmucmd_pmuinithandle_impl(struct gk20a *g, 230u32 boardobjgrp_pmucmd_pmuinithandle_impl(struct gk20a *g,
182 struct boardobjgrp *pboardobjgrp, 231 struct boardobjgrp *pboardobjgrp,
183 struct boardobjgrp_pmu_cmd *pcmd) 232 struct boardobjgrp_pmu_cmd *pcmd)
@@ -187,7 +236,8 @@ u32 boardobjgrp_pmucmd_pmuinithandle_impl(struct gk20a *g,
187 236
188 gk20a_dbg_info(""); 237 gk20a_dbg_info("");
189 238
190 if (pcmd->id == BOARDOBJGRP_GRP_CMD_ID_INVALID) 239 if (g->ops.pmu_ver.boardobj.is_boardobjgrp_pmucmd_id_valid(g,
240 pboardobjgrp, pcmd))
191 goto boardobjgrp_pmucmd_pmuinithandle_exit; 241 goto boardobjgrp_pmucmd_pmuinithandle_exit;
192 242
193 nvgpu_pmu_sysmem_surface_alloc(g, sysmem_desc, pcmd->fbsize); 243 nvgpu_pmu_sysmem_surface_alloc(g, sysmem_desc, pcmd->fbsize);
@@ -223,7 +273,8 @@ u32 boardobjgrp_pmuinithandle_impl(struct gk20a *g,
223 } 273 }
224 274
225 /* If the GRP_SET CMD has not been allocated, nothing left to do. */ 275 /* If the GRP_SET CMD has not been allocated, nothing left to do. */
226 if (((pboardobjgrp->pmu.set.id) == BOARDOBJGRP_GRP_CMD_ID_INVALID) || 276 if ((g->ops.pmu_ver.boardobj.is_boardobjgrp_pmucmd_id_valid(g,
277 pboardobjgrp, &pboardobjgrp->pmu.set))||
227 (BOARDOBJGRP_IS_EMPTY(pboardobjgrp))) 278 (BOARDOBJGRP_IS_EMPTY(pboardobjgrp)))
228 goto boardobjgrp_pmuinithandle_exit; 279 goto boardobjgrp_pmuinithandle_exit;
229 280
@@ -369,12 +420,9 @@ boardobjgrppmudatainit_super_done:
369 return status; 420 return status;
370} 421}
371 422
372u32 boardobjgrp_pmuset_impl(struct gk20a *g, struct boardobjgrp *pboardobjgrp) 423static int check_boardobjgrp_param(struct gk20a *g,
424 struct boardobjgrp *pboardobjgrp)
373{ 425{
374 u32 status = 0;
375 struct boardobjgrp_pmu_cmd *pcmd = &pboardobjgrp->pmu.set;
376 gk20a_dbg_info("");
377
378 if (pboardobjgrp == NULL) 426 if (pboardobjgrp == NULL)
379 return -EINVAL; 427 return -EINVAL;
380 428
@@ -387,6 +435,24 @@ u32 boardobjgrp_pmuset_impl(struct gk20a *g, struct boardobjgrp *pboardobjgrp)
387 if (pboardobjgrp->pmu.classid == BOARDOBJGRP_GRP_CLASS_ID_INVALID) 435 if (pboardobjgrp->pmu.classid == BOARDOBJGRP_GRP_CLASS_ID_INVALID)
388 return -EINVAL; 436 return -EINVAL;
389 437
438 /* If no objects in the group, return early */
439 if (BOARDOBJGRP_IS_EMPTY(pboardobjgrp))
440 return -EINVAL;
441
442 return 0;
443}
444
445u32 boardobjgrp_pmuset_impl(struct gk20a *g, struct boardobjgrp *pboardobjgrp)
446{
447 u32 status = 0;
448 struct boardobjgrp_pmu_cmd *pcmd =
449 (struct boardobjgrp_pmu_cmd *)(&pboardobjgrp->pmu.set);
450
451 gk20a_dbg_info("");
452
453 if (check_boardobjgrp_param(g, pboardobjgrp))
454 return -EINVAL;
455
390 if (pboardobjgrp->pmu.set.id == BOARDOBJGRP_GRP_CMD_ID_INVALID) 456 if (pboardobjgrp->pmu.set.id == BOARDOBJGRP_GRP_CMD_ID_INVALID)
391 return -EINVAL; 457 return -EINVAL;
392 458
@@ -395,10 +461,6 @@ u32 boardobjgrp_pmuset_impl(struct gk20a *g, struct boardobjgrp *pboardobjgrp)
395 (pcmd->buf == NULL)) 461 (pcmd->buf == NULL))
396 return -EINVAL; 462 return -EINVAL;
397 463
398 /* If no objects in the group, return early */
399 if (BOARDOBJGRP_IS_EMPTY(pboardobjgrp))
400 return -EINVAL;
401
402 /* Initialize PMU buffer with BOARDOBJGRP data. */ 464 /* Initialize PMU buffer with BOARDOBJGRP data. */
403 memset(pcmd->buf, 0x0, pcmd->fbsize); 465 memset(pcmd->buf, 0x0, pcmd->fbsize);
404 status = pboardobjgrp->pmudatainit(g, pboardobjgrp, 466 status = pboardobjgrp->pmudatainit(g, pboardobjgrp,
@@ -438,29 +500,76 @@ boardobjgrp_pmuset_exit:
438 return status; 500 return status;
439} 501}
440 502
441u32 503u32 boardobjgrp_pmuset_impl_v1(struct gk20a *g, struct boardobjgrp *pboardobjgrp)
442boardobjgrp_pmugetstatus_impl(struct gk20a *g, struct boardobjgrp *pboardobjgrp,
443 struct boardobjgrpmask *mask)
444{ 504{
445 u32 status = 0; 505 struct nvgpu_pmu *pmu = &g->pmu;
446 struct boardobjgrp_pmu_cmd *pcmd = &pboardobjgrp->pmu.getstatus; 506 u32 status = 0;
447 struct boardobjgrp_pmu_cmd *pset = &pboardobjgrp->pmu.set; 507 struct boardobjgrp_pmu_cmd *pcmd =
508 (struct boardobjgrp_pmu_cmd *)(&pboardobjgrp->pmu.set);
448 509
449 gk20a_dbg_info(""); 510 gk20a_dbg_info("");
450 511
451 if (pboardobjgrp == NULL) 512 if (check_boardobjgrp_param(g, pboardobjgrp))
452 return -EINVAL; 513 return -EINVAL;
453 514
454 if (!pboardobjgrp->bconstructed) 515 if ((pcmd->buf == NULL) &&
516 (pboardobjgrp->pmu.rpc_func_id ==
517 BOARDOBJGRP_GRP_RPC_FUNC_ID_INVALID))
455 return -EINVAL; 518 return -EINVAL;
456 519
457 if (pboardobjgrp->pmu.unitid == BOARDOBJGRP_UNIT_ID_INVALID) 520 /* Initialize PMU buffer with BOARDOBJGRP data. */
458 return -EINVAL; 521 memset(pcmd->buf, 0x0, pcmd->fbsize);
522 status = pboardobjgrp->pmudatainit(g, pboardobjgrp,
523 pcmd->buf);
524 if (status) {
525 nvgpu_err(g, "could not parse pmu data");
526 goto boardobjgrp_pmuset_exit;
527 }
459 528
460 if (pboardobjgrp->pmu.classid == BOARDOBJGRP_GRP_CLASS_ID_INVALID) 529 /*
530 * Reset the boolean that indicates set status
531 * for most recent instance of BOARDOBJGRP.
532 */
533 pboardobjgrp->pmu.bset = false;
534
535 /*
536 * copy constructed pmu boardobjgrp data from
537 * sysmem to pmu super surface present in FB
538 */
539 nvgpu_mem_wr_n(g, &pmu->super_surface_buf,
540 pcmd->super_surface_offset, pcmd->buf,
541 pcmd->fbsize);
542
543 /* Send the SET PMU CMD to the PMU using RPC*/
544 status = boardobjgrp_pmucmdsend_rpc(g, pboardobjgrp,
545 pcmd, false);
546 if (status) {
547 nvgpu_err(g, "could not send SET CMD to PMU");
548 goto boardobjgrp_pmuset_exit;
549 }
550
551 pboardobjgrp->pmu.bset = true;
552
553boardobjgrp_pmuset_exit:
554 return status;
555}
556
557u32
558boardobjgrp_pmugetstatus_impl(struct gk20a *g, struct boardobjgrp *pboardobjgrp,
559 struct boardobjgrpmask *mask)
560{
561 u32 status = 0;
562 struct boardobjgrp_pmu_cmd *pcmd =
563 (struct boardobjgrp_pmu_cmd *)(&pboardobjgrp->pmu.getstatus);
564 struct boardobjgrp_pmu_cmd *pset =
565 (struct boardobjgrp_pmu_cmd *)(&pboardobjgrp->pmu.set);
566
567 gk20a_dbg_info("");
568
569 if (check_boardobjgrp_param(g, pboardobjgrp))
461 return -EINVAL; 570 return -EINVAL;
462 571
463 if (pboardobjgrp->pmu.set.id == BOARDOBJGRP_GRP_CMD_ID_INVALID) 572 if (pset->id == BOARDOBJGRP_GRP_CMD_ID_INVALID)
464 return -EINVAL; 573 return -EINVAL;
465 574
466 if ((pcmd->hdrsize == 0) || 575 if ((pcmd->hdrsize == 0) ||
@@ -468,10 +577,6 @@ boardobjgrp_pmugetstatus_impl(struct gk20a *g, struct boardobjgrp *pboardobjgrp,
468 (pcmd->buf == NULL)) 577 (pcmd->buf == NULL))
469 return -EINVAL; 578 return -EINVAL;
470 579
471 /* If no objects in the group, return early */
472 if (BOARDOBJGRP_IS_EMPTY(pboardobjgrp))
473 return -EINVAL;
474
475 /* 580 /*
476 * Can only GET_STATUS if the BOARDOBJGRP has been previously SET to the 581 * Can only GET_STATUS if the BOARDOBJGRP has been previously SET to the
477 * PMU 582 * PMU
@@ -517,6 +622,66 @@ boardobjgrp_pmugetstatus_exit:
517 return status; 622 return status;
518} 623}
519 624
625u32
626boardobjgrp_pmugetstatus_impl_v1(struct gk20a *g, struct boardobjgrp *pboardobjgrp,
627 struct boardobjgrpmask *mask)
628{
629 struct nvgpu_pmu *pmu = &g->pmu;
630 u32 status = 0;
631 struct boardobjgrp_pmu_cmd *pcmd =
632 (struct boardobjgrp_pmu_cmd *)(&pboardobjgrp->pmu.getstatus);
633
634 gk20a_dbg_info("");
635
636 if (check_boardobjgrp_param(g, pboardobjgrp))
637 return -EINVAL;
638
639 if ((pcmd->buf == NULL) &&
640 (pboardobjgrp->pmu.rpc_func_id ==
641 BOARDOBJGRP_GRP_RPC_FUNC_ID_INVALID))
642 return -EINVAL;
643
644 /*
645 * Can only GET_STATUS if the BOARDOBJGRP has been
646 * previously SET to the PMU
647 */
648 if (!pboardobjgrp->pmu.bset)
649 return -EINVAL;
650
651 /*
652 * Initialize PMU buffer with the mask of
653 * BOARDOBJGRPs for which to retrieve status
654 */
655 memset(pcmd->buf, 0x0, pcmd->fbsize);
656 status = pboardobjgrp->pmuhdrdatainit(g, pboardobjgrp,
657 pcmd->buf, mask);
658 if (status) {
659 nvgpu_err(g, "could not init PMU HDR data");
660 goto boardobjgrp_pmugetstatus_exit;
661 }
662
663 /*
664 * copy constructed pmu boardobjgrp data from
665 * sysmem to pmu super surface present in FB
666 */
667 nvgpu_mem_wr_n(g, &pmu->super_surface_buf, pcmd->super_surface_offset,
668 pcmd->buf, pcmd->fbsize);
669 /* Send the GET_STATUS PMU CMD to the PMU */
670 status = boardobjgrp_pmucmdsend_rpc(g, pboardobjgrp,
671 pcmd, true);
672 if (status) {
673 nvgpu_err(g, "could not send GET_STATUS cmd to PMU");
674 goto boardobjgrp_pmugetstatus_exit;
675 }
676
677 /*copy the data back to sysmem buffer that belongs to command*/
678 nvgpu_mem_rd_n(g, &pmu->super_surface_buf,pcmd->super_surface_offset,
679 pcmd->buf, pcmd->fbsize);
680
681boardobjgrp_pmugetstatus_exit:
682 return status;
683}
684
520static u32 685static u32
521boardobjgrp_objinsert_final(struct boardobjgrp *pboardobjgrp, 686boardobjgrp_objinsert_final(struct boardobjgrp *pboardobjgrp,
522 struct boardobj *pboardobj, u8 index) 687 struct boardobj *pboardobj, u8 index)
@@ -785,3 +950,37 @@ static u32 boardobjgrp_pmucmdsend(struct gk20a *g,
785boardobjgrp_pmucmdsend_exit: 950boardobjgrp_pmucmdsend_exit:
786 return status; 951 return status;
787} 952}
953
954static u32 boardobjgrp_pmucmdsend_rpc(struct gk20a *g,
955 struct boardobjgrp *pboardobjgrp,
956 struct boardobjgrp_pmu_cmd *pcmd,
957 bool copy_out)
958{
959 struct nvgpu_pmu *pmu = &g->pmu;
960 struct nv_pmu_rpc_struct_board_obj_grp_cmd rpc;
961 int status = 0;
962
963 nvgpu_log_fn(g, " ");
964
965 memset(&rpc, 0, sizeof(struct nv_pmu_rpc_struct_board_obj_grp_cmd));
966
967 rpc.class_id = pboardobjgrp->pmu.classid;
968 rpc.command_id = copy_out ?
969 NV_PMU_BOARDOBJGRP_CMD_GET_STATUS :
970 NV_PMU_BOARDOBJGRP_CMD_SET;
971
972 rpc.hdr.unit_id = pboardobjgrp->pmu.unitid;
973 rpc.hdr.function = pboardobjgrp->pmu.rpc_func_id;
974 rpc.hdr.flags = 0x0;
975
976 status = nvgpu_pmu_rpc_execute(pmu, &(rpc.hdr),
977 (sizeof(rpc) - sizeof(rpc.scratch)),
978 pcmd->dmem_buffer_size,
979 NULL, NULL);
980
981 if (status) {
982 nvgpu_err(g, "Failed to execute RPC, status=0x%x", status);
983 }
984
985 return status;
986}