diff options
-rw-r--r-- | drivers/gpu/drm/Makefile | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_drawable.c | 197 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_drv.c | 8 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_stub.c | 3 | ||||
-rw-r--r-- | include/drm/drmP.h | 15 |
5 files changed, 4 insertions, 221 deletions
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index f3a23a329f4e..997c43d04909 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile | |||
@@ -5,7 +5,7 @@ | |||
5 | ccflags-y := -Iinclude/drm | 5 | ccflags-y := -Iinclude/drm |
6 | 6 | ||
7 | drm-y := drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \ | 7 | drm-y := drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \ |
8 | drm_context.o drm_dma.o drm_drawable.o \ | 8 | drm_context.o drm_dma.o \ |
9 | drm_drv.o drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \ | 9 | drm_drv.o drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \ |
10 | drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \ | 10 | drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \ |
11 | drm_agpsupport.o drm_scatter.o ati_pcigart.o drm_pci.o \ | 11 | drm_agpsupport.o drm_scatter.o ati_pcigart.o drm_pci.o \ |
diff --git a/drivers/gpu/drm/drm_drawable.c b/drivers/gpu/drm/drm_drawable.c deleted file mode 100644 index 170e53178d8b..000000000000 --- a/drivers/gpu/drm/drm_drawable.c +++ /dev/null | |||
@@ -1,197 +0,0 @@ | |||
1 | /** | ||
2 | * \file drm_drawable.c | ||
3 | * IOCTLs for drawables | ||
4 | * | ||
5 | * \author Rickard E. (Rik) Faith <faith@valinux.com> | ||
6 | * \author Gareth Hughes <gareth@valinux.com> | ||
7 | * \author Michel Dänzer <michel@tungstengraphics.com> | ||
8 | */ | ||
9 | |||
10 | /* | ||
11 | * Created: Tue Feb 2 08:37:54 1999 by faith@valinux.com | ||
12 | * | ||
13 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. | ||
14 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. | ||
15 | * Copyright 2006 Tungsten Graphics, Inc., Bismarck, North Dakota. | ||
16 | * All Rights Reserved. | ||
17 | * | ||
18 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
19 | * copy of this software and associated documentation files (the "Software"), | ||
20 | * to deal in the Software without restriction, including without limitation | ||
21 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
22 | * and/or sell copies of the Software, and to permit persons to whom the | ||
23 | * Software is furnished to do so, subject to the following conditions: | ||
24 | * | ||
25 | * The above copyright notice and this permission notice (including the next | ||
26 | * paragraph) shall be included in all copies or substantial portions of the | ||
27 | * Software. | ||
28 | * | ||
29 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
30 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
31 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
32 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
33 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
34 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
35 | * OTHER DEALINGS IN THE SOFTWARE. | ||
36 | */ | ||
37 | |||
38 | #include "drmP.h" | ||
39 | |||
40 | /** | ||
41 | * Allocate drawable ID and memory to store information about it. | ||
42 | */ | ||
43 | int drm_adddraw(struct drm_device *dev, void *data, struct drm_file *file_priv) | ||
44 | { | ||
45 | unsigned long irqflags; | ||
46 | struct drm_draw *draw = data; | ||
47 | int new_id = 0; | ||
48 | int ret; | ||
49 | |||
50 | again: | ||
51 | if (idr_pre_get(&dev->drw_idr, GFP_KERNEL) == 0) { | ||
52 | DRM_ERROR("Out of memory expanding drawable idr\n"); | ||
53 | return -ENOMEM; | ||
54 | } | ||
55 | |||
56 | spin_lock_irqsave(&dev->drw_lock, irqflags); | ||
57 | ret = idr_get_new_above(&dev->drw_idr, NULL, 1, &new_id); | ||
58 | if (ret == -EAGAIN) { | ||
59 | spin_unlock_irqrestore(&dev->drw_lock, irqflags); | ||
60 | goto again; | ||
61 | } | ||
62 | |||
63 | spin_unlock_irqrestore(&dev->drw_lock, irqflags); | ||
64 | |||
65 | draw->handle = new_id; | ||
66 | |||
67 | DRM_DEBUG("%d\n", draw->handle); | ||
68 | |||
69 | return 0; | ||
70 | } | ||
71 | |||
72 | /** | ||
73 | * Free drawable ID and memory to store information about it. | ||
74 | */ | ||
75 | int drm_rmdraw(struct drm_device *dev, void *data, struct drm_file *file_priv) | ||
76 | { | ||
77 | struct drm_draw *draw = data; | ||
78 | unsigned long irqflags; | ||
79 | struct drm_drawable_info *info; | ||
80 | |||
81 | spin_lock_irqsave(&dev->drw_lock, irqflags); | ||
82 | |||
83 | info = drm_get_drawable_info(dev, draw->handle); | ||
84 | if (info == NULL) { | ||
85 | spin_unlock_irqrestore(&dev->drw_lock, irqflags); | ||
86 | return -EINVAL; | ||
87 | } | ||
88 | kfree(info->rects); | ||
89 | kfree(info); | ||
90 | |||
91 | idr_remove(&dev->drw_idr, draw->handle); | ||
92 | |||
93 | spin_unlock_irqrestore(&dev->drw_lock, irqflags); | ||
94 | DRM_DEBUG("%d\n", draw->handle); | ||
95 | return 0; | ||
96 | } | ||
97 | |||
98 | int drm_update_drawable_info(struct drm_device *dev, void *data, struct drm_file *file_priv) | ||
99 | { | ||
100 | struct drm_update_draw *update = data; | ||
101 | unsigned long irqflags; | ||
102 | struct drm_clip_rect *rects; | ||
103 | struct drm_drawable_info *info; | ||
104 | int err; | ||
105 | |||
106 | info = idr_find(&dev->drw_idr, update->handle); | ||
107 | if (!info) { | ||
108 | info = kzalloc(sizeof(*info), GFP_KERNEL); | ||
109 | if (!info) | ||
110 | return -ENOMEM; | ||
111 | if (IS_ERR(idr_replace(&dev->drw_idr, info, update->handle))) { | ||
112 | DRM_ERROR("No such drawable %d\n", update->handle); | ||
113 | kfree(info); | ||
114 | return -EINVAL; | ||
115 | } | ||
116 | } | ||
117 | |||
118 | switch (update->type) { | ||
119 | case DRM_DRAWABLE_CLIPRECTS: | ||
120 | if (update->num == 0) | ||
121 | rects = NULL; | ||
122 | else if (update->num != info->num_rects) { | ||
123 | rects = kmalloc(update->num * | ||
124 | sizeof(struct drm_clip_rect), | ||
125 | GFP_KERNEL); | ||
126 | } else | ||
127 | rects = info->rects; | ||
128 | |||
129 | if (update->num && !rects) { | ||
130 | DRM_ERROR("Failed to allocate cliprect memory\n"); | ||
131 | err = -ENOMEM; | ||
132 | goto error; | ||
133 | } | ||
134 | |||
135 | if (update->num && DRM_COPY_FROM_USER(rects, | ||
136 | (struct drm_clip_rect __user *) | ||
137 | (unsigned long)update->data, | ||
138 | update->num * | ||
139 | sizeof(*rects))) { | ||
140 | DRM_ERROR("Failed to copy cliprects from userspace\n"); | ||
141 | err = -EFAULT; | ||
142 | goto error; | ||
143 | } | ||
144 | |||
145 | spin_lock_irqsave(&dev->drw_lock, irqflags); | ||
146 | |||
147 | if (rects != info->rects) { | ||
148 | kfree(info->rects); | ||
149 | } | ||
150 | |||
151 | info->rects = rects; | ||
152 | info->num_rects = update->num; | ||
153 | |||
154 | spin_unlock_irqrestore(&dev->drw_lock, irqflags); | ||
155 | |||
156 | DRM_DEBUG("Updated %d cliprects for drawable %d\n", | ||
157 | info->num_rects, update->handle); | ||
158 | break; | ||
159 | default: | ||
160 | DRM_ERROR("Invalid update type %d\n", update->type); | ||
161 | return -EINVAL; | ||
162 | } | ||
163 | |||
164 | return 0; | ||
165 | |||
166 | error: | ||
167 | if (rects != info->rects) | ||
168 | kfree(rects); | ||
169 | |||
170 | return err; | ||
171 | } | ||
172 | |||
173 | /** | ||
174 | * Caller must hold the drawable spinlock! | ||
175 | */ | ||
176 | static struct drm_drawable_info *drm_get_drawable_info(struct drm_device *dev, drm_drawable_t id) | ||
177 | { | ||
178 | return idr_find(&dev->drw_idr, id); | ||
179 | } | ||
180 | |||
181 | static int drm_drawable_free(int idr, void *p, void *data) | ||
182 | { | ||
183 | struct drm_drawable_info *info = p; | ||
184 | |||
185 | if (info) { | ||
186 | kfree(info->rects); | ||
187 | kfree(info); | ||
188 | } | ||
189 | |||
190 | return 0; | ||
191 | } | ||
192 | |||
193 | void drm_drawable_free_all(struct drm_device *dev) | ||
194 | { | ||
195 | idr_for_each(&dev->drw_idr, drm_drawable_free, NULL); | ||
196 | idr_remove_all(&dev->drw_idr); | ||
197 | } | ||
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 84da748555bc..a35a41002c33 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c | |||
@@ -91,8 +91,8 @@ static struct drm_ioctl_desc drm_ioctls[] = { | |||
91 | DRM_IOCTL_DEF(DRM_IOCTL_NEW_CTX, drm_newctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), | 91 | DRM_IOCTL_DEF(DRM_IOCTL_NEW_CTX, drm_newctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
92 | DRM_IOCTL_DEF(DRM_IOCTL_RES_CTX, drm_resctx, DRM_AUTH), | 92 | DRM_IOCTL_DEF(DRM_IOCTL_RES_CTX, drm_resctx, DRM_AUTH), |
93 | 93 | ||
94 | DRM_IOCTL_DEF(DRM_IOCTL_ADD_DRAW, drm_adddraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), | 94 | DRM_IOCTL_DEF(DRM_IOCTL_ADD_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
95 | DRM_IOCTL_DEF(DRM_IOCTL_RM_DRAW, drm_rmdraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), | 95 | DRM_IOCTL_DEF(DRM_IOCTL_RM_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
96 | 96 | ||
97 | DRM_IOCTL_DEF(DRM_IOCTL_LOCK, drm_lock, DRM_AUTH), | 97 | DRM_IOCTL_DEF(DRM_IOCTL_LOCK, drm_lock, DRM_AUTH), |
98 | DRM_IOCTL_DEF(DRM_IOCTL_UNLOCK, drm_unlock, DRM_AUTH), | 98 | DRM_IOCTL_DEF(DRM_IOCTL_UNLOCK, drm_unlock, DRM_AUTH), |
@@ -127,7 +127,7 @@ static struct drm_ioctl_desc drm_ioctls[] = { | |||
127 | 127 | ||
128 | DRM_IOCTL_DEF(DRM_IOCTL_MODESET_CTL, drm_modeset_ctl, 0), | 128 | DRM_IOCTL_DEF(DRM_IOCTL_MODESET_CTL, drm_modeset_ctl, 0), |
129 | 129 | ||
130 | DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_update_drawable_info, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), | 130 | DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
131 | 131 | ||
132 | DRM_IOCTL_DEF(DRM_IOCTL_GEM_CLOSE, drm_gem_close_ioctl, DRM_UNLOCKED), | 132 | DRM_IOCTL_DEF(DRM_IOCTL_GEM_CLOSE, drm_gem_close_ioctl, DRM_UNLOCKED), |
133 | DRM_IOCTL_DEF(DRM_IOCTL_GEM_FLINK, drm_gem_flink_ioctl, DRM_AUTH|DRM_UNLOCKED), | 133 | DRM_IOCTL_DEF(DRM_IOCTL_GEM_FLINK, drm_gem_flink_ioctl, DRM_AUTH|DRM_UNLOCKED), |
@@ -180,8 +180,6 @@ int drm_lastclose(struct drm_device * dev) | |||
180 | 180 | ||
181 | mutex_lock(&dev->struct_mutex); | 181 | mutex_lock(&dev->struct_mutex); |
182 | 182 | ||
183 | /* Free drawable information memory */ | ||
184 | drm_drawable_free_all(dev); | ||
185 | del_timer(&dev->timer); | 183 | del_timer(&dev->timer); |
186 | 184 | ||
187 | /* Clear AGP information */ | 185 | /* Clear AGP information */ |
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index d1ad57450df1..f797ae9da77c 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c | |||
@@ -240,14 +240,11 @@ int drm_fill_in_dev(struct drm_device *dev, | |||
240 | INIT_LIST_HEAD(&dev->vblank_event_list); | 240 | INIT_LIST_HEAD(&dev->vblank_event_list); |
241 | 241 | ||
242 | spin_lock_init(&dev->count_lock); | 242 | spin_lock_init(&dev->count_lock); |
243 | spin_lock_init(&dev->drw_lock); | ||
244 | spin_lock_init(&dev->event_lock); | 243 | spin_lock_init(&dev->event_lock); |
245 | init_timer(&dev->timer); | 244 | init_timer(&dev->timer); |
246 | mutex_init(&dev->struct_mutex); | 245 | mutex_init(&dev->struct_mutex); |
247 | mutex_init(&dev->ctxlist_mutex); | 246 | mutex_init(&dev->ctxlist_mutex); |
248 | 247 | ||
249 | idr_init(&dev->drw_idr); | ||
250 | |||
251 | if (drm_ht_create(&dev->map_hash, 12)) { | 248 | if (drm_ht_create(&dev->map_hash, 12)) { |
252 | return -ENOMEM; | 249 | return -ENOMEM; |
253 | } | 250 | } |
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 45d09639e9d2..989cefe33c7b 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h | |||
@@ -1037,12 +1037,6 @@ struct drm_device { | |||
1037 | struct drm_minor *control; /**< Control node for card */ | 1037 | struct drm_minor *control; /**< Control node for card */ |
1038 | struct drm_minor *primary; /**< render type primary screen head */ | 1038 | struct drm_minor *primary; /**< render type primary screen head */ |
1039 | 1039 | ||
1040 | /** \name Drawable information */ | ||
1041 | /*@{ */ | ||
1042 | spinlock_t drw_lock; | ||
1043 | struct idr drw_idr; | ||
1044 | /*@} */ | ||
1045 | |||
1046 | struct drm_mode_config mode_config; /**< Current mode config */ | 1040 | struct drm_mode_config mode_config; /**< Current mode config */ |
1047 | 1041 | ||
1048 | /** \name GEM information */ | 1042 | /** \name GEM information */ |
@@ -1229,15 +1223,6 @@ extern int drm_setsareactx(struct drm_device *dev, void *data, | |||
1229 | extern int drm_getsareactx(struct drm_device *dev, void *data, | 1223 | extern int drm_getsareactx(struct drm_device *dev, void *data, |
1230 | struct drm_file *file_priv); | 1224 | struct drm_file *file_priv); |
1231 | 1225 | ||
1232 | /* Drawable IOCTL support (drm_drawable.h) */ | ||
1233 | extern int drm_adddraw(struct drm_device *dev, void *data, | ||
1234 | struct drm_file *file_priv); | ||
1235 | extern int drm_rmdraw(struct drm_device *dev, void *data, | ||
1236 | struct drm_file *file_priv); | ||
1237 | extern int drm_update_drawable_info(struct drm_device *dev, void *data, | ||
1238 | struct drm_file *file_priv); | ||
1239 | extern void drm_drawable_free_all(struct drm_device *dev); | ||
1240 | |||
1241 | /* Authentication IOCTL support (drm_auth.h) */ | 1226 | /* Authentication IOCTL support (drm_auth.h) */ |
1242 | extern int drm_getmagic(struct drm_device *dev, void *data, | 1227 | extern int drm_getmagic(struct drm_device *dev, void *data, |
1243 | struct drm_file *file_priv); | 1228 | struct drm_file *file_priv); |