aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/drm_lock.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2007-08-25 06:23:09 -0400
committerDave Airlie <airlied@optimus.(none)>2007-10-14 20:38:20 -0400
commit6c340eac0285f3d62406d2d902d0e96fbf2a5dc0 (patch)
treea92039951cb7eaced306cfff2bad6af0ac5257ad /drivers/char/drm/drm_lock.c
parent20caafa6ecb2487d9b223aa33e7cc704f912a758 (diff)
drm: Replace filp in ioctl arguments with drm_file *file_priv.
As a fallout, replace filp storage with file_priv storage for "unique identifier of a client" all over the DRM. There is a 1:1 mapping, so this should be a noop. This could be a minor performance improvement, as everyth on Linux dereferenced filp to get file_priv anyway, while only the mmap ioct went the other direction. Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/drm_lock.c')
-rw-r--r--drivers/char/drm/drm_lock.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/drivers/char/drm/drm_lock.c b/drivers/char/drm/drm_lock.c
index 950e78dbcc3c..57c4306f4cb4 100644
--- a/drivers/char/drm/drm_lock.c
+++ b/drivers/char/drm/drm_lock.c
@@ -41,23 +41,22 @@ static int drm_notifier(void *priv);
41 * Lock ioctl. 41 * Lock ioctl.
42 * 42 *
43 * \param inode device inode. 43 * \param inode device inode.
44 * \param filp file pointer. 44 * \param file_priv DRM file private.
45 * \param cmd command. 45 * \param cmd command.
46 * \param arg user argument, pointing to a drm_lock structure. 46 * \param arg user argument, pointing to a drm_lock structure.
47 * \return zero on success or negative number on failure. 47 * \return zero on success or negative number on failure.
48 * 48 *
49 * Add the current task to the lock wait queue, and attempt to take to lock. 49 * Add the current task to the lock wait queue, and attempt to take to lock.
50 */ 50 */
51int drm_lock(struct inode *inode, struct file *filp, 51int drm_lock(struct inode *inode, struct drm_file *file_priv,
52 unsigned int cmd, unsigned long arg) 52 unsigned int cmd, unsigned long arg)
53{ 53{
54 struct drm_file *priv = filp->private_data; 54 struct drm_device *dev = file_priv->head->dev;
55 struct drm_device *dev = priv->head->dev;
56 DECLARE_WAITQUEUE(entry, current); 55 DECLARE_WAITQUEUE(entry, current);
57 struct drm_lock lock; 56 struct drm_lock lock;
58 int ret = 0; 57 int ret = 0;
59 58
60 ++priv->lock_count; 59 ++file_priv->lock_count;
61 60
62 if (copy_from_user(&lock, (struct drm_lock __user *) arg, sizeof(lock))) 61 if (copy_from_user(&lock, (struct drm_lock __user *) arg, sizeof(lock)))
63 return -EFAULT; 62 return -EFAULT;
@@ -88,7 +87,7 @@ int drm_lock(struct inode *inode, struct file *filp,
88 break; 87 break;
89 } 88 }
90 if (drm_lock_take(&dev->lock, lock.context)) { 89 if (drm_lock_take(&dev->lock, lock.context)) {
91 dev->lock.filp = filp; 90 dev->lock.file_priv = file_priv;
92 dev->lock.lock_time = jiffies; 91 dev->lock.lock_time = jiffies;
93 atomic_inc(&dev->counts[_DRM_STAT_LOCKS]); 92 atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
94 break; /* Got lock */ 93 break; /* Got lock */
@@ -142,18 +141,17 @@ int drm_lock(struct inode *inode, struct file *filp,
142 * Unlock ioctl. 141 * Unlock ioctl.
143 * 142 *
144 * \param inode device inode. 143 * \param inode device inode.
145 * \param filp file pointer. 144 * \param file_priv DRM file private.
146 * \param cmd command. 145 * \param cmd command.
147 * \param arg user argument, pointing to a drm_lock structure. 146 * \param arg user argument, pointing to a drm_lock structure.
148 * \return zero on success or negative number on failure. 147 * \return zero on success or negative number on failure.
149 * 148 *
150 * Transfer and free the lock. 149 * Transfer and free the lock.
151 */ 150 */
152int drm_unlock(struct inode *inode, struct file *filp, 151int drm_unlock(struct inode *inode, struct drm_file *file_priv,
153 unsigned int cmd, unsigned long arg) 152 unsigned int cmd, unsigned long arg)
154{ 153{
155 struct drm_file *priv = filp->private_data; 154 struct drm_device *dev = file_priv->head->dev;
156 struct drm_device *dev = priv->head->dev;
157 struct drm_lock lock; 155 struct drm_lock lock;
158 unsigned long irqflags; 156 unsigned long irqflags;
159 157
@@ -257,7 +255,7 @@ static int drm_lock_transfer(struct drm_lock_data *lock_data,
257 unsigned int old, new, prev; 255 unsigned int old, new, prev;
258 volatile unsigned int *lock = &lock_data->hw_lock->lock; 256 volatile unsigned int *lock = &lock_data->hw_lock->lock;
259 257
260 lock_data->filp = NULL; 258 lock_data->file_priv = NULL;
261 do { 259 do {
262 old = *lock; 260 old = *lock;
263 new = context | _DRM_LOCK_HELD; 261 new = context | _DRM_LOCK_HELD;
@@ -390,13 +388,13 @@ void drm_idlelock_release(struct drm_lock_data *lock_data)
390EXPORT_SYMBOL(drm_idlelock_release); 388EXPORT_SYMBOL(drm_idlelock_release);
391 389
392 390
393int drm_i_have_hw_lock(struct file *filp) 391int drm_i_have_hw_lock(struct drm_file *file_priv)
394{ 392{
395 DRM_DEVICE; 393 DRM_DEVICE;
396 394
397 return (priv->lock_count && dev->lock.hw_lock && 395 return (file_priv->lock_count && dev->lock.hw_lock &&
398 _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) && 396 _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) &&
399 dev->lock.filp == filp); 397 dev->lock.file_priv == file_priv);
400} 398}
401 399
402EXPORT_SYMBOL(drm_i_have_hw_lock); 400EXPORT_SYMBOL(drm_i_have_hw_lock);