diff options
| author | Ben Skeggs <bskeggs@redhat.com> | 2012-10-30 21:19:40 -0400 |
|---|---|---|
| committer | Ben Skeggs <bskeggs@redhat.com> | 2012-10-30 21:22:51 -0400 |
| commit | a7dbf00433fa9dc6f4a3828a17d56a9df2bd06b1 (patch) | |
| tree | d59a16030201ea5d9a1dded6585b36fe4cf8ffcf | |
| parent | 1249ac592a2f995fef977be33abf077bdb57b3aa (diff) | |
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>
| -rw-r--r-- | drivers/gpu/drm/nouveau/core/core/mm.c | 9 | ||||
| -rw-r--r-- | drivers/gpu/drm/nouveau/core/include/core/mm.h | 1 |
2 files changed, 6 insertions, 4 deletions
diff --git a/drivers/gpu/drm/nouveau/core/core/mm.c b/drivers/gpu/drm/nouveau/core/core/mm.c index 4d6206448670..a6d3cd6490f7 100644 --- a/drivers/gpu/drm/nouveau/core/core/mm.c +++ b/drivers/gpu/drm/nouveau/core/core/mm.c | |||
| @@ -218,13 +218,16 @@ nouveau_mm_init(struct nouveau_mm *mm, u32 offset, u32 length, u32 block) | |||
| 218 | node = kzalloc(sizeof(*node), GFP_KERNEL); | 218 | node = kzalloc(sizeof(*node), GFP_KERNEL); |
| 219 | if (!node) | 219 | if (!node) |
| 220 | return -ENOMEM; | 220 | return -ENOMEM; |
| 221 | node->offset = roundup(offset, mm->block_size); | 221 | |
| 222 | node->length = rounddown(offset + length, mm->block_size) - node->offset; | 222 | if (length) { |
| 223 | node->offset = roundup(offset, mm->block_size); | ||
| 224 | node->length = rounddown(offset + length, mm->block_size); | ||
| 225 | node->length -= node->offset; | ||
| 226 | } | ||
| 223 | 227 | ||
| 224 | list_add_tail(&node->nl_entry, &mm->nodes); | 228 | list_add_tail(&node->nl_entry, &mm->nodes); |
| 225 | list_add_tail(&node->fl_entry, &mm->free); | 229 | list_add_tail(&node->fl_entry, &mm->free); |
| 226 | mm->heap_nodes++; | 230 | mm->heap_nodes++; |
| 227 | mm->heap_size += length; | ||
| 228 | return 0; | 231 | return 0; |
| 229 | } | 232 | } |
| 230 | 233 | ||
diff --git a/drivers/gpu/drm/nouveau/core/include/core/mm.h b/drivers/gpu/drm/nouveau/core/include/core/mm.h index 9ee9bf4028ca..975137ba34a6 100644 --- a/drivers/gpu/drm/nouveau/core/include/core/mm.h +++ b/drivers/gpu/drm/nouveau/core/include/core/mm.h | |||
| @@ -19,7 +19,6 @@ struct nouveau_mm { | |||
| 19 | 19 | ||
| 20 | u32 block_size; | 20 | u32 block_size; |
| 21 | int heap_nodes; | 21 | int heap_nodes; |
| 22 | u32 heap_size; | ||
| 23 | }; | 22 | }; |
| 24 | 23 | ||
| 25 | int nouveau_mm_init(struct nouveau_mm *, u32 offset, u32 length, u32 block); | 24 | int nouveau_mm_init(struct nouveau_mm *, u32 offset, u32 length, u32 block); |
