summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2009-04-06 04:22:00 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2009-04-06 04:22:00 +0000
commit8152cd1e1ffc808cc5909283b8f891aea8148e32 (patch)
tree62f3b2a78ccae79576e5b8ec21842e2cd59a5f2e /sys/dev
parente5078ad265ba231e31297ed54d37eed20ebe8da1 (diff)
merge radeon_mem_release() and radeon_mem_takedown() into the drm_heap
interface as drm_mem_release() and drm_mem_takedown() respectively. While this interface's days are numbered, I'm about to make another driver use it to remove even worse code. Roll on memory management...
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/drm/drmP.h14
-rw-r--r--sys/dev/pci/drm/drm_heap.c49
-rw-r--r--sys/dev/pci/drm/radeon_cp.c4
-rw-r--r--sys/dev/pci/drm/radeon_drv.h4
-rw-r--r--sys/dev/pci/drm/radeon_mem.c43
-rw-r--r--sys/dev/pci/drm/radeon_state.c4
6 files changed, 60 insertions, 58 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h
index 1c5969dfa8c..45af2b7fec9 100644
--- a/sys/dev/pci/drm/drmP.h
+++ b/sys/dev/pci/drm/drmP.h
@@ -481,12 +481,14 @@ int drm_mtrr_add(unsigned long, size_t, int);
int drm_mtrr_del(int, unsigned long, size_t, int);
/* Heap interface (DEPRECATED) */
-int drm_init_heap(struct drm_heap *, int, int);
-struct drm_mem *
- drm_alloc_block(struct drm_heap *, int, int, struct drm_file *);
-struct drm_mem *
- drm_find_block(struct drm_heap *, int);
-void drm_free_block(struct drm_heap *, struct drm_mem *);
+int drm_init_heap(struct drm_heap *, int, int);
+struct drm_mem *drm_alloc_block(struct drm_heap *, int, int,
+ struct drm_file *);
+struct drm_mem *drm_find_block(struct drm_heap *, int);
+void drm_free_block(struct drm_heap *, struct drm_mem *);
+void drm_mem_release(struct drm_heap *, struct drm_file *);
+void drm_mem_takedown(struct drm_heap *);
+
int drm_ctxbitmap_init(struct drm_device *);
diff --git a/sys/dev/pci/drm/drm_heap.c b/sys/dev/pci/drm/drm_heap.c
index 0a62863b2c8..92d42036af4 100644
--- a/sys/dev/pci/drm/drm_heap.c
+++ b/sys/dev/pci/drm/drm_heap.c
@@ -124,7 +124,8 @@ drm_free_block(struct drm_heap *heap, struct drm_mem *p)
}
}
-/* Initialize.
+/*
+ * Initialize.
*/
int
drm_init_heap(struct drm_heap *heap, int start, int size)
@@ -144,3 +145,49 @@ drm_init_heap(struct drm_heap *heap, int start, int size)
return (0);
}
+
+/*
+ * Free all blocks associated with the releasing file.
+ */
+void
+drm_mem_release(struct drm_heap *heap, struct drm_file *file_priv)
+{
+ struct drm_mem *p, *q;
+
+ if (heap == NULL || TAILQ_EMPTY(heap))
+ return;
+
+ TAILQ_FOREACH(p, heap, link) {
+ if (p->file_priv == file_priv)
+ p->file_priv = NULL;
+ }
+
+ /* Coalesce the entries. ugh... */
+ for (p = TAILQ_FIRST(heap); p != TAILQ_END(heap); p = q) {
+ while (p->file_priv == NULL &&
+ (q = TAILQ_NEXT(p, link)) != TAILQ_END(heap) &&
+ q->file_priv == NULL) {
+ p->size += q->size;
+ TAILQ_REMOVE(heap, q, link);
+ drm_free(q);
+ }
+ q = TAILQ_NEXT(p, link);
+ }
+}
+
+/*
+ * Shutdown the heap.
+ */
+void
+drm_mem_takedown(struct drm_heap *heap)
+{
+ struct drm_mem *p;
+
+ if (heap == NULL)
+ return;
+
+ while ((p = TAILQ_FIRST(heap)) != NULL) {
+ TAILQ_REMOVE(heap, p, link);
+ drm_free(p);
+ }
+}
diff --git a/sys/dev/pci/drm/radeon_cp.c b/sys/dev/pci/drm/radeon_cp.c
index e62cef3afa3..501c9345ac1 100644
--- a/sys/dev/pci/drm/radeon_cp.c
+++ b/sys/dev/pci/drm/radeon_cp.c
@@ -1387,8 +1387,8 @@ radeon_driver_lastclose(struct drm_device *dev)
}
/* Free memory heap structures */
- radeon_mem_takedown(&(dev_priv->gart_heap));
- radeon_mem_takedown(&(dev_priv->fb_heap));
+ drm_mem_takedown(&dev_priv->gart_heap);
+ drm_mem_takedown(&dev_priv->fb_heap);
/* deallocate kernel resources */
radeon_do_cleanup_cp(dev);
diff --git a/sys/dev/pci/drm/radeon_drv.h b/sys/dev/pci/drm/radeon_drv.h
index c13084a761e..8b18cf049a7 100644
--- a/sys/dev/pci/drm/radeon_drv.h
+++ b/sys/dev/pci/drm/radeon_drv.h
@@ -366,8 +366,6 @@ extern int radeon_do_cp_idle(drm_radeon_private_t * dev_priv);
extern int radeon_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv);
extern int radeon_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv);
extern int radeon_mem_init_heap(struct drm_device *dev, void *data, struct drm_file *file_priv);
-extern void radeon_mem_takedown(struct drm_heap *heap);
-extern void radeon_mem_release(struct drm_file *, struct drm_heap *);
/* radeon_irq.c */
extern void radeon_irq_set_state(struct drm_device *dev, u32 mask, int state);
@@ -386,8 +384,6 @@ extern void radeon_driver_close(struct drm_device * dev,
extern void radeon_driver_lastclose(struct drm_device * dev);
extern int radeon_driver_open(struct drm_device * dev,
struct drm_file * file_priv);
-extern long radeon_compat_ioctl(struct file *filp, unsigned int cmd,
- unsigned long arg);
/* r300_cmdbuf.c */
extern void r300_init_reg_flags(struct drm_device *dev);
diff --git a/sys/dev/pci/drm/radeon_mem.c b/sys/dev/pci/drm/radeon_mem.c
index d095959bde7..ba1cbf44193 100644
--- a/sys/dev/pci/drm/radeon_mem.c
+++ b/sys/dev/pci/drm/radeon_mem.c
@@ -35,49 +35,6 @@
struct drm_heap *radeon_get_heap(drm_radeon_private_t *, int);
-/* Free all blocks associated with the releasing file.
- */
-void
-radeon_mem_release(struct drm_file *file_priv, struct drm_heap *heap)
-{
- struct drm_mem *p, *q;
-
- if (heap == NULL || TAILQ_EMPTY(heap))
- return;
-
- TAILQ_FOREACH(p, heap, link) {
- if (p->file_priv == file_priv)
- p->file_priv = NULL;
- }
-
- /* Coalesce the entries. ugh... */
- for (p = TAILQ_FIRST(heap); p != TAILQ_END(heap); p = q) {
- while (p->file_priv == NULL &&
- (q = TAILQ_NEXT(p, link)) != TAILQ_END(heap) &&
- q->file_priv == NULL) {
- p->size += q->size;
- TAILQ_REMOVE(heap, q, link);
- drm_free(q);
- }
- q = TAILQ_NEXT(p, link);
- }
-}
-
-/* Shutdown.
- */
-void
-radeon_mem_takedown(struct drm_heap *heap)
-{
- struct drm_mem *p;
-
- if (heap == NULL)
- return;
-
- while ((p = TAILQ_FIRST(heap)) != NULL) {
- TAILQ_REMOVE(heap, p, link);
- drm_free(p);
- }
-}
/* IOCTL HANDLERS */
diff --git a/sys/dev/pci/drm/radeon_state.c b/sys/dev/pci/drm/radeon_state.c
index 1a70c8b7f51..dbd1ea6a8dd 100644
--- a/sys/dev/pci/drm/radeon_state.c
+++ b/sys/dev/pci/drm/radeon_state.c
@@ -2487,8 +2487,8 @@ radeon_driver_close(struct drm_device *dev, struct drm_file *file_priv)
drm_radeon_private_t *dev_priv = dev->dev_private;
dev_priv->page_flipping = 0;
- radeon_mem_release(file_priv, &dev_priv->gart_heap);
- radeon_mem_release(file_priv, &dev_priv->fb_heap);
+ drm_mem_release(&dev_priv->gart_heap, file_priv);
+ drm_mem_release(&dev_priv->fb_heap, file_priv);
if (dev_priv->cp_running)
radeon_surfaces_release(file_priv, dev_priv);
}