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 <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/594402
This commit is contained in:
Terje Bergstrom
2014-11-05 10:12:17 +02:00
committed by Dan Willemsen
parent 88c760b2ea
commit 2c23d1066f
10 changed files with 44 additions and 15 deletions

View File

@@ -700,7 +700,8 @@ enum {
FERMI_TWOD_A = 0x902D, FERMI_TWOD_A = 0x902D,
KEPLER_COMPUTE_A = 0xA0C0, KEPLER_COMPUTE_A = 0xA0C0,
KEPLER_INLINE_TO_MEMORY_A = 0xA040, 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) static inline int support_gk20a_pmu(struct platform_device *dev)

View File

@@ -27,16 +27,16 @@ int gpu_init_hal(struct gk20a *g)
switch (ver) { switch (ver) {
case GK20A_GPUID_GK20A: case GK20A_GPUID_GK20A:
gk20a_dbg_info("gk20a detected"); gk20a_dbg_info("gk20a detected");
gk20a_init_hal(&g->ops); gk20a_init_hal(g);
break; break;
case GK20A_GPUID_GM20B: case GK20A_GPUID_GM20B:
gk20a_dbg_info("gm20b detected"); gk20a_dbg_info("gm20b detected");
if (gm20b_init_hal(&g->ops)) if (gm20b_init_hal(g))
return -ENODEV; return -ENODEV;
break; break;
#if defined(CONFIG_ARCH_TEGRA_18x_SOC) #if defined(CONFIG_ARCH_TEGRA_18x_SOC)
case TEGRA_18x_GPUID: case TEGRA_18x_GPUID:
if (TEGRA_18x_GPUID_HAL(&g->ops)) if (TEGRA_18x_GPUID_HAL(g))
return -ENODEV; return -ENODEV;
break; break;
#endif #endif

View File

@@ -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 = gk20a_ops;
gops->privsecurity = 0; gops->privsecurity = 0;
gk20a_init_mc(gops); gk20a_init_mc(gops);
@@ -61,5 +64,12 @@ int gk20a_init_hal(struct gpu_ops *gops)
gk20a_init_regops(gops); gk20a_init_regops(gops);
gops->name = "gk20a"; 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; return 0;
} }

View File

@@ -20,9 +20,8 @@
#include <linux/kernel.h> #include <linux/kernel.h>
struct gpu_ops;
struct gk20a; struct gk20a;
int gk20a_init_hal(struct gpu_ops *gops); int gk20a_init_hal(struct gk20a *g);
#endif /* __HAL_GK20A__ */ #endif /* __HAL_GK20A__ */

View File

@@ -15,7 +15,7 @@
#ifndef LTC_GK20A_H #ifndef LTC_GK20A_H
#define LTC_GK20A_H #define LTC_GK20A_H
struct gk20a; struct gpu_ops;
void gk20a_init_ltc(struct gpu_ops *gops); void gk20a_init_ltc(struct gpu_ops *gops);
#endif #endif

View File

@@ -18,9 +18,11 @@
struct gk20a; struct gk20a;
enum { enum {
MAXWELL_B = 0xB197, MAXWELL_B = 0xB197,
MAXWELL_COMPUTE_B = 0xB1C0, MAXWELL_COMPUTE_B = 0xB1C0,
MAXWELL_DMA_COPY_A = 0xB0B5, KEPLER_INLINE_TO_MEMORY_B= 0xA140,
MAXWELL_DMA_COPY_A = 0xB0B5,
MAXWELL_CHANNEL_GPFIFO_A= 0xB06F,
}; };
#define NVB197_SET_ALPHA_CIRCULAR_BUFFER_SIZE 0x02dc #define NVB197_SET_ALPHA_CIRCULAR_BUFFER_SIZE 0x02dc

View File

@@ -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; *gops = gm20b_ops;
#ifdef CONFIG_TEGRA_ACR #ifdef CONFIG_TEGRA_ACR
if (tegra_platform_is_linsim()) { if (tegra_platform_is_linsim()) {
@@ -127,5 +130,12 @@ int gm20b_init_hal(struct gpu_ops *gops)
gm20b_init_regops(gops); gm20b_init_regops(gops);
gops->name = "gm20b"; 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; return 0;
} }

View File

@@ -15,7 +15,7 @@
#ifndef _NVHOST_HAL_GM20B_H #ifndef _NVHOST_HAL_GM20B_H
#define _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 #endif

View File

@@ -242,7 +242,7 @@ static int vgpu_init_hal(struct gk20a *g)
case GK20A_GPUID_GK20A: case GK20A_GPUID_GK20A:
gk20a_dbg_info("gk20a detected"); gk20a_dbg_info("gk20a detected");
/* init gk20a ops then override with virt extensions */ /* 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_fifo_ops(&g->ops);
vgpu_init_gr_ops(&g->ops); vgpu_init_gr_ops(&g->ops);
vgpu_init_ltc_ops(&g->ops); vgpu_init_ltc_ops(&g->ops);

View File

@@ -122,6 +122,13 @@ struct nvgpu_gpu_characteristics {
__u64 flags; __u64 flags;
__u32 twod_class;
__u32 threed_class;
__u32 compute_class;
__u32 gpfifo_class;
__u32 inline_to_memory_class;
__u32 dma_copy_class;
/* Notes: /* Notes:
- This struct can be safely appended with new fields. However, always - This struct can be safely appended with new fields. However, always
keep the structure size multiple of 8 and make sure that the binary keep the structure size multiple of 8 and make sure that the binary