Commit 058ca50c authored by Dave Airlie's avatar Dave Airlie

drm/legacy: move lock cleanup for master into lock file (v2)

This makes it easier to remove legacy code later.

v2: move check into lock file as well.
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 9b7a7743
...@@ -274,21 +274,7 @@ void drm_master_release(struct drm_file *file_priv) ...@@ -274,21 +274,7 @@ void drm_master_release(struct drm_file *file_priv)
if (!drm_is_current_master(file_priv)) if (!drm_is_current_master(file_priv))
goto out; goto out;
if (drm_core_check_feature(dev, DRIVER_LEGACY)) { drm_legacy_lock_master_cleanup(dev, master);
/*
* Since the master is disappearing, so is the
* possibility to lock.
*/
mutex_lock(&dev->struct_mutex);
if (master->lock.hw_lock) {
if (dev->sigdata.lock == master->lock.hw_lock)
dev->sigdata.lock = NULL;
master->lock.hw_lock = NULL;
master->lock.file_priv = NULL;
wake_up_interruptible_all(&master->lock.lock_queue);
}
mutex_unlock(&dev->struct_mutex);
}
if (dev->master == file_priv->master) if (dev->master == file_priv->master)
drm_drop_master(dev, file_priv); drm_drop_master(dev, file_priv);
......
...@@ -126,4 +126,5 @@ int drm_legacy_sg_alloc(struct drm_device *dev, void *data, ...@@ -126,4 +126,5 @@ int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
int drm_legacy_sg_free(struct drm_device *dev, void *data, int drm_legacy_sg_free(struct drm_device *dev, void *data,
struct drm_file *file_priv); struct drm_file *file_priv);
void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
#endif /* __DRM_LEGACY_H__ */ #endif /* __DRM_LEGACY_H__ */
...@@ -347,3 +347,22 @@ void drm_legacy_lock_release(struct drm_device *dev, struct file *filp) ...@@ -347,3 +347,22 @@ void drm_legacy_lock_release(struct drm_device *dev, struct file *filp)
_DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock)); _DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock));
} }
} }
void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master)
{
if (!drm_core_check_feature(dev, DRIVER_LEGACY))
return;
/*
* Since the master is disappearing, so is the
* possibility to lock.
*/ mutex_lock(&dev->struct_mutex);
if (master->lock.hw_lock) {
if (dev->sigdata.lock == master->lock.hw_lock)
dev->sigdata.lock = NULL;
master->lock.hw_lock = NULL;
master->lock.file_priv = NULL;
wake_up_interruptible_all(&master->lock.lock_queue);
}
mutex_unlock(&dev->struct_mutex);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment