drm/nv50/fb/ram: Store the number of partitions in the designated fields
authorRoy Spliet <rspliet@eclipso.eu>
Fri, 12 Sep 2014 16:00:14 +0000 (18:00 +0200)
committerBen Skeggs <bskeggs@redhat.com>
Mon, 15 Sep 2014 12:25:14 +0000 (22:25 +1000)
Signed-off-by: Roy Spliet <rspliet@eclipso.eu>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/core/include/subdev/fb.h
drivers/gpu/drm/nouveau/core/subdev/fb/ramnv50.c

index a0bd0ead90ab3d96e58769619b1c973d07a18326..507c3b44e560fa405c5683d5c657d1ab4130ac4a 100644 (file)
@@ -137,6 +137,7 @@ struct nouveau_ram {
 
        int ranks;
        int parts;
+       int part_mask;
 
        int  (*get)(struct nouveau_fb *, u64 size, u32 align,
                    u32 size_nc, u32 type, struct nouveau_mem **);
index 514b0785a01982c2f78bd7c6b313fc012afe632f..64a983c9662576bad70207aad209564b32cd6b4f 100644 (file)
@@ -319,27 +319,22 @@ nv50_ram_get(struct nouveau_fb *pfb, u64 size, u32 align, u32 ncmin,
 static u32
 nv50_fb_vram_rblock(struct nouveau_fb *pfb, struct nouveau_ram *ram)
 {
-       int i, parts, colbits, rowbitsa, rowbitsb, banks;
+       int colbits, rowbitsa, rowbitsb, banks;
        u64 rowsize, predicted;
-       u32 r0, r4, rt, ru, rblock_size;
+       u32 r0, r4, rt, rblock_size;
 
        r0 = nv_rd32(pfb, 0x100200);
        r4 = nv_rd32(pfb, 0x100204);
        rt = nv_rd32(pfb, 0x100250);
-       ru = nv_rd32(pfb, 0x001540);
-       nv_debug(pfb, "memcfg 0x%08x 0x%08x 0x%08x 0x%08x\n", r0, r4, rt, ru);
-
-       for (i = 0, parts = 0; i < 8; i++) {
-               if (ru & (0x00010000 << i))
-                       parts++;
-       }
+       nv_debug(pfb, "memcfg 0x%08x 0x%08x 0x%08x 0x%08x\n", r0, r4, rt,
+                       nv_rd32(pfb, 0x001540));
 
        colbits  =  (r4 & 0x0000f000) >> 12;
        rowbitsa = ((r4 & 0x000f0000) >> 16) + 8;
        rowbitsb = ((r4 & 0x00f00000) >> 20) + 8;
        banks    = 1 << (((r4 & 0x03000000) >> 24) + 2);
 
-       rowsize = parts * banks * (1 << colbits) * 8;
+       rowsize = ram->parts * banks * (1 << colbits) * 8;
        predicted = rowsize << rowbitsa;
        if (r0 & 0x00000004)
                predicted += rowsize << rowbitsb;
@@ -376,6 +371,9 @@ nv50_ram_create_(struct nouveau_object *parent, struct nouveau_object *engine,
        ram->size = nv_rd32(pfb, 0x10020c);
        ram->size = (ram->size & 0xffffff00) | ((ram->size & 0x000000ff) << 32);
 
+       ram->part_mask = (nv_rd32(pfb, 0x001540) & 0x00ff0000) >> 16;
+       ram->parts = hweight8(ram->part_mask);
+
        switch (nv_rd32(pfb, 0x100714) & 0x00000007) {
        case 0: ram->type = NV_MEM_TYPE_DDR1; break;
        case 1: