aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_drv.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2008-11-27 23:22:24 -0500
committerDave Airlie <airlied@linux.ie>2008-12-29 02:47:22 -0500
commit7c1c2871a6a3a114853ec6836e9035ac1c0c7f7a (patch)
tree1b5debcc86ff20bd5e11b42ea5c52da42214e376 /drivers/gpu/drm/drm_drv.c
parente7f7ab45ebcb54fd5f814ea15ea079e079662f67 (diff)
drm: move to kref per-master structures.
This is step one towards having multiple masters sharing a drm device in order to get fast-user-switching to work. It splits out the information associated with the drm master into a separate kref counted structure, and allocates this when a master opens the device node. It also allows the current master to abdicate (say while VT switched), and a new master to take over the hardware. It moves the Intel and radeon drivers to using the sarea from within the new master structures. Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/drm_drv.c')
-rw-r--r--drivers/gpu/drm/drm_drv.c33
1 files changed, 3 insertions, 30 deletions
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 3cb87a932b33..9f04ca37df6d 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -74,6 +74,9 @@ static struct drm_ioctl_desc drm_ioctls[] = {
74 DRM_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), 74 DRM_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
75 DRM_IOCTL_DEF(DRM_IOCTL_GET_SAREA_CTX, drm_getsareactx, DRM_AUTH), 75 DRM_IOCTL_DEF(DRM_IOCTL_GET_SAREA_CTX, drm_getsareactx, DRM_AUTH),
76 76
77 DRM_IOCTL_DEF(DRM_IOCTL_SET_MASTER, drm_setmaster_ioctl, DRM_ROOT_ONLY),
78 DRM_IOCTL_DEF(DRM_IOCTL_DROP_MASTER, drm_dropmaster_ioctl, DRM_ROOT_ONLY),
79
77 DRM_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_addctx, DRM_AUTH|DRM_ROOT_ONLY), 80 DRM_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_addctx, DRM_AUTH|DRM_ROOT_ONLY),
78 DRM_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), 81 DRM_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
79 DRM_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_modctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), 82 DRM_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_modctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
@@ -138,8 +141,6 @@ static struct drm_ioctl_desc drm_ioctls[] = {
138 */ 141 */
139int drm_lastclose(struct drm_device * dev) 142int drm_lastclose(struct drm_device * dev)
140{ 143{
141 struct drm_magic_entry *pt, *next;
142 struct drm_map_list *r_list, *list_t;
143 struct drm_vma_entry *vma, *vma_temp; 144 struct drm_vma_entry *vma, *vma_temp;
144 int i; 145 int i;
145 146
@@ -149,12 +150,6 @@ int drm_lastclose(struct drm_device * dev)
149 dev->driver->lastclose(dev); 150 dev->driver->lastclose(dev);
150 DRM_DEBUG("driver lastclose completed\n"); 151 DRM_DEBUG("driver lastclose completed\n");
151 152
152 if (dev->unique) {
153 drm_free(dev->unique, strlen(dev->unique) + 1, DRM_MEM_DRIVER);
154 dev->unique = NULL;
155 dev->unique_len = 0;
156 }
157
158 if (dev->irq_enabled) 153 if (dev->irq_enabled)
159 drm_irq_uninstall(dev); 154 drm_irq_uninstall(dev);
160 155
@@ -164,16 +159,6 @@ int drm_lastclose(struct drm_device * dev)
164 drm_drawable_free_all(dev); 159 drm_drawable_free_all(dev);
165 del_timer(&dev->timer); 160 del_timer(&dev->timer);
166 161
167 /* Clear pid list */
168 if (dev->magicfree.next) {
169 list_for_each_entry_safe(pt, next, &dev->magicfree, head) {
170 list_del(&pt->head);
171 drm_ht_remove_item(&dev->magiclist, &pt->hash_item);
172 drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
173 }
174 drm_ht_remove(&dev->magiclist);
175 }
176
177 /* Clear AGP information */ 162 /* Clear AGP information */
178 if (drm_core_has_AGP(dev) && dev->agp) { 163 if (drm_core_has_AGP(dev) && dev->agp) {
179 struct drm_agp_mem *entry, *tempe; 164 struct drm_agp_mem *entry, *tempe;
@@ -205,13 +190,6 @@ int drm_lastclose(struct drm_device * dev)
205 drm_free(vma, sizeof(*vma), DRM_MEM_VMAS); 190 drm_free(vma, sizeof(*vma), DRM_MEM_VMAS);
206 } 191 }
207 192
208 list_for_each_entry_safe(r_list, list_t, &dev->maplist, head) {
209 if (!(r_list->map->flags & _DRM_DRIVER)) {
210 drm_rmmap_locked(dev, r_list->map);
211 r_list = NULL;
212 }
213 }
214
215 if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist) { 193 if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist) {
216 for (i = 0; i < dev->queue_count; i++) { 194 for (i = 0; i < dev->queue_count; i++) {
217 if (dev->queuelist[i]) { 195 if (dev->queuelist[i]) {
@@ -231,11 +209,6 @@ int drm_lastclose(struct drm_device * dev)
231 if (drm_core_check_feature(dev, DRIVER_HAVE_DMA)) 209 if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
232 drm_dma_takedown(dev); 210 drm_dma_takedown(dev);
233 211
234 if (dev->lock.hw_lock) {
235 dev->sigdata.lock = dev->lock.hw_lock = NULL; /* SHM removed */
236 dev->lock.file_priv = NULL;
237 wake_up_interruptible(&dev->lock.lock_queue);
238 }
239 mutex_unlock(&dev->struct_mutex); 212 mutex_unlock(&dev->struct_mutex);
240 213
241 DRM_DEBUG("lastclose completed\n"); 214 DRM_DEBUG("lastclose completed\n");