diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-06-14 14:51:01 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-06-16 04:17:58 -0400 |
commit | 14d71ebdb5bd97529ff360b240f294559754824f (patch) | |
tree | 35d1fa56fd6c0ecc88ec768c1ca0f63fd4601d76 /drivers/gpu/drm/drm_fops.c | |
parent | 2cbae7e63747c917b08a505e44b31ec8b4ee5583 (diff) |
drm: Extract drm_master_relase
Like with drm_master_open protect it with a check for primary_client
to make it clear that this can't happen on render/control nodes.
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1465930269-7883-7-git-send-email-daniel.vetter@ffwll.ch
Diffstat (limited to 'drivers/gpu/drm/drm_fops.c')
-rw-r--r-- | drivers/gpu/drm/drm_fops.c | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index e2522672719a..f3b2677de882 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c | |||
@@ -411,43 +411,12 @@ int drm_release(struct inode *inode, struct file *filp) | |||
411 | 411 | ||
412 | drm_legacy_ctxbitmap_flush(dev, file_priv); | 412 | drm_legacy_ctxbitmap_flush(dev, file_priv); |
413 | 413 | ||
414 | mutex_lock(&dev->master_mutex); | 414 | if (drm_is_primary_client(file_priv)) |
415 | 415 | drm_master_release(file_priv); | |
416 | if (file_priv->is_master) { | ||
417 | struct drm_master *master = file_priv->master; | ||
418 | |||
419 | /* | ||
420 | * Since the master is disappearing, so is the | ||
421 | * possibility to lock. | ||
422 | */ | ||
423 | mutex_lock(&dev->struct_mutex); | ||
424 | if (master->lock.hw_lock) { | ||
425 | if (dev->sigdata.lock == master->lock.hw_lock) | ||
426 | dev->sigdata.lock = NULL; | ||
427 | master->lock.hw_lock = NULL; | ||
428 | master->lock.file_priv = NULL; | ||
429 | wake_up_interruptible_all(&master->lock.lock_queue); | ||
430 | } | ||
431 | mutex_unlock(&dev->struct_mutex); | ||
432 | |||
433 | if (file_priv->minor->master == file_priv->master) { | ||
434 | /* drop the reference held my the minor */ | ||
435 | if (dev->driver->master_drop) | ||
436 | dev->driver->master_drop(dev, file_priv, true); | ||
437 | drm_master_put(&file_priv->minor->master); | ||
438 | } | ||
439 | } | ||
440 | |||
441 | /* drop the master reference held by the file priv */ | ||
442 | if (file_priv->master) | ||
443 | drm_master_put(&file_priv->master); | ||
444 | file_priv->is_master = 0; | ||
445 | mutex_unlock(&dev->master_mutex); | ||
446 | 416 | ||
447 | if (dev->driver->postclose) | 417 | if (dev->driver->postclose) |
448 | dev->driver->postclose(dev, file_priv); | 418 | dev->driver->postclose(dev, file_priv); |
449 | 419 | ||
450 | |||
451 | if (drm_core_check_feature(dev, DRIVER_PRIME)) | 420 | if (drm_core_check_feature(dev, DRIVER_PRIME)) |
452 | drm_prime_destroy_file_private(&file_priv->prime); | 421 | drm_prime_destroy_file_private(&file_priv->prime); |
453 | 422 | ||