From 3e5e4804f9c2bf5b914012852b56dbbbc00f8253 Mon Sep 17 00:00:00 2001 From: Mahantesh Kumbar Date: Fri, 16 Mar 2018 23:33:23 +0530 Subject: gpu: nvgpu: gv10x therm boardobj support - Added support for below multiple therm sensor device & defined macros GPC_TSOSC GPC SCI HBM2_SITE HBM2_COMBINED - Added PMU interface for listed therm sensor device - Added nvgpu interface for listed therm sensor device - Added construct boardobj support for listed therm sensor device & called to update nvgpu interface. - Updated devinit_get_therm_device_table() to read sensor info from therm device table from vbios table & construct respective therm device boardobj using construct_therm_device_*() based on class_id param read from vbios table. - Updated RPC handler to handle THERM ack request - Updated gv100 therm ops "get_internal_sensor_limits" to point to gp106_get_internal_sensor_limits() Change-Id: I4b4ed501d0625cb8fc7b300c820622e40ae59fe6 Signed-off-by: Mahantesh Kumbar Reviewed-on: https://git-master.nvidia.com/r/1676785 Reviewed-by: svc-misra-checker GVS: Gerrit_Virtual_Submit Reviewed-by: Vaikundanathan S Tested-by: Vaikundanathan S Reviewed-by: Vijayakumar Subbu Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/pmu/pmu_ipc.c | 12 +- drivers/gpu/nvgpu/include/nvgpu/bios.h | 7 +- .../nvgpu/include/nvgpu/pmuif/gpmuifthermsensor.h | 22 +++ drivers/gpu/nvgpu/therm/thrmdev.c | 217 ++++++++++++++++++--- drivers/gpu/nvgpu/therm/thrmdev.h | 20 +- 5 files changed, 249 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/nvgpu/common/pmu/pmu_ipc.c b/drivers/gpu/nvgpu/common/pmu/pmu_ipc.c index 68654a70..843a4551 100644 --- a/drivers/gpu/nvgpu/common/pmu/pmu_ipc.c +++ b/drivers/gpu/nvgpu/common/pmu/pmu_ipc.c @@ -841,8 +841,16 @@ static void pmu_rpc_handler(struct gk20a *g, struct pmu_msg *msg, nvgpu_pmu_dbg(g, "reply PMU_UNIT_PERF"); break; case PMU_UNIT_THERM: - nvgpu_pmu_dbg(g, "reply PMU_UNIT_THERM"); - break; + switch (rpc.function) { + case NV_PMU_RPC_ID_THERM_BOARD_OBJ_GRP_CMD: + nvgpu_pmu_dbg(g, + "reply NV_PMU_RPC_ID_THERM_BOARD_OBJ_GRP_CMD"); + break; + default: + nvgpu_pmu_dbg(g, "reply PMU_UNIT_THERM"); + break; + } + break; /* TBD case will be added */ default: nvgpu_err(g, " Invalid RPC response, stats 0x%x", diff --git a/drivers/gpu/nvgpu/include/nvgpu/bios.h b/drivers/gpu/nvgpu/include/nvgpu/bios.h index 0619fcb9..0323dce4 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/bios.h +++ b/drivers/gpu/nvgpu/include/nvgpu/bios.h @@ -890,7 +890,12 @@ struct therm_device_1x_entry { u8 flags; } ; -#define NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_GPU 0x01 +#define NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_INVALID 0x00 +#define NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_GPU 0x01 +#define NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_GPU_GPC_TSOSC 0x02 +#define NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_GPU_GPC_SCI 0x03 +#define NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_HBM2_SITE 0x70 +#define NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_HBM2_COMBINED 0x71 #define NV_VBIOS_THERM_DEVICE_1X_ENTRY_PARAM0_I2C_DEVICE_INDEX_MASK 0xFF #define NV_VBIOS_THERM_DEVICE_1X_ENTRY_PARAM0_I2C_DEVICE_INDEX_SHIFT 0 diff --git a/drivers/gpu/nvgpu/include/nvgpu/pmuif/gpmuifthermsensor.h b/drivers/gpu/nvgpu/include/nvgpu/pmuif/gpmuifthermsensor.h index 994cd5b7..8f2a8584 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/pmuif/gpmuifthermsensor.h +++ b/drivers/gpu/nvgpu/include/nvgpu/pmuif/gpmuifthermsensor.h @@ -41,15 +41,37 @@ struct nv_pmu_therm_therm_device_boardobj_set { struct nv_pmu_boardobj super; }; +struct nv_pmu_therm_therm_device_gpu_gpc_tsosc_boardobj_set { + struct nv_pmu_therm_therm_device_boardobj_set super; + u8 gpc_tsosc_idx; +}; + +struct nv_pmu_therm_therm_device_gpu_sci_boardobj_set { + struct nv_pmu_therm_therm_device_boardobj_set super; +}; + struct nv_pmu_therm_therm_device_i2c_boardobj_set { struct nv_pmu_therm_therm_device_boardobj_set super; u8 i2c_dev_idx; }; +struct nv_pmu_therm_therm_device_hbm2_site_boardobj_set { + struct nv_pmu_therm_therm_device_boardobj_set super; + u8 site_idx; +}; + +struct nv_pmu_therm_therm_device_hbm2_combined_boardobj_set { + struct nv_pmu_therm_therm_device_boardobj_set super; +}; + union nv_pmu_therm_therm_device_boardobj_set_union { struct nv_pmu_boardobj board_obj; struct nv_pmu_therm_therm_device_boardobj_set therm_device; + struct nv_pmu_therm_therm_device_gpu_gpc_tsosc_boardobj_set gpu_gpc_tsosc; + struct nv_pmu_therm_therm_device_gpu_sci_boardobj_set gpu_sci; struct nv_pmu_therm_therm_device_i2c_boardobj_set i2c; + struct nv_pmu_therm_therm_device_hbm2_site_boardobj_set hbm2_site; + struct nv_pmu_therm_therm_device_hbm2_combined_boardobj_set hbm2_combined; }; NV_PMU_BOARDOBJ_GRP_SET_MAKE_E32(therm, therm_device); diff --git a/drivers/gpu/nvgpu/therm/thrmdev.c b/drivers/gpu/nvgpu/therm/thrmdev.c index 7371ba25..aaf0a461 100644 --- a/drivers/gpu/nvgpu/therm/thrmdev.c +++ b/drivers/gpu/nvgpu/therm/thrmdev.c @@ -30,22 +30,6 @@ #include "gp106/bios_gp106.h" #include "ctrl/ctrltherm.h" -static struct boardobj *construct_therm_device(struct gk20a *g, - void *pargs, u16 pargs_size, u8 type) -{ - struct boardobj *board_obj_ptr = NULL; - u32 status; - - status = boardobj_construct_super(g, &board_obj_ptr, - pargs_size, pargs); - if (status) - return NULL; - - nvgpu_log_info(g, " Done"); - - return board_obj_ptr; -} - static u32 _therm_device_pmudata_instget(struct gk20a *g, struct nv_pmu_boardobjgrp *pmuboardobjgrp, struct nv_pmu_boardobj **ppboardobjpmudata, @@ -70,6 +54,168 @@ static u32 _therm_device_pmudata_instget(struct gk20a *g, return 0; } +static u32 construct_therm_device(struct gk20a *g, + struct boardobj **ppboardobj, u16 size, void *pargs) +{ + return boardobj_construct_super(g, ppboardobj, size, pargs); +} + +static u32 construct_therm_device_gpu(struct gk20a *g, + struct boardobj **ppboardobj, u16 size, void *pargs) +{ + return construct_therm_device(g, ppboardobj, size, pargs); +} + +static u32 construct_therm_device_gpu_sci(struct gk20a *g, + struct boardobj **ppboardobj, u16 size, void *pargs) +{ + return construct_therm_device(g, ppboardobj, size, pargs); +} + + +static u32 therm_device_pmu_data_init_gpu_gpc_tsosc(struct gk20a *g, + struct boardobj *pboard_obj, struct nv_pmu_boardobj *ppmudata) +{ + u32 status = 0; + struct therm_device_gpu_gpc_tsosc *pdev = NULL; + struct nv_pmu_therm_therm_device_gpu_gpc_tsosc_boardobj_set *pset; + + status = boardobj_pmudatainit_super(g, pboard_obj, ppmudata); + if (status != 0) { + goto exit; + } + + pdev = (struct therm_device_gpu_gpc_tsosc *)(void *)pboard_obj; + pset = (struct nv_pmu_therm_therm_device_gpu_gpc_tsosc_boardobj_set *) + (void*) ppmudata; + + pset->gpc_tsosc_idx = pdev->gpc_tsosc_idx; + +exit: + return status; +} + +static u32 construct_therm_device_gpu_tsosc(struct gk20a *g, + struct boardobj **ppboardobj, u16 size, void *pargs) +{ + struct therm_device_gpu_gpc_tsosc *pdev = NULL; + struct therm_device_gpu_gpc_tsosc *ptmp_dev = + (struct therm_device_gpu_gpc_tsosc *)pargs; + u32 status = 0; + + status = construct_therm_device(g, ppboardobj, size, pargs); + if (status != 0) { + return status; + } + + pdev = (struct therm_device_gpu_gpc_tsosc *)(void *)*ppboardobj; + + pdev->super.super.pmudatainit = + therm_device_pmu_data_init_gpu_gpc_tsosc; + + pdev->gpc_tsosc_idx = ptmp_dev->gpc_tsosc_idx; + + return status; +} + +static u32 therm_device_pmu_data_init_hbm2_site(struct gk20a *g, + struct boardobj *pboard_obj, struct nv_pmu_boardobj *ppmudata) +{ + u32 status = 0; + struct therm_device_hbm2_site *pdev = NULL; + struct nv_pmu_therm_therm_device_hbm2_site_boardobj_set *pset; + + status = boardobj_pmudatainit_super(g, pboard_obj, ppmudata); + if (status != 0) { + goto exit; + } + + pdev = (struct therm_device_hbm2_site *)(void *)pboard_obj; + pset = (struct nv_pmu_therm_therm_device_hbm2_site_boardobj_set *) + (void *)ppmudata; + + pset->site_idx = pdev->site_idx; + +exit: + return status; +} + +static u32 construct_therm_device_hbm2_site(struct gk20a *g, + struct boardobj **ppboardobj, u16 size, void *pargs) +{ + struct therm_device_hbm2_site *pdev = NULL; + struct therm_device_hbm2_site *ptmp_dev = + (struct therm_device_hbm2_site *)pargs; + u32 status = 0; + + status = construct_therm_device(g, ppboardobj, size, pargs); + if (status != 0) { + return status; + } + + pdev = (struct therm_device_hbm2_site *)(void *)*ppboardobj; + + pdev->super.super.pmudatainit = + therm_device_pmu_data_init_hbm2_site; + + pdev->site_idx = ptmp_dev->site_idx; + + return status; +} + +static u32 construct_therm_device_hbm2_combined(struct gk20a *g, + struct boardobj **ppboardobj, u16 size, void *pargs) +{ + return construct_therm_device(g, ppboardobj, size, pargs); +} + + +static struct boardobj *therm_device_construct(struct gk20a *g, + void *pargs) +{ + struct boardobj *board_obj_ptr = NULL; + u32 status = 0; + + switch (BOARDOBJ_GET_TYPE(pargs)) { + case NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_GPU: + status = construct_therm_device_gpu(g, &board_obj_ptr, + sizeof(struct therm_device), pargs); + break; + case NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_GPU_GPC_SCI: + status = construct_therm_device_gpu_sci(g, &board_obj_ptr, + sizeof(struct therm_device_gpu_sci), pargs); + break; + case NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_GPU_GPC_TSOSC: + status = construct_therm_device_gpu_tsosc(g, &board_obj_ptr, + sizeof(struct therm_device_gpu_gpc_tsosc), pargs); + break; + case NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_HBM2_SITE: + status = construct_therm_device_hbm2_site(g, &board_obj_ptr, + sizeof(struct therm_device_hbm2_site), pargs); + break; + case NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_HBM2_COMBINED: + status = construct_therm_device_hbm2_combined(g, &board_obj_ptr, + sizeof(struct therm_device_hbm2_combined), pargs); + break; + default: + nvgpu_err(g, + "unsupported therm_device class - 0x%x", + BOARDOBJ_GET_TYPE(pargs)); + break; + } + + if(status) { + board_obj_ptr = NULL; + nvgpu_err(g, + "could not allocate memory for therm_device"); + if (board_obj_ptr != NULL) + nvgpu_kfree(g, board_obj_ptr); + } + + + return board_obj_ptr; +} + static u32 devinit_get_therm_device_table(struct gk20a *g, struct therm_devices *pthermdeviceobjs) { @@ -81,10 +227,14 @@ static u32 devinit_get_therm_device_table(struct gk20a *g, struct therm_device_1x_entry *therm_device_table_entry = NULL; u32 index; u32 obj_index = 0; - u16 therm_device_size = 0; + u8 class_id = 0; union { struct boardobj boardobj; struct therm_device therm_device; + struct therm_device_gpu_sci gpu_sci; + struct therm_device_gpu_gpc_tsosc gpu_gpc_tsosc; + struct therm_device_hbm2_site hbm2_site; + struct therm_device_hbm2_combined hbm2_combined; } therm_device_data; nvgpu_log_info(g, " "); @@ -120,17 +270,34 @@ static u32 devinit_get_therm_device_table(struct gk20a *g, (curr_therm_device_table_ptr + (therm_device_table_header.table_entry_size * index)); - if (therm_device_table_entry->class_id != - NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_GPU) { + class_id = therm_device_table_entry->class_id; + + switch (class_id) { + case NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_INVALID: continue; + break; + case NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_GPU: + case NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_GPU_GPC_SCI: + break; + case NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_GPU_GPC_TSOSC: + therm_device_data.gpu_gpc_tsosc.gpc_tsosc_idx = + therm_device_table_entry->param0; + break; + case NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_HBM2_SITE: + therm_device_data.hbm2_site.site_idx = + therm_device_table_entry->param0; + break; + case NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_HBM2_COMBINED: + break; + default: + nvgpu_err(g, + "Unknown thermal device class i - %x, class - %x", + index, class_id); + goto done; } - therm_device_size = sizeof(struct therm_device); - therm_device_data.boardobj.type = CTRL_THERMAL_THERM_DEVICE_CLASS_GPU; - - boardobj = construct_therm_device(g, &therm_device_data, - therm_device_size, therm_device_data.boardobj.type); - + therm_device_data.boardobj.type = class_id; + boardobj = therm_device_construct(g, &therm_device_data); if (!boardobj) { nvgpu_err(g, "unable to create thermal device for %d type %d", diff --git a/drivers/gpu/nvgpu/therm/thrmdev.h b/drivers/gpu/nvgpu/therm/thrmdev.h index 83ff5cbf..af349c88 100644 --- a/drivers/gpu/nvgpu/therm/thrmdev.h +++ b/drivers/gpu/nvgpu/therm/thrmdev.h @@ -32,7 +32,25 @@ struct therm_devices { }; struct therm_device { - struct therm_devices super; + struct boardobj super; +}; + +struct therm_device_gpu_sci { + struct therm_device super; +}; + +struct therm_device_gpu_gpc_tsosc { + struct therm_device super; + u8 gpc_tsosc_idx; +}; + +struct therm_device_hbm2_site { + struct therm_device super; + u8 site_idx; +}; + +struct therm_device_hbm2_combined { + struct therm_device super; }; u32 therm_device_sw_setup(struct gk20a *g); -- cgit v1.2.2