Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/nouveau/fb: initialise vram controller as pfb sub-object

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>

+1313 -733
+11
drivers/gpu/drm/nouveau/Makefile
··· 80 80 nouveau-y += core/subdev/fb/nv4e.o 81 81 nouveau-y += core/subdev/fb/nv50.o 82 82 nouveau-y += core/subdev/fb/nvc0.o 83 + nouveau-y += core/subdev/fb/ramnv04.o 84 + nouveau-y += core/subdev/fb/ramnv10.o 85 + nouveau-y += core/subdev/fb/ramnv1a.o 86 + nouveau-y += core/subdev/fb/ramnv20.o 87 + nouveau-y += core/subdev/fb/ramnv40.o 88 + nouveau-y += core/subdev/fb/ramnv41.o 89 + nouveau-y += core/subdev/fb/ramnv44.o 90 + nouveau-y += core/subdev/fb/ramnv49.o 91 + nouveau-y += core/subdev/fb/ramnv4e.o 92 + nouveau-y += core/subdev/fb/ramnv50.o 93 + nouveau-y += core/subdev/fb/ramnvc0.o 83 94 nouveau-y += core/subdev/gpio/base.o 84 95 nouveau-y += core/subdev/gpio/nv10.o 85 96 nouveau-y += core/subdev/gpio/nv50.o
+1 -1
drivers/gpu/drm/nouveau/core/engine/fifo/nv40.c
··· 320 320 break; 321 321 default: 322 322 nv_wr32(priv, 0x002230, 0x00000000); 323 - nv_wr32(priv, 0x002220, ((pfb->ram.size - 512 * 1024 + 323 + nv_wr32(priv, 0x002220, ((pfb->ram->size - 512 * 1024 + 324 324 priv->ramfc->addr) >> 16) | 325 325 0x00030000); 326 326 break;
+25 -70
drivers/gpu/drm/nouveau/core/include/subdev/fb.h
··· 53 53 54 54 bool (*memtype_valid)(struct nouveau_fb *, u32 memtype); 55 55 56 - struct { 57 - enum { 58 - NV_MEM_TYPE_UNKNOWN = 0, 59 - NV_MEM_TYPE_STOLEN, 60 - NV_MEM_TYPE_SGRAM, 61 - NV_MEM_TYPE_SDRAM, 62 - NV_MEM_TYPE_DDR1, 63 - NV_MEM_TYPE_DDR2, 64 - NV_MEM_TYPE_DDR3, 65 - NV_MEM_TYPE_GDDR2, 66 - NV_MEM_TYPE_GDDR3, 67 - NV_MEM_TYPE_GDDR4, 68 - NV_MEM_TYPE_GDDR5 69 - } type; 70 - u64 stolen; 71 - u64 size; 72 - 73 - int ranks; 74 - int parts; 75 - 76 - int (*init)(struct nouveau_fb *); 77 - int (*get)(struct nouveau_fb *, u64 size, u32 align, 78 - u32 size_nc, u32 type, struct nouveau_mem **); 79 - void (*put)(struct nouveau_fb *, struct nouveau_mem **); 80 - } ram; 56 + struct nouveau_ram *ram; 81 57 82 58 struct nouveau_mm vram; 83 59 struct nouveau_mm tags; ··· 78 102 return (void *)nv_device(obj)->subdev[NVDEV_SUBDEV_FB]; 79 103 } 80 104 81 - #define nouveau_fb_create(p,e,c,d) \ 82 - nouveau_subdev_create((p), (e), (c), 0, "PFB", "fb", (d)) 83 - int nouveau_fb_preinit(struct nouveau_fb *); 84 - void nouveau_fb_destroy(struct nouveau_fb *); 85 - int nouveau_fb_init(struct nouveau_fb *); 86 - #define nouveau_fb_fini(p,s) \ 87 - nouveau_subdev_fini(&(p)->base, (s)) 88 - 89 - void _nouveau_fb_dtor(struct nouveau_object *); 90 - int _nouveau_fb_init(struct nouveau_object *); 91 - #define _nouveau_fb_fini _nouveau_subdev_fini 92 - 93 105 extern struct nouveau_oclass nv04_fb_oclass; 94 106 extern struct nouveau_oclass nv10_fb_oclass; 95 107 extern struct nouveau_oclass nv1a_fb_oclass; ··· 96 132 extern struct nouveau_oclass nv50_fb_oclass; 97 133 extern struct nouveau_oclass nvc0_fb_oclass; 98 134 99 - struct nouveau_bios; 100 - int nouveau_fb_bios_memtype(struct nouveau_bios *); 135 + struct nouveau_ram { 136 + struct nouveau_object base; 137 + enum { 138 + NV_MEM_TYPE_UNKNOWN = 0, 139 + NV_MEM_TYPE_STOLEN, 140 + NV_MEM_TYPE_SGRAM, 141 + NV_MEM_TYPE_SDRAM, 142 + NV_MEM_TYPE_DDR1, 143 + NV_MEM_TYPE_DDR2, 144 + NV_MEM_TYPE_DDR3, 145 + NV_MEM_TYPE_GDDR2, 146 + NV_MEM_TYPE_GDDR3, 147 + NV_MEM_TYPE_GDDR4, 148 + NV_MEM_TYPE_GDDR5 149 + } type; 150 + u64 stolen; 151 + u64 size; 152 + u32 tags; 101 153 102 - bool nv04_fb_memtype_valid(struct nouveau_fb *, u32 memtype); 154 + int ranks; 155 + int parts; 103 156 104 - void nv10_fb_tile_init(struct nouveau_fb *, int i, u32 addr, u32 size, 105 - u32 pitch, u32 flags, struct nouveau_fb_tile *); 106 - void nv10_fb_tile_fini(struct nouveau_fb *, int i, struct nouveau_fb_tile *); 107 - void nv10_fb_tile_prog(struct nouveau_fb *, int, struct nouveau_fb_tile *); 108 - 109 - int nv20_fb_vram_init(struct nouveau_fb *); 110 - void nv20_fb_tile_init(struct nouveau_fb *, int i, u32 addr, u32 size, 111 - u32 pitch, u32 flags, struct nouveau_fb_tile *); 112 - void nv20_fb_tile_fini(struct nouveau_fb *, int i, struct nouveau_fb_tile *); 113 - void nv20_fb_tile_prog(struct nouveau_fb *, int, struct nouveau_fb_tile *); 114 - 115 - int nv30_fb_init(struct nouveau_object *); 116 - void nv30_fb_tile_init(struct nouveau_fb *, int i, u32 addr, u32 size, 117 - u32 pitch, u32 flags, struct nouveau_fb_tile *); 118 - 119 - void nv40_fb_tile_comp(struct nouveau_fb *, int i, u32 size, u32 flags, 120 - struct nouveau_fb_tile *); 121 - 122 - int nv41_fb_vram_init(struct nouveau_fb *); 123 - int nv41_fb_init(struct nouveau_object *); 124 - void nv41_fb_tile_prog(struct nouveau_fb *, int, struct nouveau_fb_tile *); 125 - 126 - int nv44_fb_vram_init(struct nouveau_fb *); 127 - int nv44_fb_init(struct nouveau_object *); 128 - void nv44_fb_tile_prog(struct nouveau_fb *, int, struct nouveau_fb_tile *); 129 - 130 - void nv46_fb_tile_init(struct nouveau_fb *, int i, u32 addr, u32 size, 131 - u32 pitch, u32 flags, struct nouveau_fb_tile *); 132 - 133 - void nv50_fb_vram_del(struct nouveau_fb *, struct nouveau_mem **); 157 + int (*get)(struct nouveau_fb *, u64 size, u32 align, 158 + u32 size_nc, u32 type, struct nouveau_mem **); 159 + void (*put)(struct nouveau_fb *, struct nouveau_mem **); 160 + }; 134 161 135 162 #endif
+74 -51
drivers/gpu/drm/nouveau/core/subdev/fb/base.c
··· 57 57 } 58 58 59 59 int 60 - nouveau_fb_preinit(struct nouveau_fb *pfb) 60 + _nouveau_fb_fini(struct nouveau_object *object, bool suspend) 61 + { 62 + struct nouveau_fb *pfb = (void *)object; 63 + int ret; 64 + 65 + ret = nv_ofuncs(pfb->ram)->fini(nv_object(pfb->ram), suspend); 66 + if (ret && suspend) 67 + return ret; 68 + 69 + return nouveau_subdev_fini(&pfb->base, suspend); 70 + } 71 + 72 + int 73 + _nouveau_fb_init(struct nouveau_object *object) 74 + { 75 + struct nouveau_fb *pfb = (void *)object; 76 + int ret, i; 77 + 78 + ret = nouveau_subdev_init(&pfb->base); 79 + if (ret) 80 + return ret; 81 + 82 + ret = nv_ofuncs(pfb->ram)->init(nv_object(pfb->ram)); 83 + if (ret) 84 + return ret; 85 + 86 + for (i = 0; i < pfb->tile.regions; i++) 87 + pfb->tile.prog(pfb, i, &pfb->tile.region[i]); 88 + 89 + return 0; 90 + } 91 + 92 + void 93 + _nouveau_fb_dtor(struct nouveau_object *object) 94 + { 95 + struct nouveau_fb *pfb = (void *)object; 96 + int i; 97 + 98 + for (i = 0; i < pfb->tile.regions; i++) 99 + pfb->tile.fini(pfb, i, &pfb->tile.region[i]); 100 + nouveau_mm_fini(&pfb->tags); 101 + nouveau_mm_fini(&pfb->vram); 102 + 103 + nouveau_object_ref(NULL, (struct nouveau_object **)&pfb->ram); 104 + nouveau_subdev_destroy(&pfb->base); 105 + } 106 + 107 + int 108 + nouveau_fb_create_(struct nouveau_object *parent, struct nouveau_object *engine, 109 + struct nouveau_oclass *oclass, struct nouveau_oclass *ramcls, 110 + int length, void **pobject) 61 111 { 62 112 static const char *name[] = { 63 113 [NV_MEM_TYPE_UNKNOWN] = "unknown", ··· 122 72 [NV_MEM_TYPE_GDDR4 ] = "GDDR4", 123 73 [NV_MEM_TYPE_GDDR5 ] = "GDDR5", 124 74 }; 125 - int ret, tags; 75 + struct nouveau_object *ram; 76 + struct nouveau_fb *pfb; 77 + int ret; 126 78 127 - tags = pfb->ram.init(pfb); 128 - if (tags < 0 || !pfb->ram.size) { 79 + ret = nouveau_subdev_create_(parent, engine, oclass, 0, "PFB", "fb", 80 + length, pobject); 81 + pfb = *pobject; 82 + if (ret) 83 + return ret; 84 + 85 + ret = nouveau_object_ctor(nv_object(pfb), nv_object(pfb), 86 + ramcls, NULL, 0, &ram); 87 + if (ret) { 129 88 nv_fatal(pfb, "error detecting memory configuration!!\n"); 130 - return (tags < 0) ? tags : -ERANGE; 89 + return ret; 131 90 } 132 91 92 + atomic_dec(&ram->parent->refcount); 93 + atomic_dec(&ram->engine->refcount); 94 + pfb->ram = (void *)ram; 95 + 133 96 if (!nouveau_mm_initialised(&pfb->vram)) { 134 - ret = nouveau_mm_init(&pfb->vram, 0, pfb->ram.size >> 12, 1); 97 + ret = nouveau_mm_init(&pfb->vram, 0, pfb->ram->size >> 12, 1); 135 98 if (ret) 136 99 return ret; 137 100 } 138 101 139 102 if (!nouveau_mm_initialised(&pfb->tags)) { 140 - ret = nouveau_mm_init(&pfb->tags, 0, tags ? ++tags : 0, 1); 103 + ret = nouveau_mm_init(&pfb->tags, 0, pfb->ram->tags ? 104 + ++pfb->ram->tags : 0, 1); 141 105 if (ret) 142 106 return ret; 143 107 } 144 108 145 - nv_info(pfb, "RAM type: %s\n", name[pfb->ram.type]); 146 - nv_info(pfb, "RAM size: %d MiB\n", (int)(pfb->ram.size >> 20)); 147 - nv_info(pfb, " ZCOMP: %d tags\n", tags); 109 + nv_info(pfb, "RAM type: %s\n", name[pfb->ram->type]); 110 + nv_info(pfb, "RAM size: %d MiB\n", (int)(pfb->ram->size >> 20)); 111 + nv_info(pfb, " ZCOMP: %d tags\n", pfb->ram->tags); 148 112 return 0; 149 - } 150 - 151 - void 152 - nouveau_fb_destroy(struct nouveau_fb *pfb) 153 - { 154 - int i; 155 - 156 - for (i = 0; i < pfb->tile.regions; i++) 157 - pfb->tile.fini(pfb, i, &pfb->tile.region[i]); 158 - nouveau_mm_fini(&pfb->tags); 159 - nouveau_mm_fini(&pfb->vram); 160 - 161 - nouveau_subdev_destroy(&pfb->base); 162 - } 163 - 164 - void 165 - _nouveau_fb_dtor(struct nouveau_object *object) 166 - { 167 - struct nouveau_fb *pfb = (void *)object; 168 - nouveau_fb_destroy(pfb); 169 - } 170 - int 171 - nouveau_fb_init(struct nouveau_fb *pfb) 172 - { 173 - int ret, i; 174 - 175 - ret = nouveau_subdev_init(&pfb->base); 176 - if (ret) 177 - return ret; 178 - 179 - for (i = 0; i < pfb->tile.regions; i++) 180 - pfb->tile.prog(pfb, i, &pfb->tile.region[i]); 181 - 182 - return 0; 183 - } 184 - 185 - int 186 - _nouveau_fb_init(struct nouveau_object *object) 187 - { 188 - struct nouveau_fb *pfb = (void *)object; 189 - return nouveau_fb_init(pfb); 190 113 }
+3 -51
drivers/gpu/drm/nouveau/core/subdev/fb/nv04.c
··· 22 22 * Authors: Ben Skeggs 23 23 */ 24 24 25 - #include <subdev/fb.h> 25 + #include "priv.h" 26 26 27 - #define NV04_PFB_BOOT_0 0x00100000 28 - # define NV04_PFB_BOOT_0_RAM_AMOUNT 0x00000003 29 - # define NV04_PFB_BOOT_0_RAM_AMOUNT_32MB 0x00000000 30 - # define NV04_PFB_BOOT_0_RAM_AMOUNT_4MB 0x00000001 31 - # define NV04_PFB_BOOT_0_RAM_AMOUNT_8MB 0x00000002 32 - # define NV04_PFB_BOOT_0_RAM_AMOUNT_16MB 0x00000003 33 - # define NV04_PFB_BOOT_0_RAM_WIDTH_128 0x00000004 34 - # define NV04_PFB_BOOT_0_RAM_TYPE 0x00000028 35 - # define NV04_PFB_BOOT_0_RAM_TYPE_SGRAM_8MBIT 0x00000000 36 - # define NV04_PFB_BOOT_0_RAM_TYPE_SGRAM_16MBIT 0x00000008 37 - # define NV04_PFB_BOOT_0_RAM_TYPE_SGRAM_16MBIT_4BANK 0x00000010 38 - # define NV04_PFB_BOOT_0_RAM_TYPE_SDRAM_16MBIT 0x00000018 39 - # define NV04_PFB_BOOT_0_RAM_TYPE_SDRAM_64MBIT 0x00000020 40 - # define NV04_PFB_BOOT_0_RAM_TYPE_SDRAM_64MBITX16 0x00000028 41 - # define NV04_PFB_BOOT_0_UMA_ENABLE 0x00000100 42 - # define NV04_PFB_BOOT_0_UMA_SIZE 0x0000f000 43 27 #define NV04_PFB_CFG0 0x00100200 44 28 45 29 struct nv04_fb_priv { ··· 37 53 return true; 38 54 39 55 return false; 40 - } 41 - 42 - static int 43 - nv04_fb_vram_init(struct nouveau_fb *pfb) 44 - { 45 - u32 boot0 = nv_rd32(pfb, NV04_PFB_BOOT_0); 46 - if (boot0 & 0x00000100) { 47 - pfb->ram.size = ((boot0 >> 12) & 0xf) * 2 + 2; 48 - pfb->ram.size *= 1024 * 1024; 49 - } else { 50 - switch (boot0 & NV04_PFB_BOOT_0_RAM_AMOUNT) { 51 - case NV04_PFB_BOOT_0_RAM_AMOUNT_32MB: 52 - pfb->ram.size = 32 * 1024 * 1024; 53 - break; 54 - case NV04_PFB_BOOT_0_RAM_AMOUNT_16MB: 55 - pfb->ram.size = 16 * 1024 * 1024; 56 - break; 57 - case NV04_PFB_BOOT_0_RAM_AMOUNT_8MB: 58 - pfb->ram.size = 8 * 1024 * 1024; 59 - break; 60 - case NV04_PFB_BOOT_0_RAM_AMOUNT_4MB: 61 - pfb->ram.size = 4 * 1024 * 1024; 62 - break; 63 - } 64 - } 65 - 66 - if ((boot0 & 0x00000038) <= 0x10) 67 - pfb->ram.type = NV_MEM_TYPE_SGRAM; 68 - else 69 - pfb->ram.type = NV_MEM_TYPE_SDRAM; 70 - return 0; 71 56 } 72 57 73 58 static int ··· 65 112 struct nv04_fb_priv *priv; 66 113 int ret; 67 114 68 - ret = nouveau_fb_create(parent, engine, oclass, &priv); 115 + ret = nouveau_fb_create(parent, engine, oclass, &nv04_ram_oclass, &priv); 69 116 *pobject = nv_object(priv); 70 117 if (ret) 71 118 return ret; 72 119 73 120 priv->base.memtype_valid = nv04_fb_memtype_valid; 74 - priv->base.ram.init = nv04_fb_vram_init; 75 - return nouveau_fb_preinit(&priv->base); 121 + return 0; 76 122 } 77 123 78 124 struct nouveau_oclass
+3 -17
drivers/gpu/drm/nouveau/core/subdev/fb/nv10.c
··· 24 24 * 25 25 */ 26 26 27 - #include <subdev/fb.h> 27 + #include "priv.h" 28 28 29 29 struct nv10_fb_priv { 30 30 struct nouveau_fb base; 31 31 }; 32 - 33 - static int 34 - nv10_fb_vram_init(struct nouveau_fb *pfb) 35 - { 36 - u32 cfg0 = nv_rd32(pfb, 0x100200); 37 - if (cfg0 & 0x00000001) 38 - pfb->ram.type = NV_MEM_TYPE_DDR1; 39 - else 40 - pfb->ram.type = NV_MEM_TYPE_SDRAM; 41 - 42 - pfb->ram.size = nv_rd32(pfb, 0x10020c) & 0xff000000; 43 - return 0; 44 - } 45 32 46 33 void 47 34 nv10_fb_tile_init(struct nouveau_fb *pfb, int i, u32 addr, u32 size, u32 pitch, ··· 65 78 struct nv10_fb_priv *priv; 66 79 int ret; 67 80 68 - ret = nouveau_fb_create(parent, engine, oclass, &priv); 81 + ret = nouveau_fb_create(parent, engine, oclass, &nv10_ram_oclass, &priv); 69 82 *pobject = nv_object(priv); 70 83 if (ret) 71 84 return ret; 72 85 73 86 priv->base.memtype_valid = nv04_fb_memtype_valid; 74 - priv->base.ram.init = nv10_fb_vram_init; 75 87 priv->base.tile.regions = 8; 76 88 priv->base.tile.init = nv10_fb_tile_init; 77 89 priv->base.tile.fini = nv10_fb_tile_fini; 78 90 priv->base.tile.prog = nv10_fb_tile_prog; 79 - return nouveau_fb_preinit(&priv->base); 91 + return 0; 80 92 } 81 93 82 94 struct nouveau_oclass
+3 -29
drivers/gpu/drm/nouveau/core/subdev/fb/nv1a.c
··· 24 24 * 25 25 */ 26 26 27 - #include <subdev/fb.h> 27 + #include "priv.h" 28 28 29 29 struct nv1a_fb_priv { 30 30 struct nouveau_fb base; 31 31 }; 32 - 33 - static int 34 - nv1a_fb_vram_init(struct nouveau_fb *pfb) 35 - { 36 - struct pci_dev *bridge; 37 - u32 mem, mib; 38 - 39 - bridge = pci_get_bus_and_slot(0, PCI_DEVFN(0, 1)); 40 - if (!bridge) { 41 - nv_fatal(pfb, "no bridge device\n"); 42 - return -ENODEV; 43 - } 44 - 45 - if (nv_device(pfb)->chipset == 0x1a) { 46 - pci_read_config_dword(bridge, 0x7c, &mem); 47 - mib = ((mem >> 6) & 31) + 1; 48 - } else { 49 - pci_read_config_dword(bridge, 0x84, &mem); 50 - mib = ((mem >> 4) & 127) + 1; 51 - } 52 - 53 - pfb->ram.type = NV_MEM_TYPE_STOLEN; 54 - pfb->ram.size = mib * 1024 * 1024; 55 - return 0; 56 - } 57 32 58 33 static int 59 34 nv1a_fb_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ··· 38 63 struct nv1a_fb_priv *priv; 39 64 int ret; 40 65 41 - ret = nouveau_fb_create(parent, engine, oclass, &priv); 66 + ret = nouveau_fb_create(parent, engine, oclass, &nv1a_ram_oclass, &priv); 42 67 *pobject = nv_object(priv); 43 68 if (ret) 44 69 return ret; 45 70 46 71 priv->base.memtype_valid = nv04_fb_memtype_valid; 47 - priv->base.ram.init = nv1a_fb_vram_init; 48 72 priv->base.tile.regions = 8; 49 73 priv->base.tile.init = nv10_fb_tile_init; 50 74 priv->base.tile.fini = nv10_fb_tile_fini; 51 75 priv->base.tile.prog = nv10_fb_tile_prog; 52 - return nouveau_fb_preinit(&priv->base); 76 + return 0; 53 77 } 54 78 55 79 struct nouveau_oclass
+4 -22
drivers/gpu/drm/nouveau/core/subdev/fb/nv20.c
··· 24 24 * 25 25 */ 26 26 27 - #include <subdev/fb.h> 27 + #include "priv.h" 28 28 29 29 struct nv20_fb_priv { 30 30 struct nouveau_fb base; 31 31 }; 32 - 33 - int 34 - nv20_fb_vram_init(struct nouveau_fb *pfb) 35 - { 36 - u32 pbus1218 = nv_rd32(pfb, 0x001218); 37 - 38 - switch (pbus1218 & 0x00000300) { 39 - case 0x00000000: pfb->ram.type = NV_MEM_TYPE_SDRAM; break; 40 - case 0x00000100: pfb->ram.type = NV_MEM_TYPE_DDR1; break; 41 - case 0x00000200: pfb->ram.type = NV_MEM_TYPE_GDDR3; break; 42 - case 0x00000300: pfb->ram.type = NV_MEM_TYPE_GDDR2; break; 43 - } 44 - pfb->ram.size = (nv_rd32(pfb, 0x10020c) & 0xff000000); 45 - pfb->ram.parts = (nv_rd32(pfb, 0x100200) & 0x00000003) + 1; 46 - 47 - return nv_rd32(pfb, 0x100320); 48 - } 49 32 50 33 void 51 34 nv20_fb_tile_init(struct nouveau_fb *pfb, int i, u32 addr, u32 size, u32 pitch, ··· 48 65 struct nouveau_fb_tile *tile) 49 66 { 50 67 u32 tiles = DIV_ROUND_UP(size, 0x40); 51 - u32 tags = round_up(tiles / pfb->ram.parts, 0x40); 68 + u32 tags = round_up(tiles / pfb->ram->parts, 0x40); 52 69 if (!nouveau_mm_head(&pfb->tags, 1, tags, tags, 1, &tile->tag)) { 53 70 if (!(flags & 2)) tile->zcomp = 0x00000000; /* Z16 */ 54 71 else tile->zcomp = 0x04000000; /* Z24S8 */ ··· 88 105 struct nv20_fb_priv *priv; 89 106 int ret; 90 107 91 - ret = nouveau_fb_create(parent, engine, oclass, &priv); 108 + ret = nouveau_fb_create(parent, engine, oclass, &nv20_ram_oclass, &priv); 92 109 *pobject = nv_object(priv); 93 110 if (ret) 94 111 return ret; 95 112 96 113 priv->base.memtype_valid = nv04_fb_memtype_valid; 97 - priv->base.ram.init = nv20_fb_vram_init; 98 114 priv->base.tile.regions = 8; 99 115 priv->base.tile.init = nv20_fb_tile_init; 100 116 priv->base.tile.comp = nv20_fb_tile_comp; 101 117 priv->base.tile.fini = nv20_fb_tile_fini; 102 118 priv->base.tile.prog = nv20_fb_tile_prog; 103 - return nouveau_fb_preinit(&priv->base); 119 + return 0; 104 120 } 105 121 106 122 struct nouveau_oclass
+4 -5
drivers/gpu/drm/nouveau/core/subdev/fb/nv25.c
··· 24 24 * 25 25 */ 26 26 27 - #include <subdev/fb.h> 27 + #include "priv.h" 28 28 29 29 struct nv25_fb_priv { 30 30 struct nouveau_fb base; ··· 35 35 struct nouveau_fb_tile *tile) 36 36 { 37 37 u32 tiles = DIV_ROUND_UP(size, 0x40); 38 - u32 tags = round_up(tiles / pfb->ram.parts, 0x40); 38 + u32 tags = round_up(tiles / pfb->ram->parts, 0x40); 39 39 if (!nouveau_mm_head(&pfb->tags, 1, tags, tags, 1, &tile->tag)) { 40 40 if (!(flags & 2)) tile->zcomp = 0x00100000; /* Z16 */ 41 41 else tile->zcomp = 0x00200000; /* Z24S8 */ ··· 54 54 struct nv25_fb_priv *priv; 55 55 int ret; 56 56 57 - ret = nouveau_fb_create(parent, engine, oclass, &priv); 57 + ret = nouveau_fb_create(parent, engine, oclass, &nv20_ram_oclass, &priv); 58 58 *pobject = nv_object(priv); 59 59 if (ret) 60 60 return ret; 61 61 62 62 priv->base.memtype_valid = nv04_fb_memtype_valid; 63 - priv->base.ram.init = nv20_fb_vram_init; 64 63 priv->base.tile.regions = 8; 65 64 priv->base.tile.init = nv20_fb_tile_init; 66 65 priv->base.tile.comp = nv25_fb_tile_comp; 67 66 priv->base.tile.fini = nv20_fb_tile_fini; 68 67 priv->base.tile.prog = nv20_fb_tile_prog; 69 - return nouveau_fb_preinit(&priv->base); 68 + return 0; 70 69 } 71 70 72 71 struct nouveau_oclass
+4 -5
drivers/gpu/drm/nouveau/core/subdev/fb/nv30.c
··· 24 24 * 25 25 */ 26 26 27 - #include <subdev/fb.h> 27 + #include "priv.h" 28 28 29 29 struct nv30_fb_priv { 30 30 struct nouveau_fb base; ··· 54 54 struct nouveau_fb_tile *tile) 55 55 { 56 56 u32 tiles = DIV_ROUND_UP(size, 0x40); 57 - u32 tags = round_up(tiles / pfb->ram.parts, 0x40); 57 + u32 tags = round_up(tiles / pfb->ram->parts, 0x40); 58 58 if (!nouveau_mm_head(&pfb->tags, 1, tags, tags, 1, &tile->tag)) { 59 59 if (flags & 2) tile->zcomp |= 0x01000000; /* Z16 */ 60 60 else tile->zcomp |= 0x02000000; /* Z24S8 */ ··· 132 132 struct nv30_fb_priv *priv; 133 133 int ret; 134 134 135 - ret = nouveau_fb_create(parent, engine, oclass, &priv); 135 + ret = nouveau_fb_create(parent, engine, oclass, &nv20_ram_oclass, &priv); 136 136 *pobject = nv_object(priv); 137 137 if (ret) 138 138 return ret; 139 139 140 140 priv->base.memtype_valid = nv04_fb_memtype_valid; 141 - priv->base.ram.init = nv20_fb_vram_init; 142 141 priv->base.tile.regions = 8; 143 142 priv->base.tile.init = nv30_fb_tile_init; 144 143 priv->base.tile.comp = nv30_fb_tile_comp; 145 144 priv->base.tile.fini = nv20_fb_tile_fini; 146 145 priv->base.tile.prog = nv20_fb_tile_prog; 147 - return nouveau_fb_preinit(&priv->base); 146 + return 0; 148 147 } 149 148 150 149 struct nouveau_oclass
+4 -5
drivers/gpu/drm/nouveau/core/subdev/fb/nv35.c
··· 24 24 * 25 25 */ 26 26 27 - #include <subdev/fb.h> 27 + #include "priv.h" 28 28 29 29 struct nv35_fb_priv { 30 30 struct nouveau_fb base; ··· 35 35 struct nouveau_fb_tile *tile) 36 36 { 37 37 u32 tiles = DIV_ROUND_UP(size, 0x40); 38 - u32 tags = round_up(tiles / pfb->ram.parts, 0x40); 38 + u32 tags = round_up(tiles / pfb->ram->parts, 0x40); 39 39 if (!nouveau_mm_head(&pfb->tags, 1, tags, tags, 1, &tile->tag)) { 40 40 if (flags & 2) tile->zcomp |= 0x04000000; /* Z16 */ 41 41 else tile->zcomp |= 0x08000000; /* Z24S8 */ ··· 55 55 struct nv35_fb_priv *priv; 56 56 int ret; 57 57 58 - ret = nouveau_fb_create(parent, engine, oclass, &priv); 58 + ret = nouveau_fb_create(parent, engine, oclass, &nv20_ram_oclass, &priv); 59 59 *pobject = nv_object(priv); 60 60 if (ret) 61 61 return ret; 62 62 63 63 priv->base.memtype_valid = nv04_fb_memtype_valid; 64 - priv->base.ram.init = nv20_fb_vram_init; 65 64 priv->base.tile.regions = 8; 66 65 priv->base.tile.init = nv30_fb_tile_init; 67 66 priv->base.tile.comp = nv35_fb_tile_comp; 68 67 priv->base.tile.fini = nv20_fb_tile_fini; 69 68 priv->base.tile.prog = nv20_fb_tile_prog; 70 - return nouveau_fb_preinit(&priv->base); 69 + return 0; 71 70 } 72 71 73 72 struct nouveau_oclass
+4 -5
drivers/gpu/drm/nouveau/core/subdev/fb/nv36.c
··· 24 24 * 25 25 */ 26 26 27 - #include <subdev/fb.h> 27 + #include "priv.h" 28 28 29 29 struct nv36_fb_priv { 30 30 struct nouveau_fb base; ··· 35 35 struct nouveau_fb_tile *tile) 36 36 { 37 37 u32 tiles = DIV_ROUND_UP(size, 0x40); 38 - u32 tags = round_up(tiles / pfb->ram.parts, 0x40); 38 + u32 tags = round_up(tiles / pfb->ram->parts, 0x40); 39 39 if (!nouveau_mm_head(&pfb->tags, 1, tags, tags, 1, &tile->tag)) { 40 40 if (flags & 2) tile->zcomp |= 0x10000000; /* Z16 */ 41 41 else tile->zcomp |= 0x20000000; /* Z24S8 */ ··· 55 55 struct nv36_fb_priv *priv; 56 56 int ret; 57 57 58 - ret = nouveau_fb_create(parent, engine, oclass, &priv); 58 + ret = nouveau_fb_create(parent, engine, oclass, &nv20_ram_oclass, &priv); 59 59 *pobject = nv_object(priv); 60 60 if (ret) 61 61 return ret; 62 62 63 63 priv->base.memtype_valid = nv04_fb_memtype_valid; 64 - priv->base.ram.init = nv20_fb_vram_init; 65 64 priv->base.tile.regions = 8; 66 65 priv->base.tile.init = nv30_fb_tile_init; 67 66 priv->base.tile.comp = nv36_fb_tile_comp; 68 67 priv->base.tile.fini = nv20_fb_tile_fini; 69 68 priv->base.tile.prog = nv20_fb_tile_prog; 70 - return nouveau_fb_preinit(&priv->base); 69 + return 0; 71 70 } 72 71 73 72 struct nouveau_oclass
+4 -21
drivers/gpu/drm/nouveau/core/subdev/fb/nv40.c
··· 24 24 * 25 25 */ 26 26 27 - #include <subdev/fb.h> 27 + #include "priv.h" 28 28 29 29 struct nv40_fb_priv { 30 30 struct nouveau_fb base; 31 31 }; 32 - 33 - static int 34 - nv40_fb_vram_init(struct nouveau_fb *pfb) 35 - { 36 - u32 pbus1218 = nv_rd32(pfb, 0x001218); 37 - switch (pbus1218 & 0x00000300) { 38 - case 0x00000000: pfb->ram.type = NV_MEM_TYPE_SDRAM; break; 39 - case 0x00000100: pfb->ram.type = NV_MEM_TYPE_DDR1; break; 40 - case 0x00000200: pfb->ram.type = NV_MEM_TYPE_GDDR3; break; 41 - case 0x00000300: pfb->ram.type = NV_MEM_TYPE_DDR2; break; 42 - } 43 - 44 - pfb->ram.size = nv_rd32(pfb, 0x10020c) & 0xff000000; 45 - pfb->ram.parts = (nv_rd32(pfb, 0x100200) & 0x00000003) + 1; 46 - return nv_rd32(pfb, 0x100320); 47 - } 48 32 49 33 void 50 34 nv40_fb_tile_comp(struct nouveau_fb *pfb, int i, u32 size, u32 flags, 51 35 struct nouveau_fb_tile *tile) 52 36 { 53 37 u32 tiles = DIV_ROUND_UP(size, 0x80); 54 - u32 tags = round_up(tiles / pfb->ram.parts, 0x100); 38 + u32 tags = round_up(tiles / pfb->ram->parts, 0x100); 55 39 if ( (flags & 2) && 56 40 !nouveau_mm_head(&pfb->tags, 1, tags, tags, 1, &tile->tag)) { 57 41 tile->zcomp = 0x28000000; /* Z24S8_SPLIT_GRAD */ ··· 69 85 struct nv40_fb_priv *priv; 70 86 int ret; 71 87 72 - ret = nouveau_fb_create(parent, engine, oclass, &priv); 88 + ret = nouveau_fb_create(parent, engine, oclass, &nv40_ram_oclass, &priv); 73 89 *pobject = nv_object(priv); 74 90 if (ret) 75 91 return ret; 76 92 77 93 priv->base.memtype_valid = nv04_fb_memtype_valid; 78 - priv->base.ram.init = nv40_fb_vram_init; 79 94 priv->base.tile.regions = 8; 80 95 priv->base.tile.init = nv30_fb_tile_init; 81 96 priv->base.tile.comp = nv40_fb_tile_comp; 82 97 priv->base.tile.fini = nv20_fb_tile_fini; 83 98 priv->base.tile.prog = nv20_fb_tile_prog; 84 - return nouveau_fb_preinit(&priv->base); 99 + return 0; 85 100 } 86 101 87 102
+3 -20
drivers/gpu/drm/nouveau/core/subdev/fb/nv41.c
··· 24 24 * 25 25 */ 26 26 27 - #include <subdev/fb.h> 27 + #include "priv.h" 28 28 29 29 struct nv41_fb_priv { 30 30 struct nouveau_fb base; 31 31 }; 32 - 33 - int 34 - nv41_fb_vram_init(struct nouveau_fb *pfb) 35 - { 36 - u32 pfb474 = nv_rd32(pfb, 0x100474); 37 - if (pfb474 & 0x00000004) 38 - pfb->ram.type = NV_MEM_TYPE_GDDR3; 39 - if (pfb474 & 0x00000002) 40 - pfb->ram.type = NV_MEM_TYPE_DDR2; 41 - if (pfb474 & 0x00000001) 42 - pfb->ram.type = NV_MEM_TYPE_DDR1; 43 - 44 - pfb->ram.size = nv_rd32(pfb, 0x10020c) & 0xff000000; 45 - pfb->ram.parts = (nv_rd32(pfb, 0x100200) & 0x00000003) + 1; 46 - return nv_rd32(pfb, 0x100320); 47 - } 48 32 49 33 void 50 34 nv41_fb_tile_prog(struct nouveau_fb *pfb, int i, struct nouveau_fb_tile *tile) ··· 62 78 struct nv41_fb_priv *priv; 63 79 int ret; 64 80 65 - ret = nouveau_fb_create(parent, engine, oclass, &priv); 81 + ret = nouveau_fb_create(parent, engine, oclass, &nv41_ram_oclass, &priv); 66 82 *pobject = nv_object(priv); 67 83 if (ret) 68 84 return ret; 69 85 70 86 priv->base.memtype_valid = nv04_fb_memtype_valid; 71 - priv->base.ram.init = nv41_fb_vram_init; 72 87 priv->base.tile.regions = 12; 73 88 priv->base.tile.init = nv30_fb_tile_init; 74 89 priv->base.tile.comp = nv40_fb_tile_comp; 75 90 priv->base.tile.fini = nv20_fb_tile_fini; 76 91 priv->base.tile.prog = nv41_fb_tile_prog; 77 - return nouveau_fb_preinit(&priv->base); 92 + return 0; 78 93 } 79 94 80 95
+3 -19
drivers/gpu/drm/nouveau/core/subdev/fb/nv44.c
··· 24 24 * 25 25 */ 26 26 27 - #include <subdev/fb.h> 27 + #include "priv.h" 28 28 29 29 struct nv44_fb_priv { 30 30 struct nouveau_fb base; 31 31 }; 32 - 33 - int 34 - nv44_fb_vram_init(struct nouveau_fb *pfb) 35 - { 36 - u32 pfb474 = nv_rd32(pfb, 0x100474); 37 - if (pfb474 & 0x00000004) 38 - pfb->ram.type = NV_MEM_TYPE_GDDR3; 39 - if (pfb474 & 0x00000002) 40 - pfb->ram.type = NV_MEM_TYPE_DDR2; 41 - if (pfb474 & 0x00000001) 42 - pfb->ram.type = NV_MEM_TYPE_DDR1; 43 - 44 - pfb->ram.size = nv_rd32(pfb, 0x10020c) & 0xff000000; 45 - return 0; 46 - } 47 32 48 33 static void 49 34 nv44_fb_tile_init(struct nouveau_fb *pfb, int i, u32 addr, u32 size, u32 pitch, ··· 72 87 struct nv44_fb_priv *priv; 73 88 int ret; 74 89 75 - ret = nouveau_fb_create(parent, engine, oclass, &priv); 90 + ret = nouveau_fb_create(parent, engine, oclass, &nv44_ram_oclass, &priv); 76 91 *pobject = nv_object(priv); 77 92 if (ret) 78 93 return ret; 79 94 80 95 priv->base.memtype_valid = nv04_fb_memtype_valid; 81 - priv->base.ram.init = nv44_fb_vram_init; 82 96 priv->base.tile.regions = 12; 83 97 priv->base.tile.init = nv44_fb_tile_init; 84 98 priv->base.tile.fini = nv20_fb_tile_fini; 85 99 priv->base.tile.prog = nv44_fb_tile_prog; 86 - return nouveau_fb_preinit(&priv->base); 100 + return 0; 87 101 } 88 102 89 103
+3 -4
drivers/gpu/drm/nouveau/core/subdev/fb/nv46.c
··· 24 24 * 25 25 */ 26 26 27 - #include <subdev/fb.h> 27 + #include "priv.h" 28 28 29 29 struct nv46_fb_priv { 30 30 struct nouveau_fb base; ··· 52 52 struct nv46_fb_priv *priv; 53 53 int ret; 54 54 55 - ret = nouveau_fb_create(parent, engine, oclass, &priv); 55 + ret = nouveau_fb_create(parent, engine, oclass, &nv44_ram_oclass, &priv); 56 56 *pobject = nv_object(priv); 57 57 if (ret) 58 58 return ret; 59 59 60 60 priv->base.memtype_valid = nv04_fb_memtype_valid; 61 - priv->base.ram.init = nv44_fb_vram_init; 62 61 priv->base.tile.regions = 15; 63 62 priv->base.tile.init = nv46_fb_tile_init; 64 63 priv->base.tile.fini = nv20_fb_tile_fini; 65 64 priv->base.tile.prog = nv44_fb_tile_prog; 66 - return nouveau_fb_preinit(&priv->base); 65 + return 0; 67 66 } 68 67 69 68
+3 -4
drivers/gpu/drm/nouveau/core/subdev/fb/nv47.c
··· 24 24 * 25 25 */ 26 26 27 - #include <subdev/fb.h> 27 + #include "priv.h" 28 28 29 29 struct nv47_fb_priv { 30 30 struct nouveau_fb base; ··· 38 38 struct nv47_fb_priv *priv; 39 39 int ret; 40 40 41 - ret = nouveau_fb_create(parent, engine, oclass, &priv); 41 + ret = nouveau_fb_create(parent, engine, oclass, &nv41_ram_oclass, &priv); 42 42 *pobject = nv_object(priv); 43 43 if (ret) 44 44 return ret; 45 45 46 46 priv->base.memtype_valid = nv04_fb_memtype_valid; 47 - priv->base.ram.init = nv41_fb_vram_init; 48 47 priv->base.tile.regions = 15; 49 48 priv->base.tile.init = nv30_fb_tile_init; 50 49 priv->base.tile.comp = nv40_fb_tile_comp; 51 50 priv->base.tile.fini = nv20_fb_tile_fini; 52 51 priv->base.tile.prog = nv41_fb_tile_prog; 53 - return nouveau_fb_preinit(&priv->base); 52 + return 0; 54 53 } 55 54 56 55
+3 -22
drivers/gpu/drm/nouveau/core/subdev/fb/nv49.c
··· 24 24 * 25 25 */ 26 26 27 - #include <subdev/fb.h> 27 + #include "priv.h" 28 28 29 29 struct nv49_fb_priv { 30 30 struct nouveau_fb base; 31 31 }; 32 - 33 - static int 34 - nv49_fb_vram_init(struct nouveau_fb *pfb) 35 - { 36 - u32 pfb914 = nv_rd32(pfb, 0x100914); 37 - 38 - switch (pfb914 & 0x00000003) { 39 - case 0x00000000: pfb->ram.type = NV_MEM_TYPE_DDR1; break; 40 - case 0x00000001: pfb->ram.type = NV_MEM_TYPE_DDR2; break; 41 - case 0x00000002: pfb->ram.type = NV_MEM_TYPE_GDDR3; break; 42 - case 0x00000003: break; 43 - } 44 - 45 - pfb->ram.size = nv_rd32(pfb, 0x10020c) & 0xff000000; 46 - pfb->ram.parts = (nv_rd32(pfb, 0x100200) & 0x00000003) + 1; 47 - return nv_rd32(pfb, 0x100320); 48 - } 49 32 50 33 static int 51 34 nv49_fb_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ··· 38 55 struct nv49_fb_priv *priv; 39 56 int ret; 40 57 41 - ret = nouveau_fb_create(parent, engine, oclass, &priv); 58 + ret = nouveau_fb_create(parent, engine, oclass, &nv49_ram_oclass, &priv); 42 59 *pobject = nv_object(priv); 43 60 if (ret) 44 61 return ret; 45 62 46 63 priv->base.memtype_valid = nv04_fb_memtype_valid; 47 - priv->base.ram.init = nv49_fb_vram_init; 48 64 priv->base.tile.regions = 15; 49 65 priv->base.tile.init = nv30_fb_tile_init; 50 66 priv->base.tile.comp = nv40_fb_tile_comp; 51 67 priv->base.tile.fini = nv20_fb_tile_fini; 52 68 priv->base.tile.prog = nv41_fb_tile_prog; 53 - 54 - return nouveau_fb_preinit(&priv->base); 69 + return 0; 55 70 } 56 71 57 72
+3 -12
drivers/gpu/drm/nouveau/core/subdev/fb/nv4e.c
··· 24 24 * 25 25 */ 26 26 27 - #include <subdev/fb.h> 27 + #include "priv.h" 28 28 29 29 struct nv4e_fb_priv { 30 30 struct nouveau_fb base; 31 31 }; 32 - 33 - static int 34 - nv4e_fb_vram_init(struct nouveau_fb *pfb) 35 - { 36 - pfb->ram.size = nv_rd32(pfb, 0x10020c) & 0xff000000; 37 - pfb->ram.type = NV_MEM_TYPE_STOLEN; 38 - return 0; 39 - } 40 32 41 33 static int 42 34 nv4e_fb_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ··· 38 46 struct nv4e_fb_priv *priv; 39 47 int ret; 40 48 41 - ret = nouveau_fb_create(parent, engine, oclass, &priv); 49 + ret = nouveau_fb_create(parent, engine, oclass, &nv4e_ram_oclass, &priv); 42 50 *pobject = nv_object(priv); 43 51 if (ret) 44 52 return ret; 45 53 46 54 priv->base.memtype_valid = nv04_fb_memtype_valid; 47 - priv->base.ram.init = nv4e_fb_vram_init; 48 55 priv->base.tile.regions = 12; 49 56 priv->base.tile.init = nv46_fb_tile_init; 50 57 priv->base.tile.fini = nv20_fb_tile_fini; 51 58 priv->base.tile.prog = nv44_fb_tile_prog; 52 - return nouveau_fb_preinit(&priv->base); 59 + return 0; 53 60 } 54 61 55 62 struct nouveau_oclass
+6 -193
drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c
··· 27 27 #include <core/engctx.h> 28 28 #include <core/object.h> 29 29 30 - #include <subdev/fb.h> 30 + #include "priv.h" 31 31 #include <subdev/bios.h> 32 32 33 33 struct nv50_fb_priv { ··· 36 36 dma_addr_t r100c08; 37 37 }; 38 38 39 - static int types[0x80] = { 39 + int 40 + nv50_fb_memtype[0x80] = { 40 41 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41 42 1, 1, 1, 1, 0, 0, 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, 42 43 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 2, 2, 0, ··· 51 50 static bool 52 51 nv50_fb_memtype_valid(struct nouveau_fb *pfb, u32 memtype) 53 52 { 54 - return types[(memtype & 0xff00) >> 8] != 0; 55 - } 56 - 57 - static u32 58 - nv50_fb_vram_rblock(struct nouveau_fb *pfb) 59 - { 60 - int i, parts, colbits, rowbitsa, rowbitsb, banks; 61 - u64 rowsize, predicted; 62 - u32 r0, r4, rt, ru, rblock_size; 63 - 64 - r0 = nv_rd32(pfb, 0x100200); 65 - r4 = nv_rd32(pfb, 0x100204); 66 - rt = nv_rd32(pfb, 0x100250); 67 - ru = nv_rd32(pfb, 0x001540); 68 - nv_debug(pfb, "memcfg 0x%08x 0x%08x 0x%08x 0x%08x\n", r0, r4, rt, ru); 69 - 70 - for (i = 0, parts = 0; i < 8; i++) { 71 - if (ru & (0x00010000 << i)) 72 - parts++; 73 - } 74 - 75 - colbits = (r4 & 0x0000f000) >> 12; 76 - rowbitsa = ((r4 & 0x000f0000) >> 16) + 8; 77 - rowbitsb = ((r4 & 0x00f00000) >> 20) + 8; 78 - banks = 1 << (((r4 & 0x03000000) >> 24) + 2); 79 - 80 - rowsize = parts * banks * (1 << colbits) * 8; 81 - predicted = rowsize << rowbitsa; 82 - if (r0 & 0x00000004) 83 - predicted += rowsize << rowbitsb; 84 - 85 - if (predicted != pfb->ram.size) { 86 - nv_warn(pfb, "memory controller reports %d MiB VRAM\n", 87 - (u32)(pfb->ram.size >> 20)); 88 - } 89 - 90 - rblock_size = rowsize; 91 - if (rt & 1) 92 - rblock_size *= 3; 93 - 94 - nv_debug(pfb, "rblock %d bytes\n", rblock_size); 95 - return rblock_size; 96 - } 97 - 98 - static int 99 - nv50_fb_vram_init(struct nouveau_fb *pfb) 100 - { 101 - struct nouveau_device *device = nv_device(pfb); 102 - struct nouveau_bios *bios = nouveau_bios(device); 103 - const u32 rsvd_head = ( 256 * 1024) >> 12; /* vga memory */ 104 - const u32 rsvd_tail = (1024 * 1024) >> 12; /* vbios etc */ 105 - u32 size, tags = 0; 106 - int ret; 107 - 108 - pfb->ram.size = nv_rd32(pfb, 0x10020c); 109 - pfb->ram.size = (pfb->ram.size & 0xffffff00) | 110 - ((pfb->ram.size & 0x000000ff) << 32); 111 - 112 - size = (pfb->ram.size >> 12) - rsvd_head - rsvd_tail; 113 - switch (device->chipset) { 114 - case 0xaa: 115 - case 0xac: 116 - case 0xaf: /* IGPs, no reordering, no real VRAM */ 117 - ret = nouveau_mm_init(&pfb->vram, rsvd_head, size, 1); 118 - if (ret) 119 - return ret; 120 - 121 - pfb->ram.type = NV_MEM_TYPE_STOLEN; 122 - pfb->ram.stolen = (u64)nv_rd32(pfb, 0x100e10) << 12; 123 - break; 124 - default: 125 - switch (nv_rd32(pfb, 0x100714) & 0x00000007) { 126 - case 0: pfb->ram.type = NV_MEM_TYPE_DDR1; break; 127 - case 1: 128 - if (nouveau_fb_bios_memtype(bios) == NV_MEM_TYPE_DDR3) 129 - pfb->ram.type = NV_MEM_TYPE_DDR3; 130 - else 131 - pfb->ram.type = NV_MEM_TYPE_DDR2; 132 - break; 133 - case 2: pfb->ram.type = NV_MEM_TYPE_GDDR3; break; 134 - case 3: pfb->ram.type = NV_MEM_TYPE_GDDR4; break; 135 - case 4: pfb->ram.type = NV_MEM_TYPE_GDDR5; break; 136 - default: 137 - break; 138 - } 139 - 140 - ret = nouveau_mm_init(&pfb->vram, rsvd_head, size, 141 - nv50_fb_vram_rblock(pfb) >> 12); 142 - if (ret) 143 - return ret; 144 - 145 - pfb->ram.ranks = (nv_rd32(pfb, 0x100200) & 0x4) ? 2 : 1; 146 - tags = nv_rd32(pfb, 0x100320); 147 - break; 148 - } 149 - 150 - return tags; 151 - } 152 - 153 - static int 154 - nv50_fb_vram_new(struct nouveau_fb *pfb, u64 size, u32 align, u32 ncmin, 155 - u32 memtype, struct nouveau_mem **pmem) 156 - { 157 - struct nv50_fb_priv *priv = (void *)pfb; 158 - struct nouveau_mm *heap = &priv->base.vram; 159 - struct nouveau_mm *tags = &priv->base.tags; 160 - struct nouveau_mm_node *r; 161 - struct nouveau_mem *mem; 162 - int comp = (memtype & 0x300) >> 8; 163 - int type = (memtype & 0x07f); 164 - int back = (memtype & 0x800); 165 - int min, max, ret; 166 - 167 - max = (size >> 12); 168 - min = ncmin ? (ncmin >> 12) : max; 169 - align >>= 12; 170 - 171 - mem = kzalloc(sizeof(*mem), GFP_KERNEL); 172 - if (!mem) 173 - return -ENOMEM; 174 - 175 - mutex_lock(&pfb->base.mutex); 176 - if (comp) { 177 - if (align == 16) { 178 - int n = (max >> 4) * comp; 179 - 180 - ret = nouveau_mm_head(tags, 1, n, n, 1, &mem->tag); 181 - if (ret) 182 - mem->tag = NULL; 183 - } 184 - 185 - if (unlikely(!mem->tag)) 186 - comp = 0; 187 - } 188 - 189 - INIT_LIST_HEAD(&mem->regions); 190 - mem->memtype = (comp << 7) | type; 191 - mem->size = max; 192 - 193 - type = types[type]; 194 - do { 195 - if (back) 196 - ret = nouveau_mm_tail(heap, type, max, min, align, &r); 197 - else 198 - ret = nouveau_mm_head(heap, type, max, min, align, &r); 199 - if (ret) { 200 - mutex_unlock(&pfb->base.mutex); 201 - pfb->ram.put(pfb, &mem); 202 - return ret; 203 - } 204 - 205 - list_add_tail(&r->rl_entry, &mem->regions); 206 - max -= r->length; 207 - } while (max); 208 - mutex_unlock(&pfb->base.mutex); 209 - 210 - r = list_first_entry(&mem->regions, struct nouveau_mm_node, rl_entry); 211 - mem->offset = (u64)r->offset << 12; 212 - *pmem = mem; 213 - return 0; 214 - } 215 - 216 - void 217 - nv50_fb_vram_del(struct nouveau_fb *pfb, struct nouveau_mem **pmem) 218 - { 219 - struct nv50_fb_priv *priv = (void *)pfb; 220 - struct nouveau_mm_node *this; 221 - struct nouveau_mem *mem; 222 - 223 - mem = *pmem; 224 - *pmem = NULL; 225 - if (unlikely(mem == NULL)) 226 - return; 227 - 228 - mutex_lock(&pfb->base.mutex); 229 - while (!list_empty(&mem->regions)) { 230 - this = list_first_entry(&mem->regions, typeof(*this), rl_entry); 231 - 232 - list_del(&this->rl_entry); 233 - nouveau_mm_free(&priv->base.vram, &this); 234 - } 235 - 236 - nouveau_mm_free(&priv->base.tags, &mem->tag); 237 - mutex_unlock(&pfb->base.mutex); 238 - 239 - kfree(mem); 53 + return nv50_fb_memtype[(memtype & 0xff00) >> 8] != 0; 240 54 } 241 55 242 56 static const struct nouveau_enum vm_dispatch_subclients[] = { ··· 248 432 struct nv50_fb_priv *priv; 249 433 int ret; 250 434 251 - ret = nouveau_fb_create(parent, engine, oclass, &priv); 435 + ret = nouveau_fb_create(parent, engine, oclass, &nv50_ram_oclass, &priv); 252 436 *pobject = nv_object(priv); 253 437 if (ret) 254 438 return ret; ··· 265 449 } 266 450 267 451 priv->base.memtype_valid = nv50_fb_memtype_valid; 268 - priv->base.ram.init = nv50_fb_vram_init; 269 - priv->base.ram.get = nv50_fb_vram_new; 270 - priv->base.ram.put = nv50_fb_vram_del; 271 452 nv_subdev(priv)->intr = nv50_fb_intr; 272 - return nouveau_fb_preinit(&priv->base); 453 + return 0; 273 454 } 274 455 275 456 static void
+3 -140
drivers/gpu/drm/nouveau/core/subdev/fb/nvc0.c
··· 22 22 * Authors: Ben Skeggs 23 23 */ 24 24 25 - #include <subdev/fb.h> 26 - #include <subdev/ltcg.h> 27 - #include <subdev/bios.h> 25 + #include "priv.h" 28 26 29 27 struct nvc0_fb_priv { 30 28 struct nouveau_fb base; ··· 32 34 33 35 extern const u8 nvc0_pte_storage_type_map[256]; 34 36 35 - 36 37 static bool 37 38 nvc0_fb_memtype_valid(struct nouveau_fb *pfb, u32 tile_flags) 38 39 { 39 40 u8 memtype = (tile_flags & 0x0000ff00) >> 8; 40 41 return likely((nvc0_pte_storage_type_map[memtype] != 0xff)); 41 - } 42 - 43 - static int 44 - nvc0_fb_vram_init(struct nouveau_fb *pfb) 45 - { 46 - struct nouveau_bios *bios = nouveau_bios(pfb); 47 - const u32 rsvd_head = ( 256 * 1024) >> 12; /* vga memory */ 48 - const u32 rsvd_tail = (1024 * 1024) >> 12; /* vbios etc */ 49 - u32 parts = nv_rd32(pfb, 0x022438); 50 - u32 pmask = nv_rd32(pfb, 0x022554); 51 - u32 bsize = nv_rd32(pfb, 0x10f20c); 52 - u32 offset, length; 53 - bool uniform = true; 54 - int ret, part; 55 - 56 - nv_debug(pfb, "0x100800: 0x%08x\n", nv_rd32(pfb, 0x100800)); 57 - nv_debug(pfb, "parts 0x%08x mask 0x%08x\n", parts, pmask); 58 - 59 - pfb->ram.type = nouveau_fb_bios_memtype(bios); 60 - pfb->ram.ranks = (nv_rd32(pfb, 0x10f200) & 0x00000004) ? 2 : 1; 61 - 62 - /* read amount of vram attached to each memory controller */ 63 - for (part = 0; part < parts; part++) { 64 - if (!(pmask & (1 << part))) { 65 - u32 psize = nv_rd32(pfb, 0x11020c + (part * 0x1000)); 66 - if (psize != bsize) { 67 - if (psize < bsize) 68 - bsize = psize; 69 - uniform = false; 70 - } 71 - 72 - nv_debug(pfb, "%d: mem_amount 0x%08x\n", part, psize); 73 - pfb->ram.size += (u64)psize << 20; 74 - } 75 - } 76 - 77 - /* if all controllers have the same amount attached, there's no holes */ 78 - if (uniform) { 79 - offset = rsvd_head; 80 - length = (pfb->ram.size >> 12) - rsvd_head - rsvd_tail; 81 - return nouveau_mm_init(&pfb->vram, offset, length, 1); 82 - } 83 - 84 - /* otherwise, address lowest common amount from 0GiB */ 85 - ret = nouveau_mm_init(&pfb->vram, rsvd_head, (bsize << 8) * parts, 1); 86 - if (ret) 87 - return ret; 88 - 89 - /* and the rest starting from (8GiB + common_size) */ 90 - offset = (0x0200000000ULL >> 12) + (bsize << 8); 91 - length = (pfb->ram.size >> 12) - (bsize << 8) - rsvd_tail; 92 - 93 - ret = nouveau_mm_init(&pfb->vram, offset, length, 0); 94 - if (ret) { 95 - nouveau_mm_fini(&pfb->vram); 96 - return ret; 97 - } 98 - 99 - return 0; 100 - } 101 - 102 - static int 103 - nvc0_fb_vram_new(struct nouveau_fb *pfb, u64 size, u32 align, u32 ncmin, 104 - u32 memtype, struct nouveau_mem **pmem) 105 - { 106 - struct nouveau_mm *mm = &pfb->vram; 107 - struct nouveau_mm_node *r; 108 - struct nouveau_mem *mem; 109 - int type = (memtype & 0x0ff); 110 - int back = (memtype & 0x800); 111 - int ret; 112 - const bool comp = nvc0_pte_storage_type_map[type] != type; 113 - 114 - size >>= 12; 115 - align >>= 12; 116 - ncmin >>= 12; 117 - if (!ncmin) 118 - ncmin = size; 119 - 120 - mem = kzalloc(sizeof(*mem), GFP_KERNEL); 121 - if (!mem) 122 - return -ENOMEM; 123 - 124 - INIT_LIST_HEAD(&mem->regions); 125 - mem->size = size; 126 - 127 - mutex_lock(&pfb->base.mutex); 128 - if (comp) { 129 - struct nouveau_ltcg *ltcg = nouveau_ltcg(pfb->base.base.parent); 130 - 131 - /* compression only works with lpages */ 132 - if (align == (1 << (17 - 12))) { 133 - int n = size >> 5; 134 - ltcg->tags_alloc(ltcg, n, &mem->tag); 135 - } 136 - if (unlikely(!mem->tag)) 137 - type = nvc0_pte_storage_type_map[type]; 138 - } 139 - mem->memtype = type; 140 - 141 - do { 142 - if (back) 143 - ret = nouveau_mm_tail(mm, 1, size, ncmin, align, &r); 144 - else 145 - ret = nouveau_mm_head(mm, 1, size, ncmin, align, &r); 146 - if (ret) { 147 - mutex_unlock(&pfb->base.mutex); 148 - pfb->ram.put(pfb, &mem); 149 - return ret; 150 - } 151 - 152 - list_add_tail(&r->rl_entry, &mem->regions); 153 - size -= r->length; 154 - } while (size); 155 - mutex_unlock(&pfb->base.mutex); 156 - 157 - r = list_first_entry(&mem->regions, struct nouveau_mm_node, rl_entry); 158 - mem->offset = (u64)r->offset << 12; 159 - *pmem = mem; 160 - return 0; 161 - } 162 - 163 - static void 164 - nvc0_fb_vram_del(struct nouveau_fb *pfb, struct nouveau_mem **pmem) 165 - { 166 - struct nouveau_ltcg *ltcg = nouveau_ltcg(pfb->base.base.parent); 167 - 168 - if ((*pmem)->tag) 169 - ltcg->tags_free(ltcg, &(*pmem)->tag); 170 - 171 - nv50_fb_vram_del(pfb, pmem); 172 42 } 173 43 174 44 static int ··· 78 212 struct nvc0_fb_priv *priv; 79 213 int ret; 80 214 81 - ret = nouveau_fb_create(parent, engine, oclass, &priv); 215 + ret = nouveau_fb_create(parent, engine, oclass, &nvc0_ram_oclass, &priv); 82 216 *pobject = nv_object(priv); 83 217 if (ret) 84 218 return ret; 85 219 86 220 priv->base.memtype_valid = nvc0_fb_memtype_valid; 87 - priv->base.ram.init = nvc0_fb_vram_init; 88 - priv->base.ram.get = nvc0_fb_vram_new; 89 - priv->base.ram.put = nvc0_fb_vram_del; 90 221 91 222 priv->r100c10_page = alloc_page(GFP_KERNEL | __GFP_ZERO); 92 223 if (priv->r100c10_page) { ··· 94 231 return -EFAULT; 95 232 } 96 233 97 - return nouveau_fb_preinit(&priv->base); 234 + return 0; 98 235 } 99 236 100 237
+87
drivers/gpu/drm/nouveau/core/subdev/fb/priv.h
··· 1 + #ifndef __NVKM_FB_PRIV_H__ 2 + #define __NVKM_FB_PRIV_H__ 3 + 4 + #include <subdev/fb.h> 5 + 6 + #define nouveau_ram_create(p,e,o,d) \ 7 + nouveau_object_create_((p), (e), (o), 0, sizeof(**d), (void **)d) 8 + #define nouveau_ram_destroy(p) \ 9 + nouveau_object_destroy(&(p)->base) 10 + #define nouveau_ram_init(p) \ 11 + nouveau_object_init(&(p)->base) 12 + #define nouveau_ram_fini(p,s) \ 13 + nouveau_object_fini(&(p)->base, (s)) 14 + 15 + #define _nouveau_ram_dtor nouveau_object_destroy 16 + #define _nouveau_ram_init nouveau_object_init 17 + #define _nouveau_ram_fini nouveau_object_fini 18 + 19 + extern struct nouveau_oclass nv04_ram_oclass; 20 + extern struct nouveau_oclass nv10_ram_oclass; 21 + extern struct nouveau_oclass nv1a_ram_oclass; 22 + extern struct nouveau_oclass nv20_ram_oclass; 23 + extern struct nouveau_oclass nv40_ram_oclass; 24 + extern struct nouveau_oclass nv41_ram_oclass; 25 + extern struct nouveau_oclass nv44_ram_oclass; 26 + extern struct nouveau_oclass nv49_ram_oclass; 27 + extern struct nouveau_oclass nv4e_ram_oclass; 28 + extern struct nouveau_oclass nv50_ram_oclass; 29 + extern struct nouveau_oclass nvc0_ram_oclass; 30 + 31 + #define nouveau_fb_create(p,e,c,r,d) \ 32 + nouveau_fb_create_((p), (e), (c), (r), sizeof(**d), (void **)d) 33 + #define nouveau_fb_destroy(p) ({ \ 34 + struct nouveau_fb *pfb = (p); \ 35 + _nouveau_fb_dtor(nv_object(pfb)); \ 36 + }) 37 + #define nouveau_fb_init(p) ({ \ 38 + struct nouveau_fb *pfb = (p); \ 39 + _nouveau_fb_init(nv_object(pfb)); \ 40 + }) 41 + #define nouveau_fb_fini(p,s) ({ \ 42 + struct nouveau_fb *pfb = (p); \ 43 + _nouveau_fb_fini(nv_object(pfb), (s)); \ 44 + }) 45 + 46 + int nouveau_fb_create_(struct nouveau_object *, struct nouveau_object *, 47 + struct nouveau_oclass *, struct nouveau_oclass *, 48 + int length, void **pobject); 49 + void _nouveau_fb_dtor(struct nouveau_object *); 50 + int _nouveau_fb_init(struct nouveau_object *); 51 + int _nouveau_fb_fini(struct nouveau_object *, bool); 52 + 53 + struct nouveau_bios; 54 + int nouveau_fb_bios_memtype(struct nouveau_bios *); 55 + 56 + bool nv04_fb_memtype_valid(struct nouveau_fb *, u32 memtype); 57 + 58 + void nv10_fb_tile_init(struct nouveau_fb *, int i, u32 addr, u32 size, 59 + u32 pitch, u32 flags, struct nouveau_fb_tile *); 60 + void nv10_fb_tile_fini(struct nouveau_fb *, int i, struct nouveau_fb_tile *); 61 + void nv10_fb_tile_prog(struct nouveau_fb *, int, struct nouveau_fb_tile *); 62 + 63 + void nv20_fb_tile_init(struct nouveau_fb *, int i, u32 addr, u32 size, 64 + u32 pitch, u32 flags, struct nouveau_fb_tile *); 65 + void nv20_fb_tile_fini(struct nouveau_fb *, int i, struct nouveau_fb_tile *); 66 + void nv20_fb_tile_prog(struct nouveau_fb *, int, struct nouveau_fb_tile *); 67 + 68 + int nv30_fb_init(struct nouveau_object *); 69 + void nv30_fb_tile_init(struct nouveau_fb *, int i, u32 addr, u32 size, 70 + u32 pitch, u32 flags, struct nouveau_fb_tile *); 71 + 72 + void nv40_fb_tile_comp(struct nouveau_fb *, int i, u32 size, u32 flags, 73 + struct nouveau_fb_tile *); 74 + 75 + int nv41_fb_init(struct nouveau_object *); 76 + void nv41_fb_tile_prog(struct nouveau_fb *, int, struct nouveau_fb_tile *); 77 + 78 + int nv44_fb_init(struct nouveau_object *); 79 + void nv44_fb_tile_prog(struct nouveau_fb *, int, struct nouveau_fb_tile *); 80 + 81 + void nv46_fb_tile_init(struct nouveau_fb *, int i, u32 addr, u32 size, 82 + u32 pitch, u32 flags, struct nouveau_fb_tile *); 83 + 84 + void nv50_ram_put(struct nouveau_fb *, struct nouveau_mem **); 85 + extern int nv50_fb_memtype[0x80]; 86 + 87 + #endif
+95
drivers/gpu/drm/nouveau/core/subdev/fb/ramnv04.c
··· 1 + /* 2 + * Copyright 2013 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 + 25 + #define NV04_PFB_BOOT_0 0x00100000 26 + # define NV04_PFB_BOOT_0_RAM_AMOUNT 0x00000003 27 + # define NV04_PFB_BOOT_0_RAM_AMOUNT_32MB 0x00000000 28 + # define NV04_PFB_BOOT_0_RAM_AMOUNT_4MB 0x00000001 29 + # define NV04_PFB_BOOT_0_RAM_AMOUNT_8MB 0x00000002 30 + # define NV04_PFB_BOOT_0_RAM_AMOUNT_16MB 0x00000003 31 + # define NV04_PFB_BOOT_0_RAM_WIDTH_128 0x00000004 32 + # define NV04_PFB_BOOT_0_RAM_TYPE 0x00000028 33 + # define NV04_PFB_BOOT_0_RAM_TYPE_SGRAM_8MBIT 0x00000000 34 + # define NV04_PFB_BOOT_0_RAM_TYPE_SGRAM_16MBIT 0x00000008 35 + # define NV04_PFB_BOOT_0_RAM_TYPE_SGRAM_16MBIT_4BANK 0x00000010 36 + # define NV04_PFB_BOOT_0_RAM_TYPE_SDRAM_16MBIT 0x00000018 37 + # define NV04_PFB_BOOT_0_RAM_TYPE_SDRAM_64MBIT 0x00000020 38 + # define NV04_PFB_BOOT_0_RAM_TYPE_SDRAM_64MBITX16 0x00000028 39 + # define NV04_PFB_BOOT_0_UMA_ENABLE 0x00000100 40 + # define NV04_PFB_BOOT_0_UMA_SIZE 0x0000f000 41 + 42 + #include "priv.h" 43 + 44 + static int 45 + nv04_ram_create(struct nouveau_object *parent, struct nouveau_object *engine, 46 + struct nouveau_oclass *oclass, void *data, u32 size, 47 + struct nouveau_object **pobject) 48 + { 49 + struct nouveau_fb *pfb = nouveau_fb(parent); 50 + struct nouveau_ram *ram; 51 + u32 boot0 = nv_rd32(pfb, NV04_PFB_BOOT_0); 52 + int ret; 53 + 54 + ret = nouveau_ram_create(parent, engine, oclass, &ram); 55 + *pobject = nv_object(ram); 56 + if (ret) 57 + return ret; 58 + 59 + if (boot0 & 0x00000100) { 60 + ram->size = ((boot0 >> 12) & 0xf) * 2 + 2; 61 + ram->size *= 1024 * 1024; 62 + } else { 63 + switch (boot0 & NV04_PFB_BOOT_0_RAM_AMOUNT) { 64 + case NV04_PFB_BOOT_0_RAM_AMOUNT_32MB: 65 + ram->size = 32 * 1024 * 1024; 66 + break; 67 + case NV04_PFB_BOOT_0_RAM_AMOUNT_16MB: 68 + ram->size = 16 * 1024 * 1024; 69 + break; 70 + case NV04_PFB_BOOT_0_RAM_AMOUNT_8MB: 71 + ram->size = 8 * 1024 * 1024; 72 + break; 73 + case NV04_PFB_BOOT_0_RAM_AMOUNT_4MB: 74 + ram->size = 4 * 1024 * 1024; 75 + break; 76 + } 77 + } 78 + 79 + if ((boot0 & 0x00000038) <= 0x10) 80 + ram->type = NV_MEM_TYPE_SGRAM; 81 + else 82 + ram->type = NV_MEM_TYPE_SDRAM; 83 + return 0; 84 + } 85 + 86 + struct nouveau_oclass 87 + nv04_ram_oclass = { 88 + .handle = 0, 89 + .ofuncs = &(struct nouveau_ofuncs) { 90 + .ctor = nv04_ram_create, 91 + .dtor = _nouveau_ram_dtor, 92 + .init = _nouveau_ram_init, 93 + .fini = _nouveau_ram_fini, 94 + } 95 + };
+61
drivers/gpu/drm/nouveau/core/subdev/fb/ramnv10.c
··· 1 + /* 2 + * Copyright 2013 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 + 25 + #include "priv.h" 26 + 27 + static int 28 + nv10_ram_create(struct nouveau_object *parent, struct nouveau_object *engine, 29 + struct nouveau_oclass *oclass, void *data, u32 size, 30 + struct nouveau_object **pobject) 31 + { 32 + struct nouveau_fb *pfb = nouveau_fb(parent); 33 + struct nouveau_ram *ram; 34 + u32 cfg0 = nv_rd32(pfb, 0x100200); 35 + int ret; 36 + 37 + ret = nouveau_ram_create(parent, engine, oclass, &ram); 38 + *pobject = nv_object(ram); 39 + if (ret) 40 + return ret; 41 + 42 + if (cfg0 & 0x00000001) 43 + ram->type = NV_MEM_TYPE_DDR1; 44 + else 45 + ram->type = NV_MEM_TYPE_SDRAM; 46 + 47 + ram->size = nv_rd32(pfb, 0x10020c) & 0xff000000; 48 + return 0; 49 + } 50 + 51 + 52 + struct nouveau_oclass 53 + nv10_ram_oclass = { 54 + .handle = 0, 55 + .ofuncs = &(struct nouveau_ofuncs) { 56 + .ctor = nv10_ram_create, 57 + .dtor = _nouveau_ram_dtor, 58 + .init = _nouveau_ram_init, 59 + .fini = _nouveau_ram_fini, 60 + } 61 + };
+71
drivers/gpu/drm/nouveau/core/subdev/fb/ramnv1a.c
··· 1 + /* 2 + * Copyright 2013 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 + 25 + #include "priv.h" 26 + 27 + static int 28 + nv1a_ram_create(struct nouveau_object *parent, struct nouveau_object *engine, 29 + struct nouveau_oclass *oclass, void *data, u32 size, 30 + struct nouveau_object **pobject) 31 + { 32 + struct nouveau_fb *pfb = nouveau_fb(parent); 33 + struct nouveau_ram *ram; 34 + struct pci_dev *bridge; 35 + u32 mem, mib; 36 + int ret; 37 + 38 + bridge = pci_get_bus_and_slot(0, PCI_DEVFN(0, 1)); 39 + if (!bridge) { 40 + nv_fatal(pfb, "no bridge device\n"); 41 + return -ENODEV; 42 + } 43 + 44 + ret = nouveau_ram_create(parent, engine, oclass, &ram); 45 + *pobject = nv_object(ram); 46 + if (ret) 47 + return ret; 48 + 49 + if (nv_device(pfb)->chipset == 0x1a) { 50 + pci_read_config_dword(bridge, 0x7c, &mem); 51 + mib = ((mem >> 6) & 31) + 1; 52 + } else { 53 + pci_read_config_dword(bridge, 0x84, &mem); 54 + mib = ((mem >> 4) & 127) + 1; 55 + } 56 + 57 + ram->type = NV_MEM_TYPE_STOLEN; 58 + ram->size = mib * 1024 * 1024; 59 + return 0; 60 + } 61 + 62 + struct nouveau_oclass 63 + nv1a_ram_oclass = { 64 + .handle = 0, 65 + .ofuncs = &(struct nouveau_ofuncs) { 66 + .ctor = nv1a_ram_create, 67 + .dtor = _nouveau_ram_dtor, 68 + .init = _nouveau_ram_init, 69 + .fini = _nouveau_ram_fini, 70 + } 71 + };
+63
drivers/gpu/drm/nouveau/core/subdev/fb/ramnv20.c
··· 1 + /* 2 + * Copyright 2013 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 + 25 + #include "priv.h" 26 + 27 + static int 28 + nv20_ram_create(struct nouveau_object *parent, struct nouveau_object *engine, 29 + struct nouveau_oclass *oclass, void *data, u32 size, 30 + struct nouveau_object **pobject) 31 + { 32 + struct nouveau_fb *pfb = nouveau_fb(parent); 33 + struct nouveau_ram *ram; 34 + u32 pbus1218 = nv_rd32(pfb, 0x001218); 35 + int ret; 36 + 37 + ret = nouveau_ram_create(parent, engine, oclass, &ram); 38 + *pobject = nv_object(ram); 39 + if (ret) 40 + return ret; 41 + 42 + switch (pbus1218 & 0x00000300) { 43 + case 0x00000000: ram->type = NV_MEM_TYPE_SDRAM; break; 44 + case 0x00000100: ram->type = NV_MEM_TYPE_DDR1; break; 45 + case 0x00000200: ram->type = NV_MEM_TYPE_GDDR3; break; 46 + case 0x00000300: ram->type = NV_MEM_TYPE_GDDR2; break; 47 + } 48 + ram->size = (nv_rd32(pfb, 0x10020c) & 0xff000000); 49 + ram->parts = (nv_rd32(pfb, 0x100200) & 0x00000003) + 1; 50 + ram->tags = nv_rd32(pfb, 0x100320); 51 + return 0; 52 + } 53 + 54 + struct nouveau_oclass 55 + nv20_ram_oclass = { 56 + .handle = 0, 57 + .ofuncs = &(struct nouveau_ofuncs) { 58 + .ctor = nv20_ram_create, 59 + .dtor = _nouveau_ram_dtor, 60 + .init = _nouveau_ram_init, 61 + .fini = _nouveau_ram_fini, 62 + } 63 + };
+65
drivers/gpu/drm/nouveau/core/subdev/fb/ramnv40.c
··· 1 + /* 2 + * Copyright 2013 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 + 25 + #include "priv.h" 26 + 27 + static int 28 + nv40_ram_create(struct nouveau_object *parent, struct nouveau_object *engine, 29 + struct nouveau_oclass *oclass, void *data, u32 size, 30 + struct nouveau_object **pobject) 31 + { 32 + struct nouveau_fb *pfb = nouveau_fb(parent); 33 + struct nouveau_ram *ram; 34 + u32 pbus1218 = nv_rd32(pfb, 0x001218); 35 + int ret; 36 + 37 + ret = nouveau_ram_create(parent, engine, oclass, &ram); 38 + *pobject = nv_object(ram); 39 + if (ret) 40 + return ret; 41 + 42 + switch (pbus1218 & 0x00000300) { 43 + case 0x00000000: ram->type = NV_MEM_TYPE_SDRAM; break; 44 + case 0x00000100: ram->type = NV_MEM_TYPE_DDR1; break; 45 + case 0x00000200: ram->type = NV_MEM_TYPE_GDDR3; break; 46 + case 0x00000300: ram->type = NV_MEM_TYPE_DDR2; break; 47 + } 48 + 49 + ram->size = nv_rd32(pfb, 0x10020c) & 0xff000000; 50 + ram->parts = (nv_rd32(pfb, 0x100200) & 0x00000003) + 1; 51 + ram->tags = nv_rd32(pfb, 0x100320); 52 + return 0; 53 + } 54 + 55 + 56 + struct nouveau_oclass 57 + nv40_ram_oclass = { 58 + .handle = 0, 59 + .ofuncs = &(struct nouveau_ofuncs) { 60 + .ctor = nv40_ram_create, 61 + .dtor = _nouveau_ram_dtor, 62 + .init = _nouveau_ram_init, 63 + .fini = _nouveau_ram_fini, 64 + } 65 + };
+64
drivers/gpu/drm/nouveau/core/subdev/fb/ramnv41.c
··· 1 + /* 2 + * Copyright 2013 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 + 25 + #include "priv.h" 26 + 27 + static int 28 + nv41_ram_create(struct nouveau_object *parent, struct nouveau_object *engine, 29 + struct nouveau_oclass *oclass, void *data, u32 size, 30 + struct nouveau_object **pobject) 31 + { 32 + struct nouveau_fb *pfb = nouveau_fb(parent); 33 + struct nouveau_ram *ram; 34 + u32 pfb474 = nv_rd32(pfb, 0x100474); 35 + int ret; 36 + 37 + ret = nouveau_ram_create(parent, engine, oclass, &ram); 38 + *pobject = nv_object(ram); 39 + if (ret) 40 + return ret; 41 + 42 + if (pfb474 & 0x00000004) 43 + ram->type = NV_MEM_TYPE_GDDR3; 44 + if (pfb474 & 0x00000002) 45 + ram->type = NV_MEM_TYPE_DDR2; 46 + if (pfb474 & 0x00000001) 47 + ram->type = NV_MEM_TYPE_DDR1; 48 + 49 + ram->size = nv_rd32(pfb, 0x10020c) & 0xff000000; 50 + ram->parts = (nv_rd32(pfb, 0x100200) & 0x00000003) + 1; 51 + ram->tags = nv_rd32(pfb, 0x100320); 52 + return 0; 53 + } 54 + 55 + struct nouveau_oclass 56 + nv41_ram_oclass = { 57 + .handle = 0, 58 + .ofuncs = &(struct nouveau_ofuncs) { 59 + .ctor = nv41_ram_create, 60 + .dtor = _nouveau_ram_dtor, 61 + .init = _nouveau_ram_init, 62 + .fini = _nouveau_ram_fini, 63 + } 64 + };
+62
drivers/gpu/drm/nouveau/core/subdev/fb/ramnv44.c
··· 1 + /* 2 + * Copyright 2013 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 + 25 + #include "priv.h" 26 + 27 + static int 28 + nv44_ram_create(struct nouveau_object *parent, struct nouveau_object *engine, 29 + struct nouveau_oclass *oclass, void *data, u32 size, 30 + struct nouveau_object **pobject) 31 + { 32 + struct nouveau_fb *pfb = nouveau_fb(parent); 33 + struct nouveau_ram *ram; 34 + u32 pfb474 = nv_rd32(pfb, 0x100474); 35 + int ret; 36 + 37 + ret = nouveau_ram_create(parent, engine, oclass, &ram); 38 + *pobject = nv_object(ram); 39 + if (ret) 40 + return ret; 41 + 42 + if (pfb474 & 0x00000004) 43 + ram->type = NV_MEM_TYPE_GDDR3; 44 + if (pfb474 & 0x00000002) 45 + ram->type = NV_MEM_TYPE_DDR2; 46 + if (pfb474 & 0x00000001) 47 + ram->type = NV_MEM_TYPE_DDR1; 48 + 49 + ram->size = nv_rd32(pfb, 0x10020c) & 0xff000000; 50 + return 0; 51 + } 52 + 53 + struct nouveau_oclass 54 + nv44_ram_oclass = { 55 + .handle = 0, 56 + .ofuncs = &(struct nouveau_ofuncs) { 57 + .ctor = nv44_ram_create, 58 + .dtor = _nouveau_ram_dtor, 59 + .init = _nouveau_ram_init, 60 + .fini = _nouveau_ram_fini, 61 + } 62 + };
+64
drivers/gpu/drm/nouveau/core/subdev/fb/ramnv49.c
··· 1 + /* 2 + * Copyright 2013 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 + 25 + #include "priv.h" 26 + 27 + static int 28 + nv49_ram_create(struct nouveau_object *parent, struct nouveau_object *engine, 29 + struct nouveau_oclass *oclass, void *data, u32 size, 30 + struct nouveau_object **pobject) 31 + { 32 + struct nouveau_fb *pfb = nouveau_fb(parent); 33 + struct nouveau_ram *ram; 34 + u32 pfb914 = nv_rd32(pfb, 0x100914); 35 + int ret; 36 + 37 + ret = nouveau_ram_create(parent, engine, oclass, &ram); 38 + *pobject = nv_object(ram); 39 + if (ret) 40 + return ret; 41 + 42 + switch (pfb914 & 0x00000003) { 43 + case 0x00000000: pfb->ram->type = NV_MEM_TYPE_DDR1; break; 44 + case 0x00000001: pfb->ram->type = NV_MEM_TYPE_DDR2; break; 45 + case 0x00000002: pfb->ram->type = NV_MEM_TYPE_GDDR3; break; 46 + case 0x00000003: break; 47 + } 48 + 49 + pfb->ram->size = nv_rd32(pfb, 0x10020c) & 0xff000000; 50 + pfb->ram->parts = (nv_rd32(pfb, 0x100200) & 0x00000003) + 1; 51 + pfb->ram->tags = nv_rd32(pfb, 0x100320); 52 + return 0; 53 + } 54 + 55 + struct nouveau_oclass 56 + nv49_ram_oclass = { 57 + .handle = 0, 58 + .ofuncs = &(struct nouveau_ofuncs) { 59 + .ctor = nv49_ram_create, 60 + .dtor = _nouveau_ram_dtor, 61 + .init = _nouveau_ram_init, 62 + .fini = _nouveau_ram_fini, 63 + } 64 + };
+55
drivers/gpu/drm/nouveau/core/subdev/fb/ramnv4e.c
··· 1 + /* 2 + * Copyright 2013 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 + 25 + #include "priv.h" 26 + 27 + static int 28 + nv4e_ram_create(struct nouveau_object *parent, struct nouveau_object *engine, 29 + struct nouveau_oclass *oclass, void *data, u32 size, 30 + struct nouveau_object **pobject) 31 + { 32 + struct nouveau_fb *pfb = nouveau_fb(parent); 33 + struct nouveau_ram *ram; 34 + int ret; 35 + 36 + ret = nouveau_ram_create(parent, engine, oclass, &ram); 37 + *pobject = nv_object(ram); 38 + if (ret) 39 + return ret; 40 + 41 + pfb->ram->size = nv_rd32(pfb, 0x10020c) & 0xff000000; 42 + pfb->ram->type = NV_MEM_TYPE_STOLEN; 43 + return 0; 44 + } 45 + 46 + struct nouveau_oclass 47 + nv4e_ram_oclass = { 48 + .handle = 0, 49 + .ofuncs = &(struct nouveau_ofuncs) { 50 + .ctor = nv4e_ram_create, 51 + .dtor = _nouveau_ram_dtor, 52 + .init = _nouveau_ram_init, 53 + .fini = _nouveau_ram_fini, 54 + } 55 + };
+232
drivers/gpu/drm/nouveau/core/subdev/fb/ramnv50.c
··· 1 + /* 2 + * Copyright 2013 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 + 25 + #include <subdev/bios.h> 26 + #include <core/mm.h> 27 + #include "priv.h" 28 + 29 + void 30 + nv50_ram_put(struct nouveau_fb *pfb, struct nouveau_mem **pmem) 31 + { 32 + struct nouveau_mm_node *this; 33 + struct nouveau_mem *mem; 34 + 35 + mem = *pmem; 36 + *pmem = NULL; 37 + if (unlikely(mem == NULL)) 38 + return; 39 + 40 + mutex_lock(&pfb->base.mutex); 41 + while (!list_empty(&mem->regions)) { 42 + this = list_first_entry(&mem->regions, typeof(*this), rl_entry); 43 + 44 + list_del(&this->rl_entry); 45 + nouveau_mm_free(&pfb->vram, &this); 46 + } 47 + 48 + nouveau_mm_free(&pfb->tags, &mem->tag); 49 + mutex_unlock(&pfb->base.mutex); 50 + 51 + kfree(mem); 52 + } 53 + 54 + static int 55 + nv50_ram_get(struct nouveau_fb *pfb, u64 size, u32 align, u32 ncmin, 56 + u32 memtype, struct nouveau_mem **pmem) 57 + { 58 + struct nouveau_mm *heap = &pfb->vram; 59 + struct nouveau_mm *tags = &pfb->tags; 60 + struct nouveau_mm_node *r; 61 + struct nouveau_mem *mem; 62 + int comp = (memtype & 0x300) >> 8; 63 + int type = (memtype & 0x07f); 64 + int back = (memtype & 0x800); 65 + int min, max, ret; 66 + 67 + max = (size >> 12); 68 + min = ncmin ? (ncmin >> 12) : max; 69 + align >>= 12; 70 + 71 + mem = kzalloc(sizeof(*mem), GFP_KERNEL); 72 + if (!mem) 73 + return -ENOMEM; 74 + 75 + mutex_lock(&pfb->base.mutex); 76 + if (comp) { 77 + if (align == 16) { 78 + int n = (max >> 4) * comp; 79 + 80 + ret = nouveau_mm_head(tags, 1, n, n, 1, &mem->tag); 81 + if (ret) 82 + mem->tag = NULL; 83 + } 84 + 85 + if (unlikely(!mem->tag)) 86 + comp = 0; 87 + } 88 + 89 + INIT_LIST_HEAD(&mem->regions); 90 + mem->memtype = (comp << 7) | type; 91 + mem->size = max; 92 + 93 + type = nv50_fb_memtype[type]; 94 + do { 95 + if (back) 96 + ret = nouveau_mm_tail(heap, type, max, min, align, &r); 97 + else 98 + ret = nouveau_mm_head(heap, type, max, min, align, &r); 99 + if (ret) { 100 + mutex_unlock(&pfb->base.mutex); 101 + pfb->ram->put(pfb, &mem); 102 + return ret; 103 + } 104 + 105 + list_add_tail(&r->rl_entry, &mem->regions); 106 + max -= r->length; 107 + } while (max); 108 + mutex_unlock(&pfb->base.mutex); 109 + 110 + r = list_first_entry(&mem->regions, struct nouveau_mm_node, rl_entry); 111 + mem->offset = (u64)r->offset << 12; 112 + *pmem = mem; 113 + return 0; 114 + } 115 + 116 + static u32 117 + nv50_fb_vram_rblock(struct nouveau_fb *pfb, struct nouveau_ram *ram) 118 + { 119 + int i, parts, colbits, rowbitsa, rowbitsb, banks; 120 + u64 rowsize, predicted; 121 + u32 r0, r4, rt, ru, rblock_size; 122 + 123 + r0 = nv_rd32(pfb, 0x100200); 124 + r4 = nv_rd32(pfb, 0x100204); 125 + rt = nv_rd32(pfb, 0x100250); 126 + ru = nv_rd32(pfb, 0x001540); 127 + nv_debug(pfb, "memcfg 0x%08x 0x%08x 0x%08x 0x%08x\n", r0, r4, rt, ru); 128 + 129 + for (i = 0, parts = 0; i < 8; i++) { 130 + if (ru & (0x00010000 << i)) 131 + parts++; 132 + } 133 + 134 + colbits = (r4 & 0x0000f000) >> 12; 135 + rowbitsa = ((r4 & 0x000f0000) >> 16) + 8; 136 + rowbitsb = ((r4 & 0x00f00000) >> 20) + 8; 137 + banks = 1 << (((r4 & 0x03000000) >> 24) + 2); 138 + 139 + rowsize = parts * banks * (1 << colbits) * 8; 140 + predicted = rowsize << rowbitsa; 141 + if (r0 & 0x00000004) 142 + predicted += rowsize << rowbitsb; 143 + 144 + if (predicted != ram->size) { 145 + nv_warn(pfb, "memory controller reports %d MiB VRAM\n", 146 + (u32)(ram->size >> 20)); 147 + } 148 + 149 + rblock_size = rowsize; 150 + if (rt & 1) 151 + rblock_size *= 3; 152 + 153 + nv_debug(pfb, "rblock %d bytes\n", rblock_size); 154 + return rblock_size; 155 + } 156 + 157 + static int 158 + nv50_ram_create(struct nouveau_object *parent, struct nouveau_object *engine, 159 + struct nouveau_oclass *oclass, void *data, u32 datasize, 160 + struct nouveau_object **pobject) 161 + { 162 + struct nouveau_fb *pfb = nouveau_fb(parent); 163 + struct nouveau_device *device = nv_device(pfb); 164 + struct nouveau_bios *bios = nouveau_bios(device); 165 + struct nouveau_ram *ram; 166 + const u32 rsvd_head = ( 256 * 1024) >> 12; /* vga memory */ 167 + const u32 rsvd_tail = (1024 * 1024) >> 12; /* vbios etc */ 168 + u32 size; 169 + int ret; 170 + 171 + ret = nouveau_ram_create(parent, engine, oclass, &ram); 172 + *pobject = nv_object(ram); 173 + if (ret) 174 + return ret; 175 + 176 + ram->size = nv_rd32(pfb, 0x10020c); 177 + ram->size = (ram->size & 0xffffff00) | 178 + ((ram->size & 0x000000ff) << 32); 179 + 180 + size = (ram->size >> 12) - rsvd_head - rsvd_tail; 181 + switch (device->chipset) { 182 + case 0xaa: 183 + case 0xac: 184 + case 0xaf: /* IGPs, no reordering, no real VRAM */ 185 + ret = nouveau_mm_init(&pfb->vram, rsvd_head, size, 1); 186 + if (ret) 187 + return ret; 188 + 189 + ram->type = NV_MEM_TYPE_STOLEN; 190 + ram->stolen = (u64)nv_rd32(pfb, 0x100e10) << 12; 191 + break; 192 + default: 193 + switch (nv_rd32(pfb, 0x100714) & 0x00000007) { 194 + case 0: ram->type = NV_MEM_TYPE_DDR1; break; 195 + case 1: 196 + if (nouveau_fb_bios_memtype(bios) == NV_MEM_TYPE_DDR3) 197 + ram->type = NV_MEM_TYPE_DDR3; 198 + else 199 + ram->type = NV_MEM_TYPE_DDR2; 200 + break; 201 + case 2: ram->type = NV_MEM_TYPE_GDDR3; break; 202 + case 3: ram->type = NV_MEM_TYPE_GDDR4; break; 203 + case 4: ram->type = NV_MEM_TYPE_GDDR5; break; 204 + default: 205 + break; 206 + } 207 + 208 + ret = nouveau_mm_init(&pfb->vram, rsvd_head, size, 209 + nv50_fb_vram_rblock(pfb, ram) >> 12); 210 + if (ret) 211 + return ret; 212 + 213 + ram->ranks = (nv_rd32(pfb, 0x100200) & 0x4) ? 2 : 1; 214 + ram->tags = nv_rd32(pfb, 0x100320); 215 + break; 216 + } 217 + 218 + ram->get = nv50_ram_get; 219 + ram->put = nv50_ram_put; 220 + return 0; 221 + } 222 + 223 + struct nouveau_oclass 224 + nv50_ram_oclass = { 225 + .handle = 0, 226 + .ofuncs = &(struct nouveau_ofuncs) { 227 + .ctor = nv50_ram_create, 228 + .dtor = _nouveau_ram_dtor, 229 + .init = _nouveau_ram_init, 230 + .fini = _nouveau_ram_fini, 231 + } 232 + };
+186
drivers/gpu/drm/nouveau/core/subdev/fb/ramnvc0.c
··· 1 + /* 2 + * Copyright 2013 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 + 25 + #include <subdev/bios.h> 26 + #include <subdev/ltcg.h> 27 + 28 + #include "priv.h" 29 + 30 + extern const u8 nvc0_pte_storage_type_map[256]; 31 + 32 + void 33 + nvc0_ram_put(struct nouveau_fb *pfb, struct nouveau_mem **pmem) 34 + { 35 + struct nouveau_ltcg *ltcg = nouveau_ltcg(pfb); 36 + 37 + if ((*pmem)->tag) 38 + ltcg->tags_free(ltcg, &(*pmem)->tag); 39 + 40 + nv50_ram_put(pfb, pmem); 41 + } 42 + 43 + int 44 + nvc0_ram_get(struct nouveau_fb *pfb, u64 size, u32 align, u32 ncmin, 45 + u32 memtype, struct nouveau_mem **pmem) 46 + { 47 + struct nouveau_mm *mm = &pfb->vram; 48 + struct nouveau_mm_node *r; 49 + struct nouveau_mem *mem; 50 + int type = (memtype & 0x0ff); 51 + int back = (memtype & 0x800); 52 + const bool comp = nvc0_pte_storage_type_map[type] != type; 53 + int ret; 54 + 55 + size >>= 12; 56 + align >>= 12; 57 + ncmin >>= 12; 58 + if (!ncmin) 59 + ncmin = size; 60 + 61 + mem = kzalloc(sizeof(*mem), GFP_KERNEL); 62 + if (!mem) 63 + return -ENOMEM; 64 + 65 + INIT_LIST_HEAD(&mem->regions); 66 + mem->size = size; 67 + 68 + mutex_lock(&pfb->base.mutex); 69 + if (comp) { 70 + struct nouveau_ltcg *ltcg = nouveau_ltcg(pfb); 71 + 72 + /* compression only works with lpages */ 73 + if (align == (1 << (17 - 12))) { 74 + int n = size >> 5; 75 + ltcg->tags_alloc(ltcg, n, &mem->tag); 76 + } 77 + 78 + if (unlikely(!mem->tag)) 79 + type = nvc0_pte_storage_type_map[type]; 80 + } 81 + mem->memtype = type; 82 + 83 + do { 84 + if (back) 85 + ret = nouveau_mm_tail(mm, 1, size, ncmin, align, &r); 86 + else 87 + ret = nouveau_mm_head(mm, 1, size, ncmin, align, &r); 88 + if (ret) { 89 + mutex_unlock(&pfb->base.mutex); 90 + pfb->ram->put(pfb, &mem); 91 + return ret; 92 + } 93 + 94 + list_add_tail(&r->rl_entry, &mem->regions); 95 + size -= r->length; 96 + } while (size); 97 + mutex_unlock(&pfb->base.mutex); 98 + 99 + r = list_first_entry(&mem->regions, struct nouveau_mm_node, rl_entry); 100 + mem->offset = (u64)r->offset << 12; 101 + *pmem = mem; 102 + return 0; 103 + } 104 + 105 + static int 106 + nvc0_ram_create(struct nouveau_object *parent, struct nouveau_object *engine, 107 + struct nouveau_oclass *oclass, void *data, u32 size, 108 + struct nouveau_object **pobject) 109 + { 110 + struct nouveau_fb *pfb = nouveau_fb(parent); 111 + struct nouveau_bios *bios = nouveau_bios(pfb); 112 + struct nouveau_ram *ram; 113 + const u32 rsvd_head = ( 256 * 1024) >> 12; /* vga memory */ 114 + const u32 rsvd_tail = (1024 * 1024) >> 12; /* vbios etc */ 115 + u32 parts = nv_rd32(pfb, 0x022438); 116 + u32 pmask = nv_rd32(pfb, 0x022554); 117 + u32 bsize = nv_rd32(pfb, 0x10f20c); 118 + u32 offset, length; 119 + bool uniform = true; 120 + int ret, part; 121 + 122 + ret = nouveau_ram_create(parent, engine, oclass, &ram); 123 + *pobject = nv_object(ram); 124 + if (ret) 125 + return ret; 126 + 127 + nv_debug(pfb, "0x100800: 0x%08x\n", nv_rd32(pfb, 0x100800)); 128 + nv_debug(pfb, "parts 0x%08x mask 0x%08x\n", parts, pmask); 129 + 130 + ram->type = nouveau_fb_bios_memtype(bios); 131 + ram->ranks = (nv_rd32(pfb, 0x10f200) & 0x00000004) ? 2 : 1; 132 + 133 + /* read amount of vram attached to each memory controller */ 134 + for (part = 0; part < parts; part++) { 135 + if (!(pmask & (1 << part))) { 136 + u32 psize = nv_rd32(pfb, 0x11020c + (part * 0x1000)); 137 + if (psize != bsize) { 138 + if (psize < bsize) 139 + bsize = psize; 140 + uniform = false; 141 + } 142 + 143 + nv_debug(pfb, "%d: mem_amount 0x%08x\n", part, psize); 144 + ram->size += (u64)psize << 20; 145 + } 146 + } 147 + 148 + /* if all controllers have the same amount attached, there's no holes */ 149 + if (uniform) { 150 + offset = rsvd_head; 151 + length = (ram->size >> 12) - rsvd_head - rsvd_tail; 152 + ret = nouveau_mm_init(&pfb->vram, offset, length, 1); 153 + } else { 154 + /* otherwise, address lowest common amount from 0GiB */ 155 + ret = nouveau_mm_init(&pfb->vram, rsvd_head, 156 + (bsize << 8) * parts, 1); 157 + if (ret) 158 + return ret; 159 + 160 + /* and the rest starting from (8GiB + common_size) */ 161 + offset = (0x0200000000ULL >> 12) + (bsize << 8); 162 + length = (ram->size >> 12) - (bsize << 8) - rsvd_tail; 163 + 164 + ret = nouveau_mm_init(&pfb->vram, offset, length, 0); 165 + if (ret) 166 + nouveau_mm_fini(&pfb->vram); 167 + } 168 + 169 + if (ret) 170 + return ret; 171 + 172 + ram->get = nvc0_ram_get; 173 + ram->put = nvc0_ram_put; 174 + return 0; 175 + } 176 + 177 + struct nouveau_oclass 178 + nvc0_ram_oclass = { 179 + .handle = 0, 180 + .ofuncs = &(struct nouveau_ofuncs) { 181 + .ctor = nvc0_ram_create, 182 + .dtor = _nouveau_ram_dtor, 183 + .init = _nouveau_ram_init, 184 + .fini = _nouveau_ram_fini, 185 + } 186 + };
+2 -2
drivers/gpu/drm/nouveau/core/subdev/instmem/nv50.c
··· 56 56 if (ret) 57 57 return ret; 58 58 59 - ret = pfb->ram.get(pfb, size, align, 0, 0x800, &node->mem); 59 + ret = pfb->ram->get(pfb, size, align, 0, 0x800, &node->mem); 60 60 if (ret) 61 61 return ret; 62 62 ··· 71 71 { 72 72 struct nv50_instobj_priv *node = (void *)object; 73 73 struct nouveau_fb *pfb = nouveau_fb(object); 74 - pfb->ram.put(pfb, &node->mem); 74 + pfb->ram->put(pfb, &node->mem); 75 75 nouveau_instobj_destroy(&node->base); 76 76 } 77 77
+1 -1
drivers/gpu/drm/nouveau/core/subdev/ltcg/nvc0.c
··· 122 122 nv_wr32(priv, 0x17e000, priv->part_nr); 123 123 124 124 /* tags for 1/4 of VRAM should be enough (8192/4 per GiB of VRAM) */ 125 - priv->num_tags = (pfb->ram.size >> 17) / 4; 125 + priv->num_tags = (pfb->ram->size >> 17) / 4; 126 126 if (priv->num_tags > (1 << 17)) 127 127 priv->num_tags = 1 << 17; /* we have 17 bits in PTE */ 128 128 priv->num_tags = (priv->num_tags + 63) & ~63; /* round up to 64 */
+2 -2
drivers/gpu/drm/nouveau/core/subdev/vm/nv50.c
··· 86 86 87 87 /* IGPs don't have real VRAM, re-target to stolen system memory */ 88 88 target = 0; 89 - if (nouveau_fb(vma->vm->vmm)->ram.stolen) { 90 - phys += nouveau_fb(vma->vm->vmm)->ram.stolen; 89 + if (nouveau_fb(vma->vm->vmm)->ram->stolen) { 90 + phys += nouveau_fb(vma->vm->vmm)->ram->stolen; 91 91 target = 3; 92 92 } 93 93
+1 -1
drivers/gpu/drm/nouveau/nouveau_bo.c
··· 255 255 { 256 256 struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev); 257 257 struct nouveau_fb *pfb = nouveau_fb(drm->device); 258 - u32 vram_pages = pfb->ram.size >> PAGE_SHIFT; 258 + u32 vram_pages = pfb->ram->size >> PAGE_SHIFT; 259 259 260 260 if (nv_device(drm->device)->card_type == NV_10 && 261 261 nvbo->tile_mode && (type & TTM_PL_FLAG_VRAM) &&
+2 -2
drivers/gpu/drm/nouveau/nouveau_chan.c
··· 147 147 args.limit = client->vm->vmm->limit - 1; 148 148 } else 149 149 if (chan->push.buffer->bo.mem.mem_type == TTM_PL_VRAM) { 150 - u64 limit = pfb->ram.size - imem->reserved - 1; 150 + u64 limit = pfb->ram->size - imem->reserved - 1; 151 151 if (device->card_type == NV_04) { 152 152 /* nv04 vram pushbuf hack, retarget to its location in 153 153 * the framebuffer bar rather than direct vram access.. ··· 282 282 } else { 283 283 args.flags = NV_DMA_TARGET_VRAM | NV_DMA_ACCESS_RDWR; 284 284 args.start = 0; 285 - args.limit = pfb->ram.size - imem->reserved - 1; 285 + args.limit = pfb->ram->size - imem->reserved - 1; 286 286 } 287 287 288 288 ret = nouveau_object_new(nv_object(client), chan->handle, vram,
+2 -2
drivers/gpu/drm/nouveau/nouveau_fbcon.c
··· 467 467 468 468 drm_fb_helper_single_add_all_connectors(&fbcon->helper); 469 469 470 - if (pfb->ram.size <= 32 * 1024 * 1024) 470 + if (pfb->ram->size <= 32 * 1024 * 1024) 471 471 preferred_bpp = 8; 472 472 else 473 - if (pfb->ram.size <= 64 * 1024 * 1024) 473 + if (pfb->ram->size <= 64 * 1024 * 1024) 474 474 preferred_bpp = 16; 475 475 else 476 476 preferred_bpp = 32;
+7 -7
drivers/gpu/drm/nouveau/nouveau_mem.c
··· 125 125 t->reg[7] = 0x4000202 | (e->tCL - 1) << 16; 126 126 127 127 /* XXX: P.version == 1 only has DDR2 and GDDR3? */ 128 - if (pfb->ram.type == NV_MEM_TYPE_DDR2) { 128 + if (pfb->ram->type == NV_MEM_TYPE_DDR2) { 129 129 t->reg[5] |= (e->tCL + 3) << 8; 130 130 t->reg[6] |= (t->tCWL - 2) << 8; 131 131 t->reg[8] |= (e->tCL - 4); ··· 428 428 break; 429 429 } 430 430 431 - switch (pfb->ram.type * !ret) { 431 + switch (pfb->ram->type * !ret) { 432 432 case NV_MEM_TYPE_GDDR3: 433 433 ret = nouveau_mem_gddr3_mr(dev, freq, e, len, boot, t); 434 434 break; ··· 455 455 else 456 456 dll_off = !!(ramcfg[2] & 0x40); 457 457 458 - switch (pfb->ram.type) { 458 + switch (pfb->ram->type) { 459 459 case NV_MEM_TYPE_GDDR3: 460 460 t->mr[1] &= ~0x00000040; 461 461 t->mr[1] |= 0x00000040 * dll_off; ··· 522 522 t->odt = 0; 523 523 t->drive_strength = 0; 524 524 525 - switch (pfb->ram.type) { 525 + switch (pfb->ram->type) { 526 526 case NV_MEM_TYPE_DDR3: 527 527 t->odt |= (t->mr[1] & 0x200) >> 7; 528 528 case NV_MEM_TYPE_DDR2: ··· 551 551 u32 mr[3] = { info->mr[0], info->mr[1], info->mr[2] }; 552 552 u32 mr1_dlloff; 553 553 554 - switch (pfb->ram.type) { 554 + switch (pfb->ram->type) { 555 555 case NV_MEM_TYPE_DDR2: 556 556 tDLLK = 2000; 557 557 mr1_dlloff = 0x00000001; ··· 572 572 } 573 573 574 574 /* fetch current MRs */ 575 - switch (pfb->ram.type) { 575 + switch (pfb->ram->type) { 576 576 case NV_MEM_TYPE_GDDR3: 577 577 case NV_MEM_TYPE_DDR3: 578 578 mr[2] = exec->mrg(exec, 2); ··· 639 639 exec->mrs (exec, 0, info->mr[0] | 0x00000000); 640 640 exec->wait(exec, tMRD); 641 641 exec->wait(exec, tDLLK); 642 - if (pfb->ram.type == NV_MEM_TYPE_GDDR3) 642 + if (pfb->ram->type == NV_MEM_TYPE_GDDR3) 643 643 exec->precharge(exec); 644 644 } 645 645
+3 -3
drivers/gpu/drm/nouveau/nouveau_ttm.c
··· 69 69 struct nouveau_drm *drm = nouveau_bdev(man->bdev); 70 70 struct nouveau_fb *pfb = nouveau_fb(drm->device); 71 71 nouveau_mem_node_cleanup(mem->mm_node); 72 - pfb->ram.put(pfb, (struct nouveau_mem **)&mem->mm_node); 72 + pfb->ram->put(pfb, (struct nouveau_mem **)&mem->mm_node); 73 73 } 74 74 75 75 static int ··· 88 88 if (nvbo->tile_flags & NOUVEAU_GEM_TILE_NONCONTIG) 89 89 size_nc = 1 << nvbo->page_shift; 90 90 91 - ret = pfb->ram.get(pfb, mem->num_pages << PAGE_SHIFT, 91 + ret = pfb->ram->get(pfb, mem->num_pages << PAGE_SHIFT, 92 92 mem->page_alignment << PAGE_SHIFT, size_nc, 93 93 (nvbo->tile_flags >> 8) & 0x3ff, &node); 94 94 if (ret) { ··· 386 386 } 387 387 388 388 /* VRAM init */ 389 - drm->gem.vram_available = nouveau_fb(drm->device)->ram.size; 389 + drm->gem.vram_available = nouveau_fb(drm->device)->ram->size; 390 390 drm->gem.vram_available -= nouveau_instmem(drm->device)->reserved; 391 391 392 392 ret = ttm_bo_init_mm(&drm->ttm.bdev, TTM_PL_VRAM,
+9 -9
drivers/gpu/drm/nouveau/nv50_display.c
··· 159 159 .flags = NV_DMA_TARGET_VRAM | 160 160 NV_DMA_ACCESS_RDWR, 161 161 .start = 0, 162 - .limit = pfb->ram.size - 1, 162 + .limit = pfb->ram->size - 1, 163 163 .conf0 = NV50_DMA_CONF0_ENABLE | 164 164 NV50_DMA_CONF0_PART_256, 165 165 }, sizeof(struct nv_dma_class), &object); ··· 172 172 .flags = NV_DMA_TARGET_VRAM | 173 173 NV_DMA_ACCESS_RDWR, 174 174 .start = 0, 175 - .limit = pfb->ram.size - 1, 175 + .limit = pfb->ram->size - 1, 176 176 .conf0 = NV50_DMA_CONF0_ENABLE | 0x70 | 177 177 NV50_DMA_CONF0_PART_256, 178 178 }, sizeof(struct nv_dma_class), &object); ··· 185 185 .flags = NV_DMA_TARGET_VRAM | 186 186 NV_DMA_ACCESS_RDWR, 187 187 .start = 0, 188 - .limit = pfb->ram.size - 1, 188 + .limit = pfb->ram->size - 1, 189 189 .conf0 = NV50_DMA_CONF0_ENABLE | 0x7a | 190 190 NV50_DMA_CONF0_PART_256, 191 191 }, sizeof(struct nv_dma_class), &object); ··· 204 204 .flags = NV_DMA_TARGET_VRAM | 205 205 NV_DMA_ACCESS_RDWR, 206 206 .start = 0, 207 - .limit = pfb->ram.size - 1, 207 + .limit = pfb->ram->size - 1, 208 208 .conf0 = NVC0_DMA_CONF0_ENABLE, 209 209 }, sizeof(struct nv_dma_class), &object); 210 210 if (ret) ··· 216 216 .flags = NV_DMA_TARGET_VRAM | 217 217 NV_DMA_ACCESS_RDWR, 218 218 .start = 0, 219 - .limit = pfb->ram.size - 1, 219 + .limit = pfb->ram->size - 1, 220 220 .conf0 = NVC0_DMA_CONF0_ENABLE | 0xfe, 221 221 }, sizeof(struct nv_dma_class), &object); 222 222 if (ret) ··· 228 228 .flags = NV_DMA_TARGET_VRAM | 229 229 NV_DMA_ACCESS_RDWR, 230 230 .start = 0, 231 - .limit = pfb->ram.size - 1, 231 + .limit = pfb->ram->size - 1, 232 232 .conf0 = NVC0_DMA_CONF0_ENABLE | 0xfe, 233 233 }, sizeof(struct nv_dma_class), &object); 234 234 return ret; ··· 246 246 .flags = NV_DMA_TARGET_VRAM | 247 247 NV_DMA_ACCESS_RDWR, 248 248 .start = 0, 249 - .limit = pfb->ram.size - 1, 249 + .limit = pfb->ram->size - 1, 250 250 .conf0 = NVD0_DMA_CONF0_ENABLE | 251 251 NVD0_DMA_CONF0_PAGE_LP, 252 252 }, sizeof(struct nv_dma_class), &object); ··· 259 259 .flags = NV_DMA_TARGET_VRAM | 260 260 NV_DMA_ACCESS_RDWR, 261 261 .start = 0, 262 - .limit = pfb->ram.size - 1, 262 + .limit = pfb->ram->size - 1, 263 263 .conf0 = NVD0_DMA_CONF0_ENABLE | 0xfe | 264 264 NVD0_DMA_CONF0_PAGE_LP, 265 265 }, sizeof(struct nv_dma_class), &object); ··· 316 316 .flags = NV_DMA_TARGET_VRAM | 317 317 NV_DMA_ACCESS_RDWR, 318 318 .start = 0, 319 - .limit = pfb->ram.size - 1, 319 + .limit = pfb->ram->size - 1, 320 320 }, sizeof(struct nv_dma_class), &object); 321 321 if (ret) 322 322 return ret;
+2 -2
drivers/gpu/drm/nouveau/nv50_pm.c
··· 493 493 struct hwsq_ucode *hwsq = &info->mclk_hwsq; 494 494 495 495 if (mr <= 1) { 496 - if (pfb->ram.ranks > 1) 496 + if (pfb->ram->ranks > 1) 497 497 hwsq_wr32(hwsq, 0x1002c8 + ((mr - 0) * 4), data); 498 498 hwsq_wr32(hwsq, 0x1002c0 + ((mr - 0) * 4), data); 499 499 } else 500 500 if (mr <= 3) { 501 - if (pfb->ram.ranks > 1) 501 + if (pfb->ram->ranks > 1) 502 502 hwsq_wr32(hwsq, 0x1002e8 + ((mr - 2) * 4), data); 503 503 hwsq_wr32(hwsq, 0x1002e0 + ((mr - 2) * 4), data); 504 504 }
+2 -2
drivers/gpu/drm/nouveau/nva3_pm.c
··· 389 389 struct nouveau_device *device = nouveau_dev(exec->dev); 390 390 struct nouveau_fb *pfb = nouveau_fb(device); 391 391 if (mr <= 1) { 392 - if (pfb->ram.ranks > 1) 392 + if (pfb->ram->ranks > 1) 393 393 nv_wr32(device, 0x1002c8 + ((mr - 0) * 4), data); 394 394 nv_wr32(device, 0x1002c0 + ((mr - 0) * 4), data); 395 395 } else 396 396 if (mr <= 3) { 397 - if (pfb->ram.ranks > 1) 397 + if (pfb->ram->ranks > 1) 398 398 nv_wr32(device, 0x1002e8 + ((mr - 2) * 4), data); 399 399 nv_wr32(device, 0x1002e0 + ((mr - 2) * 4), data); 400 400 }
+4 -4
drivers/gpu/drm/nouveau/nvc0_pm.c
··· 477 477 { 478 478 struct nouveau_device *device = nouveau_dev(exec->dev); 479 479 struct nouveau_fb *pfb = nouveau_fb(device); 480 - if (pfb->ram.type != NV_MEM_TYPE_GDDR5) { 480 + if (pfb->ram->type != NV_MEM_TYPE_GDDR5) { 481 481 if (mr <= 1) 482 482 return nv_rd32(device, 0x10f300 + ((mr - 0) * 4)); 483 483 return nv_rd32(device, 0x10f320 + ((mr - 2) * 4)); ··· 496 496 { 497 497 struct nouveau_device *device = nouveau_dev(exec->dev); 498 498 struct nouveau_fb *pfb = nouveau_fb(device); 499 - if (pfb->ram.type != NV_MEM_TYPE_GDDR5) { 499 + if (pfb->ram->type != NV_MEM_TYPE_GDDR5) { 500 500 if (mr <= 1) { 501 501 nv_wr32(device, 0x10f300 + ((mr - 0) * 4), data); 502 - if (pfb->ram.ranks > 1) 502 + if (pfb->ram->ranks > 1) 503 503 nv_wr32(device, 0x10f308 + ((mr - 0) * 4), data); 504 504 } else 505 505 if (mr <= 3) { 506 506 nv_wr32(device, 0x10f320 + ((mr - 2) * 4), data); 507 - if (pfb->ram.ranks > 1) 507 + if (pfb->ram->ranks > 1) 508 508 nv_wr32(device, 0x10f328 + ((mr - 2) * 4), data); 509 509 } 510 510 } else {