37 static int types[0x80] = {
38 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
39 1, 1, 1, 1, 0, 0, 0, 0, 2, 2, 2, 2, 0, 0, 0, 0,
40 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 2, 2, 0,
41 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
42 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 0, 0,
43 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
44 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 2, 2, 2, 2,
45 1, 0, 2, 0, 1, 0, 2, 0, 1, 1, 2, 2, 1, 1, 0, 0
51 return types[(memtype & 0xff00) >> 8] != 0;
63 int comp = (memtype & 0x300) >> 8;
64 int type = (memtype & 0x07f);
65 int back = (memtype & 0x800);
69 min = ncmin ? (ncmin >> 12) : max;
79 int n = (max >> 4) * comp;
91 mem->
memtype = (comp << 7) | type;
102 pfb->
ram.put(pfb, &mem);
130 while (!list_empty(&mem->
regions)) {
147 u64 rowsize, predicted;
148 u32 r0,
r4, rt, ru, rblock_size;
150 r0 = nv_rd32(priv, 0x100200);
151 r4 = nv_rd32(priv, 0x100204);
152 rt = nv_rd32(priv, 0x100250);
153 ru = nv_rd32(priv, 0x001540);
154 nv_debug(priv,
"memcfg 0x%08x 0x%08x 0x%08x 0x%08x\n", r0, r4, rt, ru);
156 for (i = 0, parts = 0; i < 8; i++) {
157 if (ru & (0x00010000 << i))
161 colbits = (r4 & 0x0000f000) >> 12;
162 rowbitsa = ((r4 & 0x000f0000) >> 16) + 8;
163 rowbitsb = ((r4 & 0x00f00000) >> 20) + 8;
164 banks = 1 << (((r4 & 0x03000000) >> 24) + 2);
166 rowsize = parts * banks * (1 << colbits) * 8;
167 predicted = rowsize << rowbitsa;
169 predicted += rowsize << rowbitsb;
171 if (predicted != priv->
base.ram.size) {
172 nv_warn(priv,
"memory controller reports %d MiB VRAM\n",
173 (
u32)(priv->
base.ram.size >> 20));
176 rblock_size = rowsize;
180 nv_debug(priv,
"rblock %d bytes\n", rblock_size);
191 const u32 rsvd_head = ( 256 * 1024) >> 12;
192 const u32 rsvd_tail = (1024 * 1024) >> 12;
198 *pobject = nv_object(priv);
202 switch (nv_rd32(priv, 0x100714) & 0x00000007) {
203 case 0: priv->
base.ram.type = NV_MEM_TYPE_DDR1;
break;
206 priv->
base.ram.type = NV_MEM_TYPE_DDR3;
208 priv->
base.ram.type = NV_MEM_TYPE_DDR2;
210 case 2: priv->
base.ram.type = NV_MEM_TYPE_GDDR3;
break;
211 case 3: priv->
base.ram.type = NV_MEM_TYPE_GDDR4;
break;
212 case 4: priv->
base.ram.type = NV_MEM_TYPE_GDDR5;
break;
217 priv->
base.ram.size = nv_rd32(priv, 0x10020c);
218 priv->
base.ram.size = (priv->
base.ram.size & 0xffffff00) |
219 ((priv->
base.ram.size & 0x000000ff) << 32);
221 tags = nv_rd32(priv, 0x100320);
226 nv_debug(priv,
"%d compression tags\n", tags);
228 size = (priv->
base.ram.size >> 12) - rsvd_head - rsvd_tail;
237 priv->
base.ram.stolen = (
u64)nv_rd32(priv, 0x100e10) << 12;
238 priv->
base.ram.type = NV_MEM_TYPE_STOLEN;
242 nv50_vram_rblock(priv) >> 12);
246 priv->
base.ram.ranks = (nv_rd32(priv, 0x100200) & 0x4) ? 2 : 1;
255 if (pci_dma_mapping_error(device->
pdev, priv->
r100c08))
256 nv_warn(priv,
"failed 0x100c08 page map\n");
258 nv_warn(priv,
"failed 0x100c08 page alloc\n");
261 priv->
base.memtype_valid = nv50_fb_memtype_valid;
262 priv->
base.ram.get = nv50_fb_vram_new;
297 nv_wr32(priv, 0x100c08, priv->
r100c08 >> 8);
303 nv_wr32(priv, 0x100c90, 0x000707ff);
308 nv_wr32(priv, 0x100c90, 0x000d0fff);
311 nv_wr32(priv, 0x100c90, 0x089d1fff);
314 nv_wr32(priv, 0x100c90, 0x001d07ff);
325 .ctor = nv50_fb_ctor,
326 .dtor = nv50_fb_dtor,
327 .init = nv50_fb_init,
332 static const struct nouveau_enum vm_dispatch_subclients[] = {
333 { 0x00000000,
"GRCTX",
NULL },
334 { 0x00000001,
"NOTIFY",
NULL },
335 { 0x00000002,
"QUERY",
NULL },
336 { 0x00000003,
"COND",
NULL },
337 { 0x00000004,
"M2M_IN",
NULL },
338 { 0x00000005,
"M2M_OUT",
NULL },
339 { 0x00000006,
"M2M_NOTIFY",
NULL },
343 static const struct nouveau_enum vm_ccache_subclients[] = {
344 { 0x00000000,
"CB",
NULL },
345 { 0x00000001,
"TIC",
NULL },
346 { 0x00000002,
"TSC",
NULL },
350 static const struct nouveau_enum vm_prop_subclients[] = {
351 { 0x00000000,
"RT0",
NULL },
352 { 0x00000001,
"RT1",
NULL },
353 { 0x00000002,
"RT2",
NULL },
354 { 0x00000003,
"RT3",
NULL },
355 { 0x00000004,
"RT4",
NULL },
356 { 0x00000005,
"RT5",
NULL },
357 { 0x00000006,
"RT6",
NULL },
358 { 0x00000007,
"RT7",
NULL },
359 { 0x00000008,
"ZETA",
NULL },
360 { 0x00000009,
"LOCAL",
NULL },
361 { 0x0000000a,
"GLOBAL",
NULL },
362 { 0x0000000b,
"STACK",
NULL },
363 { 0x0000000c,
"DST2D",
NULL },
367 static const struct nouveau_enum vm_pfifo_subclients[] = {
368 { 0x00000000,
"PUSHBUF",
NULL },
369 { 0x00000001,
"SEMAPHORE",
NULL },
373 static const struct nouveau_enum vm_bar_subclients[] = {
374 { 0x00000000,
"FB",
NULL },
375 { 0x00000001,
"IN",
NULL },
380 { 0x00000000,
"STRMOUT",
NULL },
381 { 0x00000003,
"DISPATCH", vm_dispatch_subclients },
382 { 0x00000004,
"PFIFO_WRITE",
NULL },
383 { 0x00000005,
"CCACHE", vm_ccache_subclients },
384 { 0x00000006,
"PPPP",
NULL },
385 { 0x00000007,
"CLIPID",
NULL },
386 { 0x00000008,
"PFIFO_READ",
NULL },
387 { 0x00000009,
"VFETCH",
NULL },
388 { 0x0000000a,
"TEXTURE",
NULL },
389 { 0x0000000b,
"PROP", vm_prop_subclients },
390 { 0x0000000c,
"PVP",
NULL },
391 { 0x0000000d,
"PBSP",
NULL },
392 { 0x0000000e,
"PCRYPT",
NULL },
393 { 0x0000000f,
"PCOUNTER",
NULL },
394 { 0x00000011,
"PDAEMON",
NULL },
399 { 0x00000000,
"PGRAPH",
NULL },
400 { 0x00000001,
"PVP",
NULL },
401 { 0x00000004,
"PEEPHOLE",
NULL },
402 { 0x00000005,
"PFIFO", vm_pfifo_subclients },
403 { 0x00000006,
"BAR", vm_bar_subclients },
404 { 0x00000008,
"PPPP",
NULL },
405 { 0x00000009,
"PBSP",
NULL },
406 { 0x0000000a,
"PCRYPT",
NULL },
407 { 0x0000000b,
"PCOUNTER",
NULL },
408 { 0x0000000c,
"SEMAPHORE_BG",
NULL },
409 { 0x0000000d,
"PCOPY",
NULL },
410 { 0x0000000e,
"PDAEMON",
NULL },
415 { 0x00000000,
"PT_NOT_PRESENT",
NULL },
416 { 0x00000001,
"PT_TOO_SHORT",
NULL },
417 { 0x00000002,
"PAGE_NOT_PRESENT",
NULL },
418 { 0x00000003,
"PAGE_SYSTEM_ONLY",
NULL },
419 { 0x00000004,
"PAGE_READ_ONLY",
NULL },
420 { 0x00000006,
"NULL_DMAOBJ",
NULL },
421 { 0x00000007,
"WRONG_MEMTYPE",
NULL },
422 { 0x0000000b,
"VRAM_LIMIT",
NULL },
423 { 0x0000000f,
"DMAOBJ_LIMIT",
NULL },
434 u8 st0, st1, st2, st3;
437 idx = nv_rd32(priv, 0x100c90);
438 if (!(idx & 0x80000000))
442 for (i = 0; i < 6; i++) {
443 nv_wr32(priv, 0x100c90, idx | i << 24);
444 trap[
i] = nv_rd32(priv, 0x100c94);
446 nv_wr32(priv, 0x100c90, idx | 0x80000000);
454 st0 = (trap[0] & 0x0000000f) >> 0;
455 st1 = (trap[0] & 0x000000f0) >> 4;
456 st2 = (trap[0] & 0x00000f00) >> 8;
457 st3 = (trap[0] & 0x0000f000) >> 12;
459 st0 = (trap[0] & 0x000000ff) >> 0;
460 st1 = (trap[0] & 0x0000ff00) >> 8;
461 st2 = (trap[0] & 0x00ff0000) >> 16;
462 st3 = (trap[0] & 0xff000000) >> 24;
464 chan = (trap[2] << 16) | trap[1];
466 nv_error(priv,
"trapped %s at 0x%02x%04x%04x on channel 0x%08x ",
467 (trap[5] & 0x00000100) ?
"read" :
"write",
468 trap[5] & 0xff, trap[4] & 0xffff, trap[3] & 0xffff, chan);