diff options
Diffstat (limited to 'drivers/gpu/drm/drm_stub.c')
-rw-r--r-- | drivers/gpu/drm/drm_stub.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index d009661781bc..b9631e3a1ea6 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c | |||
@@ -159,6 +159,9 @@ void drm_master_put(struct drm_master **master) | |||
159 | int drm_setmaster_ioctl(struct drm_device *dev, void *data, | 159 | int drm_setmaster_ioctl(struct drm_device *dev, void *data, |
160 | struct drm_file *file_priv) | 160 | struct drm_file *file_priv) |
161 | { | 161 | { |
162 | if (file_priv->is_master) | ||
163 | return 0; | ||
164 | |||
162 | if (file_priv->minor->master && file_priv->minor->master != file_priv->master) | 165 | if (file_priv->minor->master && file_priv->minor->master != file_priv->master) |
163 | return -EINVAL; | 166 | return -EINVAL; |
164 | 167 | ||
@@ -169,6 +172,7 @@ int drm_setmaster_ioctl(struct drm_device *dev, void *data, | |||
169 | file_priv->minor->master != file_priv->master) { | 172 | file_priv->minor->master != file_priv->master) { |
170 | mutex_lock(&dev->struct_mutex); | 173 | mutex_lock(&dev->struct_mutex); |
171 | file_priv->minor->master = drm_master_get(file_priv->master); | 174 | file_priv->minor->master = drm_master_get(file_priv->master); |
175 | file_priv->is_master = 1; | ||
172 | mutex_unlock(&dev->struct_mutex); | 176 | mutex_unlock(&dev->struct_mutex); |
173 | } | 177 | } |
174 | 178 | ||
@@ -178,10 +182,15 @@ int drm_setmaster_ioctl(struct drm_device *dev, void *data, | |||
178 | int drm_dropmaster_ioctl(struct drm_device *dev, void *data, | 182 | int drm_dropmaster_ioctl(struct drm_device *dev, void *data, |
179 | struct drm_file *file_priv) | 183 | struct drm_file *file_priv) |
180 | { | 184 | { |
181 | if (!file_priv->master) | 185 | if (!file_priv->is_master) |
186 | return -EINVAL; | ||
187 | |||
188 | if (!file_priv->minor->master) | ||
182 | return -EINVAL; | 189 | return -EINVAL; |
190 | |||
183 | mutex_lock(&dev->struct_mutex); | 191 | mutex_lock(&dev->struct_mutex); |
184 | drm_master_put(&file_priv->minor->master); | 192 | drm_master_put(&file_priv->minor->master); |
193 | file_priv->is_master = 0; | ||
185 | mutex_unlock(&dev->struct_mutex); | 194 | mutex_unlock(&dev->struct_mutex); |
186 | return 0; | 195 | return 0; |
187 | } | 196 | } |
@@ -393,14 +402,14 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent, | |||
393 | if (dev->driver->load) { | 402 | if (dev->driver->load) { |
394 | ret = dev->driver->load(dev, ent->driver_data); | 403 | ret = dev->driver->load(dev, ent->driver_data); |
395 | if (ret) | 404 | if (ret) |
396 | goto err_g3; | 405 | goto err_g4; |
397 | } | 406 | } |
398 | 407 | ||
399 | /* setup the grouping for the legacy output */ | 408 | /* setup the grouping for the legacy output */ |
400 | if (drm_core_check_feature(dev, DRIVER_MODESET)) { | 409 | if (drm_core_check_feature(dev, DRIVER_MODESET)) { |
401 | ret = drm_mode_group_init_legacy_group(dev, &dev->primary->mode_group); | 410 | ret = drm_mode_group_init_legacy_group(dev, &dev->primary->mode_group); |
402 | if (ret) | 411 | if (ret) |
403 | goto err_g3; | 412 | goto err_g4; |
404 | } | 413 | } |
405 | 414 | ||
406 | list_add_tail(&dev->driver_item, &driver->device_list); | 415 | list_add_tail(&dev->driver_item, &driver->device_list); |
@@ -411,8 +420,11 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent, | |||
411 | 420 | ||
412 | return 0; | 421 | return 0; |
413 | 422 | ||
414 | err_g3: | 423 | err_g4: |
415 | drm_put_minor(&dev->primary); | 424 | drm_put_minor(&dev->primary); |
425 | err_g3: | ||
426 | if (drm_core_check_feature(dev, DRIVER_MODESET)) | ||
427 | drm_put_minor(&dev->control); | ||
416 | err_g2: | 428 | err_g2: |
417 | pci_disable_device(pdev); | 429 | pci_disable_device(pdev); |
418 | err_g1: | 430 | err_g1: |
@@ -493,11 +505,11 @@ void drm_put_dev(struct drm_device *dev) | |||
493 | dev->agp = NULL; | 505 | dev->agp = NULL; |
494 | } | 506 | } |
495 | 507 | ||
496 | drm_ht_remove(&dev->map_hash); | ||
497 | drm_ctxbitmap_cleanup(dev); | ||
498 | |||
499 | list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) | 508 | list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) |
500 | drm_rmmap(dev, r_list->map); | 509 | drm_rmmap(dev, r_list->map); |
510 | drm_ht_remove(&dev->map_hash); | ||
511 | |||
512 | drm_ctxbitmap_cleanup(dev); | ||
501 | 513 | ||
502 | if (drm_core_check_feature(dev, DRIVER_MODESET)) | 514 | if (drm_core_check_feature(dev, DRIVER_MODESET)) |
503 | drm_put_minor(&dev->control); | 515 | drm_put_minor(&dev->control); |