From 370ac6cc987f313105d548ec47d44cbaeb6950c4 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Fri, 14 Aug 2020 22:17:47 -0500 Subject: [PATCH] gpu: nvgpu: Update grmgr code to use nvgpu_device struct Instead of the nvgpu_engine_get_ids() function that will shortly be deleted, use the new nvgpu_device_get_copies() function. JIRA NVGPU-5421 Change-Id: I2b778b7818e885c807dfa90f15d03cddba9e59fc Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2399165 Reviewed-by: automaticguardword Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert Reviewed-by: Konsta Holtta Reviewed-by: Lakshmanan M Reviewed-by: svc-mobile-misra Reviewed-by: mobile promotions Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/grmgr/grmgr.c | 25 +++++++++---------------- drivers/gpu/nvgpu/include/nvgpu/mig.h | 9 +++++---- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/nvgpu/common/grmgr/grmgr.c b/drivers/gpu/nvgpu/common/grmgr/grmgr.c index 9c28decc8..557b4e1c7 100644 --- a/drivers/gpu/nvgpu/common/grmgr/grmgr.c +++ b/drivers/gpu/nvgpu/common/grmgr/grmgr.c @@ -27,6 +27,7 @@ #include #include #include +#include int nvgpu_init_gr_manager(struct gk20a *g) { @@ -45,8 +46,10 @@ int nvgpu_init_gr_manager(struct gk20a *g) gr_syspipe->gr_instance_id = 0U; gr_syspipe->gr_syspipe_id = 0U; - gr_syspipe->engine_id = 0U; gr_syspipe->num_gpc = g->mig.gpc_count; + gr_syspipe->gr_dev = nvgpu_device_get(g, NVGPU_DEVTYPE_GRAPHICS, 0U); + nvgpu_assert(gr_syspipe->gr_dev != NULL); + g->mig.gpcgrp_gpc_count[0] = gr_syspipe->num_gpc; if (g->ops.gr.config.get_gpc_mask != NULL) { gr_syspipe->gpc_mask = g->ops.gr.config.get_gpc_mask(g); @@ -55,6 +58,7 @@ int nvgpu_init_gr_manager(struct gk20a *g) BIT32(gr_syspipe->num_gpc), 1U); } + /* In Legacy mode, Local GPC Id = physical GPC Id = Logical GPC Id */ for (gpc_id = 0U; gpc_id < gr_syspipe->num_gpc; gpc_id++) { gr_syspipe->gpcs[gpc_id].logical_id = @@ -64,20 +68,9 @@ int nvgpu_init_gr_manager(struct gk20a *g) gr_syspipe->max_veid_count_per_tsg = g->fifo.max_subctx_count; gr_syspipe->veid_start_offset = 0U; - gpu_instance->num_lce = nvgpu_engine_get_ids(g, - gpu_instance->lce_engine_ids, - NVGPU_MIG_MAX_ENGINES, NVGPU_ENGINE_ASYNC_CE); - - if (gpu_instance->num_lce == 0U) { - /* Fall back to GRCE */ - gpu_instance->num_lce = nvgpu_engine_get_ids(g, - gpu_instance->lce_engine_ids, - NVGPU_MIG_MAX_ENGINES, NVGPU_ENGINE_GRCE); - if (gpu_instance->num_lce == 0U) { - nvgpu_warn(g, - "No GRCE engine available on this device!"); - } - } + gpu_instance->num_lce = nvgpu_device_get_copies(g, gpu_instance->lce_devs, + NVGPU_MIG_MAX_ENGINES); + nvgpu_assert(gpu_instance->num_lce > 0U); g->mig.max_gr_sys_pipes_supported = 1U; g->mig.gr_syspipe_en_mask = 1U; @@ -94,7 +87,7 @@ int nvgpu_init_gr_manager(struct gk20a *g) gr_syspipe->gr_instance_id, gr_syspipe->gr_syspipe_id, gr_syspipe->num_gpc, - gr_syspipe->engine_id, + gr_syspipe->gr_dev->engine_id, gr_syspipe->max_veid_count_per_tsg, gr_syspipe->veid_start_offset, gpu_instance->is_memory_partition_supported, diff --git a/drivers/gpu/nvgpu/include/nvgpu/mig.h b/drivers/gpu/nvgpu/include/nvgpu/mig.h index dc276a5a5..1de8ba759 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/mig.h +++ b/drivers/gpu/nvgpu/include/nvgpu/mig.h @@ -70,11 +70,12 @@ struct nvgpu_gr_syspipe { u32 gr_instance_id; /** GR syspipe id which is used to set gr remap window */ u32 gr_syspipe_id; + /** - * The unique per-device ID that host uses to identify any given engine. + * GR device that belongs to this syspipe. */ - u32 engine_id; - /** Number of GPC assigned to this gr syspipe. */ + const struct nvgpu_device *gr_dev; + u32 num_gpc; /** GPC Id information (logical, physical and gpcgrp Ids). */ @@ -104,7 +105,7 @@ struct nvgpu_gpu_instance { /** Number of Logical CE engine associated to this gpu instances. */ u32 num_lce; /** Memory area to store h/w CE engine ids. */ - u32 lce_engine_ids[NVGPU_MIG_MAX_ENGINES]; + const struct nvgpu_device *lce_devs[NVGPU_MIG_MAX_ENGINES]; /* Flag to indicate whether memory partition is supported or not. */ bool is_memory_partition_supported; };