gpu: nvgpu: remove circular dependency between hal.c and gk20a/

gk20a/hal.c depends on HAL init functions in all chips. But all chips
also depend on gk20a. That creates a circular dependency. In order to
solve the above, move gpu_init_hal and gk20a_detect_chip to
common/init/hal_init.c. These methods are declared in
include/nvgpu/hal_init.h. Also, the above methods are renamed to
nvgpu_init_hal and nvgpu_detect_chip respectively.

Jira NVGPU-613

Change-Id: Ib0df90287d4491571e4751475739b75fabd1041b
Signed-off-by: Debarshi Dutta <ddutta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1827576
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
ddutta
2018-09-17 13:09:18 +05:30
committed by mobile promotions
parent c5810a670d
commit c616fba1eb
7 changed files with 61 additions and 50 deletions

View File

@@ -203,6 +203,7 @@ nvgpu-y += \
common/vbios/bios.o \ common/vbios/bios.o \
common/falcon/falcon.o \ common/falcon/falcon.o \
common/falcon/falcon_queue.o \ common/falcon/falcon_queue.o \
common/init/hal_init.o \
common/pmu/pmu.o \ common/pmu/pmu.o \
common/pmu/pmu_ipc.o \ common/pmu/pmu_ipc.o \
common/pmu/pmu_fw.o \ common/pmu/pmu_fw.o \
@@ -237,7 +238,6 @@ nvgpu-y += \
gk20a/fence_gk20a.o \ gk20a/fence_gk20a.o \
gk20a/gr_ctx_gk20a_sim.o \ gk20a/gr_ctx_gk20a_sim.o \
gk20a/gr_ctx_gk20a.o \ gk20a/gr_ctx_gk20a.o \
gk20a/hal.o \
gk20a/tsg_gk20a.o \ gk20a/tsg_gk20a.o \
gk20a/fecs_trace_gk20a.o \ gk20a/fecs_trace_gk20a.o \
gm20b/hal_gm20b.o \ gm20b/hal_gm20b.o \

View File

@@ -68,6 +68,7 @@ srcs := os/posix/nvgpu.c \
common/fb/fb_gp106.c \ common/fb/fb_gp106.c \
common/fb/fb_gv100.c \ common/fb/fb_gv100.c \
common/fb/fb_gv11b.c \ common/fb/fb_gv11b.c \
common/init/hal_init.c \
common/xve/xve_gp106.c \ common/xve/xve_gp106.c \
common/therm/therm.c \ common/therm/therm.c \
common/therm/therm_gm20b.c \ common/therm/therm_gm20b.c \
@@ -157,7 +158,6 @@ srcs := os/posix/nvgpu.c \
gk20a/fence_gk20a.c \ gk20a/fence_gk20a.c \
gk20a/gr_ctx_gk20a_sim.c \ gk20a/gr_ctx_gk20a_sim.c \
gk20a/gr_ctx_gk20a.c \ gk20a/gr_ctx_gk20a.c \
gk20a/hal.c \
gk20a/tsg_gk20a.c \ gk20a/tsg_gk20a.c \
gm20b/hal_gm20b.c \ gm20b/hal_gm20b.c \
gm20b/gr_gm20b.c \ gm20b/gr_gm20b.c \

View File

@@ -22,8 +22,12 @@
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#include "gk20a.h" #include <nvgpu/gk20a.h>
#include "hal.h" #include <nvgpu/log.h>
#include <nvgpu/hal_init.h>
#include <nvgpu/mc.h>
#include <nvgpu/soc.h>
#include "gm20b/hal_gm20b.h" #include "gm20b/hal_gm20b.h"
#include "gp10b/hal_gp10b.h" #include "gp10b/hal_gp10b.h"
#include "gp106/hal_gp106.h" #include "gp106/hal_gp106.h"
@@ -33,52 +37,86 @@
#include "nvgpu_gpuid_next.h" #include "nvgpu_gpuid_next.h"
#endif #endif
#include <nvgpu/log.h> int nvgpu_init_hal(struct gk20a *g)
int gpu_init_hal(struct gk20a *g)
{ {
int err = 0;
u32 ver = g->params.gpu_arch + g->params.gpu_impl; u32 ver = g->params.gpu_arch + g->params.gpu_impl;
switch (ver) { switch (ver) {
case GK20A_GPUID_GM20B: case GK20A_GPUID_GM20B:
nvgpu_log_info(g, "gm20b detected");
if (gm20b_init_hal(g) != 0) {
return -ENODEV;
}
break;
case GK20A_GPUID_GM20B_B: case GK20A_GPUID_GM20B_B:
nvgpu_log_info(g, "gm20b detected"); nvgpu_log_info(g, "gm20b detected");
if (gm20b_init_hal(g)) { if (gm20b_init_hal(g) != 0) {
return -ENODEV; return -ENODEV;
} }
break; break;
case NVGPU_GPUID_GP10B: case NVGPU_GPUID_GP10B:
if (gp10b_init_hal(g)) { if (gp10b_init_hal(g) != 0) {
return -ENODEV; return -ENODEV;
} }
break; break;
case NVGPU_GPUID_GP104: case NVGPU_GPUID_GP104:
if (gp106_init_hal(g) != 0) {
return -ENODEV;
}
break;
case NVGPU_GPUID_GP106: case NVGPU_GPUID_GP106:
if (gp106_init_hal(g)) { if (gp106_init_hal(g) != 0) {
return -ENODEV; return -ENODEV;
} }
break; break;
case NVGPU_GPUID_GV11B: case NVGPU_GPUID_GV11B:
if (gv11b_init_hal(g)) { if (gv11b_init_hal(g) != 0) {
return -ENODEV; return -ENODEV;
} }
break; break;
case NVGPU_GPUID_GV100: case NVGPU_GPUID_GV100:
if (gv100_init_hal(g)) { if (gv100_init_hal(g) != 0) {
return -ENODEV; return -ENODEV;
} }
break; break;
#if defined(CONFIG_TEGRA_GPU_NEXT) #if defined(CONFIG_TEGRA_GPU_NEXT)
case NVGPU_GPUID_NEXT: case NVGPU_GPUID_NEXT:
if (NVGPU_NEXT_INIT_HAL(g)) { if (NVGPU_NEXT_INIT_HAL(g) != 0) {
return -ENODEV; return -ENODEV;
} }
break; break;
#endif #endif
default: default:
nvgpu_err(g, "no support for %x", ver); nvgpu_err(g, "no support for %x", ver);
return -ENODEV; err = -ENODEV;
break;
} }
return 0; return err;
}
int nvgpu_detect_chip(struct gk20a *g)
{
struct nvgpu_gpu_params *p = &g->params;
if (p->gpu_arch != 0U) {
return 0;
}
nvgpu_mc_boot_0(g, &p->gpu_arch, &p->gpu_impl, &p->gpu_rev);
if ((p->gpu_arch + p->gpu_impl) == (u32)NVGPU_GPUID_GV11B) {
/* overwrite gpu revison for A02 */
if (!nvgpu_is_soc_t194_a01(g)) {
p->gpu_rev = 0xa2;
}
}
nvgpu_log_info(g, "arch: %x, impl: %x, rev: %x\n",
g->params.gpu_arch,
g->params.gpu_impl,
g->params.gpu_rev);
return nvgpu_init_hal(g);
} }

