Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: move drm-lock API to drm_legacy.h

Same as the other legacy APIs, most of this is internal, so prefix it with
drm_legacy_* and move into drm_legacy.h.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>

authored by

David Herrmann and committed by
Dave Airlie
bb6d822e d4f68a75

+38 -35
+3 -3
drivers/gpu/drm/drm_fops.c
··· 268 268 { 269 269 struct drm_file *file_priv = filp->private_data; 270 270 271 - if (drm_i_have_hw_lock(dev, file_priv)) { 271 + if (drm_legacy_i_have_hw_lock(dev, file_priv)) { 272 272 DRM_DEBUG("File %p released, freeing lock for context %d\n", 273 273 filp, _DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock)); 274 - drm_lock_free(&file_priv->master->lock, 275 - _DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock)); 274 + drm_legacy_lock_free(&file_priv->master->lock, 275 + _DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock)); 276 276 } 277 277 } 278 278
+2 -2
drivers/gpu/drm/drm_ioctl.c
··· 82 82 DRM_IOCTL_DEF(DRM_IOCTL_ADD_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), 83 83 DRM_IOCTL_DEF(DRM_IOCTL_RM_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), 84 84 85 - DRM_IOCTL_DEF(DRM_IOCTL_LOCK, drm_lock, DRM_AUTH), 86 - DRM_IOCTL_DEF(DRM_IOCTL_UNLOCK, drm_unlock, DRM_AUTH), 85 + DRM_IOCTL_DEF(DRM_IOCTL_LOCK, drm_legacy_lock, DRM_AUTH), 86 + DRM_IOCTL_DEF(DRM_IOCTL_UNLOCK, drm_legacy_unlock, DRM_AUTH), 87 87 88 88 DRM_IOCTL_DEF(DRM_IOCTL_FINISH, drm_noop, DRM_AUTH), 89 89
+9
drivers/gpu/drm/drm_legacy.h
··· 83 83 struct list_head head; 84 84 }; 85 85 86 + /* 87 + * Generic Userspace Locking-API 88 + */ 89 + 90 + int drm_legacy_i_have_hw_lock(struct drm_device *d, struct drm_file *f); 91 + int drm_legacy_lock(struct drm_device *d, void *v, struct drm_file *f); 92 + int drm_legacy_unlock(struct drm_device *d, void *v, struct drm_file *f); 93 + int drm_legacy_lock_free(struct drm_lock_data *lock, unsigned int ctx); 94 + 86 95 #endif /* __DRM_LEGACY_H__ */
+11 -9
drivers/gpu/drm/drm_lock.c
··· 52 52 * 53 53 * Add the current task to the lock wait queue, and attempt to take to lock. 54 54 */ 55 - int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv) 55 + int drm_legacy_lock(struct drm_device *dev, void *data, 56 + struct drm_file *file_priv) 56 57 { 57 58 DECLARE_WAITQUEUE(entry, current); 58 59 struct drm_lock *lock = data; ··· 147 146 * 148 147 * Transfer and free the lock. 149 148 */ 150 - int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv) 149 + int drm_legacy_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv) 151 150 { 152 151 struct drm_lock *lock = data; 153 152 struct drm_master *master = file_priv->master; ··· 158 157 return -EINVAL; 159 158 } 160 159 161 - if (drm_lock_free(&master->lock, lock->context)) { 160 + if (drm_legacy_lock_free(&master->lock, lock->context)) { 162 161 /* FIXME: Should really bail out here. */ 163 162 } 164 163 ··· 251 250 * Marks the lock as not held, via the \p cmpxchg instruction. Wakes any task 252 251 * waiting on the lock queue. 253 252 */ 254 - int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context) 253 + int drm_legacy_lock_free(struct drm_lock_data *lock_data, unsigned int context) 255 254 { 256 255 unsigned int old, new, prev; 257 256 volatile unsigned int *lock = &lock_data->hw_lock->lock; ··· 325 324 * having to worry about starvation. 326 325 */ 327 326 328 - void drm_idlelock_take(struct drm_lock_data *lock_data) 327 + void drm_legacy_idlelock_take(struct drm_lock_data *lock_data) 329 328 { 330 329 int ret; 331 330 ··· 342 341 } 343 342 spin_unlock_bh(&lock_data->spinlock); 344 343 } 345 - EXPORT_SYMBOL(drm_idlelock_take); 344 + EXPORT_SYMBOL(drm_legacy_idlelock_take); 346 345 347 - void drm_idlelock_release(struct drm_lock_data *lock_data) 346 + void drm_legacy_idlelock_release(struct drm_lock_data *lock_data) 348 347 { 349 348 unsigned int old, prev; 350 349 volatile unsigned int *lock = &lock_data->hw_lock->lock; ··· 362 361 } 363 362 spin_unlock_bh(&lock_data->spinlock); 364 363 } 365 - EXPORT_SYMBOL(drm_idlelock_release); 364 + EXPORT_SYMBOL(drm_legacy_idlelock_release); 366 365 367 - int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv) 366 + int drm_legacy_i_have_hw_lock(struct drm_device *dev, 367 + struct drm_file *file_priv) 368 368 { 369 369 struct drm_master *master = file_priv->master; 370 370 return (file_priv->lock_count && master->lock.hw_lock &&
+2 -2
drivers/gpu/drm/i810/i810_dma.c
··· 1215 1215 } 1216 1216 1217 1217 if (file_priv->master && file_priv->master->lock.hw_lock) { 1218 - drm_idlelock_take(&file_priv->master->lock); 1218 + drm_legacy_idlelock_take(&file_priv->master->lock); 1219 1219 i810_driver_reclaim_buffers(dev, file_priv); 1220 - drm_idlelock_release(&file_priv->master->lock); 1220 + drm_legacy_idlelock_release(&file_priv->master->lock); 1221 1221 } else { 1222 1222 /* master disappeared, clean up stuff anyway and hope nothing 1223 1223 * goes wrong */
+2 -2
drivers/gpu/drm/savage/savage_bci.c
··· 1051 1051 return; 1052 1052 1053 1053 if (file_priv->master && file_priv->master->lock.hw_lock) { 1054 - drm_idlelock_take(&file_priv->master->lock); 1054 + drm_legacy_idlelock_take(&file_priv->master->lock); 1055 1055 release_idlelock = 1; 1056 1056 } 1057 1057 ··· 1070 1070 } 1071 1071 1072 1072 if (release_idlelock) 1073 - drm_idlelock_release(&file_priv->master->lock); 1073 + drm_legacy_idlelock_release(&file_priv->master->lock); 1074 1074 } 1075 1075 1076 1076 const struct drm_ioctl_desc savage_ioctls[] = {
+3 -3
drivers/gpu/drm/sis/sis_mm.c
··· 319 319 if (!(file->minor->master && file->master->lock.hw_lock)) 320 320 return; 321 321 322 - drm_idlelock_take(&file->master->lock); 322 + drm_legacy_idlelock_take(&file->master->lock); 323 323 324 324 mutex_lock(&dev->struct_mutex); 325 325 if (list_empty(&file_priv->obj_list)) { 326 326 mutex_unlock(&dev->struct_mutex); 327 - drm_idlelock_release(&file->master->lock); 327 + drm_legacy_idlelock_release(&file->master->lock); 328 328 329 329 return; 330 330 } ··· 345 345 } 346 346 mutex_unlock(&dev->struct_mutex); 347 347 348 - drm_idlelock_release(&file->master->lock); 348 + drm_legacy_idlelock_release(&file->master->lock); 349 349 350 350 return; 351 351 }
+3 -3
drivers/gpu/drm/via/via_mm.c
··· 211 211 if (!(file->minor->master && file->master->lock.hw_lock)) 212 212 return; 213 213 214 - drm_idlelock_take(&file->master->lock); 214 + drm_legacy_idlelock_take(&file->master->lock); 215 215 216 216 mutex_lock(&dev->struct_mutex); 217 217 if (list_empty(&file_priv->obj_list)) { 218 218 mutex_unlock(&dev->struct_mutex); 219 - drm_idlelock_release(&file->master->lock); 219 + drm_legacy_idlelock_release(&file->master->lock); 220 220 221 221 return; 222 222 } ··· 231 231 } 232 232 mutex_unlock(&dev->struct_mutex); 233 233 234 - drm_idlelock_release(&file->master->lock); 234 + drm_legacy_idlelock_release(&file->master->lock); 235 235 236 236 return; 237 237 }
+3 -11
include/drm/drmP.h
··· 1143 1143 void drm_clflush_sg(struct sg_table *st); 1144 1144 void drm_clflush_virt_range(void *addr, unsigned long length); 1145 1145 1146 - /* Locking IOCTL support (drm_lock.h) */ 1147 - extern int drm_lock(struct drm_device *dev, void *data, 1148 - struct drm_file *file_priv); 1149 - extern int drm_unlock(struct drm_device *dev, void *data, 1150 - struct drm_file *file_priv); 1151 - extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context); 1152 - extern void drm_idlelock_take(struct drm_lock_data *lock_data); 1153 - extern void drm_idlelock_release(struct drm_lock_data *lock_data); 1154 - 1155 1146 /* 1156 1147 * These are exported to drivers so that they can implement fencing using 1157 1148 * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. 1158 1149 */ 1159 - 1160 - extern int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv); 1161 1150 1162 1151 /* DMA support (drm_dma.h) */ 1163 1152 extern int drm_legacy_dma_setup(struct drm_device *dev); ··· 1351 1362 int drm_legacy_addbufs_pci(struct drm_device *d, struct drm_buf_desc *req); 1352 1363 1353 1364 void drm_legacy_vma_flush(struct drm_device *d); 1365 + 1366 + void drm_legacy_idlelock_take(struct drm_lock_data *lock); 1367 + void drm_legacy_idlelock_release(struct drm_lock_data *lock); 1354 1368 1355 1369 /* sysfs support (drm_sysfs.c) */ 1356 1370 struct drm_sysfs_class;