summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/perf/perf.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/perf/perf.c')
-rw-r--r--drivers/gpu/nvgpu/perf/perf.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/perf/perf.c b/drivers/gpu/nvgpu/perf/perf.c
new file mode 100644
index 00000000..3821a8dc
--- /dev/null
+++ b/drivers/gpu/nvgpu/perf/perf.c
@@ -0,0 +1,98 @@
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 "perf.h"
16#include "pmuif/gpmuifperf.h"
17#include "pmuif/gpmuifperfvfe.h"
18#include "gk20a/pmu_gk20a.h"
19
20struct perfrpc_pmucmdhandler_params {
21 struct nv_pmu_perf_rpc *prpccall;
22 u32 success;
23};
24
25static void perfrpc_pmucmdhandler(struct gk20a *g, struct pmu_msg *msg,
26 void *param, u32 handle, u32 status)
27{
28 struct perfrpc_pmucmdhandler_params *phandlerparams =
29 (struct perfrpc_pmucmdhandler_params *)param;
30
31 gk20a_dbg_info("");
32
33 if (msg->msg.perf.msg_type != NV_PMU_PERF_MSG_ID_RPC) {
34 gk20a_err(dev_from_gk20a(g),
35 "unsupported msg for VFE LOAD RPC %x",
36 msg->msg.perf.msg_type);
37 return;
38 }
39
40 if (phandlerparams->prpccall->b_supported)
41 phandlerparams->success = 1;
42}
43
44u32 perf_pmu_vfe_load(struct gk20a *g)
45{
46 struct pmu_cmd cmd;
47 struct pmu_msg msg;
48 struct pmu_payload payload = { {0} };
49 u32 status;
50 u32 seqdesc;
51 struct nv_pmu_perf_rpc rpccall = {0};
52 struct perfrpc_pmucmdhandler_params handler = {0};
53
54 rpccall.function = NV_PMU_PERF_RPC_ID_VFE_LOAD;
55 rpccall.params.vfe_load.b_load = true;
56 cmd.hdr.unit_id = PMU_UNIT_PERF;
57 cmd.hdr.size = (u32)sizeof(struct nv_pmu_perf_cmd) +
58 (u32)sizeof(struct pmu_hdr);
59
60 cmd.cmd.perf.cmd_type = NV_PMU_PERF_CMD_ID_RPC;
61 msg.hdr.size = sizeof(struct pmu_msg);
62
63 payload.in.buf = (u8 *)&rpccall;
64 payload.in.size = (u32)sizeof(struct nv_pmu_perf_rpc);
65 payload.in.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED;
66 payload.in.offset = NV_PMU_PERF_CMD_RPC_ALLOC_OFFSET;
67
68 payload.out.buf = (u8 *)&rpccall;
69 payload.out.size = (u32)sizeof(struct nv_pmu_perf_rpc);
70 payload.out.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED;
71 payload.out.offset = NV_PMU_PERF_MSG_RPC_ALLOC_OFFSET;
72
73 handler.prpccall = &rpccall;
74 handler.success = 0;
75
76 status = gk20a_pmu_cmd_post(g, &cmd, NULL, &payload,
77 PMU_COMMAND_QUEUE_LPQ,
78 perfrpc_pmucmdhandler, (void *)&handler,
79 &seqdesc, ~0);
80
81 if (status) {
82 gk20a_err(dev_from_gk20a(g),
83 "unable to post perf RPC cmd %x",
84 cmd.cmd.perf.cmd_type);
85 goto done;
86 }
87
88 pmu_wait_message_cond(&g->pmu,
89 gk20a_get_gr_idle_timeout(g),
90 &handler.success, 1);
91
92 if (handler.success == 0) {
93 status = -EINVAL;
94 gk20a_err(dev_from_gk20a(g), "rpc call to load VFE failed");
95 }
96done:
97 return status;
98}