diff --git a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c index 5660f521e..defa4fdd2 100644 --- a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c @@ -582,11 +582,24 @@ static int gk20a_ctrl_vsm_mapping(struct gk20a *g, { int err = 0; struct gr_gk20a *gr = &g->gr; - size_t write_size = gr->no_of_sm * sizeof(struct sm_info); + size_t write_size = gr->no_of_sm * + sizeof(struct nvgpu_gpu_vsms_mapping_entry); + struct nvgpu_gpu_vsms_mapping_entry *vsms_buf; + u32 i; + + vsms_buf = kzalloc(write_size, GFP_KERNEL); + if (vsms_buf == NULL) + return -ENOMEM; + + for (i = 0; i < gr->no_of_sm; i++) { + vsms_buf[i].gpc_index = gr->sm_to_cluster[i].gpc_index; + vsms_buf[i].tpc_index = gr->sm_to_cluster[i].tpc_index; + } err = copy_to_user((void __user *)(uintptr_t) args->vsms_map_buf_addr, - gr->sm_to_cluster, write_size); + vsms_buf, write_size); + kfree(vsms_buf); return err; } diff --git a/include/uapi/linux/nvgpu.h b/include/uapi/linux/nvgpu.h index 649cdf024..052bebc8c 100644 --- a/include/uapi/linux/nvgpu.h +++ b/include/uapi/linux/nvgpu.h @@ -383,6 +383,11 @@ struct nvgpu_gpu_num_vsms { __u32 reserved; }; +struct nvgpu_gpu_vsms_mapping_entry { + __u8 gpc_index; + __u8 tpc_index; +}; + struct nvgpu_gpu_vsms_mapping { __u64 vsms_map_buf_addr; };