aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nouveau_object.c
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2010-06-01 01:32:24 -0400
committerBen Skeggs <bskeggs@redhat.com>2010-07-12 20:12:51 -0400
commitb833ac26f1f1c8e8d9149d83dbdd91432f2807d5 (patch)
tree2899ec81e2c41c6942d75d9039748c0a882ce321 /drivers/gpu/drm/nouveau/nouveau_object.c
parentd17f395cdcec39033a481f96d75e8b3d3c41d43a (diff)
drm/nouveau: use drm_mm in preference to custom code doing the same thing
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_object.c')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_object.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_object.c b/drivers/gpu/drm/nouveau/nouveau_object.c
index e7c100ba63a1..d436c3c7f4f5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_object.c
+++ b/drivers/gpu/drm/nouveau/nouveau_object.c
@@ -209,7 +209,7 @@ nouveau_gpuobj_new(struct drm_device *dev, struct nouveau_channel *chan,
209 struct drm_nouveau_private *dev_priv = dev->dev_private; 209 struct drm_nouveau_private *dev_priv = dev->dev_private;
210 struct nouveau_engine *engine = &dev_priv->engine; 210 struct nouveau_engine *engine = &dev_priv->engine;
211 struct nouveau_gpuobj *gpuobj; 211 struct nouveau_gpuobj *gpuobj;
212 struct mem_block *pramin = NULL; 212 struct drm_mm *pramin = NULL;
213 int ret; 213 int ret;
214 214
215 NV_DEBUG(dev, "ch%d size=%u align=%d flags=0x%08x\n", 215 NV_DEBUG(dev, "ch%d size=%u align=%d flags=0x%08x\n",
@@ -233,17 +233,17 @@ nouveau_gpuobj_new(struct drm_device *dev, struct nouveau_channel *chan,
233 * available. 233 * available.
234 */ 234 */
235 if (chan) { 235 if (chan) {
236 if (chan->ramin_heap) { 236 if (chan->ramin_heap.ml_entry.next) {
237 NV_DEBUG(dev, "private heap\n"); 237 NV_DEBUG(dev, "private heap\n");
238 pramin = chan->ramin_heap; 238 pramin = &chan->ramin_heap;
239 } else 239 } else
240 if (dev_priv->card_type < NV_50) { 240 if (dev_priv->card_type < NV_50) {
241 NV_DEBUG(dev, "global heap fallback\n"); 241 NV_DEBUG(dev, "global heap fallback\n");
242 pramin = dev_priv->ramin_heap; 242 pramin = &dev_priv->ramin_heap;
243 } 243 }
244 } else { 244 } else {
245 NV_DEBUG(dev, "global heap\n"); 245 NV_DEBUG(dev, "global heap\n");
246 pramin = dev_priv->ramin_heap; 246 pramin = &dev_priv->ramin_heap;
247 } 247 }
248 248
249 if (!pramin) { 249 if (!pramin) {
@@ -260,9 +260,10 @@ nouveau_gpuobj_new(struct drm_device *dev, struct nouveau_channel *chan,
260 } 260 }
261 261
262 /* Allocate a chunk of the PRAMIN aperture */ 262 /* Allocate a chunk of the PRAMIN aperture */
263 gpuobj->im_pramin = nouveau_mem_alloc_block(pramin, size, 263 gpuobj->im_pramin = drm_mm_search_free(pramin, size, align, 0);
264 drm_order(align), 264 if (gpuobj->im_pramin)
265 (struct drm_file *)-2, 0); 265 gpuobj->im_pramin = drm_mm_get_block(gpuobj->im_pramin, size, align);
266
266 if (!gpuobj->im_pramin) { 267 if (!gpuobj->im_pramin) {
267 nouveau_gpuobj_del(dev, &gpuobj); 268 nouveau_gpuobj_del(dev, &gpuobj);
268 return -ENOMEM; 269 return -ENOMEM;
@@ -386,7 +387,7 @@ nouveau_gpuobj_del(struct drm_device *dev, struct nouveau_gpuobj **pgpuobj)
386 if (gpuobj->flags & NVOBJ_FLAG_FAKE) 387 if (gpuobj->flags & NVOBJ_FLAG_FAKE)
387 kfree(gpuobj->im_pramin); 388 kfree(gpuobj->im_pramin);
388 else 389 else
389 nouveau_mem_free_block(gpuobj->im_pramin); 390 drm_mm_put_block(gpuobj->im_pramin);
390 } 391 }
391 392
392 list_del(&gpuobj->list); 393 list_del(&gpuobj->list);
@@ -589,7 +590,7 @@ nouveau_gpuobj_new_fake(struct drm_device *dev, uint32_t p_offset,
589 list_add_tail(&gpuobj->list, &dev_priv->gpuobj_list); 590 list_add_tail(&gpuobj->list, &dev_priv->gpuobj_list);
590 591
591 if (p_offset != ~0) { 592 if (p_offset != ~0) {
592 gpuobj->im_pramin = kzalloc(sizeof(struct mem_block), 593 gpuobj->im_pramin = kzalloc(sizeof(struct drm_mm_node),
593 GFP_KERNEL); 594 GFP_KERNEL);
594 if (!gpuobj->im_pramin) { 595 if (!gpuobj->im_pramin) {
595 nouveau_gpuobj_del(dev, &gpuobj); 596 nouveau_gpuobj_del(dev, &gpuobj);
@@ -944,8 +945,7 @@ nouveau_gpuobj_channel_init_pramin(struct nouveau_channel *chan)
944 } 945 }
945 pramin = chan->ramin->gpuobj; 946 pramin = chan->ramin->gpuobj;
946 947
947 ret = nouveau_mem_init_heap(&chan->ramin_heap, 948 ret = drm_mm_init(&chan->ramin_heap, pramin->im_pramin->start + base, size);
948 pramin->im_pramin->start + base, size);
949 if (ret) { 949 if (ret) {
950 NV_ERROR(dev, "Error creating PRAMIN heap: %d\n", ret); 950 NV_ERROR(dev, "Error creating PRAMIN heap: %d\n", ret);
951 nouveau_gpuobj_ref_del(dev, &chan->ramin); 951 nouveau_gpuobj_ref_del(dev, &chan->ramin);
@@ -1130,8 +1130,8 @@ nouveau_gpuobj_channel_takedown(struct nouveau_channel *chan)
1130 for (i = 0; i < dev_priv->vm_vram_pt_nr; i++) 1130 for (i = 0; i < dev_priv->vm_vram_pt_nr; i++)
1131 nouveau_gpuobj_ref_del(dev, &chan->vm_vram_pt[i]); 1131 nouveau_gpuobj_ref_del(dev, &chan->vm_vram_pt[i]);
1132 1132
1133 if (chan->ramin_heap) 1133 if (chan->ramin_heap.free_stack.next)
1134 nouveau_mem_takedown(&chan->ramin_heap); 1134 drm_mm_takedown(&chan->ramin_heap);
1135 if (chan->ramin) 1135 if (chan->ramin)
1136 nouveau_gpuobj_ref_del(dev, &chan->ramin); 1136 nouveau_gpuobj_ref_del(dev, &chan->ramin);
1137 1137