summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Dänzer <michel@tungstengraphics.com>2006-08-23 16:04:41 +0200
committerMichel Dänzer <michel@tungstengraphics.com>2006-09-29 12:55:08 +0200
commitbaa26c5faa3d5903569d1c94ad93b843d6979ba5 (patch)
treed7b354f78e40318f2e7b44b4b428a8d2a082f395
parent9810ec2737de6aa81e764225f580e4ea39de437a (diff)
Only reallocate cliprect memory if the number of cliprects changes.
Also improve diagnostic output. (cherry picked from af48be1096221d551319c67a9e782b50ef58fefd commit)
-rw-r--r--shared-core/drm_drawable.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/shared-core/drm_drawable.c b/shared-core/drm_drawable.c
index ca6eb81c..511f3eae 100644
--- a/shared-core/drm_drawable.c
+++ b/shared-core/drm_drawable.c
@@ -166,6 +166,7 @@ int drm_rmdraw(DRM_IOCTL_ARGS)
spin_unlock_irqrestore(&dev->drw_lock, irqflags);
+ DRM_DEBUG("%d\n", draw.handle);
return 0;
}
@@ -209,30 +210,42 @@ int drm_update_drawable_info(DRM_IOCTL_ARGS) {
switch (update.type) {
case DRM_DRAWABLE_CLIPRECTS:
- new_data = drm_alloc(update.num * sizeof(drm_clip_rect_t),
- DRM_MEM_BUFS);
+ if (update.num != info->num_rects) {
+ new_data = drm_alloc(update.num *
+ sizeof(drm_clip_rect_t),
+ DRM_MEM_BUFS);
- if (!new_data) {
- DRM_ERROR("Failed to allocate cliprect memory\n");
- spin_unlock_irqrestore(&dev->drw_lock, irqflags);
- return DRM_ERR(ENOMEM);
+ if (!new_data) {
+ DRM_ERROR("Can't allocate cliprect memory\n");
+ spin_unlock_irqrestore(&dev->drw_lock, irqflags);
+ return DRM_ERR(ENOMEM);
+ }
+
+ info->rects = new_data;
}
- if (DRM_COPY_FROM_USER(new_data,
+ if (DRM_COPY_FROM_USER(info->rects,
(drm_clip_rect_t __user *)
(unsigned long)update.data,
update.num * sizeof(drm_clip_rect_t))) {
- DRM_ERROR("Failed to copy cliprects from userspace\n");
+ DRM_ERROR("Can't copy cliprects from userspace\n");
spin_unlock_irqrestore(&dev->drw_lock, irqflags);
return DRM_ERR(EFAULT);
}
- drm_free(info->rects, info->num_rects * sizeof(drm_clip_rect_t),
- DRM_MEM_BUFS);
+ if (update.num != info->num_rects) {
+ drm_free(info->rects, info->num_rects *
+ sizeof(drm_clip_rect_t), DRM_MEM_BUFS);
+ info->num_rects = update.num;
+ }
- info->rects = new_data;
- info->num_rects = update.num;
+ DRM_DEBUG("Updated %d cliprects for drawable %d\n",
+ info->num_rects, id);
break;
+ default:
+ DRM_ERROR("Invalid update type %d\n", update.type);
+ spin_unlock_irqrestore(&dev->drw_lock, irqflags);
+ return DRM_ERR(EINVAL);
}
spin_unlock_irqrestore(&dev->drw_lock, irqflags);