Skip to content

Commit

Permalink
drm/nouveau: allow creation of zero-sized mm
Browse files Browse the repository at this point in the history
Useful for places where a given chipset may or may not have a given
resource, and we want to avoid having to spray checks for the mm's
existance around everywhere.

Signed-off-by: Ben Skeggs <[email protected]>
  • Loading branch information
Ben Skeggs committed Oct 31, 2012
1 parent 1249ac5 commit a7dbf00
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 6 additions & 3 deletions drivers/gpu/drm/nouveau/core/core/mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,16 @@ nouveau_mm_init(struct nouveau_mm *mm, u32 offset, u32 length, u32 block)
node = kzalloc(sizeof(*node), GFP_KERNEL);
if (!node)
return -ENOMEM;
node->offset = roundup(offset, mm->block_size);
node->length = rounddown(offset + length, mm->block_size) - node->offset;

if (length) {
node->offset = roundup(offset, mm->block_size);
node->length = rounddown(offset + length, mm->block_size);
node->length -= node->offset;
}

list_add_tail(&node->nl_entry, &mm->nodes);
list_add_tail(&node->fl_entry, &mm->free);
mm->heap_nodes++;
mm->heap_size += length;
return 0;
}

Expand Down
1 change: 0 additions & 1 deletion drivers/gpu/drm/nouveau/core/include/core/mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ struct nouveau_mm {

u32 block_size;
int heap_nodes;
u32 heap_size;
};

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

0 comments on commit a7dbf00

Please sign in to comment.