From 180604fec0bde1710923e78a3877d49892cbf883 Mon Sep 17 00:00:00 2001 From: Thomas Fleury Date: Fri, 26 Jan 2018 17:56:55 -0800 Subject: gpu: nvgpu: gv100: fb hal to init and enable nvlink Add the following hals: (1) init_nvlink to configure nvlink(s) for sysmem in HSHUB (2) enable_nvlink to switch from PCIe sysmem to nvlink sysmem, and setup atomics. Change-Id: I73d2370aaf8e0530158a1091d9efef4a8cf2aac5 Signed-off-by: Thomas Fleury Reviewed-on: https://git-master.nvidia.com/r/1648044 Reviewed-by: svc-mobile-coverity GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/gk20a.h | 2 ++ drivers/gpu/nvgpu/gv100/fb_gv100.c | 52 +++++++++++++++++++++++++++++++++- drivers/gpu/nvgpu/gv100/fb_gv100.h | 2 ++ drivers/gpu/nvgpu/gv100/hal_gv100.c | 2 ++ drivers/gpu/nvgpu/gv100/nvlink_gv100.c | 14 +++++++++ 5 files changed, 71 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index 40656edd..ac3364b0 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -481,6 +481,8 @@ struct gpu_ops { void (*tlb_invalidate)(struct gk20a *g, struct nvgpu_mem *pdb); void (*hub_isr)(struct gk20a *g); int (*mem_unlock)(struct gk20a *g); + int (*init_nvlink)(struct gk20a *g); + int (*enable_nvlink)(struct gk20a *g); } fb; struct { void (*slcg_bus_load_gating_prod)(struct gk20a *g, bool prod); diff --git a/drivers/gpu/nvgpu/gv100/fb_gv100.c b/drivers/gpu/nvgpu/gv100/fb_gv100.c index 0a2939bf..84a8d64a 100644 --- a/drivers/gpu/nvgpu/gv100/fb_gv100.c +++ b/drivers/gpu/nvgpu/gv100/fb_gv100.c @@ -1,7 +1,7 @@ /* * GV100 FB * - * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -182,3 +182,53 @@ exit: return err; } + +int gv100_fb_init_nvlink(struct gk20a *g) +{ + u32 data; + u32 mask = g->nvlink.enabled_links; + + /* Map enabled link to SYSMEM */ + data = nvgpu_readl(g, fb_hshub_config0_r()); + data = set_field(data, fb_hshub_config0_sysmem_nvlink_mask_m(), + fb_hshub_config0_sysmem_nvlink_mask_f(mask)); + nvgpu_writel(g, fb_hshub_config0_r(), data); + + return 0; +} + +int gv100_fb_enable_nvlink(struct gk20a *g) +{ + u32 data; + + nvgpu_log(g, gpu_dbg_nvlink|gpu_dbg_info, "enabling nvlink"); + + /* Enable nvlink for NISO FBHUB */ + data = nvgpu_readl(g, fb_niso_cfg1_r()); + data = set_field(data, fb_niso_cfg1_sysmem_nvlink_m(), + fb_niso_cfg1_sysmem_nvlink_enabled_f()); + nvgpu_writel(g, fb_niso_cfg1_r(), data); + + /* Setup atomics */ + data = nvgpu_readl(g, fb_mmu_ctrl_r()); + data = set_field(data, fb_mmu_ctrl_atomic_capability_mode_m(), + fb_mmu_ctrl_atomic_capability_mode_rmw_f()); + nvgpu_writel(g, fb_mmu_ctrl_r(), data); + + data = nvgpu_readl(g, fb_hsmmu_pri_mmu_ctrl_r()); + data = set_field(data, fb_hsmmu_pri_mmu_ctrl_atomic_capability_mode_m(), + fb_hsmmu_pri_mmu_ctrl_atomic_capability_mode_rmw_f()); + nvgpu_writel(g, fb_hsmmu_pri_mmu_ctrl_r(), data); + + data = nvgpu_readl(g, fb_fbhub_num_active_ltcs_r()); + data = set_field(data, fb_fbhub_num_active_ltcs_hub_sys_atomic_mode_m(), + fb_fbhub_num_active_ltcs_hub_sys_atomic_mode_use_rmw_f()); + nvgpu_writel(g, fb_fbhub_num_active_ltcs_r(), data); + + data = nvgpu_readl(g, fb_hshub_num_active_ltcs_r()); + data = set_field(data, fb_hshub_num_active_ltcs_hub_sys_atomic_mode_m(), + fb_hshub_num_active_ltcs_hub_sys_atomic_mode_use_rmw_f()); + nvgpu_writel(g, fb_hshub_num_active_ltcs_r(), data); + + return 0; +} diff --git a/drivers/gpu/nvgpu/gv100/fb_gv100.h b/drivers/gpu/nvgpu/gv100/fb_gv100.h index b6db262a..5b99fe5e 100644 --- a/drivers/gpu/nvgpu/gv100/fb_gv100.h +++ b/drivers/gpu/nvgpu/gv100/fb_gv100.h @@ -29,4 +29,6 @@ struct gk20a; void gv100_fb_reset(struct gk20a *g); int gv100_fb_memory_unlock(struct gk20a *g); +int gv100_fb_init_nvlink(struct gk20a *g); +int gv100_fb_enable_nvlink(struct gk20a *g); #endif diff --git a/drivers/gpu/nvgpu/gv100/hal_gv100.c b/drivers/gpu/nvgpu/gv100/hal_gv100.c index 53d61bfb..c380df8d 100644 --- a/drivers/gpu/nvgpu/gv100/hal_gv100.c +++ b/drivers/gpu/nvgpu/gv100/hal_gv100.c @@ -445,6 +445,8 @@ static const struct gpu_ops gv100_ops = { .tlb_invalidate = gk20a_fb_tlb_invalidate, .hub_isr = gv11b_fb_hub_isr, .mem_unlock = gv100_fb_memory_unlock, + .init_nvlink = gv100_fb_init_nvlink, + .enable_nvlink = gv100_fb_enable_nvlink, }, .fifo = { .get_preempt_timeout = gv100_fifo_get_preempt_timeout, diff --git a/drivers/gpu/nvgpu/gv100/nvlink_gv100.c b/drivers/gpu/nvgpu/gv100/nvlink_gv100.c index e5e65c51..ba649382 100644 --- a/drivers/gpu/nvgpu/gv100/nvlink_gv100.c +++ b/drivers/gpu/nvgpu/gv100/nvlink_gv100.c @@ -1638,6 +1638,13 @@ int gv100_nvlink_init(struct gk20a *g) /* Set HSHUB and SG_PHY */ __nvgpu_set_enabled(g, NVGPU_MM_USE_PHYSICAL_SG, true); + + err = g->ops.fb.enable_nvlink(g); + if (err) { + nvgpu_err(g, "failed switch to nvlink sysmem"); + return err; + } + return err; } @@ -2142,12 +2149,19 @@ int gv100_nvlink_interface_init(struct gk20a *g) { unsigned long mask = g->nvlink.enabled_links; u32 link_id; + int err; for_each_set_bit(link_id, &mask, 32) { gv100_nvlink_initialize_mif(g, link_id); gv100_nvlink_mif_intr_enable(g, link_id, true); } + err = g->ops.fb.init_nvlink(g); + if (err) { + nvgpu_err(g, "failed to setup nvlinks for sysmem"); + return err; + } + return 0; } -- cgit v1.2.2