summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c
diff options
context:
space:
mode:
authorThomas Fleury <tfleury@nvidia.com>2016-10-21 19:43:47 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2016-12-09 23:24:07 -0500
commitdfb061cbdbc0a87391e475b5d86303cb028eb549 (patch)
treeba0be402c85d13be093467f8877e3174a771c683 /drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c
parent71ecc8f660503eed4a094b1b1531e8e92a6de0bb (diff)
gpu: nvgpu: get voltage, current, power and temperature
Add ioctls to retrieve voltage, current, power and temperature. Add flags in GPU characteristics to indicate if feature is supported. Jira DNVGPU-166 Change-Id: Idd5a767326c9d43630e8289ca7d2c27bb96a9f14 Signed-off-by: David Nieto <dmartineznie@nvidia.com> Reviewed-on: http://git-master/r/1241862 Tested-by: Thomas Fleury <tfleury@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com> Reviewed-on: http://git-master/r/1267153
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c134
1 files changed, 133 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c
index 3de84851..23fbdce0 100644
--- a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c
@@ -1063,7 +1063,6 @@ static int nvgpu_gpu_clk_set_info(struct gk20a *g,
1063 return ret; 1063 return ret;
1064} 1064}
1065 1065
1066
1067static int nvgpu_gpu_clk_get_info(struct gk20a *g, 1066static int nvgpu_gpu_clk_get_info(struct gk20a *g,
1068 struct gk20a_ctrl_priv *priv, 1067 struct gk20a_ctrl_priv *priv,
1069 struct nvgpu_gpu_clk_get_info_args *args) 1068 struct nvgpu_gpu_clk_get_info_args *args)
@@ -1172,6 +1171,119 @@ static int nvgpu_gpu_clk_get_event_fd(struct gk20a *g,
1172 1171
1173 return nvgpu_clk_arb_install_event_fd(g, session, &args->event_fd); 1172 return nvgpu_clk_arb_install_event_fd(g, session, &args->event_fd);
1174} 1173}
1174
1175static int nvgpu_gpu_get_voltage(struct gk20a *g,
1176 struct nvgpu_gpu_get_voltage_args *args)
1177{
1178 int err = -EINVAL;
1179
1180 gk20a_dbg_fn("");
1181
1182 if (args->reserved)
1183 return -EINVAL;
1184
1185 if (!(g->gpu_characteristics.flags & NVGPU_GPU_FLAGS_SUPPORT_GET_VOLTAGE))
1186 return -EINVAL;
1187
1188 err = gk20a_busy(g->dev);
1189 if (err)
1190 return err;
1191
1192 switch (args->which) {
1193 case NVGPU_GPU_VOLTAGE_CORE:
1194 err = volt_get_voltage(g, CTRL_VOLT_DOMAIN_LOGIC, &args->voltage);
1195 break;
1196 case NVGPU_GPU_VOLTAGE_SRAM:
1197 err = volt_get_voltage(g, CTRL_VOLT_DOMAIN_SRAM, &args->voltage);
1198 break;
1199 case NVGPU_GPU_VOLTAGE_BUS:
1200 err = pmgr_pwr_devices_get_voltage(g, &args->voltage);
1201 break;
1202 default:
1203 err = -EINVAL;
1204 }
1205
1206 gk20a_idle(g->dev);
1207
1208 return err;
1209}
1210
1211static int nvgpu_gpu_get_current(struct gk20a *g,
1212 struct nvgpu_gpu_get_current_args *args)
1213{
1214 int err;
1215
1216 gk20a_dbg_fn("");
1217
1218 if (args->reserved[0] || args->reserved[1] || args->reserved[2])
1219 return -EINVAL;
1220
1221 if (!(g->gpu_characteristics.flags & NVGPU_GPU_FLAGS_SUPPORT_GET_CURRENT))
1222 return -EINVAL;
1223
1224 err = gk20a_busy(g->dev);
1225 if (err)
1226 return err;
1227
1228 err = pmgr_pwr_devices_get_current(g, &args->currnt);
1229
1230 gk20a_idle(g->dev);
1231
1232 return err;
1233}
1234
1235static int nvgpu_gpu_get_power(struct gk20a *g,
1236 struct nvgpu_gpu_get_power_args *args)
1237{
1238 int err;
1239
1240 gk20a_dbg_fn("");
1241
1242 if (args->reserved[0] || args->reserved[1] || args->reserved[2])
1243 return -EINVAL;
1244
1245 if (!(g->gpu_characteristics.flags & NVGPU_GPU_FLAGS_SUPPORT_GET_POWER))
1246 return -EINVAL;
1247
1248 err = gk20a_busy(g->dev);
1249 if (err)
1250 return err;
1251
1252 err = pmgr_pwr_devices_get_power(g, &args->power);
1253
1254 gk20a_idle(g->dev);
1255
1256 return err;
1257}
1258
1259static int nvgpu_gpu_get_temperature(struct gk20a *g,
1260 struct nvgpu_gpu_get_temperature_args *args)
1261{
1262 int err;
1263 u32 temp_f24_8;
1264
1265 gk20a_dbg_fn("");
1266
1267 if (args->reserved[0] || args->reserved[1] || args->reserved[2])
1268 return -EINVAL;
1269
1270 if (!g->ops.therm.get_internal_sensor_curr_temp)
1271 return -EINVAL;
1272
1273 err = gk20a_busy(g->dev);
1274 if (err)
1275 return err;
1276
1277 err = g->ops.therm.get_internal_sensor_curr_temp(g, &temp_f24_8);
1278
1279 gk20a_idle(g->dev);
1280
1281 /* Convert from standard S24.8 fixed point to mC */
1282 if (!err)
1283 args->temperature = (temp_f24_8 * 1000) / 256;
1284
1285 return err;
1286}
1175#endif 1287#endif
1176 1288
1177long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 1289long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
@@ -1461,6 +1573,26 @@ long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg
1461 err = nvgpu_gpu_clk_get_event_fd(g, priv, 1573 err = nvgpu_gpu_clk_get_event_fd(g, priv,
1462 (struct nvgpu_gpu_clk_get_event_fd_args *)buf); 1574 (struct nvgpu_gpu_clk_get_event_fd_args *)buf);
1463 break; 1575 break;
1576
1577 case NVGPU_GPU_IOCTL_GET_VOLTAGE:
1578 err = nvgpu_gpu_get_voltage(g,
1579 (struct nvgpu_gpu_get_voltage_args *)buf);
1580 break;
1581
1582 case NVGPU_GPU_IOCTL_GET_CURRENT:
1583 err = nvgpu_gpu_get_current(g,
1584 (struct nvgpu_gpu_get_current_args *)buf);
1585 break;
1586
1587 case NVGPU_GPU_IOCTL_GET_POWER:
1588 err = nvgpu_gpu_get_power(g,
1589 (struct nvgpu_gpu_get_power_args *)buf);
1590 break;
1591
1592 case NVGPU_GPU_IOCTL_GET_TEMPERATURE:
1593 err = nvgpu_gpu_get_temperature(g,
1594 (struct nvgpu_gpu_get_temperature_args *)buf);
1595 break;
1464#endif 1596#endif
1465 1597
1466 default: 1598 default: