Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3ac9f25 authored by Daniel Vetter's avatar Daniel Vetter
Browse files

drm: Extract drm_is_current_master



Just rolling out a bit of abstraction to be able to clean
up the master logic in the next step.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarEmil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent d6ed682e
Loading
Loading
Loading
Loading
+9 −3
Original line number Original line Diff line number Diff line
@@ -183,7 +183,7 @@ int drm_setmaster_ioctl(struct drm_device *dev, void *data,
	int ret = 0;
	int ret = 0;


	mutex_lock(&dev->master_mutex);
	mutex_lock(&dev->master_mutex);
	if (file_priv->is_master)
	if (drm_is_current_master(file_priv))
		goto out_unlock;
		goto out_unlock;


	if (dev->master) {
	if (dev->master) {
@@ -222,7 +222,7 @@ int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
	int ret = -EINVAL;
	int ret = -EINVAL;


	mutex_lock(&dev->master_mutex);
	mutex_lock(&dev->master_mutex);
	if (!file_priv->is_master)
	if (!drm_is_current_master(file_priv))
		goto out_unlock;
		goto out_unlock;


	if (!dev->master)
	if (!dev->master)
@@ -261,7 +261,7 @@ void drm_master_release(struct drm_file *file_priv)
	if (file_priv->magic)
	if (file_priv->magic)
		idr_remove(&file_priv->master->magic_map, file_priv->magic);
		idr_remove(&file_priv->master->magic_map, file_priv->magic);


	if (!file_priv->is_master)
	if (!drm_is_current_master(file_priv))
		goto out;
		goto out;


	if (!drm_core_check_feature(dev, DRIVER_MODESET)) {
	if (!drm_core_check_feature(dev, DRIVER_MODESET)) {
@@ -289,6 +289,12 @@ void drm_master_release(struct drm_file *file_priv)
	mutex_unlock(&dev->master_mutex);
	mutex_unlock(&dev->master_mutex);
}
}


bool drm_is_current_master(struct drm_file *fpriv)
{
	return fpriv->is_master;
}
EXPORT_SYMBOL(drm_is_current_master);

struct drm_master *drm_master_get(struct drm_master *master)
struct drm_master *drm_master_get(struct drm_master *master)
{
{
	kref_get(&master->refcount);
	kref_get(&master->refcount);
+1 −1
Original line number Original line Diff line number Diff line
@@ -3643,7 +3643,7 @@ int drm_mode_getfb(struct drm_device *dev,
	r->bpp = fb->bits_per_pixel;
	r->bpp = fb->bits_per_pixel;
	r->pitch = fb->pitches[0];
	r->pitch = fb->pitches[0];
	if (fb->funcs->create_handle) {
	if (fb->funcs->create_handle) {
		if (file_priv->is_master || capable(CAP_SYS_ADMIN) ||
		if (drm_is_current_master(file_priv) || capable(CAP_SYS_ADMIN) ||
		    drm_is_control_client(file_priv)) {
		    drm_is_control_client(file_priv)) {
			ret = fb->funcs->create_handle(fb, file_priv,
			ret = fb->funcs->create_handle(fb, file_priv,
						       &r->handle);
						       &r->handle);
+1 −1
Original line number Original line Diff line number Diff line
@@ -102,7 +102,7 @@ int drm_clients_info(struct seq_file *m, void *data)
			   task ? task->comm : "<unknown>",
			   task ? task->comm : "<unknown>",
			   pid_vnr(priv->pid),
			   pid_vnr(priv->pid),
			   priv->minor->index,
			   priv->minor->index,
			   priv->is_master ? 'y' : 'n',
			   drm_is_current_master(priv) ? 'y' : 'n',
			   priv->authenticated ? 'y' : 'n',
			   priv->authenticated ? 'y' : 'n',
			   from_kuid_munged(seq_user_ns(m), priv->uid),
			   from_kuid_munged(seq_user_ns(m), priv->uid),
			   priv->magic);
			   priv->magic);
+2 −1
Original line number Original line Diff line number Diff line
@@ -481,7 +481,8 @@ int drm_ioctl_permit(u32 flags, struct drm_file *file_priv)
		return -EACCES;
		return -EACCES;


	/* MASTER is only for master or control clients */
	/* MASTER is only for master or control clients */
	if (unlikely((flags & DRM_MASTER) && !file_priv->is_master &&
	if (unlikely((flags & DRM_MASTER) && 
		     !drm_is_current_master(file_priv) &&
		     !drm_is_control_client(file_priv)))
		     !drm_is_control_client(file_priv)))
		return -EACCES;
		return -EACCES;


+1 −1
Original line number Original line Diff line number Diff line
@@ -219,7 +219,7 @@ int drm_legacy_lock(struct drm_device *dev, void *data,
	/* don't set the block all signals on the master process for now 
	/* don't set the block all signals on the master process for now 
	 * really probably not the correct answer but lets us debug xkb
	 * really probably not the correct answer but lets us debug xkb
 	 * xserver for now */
 	 * xserver for now */
	if (!file_priv->is_master) {
	if (!drm_is_current_master(file_priv)) {
		dev->sigdata.context = lock->context;
		dev->sigdata.context = lock->context;
		dev->sigdata.lock = master->lock.hw_lock;
		dev->sigdata.lock = master->lock.hw_lock;
	}
	}
Loading