diff options
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c | 134 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a.h | 1 | ||||
-rw-r--r-- | include/uapi/linux/nvgpu.h | 33 |
3 files changed, 167 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 | |||
1067 | static int nvgpu_gpu_clk_get_info(struct gk20a *g, | 1066 | static 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 | |||
1175 | static 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 | |||
1211 | static 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 | |||
1235 | static 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 | |||
1259 | static 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 | ||
1177 | long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | 1289 | long 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: |
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index 564026a4..071111ab 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h | |||
@@ -588,6 +588,7 @@ struct gpu_ops { | |||
588 | int (*init_therm_setup_hw)(struct gk20a *g); | 588 | int (*init_therm_setup_hw)(struct gk20a *g); |
589 | int (*elcg_init_idle_filters)(struct gk20a *g); | 589 | int (*elcg_init_idle_filters)(struct gk20a *g); |
590 | void (*therm_debugfs_init)(struct gk20a *g); | 590 | void (*therm_debugfs_init)(struct gk20a *g); |
591 | int (*get_internal_sensor_curr_temp)(struct gk20a *g, u32 *temp_f24_8); | ||
591 | } therm; | 592 | } therm; |
592 | struct { | 593 | struct { |
593 | bool (*is_pmu_supported)(struct gk20a *g); | 594 | bool (*is_pmu_supported)(struct gk20a *g); |
diff --git a/include/uapi/linux/nvgpu.h b/include/uapi/linux/nvgpu.h index 13492e0d..f45be911 100644 --- a/include/uapi/linux/nvgpu.h +++ b/include/uapi/linux/nvgpu.h | |||
@@ -721,6 +721,31 @@ struct nvgpu_gpu_get_fbp_l2_masks_args { | |||
721 | __u64 mask_buf_addr; | 721 | __u64 mask_buf_addr; |
722 | }; | 722 | }; |
723 | 723 | ||
724 | #define NVGPU_GPU_VOLTAGE_CORE 1 | ||
725 | #define NVGPU_GPU_VOLTAGE_SRAM 2 | ||
726 | #define NVGPU_GPU_VOLTAGE_BUS 3 /* input to regulator */ | ||
727 | |||
728 | struct nvgpu_gpu_get_voltage_args { | ||
729 | __u64 reserved; | ||
730 | __u32 which; /* in: NVGPU_GPU_VOLTAGE_* */ | ||
731 | __u32 voltage; /* uV */ | ||
732 | }; | ||
733 | |||
734 | struct nvgpu_gpu_get_current_args { | ||
735 | __u32 reserved[3]; | ||
736 | __u32 currnt; /* mA */ | ||
737 | }; | ||
738 | |||
739 | struct nvgpu_gpu_get_power_args { | ||
740 | __u32 reserved[3]; | ||
741 | __u32 power; /* mW */ | ||
742 | }; | ||
743 | |||
744 | struct nvgpu_gpu_get_temperature_args { | ||
745 | __u32 reserved[3]; | ||
746 | __u32 temperature; /* mC */ | ||
747 | }; | ||
748 | |||
724 | #define NVGPU_GPU_IOCTL_ZCULL_GET_CTX_SIZE \ | 749 | #define NVGPU_GPU_IOCTL_ZCULL_GET_CTX_SIZE \ |
725 | _IOR(NVGPU_GPU_IOCTL_MAGIC, 1, struct nvgpu_gpu_zcull_get_ctx_size_args) | 750 | _IOR(NVGPU_GPU_IOCTL_MAGIC, 1, struct nvgpu_gpu_zcull_get_ctx_size_args) |
726 | #define NVGPU_GPU_IOCTL_ZCULL_GET_INFO \ | 751 | #define NVGPU_GPU_IOCTL_ZCULL_GET_INFO \ |
@@ -792,6 +817,14 @@ struct nvgpu_gpu_get_fbp_l2_masks_args { | |||
792 | #define NVGPU_GPU_IOCTL_GET_MEMORY_STATE \ | 817 | #define NVGPU_GPU_IOCTL_GET_MEMORY_STATE \ |
793 | _IOWR(NVGPU_GPU_IOCTL_MAGIC, 33, \ | 818 | _IOWR(NVGPU_GPU_IOCTL_MAGIC, 33, \ |
794 | struct nvgpu_gpu_get_memory_state_args) | 819 | struct nvgpu_gpu_get_memory_state_args) |
820 | #define NVGPU_GPU_IOCTL_GET_VOLTAGE \ | ||
821 | _IOWR(NVGPU_GPU_IOCTL_MAGIC, 33, struct nvgpu_gpu_get_voltage_args) | ||
822 | #define NVGPU_GPU_IOCTL_GET_CURRENT \ | ||
823 | _IOWR(NVGPU_GPU_IOCTL_MAGIC, 34, struct nvgpu_gpu_get_current_args) | ||
824 | #define NVGPU_GPU_IOCTL_GET_POWER \ | ||
825 | _IOWR(NVGPU_GPU_IOCTL_MAGIC, 35, struct nvgpu_gpu_get_power_args) | ||
826 | #define NVGPU_GPU_IOCTL_GET_TEMPERATURE \ | ||
827 | _IOWR(NVGPU_GPU_IOCTL_MAGIC, 36, struct nvgpu_gpu_get_temperature_args) | ||
795 | #define NVGPU_GPU_IOCTL_GET_FBP_L2_MASKS \ | 828 | #define NVGPU_GPU_IOCTL_GET_FBP_L2_MASKS \ |
796 | _IOWR(NVGPU_GPU_IOCTL_MAGIC, 38, struct nvgpu_gpu_get_fbp_l2_masks_args) | 829 | _IOWR(NVGPU_GPU_IOCTL_MAGIC, 38, struct nvgpu_gpu_get_fbp_l2_masks_args) |
797 | #define NVGPU_GPU_IOCTL_LAST \ | 830 | #define NVGPU_GPU_IOCTL_LAST \ |