aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2012-04-19 21:54:33 -0400
committerBen Skeggs <bskeggs@redhat.com>2012-05-24 02:31:58 -0400
commitd58086deaa32dc5e630aab222851b282f77e00bb (patch)
tree2fab5eec82dcc5fa89d7d4e876cc6e561a30cc53 /drivers
parenta8f81837c506aba186b42f0c67633e85851395b1 (diff)
drm/nv40-50/gr: restructure grctx/prog generation
The conditional definition of the generation helper functions apparently confuses some IDEs.... Reported-by: Marcin Slusarz <marcin.slusarz@gmail.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.h6
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_grctx.h4
-rw-r--r--drivers/gpu/drm/nouveau/nv40_graph.c29
-rw-r--r--drivers/gpu/drm/nouveau/nv40_grctx.c32
-rw-r--r--drivers/gpu/drm/nouveau/nv50_graph.c21
-rw-r--r--drivers/gpu/drm/nouveau/nv50_grctx.c31
6 files changed, 71 insertions, 52 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 7dd344a597a8..87619a94fa42 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -1286,13 +1286,15 @@ extern int nv20_graph_create(struct drm_device *);
1286 1286
1287/* nv40_graph.c */ 1287/* nv40_graph.c */
1288extern int nv40_graph_create(struct drm_device *); 1288extern int nv40_graph_create(struct drm_device *);
1289extern void nv40_grctx_init(struct nouveau_grctx *); 1289extern void nv40_grctx_init(struct drm_device *, u32 *size);
1290extern void nv40_grctx_fill(struct drm_device *, struct nouveau_gpuobj *);
1290 1291
1291/* nv50_graph.c */ 1292/* nv50_graph.c */
1292extern int nv50_graph_create(struct drm_device *); 1293extern int nv50_graph_create(struct drm_device *);
1293extern int nv50_grctx_init(struct nouveau_grctx *);
1294extern struct nouveau_enum nv50_data_error_names[]; 1294extern struct nouveau_enum nv50_data_error_names[];
1295extern int nv50_graph_isr_chid(struct drm_device *dev, u64 inst); 1295extern int nv50_graph_isr_chid(struct drm_device *dev, u64 inst);
1296extern int nv50_grctx_init(struct drm_device *, u32 *, u32, u32 *, u32 *);
1297extern void nv50_grctx_fill(struct drm_device *, struct nouveau_gpuobj *);
1296 1298
1297/* nvc0_graph.c */ 1299/* nvc0_graph.c */
1298extern int nvc0_graph_create(struct drm_device *); 1300extern int nvc0_graph_create(struct drm_device *);
diff --git a/drivers/gpu/drm/nouveau/nouveau_grctx.h b/drivers/gpu/drm/nouveau/nouveau_grctx.h
index 86c2e374e938..b0795ececbda 100644
--- a/drivers/gpu/drm/nouveau/nouveau_grctx.h
+++ b/drivers/gpu/drm/nouveau/nouveau_grctx.h
@@ -18,7 +18,6 @@ struct nouveau_grctx {
18 uint32_t ctxvals_base; 18 uint32_t ctxvals_base;
19}; 19};
20 20
21#ifdef CP_CTX
22static inline void 21static inline void
23cp_out(struct nouveau_grctx *ctx, uint32_t inst) 22cp_out(struct nouveau_grctx *ctx, uint32_t inst)
24{ 23{
@@ -88,10 +87,8 @@ _cp_bra(struct nouveau_grctx *ctx, u32 mod, int flag, int state, int name)
88 (state ? 0 : CP_BRA_IF_CLEAR)); 87 (state ? 0 : CP_BRA_IF_CLEAR));
89} 88}
90#define cp_bra(c, f, s, n) _cp_bra((c), 0, CP_FLAG_##f, CP_FLAG_##f##_##s, n) 89#define cp_bra(c, f, s, n) _cp_bra((c), 0, CP_FLAG_##f, CP_FLAG_##f##_##s, n)
91#ifdef CP_BRA_MOD
92#define cp_cal(c, f, s, n) _cp_bra((c), 1, CP_FLAG_##f, CP_FLAG_##f##_##s, n) 90#define cp_cal(c, f, s, n) _cp_bra((c), 1, CP_FLAG_##f, CP_FLAG_##f##_##s, n)
93#define cp_ret(c, f, s) _cp_bra((c), 2, CP_FLAG_##f, CP_FLAG_##f##_##s, 0) 91#define cp_ret(c, f, s) _cp_bra((c), 2, CP_FLAG_##f, CP_FLAG_##f##_##s, 0)
94#endif
95 92
96static inline void 93static inline void
97_cp_wait(struct nouveau_grctx *ctx, int flag, int state) 94_cp_wait(struct nouveau_grctx *ctx, int flag, int state)
@@ -128,6 +125,5 @@ gr_def(struct nouveau_grctx *ctx, uint32_t reg, uint32_t val)
128 125
129 nv_wo32(ctx->data, reg * 4, val); 126 nv_wo32(ctx->data, reg * 4, val);
130} 127}
131#endif
132 128
133#endif 129#endif
diff --git a/drivers/gpu/drm/nouveau/nv40_graph.c b/drivers/gpu/drm/nouveau/nv40_graph.c
index ba14a93d8afa..6d8147b07c83 100644
--- a/drivers/gpu/drm/nouveau/nv40_graph.c
+++ b/drivers/gpu/drm/nouveau/nv40_graph.c
@@ -27,7 +27,6 @@
27#include "drmP.h" 27#include "drmP.h"
28#include "drm.h" 28#include "drm.h"
29#include "nouveau_drv.h" 29#include "nouveau_drv.h"
30#include "nouveau_grctx.h"
31#include "nouveau_ramht.h" 30#include "nouveau_ramht.h"
32 31
33struct nv40_graph_engine { 32struct nv40_graph_engine {
@@ -42,7 +41,6 @@ nv40_graph_context_new(struct nouveau_channel *chan, int engine)
42 struct drm_device *dev = chan->dev; 41 struct drm_device *dev = chan->dev;
43 struct drm_nouveau_private *dev_priv = dev->dev_private; 42 struct drm_nouveau_private *dev_priv = dev->dev_private;
44 struct nouveau_gpuobj *grctx = NULL; 43 struct nouveau_gpuobj *grctx = NULL;
45 struct nouveau_grctx ctx = {};
46 unsigned long flags; 44 unsigned long flags;
47 int ret; 45 int ret;
48 46
@@ -52,11 +50,7 @@ nv40_graph_context_new(struct nouveau_channel *chan, int engine)
52 return ret; 50 return ret;
53 51
54 /* Initialise default context values */ 52 /* Initialise default context values */
55 ctx.dev = chan->dev; 53 nv40_grctx_fill(dev, grctx);
56 ctx.mode = NOUVEAU_GRCTX_VALS;
57 ctx.data = grctx;
58 nv40_grctx_init(&ctx);
59
60 nv_wo32(grctx, 0, grctx->vinst); 54 nv_wo32(grctx, 0, grctx->vinst);
61 55
62 /* init grctx pointer in ramfc, and on PFIFO if channel is 56 /* init grctx pointer in ramfc, and on PFIFO if channel is
@@ -184,8 +178,7 @@ nv40_graph_init(struct drm_device *dev, int engine)
184 struct nv40_graph_engine *pgraph = nv_engine(dev, engine); 178 struct nv40_graph_engine *pgraph = nv_engine(dev, engine);
185 struct drm_nouveau_private *dev_priv = dev->dev_private; 179 struct drm_nouveau_private *dev_priv = dev->dev_private;
186 struct nouveau_fb_engine *pfb = &dev_priv->engine.fb; 180 struct nouveau_fb_engine *pfb = &dev_priv->engine.fb;
187 struct nouveau_grctx ctx = {}; 181 uint32_t vramsz;
188 uint32_t vramsz, *cp;
189 int i, j; 182 int i, j;
190 183
191 nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) & 184 nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) &
@@ -193,22 +186,8 @@ nv40_graph_init(struct drm_device *dev, int engine)
193 nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) | 186 nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) |
194 NV_PMC_ENABLE_PGRAPH); 187 NV_PMC_ENABLE_PGRAPH);
195 188
196 cp = kmalloc(sizeof(*cp) * 256, GFP_KERNEL); 189 /* generate and upload context program */
197 if (!cp) 190 nv40_grctx_init(dev, &pgraph->grctx_size);
198 return -ENOMEM;
199
200 ctx.dev = dev;
201 ctx.mode = NOUVEAU_GRCTX_PROG;
202 ctx.data = cp;
203 ctx.ctxprog_max = 256;
204 nv40_grctx_init(&ctx);
205 pgraph->grctx_size = ctx.ctxvals_pos * 4;
206
207 nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_INDEX, 0);
208 for (i = 0; i < ctx.ctxprog_len; i++)
209 nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_DATA, cp[i]);
210
211 kfree(cp);
212 191
213 /* No context present currently */ 192 /* No context present currently */
214 nv_wr32(dev, NV40_PGRAPH_CTXCTL_CUR, 0x00000000); 193 nv_wr32(dev, NV40_PGRAPH_CTXCTL_CUR, 0x00000000);
diff --git a/drivers/gpu/drm/nouveau/nv40_grctx.c b/drivers/gpu/drm/nouveau/nv40_grctx.c
index f70447d131d7..be0a74750fb1 100644
--- a/drivers/gpu/drm/nouveau/nv40_grctx.c
+++ b/drivers/gpu/drm/nouveau/nv40_grctx.c
@@ -595,8 +595,8 @@ nv40_graph_construct_shader(struct nouveau_grctx *ctx)
595 } 595 }
596} 596}
597 597
598void 598static void
599nv40_grctx_init(struct nouveau_grctx *ctx) 599nv40_grctx_generate(struct nouveau_grctx *ctx)
600{ 600{
601 /* decide whether we're loading/unloading the context */ 601 /* decide whether we're loading/unloading the context */
602 cp_bra (ctx, AUTO_SAVE, PENDING, cp_setup_save); 602 cp_bra (ctx, AUTO_SAVE, PENDING, cp_setup_save);
@@ -660,3 +660,31 @@ nv40_grctx_init(struct nouveau_grctx *ctx)
660 cp_out (ctx, CP_END); 660 cp_out (ctx, CP_END);
661} 661}
662 662
663void
664nv40_grctx_fill(struct drm_device *dev, struct nouveau_gpuobj *mem)
665{
666 nv40_grctx_generate(&(struct nouveau_grctx) {
667 .dev = dev,
668 .mode = NOUVEAU_GRCTX_VALS,
669 .data = mem,
670 });
671}
672
673void
674nv40_grctx_init(struct drm_device *dev, u32 *size)
675{
676 u32 ctxprog[256], i;
677 struct nouveau_grctx ctx = {
678 .dev = dev,
679 .mode = NOUVEAU_GRCTX_PROG,
680 .data = ctxprog,
681 .ctxprog_max = ARRAY_SIZE(ctxprog)
682 };
683
684 nv40_grctx_generate(&ctx);
685
686 nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_INDEX, 0);
687 for (i = 0; i < ctx.ctxprog_len; i++)
688 nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_DATA, ctxprog[i]);
689 *size = ctx.ctxvals_pos * 4;
690}
diff --git a/drivers/gpu/drm/nouveau/nv50_graph.c b/drivers/gpu/drm/nouveau/nv50_graph.c
index 33d5711a918d..2698d80c8eb2 100644
--- a/drivers/gpu/drm/nouveau/nv50_graph.c
+++ b/drivers/gpu/drm/nouveau/nv50_graph.c
@@ -28,7 +28,6 @@
28#include "drm.h" 28#include "drm.h"
29#include "nouveau_drv.h" 29#include "nouveau_drv.h"
30#include "nouveau_ramht.h" 30#include "nouveau_ramht.h"
31#include "nouveau_grctx.h"
32#include "nouveau_dma.h" 31#include "nouveau_dma.h"
33#include "nouveau_vm.h" 32#include "nouveau_vm.h"
34#include "nv50_evo.h" 33#include "nv50_evo.h"
@@ -229,7 +228,6 @@ nv50_graph_context_new(struct nouveau_channel *chan, int engine)
229 struct nouveau_gpuobj *ramin = chan->ramin; 228 struct nouveau_gpuobj *ramin = chan->ramin;
230 struct nouveau_gpuobj *grctx = NULL; 229 struct nouveau_gpuobj *grctx = NULL;
231 struct nv50_graph_engine *pgraph = nv_engine(dev, engine); 230 struct nv50_graph_engine *pgraph = nv_engine(dev, engine);
232 struct nouveau_grctx ctx = {};
233 int hdr, ret; 231 int hdr, ret;
234 232
235 NV_DEBUG(dev, "ch%d\n", chan->id); 233 NV_DEBUG(dev, "ch%d\n", chan->id);
@@ -248,11 +246,7 @@ nv50_graph_context_new(struct nouveau_channel *chan, int engine)
248 nv_wo32(ramin, hdr + 0x10, 0); 246 nv_wo32(ramin, hdr + 0x10, 0);
249 nv_wo32(ramin, hdr + 0x14, 0x00010000); 247 nv_wo32(ramin, hdr + 0x14, 0x00010000);
250 248
251 ctx.dev = chan->dev; 249 nv50_grctx_fill(dev, grctx);
252 ctx.mode = NOUVEAU_GRCTX_VALS;
253 ctx.data = grctx;
254 nv50_grctx_init(&ctx);
255
256 nv_wo32(grctx, 0x00000, chan->ramin->vinst >> 12); 250 nv_wo32(grctx, 0x00000, chan->ramin->vinst >> 12);
257 251
258 dev_priv->engine.instmem.flush(dev); 252 dev_priv->engine.instmem.flush(dev);
@@ -996,28 +990,21 @@ nv50_graph_create(struct drm_device *dev)
996{ 990{
997 struct drm_nouveau_private *dev_priv = dev->dev_private; 991 struct drm_nouveau_private *dev_priv = dev->dev_private;
998 struct nv50_graph_engine *pgraph; 992 struct nv50_graph_engine *pgraph;
999 struct nouveau_grctx ctx = {};
1000 int ret; 993 int ret;
1001 994
1002 pgraph = kzalloc(sizeof(*pgraph),GFP_KERNEL); 995 pgraph = kzalloc(sizeof(*pgraph),GFP_KERNEL);
1003 if (!pgraph) 996 if (!pgraph)
1004 return -ENOMEM; 997 return -ENOMEM;
1005 998
1006 ctx.dev = dev; 999 ret = nv50_grctx_init(dev, pgraph->ctxprog, ARRAY_SIZE(pgraph->ctxprog),
1007 ctx.mode = NOUVEAU_GRCTX_PROG; 1000 &pgraph->ctxprog_size,
1008 ctx.data = pgraph->ctxprog; 1001 &pgraph->grctx_size);
1009 ctx.ctxprog_max = ARRAY_SIZE(pgraph->ctxprog);
1010
1011 ret = nv50_grctx_init(&ctx);
1012 if (ret) { 1002 if (ret) {
1013 NV_ERROR(dev, "PGRAPH: ctxprog build failed\n"); 1003 NV_ERROR(dev, "PGRAPH: ctxprog build failed\n");
1014 kfree(pgraph); 1004 kfree(pgraph);
1015 return 0; 1005 return 0;
1016 } 1006 }
1017 1007
1018 pgraph->grctx_size = ctx.ctxvals_pos * 4;
1019 pgraph->ctxprog_size = ctx.ctxprog_len;
1020
1021 pgraph->base.destroy = nv50_graph_destroy; 1008 pgraph->base.destroy = nv50_graph_destroy;
1022 pgraph->base.init = nv50_graph_init; 1009 pgraph->base.init = nv50_graph_init;
1023 pgraph->base.fini = nv50_graph_fini; 1010 pgraph->base.fini = nv50_graph_fini;
diff --git a/drivers/gpu/drm/nouveau/nv50_grctx.c b/drivers/gpu/drm/nouveau/nv50_grctx.c
index 4b46d6968566..7ac7e6810966 100644
--- a/drivers/gpu/drm/nouveau/nv50_grctx.c
+++ b/drivers/gpu/drm/nouveau/nv50_grctx.c
@@ -172,8 +172,8 @@ static void nv50_graph_construct_xfer2(struct nouveau_grctx *ctx);
172 172
173/* Main function: construct the ctxprog skeleton, call the other functions. */ 173/* Main function: construct the ctxprog skeleton, call the other functions. */
174 174
175int 175static int
176nv50_grctx_init(struct nouveau_grctx *ctx) 176nv50_grctx_generate(struct nouveau_grctx *ctx)
177{ 177{
178 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private; 178 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
179 179
@@ -277,6 +277,33 @@ nv50_grctx_init(struct nouveau_grctx *ctx)
277 return 0; 277 return 0;
278} 278}
279 279
280void
281nv50_grctx_fill(struct drm_device *dev, struct nouveau_gpuobj *mem)
282{
283 nv50_grctx_generate(&(struct nouveau_grctx) {
284 .dev = dev,
285 .mode = NOUVEAU_GRCTX_VALS,
286 .data = mem,
287 });
288}
289
290int
291nv50_grctx_init(struct drm_device *dev, u32 *data, u32 max, u32 *len, u32 *cnt)
292{
293 struct nouveau_grctx ctx = {
294 .dev = dev,
295 .mode = NOUVEAU_GRCTX_PROG,
296 .data = data,
297 .ctxprog_max = max
298 };
299 int ret;
300
301 ret = nv50_grctx_generate(&ctx);
302 *cnt = ctx.ctxvals_pos * 4;
303 *len = ctx.ctxprog_len;
304 return ret;
305}
306
280/* 307/*
281 * Constructs MMIO part of ctxprog and ctxvals. Just a matter of knowing which 308 * Constructs MMIO part of ctxprog and ctxvals. Just a matter of knowing which
282 * registers to save/restore and the default values for them. 309 * registers to save/restore and the default values for them.