aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2011-06-06 00:15:46 -0400
committerBen Skeggs <bskeggs@redhat.com>2011-06-23 01:59:27 -0400
commitf91bac5bf694e8060b7473fb0aefb8de09aa9595 (patch)
tree5c9ca0841bd831f3287bd686160c7e555a2391c3
parent111af5c100fa0c0b94301f719dd22dab87f5d0a4 (diff)
drm/nouveau: store bo's page size in nouveau_bo
Was previously assuming a page size of 4KiB unless a VMA was present to override it. Eventually, a buffer won't necessarily have a VMA at all at some stages of its life, so we need to store this info elsewhere. Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c27
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.h1
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_mem.c6
3 files changed, 15 insertions, 19 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 12d264b57e1d..71d01ce6598e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -58,7 +58,7 @@ nouveau_bo_del_ttm(struct ttm_buffer_object *bo)
58 58
59static void 59static void
60nouveau_bo_fixup_align(struct nouveau_bo *nvbo, u32 flags, 60nouveau_bo_fixup_align(struct nouveau_bo *nvbo, u32 flags,
61 int *align, int *size, int *page_shift) 61 int *align, int *size)
62{ 62{
63 struct drm_nouveau_private *dev_priv = nouveau_bdev(nvbo->bo.bdev); 63 struct drm_nouveau_private *dev_priv = nouveau_bdev(nvbo->bo.bdev);
64 64
@@ -82,17 +82,8 @@ nouveau_bo_fixup_align(struct nouveau_bo *nvbo, u32 flags,
82 } 82 }
83 } 83 }
84 } else { 84 } else {
85 if (likely(dev_priv->chan_vm)) { 85 *size = roundup(*size, (1 << nvbo->page_shift));
86 if (!(flags & TTM_PL_FLAG_TT) && *size > 256 * 1024) 86 *align = max((1 << nvbo->page_shift), *align);
87 *page_shift = dev_priv->chan_vm->lpg_shift;
88 else
89 *page_shift = dev_priv->chan_vm->spg_shift;
90 } else {
91 *page_shift = 12;
92 }
93
94 *size = roundup(*size, (1 << *page_shift));
95 *align = max((1 << *page_shift), *align);
96 } 87 }
97 88
98 *size = roundup(*size, PAGE_SIZE); 89 *size = roundup(*size, PAGE_SIZE);
@@ -105,7 +96,7 @@ nouveau_bo_new(struct drm_device *dev, struct nouveau_channel *chan,
105{ 96{
106 struct drm_nouveau_private *dev_priv = dev->dev_private; 97 struct drm_nouveau_private *dev_priv = dev->dev_private;
107 struct nouveau_bo *nvbo; 98 struct nouveau_bo *nvbo;
108 int ret = 0, page_shift = 0; 99 int ret;
109 100
110 nvbo = kzalloc(sizeof(struct nouveau_bo), GFP_KERNEL); 101 nvbo = kzalloc(sizeof(struct nouveau_bo), GFP_KERNEL);
111 if (!nvbo) 102 if (!nvbo)
@@ -116,11 +107,17 @@ nouveau_bo_new(struct drm_device *dev, struct nouveau_channel *chan,
116 nvbo->tile_flags = tile_flags; 107 nvbo->tile_flags = tile_flags;
117 nvbo->bo.bdev = &dev_priv->ttm.bdev; 108 nvbo->bo.bdev = &dev_priv->ttm.bdev;
118 109
119 nouveau_bo_fixup_align(nvbo, flags, &align, &size, &page_shift); 110 nvbo->page_shift = 12;
111 if (dev_priv->bar1_vm) {
112 if (!(flags & TTM_PL_FLAG_TT) && size > 256 * 1024)
113 nvbo->page_shift = dev_priv->bar1_vm->lpg_shift;
114 }
115
116 nouveau_bo_fixup_align(nvbo, flags, &align, &size);
120 align >>= PAGE_SHIFT; 117 align >>= PAGE_SHIFT;
121 118
122 if (dev_priv->chan_vm) { 119 if (dev_priv->chan_vm) {
123 ret = nouveau_vm_get(dev_priv->chan_vm, size, page_shift, 120 ret = nouveau_vm_get(dev_priv->chan_vm, size, nvbo->page_shift,
124 NV_MEM_ACCESS_RW, &nvbo->vma); 121 NV_MEM_ACCESS_RW, &nvbo->vma);
125 if (ret) { 122 if (ret) {
126 kfree(nvbo); 123 kfree(nvbo);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 0f5396602afb..1439188c3422 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -116,6 +116,7 @@ struct nouveau_bo {
116 struct nouveau_channel *channel; 116 struct nouveau_channel *channel;
117 117
118 struct nouveau_vma vma; 118 struct nouveau_vma vma;
119 unsigned page_shift;
119 120
120 uint32_t tile_mode; 121 uint32_t tile_mode;
121 uint32_t tile_flags; 122 uint32_t tile_flags;
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
index 5ee14d216ce8..f55b51be1bf1 100644
--- a/drivers/gpu/drm/nouveau/nouveau_mem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_mem.c
@@ -794,7 +794,7 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
794 int ret; 794 int ret;
795 795
796 if (nvbo->tile_flags & NOUVEAU_GEM_TILE_NONCONTIG) 796 if (nvbo->tile_flags & NOUVEAU_GEM_TILE_NONCONTIG)
797 size_nc = 1 << nvbo->vma.node->type; 797 size_nc = 1 << nvbo->page_shift;
798 798
799 ret = vram->get(dev, mem->num_pages << PAGE_SHIFT, 799 ret = vram->get(dev, mem->num_pages << PAGE_SHIFT,
800 mem->page_alignment << PAGE_SHIFT, size_nc, 800 mem->page_alignment << PAGE_SHIFT, size_nc,
@@ -804,9 +804,7 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
804 return (ret == -ENOSPC) ? 0 : ret; 804 return (ret == -ENOSPC) ? 0 : ret;
805 } 805 }
806 806
807 node->page_shift = 12; 807 node->page_shift = nvbo->page_shift;
808 if (nvbo->vma.node)
809 node->page_shift = nvbo->vma.node->type;
810 808
811 mem->mm_node = node; 809 mem->mm_node = node;
812 mem->start = node->offset >> PAGE_SHIFT; 810 mem->start = node->offset >> PAGE_SHIFT;