aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2015-04-14 22:47:29 -0400
committerDave Airlie <airlied@redhat.com>2015-04-14 22:47:29 -0400
commit665ae581ae82ed6a28980a32b9d37345db4eed32 (patch)
tree8c434951d4b0d753cb35d2f45648c6e7dddbe8ea
parent1d2add28edd268a8290801ccf46b37f6d5239cdb (diff)
parent4195f40685a5f2783b4decece13ed740b61ee038 (diff)
Merge branch 'linux-4.1' of git://anongit.freedesktop.org/git/nouveau/linux-2.6 into drm-next
- gk20a iommu support - gm107 graphics support without needing proprietary ucode - various random fixes - more gm20x bring-up, fifo/ce are ok, gr is mostly complete with the exception of ctxsw ucode.. nvidia aren't playing nice yet so there's not much more that can be done at this point... I spent a lot of time trying to find a viable way of doing gr ctxsw without signed firmware, but the "security" restrictions on the fecs/gpccs falcons are excessive and go beyond what'd be necessary to protect the host from malicious firmware. This newer nvidia hw is VERY open-source unfriendly. I have some experimental host-based ctxsw work that could be a viable (albeit unsatisfactory and slow) workaround in the meantime, but it needs some more work and i'd like to get the 3d driver working properly before i commit to pushing it. * 'linux-4.1' of git://anongit.freedesktop.org/git/nouveau/linux-2.6: (40 commits) drm/nouveau/bios: fix fetching from acpi on certain systems drm/nouveau/gr/gm206: initial init+ctx code drm/nouveau/ce/gm206: enable support via gm204 code drm/nouveau/fifo/gm206: enable support via gm204 code drm/nouveau/gr/gm204: initial init+ctx code drm/nouveau: support for buffer moves via MaxwellDmaCopyA drm/nouveau/ce/gm204: initial support drm/nouveau: add support for gm20x fifo channels drm/nouveau/fifo/gm204: initial support drm/nouveau/gr/gk104-: prevent reading non-existent regs in intr handler drm/nouveau/gr/gm107: very slightly demagic part of attrib cb setup drm/nouveau/gr/gk104-: correct crop/zrop num_active_fbps setting drm/nouveau/gr/gf100-: add symbolic names for classes drm/nouveau/gr/gm107: support tpc "strand" ctxsw in gpccs ucode drm/nouveau/gr/gf100-: support mmio access with gpc offset from gpccs ucode drm/nouveau/gr: fix engine name, cosmetic search+replace mistake drm/nouveau/pmu/gk20a: add some missing statics drm/nouveau/platform: fix probe error path drm/nouveau/platform: release IOMMU's mm upon exit drm/nouveau/gr/gk104-gk20a: call pmu to disable any power-gating before ctor() ...
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/class.h10
-rw-r--r--drivers/gpu/drm/nouveau/include/nvkm/engine/ce.h3
-rw-r--r--drivers/gpu/drm/nouveau/include/nvkm/engine/fifo.h1
-rw-r--r--drivers/gpu/drm/nouveau/include/nvkm/engine/gr.h4
-rw-r--r--drivers/gpu/drm/nouveau/include/nvkm/subdev/instmem.h1
-rw-r--r--drivers/gpu/drm/nouveau/include/nvkm/subdev/pmu.h1
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_chan.c3
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_display.c9
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drm.c1
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drm.h4
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_gem.c3
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_platform.c79
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_platform.h18
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_ttm.c3
-rw-r--r--drivers/gpu/drm/nouveau/nv84_fence.c14
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/ce/Kbuild1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/ce/gm204.c173
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/device/base.c10
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/device/gk104.c6
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/device/gm100.c16
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/gf110.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/Kbuild1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c7
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.h2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/gm204.c57
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/Kbuild4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgf100.h29
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgk104.c16
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm107.c20
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm204.c1054
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm206.c83
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpc.fuc114
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgf100.fuc3.h294
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgf117.fuc3.h354
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk104.fuc3.h354
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk110.fuc3.h354
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk208.fuc5.h230
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgm107.fuc52
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgm107.fuc5.h480
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/macros.fuc32
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c22
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h20
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/gf108.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/gf110.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/gk104.c17
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/gk110.c45
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/gk110b.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/gk208.c47
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/gk20a.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/gm107.c26
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/gm204.c387
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/gm206.c40
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowacpi.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/bus/hwsq.c2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/bus/hwsq.h44
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/devinit/nv04.h2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/fb/Kbuild1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/fb/base.c26
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/fb/gk20a.c1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/fb/priv.h1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgk20a.c149
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/fuse/gm107.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/instmem/Kbuild1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c440
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gf100.c10
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/mxm/nv50.c2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/pmu/Kbuild1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk110.c95
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk208.c1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk20a.c7
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/pmu/priv.h2
-rw-r--r--include/uapi/drm/nouveau_drm.h1
75 files changed, 3957 insertions, 1314 deletions
diff --git a/drivers/gpu/drm/nouveau/include/nvif/class.h b/drivers/gpu/drm/nouveau/include/nvif/class.h
index 5ad17fc36ae3..0b5af0fe8659 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/class.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/class.h
@@ -12,6 +12,13 @@
12#define NV_DMA_TO_MEMORY 0x00000003 12#define NV_DMA_TO_MEMORY 0x00000003
13#define NV_DMA_IN_MEMORY 0x0000003d 13#define NV_DMA_IN_MEMORY 0x0000003d
14 14
15#define FERMI_TWOD_A 0x0000902d
16
17#define FERMI_MEMORY_TO_MEMORY_FORMAT_A 0x0000903d
18
19#define KEPLER_INLINE_TO_MEMORY_A 0x0000a040
20#define KEPLER_INLINE_TO_MEMORY_B 0x0000a140
21
15#define NV04_DISP 0x00000046 22#define NV04_DISP 0x00000046
16 23
17#define NV03_CHANNEL_DMA 0x0000006b 24#define NV03_CHANNEL_DMA 0x0000006b
@@ -25,6 +32,7 @@
25#define G82_CHANNEL_GPFIFO 0x0000826f 32#define G82_CHANNEL_GPFIFO 0x0000826f
26#define FERMI_CHANNEL_GPFIFO 0x0000906f 33#define FERMI_CHANNEL_GPFIFO 0x0000906f
27#define KEPLER_CHANNEL_GPFIFO_A 0x0000a06f 34#define KEPLER_CHANNEL_GPFIFO_A 0x0000a06f
35#define MAXWELL_CHANNEL_GPFIFO_A 0x0000b06f
28 36
29#define NV50_DISP 0x00005070 37#define NV50_DISP 0x00005070
30#define G82_DISP 0x00008270 38#define G82_DISP 0x00008270
@@ -84,6 +92,7 @@
84#define KEPLER_C 0x0000a297 92#define KEPLER_C 0x0000a297
85 93
86#define MAXWELL_A 0x0000b097 94#define MAXWELL_A 0x0000b097
95#define MAXWELL_B 0x0000b197
87 96
88#define FERMI_COMPUTE_A 0x000090c0 97#define FERMI_COMPUTE_A 0x000090c0
89#define FERMI_COMPUTE_B 0x000091c0 98#define FERMI_COMPUTE_B 0x000091c0
@@ -92,6 +101,7 @@
92#define KEPLER_COMPUTE_B 0x0000a1c0 101#define KEPLER_COMPUTE_B 0x0000a1c0
93 102
94#define MAXWELL_COMPUTE_A 0x0000b0c0 103#define MAXWELL_COMPUTE_A 0x0000b0c0
104#define MAXWELL_COMPUTE_B 0x0000b1c0
95 105
96 106
97/******************************************************************************* 107/*******************************************************************************
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/engine/ce.h b/drivers/gpu/drm/nouveau/include/nvkm/engine/ce.h
index 7e29c52617ea..e832f729e1b4 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/engine/ce.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/engine/ce.h
@@ -10,4 +10,7 @@ extern struct nvkm_oclass gf100_ce1_oclass;
10extern struct nvkm_oclass gk104_ce0_oclass; 10extern struct nvkm_oclass gk104_ce0_oclass;
11extern struct nvkm_oclass gk104_ce1_oclass; 11extern struct nvkm_oclass gk104_ce1_oclass;
12extern struct nvkm_oclass gk104_ce2_oclass; 12extern struct nvkm_oclass gk104_ce2_oclass;
13extern struct nvkm_oclass gm204_ce0_oclass;
14extern struct nvkm_oclass gm204_ce1_oclass;
15extern struct nvkm_oclass gm204_ce2_oclass;
13#endif 16#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/engine/fifo.h b/drivers/gpu/drm/nouveau/include/nvkm/engine/fifo.h
index 05321ce7ab15..97cdeab8e44c 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/engine/fifo.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/engine/fifo.h
@@ -116,6 +116,7 @@ extern struct nvkm_oclass *gf100_fifo_oclass;
116extern struct nvkm_oclass *gk104_fifo_oclass; 116extern struct nvkm_oclass *gk104_fifo_oclass;
117extern struct nvkm_oclass *gk20a_fifo_oclass; 117extern struct nvkm_oclass *gk20a_fifo_oclass;
118extern struct nvkm_oclass *gk208_fifo_oclass; 118extern struct nvkm_oclass *gk208_fifo_oclass;
119extern struct nvkm_oclass *gm204_fifo_oclass;
119 120
120int nvkm_fifo_uevent_ctor(struct nvkm_object *, void *, u32, 121int nvkm_fifo_uevent_ctor(struct nvkm_object *, void *, u32,
121 struct nvkm_notify *); 122 struct nvkm_notify *);
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/engine/gr.h b/drivers/gpu/drm/nouveau/include/nvkm/engine/gr.h
index 93ef1f2bfac4..7cbe20280760 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/engine/gr.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/engine/gr.h
@@ -38,7 +38,7 @@ nvkm_gr(void *obj)
38} 38}
39 39
40#define nvkm_gr_create(p,e,c,y,d) \ 40#define nvkm_gr_create(p,e,c,y,d) \
41 nvkm_engine_create((p), (e), (c), (y), "PGR", "graphics", (d)) 41 nvkm_engine_create((p), (e), (c), (y), "PGRAPH", "graphics", (d))
42#define nvkm_gr_destroy(d) \ 42#define nvkm_gr_destroy(d) \
43 nvkm_engine_destroy(&(d)->base) 43 nvkm_engine_destroy(&(d)->base)
44#define nvkm_gr_init(d) \ 44#define nvkm_gr_init(d) \
@@ -72,6 +72,8 @@ extern struct nvkm_oclass *gk110_gr_oclass;
72extern struct nvkm_oclass *gk110b_gr_oclass; 72extern struct nvkm_oclass *gk110b_gr_oclass;
73extern struct nvkm_oclass *gk208_gr_oclass; 73extern struct nvkm_oclass *gk208_gr_oclass;
74extern struct nvkm_oclass *gm107_gr_oclass; 74extern struct nvkm_oclass *gm107_gr_oclass;
75extern struct nvkm_oclass *gm204_gr_oclass;
76extern struct nvkm_oclass *gm206_gr_oclass;
75 77
76#include <core/enum.h> 78#include <core/enum.h>
77 79
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/instmem.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/instmem.h
index d104c1aac807..1bcb763cfca0 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/instmem.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/instmem.h
@@ -45,4 +45,5 @@ nvkm_instmem(void *obj)
45extern struct nvkm_oclass *nv04_instmem_oclass; 45extern struct nvkm_oclass *nv04_instmem_oclass;
46extern struct nvkm_oclass *nv40_instmem_oclass; 46extern struct nvkm_oclass *nv40_instmem_oclass;
47extern struct nvkm_oclass *nv50_instmem_oclass; 47extern struct nvkm_oclass *nv50_instmem_oclass;
48extern struct nvkm_oclass *gk20a_instmem_oclass;
48#endif 49#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/pmu.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/pmu.h
index 7b86acc634a0..755942352557 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/pmu.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/pmu.h
@@ -35,6 +35,7 @@ extern struct nvkm_oclass *gt215_pmu_oclass;
35extern struct nvkm_oclass *gf100_pmu_oclass; 35extern struct nvkm_oclass *gf100_pmu_oclass;
36extern struct nvkm_oclass *gf110_pmu_oclass; 36extern struct nvkm_oclass *gf110_pmu_oclass;
37extern struct nvkm_oclass *gk104_pmu_oclass; 37extern struct nvkm_oclass *gk104_pmu_oclass;
38extern struct nvkm_oclass *gk110_pmu_oclass;
38extern struct nvkm_oclass *gk208_pmu_oclass; 39extern struct nvkm_oclass *gk208_pmu_oclass;
39extern struct nvkm_oclass *gk20a_pmu_oclass; 40extern struct nvkm_oclass *gk20a_pmu_oclass;
40 41
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 77326e344dad..6edcce1658b7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1110,6 +1110,8 @@ nouveau_bo_move_init(struct nouveau_drm *drm)
1110 struct ttm_mem_reg *, struct ttm_mem_reg *); 1110 struct ttm_mem_reg *, struct ttm_mem_reg *);
1111 int (*init)(struct nouveau_channel *, u32 handle); 1111 int (*init)(struct nouveau_channel *, u32 handle);
1112 } _methods[] = { 1112 } _methods[] = {
1113 { "COPY", 4, 0xb0b5, nve0_bo_move_copy, nve0_bo_move_init },
1114 { "GRCE", 0, 0xb0b5, nve0_bo_move_copy, nvc0_bo_move_init },
1113 { "COPY", 4, 0xa0b5, nve0_bo_move_copy, nve0_bo_move_init }, 1115 { "COPY", 4, 0xa0b5, nve0_bo_move_copy, nve0_bo_move_init },
1114 { "GRCE", 0, 0xa0b5, nve0_bo_move_copy, nvc0_bo_move_init }, 1116 { "GRCE", 0, 0xa0b5, nve0_bo_move_copy, nvc0_bo_move_init },
1115 { "COPY1", 5, 0x90b8, nvc0_bo_move_copy, nvc0_bo_move_init }, 1117 { "COPY1", 5, 0x90b8, nvc0_bo_move_copy, nvc0_bo_move_init },
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index e581f63cbf25..0589babc506e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -184,7 +184,8 @@ static int
184nouveau_channel_ind(struct nouveau_drm *drm, struct nvif_device *device, 184nouveau_channel_ind(struct nouveau_drm *drm, struct nvif_device *device,
185 u32 handle, u32 engine, struct nouveau_channel **pchan) 185 u32 handle, u32 engine, struct nouveau_channel **pchan)
186{ 186{
187 static const u16 oclasses[] = { KEPLER_CHANNEL_GPFIFO_A, 187 static const u16 oclasses[] = { MAXWELL_CHANNEL_GPFIFO_A,
188 KEPLER_CHANNEL_GPFIFO_A,
188 FERMI_CHANNEL_GPFIFO, 189 FERMI_CHANNEL_GPFIFO,
189 G82_CHANNEL_GPFIFO, 190 G82_CHANNEL_GPFIFO,
190 NV50_CHANNEL_GPFIFO, 191 NV50_CHANNEL_GPFIFO,
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 860b0e2d4181..8670d90cdc11 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -869,13 +869,20 @@ nouveau_display_dumb_create(struct drm_file *file_priv, struct drm_device *dev,
869 struct drm_mode_create_dumb *args) 869 struct drm_mode_create_dumb *args)
870{ 870{
871 struct nouveau_bo *bo; 871 struct nouveau_bo *bo;
872 uint32_t domain;
872 int ret; 873 int ret;
873 874
874 args->pitch = roundup(args->width * (args->bpp / 8), 256); 875 args->pitch = roundup(args->width * (args->bpp / 8), 256);
875 args->size = args->pitch * args->height; 876 args->size = args->pitch * args->height;
876 args->size = roundup(args->size, PAGE_SIZE); 877 args->size = roundup(args->size, PAGE_SIZE);
877 878
878 ret = nouveau_gem_new(dev, args->size, 0, NOUVEAU_GEM_DOMAIN_VRAM, 0, 0, &bo); 879 /* Use VRAM if there is any ; otherwise fallback to system memory */
880 if (nouveau_drm(dev)->device.info.ram_size != 0)
881 domain = NOUVEAU_GEM_DOMAIN_VRAM;
882 else
883 domain = NOUVEAU_GEM_DOMAIN_GART;
884
885 ret = nouveau_gem_new(dev, args->size, 0, domain, 0, 0, &bo);
879 if (ret) 886 if (ret)
880 return ret; 887 return ret;
881 888
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 8763deb5188b..89049335b738 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -181,6 +181,7 @@ nouveau_accel_init(struct nouveau_drm *drm)
181 break; 181 break;
182 case FERMI_CHANNEL_GPFIFO: 182 case FERMI_CHANNEL_GPFIFO:
183 case KEPLER_CHANNEL_GPFIFO_A: 183 case KEPLER_CHANNEL_GPFIFO_A:
184 case MAXWELL_CHANNEL_GPFIFO_A:
184 ret = nvc0_fence_create(drm); 185 ret = nvc0_fence_create(drm);
185 break; 186 break;
186 default: 187 default:
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
index fc68f0973f9e..dd726523ca99 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
@@ -10,7 +10,7 @@
10 10
11#define DRIVER_MAJOR 1 11#define DRIVER_MAJOR 1
12#define DRIVER_MINOR 2 12#define DRIVER_MINOR 2
13#define DRIVER_PATCHLEVEL 1 13#define DRIVER_PATCHLEVEL 2
14 14
15/* 15/*
16 * 1.1.1: 16 * 1.1.1:
@@ -28,6 +28,8 @@
28 * - fermi,kepler,maxwell zbc 28 * - fermi,kepler,maxwell zbc
29 * 1.2.1: 29 * 1.2.1:
30 * - allow concurrent access to bo's mapped read/write. 30 * - allow concurrent access to bo's mapped read/write.
31 * 1.2.2:
32 * - add NOUVEAU_GEM_DOMAIN_COHERENT flag
31 */ 33 */
32 34
33#include <nvif/client.h> 35#include <nvif/client.h>
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 7c077fced1d1..0e690bf19fc9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -189,6 +189,9 @@ nouveau_gem_new(struct drm_device *dev, int size, int align, uint32_t domain,
189 if (!flags || domain & NOUVEAU_GEM_DOMAIN_CPU) 189 if (!flags || domain & NOUVEAU_GEM_DOMAIN_CPU)
190 flags |= TTM_PL_FLAG_SYSTEM; 190 flags |= TTM_PL_FLAG_SYSTEM;
191 191
192 if (domain & NOUVEAU_GEM_DOMAIN_COHERENT)
193 flags |= TTM_PL_FLAG_UNCACHED;
194
192 ret = nouveau_bo_new(dev, size, align, flags, tile_mode, 195 ret = nouveau_bo_new(dev, size, align, flags, tile_mode,
193 tile_flags, NULL, NULL, pnvbo); 196 tile_flags, NULL, NULL, pnvbo);
194 if (ret) 197 if (ret)
diff --git a/drivers/gpu/drm/nouveau/nouveau_platform.c b/drivers/gpu/drm/nouveau/nouveau_platform.c
index dc5900bf54ff..775277f1edb0 100644
--- a/drivers/gpu/drm/nouveau/nouveau_platform.c
+++ b/drivers/gpu/drm/nouveau/nouveau_platform.c
@@ -27,6 +27,7 @@
27#include <linux/of.h> 27#include <linux/of.h>
28#include <linux/reset.h> 28#include <linux/reset.h>
29#include <linux/regulator/consumer.h> 29#include <linux/regulator/consumer.h>
30#include <linux/iommu.h>
30#include <soc/tegra/fuse.h> 31#include <soc/tegra/fuse.h>
31#include <soc/tegra/pmc.h> 32#include <soc/tegra/pmc.h>
32 33
@@ -91,6 +92,72 @@ static int nouveau_platform_power_down(struct nouveau_platform_gpu *gpu)
91 return 0; 92 return 0;
92} 93}
93 94
95static void nouveau_platform_probe_iommu(struct device *dev,
96 struct nouveau_platform_gpu *gpu)
97{
98 int err;
99 unsigned long pgsize_bitmap;
100
101 mutex_init(&gpu->iommu.mutex);
102
103 if (iommu_present(&platform_bus_type)) {
104 gpu->iommu.domain = iommu_domain_alloc(&platform_bus_type);
105 if (IS_ERR(gpu->iommu.domain))
106 goto error;
107
108 /*
109 * A IOMMU is only usable if it supports page sizes smaller
110 * or equal to the system's PAGE_SIZE, with a preference if
111 * both are equal.
112 */
113 pgsize_bitmap = gpu->iommu.domain->ops->pgsize_bitmap;
114 if (pgsize_bitmap & PAGE_SIZE) {
115 gpu->iommu.pgshift = PAGE_SHIFT;
116 } else {
117 gpu->iommu.pgshift = fls(pgsize_bitmap & ~PAGE_MASK);
118 if (gpu->iommu.pgshift == 0) {
119 dev_warn(dev, "unsupported IOMMU page size\n");
120 goto free_domain;
121 }
122 gpu->iommu.pgshift -= 1;
123 }
124
125 err = iommu_attach_device(gpu->iommu.domain, dev);
126 if (err)
127 goto free_domain;
128
129 err = nvkm_mm_init(&gpu->iommu._mm, 0,
130 (1ULL << 40) >> gpu->iommu.pgshift, 1);
131 if (err)
132 goto detach_device;
133
134 gpu->iommu.mm = &gpu->iommu._mm;
135 }
136
137 return;
138
139detach_device:
140 iommu_detach_device(gpu->iommu.domain, dev);
141
142free_domain:
143 iommu_domain_free(gpu->iommu.domain);
144
145error:
146 gpu->iommu.domain = NULL;
147 gpu->iommu.pgshift = 0;
148 dev_err(dev, "cannot initialize IOMMU MM\n");
149}
150
151static void nouveau_platform_remove_iommu(struct device *dev,
152 struct nouveau_platform_gpu *gpu)
153{
154 if (gpu->iommu.domain) {
155 nvkm_mm_fini(&gpu->iommu._mm);
156 iommu_detach_device(gpu->iommu.domain, dev);
157 iommu_domain_free(gpu->iommu.domain);
158 }
159}
160
94static int nouveau_platform_probe(struct platform_device *pdev) 161static int nouveau_platform_probe(struct platform_device *pdev)
95{ 162{
96 struct nouveau_platform_gpu *gpu; 163 struct nouveau_platform_gpu *gpu;
@@ -118,6 +185,8 @@ static int nouveau_platform_probe(struct platform_device *pdev)
118 if (IS_ERR(gpu->clk_pwr)) 185 if (IS_ERR(gpu->clk_pwr))
119 return PTR_ERR(gpu->clk_pwr); 186 return PTR_ERR(gpu->clk_pwr);
120 187
188 nouveau_platform_probe_iommu(&pdev->dev, gpu);
189
121 err = nouveau_platform_power_up(gpu); 190 err = nouveau_platform_power_up(gpu);
122 if (err) 191 if (err)
123 return err; 192 return err;
@@ -140,10 +209,9 @@ static int nouveau_platform_probe(struct platform_device *pdev)
140err_unref: 209err_unref:
141 drm_dev_unref(drm); 210 drm_dev_unref(drm);
142 211
143 return 0;
144
145power_down: 212power_down:
146 nouveau_platform_power_down(gpu); 213 nouveau_platform_power_down(gpu);
214 nouveau_platform_remove_iommu(&pdev->dev, gpu);
147 215
148 return err; 216 return err;
149} 217}
@@ -154,10 +222,15 @@ static int nouveau_platform_remove(struct platform_device *pdev)
154 struct nouveau_drm *drm = nouveau_drm(drm_dev); 222 struct nouveau_drm *drm = nouveau_drm(drm_dev);
155 struct nvkm_device *device = nvxx_device(&drm->device); 223 struct nvkm_device *device = nvxx_device(&drm->device);
156 struct nouveau_platform_gpu *gpu = nv_device_to_platform(device)->gpu; 224 struct nouveau_platform_gpu *gpu = nv_device_to_platform(device)->gpu;
225 int err;
157 226
158 nouveau_drm_device_remove(drm_dev); 227 nouveau_drm_device_remove(drm_dev);
159 228
160 return nouveau_platform_power_down(gpu); 229 err = nouveau_platform_power_down(gpu);
230
231 nouveau_platform_remove_iommu(&pdev->dev, gpu);
232
233 return err;
161} 234}
162 235
163#if IS_ENABLED(CONFIG_OF) 236#if IS_ENABLED(CONFIG_OF)
diff --git a/drivers/gpu/drm/nouveau/nouveau_platform.h b/drivers/gpu/drm/nouveau/nouveau_platform.h
index 268bb7213681..392874cf4725 100644
--- a/drivers/gpu/drm/nouveau/nouveau_platform.h
+++ b/drivers/gpu/drm/nouveau/nouveau_platform.h
@@ -24,10 +24,12 @@
24#define __NOUVEAU_PLATFORM_H__ 24#define __NOUVEAU_PLATFORM_H__
25 25
26#include "core/device.h" 26#include "core/device.h"
27#include "core/mm.h"
27 28
28struct reset_control; 29struct reset_control;
29struct clk; 30struct clk;
30struct regulator; 31struct regulator;
32struct iommu_domain;
31struct platform_driver; 33struct platform_driver;
32 34
33struct nouveau_platform_gpu { 35struct nouveau_platform_gpu {
@@ -36,6 +38,22 @@ struct nouveau_platform_gpu {
36 struct clk *clk_pwr; 38 struct clk *clk_pwr;
37 39
38 struct regulator *vdd; 40 struct regulator *vdd;
41
42 struct {
43 /*
44 * Protects accesses to mm from subsystems
45 */
46 struct mutex mutex;
47
48 struct nvkm_mm _mm;
49 /*
50 * Just points to _mm. We need this to avoid embedding
51 * struct nvkm_mm in os.h
52 */
53 struct nvkm_mm *mm;
54 struct iommu_domain *domain;
55 unsigned long pgshift;
56 } iommu;
39}; 57};
40 58
41struct nouveau_platform_device { 59struct nouveau_platform_device {
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 273e50110ec3..18f449715788 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -82,6 +82,9 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
82 u32 size_nc = 0; 82 u32 size_nc = 0;
83 int ret; 83 int ret;
84 84
85 if (drm->device.info.ram_size == 0)
86 return -ENOMEM;
87
85 if (nvbo->tile_flags & NOUVEAU_GEM_TILE_NONCONTIG) 88 if (nvbo->tile_flags & NOUVEAU_GEM_TILE_NONCONTIG)
86 size_nc = 1 << nvbo->page_shift; 89 size_nc = 1 << nvbo->page_shift;
87 90
diff --git a/drivers/gpu/drm/nouveau/nv84_fence.c b/drivers/gpu/drm/nouveau/nv84_fence.c
index bf429cabbaa8..a03db4368696 100644
--- a/drivers/gpu/drm/nouveau/nv84_fence.c
+++ b/drivers/gpu/drm/nouveau/nv84_fence.c
@@ -215,6 +215,7 @@ nv84_fence_create(struct nouveau_drm *drm)
215{ 215{
216 struct nvkm_fifo *pfifo = nvxx_fifo(&drm->device); 216 struct nvkm_fifo *pfifo = nvxx_fifo(&drm->device);
217 struct nv84_fence_priv *priv; 217 struct nv84_fence_priv *priv;
218 u32 domain;
218 int ret; 219 int ret;
219 220
220 priv = drm->fence = kzalloc(sizeof(*priv), GFP_KERNEL); 221 priv = drm->fence = kzalloc(sizeof(*priv), GFP_KERNEL);
@@ -231,10 +232,17 @@ nv84_fence_create(struct nouveau_drm *drm)
231 priv->base.context_base = fence_context_alloc(priv->base.contexts); 232 priv->base.context_base = fence_context_alloc(priv->base.contexts);
232 priv->base.uevent = true; 233 priv->base.uevent = true;
233 234
234 ret = nouveau_bo_new(drm->dev, 16 * priv->base.contexts, 0, 235 /* Use VRAM if there is any ; otherwise fallback to system memory */
235 TTM_PL_FLAG_VRAM, 0, 0, NULL, NULL, &priv->bo); 236 domain = drm->device.info.ram_size != 0 ? TTM_PL_FLAG_VRAM :
237 /*
238 * fences created in sysmem must be non-cached or we
239 * will lose CPU/GPU coherency!
240 */
241 TTM_PL_FLAG_TT | TTM_PL_FLAG_UNCACHED;
242 ret = nouveau_bo_new(drm->dev, 16 * priv->base.contexts, 0, domain, 0,
243 0, NULL, NULL, &priv->bo);
236 if (ret == 0) { 244 if (ret == 0) {
237 ret = nouveau_bo_pin(priv->bo, TTM_PL_FLAG_VRAM, false); 245 ret = nouveau_bo_pin(priv->bo, domain, false);
238 if (ret == 0) { 246 if (ret == 0) {
239 ret = nouveau_bo_map(priv->bo); 247 ret = nouveau_bo_map(priv->bo);
240 if (ret) 248 if (ret)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/ce/Kbuild b/drivers/gpu/drm/nouveau/nvkm/engine/ce/Kbuild
index 858797453e0b..fa8cda7058cd 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/ce/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/ce/Kbuild
@@ -1,3 +1,4 @@
1nvkm-y += nvkm/engine/ce/gt215.o 1nvkm-y += nvkm/engine/ce/gt215.o
2nvkm-y += nvkm/engine/ce/gf100.o 2nvkm-y += nvkm/engine/ce/gf100.o
3nvkm-y += nvkm/engine/ce/gk104.o 3nvkm-y += nvkm/engine/ce/gk104.o
4nvkm-y += nvkm/engine/ce/gm204.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/ce/gm204.c b/drivers/gpu/drm/nouveau/nvkm/engine/ce/gm204.c
new file mode 100644
index 000000000000..577eb2eead05
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/ce/gm204.c
@@ -0,0 +1,173 @@
1/*
2 * Copyright 2015 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs
23 */
24#include <engine/ce.h>
25
26#include <core/engctx.h>
27
28struct gm204_ce_priv {
29 struct nvkm_engine base;
30};
31
32/*******************************************************************************
33 * Copy object classes
34 ******************************************************************************/
35
36static struct nvkm_oclass
37gm204_ce_sclass[] = {
38 { 0xb0b5, &nvkm_object_ofuncs },
39 {},
40};
41
42/*******************************************************************************
43 * PCE context
44 ******************************************************************************/
45
46static struct nvkm_ofuncs
47gm204_ce_context_ofuncs = {
48 .ctor = _nvkm_engctx_ctor,
49 .dtor = _nvkm_engctx_dtor,
50 .init = _nvkm_engctx_init,
51 .fini = _nvkm_engctx_fini,
52 .rd32 = _nvkm_engctx_rd32,
53 .wr32 = _nvkm_engctx_wr32,
54};
55
56static struct nvkm_oclass
57gm204_ce_cclass = {
58 .handle = NV_ENGCTX(CE0, 0x24),
59 .ofuncs = &gm204_ce_context_ofuncs,
60};
61
62/*******************************************************************************
63 * PCE engine/subdev functions
64 ******************************************************************************/
65
66static void
67gm204_ce_intr(struct nvkm_subdev *subdev)
68{
69 const int ce = nv_subidx(subdev) - NVDEV_ENGINE_CE0;
70 struct gm204_ce_priv *priv = (void *)subdev;
71 u32 stat = nv_rd32(priv, 0x104908 + (ce * 0x1000));
72
73 if (stat) {
74 nv_warn(priv, "unhandled intr 0x%08x\n", stat);
75 nv_wr32(priv, 0x104908 + (ce * 0x1000), stat);
76 }
77}
78
79static int
80gm204_ce0_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
81 struct nvkm_oclass *oclass, void *data, u32 size,
82 struct nvkm_object **pobject)
83{
84 struct gm204_ce_priv *priv;
85 int ret;
86
87 ret = nvkm_engine_create(parent, engine, oclass, true,
88 "PCE0", "ce0", &priv);
89 *pobject = nv_object(priv);
90 if (ret)
91 return ret;
92
93 nv_subdev(priv)->unit = 0x00000040;
94 nv_subdev(priv)->intr = gm204_ce_intr;
95 nv_engine(priv)->cclass = &gm204_ce_cclass;
96 nv_engine(priv)->sclass = gm204_ce_sclass;
97 return 0;
98}
99
100static int
101gm204_ce1_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
102 struct nvkm_oclass *oclass, void *data, u32 size,
103 struct nvkm_object **pobject)
104{
105 struct gm204_ce_priv *priv;
106 int ret;
107
108 ret = nvkm_engine_create(parent, engine, oclass, true,
109 "PCE1", "ce1", &priv);
110 *pobject = nv_object(priv);
111 if (ret)
112 return ret;
113
114 nv_subdev(priv)->unit = 0x00000080;
115 nv_subdev(priv)->intr = gm204_ce_intr;
116 nv_engine(priv)->cclass = &gm204_ce_cclass;
117 nv_engine(priv)->sclass = gm204_ce_sclass;
118 return 0;
119}
120
121static int
122gm204_ce2_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
123 struct nvkm_oclass *oclass, void *data, u32 size,
124 struct nvkm_object **pobject)
125{
126 struct gm204_ce_priv *priv;
127 int ret;
128
129 ret = nvkm_engine_create(parent, engine, oclass, true,
130 "PCE2", "ce2", &priv);
131 *pobject = nv_object(priv);
132 if (ret)
133 return ret;
134
135 nv_subdev(priv)->unit = 0x00200000;
136 nv_subdev(priv)->intr = gm204_ce_intr;
137 nv_engine(priv)->cclass = &gm204_ce_cclass;
138 nv_engine(priv)->sclass = gm204_ce_sclass;
139 return 0;
140}
141
142struct nvkm_oclass
143gm204_ce0_oclass = {
144 .handle = NV_ENGINE(CE0, 0x24),
145 .ofuncs = &(struct nvkm_ofuncs) {
146 .ctor = gm204_ce0_ctor,
147 .dtor = _nvkm_engine_dtor,
148 .init = _nvkm_engine_init,
149 .fini = _nvkm_engine_fini,
150 },
151};
152
153struct nvkm_oclass
154gm204_ce1_oclass = {
155 .handle = NV_ENGINE(CE1, 0x24),
156 .ofuncs = &(struct nvkm_ofuncs) {
157 .ctor = gm204_ce1_ctor,
158 .dtor = _nvkm_engine_dtor,
159 .init = _nvkm_engine_init,
160 .fini = _nvkm_engine_fini,
161 },
162};
163
164struct nvkm_oclass
165gm204_ce2_oclass = {
166 .handle = NV_ENGINE(CE2, 0x24),
167 .ofuncs = &(struct nvkm_ofuncs) {
168 .ctor = gm204_ce2_ctor,
169 .dtor = _nvkm_engine_dtor,
170 .init = _nvkm_engine_init,
171 .fini = _nvkm_engine_fini,
172 },
173};
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
index 6efa8f38ff54..63d8e52f4b22 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
@@ -139,9 +139,13 @@ nvkm_devobj_info(struct nvkm_object *object, void *data, u32 size)
139 139
140 args->v0.chipset = device->chipset; 140 args->v0.chipset = device->chipset;
141 args->v0.revision = device->chiprev; 141 args->v0.revision = device->chiprev;
142 if (pfb) args->v0.ram_size = args->v0.ram_user = pfb->ram->size; 142 if (pfb && pfb->ram)
143 else args->v0.ram_size = args->v0.ram_user = 0; 143 args->v0.ram_size = args->v0.ram_user = pfb->ram->size;
144 if (imem) args->v0.ram_user = args->v0.ram_user - imem->reserved; 144 else
145 args->v0.ram_size = args->v0.ram_user = 0;
146 if (imem && args->v0.ram_size > 0)
147 args->v0.ram_user = args->v0.ram_user - imem->reserved;
148
145 return 0; 149 return 0;
146} 150}
147 151
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/gk104.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/gk104.c
index bf5893458a47..6a9483f65d83 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/gk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/gk104.c
@@ -171,7 +171,7 @@ gk104_identify(struct nvkm_device *device)
171 device->oclass[NVDEV_SUBDEV_FB ] = gk20a_fb_oclass; 171 device->oclass[NVDEV_SUBDEV_FB ] = gk20a_fb_oclass;
172 device->oclass[NVDEV_SUBDEV_LTC ] = gk104_ltc_oclass; 172 device->oclass[NVDEV_SUBDEV_LTC ] = gk104_ltc_oclass;
173 device->oclass[NVDEV_SUBDEV_IBUS ] = &gk20a_ibus_oclass; 173 device->oclass[NVDEV_SUBDEV_IBUS ] = &gk20a_ibus_oclass;
174 device->oclass[NVDEV_SUBDEV_INSTMEM] = nv50_instmem_oclass; 174 device->oclass[NVDEV_SUBDEV_INSTMEM] = gk20a_instmem_oclass;
175 device->oclass[NVDEV_SUBDEV_MMU ] = &gf100_mmu_oclass; 175 device->oclass[NVDEV_SUBDEV_MMU ] = &gf100_mmu_oclass;
176 device->oclass[NVDEV_SUBDEV_BAR ] = &gk20a_bar_oclass; 176 device->oclass[NVDEV_SUBDEV_BAR ] = &gk20a_bar_oclass;
177 device->oclass[NVDEV_ENGINE_DMAOBJ ] = gf110_dmaeng_oclass; 177 device->oclass[NVDEV_ENGINE_DMAOBJ ] = gf110_dmaeng_oclass;
@@ -202,7 +202,7 @@ gk104_identify(struct nvkm_device *device)
202 device->oclass[NVDEV_SUBDEV_INSTMEM] = nv50_instmem_oclass; 202 device->oclass[NVDEV_SUBDEV_INSTMEM] = nv50_instmem_oclass;
203 device->oclass[NVDEV_SUBDEV_MMU ] = &gf100_mmu_oclass; 203 device->oclass[NVDEV_SUBDEV_MMU ] = &gf100_mmu_oclass;
204 device->oclass[NVDEV_SUBDEV_BAR ] = &gf100_bar_oclass; 204 device->oclass[NVDEV_SUBDEV_BAR ] = &gf100_bar_oclass;
205 device->oclass[NVDEV_SUBDEV_PMU ] = gf110_pmu_oclass; 205 device->oclass[NVDEV_SUBDEV_PMU ] = gk110_pmu_oclass;
206 device->oclass[NVDEV_SUBDEV_VOLT ] = &nv40_volt_oclass; 206 device->oclass[NVDEV_SUBDEV_VOLT ] = &nv40_volt_oclass;
207 device->oclass[NVDEV_ENGINE_DMAOBJ ] = gf110_dmaeng_oclass; 207 device->oclass[NVDEV_ENGINE_DMAOBJ ] = gf110_dmaeng_oclass;
208 device->oclass[NVDEV_ENGINE_FIFO ] = gk104_fifo_oclass; 208 device->oclass[NVDEV_ENGINE_FIFO ] = gk104_fifo_oclass;
@@ -236,7 +236,7 @@ gk104_identify(struct nvkm_device *device)
236 device->oclass[NVDEV_SUBDEV_INSTMEM] = nv50_instmem_oclass; 236 device->oclass[NVDEV_SUBDEV_INSTMEM] = nv50_instmem_oclass;
237 device->oclass[NVDEV_SUBDEV_MMU ] = &gf100_mmu_oclass; 237 device->oclass[NVDEV_SUBDEV_MMU ] = &gf100_mmu_oclass;
238 device->oclass[NVDEV_SUBDEV_BAR ] = &gf100_bar_oclass; 238 device->oclass[NVDEV_SUBDEV_BAR ] = &gf100_bar_oclass;
239 device->oclass[NVDEV_SUBDEV_PMU ] = gf110_pmu_oclass; 239 device->oclass[NVDEV_SUBDEV_PMU ] = gk110_pmu_oclass;
240 device->oclass[NVDEV_SUBDEV_VOLT ] = &nv40_volt_oclass; 240 device->oclass[NVDEV_SUBDEV_VOLT ] = &nv40_volt_oclass;
241 device->oclass[NVDEV_ENGINE_DMAOBJ ] = gf110_dmaeng_oclass; 241 device->oclass[NVDEV_ENGINE_DMAOBJ ] = gf110_dmaeng_oclass;
242 device->oclass[NVDEV_ENGINE_FIFO ] = gk104_fifo_oclass; 242 device->oclass[NVDEV_ENGINE_FIFO ] = gk104_fifo_oclass;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/gm100.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/gm100.c
index 108d048da764..70abf1ec7c98 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/gm100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/gm100.c
@@ -127,16 +127,14 @@ gm100_identify(struct nvkm_device *device)
127 device->oclass[NVDEV_SUBDEV_VOLT ] = &nv40_volt_oclass; 127 device->oclass[NVDEV_SUBDEV_VOLT ] = &nv40_volt_oclass;
128#endif 128#endif
129 device->oclass[NVDEV_ENGINE_DMAOBJ ] = gf110_dmaeng_oclass; 129 device->oclass[NVDEV_ENGINE_DMAOBJ ] = gf110_dmaeng_oclass;
130#if 0 130 device->oclass[NVDEV_ENGINE_FIFO ] = gm204_fifo_oclass;
131 device->oclass[NVDEV_ENGINE_FIFO ] = gk208_fifo_oclass;
132 device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass; 131 device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
133 device->oclass[NVDEV_ENGINE_GR ] = gm107_gr_oclass; 132 device->oclass[NVDEV_ENGINE_GR ] = gm204_gr_oclass;
134#endif
135 device->oclass[NVDEV_ENGINE_DISP ] = gm204_disp_oclass; 133 device->oclass[NVDEV_ENGINE_DISP ] = gm204_disp_oclass;
136#if 0
137 device->oclass[NVDEV_ENGINE_CE0 ] = &gm204_ce0_oclass; 134 device->oclass[NVDEV_ENGINE_CE0 ] = &gm204_ce0_oclass;
138 device->oclass[NVDEV_ENGINE_CE1 ] = &gm204_ce1_oclass; 135 device->oclass[NVDEV_ENGINE_CE1 ] = &gm204_ce1_oclass;
139 device->oclass[NVDEV_ENGINE_CE2 ] = &gm204_ce2_oclass; 136 device->oclass[NVDEV_ENGINE_CE2 ] = &gm204_ce2_oclass;
137#if 0
140 device->oclass[NVDEV_ENGINE_MSVLD ] = &gk104_msvld_oclass; 138 device->oclass[NVDEV_ENGINE_MSVLD ] = &gk104_msvld_oclass;
141 device->oclass[NVDEV_ENGINE_MSPDEC ] = &gk104_mspdec_oclass; 139 device->oclass[NVDEV_ENGINE_MSPDEC ] = &gk104_mspdec_oclass;
142 device->oclass[NVDEV_ENGINE_MSPPP ] = &gf100_msppp_oclass; 140 device->oclass[NVDEV_ENGINE_MSPPP ] = &gf100_msppp_oclass;
@@ -170,16 +168,14 @@ gm100_identify(struct nvkm_device *device)
170 device->oclass[NVDEV_SUBDEV_VOLT ] = &nv40_volt_oclass; 168 device->oclass[NVDEV_SUBDEV_VOLT ] = &nv40_volt_oclass;
171#endif 169#endif
172 device->oclass[NVDEV_ENGINE_DMAOBJ ] = gf110_dmaeng_oclass; 170 device->oclass[NVDEV_ENGINE_DMAOBJ ] = gf110_dmaeng_oclass;
173#if 0 171 device->oclass[NVDEV_ENGINE_FIFO ] = gm204_fifo_oclass;
174 device->oclass[NVDEV_ENGINE_FIFO ] = gk208_fifo_oclass;
175 device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass; 172 device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
176 device->oclass[NVDEV_ENGINE_GR ] = gm107_gr_oclass; 173 device->oclass[NVDEV_ENGINE_GR ] = gm206_gr_oclass;
177#endif
178 device->oclass[NVDEV_ENGINE_DISP ] = gm204_disp_oclass; 174 device->oclass[NVDEV_ENGINE_DISP ] = gm204_disp_oclass;
179#if 0
180 device->oclass[NVDEV_ENGINE_CE0 ] = &gm204_ce0_oclass; 175 device->oclass[NVDEV_ENGINE_CE0 ] = &gm204_ce0_oclass;
181 device->oclass[NVDEV_ENGINE_CE1 ] = &gm204_ce1_oclass; 176 device->oclass[NVDEV_ENGINE_CE1 ] = &gm204_ce1_oclass;
182 device->oclass[NVDEV_ENGINE_CE2 ] = &gm204_ce2_oclass; 177 device->oclass[NVDEV_ENGINE_CE2 ] = &gm204_ce2_oclass;
178#if 0
183 device->oclass[NVDEV_ENGINE_MSVLD ] = &gk104_msvld_oclass; 179 device->oclass[NVDEV_ENGINE_MSVLD ] = &gk104_msvld_oclass;
184 device->oclass[NVDEV_ENGINE_MSPDEC ] = &gk104_mspdec_oclass; 180 device->oclass[NVDEV_ENGINE_MSPDEC ] = &gk104_mspdec_oclass;
185 device->oclass[NVDEV_ENGINE_MSPPP ] = &gf100_msppp_oclass; 181 device->oclass[NVDEV_ENGINE_MSPPP ] = &gf100_msppp_oclass;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf110.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf110.c
index 0ebf466e9ef3..9ef6728c528d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf110.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf110.c
@@ -413,8 +413,8 @@ gf110_disp_base_mthd_base = {
413 413
414static const struct nv50_disp_mthd_list 414static const struct nv50_disp_mthd_list
415gf110_disp_base_mthd_image = { 415gf110_disp_base_mthd_image = {
416 .mthd = 0x0400, 416 .mthd = 0x0020,
417 .addr = 0x000400, 417 .addr = 0x000020,
418 .data = { 418 .data = {
419 { 0x0400, 0x661400 }, 419 { 0x0400, 0x661400 },
420 { 0x0404, 0x661404 }, 420 { 0x0404, 0x661404 },
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
index 84ade810e27c..8ba808df24ad 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
@@ -229,7 +229,7 @@ nv50_disp_dmac_create_(struct nvkm_object *parent,
229 229
230 switch (dmac->pushdma->target) { 230 switch (dmac->pushdma->target) {
231 case NV_MEM_TARGET_VRAM: 231 case NV_MEM_TARGET_VRAM:
232 dmac->push = 0x00000000 | dmac->pushdma->start >> 8; 232 dmac->push = 0x00000001 | dmac->pushdma->start >> 8;
233 break; 233 break;
234 case NV_MEM_TARGET_PCI_NOSNOOP: 234 case NV_MEM_TARGET_PCI_NOSNOOP:
235 dmac->push = 0x00000003 | dmac->pushdma->start >> 8; 235 dmac->push = 0x00000003 | dmac->pushdma->start >> 8;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/Kbuild b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/Kbuild
index c5a2d8718c5b..42891cb71ea3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/Kbuild
@@ -9,3 +9,4 @@ nvkm-y += nvkm/engine/fifo/gf100.o
9nvkm-y += nvkm/engine/fifo/gk104.o 9nvkm-y += nvkm/engine/fifo/gk104.o
10nvkm-y += nvkm/engine/fifo/gk20a.o 10nvkm-y += nvkm/engine/fifo/gk20a.o
11nvkm-y += nvkm/engine/fifo/gk208.o 11nvkm-y += nvkm/engine/fifo/gk208.o
12nvkm-y += nvkm/engine/fifo/gm204.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
index 9585539e59f2..e10f9644140f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
@@ -323,8 +323,8 @@ gk104_fifo_chan_fini(struct nvkm_object *object, bool suspend)
323 return nvkm_fifo_channel_fini(&chan->base, suspend); 323 return nvkm_fifo_channel_fini(&chan->base, suspend);
324} 324}
325 325
326static struct nvkm_ofuncs 326struct nvkm_ofuncs
327gk104_fifo_ofuncs = { 327gk104_fifo_chan_ofuncs = {
328 .ctor = gk104_fifo_chan_ctor, 328 .ctor = gk104_fifo_chan_ctor,
329 .dtor = _nvkm_fifo_channel_dtor, 329 .dtor = _nvkm_fifo_channel_dtor,
330 .init = gk104_fifo_chan_init, 330 .init = gk104_fifo_chan_init,
@@ -337,7 +337,7 @@ gk104_fifo_ofuncs = {
337 337
338static struct nvkm_oclass 338static struct nvkm_oclass
339gk104_fifo_sclass[] = { 339gk104_fifo_sclass[] = {
340 { KEPLER_CHANNEL_GPFIFO_A, &gk104_fifo_ofuncs }, 340 { KEPLER_CHANNEL_GPFIFO_A, &gk104_fifo_chan_ofuncs },
341 {} 341 {}
342}; 342};
343 343
@@ -774,6 +774,7 @@ gk104_fifo_intr_fault(struct gk104_fifo_priv *priv, int unit)
774 while (object) { 774 while (object) {
775 switch (nv_mclass(object)) { 775 switch (nv_mclass(object)) {
776 case KEPLER_CHANNEL_GPFIFO_A: 776 case KEPLER_CHANNEL_GPFIFO_A:
777 case MAXWELL_CHANNEL_GPFIFO_A:
777 gk104_fifo_recover(priv, engine, (void *)object); 778 gk104_fifo_recover(priv, engine, (void *)object);
778 break; 779 break;
779 } 780 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.h b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.h
index 3046e00ed6ba..318d30d6ee1a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.h
@@ -13,4 +13,6 @@ struct gk104_fifo_impl {
13 struct nvkm_oclass base; 13 struct nvkm_oclass base;
14 u32 channels; 14 u32 channels;
15}; 15};
16
17extern struct nvkm_ofuncs gk104_fifo_chan_ofuncs;
16#endif 18#endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gm204.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gm204.c
new file mode 100644
index 000000000000..749d525dd8e3
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gm204.c
@@ -0,0 +1,57 @@
1/*
2 * Copyright 2015 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs
23 */
24#include "gk104.h"
25
26#include <nvif/class.h>
27
28static struct nvkm_oclass
29gm204_fifo_sclass[] = {
30 { MAXWELL_CHANNEL_GPFIFO_A, &gk104_fifo_chan_ofuncs },
31 {}
32};
33
34static int
35gm204_fifo_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
36 struct nvkm_oclass *oclass, void *data, u32 size,
37 struct nvkm_object **pobject)
38{
39 int ret = gk104_fifo_ctor(parent, engine, oclass, data, size, pobject);
40 if (ret == 0) {
41 struct gk104_fifo_priv *priv = (void *)*pobject;
42 nv_engine(priv)->sclass = gm204_fifo_sclass;
43 }
44 return ret;
45}
46
47struct nvkm_oclass *
48gm204_fifo_oclass = &(struct gk104_fifo_impl) {
49 .base.handle = NV_ENGINE(FIFO, 0x24),
50 .base.ofuncs = &(struct nvkm_ofuncs) {
51 .ctor = gm204_fifo_ctor,
52 .dtor = gk104_fifo_dtor,
53 .init = gk104_fifo_init,
54 .fini = _nvkm_fifo_fini,
55 },
56 .channels = 4096,
57}.base;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/Kbuild b/drivers/gpu/drm/nouveau/nvkm/engine/gr/Kbuild
index 1771d944591b..2e1b92f71d9e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/Kbuild
@@ -12,6 +12,8 @@ nvkm-y += nvkm/engine/gr/ctxgk110.o
12nvkm-y += nvkm/engine/gr/ctxgk110b.o 12nvkm-y += nvkm/engine/gr/ctxgk110b.o
13nvkm-y += nvkm/engine/gr/ctxgk208.o 13nvkm-y += nvkm/engine/gr/ctxgk208.o
14nvkm-y += nvkm/engine/gr/ctxgm107.o 14nvkm-y += nvkm/engine/gr/ctxgm107.o
15nvkm-y += nvkm/engine/gr/ctxgm204.o
16nvkm-y += nvkm/engine/gr/ctxgm206.o
15nvkm-y += nvkm/engine/gr/nv04.o 17nvkm-y += nvkm/engine/gr/nv04.o
16nvkm-y += nvkm/engine/gr/nv10.o 18nvkm-y += nvkm/engine/gr/nv10.o
17nvkm-y += nvkm/engine/gr/nv20.o 19nvkm-y += nvkm/engine/gr/nv20.o
@@ -34,3 +36,5 @@ nvkm-y += nvkm/engine/gr/gk110.o
34nvkm-y += nvkm/engine/gr/gk110b.o 36nvkm-y += nvkm/engine/gr/gk110b.o
35nvkm-y += nvkm/engine/gr/gk208.o 37nvkm-y += nvkm/engine/gr/gk208.o
36nvkm-y += nvkm/engine/gr/gm107.o 38nvkm-y += nvkm/engine/gr/gm107.o
39nvkm-y += nvkm/engine/gr/gm204.o
40nvkm-y += nvkm/engine/gr/gm206.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgf100.h b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgf100.h
index 1166b1aa1525..3676a3342bc5 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgf100.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgf100.h
@@ -88,11 +88,22 @@ void gk104_grctx_generate_bundle(struct gf100_grctx *);
88void gk104_grctx_generate_pagepool(struct gf100_grctx *); 88void gk104_grctx_generate_pagepool(struct gf100_grctx *);
89void gk104_grctx_generate_unkn(struct gf100_gr_priv *); 89void gk104_grctx_generate_unkn(struct gf100_gr_priv *);
90void gk104_grctx_generate_r418bb8(struct gf100_gr_priv *); 90void gk104_grctx_generate_r418bb8(struct gf100_gr_priv *);
91void gk104_grctx_generate_rop_active_fbps(struct gf100_gr_priv *);
92
91 93
92extern struct nvkm_oclass *gk110_grctx_oclass; 94extern struct nvkm_oclass *gk110_grctx_oclass;
93extern struct nvkm_oclass *gk110b_grctx_oclass; 95extern struct nvkm_oclass *gk110b_grctx_oclass;
94extern struct nvkm_oclass *gk208_grctx_oclass; 96extern struct nvkm_oclass *gk208_grctx_oclass;
97
95extern struct nvkm_oclass *gm107_grctx_oclass; 98extern struct nvkm_oclass *gm107_grctx_oclass;
99void gm107_grctx_generate_bundle(struct gf100_grctx *);
100void gm107_grctx_generate_pagepool(struct gf100_grctx *);
101void gm107_grctx_generate_attrib(struct gf100_grctx *);
102
103extern struct nvkm_oclass *gm204_grctx_oclass;
104void gm204_grctx_generate_main(struct gf100_gr_priv *, struct gf100_grctx *);
105
106extern struct nvkm_oclass *gm206_grctx_oclass;
96 107
97/* context init value lists */ 108/* context init value lists */
98 109
@@ -196,4 +207,22 @@ extern const struct gf100_gr_init gk208_grctx_init_rstr2d_0[];
196 207
197extern const struct gf100_gr_init gk208_grctx_init_prop_0[]; 208extern const struct gf100_gr_init gk208_grctx_init_prop_0[];
198extern const struct gf100_gr_init gk208_grctx_init_crstr_0[]; 209extern const struct gf100_gr_init gk208_grctx_init_crstr_0[];
210
211extern const struct gf100_gr_init gm107_grctx_init_gpc_unk_0[];
212extern const struct gf100_gr_init gm107_grctx_init_wwdx_0[];
213
214extern const struct gf100_gr_pack gm204_grctx_pack_icmd[];
215
216extern const struct gf100_gr_pack gm204_grctx_pack_mthd[];
217
218extern const struct gf100_gr_pack gm204_grctx_pack_hub[];
219
220extern const struct gf100_gr_init gm204_grctx_init_prop_0[];
221extern const struct gf100_gr_init gm204_grctx_init_setup_0[];
222extern const struct gf100_gr_init gm204_grctx_init_gpm_0[];
223extern const struct gf100_gr_init gm204_grctx_init_gpc_unk_2[];
224
225extern const struct gf100_gr_pack gm204_grctx_pack_tpc[];
226
227extern const struct gf100_gr_pack gm204_grctx_pack_ppc[];
199#endif 228#endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgk104.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgk104.c
index 5e9454ba158f..b12f6a9fd926 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgk104.c
@@ -941,6 +941,14 @@ gk104_grctx_generate_r418bb8(struct gf100_gr_priv *priv)
941} 941}
942 942
943void 943void
944gk104_grctx_generate_rop_active_fbps(struct gf100_gr_priv *priv)
945{
946 const u32 fbp_count = nv_rd32(priv, 0x120074);
947 nv_mask(priv, 0x408850, 0x0000000f, fbp_count); /* zrop */
948 nv_mask(priv, 0x408958, 0x0000000f, fbp_count); /* crop */
949}
950
951void
944gk104_grctx_generate_main(struct gf100_gr_priv *priv, struct gf100_grctx *info) 952gk104_grctx_generate_main(struct gf100_gr_priv *priv, struct gf100_grctx *info)
945{ 953{
946 struct gf100_grctx_oclass *oclass = (void *)nv_engine(priv)->cclass; 954 struct gf100_grctx_oclass *oclass = (void *)nv_engine(priv)->cclass;
@@ -970,13 +978,7 @@ gk104_grctx_generate_main(struct gf100_gr_priv *priv, struct gf100_grctx *info)
970 nv_wr32(priv, 0x4064d0 + (i * 0x04), 0x00000000); 978 nv_wr32(priv, 0x4064d0 + (i * 0x04), 0x00000000);
971 979
972 nv_wr32(priv, 0x405b00, (priv->tpc_total << 8) | priv->gpc_nr); 980 nv_wr32(priv, 0x405b00, (priv->tpc_total << 8) | priv->gpc_nr);
973 if (priv->gpc_nr == 1) { 981 gk104_grctx_generate_rop_active_fbps(priv);
974 nv_mask(priv, 0x408850, 0x0000000f, priv->tpc_nr[0]);
975 nv_mask(priv, 0x408958, 0x0000000f, priv->tpc_nr[0]);
976 } else {
977 nv_mask(priv, 0x408850, 0x0000000f, priv->gpc_nr);
978 nv_mask(priv, 0x408958, 0x0000000f, priv->gpc_nr);
979 }
980 nv_mask(priv, 0x419f78, 0x00000001, 0x00000000); 982 nv_mask(priv, 0x419f78, 0x00000001, 0x00000000);
981 983
982 gf100_gr_icmd(priv, oclass->icmd); 984 gf100_gr_icmd(priv, oclass->icmd);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm107.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm107.c
index b2fae6e389e2..fbeaae3ae6ce 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm107.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm107.c
@@ -699,7 +699,7 @@ gm107_grctx_pack_hub[] = {
699 {} 699 {}
700}; 700};
701 701
702static const struct gf100_gr_init 702const struct gf100_gr_init
703gm107_grctx_init_gpc_unk_0[] = { 703gm107_grctx_init_gpc_unk_0[] = {
704 { 0x418380, 1, 0x04, 0x00000056 }, 704 { 0x418380, 1, 0x04, 0x00000056 },
705 {} 705 {}
@@ -834,7 +834,7 @@ gm107_grctx_init_cbm_0[] = {
834 {} 834 {}
835}; 835};
836 836
837static const struct gf100_gr_init 837const struct gf100_gr_init
838gm107_grctx_init_wwdx_0[] = { 838gm107_grctx_init_wwdx_0[] = {
839 { 0x41bf00, 1, 0x04, 0x0a418820 }, 839 { 0x41bf00, 1, 0x04, 0x0a418820 },
840 { 0x41bf04, 1, 0x04, 0x062080e6 }, 840 { 0x41bf04, 1, 0x04, 0x062080e6 },
@@ -860,7 +860,7 @@ gm107_grctx_pack_ppc[] = {
860 * PGRAPH context implementation 860 * PGRAPH context implementation
861 ******************************************************************************/ 861 ******************************************************************************/
862 862
863static void 863void
864gm107_grctx_generate_bundle(struct gf100_grctx *info) 864gm107_grctx_generate_bundle(struct gf100_grctx *info)
865{ 865{
866 const struct gf100_grctx_oclass *impl = gf100_grctx_impl(info->priv); 866 const struct gf100_grctx_oclass *impl = gf100_grctx_impl(info->priv);
@@ -877,7 +877,7 @@ gm107_grctx_generate_bundle(struct gf100_grctx *info)
877 mmio_wr32(info, 0x4064c8, (state_limit << 16) | token_limit); 877 mmio_wr32(info, 0x4064c8, (state_limit << 16) | token_limit);
878} 878}
879 879
880static void 880void
881gm107_grctx_generate_pagepool(struct gf100_grctx *info) 881gm107_grctx_generate_pagepool(struct gf100_grctx *info)
882{ 882{
883 const struct gf100_grctx_oclass *impl = gf100_grctx_impl(info->priv); 883 const struct gf100_grctx_oclass *impl = gf100_grctx_impl(info->priv);
@@ -892,7 +892,7 @@ gm107_grctx_generate_pagepool(struct gf100_grctx *info)
892 mmio_wr32(info, 0x418e30, 0x80000000); /* guess at it being related */ 892 mmio_wr32(info, 0x418e30, 0x80000000); /* guess at it being related */
893} 893}
894 894
895static void 895void
896gm107_grctx_generate_attrib(struct gf100_grctx *info) 896gm107_grctx_generate_attrib(struct gf100_grctx *info)
897{ 897{
898 struct gf100_gr_priv *priv = info->priv; 898 struct gf100_gr_priv *priv = info->priv;
@@ -926,7 +926,7 @@ gm107_grctx_generate_attrib(struct gf100_grctx *info)
926 mmio_wr32(info, o + 0xe4, as); 926 mmio_wr32(info, o + 0xe4, as);
927 mmio_wr32(info, o + 0xf8, ao); 927 mmio_wr32(info, o + 0xf8, ao);
928 ao += impl->alpha_nr_max * priv->ppc_tpc_nr[gpc][ppc]; 928 ao += impl->alpha_nr_max * priv->ppc_tpc_nr[gpc][ppc];
929 mmio_wr32(info, u, (0x715 /*XXX*/ << 16) | bs); 929 mmio_wr32(info, u, ((bs / 3 /*XXX*/) << 16) | bs);
930 } 930 }
931 } 931 }
932} 932}
@@ -982,13 +982,7 @@ gm107_grctx_generate_main(struct gf100_gr_priv *priv, struct gf100_grctx *info)
982 982
983 nv_wr32(priv, 0x405b00, (priv->tpc_total << 8) | priv->gpc_nr); 983 nv_wr32(priv, 0x405b00, (priv->tpc_total << 8) | priv->gpc_nr);
984 984
985 if (priv->gpc_nr == 1) { 985 gk104_grctx_generate_rop_active_fbps(priv);
986 nv_mask(priv, 0x408850, 0x0000000f, priv->tpc_nr[0]);
987 nv_mask(priv, 0x408958, 0x0000000f, priv->tpc_nr[0]);
988 } else {
989 nv_mask(priv, 0x408850, 0x0000000f, priv->gpc_nr);
990 nv_mask(priv, 0x408958, 0x0000000f, priv->gpc_nr);
991 }
992 986
993 gf100_gr_icmd(priv, oclass->icmd); 987 gf100_gr_icmd(priv, oclass->icmd);
994 nv_wr32(priv, 0x404154, 0x00000400); 988 nv_wr32(priv, 0x404154, 0x00000400);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm204.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm204.c
new file mode 100644
index 000000000000..ea8e66151aa8
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm204.c
@@ -0,0 +1,1054 @@
1/*
2 * Copyright 2015 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs <bskeggs@redhat.com>
23 */
24#include "ctxgf100.h"
25
26/*******************************************************************************
27 * PGRAPH context register lists
28 ******************************************************************************/
29
30static const struct gf100_gr_init
31gm204_grctx_init_icmd_0[] = {
32 { 0x001000, 1, 0x01, 0x00000002 },
33 { 0x0006aa, 1, 0x01, 0x00000001 },
34 { 0x0006ad, 2, 0x01, 0x00000100 },
35 { 0x0006b1, 1, 0x01, 0x00000011 },
36 { 0x00078c, 1, 0x01, 0x00000008 },
37 { 0x000792, 1, 0x01, 0x00000001 },
38 { 0x000794, 3, 0x01, 0x00000001 },
39 { 0x000797, 1, 0x01, 0x000000cf },
40 { 0x00079a, 1, 0x01, 0x00000002 },
41 { 0x0007a1, 1, 0x01, 0x00000001 },
42 { 0x0007a3, 3, 0x01, 0x00000001 },
43 { 0x000831, 1, 0x01, 0x00000004 },
44 { 0x01e100, 1, 0x01, 0x00000001 },
45 { 0x001000, 1, 0x01, 0x00000008 },
46 { 0x000039, 3, 0x01, 0x00000000 },
47 { 0x000380, 1, 0x01, 0x00000001 },
48 { 0x000366, 2, 0x01, 0x00000000 },
49 { 0x000368, 1, 0x01, 0x00000fff },
50 { 0x000370, 2, 0x01, 0x00000000 },
51 { 0x000372, 1, 0x01, 0x000fffff },
52 { 0x000374, 1, 0x01, 0x00000100 },
53 { 0x000818, 8, 0x01, 0x00000000 },
54 { 0x000848, 16, 0x01, 0x00000000 },
55 { 0x000738, 1, 0x01, 0x00000000 },
56 { 0x000b07, 1, 0x01, 0x00000002 },
57 { 0x000b08, 2, 0x01, 0x00000100 },
58 { 0x000b0a, 1, 0x01, 0x00000001 },
59 { 0x000a04, 1, 0x01, 0x000000ff },
60 { 0x000a0b, 1, 0x01, 0x00000040 },
61 { 0x00097f, 1, 0x01, 0x00000100 },
62 { 0x000a02, 1, 0x01, 0x00000001 },
63 { 0x000809, 1, 0x01, 0x00000007 },
64 { 0x00c221, 1, 0x01, 0x00000040 },
65 { 0x00c401, 1, 0x01, 0x00000001 },
66 { 0x00c402, 1, 0x01, 0x00010001 },
67 { 0x00c403, 2, 0x01, 0x00000001 },
68 { 0x00c40e, 1, 0x01, 0x00000020 },
69 { 0x01e100, 1, 0x01, 0x00000001 },
70 { 0x001000, 1, 0x01, 0x00000001 },
71 { 0x000b07, 1, 0x01, 0x00000002 },
72 { 0x000b08, 2, 0x01, 0x00000100 },
73 { 0x000b0a, 1, 0x01, 0x00000001 },
74 { 0x01e100, 1, 0x01, 0x00000001 },
75 { 0x001000, 1, 0x01, 0x00000004 },
76 { 0x000039, 3, 0x01, 0x00000000 },
77 { 0x0000a9, 1, 0x01, 0x0000ffff },
78 { 0x000038, 1, 0x01, 0x0fac6881 },
79 { 0x00003d, 1, 0x01, 0x00000001 },
80 { 0x0000e8, 8, 0x01, 0x00000400 },
81 { 0x000078, 8, 0x01, 0x00000300 },
82 { 0x000050, 1, 0x01, 0x00000011 },
83 { 0x000058, 8, 0x01, 0x00000008 },
84 { 0x000208, 8, 0x01, 0x00000001 },
85 { 0x000081, 1, 0x01, 0x00000001 },
86 { 0x000085, 1, 0x01, 0x00000004 },
87 { 0x000088, 1, 0x01, 0x00000400 },
88 { 0x000090, 1, 0x01, 0x00000300 },
89 { 0x000098, 1, 0x01, 0x00001001 },
90 { 0x0000e3, 1, 0x01, 0x00000001 },
91 { 0x0000da, 1, 0x01, 0x00000001 },
92 { 0x0000b4, 4, 0x01, 0x88888888 },
93 { 0x0000f8, 1, 0x01, 0x00000003 },
94 { 0x0000fa, 1, 0x01, 0x00000001 },
95 { 0x0000b1, 2, 0x01, 0x00000001 },
96 { 0x00009f, 4, 0x01, 0x0000ffff },
97 { 0x0000a8, 1, 0x01, 0x0000ffff },
98 { 0x0000ad, 1, 0x01, 0x0000013e },
99 { 0x0000e1, 1, 0x01, 0x00000010 },
100 { 0x000290, 16, 0x01, 0x00000000 },
101 { 0x0003b0, 16, 0x01, 0x00000000 },
102 { 0x0002a0, 16, 0x01, 0x00000000 },
103 { 0x000420, 16, 0x01, 0x00000000 },
104 { 0x0002b0, 16, 0x01, 0x00000000 },
105 { 0x000430, 16, 0x01, 0x00000000 },
106 { 0x0002c0, 16, 0x01, 0x00000000 },
107 { 0x0004d0, 16, 0x01, 0x00000000 },
108 { 0x000720, 16, 0x01, 0x00000000 },
109 { 0x0008c0, 16, 0x01, 0x00000000 },
110 { 0x000890, 16, 0x01, 0x00000000 },
111 { 0x0008e0, 16, 0x01, 0x00000000 },
112 { 0x0008a0, 16, 0x01, 0x00000000 },
113 { 0x0008f0, 16, 0x01, 0x00000000 },
114 { 0x00094c, 1, 0x01, 0x000000ff },
115 { 0x00094d, 1, 0x01, 0xffffffff },
116 { 0x00094e, 1, 0x01, 0x00000002 },
117 { 0x0002f2, 2, 0x01, 0x00000001 },
118 { 0x0002f5, 1, 0x01, 0x00000001 },
119 { 0x0002f7, 1, 0x01, 0x00000001 },
120 { 0x000303, 1, 0x01, 0x00000001 },
121 { 0x0002e6, 1, 0x01, 0x00000001 },
122 { 0x000466, 1, 0x01, 0x00000052 },
123 { 0x000301, 1, 0x01, 0x3f800000 },
124 { 0x000304, 1, 0x01, 0x30201000 },
125 { 0x000305, 1, 0x01, 0x70605040 },
126 { 0x000306, 1, 0x01, 0xb8a89888 },
127 { 0x000307, 1, 0x01, 0xf8e8d8c8 },
128 { 0x00030a, 1, 0x01, 0x00ffff00 },
129 { 0x00030b, 1, 0x01, 0x0000001a },
130 { 0x00030c, 1, 0x01, 0x00000001 },
131 { 0x000318, 1, 0x01, 0x00000001 },
132 { 0x000340, 1, 0x01, 0x00000000 },
133 { 0x00037d, 1, 0x01, 0x00000006 },
134 { 0x0003a0, 1, 0x01, 0x00000002 },
135 { 0x0003aa, 1, 0x01, 0x00000001 },
136 { 0x0003a9, 1, 0x01, 0x00000001 },
137 { 0x000380, 1, 0x01, 0x00000001 },
138 { 0x000383, 1, 0x01, 0x00000011 },
139 { 0x000360, 1, 0x01, 0x00000040 },
140 { 0x000366, 2, 0x01, 0x00000000 },
141 { 0x000368, 1, 0x01, 0x00000fff },
142 { 0x000370, 2, 0x01, 0x00000000 },
143 { 0x000372, 1, 0x01, 0x000fffff },
144 { 0x000374, 1, 0x01, 0x00000100 },
145 { 0x00037a, 1, 0x01, 0x00000012 },
146 { 0x000619, 1, 0x01, 0x00000003 },
147 { 0x000811, 1, 0x01, 0x00000003 },
148 { 0x000812, 1, 0x01, 0x00000004 },
149 { 0x000813, 1, 0x01, 0x00000006 },
150 { 0x000814, 1, 0x01, 0x00000008 },
151 { 0x000815, 1, 0x01, 0x0000000b },
152 { 0x000800, 6, 0x01, 0x00000001 },
153 { 0x000632, 1, 0x01, 0x00000001 },
154 { 0x000633, 1, 0x01, 0x00000002 },
155 { 0x000634, 1, 0x01, 0x00000003 },
156 { 0x000635, 1, 0x01, 0x00000004 },
157 { 0x000654, 1, 0x01, 0x3f800000 },
158 { 0x000657, 1, 0x01, 0x3f800000 },
159 { 0x000655, 2, 0x01, 0x3f800000 },
160 { 0x0006cd, 1, 0x01, 0x3f800000 },
161 { 0x0007f5, 1, 0x01, 0x3f800000 },
162 { 0x0007dc, 1, 0x01, 0x39291909 },
163 { 0x0007dd, 1, 0x01, 0x79695949 },
164 { 0x0007de, 1, 0x01, 0xb9a99989 },
165 { 0x0007df, 1, 0x01, 0xf9e9d9c9 },
166 { 0x0007e8, 1, 0x01, 0x00003210 },
167 { 0x0007e9, 1, 0x01, 0x00007654 },
168 { 0x0007ea, 1, 0x01, 0x00000098 },
169 { 0x0007ec, 1, 0x01, 0x39291909 },
170 { 0x0007ed, 1, 0x01, 0x79695949 },
171 { 0x0007ee, 1, 0x01, 0xb9a99989 },
172 { 0x0007ef, 1, 0x01, 0xf9e9d9c9 },
173 { 0x0007f0, 1, 0x01, 0x00003210 },
174 { 0x0007f1, 1, 0x01, 0x00007654 },
175 { 0x0007f2, 1, 0x01, 0x00000098 },
176 { 0x0005a5, 1, 0x01, 0x00000001 },
177 { 0x0005aa, 1, 0x01, 0x00000002 },
178 { 0x0005cb, 1, 0x01, 0x00000004 },
179 { 0x0005d0, 1, 0x01, 0x20181008 },
180 { 0x0005d1, 1, 0x01, 0x40383028 },
181 { 0x0005d2, 1, 0x01, 0x60585048 },
182 { 0x0005d3, 1, 0x01, 0x80787068 },
183 { 0x000980, 128, 0x01, 0x00000000 },
184 { 0x000468, 1, 0x01, 0x00000004 },
185 { 0x00046c, 1, 0x01, 0x00000001 },
186 { 0x000470, 96, 0x01, 0x00000000 },
187 { 0x0005e0, 16, 0x01, 0x00000d10 },
188 { 0x000510, 16, 0x01, 0x3f800000 },
189 { 0x000520, 1, 0x01, 0x000002b6 },
190 { 0x000529, 1, 0x01, 0x00000001 },
191 { 0x000530, 16, 0x01, 0xffff0000 },
192 { 0x000550, 32, 0x01, 0xffff0000 },
193 { 0x000585, 1, 0x01, 0x0000003f },
194 { 0x000576, 1, 0x01, 0x00000003 },
195 { 0x00057b, 1, 0x01, 0x00000059 },
196 { 0x000586, 1, 0x01, 0x00000040 },
197 { 0x000582, 2, 0x01, 0x00000080 },
198 { 0x000595, 1, 0x01, 0x00400040 },
199 { 0x000596, 1, 0x01, 0x00000492 },
200 { 0x000597, 1, 0x01, 0x08080203 },
201 { 0x0005ad, 1, 0x01, 0x00000008 },
202 { 0x000598, 1, 0x01, 0x00020001 },
203 { 0x0005d4, 1, 0x01, 0x00000001 },
204 { 0x0005c2, 1, 0x01, 0x00000001 },
205 { 0x000638, 2, 0x01, 0x00000001 },
206 { 0x00063a, 1, 0x01, 0x00000002 },
207 { 0x00063b, 2, 0x01, 0x00000001 },
208 { 0x00063d, 1, 0x01, 0x00000002 },
209 { 0x00063e, 1, 0x01, 0x00000001 },
210 { 0x0008b8, 8, 0x01, 0x00000001 },
211 { 0x000900, 8, 0x01, 0x00000001 },
212 { 0x000908, 8, 0x01, 0x00000002 },
213 { 0x000910, 16, 0x01, 0x00000001 },
214 { 0x000920, 8, 0x01, 0x00000002 },
215 { 0x000928, 8, 0x01, 0x00000001 },
216 { 0x000662, 1, 0x01, 0x00000001 },
217 { 0x000648, 9, 0x01, 0x00000001 },
218 { 0x000674, 1, 0x01, 0x00000001 },
219 { 0x000658, 1, 0x01, 0x0000000f },
220 { 0x0007ff, 1, 0x01, 0x0000000a },
221 { 0x00066a, 1, 0x01, 0x40000000 },
222 { 0x00066b, 1, 0x01, 0x10000000 },
223 { 0x00066c, 2, 0x01, 0xffff0000 },
224 { 0x0007af, 2, 0x01, 0x00000008 },
225 { 0x0007f6, 1, 0x01, 0x00000001 },
226 { 0x0006b2, 1, 0x01, 0x00000055 },
227 { 0x0007ad, 1, 0x01, 0x00000003 },
228 { 0x000971, 1, 0x01, 0x00000008 },
229 { 0x000972, 1, 0x01, 0x00000040 },
230 { 0x000973, 1, 0x01, 0x0000012c },
231 { 0x00097c, 1, 0x01, 0x00000040 },
232 { 0x000975, 1, 0x01, 0x00000020 },
233 { 0x000976, 1, 0x01, 0x00000001 },
234 { 0x000977, 1, 0x01, 0x00000020 },
235 { 0x000978, 1, 0x01, 0x00000001 },
236 { 0x000957, 1, 0x01, 0x00000003 },
237 { 0x00095e, 1, 0x01, 0x20164010 },
238 { 0x00095f, 1, 0x01, 0x00000020 },
239 { 0x000a0d, 1, 0x01, 0x00000006 },
240 { 0x00097d, 1, 0x01, 0x0000000c },
241 { 0x000683, 1, 0x01, 0x00000006 },
242 { 0x000687, 1, 0x01, 0x003fffff },
243 { 0x0006a0, 1, 0x01, 0x00000005 },
244 { 0x000840, 1, 0x01, 0x00400008 },
245 { 0x000841, 1, 0x01, 0x08000080 },
246 { 0x000842, 1, 0x01, 0x00400008 },
247 { 0x000843, 1, 0x01, 0x08000080 },
248 { 0x000818, 8, 0x01, 0x00000000 },
249 { 0x000848, 16, 0x01, 0x00000000 },
250 { 0x000738, 1, 0x01, 0x00000000 },
251 { 0x0006aa, 1, 0x01, 0x00000001 },
252 { 0x0006ab, 1, 0x01, 0x00000002 },
253 { 0x0006ac, 1, 0x01, 0x00000080 },
254 { 0x0006ad, 2, 0x01, 0x00000100 },
255 { 0x0006b1, 1, 0x01, 0x00000011 },
256 { 0x0006bb, 1, 0x01, 0x000000cf },
257 { 0x0006ce, 1, 0x01, 0x2a712488 },
258 { 0x000739, 1, 0x01, 0x4085c000 },
259 { 0x00073a, 1, 0x01, 0x00000080 },
260 { 0x000786, 1, 0x01, 0x80000100 },
261 { 0x00073c, 1, 0x01, 0x00010100 },
262 { 0x00073d, 1, 0x01, 0x02800000 },
263 { 0x000787, 1, 0x01, 0x000000cf },
264 { 0x00078c, 1, 0x01, 0x00000008 },
265 { 0x000792, 1, 0x01, 0x00000001 },
266 { 0x000794, 3, 0x01, 0x00000001 },
267 { 0x000797, 1, 0x01, 0x000000cf },
268 { 0x000836, 1, 0x01, 0x00000001 },
269 { 0x00079a, 1, 0x01, 0x00000002 },
270 { 0x000833, 1, 0x01, 0x04444480 },
271 { 0x0007a1, 1, 0x01, 0x00000001 },
272 { 0x0007a3, 3, 0x01, 0x00000001 },
273 { 0x000831, 1, 0x01, 0x00000004 },
274 { 0x000b07, 1, 0x01, 0x00000002 },
275 { 0x000b08, 2, 0x01, 0x00000100 },
276 { 0x000b0a, 1, 0x01, 0x00000001 },
277 { 0x000a04, 1, 0x01, 0x000000ff },
278 { 0x000a0b, 1, 0x01, 0x00000040 },
279 { 0x00097f, 1, 0x01, 0x00000100 },
280 { 0x000a02, 1, 0x01, 0x00000001 },
281 { 0x000809, 1, 0x01, 0x00000007 },
282 { 0x00c221, 1, 0x01, 0x00000040 },
283 { 0x00c1b0, 8, 0x01, 0x0000000f },
284 { 0x00c1b8, 1, 0x01, 0x0fac6881 },
285 { 0x00c1b9, 1, 0x01, 0x00fac688 },
286 { 0x00c401, 1, 0x01, 0x00000001 },
287 { 0x00c402, 1, 0x01, 0x00010001 },
288 { 0x00c403, 2, 0x01, 0x00000001 },
289 { 0x00c40e, 1, 0x01, 0x00000020 },
290 { 0x00c413, 4, 0x01, 0x88888888 },
291 { 0x00c423, 1, 0x01, 0x0000ff00 },
292 { 0x00c420, 1, 0x01, 0x00880101 },
293 { 0x01e100, 1, 0x01, 0x00000001 },
294 {}
295};
296
297const struct gf100_gr_pack
298gm204_grctx_pack_icmd[] = {
299 { gm204_grctx_init_icmd_0 },
300 {}
301};
302
303static const struct gf100_gr_init
304gm204_grctx_init_b197_0[] = {
305 { 0x000800, 8, 0x40, 0x00000000 },
306 { 0x000804, 8, 0x40, 0x00000000 },
307 { 0x000808, 8, 0x40, 0x00000400 },
308 { 0x00080c, 8, 0x40, 0x00000300 },
309 { 0x000810, 1, 0x04, 0x000000cf },
310 { 0x000850, 7, 0x40, 0x00000000 },
311 { 0x000814, 8, 0x40, 0x00000040 },
312 { 0x000818, 8, 0x40, 0x00000001 },
313 { 0x00081c, 8, 0x40, 0x00000000 },
314 { 0x000820, 8, 0x40, 0x00000000 },
315 { 0x001c00, 16, 0x10, 0x00000000 },
316 { 0x001c04, 16, 0x10, 0x00000000 },
317 { 0x001c08, 16, 0x10, 0x00000000 },
318 { 0x001c0c, 16, 0x10, 0x00000000 },
319 { 0x001d00, 16, 0x10, 0x00000000 },
320 { 0x001d04, 16, 0x10, 0x00000000 },
321 { 0x001d08, 16, 0x10, 0x00000000 },
322 { 0x001d0c, 16, 0x10, 0x00000000 },
323 { 0x001f00, 16, 0x08, 0x00000000 },
324 { 0x001f04, 16, 0x08, 0x00000000 },
325 { 0x001f80, 16, 0x08, 0x00000000 },
326 { 0x001f84, 16, 0x08, 0x00000000 },
327 { 0x002000, 1, 0x04, 0x00000000 },
328 { 0x002040, 1, 0x04, 0x00000011 },
329 { 0x002080, 1, 0x04, 0x00000020 },
330 { 0x0020c0, 1, 0x04, 0x00000030 },
331 { 0x002100, 1, 0x04, 0x00000040 },
332 { 0x002140, 1, 0x04, 0x00000051 },
333 { 0x00200c, 6, 0x40, 0x00000001 },
334 { 0x002010, 1, 0x04, 0x00000000 },
335 { 0x002050, 1, 0x04, 0x00000000 },
336 { 0x002090, 1, 0x04, 0x00000001 },
337 { 0x0020d0, 1, 0x04, 0x00000002 },
338 { 0x002110, 1, 0x04, 0x00000003 },
339 { 0x002150, 1, 0x04, 0x00000004 },
340 { 0x000380, 4, 0x20, 0x00000000 },
341 { 0x000384, 4, 0x20, 0x00000000 },
342 { 0x000388, 4, 0x20, 0x00000000 },
343 { 0x00038c, 4, 0x20, 0x00000000 },
344 { 0x000700, 4, 0x10, 0x00000000 },
345 { 0x000704, 4, 0x10, 0x00000000 },
346 { 0x000708, 4, 0x10, 0x00000000 },
347 { 0x002800, 128, 0x04, 0x00000000 },
348 { 0x000a00, 16, 0x20, 0x00000000 },
349 { 0x000a04, 16, 0x20, 0x00000000 },
350 { 0x000a08, 16, 0x20, 0x00000000 },
351 { 0x000a0c, 16, 0x20, 0x00000000 },
352 { 0x000a10, 16, 0x20, 0x00000000 },
353 { 0x000a14, 16, 0x20, 0x00000000 },
354 { 0x000a18, 16, 0x20, 0x00006420 },
355 { 0x000a1c, 16, 0x20, 0x00000000 },
356 { 0x000c00, 16, 0x10, 0x00000000 },
357 { 0x000c04, 16, 0x10, 0x00000000 },
358 { 0x000c08, 16, 0x10, 0x00000000 },
359 { 0x000c0c, 16, 0x10, 0x3f800000 },
360 { 0x000d00, 8, 0x08, 0xffff0000 },
361 { 0x000d04, 8, 0x08, 0xffff0000 },
362 { 0x000e00, 16, 0x10, 0x00000000 },
363 { 0x000e04, 16, 0x10, 0xffff0000 },
364 { 0x000e08, 16, 0x10, 0xffff0000 },
365 { 0x000d40, 4, 0x08, 0x00000000 },
366 { 0x000d44, 4, 0x08, 0x00000000 },
367 { 0x001e00, 8, 0x20, 0x00000001 },
368 { 0x001e04, 8, 0x20, 0x00000001 },
369 { 0x001e08, 8, 0x20, 0x00000002 },
370 { 0x001e0c, 8, 0x20, 0x00000001 },
371 { 0x001e10, 8, 0x20, 0x00000001 },
372 { 0x001e14, 8, 0x20, 0x00000002 },
373 { 0x001e18, 8, 0x20, 0x00000001 },
374 { 0x001480, 8, 0x10, 0x00000000 },
375 { 0x001484, 8, 0x10, 0x00000000 },
376 { 0x001488, 8, 0x10, 0x00000000 },
377 { 0x003400, 128, 0x04, 0x00000000 },
378 { 0x00030c, 1, 0x04, 0x00000001 },
379 { 0x001944, 1, 0x04, 0x00000000 },
380 { 0x001514, 1, 0x04, 0x00000000 },
381 { 0x000d68, 1, 0x04, 0x0000ffff },
382 { 0x00121c, 1, 0x04, 0x0fac6881 },
383 { 0x000fac, 1, 0x04, 0x00000001 },
384 { 0x001538, 1, 0x04, 0x00000001 },
385 { 0x000fe0, 2, 0x04, 0x00000000 },
386 { 0x000fe8, 1, 0x04, 0x00000014 },
387 { 0x000fec, 1, 0x04, 0x00000040 },
388 { 0x000ff0, 1, 0x04, 0x00000000 },
389 { 0x00179c, 1, 0x04, 0x00000000 },
390 { 0x001228, 1, 0x04, 0x00000400 },
391 { 0x00122c, 1, 0x04, 0x00000300 },
392 { 0x001230, 1, 0x04, 0x00010001 },
393 { 0x0007f8, 1, 0x04, 0x00000000 },
394 { 0x001208, 1, 0x04, 0x00000000 },
395 { 0x0015b4, 1, 0x04, 0x00000001 },
396 { 0x0015cc, 1, 0x04, 0x00000000 },
397 { 0x001534, 1, 0x04, 0x00000000 },
398 { 0x000754, 1, 0x04, 0x00000001 },
399 { 0x000fb0, 1, 0x04, 0x00000000 },
400 { 0x0015d0, 1, 0x04, 0x00000000 },
401 { 0x0011e0, 4, 0x04, 0x88888888 },
402 { 0x00153c, 1, 0x04, 0x00000000 },
403 { 0x0016b4, 1, 0x04, 0x00000003 },
404 { 0x000fa4, 1, 0x04, 0x00000001 },
405 { 0x000fbc, 4, 0x04, 0x0000ffff },
406 { 0x000fa8, 1, 0x04, 0x0000ffff },
407 { 0x000df8, 2, 0x04, 0x00000000 },
408 { 0x001948, 1, 0x04, 0x00000000 },
409 { 0x001970, 1, 0x04, 0x00000001 },
410 { 0x00161c, 1, 0x04, 0x000009f0 },
411 { 0x000dcc, 1, 0x04, 0x00000010 },
412 { 0x0015e4, 1, 0x04, 0x00000000 },
413 { 0x001160, 32, 0x04, 0x25e00040 },
414 { 0x001880, 32, 0x04, 0x00000000 },
415 { 0x000f84, 2, 0x04, 0x00000000 },
416 { 0x0017c8, 2, 0x04, 0x00000000 },
417 { 0x0017d0, 1, 0x04, 0x000000ff },
418 { 0x0017d4, 1, 0x04, 0xffffffff },
419 { 0x0017d8, 1, 0x04, 0x00000002 },
420 { 0x0017dc, 1, 0x04, 0x00000000 },
421 { 0x0015f4, 2, 0x04, 0x00000000 },
422 { 0x001434, 2, 0x04, 0x00000000 },
423 { 0x000d74, 1, 0x04, 0x00000000 },
424 { 0x0013a4, 1, 0x04, 0x00000000 },
425 { 0x001318, 1, 0x04, 0x00000001 },
426 { 0x001080, 2, 0x04, 0x00000000 },
427 { 0x001088, 2, 0x04, 0x00000001 },
428 { 0x001090, 1, 0x04, 0x00000000 },
429 { 0x001094, 1, 0x04, 0x00000001 },
430 { 0x001098, 1, 0x04, 0x00000000 },
431 { 0x00109c, 1, 0x04, 0x00000001 },
432 { 0x0010a0, 2, 0x04, 0x00000000 },
433 { 0x001644, 1, 0x04, 0x00000000 },
434 { 0x000748, 1, 0x04, 0x00000000 },
435 { 0x000de8, 1, 0x04, 0x00000000 },
436 { 0x001648, 1, 0x04, 0x00000000 },
437 { 0x0012a4, 1, 0x04, 0x00000000 },
438 { 0x001120, 4, 0x04, 0x00000000 },
439 { 0x001118, 1, 0x04, 0x00000000 },
440 { 0x00164c, 1, 0x04, 0x00000000 },
441 { 0x001658, 1, 0x04, 0x00000000 },
442 { 0x001910, 1, 0x04, 0x00000290 },
443 { 0x001518, 1, 0x04, 0x00000000 },
444 { 0x00165c, 1, 0x04, 0x00000001 },
445 { 0x001520, 1, 0x04, 0x00000000 },
446 { 0x001604, 1, 0x04, 0x00000000 },
447 { 0x001570, 1, 0x04, 0x00000000 },
448 { 0x0013b0, 2, 0x04, 0x3f800000 },
449 { 0x00020c, 1, 0x04, 0x00000000 },
450 { 0x001670, 1, 0x04, 0x30201000 },
451 { 0x001674, 1, 0x04, 0x70605040 },
452 { 0x001678, 1, 0x04, 0xb8a89888 },
453 { 0x00167c, 1, 0x04, 0xf8e8d8c8 },
454 { 0x00166c, 1, 0x04, 0x00000000 },
455 { 0x001680, 1, 0x04, 0x00ffff00 },
456 { 0x0012d0, 1, 0x04, 0x00000003 },
457 { 0x00113c, 1, 0x04, 0x00000000 },
458 { 0x0012d4, 1, 0x04, 0x00000002 },
459 { 0x001684, 2, 0x04, 0x00000000 },
460 { 0x000dac, 2, 0x04, 0x00001b02 },
461 { 0x000db4, 1, 0x04, 0x00000000 },
462 { 0x00168c, 1, 0x04, 0x00000000 },
463 { 0x0015bc, 1, 0x04, 0x00000000 },
464 { 0x00156c, 1, 0x04, 0x00000000 },
465 { 0x00187c, 1, 0x04, 0x00000000 },
466 { 0x001110, 1, 0x04, 0x00000001 },
467 { 0x000dc0, 3, 0x04, 0x00000000 },
468 { 0x000f40, 5, 0x04, 0x00000000 },
469 { 0x001234, 1, 0x04, 0x00000000 },
470 { 0x001690, 1, 0x04, 0x00000000 },
471 { 0x000790, 5, 0x04, 0x00000000 },
472 { 0x00077c, 1, 0x04, 0x00000000 },
473 { 0x001000, 1, 0x04, 0x00000010 },
474 { 0x0010fc, 1, 0x04, 0x00000000 },
475 { 0x001290, 1, 0x04, 0x00000000 },
476 { 0x000218, 1, 0x04, 0x00000010 },
477 { 0x0012d8, 1, 0x04, 0x00000000 },
478 { 0x0012dc, 1, 0x04, 0x00000010 },
479 { 0x000d94, 1, 0x04, 0x00000001 },
480 { 0x00155c, 2, 0x04, 0x00000000 },
481 { 0x001564, 1, 0x04, 0x00000fff },
482 { 0x001574, 2, 0x04, 0x00000000 },
483 { 0x00157c, 1, 0x04, 0x000fffff },
484 { 0x001354, 1, 0x04, 0x00000000 },
485 { 0x001610, 1, 0x04, 0x00000012 },
486 { 0x001608, 2, 0x04, 0x00000000 },
487 { 0x00260c, 1, 0x04, 0x00000000 },
488 { 0x0007ac, 1, 0x04, 0x00000000 },
489 { 0x00162c, 1, 0x04, 0x00000003 },
490 { 0x000210, 1, 0x04, 0x00000000 },
491 { 0x000320, 1, 0x04, 0x00000000 },
492 { 0x000324, 6, 0x04, 0x3f800000 },
493 { 0x000750, 1, 0x04, 0x00000000 },
494 { 0x000760, 1, 0x04, 0x39291909 },
495 { 0x000764, 1, 0x04, 0x79695949 },
496 { 0x000768, 1, 0x04, 0xb9a99989 },
497 { 0x00076c, 1, 0x04, 0xf9e9d9c9 },
498 { 0x000770, 1, 0x04, 0x30201000 },
499 { 0x000774, 1, 0x04, 0x70605040 },
500 { 0x000778, 1, 0x04, 0x00009080 },
501 { 0x000780, 1, 0x04, 0x39291909 },
502 { 0x000784, 1, 0x04, 0x79695949 },
503 { 0x000788, 1, 0x04, 0xb9a99989 },
504 { 0x00078c, 1, 0x04, 0xf9e9d9c9 },
505 { 0x0007d0, 1, 0x04, 0x30201000 },
506 { 0x0007d4, 1, 0x04, 0x70605040 },
507 { 0x0007d8, 1, 0x04, 0x00009080 },
508 { 0x001004, 1, 0x04, 0x00000000 },
509 { 0x001240, 8, 0x04, 0x00000000 },
510 { 0x00037c, 1, 0x04, 0x00000001 },
511 { 0x000740, 1, 0x04, 0x00000000 },
512 { 0x001148, 1, 0x04, 0x00000000 },
513 { 0x000fb4, 1, 0x04, 0x00000000 },
514 { 0x000fb8, 1, 0x04, 0x00000002 },
515 { 0x001130, 1, 0x04, 0x00000002 },
516 { 0x000fd4, 2, 0x04, 0x00000000 },
517 { 0x001030, 1, 0x04, 0x20181008 },
518 { 0x001034, 1, 0x04, 0x40383028 },
519 { 0x001038, 1, 0x04, 0x60585048 },
520 { 0x00103c, 1, 0x04, 0x80787068 },
521 { 0x000744, 1, 0x04, 0x00000000 },
522 { 0x002600, 1, 0x04, 0x00000000 },
523 { 0x001918, 1, 0x04, 0x00000000 },
524 { 0x00191c, 1, 0x04, 0x00000900 },
525 { 0x001920, 1, 0x04, 0x00000405 },
526 { 0x001308, 1, 0x04, 0x00000001 },
527 { 0x001924, 1, 0x04, 0x00000000 },
528 { 0x0013ac, 1, 0x04, 0x00000000 },
529 { 0x00192c, 1, 0x04, 0x00000001 },
530 { 0x00193c, 1, 0x04, 0x00002c1c },
531 { 0x000d7c, 1, 0x04, 0x00000000 },
532 { 0x000f8c, 1, 0x04, 0x00000000 },
533 { 0x0002c0, 1, 0x04, 0x00000001 },
534 { 0x001510, 1, 0x04, 0x00000000 },
535 { 0x001940, 1, 0x04, 0x00000000 },
536 { 0x000ff4, 2, 0x04, 0x00000000 },
537 { 0x00194c, 2, 0x04, 0x00000000 },
538 { 0x001968, 1, 0x04, 0x00000000 },
539 { 0x001590, 1, 0x04, 0x0000003f },
540 { 0x0007e8, 4, 0x04, 0x00000000 },
541 { 0x00196c, 1, 0x04, 0x00000011 },
542 { 0x0002e4, 1, 0x04, 0x0000b001 },
543 { 0x00036c, 2, 0x04, 0x00000000 },
544 { 0x00197c, 1, 0x04, 0x00000000 },
545 { 0x000fcc, 2, 0x04, 0x00000000 },
546 { 0x0002d8, 1, 0x04, 0x00000040 },
547 { 0x001980, 1, 0x04, 0x00000080 },
548 { 0x001504, 1, 0x04, 0x00000080 },
549 { 0x001984, 1, 0x04, 0x00000000 },
550 { 0x000f60, 1, 0x04, 0x00000000 },
551 { 0x000f64, 1, 0x04, 0x00400040 },
552 { 0x000f68, 1, 0x04, 0x00002212 },
553 { 0x000f6c, 1, 0x04, 0x08080203 },
554 { 0x001108, 1, 0x04, 0x00000008 },
555 { 0x000f70, 1, 0x04, 0x00080001 },
556 { 0x000ffc, 1, 0x04, 0x00000000 },
557 { 0x001134, 1, 0x04, 0x00000000 },
558 { 0x000f1c, 1, 0x04, 0x00000000 },
559 { 0x0011f8, 1, 0x04, 0x00000000 },
560 { 0x001138, 1, 0x04, 0x00000001 },
561 { 0x000300, 1, 0x04, 0x00000001 },
562 { 0x0013a8, 1, 0x04, 0x00000000 },
563 { 0x001224, 1, 0x04, 0x00000000 },
564 { 0x0012ec, 1, 0x04, 0x00000000 },
565 { 0x001310, 1, 0x04, 0x00000000 },
566 { 0x001314, 1, 0x04, 0x00000001 },
567 { 0x001380, 1, 0x04, 0x00000000 },
568 { 0x001384, 4, 0x04, 0x00000001 },
569 { 0x001394, 1, 0x04, 0x00000000 },
570 { 0x00139c, 1, 0x04, 0x00000000 },
571 { 0x001398, 1, 0x04, 0x00000000 },
572 { 0x001594, 1, 0x04, 0x00000000 },
573 { 0x001598, 4, 0x04, 0x00000001 },
574 { 0x000f54, 3, 0x04, 0x00000000 },
575 { 0x0019bc, 1, 0x04, 0x00000000 },
576 { 0x000f9c, 2, 0x04, 0x00000000 },
577 { 0x0012cc, 1, 0x04, 0x00000000 },
578 { 0x0012e8, 1, 0x04, 0x00000000 },
579 { 0x00130c, 1, 0x04, 0x00000001 },
580 { 0x001360, 8, 0x04, 0x00000000 },
581 { 0x00133c, 2, 0x04, 0x00000001 },
582 { 0x001344, 1, 0x04, 0x00000002 },
583 { 0x001348, 2, 0x04, 0x00000001 },
584 { 0x001350, 1, 0x04, 0x00000002 },
585 { 0x001358, 1, 0x04, 0x00000001 },
586 { 0x0012e4, 1, 0x04, 0x00000000 },
587 { 0x00131c, 4, 0x04, 0x00000000 },
588 { 0x0019c0, 1, 0x04, 0x00000000 },
589 { 0x001140, 1, 0x04, 0x00000000 },
590 { 0x000dd0, 1, 0x04, 0x00000000 },
591 { 0x000dd4, 1, 0x04, 0x00000001 },
592 { 0x0002f4, 1, 0x04, 0x00000000 },
593 { 0x0019c4, 1, 0x04, 0x00000000 },
594 { 0x0019c8, 1, 0x04, 0x00001500 },
595 { 0x00135c, 1, 0x04, 0x00000000 },
596 { 0x000f90, 1, 0x04, 0x00000000 },
597 { 0x0019e0, 8, 0x04, 0x00000001 },
598 { 0x0019cc, 1, 0x04, 0x00000001 },
599 { 0x00111c, 1, 0x04, 0x00000001 },
600 { 0x0015b8, 1, 0x04, 0x00000000 },
601 { 0x001a00, 1, 0x04, 0x00001111 },
602 { 0x001a04, 7, 0x04, 0x00000000 },
603 { 0x000d6c, 2, 0x04, 0xffff0000 },
604 { 0x0010f8, 1, 0x04, 0x00001010 },
605 { 0x000d80, 5, 0x04, 0x00000000 },
606 { 0x000da0, 1, 0x04, 0x00000000 },
607 { 0x0007a4, 2, 0x04, 0x00000000 },
608 { 0x001508, 1, 0x04, 0x80000000 },
609 { 0x00150c, 1, 0x04, 0x40000000 },
610 { 0x001668, 1, 0x04, 0x00000000 },
611 { 0x000318, 2, 0x04, 0x00000008 },
612 { 0x000d9c, 1, 0x04, 0x00000001 },
613 { 0x000f14, 1, 0x04, 0x00000000 },
614 { 0x000374, 1, 0x04, 0x00000000 },
615 { 0x000378, 1, 0x04, 0x0000000c },
616 { 0x0007dc, 1, 0x04, 0x00000000 },
617 { 0x00074c, 1, 0x04, 0x00000055 },
618 { 0x001420, 1, 0x04, 0x00000003 },
619 { 0x001008, 1, 0x04, 0x00000008 },
620 { 0x00100c, 1, 0x04, 0x00000040 },
621 { 0x001010, 1, 0x04, 0x0000012c },
622 { 0x000d60, 1, 0x04, 0x00000040 },
623 { 0x001018, 1, 0x04, 0x00000020 },
624 { 0x00101c, 1, 0x04, 0x00000001 },
625 { 0x001020, 1, 0x04, 0x00000020 },
626 { 0x001024, 1, 0x04, 0x00000001 },
627 { 0x001444, 3, 0x04, 0x00000000 },
628 { 0x000360, 1, 0x04, 0x20164010 },
629 { 0x000364, 1, 0x04, 0x00000020 },
630 { 0x000368, 1, 0x04, 0x00000000 },
631 { 0x000da8, 1, 0x04, 0x00000030 },
632 { 0x000de4, 1, 0x04, 0x00000000 },
633 { 0x000204, 1, 0x04, 0x00000006 },
634 { 0x0002d0, 1, 0x04, 0x003fffff },
635 { 0x001220, 1, 0x04, 0x00000005 },
636 { 0x000fdc, 1, 0x04, 0x00000000 },
637 { 0x000f98, 1, 0x04, 0x00400008 },
638 { 0x001284, 1, 0x04, 0x08000080 },
639 { 0x001450, 1, 0x04, 0x00400008 },
640 { 0x001454, 1, 0x04, 0x08000080 },
641 { 0x000214, 1, 0x04, 0x00000000 },
642 {}
643};
644
645const struct gf100_gr_pack
646gm204_grctx_pack_mthd[] = {
647 { gm204_grctx_init_b197_0, 0xb197 },
648 { gf100_grctx_init_902d_0, 0x902d },
649 {}
650};
651
652static const struct gf100_gr_init
653gm204_grctx_init_fe_0[] = {
654 { 0x404004, 8, 0x04, 0x00000000 },
655 { 0x404024, 1, 0x04, 0x0000e000 },
656 { 0x404028, 8, 0x04, 0x00000000 },
657 { 0x4040a8, 8, 0x04, 0x00000000 },
658 { 0x4040c8, 1, 0x04, 0xf801008f },
659 { 0x4040d0, 6, 0x04, 0x00000000 },
660 { 0x4040f8, 1, 0x04, 0x00000000 },
661 { 0x404100, 10, 0x04, 0x00000000 },
662 { 0x404130, 2, 0x04, 0x00000000 },
663 { 0x404150, 1, 0x04, 0x0000002e },
664 { 0x404154, 2, 0x04, 0x00000800 },
665 { 0x404164, 1, 0x04, 0x00000045 },
666 { 0x40417c, 2, 0x04, 0x00000000 },
667 { 0x404194, 1, 0x04, 0x33000700 },
668 { 0x4041a0, 4, 0x04, 0x00000000 },
669 { 0x4041c4, 2, 0x04, 0x00000000 },
670 {}
671};
672
673static const struct gf100_gr_init
674gm204_grctx_init_ds_0[] = {
675 { 0x405800, 1, 0x04, 0x8f8001bf },
676 { 0x405830, 1, 0x04, 0x04001000 },
677 { 0x405834, 1, 0x04, 0x08000000 },
678 { 0x405838, 1, 0x04, 0x00010000 },
679 { 0x405854, 1, 0x04, 0x00000000 },
680 { 0x405870, 4, 0x04, 0x00000001 },
681 { 0x405a00, 2, 0x04, 0x00000000 },
682 { 0x405a18, 1, 0x04, 0x00000000 },
683 { 0x405a1c, 1, 0x04, 0x000000ff },
684 {}
685};
686
687static const struct gf100_gr_init
688gm204_grctx_init_cwd_0[] = {
689 { 0x405b00, 1, 0x04, 0x00000000 },
690 { 0x405b10, 1, 0x04, 0x00001000 },
691 { 0x405b20, 1, 0x04, 0x04000000 },
692 { 0x405b60, 6, 0x04, 0x00000000 },
693 { 0x405ba0, 6, 0x04, 0x00000000 },
694 {}
695};
696
697static const struct gf100_gr_init
698gm204_grctx_init_pd_0[] = {
699 { 0x406020, 1, 0x04, 0x17410001 },
700 { 0x406028, 4, 0x04, 0x00000001 },
701 { 0x4064a8, 1, 0x04, 0x00000000 },
702 { 0x4064ac, 1, 0x04, 0x00003fff },
703 { 0x4064b0, 3, 0x04, 0x00000000 },
704 { 0x4064c0, 1, 0x04, 0x80400280 },
705 { 0x4064c4, 1, 0x04, 0x0400ffff },
706 { 0x4064c8, 1, 0x04, 0x01800780 },
707 { 0x4064cc, 9, 0x04, 0x00000000 },
708 { 0x4064fc, 1, 0x04, 0x0000022a },
709 { 0x406500, 1, 0x04, 0x00000000 },
710 {}
711};
712
713static const struct gf100_gr_init
714gm204_grctx_init_be_0[] = {
715 { 0x408800, 1, 0x04, 0x32882a3c },
716 { 0x408804, 1, 0x04, 0x00000040 },
717 { 0x408808, 1, 0x04, 0x1003e005 },
718 { 0x408840, 1, 0x04, 0x00000e0b },
719 { 0x408900, 1, 0x04, 0xb080b801 },
720 { 0x408904, 1, 0x04, 0x63038001 },
721 { 0x408908, 1, 0x04, 0x12c8502f },
722 { 0x408980, 1, 0x04, 0x0000011d },
723 {}
724};
725
726const struct gf100_gr_pack
727gm204_grctx_pack_hub[] = {
728 { gf100_grctx_init_main_0 },
729 { gm204_grctx_init_fe_0 },
730 { gk110_grctx_init_pri_0 },
731 { gk104_grctx_init_memfmt_0 },
732 { gm204_grctx_init_ds_0 },
733 { gm204_grctx_init_cwd_0 },
734 { gm204_grctx_init_pd_0 },
735 { gk208_grctx_init_rstr2d_0 },
736 { gk104_grctx_init_scc_0 },
737 { gm204_grctx_init_be_0 },
738 {}
739};
740
741const struct gf100_gr_init
742gm204_grctx_init_prop_0[] = {
743 { 0x418400, 1, 0x04, 0x38e01e00 },
744 { 0x418404, 1, 0x04, 0x70001fff },
745 { 0x41840c, 1, 0x04, 0x20001008 },
746 { 0x418410, 2, 0x04, 0x0fff0fff },
747 { 0x418418, 1, 0x04, 0x07ff07ff },
748 { 0x41841c, 1, 0x04, 0x3feffbff },
749 { 0x418450, 6, 0x04, 0x00000000 },
750 { 0x418468, 1, 0x04, 0x00000001 },
751 { 0x41846c, 2, 0x04, 0x00000000 },
752 {}
753};
754
755static const struct gf100_gr_init
756gm204_grctx_init_gpc_unk_1[] = {
757 { 0x418600, 1, 0x04, 0x0000007f },
758 { 0x418684, 1, 0x04, 0x0000001f },
759 { 0x418700, 1, 0x04, 0x00000002 },
760 { 0x418704, 1, 0x04, 0x00000080 },
761 { 0x418708, 1, 0x04, 0x40000000 },
762 { 0x41870c, 2, 0x04, 0x00000000 },
763 { 0x418728, 1, 0x04, 0x00010000 },
764 {}
765};
766
767const struct gf100_gr_init
768gm204_grctx_init_setup_0[] = {
769 { 0x418800, 1, 0x04, 0x7006863a },
770 { 0x418808, 1, 0x04, 0x00000000 },
771 { 0x418810, 1, 0x04, 0x00000000 },
772 { 0x418828, 1, 0x04, 0x00000044 },
773 { 0x418830, 1, 0x04, 0x10000001 },
774 { 0x4188d8, 1, 0x04, 0x00000008 },
775 { 0x4188e0, 1, 0x04, 0x01000000 },
776 { 0x4188e8, 5, 0x04, 0x00000000 },
777 { 0x4188fc, 1, 0x04, 0x20100058 },
778 {}
779};
780
781const struct gf100_gr_init
782gm204_grctx_init_gpm_0[] = {
783 { 0x418c10, 8, 0x04, 0x00000000 },
784 { 0x418c40, 1, 0x04, 0xffffffff },
785 { 0x418c6c, 1, 0x04, 0x00000001 },
786 { 0x418c80, 1, 0x04, 0x20200000 },
787 {}
788};
789
790const struct gf100_gr_init
791gm204_grctx_init_gpc_unk_2[] = {
792 { 0x418e00, 1, 0x04, 0x90040000 },
793 { 0x418e24, 1, 0x04, 0x00000000 },
794 { 0x418e28, 1, 0x04, 0x00000030 },
795 { 0x418e2c, 1, 0x04, 0x00000100 },
796 { 0x418e30, 3, 0x04, 0x00000000 },
797 { 0x418e40, 22, 0x04, 0x00000000 },
798 { 0x418ea0, 12, 0x04, 0x00000000 },
799 {}
800};
801
802static const struct gf100_gr_pack
803gm204_grctx_pack_gpc[] = {
804 { gm107_grctx_init_gpc_unk_0 },
805 { gm204_grctx_init_prop_0 },
806 { gm204_grctx_init_gpc_unk_1 },
807 { gm204_grctx_init_setup_0 },
808 { gf100_grctx_init_zcull_0 },
809 { gk208_grctx_init_crstr_0 },
810 { gm204_grctx_init_gpm_0 },
811 { gm204_grctx_init_gpc_unk_2 },
812 { gf100_grctx_init_gcc_0 },
813 {}
814};
815
816static const struct gf100_gr_init
817gm204_grctx_init_pe_0[] = {
818 { 0x419848, 1, 0x04, 0x00000000 },
819 { 0x419864, 1, 0x04, 0x00000029 },
820 { 0x419888, 1, 0x04, 0x00000000 },
821 {}
822};
823
824static const struct gf100_gr_init
825gm204_grctx_init_tex_0[] = {
826 { 0x419a00, 1, 0x04, 0x000100f0 },
827 { 0x419a04, 1, 0x04, 0x00000005 },
828 { 0x419a08, 1, 0x04, 0x00000621 },
829 { 0x419a0c, 1, 0x04, 0x00320000 },
830 { 0x419a10, 1, 0x04, 0x00000000 },
831 { 0x419a14, 1, 0x04, 0x00000200 },
832 { 0x419a1c, 1, 0x04, 0x0010c000 },
833 { 0x419a20, 1, 0x04, 0x20008a00 },
834 { 0x419a30, 1, 0x04, 0x00000001 },
835 { 0x419a3c, 1, 0x04, 0x0000181e },
836 { 0x419ac4, 1, 0x04, 0x00000000 },
837 {}
838};
839
840static const struct gf100_gr_init
841gm204_grctx_init_mpc_0[] = {
842 { 0x419c00, 1, 0x04, 0x0000009a },
843 { 0x419c04, 1, 0x04, 0x80000bd6 },
844 { 0x419c08, 1, 0x04, 0x00000002 },
845 { 0x419c20, 1, 0x04, 0x00000000 },
846 { 0x419c24, 1, 0x04, 0x00084210 },
847 { 0x419c28, 1, 0x04, 0x3efbefbe },
848 { 0x419c2c, 1, 0x04, 0x00000000 },
849 { 0x419c34, 1, 0x04, 0x71ff1ff3 },
850 { 0x419c3c, 1, 0x04, 0x00001919 },
851 { 0x419c50, 1, 0x04, 0x00000005 },
852 {}
853};
854
855static const struct gf100_gr_init
856gm204_grctx_init_l1c_0[] = {
857 { 0x419c84, 1, 0x04, 0x0000003e },
858 { 0x419c90, 1, 0x04, 0x0000000a },
859 {}
860};
861
862static const struct gf100_gr_init
863gm204_grctx_init_sm_0[] = {
864 { 0x419e04, 3, 0x04, 0x00000000 },
865 { 0x419e10, 1, 0x04, 0x00001c02 },
866 { 0x419e44, 1, 0x04, 0x00d3eff2 },
867 { 0x419e48, 1, 0x04, 0x00000000 },
868 { 0x419e4c, 1, 0x04, 0x0000007f },
869 { 0x419e50, 1, 0x04, 0x00000000 },
870 { 0x419e58, 6, 0x04, 0x00000000 },
871 { 0x419e74, 10, 0x04, 0x00000000 },
872 { 0x419eac, 1, 0x04, 0x0001cf8b },
873 { 0x419eb0, 1, 0x04, 0x00030300 },
874 { 0x419eb8, 1, 0x04, 0x40000000 },
875 { 0x419ef0, 24, 0x04, 0x00000000 },
876 { 0x419f68, 2, 0x04, 0x00000000 },
877 { 0x419f70, 1, 0x04, 0x00000020 },
878 { 0x419f78, 1, 0x04, 0x00010beb },
879 { 0x419f7c, 1, 0x04, 0x00000000 },
880 {}
881};
882
883const struct gf100_gr_pack
884gm204_grctx_pack_tpc[] = {
885 { gm204_grctx_init_pe_0 },
886 { gm204_grctx_init_tex_0 },
887 { gm204_grctx_init_mpc_0 },
888 { gm204_grctx_init_l1c_0 },
889 { gm204_grctx_init_sm_0 },
890 {}
891};
892
893static const struct gf100_gr_init
894gm204_grctx_init_pes_0[] = {
895 { 0x41be24, 1, 0x04, 0x0000000e },
896 {}
897};
898
899static const struct gf100_gr_init
900gm204_grctx_init_cbm_0[] = {
901 { 0x41bec0, 1, 0x04, 0x00000000 },
902 { 0x41bec4, 1, 0x04, 0x01030000 },
903 { 0x41bee4, 1, 0x04, 0x00000000 },
904 { 0x41bef0, 1, 0x04, 0x000003ff },
905 { 0x41bef4, 2, 0x04, 0x00000000 },
906 {}
907};
908
909const struct gf100_gr_pack
910gm204_grctx_pack_ppc[] = {
911 { gm204_grctx_init_pes_0 },
912 { gm204_grctx_init_cbm_0 },
913 { gm107_grctx_init_wwdx_0 },
914 {}
915};
916
917/*******************************************************************************
918 * PGRAPH context implementation
919 ******************************************************************************/
920
921static void
922gm204_grctx_generate_tpcid(struct gf100_gr_priv *priv)
923{
924 int gpc, tpc, id;
925
926 for (tpc = 0, id = 0; tpc < 4; tpc++) {
927 for (gpc = 0; gpc < priv->gpc_nr; gpc++) {
928 if (tpc < priv->tpc_nr[gpc]) {
929 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x698), id);
930 nv_wr32(priv, GPC_UNIT(gpc, 0x0c10 + tpc * 4), id);
931 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x088), id);
932 id++;
933 }
934 }
935 }
936}
937
938static void
939gm204_grctx_generate_rop_active_fbps(struct gf100_gr_priv *priv)
940{
941 const u32 fbp_count = nv_rd32(priv, 0x12006c);
942 nv_mask(priv, 0x408850, 0x0000000f, fbp_count); /* zrop */
943 nv_mask(priv, 0x408958, 0x0000000f, fbp_count); /* crop */
944}
945
946static void
947gm204_grctx_generate_405b60(struct gf100_gr_priv *priv)
948{
949 const u32 dist_nr = DIV_ROUND_UP(priv->tpc_total, 4);
950 u32 dist[TPC_MAX] = {};
951 u32 gpcs[GPC_MAX] = {};
952 u8 tpcnr[GPC_MAX];
953 int tpc, gpc, i;
954
955 memcpy(tpcnr, priv->tpc_nr, sizeof(priv->tpc_nr));
956
957 /* won't result in the same distribution as the binary driver where
958 * some of the gpcs have more tpcs than others, but this shall do
959 * for the moment. the code for earlier gpus has this issue too.
960 */
961 for (gpc = -1, i = 0; i < priv->tpc_total; i++) {
962 do {
963 gpc = (gpc + 1) % priv->gpc_nr;
964 } while(!tpcnr[gpc]);
965 tpc = priv->tpc_nr[gpc] - tpcnr[gpc]--;
966
967 dist[i / 4] |= ((gpc << 4) | tpc) << ((i % 4) * 8);
968 gpcs[gpc] |= i << (tpc * 8);
969 }
970
971 for (i = 0; i < dist_nr; i++)
972 nv_wr32(priv, 0x405b60 + (i * 4), dist[i]);
973 for (i = 0; i < priv->gpc_nr; i++)
974 nv_wr32(priv, 0x405ba0 + (i * 4), gpcs[i]);
975}
976
977void
978gm204_grctx_generate_main(struct gf100_gr_priv *priv, struct gf100_grctx *info)
979{
980 struct gf100_grctx_oclass *oclass = (void *)nv_engine(priv)->cclass;
981 u32 tmp;
982 int i;
983
984 gf100_gr_mmio(priv, oclass->hub);
985 gf100_gr_mmio(priv, oclass->gpc);
986 gf100_gr_mmio(priv, oclass->zcull);
987 gf100_gr_mmio(priv, oclass->tpc);
988 gf100_gr_mmio(priv, oclass->ppc);
989
990 nv_wr32(priv, 0x404154, 0x00000000);
991
992 oclass->bundle(info);
993 oclass->pagepool(info);
994 oclass->attrib(info);
995 oclass->unkn(priv);
996
997 gm204_grctx_generate_tpcid(priv);
998 gf100_grctx_generate_r406028(priv);
999 gk104_grctx_generate_r418bb8(priv);
1000
1001 for (i = 0; i < 8; i++)
1002 nv_wr32(priv, 0x4064d0 + (i * 0x04), 0x00000000);
1003 nv_wr32(priv, 0x406500, 0x00000000);
1004
1005 nv_wr32(priv, 0x405b00, (priv->tpc_total << 8) | priv->gpc_nr);
1006
1007 gm204_grctx_generate_rop_active_fbps(priv);
1008
1009 for (tmp = 0, i = 0; i < priv->gpc_nr; i++)
1010 tmp |= ((1 << priv->tpc_nr[i]) - 1) << (i * 4);
1011 nv_wr32(priv, 0x4041c4, tmp);
1012
1013 gm204_grctx_generate_405b60(priv);
1014
1015 gf100_gr_icmd(priv, oclass->icmd);
1016 nv_wr32(priv, 0x404154, 0x00000800);
1017 gf100_gr_mthd(priv, oclass->mthd);
1018
1019 nv_mask(priv, 0x418e94, 0xffffffff, 0xc4230000);
1020 nv_mask(priv, 0x418e4c, 0xffffffff, 0x70000000);
1021}
1022
1023struct nvkm_oclass *
1024gm204_grctx_oclass = &(struct gf100_grctx_oclass) {
1025 .base.handle = NV_ENGCTX(GR, 0x24),
1026 .base.ofuncs = &(struct nvkm_ofuncs) {
1027 .ctor = gf100_gr_context_ctor,
1028 .dtor = gf100_gr_context_dtor,
1029 .init = _nvkm_gr_context_init,
1030 .fini = _nvkm_gr_context_fini,
1031 .rd32 = _nvkm_gr_context_rd32,
1032 .wr32 = _nvkm_gr_context_wr32,
1033 },
1034 .main = gm204_grctx_generate_main,
1035 .unkn = gk104_grctx_generate_unkn,
1036 .hub = gm204_grctx_pack_hub,
1037 .gpc = gm204_grctx_pack_gpc,
1038 .zcull = gf100_grctx_pack_zcull,
1039 .tpc = gm204_grctx_pack_tpc,
1040 .ppc = gm204_grctx_pack_ppc,
1041 .icmd = gm204_grctx_pack_icmd,
1042 .mthd = gm204_grctx_pack_mthd,
1043 .bundle = gm107_grctx_generate_bundle,
1044 .bundle_size = 0x3000,
1045 .bundle_min_gpm_fifo_depth = 0x180,
1046 .bundle_token_limit = 0x780,
1047 .pagepool = gm107_grctx_generate_pagepool,
1048 .pagepool_size = 0x20000,
1049 .attrib = gm107_grctx_generate_attrib,
1050 .attrib_nr_max = 0x600,
1051 .attrib_nr = 0x400,
1052 .alpha_nr_max = 0x1800,
1053 .alpha_nr = 0x1000,
1054}.base;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm206.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm206.c
new file mode 100644
index 000000000000..91ec41617943
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm206.c
@@ -0,0 +1,83 @@
1/*
2 * Copyright 2015 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs <bskeggs@redhat.com>
23 */
24#include "ctxgf100.h"
25
26static const struct gf100_gr_init
27gm206_grctx_init_gpc_unk_1[] = {
28 { 0x418600, 1, 0x04, 0x0000007f },
29 { 0x418684, 1, 0x04, 0x0000001f },
30 { 0x418700, 1, 0x04, 0x00000002 },
31 { 0x418704, 1, 0x04, 0x00000080 },
32 { 0x418708, 1, 0x04, 0x40000000 },
33 { 0x41870c, 2, 0x04, 0x00000000 },
34 { 0x418728, 1, 0x04, 0x00300020 },
35 {}
36};
37
38static const struct gf100_gr_pack
39gm206_grctx_pack_gpc[] = {
40 { gm107_grctx_init_gpc_unk_0 },
41 { gm204_grctx_init_prop_0 },
42 { gm206_grctx_init_gpc_unk_1 },
43 { gm204_grctx_init_setup_0 },
44 { gf100_grctx_init_zcull_0 },
45 { gk208_grctx_init_crstr_0 },
46 { gm204_grctx_init_gpm_0 },
47 { gm204_grctx_init_gpc_unk_2 },
48 { gf100_grctx_init_gcc_0 },
49 {}
50};
51
52struct nvkm_oclass *
53gm206_grctx_oclass = &(struct gf100_grctx_oclass) {
54 .base.handle = NV_ENGCTX(GR, 0x26),
55 .base.ofuncs = &(struct nvkm_ofuncs) {
56 .ctor = gf100_gr_context_ctor,
57 .dtor = gf100_gr_context_dtor,
58 .init = _nvkm_gr_context_init,
59 .fini = _nvkm_gr_context_fini,
60 .rd32 = _nvkm_gr_context_rd32,
61 .wr32 = _nvkm_gr_context_wr32,
62 },
63 .main = gm204_grctx_generate_main,
64 .unkn = gk104_grctx_generate_unkn,
65 .hub = gm204_grctx_pack_hub,
66 .gpc = gm206_grctx_pack_gpc,
67 .zcull = gf100_grctx_pack_zcull,
68 .tpc = gm204_grctx_pack_tpc,
69 .ppc = gm204_grctx_pack_ppc,
70 .icmd = gm204_grctx_pack_icmd,
71 .mthd = gm204_grctx_pack_mthd,
72 .bundle = gm107_grctx_generate_bundle,
73 .bundle_size = 0x3000,
74 .bundle_min_gpm_fifo_depth = 0x180,
75 .bundle_token_limit = 0x780,
76 .pagepool = gm107_grctx_generate_pagepool,
77 .pagepool_size = 0x20000,
78 .attrib = gm107_grctx_generate_attrib,
79 .attrib_nr_max = 0x600,
80 .attrib_nr = 0x400,
81 .alpha_nr_max = 0x1800,
82 .alpha_nr = 0x1000,
83}.base;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpc.fuc b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpc.fuc
index eaed1599b90f..194afe910d21 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpc.fuc
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpc.fuc
@@ -52,6 +52,12 @@ mmio_list_base:
52#endif 52#endif
53 53
54#ifdef INCLUDE_CODE 54#ifdef INCLUDE_CODE
55#define gpc_wr32(addr,reg) /*
56*/ mov b32 $r15 reg /*
57*/ imm32($r14, addr) /*
58*/ or $r14 NV_PGRAPH_GPCX_GPCCS_MMIO_CTRL_BASE_ENABLE /*
59*/ call(nv_wr32)
60
55// reports an exception to the host 61// reports an exception to the host
56// 62//
57// In: $r15 error code (see os.h) 63// In: $r15 error code (see os.h)
@@ -64,6 +70,43 @@ error:
64 pop $r14 70 pop $r14
65 ret 71 ret
66 72
73#if CHIPSET >= GM107
74tpc_strand_wait:
75 push $r9
76 trace_set(T_STRTPC)
77 tpc_strand_busy:
78 nv_iord($r9, NV_PGRAPH_GPCX_GPCCS_TPC_STATUS, 0)
79 bra b32 $r9 0x0 ne #tpc_strand_busy
80 trace_clr(T_STRTPC)
81 pop $r9
82 ret
83
84#define tpc_strand_wait() call(tpc_strand_wait)
85#define tpc_strand_enable() /*
86*/ mov $r15 NV_PGRAPH_GPC0_TPCX_STRAND_CMD_ENABLE /*
87*/ gpc_wr32(NV_PGRAPH_GPC0_TPCX_STRAND_CMD, $r15) /*
88*/ tpc_strand_wait()
89#define tpc_strand_disable() /*
90*/ mov $r15 NV_PGRAPH_GPC0_TPCX_STRAND_CMD_DISABLE /*
91*/ gpc_wr32(NV_PGRAPH_GPC0_TPCX_STRAND_CMD, $r15) /*
92*/ tpc_strand_wait()
93#define tpc_strand_seek(p) /*
94*/ mov $r15 NV_PGRAPH_GPC0_TPCX_STRAND_INDEX_ALL /*
95*/ gpc_wr32(NV_PGRAPH_GPC0_TPCX_STRAND_INDEX, $r15) /*
96*/ mov $r15 p /*
97*/ gpc_wr32(NV_PGRAPH_GPC0_TPCX_STRAND_SELECT, $r15) /*
98*/ mov $r15 NV_PGRAPH_GPC0_TPCX_STRAND_CMD_SEEK /*
99*/ tpc_strand_wait()
100#define tpc_strand_info(m) /*
101*/ gpc_wr32(NV_PGRAPH_GPC0_TPCX_STRAND_CMD, $r15) /*
102*/ mov $r15 m /*
103*/ gpc_wr32(NV_PGRAPH_GPC0_TPCX_STRAND_DATA, $r15) /*
104*/ mov $r15 NV_PGRAPH_GPC0_TPCX_STRAND_CMD_GET_INFO /*
105*/ gpc_wr32(NV_PGRAPH_GPC0_TPCX_STRAND_CMD, $r15) /*
106*/ tpc_strand_wait()
107#endif
108
109
67// GPC fuc initialisation, executed by triggering ucode start, will 110// GPC fuc initialisation, executed by triggering ucode start, will
68// fall through to main loop after completion. 111// fall through to main loop after completion.
69// 112//
@@ -101,7 +144,7 @@ init:
101 // enable interrupts 144 // enable interrupts
102 bset $flags ie0 145 bset $flags ie0
103 146
104 // figure out which GPC we are, and how many TPCs we have 147 // how many TPCs do we have?
105 nv_iord($r2, NV_PGRAPH_GPCX_GPCCS_UNITS, 0) 148 nv_iord($r2, NV_PGRAPH_GPCX_GPCCS_UNITS, 0)
106 mov $r3 1 149 mov $r3 1
107 and $r2 0x1f 150 and $r2 0x1f
@@ -109,8 +152,12 @@ init:
109 sub b32 $r3 1 152 sub b32 $r3 1
110 st b32 D[$r0 + #tpc_count] $r2 153 st b32 D[$r0 + #tpc_count] $r2
111 st b32 D[$r0 + #tpc_mask] $r3 154 st b32 D[$r0 + #tpc_mask] $r3
155
156 // determine which GPC we are, setup (optional) mmio access offset
112 nv_iord($r2, NV_PGRAPH_GPCX_GPCCS_MYINDEX, 0) 157 nv_iord($r2, NV_PGRAPH_GPCX_GPCCS_MYINDEX, 0)
113 st b32 D[$r0 + #gpc_id] $r2 158 st b32 D[$r0 + #gpc_id] $r2
159 shl b32 $r2 15
160 nv_iowr(NV_PGRAPH_GPCX_GPCCS_MMIO_BASE, 0, $r2)
114 161
115#if NV_PGRAPH_GPCX_UNK__SIZE > 0 162#if NV_PGRAPH_GPCX_UNK__SIZE > 0
116 // figure out which, and how many, UNKs are actually present 163 // figure out which, and how many, UNKs are actually present
@@ -186,8 +233,56 @@ init:
186 // calculate size of strand context data 233 // calculate size of strand context data
187 mov b32 $r15 $r2 234 mov b32 $r15 $r2
188 call(strand_ctx_init) 235 call(strand_ctx_init)
236 add b32 $r2 $r15
189 add b32 $r3 $r15 237 add b32 $r3 $r15
190 238
239#if CHIPSET >= GM107
240 // calculate size of tpc strand context data
241 mov $r15 NV_PGRAPH_GPC0_TPCX_STRAND_INDEX_ALL
242 gpc_wr32(NV_PGRAPH_GPC0_TPCX_STRAND_INDEX, $r15)
243 tpc_strand_enable();
244 tpc_strand_seek(0);
245 tpc_strand_info(-1);
246
247 ld b32 $r4 D[$r0 + #tpc_count]
248 mov $r5 NV_PGRAPH_GPC0_TPC0
249 ld b32 $r6 D[$r0 + #gpc_id]
250 shl b32 $r6 15
251 add b32 $r5 $r6
252 tpc_strand_init_tpc_loop:
253 add b32 $r14 $r5 NV_TPC_STRAND_CNT
254 call(nv_rd32)
255 mov b32 $r6 $r15
256 clear b32 $r7
257 tpc_strand_init_idx_loop:
258 add b32 $r14 $r5 NV_TPC_STRAND_INDEX
259 mov b32 $r15 $r7
260 call(nv_wr32)
261 add b32 $r14 $r5 NV_TPC_STRAND_SAVE_SWBASE
262 shr b32 $r15 $r2 8
263 call(nv_wr32)
264 add b32 $r14 $r5 NV_TPC_STRAND_LOAD_SWBASE
265 shr b32 $r15 $r2 8
266 call(nv_wr32)
267 add b32 $r14 $r5 NV_TPC_STRAND_WORDS
268 call(nv_rd32)
269 shr b32 $r15 6
270 add b32 $r15 1
271 shl b32 $r15 8
272 add b32 $r2 $r15
273 add b32 $r3 $r15
274 add b32 $r7 1
275 sub b32 $r6 1
276 bra nz #tpc_strand_init_idx_loop
277 add b32 $r5 NV_PGRAPH_GPC0_TPC0__SIZE
278 sub b32 $r4 1
279 bra nz #tpc_strand_init_tpc_loop
280
281 mov $r15 NV_PGRAPH_GPC0_TPCX_STRAND_INDEX_ALL
282 gpc_wr32(NV_PGRAPH_GPC0_TPCX_STRAND_INDEX, $r15)
283 tpc_strand_disable();
284#endif
285
191 // save context size, and tell HUB we're done 286 // save context size, and tell HUB we're done
192 nv_iowr(NV_PGRAPH_GPCX_GPCCS_CC_SCRATCH_VAL(1), 0, $r3) 287 nv_iowr(NV_PGRAPH_GPCX_GPCCS_CC_SCRATCH_VAL(1), 0, $r3)
193 clear b32 $r2 288 clear b32 $r2
@@ -306,6 +401,9 @@ ctx_redswitch:
306ctx_xfer: 401ctx_xfer:
307 // set context base address 402 // set context base address
308 nv_iowr(NV_PGRAPH_GPCX_GPCCS_MEM_BASE, 0, $r15) 403 nv_iowr(NV_PGRAPH_GPCX_GPCCS_MEM_BASE, 0, $r15)
404#if CHIPSET >= GM107
405 gpc_wr32(NV_PGRAPH_GPC0_TPCX_STRAND_MEM_BASE, $r15)
406#endif
309 bra not $p1 #ctx_xfer_not_load 407 bra not $p1 #ctx_xfer_not_load
310 call(ctx_redswitch) 408 call(ctx_redswitch)
311 ctx_xfer_not_load: 409 ctx_xfer_not_load:
@@ -318,6 +416,14 @@ ctx_xfer:
318 add b32 $r2 NV_PGRAPH_GPCX_GPCCS_STRAND_CMD_SAVE 416 add b32 $r2 NV_PGRAPH_GPCX_GPCCS_STRAND_CMD_SAVE
319 nv_iowr(NV_PGRAPH_GPCX_GPCCS_STRAND_CMD, 0x3f, $r2) 417 nv_iowr(NV_PGRAPH_GPCX_GPCCS_STRAND_CMD, 0x3f, $r2)
320 418
419#if CHIPSET >= GM107
420 tpc_strand_enable();
421 tpc_strand_seek(0);
422 xbit $r15 $flags $p1 // SAVE/LOAD
423 add b32 $r15 NV_PGRAPH_GPC0_TPCX_STRAND_CMD_SAVE
424 gpc_wr32(NV_PGRAPH_GPC0_TPCX_STRAND_CMD, $r15)
425#endif
426
321 // mmio context 427 // mmio context
322 xbit $r10 $flags $p1 // direction 428 xbit $r10 $flags $p1 // direction
323 or $r10 2 // first 429 or $r10 2 // first
@@ -362,6 +468,9 @@ ctx_xfer:
362 468
363 // wait for strands to finish 469 // wait for strands to finish
364 call(strand_wait) 470 call(strand_wait)
471#if CHIPSET >= GM107
472 tpc_strand_wait()
473#endif
365 474
366 // if load, or a save without a load following, do some 475 // if load, or a save without a load following, do some
367 // unknown stuff that's done after finishing a block of 476 // unknown stuff that's done after finishing a block of
@@ -370,6 +479,9 @@ ctx_xfer:
370 bra not $p2 #ctx_xfer_done 479 bra not $p2 #ctx_xfer_done
371 ctx_xfer_post: 480 ctx_xfer_post:
372 call(strand_post) 481 call(strand_post)
482#if CHIPSET >= GM107
483 tpc_strand_disable()
484#endif
373 485
374 // mark completion in HUB's barrier 486 // mark completion in HUB's barrier
375 ctx_xfer_done: 487 ctx_xfer_done:
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgf100.fuc3.h b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgf100.fuc3.h
index ea32f56c0a92..231f696d1e0a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgf100.fuc3.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgf100.fuc3.h
@@ -310,7 +310,7 @@ uint32_t gf100_grgpc_code[] = {
310 0x03f01200, 310 0x03f01200,
311 0x0002d000, 311 0x0002d000,
312 0x17f104bd, 312 0x17f104bd,
313 0x10fe04e6, 313 0x10fe04f8,
314 0x0007f100, 314 0x0007f100,
315 0x0003f007, 315 0x0003f007,
316 0xbd0000d0, 316 0xbd0000d0,
@@ -329,157 +329,157 @@ uint32_t gf100_grgpc_code[] = {
329 0xf0860027, 329 0xf0860027,
330 0x22cf0123, 330 0x22cf0123,
331 0x04028000, 331 0x04028000,
332 0x010027f1, 332 0xf10f24b6,
333 0xcf0223f0, 333 0xf0c90007,
334 0x34bd0022, 334 0x02d00103,
335 0xf1082595,
336 0xf0c00007,
337 0x05d00103,
338 0xf104bd00, 335 0xf104bd00,
339 0xf0c10007, 336 0xf0010027,
340 0x05d00103, 337 0x22cf0223,
341 0x9804bd00, 338 0x9534bd00,
342 0x0f98000e, 339 0x07f10825,
343 0x5021f501, 340 0x03f0c000,
344 0x002fbb01, 341 0x0005d001,
345 0x98003fbb, 342 0x07f104bd,
346 0x0f98010e, 343 0x03f0c100,
347 0x5021f502, 344 0x0005d001,
348 0x050e9801, 345 0x0e9804bd,
349 0xbb00effd, 346 0x010f9800,
350 0x3ebb002e, 347 0x015021f5,
351 0x0235b600, 348 0xbb002fbb,
352 0xd30007f1, 349 0x0e98003f,
353 0xd00103f0, 350 0x020f9801,
354 0x04bd0003, 351 0x015021f5,
355 0xb60825b6, 352 0xfd050e98,
356 0x20b60635, 353 0x2ebb00ef,
357 0x0130b601, 354 0x003ebb00,
358 0xb60824b6, 355 0xf10235b6,
359 0x2fb90834, 356 0xf0d30007,
360 0xd321f502, 357 0x03d00103,
361 0x003fbb02, 358 0xb604bd00,
362 0x010007f1, 359 0x35b60825,
360 0x0120b606,
361 0xb60130b6,
362 0x34b60824,
363 0x022fb908,
364 0x02d321f5,
365 0xbb002fbb,
366 0x07f1003f,
367 0x03f00100,
368 0x0003d002,
369 0x24bd04bd,
370 0xf11f29f0,
371 0xf0080007,
372 0x02d00203,
373/* 0x04bb: main */
374 0xf404bd00,
375 0x28f40031,
376 0x1cd7f000,
377 0xf43921f4,
378 0xe4b0f401,
379 0x1e18f404,
380 0xf00181fe,
381 0x20bd0627,
382 0xb60412fd,
383 0x1efd01e4,
384 0x0018fe05,
385 0x05b021f5,
386/* 0x04eb: main_not_ctx_xfer */
387 0x94d30ef4,
388 0xf5f010ef,
389 0x7e21f501,
390 0xc60ef403,
391/* 0x04f8: ih */
392 0x88fe80f9,
393 0xf980f901,
394 0xf9a0f990,
395 0xf9d0f9b0,
396 0xbdf0f9e0,
397 0x00a7f104,
398 0x00a3f002,
399 0xc400aacf,
400 0x0bf404ab,
401 0x1cd7f02c,
402 0x1a00e7f1,
403 0xcf00e3f0,
404 0xf7f100ee,
405 0xf3f01900,
406 0x00ffcf00,
407 0xf00421f4,
408 0x07f101e7,
409 0x03f01d00,
410 0x000ed000,
411/* 0x0546: ih_no_fifo */
412 0x07f104bd,
413 0x03f00100,
414 0x000ad000,
415 0xf0fc04bd,
416 0xd0fce0fc,
417 0xa0fcb0fc,
418 0x80fc90fc,
419 0xfc0088fe,
420 0x0032f480,
421/* 0x056a: hub_barrier_done */
422 0xf7f001f8,
423 0x040e9801,
424 0xb904febb,
425 0xe7f102ff,
426 0xe3f09418,
427 0x9d21f440,
428/* 0x0582: ctx_redswitch */
429 0xf7f000f8,
430 0x0007f120,
431 0x0103f085,
432 0xbd000fd0,
433 0x08e7f004,
434/* 0x0594: ctx_redswitch_delay */
435 0xf401e2b6,
436 0xf5f1fd1b,
437 0xf5f10800,
438 0x07f10200,
439 0x03f08500,
440 0x000fd001,
441 0x00f804bd,
442/* 0x05b0: ctx_xfer */
443 0x810007f1,
363 0xd00203f0, 444 0xd00203f0,
364 0x04bd0003,
365 0x29f024bd,
366 0x0007f11f,
367 0x0203f008,
368 0xbd0002d0,
369/* 0x04a9: main */
370 0x0031f404,
371 0xf00028f4,
372 0x21f41cd7,
373 0xf401f439,
374 0xf404e4b0,
375 0x81fe1e18,
376 0x0627f001,
377 0x12fd20bd,
378 0x01e4b604,
379 0xfe051efd,
380 0x21f50018,
381 0x0ef4059e,
382/* 0x04d9: main_not_ctx_xfer */
383 0x10ef94d3,
384 0xf501f5f0,
385 0xf4037e21,
386/* 0x04e6: ih */
387 0x80f9c60e,
388 0xf90188fe,
389 0xf990f980,
390 0xf9b0f9a0,
391 0xf9e0f9d0,
392 0xf104bdf0,
393 0xf00200a7,
394 0xaacf00a3,
395 0x04abc400,
396 0xf02c0bf4,
397 0xe7f11cd7,
398 0xe3f01a00,
399 0x00eecf00,
400 0x1900f7f1,
401 0xcf00f3f0,
402 0x21f400ff,
403 0x01e7f004,
404 0x1d0007f1,
405 0xd00003f0,
406 0x04bd000e,
407/* 0x0534: ih_no_fifo */
408 0x010007f1,
409 0xd00003f0,
410 0x04bd000a,
411 0xe0fcf0fc,
412 0xb0fcd0fc,
413 0x90fca0fc,
414 0x88fe80fc,
415 0xf480fc00,
416 0x01f80032,
417/* 0x0558: hub_barrier_done */
418 0x9801f7f0,
419 0xfebb040e,
420 0x02ffb904,
421 0x9418e7f1,
422 0xf440e3f0,
423 0x00f89d21,
424/* 0x0570: ctx_redswitch */
425 0xf120f7f0,
426 0xf0850007,
427 0x0fd00103,
428 0xf004bd00,
429/* 0x0582: ctx_redswitch_delay */
430 0xe2b608e7,
431 0xfd1bf401,
432 0x0800f5f1,
433 0x0200f5f1,
434 0x850007f1,
435 0xd00103f0,
436 0x04bd000f, 445 0x04bd000f,
437/* 0x059e: ctx_xfer */ 446 0xf50711f4,
438 0x07f100f8, 447/* 0x05c3: ctx_xfer_not_load */
439 0x03f08100, 448 0xf5058221,
440 0x000fd002, 449 0xbd026a21,
441 0x11f404bd, 450 0xfc07f124,
442 0x7021f507, 451 0x0203f047,
443/* 0x05b1: ctx_xfer_not_load */ 452 0xbd0002d0,
444 0x6a21f505, 453 0x012cf004,
445 0xf124bd02, 454 0xf10320b6,
446 0xf047fc07, 455 0xf04afc07,
447 0x02d00203, 456 0x02d00203,
448 0xf004bd00, 457 0xf004bd00,
449 0x20b6012c, 458 0xa5f001ac,
450 0xfc07f103, 459 0x00b7f102,
451 0x0203f04a, 460 0x50b3f000,
452 0xbd0002d0, 461 0xb6040c98,
453 0x01acf004, 462 0xbcbb0fc4,
454 0xf102a5f0, 463 0x000c9800,
455 0xf00000b7, 464 0xf0010d98,
456 0x0c9850b3, 465 0x21f500e7,
457 0x0fc4b604, 466 0xacf0016f,
458 0x9800bcbb, 467 0x04a5f001,
459 0x0d98000c, 468 0x4000b7f1,
460 0x00e7f001, 469 0x9850b3f0,
461 0x016f21f5, 470 0xc4b6040c,
462 0xf001acf0, 471 0x00bcbb0f,
463 0xb7f104a5, 472 0x98010c98,
464 0xb3f04000, 473 0x0f98020d,
465 0x040c9850, 474 0x00e7f106,
466 0xbb0fc4b6, 475 0x6f21f508,
467 0x0c9800bc, 476 0x5e21f501,
468 0x020d9801, 477 0x0601f402,
469 0xf1060f98, 478/* 0x063b: ctx_xfer_post */
470 0xf50800e7, 479 0xf50712f4,
471 0xf5016f21, 480/* 0x063f: ctx_xfer_done */
472 0xf4025e21, 481 0xf5027f21,
473 0x12f40601, 482 0xf8056a21,
474/* 0x0629: ctx_xfer_post */
475 0x7f21f507,
476/* 0x062d: ctx_xfer_done */
477 0x5821f502,
478 0x0000f805,
479 0x00000000,
480 0x00000000,
481 0x00000000,
482 0x00000000,
483 0x00000000, 483 0x00000000,
484 0x00000000, 484 0x00000000,
485 0x00000000, 485 0x00000000,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgf117.fuc3.h b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgf117.fuc3.h
index 9a36d9cbb8a5..64d07df4b8b1 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgf117.fuc3.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgf117.fuc3.h
@@ -314,7 +314,7 @@ uint32_t gf117_grgpc_code[] = {
314 0x03f01200, 314 0x03f01200,
315 0x0002d000, 315 0x0002d000,
316 0x17f104bd, 316 0x17f104bd,
317 0x10fe0530, 317 0x10fe0542,
318 0x0007f100, 318 0x0007f100,
319 0x0003f007, 319 0x0003f007,
320 0xbd0000d0, 320 0xbd0000d0,
@@ -333,188 +333,188 @@ uint32_t gf117_grgpc_code[] = {
333 0xf0860027, 333 0xf0860027,
334 0x22cf0123, 334 0x22cf0123,
335 0x04028000, 335 0x04028000,
336 0x0c30e7f1, 336 0xf10f24b6,
337 0xbd50e3f0, 337 0xf0c90007,
338 0xbd34bd24, 338 0x02d00103,
339/* 0x0421: init_unk_loop */
340 0x6821f444,
341 0xf400f6b0,
342 0xf7f00f0b,
343 0x04f2bb01,
344 0xb6054ffd,
345/* 0x0436: init_unk_next */
346 0x20b60130,
347 0x04e0b601,
348 0xf40126b0,
349/* 0x0442: init_unk_done */
350 0x0380e21b,
351 0x08048007,
352 0x010027f1,
353 0xcf0223f0,
354 0x34bd0022,
355 0xf1082595,
356 0xf0c00007,
357 0x05d00103,
358 0xf104bd00, 339 0xf104bd00,
359 0xf0c10007, 340 0xf00c30e7,
360 0x05d00103, 341 0x24bd50e3,
361 0x9804bd00, 342 0x44bd34bd,
362 0x0f98000e, 343/* 0x0430: init_unk_loop */
363 0x5021f501, 344 0xb06821f4,
364 0x002fbb01, 345 0x0bf400f6,
365 0x98003fbb, 346 0x01f7f00f,
366 0x0f98010e, 347 0xfd04f2bb,
367 0x5021f502, 348 0x30b6054f,
368 0x050e9801, 349/* 0x0445: init_unk_next */
369 0xbb00effd, 350 0x0120b601,
370 0x3ebb002e, 351 0xb004e0b6,
371 0x020e9800, 352 0x1bf40126,
372 0xf5030f98, 353/* 0x0451: init_unk_done */
373 0x98015021, 354 0x070380e2,
374 0xeffd070e, 355 0xf1080480,
375 0x002ebb00, 356 0xf0010027,
376 0xb6003ebb, 357 0x22cf0223,
377 0x07f10235, 358 0x9534bd00,
378 0x03f0d300, 359 0x07f10825,
379 0x0003d001, 360 0x03f0c000,
380 0x25b604bd, 361 0x0005d001,
381 0x0635b608,
382 0xb60120b6,
383 0x24b60130,
384 0x0834b608,
385 0xf5022fb9,
386 0xbb02d321,
387 0x07f1003f,
388 0x03f00100,
389 0x0003d002,
390 0x24bd04bd,
391 0xf11f29f0,
392 0xf0080007,
393 0x02d00203,
394/* 0x04f3: main */
395 0xf404bd00,
396 0x28f40031,
397 0x24d7f000,
398 0xf43921f4,
399 0xe4b0f401,
400 0x1e18f404,
401 0xf00181fe,
402 0x20bd0627,
403 0xb60412fd,
404 0x1efd01e4,
405 0x0018fe05,
406 0x05e821f5,
407/* 0x0523: main_not_ctx_xfer */
408 0x94d30ef4,
409 0xf5f010ef,
410 0x7e21f501,
411 0xc60ef403,
412/* 0x0530: ih */
413 0x88fe80f9,
414 0xf980f901,
415 0xf9a0f990,
416 0xf9d0f9b0,
417 0xbdf0f9e0,
418 0x00a7f104,
419 0x00a3f002,
420 0xc400aacf,
421 0x0bf404ab,
422 0x24d7f02c,
423 0x1a00e7f1,
424 0xcf00e3f0,
425 0xf7f100ee,
426 0xf3f01900,
427 0x00ffcf00,
428 0xf00421f4,
429 0x07f101e7,
430 0x03f01d00,
431 0x000ed000,
432/* 0x057e: ih_no_fifo */
433 0x07f104bd, 362 0x07f104bd,
434 0x03f00100, 363 0x03f0c100,
435 0x000ad000, 364 0x0005d001,
436 0xf0fc04bd, 365 0x0e9804bd,
437 0xd0fce0fc, 366 0x010f9800,
438 0xa0fcb0fc, 367 0x015021f5,
439 0x80fc90fc, 368 0xbb002fbb,
440 0xfc0088fe, 369 0x0e98003f,
441 0x0032f480, 370 0x020f9801,
442/* 0x05a2: hub_barrier_done */ 371 0x015021f5,
443 0xf7f001f8, 372 0xfd050e98,
444 0x040e9801, 373 0x2ebb00ef,
445 0xb904febb, 374 0x003ebb00,
446 0xe7f102ff, 375 0x98020e98,
447 0xe3f09418, 376 0x21f5030f,
448 0x9d21f440, 377 0x0e980150,
449/* 0x05ba: ctx_redswitch */ 378 0x00effd07,
450 0xf7f000f8, 379 0xbb002ebb,
451 0x0007f120, 380 0x35b6003e,
452 0x0103f085, 381 0x0007f102,
453 0xbd000fd0, 382 0x0103f0d3,
454 0x08e7f004, 383 0xbd0003d0,
455/* 0x05cc: ctx_redswitch_delay */ 384 0x0825b604,
456 0xf401e2b6, 385 0xb60635b6,
457 0xf5f1fd1b, 386 0x30b60120,
458 0xf5f10800, 387 0x0824b601,
459 0x07f10200, 388 0xb90834b6,
460 0x03f08500, 389 0x21f5022f,
461 0x000fd001, 390 0x2fbb02d3,
462 0x00f804bd, 391 0x003fbb00,
463/* 0x05e8: ctx_xfer */ 392 0x010007f1,
464 0x810007f1,
465 0xd00203f0, 393 0xd00203f0,
466 0x04bd000f, 394 0x04bd0003,
467 0xf50711f4, 395 0x29f024bd,
468/* 0x05fb: ctx_xfer_not_load */ 396 0x0007f11f,
469 0xf505ba21, 397 0x0203f008,
470 0xbd026a21,
471 0xfc07f124,
472 0x0203f047,
473 0xbd0002d0, 398 0xbd0002d0,
474 0x012cf004, 399/* 0x0505: main */
475 0xf10320b6, 400 0x0031f404,
476 0xf04afc07, 401 0xf00028f4,
402 0x21f424d7,
403 0xf401f439,
404 0xf404e4b0,
405 0x81fe1e18,
406 0x0627f001,
407 0x12fd20bd,
408 0x01e4b604,
409 0xfe051efd,
410 0x21f50018,
411 0x0ef405fa,
412/* 0x0535: main_not_ctx_xfer */
413 0x10ef94d3,
414 0xf501f5f0,
415 0xf4037e21,
416/* 0x0542: ih */
417 0x80f9c60e,
418 0xf90188fe,
419 0xf990f980,
420 0xf9b0f9a0,
421 0xf9e0f9d0,
422 0xf104bdf0,
423 0xf00200a7,
424 0xaacf00a3,
425 0x04abc400,
426 0xf02c0bf4,
427 0xe7f124d7,
428 0xe3f01a00,
429 0x00eecf00,
430 0x1900f7f1,
431 0xcf00f3f0,
432 0x21f400ff,
433 0x01e7f004,
434 0x1d0007f1,
435 0xd00003f0,
436 0x04bd000e,
437/* 0x0590: ih_no_fifo */
438 0x010007f1,
439 0xd00003f0,
440 0x04bd000a,
441 0xe0fcf0fc,
442 0xb0fcd0fc,
443 0x90fca0fc,
444 0x88fe80fc,
445 0xf480fc00,
446 0x01f80032,
447/* 0x05b4: hub_barrier_done */
448 0x9801f7f0,
449 0xfebb040e,
450 0x02ffb904,
451 0x9418e7f1,
452 0xf440e3f0,
453 0x00f89d21,
454/* 0x05cc: ctx_redswitch */
455 0xf120f7f0,
456 0xf0850007,
457 0x0fd00103,
458 0xf004bd00,
459/* 0x05de: ctx_redswitch_delay */
460 0xe2b608e7,
461 0xfd1bf401,
462 0x0800f5f1,
463 0x0200f5f1,
464 0x850007f1,
465 0xd00103f0,
466 0x04bd000f,
467/* 0x05fa: ctx_xfer */
468 0x07f100f8,
469 0x03f08100,
470 0x000fd002,
471 0x11f404bd,
472 0xcc21f507,
473/* 0x060d: ctx_xfer_not_load */
474 0x6a21f505,
475 0xf124bd02,
476 0xf047fc07,
477 0x02d00203, 477 0x02d00203,
478 0xf004bd00, 478 0xf004bd00,
479 0xa5f001ac, 479 0x20b6012c,
480 0x00b7f102, 480 0xfc07f103,
481 0x50b3f000, 481 0x0203f04a,
482 0xb6040c98, 482 0xbd0002d0,
483 0xbcbb0fc4, 483 0x01acf004,
484 0x000c9800, 484 0xf102a5f0,
485 0xf0010d98, 485 0xf00000b7,
486 0x21f500e7, 486 0x0c9850b3,
487 0xacf0016f, 487 0x0fc4b604,
488 0x00b7f101, 488 0x9800bcbb,
489 0x50b3f040, 489 0x0d98000c,
490 0xb6040c98, 490 0x00e7f001,
491 0xbcbb0fc4, 491 0x016f21f5,
492 0x010c9800, 492 0xf101acf0,
493 0x98020d98, 493 0xf04000b7,
494 0xe7f1060f, 494 0x0c9850b3,
495 0x21f50800, 495 0x0fc4b604,
496 0xacf0016f, 496 0x9800bcbb,
497 0x04a5f001, 497 0x0d98010c,
498 0x3000b7f1, 498 0x060f9802,
499 0x9850b3f0, 499 0x0800e7f1,
500 0xc4b6040c, 500 0x016f21f5,
501 0x00bcbb0f, 501 0xf001acf0,
502 0x98020c98, 502 0xb7f104a5,
503 0x0f98030d, 503 0xb3f03000,
504 0x00e7f108, 504 0x040c9850,
505 0x6f21f502, 505 0xbb0fc4b6,
506 0x5e21f501, 506 0x0c9800bc,
507 0x0601f402, 507 0x030d9802,
508/* 0x0697: ctx_xfer_post */ 508 0xf1080f98,
509 0xf50712f4, 509 0xf50200e7,
510/* 0x069b: ctx_xfer_done */ 510 0xf5016f21,
511 0xf5027f21, 511 0xf4025e21,
512 0xf805a221, 512 0x12f40601,
513 0x00000000, 513/* 0x06a9: ctx_xfer_post */
514 0x00000000, 514 0x7f21f507,
515 0x00000000, 515/* 0x06ad: ctx_xfer_done */
516 0x00000000, 516 0xb421f502,
517 0x00000000, 517 0x0000f805,
518 0x00000000, 518 0x00000000,
519 0x00000000, 519 0x00000000,
520 0x00000000, 520 0x00000000,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk104.fuc3.h b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk104.fuc3.h
index 49020fff4317..2f596433c222 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk104.fuc3.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk104.fuc3.h
@@ -314,7 +314,7 @@ uint32_t gk104_grgpc_code[] = {
314 0x03f01200, 314 0x03f01200,
315 0x0002d000, 315 0x0002d000,
316 0x17f104bd, 316 0x17f104bd,
317 0x10fe0530, 317 0x10fe0542,
318 0x0007f100, 318 0x0007f100,
319 0x0003f007, 319 0x0003f007,
320 0xbd0000d0, 320 0xbd0000d0,
@@ -333,188 +333,188 @@ uint32_t gk104_grgpc_code[] = {
333 0xf0860027, 333 0xf0860027,
334 0x22cf0123, 334 0x22cf0123,
335 0x04028000, 335 0x04028000,
336 0x0c30e7f1, 336 0xf10f24b6,
337 0xbd50e3f0, 337 0xf0c90007,
338 0xbd34bd24, 338 0x02d00103,
339/* 0x0421: init_unk_loop */
340 0x6821f444,
341 0xf400f6b0,
342 0xf7f00f0b,
343 0x04f2bb01,
344 0xb6054ffd,
345/* 0x0436: init_unk_next */
346 0x20b60130,
347 0x04e0b601,
348 0xf40126b0,
349/* 0x0442: init_unk_done */
350 0x0380e21b,
351 0x08048007,
352 0x010027f1,
353 0xcf0223f0,
354 0x34bd0022,
355 0xf1082595,
356 0xf0c00007,
357 0x05d00103,
358 0xf104bd00, 339 0xf104bd00,
359 0xf0c10007, 340 0xf00c30e7,
360 0x05d00103, 341 0x24bd50e3,
361 0x9804bd00, 342 0x44bd34bd,
362 0x0f98000e, 343/* 0x0430: init_unk_loop */
363 0x5021f501, 344 0xb06821f4,
364 0x002fbb01, 345 0x0bf400f6,
365 0x98003fbb, 346 0x01f7f00f,
366 0x0f98010e, 347 0xfd04f2bb,
367 0x5021f502, 348 0x30b6054f,
368 0x050e9801, 349/* 0x0445: init_unk_next */
369 0xbb00effd, 350 0x0120b601,
370 0x3ebb002e, 351 0xb004e0b6,
371 0x020e9800, 352 0x1bf40126,
372 0xf5030f98, 353/* 0x0451: init_unk_done */
373 0x98015021, 354 0x070380e2,
374 0xeffd070e, 355 0xf1080480,
375 0x002ebb00, 356 0xf0010027,
376 0xb6003ebb, 357 0x22cf0223,
377 0x07f10235, 358 0x9534bd00,
378 0x03f0d300, 359 0x07f10825,
379 0x0003d001, 360 0x03f0c000,
380 0x25b604bd, 361 0x0005d001,
381 0x0635b608,
382 0xb60120b6,
383 0x24b60130,
384 0x0834b608,
385 0xf5022fb9,
386 0xbb02d321,
387 0x07f1003f,
388 0x03f00100,
389 0x0003d002,
390 0x24bd04bd,
391 0xf11f29f0,
392 0xf0080007,
393 0x02d00203,
394/* 0x04f3: main */
395 0xf404bd00,
396 0x28f40031,
397 0x24d7f000,
398 0xf43921f4,
399 0xe4b0f401,
400 0x1e18f404,
401 0xf00181fe,
402 0x20bd0627,
403 0xb60412fd,
404 0x1efd01e4,
405 0x0018fe05,
406 0x05e821f5,
407/* 0x0523: main_not_ctx_xfer */
408 0x94d30ef4,
409 0xf5f010ef,
410 0x7e21f501,
411 0xc60ef403,
412/* 0x0530: ih */
413 0x88fe80f9,
414 0xf980f901,
415 0xf9a0f990,
416 0xf9d0f9b0,
417 0xbdf0f9e0,
418 0x00a7f104,
419 0x00a3f002,
420 0xc400aacf,
421 0x0bf404ab,
422 0x24d7f02c,
423 0x1a00e7f1,
424 0xcf00e3f0,
425 0xf7f100ee,
426 0xf3f01900,
427 0x00ffcf00,
428 0xf00421f4,
429 0x07f101e7,
430 0x03f01d00,
431 0x000ed000,
432/* 0x057e: ih_no_fifo */
433 0x07f104bd, 362 0x07f104bd,
434 0x03f00100, 363 0x03f0c100,
435 0x000ad000, 364 0x0005d001,
436 0xf0fc04bd, 365 0x0e9804bd,
437 0xd0fce0fc, 366 0x010f9800,
438 0xa0fcb0fc, 367 0x015021f5,
439 0x80fc90fc, 368 0xbb002fbb,
440 0xfc0088fe, 369 0x0e98003f,
441 0x0032f480, 370 0x020f9801,
442/* 0x05a2: hub_barrier_done */ 371 0x015021f5,
443 0xf7f001f8, 372 0xfd050e98,
444 0x040e9801, 373 0x2ebb00ef,
445 0xb904febb, 374 0x003ebb00,
446 0xe7f102ff, 375 0x98020e98,
447 0xe3f09418, 376 0x21f5030f,
448 0x9d21f440, 377 0x0e980150,
449/* 0x05ba: ctx_redswitch */ 378 0x00effd07,
450 0xf7f000f8, 379 0xbb002ebb,
451 0x0007f120, 380 0x35b6003e,
452 0x0103f085, 381 0x0007f102,
453 0xbd000fd0, 382 0x0103f0d3,
454 0x08e7f004, 383 0xbd0003d0,
455/* 0x05cc: ctx_redswitch_delay */ 384 0x0825b604,
456 0xf401e2b6, 385 0xb60635b6,
457 0xf5f1fd1b, 386 0x30b60120,
458 0xf5f10800, 387 0x0824b601,
459 0x07f10200, 388 0xb90834b6,
460 0x03f08500, 389 0x21f5022f,
461 0x000fd001, 390 0x2fbb02d3,
462 0x00f804bd, 391 0x003fbb00,
463/* 0x05e8: ctx_xfer */ 392 0x010007f1,
464 0x810007f1,
465 0xd00203f0, 393 0xd00203f0,
466 0x04bd000f, 394 0x04bd0003,
467 0xf50711f4, 395 0x29f024bd,
468/* 0x05fb: ctx_xfer_not_load */ 396 0x0007f11f,
469 0xf505ba21, 397 0x0203f008,
470 0xbd026a21,
471 0xfc07f124,
472 0x0203f047,
473 0xbd0002d0, 398 0xbd0002d0,
474 0x012cf004, 399/* 0x0505: main */
475 0xf10320b6, 400 0x0031f404,
476 0xf04afc07, 401 0xf00028f4,
402 0x21f424d7,
403 0xf401f439,
404 0xf404e4b0,
405 0x81fe1e18,
406 0x0627f001,
407 0x12fd20bd,
408 0x01e4b604,
409 0xfe051efd,
410 0x21f50018,
411 0x0ef405fa,
412/* 0x0535: main_not_ctx_xfer */
413 0x10ef94d3,
414 0xf501f5f0,
415 0xf4037e21,
416/* 0x0542: ih */
417 0x80f9c60e,
418 0xf90188fe,
419 0xf990f980,
420 0xf9b0f9a0,
421 0xf9e0f9d0,
422 0xf104bdf0,
423 0xf00200a7,
424 0xaacf00a3,
425 0x04abc400,
426 0xf02c0bf4,
427 0xe7f124d7,
428 0xe3f01a00,
429 0x00eecf00,
430 0x1900f7f1,
431 0xcf00f3f0,
432 0x21f400ff,
433 0x01e7f004,
434 0x1d0007f1,
435 0xd00003f0,
436 0x04bd000e,
437/* 0x0590: ih_no_fifo */
438 0x010007f1,
439 0xd00003f0,
440 0x04bd000a,
441 0xe0fcf0fc,
442 0xb0fcd0fc,
443 0x90fca0fc,
444 0x88fe80fc,
445 0xf480fc00,
446 0x01f80032,
447/* 0x05b4: hub_barrier_done */
448 0x9801f7f0,
449 0xfebb040e,
450 0x02ffb904,
451 0x9418e7f1,
452 0xf440e3f0,
453 0x00f89d21,
454/* 0x05cc: ctx_redswitch */
455 0xf120f7f0,
456 0xf0850007,
457 0x0fd00103,
458 0xf004bd00,
459/* 0x05de: ctx_redswitch_delay */
460 0xe2b608e7,
461 0xfd1bf401,
462 0x0800f5f1,
463 0x0200f5f1,
464 0x850007f1,
465 0xd00103f0,
466 0x04bd000f,
467/* 0x05fa: ctx_xfer */
468 0x07f100f8,
469 0x03f08100,
470 0x000fd002,
471 0x11f404bd,
472 0xcc21f507,
473/* 0x060d: ctx_xfer_not_load */
474 0x6a21f505,
475 0xf124bd02,
476 0xf047fc07,
477 0x02d00203, 477 0x02d00203,
478 0xf004bd00, 478 0xf004bd00,
479 0xa5f001ac, 479 0x20b6012c,
480 0x00b7f102, 480 0xfc07f103,
481 0x50b3f000, 481 0x0203f04a,
482 0xb6040c98, 482 0xbd0002d0,
483 0xbcbb0fc4, 483 0x01acf004,
484 0x000c9800, 484 0xf102a5f0,
485 0xf0010d98, 485 0xf00000b7,
486 0x21f500e7, 486 0x0c9850b3,
487 0xacf0016f, 487 0x0fc4b604,
488 0x00b7f101, 488 0x9800bcbb,
489 0x50b3f040, 489 0x0d98000c,
490 0xb6040c98, 490 0x00e7f001,
491 0xbcbb0fc4, 491 0x016f21f5,
492 0x010c9800, 492 0xf101acf0,
493 0x98020d98, 493 0xf04000b7,
494 0xe7f1060f, 494 0x0c9850b3,
495 0x21f50800, 495 0x0fc4b604,
496 0xacf0016f, 496 0x9800bcbb,
497 0x04a5f001, 497 0x0d98010c,
498 0x3000b7f1, 498 0x060f9802,
499 0x9850b3f0, 499 0x0800e7f1,
500 0xc4b6040c, 500 0x016f21f5,
501 0x00bcbb0f, 501 0xf001acf0,
502 0x98020c98, 502 0xb7f104a5,
503 0x0f98030d, 503 0xb3f03000,
504 0x00e7f108, 504 0x040c9850,
505 0x6f21f502, 505 0xbb0fc4b6,
506 0x5e21f501, 506 0x0c9800bc,
507 0x0601f402, 507 0x030d9802,
508/* 0x0697: ctx_xfer_post */ 508 0xf1080f98,
509 0xf50712f4, 509 0xf50200e7,
510/* 0x069b: ctx_xfer_done */ 510 0xf5016f21,
511 0xf5027f21, 511 0xf4025e21,
512 0xf805a221, 512 0x12f40601,
513 0x00000000, 513/* 0x06a9: ctx_xfer_post */
514 0x00000000, 514 0x7f21f507,
515 0x00000000, 515/* 0x06ad: ctx_xfer_done */
516 0x00000000, 516 0xb421f502,
517 0x00000000, 517 0x0000f805,
518 0x00000000, 518 0x00000000,
519 0x00000000, 519 0x00000000,
520 0x00000000, 520 0x00000000,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk110.fuc3.h b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk110.fuc3.h
index c95b07e3bce5..ee8e54db8fc9 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk110.fuc3.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk110.fuc3.h
@@ -314,7 +314,7 @@ uint32_t gk110_grgpc_code[] = {
314 0x03f01200, 314 0x03f01200,
315 0x0002d000, 315 0x0002d000,
316 0x17f104bd, 316 0x17f104bd,
317 0x10fe0530, 317 0x10fe0542,
318 0x0007f100, 318 0x0007f100,
319 0x0003f007, 319 0x0003f007,
320 0xbd0000d0, 320 0xbd0000d0,
@@ -333,188 +333,188 @@ uint32_t gk110_grgpc_code[] = {
333 0xf0860027, 333 0xf0860027,
334 0x22cf0123, 334 0x22cf0123,
335 0x04028000, 335 0x04028000,
336 0x0c30e7f1, 336 0xf10f24b6,
337 0xbd50e3f0, 337 0xf0c90007,
338 0xbd34bd24, 338 0x02d00103,
339/* 0x0421: init_unk_loop */
340 0x6821f444,
341 0xf400f6b0,
342 0xf7f00f0b,
343 0x04f2bb01,
344 0xb6054ffd,
345/* 0x0436: init_unk_next */
346 0x20b60130,
347 0x04e0b601,
348 0xf40226b0,
349/* 0x0442: init_unk_done */
350 0x0380e21b,
351 0x08048007,
352 0x010027f1,
353 0xcf0223f0,
354 0x34bd0022,
355 0xf1082595,
356 0xf0c00007,
357 0x05d00103,
358 0xf104bd00, 339 0xf104bd00,
359 0xf0c10007, 340 0xf00c30e7,
360 0x05d00103, 341 0x24bd50e3,
361 0x9804bd00, 342 0x44bd34bd,
362 0x0f98000e, 343/* 0x0430: init_unk_loop */
363 0x5021f501, 344 0xb06821f4,
364 0x002fbb01, 345 0x0bf400f6,
365 0x98003fbb, 346 0x01f7f00f,
366 0x0f98010e, 347 0xfd04f2bb,
367 0x5021f502, 348 0x30b6054f,
368 0x050e9801, 349/* 0x0445: init_unk_next */
369 0xbb00effd, 350 0x0120b601,
370 0x3ebb002e, 351 0xb004e0b6,
371 0x020e9800, 352 0x1bf40226,
372 0xf5030f98, 353/* 0x0451: init_unk_done */
373 0x98015021, 354 0x070380e2,
374 0xeffd070e, 355 0xf1080480,
375 0x002ebb00, 356 0xf0010027,
376 0xb6003ebb, 357 0x22cf0223,
377 0x07f10235, 358 0x9534bd00,
378 0x03f0d300, 359 0x07f10825,
379 0x0003d001, 360 0x03f0c000,
380 0x25b604bd, 361 0x0005d001,
381 0x0635b608,
382 0xb60120b6,
383 0x24b60130,
384 0x0834b608,
385 0xf5022fb9,
386 0xbb02d321,
387 0x07f1003f,
388 0x03f00100,
389 0x0003d002,
390 0x24bd04bd,
391 0xf11f29f0,
392 0xf0300007,
393 0x02d00203,
394/* 0x04f3: main */
395 0xf404bd00,
396 0x28f40031,
397 0x24d7f000,
398 0xf43921f4,
399 0xe4b0f401,
400 0x1e18f404,
401 0xf00181fe,
402 0x20bd0627,
403 0xb60412fd,
404 0x1efd01e4,
405 0x0018fe05,
406 0x05e821f5,
407/* 0x0523: main_not_ctx_xfer */
408 0x94d30ef4,
409 0xf5f010ef,
410 0x7e21f501,
411 0xc60ef403,
412/* 0x0530: ih */
413 0x88fe80f9,
414 0xf980f901,
415 0xf9a0f990,
416 0xf9d0f9b0,
417 0xbdf0f9e0,
418 0x00a7f104,
419 0x00a3f002,
420 0xc400aacf,
421 0x0bf404ab,
422 0x24d7f02c,
423 0x1a00e7f1,
424 0xcf00e3f0,
425 0xf7f100ee,
426 0xf3f01900,
427 0x00ffcf00,
428 0xf00421f4,
429 0x07f101e7,
430 0x03f01d00,
431 0x000ed000,
432/* 0x057e: ih_no_fifo */
433 0x07f104bd, 362 0x07f104bd,
434 0x03f00100, 363 0x03f0c100,
435 0x000ad000, 364 0x0005d001,
436 0xf0fc04bd, 365 0x0e9804bd,
437 0xd0fce0fc, 366 0x010f9800,
438 0xa0fcb0fc, 367 0x015021f5,
439 0x80fc90fc, 368 0xbb002fbb,
440 0xfc0088fe, 369 0x0e98003f,
441 0x0032f480, 370 0x020f9801,
442/* 0x05a2: hub_barrier_done */ 371 0x015021f5,
443 0xf7f001f8, 372 0xfd050e98,
444 0x040e9801, 373 0x2ebb00ef,
445 0xb904febb, 374 0x003ebb00,
446 0xe7f102ff, 375 0x98020e98,
447 0xe3f09418, 376 0x21f5030f,
448 0x9d21f440, 377 0x0e980150,
449/* 0x05ba: ctx_redswitch */ 378 0x00effd07,
450 0xf7f000f8, 379 0xbb002ebb,
451 0x0007f120, 380 0x35b6003e,
452 0x0103f085, 381 0x0007f102,
453 0xbd000fd0, 382 0x0103f0d3,
454 0x08e7f004, 383 0xbd0003d0,
455/* 0x05cc: ctx_redswitch_delay */ 384 0x0825b604,
456 0xf401e2b6, 385 0xb60635b6,
457 0xf5f1fd1b, 386 0x30b60120,
458 0xf5f10800, 387 0x0824b601,
459 0x07f10200, 388 0xb90834b6,
460 0x03f08500, 389 0x21f5022f,
461 0x000fd001, 390 0x2fbb02d3,
462 0x00f804bd, 391 0x003fbb00,
463/* 0x05e8: ctx_xfer */ 392 0x010007f1,
464 0x810007f1,
465 0xd00203f0, 393 0xd00203f0,
466 0x04bd000f, 394 0x04bd0003,
467 0xf50711f4, 395 0x29f024bd,
468/* 0x05fb: ctx_xfer_not_load */ 396 0x0007f11f,
469 0xf505ba21, 397 0x0203f030,
470 0xbd026a21,
471 0xfc07f124,
472 0x0203f047,
473 0xbd0002d0, 398 0xbd0002d0,
474 0x012cf004, 399/* 0x0505: main */
475 0xf10320b6, 400 0x0031f404,
476 0xf04afc07, 401 0xf00028f4,
402 0x21f424d7,
403 0xf401f439,
404 0xf404e4b0,
405 0x81fe1e18,
406 0x0627f001,
407 0x12fd20bd,
408 0x01e4b604,
409 0xfe051efd,
410 0x21f50018,
411 0x0ef405fa,
412/* 0x0535: main_not_ctx_xfer */
413 0x10ef94d3,
414 0xf501f5f0,
415 0xf4037e21,
416/* 0x0542: ih */
417 0x80f9c60e,
418 0xf90188fe,
419 0xf990f980,
420 0xf9b0f9a0,
421 0xf9e0f9d0,
422 0xf104bdf0,
423 0xf00200a7,
424 0xaacf00a3,
425 0x04abc400,
426 0xf02c0bf4,
427 0xe7f124d7,
428 0xe3f01a00,
429 0x00eecf00,
430 0x1900f7f1,
431 0xcf00f3f0,
432 0x21f400ff,
433 0x01e7f004,
434 0x1d0007f1,
435 0xd00003f0,
436 0x04bd000e,
437/* 0x0590: ih_no_fifo */
438 0x010007f1,
439 0xd00003f0,
440 0x04bd000a,
441 0xe0fcf0fc,
442 0xb0fcd0fc,
443 0x90fca0fc,
444 0x88fe80fc,
445 0xf480fc00,
446 0x01f80032,
447/* 0x05b4: hub_barrier_done */
448 0x9801f7f0,
449 0xfebb040e,
450 0x02ffb904,
451 0x9418e7f1,
452 0xf440e3f0,
453 0x00f89d21,
454/* 0x05cc: ctx_redswitch */
455 0xf120f7f0,
456 0xf0850007,
457 0x0fd00103,
458 0xf004bd00,
459/* 0x05de: ctx_redswitch_delay */
460 0xe2b608e7,
461 0xfd1bf401,
462 0x0800f5f1,
463 0x0200f5f1,
464 0x850007f1,
465 0xd00103f0,
466 0x04bd000f,
467/* 0x05fa: ctx_xfer */
468 0x07f100f8,
469 0x03f08100,
470 0x000fd002,
471 0x11f404bd,
472 0xcc21f507,
473/* 0x060d: ctx_xfer_not_load */
474 0x6a21f505,
475 0xf124bd02,
476 0xf047fc07,
477 0x02d00203, 477 0x02d00203,
478 0xf004bd00, 478 0xf004bd00,
479 0xa5f001ac, 479 0x20b6012c,
480 0x00b7f102, 480 0xfc07f103,
481 0x50b3f000, 481 0x0203f04a,
482 0xb6040c98, 482 0xbd0002d0,
483 0xbcbb0fc4, 483 0x01acf004,
484 0x000c9800, 484 0xf102a5f0,
485 0xf0010d98, 485 0xf00000b7,
486 0x21f500e7, 486 0x0c9850b3,
487 0xacf0016f, 487 0x0fc4b604,
488 0x00b7f101, 488 0x9800bcbb,
489 0x50b3f040, 489 0x0d98000c,
490 0xb6040c98, 490 0x00e7f001,
491 0xbcbb0fc4, 491 0x016f21f5,
492 0x010c9800, 492 0xf101acf0,
493 0x98020d98, 493 0xf04000b7,
494 0xe7f1060f, 494 0x0c9850b3,
495 0x21f50800, 495 0x0fc4b604,
496 0xacf0016f, 496 0x9800bcbb,
497 0x04a5f001, 497 0x0d98010c,
498 0x3000b7f1, 498 0x060f9802,
499 0x9850b3f0, 499 0x0800e7f1,
500 0xc4b6040c, 500 0x016f21f5,
501 0x00bcbb0f, 501 0xf001acf0,
502 0x98020c98, 502 0xb7f104a5,
503 0x0f98030d, 503 0xb3f03000,
504 0x00e7f108, 504 0x040c9850,
505 0x6f21f502, 505 0xbb0fc4b6,
506 0x5e21f501, 506 0x0c9800bc,
507 0x0601f402, 507 0x030d9802,
508/* 0x0697: ctx_xfer_post */ 508 0xf1080f98,
509 0xf50712f4, 509 0xf50200e7,
510/* 0x069b: ctx_xfer_done */ 510 0xf5016f21,
511 0xf5027f21, 511 0xf4025e21,
512 0xf805a221, 512 0x12f40601,
513 0x00000000, 513/* 0x06a9: ctx_xfer_post */
514 0x00000000, 514 0x7f21f507,
515 0x00000000, 515/* 0x06ad: ctx_xfer_done */
516 0x00000000, 516 0xb421f502,
517 0x00000000, 517 0x0000f805,
518 0x00000000, 518 0x00000000,
519 0x00000000, 519 0x00000000,
520 0x00000000, 520 0x00000000,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk208.fuc5.h b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk208.fuc5.h
index 7e1c28ee7591..fbcc342f896f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk208.fuc5.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk208.fuc5.h
@@ -276,7 +276,7 @@ uint32_t gk208_grgpc_code[] = {
276 0x02020014, 276 0x02020014,
277 0xf6120040, 277 0xf6120040,
278 0x04bd0002, 278 0x04bd0002,
279 0xfe047241, 279 0xfe048141,
280 0x00400010, 280 0x00400010,
281 0x0000f607, 281 0x0000f607,
282 0x040204bd, 282 0x040204bd,
@@ -291,20 +291,23 @@ uint32_t gk208_grgpc_code[] = {
291 0x820603b5, 291 0x820603b5,
292 0xcf018600, 292 0xcf018600,
293 0x02b50022, 293 0x02b50022,
294 0x0f24b604,
295 0x01c90080,
296 0xbd0002f6,
294 0x0c308e04, 297 0x0c308e04,
295 0xbd24bd50, 298 0xbd24bd50,
296/* 0x0377: init_unk_loop */ 299/* 0x0383: init_unk_loop */
297 0x7e44bd34, 300 0x7e44bd34,
298 0xb0000065, 301 0xb0000065,
299 0x0bf400f6, 302 0x0bf400f6,
300 0xbb010f0e, 303 0xbb010f0e,
301 0x4ffd04f2, 304 0x4ffd04f2,
302 0x0130b605, 305 0x0130b605,
303/* 0x038c: init_unk_next */ 306/* 0x0398: init_unk_next */
304 0xb60120b6, 307 0xb60120b6,
305 0x26b004e0, 308 0x26b004e0,
306 0xe21bf401, 309 0xe21bf401,
307/* 0x0398: init_unk_done */ 310/* 0x03a4: init_unk_done */
308 0xb50703b5, 311 0xb50703b5,
309 0x00820804, 312 0x00820804,
310 0x22cf0201, 313 0x22cf0201,
@@ -338,121 +341,118 @@ uint32_t gk208_grgpc_code[] = {
338 0xb60824b6, 341 0xb60824b6,
339 0x2fb20834, 342 0x2fb20834,
340 0x0002687e, 343 0x0002687e,
341 0x80003fbb, 344 0xbb002fbb,
342 0xf6020100, 345 0x0080003f,
343 0x04bd0003, 346 0x03f60201,
344 0x29f024bd, 347 0xbd04bd00,
345 0x3000801f, 348 0x1f29f024,
346 0x0002f602, 349 0x02300080,
347/* 0x0436: main */ 350 0xbd0002f6,
348 0x31f404bd, 351/* 0x0445: main */
349 0x0028f400, 352 0x0031f404,
350 0x377e240d, 353 0x0d0028f4,
351 0x01f40000, 354 0x00377e24,
352 0x04e4b0f4, 355 0xf401f400,
353 0xfe1d18f4, 356 0xf404e4b0,
354 0x06020181, 357 0x81fe1d18,
355 0x12fd20bd, 358 0xbd060201,
356 0x01e4b604, 359 0x0412fd20,
357 0xfe051efd, 360 0xfd01e4b6,
358 0x097e0018, 361 0x18fe051e,
359 0x0ef40005, 362 0x05187e00,
360/* 0x0465: main_not_ctx_xfer */ 363 0xd40ef400,
361 0x10ef94d4, 364/* 0x0474: main_not_ctx_xfer */
362 0x7e01f5f0, 365 0xf010ef94,
363 0xf40002f8, 366 0xf87e01f5,
364/* 0x0472: ih */ 367 0x0ef40002,
365 0x80f9c70e, 368/* 0x0481: ih */
366 0xf90188fe, 369 0xfe80f9c7,
367 0xf990f980, 370 0x80f90188,
368 0xf9b0f9a0, 371 0xa0f990f9,
369 0xf9e0f9d0, 372 0xd0f9b0f9,
370 0x4a04bdf0, 373 0xf0f9e0f9,
371 0xaacf0200, 374 0x004a04bd,
372 0x04abc400, 375 0x00aacf02,
373 0x0d1f0bf4, 376 0xf404abc4,
374 0x1a004e24, 377 0x240d1f0b,
375 0x4f00eecf, 378 0xcf1a004e,
376 0xffcf1900, 379 0x004f00ee,
377 0x00047e00, 380 0x00ffcf19,
378 0x40010e00, 381 0x0000047e,
379 0x0ef61d00, 382 0x0040010e,
380/* 0x04af: ih_no_fifo */ 383 0x000ef61d,
381 0x4004bd00, 384/* 0x04be: ih_no_fifo */
382 0x0af60100, 385 0x004004bd,
383 0xfc04bd00, 386 0x000af601,
384 0xfce0fcf0, 387 0xf0fc04bd,
385 0xfcb0fcd0, 388 0xd0fce0fc,
386 0xfc90fca0, 389 0xa0fcb0fc,
387 0x0088fe80, 390 0x80fc90fc,
388 0x32f480fc, 391 0xfc0088fe,
389/* 0x04cf: hub_barrier_done */ 392 0x0032f480,
390 0x0f01f800, 393/* 0x04de: hub_barrier_done */
391 0x040e9801, 394 0x010f01f8,
392 0xb204febb, 395 0xbb040e98,
393 0x94188eff, 396 0xffb204fe,
394 0x008f7e40, 397 0x4094188e,
395/* 0x04e3: ctx_redswitch */ 398 0x00008f7e,
396 0x0f00f800, 399/* 0x04f2: ctx_redswitch */
397 0x85008020, 400 0x200f00f8,
401 0x01850080,
402 0xbd000ff6,
403/* 0x04ff: ctx_redswitch_delay */
404 0xb6080e04,
405 0x1bf401e2,
406 0x00f5f1fd,
407 0x00f5f108,
408 0x85008002,
398 0x000ff601, 409 0x000ff601,
399 0x080e04bd, 410 0x00f804bd,
400/* 0x04f0: ctx_redswitch_delay */ 411/* 0x0518: ctx_xfer */
401 0xf401e2b6, 412 0x02810080,
402 0xf5f1fd1b, 413 0xbd000ff6,
403 0xf5f10800, 414 0x0711f404,
404 0x00800200, 415 0x0004f27e,
405 0x0ff60185, 416/* 0x0528: ctx_xfer_not_load */
406 0xf804bd00, 417 0x0002167e,
407/* 0x0509: ctx_xfer */ 418 0xfc8024bd,
408 0x81008000, 419 0x02f60247,
409 0x000ff602,
410 0x11f404bd,
411 0x04e37e07,
412/* 0x0519: ctx_xfer_not_load */
413 0x02167e00,
414 0x8024bd00,
415 0xf60247fc,
416 0x04bd0002,
417 0xb6012cf0,
418 0xfc800320,
419 0x02f6024a,
420 0xf004bd00, 420 0xf004bd00,
421 0xa5f001ac, 421 0x20b6012c,
422 0x00008b02, 422 0x4afc8003,
423 0x040c9850, 423 0x0002f602,
424 0xbb0fc4b6, 424 0xacf004bd,
425 0x0c9800bc, 425 0x02a5f001,
426 0x010d9800, 426 0x5000008b,
427 0x3d7e000e,
428 0xacf00001,
429 0x40008b01,
430 0x040c9850,
431 0xbb0fc4b6,
432 0x0c9800bc,
433 0x020d9801,
434 0x4e060f98,
435 0x3d7e0800,
436 0xacf00001,
437 0x04a5f001,
438 0x5030008b,
439 0xb6040c98, 427 0xb6040c98,
440 0xbcbb0fc4, 428 0xbcbb0fc4,
441 0x020c9800, 429 0x000c9800,
442 0x98030d98, 430 0x0e010d98,
443 0x004e080f, 431 0x013d7e00,
444 0x013d7e02, 432 0x01acf000,
445 0x020a7e00, 433 0x5040008b,
446 0x0601f400, 434 0xb6040c98,
447/* 0x05a3: ctx_xfer_post */ 435 0xbcbb0fc4,
448 0x7e0712f4, 436 0x010c9800,
449/* 0x05a7: ctx_xfer_done */ 437 0x98020d98,
450 0x7e000227, 438 0x004e060f,
451 0xf80004cf, 439 0x013d7e08,
452 0x00000000, 440 0x01acf000,
453 0x00000000, 441 0x8b04a5f0,
454 0x00000000, 442 0x98503000,
455 0x00000000, 443 0xc4b6040c,
444 0x00bcbb0f,
445 0x98020c98,
446 0x0f98030d,
447 0x02004e08,
448 0x00013d7e,
449 0x00020a7e,
450 0xf40601f4,
451/* 0x05b2: ctx_xfer_post */
452 0x277e0712,
453/* 0x05b6: ctx_xfer_done */
454 0xde7e0002,
455 0x00f80004,
456 0x00000000, 456 0x00000000,
457 0x00000000, 457 0x00000000,
458 0x00000000, 458 0x00000000,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgm107.fuc5 b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgm107.fuc5
index e730603891d7..47802c7ecca1 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgm107.fuc5
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgm107.fuc5
@@ -24,7 +24,7 @@
24 24
25#define NV_PGRAPH_GPCX_UNK__SIZE 0x00000002 25#define NV_PGRAPH_GPCX_UNK__SIZE 0x00000002
26 26
27#define CHIPSET GK208 27#define CHIPSET GM107
28#include "macros.fuc" 28#include "macros.fuc"
29 29
30.section #gm107_grgpc_data 30.section #gm107_grgpc_data
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgm107.fuc5.h b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgm107.fuc5.h
index 6d53b67dd3c4..51f5c3c6e966 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgm107.fuc5.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgm107.fuc5.h
@@ -41,7 +41,7 @@ uint32_t gm107_grgpc_data[] = {
41}; 41};
42 42
43uint32_t gm107_grgpc_code[] = { 43uint32_t gm107_grgpc_code[] = {
44 0x03140ef5, 44 0x03410ef5,
45/* 0x0004: queue_put */ 45/* 0x0004: queue_put */
46 0x9800d898, 46 0x9800d898,
47 0x86f001d9, 47 0x86f001d9,
@@ -268,187 +268,319 @@ uint32_t gm107_grgpc_code[] = {
268 0x409c1c8e, 268 0x409c1c8e,
269 0x00008f7e, 269 0x00008f7e,
270 0x00f8e0fc, 270 0x00f8e0fc,
271/* 0x0314: init */ 271/* 0x0314: tpc_strand_wait */
272 0x004104bd, 272 0x94bd90f9,
273 0x0011cf42, 273 0x800a99f0,
274 0x010911e7, 274 0xf6023700,
275 0xfe0814b6, 275 0x04bd0009,
276 0x02020014, 276/* 0x0324: tpc_strand_busy */
277 0xf6120040, 277 0x033f0089,
278 0x04bd0002, 278 0xb30099cf,
279 0xfe047241, 279 0xbdf90094,
280 0x00400010, 280 0x0a99f094,
281 0x0000f607, 281 0x02170080,
282 0x040204bd, 282 0xbd0009f6,
283 0xf6040040, 283 0xf890fc04,
284 0x04bd0002, 284/* 0x0341: init */
285 0x821031f4, 285 0x4104bd00,
286 0xcf018200, 286 0x11cf4200,
287 0x01030022, 287 0x0911e700,
288 0xbb1f24f0, 288 0x0814b601,
289 0x32b60432, 289 0x020014fe,
290 0x0502b501, 290 0x12004002,
291 0x820603b5, 291 0xbd0002f6,
292 0xcf018600, 292 0x05b04104,
293 0x02b50022, 293 0x400010fe,
294 0x0c308e04, 294 0x00f60700,
295 0xbd24bd50, 295 0x0204bd00,
296/* 0x0377: init_unk_loop */ 296 0x04004004,
297 0x7e44bd34, 297 0xbd0002f6,
298 0xb0000065, 298 0x1031f404,
299 0x0bf400f6, 299 0x01820082,
300 0xbb010f0e, 300 0x030022cf,
301 0x4ffd04f2, 301 0x1f24f001,
302 0x0130b605, 302 0xb60432bb,
303/* 0x038c: init_unk_next */ 303 0x02b50132,
304 0xb60120b6, 304 0x0603b505,
305 0x26b004e0, 305 0x01860082,
306 0xe21bf402, 306 0xb50022cf,
307/* 0x0398: init_unk_done */ 307 0x24b60402,
308 0xb50703b5, 308 0xc900800f,
309 0x00820804, 309 0x0002f601,
310 0x22cf0201, 310 0x308e04bd,
311 0x9534bd00, 311 0x24bd500c,
312 0x00800825, 312 0x44bd34bd,
313 0x05f601c0, 313/* 0x03b0: init_unk_loop */
314 0x8004bd00, 314 0x0000657e,
315 0xf601c100, 315 0xf400f6b0,
316 0x010f0e0b,
317 0xfd04f2bb,
318 0x30b6054f,
319/* 0x03c5: init_unk_next */
320 0x0120b601,
321 0xb004e0b6,
322 0x1bf40226,
323/* 0x03d1: init_unk_done */
324 0x0703b5e2,
325 0x820804b5,
326 0xcf020100,
327 0x34bd0022,
328 0x80082595,
329 0xf601c000,
316 0x04bd0005, 330 0x04bd0005,
317 0x98000e98, 331 0x01c10080,
318 0x207e010f, 332 0xbd0005f6,
319 0x2fbb0001, 333 0x000e9804,
334 0x7e010f98,
335 0xbb000120,
336 0x3fbb002f,
337 0x010e9800,
338 0x7e020f98,
339 0x98000120,
340 0xeffd050e,
341 0x002ebb00,
342 0x98003ebb,
343 0x0f98020e,
344 0x01207e03,
345 0x070e9800,
346 0xbb00effd,
347 0x3ebb002e,
348 0x0235b600,
349 0x01d30080,
350 0xbd0003f6,
351 0x0825b604,
352 0xb60635b6,
353 0x30b60120,
354 0x0824b601,
355 0xb20834b6,
356 0x02687e2f,
357 0x002fbb00,
358 0x0f003fbb,
359 0x8effb23f,
360 0xf0501d60,
361 0x8f7e01e5,
362 0x0c0f0000,
363 0xa88effb2,
364 0xe5f0501d,
365 0x008f7e01,
366 0x03147e00,
367 0xb23f0f00,
368 0x1d608eff,
369 0x01e5f050,
370 0x00008f7e,
371 0xffb2000f,
372 0x501d9c8e,
373 0x7e01e5f0,
374 0x0f00008f,
375 0x03147e01,
376 0x8effb200,
377 0xf0501da8,
378 0x8f7e01e5,
379 0xff0f0000,
380 0x988effb2,
381 0xe5f0501d,
382 0x008f7e01,
383 0xb2020f00,
384 0x1da88eff,
385 0x01e5f050,
386 0x00008f7e,
387 0x0003147e,
388 0x85050498,
389 0x98504000,
390 0x64b60406,
391 0x0056bb0f,
392/* 0x04e0: tpc_strand_init_tpc_loop */
393 0x05705eb8,
394 0x00657e00,
395 0xbdf6b200,
396/* 0x04ed: tpc_strand_init_idx_loop */
397 0x605eb874,
398 0x7fb20005,
399 0x00008f7e,
400 0x05885eb8,
401 0x082f9500,
402 0x00008f7e,
403 0x058c5eb8,
404 0x082f9500,
405 0x00008f7e,
406 0x05905eb8,
407 0x00657e00,
408 0x06f5b600,
409 0xb601f0b6,
410 0x2fbb08f4,
320 0x003fbb00, 411 0x003fbb00,
321 0x98010e98, 412 0xb60170b6,
322 0x207e020f, 413 0x1bf40162,
323 0x0e980001, 414 0x0050b7bf,
324 0x00effd05, 415 0x0142b608,
325 0xbb002ebb, 416 0x0fa81bf4,
326 0x0e98003e, 417 0x8effb23f,
327 0x030f9802, 418 0xf0501d60,
328 0x0001207e, 419 0x8f7e01e5,
329 0xfd070e98, 420 0x0d0f0000,
330 0x2ebb00ef, 421 0xa88effb2,
331 0x003ebb00, 422 0xe5f0501d,
332 0x800235b6, 423 0x008f7e01,
333 0xf601d300, 424 0x03147e00,
334 0x04bd0003, 425 0x01008000,
335 0xb60825b6, 426 0x0003f602,
336 0x20b60635, 427 0x24bd04bd,
337 0x0130b601, 428 0x801f29f0,
338 0xb60824b6, 429 0xf6023000,
339 0x2fb20834,
340 0x0002687e,
341 0x80003fbb,
342 0xf6020100,
343 0x04bd0003,
344 0x29f024bd,
345 0x3000801f,
346 0x0002f602,
347/* 0x0436: main */
348 0x31f404bd,
349 0x0028f400,
350 0x377e240d,
351 0x01f40000,
352 0x04e4b0f4,
353 0xfe1d18f4,
354 0x06020181,
355 0x12fd20bd,
356 0x01e4b604,
357 0xfe051efd,
358 0x097e0018,
359 0x0ef40005,
360/* 0x0465: main_not_ctx_xfer */
361 0x10ef94d4,
362 0x7e01f5f0,
363 0xf40002f8,
364/* 0x0472: ih */
365 0x80f9c70e,
366 0xf90188fe,
367 0xf990f980,
368 0xf9b0f9a0,
369 0xf9e0f9d0,
370 0x4a04bdf0,
371 0xaacf0200,
372 0x04abc400,
373 0x0d1f0bf4,
374 0x1a004e24,
375 0x4f00eecf,
376 0xffcf1900,
377 0x00047e00,
378 0x40010e00,
379 0x0ef61d00,
380/* 0x04af: ih_no_fifo */
381 0x4004bd00,
382 0x0af60100,
383 0xfc04bd00,
384 0xfce0fcf0,
385 0xfcb0fcd0,
386 0xfc90fca0,
387 0x0088fe80,
388 0x32f480fc,
389/* 0x04cf: hub_barrier_done */
390 0x0f01f800,
391 0x040e9801,
392 0xb204febb,
393 0x94188eff,
394 0x008f7e40,
395/* 0x04e3: ctx_redswitch */
396 0x0f00f800,
397 0x85008020,
398 0x000ff601,
399 0x080e04bd,
400/* 0x04f0: ctx_redswitch_delay */
401 0xf401e2b6,
402 0xf5f1fd1b,
403 0xf5f10800,
404 0x00800200,
405 0x0ff60185,
406 0xf804bd00,
407/* 0x0509: ctx_xfer */
408 0x81008000,
409 0x000ff602,
410 0x11f404bd,
411 0x04e37e07,
412/* 0x0519: ctx_xfer_not_load */
413 0x02167e00,
414 0x8024bd00,
415 0xf60247fc,
416 0x04bd0002, 430 0x04bd0002,
417 0xb6012cf0, 431/* 0x0574: main */
418 0xfc800320, 432 0xf40031f4,
419 0x02f6024a, 433 0x240d0028,
434 0x0000377e,
435 0xb0f401f4,
436 0x18f404e4,
437 0x0181fe1d,
438 0x20bd0602,
439 0xb60412fd,
440 0x1efd01e4,
441 0x0018fe05,
442 0x0006477e,
443/* 0x05a3: main_not_ctx_xfer */
444 0x94d40ef4,
445 0xf5f010ef,
446 0x02f87e01,
447 0xc70ef400,
448/* 0x05b0: ih */
449 0x88fe80f9,
450 0xf980f901,
451 0xf9a0f990,
452 0xf9d0f9b0,
453 0xbdf0f9e0,
454 0x02004a04,
455 0xc400aacf,
456 0x0bf404ab,
457 0x4e240d1f,
458 0xeecf1a00,
459 0x19004f00,
460 0x7e00ffcf,
461 0x0e000004,
462 0x1d004001,
463 0xbd000ef6,
464/* 0x05ed: ih_no_fifo */
465 0x01004004,
466 0xbd000af6,
467 0xfcf0fc04,
468 0xfcd0fce0,
469 0xfca0fcb0,
470 0xfe80fc90,
471 0x80fc0088,
472 0xf80032f4,
473/* 0x060d: hub_barrier_done */
474 0x98010f01,
475 0xfebb040e,
476 0x8effb204,
477 0x7e409418,
478 0xf800008f,
479/* 0x0621: ctx_redswitch */
480 0x80200f00,
481 0xf6018500,
482 0x04bd000f,
483/* 0x062e: ctx_redswitch_delay */
484 0xe2b6080e,
485 0xfd1bf401,
486 0x0800f5f1,
487 0x0200f5f1,
488 0x01850080,
489 0xbd000ff6,
490/* 0x0647: ctx_xfer */
491 0x8000f804,
492 0xf6028100,
493 0x04bd000f,
494 0xc48effb2,
495 0xe5f0501d,
496 0x008f7e01,
497 0x0711f400,
498 0x0006217e,
499/* 0x0664: ctx_xfer_not_load */
500 0x0002167e,
501 0xfc8024bd,
502 0x02f60247,
420 0xf004bd00, 503 0xf004bd00,
504 0x20b6012c,
505 0x4afc8003,
506 0x0002f602,
507 0x0c0f04bd,
508 0xa88effb2,
509 0xe5f0501d,
510 0x008f7e01,
511 0x03147e00,
512 0xb23f0f00,
513 0x1d608eff,
514 0x01e5f050,
515 0x00008f7e,
516 0xffb2000f,
517 0x501d9c8e,
518 0x7e01e5f0,
519 0x0f00008f,
520 0x03147e01,
521 0x01fcf000,
522 0xb203f0b6,
523 0x1da88eff,
524 0x01e5f050,
525 0x00008f7e,
526 0xf001acf0,
527 0x008b02a5,
528 0x0c985000,
529 0x0fc4b604,
530 0x9800bcbb,
531 0x0d98000c,
532 0x7e000e01,
533 0xf000013d,
534 0x008b01ac,
535 0x0c985040,
536 0x0fc4b604,
537 0x9800bcbb,
538 0x0d98010c,
539 0x060f9802,
540 0x7e08004e,
541 0xf000013d,
421 0xa5f001ac, 542 0xa5f001ac,
422 0x00008b02, 543 0x30008b04,
423 0x040c9850, 544 0x040c9850,
424 0xbb0fc4b6, 545 0xbb0fc4b6,
425 0x0c9800bc, 546 0x0c9800bc,
426 0x010d9800, 547 0x030d9802,
427 0x3d7e000e, 548 0x4e080f98,
428 0xacf00001, 549 0x3d7e0200,
429 0x40008b01, 550 0x0a7e0001,
430 0x040c9850, 551 0x147e0002,
431 0xbb0fc4b6, 552 0x01f40003,
432 0x0c9800bc, 553 0x1a12f406,
433 0x020d9801, 554/* 0x073c: ctx_xfer_post */
434 0x4e060f98, 555 0x0002277e,
435 0x3d7e0800, 556 0xffb20d0f,
436 0xacf00001, 557 0x501da88e,
437 0x04a5f001, 558 0x7e01e5f0,
438 0x5030008b, 559 0x7e00008f,
439 0xb6040c98, 560/* 0x0753: ctx_xfer_done */
440 0xbcbb0fc4, 561 0x7e000314,
441 0x020c9800, 562 0xf800060d,
442 0x98030d98, 563 0x00000000,
443 0x004e080f, 564 0x00000000,
444 0x013d7e02, 565 0x00000000,
445 0x020a7e00, 566 0x00000000,
446 0x0601f400, 567 0x00000000,
447/* 0x05a3: ctx_xfer_post */ 568 0x00000000,
448 0x7e0712f4, 569 0x00000000,
449/* 0x05a7: ctx_xfer_done */ 570 0x00000000,
450 0x7e000227, 571 0x00000000,
451 0xf80004cf, 572 0x00000000,
573 0x00000000,
574 0x00000000,
575 0x00000000,
576 0x00000000,
577 0x00000000,
578 0x00000000,
579 0x00000000,
580 0x00000000,
581 0x00000000,
582 0x00000000,
583 0x00000000,
452 0x00000000, 584 0x00000000,
453 0x00000000, 585 0x00000000,
454 0x00000000, 586 0x00000000,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/macros.fuc b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/macros.fuc
index 2a0b0f844299..fa618066441a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/macros.fuc
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/macros.fuc
@@ -29,6 +29,7 @@
29#define GK100 0xe0 29#define GK100 0xe0
30#define GK110 0xf0 30#define GK110 0xf0
31#define GK208 0x108 31#define GK208 0x108
32#define GM107 0x117
32 33
33#define NV_PGRAPH_TRAPPED_ADDR 0x400704 34#define NV_PGRAPH_TRAPPED_ADDR 0x400704
34#define NV_PGRAPH_TRAPPED_DATA_LO 0x400708 35#define NV_PGRAPH_TRAPPED_DATA_LO 0x400708
@@ -79,7 +80,9 @@
79#define NV_PGRAPH_FECS_MMCTX_MULTI_STRIDE 0x409718 80#define NV_PGRAPH_FECS_MMCTX_MULTI_STRIDE 0x409718
80#define NV_PGRAPH_FECS_MMCTX_MULTI_MASK 0x40971c 81#define NV_PGRAPH_FECS_MMCTX_MULTI_MASK 0x40971c
81#define NV_PGRAPH_FECS_MMCTX_QUEUE 0x409720 82#define NV_PGRAPH_FECS_MMCTX_QUEUE 0x409720
83#define NV_PGRAPH_FECS_MMIO_BASE 0x409724
82#define NV_PGRAPH_FECS_MMIO_CTRL 0x409728 84#define NV_PGRAPH_FECS_MMIO_CTRL 0x409728
85#define NV_PGRAPH_FECS_MMIO_CTRL_BASE_ENABLE 0x00000001
83#define NV_PGRAPH_FECS_MMIO_RDVAL 0x40972c 86#define NV_PGRAPH_FECS_MMIO_RDVAL 0x40972c
84#define NV_PGRAPH_FECS_MMIO_WRVAL 0x409730 87#define NV_PGRAPH_FECS_MMIO_WRVAL 0x409730
85#define NV_PGRAPH_FECS_MMCTX_LOAD_COUNT 0x40974c 88#define NV_PGRAPH_FECS_MMCTX_LOAD_COUNT 0x40974c
@@ -147,6 +150,11 @@
147#define NV_PGRAPH_GPCX_GPCCS_MYINDEX 0x41a618 150#define NV_PGRAPH_GPCX_GPCCS_MYINDEX 0x41a618
148#define NV_PGRAPH_GPCX_GPCCS_MMCTX_SAVE_SWBASE 0x41a700 151#define NV_PGRAPH_GPCX_GPCCS_MMCTX_SAVE_SWBASE 0x41a700
149#define NV_PGRAPH_GPCX_GPCCS_MMCTX_LOAD_SWBASE 0x41a704 152#define NV_PGRAPH_GPCX_GPCCS_MMCTX_LOAD_SWBASE 0x41a704
153#define NV_PGRAPH_GPCX_GPCCS_MMIO_BASE 0x41a724
154#define NV_PGRAPH_GPCX_GPCCS_MMIO_CTRL 0x41a728
155#define NV_PGRAPH_GPCX_GPCCS_MMIO_CTRL_BASE_ENABLE 0x00000001
156#define NV_PGRAPH_GPCX_GPCCS_MMIO_RDVAL 0x41a72c
157#define NV_PGRAPH_GPCX_GPCCS_MMIO_WRVAL 0x41a730
150#define NV_PGRAPH_GPCX_GPCCS_MMCTX_LOAD_COUNT 0x41a74c 158#define NV_PGRAPH_GPCX_GPCCS_MMCTX_LOAD_COUNT 0x41a74c
151#if CHIPSET < GK110 159#if CHIPSET < GK110
152#define NV_PGRAPH_GPCX_GPCCS_CC_SCRATCH_VAL(n) ((n) * 4 + 0x41a800) 160#define NV_PGRAPH_GPCX_GPCCS_CC_SCRATCH_VAL(n) ((n) * 4 + 0x41a800)
@@ -164,6 +172,29 @@
164#define NV_PGRAPH_GPCX_GPCCS_STRAND_CMD_SAVE 0x00000003 172#define NV_PGRAPH_GPCX_GPCCS_STRAND_CMD_SAVE 0x00000003
165#define NV_PGRAPH_GPCX_GPCCS_STRAND_CMD_LOAD 0x00000004 173#define NV_PGRAPH_GPCX_GPCCS_STRAND_CMD_LOAD 0x00000004
166#define NV_PGRAPH_GPCX_GPCCS_MEM_BASE 0x41aa04 174#define NV_PGRAPH_GPCX_GPCCS_MEM_BASE 0x41aa04
175#define NV_PGRAPH_GPCX_GPCCS_TPC_STATUS 0x41acfc
176
177#define NV_PGRAPH_GPC0_TPC0 0x504000
178#define NV_PGRAPH_GPC0_TPC0__SIZE 0x000800
179
180#define NV_PGRAPH_GPC0_TPCX_STRAND_INDEX 0x501d60
181#define NV_PGRAPH_GPC0_TPCX_STRAND_INDEX_ALL 0x0000003f
182#define NV_PGRAPH_GPC0_TPCX_STRAND_DATA 0x501d98
183#define NV_PGRAPH_GPC0_TPCX_STRAND_SELECT 0x501d9c
184#define NV_PGRAPH_GPC0_TPCX_STRAND_CMD 0x501da8
185#define NV_PGRAPH_GPC0_TPCX_STRAND_CMD_SEEK 0x00000001
186#define NV_PGRAPH_GPC0_TPCX_STRAND_CMD_GET_INFO 0x00000002
187#define NV_PGRAPH_GPC0_TPCX_STRAND_CMD_SAVE 0x00000003
188#define NV_PGRAPH_GPC0_TPCX_STRAND_CMD_LOAD 0x00000004
189#define NV_PGRAPH_GPC0_TPCX_STRAND_CMD_ENABLE 0x0000000c
190#define NV_PGRAPH_GPC0_TPCX_STRAND_CMD_DISABLE 0x0000000d
191#define NV_PGRAPH_GPC0_TPCX_STRAND_MEM_BASE 0x501dc4
192
193#define NV_TPC_STRAND_INDEX 0x560
194#define NV_TPC_STRAND_CNT 0x570
195#define NV_TPC_STRAND_SAVE_SWBASE 0x588
196#define NV_TPC_STRAND_LOAD_SWBASE 0x58c
197#define NV_TPC_STRAND_WORDS 0x590
167 198
168#define mmctx_data(r,c) .b32 (((c - 1) << 26) | r) 199#define mmctx_data(r,c) .b32 (((c - 1) << 26) | r)
169#define queue_init .skip 72 // (2 * 4) + ((8 * 4) * 2) 200#define queue_init .skip 72 // (2 * 4) + ((8 * 4) * 2)
@@ -178,6 +209,7 @@
178#define T_SAVE 7 209#define T_SAVE 7
179#define T_LCHAN 8 210#define T_LCHAN 8
180#define T_LCTXH 9 211#define T_LCTXH 9
212#define T_STRTPC 10
181 213
182#if CHIPSET < GK208 214#if CHIPSET < GK208
183#define imm32(reg,val) /* 215#define imm32(reg,val) /*
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
index 1dd482e9da77..5606c25e5d02 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
@@ -236,7 +236,7 @@ static int
236gf100_gr_set_shader_exceptions(struct nvkm_object *object, u32 mthd, 236gf100_gr_set_shader_exceptions(struct nvkm_object *object, u32 mthd,
237 void *pdata, u32 size) 237 void *pdata, u32 size)
238{ 238{
239 struct gf100_gr_priv *priv = (void *)nv_engine(object); 239 struct gf100_gr_priv *priv = (void *)object->engine;
240 if (size >= sizeof(u32)) { 240 if (size >= sizeof(u32)) {
241 u32 data = *(u32 *)pdata ? 0xffffffff : 0x00000000; 241 u32 data = *(u32 *)pdata ? 0xffffffff : 0x00000000;
242 nv_wr32(priv, 0x419e44, data); 242 nv_wr32(priv, 0x419e44, data);
@@ -260,8 +260,8 @@ gf100_gr_90c0_omthds[] = {
260 260
261struct nvkm_oclass 261struct nvkm_oclass
262gf100_gr_sclass[] = { 262gf100_gr_sclass[] = {
263 { 0x902d, &nvkm_object_ofuncs }, 263 { FERMI_TWOD_A, &nvkm_object_ofuncs },
264 { 0x9039, &nvkm_object_ofuncs }, 264 { FERMI_MEMORY_TO_MEMORY_FORMAT_A, &nvkm_object_ofuncs },
265 { FERMI_A, &gf100_fermi_ofuncs, gf100_gr_9097_omthds }, 265 { FERMI_A, &gf100_fermi_ofuncs, gf100_gr_9097_omthds },
266 { FERMI_COMPUTE_A, &nvkm_object_ofuncs, gf100_gr_90c0_omthds }, 266 { FERMI_COMPUTE_A, &nvkm_object_ofuncs, gf100_gr_90c0_omthds },
267 {} 267 {}
@@ -1097,12 +1097,26 @@ gf100_gr_intr(struct nvkm_subdev *subdev)
1097 u32 subc = (addr & 0x00070000) >> 16; 1097 u32 subc = (addr & 0x00070000) >> 16;
1098 u32 data = nv_rd32(priv, 0x400708); 1098 u32 data = nv_rd32(priv, 0x400708);
1099 u32 code = nv_rd32(priv, 0x400110); 1099 u32 code = nv_rd32(priv, 0x400110);
1100 u32 class = nv_rd32(priv, 0x404200 + (subc * 4)); 1100 u32 class;
1101 int chid; 1101 int chid;
1102 1102
1103 if (nv_device(priv)->card_type < NV_E0 || subc < 4)
1104 class = nv_rd32(priv, 0x404200 + (subc * 4));
1105 else
1106 class = 0x0000;
1107
1103 engctx = nvkm_engctx_get(engine, inst); 1108 engctx = nvkm_engctx_get(engine, inst);
1104 chid = pfifo->chid(pfifo, engctx); 1109 chid = pfifo->chid(pfifo, engctx);
1105 1110
1111 if (stat & 0x00000001) {
1112 /*
1113 * notifier interrupt, only needed for cyclestats
1114 * can be safely ignored
1115 */
1116 nv_wr32(priv, 0x400100, 0x00000001);
1117 stat &= ~0x00000001;
1118 }
1119
1106 if (stat & 0x00000010) { 1120 if (stat & 0x00000010) {
1107 handle = nvkm_handle_get_class(engctx, class); 1121 handle = nvkm_handle_get_class(engctx, class);
1108 if (!handle || nv_call(handle->object, mthd, data)) { 1122 if (!handle || nv_call(handle->object, mthd, data)) {
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h
index aeeca1be9cf0..8af1a89eda84 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h
@@ -124,10 +124,12 @@ void gf100_gr_dtor(struct nvkm_object *);
124int gf100_gr_init(struct nvkm_object *); 124int gf100_gr_init(struct nvkm_object *);
125void gf100_gr_zbc_init(struct gf100_gr_priv *); 125void gf100_gr_zbc_init(struct gf100_gr_priv *);
126 126
127int gk104_gr_fini(struct nvkm_object *, bool); 127int gk104_gr_ctor(struct nvkm_object *, struct nvkm_object *,
128 struct nvkm_oclass *, void *data, u32 size,
129 struct nvkm_object **);
128int gk104_gr_init(struct nvkm_object *); 130int gk104_gr_init(struct nvkm_object *);
129 131
130int gk110_gr_fini(struct nvkm_object *, bool); 132int gm204_gr_init(struct nvkm_object *);
131 133
132extern struct nvkm_ofuncs gf100_fermi_ofuncs; 134extern struct nvkm_ofuncs gf100_fermi_ofuncs;
133 135
@@ -136,6 +138,7 @@ extern struct nvkm_omthds gf100_gr_9097_omthds[];
136extern struct nvkm_omthds gf100_gr_90c0_omthds[]; 138extern struct nvkm_omthds gf100_gr_90c0_omthds[];
137extern struct nvkm_oclass gf110_gr_sclass[]; 139extern struct nvkm_oclass gf110_gr_sclass[];
138extern struct nvkm_oclass gk110_gr_sclass[]; 140extern struct nvkm_oclass gk110_gr_sclass[];
141extern struct nvkm_oclass gm204_gr_sclass[];
139 142
140struct gf100_gr_init { 143struct gf100_gr_init {
141 u32 addr; 144 u32 addr;
@@ -247,4 +250,17 @@ extern const struct gf100_gr_init gk110_gr_init_tex_0[];
247extern const struct gf100_gr_init gk110_gr_init_sm_0[]; 250extern const struct gf100_gr_init gk110_gr_init_sm_0[];
248 251
249extern const struct gf100_gr_init gk208_gr_init_gpc_unk_0[]; 252extern const struct gf100_gr_init gk208_gr_init_gpc_unk_0[];
253
254extern const struct gf100_gr_init gm107_gr_init_scc_0[];
255extern const struct gf100_gr_init gm107_gr_init_prop_0[];
256extern const struct gf100_gr_init gm107_gr_init_setup_1[];
257extern const struct gf100_gr_init gm107_gr_init_zcull_0[];
258extern const struct gf100_gr_init gm107_gr_init_gpc_unk_1[];
259extern const struct gf100_gr_init gm107_gr_init_tex_0[];
260extern const struct gf100_gr_init gm107_gr_init_l1c_0[];
261extern const struct gf100_gr_init gm107_gr_init_wwdx_0[];
262extern const struct gf100_gr_init gm107_gr_init_cbm_0[];
263void gm107_gr_init_bios(struct gf100_gr_priv *);
264
265extern const struct gf100_gr_pack gm204_gr_pack_mmio[];
250#endif 266#endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf108.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf108.c
index 5362c8176e64..8df73421c78c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf108.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf108.c
@@ -32,8 +32,8 @@
32 32
33static struct nvkm_oclass 33static struct nvkm_oclass
34gf108_gr_sclass[] = { 34gf108_gr_sclass[] = {
35 { 0x902d, &nvkm_object_ofuncs }, 35 { FERMI_TWOD_A, &nvkm_object_ofuncs },
36 { 0x9039, &nvkm_object_ofuncs }, 36 { FERMI_MEMORY_TO_MEMORY_FORMAT_A, &nvkm_object_ofuncs },
37 { FERMI_A, &gf100_fermi_ofuncs, gf100_gr_9097_omthds }, 37 { FERMI_A, &gf100_fermi_ofuncs, gf100_gr_9097_omthds },
38 { FERMI_B, &gf100_fermi_ofuncs, gf100_gr_9097_omthds }, 38 { FERMI_B, &gf100_fermi_ofuncs, gf100_gr_9097_omthds },
39 { FERMI_COMPUTE_A, &nvkm_object_ofuncs, gf100_gr_90c0_omthds }, 39 { FERMI_COMPUTE_A, &nvkm_object_ofuncs, gf100_gr_90c0_omthds },
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf110.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf110.c
index 88beb491b7b8..ef76e2dd1d31 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf110.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf110.c
@@ -32,8 +32,8 @@
32 32
33struct nvkm_oclass 33struct nvkm_oclass
34gf110_gr_sclass[] = { 34gf110_gr_sclass[] = {
35 { 0x902d, &nvkm_object_ofuncs }, 35 { FERMI_TWOD_A, &nvkm_object_ofuncs },
36 { 0x9039, &nvkm_object_ofuncs }, 36 { FERMI_MEMORY_TO_MEMORY_FORMAT_A, &nvkm_object_ofuncs },
37 { FERMI_A, &gf100_fermi_ofuncs, gf100_gr_9097_omthds }, 37 { FERMI_A, &gf100_fermi_ofuncs, gf100_gr_9097_omthds },
38 { FERMI_B, &gf100_fermi_ofuncs, gf100_gr_9097_omthds }, 38 { FERMI_B, &gf100_fermi_ofuncs, gf100_gr_9097_omthds },
39 { FERMI_C, &gf100_fermi_ofuncs, gf100_gr_9097_omthds }, 39 { FERMI_C, &gf100_fermi_ofuncs, gf100_gr_9097_omthds },
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk104.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk104.c
index 489fdd94b885..46f7844eca70 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk104.c
@@ -34,8 +34,8 @@
34 34
35static struct nvkm_oclass 35static struct nvkm_oclass
36gk104_gr_sclass[] = { 36gk104_gr_sclass[] = {
37 { 0x902d, &nvkm_object_ofuncs }, 37 { FERMI_TWOD_A, &nvkm_object_ofuncs },
38 { 0xa040, &nvkm_object_ofuncs }, 38 { KEPLER_INLINE_TO_MEMORY_A, &nvkm_object_ofuncs },
39 { KEPLER_A, &gf100_fermi_ofuncs, gf100_gr_9097_omthds }, 39 { KEPLER_A, &gf100_fermi_ofuncs, gf100_gr_9097_omthds },
40 { KEPLER_COMPUTE_A, &nvkm_object_ofuncs, gf100_gr_90c0_omthds }, 40 { KEPLER_COMPUTE_A, &nvkm_object_ofuncs, gf100_gr_90c0_omthds },
41 {} 41 {}
@@ -310,6 +310,17 @@ gk104_gr_init(struct nvkm_object *object)
310 return gf100_gr_init_ctxctl(priv); 310 return gf100_gr_init_ctxctl(priv);
311} 311}
312 312
313int
314gk104_gr_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
315 struct nvkm_oclass *oclass, void *data, u32 size,
316 struct nvkm_object **pobject)
317{
318 struct nvkm_pmu *pmu = nvkm_pmu(parent);
319 if (pmu)
320 pmu->pgob(pmu, false);
321 return gf100_gr_ctor(parent, engine, oclass, data, size, pobject);
322}
323
313#include "fuc/hubgk104.fuc3.h" 324#include "fuc/hubgk104.fuc3.h"
314 325
315static struct gf100_gr_ucode 326static struct gf100_gr_ucode
@@ -334,7 +345,7 @@ struct nvkm_oclass *
334gk104_gr_oclass = &(struct gf100_gr_oclass) { 345gk104_gr_oclass = &(struct gf100_gr_oclass) {
335 .base.handle = NV_ENGINE(GR, 0xe4), 346 .base.handle = NV_ENGINE(GR, 0xe4),
336 .base.ofuncs = &(struct nvkm_ofuncs) { 347 .base.ofuncs = &(struct nvkm_ofuncs) {
337 .ctor = gf100_gr_ctor, 348 .ctor = gk104_gr_ctor,
338 .dtor = gf100_gr_dtor, 349 .dtor = gf100_gr_dtor,
339 .init = gk104_gr_init, 350 .init = gk104_gr_init,
340 .fini = _nvkm_gr_fini, 351 .fini = _nvkm_gr_fini,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk110.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk110.c
index 78e03ab1608e..f4cd8e5546af 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk110.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk110.c
@@ -34,8 +34,8 @@
34 34
35struct nvkm_oclass 35struct nvkm_oclass
36gk110_gr_sclass[] = { 36gk110_gr_sclass[] = {
37 { 0x902d, &nvkm_object_ofuncs }, 37 { FERMI_TWOD_A, &nvkm_object_ofuncs },
38 { 0xa140, &nvkm_object_ofuncs }, 38 { KEPLER_INLINE_TO_MEMORY_B, &nvkm_object_ofuncs },
39 { KEPLER_B, &gf100_fermi_ofuncs, gf100_gr_9097_omthds }, 39 { KEPLER_B, &gf100_fermi_ofuncs, gf100_gr_9097_omthds },
40 { KEPLER_COMPUTE_B, &nvkm_object_ofuncs, gf100_gr_90c0_omthds }, 40 { KEPLER_COMPUTE_B, &nvkm_object_ofuncs, gf100_gr_90c0_omthds },
41 {} 41 {}
@@ -173,43 +173,6 @@ gk110_gr_pack_mmio[] = {
173 * PGRAPH engine/subdev functions 173 * PGRAPH engine/subdev functions
174 ******************************************************************************/ 174 ******************************************************************************/
175 175
176int
177gk110_gr_fini(struct nvkm_object *object, bool suspend)
178{
179 struct gf100_gr_priv *priv = (void *)object;
180 static const struct {
181 u32 addr;
182 u32 data;
183 } magic[] = {
184 { 0x020520, 0xfffffffc },
185 { 0x020524, 0xfffffffe },
186 { 0x020524, 0xfffffffc },
187 { 0x020524, 0xfffffff8 },
188 { 0x020524, 0xffffffe0 },
189 { 0x020530, 0xfffffffe },
190 { 0x02052c, 0xfffffffa },
191 { 0x02052c, 0xfffffff0 },
192 { 0x02052c, 0xffffffc0 },
193 { 0x02052c, 0xffffff00 },
194 { 0x02052c, 0xfffffc00 },
195 { 0x02052c, 0xfffcfc00 },
196 { 0x02052c, 0xfff0fc00 },
197 { 0x02052c, 0xff80fc00 },
198 { 0x020528, 0xfffffffe },
199 { 0x020528, 0xfffffffc },
200 };
201 int i;
202
203 nv_mask(priv, 0x000200, 0x08001000, 0x00000000);
204 nv_mask(priv, 0x0206b4, 0x00000000, 0x00000000);
205 for (i = 0; i < ARRAY_SIZE(magic); i++) {
206 nv_wr32(priv, magic[i].addr, magic[i].data);
207 nv_wait(priv, magic[i].addr, 0x80000000, 0x00000000);
208 }
209
210 return nvkm_gr_fini(&priv->base, suspend);
211}
212
213#include "fuc/hubgk110.fuc3.h" 176#include "fuc/hubgk110.fuc3.h"
214 177
215struct gf100_gr_ucode 178struct gf100_gr_ucode
@@ -234,10 +197,10 @@ struct nvkm_oclass *
234gk110_gr_oclass = &(struct gf100_gr_oclass) { 197gk110_gr_oclass = &(struct gf100_gr_oclass) {
235 .base.handle = NV_ENGINE(GR, 0xf0), 198 .base.handle = NV_ENGINE(GR, 0xf0),
236 .base.ofuncs = &(struct nvkm_ofuncs) { 199 .base.ofuncs = &(struct nvkm_ofuncs) {
237 .ctor = gf100_gr_ctor, 200 .ctor = gk104_gr_ctor,
238 .dtor = gf100_gr_dtor, 201 .dtor = gf100_gr_dtor,
239 .init = gk104_gr_init, 202 .init = gk104_gr_init,
240 .fini = gk110_gr_fini, 203 .fini = _nvkm_gr_fini,
241 }, 204 },
242 .cclass = &gk110_grctx_oclass, 205 .cclass = &gk110_grctx_oclass,
243 .sclass = gk110_gr_sclass, 206 .sclass = gk110_gr_sclass,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk110b.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk110b.c
index 5292c5a9a38c..9ff9eab0ccaf 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk110b.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk110b.c
@@ -102,10 +102,10 @@ struct nvkm_oclass *
102gk110b_gr_oclass = &(struct gf100_gr_oclass) { 102gk110b_gr_oclass = &(struct gf100_gr_oclass) {
103 .base.handle = NV_ENGINE(GR, 0xf1), 103 .base.handle = NV_ENGINE(GR, 0xf1),
104 .base.ofuncs = &(struct nvkm_ofuncs) { 104 .base.ofuncs = &(struct nvkm_ofuncs) {
105 .ctor = gf100_gr_ctor, 105 .ctor = gk104_gr_ctor,
106 .dtor = gf100_gr_dtor, 106 .dtor = gf100_gr_dtor,
107 .init = gk104_gr_init, 107 .init = gk104_gr_init,
108 .fini = gk110_gr_fini, 108 .fini = _nvkm_gr_fini,
109 }, 109 },
110 .cclass = &gk110b_grctx_oclass, 110 .cclass = &gk110b_grctx_oclass,
111 .sclass = gk110_gr_sclass, 111 .sclass = gk110_gr_sclass,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk208.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk208.c
index ae6b853173b6..85f44a3d5d11 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk208.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk208.c
@@ -34,10 +34,10 @@
34 34
35static struct nvkm_oclass 35static struct nvkm_oclass
36gk208_gr_sclass[] = { 36gk208_gr_sclass[] = {
37 { 0x902d, &nvkm_object_ofuncs }, 37 { FERMI_TWOD_A, &nvkm_object_ofuncs },
38 { 0xa140, &nvkm_object_ofuncs }, 38 { KEPLER_INLINE_TO_MEMORY_B, &nvkm_object_ofuncs },
39 { KEPLER_B, &gf100_fermi_ofuncs }, 39 { KEPLER_B, &gf100_fermi_ofuncs },
40 { 0xa1c0, &nvkm_object_ofuncs }, 40 { KEPLER_COMPUTE_B, &nvkm_object_ofuncs },
41 {} 41 {}
42}; 42};
43 43
@@ -152,43 +152,6 @@ gk208_gr_pack_mmio[] = {
152 * PGRAPH engine/subdev functions 152 * PGRAPH engine/subdev functions
153 ******************************************************************************/ 153 ******************************************************************************/
154 154
155static int
156gk208_gr_fini(struct nvkm_object *object, bool suspend)
157{
158 struct gf100_gr_priv *priv = (void *)object;
159 static const struct {
160 u32 addr;
161 u32 data;
162 } magic[] = {
163 { 0x020520, 0xfffffffc },
164 { 0x020524, 0xfffffffe },
165 { 0x020524, 0xfffffffc },
166 { 0x020524, 0xfffffff8 },
167 { 0x020524, 0xffffffe0 },
168 { 0x020530, 0xfffffffe },
169 { 0x02052c, 0xfffffffa },
170 { 0x02052c, 0xfffffff0 },
171 { 0x02052c, 0xffffffc0 },
172 { 0x02052c, 0xffffff00 },
173 { 0x02052c, 0xfffffc00 },
174 { 0x02052c, 0xfffcfc00 },
175 { 0x02052c, 0xfff0fc00 },
176 { 0x02052c, 0xff80fc00 },
177 { 0x020528, 0xfffffffe },
178 { 0x020528, 0xfffffffc },
179 };
180 int i;
181
182 nv_mask(priv, 0x000200, 0x08001000, 0x00000000);
183 nv_mask(priv, 0x0206b4, 0x00000000, 0x00000000);
184 for (i = 0; i < ARRAY_SIZE(magic); i++) {
185 nv_wr32(priv, magic[i].addr, magic[i].data);
186 nv_wait(priv, magic[i].addr, 0x80000000, 0x00000000);
187 }
188
189 return nvkm_gr_fini(&priv->base, suspend);
190}
191
192#include "fuc/hubgk208.fuc5.h" 155#include "fuc/hubgk208.fuc5.h"
193 156
194static struct gf100_gr_ucode 157static struct gf100_gr_ucode
@@ -213,10 +176,10 @@ struct nvkm_oclass *
213gk208_gr_oclass = &(struct gf100_gr_oclass) { 176gk208_gr_oclass = &(struct gf100_gr_oclass) {
214 .base.handle = NV_ENGINE(GR, 0x08), 177 .base.handle = NV_ENGINE(GR, 0x08),
215 .base.ofuncs = &(struct nvkm_ofuncs) { 178 .base.ofuncs = &(struct nvkm_ofuncs) {
216 .ctor = gf100_gr_ctor, 179 .ctor = gk104_gr_ctor,
217 .dtor = gf100_gr_dtor, 180 .dtor = gf100_gr_dtor,
218 .init = gk104_gr_init, 181 .init = gk104_gr_init,
219 .fini = gk208_gr_fini, 182 .fini = _nvkm_gr_fini,
220 }, 183 },
221 .cclass = &gk208_grctx_oclass, 184 .cclass = &gk208_grctx_oclass,
222 .sclass = gk208_gr_sclass, 185 .sclass = gk208_gr_sclass,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk20a.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk20a.c
index 213755534084..40ff5eb9180c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk20a.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk20a.c
@@ -26,8 +26,8 @@
26 26
27static struct nvkm_oclass 27static struct nvkm_oclass
28gk20a_gr_sclass[] = { 28gk20a_gr_sclass[] = {
29 { 0x902d, &nvkm_object_ofuncs }, 29 { FERMI_TWOD_A, &nvkm_object_ofuncs },
30 { 0xa040, &nvkm_object_ofuncs }, 30 { KEPLER_INLINE_TO_MEMORY_A, &nvkm_object_ofuncs },
31 { KEPLER_C, &gf100_fermi_ofuncs, gf100_gr_9097_omthds }, 31 { KEPLER_C, &gf100_fermi_ofuncs, gf100_gr_9097_omthds },
32 { KEPLER_COMPUTE_A, &nvkm_object_ofuncs, gf100_gr_90c0_omthds }, 32 { KEPLER_COMPUTE_A, &nvkm_object_ofuncs, gf100_gr_90c0_omthds },
33 {} 33 {}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gm107.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gm107.c
index 124492b8a2d6..a5ebd459bc24 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gm107.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gm107.c
@@ -35,8 +35,8 @@
35 35
36static struct nvkm_oclass 36static struct nvkm_oclass
37gm107_gr_sclass[] = { 37gm107_gr_sclass[] = {
38 { 0x902d, &nvkm_object_ofuncs }, 38 { FERMI_TWOD_A, &nvkm_object_ofuncs },
39 { 0xa140, &nvkm_object_ofuncs }, 39 { KEPLER_INLINE_TO_MEMORY_B, &nvkm_object_ofuncs },
40 { MAXWELL_A, &gf100_fermi_ofuncs, gf100_gr_9097_omthds }, 40 { MAXWELL_A, &gf100_fermi_ofuncs, gf100_gr_9097_omthds },
41 { MAXWELL_COMPUTE_A, &nvkm_object_ofuncs, gf100_gr_90c0_omthds }, 41 { MAXWELL_COMPUTE_A, &nvkm_object_ofuncs, gf100_gr_90c0_omthds },
42 {} 42 {}
@@ -71,7 +71,7 @@ gm107_gr_init_ds_0[] = {
71 {} 71 {}
72}; 72};
73 73
74static const struct gf100_gr_init 74const struct gf100_gr_init
75gm107_gr_init_scc_0[] = { 75gm107_gr_init_scc_0[] = {
76 { 0x40803c, 1, 0x04, 0x00000010 }, 76 { 0x40803c, 1, 0x04, 0x00000010 },
77 {} 77 {}
@@ -85,14 +85,14 @@ gm107_gr_init_sked_0[] = {
85 {} 85 {}
86}; 86};
87 87
88static const struct gf100_gr_init 88const struct gf100_gr_init
89gm107_gr_init_prop_0[] = { 89gm107_gr_init_prop_0[] = {
90 { 0x418408, 1, 0x04, 0x00000000 }, 90 { 0x418408, 1, 0x04, 0x00000000 },
91 { 0x4184a0, 1, 0x04, 0x00000000 }, 91 { 0x4184a0, 1, 0x04, 0x00000000 },
92 {} 92 {}
93}; 93};
94 94
95static const struct gf100_gr_init 95const struct gf100_gr_init
96gm107_gr_init_setup_1[] = { 96gm107_gr_init_setup_1[] = {
97 { 0x4188c8, 2, 0x04, 0x00000000 }, 97 { 0x4188c8, 2, 0x04, 0x00000000 },
98 { 0x4188d0, 1, 0x04, 0x00010000 }, 98 { 0x4188d0, 1, 0x04, 0x00010000 },
@@ -100,7 +100,7 @@ gm107_gr_init_setup_1[] = {
100 {} 100 {}
101}; 101};
102 102
103static const struct gf100_gr_init 103const struct gf100_gr_init
104gm107_gr_init_zcull_0[] = { 104gm107_gr_init_zcull_0[] = {
105 { 0x418910, 1, 0x04, 0x00010001 }, 105 { 0x418910, 1, 0x04, 0x00010001 },
106 { 0x418914, 1, 0x04, 0x00000301 }, 106 { 0x418914, 1, 0x04, 0x00000301 },
@@ -111,7 +111,7 @@ gm107_gr_init_zcull_0[] = {
111 {} 111 {}
112}; 112};
113 113
114static const struct gf100_gr_init 114const struct gf100_gr_init
115gm107_gr_init_gpc_unk_1[] = { 115gm107_gr_init_gpc_unk_1[] = {
116 { 0x418d00, 1, 0x04, 0x00000000 }, 116 { 0x418d00, 1, 0x04, 0x00000000 },
117 { 0x418f00, 1, 0x04, 0x00000400 }, 117 { 0x418f00, 1, 0x04, 0x00000400 },
@@ -134,7 +134,7 @@ gm107_gr_init_tpccs_0[] = {
134 {} 134 {}
135}; 135};
136 136
137static const struct gf100_gr_init 137const struct gf100_gr_init
138gm107_gr_init_tex_0[] = { 138gm107_gr_init_tex_0[] = {
139 { 0x419ab0, 1, 0x04, 0x00000000 }, 139 { 0x419ab0, 1, 0x04, 0x00000000 },
140 { 0x419ab8, 1, 0x04, 0x000000e7 }, 140 { 0x419ab8, 1, 0x04, 0x000000e7 },
@@ -160,7 +160,7 @@ gm107_gr_init_pe_0[] = {
160 {} 160 {}
161}; 161};
162 162
163static const struct gf100_gr_init 163const struct gf100_gr_init
164gm107_gr_init_l1c_0[] = { 164gm107_gr_init_l1c_0[] = {
165 { 0x419c98, 1, 0x04, 0x00000000 }, 165 { 0x419c98, 1, 0x04, 0x00000000 },
166 { 0x419cc0, 2, 0x04, 0x00000000 }, 166 { 0x419cc0, 2, 0x04, 0x00000000 },
@@ -206,14 +206,14 @@ gm107_gr_init_pes_0[] = {
206 {} 206 {}
207}; 207};
208 208
209static const struct gf100_gr_init 209const struct gf100_gr_init
210gm107_gr_init_wwdx_0[] = { 210gm107_gr_init_wwdx_0[] = {
211 { 0x41bfd4, 1, 0x04, 0x00800000 }, 211 { 0x41bfd4, 1, 0x04, 0x00800000 },
212 { 0x41bfdc, 1, 0x04, 0x00000000 }, 212 { 0x41bfdc, 1, 0x04, 0x00000000 },
213 {} 213 {}
214}; 214};
215 215
216static const struct gf100_gr_init 216const struct gf100_gr_init
217gm107_gr_init_cbm_0[] = { 217gm107_gr_init_cbm_0[] = {
218 { 0x41becc, 1, 0x04, 0x00000000 }, 218 { 0x41becc, 1, 0x04, 0x00000000 },
219 {} 219 {}
@@ -291,7 +291,7 @@ gm107_gr_pack_mmio[] = {
291 * PGRAPH engine/subdev functions 291 * PGRAPH engine/subdev functions
292 ******************************************************************************/ 292 ******************************************************************************/
293 293
294static void 294void
295gm107_gr_init_bios(struct gf100_gr_priv *priv) 295gm107_gr_init_bios(struct gf100_gr_priv *priv)
296{ 296{
297 static const struct { 297 static const struct {
@@ -464,7 +464,7 @@ gm107_gr_oclass = &(struct gf100_gr_oclass) {
464 .cclass = &gm107_grctx_oclass, 464 .cclass = &gm107_grctx_oclass,
465 .sclass = gm107_gr_sclass, 465 .sclass = gm107_gr_sclass,
466 .mmio = gm107_gr_pack_mmio, 466 .mmio = gm107_gr_pack_mmio,
467 .fecs.ucode = 0 ? &gm107_gr_fecs_ucode : NULL, 467 .fecs.ucode = &gm107_gr_fecs_ucode,
468 .gpccs.ucode = &gm107_gr_gpccs_ucode, 468 .gpccs.ucode = &gm107_gr_gpccs_ucode,
469 .ppc_nr = 2, 469 .ppc_nr = 2,
470}.base; 470}.base;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gm204.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gm204.c
new file mode 100644
index 000000000000..2f5eadd12a9b
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gm204.c
@@ -0,0 +1,387 @@
1/*
2 * Copyright 2015 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs <bskeggs@redhat.com>
23 */
24#include "gf100.h"
25#include "ctxgf100.h"
26
27#include <nvif/class.h>
28
29/*******************************************************************************
30 * Graphics object classes
31 ******************************************************************************/
32
33struct nvkm_oclass
34gm204_gr_sclass[] = {
35 { FERMI_TWOD_A, &nvkm_object_ofuncs },
36 { KEPLER_INLINE_TO_MEMORY_B, &nvkm_object_ofuncs },
37 { MAXWELL_B, &gf100_fermi_ofuncs, gf100_gr_9097_omthds },
38 { MAXWELL_COMPUTE_B, &nvkm_object_ofuncs, gf100_gr_90c0_omthds },
39 {}
40};
41
42/*******************************************************************************
43 * PGRAPH register lists
44 ******************************************************************************/
45
46static const struct gf100_gr_init
47gm204_gr_init_main_0[] = {
48 { 0x400080, 1, 0x04, 0x003003e2 },
49 { 0x400088, 1, 0x04, 0xe007bfe7 },
50 { 0x40008c, 1, 0x04, 0x00060000 },
51 { 0x400090, 1, 0x04, 0x00000030 },
52 { 0x40013c, 1, 0x04, 0x003901f3 },
53 { 0x400140, 1, 0x04, 0x00000100 },
54 { 0x400144, 1, 0x04, 0x00000000 },
55 { 0x400148, 1, 0x04, 0x00000110 },
56 { 0x400138, 1, 0x04, 0x00000000 },
57 { 0x400130, 2, 0x04, 0x00000000 },
58 { 0x400124, 1, 0x04, 0x00000002 },
59 {}
60};
61
62static const struct gf100_gr_init
63gm204_gr_init_fe_0[] = {
64 { 0x40415c, 1, 0x04, 0x00000000 },
65 { 0x404170, 1, 0x04, 0x00000000 },
66 { 0x4041b4, 1, 0x04, 0x00000000 },
67 { 0x4041b8, 1, 0x04, 0x00000010 },
68 {}
69};
70
71static const struct gf100_gr_init
72gm204_gr_init_ds_0[] = {
73 { 0x40583c, 1, 0x04, 0x00000000 },
74 { 0x405844, 1, 0x04, 0x00ffffff },
75 { 0x40584c, 1, 0x04, 0x00000001 },
76 { 0x405850, 1, 0x04, 0x00000000 },
77 { 0x405900, 1, 0x04, 0x00000000 },
78 { 0x405908, 1, 0x04, 0x00000000 },
79 {}
80};
81
82static const struct gf100_gr_init
83gm204_gr_init_sked_0[] = {
84 { 0x407010, 1, 0x04, 0x00000000 },
85 { 0x407040, 1, 0x04, 0x80440434 },
86 { 0x407048, 1, 0x04, 0x00000008 },
87 {}
88};
89
90static const struct gf100_gr_init
91gm204_gr_init_tpccs_0[] = {
92 { 0x419d60, 1, 0x04, 0x0000003f },
93 { 0x419d88, 3, 0x04, 0x00000000 },
94 { 0x419dc4, 1, 0x04, 0x00000000 },
95 { 0x419dc8, 1, 0x04, 0x00000501 },
96 { 0x419dd0, 1, 0x04, 0x00000000 },
97 { 0x419dd4, 1, 0x04, 0x00000100 },
98 { 0x419dd8, 1, 0x04, 0x00000001 },
99 { 0x419ddc, 1, 0x04, 0x00000002 },
100 { 0x419de0, 1, 0x04, 0x00000001 },
101 { 0x419de8, 1, 0x04, 0x000000cc },
102 { 0x419dec, 1, 0x04, 0x00000000 },
103 { 0x419df0, 1, 0x04, 0x000000cc },
104 { 0x419df4, 1, 0x04, 0x00000000 },
105 { 0x419d0c, 1, 0x04, 0x00000000 },
106 { 0x419d10, 1, 0x04, 0x00000014 },
107 {}
108};
109
110static const struct gf100_gr_init
111gm204_gr_init_pe_0[] = {
112 { 0x419900, 1, 0x04, 0x000000ff },
113 { 0x419810, 1, 0x04, 0x00000000 },
114 { 0x41980c, 1, 0x04, 0x00000010 },
115 { 0x419844, 1, 0x04, 0x00000000 },
116 { 0x419838, 1, 0x04, 0x000000ff },
117 { 0x419850, 1, 0x04, 0x00000004 },
118 { 0x419854, 2, 0x04, 0x00000000 },
119 { 0x419894, 3, 0x04, 0x00100401 },
120 {}
121};
122
123static const struct gf100_gr_init
124gm204_gr_init_sm_0[] = {
125 { 0x419e30, 1, 0x04, 0x000000ff },
126 { 0x419e00, 1, 0x04, 0x00000000 },
127 { 0x419ea0, 1, 0x04, 0x00000000 },
128 { 0x419ee4, 1, 0x04, 0x00000000 },
129 { 0x419ea4, 1, 0x04, 0x00000100 },
130 { 0x419ea8, 1, 0x04, 0x00000000 },
131 { 0x419ee8, 1, 0x04, 0x00000091 },
132 { 0x419eb4, 1, 0x04, 0x00000000 },
133 { 0x419ebc, 2, 0x04, 0x00000000 },
134 { 0x419edc, 1, 0x04, 0x000c1810 },
135 { 0x419ed8, 1, 0x04, 0x00000000 },
136 { 0x419ee0, 1, 0x04, 0x00000000 },
137 {}
138};
139
140static const struct gf100_gr_init
141gm204_gr_init_l1c_1[] = {
142 { 0x419cf8, 2, 0x04, 0x00000000 },
143 {}
144};
145
146static const struct gf100_gr_init
147gm204_gr_init_sm_1[] = {
148 { 0x419f74, 1, 0x04, 0x00055155 },
149 { 0x419f80, 4, 0x04, 0x00000000 },
150 {}
151};
152
153static const struct gf100_gr_init
154gm204_gr_init_l1c_2[] = {
155 { 0x419ccc, 2, 0x04, 0x00000000 },
156 { 0x419c80, 1, 0x04, 0x3f006022 },
157 { 0x419c88, 1, 0x04, 0x00210000 },
158 {}
159};
160
161static const struct gf100_gr_init
162gm204_gr_init_pes_0[] = {
163 { 0x41be50, 1, 0x04, 0x000000ff },
164 { 0x41be04, 1, 0x04, 0x00000000 },
165 { 0x41be08, 1, 0x04, 0x00000004 },
166 { 0x41be0c, 1, 0x04, 0x00000008 },
167 { 0x41be10, 1, 0x04, 0x2e3b8bc7 },
168 { 0x41be14, 2, 0x04, 0x00000000 },
169 { 0x41be3c, 5, 0x04, 0x00100401 },
170 {}
171};
172
173static const struct gf100_gr_init
174gm204_gr_init_be_0[] = {
175 { 0x408890, 1, 0x04, 0x000000ff },
176 { 0x40880c, 1, 0x04, 0x00000000 },
177 { 0x408850, 1, 0x04, 0x00000004 },
178 { 0x408878, 1, 0x04, 0x01b4201c },
179 { 0x40887c, 1, 0x04, 0x80004c55 },
180 { 0x408880, 1, 0x04, 0x0018c258 },
181 { 0x408884, 1, 0x04, 0x0000160f },
182 { 0x408974, 1, 0x04, 0x000000ff },
183 { 0x408910, 9, 0x04, 0x00000000 },
184 { 0x408950, 1, 0x04, 0x00000000 },
185 { 0x408954, 1, 0x04, 0x0000ffff },
186 { 0x408958, 1, 0x04, 0x00000034 },
187 { 0x40895c, 1, 0x04, 0x84b17403 },
188 { 0x408960, 1, 0x04, 0x04c1884f },
189 { 0x408964, 1, 0x04, 0x04714445 },
190 { 0x408968, 1, 0x04, 0x0280802f },
191 { 0x40896c, 1, 0x04, 0x04304856 },
192 { 0x408970, 1, 0x04, 0x00012800 },
193 { 0x408984, 1, 0x04, 0x00000000 },
194 { 0x408988, 1, 0x04, 0x08040201 },
195 { 0x40898c, 1, 0x04, 0x80402010 },
196 {}
197};
198
199const struct gf100_gr_pack
200gm204_gr_pack_mmio[] = {
201 { gm204_gr_init_main_0 },
202 { gm204_gr_init_fe_0 },
203 { gf100_gr_init_pri_0 },
204 { gf100_gr_init_rstr2d_0 },
205 { gf100_gr_init_pd_0 },
206 { gm204_gr_init_ds_0 },
207 { gm107_gr_init_scc_0 },
208 { gm204_gr_init_sked_0 },
209 { gk110_gr_init_cwd_0 },
210 { gm107_gr_init_prop_0 },
211 { gk208_gr_init_gpc_unk_0 },
212 { gf100_gr_init_setup_0 },
213 { gf100_gr_init_crstr_0 },
214 { gm107_gr_init_setup_1 },
215 { gm107_gr_init_zcull_0 },
216 { gf100_gr_init_gpm_0 },
217 { gm107_gr_init_gpc_unk_1 },
218 { gf100_gr_init_gcc_0 },
219 { gm204_gr_init_tpccs_0 },
220 { gm107_gr_init_tex_0 },
221 { gm204_gr_init_pe_0 },
222 { gm107_gr_init_l1c_0 },
223 { gf100_gr_init_mpc_0 },
224 { gm204_gr_init_sm_0 },
225 { gm204_gr_init_l1c_1 },
226 { gm204_gr_init_sm_1 },
227 { gm204_gr_init_l1c_2 },
228 { gm204_gr_init_pes_0 },
229 { gm107_gr_init_wwdx_0 },
230 { gm107_gr_init_cbm_0 },
231 { gm204_gr_init_be_0 },
232 {}
233};
234
235const struct gf100_gr_pack *
236gm204_gr_data[] = {
237 gm204_gr_pack_mmio,
238 NULL
239};
240
241/*******************************************************************************
242 * PGRAPH engine/subdev functions
243 ******************************************************************************/
244
245static int
246gm204_gr_init_ctxctl(struct gf100_gr_priv *priv)
247{
248 return 0;
249}
250
251int
252gm204_gr_init(struct nvkm_object *object)
253{
254 struct gf100_gr_oclass *oclass = (void *)object->oclass;
255 struct gf100_gr_priv *priv = (void *)object;
256 const u32 magicgpc918 = DIV_ROUND_UP(0x00800000, priv->tpc_total);
257 u32 data[TPC_MAX / 8] = {};
258 u8 tpcnr[GPC_MAX];
259 int gpc, tpc, ppc, rop;
260 int ret, i;
261 u32 tmp;
262
263 ret = nvkm_gr_init(&priv->base);
264 if (ret)
265 return ret;
266
267 tmp = nv_rd32(priv, 0x100c80); /*XXX: mask? */
268 nv_wr32(priv, 0x418880, 0x00001000 | (tmp & 0x00000fff));
269 nv_wr32(priv, 0x418890, 0x00000000);
270 nv_wr32(priv, 0x418894, 0x00000000);
271 nv_wr32(priv, 0x4188b4, priv->unk4188b4->addr >> 8);
272 nv_wr32(priv, 0x4188b8, priv->unk4188b8->addr >> 8);
273 nv_mask(priv, 0x4188b0, 0x00040000, 0x00040000);
274
275 /*XXX: belongs in fb */
276 nv_wr32(priv, 0x100cc8, priv->unk4188b4->addr >> 8);
277 nv_wr32(priv, 0x100ccc, priv->unk4188b8->addr >> 8);
278 nv_mask(priv, 0x100cc4, 0x00040000, 0x00040000);
279
280 gf100_gr_mmio(priv, oclass->mmio);
281
282 gm107_gr_init_bios(priv);
283
284 nv_wr32(priv, GPC_UNIT(0, 0x3018), 0x00000001);
285
286 memset(data, 0x00, sizeof(data));
287 memcpy(tpcnr, priv->tpc_nr, sizeof(priv->tpc_nr));
288 for (i = 0, gpc = -1; i < priv->tpc_total; i++) {
289 do {
290 gpc = (gpc + 1) % priv->gpc_nr;
291 } while (!tpcnr[gpc]);
292 tpc = priv->tpc_nr[gpc] - tpcnr[gpc]--;
293
294 data[i / 8] |= tpc << ((i % 8) * 4);
295 }
296
297 nv_wr32(priv, GPC_BCAST(0x0980), data[0]);
298 nv_wr32(priv, GPC_BCAST(0x0984), data[1]);
299 nv_wr32(priv, GPC_BCAST(0x0988), data[2]);
300 nv_wr32(priv, GPC_BCAST(0x098c), data[3]);
301
302 for (gpc = 0; gpc < priv->gpc_nr; gpc++) {
303 nv_wr32(priv, GPC_UNIT(gpc, 0x0914),
304 priv->magic_not_rop_nr << 8 | priv->tpc_nr[gpc]);
305 nv_wr32(priv, GPC_UNIT(gpc, 0x0910), 0x00040000 |
306 priv->tpc_total);
307 nv_wr32(priv, GPC_UNIT(gpc, 0x0918), magicgpc918);
308 }
309
310 nv_wr32(priv, GPC_BCAST(0x3fd4), magicgpc918);
311 nv_wr32(priv, GPC_BCAST(0x08ac), nv_rd32(priv, 0x100800));
312 nv_wr32(priv, GPC_BCAST(0x033c), nv_rd32(priv, 0x100804));
313
314 nv_wr32(priv, 0x400500, 0x00010001);
315 nv_wr32(priv, 0x400100, 0xffffffff);
316 nv_wr32(priv, 0x40013c, 0xffffffff);
317 nv_wr32(priv, 0x400124, 0x00000002);
318 nv_wr32(priv, 0x409c24, 0x000e0000);
319 nv_wr32(priv, 0x405848, 0xc0000000);
320 nv_wr32(priv, 0x40584c, 0x00000001);
321 nv_wr32(priv, 0x404000, 0xc0000000);
322 nv_wr32(priv, 0x404600, 0xc0000000);
323 nv_wr32(priv, 0x408030, 0xc0000000);
324 nv_wr32(priv, 0x404490, 0xc0000000);
325 nv_wr32(priv, 0x406018, 0xc0000000);
326 nv_wr32(priv, 0x407020, 0x40000000);
327 nv_wr32(priv, 0x405840, 0xc0000000);
328 nv_wr32(priv, 0x405844, 0x00ffffff);
329 nv_mask(priv, 0x419cc0, 0x00000008, 0x00000008);
330
331 for (gpc = 0; gpc < priv->gpc_nr; gpc++) {
332 printk(KERN_ERR "ppc %d %d\n", gpc, priv->ppc_nr[gpc]);
333 for (ppc = 0; ppc < priv->ppc_nr[gpc]; ppc++)
334 nv_wr32(priv, PPC_UNIT(gpc, ppc, 0x038), 0xc0000000);
335 nv_wr32(priv, GPC_UNIT(gpc, 0x0420), 0xc0000000);
336 nv_wr32(priv, GPC_UNIT(gpc, 0x0900), 0xc0000000);
337 nv_wr32(priv, GPC_UNIT(gpc, 0x1028), 0xc0000000);
338 nv_wr32(priv, GPC_UNIT(gpc, 0x0824), 0xc0000000);
339 for (tpc = 0; tpc < priv->tpc_nr[gpc]; tpc++) {
340 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x508), 0xffffffff);
341 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x50c), 0xffffffff);
342 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x224), 0xc0000000);
343 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x48c), 0xc0000000);
344 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x084), 0xc0000000);
345 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x430), 0xc0000000);
346 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x644), 0x00dffffe);
347 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x64c), 0x00000005);
348 }
349 nv_wr32(priv, GPC_UNIT(gpc, 0x2c90), 0xffffffff);
350 nv_wr32(priv, GPC_UNIT(gpc, 0x2c94), 0xffffffff);
351 }
352
353 for (rop = 0; rop < priv->rop_nr; rop++) {
354 nv_wr32(priv, ROP_UNIT(rop, 0x144), 0x40000000);
355 nv_wr32(priv, ROP_UNIT(rop, 0x070), 0x40000000);
356 nv_wr32(priv, ROP_UNIT(rop, 0x204), 0xffffffff);
357 nv_wr32(priv, ROP_UNIT(rop, 0x208), 0xffffffff);
358 }
359
360 nv_wr32(priv, 0x400108, 0xffffffff);
361 nv_wr32(priv, 0x400138, 0xffffffff);
362 nv_wr32(priv, 0x400118, 0xffffffff);
363 nv_wr32(priv, 0x400130, 0xffffffff);
364 nv_wr32(priv, 0x40011c, 0xffffffff);
365 nv_wr32(priv, 0x400134, 0xffffffff);
366
367 nv_wr32(priv, 0x400054, 0x2c350f63);
368
369 gf100_gr_zbc_init(priv);
370
371 return gm204_gr_init_ctxctl(priv);
372}
373
374struct nvkm_oclass *
375gm204_gr_oclass = &(struct gf100_gr_oclass) {
376 .base.handle = NV_ENGINE(GR, 0x24),
377 .base.ofuncs = &(struct nvkm_ofuncs) {
378 .ctor = gf100_gr_ctor,
379 .dtor = gf100_gr_dtor,
380 .init = gm204_gr_init,
381 .fini = _nvkm_gr_fini,
382 },
383 .cclass = &gm204_grctx_oclass,
384 .sclass = gm204_gr_sclass,
385 .mmio = gm204_gr_pack_mmio,
386 .ppc_nr = 2,
387}.base;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gm206.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gm206.c
new file mode 100644
index 000000000000..04b9733d146a
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gm206.c
@@ -0,0 +1,40 @@
1/*
2 * Copyright 2015 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs <bskeggs@redhat.com>
23 */
24#include "gf100.h"
25#include "ctxgf100.h"
26
27struct nvkm_oclass *
28gm206_gr_oclass = &(struct gf100_gr_oclass) {
29 .base.handle = NV_ENGINE(GR, 0x26),
30 .base.ofuncs = &(struct nvkm_ofuncs) {
31 .ctor = gf100_gr_ctor,
32 .dtor = gf100_gr_dtor,
33 .init = gm204_gr_init,
34 .fini = _nvkm_gr_fini,
35 },
36 .cclass = &gm206_grctx_oclass,
37 .sclass = gm204_gr_sclass,
38 .mmio = gm204_gr_pack_mmio,
39 .ppc_nr = 2,
40}.base;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowacpi.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowacpi.c
index 1fbd93bbb561..f9d0eb5647fa 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowacpi.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowacpi.c
@@ -52,7 +52,7 @@ acpi_read_fast(void *data, u32 offset, u32 length, struct nvkm_bios *bios)
52 u32 start = offset & ~0x00000fff; 52 u32 start = offset & ~0x00000fff;
53 u32 fetch = limit - start; 53 u32 fetch = limit - start;
54 54
55 if (nvbios_extend(bios, limit) > 0) { 55 if (nvbios_extend(bios, limit) >= 0) {
56 int ret = nouveau_acpi_get_bios_chunk(bios->data, start, fetch); 56 int ret = nouveau_acpi_get_bios_chunk(bios->data, start, fetch);
57 if (ret == fetch) 57 if (ret == fetch)
58 return fetch; 58 return fetch;
@@ -73,7 +73,7 @@ acpi_read_slow(void *data, u32 offset, u32 length, struct nvkm_bios *bios)
73 u32 start = offset & ~0xfff; 73 u32 start = offset & ~0xfff;
74 u32 fetch = 0; 74 u32 fetch = 0;
75 75
76 if (nvbios_extend(bios, limit) > 0) { 76 if (nvbios_extend(bios, limit) >= 0) {
77 while (start + fetch < limit) { 77 while (start + fetch < limit) {
78 int ret = nouveau_acpi_get_bios_chunk(bios->data, 78 int ret = nouveau_acpi_get_bios_chunk(bios->data,
79 start + fetch, 79 start + fetch,
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bus/hwsq.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bus/hwsq.c
index b8853bf16b23..7622b41619a0 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bus/hwsq.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bus/hwsq.c
@@ -29,7 +29,7 @@ struct nvkm_hwsq {
29 u32 data; 29 u32 data;
30 struct { 30 struct {
31 u8 data[512]; 31 u8 data[512];
32 u8 size; 32 u16 size;
33 } c; 33 } c;
34}; 34};
35 35
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bus/hwsq.h b/drivers/gpu/drm/nouveau/nvkm/subdev/bus/hwsq.h
index 3394a5ea8a9f..ebf709c27e3a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bus/hwsq.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bus/hwsq.h
@@ -11,17 +11,34 @@ struct hwsq {
11struct hwsq_reg { 11struct hwsq_reg {
12 int sequence; 12 int sequence;
13 bool force; 13 bool force;
14 u32 addr[2]; 14 u32 addr;
15 u32 stride; /* in bytes */
16 u32 mask;
15 u32 data; 17 u32 data;
16}; 18};
17 19
18static inline struct hwsq_reg 20static inline struct hwsq_reg
21hwsq_stride(u32 addr, u32 stride, u32 mask)
22{
23 return (struct hwsq_reg) {
24 .sequence = 0,
25 .force = 0,
26 .addr = addr,
27 .stride = stride,
28 .mask = mask,
29 .data = 0xdeadbeef,
30 };
31}
32
33static inline struct hwsq_reg
19hwsq_reg2(u32 addr1, u32 addr2) 34hwsq_reg2(u32 addr1, u32 addr2)
20{ 35{
21 return (struct hwsq_reg) { 36 return (struct hwsq_reg) {
22 .sequence = 0, 37 .sequence = 0,
23 .force = 0, 38 .force = 0,
24 .addr = { addr1, addr2 }, 39 .addr = addr1,
40 .stride = addr2 - addr1,
41 .mask = 0x3,
25 .data = 0xdeadbeef, 42 .data = 0xdeadbeef,
26 }; 43 };
27} 44}
@@ -29,7 +46,14 @@ hwsq_reg2(u32 addr1, u32 addr2)
29static inline struct hwsq_reg 46static inline struct hwsq_reg
30hwsq_reg(u32 addr) 47hwsq_reg(u32 addr)
31{ 48{
32 return hwsq_reg2(addr, addr); 49 return (struct hwsq_reg) {
50 .sequence = 0,
51 .force = 0,
52 .addr = addr,
53 .stride = 0,
54 .mask = 0x1,
55 .data = 0xdeadbeef,
56 };
33} 57}
34 58
35static inline int 59static inline int
@@ -62,18 +86,24 @@ static inline u32
62hwsq_rd32(struct hwsq *ram, struct hwsq_reg *reg) 86hwsq_rd32(struct hwsq *ram, struct hwsq_reg *reg)
63{ 87{
64 if (reg->sequence != ram->sequence) 88 if (reg->sequence != ram->sequence)
65 reg->data = nv_rd32(ram->subdev, reg->addr[0]); 89 reg->data = nv_rd32(ram->subdev, reg->addr);
66 return reg->data; 90 return reg->data;
67} 91}
68 92
69static inline void 93static inline void
70hwsq_wr32(struct hwsq *ram, struct hwsq_reg *reg, u32 data) 94hwsq_wr32(struct hwsq *ram, struct hwsq_reg *reg, u32 data)
71{ 95{
96 u32 mask, off = 0;
97
72 reg->sequence = ram->sequence; 98 reg->sequence = ram->sequence;
73 reg->data = data; 99 reg->data = data;
74 if (reg->addr[0] != reg->addr[1]) 100
75 nvkm_hwsq_wr32(ram->hwsq, reg->addr[1], reg->data); 101 for (mask = reg->mask; mask > 0; mask = (mask & ~1) >> 1) {
76 nvkm_hwsq_wr32(ram->hwsq, reg->addr[0], reg->data); 102 if (mask & 1)
103 nvkm_hwsq_wr32(ram->hwsq, reg->addr+off, reg->data);
104
105 off += reg->stride;
106 }
77} 107}
78 108
79static inline void 109static inline void
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
index b24a9cc04b73..39a83d82e0cd 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
@@ -184,7 +184,7 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)
184 nv_debug(clk, "setting performance state %d\n", pstatei); 184 nv_debug(clk, "setting performance state %d\n", pstatei);
185 clk->pstate = pstatei; 185 clk->pstate = pstatei;
186 186
187 if (pfb->ram->calc) { 187 if (pfb->ram && pfb->ram->calc) {
188 int khz = pstate->base.domain[nv_clk_src_mem]; 188 int khz = pstate->base.domain[nv_clk_src_mem];
189 do { 189 do {
190 ret = pfb->ram->calc(pfb, khz); 190 ret = pfb->ram->calc(pfb, khz);
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/nv04.h b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/nv04.h
index 14a51a9ff7d0..7c63abf11e22 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/nv04.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/nv04.h
@@ -5,7 +5,7 @@ struct nvkm_pll_vals;
5 5
6struct nv04_devinit_priv { 6struct nv04_devinit_priv {
7 struct nvkm_devinit base; 7 struct nvkm_devinit base;
8 u8 owner; 8 int owner;
9}; 9};
10 10
11int nv04_devinit_ctor(struct nvkm_object *, struct nvkm_object *, 11int nv04_devinit_ctor(struct nvkm_object *, struct nvkm_object *,
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/Kbuild b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/Kbuild
index 904d601e8a50..d6be4c6c5408 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/Kbuild
@@ -37,7 +37,6 @@ nvkm-y += nvkm/subdev/fb/ramgt215.o
37nvkm-y += nvkm/subdev/fb/rammcp77.o 37nvkm-y += nvkm/subdev/fb/rammcp77.o
38nvkm-y += nvkm/subdev/fb/ramgf100.o 38nvkm-y += nvkm/subdev/fb/ramgf100.o
39nvkm-y += nvkm/subdev/fb/ramgk104.o 39nvkm-y += nvkm/subdev/fb/ramgk104.o
40nvkm-y += nvkm/subdev/fb/ramgk20a.o
41nvkm-y += nvkm/subdev/fb/ramgm107.o 40nvkm-y += nvkm/subdev/fb/ramgm107.o
42nvkm-y += nvkm/subdev/fb/sddr2.o 41nvkm-y += nvkm/subdev/fb/sddr2.o
43nvkm-y += nvkm/subdev/fb/sddr3.o 42nvkm-y += nvkm/subdev/fb/sddr3.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/base.c
index 16589fa613cd..61fde43dab71 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/base.c
@@ -55,9 +55,11 @@ _nvkm_fb_fini(struct nvkm_object *object, bool suspend)
55 struct nvkm_fb *pfb = (void *)object; 55 struct nvkm_fb *pfb = (void *)object;
56 int ret; 56 int ret;
57 57
58 ret = nv_ofuncs(pfb->ram)->fini(nv_object(pfb->ram), suspend); 58 if (pfb->ram) {
59 if (ret && suspend) 59 ret = nv_ofuncs(pfb->ram)->fini(nv_object(pfb->ram), suspend);
60 return ret; 60 if (ret && suspend)
61 return ret;
62 }
61 63
62 return nvkm_subdev_fini(&pfb->base, suspend); 64 return nvkm_subdev_fini(&pfb->base, suspend);
63} 65}
@@ -72,9 +74,11 @@ _nvkm_fb_init(struct nvkm_object *object)
72 if (ret) 74 if (ret)
73 return ret; 75 return ret;
74 76
75 ret = nv_ofuncs(pfb->ram)->init(nv_object(pfb->ram)); 77 if (pfb->ram) {
76 if (ret) 78 ret = nv_ofuncs(pfb->ram)->init(nv_object(pfb->ram));
77 return ret; 79 if (ret)
80 return ret;
81 }
78 82
79 for (i = 0; i < pfb->tile.regions; i++) 83 for (i = 0; i < pfb->tile.regions; i++)
80 pfb->tile.prog(pfb, i, &pfb->tile.region[i]); 84 pfb->tile.prog(pfb, i, &pfb->tile.region[i]);
@@ -91,9 +95,12 @@ _nvkm_fb_dtor(struct nvkm_object *object)
91 for (i = 0; i < pfb->tile.regions; i++) 95 for (i = 0; i < pfb->tile.regions; i++)
92 pfb->tile.fini(pfb, i, &pfb->tile.region[i]); 96 pfb->tile.fini(pfb, i, &pfb->tile.region[i]);
93 nvkm_mm_fini(&pfb->tags); 97 nvkm_mm_fini(&pfb->tags);
94 nvkm_mm_fini(&pfb->vram);
95 98
96 nvkm_object_ref(NULL, (struct nvkm_object **)&pfb->ram); 99 if (pfb->ram) {
100 nvkm_mm_fini(&pfb->vram);
101 nvkm_object_ref(NULL, (struct nvkm_object **)&pfb->ram);
102 }
103
97 nvkm_subdev_destroy(&pfb->base); 104 nvkm_subdev_destroy(&pfb->base);
98} 105}
99 106
@@ -127,6 +134,9 @@ nvkm_fb_create_(struct nvkm_object *parent, struct nvkm_object *engine,
127 134
128 pfb->memtype_valid = impl->memtype; 135 pfb->memtype_valid = impl->memtype;
129 136
137 if (!impl->ram)
138 return 0;
139
130 ret = nvkm_object_ctor(nv_object(pfb), NULL, impl->ram, NULL, 0, &ram); 140 ret = nvkm_object_ctor(nv_object(pfb), NULL, impl->ram, NULL, 0, &ram);
131 if (ret) { 141 if (ret) {
132 nv_fatal(pfb, "error detecting memory configuration!!\n"); 142 nv_fatal(pfb, "error detecting memory configuration!!\n");
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gk20a.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gk20a.c
index 6762847c05e8..a5d7857d3898 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gk20a.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gk20a.c
@@ -65,5 +65,4 @@ gk20a_fb_oclass = &(struct nvkm_fb_impl) {
65 .fini = _nvkm_fb_fini, 65 .fini = _nvkm_fb_fini,
66 }, 66 },
67 .memtype = gf100_fb_memtype_valid, 67 .memtype = gf100_fb_memtype_valid,
68 .ram = &gk20a_ram_oclass,
69}.base; 68}.base;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/priv.h b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/priv.h
index d82da02daa1f..485c4b64819a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/priv.h
@@ -32,7 +32,6 @@ extern struct nvkm_oclass gt215_ram_oclass;
32extern struct nvkm_oclass mcp77_ram_oclass; 32extern struct nvkm_oclass mcp77_ram_oclass;
33extern struct nvkm_oclass gf100_ram_oclass; 33extern struct nvkm_oclass gf100_ram_oclass;
34extern struct nvkm_oclass gk104_ram_oclass; 34extern struct nvkm_oclass gk104_ram_oclass;
35extern struct nvkm_oclass gk20a_ram_oclass;
36extern struct nvkm_oclass gm107_ram_oclass; 35extern struct nvkm_oclass gm107_ram_oclass;
37 36
38int nvkm_sddr2_calc(struct nvkm_ram *ram); 37int nvkm_sddr2_calc(struct nvkm_ram *ram);
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgk20a.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgk20a.c
deleted file mode 100644
index 5f30db140b47..000000000000
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgk20a.c
+++ /dev/null
@@ -1,149 +0,0 @@
1/*
2 * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22#include "priv.h"
23
24#include <core/device.h>
25
26struct gk20a_mem {
27 struct nvkm_mem base;
28 void *cpuaddr;
29 dma_addr_t handle;
30};
31#define to_gk20a_mem(m) container_of(m, struct gk20a_mem, base)
32
33static void
34gk20a_ram_put(struct nvkm_fb *pfb, struct nvkm_mem **pmem)
35{
36 struct device *dev = nv_device_base(nv_device(pfb));
37 struct gk20a_mem *mem = to_gk20a_mem(*pmem);
38
39 *pmem = NULL;
40 if (unlikely(mem == NULL))
41 return;
42
43 if (likely(mem->cpuaddr))
44 dma_free_coherent(dev, mem->base.size << PAGE_SHIFT,
45 mem->cpuaddr, mem->handle);
46
47 kfree(mem->base.pages);
48 kfree(mem);
49}
50
51static int
52gk20a_ram_get(struct nvkm_fb *pfb, u64 size, u32 align, u32 ncmin,
53 u32 memtype, struct nvkm_mem **pmem)
54{
55 struct device *dev = nv_device_base(nv_device(pfb));
56 struct gk20a_mem *mem;
57 u32 type = memtype & 0xff;
58 u32 npages, order;
59 int i;
60
61 nv_debug(pfb, "%s: size: %llx align: %x, ncmin: %x\n", __func__, size,
62 align, ncmin);
63
64 npages = size >> PAGE_SHIFT;
65 if (npages == 0)
66 npages = 1;
67
68 if (align == 0)
69 align = PAGE_SIZE;
70 align >>= PAGE_SHIFT;
71
72 /* round alignment to the next power of 2, if needed */
73 order = fls(align);
74 if ((align & (align - 1)) == 0)
75 order--;
76 align = BIT(order);
77
78 /* ensure returned address is correctly aligned */
79 npages = max(align, npages);
80
81 mem = kzalloc(sizeof(*mem), GFP_KERNEL);
82 if (!mem)
83 return -ENOMEM;
84
85 mem->base.size = npages;
86 mem->base.memtype = type;
87
88 mem->base.pages = kzalloc(sizeof(dma_addr_t) * npages, GFP_KERNEL);
89 if (!mem->base.pages) {
90 kfree(mem);
91 return -ENOMEM;
92 }
93
94 *pmem = &mem->base;
95
96 mem->cpuaddr = dma_alloc_coherent(dev, npages << PAGE_SHIFT,
97 &mem->handle, GFP_KERNEL);
98 if (!mem->cpuaddr) {
99 nv_error(pfb, "%s: cannot allocate memory!\n", __func__);
100 gk20a_ram_put(pfb, pmem);
101 return -ENOMEM;
102 }
103
104 align <<= PAGE_SHIFT;
105
106 /* alignment check */
107 if (unlikely(mem->handle & (align - 1)))
108 nv_warn(pfb, "memory not aligned as requested: %pad (0x%x)\n",
109 &mem->handle, align);
110
111 nv_debug(pfb, "alloc size: 0x%x, align: 0x%x, paddr: %pad, vaddr: %p\n",
112 npages << PAGE_SHIFT, align, &mem->handle, mem->cpuaddr);
113
114 for (i = 0; i < npages; i++)
115 mem->base.pages[i] = mem->handle + (PAGE_SIZE * i);
116
117 mem->base.offset = (u64)mem->base.pages[0];
118 return 0;
119}
120
121static int
122gk20a_ram_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
123 struct nvkm_oclass *oclass, void *data, u32 datasize,
124 struct nvkm_object **pobject)
125{
126 struct nvkm_ram *ram;
127 int ret;
128
129 ret = nvkm_ram_create(parent, engine, oclass, &ram);
130 *pobject = nv_object(ram);
131 if (ret)
132 return ret;
133 ram->type = NV_MEM_TYPE_STOLEN;
134 ram->size = get_num_physpages() << PAGE_SHIFT;
135
136 ram->get = gk20a_ram_get;
137 ram->put = gk20a_ram_put;
138 return 0;
139}
140
141struct nvkm_oclass
142gk20a_ram_oclass = {
143 .ofuncs = &(struct nvkm_ofuncs) {
144 .ctor = gk20a_ram_ctor,
145 .dtor = _nvkm_ram_dtor,
146 .init = _nvkm_ram_init,
147 .fini = _nvkm_ram_fini,
148 },
149};
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fuse/gm107.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fuse/gm107.c
index ba19158a5912..0b256aa4960f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fuse/gm107.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fuse/gm107.c
@@ -45,10 +45,8 @@ gm107_fuse_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
45 45
46 ret = nvkm_fuse_create(parent, engine, oclass, &priv); 46 ret = nvkm_fuse_create(parent, engine, oclass, &priv);
47 *pobject = nv_object(priv); 47 *pobject = nv_object(priv);
48 if (ret)
49 return ret;
50 48
51 return 0; 49 return ret;
52} 50}
53 51
54struct nvkm_oclass 52struct nvkm_oclass
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/Kbuild b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/Kbuild
index e6f35abe7879..13bb7fc0a569 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/Kbuild
@@ -2,3 +2,4 @@ nvkm-y += nvkm/subdev/instmem/base.o
2nvkm-y += nvkm/subdev/instmem/nv04.o 2nvkm-y += nvkm/subdev/instmem/nv04.o
3nvkm-y += nvkm/subdev/instmem/nv40.o 3nvkm-y += nvkm/subdev/instmem/nv40.o
4nvkm-y += nvkm/subdev/instmem/nv50.o 4nvkm-y += nvkm/subdev/instmem/nv50.o
5nvkm-y += nvkm/subdev/instmem/gk20a.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c
new file mode 100644
index 000000000000..dd0994d9ebfc
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c
@@ -0,0 +1,440 @@
1/*
2 * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22
23/*
24 * GK20A does not have dedicated video memory, and to accurately represent this
25 * fact Nouveau will not create a RAM device for it. Therefore its instmem
26 * implementation must be done directly on top of system memory, while providing
27 * coherent read and write operations.
28 *
29 * Instmem can be allocated through two means:
30 * 1) If an IOMMU mapping has been probed, the IOMMU API is used to make memory
31 * pages contiguous to the GPU. This is the preferred way.
32 * 2) If no IOMMU mapping is probed, the DMA API is used to allocate physically
33 * contiguous memory.
34 *
35 * In both cases CPU read and writes are performed using PRAMIN (i.e. using the
36 * GPU path) to ensure these operations are coherent for the GPU. This allows us
37 * to use more "relaxed" allocation parameters when using the DMA API, since we
38 * never need a kernel mapping.
39 */
40
41#include <subdev/fb.h>
42#include <core/mm.h>
43#include <core/device.h>
44
45#ifdef __KERNEL__
46#include <linux/dma-attrs.h>
47#include <linux/iommu.h>
48#include <nouveau_platform.h>
49#endif
50
51#include "priv.h"
52
53struct gk20a_instobj_priv {
54 struct nvkm_instobj base;
55 /* Must be second member here - see nouveau_gpuobj_map_vm() */
56 struct nvkm_mem *mem;
57 /* Pointed by mem */
58 struct nvkm_mem _mem;
59};
60
61/*
62 * Used for objects allocated using the DMA API
63 */
64struct gk20a_instobj_dma {
65 struct gk20a_instobj_priv base;
66
67 void *cpuaddr;
68 dma_addr_t handle;
69 struct nvkm_mm_node r;
70};
71
72/*
73 * Used for objects flattened using the IOMMU API
74 */
75struct gk20a_instobj_iommu {
76 struct gk20a_instobj_priv base;
77
78 /* array of base.mem->size pages */
79 struct page *pages[];
80};
81
82struct gk20a_instmem_priv {
83 struct nvkm_instmem base;
84 spinlock_t lock;
85 u64 addr;
86
87 /* Only used if IOMMU if present */
88 struct mutex *mm_mutex;
89 struct nvkm_mm *mm;
90 struct iommu_domain *domain;
91 unsigned long iommu_pgshift;
92
93 /* Only used by DMA API */
94 struct dma_attrs attrs;
95};
96
97/*
98 * Use PRAMIN to read/write data and avoid coherency issues.
99 * PRAMIN uses the GPU path and ensures data will always be coherent.
100 *
101 * A dynamic mapping based solution would be desirable in the future, but
102 * the issue remains of how to maintain coherency efficiently. On ARM it is
103 * not easy (if possible at all?) to create uncached temporary mappings.
104 */
105
106static u32
107gk20a_instobj_rd32(struct nvkm_object *object, u64 offset)
108{
109 struct gk20a_instmem_priv *priv = (void *)nvkm_instmem(object);
110 struct gk20a_instobj_priv *node = (void *)object;
111 unsigned long flags;
112 u64 base = (node->mem->offset + offset) & 0xffffff00000ULL;
113 u64 addr = (node->mem->offset + offset) & 0x000000fffffULL;
114 u32 data;
115
116 spin_lock_irqsave(&priv->lock, flags);
117 if (unlikely(priv->addr != base)) {
118 nv_wr32(priv, 0x001700, base >> 16);
119 priv->addr = base;
120 }
121 data = nv_rd32(priv, 0x700000 + addr);
122 spin_unlock_irqrestore(&priv->lock, flags);
123 return data;
124}
125
126static void
127gk20a_instobj_wr32(struct nvkm_object *object, u64 offset, u32 data)
128{
129 struct gk20a_instmem_priv *priv = (void *)nvkm_instmem(object);
130 struct gk20a_instobj_priv *node = (void *)object;
131 unsigned long flags;
132 u64 base = (node->mem->offset + offset) & 0xffffff00000ULL;
133 u64 addr = (node->mem->offset + offset) & 0x000000fffffULL;
134
135 spin_lock_irqsave(&priv->lock, flags);
136 if (unlikely(priv->addr != base)) {
137 nv_wr32(priv, 0x001700, base >> 16);
138 priv->addr = base;
139 }
140 nv_wr32(priv, 0x700000 + addr, data);
141 spin_unlock_irqrestore(&priv->lock, flags);
142}
143
144static void
145gk20a_instobj_dtor_dma(struct gk20a_instobj_priv *_node)
146{
147 struct gk20a_instobj_dma *node = (void *)_node;
148 struct gk20a_instmem_priv *priv = (void *)nvkm_instmem(node);
149 struct device *dev = nv_device_base(nv_device(priv));
150
151 if (unlikely(!node->cpuaddr))
152 return;
153
154 dma_free_attrs(dev, _node->mem->size << PAGE_SHIFT, node->cpuaddr,
155 node->handle, &priv->attrs);
156}
157
158static void
159gk20a_instobj_dtor_iommu(struct gk20a_instobj_priv *_node)
160{
161 struct gk20a_instobj_iommu *node = (void *)_node;
162 struct gk20a_instmem_priv *priv = (void *)nvkm_instmem(node);
163 struct nvkm_mm_node *r;
164 int i;
165
166 if (unlikely(list_empty(&_node->mem->regions)))
167 return;
168
169 r = list_first_entry(&_node->mem->regions, struct nvkm_mm_node,
170 rl_entry);
171
172 /* clear bit 34 to unmap pages */
173 r->offset &= ~BIT(34 - priv->iommu_pgshift);
174
175 /* Unmap pages from GPU address space and free them */
176 for (i = 0; i < _node->mem->size; i++) {
177 iommu_unmap(priv->domain,
178 (r->offset + i) << priv->iommu_pgshift, PAGE_SIZE);
179 __free_page(node->pages[i]);
180 }
181
182 /* Release area from GPU address space */
183 mutex_lock(priv->mm_mutex);
184 nvkm_mm_free(priv->mm, &r);
185 mutex_unlock(priv->mm_mutex);
186}
187
188static void
189gk20a_instobj_dtor(struct nvkm_object *object)
190{
191 struct gk20a_instobj_priv *node = (void *)object;
192 struct gk20a_instmem_priv *priv = (void *)nvkm_instmem(node);
193
194 if (priv->domain)
195 gk20a_instobj_dtor_iommu(node);
196 else
197 gk20a_instobj_dtor_dma(node);
198
199 nvkm_instobj_destroy(&node->base);
200}
201
202static int
203gk20a_instobj_ctor_dma(struct nvkm_object *parent, struct nvkm_object *engine,
204 struct nvkm_oclass *oclass, u32 npages, u32 align,
205 struct gk20a_instobj_priv **_node)
206{
207 struct gk20a_instobj_dma *node;
208 struct gk20a_instmem_priv *priv = (void *)nvkm_instmem(parent);
209 struct device *dev = nv_device_base(nv_device(parent));
210 int ret;
211
212 ret = nvkm_instobj_create_(parent, engine, oclass, sizeof(*node),
213 (void **)&node);
214 *_node = &node->base;
215 if (ret)
216 return ret;
217
218 node->cpuaddr = dma_alloc_attrs(dev, npages << PAGE_SHIFT,
219 &node->handle, GFP_KERNEL,
220 &priv->attrs);
221 if (!node->cpuaddr) {
222 nv_error(priv, "cannot allocate DMA memory\n");
223 return -ENOMEM;
224 }
225
226 /* alignment check */
227 if (unlikely(node->handle & (align - 1)))
228 nv_warn(priv, "memory not aligned as requested: %pad (0x%x)\n",
229 &node->handle, align);
230
231 /* present memory for being mapped using small pages */
232 node->r.type = 12;
233 node->r.offset = node->handle >> 12;
234 node->r.length = (npages << PAGE_SHIFT) >> 12;
235
236 node->base._mem.offset = node->handle;
237
238 INIT_LIST_HEAD(&node->base._mem.regions);
239 list_add_tail(&node->r.rl_entry, &node->base._mem.regions);
240
241 return 0;
242}
243
244static int
245gk20a_instobj_ctor_iommu(struct nvkm_object *parent, struct nvkm_object *engine,
246 struct nvkm_oclass *oclass, u32 npages, u32 align,
247 struct gk20a_instobj_priv **_node)
248{
249 struct gk20a_instobj_iommu *node;
250 struct gk20a_instmem_priv *priv = (void *)nvkm_instmem(parent);
251 struct nvkm_mm_node *r;
252 int ret;
253 int i;
254
255 ret = nvkm_instobj_create_(parent, engine, oclass,
256 sizeof(*node) + sizeof(node->pages[0]) * npages,
257 (void **)&node);
258 *_node = &node->base;
259 if (ret)
260 return ret;
261
262 /* Allocate backing memory */
263 for (i = 0; i < npages; i++) {
264 struct page *p = alloc_page(GFP_KERNEL);
265
266 if (p == NULL) {
267 ret = -ENOMEM;
268 goto free_pages;
269 }
270 node->pages[i] = p;
271 }
272
273 mutex_lock(priv->mm_mutex);
274 /* Reserve area from GPU address space */
275 ret = nvkm_mm_head(priv->mm, 0, 1, npages, npages,
276 align >> priv->iommu_pgshift, &r);
277 mutex_unlock(priv->mm_mutex);
278 if (ret) {
279 nv_error(priv, "virtual space is full!\n");
280 goto free_pages;
281 }
282
283 /* Map into GPU address space */
284 for (i = 0; i < npages; i++) {
285 struct page *p = node->pages[i];
286 u32 offset = (r->offset + i) << priv->iommu_pgshift;
287
288 ret = iommu_map(priv->domain, offset, page_to_phys(p),
289 PAGE_SIZE, IOMMU_READ | IOMMU_WRITE);
290 if (ret < 0) {
291 nv_error(priv, "IOMMU mapping failure: %d\n", ret);
292
293 while (i-- > 0) {
294 offset -= PAGE_SIZE;
295 iommu_unmap(priv->domain, offset, PAGE_SIZE);
296 }
297 goto release_area;
298 }
299 }
300
301 /* Bit 34 tells that an address is to be resolved through the IOMMU */
302 r->offset |= BIT(34 - priv->iommu_pgshift);
303
304 node->base._mem.offset = ((u64)r->offset) << priv->iommu_pgshift;
305
306 INIT_LIST_HEAD(&node->base._mem.regions);
307 list_add_tail(&r->rl_entry, &node->base._mem.regions);
308
309 return 0;
310
311release_area:
312 mutex_lock(priv->mm_mutex);
313 nvkm_mm_free(priv->mm, &r);
314 mutex_unlock(priv->mm_mutex);
315
316free_pages:
317 for (i = 0; i < npages && node->pages[i] != NULL; i++)
318 __free_page(node->pages[i]);
319
320 return ret;
321}
322
323static int
324gk20a_instobj_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
325 struct nvkm_oclass *oclass, void *data, u32 _size,
326 struct nvkm_object **pobject)
327{
328 struct nvkm_instobj_args *args = data;
329 struct gk20a_instmem_priv *priv = (void *)nvkm_instmem(parent);
330 struct gk20a_instobj_priv *node;
331 u32 size, align;
332 int ret;
333
334 nv_debug(parent, "%s (%s): size: %x align: %x\n", __func__,
335 priv->domain ? "IOMMU" : "DMA", args->size, args->align);
336
337 /* Round size and align to page bounds */
338 size = max(roundup(args->size, PAGE_SIZE), PAGE_SIZE);
339 align = max(roundup(args->align, PAGE_SIZE), PAGE_SIZE);
340
341 if (priv->domain)
342 ret = gk20a_instobj_ctor_iommu(parent, engine, oclass,
343 size >> PAGE_SHIFT, align, &node);
344 else
345 ret = gk20a_instobj_ctor_dma(parent, engine, oclass,
346 size >> PAGE_SHIFT, align, &node);
347 *pobject = nv_object(node);
348 if (ret)
349 return ret;
350
351 node->mem = &node->_mem;
352
353 /* present memory for being mapped using small pages */
354 node->mem->size = size >> 12;
355 node->mem->memtype = 0;
356 node->mem->page_shift = 12;
357
358 node->base.addr = node->mem->offset;
359 node->base.size = size;
360
361 nv_debug(parent, "alloc size: 0x%x, align: 0x%x, gaddr: 0x%llx\n",
362 size, align, node->mem->offset);
363
364 return 0;
365}
366
367static struct nvkm_instobj_impl
368gk20a_instobj_oclass = {
369 .base.ofuncs = &(struct nvkm_ofuncs) {
370 .ctor = gk20a_instobj_ctor,
371 .dtor = gk20a_instobj_dtor,
372 .init = _nvkm_instobj_init,
373 .fini = _nvkm_instobj_fini,
374 .rd32 = gk20a_instobj_rd32,
375 .wr32 = gk20a_instobj_wr32,
376 },
377};
378
379
380
381static int
382gk20a_instmem_fini(struct nvkm_object *object, bool suspend)
383{
384 struct gk20a_instmem_priv *priv = (void *)object;
385 priv->addr = ~0ULL;
386 return nvkm_instmem_fini(&priv->base, suspend);
387}
388
389static int
390gk20a_instmem_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
391 struct nvkm_oclass *oclass, void *data, u32 size,
392 struct nvkm_object **pobject)
393{
394 struct gk20a_instmem_priv *priv;
395 struct nouveau_platform_device *plat;
396 int ret;
397
398 ret = nvkm_instmem_create(parent, engine, oclass, &priv);
399 *pobject = nv_object(priv);
400 if (ret)
401 return ret;
402
403 spin_lock_init(&priv->lock);
404
405 plat = nv_device_to_platform(nv_device(parent));
406 if (plat->gpu->iommu.domain) {
407 priv->domain = plat->gpu->iommu.domain;
408 priv->mm = plat->gpu->iommu.mm;
409 priv->iommu_pgshift = plat->gpu->iommu.pgshift;
410 priv->mm_mutex = &plat->gpu->iommu.mutex;
411
412 nv_info(priv, "using IOMMU\n");
413 } else {
414 init_dma_attrs(&priv->attrs);
415 /*
416 * We will access instmem through PRAMIN and thus do not need a
417 * consistent CPU pointer or kernel mapping
418 */
419 dma_set_attr(DMA_ATTR_NON_CONSISTENT, &priv->attrs);
420 dma_set_attr(DMA_ATTR_WEAK_ORDERING, &priv->attrs);
421 dma_set_attr(DMA_ATTR_WRITE_COMBINE, &priv->attrs);
422 dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &priv->attrs);
423
424 nv_info(priv, "using DMA API\n");
425 }
426
427 return 0;
428}
429
430struct nvkm_oclass *
431gk20a_instmem_oclass = &(struct nvkm_instmem_impl) {
432 .base.handle = NV_SUBDEV(INSTMEM, 0xea),
433 .base.ofuncs = &(struct nvkm_ofuncs) {
434 .ctor = gk20a_instmem_ctor,
435 .dtor = _nvkm_instmem_dtor,
436 .init = _nvkm_instmem_init,
437 .fini = gk20a_instmem_fini,
438 },
439 .instobj = &gk20a_instobj_oclass.base,
440}.base;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gf100.c b/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gf100.c
index 8e7cc6200d60..7fb5ea0314cb 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gf100.c
@@ -136,7 +136,8 @@ gf100_ltc_dtor(struct nvkm_object *object)
136 struct nvkm_ltc_priv *priv = (void *)object; 136 struct nvkm_ltc_priv *priv = (void *)object;
137 137
138 nvkm_mm_fini(&priv->tags); 138 nvkm_mm_fini(&priv->tags);
139 nvkm_mm_free(&pfb->vram, &priv->tag_ram); 139 if (pfb->ram)
140 nvkm_mm_free(&pfb->vram, &priv->tag_ram);
140 141
141 nvkm_ltc_destroy(priv); 142 nvkm_ltc_destroy(priv);
142} 143}
@@ -149,6 +150,12 @@ gf100_ltc_init_tag_ram(struct nvkm_fb *pfb, struct nvkm_ltc_priv *priv)
149 u32 tag_size, tag_margin, tag_align; 150 u32 tag_size, tag_margin, tag_align;
150 int ret; 151 int ret;
151 152
153 /* No VRAM, no tags for now. */
154 if (!pfb->ram) {
155 priv->num_tags = 0;
156 goto mm_init;
157 }
158
152 /* tags for 1/4 of VRAM should be enough (8192/4 per GiB of VRAM) */ 159 /* tags for 1/4 of VRAM should be enough (8192/4 per GiB of VRAM) */
153 priv->num_tags = (pfb->ram->size >> 17) / 4; 160 priv->num_tags = (pfb->ram->size >> 17) / 4;
154 if (priv->num_tags > (1 << 17)) 161 if (priv->num_tags > (1 << 17))
@@ -183,6 +190,7 @@ gf100_ltc_init_tag_ram(struct nvkm_fb *pfb, struct nvkm_ltc_priv *priv)
183 priv->tag_base = tag_base; 190 priv->tag_base = tag_base;
184 } 191 }
185 192
193mm_init:
186 ret = nvkm_mm_init(&priv->tags, 0, priv->num_tags, 1); 194 ret = nvkm_mm_init(&priv->tags, 0, priv->num_tags, 1);
187 return ret; 195 return ret;
188} 196}
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mxm/nv50.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mxm/nv50.c
index 42cac13ca629..f20e4ca87e17 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mxm/nv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mxm/nv50.c
@@ -182,7 +182,7 @@ mxm_show_unmatched(struct nvkm_mxm *mxm, u8 *data, void *info)
182{ 182{
183 u64 desc = *(u64 *)data; 183 u64 desc = *(u64 *)data;
184 if ((desc & 0xf0) != 0xf0) 184 if ((desc & 0xf0) != 0xf0)
185 nv_info(mxm, "unmatched output device 0x%016llx\n", desc); 185 nv_info(mxm, "unmatched output device 0x%016llx\n", desc);
186 return true; 186 return true;
187} 187}
188 188
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/Kbuild b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/Kbuild
index 9a150d520225..7081d6a9b95f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/Kbuild
@@ -4,5 +4,6 @@ nvkm-y += nvkm/subdev/pmu/gt215.o
4nvkm-y += nvkm/subdev/pmu/gf100.o 4nvkm-y += nvkm/subdev/pmu/gf100.o
5nvkm-y += nvkm/subdev/pmu/gf110.o 5nvkm-y += nvkm/subdev/pmu/gf110.o
6nvkm-y += nvkm/subdev/pmu/gk104.o 6nvkm-y += nvkm/subdev/pmu/gk104.o
7nvkm-y += nvkm/subdev/pmu/gk110.o
7nvkm-y += nvkm/subdev/pmu/gk208.o 8nvkm-y += nvkm/subdev/pmu/gk208.o
8nvkm-y += nvkm/subdev/pmu/gk20a.o 9nvkm-y += nvkm/subdev/pmu/gk20a.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk110.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk110.c
new file mode 100644
index 000000000000..89bb94b0af8b
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk110.c
@@ -0,0 +1,95 @@
1/*
2 * Copyright 2015 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs
23 */
24#define gf110_pmu_code gk110_pmu_code
25#define gf110_pmu_data gk110_pmu_data
26#include "priv.h"
27#include "fuc/gf110.fuc4.h"
28
29#include <subdev/timer.h>
30
31void
32gk110_pmu_pgob(struct nvkm_pmu *pmu, bool enable)
33{
34 static const struct {
35 u32 addr;
36 u32 data;
37 } magic[] = {
38 { 0x020520, 0xfffffffc },
39 { 0x020524, 0xfffffffe },
40 { 0x020524, 0xfffffffc },
41 { 0x020524, 0xfffffff8 },
42 { 0x020524, 0xffffffe0 },
43 { 0x020530, 0xfffffffe },
44 { 0x02052c, 0xfffffffa },
45 { 0x02052c, 0xfffffff0 },
46 { 0x02052c, 0xffffffc0 },
47 { 0x02052c, 0xffffff00 },
48 { 0x02052c, 0xfffffc00 },
49 { 0x02052c, 0xfffcfc00 },
50 { 0x02052c, 0xfff0fc00 },
51 { 0x02052c, 0xff80fc00 },
52 { 0x020528, 0xfffffffe },
53 { 0x020528, 0xfffffffc },
54 };
55 int i;
56
57 nv_mask(pmu, 0x000200, 0x00001000, 0x00000000);
58 nv_rd32(pmu, 0x000200);
59 nv_mask(pmu, 0x000200, 0x08000000, 0x08000000);
60 msleep(50);
61
62 nv_mask(pmu, 0x10a78c, 0x00000002, 0x00000002);
63 nv_mask(pmu, 0x10a78c, 0x00000001, 0x00000001);
64 nv_mask(pmu, 0x10a78c, 0x00000001, 0x00000000);
65
66 nv_mask(pmu, 0x0206b4, 0x00000000, 0x00000000);
67 for (i = 0; i < ARRAY_SIZE(magic); i++) {
68 nv_wr32(pmu, magic[i].addr, magic[i].data);
69 nv_wait(pmu, magic[i].addr, 0x80000000, 0x00000000);
70 }
71
72 nv_mask(pmu, 0x10a78c, 0x00000002, 0x00000000);
73 nv_mask(pmu, 0x10a78c, 0x00000001, 0x00000001);
74 nv_mask(pmu, 0x10a78c, 0x00000001, 0x00000000);
75
76 nv_mask(pmu, 0x000200, 0x08000000, 0x00000000);
77 nv_mask(pmu, 0x000200, 0x00001000, 0x00001000);
78 nv_rd32(pmu, 0x000200);
79}
80
81struct nvkm_oclass *
82gk110_pmu_oclass = &(struct nvkm_pmu_impl) {
83 .base.handle = NV_SUBDEV(PMU, 0xf0),
84 .base.ofuncs = &(struct nvkm_ofuncs) {
85 .ctor = _nvkm_pmu_ctor,
86 .dtor = _nvkm_pmu_dtor,
87 .init = _nvkm_pmu_init,
88 .fini = _nvkm_pmu_fini,
89 },
90 .code.data = gk110_pmu_code,
91 .code.size = sizeof(gk110_pmu_code),
92 .data.data = gk110_pmu_data,
93 .data.size = sizeof(gk110_pmu_data),
94 .pgob = gk110_pmu_pgob,
95}.base;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk208.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk208.c
index 6f9c09af1a49..b14134ef9ea5 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk208.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk208.c
@@ -37,4 +37,5 @@ gk208_pmu_oclass = &(struct nvkm_pmu_impl) {
37 .code.size = sizeof(gk208_pmu_code), 37 .code.size = sizeof(gk208_pmu_code),
38 .data.data = gk208_pmu_data, 38 .data.data = gk208_pmu_data,
39 .data.size = sizeof(gk208_pmu_data), 39 .data.size = sizeof(gk208_pmu_data),
40 .pgob = gk110_pmu_pgob,
40}.base; 41}.base;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk20a.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk20a.c
index a49934bbe637..594f746e68f2 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk20a.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk20a.c
@@ -159,7 +159,7 @@ resched:
159 nvkm_timer_alarm(priv, 100000000, alarm); 159 nvkm_timer_alarm(priv, 100000000, alarm);
160} 160}
161 161
162int 162static int
163gk20a_pmu_fini(struct nvkm_object *object, bool suspend) 163gk20a_pmu_fini(struct nvkm_object *object, bool suspend)
164{ 164{
165 struct nvkm_pmu *pmu = (void *)object; 165 struct nvkm_pmu *pmu = (void *)object;
@@ -170,7 +170,7 @@ gk20a_pmu_fini(struct nvkm_object *object, bool suspend)
170 return nvkm_subdev_fini(&pmu->base, suspend); 170 return nvkm_subdev_fini(&pmu->base, suspend);
171} 171}
172 172
173int 173static int
174gk20a_pmu_init(struct nvkm_object *object) 174gk20a_pmu_init(struct nvkm_object *object)
175{ 175{
176 struct nvkm_pmu *pmu = (void *)object; 176 struct nvkm_pmu *pmu = (void *)object;
@@ -192,7 +192,8 @@ gk20a_pmu_init(struct nvkm_object *object)
192 return ret; 192 return ret;
193} 193}
194 194
195struct gk20a_pmu_dvfs_data gk20a_dvfs_data= { 195static struct gk20a_pmu_dvfs_data
196gk20a_dvfs_data= {
196 .p_load_target = 70, 197 .p_load_target = 70,
197 .p_load_max = 90, 198 .p_load_max = 90,
198 .p_smooth = 1, 199 .p_smooth = 1,
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/priv.h b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/priv.h
index 998410563bfd..799e7c8b88f5 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/priv.h
@@ -40,4 +40,6 @@ struct nvkm_pmu_impl {
40 40
41 void (*pgob)(struct nvkm_pmu *, bool); 41 void (*pgob)(struct nvkm_pmu *, bool);
42}; 42};
43
44void gk110_pmu_pgob(struct nvkm_pmu *, bool);
43#endif 45#endif
diff --git a/include/uapi/drm/nouveau_drm.h b/include/uapi/drm/nouveau_drm.h
index 0d7608dc1a34..5507eead5863 100644
--- a/include/uapi/drm/nouveau_drm.h
+++ b/include/uapi/drm/nouveau_drm.h
@@ -39,6 +39,7 @@
39#define NOUVEAU_GEM_DOMAIN_VRAM (1 << 1) 39#define NOUVEAU_GEM_DOMAIN_VRAM (1 << 1)
40#define NOUVEAU_GEM_DOMAIN_GART (1 << 2) 40#define NOUVEAU_GEM_DOMAIN_GART (1 << 2)
41#define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3) 41#define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3)
42#define NOUVEAU_GEM_DOMAIN_COHERENT (1 << 4)
42 43
43#define NOUVEAU_GEM_TILE_COMP 0x00030000 /* nv50-only */ 44#define NOUVEAU_GEM_TILE_COMP 0x00030000 /* nv50-only */
44#define NOUVEAU_GEM_TILE_LAYOUT_MASK 0x0000ff00 45#define NOUVEAU_GEM_TILE_LAYOUT_MASK 0x0000ff00