summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Noland <rnoland@2hip.net>2008-08-22 21:45:41 -0400
committerRobert Noland <rnoland@2hip.net>2008-08-24 15:25:20 -0400
commitbfea578352aaaed08555e86c9951b3932f39d122 (patch)
tree495d237b5ebcde71dcde76c4083c789d84392eed
parent0687c0a4ec78730f752cee04a5b0862f47dbf026 (diff)
[FreeBSD] Add drm_drawable_free_all()
-rw-r--r--bsd-core/drmP.h3
-rw-r--r--bsd-core/drm_drawable.c19
-rw-r--r--bsd-core/drm_drv.c2
3 files changed, 24 insertions, 0 deletions
diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h
index 473427f3..74487e55 100644
--- a/bsd-core/drmP.h
+++ b/bsd-core/drmP.h
@@ -1031,6 +1031,9 @@ int drm_update_draw(struct drm_device *dev, void *data,
struct drm_drawable_info *drm_get_drawable_info(struct drm_device *dev,
int handle);
+/* Drawable support (drm_drawable.c) */
+void drm_drawable_free_all(struct drm_device *dev);
+
/* Authentication IOCTL support (drm_auth.c) */
int drm_getmagic(struct drm_device *dev, void *data,
struct drm_file *file_priv);
diff --git a/bsd-core/drm_drawable.c b/bsd-core/drm_drawable.c
index 268b956c..1d85cb45 100644
--- a/bsd-core/drm_drawable.c
+++ b/bsd-core/drm_drawable.c
@@ -151,3 +151,22 @@ int drm_update_draw(struct drm_device *dev, void *data,
return EINVAL;
}
}
+
+void drm_drawable_free_all(struct drm_device *dev)
+{
+ struct bsd_drm_drawable_info *info, *next;
+
+ DRM_SPINLOCK(&dev->drw_lock);
+ for (info = RB_MIN(drawable_tree, &dev->drw_head);
+ info != NULL ; info = next) {
+ next = RB_NEXT(drawable_tree, &dev->drw_head, info);
+ RB_REMOVE(drawable_tree, &dev->drw_head,
+ (struct bsd_drm_drawable_info *)info);
+ DRM_SPINUNLOCK(&dev->drw_lock);
+ free_unr(dev->drw_unrhdr, info->handle);
+ drm_free(info, sizeof(struct bsd_drm_drawable_info),
+ DRM_MEM_DRAWABLE);
+ DRM_SPINLOCK(&dev->drw_lock);
+ }
+ DRM_SPINUNLOCK(&dev->drw_lock);
+}
diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c
index d369af4c..32b284e1 100644
--- a/bsd-core/drm_drv.c
+++ b/bsd-core/drm_drv.c
@@ -460,6 +460,8 @@ static int drm_lastclose(struct drm_device *dev)
dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
}
+ drm_drawable_free_all(dev);
+
/* Clear AGP information */
if ( dev->agp ) {
drm_agp_mem_t *entry;