View File

@@ -45,7 +45,6 @@
#include "gk20a.h" #include "gk20a.h"
#include "dbg_gpu_gk20a.h" #include "dbg_gpu_gk20a.h"
#include "hal.h"
#include "pstate/pstate.h" #include "pstate/pstate.h"
void __nvgpu_check_gpu_state(struct gk20a *g) void __nvgpu_check_gpu_state(struct gk20a *g)
@@ -65,33 +64,6 @@ void __gk20a_warn_on_no_regs(void)
WARN_ONCE(1, "Attempted access to GPU regs after unmapping!"); WARN_ONCE(1, "Attempted access to GPU regs after unmapping!");
} }
int gk20a_detect_chip(struct gk20a *g)
{
struct nvgpu_gpu_params *p = &g->params;
if (p->gpu_arch) {
return 0;
}
nvgpu_mc_boot_0(g, &p->gpu_arch, &p->gpu_impl, &p->gpu_rev);
if ((p->gpu_arch + p->gpu_impl) == NVGPU_GPUID_GV11B) {
/* overwrite gpu revison for A02 */
if (!nvgpu_is_soc_t194_a01(g)) {
p->gpu_rev = 0xa2;
}
}
nvgpu_log_info(g, "arch: %x, impl: %x, rev: %x\n",
g->params.gpu_arch,
g->params.gpu_impl,
g->params.gpu_rev);
return gpu_init_hal(g);
}
static void gk20a_mask_interrupts(struct gk20a *g) static void gk20a_mask_interrupts(struct gk20a *g)
{ {
if (g->ops.mc.intr_mask != NULL) { if (g->ops.mc.intr_mask != NULL) {

View File

@@ -1761,5 +1761,4 @@ static inline bool gk20a_platform_has_syncpoints(struct gk20a *g)
#endif #endif
} }
int gk20a_detect_chip(struct gk20a *g);
#endif /* GK20A_H */ #endif /* GK20A_H */

View File

@@ -22,11 +22,12 @@
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#ifndef NVGPU_GK20A_HAL_H #ifndef NVGPU_HAL_INIT_H
#define NVGPU_GK20A_HAL_H #define NVGPU_HAL_INIT_H
struct gk20a; struct gk20a;
int gpu_init_hal(struct gk20a *g); int nvgpu_init_hal(struct gk20a *g);
int nvgpu_detect_chip(struct gk20a *g);
#endif /* NVGPU_GK20A_HAL_H */ #endif /* NVGPU_HAL_INIT_H */

View File

@@ -33,6 +33,7 @@
#include <soc/tegra/fuse.h> #include <soc/tegra/fuse.h>
#include <nvgpu/hal_init.h>
#include <nvgpu/dma.h> #include <nvgpu/dma.h>
#include <nvgpu/kmem.h> #include <nvgpu/kmem.h>
#include <nvgpu/nvgpu_common.h> #include <nvgpu/nvgpu_common.h>
@@ -266,7 +267,7 @@ int gk20a_pm_finalize_poweron(struct device *dev)
INIT_WORK(&l->nonstall_fn_work, nvgpu_intr_nonstall_cb); INIT_WORK(&l->nonstall_fn_work, nvgpu_intr_nonstall_cb);
} }
err = gk20a_detect_chip(g); err = nvgpu_detect_chip(g);
if (err) if (err)
goto done; goto done;