aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nv50_vram.c
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2011-02-13 18:57:35 -0500
committerBen Skeggs <bskeggs@redhat.com>2011-02-24 15:46:07 -0500
commit8f7286f8e4e80f7b868ba3d117ae900f0d207cbe (patch)
tree018804469b7bce4033b4156442c904512282fab2 /drivers/gpu/drm/nouveau/nv50_vram.c
parent26c0c9e33a2eb44b345d22d5928d5c8b7b261226 (diff)
drm/nv50: support for compression
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nv50_vram.c')
-rw-r--r--drivers/gpu/drm/nouveau/nv50_vram.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/drivers/gpu/drm/nouveau/nv50_vram.c b/drivers/gpu/drm/nouveau/nv50_vram.c
index ff6cbae40e58..ffbc3d8cf5be 100644
--- a/drivers/gpu/drm/nouveau/nv50_vram.c
+++ b/drivers/gpu/drm/nouveau/nv50_vram.c
@@ -69,6 +69,11 @@ nv50_vram_del(struct drm_device *dev, struct nouveau_mem **pmem)
69 list_del(&this->rl_entry); 69 list_del(&this->rl_entry);
70 nouveau_mm_put(mm, this); 70 nouveau_mm_put(mm, this);
71 } 71 }
72
73 if (mem->tag) {
74 drm_mm_put_block(mem->tag);
75 mem->tag = NULL;
76 }
72 mutex_unlock(&mm->mutex); 77 mutex_unlock(&mm->mutex);
73 78
74 kfree(mem); 79 kfree(mem);
@@ -76,7 +81,7 @@ nv50_vram_del(struct drm_device *dev, struct nouveau_mem **pmem)
76 81
77int 82int
78nv50_vram_new(struct drm_device *dev, u64 size, u32 align, u32 size_nc, 83nv50_vram_new(struct drm_device *dev, u64 size, u32 align, u32 size_nc,
79 u32 type, struct nouveau_mem **pmem) 84 u32 memtype, struct nouveau_mem **pmem)
80{ 85{
81 struct drm_nouveau_private *dev_priv = dev->dev_private; 86 struct drm_nouveau_private *dev_priv = dev->dev_private;
82 struct ttm_bo_device *bdev = &dev_priv->ttm.bdev; 87 struct ttm_bo_device *bdev = &dev_priv->ttm.bdev;
@@ -84,6 +89,8 @@ nv50_vram_new(struct drm_device *dev, u64 size, u32 align, u32 size_nc,
84 struct nouveau_mm *mm = man->priv; 89 struct nouveau_mm *mm = man->priv;
85 struct nouveau_mm_node *r; 90 struct nouveau_mm_node *r;
86 struct nouveau_mem *mem; 91 struct nouveau_mem *mem;
92 int comp = (memtype & 0x300) >> 8;
93 int type = (memtype & 0x07f);
87 int ret; 94 int ret;
88 95
89 if (!types[type]) 96 if (!types[type])
@@ -96,12 +103,26 @@ nv50_vram_new(struct drm_device *dev, u64 size, u32 align, u32 size_nc,
96 if (!mem) 103 if (!mem)
97 return -ENOMEM; 104 return -ENOMEM;
98 105
106 mutex_lock(&mm->mutex);
107 if (comp) {
108 if (align == 16) {
109 struct nouveau_fb_engine *pfb = &dev_priv->engine.fb;
110 int n = (size >> 4) * comp;
111
112 mem->tag = drm_mm_search_free(&pfb->tag_heap, n, 0, 0);
113 if (mem->tag)
114 mem->tag = drm_mm_get_block(mem->tag, n, 0);
115 }
116
117 if (unlikely(!mem->tag))
118 comp = 0;
119 }
120
99 INIT_LIST_HEAD(&mem->regions); 121 INIT_LIST_HEAD(&mem->regions);
100 mem->dev = dev_priv->dev; 122 mem->dev = dev_priv->dev;
101 mem->memtype = type; 123 mem->memtype = (comp << 7) | type;
102 mem->size = size; 124 mem->size = size;
103 125
104 mutex_lock(&mm->mutex);
105 do { 126 do {
106 ret = nouveau_mm_get(mm, types[type], size, size_nc, align, &r); 127 ret = nouveau_mm_get(mm, types[type], size, size_nc, align, &r);
107 if (ret) { 128 if (ret) {