aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <airlied@gmail.com>2014-08-07 17:30:53 -0400
committerDave Airlie <airlied@gmail.com>2014-08-07 17:30:53 -0400
commit7963e9db1b1f842fdc53309baa8714d38e9f5681 (patch)
tree9829f2d38b6df9f5a07c349766e77b002cb34539
parentfa1d0ee69ca8c123dd791d52830a2e146985ce85 (diff)
Revert "drm: drop redundant drm_file->is_master"
This reverts commit 48ba813701eb14b3008edefef4a0789b328e278c. Thanks to Chris: "drm_file->is_master is not synomous with having drm_file->master == drm_file->minor->master. This is because drm_file->master is the same for all drm_files of the same generation and so when there is a master, every drm_file believes itself to be the master. Confusion ensues and things go pear shaped when one file is closed and there is no master anymore." Conflicts: drivers/gpu/drm/drm_drv.c drivers/gpu/drm/drm_stub.c
-rw-r--r--drivers/gpu/drm/drm_crtc.c2
-rw-r--r--drivers/gpu/drm/drm_drv.c10
-rw-r--r--drivers/gpu/drm/drm_fops.c4
-rw-r--r--drivers/gpu/drm/drm_ioctl.c2
-rw-r--r--drivers/gpu/drm/drm_lock.c2
-rw-r--r--drivers/gpu/drm/i915/i915_gem_execbuffer.c4
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.c2
-rw-r--r--drivers/staging/imx-drm/imx-drm-core.c2
-rw-r--r--include/drm/drmP.h19
9 files changed, 20 insertions, 27 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index ca8bb1bc92a0..fa2be249999c 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -3244,7 +3244,7 @@ int drm_mode_getfb(struct drm_device *dev,
3244 r->bpp = fb->bits_per_pixel; 3244 r->bpp = fb->bits_per_pixel;
3245 r->pitch = fb->pitches[0]; 3245 r->pitch = fb->pitches[0];
3246 if (fb->funcs->create_handle) { 3246 if (fb->funcs->create_handle) {
3247 if (drm_is_master(file_priv) || capable(CAP_SYS_ADMIN) || 3247 if (file_priv->is_master || capable(CAP_SYS_ADMIN) ||
3248 drm_is_control_client(file_priv)) { 3248 drm_is_control_client(file_priv)) {
3249 ret = fb->funcs->create_handle(fb, file_priv, 3249 ret = fb->funcs->create_handle(fb, file_priv,
3250 &r->handle); 3250 &r->handle);
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 92bc6b1d9646..3242e208c0d0 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -179,7 +179,7 @@ int drm_setmaster_ioctl(struct drm_device *dev, void *data,
179 int ret = 0; 179 int ret = 0;
180 180
181 mutex_lock(&dev->master_mutex); 181 mutex_lock(&dev->master_mutex);
182 if (drm_is_master(file_priv)) 182 if (file_priv->is_master)
183 goto out_unlock; 183 goto out_unlock;
184 184
185 if (file_priv->minor->master) { 185 if (file_priv->minor->master) {
@@ -193,10 +193,13 @@ int drm_setmaster_ioctl(struct drm_device *dev, void *data,
193 } 193 }
194 194
195 file_priv->minor->master = drm_master_get(file_priv->master); 195 file_priv->minor->master = drm_master_get(file_priv->master);
196 file_priv->is_master = 1;
196 if (dev->driver->master_set) { 197 if (dev->driver->master_set) {
197 ret = dev->driver->master_set(dev, file_priv, false); 198 ret = dev->driver->master_set(dev, file_priv, false);
198 if (unlikely(ret != 0)) 199 if (unlikely(ret != 0)) {
200 file_priv->is_master = 0;
199 drm_master_put(&file_priv->minor->master); 201 drm_master_put(&file_priv->minor->master);
202 }
200 } 203 }
201 204
202out_unlock: 205out_unlock:
@@ -210,7 +213,7 @@ int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
210 int ret = -EINVAL; 213 int ret = -EINVAL;
211 214
212 mutex_lock(&dev->master_mutex); 215 mutex_lock(&dev->master_mutex);
213 if (!drm_is_master(file_priv)) 216 if (!file_priv->is_master)
214 goto out_unlock; 217 goto out_unlock;
215 218
216 if (!file_priv->minor->master) 219 if (!file_priv->minor->master)
@@ -220,6 +223,7 @@ int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
220 if (dev->driver->master_drop) 223 if (dev->driver->master_drop)
221 dev->driver->master_drop(dev, file_priv, false); 224 dev->driver->master_drop(dev, file_priv, false);
222 drm_master_put(&file_priv->minor->master); 225 drm_master_put(&file_priv->minor->master);
226 file_priv->is_master = 0;
223 227
224out_unlock: 228out_unlock:
225 mutex_unlock(&dev->master_mutex); 229 mutex_unlock(&dev->master_mutex);
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 4b060942cb3c..79d5221c6e41 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -194,6 +194,7 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor)
194 goto out_close; 194 goto out_close;
195 } 195 }
196 196
197 priv->is_master = 1;
197 /* take another reference for the copy in the local file priv */ 198 /* take another reference for the copy in the local file priv */
198 priv->master = drm_master_get(priv->minor->master); 199 priv->master = drm_master_get(priv->minor->master);
199 priv->authenticated = 1; 200 priv->authenticated = 1;
@@ -425,7 +426,7 @@ int drm_release(struct inode *inode, struct file *filp)
425 426
426 mutex_lock(&dev->master_mutex); 427 mutex_lock(&dev->master_mutex);
427 428
428 if (drm_is_master(file_priv)) { 429 if (file_priv->is_master) {
429 struct drm_master *master = file_priv->master; 430 struct drm_master *master = file_priv->master;
430 431
431 /** 432 /**
@@ -453,6 +454,7 @@ int drm_release(struct inode *inode, struct file *filp)
453 /* drop the master reference held by the file priv */ 454 /* drop the master reference held by the file priv */
454 if (file_priv->master) 455 if (file_priv->master)
455 drm_master_put(&file_priv->master); 456 drm_master_put(&file_priv->master);
457 file_priv->is_master = 0;
456 mutex_unlock(&dev->master_mutex); 458 mutex_unlock(&dev->master_mutex);
457 459
458 if (dev->driver->postclose) 460 if (dev->driver->postclose)
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index d3d1a8c72e98..40be746b7e68 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -607,7 +607,7 @@ static int drm_ioctl_permit(u32 flags, struct drm_file *file_priv)
607 return -EACCES; 607 return -EACCES;
608 608
609 /* MASTER is only for master or control clients */ 609 /* MASTER is only for master or control clients */
610 if (unlikely((flags & DRM_MASTER) && !drm_is_master(file_priv) && 610 if (unlikely((flags & DRM_MASTER) && !file_priv->is_master &&
611 !drm_is_control_client(file_priv))) 611 !drm_is_control_client(file_priv)))
612 return -EACCES; 612 return -EACCES;
613 613
diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
index ea1572596578..e26b59e385ff 100644
--- a/drivers/gpu/drm/drm_lock.c
+++ b/drivers/gpu/drm/drm_lock.c
@@ -112,7 +112,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
112 /* don't set the block all signals on the master process for now 112 /* don't set the block all signals on the master process for now
113 * really probably not the correct answer but lets us debug xkb 113 * really probably not the correct answer but lets us debug xkb
114 * xserver for now */ 114 * xserver for now */
115 if (!drm_is_master(file_priv)) { 115 if (!file_priv->is_master) {
116 sigemptyset(&dev->sigmask); 116 sigemptyset(&dev->sigmask);
117 sigaddset(&dev->sigmask, SIGSTOP); 117 sigaddset(&dev->sigmask, SIGSTOP);
118 sigaddset(&dev->sigmask, SIGTSTP); 118 sigaddset(&dev->sigmask, SIGTSTP);
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 2dd19da6b4b3..60998fc4e5b2 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1260,7 +1260,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
1260 1260
1261 flags = 0; 1261 flags = 0;
1262 if (args->flags & I915_EXEC_SECURE) { 1262 if (args->flags & I915_EXEC_SECURE) {
1263 if (!drm_is_master(file) || !capable(CAP_SYS_ADMIN)) 1263 if (!file->is_master || !capable(CAP_SYS_ADMIN))
1264 return -EPERM; 1264 return -EPERM;
1265 1265
1266 flags |= I915_DISPATCH_SECURE; 1266 flags |= I915_DISPATCH_SECURE;
@@ -1369,7 +1369,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
1369 ret = i915_parse_cmds(ring, 1369 ret = i915_parse_cmds(ring,
1370 batch_obj, 1370 batch_obj,
1371 args->batch_start_offset, 1371 args->batch_start_offset,
1372 drm_is_master(file)); 1372 file->is_master);
1373 if (ret) 1373 if (ret)
1374 goto err; 1374 goto err;
1375 1375
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 63c4d6f0281e..18b54acacfbb 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -990,7 +990,7 @@ static struct vmw_master *vmw_master_check(struct drm_device *dev,
990 if (unlikely(ret != 0)) 990 if (unlikely(ret != 0))
991 return ERR_PTR(-ERESTARTSYS); 991 return ERR_PTR(-ERESTARTSYS);
992 992
993 if (drm_is_master(file_priv)) { 993 if (file_priv->is_master) {
994 mutex_unlock(&dev->master_mutex); 994 mutex_unlock(&dev->master_mutex);
995 return NULL; 995 return NULL;
996 } 996 }
diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c
index 72913b299047..6f54ff4f9372 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -182,7 +182,7 @@ static void imx_drm_driver_preclose(struct drm_device *drm,
182{ 182{
183 int i; 183 int i;
184 184
185 if (!drm_is_master(file)) 185 if (!file->is_master)
186 return; 186 return;
187 187
188 for (i = 0; i < MAX_CRTC; i++) 188 for (i = 0; i < MAX_CRTC; i++)
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index a57646382086..a12fbbac373c 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -384,6 +384,8 @@ struct drm_prime_file_private {
384/** File private data */ 384/** File private data */
385struct drm_file { 385struct drm_file {
386 unsigned authenticated :1; 386 unsigned authenticated :1;
387 /* Whether we're master for a minor. Protected by master_mutex */
388 unsigned is_master :1;
387 /* true when the client has asked us to expose stereo 3D mode flags */ 389 /* true when the client has asked us to expose stereo 3D mode flags */
388 unsigned stereo_allowed :1; 390 unsigned stereo_allowed :1;
389 /* 391 /*
@@ -1020,7 +1022,7 @@ struct drm_device {
1020 /** \name Locks */ 1022 /** \name Locks */
1021 /*@{ */ 1023 /*@{ */
1022 struct mutex struct_mutex; /**< For others */ 1024 struct mutex struct_mutex; /**< For others */
1023 struct mutex master_mutex; /**< For drm_minor::master */ 1025 struct mutex master_mutex; /**< For drm_minor::master and drm_file::is_master */
1024 /*@} */ 1026 /*@} */
1025 1027
1026 /** \name Usage Counters */ 1028 /** \name Usage Counters */
@@ -1158,21 +1160,6 @@ static inline bool drm_is_primary_client(const struct drm_file *file_priv)
1158 return file_priv->minor->type == DRM_MINOR_LEGACY; 1160 return file_priv->minor->type == DRM_MINOR_LEGACY;
1159} 1161}
1160 1162
1161/**
1162 * drm_is_master() - Check whether a DRM open-file is DRM-Master
1163 * @file: DRM open-file context
1164 *
1165 * This checks whether a DRM open-file context is owner of the master context
1166 * attached to it. If a file owns a master context, it's called DRM-Master.
1167 * Per DRM device, only one such file can be DRM-Master at a time.
1168 *
1169 * Returns: True if the file is DRM-Master, otherwise false.
1170 */
1171static inline bool drm_is_master(const struct drm_file *file)
1172{
1173 return file->master && file->master == file->minor->master;
1174}
1175
1176/******************************************************************/ 1163/******************************************************************/
1177/** \name Internal function definitions */ 1164/** \name Internal function definitions */
1178/*@{*/ 1165/*@{*/