aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2014-08-09 14:10:28 -0400
committerBen Skeggs <bskeggs@redhat.com>2014-08-09 15:28:12 -0400
commitf392ec4b1d92004949e5a4f4418b1fbb2582ef0d (patch)
tree874ee094191f6c8e4d59e11fa744c0d4f2a61e55 /drivers/gpu
parent80bc340b3dd720c5b7818e21a9a1ee36e1d7ef30 (diff)
drm/nouveau: use ram info from nvif_device
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/hw.c9
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_abi16.c4
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c3
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_chan.c11
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_fbcon.c5
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_ttm.c3
-rw-r--r--drivers/gpu/drm/nouveau/nv50_display.c12
-rw-r--r--drivers/gpu/drm/nouveau/nvif/device.h2
8 files changed, 17 insertions, 32 deletions
diff --git a/drivers/gpu/drm/nouveau/dispnv04/hw.c b/drivers/gpu/drm/nouveau/dispnv04/hw.c
index c9dc5541acbf..3d4c19300768 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/hw.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/hw.c
@@ -662,7 +662,6 @@ nv_load_state_ext(struct drm_device *dev, int head,
662 struct nouveau_drm *drm = nouveau_drm(dev); 662 struct nouveau_drm *drm = nouveau_drm(dev);
663 struct nvif_device *device = &drm->device; 663 struct nvif_device *device = &drm->device;
664 struct nouveau_timer *ptimer = nvkm_timer(device); 664 struct nouveau_timer *ptimer = nvkm_timer(device);
665 struct nouveau_fb *pfb = nvkm_fb(device);
666 struct nv04_crtc_reg *regp = &state->crtc_reg[head]; 665 struct nv04_crtc_reg *regp = &state->crtc_reg[head];
667 uint32_t reg900; 666 uint32_t reg900;
668 int i; 667 int i;
@@ -679,10 +678,10 @@ nv_load_state_ext(struct drm_device *dev, int head,
679 nvif_wr32(device, NV_PVIDEO_INTR_EN, 0); 678 nvif_wr32(device, NV_PVIDEO_INTR_EN, 0);
680 nvif_wr32(device, NV_PVIDEO_OFFSET_BUFF(0), 0); 679 nvif_wr32(device, NV_PVIDEO_OFFSET_BUFF(0), 0);
681 nvif_wr32(device, NV_PVIDEO_OFFSET_BUFF(1), 0); 680 nvif_wr32(device, NV_PVIDEO_OFFSET_BUFF(1), 0);
682 nvif_wr32(device, NV_PVIDEO_LIMIT(0), pfb->ram->size - 1); 681 nvif_wr32(device, NV_PVIDEO_LIMIT(0), device->info.ram_size - 1);
683 nvif_wr32(device, NV_PVIDEO_LIMIT(1), pfb->ram->size - 1); 682 nvif_wr32(device, NV_PVIDEO_LIMIT(1), device->info.ram_size - 1);
684 nvif_wr32(device, NV_PVIDEO_UVPLANE_LIMIT(0), pfb->ram->size - 1); 683 nvif_wr32(device, NV_PVIDEO_UVPLANE_LIMIT(0), device->info.ram_size - 1);
685 nvif_wr32(device, NV_PVIDEO_UVPLANE_LIMIT(1), pfb->ram->size - 1); 684 nvif_wr32(device, NV_PVIDEO_UVPLANE_LIMIT(1), device->info.ram_size - 1);
686 nvif_wr32(device, NV_PBUS_POWERCTRL_2, 0); 685 nvif_wr32(device, NV_PBUS_POWERCTRL_2, 0);
687 686
688 NVWriteCRTC(dev, head, NV_PCRTC_CURSOR_CONFIG, regp->cursor_cfg); 687 NVWriteCRTC(dev, head, NV_PCRTC_CURSOR_CONFIG, regp->cursor_cfg);
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index 43dfc3e83409..615714c1727d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -240,8 +240,6 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
240 struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev); 240 struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev);
241 struct nouveau_abi16_chan *chan; 241 struct nouveau_abi16_chan *chan;
242 struct nvif_device *device; 242 struct nvif_device *device;
243 struct nouveau_instmem *imem;
244 struct nouveau_fb *pfb;
245 int ret; 243 int ret;
246 244
247 if (unlikely(!abi16)) 245 if (unlikely(!abi16))
@@ -251,8 +249,6 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
251 return nouveau_abi16_put(abi16, -ENODEV); 249 return nouveau_abi16_put(abi16, -ENODEV);
252 250
253 device = &abi16->device; 251 device = &abi16->device;
254 imem = nvkm_instmem(device);
255 pfb = nvkm_fb(device);
256 252
257 /* hack to allow channel engine type specification on kepler */ 253 /* hack to allow channel engine type specification on kepler */
258 if (device->info.family >= NV_DEVICE_INFO_V0_KEPLER) { 254 if (device->info.family >= NV_DEVICE_INFO_V0_KEPLER) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 42b3ca881364..da5d631aa5b9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -257,8 +257,7 @@ static void
257set_placement_range(struct nouveau_bo *nvbo, uint32_t type) 257set_placement_range(struct nouveau_bo *nvbo, uint32_t type)
258{ 258{
259 struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev); 259 struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);
260 struct nouveau_fb *pfb = nvkm_fb(&drm->device); 260 u32 vram_pages = drm->device.info.ram_size >> PAGE_SHIFT;
261 u32 vram_pages = pfb->ram->size >> PAGE_SHIFT;
262 261
263 if (drm->device.info.family == NV_DEVICE_INFO_V0_CELSIUS && 262 if (drm->device.info.family == NV_DEVICE_INFO_V0_CELSIUS &&
264 nvbo->tile_mode && (type & TTM_PL_FLAG_VRAM) && 263 nvbo->tile_mode && (type & TTM_PL_FLAG_VRAM) &&
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index b4173be38451..99cd9e4a2aa6 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -88,9 +88,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
88 u32 handle, u32 size, struct nouveau_channel **pchan) 88 u32 handle, u32 size, struct nouveau_channel **pchan)
89{ 89{
90 struct nouveau_cli *cli = (void *)nvif_client(&device->base); 90 struct nouveau_cli *cli = (void *)nvif_client(&device->base);
91 struct nouveau_instmem *imem = nvkm_instmem(device);
92 struct nouveau_vmmgr *vmm = nvkm_vmmgr(device); 91 struct nouveau_vmmgr *vmm = nvkm_vmmgr(device);
93 struct nouveau_fb *pfb = nvkm_fb(device);
94 struct nv_dma_v0 args = {}; 92 struct nv_dma_v0 args = {};
95 struct nouveau_channel *chan; 93 struct nouveau_channel *chan;
96 u32 target; 94 u32 target;
@@ -141,7 +139,6 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
141 args.limit = cli->vm->vmm->limit - 1; 139 args.limit = cli->vm->vmm->limit - 1;
142 } else 140 } else
143 if (chan->push.buffer->bo.mem.mem_type == TTM_PL_VRAM) { 141 if (chan->push.buffer->bo.mem.mem_type == TTM_PL_VRAM) {
144 u64 limit = pfb->ram->size - imem->reserved - 1;
145 if (device->info.family == NV_DEVICE_INFO_V0_TNT) { 142 if (device->info.family == NV_DEVICE_INFO_V0_TNT) {
146 /* nv04 vram pushbuf hack, retarget to its location in 143 /* nv04 vram pushbuf hack, retarget to its location in
147 * the framebuffer bar rather than direct vram access.. 144 * the framebuffer bar rather than direct vram access..
@@ -150,12 +147,12 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
150 args.target = NV_DMA_V0_TARGET_PCI; 147 args.target = NV_DMA_V0_TARGET_PCI;
151 args.access = NV_DMA_V0_ACCESS_RDWR; 148 args.access = NV_DMA_V0_ACCESS_RDWR;
152 args.start = nv_device_resource_start(nvkm_device(device), 1); 149 args.start = nv_device_resource_start(nvkm_device(device), 1);
153 args.limit = args.start + limit; 150 args.limit = args.start + device->info.ram_user - 1;
154 } else { 151 } else {
155 args.target = NV_DMA_V0_TARGET_VRAM; 152 args.target = NV_DMA_V0_TARGET_VRAM;
156 args.access = NV_DMA_V0_ACCESS_RDWR; 153 args.access = NV_DMA_V0_ACCESS_RDWR;
157 args.start = 0; 154 args.start = 0;
158 args.limit = limit; 155 args.limit = device->info.ram_user - 1;
159 } 156 }
160 } else { 157 } else {
161 if (chan->drm->agp.stat == ENABLED) { 158 if (chan->drm->agp.stat == ENABLED) {
@@ -284,9 +281,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
284{ 281{
285 struct nvif_device *device = chan->device; 282 struct nvif_device *device = chan->device;
286 struct nouveau_cli *cli = (void *)nvif_client(&device->base); 283 struct nouveau_cli *cli = (void *)nvif_client(&device->base);
287 struct nouveau_instmem *imem = nvkm_instmem(device);
288 struct nouveau_vmmgr *vmm = nvkm_vmmgr(device); 284 struct nouveau_vmmgr *vmm = nvkm_vmmgr(device);
289 struct nouveau_fb *pfb = nvkm_fb(device);
290 struct nouveau_software_chan *swch; 285 struct nouveau_software_chan *swch;
291 struct nv_dma_v0 args = {}; 286 struct nv_dma_v0 args = {};
292 int ret, i; 287 int ret, i;
@@ -304,7 +299,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
304 args.target = NV_DMA_V0_TARGET_VRAM; 299 args.target = NV_DMA_V0_TARGET_VRAM;
305 args.access = NV_DMA_V0_ACCESS_RDWR; 300 args.access = NV_DMA_V0_ACCESS_RDWR;
306 args.start = 0; 301 args.start = 0;
307 args.limit = pfb->ram->size - imem->reserved - 1; 302 args.limit = device->info.ram_user - 1;
308 } 303 }
309 304
310 ret = nvif_object_init(chan->object, NULL, vram, 305 ret = nvif_object_init(chan->object, NULL, vram,
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 2f22da0e1ec4..ebfe3180109e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -491,7 +491,6 @@ int
491nouveau_fbcon_init(struct drm_device *dev) 491nouveau_fbcon_init(struct drm_device *dev)
492{ 492{
493 struct nouveau_drm *drm = nouveau_drm(dev); 493 struct nouveau_drm *drm = nouveau_drm(dev);
494 struct nouveau_fb *pfb = nvkm_fb(&drm->device);
495 struct nouveau_fbdev *fbcon; 494 struct nouveau_fbdev *fbcon;
496 int preferred_bpp; 495 int preferred_bpp;
497 int ret; 496 int ret;
@@ -518,10 +517,10 @@ nouveau_fbcon_init(struct drm_device *dev)
518 517
519 drm_fb_helper_single_add_all_connectors(&fbcon->helper); 518 drm_fb_helper_single_add_all_connectors(&fbcon->helper);
520 519
521 if (pfb->ram->size <= 32 * 1024 * 1024) 520 if (drm->device.info.ram_size <= 32 * 1024 * 1024)
522 preferred_bpp = 8; 521 preferred_bpp = 8;
523 else 522 else
524 if (pfb->ram->size <= 64 * 1024 * 1024) 523 if (drm->device.info.ram_size <= 64 * 1024 * 1024)
525 preferred_bpp = 16; 524 preferred_bpp = 16;
526 else 525 else
527 preferred_bpp = 32; 526 preferred_bpp = 32;
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 244c58ee45a6..53874b76b031 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -389,8 +389,7 @@ nouveau_ttm_init(struct nouveau_drm *drm)
389 } 389 }
390 390
391 /* VRAM init */ 391 /* VRAM init */
392 drm->gem.vram_available = nvkm_fb(&drm->device)->ram->size; 392 drm->gem.vram_available = drm->device.info.ram_user;
393 drm->gem.vram_available -= nvkm_instmem(&drm->device)->reserved;
394 393
395 ret = ttm_bo_init_mm(&drm->ttm.bdev, TTM_PL_VRAM, 394 ret = ttm_bo_init_mm(&drm->ttm.bdev, TTM_PL_VRAM,
396 drm->gem.vram_available >> PAGE_SHIFT); 395 drm->gem.vram_available >> PAGE_SHIFT);
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index 9e9fa585b304..03949eaa629f 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -195,19 +195,19 @@ nv50_dmac_create(struct nvif_object *disp, const u32 *oclass, u8 head,
195 void *data, u32 size, u64 syncbuf, 195 void *data, u32 size, u64 syncbuf,
196 struct nv50_dmac *dmac) 196 struct nv50_dmac *dmac)
197{ 197{
198 struct nouveau_fb *pfb = nvkm_fb(nvif_device(disp)); 198 struct nvif_device *device = nvif_device(disp);
199 struct nv50_disp_core_channel_dma_v0 *args = data; 199 struct nv50_disp_core_channel_dma_v0 *args = data;
200 struct nvif_object pushbuf; 200 struct nvif_object pushbuf;
201 int ret; 201 int ret;
202 202
203 mutex_init(&dmac->lock); 203 mutex_init(&dmac->lock);
204 204
205 dmac->ptr = pci_alloc_consistent(nvkm_device(nvif_device(disp))->pdev, 205 dmac->ptr = pci_alloc_consistent(nvkm_device(device)->pdev,
206 PAGE_SIZE, &dmac->handle); 206 PAGE_SIZE, &dmac->handle);
207 if (!dmac->ptr) 207 if (!dmac->ptr)
208 return -ENOMEM; 208 return -ENOMEM;
209 209
210 ret = nvif_object_init(nvif_object(nvif_device(disp)), NULL, 210 ret = nvif_object_init(nvif_object(device), NULL,
211 args->pushbuf, NV_DMA_FROM_MEMORY, 211 args->pushbuf, NV_DMA_FROM_MEMORY,
212 &(struct nv_dma_v0) { 212 &(struct nv_dma_v0) {
213 .target = NV_DMA_V0_TARGET_PCI_US, 213 .target = NV_DMA_V0_TARGET_PCI_US,
@@ -241,7 +241,7 @@ nv50_dmac_create(struct nvif_object *disp, const u32 *oclass, u8 head,
241 .target = NV_DMA_V0_TARGET_VRAM, 241 .target = NV_DMA_V0_TARGET_VRAM,
242 .access = NV_DMA_V0_ACCESS_RDWR, 242 .access = NV_DMA_V0_ACCESS_RDWR,
243 .start = 0, 243 .start = 0,
244 .limit = pfb->ram->size - 1, 244 .limit = device->info.ram_user - 1,
245 }, sizeof(struct nv_dma_v0), 245 }, sizeof(struct nv_dma_v0),
246 &dmac->vram); 246 &dmac->vram);
247 if (ret) 247 if (ret)
@@ -2339,7 +2339,6 @@ nv50_fb_ctor(struct drm_framebuffer *fb)
2339 struct nouveau_drm *drm = nouveau_drm(fb->dev); 2339 struct nouveau_drm *drm = nouveau_drm(fb->dev);
2340 struct nouveau_bo *nvbo = nv_fb->nvbo; 2340 struct nouveau_bo *nvbo = nv_fb->nvbo;
2341 struct nv50_disp *disp = nv50_disp(fb->dev); 2341 struct nv50_disp *disp = nv50_disp(fb->dev);
2342 struct nouveau_fb *pfb = nvkm_fb(&drm->device);
2343 u8 kind = nouveau_bo_tile_layout(nvbo) >> 8; 2342 u8 kind = nouveau_bo_tile_layout(nvbo) >> 8;
2344 u8 tile = nvbo->tile_mode; 2343 u8 tile = nvbo->tile_mode;
2345 2344
@@ -2377,7 +2376,8 @@ nv50_fb_ctor(struct drm_framebuffer *fb)
2377 } 2376 }
2378 nv_fb->r_handle = 0xffff0000 | kind; 2377 nv_fb->r_handle = 0xffff0000 | kind;
2379 2378
2380 return nv50_fbdma_init(fb->dev, nv_fb->r_handle, 0, pfb->ram->size, kind); 2379 return nv50_fbdma_init(fb->dev, nv_fb->r_handle, 0,
2380 drm->device.info.ram_user, kind);
2381} 2381}
2382 2382
2383/****************************************************************************** 2383/******************************************************************************
diff --git a/drivers/gpu/drm/nouveau/nvif/device.h b/drivers/gpu/drm/nouveau/nvif/device.h
index b3928765f659..43180f9fe630 100644
--- a/drivers/gpu/drm/nouveau/nvif/device.h
+++ b/drivers/gpu/drm/nouveau/nvif/device.h
@@ -29,7 +29,6 @@ void nvif_device_ref(struct nvif_device *, struct nvif_device **);
29/*XXX*/ 29/*XXX*/
30#include <subdev/bios.h> 30#include <subdev/bios.h>
31#include <subdev/fb.h> 31#include <subdev/fb.h>
32#include <subdev/instmem.h>
33#include <subdev/vm.h> 32#include <subdev/vm.h>
34#include <subdev/bar.h> 33#include <subdev/bar.h>
35#include <subdev/gpio.h> 34#include <subdev/gpio.h>
@@ -41,7 +40,6 @@ void nvif_device_ref(struct nvif_device *, struct nvif_device **);
41#define nvkm_device(a) nv_device(nvkm_object((a))) 40#define nvkm_device(a) nv_device(nvkm_object((a)))
42#define nvkm_bios(a) nouveau_bios(nvkm_device(a)) 41#define nvkm_bios(a) nouveau_bios(nvkm_device(a))
43#define nvkm_fb(a) nouveau_fb(nvkm_device(a)) 42#define nvkm_fb(a) nouveau_fb(nvkm_device(a))
44#define nvkm_instmem(a) nouveau_instmem(nvkm_device(a))
45#define nvkm_vmmgr(a) nouveau_vmmgr(nvkm_device(a)) 43#define nvkm_vmmgr(a) nouveau_vmmgr(nvkm_device(a))
46#define nvkm_bar(a) nouveau_bar(nvkm_device(a)) 44#define nvkm_bar(a) nouveau_bar(nvkm_device(a))
47#define nvkm_gpio(a) nouveau_gpio(nvkm_device(a)) 45#define nvkm_gpio(a) nouveau_gpio(nvkm_device(a))