diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2010-12-06 00:28:54 -0500 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2010-12-07 22:48:20 -0500 |
commit | 60d2a88ae896ae51c76f8b15c2f4b762d5b00864 (patch) | |
tree | e136aee905d35f8936036fd01af1ca29526fcc67 | |
parent | 34cf01bc4b8021cef62cbd79224577c13d01b106 (diff) |
drm/nouveau: kick vram functions out into an "engine"
NVC0 will be able to share some of nv50's paths this way. This also makes
it the card-specific vram code responsible for deciding if a given set
of tile_flags is valid, rather than duplicating the allowed types in
nv50_vram.c and nouveau_gem.c
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_drv.h | 12 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_gem.c | 30 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_mem.c | 47 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_mm.h | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_state.c | 16 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nv50_instmem.c | 9 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nv50_vram.c | 10 |
7 files changed, 74 insertions, 51 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index 2cd87e6b54b7..f8931b2d129b 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h | |||
@@ -501,6 +501,15 @@ struct nouveau_crypt_engine { | |||
501 | void (*tlb_flush)(struct drm_device *dev); | 501 | void (*tlb_flush)(struct drm_device *dev); |
502 | }; | 502 | }; |
503 | 503 | ||
504 | struct nouveau_vram_engine { | ||
505 | int (*init)(struct drm_device *); | ||
506 | int (*get)(struct drm_device *, u64, u32 align, u32 size_nc, | ||
507 | u32 type, struct nouveau_vram **); | ||
508 | void (*put)(struct drm_device *, struct nouveau_vram **); | ||
509 | |||
510 | bool (*flags_valid)(struct drm_device *, u32 tile_flags); | ||
511 | }; | ||
512 | |||
504 | struct nouveau_engine { | 513 | struct nouveau_engine { |
505 | struct nouveau_instmem_engine instmem; | 514 | struct nouveau_instmem_engine instmem; |
506 | struct nouveau_mc_engine mc; | 515 | struct nouveau_mc_engine mc; |
@@ -512,6 +521,7 @@ struct nouveau_engine { | |||
512 | struct nouveau_gpio_engine gpio; | 521 | struct nouveau_gpio_engine gpio; |
513 | struct nouveau_pm_engine pm; | 522 | struct nouveau_pm_engine pm; |
514 | struct nouveau_crypt_engine crypt; | 523 | struct nouveau_crypt_engine crypt; |
524 | struct nouveau_vram_engine vram; | ||
515 | }; | 525 | }; |
516 | 526 | ||
517 | struct nouveau_pll_vals { | 527 | struct nouveau_pll_vals { |
@@ -821,6 +831,8 @@ extern void nouveau_mem_gart_fini(struct drm_device *); | |||
821 | extern int nouveau_mem_init_agp(struct drm_device *); | 831 | extern int nouveau_mem_init_agp(struct drm_device *); |
822 | extern int nouveau_mem_reset_agp(struct drm_device *); | 832 | extern int nouveau_mem_reset_agp(struct drm_device *); |
823 | extern void nouveau_mem_close(struct drm_device *); | 833 | extern void nouveau_mem_close(struct drm_device *); |
834 | extern int nouveau_mem_detect(struct drm_device *); | ||
835 | extern bool nouveau_mem_flags_valid(struct drm_device *, u32 tile_flags); | ||
824 | extern struct nouveau_tile_reg *nv10_mem_set_tiling( | 836 | extern struct nouveau_tile_reg *nv10_mem_set_tiling( |
825 | struct drm_device *dev, uint32_t addr, uint32_t size, | 837 | struct drm_device *dev, uint32_t addr, uint32_t size, |
826 | uint32_t pitch, uint32_t flags); | 838 | uint32_t pitch, uint32_t flags); |
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 0adb2a85c143..506c508b7eda 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c | |||
@@ -103,32 +103,6 @@ nouveau_gem_info(struct drm_gem_object *gem, struct drm_nouveau_gem_info *rep) | |||
103 | return 0; | 103 | return 0; |
104 | } | 104 | } |
105 | 105 | ||
106 | static bool | ||
107 | nouveau_gem_tile_flags_valid(struct drm_device *dev, uint32_t tile_flags) | ||
108 | { | ||
109 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
110 | |||
111 | if (dev_priv->card_type >= NV_50) { | ||
112 | switch (tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK) { | ||
113 | case 0x0000: | ||
114 | case 0x1800: | ||
115 | case 0x2800: | ||
116 | case 0x4800: | ||
117 | case 0x7000: | ||
118 | case 0x7400: | ||
119 | case 0x7a00: | ||
120 | case 0xe000: | ||
121 | return true; | ||
122 | } | ||
123 | } else { | ||
124 | if (!(tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK)) | ||
125 | return true; | ||
126 | } | ||
127 | |||
128 | NV_ERROR(dev, "bad page flags: 0x%08x\n", tile_flags); | ||
129 | return false; | ||
130 | } | ||
131 | |||
132 | int | 106 | int |
133 | nouveau_gem_ioctl_new(struct drm_device *dev, void *data, | 107 | nouveau_gem_ioctl_new(struct drm_device *dev, void *data, |
134 | struct drm_file *file_priv) | 108 | struct drm_file *file_priv) |
@@ -150,8 +124,10 @@ nouveau_gem_ioctl_new(struct drm_device *dev, void *data, | |||
150 | if (!flags || req->info.domain & NOUVEAU_GEM_DOMAIN_CPU) | 124 | if (!flags || req->info.domain & NOUVEAU_GEM_DOMAIN_CPU) |
151 | flags |= TTM_PL_FLAG_SYSTEM; | 125 | flags |= TTM_PL_FLAG_SYSTEM; |
152 | 126 | ||
153 | if (!nouveau_gem_tile_flags_valid(dev, req->info.tile_flags)) | 127 | if (!dev_priv->engine.vram.flags_valid(dev, req->info.tile_flags)) { |
128 | NV_ERROR(dev, "bad page flags: 0x%08x\n", req->info.tile_flags); | ||
154 | return -EINVAL; | 129 | return -EINVAL; |
130 | } | ||
155 | 131 | ||
156 | if (req->channel_hint) { | 132 | if (req->channel_hint) { |
157 | chan = nouveau_channel_get(dev, file_priv, req->channel_hint); | 133 | chan = nouveau_channel_get(dev, file_priv, req->channel_hint); |
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c index 5a1809480388..224181193a1f 100644 --- a/drivers/gpu/drm/nouveau/nouveau_mem.c +++ b/drivers/gpu/drm/nouveau/nouveau_mem.c | |||
@@ -241,7 +241,7 @@ nouveau_mem_detect_nforce(struct drm_device *dev) | |||
241 | return 0; | 241 | return 0; |
242 | } | 242 | } |
243 | 243 | ||
244 | static int | 244 | int |
245 | nouveau_mem_detect(struct drm_device *dev) | 245 | nouveau_mem_detect(struct drm_device *dev) |
246 | { | 246 | { |
247 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 247 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
@@ -255,26 +255,25 @@ nouveau_mem_detect(struct drm_device *dev) | |||
255 | if (dev_priv->card_type < NV_50) { | 255 | if (dev_priv->card_type < NV_50) { |
256 | dev_priv->vram_size = nv_rd32(dev, NV04_PFB_FIFO_DATA); | 256 | dev_priv->vram_size = nv_rd32(dev, NV04_PFB_FIFO_DATA); |
257 | dev_priv->vram_size &= NV10_PFB_FIFO_DATA_RAM_AMOUNT_MB_MASK; | 257 | dev_priv->vram_size &= NV10_PFB_FIFO_DATA_RAM_AMOUNT_MB_MASK; |
258 | } else | ||
259 | if (dev_priv->card_type < NV_C0) { | ||
260 | if (nv50_vram_init(dev)) | ||
261 | return -ENOMEM; | ||
262 | } else { | 258 | } else { |
263 | dev_priv->vram_size = nv_rd32(dev, 0x10f20c) << 20; | 259 | dev_priv->vram_size = nv_rd32(dev, 0x10f20c) << 20; |
264 | dev_priv->vram_size *= nv_rd32(dev, 0x121c74); | 260 | dev_priv->vram_size *= nv_rd32(dev, 0x121c74); |
265 | } | 261 | } |
266 | 262 | ||
267 | NV_INFO(dev, "Detected %dMiB VRAM\n", (int)(dev_priv->vram_size >> 20)); | ||
268 | if (dev_priv->vram_sys_base) { | ||
269 | NV_INFO(dev, "Stolen system memory at: 0x%010llx\n", | ||
270 | dev_priv->vram_sys_base); | ||
271 | } | ||
272 | |||
273 | if (dev_priv->vram_size) | 263 | if (dev_priv->vram_size) |
274 | return 0; | 264 | return 0; |
275 | return -ENOMEM; | 265 | return -ENOMEM; |
276 | } | 266 | } |
277 | 267 | ||
268 | bool | ||
269 | nouveau_mem_flags_valid(struct drm_device *dev, u32 tile_flags) | ||
270 | { | ||
271 | if (!(tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK)) | ||
272 | return true; | ||
273 | |||
274 | return false; | ||
275 | } | ||
276 | |||
278 | #if __OS_HAS_AGP | 277 | #if __OS_HAS_AGP |
279 | static unsigned long | 278 | static unsigned long |
280 | get_agp_mode(struct drm_device *dev, unsigned long mode) | 279 | get_agp_mode(struct drm_device *dev, unsigned long mode) |
@@ -432,11 +431,16 @@ nouveau_mem_vram_init(struct drm_device *dev) | |||
432 | else | 431 | else |
433 | dev_priv->ramin_rsvd_vram = (512 * 1024); | 432 | dev_priv->ramin_rsvd_vram = (512 * 1024); |
434 | 433 | ||
435 | /* initialise gpu-specific vram backend */ | 434 | ret = dev_priv->engine.vram.init(dev); |
436 | ret = nouveau_mem_detect(dev); | ||
437 | if (ret) | 435 | if (ret) |
438 | return ret; | 436 | return ret; |
439 | 437 | ||
438 | NV_INFO(dev, "Detected %dMiB VRAM\n", (int)(dev_priv->vram_size >> 20)); | ||
439 | if (dev_priv->vram_sys_base) { | ||
440 | NV_INFO(dev, "Stolen system memory at: 0x%010llx\n", | ||
441 | dev_priv->vram_sys_base); | ||
442 | } | ||
443 | |||
440 | dev_priv->fb_available_size = dev_priv->vram_size; | 444 | dev_priv->fb_available_size = dev_priv->vram_size; |
441 | dev_priv->fb_mappable_pages = dev_priv->fb_available_size; | 445 | dev_priv->fb_mappable_pages = dev_priv->fb_available_size; |
442 | if (dev_priv->fb_mappable_pages > pci_resource_len(dev->pdev, 1)) | 446 | if (dev_priv->fb_mappable_pages > pci_resource_len(dev->pdev, 1)) |
@@ -698,9 +702,10 @@ nouveau_vram_manager_del(struct ttm_mem_type_manager *man, | |||
698 | struct ttm_mem_reg *mem) | 702 | struct ttm_mem_reg *mem) |
699 | { | 703 | { |
700 | struct drm_nouveau_private *dev_priv = nouveau_bdev(man->bdev); | 704 | struct drm_nouveau_private *dev_priv = nouveau_bdev(man->bdev); |
705 | struct nouveau_vram_engine *vram = &dev_priv->engine.vram; | ||
701 | struct drm_device *dev = dev_priv->dev; | 706 | struct drm_device *dev = dev_priv->dev; |
702 | 707 | ||
703 | nv50_vram_del(dev, (struct nouveau_vram **)&mem->mm_node); | 708 | vram->put(dev, (struct nouveau_vram **)&mem->mm_node); |
704 | } | 709 | } |
705 | 710 | ||
706 | static int | 711 | static int |
@@ -710,30 +715,30 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man, | |||
710 | struct ttm_mem_reg *mem) | 715 | struct ttm_mem_reg *mem) |
711 | { | 716 | { |
712 | struct drm_nouveau_private *dev_priv = nouveau_bdev(man->bdev); | 717 | struct drm_nouveau_private *dev_priv = nouveau_bdev(man->bdev); |
718 | struct nouveau_vram_engine *vram = &dev_priv->engine.vram; | ||
713 | struct drm_device *dev = dev_priv->dev; | 719 | struct drm_device *dev = dev_priv->dev; |
714 | struct nouveau_bo *nvbo = nouveau_bo(bo); | 720 | struct nouveau_bo *nvbo = nouveau_bo(bo); |
715 | struct nouveau_vram *vram; | 721 | struct nouveau_vram *node; |
716 | u32 size_nc = 0; | 722 | u32 size_nc = 0; |
717 | int ret; | 723 | int ret; |
718 | 724 | ||
719 | if (nvbo->tile_flags & NOUVEAU_GEM_TILE_NONCONTIG) | 725 | if (nvbo->tile_flags & NOUVEAU_GEM_TILE_NONCONTIG) |
720 | size_nc = 1 << nvbo->vma.node->type; | 726 | size_nc = 1 << nvbo->vma.node->type; |
721 | 727 | ||
722 | ret = nv50_vram_new(dev, mem->num_pages << PAGE_SHIFT, | 728 | ret = vram->get(dev, mem->num_pages << PAGE_SHIFT, |
723 | mem->page_alignment << PAGE_SHIFT, size_nc, | 729 | mem->page_alignment << PAGE_SHIFT, size_nc, |
724 | (nvbo->tile_flags >> 8) & 0x7f, &vram); | 730 | (nvbo->tile_flags >> 8) & 0xff, &node); |
725 | if (ret) | 731 | if (ret) |
726 | return ret; | 732 | return ret; |
727 | 733 | ||
728 | mem->mm_node = vram; | 734 | mem->mm_node = node; |
729 | mem->start = vram->offset >> PAGE_SHIFT; | 735 | mem->start = node->offset >> PAGE_SHIFT; |
730 | return 0; | 736 | return 0; |
731 | } | 737 | } |
732 | 738 | ||
733 | void | 739 | void |
734 | nouveau_vram_manager_debug(struct ttm_mem_type_manager *man, const char *prefix) | 740 | nouveau_vram_manager_debug(struct ttm_mem_type_manager *man, const char *prefix) |
735 | { | 741 | { |
736 | struct ttm_bo_global *glob = man->bdev->glob; | ||
737 | struct nouveau_mm *mm = man->priv; | 742 | struct nouveau_mm *mm = man->priv; |
738 | struct nouveau_mm_node *r; | 743 | struct nouveau_mm_node *r; |
739 | u64 total = 0, ttotal[3] = {}, tused[3] = {}, tfree[3] = {}; | 744 | u64 total = 0, ttotal[3] = {}, tused[3] = {}, tfree[3] = {}; |
diff --git a/drivers/gpu/drm/nouveau/nouveau_mm.h b/drivers/gpu/drm/nouveau/nouveau_mm.h index 7e8f8bd86d47..250e642de0a7 100644 --- a/drivers/gpu/drm/nouveau/nouveau_mm.h +++ b/drivers/gpu/drm/nouveau/nouveau_mm.h | |||
@@ -57,5 +57,6 @@ int nv50_vram_init(struct drm_device *); | |||
57 | int nv50_vram_new(struct drm_device *, u64 size, u32 align, u32 size_nc, | 57 | int nv50_vram_new(struct drm_device *, u64 size, u32 align, u32 size_nc, |
58 | u32 memtype, struct nouveau_vram **); | 58 | u32 memtype, struct nouveau_vram **); |
59 | void nv50_vram_del(struct drm_device *, struct nouveau_vram **); | 59 | void nv50_vram_del(struct drm_device *, struct nouveau_vram **); |
60 | bool nv50_vram_flags_valid(struct drm_device *, u32 tile_flags); | ||
60 | 61 | ||
61 | #endif | 62 | #endif |
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c index e0811f93243d..8eac943e8fd2 100644 --- a/drivers/gpu/drm/nouveau/nouveau_state.c +++ b/drivers/gpu/drm/nouveau/nouveau_state.c | |||
@@ -100,6 +100,8 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev) | |||
100 | engine->pm.clock_set = nv04_pm_clock_set; | 100 | engine->pm.clock_set = nv04_pm_clock_set; |
101 | engine->crypt.init = nouveau_stub_init; | 101 | engine->crypt.init = nouveau_stub_init; |
102 | engine->crypt.takedown = nouveau_stub_takedown; | 102 | engine->crypt.takedown = nouveau_stub_takedown; |
103 | engine->vram.init = nouveau_mem_detect; | ||
104 | engine->vram.flags_valid = nouveau_mem_flags_valid; | ||
103 | break; | 105 | break; |
104 | case 0x10: | 106 | case 0x10: |
105 | engine->instmem.init = nv04_instmem_init; | 107 | engine->instmem.init = nv04_instmem_init; |
@@ -157,6 +159,8 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev) | |||
157 | engine->pm.clock_set = nv04_pm_clock_set; | 159 | engine->pm.clock_set = nv04_pm_clock_set; |
158 | engine->crypt.init = nouveau_stub_init; | 160 | engine->crypt.init = nouveau_stub_init; |
159 | engine->crypt.takedown = nouveau_stub_takedown; | 161 | engine->crypt.takedown = nouveau_stub_takedown; |
162 | engine->vram.init = nouveau_mem_detect; | ||
163 | engine->vram.flags_valid = nouveau_mem_flags_valid; | ||
160 | break; | 164 | break; |
161 | case 0x20: | 165 | case 0x20: |
162 | engine->instmem.init = nv04_instmem_init; | 166 | engine->instmem.init = nv04_instmem_init; |
@@ -214,6 +218,8 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev) | |||
214 | engine->pm.clock_set = nv04_pm_clock_set; | 218 | engine->pm.clock_set = nv04_pm_clock_set; |
215 | engine->crypt.init = nouveau_stub_init; | 219 | engine->crypt.init = nouveau_stub_init; |
216 | engine->crypt.takedown = nouveau_stub_takedown; | 220 | engine->crypt.takedown = nouveau_stub_takedown; |
221 | engine->vram.init = nouveau_mem_detect; | ||
222 | engine->vram.flags_valid = nouveau_mem_flags_valid; | ||
217 | break; | 223 | break; |
218 | case 0x30: | 224 | case 0x30: |
219 | engine->instmem.init = nv04_instmem_init; | 225 | engine->instmem.init = nv04_instmem_init; |
@@ -273,6 +279,8 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev) | |||
273 | engine->pm.voltage_set = nouveau_voltage_gpio_set; | 279 | engine->pm.voltage_set = nouveau_voltage_gpio_set; |
274 | engine->crypt.init = nouveau_stub_init; | 280 | engine->crypt.init = nouveau_stub_init; |
275 | engine->crypt.takedown = nouveau_stub_takedown; | 281 | engine->crypt.takedown = nouveau_stub_takedown; |
282 | engine->vram.init = nouveau_mem_detect; | ||
283 | engine->vram.flags_valid = nouveau_mem_flags_valid; | ||
276 | break; | 284 | break; |
277 | case 0x40: | 285 | case 0x40: |
278 | case 0x60: | 286 | case 0x60: |
@@ -334,6 +342,8 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev) | |||
334 | engine->pm.temp_get = nv40_temp_get; | 342 | engine->pm.temp_get = nv40_temp_get; |
335 | engine->crypt.init = nouveau_stub_init; | 343 | engine->crypt.init = nouveau_stub_init; |
336 | engine->crypt.takedown = nouveau_stub_takedown; | 344 | engine->crypt.takedown = nouveau_stub_takedown; |
345 | engine->vram.init = nouveau_mem_detect; | ||
346 | engine->vram.flags_valid = nouveau_mem_flags_valid; | ||
337 | break; | 347 | break; |
338 | case 0x50: | 348 | case 0x50: |
339 | case 0x80: /* gotta love NVIDIA's consistency.. */ | 349 | case 0x80: /* gotta love NVIDIA's consistency.. */ |
@@ -444,6 +454,10 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev) | |||
444 | engine->crypt.takedown = nouveau_stub_takedown; | 454 | engine->crypt.takedown = nouveau_stub_takedown; |
445 | break; | 455 | break; |
446 | } | 456 | } |
457 | engine->vram.init = nv50_vram_init; | ||
458 | engine->vram.get = nv50_vram_new; | ||
459 | engine->vram.put = nv50_vram_del; | ||
460 | engine->vram.flags_valid = nv50_vram_flags_valid; | ||
447 | break; | 461 | break; |
448 | case 0xC0: | 462 | case 0xC0: |
449 | engine->instmem.init = nvc0_instmem_init; | 463 | engine->instmem.init = nvc0_instmem_init; |
@@ -495,6 +509,8 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev) | |||
495 | engine->gpio.irq_enable = nv50_gpio_irq_enable; | 509 | engine->gpio.irq_enable = nv50_gpio_irq_enable; |
496 | engine->crypt.init = nouveau_stub_init; | 510 | engine->crypt.init = nouveau_stub_init; |
497 | engine->crypt.takedown = nouveau_stub_takedown; | 511 | engine->crypt.takedown = nouveau_stub_takedown; |
512 | engine->vram.init = nouveau_mem_detect; | ||
513 | engine->vram.flags_valid = nouveau_mem_flags_valid; | ||
498 | break; | 514 | break; |
499 | default: | 515 | default: |
500 | NV_ERROR(dev, "NV%02x unsupported\n", dev_priv->chipset); | 516 | NV_ERROR(dev, "NV%02x unsupported\n", dev_priv->chipset); |
diff --git a/drivers/gpu/drm/nouveau/nv50_instmem.c b/drivers/gpu/drm/nouveau/nv50_instmem.c index e2efd6f22ffb..38f30270cb9f 100644 --- a/drivers/gpu/drm/nouveau/nv50_instmem.c +++ b/drivers/gpu/drm/nouveau/nv50_instmem.c | |||
@@ -312,6 +312,7 @@ nv50_instmem_get(struct nouveau_gpuobj *gpuobj, u32 size, u32 align) | |||
312 | { | 312 | { |
313 | struct drm_device *dev = gpuobj->dev; | 313 | struct drm_device *dev = gpuobj->dev; |
314 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 314 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
315 | struct nouveau_vram_engine *vram = &dev_priv->engine.vram; | ||
315 | struct nv50_gpuobj_node *node = NULL; | 316 | struct nv50_gpuobj_node *node = NULL; |
316 | int ret; | 317 | int ret; |
317 | 318 | ||
@@ -323,7 +324,7 @@ nv50_instmem_get(struct nouveau_gpuobj *gpuobj, u32 size, u32 align) | |||
323 | size = (size + 4095) & ~4095; | 324 | size = (size + 4095) & ~4095; |
324 | align = max(align, (u32)4096); | 325 | align = max(align, (u32)4096); |
325 | 326 | ||
326 | ret = nv50_vram_new(dev, size, align, 0, 0, &node->vram); | 327 | ret = vram->get(dev, size, align, 0, 0, &node->vram); |
327 | if (ret) { | 328 | if (ret) { |
328 | kfree(node); | 329 | kfree(node); |
329 | return ret; | 330 | return ret; |
@@ -336,7 +337,7 @@ nv50_instmem_get(struct nouveau_gpuobj *gpuobj, u32 size, u32 align) | |||
336 | NV_MEM_ACCESS_RW | NV_MEM_ACCESS_SYS, | 337 | NV_MEM_ACCESS_RW | NV_MEM_ACCESS_SYS, |
337 | &node->chan_vma); | 338 | &node->chan_vma); |
338 | if (ret) { | 339 | if (ret) { |
339 | nv50_vram_del(dev, &node->vram); | 340 | vram->put(dev, &node->vram); |
340 | kfree(node); | 341 | kfree(node); |
341 | return ret; | 342 | return ret; |
342 | } | 343 | } |
@@ -354,6 +355,8 @@ void | |||
354 | nv50_instmem_put(struct nouveau_gpuobj *gpuobj) | 355 | nv50_instmem_put(struct nouveau_gpuobj *gpuobj) |
355 | { | 356 | { |
356 | struct drm_device *dev = gpuobj->dev; | 357 | struct drm_device *dev = gpuobj->dev; |
358 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
359 | struct nouveau_vram_engine *vram = &dev_priv->engine.vram; | ||
357 | struct nv50_gpuobj_node *node; | 360 | struct nv50_gpuobj_node *node; |
358 | 361 | ||
359 | node = gpuobj->node; | 362 | node = gpuobj->node; |
@@ -363,7 +366,7 @@ nv50_instmem_put(struct nouveau_gpuobj *gpuobj) | |||
363 | nouveau_vm_unmap(&node->chan_vma); | 366 | nouveau_vm_unmap(&node->chan_vma); |
364 | nouveau_vm_put(&node->chan_vma); | 367 | nouveau_vm_put(&node->chan_vma); |
365 | } | 368 | } |
366 | nv50_vram_del(dev, &node->vram); | 369 | vram->put(dev, &node->vram); |
367 | kfree(node); | 370 | kfree(node); |
368 | } | 371 | } |
369 | 372 | ||
diff --git a/drivers/gpu/drm/nouveau/nv50_vram.c b/drivers/gpu/drm/nouveau/nv50_vram.c index 6e753356cd94..47489ed0a5a8 100644 --- a/drivers/gpu/drm/nouveau/nv50_vram.c +++ b/drivers/gpu/drm/nouveau/nv50_vram.c | |||
@@ -37,6 +37,16 @@ static int types[0x80] = { | |||
37 | 1, 0, 2, 0, 1, 0, 2, 0, 1, 1, 2, 2, 1, 1, 0, 0 | 37 | 1, 0, 2, 0, 1, 0, 2, 0, 1, 1, 2, 2, 1, 1, 0, 0 |
38 | }; | 38 | }; |
39 | 39 | ||
40 | bool | ||
41 | nv50_vram_flags_valid(struct drm_device *dev, u32 tile_flags) | ||
42 | { | ||
43 | int type = (tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK) >> 8; | ||
44 | |||
45 | if (likely(type < sizeof(types) && types[type])) | ||
46 | return true; | ||
47 | return false; | ||
48 | } | ||
49 | |||
40 | void | 50 | void |
41 | nv50_vram_del(struct drm_device *dev, struct nouveau_vram **pvram) | 51 | nv50_vram_del(struct drm_device *dev, struct nouveau_vram **pvram) |
42 | { | 52 | { |