diff options
Diffstat (limited to 'drivers/char/drm/drm_fops.c')
-rw-r--r-- | drivers/char/drm/drm_fops.c | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/drivers/char/drm/drm_fops.c b/drivers/char/drm/drm_fops.c index f09d4b5002b0..68f0da801ed8 100644 --- a/drivers/char/drm/drm_fops.c +++ b/drivers/char/drm/drm_fops.c | |||
@@ -129,16 +129,15 @@ static int drm_setup(struct drm_device * dev) | |||
129 | int drm_open(struct inode *inode, struct file *filp) | 129 | int drm_open(struct inode *inode, struct file *filp) |
130 | { | 130 | { |
131 | struct drm_device *dev = NULL; | 131 | struct drm_device *dev = NULL; |
132 | int minor = iminor(inode); | 132 | int minor_id = iminor(inode); |
133 | struct drm_minor *minor; | ||
133 | int retcode = 0; | 134 | int retcode = 0; |
134 | 135 | ||
135 | if (!((minor >= 0) && (minor < drm_cards_limit))) | 136 | minor = idr_find(&drm_minors_idr, minor_id); |
137 | if (!minor) | ||
136 | return -ENODEV; | 138 | return -ENODEV; |
137 | 139 | ||
138 | if (!drm_heads[minor]) | 140 | if (!(dev = minor->dev)) |
139 | return -ENODEV; | ||
140 | |||
141 | if (!(dev = drm_heads[minor]->dev)) | ||
142 | return -ENODEV; | 141 | return -ENODEV; |
143 | 142 | ||
144 | retcode = drm_open_helper(inode, filp, dev); | 143 | retcode = drm_open_helper(inode, filp, dev); |
@@ -168,19 +167,18 @@ EXPORT_SYMBOL(drm_open); | |||
168 | int drm_stub_open(struct inode *inode, struct file *filp) | 167 | int drm_stub_open(struct inode *inode, struct file *filp) |
169 | { | 168 | { |
170 | struct drm_device *dev = NULL; | 169 | struct drm_device *dev = NULL; |
171 | int minor = iminor(inode); | 170 | struct drm_minor *minor; |
171 | int minor_id = iminor(inode); | ||
172 | int err = -ENODEV; | 172 | int err = -ENODEV; |
173 | const struct file_operations *old_fops; | 173 | const struct file_operations *old_fops; |
174 | 174 | ||
175 | DRM_DEBUG("\n"); | 175 | DRM_DEBUG("\n"); |
176 | 176 | ||
177 | if (!((minor >= 0) && (minor < drm_cards_limit))) | 177 | minor = idr_find(&drm_minors_idr, minor_id); |
178 | return -ENODEV; | 178 | if (!minor) |
179 | |||
180 | if (!drm_heads[minor]) | ||
181 | return -ENODEV; | 179 | return -ENODEV; |
182 | 180 | ||
183 | if (!(dev = drm_heads[minor]->dev)) | 181 | if (!(dev = minor->dev)) |
184 | return -ENODEV; | 182 | return -ENODEV; |
185 | 183 | ||
186 | old_fops = filp->f_op; | 184 | old_fops = filp->f_op; |
@@ -225,7 +223,7 @@ static int drm_cpu_valid(void) | |||
225 | static int drm_open_helper(struct inode *inode, struct file *filp, | 223 | static int drm_open_helper(struct inode *inode, struct file *filp, |
226 | struct drm_device * dev) | 224 | struct drm_device * dev) |
227 | { | 225 | { |
228 | int minor = iminor(inode); | 226 | int minor_id = iminor(inode); |
229 | struct drm_file *priv; | 227 | struct drm_file *priv; |
230 | int ret; | 228 | int ret; |
231 | 229 | ||
@@ -234,7 +232,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp, | |||
234 | if (!drm_cpu_valid()) | 232 | if (!drm_cpu_valid()) |
235 | return -EINVAL; | 233 | return -EINVAL; |
236 | 234 | ||
237 | DRM_DEBUG("pid = %d, minor = %d\n", task_pid_nr(current), minor); | 235 | DRM_DEBUG("pid = %d, minor = %d\n", task_pid_nr(current), minor_id); |
238 | 236 | ||
239 | priv = drm_alloc(sizeof(*priv), DRM_MEM_FILES); | 237 | priv = drm_alloc(sizeof(*priv), DRM_MEM_FILES); |
240 | if (!priv) | 238 | if (!priv) |
@@ -245,8 +243,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp, | |||
245 | priv->filp = filp; | 243 | priv->filp = filp; |
246 | priv->uid = current->euid; | 244 | priv->uid = current->euid; |
247 | priv->pid = task_pid_nr(current); | 245 | priv->pid = task_pid_nr(current); |
248 | priv->minor = minor; | 246 | priv->minor = idr_find(&drm_minors_idr, minor_id); |
249 | priv->head = drm_heads[minor]; | ||
250 | priv->ioctl_count = 0; | 247 | priv->ioctl_count = 0; |
251 | /* for compatibility root is always authenticated */ | 248 | /* for compatibility root is always authenticated */ |
252 | priv->authenticated = capable(CAP_SYS_ADMIN); | 249 | priv->authenticated = capable(CAP_SYS_ADMIN); |
@@ -297,11 +294,11 @@ static int drm_open_helper(struct inode *inode, struct file *filp, | |||
297 | int drm_fasync(int fd, struct file *filp, int on) | 294 | int drm_fasync(int fd, struct file *filp, int on) |
298 | { | 295 | { |
299 | struct drm_file *priv = filp->private_data; | 296 | struct drm_file *priv = filp->private_data; |
300 | struct drm_device *dev = priv->head->dev; | 297 | struct drm_device *dev = priv->minor->dev; |
301 | int retcode; | 298 | int retcode; |
302 | 299 | ||
303 | DRM_DEBUG("fd = %d, device = 0x%lx\n", fd, | 300 | DRM_DEBUG("fd = %d, device = 0x%lx\n", fd, |
304 | (long)old_encode_dev(priv->head->device)); | 301 | (long)old_encode_dev(priv->minor->device)); |
305 | retcode = fasync_helper(fd, filp, on, &dev->buf_async); | 302 | retcode = fasync_helper(fd, filp, on, &dev->buf_async); |
306 | if (retcode < 0) | 303 | if (retcode < 0) |
307 | return retcode; | 304 | return retcode; |
@@ -324,7 +321,7 @@ EXPORT_SYMBOL(drm_fasync); | |||
324 | int drm_release(struct inode *inode, struct file *filp) | 321 | int drm_release(struct inode *inode, struct file *filp) |
325 | { | 322 | { |
326 | struct drm_file *file_priv = filp->private_data; | 323 | struct drm_file *file_priv = filp->private_data; |
327 | struct drm_device *dev = file_priv->head->dev; | 324 | struct drm_device *dev = file_priv->minor->dev; |
328 | int retcode = 0; | 325 | int retcode = 0; |
329 | unsigned long irqflags; | 326 | unsigned long irqflags; |
330 | 327 | ||
@@ -341,14 +338,14 @@ int drm_release(struct inode *inode, struct file *filp) | |||
341 | 338 | ||
342 | DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n", | 339 | DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n", |
343 | task_pid_nr(current), | 340 | task_pid_nr(current), |
344 | (long)old_encode_dev(file_priv->head->device), | 341 | (long)old_encode_dev(file_priv->minor->device), |
345 | dev->open_count); | 342 | dev->open_count); |
346 | 343 | ||
347 | if (dev->driver->reclaim_buffers_locked && dev->lock.hw_lock) { | 344 | if (dev->driver->reclaim_buffers_locked && dev->lock.hw_lock) { |
348 | if (drm_i_have_hw_lock(dev, file_priv)) { | 345 | if (drm_i_have_hw_lock(dev, file_priv)) { |
349 | dev->driver->reclaim_buffers_locked(dev, file_priv); | 346 | dev->driver->reclaim_buffers_locked(dev, file_priv); |
350 | } else { | 347 | } else { |
351 | unsigned long _end=jiffies + 3*DRM_HZ; | 348 | unsigned long endtime = jiffies + 3 * DRM_HZ; |
352 | int locked = 0; | 349 | int locked = 0; |
353 | 350 | ||
354 | drm_idlelock_take(&dev->lock); | 351 | drm_idlelock_take(&dev->lock); |
@@ -366,7 +363,7 @@ int drm_release(struct inode *inode, struct file *filp) | |||
366 | if (locked) | 363 | if (locked) |
367 | break; | 364 | break; |
368 | schedule(); | 365 | schedule(); |
369 | } while (!time_after_eq(jiffies, _end)); | 366 | } while (!time_after_eq(jiffies, endtime)); |
370 | 367 | ||
371 | if (!locked) { | 368 | if (!locked) { |
372 | DRM_ERROR("reclaim_buffers_locked() deadlock. Please rework this\n" | 369 | DRM_ERROR("reclaim_buffers_locked() deadlock. Please rework this\n" |