summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorddutta <ddutta@nvidia.com>2018-09-17 03:39:18 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-09-21 06:15:35 -0400
commitc616fba1eb357684e3796603a226f4df7d88be73 (patch)
tree8ace774fed31400ac8073cf67378689d6068d4a5 /drivers
parentc5810a670d367ae1dc405fcc3108e11265df34bb (diff)
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/nvgpu/Makefile2
-rw-r--r--drivers/gpu/nvgpu/Makefile.sources2
-rw-r--r--drivers/gpu/nvgpu/common/init/hal_init.c (renamed from drivers/gpu/nvgpu/gk20a/hal.c)66
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.c28
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/gk20a.h1
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/hal_init.h (renamed from drivers/gpu/nvgpu/gk20a/hal.h)9
-rw-r--r--drivers/gpu/nvgpu/os/linux/module.c3
7 files changed, 61 insertions, 50 deletions
diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile
index 1b7dbd26..bf02affe 100644
--- a/drivers/gpu/nvgpu/Makefile
+++ b/drivers/gpu/nvgpu/Makefile
@@ -203,6 +203,7 @@ nvgpu-y += \
203 common/vbios/bios.o \ 203 common/vbios/bios.o \
204 common/falcon/falcon.o \ 204 common/falcon/falcon.o \
205 common/falcon/falcon_queue.o \ 205 common/falcon/falcon_queue.o \
206 common/init/hal_init.o \
206 common/pmu/pmu.o \ 207 common/pmu/pmu.o \
207 common/pmu/pmu_ipc.o \ 208 common/pmu/pmu_ipc.o \
208 common/pmu/pmu_fw.o \ 209 common/pmu/pmu_fw.o \
@@ -237,7 +238,6 @@ nvgpu-y += \
237 gk20a/fence_gk20a.o \ 238 gk20a/fence_gk20a.o \
238 gk20a/gr_ctx_gk20a_sim.o \ 239 gk20a/gr_ctx_gk20a_sim.o \
239 gk20a/gr_ctx_gk20a.o \ 240 gk20a/gr_ctx_gk20a.o \
240 gk20a/hal.o \
241 gk20a/tsg_gk20a.o \ 241 gk20a/tsg_gk20a.o \
242 gk20a/fecs_trace_gk20a.o \ 242 gk20a/fecs_trace_gk20a.o \
243 gm20b/hal_gm20b.o \ 243 gm20b/hal_gm20b.o \
diff --git a/drivers/gpu/nvgpu/Makefile.sources b/drivers/gpu/nvgpu/Makefile.sources
index 5c15ebd0..4e67434d 100644
--- a/drivers/gpu/nvgpu/Makefile.sources
+++ b/drivers/gpu/nvgpu/Makefile.sources
@@ -68,6 +68,7 @@ srcs := os/posix/nvgpu.c \
68 common/fb/fb_gp106.c \ 68 common/fb/fb_gp106.c \
69 common/fb/fb_gv100.c \ 69 common/fb/fb_gv100.c \
70 common/fb/fb_gv11b.c \ 70 common/fb/fb_gv11b.c \
71 common/init/hal_init.c \
71 common/xve/xve_gp106.c \ 72 common/xve/xve_gp106.c \
72 common/therm/therm.c \ 73 common/therm/therm.c \
73 common/therm/therm_gm20b.c \ 74 common/therm/therm_gm20b.c \
@@ -157,7 +158,6 @@ srcs := os/posix/nvgpu.c \
157 gk20a/fence_gk20a.c \ 158 gk20a/fence_gk20a.c \
158 gk20a/gr_ctx_gk20a_sim.c \ 159 gk20a/gr_ctx_gk20a_sim.c \
159 gk20a/gr_ctx_gk20a.c \ 160 gk20a/gr_ctx_gk20a.c \
160 gk20a/hal.c \
161 gk20a/tsg_gk20a.c \ 161 gk20a/tsg_gk20a.c \
162 gm20b/hal_gm20b.c \ 162 gm20b/hal_gm20b.c \
163 gm20b/gr_gm20b.c \ 163 gm20b/gr_gm20b.c \
diff --git a/drivers/gpu/nvgpu/gk20a/hal.c b/drivers/gpu/nvgpu/common/init/hal_init.c
index f2f55d43..598790b6 100644
--- a/drivers/gpu/nvgpu/gk20a/hal.c
+++ b/drivers/gpu/nvgpu/common/init/hal_init.c
@@ -22,8 +22,12 @@
22 * DEALINGS IN THE SOFTWARE. 22 * DEALINGS IN THE SOFTWARE.
23 */ 23 */
24 24
25#include "gk20a.h" 25#include <nvgpu/gk20a.h>
26#include "hal.h" 26#include <nvgpu/log.h>
27#include <nvgpu/hal_init.h>
28#include <nvgpu/mc.h>
29#include <nvgpu/soc.h>
30
27#include "gm20b/hal_gm20b.h" 31#include "gm20b/hal_gm20b.h"
28#include "gp10b/hal_gp10b.h" 32#include "gp10b/hal_gp10b.h"
29#include "gp106/hal_gp106.h" 33#include "gp106/hal_gp106.h"
@@ -33,52 +37,86 @@
33#include "nvgpu_gpuid_next.h" 37#include "nvgpu_gpuid_next.h"
34#endif 38#endif
35 39
36#include <nvgpu/log.h> 40int nvgpu_init_hal(struct gk20a *g)
37
38int gpu_init_hal(struct gk20a *g)
39{ 41{
42 int err = 0;
40 u32 ver = g->params.gpu_arch + g->params.gpu_impl; 43 u32 ver = g->params.gpu_arch + g->params.gpu_impl;
44
41 switch (ver) { 45 switch (ver) {
42 case GK20A_GPUID_GM20B: 46 case GK20A_GPUID_GM20B:
47 nvgpu_log_info(g, "gm20b detected");
48 if (gm20b_init_hal(g) != 0) {
49 return -ENODEV;
50 }
51 break;
43 case GK20A_GPUID_GM20B_B: 52 case GK20A_GPUID_GM20B_B:
44 nvgpu_log_info(g, "gm20b detected"); 53 nvgpu_log_info(g, "gm20b detected");
45 if (gm20b_init_hal(g)) { 54 if (gm20b_init_hal(g) != 0) {
46 return -ENODEV; 55 return -ENODEV;
47 } 56 }
48 break; 57 break;
49 case NVGPU_GPUID_GP10B: 58 case NVGPU_GPUID_GP10B:
50 if (gp10b_init_hal(g)) { 59 if (gp10b_init_hal(g) != 0) {
51 return -ENODEV; 60 return -ENODEV;
52 } 61 }
53 break; 62 break;
54 case NVGPU_GPUID_GP104: 63 case NVGPU_GPUID_GP104:
64 if (gp106_init_hal(g) != 0) {
65 return -ENODEV;
66 }
67 break;
55 case NVGPU_GPUID_GP106: 68 case NVGPU_GPUID_GP106:
56 if (gp106_init_hal(g)) { 69 if (gp106_init_hal(g) != 0) {
57 return -ENODEV; 70 return -ENODEV;
58 } 71 }
59 break; 72 break;
60 case NVGPU_GPUID_GV11B: 73 case NVGPU_GPUID_GV11B:
61 if (gv11b_init_hal(g)) { 74 if (gv11b_init_hal(g) != 0) {
62 return -ENODEV; 75 return -ENODEV;
63 } 76 }
64 break; 77 break;
65 case NVGPU_GPUID_GV100: 78 case NVGPU_GPUID_GV100:
66 if (gv100_init_hal(g)) { 79 if (gv100_init_hal(g) != 0) {
67 return -ENODEV; 80 return -ENODEV;
68 } 81 }
69 break; 82 break;
70#if defined(CONFIG_TEGRA_GPU_NEXT) 83#if defined(CONFIG_TEGRA_GPU_NEXT)
71 case NVGPU_GPUID_NEXT: 84 case NVGPU_GPUID_NEXT:
72 if (NVGPU_NEXT_INIT_HAL(g)) { 85 if (NVGPU_NEXT_INIT_HAL(g) != 0) {
73 return -ENODEV; 86 return -ENODEV;
74 } 87 }
75 break; 88 break;
76#endif 89#endif
77
78 default: 90 default:
79 nvgpu_err(g, "no support for %x", ver); 91 nvgpu_err(g, "no support for %x", ver);
80 return -ENODEV; 92 err = -ENODEV;
93 break;
94 }
95
96 return err;
97}
98
99
100int nvgpu_detect_chip(struct gk20a *g)
101{
102 struct nvgpu_gpu_params *p = &g->params;
103
104 if (p->gpu_arch != 0U) {
105 return 0;
106 }
107
108 nvgpu_mc_boot_0(g, &p->gpu_arch, &p->gpu_impl, &p->gpu_rev);
109
110 if ((p->gpu_arch + p->gpu_impl) == (u32)NVGPU_GPUID_GV11B) {
111 /* overwrite gpu revison for A02 */
112 if (!nvgpu_is_soc_t194_a01(g)) {
113 p->gpu_rev = 0xa2;
114 }
81 } 115 }
116 nvgpu_log_info(g, "arch: %x, impl: %x, rev: %x\n",
117 g->params.gpu_arch,
118 g->params.gpu_impl,
119 g->params.gpu_rev);
82 120
83 return 0; 121 return nvgpu_init_hal(g);
84} 122}
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c
index 1caa1dcf..223c7727 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.c
@@ -45,7 +45,6 @@
45#include "gk20a.h" 45#include "gk20a.h"
46 46
47#include "dbg_gpu_gk20a.h" 47#include "dbg_gpu_gk20a.h"
48#include "hal.h"
49#include "pstate/pstate.h" 48#include "pstate/pstate.h"
50 49
51void __nvgpu_check_gpu_state(struct gk20a *g) 50void __nvgpu_check_gpu_state(struct gk20a *g)
@@ -65,33 +64,6 @@ void __gk20a_warn_on_no_regs(void)
65 WARN_ONCE(1, "Attempted access to GPU regs after unmapping!"); 64 WARN_ONCE(1, "Attempted access to GPU regs after unmapping!");
66} 65}
67 66
68int gk20a_detect_chip(struct gk20a *g)
69{
70 struct nvgpu_gpu_params *p = &g->params;
71
72 if (p->gpu_arch) {
73 return 0;
74 }
75
76 nvgpu_mc_boot_0(g, &p->gpu_arch, &p->gpu_impl, &p->gpu_rev);
77
78 if ((p->gpu_arch + p->gpu_impl) == NVGPU_GPUID_GV11B) {
79
80 /* overwrite gpu revison for A02 */
81 if (!nvgpu_is_soc_t194_a01(g)) {
82 p->gpu_rev = 0xa2;
83 }
84
85 }
86
87 nvgpu_log_info(g, "arch: %x, impl: %x, rev: %x\n",
88 g->params.gpu_arch,
89 g->params.gpu_impl,
90 g->params.gpu_rev);
91
92 return gpu_init_hal(g);
93}
94
95static void gk20a_mask_interrupts(struct gk20a *g) 67static void gk20a_mask_interrupts(struct gk20a *g)
96{ 68{
97 if (g->ops.mc.intr_mask != NULL) { 69 if (g->ops.mc.intr_mask != NULL) {
diff --git a/drivers/gpu/nvgpu/include/nvgpu/gk20a.h b/drivers/gpu/nvgpu/include/nvgpu/gk20a.h
index a653109a..244b6ed2 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/gk20a.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/gk20a.h
@@ -1761,5 +1761,4 @@ static inline bool gk20a_platform_has_syncpoints(struct gk20a *g)
1761#endif 1761#endif
1762} 1762}
1763 1763
1764int gk20a_detect_chip(struct gk20a *g);
1765#endif /* GK20A_H */ 1764#endif /* GK20A_H */
diff --git a/drivers/gpu/nvgpu/gk20a/hal.h b/drivers/gpu/nvgpu/include/nvgpu/hal_init.h
index 0a6e7094..06e58e70 100644
--- a/drivers/gpu/nvgpu/gk20a/hal.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/hal_init.h
@@ -22,11 +22,12 @@
22 * DEALINGS IN THE SOFTWARE. 22 * DEALINGS IN THE SOFTWARE.
23 */ 23 */
24 24
25#ifndef NVGPU_GK20A_HAL_H 25#ifndef NVGPU_HAL_INIT_H
26#define NVGPU_GK20A_HAL_H 26#define NVGPU_HAL_INIT_H
27 27
28struct gk20a; 28struct gk20a;
29 29
30int gpu_init_hal(struct gk20a *g); 30int nvgpu_init_hal(struct gk20a *g);
31int nvgpu_detect_chip(struct gk20a *g);
31 32
32#endif /* NVGPU_GK20A_HAL_H */ 33#endif /* NVGPU_HAL_INIT_H */
diff --git a/drivers/gpu/nvgpu/os/linux/module.c b/drivers/gpu/nvgpu/os/linux/module.c
index 9d84cc2f..dbc97f95 100644
--- a/drivers/gpu/nvgpu/os/linux/module.c
+++ b/drivers/gpu/nvgpu/os/linux/module.c
@@ -33,6 +33,7 @@
33 33
34#include <soc/tegra/fuse.h> 34#include <soc/tegra/fuse.h>
35 35
36#include <nvgpu/hal_init.h>
36#include <nvgpu/dma.h> 37#include <nvgpu/dma.h>
37#include <nvgpu/kmem.h> 38#include <nvgpu/kmem.h>
38#include <nvgpu/nvgpu_common.h> 39#include <nvgpu/nvgpu_common.h>
@@ -266,7 +267,7 @@ int gk20a_pm_finalize_poweron(struct device *dev)
266 INIT_WORK(&l->nonstall_fn_work, nvgpu_intr_nonstall_cb); 267 INIT_WORK(&l->nonstall_fn_work, nvgpu_intr_nonstall_cb);
267 } 268 }
268 269
269 err = gk20a_detect_chip(g); 270 err = nvgpu_detect_chip(g);
270 if (err) 271 if (err)
271 goto done; 272 goto done;
272 273