summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny He <suhe@nvidia.com>2017-07-05 22:05:06 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-07-24 02:35:04 -0400
commit907fcae63816b68e43e07e3d7abaad87954b8326 (patch)
tree9be974cddd1c23d17488c23377d9a36ccf69499a
parentd717c69d2b1992688589ae389380fedf0b06c720 (diff)
gpu: nvgpu: Reorg bus HAL initialization
Reorganize HAL initialization to remove inheritance and construct the gpu_ops struct at compile time. This patch only covers the bus sub-module of the gpu_ops struct. Perform HAL function assignments in hal_gxxxx.c through the population of a chip-specific copy of gpu_ops. Jira NVGPU-74 Change-Id: If03303c34d91480d41fc29e66069efd43e970d75 Signed-off-by: Sunny He <suhe@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1514660 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
-rw-r--r--drivers/gpu/nvgpu/gk20a/bus_gk20a.c2
-rw-r--r--drivers/gpu/nvgpu/gk20a/bus_gk20a.h4
-rw-r--r--drivers/gpu/nvgpu/gm20b/bus_gm20b.c11
-rw-r--r--drivers/gpu/nvgpu/gm20b/bus_gm20b.h5
-rw-r--r--drivers/gpu/nvgpu/gm20b/hal_gm20b.c12
-rw-r--r--drivers/gpu/nvgpu/gp106/hal_gp106.c11
-rw-r--r--drivers/gpu/nvgpu/gp10b/hal_gp10b.c11
7 files changed, 38 insertions, 18 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/bus_gk20a.c b/drivers/gpu/nvgpu/gk20a/bus_gk20a.c
index 45cebd7f..2d5f0766 100644
--- a/drivers/gpu/nvgpu/gk20a/bus_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/bus_gk20a.c
@@ -129,7 +129,7 @@ int gk20a_read_ptimer(struct gk20a *g, u64 *value)
129 return -EBUSY; 129 return -EBUSY;
130} 130}
131 131
132static int gk20a_bus_bar1_bind(struct gk20a *g, struct nvgpu_mem *bar1_inst) 132int gk20a_bus_bar1_bind(struct gk20a *g, struct nvgpu_mem *bar1_inst)
133{ 133{
134 u64 iova = gk20a_mm_inst_block_addr(g, bar1_inst); 134 u64 iova = gk20a_mm_inst_block_addr(g, bar1_inst);
135 u32 ptr_v = (u32)(iova >> bar1_instance_block_shift_gk20a()); 135 u32 ptr_v = (u32)(iova >> bar1_instance_block_shift_gk20a());
diff --git a/drivers/gpu/nvgpu/gk20a/bus_gk20a.h b/drivers/gpu/nvgpu/gk20a/bus_gk20a.h
index 344350b4..045063d7 100644
--- a/drivers/gpu/nvgpu/gk20a/bus_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/bus_gk20a.h
@@ -20,11 +20,11 @@
20 20
21struct gk20a; 21struct gk20a;
22struct gpu_ops; 22struct gpu_ops;
23 23struct nvgpu_mem;
24void gk20a_init_bus(struct gpu_ops *gops);
25 24
26void gk20a_bus_isr(struct gk20a *g); 25void gk20a_bus_isr(struct gk20a *g);
27int gk20a_read_ptimer(struct gk20a *g, u64 *value); 26int gk20a_read_ptimer(struct gk20a *g, u64 *value);
28void gk20a_bus_init_hw(struct gk20a *g); 27void gk20a_bus_init_hw(struct gk20a *g);
28int gk20a_bus_bar1_bind(struct gk20a *g, struct nvgpu_mem *bar1_inst);
29 29
30#endif /* GK20A_H */ 30#endif /* GK20A_H */
diff --git a/drivers/gpu/nvgpu/gm20b/bus_gm20b.c b/drivers/gpu/nvgpu/gm20b/bus_gm20b.c
index 11c11e23..0da19db8 100644
--- a/drivers/gpu/nvgpu/gm20b/bus_gm20b.c
+++ b/drivers/gpu/nvgpu/gm20b/bus_gm20b.c
@@ -22,7 +22,7 @@
22 22
23#include <nvgpu/hw/gm20b/hw_bus_gm20b.h> 23#include <nvgpu/hw/gm20b/hw_bus_gm20b.h>
24 24
25static int gm20b_bus_bar1_bind(struct gk20a *g, struct nvgpu_mem *bar1_inst) 25int gm20b_bus_bar1_bind(struct gk20a *g, struct nvgpu_mem *bar1_inst)
26{ 26{
27 struct nvgpu_timeout timeout; 27 struct nvgpu_timeout timeout;
28 int err = 0; 28 int err = 0;
@@ -53,12 +53,3 @@ static int gm20b_bus_bar1_bind(struct gk20a *g, struct nvgpu_mem *bar1_inst)
53 53
54 return err; 54 return err;
55} 55}
56
57void gm20b_init_bus(struct gpu_ops *gops)
58{
59 gops->bus.init_hw = gk20a_bus_init_hw;
60 gops->bus.isr = gk20a_bus_isr;
61 gops->bus.read_ptimer = gk20a_read_ptimer;
62 gops->bus.get_timestamps_zipper = nvgpu_get_timestamps_zipper;
63 gops->bus.bar1_bind = gm20b_bus_bar1_bind;
64}
diff --git a/drivers/gpu/nvgpu/gm20b/bus_gm20b.h b/drivers/gpu/nvgpu/gm20b/bus_gm20b.h
index 853e50a6..ad3f72ac 100644
--- a/drivers/gpu/nvgpu/gm20b/bus_gm20b.h
+++ b/drivers/gpu/nvgpu/gm20b/bus_gm20b.h
@@ -16,8 +16,9 @@
16#ifndef _NVGPU_GM20B_BUS 16#ifndef _NVGPU_GM20B_BUS
17#define _NVGPU_GM20B_BUS 17#define _NVGPU_GM20B_BUS
18 18
19struct gpu_ops; 19struct gk20a;
20struct nvgpu_mem;
20 21
21void gm20b_init_bus(struct gpu_ops *gops); 22int gm20b_bus_bar1_bind(struct gk20a *g, struct nvgpu_mem *bar1_inst);
22 23
23#endif 24#endif
diff --git a/drivers/gpu/nvgpu/gm20b/hal_gm20b.c b/drivers/gpu/nvgpu/gm20b/hal_gm20b.c
index 300f0872..fa7cf368 100644
--- a/drivers/gpu/nvgpu/gm20b/hal_gm20b.c
+++ b/drivers/gpu/nvgpu/gm20b/hal_gm20b.c
@@ -36,11 +36,13 @@
36#include "regops_gm20b.h" 36#include "regops_gm20b.h"
37#include "cde_gm20b.h" 37#include "cde_gm20b.h"
38#include "therm_gm20b.h" 38#include "therm_gm20b.h"
39#include "bus_gm20b.h"
39#include "hal_gm20b.h" 40#include "hal_gm20b.h"
40 41
41#include <nvgpu/debug.h> 42#include <nvgpu/debug.h>
42#include <nvgpu/bug.h> 43#include <nvgpu/bug.h>
43#include <nvgpu/enabled.h> 44#include <nvgpu/enabled.h>
45#include <nvgpu/bus.h>
44 46
45#include <nvgpu/hw/gm20b/hw_proj_gm20b.h> 47#include <nvgpu/hw/gm20b/hw_proj_gm20b.h>
46#include <nvgpu/hw/gm20b/hw_fuse_gm20b.h> 48#include <nvgpu/hw/gm20b/hw_fuse_gm20b.h>
@@ -234,6 +236,13 @@ static const struct gpu_ops gm20b_ops = {
234 .cde = { 236 .cde = {
235 .get_program_numbers = gm20b_cde_get_program_numbers, 237 .get_program_numbers = gm20b_cde_get_program_numbers,
236 }, 238 },
239 .bus = {
240 .init_hw = gk20a_bus_init_hw,
241 .isr = gk20a_bus_isr,
242 .read_ptimer = gk20a_read_ptimer,
243 .get_timestamps_zipper = nvgpu_get_timestamps_zipper,
244 .bar1_bind = gm20b_bus_bar1_bind,
245 },
237#if defined(CONFIG_GK20A_CYCLE_STATS) 246#if defined(CONFIG_GK20A_CYCLE_STATS)
238 .css = { 247 .css = {
239 .enable_snapshot = css_hw_enable_snapshot, 248 .enable_snapshot = css_hw_enable_snapshot,
@@ -263,6 +272,7 @@ int gm20b_init_hal(struct gk20a *g)
263 gops->dbg_session_ops = gm20b_ops.dbg_session_ops; 272 gops->dbg_session_ops = gm20b_ops.dbg_session_ops;
264 gops->debug = gm20b_ops.debug; 273 gops->debug = gm20b_ops.debug;
265 gops->cde = gm20b_ops.cde; 274 gops->cde = gm20b_ops.cde;
275 gops->bus = gm20b_ops.bus;
266#if defined(CONFIG_GK20A_CYCLE_STATS) 276#if defined(CONFIG_GK20A_CYCLE_STATS)
267 gops->css = gm20b_ops.css; 277 gops->css = gm20b_ops.css;
268#endif 278#endif
@@ -302,8 +312,8 @@ int gm20b_init_hal(struct gk20a *g)
302 } 312 }
303 } 313 }
304#endif 314#endif
315
305 g->bootstrap_owner = LSF_BOOTSTRAP_OWNER_DEFAULT; 316 g->bootstrap_owner = LSF_BOOTSTRAP_OWNER_DEFAULT;
306 gk20a_init_bus(gops);
307 gk20a_init_priv_ring(gops); 317 gk20a_init_priv_ring(gops);
308 gm20b_init_gr(gops); 318 gm20b_init_gr(gops);
309 gm20b_init_fb(gops); 319 gm20b_init_fb(gops);
diff --git a/drivers/gpu/nvgpu/gp106/hal_gp106.c b/drivers/gpu/nvgpu/gp106/hal_gp106.c
index c54232aa..dde0468a 100644
--- a/drivers/gpu/nvgpu/gp106/hal_gp106.c
+++ b/drivers/gpu/nvgpu/gp106/hal_gp106.c
@@ -59,6 +59,7 @@
59 59
60#include <nvgpu/debug.h> 60#include <nvgpu/debug.h>
61#include <nvgpu/bug.h> 61#include <nvgpu/bug.h>
62#include <nvgpu/bus.h>
62 63
63#include <nvgpu/hw/gp106/hw_proj_gp106.h> 64#include <nvgpu/hw/gp106/hw_proj_gp106.h>
64 65
@@ -278,6 +279,13 @@ static const struct gpu_ops gp106_ops = {
278 .need_scatter_buffer = gp10b_need_scatter_buffer, 279 .need_scatter_buffer = gp10b_need_scatter_buffer,
279 .populate_scatter_buffer = gp10b_populate_scatter_buffer, 280 .populate_scatter_buffer = gp10b_populate_scatter_buffer,
280 }, 281 },
282 .bus = {
283 .init_hw = gk20a_bus_init_hw,
284 .isr = gk20a_bus_isr,
285 .read_ptimer = gk20a_read_ptimer,
286 .get_timestamps_zipper = nvgpu_get_timestamps_zipper,
287 .bar1_bind = gk20a_bus_bar1_bind,
288 },
281#if defined(CONFIG_GK20A_CYCLE_STATS) 289#if defined(CONFIG_GK20A_CYCLE_STATS)
282 .css = { 290 .css = {
283 .enable_snapshot = css_hw_enable_snapshot, 291 .enable_snapshot = css_hw_enable_snapshot,
@@ -324,6 +332,7 @@ int gp106_init_hal(struct gk20a *g)
324 gops->debug = gp106_ops.debug; 332 gops->debug = gp106_ops.debug;
325 gops->dbg_session_ops = gp106_ops.dbg_session_ops; 333 gops->dbg_session_ops = gp106_ops.dbg_session_ops;
326 gops->cde = gp106_ops.cde; 334 gops->cde = gp106_ops.cde;
335 gops->bus = gp106_ops.bus;
327#if defined(CONFIG_GK20A_CYCLE_STATS) 336#if defined(CONFIG_GK20A_CYCLE_STATS)
328 gops->css = gp106_ops.css; 337 gops->css = gp106_ops.css;
329#endif 338#endif
@@ -339,8 +348,8 @@ int gp106_init_hal(struct gk20a *g)
339 gops->privsecurity = 1; 348 gops->privsecurity = 1;
340 gops->securegpccs = 1; 349 gops->securegpccs = 1;
341 gops->pmupstate = true; 350 gops->pmupstate = true;
351
342 g->bootstrap_owner = LSF_FALCON_ID_SEC2; 352 g->bootstrap_owner = LSF_FALCON_ID_SEC2;
343 gk20a_init_bus(gops);
344 gp10b_init_priv_ring(gops); 353 gp10b_init_priv_ring(gops);
345 gp106_init_gr(gops); 354 gp106_init_gr(gops);
346 gp10b_init_fecs_trace_ops(gops); 355 gp10b_init_fecs_trace_ops(gops);
diff --git a/drivers/gpu/nvgpu/gp10b/hal_gp10b.c b/drivers/gpu/nvgpu/gp10b/hal_gp10b.c
index e526af4c..fab1c238 100644
--- a/drivers/gpu/nvgpu/gp10b/hal_gp10b.c
+++ b/drivers/gpu/nvgpu/gp10b/hal_gp10b.c
@@ -50,6 +50,7 @@
50#include <nvgpu/debug.h> 50#include <nvgpu/debug.h>
51#include <nvgpu/bug.h> 51#include <nvgpu/bug.h>
52#include <nvgpu/enabled.h> 52#include <nvgpu/enabled.h>
53#include <nvgpu/bus.h>
53 54
54#include <nvgpu/hw/gp10b/hw_proj_gp10b.h> 55#include <nvgpu/hw/gp10b/hw_proj_gp10b.h>
55#include <nvgpu/hw/gp10b/hw_fuse_gp10b.h> 56#include <nvgpu/hw/gp10b/hw_fuse_gp10b.h>
@@ -245,6 +246,13 @@ static const struct gpu_ops gp10b_ops = {
245 .need_scatter_buffer = gp10b_need_scatter_buffer, 246 .need_scatter_buffer = gp10b_need_scatter_buffer,
246 .populate_scatter_buffer = gp10b_populate_scatter_buffer, 247 .populate_scatter_buffer = gp10b_populate_scatter_buffer,
247 }, 248 },
249 .bus = {
250 .init_hw = gk20a_bus_init_hw,
251 .isr = gk20a_bus_isr,
252 .read_ptimer = gk20a_read_ptimer,
253 .get_timestamps_zipper = nvgpu_get_timestamps_zipper,
254 .bar1_bind = gk20a_bus_bar1_bind,
255 },
248#if defined(CONFIG_GK20A_CYCLE_STATS) 256#if defined(CONFIG_GK20A_CYCLE_STATS)
249 .css = { 257 .css = {
250 .enable_snapshot = css_hw_enable_snapshot, 258 .enable_snapshot = css_hw_enable_snapshot,
@@ -274,6 +282,7 @@ int gp10b_init_hal(struct gk20a *g)
274 gops->debug = gp10b_ops.debug; 282 gops->debug = gp10b_ops.debug;
275 gops->dbg_session_ops = gp10b_ops.dbg_session_ops; 283 gops->dbg_session_ops = gp10b_ops.dbg_session_ops;
276 gops->cde = gp10b_ops.cde; 284 gops->cde = gp10b_ops.cde;
285 gops->bus = gp10b_ops.bus;
277#if defined(CONFIG_GK20A_CYCLE_STATS) 286#if defined(CONFIG_GK20A_CYCLE_STATS)
278 gops->css = gp10b_ops.css; 287 gops->css = gp10b_ops.css;
279#endif 288#endif
@@ -321,8 +330,8 @@ int gp10b_init_hal(struct gk20a *g)
321 } 330 }
322 } 331 }
323#endif 332#endif
333
324 g->bootstrap_owner = LSF_BOOTSTRAP_OWNER_DEFAULT; 334 g->bootstrap_owner = LSF_BOOTSTRAP_OWNER_DEFAULT;
325 gk20a_init_bus(gops);
326 gp10b_init_priv_ring(gops); 335 gp10b_init_priv_ring(gops);
327 gp10b_init_gr(gops); 336 gp10b_init_gr(gops);
328 gp10b_init_fecs_trace_ops(gops); 337 gp10b_init_fecs_trace_ops(gops);