From 2c23d1066f947e697240f5e61529c5b48407fa08 Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Wed, 5 Nov 2014 10:12:17 +0200 Subject: gpu: nvgpu: Add class numbers to characteristics Some kernel APIs rely on user space knowing class numbers. Allow querying the numbers from kernel. Bug 1567274 Change-Id: Idec2fe8ee983ee74bcbf9dfc98f71bbcc1492cfb Signed-off-by: Terje Bergstrom Reviewed-on: http://git-master/r/594402 --- drivers/gpu/nvgpu/gk20a/gk20a.h | 3 ++- drivers/gpu/nvgpu/gk20a/hal.c | 6 +++--- drivers/gpu/nvgpu/gk20a/hal_gk20a.c | 12 +++++++++++- drivers/gpu/nvgpu/gk20a/hal_gk20a.h | 3 +-- drivers/gpu/nvgpu/gk20a/ltc_gk20a.h | 2 +- drivers/gpu/nvgpu/gm20b/gr_gm20b.h | 8 +++++--- drivers/gpu/nvgpu/gm20b/hal_gm20b.c | 12 +++++++++++- drivers/gpu/nvgpu/gm20b/hal_gm20b.h | 4 ++-- drivers/gpu/nvgpu/vgpu/vgpu.c | 2 +- include/uapi/linux/nvgpu.h | 7 +++++++ 10 files changed, 44 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index e3392ae8..a56614ab 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -700,7 +700,8 @@ enum { FERMI_TWOD_A = 0x902D, KEPLER_COMPUTE_A = 0xA0C0, KEPLER_INLINE_TO_MEMORY_A = 0xA040, - KEPLER_DMA_COPY_A = 0xA0B5, /*not sure about this one*/ + KEPLER_DMA_COPY_A = 0xA0B5, + KEPLER_CHANNEL_GPFIFO_C = 0xA26F, }; static inline int support_gk20a_pmu(struct platform_device *dev) diff --git a/drivers/gpu/nvgpu/gk20a/hal.c b/drivers/gpu/nvgpu/gk20a/hal.c index 56553819..10607af0 100644 --- a/drivers/gpu/nvgpu/gk20a/hal.c +++ b/drivers/gpu/nvgpu/gk20a/hal.c @@ -27,16 +27,16 @@ int gpu_init_hal(struct gk20a *g) switch (ver) { case GK20A_GPUID_GK20A: gk20a_dbg_info("gk20a detected"); - gk20a_init_hal(&g->ops); + gk20a_init_hal(g); break; case GK20A_GPUID_GM20B: gk20a_dbg_info("gm20b detected"); - if (gm20b_init_hal(&g->ops)) + if (gm20b_init_hal(g)) return -ENODEV; break; #if defined(CONFIG_ARCH_TEGRA_18x_SOC) case TEGRA_18x_GPUID: - if (TEGRA_18x_GPUID_HAL(&g->ops)) + if (TEGRA_18x_GPUID_HAL(g)) return -ENODEV; break; #endif diff --git a/drivers/gpu/nvgpu/gk20a/hal_gk20a.c b/drivers/gpu/nvgpu/gk20a/hal_gk20a.c index 7000f682..ada2f034 100644 --- a/drivers/gpu/nvgpu/gk20a/hal_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/hal_gk20a.c @@ -45,8 +45,11 @@ static struct gpu_ops gk20a_ops = { } }; -int gk20a_init_hal(struct gpu_ops *gops) +int gk20a_init_hal(struct gk20a *g) { + struct gpu_ops *gops = &g->ops; + struct nvgpu_gpu_characteristics *c = &g->gpu_characteristics; + *gops = gk20a_ops; gops->privsecurity = 0; gk20a_init_mc(gops); @@ -61,5 +64,12 @@ int gk20a_init_hal(struct gpu_ops *gops) gk20a_init_regops(gops); gops->name = "gk20a"; + c->twod_class = FERMI_TWOD_A; + c->threed_class = KEPLER_C; + c->compute_class = KEPLER_COMPUTE_A; + c->gpfifo_class = KEPLER_CHANNEL_GPFIFO_C; + c->inline_to_memory_class = KEPLER_INLINE_TO_MEMORY_A; + c->dma_copy_class = KEPLER_DMA_COPY_A; + return 0; } diff --git a/drivers/gpu/nvgpu/gk20a/hal_gk20a.h b/drivers/gpu/nvgpu/gk20a/hal_gk20a.h index db77a4a7..f214432a 100644 --- a/drivers/gpu/nvgpu/gk20a/hal_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/hal_gk20a.h @@ -20,9 +20,8 @@ #include -struct gpu_ops; struct gk20a; -int gk20a_init_hal(struct gpu_ops *gops); +int gk20a_init_hal(struct gk20a *g); #endif /* __HAL_GK20A__ */ diff --git a/drivers/gpu/nvgpu/gk20a/ltc_gk20a.h b/drivers/gpu/nvgpu/gk20a/ltc_gk20a.h index df7dc9e4..3cace0fd 100644 --- a/drivers/gpu/nvgpu/gk20a/ltc_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/ltc_gk20a.h @@ -15,7 +15,7 @@ #ifndef LTC_GK20A_H #define LTC_GK20A_H -struct gk20a; +struct gpu_ops; void gk20a_init_ltc(struct gpu_ops *gops); #endif diff --git a/drivers/gpu/nvgpu/gm20b/gr_gm20b.h b/drivers/gpu/nvgpu/gm20b/gr_gm20b.h index 8348b9d9..470e5bae 100644 --- a/drivers/gpu/nvgpu/gm20b/gr_gm20b.h +++ b/drivers/gpu/nvgpu/gm20b/gr_gm20b.h @@ -18,9 +18,11 @@ struct gk20a; enum { - MAXWELL_B = 0xB197, - MAXWELL_COMPUTE_B = 0xB1C0, - MAXWELL_DMA_COPY_A = 0xB0B5, + MAXWELL_B = 0xB197, + MAXWELL_COMPUTE_B = 0xB1C0, + KEPLER_INLINE_TO_MEMORY_B= 0xA140, + MAXWELL_DMA_COPY_A = 0xB0B5, + MAXWELL_CHANNEL_GPFIFO_A= 0xB06F, }; #define NVB197_SET_ALPHA_CIRCULAR_BUFFER_SIZE 0x02dc diff --git a/drivers/gpu/nvgpu/gm20b/hal_gm20b.c b/drivers/gpu/nvgpu/gm20b/hal_gm20b.c index 2b534816..e95f8878 100644 --- a/drivers/gpu/nvgpu/gm20b/hal_gm20b.c +++ b/drivers/gpu/nvgpu/gm20b/hal_gm20b.c @@ -83,8 +83,11 @@ static struct gpu_ops gm20b_ops = { } }; -int gm20b_init_hal(struct gpu_ops *gops) +int gm20b_init_hal(struct gk20a *g) { + struct gpu_ops *gops = &g->ops; + struct nvgpu_gpu_characteristics *c = &g->gpu_characteristics; + *gops = gm20b_ops; #ifdef CONFIG_TEGRA_ACR if (tegra_platform_is_linsim()) { @@ -127,5 +130,12 @@ int gm20b_init_hal(struct gpu_ops *gops) gm20b_init_regops(gops); gops->name = "gm20b"; + c->twod_class = FERMI_TWOD_A; + c->threed_class = MAXWELL_B; + c->compute_class = MAXWELL_COMPUTE_B; + c->gpfifo_class = MAXWELL_CHANNEL_GPFIFO_A; + c->inline_to_memory_class = KEPLER_INLINE_TO_MEMORY_B; + c->dma_copy_class = MAXWELL_DMA_COPY_A; + return 0; } diff --git a/drivers/gpu/nvgpu/gm20b/hal_gm20b.h b/drivers/gpu/nvgpu/gm20b/hal_gm20b.h index 99e193fc..2416876d 100644 --- a/drivers/gpu/nvgpu/gm20b/hal_gm20b.h +++ b/drivers/gpu/nvgpu/gm20b/hal_gm20b.h @@ -15,7 +15,7 @@ #ifndef _NVHOST_HAL_GM20B_H #define _NVHOST_HAL_GM20B_H -struct gpu_ops; +struct gk20a; -int gm20b_init_hal(struct gpu_ops *gops); +int gm20b_init_hal(struct gk20a *g); #endif diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.c b/drivers/gpu/nvgpu/vgpu/vgpu.c index 82a0851e..f9b97d97 100644 --- a/drivers/gpu/nvgpu/vgpu/vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/vgpu.c @@ -242,7 +242,7 @@ static int vgpu_init_hal(struct gk20a *g) case GK20A_GPUID_GK20A: gk20a_dbg_info("gk20a detected"); /* init gk20a ops then override with virt extensions */ - gk20a_init_hal(&g->ops); + gk20a_init_hal(g); vgpu_init_fifo_ops(&g->ops); vgpu_init_gr_ops(&g->ops); vgpu_init_ltc_ops(&g->ops); diff --git a/include/uapi/linux/nvgpu.h b/include/uapi/linux/nvgpu.h index b7f65d75..6bde9d41 100644 --- a/include/uapi/linux/nvgpu.h +++ b/include/uapi/linux/nvgpu.h @@ -122,6 +122,13 @@ struct nvgpu_gpu_characteristics { __u64 flags; + __u32 twod_class; + __u32 threed_class; + __u32 compute_class; + __u32 gpfifo_class; + __u32 inline_to_memory_class; + __u32 dma_copy_class; + /* Notes: - This struct can be safely appended with new fields. However, always keep the structure size multiple of 8 and make sure that the binary -- cgit v1.2.2