gpu: nvgpu: add macros to get current GR instance

Add macros to get current GR instance id and the pointer
nvgpu_gr_get_cur_instance_ptr()
nvgpu_gr_get_cur_instance_id()

This approach makes sure that the caller is getting GR instance pointer
under mutex g->mig.gr_syspipe_lock in MIG mode. Trying to access
current GR instance outside of this lock in MIG mode dumps a warning.

Return 0th instance in case MIG mode is disabled.

Use these macros in nvgpu instead of direct reference to
g->mig.cur_gr_instance.

Store instance id in struct nvgpu_gr. This is to retrieve GR instance
id in functions where struct nvgpu_gr pointer is already available.

Jira NVGPU-5648

Change-Id: Ibfef6a22371bfdccfdc2a7d636b0a3e8d0eff6d9
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2413140
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Deepak Nibade
2020-09-11 16:50:08 +05:30
committed by Alex Waterman
parent db20451d0d
commit ebb66b5d50
5 changed files with 49 additions and 11 deletions

View File

@@ -23,6 +23,7 @@
#include <nvgpu/gk20a.h>
#include <nvgpu/types.h>
#include <nvgpu/gr/gr_utils.h>
#include <nvgpu/gr/gr_instances.h>
#include <nvgpu/gr/config.h>
@@ -35,23 +36,27 @@ u32 nvgpu_gr_checksum_u32(u32 a, u32 b)
struct nvgpu_gr_falcon *nvgpu_gr_get_falcon_ptr(struct gk20a *g)
{
return g->gr[g->mig.cur_gr_instance].falcon;
struct nvgpu_gr *gr = nvgpu_gr_get_cur_instance_ptr(g);
return gr->falcon;
}
struct nvgpu_gr_config *nvgpu_gr_get_config_ptr(struct gk20a *g)
{
return g->gr[g->mig.cur_gr_instance].config;
struct nvgpu_gr *gr = nvgpu_gr_get_cur_instance_ptr(g);
return gr->config;
}
struct nvgpu_gr_intr *nvgpu_gr_get_intr_ptr(struct gk20a *g)
{
return g->gr[g->mig.cur_gr_instance].intr;
struct nvgpu_gr *gr = nvgpu_gr_get_cur_instance_ptr(g);
return gr->intr;
}
#ifdef CONFIG_NVGPU_NON_FUSA
u32 nvgpu_gr_get_override_ecc_val(struct gk20a *g)
{
return g->gr[g->mig.cur_gr_instance].fecs_feature_override_ecc_val;
struct nvgpu_gr *gr = nvgpu_gr_get_cur_instance_ptr(g);
return gr->fecs_feature_override_ecc_val;
}
void nvgpu_gr_override_ecc_val(struct nvgpu_gr *gr, u32 ecc_val)