aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2012-10-09 22:13:38 -0400
committerBen Skeggs <bskeggs@redhat.com>2012-11-28 18:56:30 -0500
commit7e0f992b796e102d32b75392fba38be7cab1c5a9 (patch)
tree13670bb72bee84b7bdeb13c9ee734679bac32498
parent6d338081a6008b3638ca45e0020c5a0cebe362fd (diff)
drm/nouveau: replace some open-coded mm_initialised checks
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r--drivers/gpu/drm/nouveau/core/core/mm.c17
-rw-r--r--drivers/gpu/drm/nouveau/core/include/core/mm.h6
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/fb/base.c8
3 files changed, 18 insertions, 13 deletions
diff --git a/drivers/gpu/drm/nouveau/core/core/mm.c b/drivers/gpu/drm/nouveau/core/core/mm.c
index a6d3cd6490f7..0261a11b2ae0 100644
--- a/drivers/gpu/drm/nouveau/core/core/mm.c
+++ b/drivers/gpu/drm/nouveau/core/core/mm.c
@@ -234,15 +234,18 @@ nouveau_mm_init(struct nouveau_mm *mm, u32 offset, u32 length, u32 block)
234int 234int
235nouveau_mm_fini(struct nouveau_mm *mm) 235nouveau_mm_fini(struct nouveau_mm *mm)
236{ 236{
237 struct nouveau_mm_node *node, *heap = 237 if (nouveau_mm_initialised(mm)) {
238 list_first_entry(&mm->nodes, struct nouveau_mm_node, nl_entry); 238 struct nouveau_mm_node *node, *heap =
239 int nodes = 0; 239 list_first_entry(&mm->nodes, typeof(*heap), nl_entry);
240 int nodes = 0;
241
242 list_for_each_entry(node, &mm->nodes, nl_entry) {
243 if (WARN_ON(nodes++ == mm->heap_nodes))
244 return -EBUSY;
245 }
240 246
241 list_for_each_entry(node, &mm->nodes, nl_entry) { 247 kfree(heap);
242 if (WARN_ON(nodes++ == mm->heap_nodes))
243 return -EBUSY;
244 } 248 }
245 249
246 kfree(heap);
247 return 0; 250 return 0;
248} 251}
diff --git a/drivers/gpu/drm/nouveau/core/include/core/mm.h b/drivers/gpu/drm/nouveau/core/include/core/mm.h
index 975137ba34a6..2514e81ade02 100644
--- a/drivers/gpu/drm/nouveau/core/include/core/mm.h
+++ b/drivers/gpu/drm/nouveau/core/include/core/mm.h
@@ -21,6 +21,12 @@ struct nouveau_mm {
21 int heap_nodes; 21 int heap_nodes;
22}; 22};
23 23
24static inline bool
25nouveau_mm_initialised(struct nouveau_mm *mm)
26{
27 return mm->block_size != 0;
28}
29
24int nouveau_mm_init(struct nouveau_mm *, u32 offset, u32 length, u32 block); 30int nouveau_mm_init(struct nouveau_mm *, u32 offset, u32 length, u32 block);
25int nouveau_mm_fini(struct nouveau_mm *); 31int nouveau_mm_fini(struct nouveau_mm *);
26int nouveau_mm_head(struct nouveau_mm *, u8 type, u32 size_max, u32 size_min, 32int nouveau_mm_head(struct nouveau_mm *, u8 type, u32 size_max, u32 size_min,
diff --git a/drivers/gpu/drm/nouveau/core/subdev/fb/base.c b/drivers/gpu/drm/nouveau/core/subdev/fb/base.c
index f0086de8af31..9fae64d60954 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/fb/base.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/fb/base.c
@@ -85,12 +85,8 @@ nouveau_fb_destroy(struct nouveau_fb *pfb)
85 85
86 for (i = 0; i < pfb->tile.regions; i++) 86 for (i = 0; i < pfb->tile.regions; i++)
87 pfb->tile.fini(pfb, i, &pfb->tile.region[i]); 87 pfb->tile.fini(pfb, i, &pfb->tile.region[i]);
88 88 nouveau_mm_fini(&pfb->tags);
89 if (pfb->tags.block_size) 89 nouveau_mm_fini(&pfb->vram);
90 nouveau_mm_fini(&pfb->tags);
91
92 if (pfb->vram.block_size)
93 nouveau_mm_fini(&pfb->vram);
94 90
95 nouveau_subdev_destroy(&pfb->base); 91 nouveau_subdev_destroy(&pfb->base);
96} 92}