diff --git a/drivers/gpu/nvgpu/common/init/nvgpu_init.c b/drivers/gpu/nvgpu/common/init/nvgpu_init.c index 4b68e8851..577019a42 100644 --- a/drivers/gpu/nvgpu/common/init/nvgpu_init.c +++ b/drivers/gpu/nvgpu/common/init/nvgpu_init.c @@ -46,7 +46,7 @@ bool is_nvgpu_gpu_state_valid(struct gk20a *g) { - u32 boot_0 = nvgpu_mc_boot_0(g, NULL, NULL, NULL); + u32 boot_0 = g->ops.mc.get_chip_details(g, NULL, NULL, NULL); if (boot_0 == 0xffffffffU) { nvgpu_err(g, "GPU has disappeared from bus!!"); diff --git a/drivers/gpu/nvgpu/common/mc/mc.c b/drivers/gpu/nvgpu/common/mc/mc.c index 49cf736e4..5ab6814ca 100644 --- a/drivers/gpu/nvgpu/common/mc/mc.c +++ b/drivers/gpu/nvgpu/common/mc/mc.c @@ -22,36 +22,9 @@ * DEALINGS IN THE SOFTWARE. */ -#include #include #include -#include - -u32 nvgpu_mc_boot_0(struct gk20a *g, u32 *arch, u32 *impl, u32 *rev) -{ - u32 val = nvgpu_readl_impl(g, mc_boot_0_r()); - - if (val != U32_MAX) { - - if (arch != NULL) { - *arch = mc_boot_0_architecture_v(val) << - NVGPU_GPU_ARCHITECTURE_SHIFT; - } - - if (impl != NULL) { - *impl = mc_boot_0_implementation_v(val); - } - - if (rev != NULL) { - *rev = (mc_boot_0_major_revision_v(val) << 4) | - mc_boot_0_minor_revision_v(val); - } - } - - return val; -} - /** * cyclic_delta - Returns delta of cyclic integers a and b. * diff --git a/drivers/gpu/nvgpu/hal/init/hal_gm20b.c b/drivers/gpu/nvgpu/hal/init/hal_gm20b.c index 83b47631d..a02ba31bf 100644 --- a/drivers/gpu/nvgpu/hal/init/hal_gm20b.c +++ b/drivers/gpu/nvgpu/hal/init/hal_gm20b.c @@ -958,6 +958,7 @@ static const struct gpu_ops gm20b_ops = { }, #endif .mc = { + .get_chip_details = gm20b_get_chip_details, .intr_mask = gm20b_mc_intr_mask, .intr_enable = gm20b_mc_intr_enable, #ifdef CONFIG_NVGPU_LS_PMU diff --git a/drivers/gpu/nvgpu/hal/init/hal_gp10b.c b/drivers/gpu/nvgpu/hal/init/hal_gp10b.c index d12f680fe..894fa8b13 100644 --- a/drivers/gpu/nvgpu/hal/init/hal_gp10b.c +++ b/drivers/gpu/nvgpu/hal/init/hal_gp10b.c @@ -1054,6 +1054,7 @@ static const struct gpu_ops gp10b_ops = { }, #endif .mc = { + .get_chip_details = gm20b_get_chip_details, .intr_mask = mc_gp10b_intr_mask, .intr_enable = mc_gp10b_intr_enable, #ifdef CONFIG_NVGPU_LS_PMU diff --git a/drivers/gpu/nvgpu/hal/init/hal_gv11b.c b/drivers/gpu/nvgpu/hal/init/hal_gv11b.c index da192cee3..4bb4fed4c 100644 --- a/drivers/gpu/nvgpu/hal/init/hal_gv11b.c +++ b/drivers/gpu/nvgpu/hal/init/hal_gv11b.c @@ -1257,6 +1257,7 @@ static const struct gpu_ops gv11b_ops = { }, #endif .mc = { + .get_chip_details = gm20b_get_chip_details, .intr_mask = mc_gp10b_intr_mask, .intr_enable = mc_gv11b_intr_enable, #ifdef CONFIG_NVGPU_LS_PMU diff --git a/drivers/gpu/nvgpu/hal/init/hal_init.c b/drivers/gpu/nvgpu/hal/init/hal_init.c index 1935d8150..c73811bc5 100644 --- a/drivers/gpu/nvgpu/hal/init/hal_init.c +++ b/drivers/gpu/nvgpu/hal/init/hal_init.c @@ -36,6 +36,8 @@ #include "hal_tu104.h" #endif +#include "hal/mc/mc_gm20b.h" + int nvgpu_init_hal(struct gk20a *g) { int err = 0; @@ -97,9 +99,10 @@ int nvgpu_detect_chip(struct gk20a *g) return 0; } - boot_0 = nvgpu_mc_boot_0(g, &p->gpu_arch, &p->gpu_impl, &p->gpu_rev); + boot_0 = gm20b_get_chip_details(g, &p->gpu_arch, + &p->gpu_impl, &p->gpu_rev); if (boot_0 == U32_MAX) { - nvgpu_err(g, "nvgpu_mc_boot_0 failure!"); + nvgpu_err(g, "get_chip_details failure!"); return -ENODEV; } diff --git a/drivers/gpu/nvgpu/hal/init/hal_tu104.c b/drivers/gpu/nvgpu/hal/init/hal_tu104.c index d4bcd795c..599f0c496 100644 --- a/drivers/gpu/nvgpu/hal/init/hal_tu104.c +++ b/drivers/gpu/nvgpu/hal/init/hal_tu104.c @@ -1274,6 +1274,7 @@ static const struct gpu_ops tu104_ops = { }, #endif .mc = { + .get_chip_details = gm20b_get_chip_details, .intr_enable = intr_tu104_enable, .intr_mask = intr_tu104_mask, #ifdef CONFIG_NVGPU_LS_PMU diff --git a/drivers/gpu/nvgpu/hal/mc/mc_gm20b.h b/drivers/gpu/nvgpu/hal/mc/mc_gm20b.h index d6a21cec4..bb0e701d7 100644 --- a/drivers/gpu/nvgpu/hal/mc/mc_gm20b.h +++ b/drivers/gpu/nvgpu/hal/mc/mc_gm20b.h @@ -32,6 +32,8 @@ struct gk20a; enum nvgpu_unit; +u32 gm20b_get_chip_details(struct gk20a *g, u32 *arch, u32 *impl, u32 *rev); + u32 gm20b_mc_isr_nonstall(struct gk20a *g); void gm20b_mc_enable(struct gk20a *g, u32 units); void gm20b_mc_disable(struct gk20a *g, u32 units); diff --git a/drivers/gpu/nvgpu/hal/mc/mc_gm20b_fusa.c b/drivers/gpu/nvgpu/hal/mc/mc_gm20b_fusa.c index 28369da19..dcda4a504 100644 --- a/drivers/gpu/nvgpu/hal/mc/mc_gm20b_fusa.c +++ b/drivers/gpu/nvgpu/hal/mc/mc_gm20b_fusa.c @@ -37,6 +37,30 @@ #include +u32 gm20b_get_chip_details(struct gk20a *g, u32 *arch, u32 *impl, u32 *rev) +{ + u32 val = nvgpu_readl_impl(g, mc_boot_0_r()); + + if (val != U32_MAX) { + + if (arch != NULL) { + *arch = mc_boot_0_architecture_v(val) << + NVGPU_GPU_ARCHITECTURE_SHIFT; + } + + if (impl != NULL) { + *impl = mc_boot_0_implementation_v(val); + } + + if (rev != NULL) { + *rev = (mc_boot_0_major_revision_v(val) << 4) | + mc_boot_0_minor_revision_v(val); + } + } + + return val; +} + u32 gm20b_mc_isr_nonstall(struct gk20a *g) { u32 ops = 0U; diff --git a/drivers/gpu/nvgpu/hal/vgpu/init/vgpu_hal_gp10b.c b/drivers/gpu/nvgpu/hal/vgpu/init/vgpu_hal_gp10b.c index 2f011bcbe..ea5386b71 100644 --- a/drivers/gpu/nvgpu/hal/vgpu/init/vgpu_hal_gp10b.c +++ b/drivers/gpu/nvgpu/hal/vgpu/init/vgpu_hal_gp10b.c @@ -751,6 +751,7 @@ static const struct gpu_ops vgpu_gp10b_ops = { }, #endif .mc = { + .get_chip_details = NULL, .intr_mask = NULL, .intr_enable = NULL, #ifdef CONFIG_NVGPU_LS_PMU diff --git a/drivers/gpu/nvgpu/hal/vgpu/init/vgpu_hal_gv11b.c b/drivers/gpu/nvgpu/hal/vgpu/init/vgpu_hal_gv11b.c index 2a3078b51..855504c18 100644 --- a/drivers/gpu/nvgpu/hal/vgpu/init/vgpu_hal_gv11b.c +++ b/drivers/gpu/nvgpu/hal/vgpu/init/vgpu_hal_gv11b.c @@ -873,6 +873,7 @@ static const struct gpu_ops vgpu_gv11b_ops = { }, #endif .mc = { + .get_chip_details = NULL, .intr_mask = NULL, .intr_enable = NULL, #ifdef CONFIG_NVGPU_LS_PMU diff --git a/drivers/gpu/nvgpu/include/nvgpu/gk20a.h b/drivers/gpu/nvgpu/include/nvgpu/gk20a.h index 78615c8c0..0e5ca615c 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/gk20a.h +++ b/drivers/gpu/nvgpu/include/nvgpu/gk20a.h @@ -1146,9 +1146,6 @@ int gk20a_do_idle_impl(struct gk20a *g, bool force_reset); int gk20a_do_unidle_impl(struct gk20a *g); #endif -/** Bit offset of the Architecture field in the HW version register */ -#define NVGPU_GPU_ARCHITECTURE_SHIFT 4U - /** * Constructs unique and compact GPUID from nvgpu_gpu_characteristics * arch/impl fields. diff --git a/drivers/gpu/nvgpu/include/nvgpu/gops_mc.h b/drivers/gpu/nvgpu/include/nvgpu/gops_mc.h index 685ce6f3f..78328bc21 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/gops_mc.h +++ b/drivers/gpu/nvgpu/include/nvgpu/gops_mc.h @@ -38,6 +38,40 @@ struct gk20a; * @see gpu_ops. */ struct gops_mc { + /** + * @brief Get the GPU architecture, implementation and revision. + * + * @param g [in] The GPU driver struct. + * @param arch [out] The GPU architecture level. Can be passed as + * NULL if not needed by the caller. + * @param impl [out] The implementation of the GPU architecture. + * Can be passed as NULL if not needed by the + * caller. + * @param rev [out] The revision of the chip. Can be passed as + * NULL if not needed by the caller. + * + * This function is invoked to get the GPU architecture, implementation + * and revision level of the GPU chip before #nvgpu_finalize_poweron. + * These values are used for chip specific SW/HW handling in the + * driver. + * + * Steps: + * - Read the register mc_boot_0_r(). + * - If value is not #U32_MAX + * - Set in \a arch, the value obtained by mc_boot_0_architecture_v() + * of the read value shifting left by #NVGPU_GPU_ARCHITECTURE_SHIFT. + * - Set in \a impl, the value obtained by + * mc_boot_0_implementation_v() of the read value. + * - Set in \a rev, value obtained by shifting left + * mc_boot_0_major_revision_v() of the read value by 4 OR'ing with + * mc_boot_0_minor_revision_v() of the value. + * - return the value of the register mc_boot_0_r read. + * + * @return value read from mc_boot_0_r(). + */ + u32 (*get_chip_details)(struct gk20a *g, + u32 *arch, u32 *impl, u32 *rev); + /** * @brief Clear the GPU device interrupts at master level. * diff --git a/drivers/gpu/nvgpu/include/nvgpu/mc.h b/drivers/gpu/nvgpu/include/nvgpu/mc.h index 65b73f661..f0dbd567b 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/mc.h +++ b/drivers/gpu/nvgpu/include/nvgpu/mc.h @@ -46,6 +46,9 @@ enum nvgpu_unit { #endif }; +/** Bit offset of the Architecture field in the HW version register */ +#define NVGPU_GPU_ARCHITECTURE_SHIFT 4U + #define NVGPU_MC_INTR_STALLING 0U #define NVGPU_MC_INTR_NONSTALLING 1U @@ -53,7 +56,6 @@ enum nvgpu_unit { #define NVGPU_NONSTALL_OPS_WAKEUP_SEMAPHORE BIT32(0) #define NVGPU_NONSTALL_OPS_POST_EVENTS BIT32(1) -u32 nvgpu_mc_boot_0(struct gk20a *g, u32 *arch, u32 *impl, u32 *rev); void nvgpu_wait_for_deferred_interrupts(struct gk20a *g); #endif diff --git a/userspace/units/init/nvgpu-init.c b/userspace/units/init/nvgpu-init.c index b2da0852c..2dcb9aee8 100644 --- a/userspace/units/init/nvgpu-init.c +++ b/userspace/units/init/nvgpu-init.c @@ -559,8 +559,8 @@ struct unit_module_test init_tests[] = { UNIT_TEST(init_setup_env, test_setup_env, NULL, 0), UNIT_TEST(init_can_busy, test_can_busy, NULL, 0), UNIT_TEST(init_get_put, test_get_put, NULL, 0), - UNIT_TEST(init_check_gpu_state, test_check_gpu_state, NULL, 0), UNIT_TEST(init_hal_init, test_hal_init, NULL, 0), + UNIT_TEST(init_check_gpu_state, test_check_gpu_state, NULL, 0), UNIT_TEST(init_poweron, test_poweron, NULL, 0), UNIT_TEST(init_poweron_branches, test_poweron_branches, NULL, 0), UNIT_TEST(init_poweroff, test_poweroff, NULL, 0),