diff options
author | Deepak Nibade <dnibade@nvidia.com> | 2016-12-27 05:01:00 -0500 |
---|---|---|
committer | Deepak Nibade <dnibade@nvidia.com> | 2016-12-27 05:35:06 -0500 |
commit | 7a81883a0d70c3a43ad2841ac235f6dc344c60fb (patch) | |
tree | 92923d2efccf90d1961071fa9acde59178a0d688 /drivers/gpu/nvgpu/therm/thrmpmu.c | |
parent | 505b442551a2e27aa3bc9e608c5a2bc9fccecbc4 (diff) | |
parent | 2aa3c85f8e82b3c07c39e677663abd3687c1822a (diff) |
Merge remote-tracking branch 'remotes/origin/dev/merge-nvgpu-t18x-into-nvgpu' into dev-kernel
Merge T186 - gp10b/gp106 code into common nvgpu repo
Bug 200266498
Change-Id: Ibf100ee38010cbed85c149b69b99147256f9a005
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/therm/thrmpmu.c')
-rw-r--r-- | drivers/gpu/nvgpu/therm/thrmpmu.c | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/therm/thrmpmu.c b/drivers/gpu/nvgpu/therm/thrmpmu.c new file mode 100644 index 00000000..0d0a4b3a --- /dev/null +++ b/drivers/gpu/nvgpu/therm/thrmpmu.c | |||
@@ -0,0 +1,142 @@ | |||
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 "include/bios.h" | ||
16 | #include "boardobj/boardobjgrp.h" | ||
17 | #include "boardobj/boardobjgrp_e32.h" | ||
18 | #include "pmuif/gpmuifboardobj.h" | ||
19 | #include "thrmpmu.h" | ||
20 | #include "pmuif/gpmuiftherm.h" | ||
21 | |||
22 | struct therm_pmucmdhandler_params { | ||
23 | struct nv_pmu_therm_rpc *prpccall; | ||
24 | u32 success; | ||
25 | }; | ||
26 | |||
27 | static void therm_pmucmdhandler(struct gk20a *g, struct pmu_msg *msg, | ||
28 | void *param, u32 handle, u32 status) | ||
29 | { | ||
30 | struct therm_pmucmdhandler_params *phandlerparams = | ||
31 | (struct therm_pmucmdhandler_params *)param; | ||
32 | |||
33 | if (msg->msg.therm.msg_type != NV_PMU_THERM_MSG_ID_RPC) { | ||
34 | gk20a_err(dev_from_gk20a(g), | ||
35 | "unknow msg %x", | ||
36 | msg->msg.pmgr.msg_type); | ||
37 | return; | ||
38 | } | ||
39 | |||
40 | if (!phandlerparams->prpccall->b_supported) | ||
41 | gk20a_err(dev_from_gk20a(g), | ||
42 | "RPC msg %x failed", | ||
43 | msg->msg.pmgr.msg_type); | ||
44 | else | ||
45 | phandlerparams->success = 1; | ||
46 | } | ||
47 | |||
48 | u32 therm_send_pmgr_tables_to_pmu(struct gk20a *g) | ||
49 | { | ||
50 | u32 status = 0; | ||
51 | struct boardobjgrp *pboardobjgrp = NULL; | ||
52 | |||
53 | if (!BOARDOBJGRP_IS_EMPTY(&g->therm_pmu.therm_deviceobjs.super.super)) { | ||
54 | pboardobjgrp = &g->therm_pmu.therm_deviceobjs.super.super; | ||
55 | status = pboardobjgrp->pmuinithandle(g, pboardobjgrp); | ||
56 | if (status) { | ||
57 | gk20a_err(dev_from_gk20a(g), | ||
58 | "therm_send_pmgr_tables_to_pmu - therm_device failed %x", | ||
59 | status); | ||
60 | goto exit; | ||
61 | } | ||
62 | } | ||
63 | |||
64 | if (!BOARDOBJGRP_IS_EMPTY( | ||
65 | &g->therm_pmu.therm_channelobjs.super.super)) { | ||
66 | pboardobjgrp = &g->therm_pmu.therm_channelobjs.super.super; | ||
67 | status = pboardobjgrp->pmuinithandle(g, pboardobjgrp); | ||
68 | if (status) { | ||
69 | gk20a_err(dev_from_gk20a(g), | ||
70 | "therm_send_pmgr_tables_to_pmu - therm_channel failed %x", | ||
71 | status); | ||
72 | goto exit; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | exit: | ||
77 | return status; | ||
78 | } | ||
79 | |||
80 | u32 therm_set_warn_temp_limit(struct gk20a *g) | ||
81 | { | ||
82 | u32 status; | ||
83 | u32 seqdesc = 0; | ||
84 | struct pmu_cmd cmd = { {0} }; | ||
85 | struct pmu_msg msg = { {0} }; | ||
86 | struct pmu_payload payload = { {0} }; | ||
87 | struct nv_pmu_therm_rpc rpccall = {0}; | ||
88 | struct therm_pmucmdhandler_params handlerparams = {0}; | ||
89 | |||
90 | rpccall.function = NV_PMU_THERM_RPC_ID_SLCT_EVENT_TEMP_TH_SET; | ||
91 | rpccall.params.slct_event_temp_th_set.event_id = | ||
92 | NV_PMU_THERM_EVENT_THERMAL_1; | ||
93 | rpccall.params.slct_event_temp_th_set.temp_threshold = g->curr_warn_temp; | ||
94 | rpccall.b_supported = 0; | ||
95 | |||
96 | cmd.hdr.unit_id = PMU_UNIT_THERM; | ||
97 | cmd.hdr.size = ((u32)sizeof(struct nv_pmu_therm_cmd) + | ||
98 | (u32)sizeof(struct pmu_hdr)); | ||
99 | cmd.cmd.therm.cmd_type = NV_PMU_THERM_CMD_ID_RPC; | ||
100 | |||
101 | msg.hdr.size = sizeof(struct pmu_msg); | ||
102 | |||
103 | payload.in.buf = (u8 *)&rpccall; | ||
104 | payload.in.size = (u32)sizeof(struct nv_pmu_therm_rpc); | ||
105 | payload.in.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED; | ||
106 | payload.in.offset = NV_PMU_THERM_CMD_RPC_ALLOC_OFFSET; | ||
107 | |||
108 | payload.out.buf = (u8 *)&rpccall; | ||
109 | payload.out.size = (u32)sizeof(struct nv_pmu_therm_rpc); | ||
110 | payload.out.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED; | ||
111 | payload.out.offset = NV_PMU_CLK_MSG_RPC_ALLOC_OFFSET; | ||
112 | |||
113 | /* Setup the handler params to communicate back results.*/ | ||
114 | handlerparams.success = 0; | ||
115 | handlerparams.prpccall = &rpccall; | ||
116 | |||
117 | status = gk20a_pmu_cmd_post(g, &cmd, NULL, &payload, | ||
118 | PMU_COMMAND_QUEUE_LPQ, | ||
119 | therm_pmucmdhandler, | ||
120 | (void *)&handlerparams, | ||
121 | &seqdesc, ~0); | ||
122 | if (status) { | ||
123 | gk20a_err(dev_from_gk20a(g), | ||
124 | "unable to post pmgr cmd for unit %x cmd id %x size %x", | ||
125 | cmd.hdr.unit_id, cmd.cmd.therm.cmd_type, cmd.hdr.size); | ||
126 | goto exit; | ||
127 | } | ||
128 | |||
129 | pmu_wait_message_cond(&g->pmu, | ||
130 | gk20a_get_gr_idle_timeout(g), | ||
131 | &handlerparams.success, 1); | ||
132 | |||
133 | if (handlerparams.success == 0) { | ||
134 | gk20a_err(dev_from_gk20a(g), "could not process cmd\n"); | ||
135 | status = -ETIMEDOUT; | ||
136 | goto exit; | ||
137 | } | ||
138 | |||
139 | exit: | ||
140 | return status; | ||
141 | } | ||
142 | |||