Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 269607
b: refs/heads/master
c: a12036b
h: refs/heads/master
i:
  269605: 3c7c100
  269603: da72726
  269599: 8d8d3b1
v: v3
  • Loading branch information
Ben Skeggs committed Sep 20, 2011
1 parent 3c24290 commit 3c602d9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 987eec10dd76624d0edacdc7ecc7e1a6fc877373
refs/heads/master: a12036ba2c0a190c93e5238c5f32fdb8c023c068
47 changes: 27 additions & 20 deletions trunk/drivers/gpu/drm/nouveau/nouveau_mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,25 @@ nouveau_mm_get(struct nouveau_mm *mm, int type, u32 size, u32 size_nc,
int
nouveau_mm_init(struct nouveau_mm *mm, u32 offset, u32 length, u32 block)
{
struct nouveau_mm_node *heap;
struct nouveau_mm_node *node;

if (block) {
mutex_init(&mm->mutex);
INIT_LIST_HEAD(&mm->nodes);
INIT_LIST_HEAD(&mm->free);
mm->block_size = block;
mm->heap_nodes = 0;
}

heap = kzalloc(sizeof(*heap), GFP_KERNEL);
if (!heap)
node = kzalloc(sizeof(*node), GFP_KERNEL);
if (!node)
return -ENOMEM;
heap->offset = roundup(offset, block);
heap->length = rounddown(offset + length, block) - heap->offset;

mutex_init(&mm->mutex);
mm->block_size = block;
INIT_LIST_HEAD(&mm->nodes);
INIT_LIST_HEAD(&mm->free);
node->offset = roundup(offset, mm->block_size);
node->length = rounddown(offset + length, mm->block_size) - node->offset;

list_add(&heap->nl_entry, &mm->nodes);
list_add(&heap->fl_entry, &mm->free);
list_add_tail(&node->nl_entry, &mm->nodes);
list_add_tail(&node->fl_entry, &mm->free);
mm->heap_nodes++;
return 0;
}

Expand All @@ -152,15 +156,18 @@ nouveau_mm_fini(struct nouveau_mm *mm)
{
struct nouveau_mm_node *node, *heap =
list_first_entry(&mm->nodes, struct nouveau_mm_node, nl_entry);

if (!list_is_singular(&mm->nodes)) {
printk(KERN_ERR "nouveau_mm not empty at destroy time!\n");
list_for_each_entry(node, &mm->nodes, nl_entry) {
printk(KERN_ERR "0x%02x: 0x%08x 0x%08x\n",
node->type, node->offset, node->length);
int nodes = 0;

list_for_each_entry(node, &mm->nodes, nl_entry) {
if (nodes++ == mm->heap_nodes) {
printk(KERN_ERR "nouveau_mm in use at destroy time!\n");
list_for_each_entry(node, &mm->nodes, nl_entry) {
printk(KERN_ERR "0x%02x: 0x%08x 0x%08x\n",
node->type, node->offset, node->length);
}
WARN_ON(1);
return -EBUSY;
}
WARN_ON(1);
return -EBUSY;
}

kfree(heap);
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/gpu/drm/nouveau/nouveau_mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct nouveau_mm {
struct mutex mutex;

u32 block_size;
int heap_nodes;
};

int nouveau_mm_init(struct nouveau_mm *, u32 offset, u32 length, u32 block);
Expand Down

0 comments on commit 3c602d9

Please sign in to comment.