From 7c5cf70268ca038f85686fbdec29729d1a9024c1 Mon Sep 17 00:00:00 2001 From: David Nieto Date: Tue, 8 Aug 2017 12:50:55 -0700 Subject: gpu: nvgpu: add support for pre-os FW Pre-os firmware takes care, among others, of the control of FAN till the driver takes over its control. On some GPUs not enabling this FW can lead tp physical board damage, hence it is needed to run this firmware. JIRA: NVGPUGV100-9 Change-Id: I18d54cfd5eb64ecec79c5dae67ac8d5bb1facf36 Signed-off-by: David Nieto Reviewed-on: https://git-master.nvidia.com/r/1549035 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svc-mobile-coverity Reviewed-by: svccoveritychecker Reviewed-by: Vijayakumar Subbu Reviewed-by: Konsta Holtta GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/common/linux/pci.c | 2 ++ drivers/gpu/nvgpu/gk20a/gk20a.c | 4 ++-- drivers/gpu/nvgpu/gk20a/gk20a.h | 6 +++++- drivers/gpu/nvgpu/gp106/bios_gp106.c | 19 ++++++++++++++----- drivers/gpu/nvgpu/gp106/bios_gp106.h | 3 +-- drivers/gpu/nvgpu/gp106/hal_gp106.c | 7 +++++-- 6 files changed, 29 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/nvgpu/common/linux/pci.c b/drivers/gpu/nvgpu/common/linux/pci.c index 6e3e02e5..92764c21 100644 --- a/drivers/gpu/nvgpu/common/linux/pci.c +++ b/drivers/gpu/nvgpu/common/linux/pci.c @@ -239,6 +239,7 @@ static struct gk20a_platform nvgpu_pci_device[] = { .honors_aperture = true, .vbios_min_version = 0x88001e00, .hardcode_sw_threshold = false, + .run_preos = true, }, { /* DEVICE=PG503 SKU 200 ES */ /* ptimer src frequency in hz */ @@ -272,6 +273,7 @@ static struct gk20a_platform nvgpu_pci_device[] = { .honors_aperture = true, .vbios_min_version = 0x88001e00, .hardcode_sw_threshold = false, + .run_preos = true, } }; diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c index 17ba3ee4..d1ad5992 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a.c @@ -187,8 +187,8 @@ int gk20a_finalize_poweron(struct gk20a *g) nvgpu_flcn_sw_init(g, FALCON_ID_PMU); nvgpu_flcn_sw_init(g, FALCON_ID_SEC2); - if (g->ops.bios_init) - err = g->ops.bios_init(g); + if (g->ops.bios.init) + err = g->ops.bios.init(g); if (err) goto done; diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index 97b40474..537d03d8 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -969,7 +969,11 @@ struct gpu_ops { int (*bar1_bind)(struct gk20a *g, struct nvgpu_mem *bar1_inst); } bus; - int (*bios_init)(struct gk20a *g); + struct { + int (*init)(struct gk20a *g); + int (*preos_wait_for_halt)(struct gk20a *g); + void (*preos_reload_check)(struct gk20a *g); + } bios; #if defined(CONFIG_GK20A_CYCLE_STATS) struct { diff --git a/drivers/gpu/nvgpu/gp106/bios_gp106.c b/drivers/gpu/nvgpu/gp106/bios_gp106.c index b7e031c6..3178ae53 100644 --- a/drivers/gpu/nvgpu/gp106/bios_gp106.c +++ b/drivers/gpu/nvgpu/gp106/bios_gp106.c @@ -135,6 +135,16 @@ out: return err; } +int gp106_bios_preos_wait_for_halt(struct gk20a *g) +{ + int err = 0; + + if (nvgpu_flcn_wait_for_halt(g->pmu.flcn, PMU_BOOT_TIMEOUT_MAX / 1000)) + err = -ETIMEDOUT; + + return err; +} + static int gp106_bios_preos(struct gk20a *g) { int err = 0; @@ -146,6 +156,9 @@ static int gp106_bios_preos(struct gk20a *g) goto out; } + if (g->ops.bios.preos_reload_check) + g->ops.bios.preos_reload_check(g); + upload_code(g, g->bios.preos.bootloader_phys_base, g->bios.preos.bootloader, g->bios.preos.bootloader_size, @@ -161,11 +174,7 @@ static int gp106_bios_preos(struct gk20a *g) nvgpu_flcn_bootstrap(g->pmu.flcn, g->bios.preos.code_entry_point); - if (nvgpu_flcn_wait_for_halt(g->pmu.flcn, - PMU_BOOT_TIMEOUT_MAX / 1000)) { - err = -ETIMEDOUT; - goto out; - } + err = g->ops.bios.preos_wait_for_halt(g); nvgpu_flcn_clear_halt_intr_status(g->pmu.flcn, gk20a_get_gr_idle_timeout(g)); diff --git a/drivers/gpu/nvgpu/gp106/bios_gp106.h b/drivers/gpu/nvgpu/gp106/bios_gp106.h index 0301177e..a5229fff 100644 --- a/drivers/gpu/nvgpu/gp106/bios_gp106.h +++ b/drivers/gpu/nvgpu/gp106/bios_gp106.h @@ -27,6 +27,5 @@ struct gk20a; struct gpu_ops; int gp106_bios_init(struct gk20a *g); -void gp106_init_bios_ops(struct gpu_ops *gops); - +int gp106_bios_preos_wait_for_halt(struct gk20a *g); #endif diff --git a/drivers/gpu/nvgpu/gp106/hal_gp106.c b/drivers/gpu/nvgpu/gp106/hal_gp106.c index 1c423785..8523e7d1 100644 --- a/drivers/gpu/nvgpu/gp106/hal_gp106.c +++ b/drivers/gpu/nvgpu/gp106/hal_gp106.c @@ -216,6 +216,10 @@ static int gp106_init_gpu_characteristics(struct gk20a *g) } static const struct gpu_ops gp106_ops = { + .bios = { + .init = gp106_bios_init, + .preos_wait_for_halt = gp106_bios_preos_wait_for_halt, + }, .ltc = { .determine_L2_size_bytes = gp10b_determine_L2_size_bytes, .set_zbc_color_entry = gm20b_ltc_set_zbc_color_entry, @@ -695,7 +699,6 @@ static const struct gpu_ops gp106_ops = { }, .get_litter_value = gp106_get_litter_value, .chip_init_gpu_characteristics = gp106_init_gpu_characteristics, - .bios_init = gp106_bios_init, }; int gp106_init_hal(struct gk20a *g) @@ -705,6 +708,7 @@ int gp106_init_hal(struct gk20a *g) gk20a_dbg_fn(""); + gops->bios = gp106_ops.bios; gops->ltc = gp106_ops.ltc; gops->ce2 = gp106_ops.ce2; gops->gr = gp106_ops.gr; @@ -747,7 +751,6 @@ int gp106_init_hal(struct gk20a *g) gops->get_litter_value = gp106_ops.get_litter_value; gops->chip_init_gpu_characteristics = gp106_ops.chip_init_gpu_characteristics; - gops->bios_init = gp106_ops.bios_init; __nvgpu_set_enabled(g, NVGPU_GR_USE_DMA_FOR_FW_BOOTSTRAP, true); __nvgpu_set_enabled(g, NVGPU_SEC_PRIVSECURITY, true); -- cgit v1.2.2