drm/nouveau: allow creation of zero-sized mm
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 <bskeggs@redhat.com>
This commit is contained in:
@@ -218,13 +218,16 @@ nouveau_mm_init(struct nouveau_mm *mm, u32 offset, u32 length, u32 block)
|
|||||||
node = kzalloc(sizeof(*node), GFP_KERNEL);
|
node = kzalloc(sizeof(*node), GFP_KERNEL);
|
||||||
if (!node)
|
if (!node)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
if (length) {
|
||||||
node->offset = roundup(offset, mm->block_size);
|
node->offset = roundup(offset, mm->block_size);
|
||||||
node->length = rounddown(offset + length, mm->block_size) - node->offset;
|
node->length = rounddown(offset + length, mm->block_size);
|
||||||
|
node->length -= node->offset;
|
||||||
|
}
|
||||||
|
|
||||||
list_add_tail(&node->nl_entry, &mm->nodes);
|
list_add_tail(&node->nl_entry, &mm->nodes);
|
||||||
list_add_tail(&node->fl_entry, &mm->free);
|
list_add_tail(&node->fl_entry, &mm->free);
|
||||||
mm->heap_nodes++;
|
mm->heap_nodes++;
|
||||||
mm->heap_size += length;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,7 +19,6 @@ struct nouveau_mm {
|
|||||||
|
|
||||||
u32 block_size;
|
u32 block_size;
|
||||||
int heap_nodes;
|
int heap_nodes;
|
||||||
u32 heap_size;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int nouveau_mm_init(struct nouveau_mm *, u32 offset, u32 length, u32 block);
|
int nouveau_mm_init(struct nouveau_mm *, u32 offset, u32 length, u32 block);
|
||||||
|
Reference in New Issue
Block a user