aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--drivers/char/drm/drmP.h112
-rw-r--r--drivers/char/drm/drm_agpsupport.c53
-rw-r--r--drivers/char/drm/drm_auth.c26
-rw-r--r--drivers/char/drm/drm_bufs.c66
-rw-r--r--drivers/char/drm/drm_context.c56
-rw-r--r--drivers/char/drm/drm_dma.c11
-rw-r--r--drivers/char/drm/drm_drv.c27
-rw-r--r--drivers/char/drm/drm_fops.c34
-rw-r--r--drivers/char/drm/drm_ioc32.c2
-rw-r--r--drivers/char/drm/drm_ioctl.c39
-rw-r--r--drivers/char/drm/drm_irq.c19
-rw-r--r--drivers/char/drm/drm_lock.c26
-rw-r--r--drivers/char/drm/drm_os_linux.h9
-rw-r--r--drivers/char/drm/drm_scatter.c10
-rw-r--r--drivers/char/drm/drm_vm.c4
-rw-r--r--drivers/char/drm/i810_dma.c127
-rw-r--r--drivers/char/drm/i810_drv.h7
-rw-r--r--drivers/char/drm/i830_dma.c99
-rw-r--r--drivers/char/drm/i830_drv.h9
-rw-r--r--drivers/char/drm/i830_irq.c16
-rw-r--r--drivers/char/drm/i915_dma.c12
-rw-r--r--drivers/char/drm/i915_drv.h7
-rw-r--r--drivers/char/drm/i915_irq.c2
-rw-r--r--drivers/char/drm/i915_mem.c41
-rw-r--r--drivers/char/drm/mga_dma.c15
-rw-r--r--drivers/char/drm/mga_state.c12
-rw-r--r--drivers/char/drm/r128_cce.c24
-rw-r--r--drivers/char/drm/r128_drv.h3
-rw-r--r--drivers/char/drm/r128_state.c43
-rw-r--r--drivers/char/drm/r300_cmdbuf.c8
-rw-r--r--drivers/char/drm/radeon_cp.c31
-rw-r--r--drivers/char/drm/radeon_drv.h13
-rw-r--r--drivers/char/drm/radeon_irq.c2
-rw-r--r--drivers/char/drm/radeon_mem.c40
-rw-r--r--drivers/char/drm/radeon_state.c195
-rw-r--r--drivers/char/drm/savage_bci.c20
-rw-r--r--drivers/char/drm/savage_drv.h3
-rw-r--r--drivers/char/drm/savage_state.c2
-rw-r--r--drivers/char/drm/sis_drv.h3
-rw-r--r--drivers/char/drm/sis_mm.c16
-rw-r--r--drivers/char/drm/via_dma.c8
-rw-r--r--drivers/char/drm/via_drv.h2
-rw-r--r--drivers/char/drm/via_mm.c10
43 files changed, 603 insertions, 661 deletions
diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h
index 0df87fc3dcb2..9c53b8883139 100644
--- a/drivers/char/drm/drmP.h
+++ b/drivers/char/drm/drmP.h
@@ -34,6 +34,8 @@
34#ifndef _DRM_P_H_ 34#ifndef _DRM_P_H_
35#define _DRM_P_H_ 35#define _DRM_P_H_
36 36
37struct drm_file;
38
37/* If you want the memory alloc debug functionality, change define below */ 39/* If you want the memory alloc debug functionality, change define below */
38/* #define DEBUG_MEMORY */ 40/* #define DEBUG_MEMORY */
39 41
@@ -257,11 +259,11 @@ do { \
257 * Ioctl function type. 259 * Ioctl function type.
258 * 260 *
259 * \param inode device inode. 261 * \param inode device inode.
260 * \param filp file pointer. 262 * \param file_priv DRM file private pointer.
261 * \param cmd command. 263 * \param cmd command.
262 * \param arg argument. 264 * \param arg argument.
263 */ 265 */
264typedef int drm_ioctl_t(struct inode *inode, struct file *filp, 266typedef int drm_ioctl_t(struct inode *inode, struct drm_file *file_priv,
265 unsigned int cmd, unsigned long arg); 267 unsigned int cmd, unsigned long arg);
266 268
267typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd, 269typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
@@ -304,7 +306,7 @@ struct drm_buf {
304 __volatile__ int waiting; /**< On kernel DMA queue */ 306 __volatile__ int waiting; /**< On kernel DMA queue */
305 __volatile__ int pending; /**< On hardware DMA queue */ 307 __volatile__ int pending; /**< On hardware DMA queue */
306 wait_queue_head_t dma_wait; /**< Processes waiting */ 308 wait_queue_head_t dma_wait; /**< Processes waiting */
307 struct file *filp; /**< Pointer to holding file descr */ 309 struct drm_file *file_priv; /**< Private of holding file descr */
308 int context; /**< Kernel queue for this buffer */ 310 int context; /**< Kernel queue for this buffer */
309 int while_locked; /**< Dispatch this buffer while locked */ 311 int while_locked; /**< Dispatch this buffer while locked */
310 enum { 312 enum {
@@ -377,6 +379,7 @@ struct drm_file {
377 int remove_auth_on_close; 379 int remove_auth_on_close;
378 unsigned long lock_count; 380 unsigned long lock_count;
379 void *driver_priv; 381 void *driver_priv;
382 struct file *filp;
380}; 383};
381 384
382/** Wait queue */ 385/** Wait queue */
@@ -403,7 +406,7 @@ struct drm_queue {
403 */ 406 */
404struct drm_lock_data { 407struct drm_lock_data {
405 struct drm_hw_lock *hw_lock; /**< Hardware lock */ 408 struct drm_hw_lock *hw_lock; /**< Hardware lock */
406 struct file *filp; /**< File descr of lock holder (0=kernel) */ 409 struct drm_file *file_priv; /**< File descr of lock holder (0=kernel) */
407 wait_queue_head_t lock_queue; /**< Queue of blocked processes */ 410 wait_queue_head_t lock_queue; /**< Queue of blocked processes */
408 unsigned long lock_time; /**< Time of last lock in jiffies */ 411 unsigned long lock_time; /**< Time of last lock in jiffies */
409 spinlock_t spinlock; 412 spinlock_t spinlock;
@@ -552,7 +555,7 @@ struct drm_driver {
552 int (*load) (struct drm_device *, unsigned long flags); 555 int (*load) (struct drm_device *, unsigned long flags);
553 int (*firstopen) (struct drm_device *); 556 int (*firstopen) (struct drm_device *);
554 int (*open) (struct drm_device *, struct drm_file *); 557 int (*open) (struct drm_device *, struct drm_file *);
555 void (*preclose) (struct drm_device *, struct file * filp); 558 void (*preclose) (struct drm_device *, struct drm_file *file_priv);
556 void (*postclose) (struct drm_device *, struct drm_file *); 559 void (*postclose) (struct drm_device *, struct drm_file *);
557 void (*lastclose) (struct drm_device *); 560 void (*lastclose) (struct drm_device *);
558 int (*unload) (struct drm_device *); 561 int (*unload) (struct drm_device *);
@@ -587,11 +590,12 @@ struct drm_driver {
587 void (*irq_preinstall) (struct drm_device *dev); 590 void (*irq_preinstall) (struct drm_device *dev);
588 void (*irq_postinstall) (struct drm_device *dev); 591 void (*irq_postinstall) (struct drm_device *dev);
589 void (*irq_uninstall) (struct drm_device *dev); 592 void (*irq_uninstall) (struct drm_device *dev);
590 void (*reclaim_buffers) (struct drm_device *dev, struct file * filp); 593 void (*reclaim_buffers) (struct drm_device *dev,
594 struct drm_file * file_priv);
591 void (*reclaim_buffers_locked) (struct drm_device *dev, 595 void (*reclaim_buffers_locked) (struct drm_device *dev,
592 struct file *filp); 596 struct drm_file *file_priv);
593 void (*reclaim_buffers_idlelocked) (struct drm_device *dev, 597 void (*reclaim_buffers_idlelocked) (struct drm_device *dev,
594 struct file * filp); 598 struct drm_file *file_priv);
595 unsigned long (*get_map_ofs) (struct drm_map * map); 599 unsigned long (*get_map_ofs) (struct drm_map * map);
596 unsigned long (*get_reg_ofs) (struct drm_device *dev); 600 unsigned long (*get_reg_ofs) (struct drm_device *dev);
597 void (*set_version) (struct drm_device *dev, 601 void (*set_version) (struct drm_device *dev,
@@ -850,69 +854,69 @@ extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start);
850extern int drm_unbind_agp(DRM_AGP_MEM * handle); 854extern int drm_unbind_agp(DRM_AGP_MEM * handle);
851 855
852 /* Misc. IOCTL support (drm_ioctl.h) */ 856 /* Misc. IOCTL support (drm_ioctl.h) */
853extern int drm_irq_by_busid(struct inode *inode, struct file *filp, 857extern int drm_irq_by_busid(struct inode *inode, struct drm_file *file_priv,
854 unsigned int cmd, unsigned long arg); 858 unsigned int cmd, unsigned long arg);
855extern int drm_getunique(struct inode *inode, struct file *filp, 859extern int drm_getunique(struct inode *inode, struct drm_file *file_priv,
856 unsigned int cmd, unsigned long arg); 860 unsigned int cmd, unsigned long arg);
857extern int drm_setunique(struct inode *inode, struct file *filp, 861extern int drm_setunique(struct inode *inode, struct drm_file *file_priv,
858 unsigned int cmd, unsigned long arg); 862 unsigned int cmd, unsigned long arg);
859extern int drm_getmap(struct inode *inode, struct file *filp, 863extern int drm_getmap(struct inode *inode, struct drm_file *file_priv,
860 unsigned int cmd, unsigned long arg); 864 unsigned int cmd, unsigned long arg);
861extern int drm_getclient(struct inode *inode, struct file *filp, 865extern int drm_getclient(struct inode *inode, struct drm_file *file_priv,
862 unsigned int cmd, unsigned long arg); 866 unsigned int cmd, unsigned long arg);
863extern int drm_getstats(struct inode *inode, struct file *filp, 867extern int drm_getstats(struct inode *inode, struct drm_file *file_priv,
864 unsigned int cmd, unsigned long arg); 868 unsigned int cmd, unsigned long arg);
865extern int drm_setversion(struct inode *inode, struct file *filp, 869extern int drm_setversion(struct inode *inode, struct drm_file *file_priv,
866 unsigned int cmd, unsigned long arg); 870 unsigned int cmd, unsigned long arg);
867extern int drm_noop(struct inode *inode, struct file *filp, 871extern int drm_noop(struct inode *inode, struct drm_file *file_priv,
868 unsigned int cmd, unsigned long arg); 872 unsigned int cmd, unsigned long arg);
869 873
870 /* Context IOCTL support (drm_context.h) */ 874 /* Context IOCTL support (drm_context.h) */
871extern int drm_resctx(struct inode *inode, struct file *filp, 875extern int drm_resctx(struct inode *inode, struct drm_file *file_priv,
872 unsigned int cmd, unsigned long arg); 876 unsigned int cmd, unsigned long arg);
873extern int drm_addctx(struct inode *inode, struct file *filp, 877extern int drm_addctx(struct inode *inode, struct drm_file *file_priv,
874 unsigned int cmd, unsigned long arg); 878 unsigned int cmd, unsigned long arg);
875extern int drm_modctx(struct inode *inode, struct file *filp, 879extern int drm_modctx(struct inode *inode, struct drm_file *file_priv,
876 unsigned int cmd, unsigned long arg); 880 unsigned int cmd, unsigned long arg);
877extern int drm_getctx(struct inode *inode, struct file *filp, 881extern int drm_getctx(struct inode *inode, struct drm_file *file_priv,
878 unsigned int cmd, unsigned long arg); 882 unsigned int cmd, unsigned long arg);
879extern int drm_switchctx(struct inode *inode, struct file *filp, 883extern int drm_switchctx(struct inode *inode, struct drm_file *file_priv,
880 unsigned int cmd, unsigned long arg); 884 unsigned int cmd, unsigned long arg);
881extern int drm_newctx(struct inode *inode, struct file *filp, 885extern int drm_newctx(struct inode *inode, struct drm_file *file_priv,
882 unsigned int cmd, unsigned long arg); 886 unsigned int cmd, unsigned long arg);
883extern int drm_rmctx(struct inode *inode, struct file *filp, 887extern int drm_rmctx(struct inode *inode, struct drm_file *file_priv,
884 unsigned int cmd, unsigned long arg); 888 unsigned int cmd, unsigned long arg);
885 889
886extern int drm_ctxbitmap_init(struct drm_device *dev); 890extern int drm_ctxbitmap_init(struct drm_device *dev);
887extern void drm_ctxbitmap_cleanup(struct drm_device *dev); 891extern void drm_ctxbitmap_cleanup(struct drm_device *dev);
888extern void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle); 892extern void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
889 893
890extern int drm_setsareactx(struct inode *inode, struct file *filp, 894extern int drm_setsareactx(struct inode *inode, struct drm_file *file_priv,
891 unsigned int cmd, unsigned long arg); 895 unsigned int cmd, unsigned long arg);
892extern int drm_getsareactx(struct inode *inode, struct file *filp, 896extern int drm_getsareactx(struct inode *inode, struct drm_file *file_priv,
893 unsigned int cmd, unsigned long arg); 897 unsigned int cmd, unsigned long arg);
894 898
895 /* Drawable IOCTL support (drm_drawable.h) */ 899 /* Drawable IOCTL support (drm_drawable.h) */
896extern int drm_adddraw(struct inode *inode, struct file *filp, 900extern int drm_adddraw(struct inode *inode, struct drm_file *file_priv,
897 unsigned int cmd, unsigned long arg); 901 unsigned int cmd, unsigned long arg);
898extern int drm_rmdraw(struct inode *inode, struct file *filp, 902extern int drm_rmdraw(struct inode *inode, struct drm_file *file_priv,
899 unsigned int cmd, unsigned long arg); 903 unsigned int cmd, unsigned long arg);
900extern int drm_update_drawable_info(struct inode *inode, struct file *filp, 904extern int drm_update_drawable_info(struct inode *inode, struct drm_file *file_priv,
901 unsigned int cmd, unsigned long arg); 905 unsigned int cmd, unsigned long arg);
902extern struct drm_drawable_info *drm_get_drawable_info(struct drm_device *dev, 906extern struct drm_drawable_info *drm_get_drawable_info(struct drm_device *dev,
903 drm_drawable_t id); 907 drm_drawable_t id);
904extern void drm_drawable_free_all(struct drm_device *dev); 908extern void drm_drawable_free_all(struct drm_device *dev);
905 909
906 /* Authentication IOCTL support (drm_auth.h) */ 910 /* Authentication IOCTL support (drm_auth.h) */
907extern int drm_getmagic(struct inode *inode, struct file *filp, 911extern int drm_getmagic(struct inode *inode, struct drm_file *file_priv,
908 unsigned int cmd, unsigned long arg); 912 unsigned int cmd, unsigned long arg);
909extern int drm_authmagic(struct inode *inode, struct file *filp, 913extern int drm_authmagic(struct inode *inode, struct drm_file *file_priv,
910 unsigned int cmd, unsigned long arg); 914 unsigned int cmd, unsigned long arg);
911 915
912 /* Locking IOCTL support (drm_lock.h) */ 916 /* Locking IOCTL support (drm_lock.h) */
913extern int drm_lock(struct inode *inode, struct file *filp, 917extern int drm_lock(struct inode *inode, struct drm_file *file_priv,
914 unsigned int cmd, unsigned long arg); 918 unsigned int cmd, unsigned long arg);
915extern int drm_unlock(struct inode *inode, struct file *filp, 919extern int drm_unlock(struct inode *inode, struct drm_file *file_priv,
916 unsigned int cmd, unsigned long arg); 920 unsigned int cmd, unsigned long arg);
917extern int drm_lock_take(struct drm_lock_data *lock_data, unsigned int context); 921extern int drm_lock_take(struct drm_lock_data *lock_data, unsigned int context);
918extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context); 922extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context);
@@ -924,8 +928,7 @@ extern void drm_idlelock_release(struct drm_lock_data *lock_data);
924 * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. 928 * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
925 */ 929 */
926 930
927extern int drm_i_have_hw_lock(struct file *filp); 931extern int drm_i_have_hw_lock(struct drm_file *file_priv);
928extern int drm_kernel_take_hw_lock(struct file *filp);
929 932
930 /* Buffer management support (drm_bufs.h) */ 933 /* Buffer management support (drm_bufs.h) */
931extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request); 934extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request);
@@ -933,23 +936,23 @@ extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request
933extern int drm_addmap(struct drm_device *dev, unsigned int offset, 936extern int drm_addmap(struct drm_device *dev, unsigned int offset,
934 unsigned int size, enum drm_map_type type, 937 unsigned int size, enum drm_map_type type,
935 enum drm_map_flags flags, drm_local_map_t ** map_ptr); 938 enum drm_map_flags flags, drm_local_map_t ** map_ptr);
936extern int drm_addmap_ioctl(struct inode *inode, struct file *filp, 939extern int drm_addmap_ioctl(struct inode *inode, struct drm_file *file_priv,
937 unsigned int cmd, unsigned long arg); 940 unsigned int cmd, unsigned long arg);
938extern int drm_rmmap(struct drm_device *dev, drm_local_map_t * map); 941extern int drm_rmmap(struct drm_device *dev, drm_local_map_t * map);
939extern int drm_rmmap_locked(struct drm_device *dev, drm_local_map_t * map); 942extern int drm_rmmap_locked(struct drm_device *dev, drm_local_map_t * map);
940extern int drm_rmmap_ioctl(struct inode *inode, struct file *filp, 943extern int drm_rmmap_ioctl(struct inode *inode, struct drm_file *file_priv,
941 unsigned int cmd, unsigned long arg); 944 unsigned int cmd, unsigned long arg);
942 945
943extern int drm_order(unsigned long size); 946extern int drm_order(unsigned long size);
944extern int drm_addbufs(struct inode *inode, struct file *filp, 947extern int drm_addbufs(struct inode *inode, struct drm_file *file_priv,
945 unsigned int cmd, unsigned long arg); 948 unsigned int cmd, unsigned long arg);
946extern int drm_infobufs(struct inode *inode, struct file *filp, 949extern int drm_infobufs(struct inode *inode, struct drm_file *file_priv,
947 unsigned int cmd, unsigned long arg); 950 unsigned int cmd, unsigned long arg);
948extern int drm_markbufs(struct inode *inode, struct file *filp, 951extern int drm_markbufs(struct inode *inode, struct drm_file *file_priv,
949 unsigned int cmd, unsigned long arg); 952 unsigned int cmd, unsigned long arg);
950extern int drm_freebufs(struct inode *inode, struct file *filp, 953extern int drm_freebufs(struct inode *inode, struct drm_file *file_priv,
951 unsigned int cmd, unsigned long arg); 954 unsigned int cmd, unsigned long arg);
952extern int drm_mapbufs(struct inode *inode, struct file *filp, 955extern int drm_mapbufs(struct inode *inode, struct drm_file *file_priv,
953 unsigned int cmd, unsigned long arg); 956 unsigned int cmd, unsigned long arg);
954extern unsigned long drm_get_resource_start(struct drm_device *dev, 957extern unsigned long drm_get_resource_start(struct drm_device *dev,
955 unsigned int resource); 958 unsigned int resource);
@@ -960,10 +963,11 @@ extern unsigned long drm_get_resource_len(struct drm_device *dev,
960extern int drm_dma_setup(struct drm_device *dev); 963extern int drm_dma_setup(struct drm_device *dev);
961extern void drm_dma_takedown(struct drm_device *dev); 964extern void drm_dma_takedown(struct drm_device *dev);
962extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf); 965extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf);
963extern void drm_core_reclaim_buffers(struct drm_device *dev, struct file *filp); 966extern void drm_core_reclaim_buffers(struct drm_device *dev,
967 struct drm_file *filp);
964 968
965 /* IRQ support (drm_irq.h) */ 969 /* IRQ support (drm_irq.h) */
966extern int drm_control(struct inode *inode, struct file *filp, 970extern int drm_control(struct inode *inode, struct drm_file *file_priv,
967 unsigned int cmd, unsigned long arg); 971 unsigned int cmd, unsigned long arg);
968extern irqreturn_t drm_irq_handler(DRM_IRQ_ARGS); 972extern irqreturn_t drm_irq_handler(DRM_IRQ_ARGS);
969extern int drm_irq_uninstall(struct drm_device *dev); 973extern int drm_irq_uninstall(struct drm_device *dev);
@@ -971,7 +975,7 @@ extern void drm_driver_irq_preinstall(struct drm_device *dev);
971extern void drm_driver_irq_postinstall(struct drm_device *dev); 975extern void drm_driver_irq_postinstall(struct drm_device *dev);
972extern void drm_driver_irq_uninstall(struct drm_device *dev); 976extern void drm_driver_irq_uninstall(struct drm_device *dev);
973 977
974extern int drm_wait_vblank(struct inode *inode, struct file *filp, 978extern int drm_wait_vblank(struct inode *inode, struct drm_file *file_priv,
975 unsigned int cmd, unsigned long arg); 979 unsigned int cmd, unsigned long arg);
976extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq); 980extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq);
977extern void drm_vbl_send_signals(struct drm_device *dev); 981extern void drm_vbl_send_signals(struct drm_device *dev);
@@ -980,28 +984,28 @@ extern void drm_locked_tasklet(struct drm_device *dev, void(*func)(struct drm_de
980 /* AGP/GART support (drm_agpsupport.h) */ 984 /* AGP/GART support (drm_agpsupport.h) */
981extern struct drm_agp_head *drm_agp_init(struct drm_device *dev); 985extern struct drm_agp_head *drm_agp_init(struct drm_device *dev);
982extern int drm_agp_acquire(struct drm_device *dev); 986extern int drm_agp_acquire(struct drm_device *dev);
983extern int drm_agp_acquire_ioctl(struct inode *inode, struct file *filp, 987extern int drm_agp_acquire_ioctl(struct inode *inode, struct drm_file *file_priv,
984 unsigned int cmd, unsigned long arg); 988 unsigned int cmd, unsigned long arg);
985extern int drm_agp_release(struct drm_device *dev); 989extern int drm_agp_release(struct drm_device *dev);
986extern int drm_agp_release_ioctl(struct inode *inode, struct file *filp, 990extern int drm_agp_release_ioctl(struct inode *inode, struct drm_file *file_priv,
987 unsigned int cmd, unsigned long arg); 991 unsigned int cmd, unsigned long arg);
988extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode); 992extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode);
989extern int drm_agp_enable_ioctl(struct inode *inode, struct file *filp, 993extern int drm_agp_enable_ioctl(struct inode *inode, struct drm_file *file_priv,
990 unsigned int cmd, unsigned long arg); 994 unsigned int cmd, unsigned long arg);
991extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info * info); 995extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info * info);
992extern int drm_agp_info_ioctl(struct inode *inode, struct file *filp, 996extern int drm_agp_info_ioctl(struct inode *inode, struct drm_file *file_priv,
993 unsigned int cmd, unsigned long arg); 997 unsigned int cmd, unsigned long arg);
994extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request); 998extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request);
995extern int drm_agp_alloc_ioctl(struct inode *inode, struct file *filp, 999extern int drm_agp_alloc_ioctl(struct inode *inode, struct drm_file *file_priv,
996 unsigned int cmd, unsigned long arg); 1000 unsigned int cmd, unsigned long arg);
997extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request); 1001extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request);
998extern int drm_agp_free_ioctl(struct inode *inode, struct file *filp, 1002extern int drm_agp_free_ioctl(struct inode *inode, struct drm_file *file_priv,
999 unsigned int cmd, unsigned long arg); 1003 unsigned int cmd, unsigned long arg);
1000extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request); 1004extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request);
1001extern int drm_agp_unbind_ioctl(struct inode *inode, struct file *filp, 1005extern int drm_agp_unbind_ioctl(struct inode *inode, struct drm_file *file_priv,
1002 unsigned int cmd, unsigned long arg); 1006 unsigned int cmd, unsigned long arg);
1003extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request); 1007extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
1004extern int drm_agp_bind_ioctl(struct inode *inode, struct file *filp, 1008extern int drm_agp_bind_ioctl(struct inode *inode, struct drm_file *file_priv,
1005 unsigned int cmd, unsigned long arg); 1009 unsigned int cmd, unsigned long arg);
1006extern DRM_AGP_MEM *drm_agp_allocate_memory(struct agp_bridge_data *bridge, 1010extern DRM_AGP_MEM *drm_agp_allocate_memory(struct agp_bridge_data *bridge,
1007 size_t pages, u32 type); 1011 size_t pages, u32 type);
@@ -1033,9 +1037,9 @@ extern int drm_proc_cleanup(int minor,
1033 1037
1034 /* Scatter Gather Support (drm_scatter.h) */ 1038 /* Scatter Gather Support (drm_scatter.h) */
1035extern void drm_sg_cleanup(struct drm_sg_mem * entry); 1039extern void drm_sg_cleanup(struct drm_sg_mem * entry);
1036extern int drm_sg_alloc(struct inode *inode, struct file *filp, 1040extern int drm_sg_alloc(struct inode *inode, struct drm_file *file_priv,
1037 unsigned int cmd, unsigned long arg); 1041 unsigned int cmd, unsigned long arg);
1038extern int drm_sg_free(struct inode *inode, struct file *filp, 1042extern int drm_sg_free(struct inode *inode, struct drm_file *file_priv,
1039 unsigned int cmd, unsigned long arg); 1043 unsigned int cmd, unsigned long arg);
1040 1044
1041 /* ATI PCIGART support (ati_pcigart.h) */ 1045 /* ATI PCIGART support (ati_pcigart.h) */
diff --git a/drivers/char/drm/drm_agpsupport.c b/drivers/char/drm/drm_agpsupport.c
index 354f0e3674bf..6d7a69abdc62 100644
--- a/drivers/char/drm/drm_agpsupport.c
+++ b/drivers/char/drm/drm_agpsupport.c
@@ -40,7 +40,7 @@
40 * Get AGP information. 40 * Get AGP information.
41 * 41 *
42 * \param inode device inode. 42 * \param inode device inode.
43 * \param filp file pointer. 43 * \param file_priv DRM file private.
44 * \param cmd command. 44 * \param cmd command.
45 * \param arg pointer to a (output) drm_agp_info structure. 45 * \param arg pointer to a (output) drm_agp_info structure.
46 * \return zero on success or a negative number on failure. 46 * \return zero on success or a negative number on failure.
@@ -71,11 +71,10 @@ int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info)
71 71
72EXPORT_SYMBOL(drm_agp_info); 72EXPORT_SYMBOL(drm_agp_info);
73 73
74int drm_agp_info_ioctl(struct inode *inode, struct file *filp, 74int drm_agp_info_ioctl(struct inode *inode, struct drm_file *file_priv,
75 unsigned int cmd, unsigned long arg) 75 unsigned int cmd, unsigned long arg)
76{ 76{
77 struct drm_file *priv = filp->private_data; 77 struct drm_device *dev = file_priv->head->dev;
78 struct drm_device *dev = priv->head->dev;
79 struct drm_agp_info info; 78 struct drm_agp_info info;
80 int err; 79 int err;
81 80
@@ -115,7 +114,7 @@ EXPORT_SYMBOL(drm_agp_acquire);
115 * Acquire the AGP device (ioctl). 114 * Acquire the AGP device (ioctl).
116 * 115 *
117 * \param inode device inode. 116 * \param inode device inode.
118 * \param filp file pointer. 117 * \param file_priv DRM file private.
119 * \param cmd command. 118 * \param cmd command.
120 * \param arg user argument. 119 * \param arg user argument.
121 * \return zero on success or a negative number on failure. 120 * \return zero on success or a negative number on failure.
@@ -123,12 +122,10 @@ EXPORT_SYMBOL(drm_agp_acquire);
123 * Verifies the AGP device hasn't been acquired before and calls 122 * Verifies the AGP device hasn't been acquired before and calls
124 * \c agp_backend_acquire. 123 * \c agp_backend_acquire.
125 */ 124 */
126int drm_agp_acquire_ioctl(struct inode *inode, struct file *filp, 125int drm_agp_acquire_ioctl(struct inode *inode, struct drm_file *file_priv,
127 unsigned int cmd, unsigned long arg) 126 unsigned int cmd, unsigned long arg)
128{ 127{
129 struct drm_file *priv = filp->private_data; 128 return drm_agp_acquire((struct drm_device *) file_priv->head->dev);
130
131 return drm_agp_acquire((struct drm_device *) priv->head->dev);
132} 129}
133 130
134/** 131/**
@@ -149,11 +146,10 @@ int drm_agp_release(struct drm_device * dev)
149} 146}
150EXPORT_SYMBOL(drm_agp_release); 147EXPORT_SYMBOL(drm_agp_release);
151 148
152int drm_agp_release_ioctl(struct inode *inode, struct file *filp, 149int drm_agp_release_ioctl(struct inode *inode, struct drm_file *file_priv,
153 unsigned int cmd, unsigned long arg) 150 unsigned int cmd, unsigned long arg)
154{ 151{
155 struct drm_file *priv = filp->private_data; 152 struct drm_device *dev = file_priv->head->dev;
156 struct drm_device *dev = priv->head->dev;
157 153
158 return drm_agp_release(dev); 154 return drm_agp_release(dev);
159} 155}
@@ -182,11 +178,10 @@ int drm_agp_enable(struct drm_device * dev, struct drm_agp_mode mode)
182 178
183EXPORT_SYMBOL(drm_agp_enable); 179EXPORT_SYMBOL(drm_agp_enable);
184 180
185int drm_agp_enable_ioctl(struct inode *inode, struct file *filp, 181int drm_agp_enable_ioctl(struct inode *inode, struct drm_file *file_priv,
186 unsigned int cmd, unsigned long arg) 182 unsigned int cmd, unsigned long arg)
187{ 183{
188 struct drm_file *priv = filp->private_data; 184 struct drm_device *dev = file_priv->head->dev;
189 struct drm_device *dev = priv->head->dev;
190 struct drm_agp_mode mode; 185 struct drm_agp_mode mode;
191 186
192 if (copy_from_user(&mode, (struct drm_agp_mode __user *) arg, sizeof(mode))) 187 if (copy_from_user(&mode, (struct drm_agp_mode __user *) arg, sizeof(mode)))
@@ -199,7 +194,7 @@ int drm_agp_enable_ioctl(struct inode *inode, struct file *filp,
199 * Allocate AGP memory. 194 * Allocate AGP memory.
200 * 195 *
201 * \param inode device inode. 196 * \param inode device inode.
202 * \param filp file pointer. 197 * \param file_priv file private pointer.
203 * \param cmd command. 198 * \param cmd command.
204 * \param arg pointer to a drm_agp_buffer structure. 199 * \param arg pointer to a drm_agp_buffer structure.
205 * \return zero on success or a negative number on failure. 200 * \return zero on success or a negative number on failure.
@@ -241,11 +236,10 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
241} 236}
242EXPORT_SYMBOL(drm_agp_alloc); 237EXPORT_SYMBOL(drm_agp_alloc);
243 238
244int drm_agp_alloc_ioctl(struct inode *inode, struct file *filp, 239int drm_agp_alloc_ioctl(struct inode *inode, struct drm_file *file_priv,
245 unsigned int cmd, unsigned long arg) 240 unsigned int cmd, unsigned long arg)
246{ 241{
247 struct drm_file *priv = filp->private_data; 242 struct drm_device *dev = file_priv->head->dev;
248 struct drm_device *dev = priv->head->dev;
249 struct drm_agp_buffer request; 243 struct drm_agp_buffer request;
250 struct drm_agp_buffer __user *argp = (void __user *)arg; 244 struct drm_agp_buffer __user *argp = (void __user *)arg;
251 int err; 245 int err;
@@ -297,7 +291,7 @@ static struct drm_agp_mem *drm_agp_lookup_entry(struct drm_device * dev,
297 * Unbind AGP memory from the GATT (ioctl). 291 * Unbind AGP memory from the GATT (ioctl).
298 * 292 *
299 * \param inode device inode. 293 * \param inode device inode.
300 * \param filp file pointer. 294 * \param file_priv DRM file private.
301 * \param cmd command. 295 * \param cmd command.
302 * \param arg pointer to a drm_agp_binding structure. 296 * \param arg pointer to a drm_agp_binding structure.
303 * \return zero on success or a negative number on failure. 297 * \return zero on success or a negative number on failure.
@@ -323,11 +317,10 @@ int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request)
323} 317}
324EXPORT_SYMBOL(drm_agp_unbind); 318EXPORT_SYMBOL(drm_agp_unbind);
325 319
326int drm_agp_unbind_ioctl(struct inode *inode, struct file *filp, 320int drm_agp_unbind_ioctl(struct inode *inode, struct drm_file *file_priv,
327 unsigned int cmd, unsigned long arg) 321 unsigned int cmd, unsigned long arg)
328{ 322{
329 struct drm_file *priv = filp->private_data; 323 struct drm_device *dev = file_priv->head->dev;
330 struct drm_device *dev = priv->head->dev;
331 struct drm_agp_binding request; 324 struct drm_agp_binding request;
332 325
333 if (copy_from_user 326 if (copy_from_user
@@ -341,7 +334,7 @@ int drm_agp_unbind_ioctl(struct inode *inode, struct file *filp,
341 * Bind AGP memory into the GATT (ioctl) 334 * Bind AGP memory into the GATT (ioctl)
342 * 335 *
343 * \param inode device inode. 336 * \param inode device inode.
344 * \param filp file pointer. 337 * \param file_priv DRM file private.
345 * \param cmd command. 338 * \param cmd command.
346 * \param arg pointer to a drm_agp_binding structure. 339 * \param arg pointer to a drm_agp_binding structure.
347 * \return zero on success or a negative number on failure. 340 * \return zero on success or a negative number on failure.
@@ -372,11 +365,10 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
372} 365}
373EXPORT_SYMBOL(drm_agp_bind); 366EXPORT_SYMBOL(drm_agp_bind);
374 367
375int drm_agp_bind_ioctl(struct inode *inode, struct file *filp, 368int drm_agp_bind_ioctl(struct inode *inode, struct drm_file *file_priv,
376 unsigned int cmd, unsigned long arg) 369 unsigned int cmd, unsigned long arg)
377{ 370{
378 struct drm_file *priv = filp->private_data; 371 struct drm_device *dev = file_priv->head->dev;
379 struct drm_device *dev = priv->head->dev;
380 struct drm_agp_binding request; 372 struct drm_agp_binding request;
381 373
382 if (copy_from_user 374 if (copy_from_user
@@ -390,7 +382,7 @@ int drm_agp_bind_ioctl(struct inode *inode, struct file *filp,
390 * Free AGP memory (ioctl). 382 * Free AGP memory (ioctl).
391 * 383 *
392 * \param inode device inode. 384 * \param inode device inode.
393 * \param filp file pointer. 385 * \param file_priv DRM file private.
394 * \param cmd command. 386 * \param cmd command.
395 * \param arg pointer to a drm_agp_buffer structure. 387 * \param arg pointer to a drm_agp_buffer structure.
396 * \return zero on success or a negative number on failure. 388 * \return zero on success or a negative number on failure.
@@ -419,11 +411,10 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
419} 411}
420EXPORT_SYMBOL(drm_agp_free); 412EXPORT_SYMBOL(drm_agp_free);
421 413
422int drm_agp_free_ioctl(struct inode *inode, struct file *filp, 414int drm_agp_free_ioctl(struct inode *inode, struct drm_file *file_priv,
423 unsigned int cmd, unsigned long arg) 415 unsigned int cmd, unsigned long arg)
424{ 416{
425 struct drm_file *priv = filp->private_data; 417 struct drm_device *dev = file_priv->head->dev;
426 struct drm_device *dev = priv->head->dev;
427 struct drm_agp_buffer request; 418 struct drm_agp_buffer request;
428 419
429 if (copy_from_user 420 if (copy_from_user
diff --git a/drivers/char/drm/drm_auth.c b/drivers/char/drm/drm_auth.c
index 7f777da872cd..dc66cfef7ec3 100644
--- a/drivers/char/drm/drm_auth.c
+++ b/drivers/char/drm/drm_auth.c
@@ -128,27 +128,26 @@ static int drm_remove_magic(struct drm_device * dev, drm_magic_t magic)
128 * Get a unique magic number (ioctl). 128 * Get a unique magic number (ioctl).
129 * 129 *
130 * \param inode device inode. 130 * \param inode device inode.
131 * \param filp file pointer. 131 * \param file_priv DRM file private.
132 * \param cmd command. 132 * \param cmd command.
133 * \param arg pointer to a resulting drm_auth structure. 133 * \param arg pointer to a resulting drm_auth structure.
134 * \return zero on success, or a negative number on failure. 134 * \return zero on success, or a negative number on failure.
135 * 135 *
136 * If there is a magic number in drm_file::magic then use it, otherwise 136 * If there is a magic number in drm_file::magic then use it, otherwise
137 * searches an unique non-zero magic number and add it associating it with \p 137 * searches an unique non-zero magic number and add it associating it with \p
138 * filp. 138 * file_priv.
139 */ 139 */
140int drm_getmagic(struct inode *inode, struct file *filp, 140int drm_getmagic(struct inode *inode, struct drm_file *file_priv,
141 unsigned int cmd, unsigned long arg) 141 unsigned int cmd, unsigned long arg)
142{ 142{
143 static drm_magic_t sequence = 0; 143 static drm_magic_t sequence = 0;
144 static DEFINE_SPINLOCK(lock); 144 static DEFINE_SPINLOCK(lock);
145 struct drm_file *priv = filp->private_data; 145 struct drm_device *dev = file_priv->head->dev;
146 struct drm_device *dev = priv->head->dev;
147 struct drm_auth auth; 146 struct drm_auth auth;
148 147
149 /* Find unique magic */ 148 /* Find unique magic */
150 if (priv->magic) { 149 if (file_priv->magic) {
151 auth.magic = priv->magic; 150 auth.magic = file_priv->magic;
152 } else { 151 } else {
153 do { 152 do {
154 spin_lock(&lock); 153 spin_lock(&lock);
@@ -157,8 +156,8 @@ int drm_getmagic(struct inode *inode, struct file *filp,
157 auth.magic = sequence++; 156 auth.magic = sequence++;
158 spin_unlock(&lock); 157 spin_unlock(&lock);
159 } while (drm_find_file(dev, auth.magic)); 158 } while (drm_find_file(dev, auth.magic));
160 priv->magic = auth.magic; 159 file_priv->magic = auth.magic;
161 drm_add_magic(dev, priv, auth.magic); 160 drm_add_magic(dev, file_priv, auth.magic);
162 } 161 }
163 162
164 DRM_DEBUG("%u\n", auth.magic); 163 DRM_DEBUG("%u\n", auth.magic);
@@ -171,18 +170,17 @@ int drm_getmagic(struct inode *inode, struct file *filp,
171 * Authenticate with a magic. 170 * Authenticate with a magic.
172 * 171 *
173 * \param inode device inode. 172 * \param inode device inode.
174 * \param filp file pointer. 173 * \param file_priv DRM file private.
175 * \param cmd command. 174 * \param cmd command.
176 * \param arg pointer to a drm_auth structure. 175 * \param arg pointer to a drm_auth structure.
177 * \return zero if authentication successed, or a negative number otherwise. 176 * \return zero if authentication successed, or a negative number otherwise.
178 * 177 *
179 * Checks if \p filp is associated with the magic number passed in \arg. 178 * Checks if \p file_priv is associated with the magic number passed in \arg.
180 */ 179 */
181int drm_authmagic(struct inode *inode, struct file *filp, 180int drm_authmagic(struct inode *inode, struct drm_file *file_priv,
182 unsigned int cmd, unsigned long arg) 181 unsigned int cmd, unsigned long arg)
183{ 182{
184 struct drm_file *priv = filp->private_data; 183 struct drm_device *dev = file_priv->head->dev;
185 struct drm_device *dev = priv->head->dev;
186 struct drm_auth auth; 184 struct drm_auth auth;
187 struct drm_file *file; 185 struct drm_file *file;
188 186
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c
index c115b39b8517..e7253874fa8f 100644
--- a/drivers/char/drm/drm_bufs.c
+++ b/drivers/char/drm/drm_bufs.c
@@ -92,7 +92,7 @@ static int drm_map_handle(struct drm_device *dev, struct drm_hash_item *hash,
92 * Ioctl to specify a range of memory that is available for mapping by a non-root process. 92 * Ioctl to specify a range of memory that is available for mapping by a non-root process.
93 * 93 *
94 * \param inode device inode. 94 * \param inode device inode.
95 * \param filp file pointer. 95 * \param file_priv DRM file private.
96 * \param cmd command. 96 * \param cmd command.
97 * \param arg pointer to a drm_map structure. 97 * \param arg pointer to a drm_map structure.
98 * \return zero on success or a negative value on error. 98 * \return zero on success or a negative value on error.
@@ -332,19 +332,15 @@ int drm_addmap(struct drm_device * dev, unsigned int offset,
332 332
333EXPORT_SYMBOL(drm_addmap); 333EXPORT_SYMBOL(drm_addmap);
334 334
335int drm_addmap_ioctl(struct inode *inode, struct file *filp, 335int drm_addmap_ioctl(struct inode *inode, struct drm_file *file_priv,
336 unsigned int cmd, unsigned long arg) 336 unsigned int cmd, unsigned long arg)
337{ 337{
338 struct drm_file *priv = filp->private_data; 338 struct drm_device *dev = file_priv->head->dev;
339 struct drm_device *dev = priv->head->dev;
340 struct drm_map map; 339 struct drm_map map;
341 struct drm_map_list *maplist; 340 struct drm_map_list *maplist;
342 struct drm_map __user *argp = (void __user *)arg; 341 struct drm_map __user *argp = (void __user *)arg;
343 int err; 342 int err;
344 343
345 if (!(filp->f_mode & 3))
346 return -EACCES; /* Require read/write */
347
348 if (copy_from_user(&map, argp, sizeof(map))) { 344 if (copy_from_user(&map, argp, sizeof(map))) {
349 return -EFAULT; 345 return -EFAULT;
350 } 346 }
@@ -372,7 +368,7 @@ int drm_addmap_ioctl(struct inode *inode, struct file *filp,
372 * isn't in use. 368 * isn't in use.
373 * 369 *
374 * \param inode device inode. 370 * \param inode device inode.
375 * \param filp file pointer. 371 * \param file_priv DRM file private.
376 * \param cmd command. 372 * \param cmd command.
377 * \param arg pointer to a struct drm_map structure. 373 * \param arg pointer to a struct drm_map structure.
378 * \return zero on success or a negative value on error. 374 * \return zero on success or a negative value on error.
@@ -453,11 +449,10 @@ int drm_rmmap(struct drm_device *dev, drm_local_map_t *map)
453 * gets used by drivers that the server doesn't need to care about. This seems 449 * gets used by drivers that the server doesn't need to care about. This seems
454 * unlikely. 450 * unlikely.
455 */ 451 */
456int drm_rmmap_ioctl(struct inode *inode, struct file *filp, 452int drm_rmmap_ioctl(struct inode *inode, struct drm_file *file_priv,
457 unsigned int cmd, unsigned long arg) 453 unsigned int cmd, unsigned long arg)
458{ 454{
459 struct drm_file *priv = filp->private_data; 455 struct drm_device *dev = file_priv->head->dev;
460 struct drm_device *dev = priv->head->dev;
461 struct drm_map request; 456 struct drm_map request;
462 drm_local_map_t *map = NULL; 457 drm_local_map_t *map = NULL;
463 struct drm_map_list *r_list; 458 struct drm_map_list *r_list;
@@ -661,7 +656,7 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request)
661 buf->waiting = 0; 656 buf->waiting = 0;
662 buf->pending = 0; 657 buf->pending = 0;
663 init_waitqueue_head(&buf->dma_wait); 658 init_waitqueue_head(&buf->dma_wait);
664 buf->filp = NULL; 659 buf->file_priv = NULL;
665 660
666 buf->dev_priv_size = dev->driver->dev_priv_size; 661 buf->dev_priv_size = dev->driver->dev_priv_size;
667 buf->dev_private = drm_alloc(buf->dev_priv_size, DRM_MEM_BUFS); 662 buf->dev_private = drm_alloc(buf->dev_priv_size, DRM_MEM_BUFS);
@@ -872,7 +867,7 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request)
872 buf->waiting = 0; 867 buf->waiting = 0;
873 buf->pending = 0; 868 buf->pending = 0;
874 init_waitqueue_head(&buf->dma_wait); 869 init_waitqueue_head(&buf->dma_wait);
875 buf->filp = NULL; 870 buf->file_priv = NULL;
876 871
877 buf->dev_priv_size = dev->driver->dev_priv_size; 872 buf->dev_priv_size = dev->driver->dev_priv_size;
878 buf->dev_private = drm_alloc(buf->dev_priv_size, 873 buf->dev_private = drm_alloc(buf->dev_priv_size,
@@ -1050,7 +1045,7 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request
1050 buf->waiting = 0; 1045 buf->waiting = 0;
1051 buf->pending = 0; 1046 buf->pending = 0;
1052 init_waitqueue_head(&buf->dma_wait); 1047 init_waitqueue_head(&buf->dma_wait);
1053 buf->filp = NULL; 1048 buf->file_priv = NULL;
1054 1049
1055 buf->dev_priv_size = dev->driver->dev_priv_size; 1050 buf->dev_priv_size = dev->driver->dev_priv_size;
1056 buf->dev_private = drm_alloc(buf->dev_priv_size, DRM_MEM_BUFS); 1051 buf->dev_private = drm_alloc(buf->dev_priv_size, DRM_MEM_BUFS);
@@ -1211,7 +1206,7 @@ static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request
1211 buf->waiting = 0; 1206 buf->waiting = 0;
1212 buf->pending = 0; 1207 buf->pending = 0;
1213 init_waitqueue_head(&buf->dma_wait); 1208 init_waitqueue_head(&buf->dma_wait);
1214 buf->filp = NULL; 1209 buf->file_priv = NULL;
1215 1210
1216 buf->dev_priv_size = dev->driver->dev_priv_size; 1211 buf->dev_priv_size = dev->driver->dev_priv_size;
1217 buf->dev_private = drm_alloc(buf->dev_priv_size, DRM_MEM_BUFS); 1212 buf->dev_private = drm_alloc(buf->dev_priv_size, DRM_MEM_BUFS);
@@ -1275,7 +1270,7 @@ static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request
1275 * Add buffers for DMA transfers (ioctl). 1270 * Add buffers for DMA transfers (ioctl).
1276 * 1271 *
1277 * \param inode device inode. 1272 * \param inode device inode.
1278 * \param filp file pointer. 1273 * \param file_priv DRM file private.
1279 * \param cmd command. 1274 * \param cmd command.
1280 * \param arg pointer to a struct drm_buf_desc request. 1275 * \param arg pointer to a struct drm_buf_desc request.
1281 * \return zero on success or a negative number on failure. 1276 * \return zero on success or a negative number on failure.
@@ -1285,12 +1280,11 @@ static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request
1285 * addbufs_sg() or addbufs_pci() for AGP, scatter-gather or consistent 1280 * addbufs_sg() or addbufs_pci() for AGP, scatter-gather or consistent
1286 * PCI memory respectively. 1281 * PCI memory respectively.
1287 */ 1282 */
1288int drm_addbufs(struct inode *inode, struct file *filp, 1283int drm_addbufs(struct inode *inode, struct drm_file *file_priv,
1289 unsigned int cmd, unsigned long arg) 1284 unsigned int cmd, unsigned long arg)
1290{ 1285{
1291 struct drm_buf_desc request; 1286 struct drm_buf_desc request;
1292 struct drm_file *priv = filp->private_data; 1287 struct drm_device *dev = file_priv->head->dev;
1293 struct drm_device *dev = priv->head->dev;
1294 int ret; 1288 int ret;
1295 1289
1296 if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA)) 1290 if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
@@ -1328,7 +1322,7 @@ int drm_addbufs(struct inode *inode, struct file *filp,
1328 * large buffers can be used for image transfer). 1322 * large buffers can be used for image transfer).
1329 * 1323 *
1330 * \param inode device inode. 1324 * \param inode device inode.
1331 * \param filp file pointer. 1325 * \param file_priv DRM file private.
1332 * \param cmd command. 1326 * \param cmd command.
1333 * \param arg pointer to a drm_buf_info structure. 1327 * \param arg pointer to a drm_buf_info structure.
1334 * \return zero on success or a negative number on failure. 1328 * \return zero on success or a negative number on failure.
@@ -1337,11 +1331,10 @@ int drm_addbufs(struct inode *inode, struct file *filp,
1337 * lock, preventing of allocating more buffers after this call. Information 1331 * lock, preventing of allocating more buffers after this call. Information
1338 * about each requested buffer is then copied into user space. 1332 * about each requested buffer is then copied into user space.
1339 */ 1333 */
1340int drm_infobufs(struct inode *inode, struct file *filp, 1334int drm_infobufs(struct inode *inode, struct drm_file *file_priv,
1341 unsigned int cmd, unsigned long arg) 1335 unsigned int cmd, unsigned long arg)
1342{ 1336{
1343 struct drm_file *priv = filp->private_data; 1337 struct drm_device *dev = file_priv->head->dev;
1344 struct drm_device *dev = priv->head->dev;
1345 struct drm_device_dma *dma = dev->dma; 1338 struct drm_device_dma *dma = dev->dma;
1346 struct drm_buf_info request; 1339 struct drm_buf_info request;
1347 struct drm_buf_info __user *argp = (void __user *)arg; 1340 struct drm_buf_info __user *argp = (void __user *)arg;
@@ -1415,7 +1408,7 @@ int drm_infobufs(struct inode *inode, struct file *filp,
1415 * Specifies a low and high water mark for buffer allocation 1408 * Specifies a low and high water mark for buffer allocation
1416 * 1409 *
1417 * \param inode device inode. 1410 * \param inode device inode.
1418 * \param filp file pointer. 1411 * \param file_priv DRM file private.
1419 * \param cmd command. 1412 * \param cmd command.
1420 * \param arg a pointer to a drm_buf_desc structure. 1413 * \param arg a pointer to a drm_buf_desc structure.
1421 * \return zero on success or a negative number on failure. 1414 * \return zero on success or a negative number on failure.
@@ -1425,11 +1418,10 @@ int drm_infobufs(struct inode *inode, struct file *filp,
1425 * 1418 *
1426 * \note This ioctl is deprecated and mostly never used. 1419 * \note This ioctl is deprecated and mostly never used.
1427 */ 1420 */
1428int drm_markbufs(struct inode *inode, struct file *filp, 1421int drm_markbufs(struct inode *inode, struct drm_file *file_priv,
1429 unsigned int cmd, unsigned long arg) 1422 unsigned int cmd, unsigned long arg)
1430{ 1423{
1431 struct drm_file *priv = filp->private_data; 1424 struct drm_device *dev = file_priv->head->dev;
1432 struct drm_device *dev = priv->head->dev;
1433 struct drm_device_dma *dma = dev->dma; 1425 struct drm_device_dma *dma = dev->dma;
1434 struct drm_buf_desc request; 1426 struct drm_buf_desc request;
1435 int order; 1427 int order;
@@ -1467,7 +1459,7 @@ int drm_markbufs(struct inode *inode, struct file *filp,
1467 * Unreserve the buffers in list, previously reserved using drmDMA. 1459 * Unreserve the buffers in list, previously reserved using drmDMA.
1468 * 1460 *
1469 * \param inode device inode. 1461 * \param inode device inode.
1470 * \param filp file pointer. 1462 * \param file_priv DRM file private.
1471 * \param cmd command. 1463 * \param cmd command.
1472 * \param arg pointer to a drm_buf_free structure. 1464 * \param arg pointer to a drm_buf_free structure.
1473 * \return zero on success or a negative number on failure. 1465 * \return zero on success or a negative number on failure.
@@ -1475,11 +1467,10 @@ int drm_markbufs(struct inode *inode, struct file *filp,
1475 * Calls free_buffer() for each used buffer. 1467 * Calls free_buffer() for each used buffer.
1476 * This function is primarily used for debugging. 1468 * This function is primarily used for debugging.
1477 */ 1469 */
1478int drm_freebufs(struct inode *inode, struct file *filp, 1470int drm_freebufs(struct inode *inode, struct drm_file *file_priv,
1479 unsigned int cmd, unsigned long arg) 1471 unsigned int cmd, unsigned long arg)
1480{ 1472{
1481 struct drm_file *priv = filp->private_data; 1473 struct drm_device *dev = file_priv->head->dev;
1482 struct drm_device *dev = priv->head->dev;
1483 struct drm_device_dma *dma = dev->dma; 1474 struct drm_device_dma *dma = dev->dma;
1484 struct drm_buf_free request; 1475 struct drm_buf_free request;
1485 int i; 1476 int i;
@@ -1506,7 +1497,7 @@ int drm_freebufs(struct inode *inode, struct file *filp,
1506 return -EINVAL; 1497 return -EINVAL;
1507 } 1498 }
1508 buf = dma->buflist[idx]; 1499 buf = dma->buflist[idx];
1509 if (buf->filp != filp) { 1500 if (buf->file_priv != file_priv) {
1510 DRM_ERROR("Process %d freeing buffer not owned\n", 1501 DRM_ERROR("Process %d freeing buffer not owned\n",
1511 current->pid); 1502 current->pid);
1512 return -EINVAL; 1503 return -EINVAL;
@@ -1521,7 +1512,7 @@ int drm_freebufs(struct inode *inode, struct file *filp,
1521 * Maps all of the DMA buffers into client-virtual space (ioctl). 1512 * Maps all of the DMA buffers into client-virtual space (ioctl).
1522 * 1513 *
1523 * \param inode device inode. 1514 * \param inode device inode.
1524 * \param filp file pointer. 1515 * \param file_priv DRM file private.
1525 * \param cmd command. 1516 * \param cmd command.
1526 * \param arg pointer to a drm_buf_map structure. 1517 * \param arg pointer to a drm_buf_map structure.
1527 * \return zero on success or a negative number on failure. 1518 * \return zero on success or a negative number on failure.
@@ -1531,11 +1522,10 @@ int drm_freebufs(struct inode *inode, struct file *filp,
1531 * offset equal to 0, which drm_mmap() interpretes as PCI buffers and calls 1522 * offset equal to 0, which drm_mmap() interpretes as PCI buffers and calls
1532 * drm_mmap_dma(). 1523 * drm_mmap_dma().
1533 */ 1524 */
1534int drm_mapbufs(struct inode *inode, struct file *filp, 1525int drm_mapbufs(struct inode *inode, struct drm_file *file_priv,
1535 unsigned int cmd, unsigned long arg) 1526 unsigned int cmd, unsigned long arg)
1536{ 1527{
1537 struct drm_file *priv = filp->private_data; 1528 struct drm_device *dev = file_priv->head->dev;
1538 struct drm_device *dev = priv->head->dev;
1539 struct drm_device_dma *dma = dev->dma; 1529 struct drm_device_dma *dma = dev->dma;
1540 struct drm_buf_map __user *argp = (void __user *)arg; 1530 struct drm_buf_map __user *argp = (void __user *)arg;
1541 int retcode = 0; 1531 int retcode = 0;
@@ -1577,13 +1567,13 @@ int drm_mapbufs(struct inode *inode, struct file *filp,
1577 } 1567 }
1578 1568
1579 down_write(&current->mm->mmap_sem); 1569 down_write(&current->mm->mmap_sem);
1580 virtual = do_mmap(filp, 0, map->size, 1570 virtual = do_mmap(file_priv->filp, 0, map->size,
1581 PROT_READ | PROT_WRITE, 1571 PROT_READ | PROT_WRITE,
1582 MAP_SHARED, token); 1572 MAP_SHARED, token);
1583 up_write(&current->mm->mmap_sem); 1573 up_write(&current->mm->mmap_sem);
1584 } else { 1574 } else {
1585 down_write(&current->mm->mmap_sem); 1575 down_write(&current->mm->mmap_sem);
1586 virtual = do_mmap(filp, 0, dma->byte_count, 1576 virtual = do_mmap(file_priv->filp, 0, dma->byte_count,
1587 PROT_READ | PROT_WRITE, 1577 PROT_READ | PROT_WRITE,
1588 MAP_SHARED, 0); 1578 MAP_SHARED, 0);
1589 up_write(&current->mm->mmap_sem); 1579 up_write(&current->mm->mmap_sem);
diff --git a/drivers/char/drm/drm_context.c b/drivers/char/drm/drm_context.c
index 61ad986baa8d..4037a3602f1e 100644
--- a/drivers/char/drm/drm_context.c
+++ b/drivers/char/drm/drm_context.c
@@ -131,7 +131,7 @@ void drm_ctxbitmap_cleanup(struct drm_device * dev)
131 * Get per-context SAREA. 131 * Get per-context SAREA.
132 * 132 *
133 * \param inode device inode. 133 * \param inode device inode.
134 * \param filp file pointer. 134 * \param file_priv DRM file private.
135 * \param cmd command. 135 * \param cmd command.
136 * \param arg user argument pointing to a drm_ctx_priv_map structure. 136 * \param arg user argument pointing to a drm_ctx_priv_map structure.
137 * \return zero on success or a negative number on failure. 137 * \return zero on success or a negative number on failure.
@@ -139,11 +139,10 @@ void drm_ctxbitmap_cleanup(struct drm_device * dev)
139 * Gets the map from drm_device::ctx_idr with the handle specified and 139 * Gets the map from drm_device::ctx_idr with the handle specified and
140 * returns its handle. 140 * returns its handle.
141 */ 141 */
142int drm_getsareactx(struct inode *inode, struct file *filp, 142int drm_getsareactx(struct inode *inode, struct drm_file *file_priv,
143 unsigned int cmd, unsigned long arg) 143 unsigned int cmd, unsigned long arg)
144{ 144{
145 struct drm_file *priv = filp->private_data; 145 struct drm_device *dev = file_priv->head->dev;
146 struct drm_device *dev = priv->head->dev;
147 struct drm_ctx_priv_map __user *argp = (void __user *)arg; 146 struct drm_ctx_priv_map __user *argp = (void __user *)arg;
148 struct drm_ctx_priv_map request; 147 struct drm_ctx_priv_map request;
149 struct drm_map *map; 148 struct drm_map *map;
@@ -182,7 +181,7 @@ int drm_getsareactx(struct inode *inode, struct file *filp,
182 * Set per-context SAREA. 181 * Set per-context SAREA.
183 * 182 *
184 * \param inode device inode. 183 * \param inode device inode.
185 * \param filp file pointer. 184 * \param file_priv DRM file private.
186 * \param cmd command. 185 * \param cmd command.
187 * \param arg user argument pointing to a drm_ctx_priv_map structure. 186 * \param arg user argument pointing to a drm_ctx_priv_map structure.
188 * \return zero on success or a negative number on failure. 187 * \return zero on success or a negative number on failure.
@@ -190,11 +189,10 @@ int drm_getsareactx(struct inode *inode, struct file *filp,
190 * Searches the mapping specified in \p arg and update the entry in 189 * Searches the mapping specified in \p arg and update the entry in
191 * drm_device::ctx_idr with it. 190 * drm_device::ctx_idr with it.
192 */ 191 */
193int drm_setsareactx(struct inode *inode, struct file *filp, 192int drm_setsareactx(struct inode *inode, struct drm_file *file_priv,
194 unsigned int cmd, unsigned long arg) 193 unsigned int cmd, unsigned long arg)
195{ 194{
196 struct drm_file *priv = filp->private_data; 195 struct drm_device *dev = file_priv->head->dev;
197 struct drm_device *dev = priv->head->dev;
198 struct drm_ctx_priv_map request; 196 struct drm_ctx_priv_map request;
199 struct drm_map *map = NULL; 197 struct drm_map *map = NULL;
200 struct drm_map_list *r_list = NULL; 198 struct drm_map_list *r_list = NULL;
@@ -292,12 +290,12 @@ static int drm_context_switch_complete(struct drm_device * dev, int new)
292 * Reserve contexts. 290 * Reserve contexts.
293 * 291 *
294 * \param inode device inode. 292 * \param inode device inode.
295 * \param filp file pointer. 293 * \param file_priv DRM file private.
296 * \param cmd command. 294 * \param cmd command.
297 * \param arg user argument pointing to a drm_ctx_res structure. 295 * \param arg user argument pointing to a drm_ctx_res structure.
298 * \return zero on success or a negative number on failure. 296 * \return zero on success or a negative number on failure.
299 */ 297 */
300int drm_resctx(struct inode *inode, struct file *filp, 298int drm_resctx(struct inode *inode, struct drm_file *file_priv,
301 unsigned int cmd, unsigned long arg) 299 unsigned int cmd, unsigned long arg)
302{ 300{
303 struct drm_ctx_res res; 301 struct drm_ctx_res res;
@@ -327,18 +325,17 @@ int drm_resctx(struct inode *inode, struct file *filp,
327 * Add context. 325 * Add context.
328 * 326 *
329 * \param inode device inode. 327 * \param inode device inode.
330 * \param filp file pointer. 328 * \param file_priv DRM file private.
331 * \param cmd command. 329 * \param cmd command.
332 * \param arg user argument pointing to a drm_ctx structure. 330 * \param arg user argument pointing to a drm_ctx structure.
333 * \return zero on success or a negative number on failure. 331 * \return zero on success or a negative number on failure.
334 * 332 *
335 * Get a new handle for the context and copy to userspace. 333 * Get a new handle for the context and copy to userspace.
336 */ 334 */
337int drm_addctx(struct inode *inode, struct file *filp, 335int drm_addctx(struct inode *inode, struct drm_file *file_priv,
338 unsigned int cmd, unsigned long arg) 336 unsigned int cmd, unsigned long arg)
339{ 337{
340 struct drm_file *priv = filp->private_data; 338 struct drm_device *dev = file_priv->head->dev;
341 struct drm_device *dev = priv->head->dev;
342 struct drm_ctx_list *ctx_entry; 339 struct drm_ctx_list *ctx_entry;
343 struct drm_ctx __user *argp = (void __user *)arg; 340 struct drm_ctx __user *argp = (void __user *)arg;
344 struct drm_ctx ctx; 341 struct drm_ctx ctx;
@@ -374,7 +371,7 @@ int drm_addctx(struct inode *inode, struct file *filp,
374 371
375 INIT_LIST_HEAD(&ctx_entry->head); 372 INIT_LIST_HEAD(&ctx_entry->head);
376 ctx_entry->handle = ctx.handle; 373 ctx_entry->handle = ctx.handle;
377 ctx_entry->tag = priv; 374 ctx_entry->tag = file_priv;
378 375
379 mutex_lock(&dev->ctxlist_mutex); 376 mutex_lock(&dev->ctxlist_mutex);
380 list_add(&ctx_entry->head, &dev->ctxlist); 377 list_add(&ctx_entry->head, &dev->ctxlist);
@@ -386,7 +383,7 @@ int drm_addctx(struct inode *inode, struct file *filp,
386 return 0; 383 return 0;
387} 384}
388 385
389int drm_modctx(struct inode *inode, struct file *filp, 386int drm_modctx(struct inode *inode, struct drm_file *file_priv,
390 unsigned int cmd, unsigned long arg) 387 unsigned int cmd, unsigned long arg)
391{ 388{
392 /* This does nothing */ 389 /* This does nothing */
@@ -397,12 +394,12 @@ int drm_modctx(struct inode *inode, struct file *filp,
397 * Get context. 394 * Get context.
398 * 395 *
399 * \param inode device inode. 396 * \param inode device inode.
400 * \param filp file pointer. 397 * \param file_priv DRM file private.
401 * \param cmd command. 398 * \param cmd command.
402 * \param arg user argument pointing to a drm_ctx structure. 399 * \param arg user argument pointing to a drm_ctx structure.
403 * \return zero on success or a negative number on failure. 400 * \return zero on success or a negative number on failure.
404 */ 401 */
405int drm_getctx(struct inode *inode, struct file *filp, 402int drm_getctx(struct inode *inode, struct drm_file *file_priv,
406 unsigned int cmd, unsigned long arg) 403 unsigned int cmd, unsigned long arg)
407{ 404{
408 struct drm_ctx __user *argp = (void __user *)arg; 405 struct drm_ctx __user *argp = (void __user *)arg;
@@ -423,18 +420,17 @@ int drm_getctx(struct inode *inode, struct file *filp,
423 * Switch context. 420 * Switch context.
424 * 421 *
425 * \param inode device inode. 422 * \param inode device inode.
426 * \param filp file pointer. 423 * \param file_priv DRM file private.
427 * \param cmd command. 424 * \param cmd command.
428 * \param arg user argument pointing to a drm_ctx structure. 425 * \param arg user argument pointing to a drm_ctx structure.
429 * \return zero on success or a negative number on failure. 426 * \return zero on success or a negative number on failure.
430 * 427 *
431 * Calls context_switch(). 428 * Calls context_switch().
432 */ 429 */
433int drm_switchctx(struct inode *inode, struct file *filp, 430int drm_switchctx(struct inode *inode, struct drm_file *file_priv,
434 unsigned int cmd, unsigned long arg) 431 unsigned int cmd, unsigned long arg)
435{ 432{
436 struct drm_file *priv = filp->private_data; 433 struct drm_device *dev = file_priv->head->dev;
437 struct drm_device *dev = priv->head->dev;
438 struct drm_ctx ctx; 434 struct drm_ctx ctx;
439 435
440 if (copy_from_user(&ctx, (struct drm_ctx __user *) arg, sizeof(ctx))) 436 if (copy_from_user(&ctx, (struct drm_ctx __user *) arg, sizeof(ctx)))
@@ -448,18 +444,17 @@ int drm_switchctx(struct inode *inode, struct file *filp,
448 * New context. 444 * New context.
449 * 445 *
450 * \param inode device inode. 446 * \param inode device inode.
451 * \param filp file pointer. 447 * \param file_priv DRM file private.
452 * \param cmd command. 448 * \param cmd command.
453 * \param arg user argument pointing to a drm_ctx structure. 449 * \param arg user argument pointing to a drm_ctx structure.
454 * \return zero on success or a negative number on failure. 450 * \return zero on success or a negative number on failure.
455 * 451 *
456 * Calls context_switch_complete(). 452 * Calls context_switch_complete().
457 */ 453 */
458int drm_newctx(struct inode *inode, struct file *filp, 454int drm_newctx(struct inode *inode, struct drm_file *file_priv,
459 unsigned int cmd, unsigned long arg) 455 unsigned int cmd, unsigned long arg)
460{ 456{
461 struct drm_file *priv = filp->private_data; 457 struct drm_device *dev = file_priv->head->dev;
462 struct drm_device *dev = priv->head->dev;
463 struct drm_ctx ctx; 458 struct drm_ctx ctx;
464 459
465 if (copy_from_user(&ctx, (struct drm_ctx __user *) arg, sizeof(ctx))) 460 if (copy_from_user(&ctx, (struct drm_ctx __user *) arg, sizeof(ctx)))
@@ -475,18 +470,17 @@ int drm_newctx(struct inode *inode, struct file *filp,
475 * Remove context. 470 * Remove context.
476 * 471 *
477 * \param inode device inode. 472 * \param inode device inode.
478 * \param filp file pointer. 473 * \param file_priv DRM file private.
479 * \param cmd command. 474 * \param cmd command.
480 * \param arg user argument pointing to a drm_ctx structure. 475 * \param arg user argument pointing to a drm_ctx structure.
481 * \return zero on success or a negative number on failure. 476 * \return zero on success or a negative number on failure.
482 * 477 *
483 * If not the special kernel context, calls ctxbitmap_free() to free the specified context. 478 * If not the special kernel context, calls ctxbitmap_free() to free the specified context.
484 */ 479 */
485int drm_rmctx(struct inode *inode, struct file *filp, 480int drm_rmctx(struct inode *inode, struct drm_file *file_priv,
486 unsigned int cmd, unsigned long arg) 481 unsigned int cmd, unsigned long arg)
487{ 482{
488 struct drm_file *priv = filp->private_data; 483 struct drm_device *dev = file_priv->head->dev;
489 struct drm_device *dev = priv->head->dev;
490 struct drm_ctx ctx; 484 struct drm_ctx ctx;
491 485
492 if (copy_from_user(&ctx, (struct drm_ctx __user *) arg, sizeof(ctx))) 486 if (copy_from_user(&ctx, (struct drm_ctx __user *) arg, sizeof(ctx)))
@@ -494,7 +488,7 @@ int drm_rmctx(struct inode *inode, struct file *filp,
494 488
495 DRM_DEBUG("%d\n", ctx.handle); 489 DRM_DEBUG("%d\n", ctx.handle);
496 if (ctx.handle == DRM_KERNEL_CONTEXT + 1) { 490 if (ctx.handle == DRM_KERNEL_CONTEXT + 1) {
497 priv->remove_auth_on_close = 1; 491 file_priv->remove_auth_on_close = 1;
498 } 492 }
499 if (ctx.handle != DRM_KERNEL_CONTEXT) { 493 if (ctx.handle != DRM_KERNEL_CONTEXT) {
500 if (dev->driver->context_dtor) 494 if (dev->driver->context_dtor)
diff --git a/drivers/char/drm/drm_dma.c b/drivers/char/drm/drm_dma.c
index 802fbdbfe1b3..7a8e2fba4678 100644
--- a/drivers/char/drm/drm_dma.c
+++ b/drivers/char/drm/drm_dma.c
@@ -136,7 +136,7 @@ void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf)
136 136
137 buf->waiting = 0; 137 buf->waiting = 0;
138 buf->pending = 0; 138 buf->pending = 0;
139 buf->filp = NULL; 139 buf->file_priv = NULL;
140 buf->used = 0; 140 buf->used = 0;
141 141
142 if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) 142 if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE)
@@ -148,11 +148,12 @@ void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf)
148/** 148/**
149 * Reclaim the buffers. 149 * Reclaim the buffers.
150 * 150 *
151 * \param filp file pointer. 151 * \param file_priv DRM file private.
152 * 152 *
153 * Frees each buffer associated with \p filp not already on the hardware. 153 * Frees each buffer associated with \p file_priv not already on the hardware.
154 */ 154 */
155void drm_core_reclaim_buffers(struct drm_device *dev, struct file *filp) 155void drm_core_reclaim_buffers(struct drm_device *dev,
156 struct drm_file *file_priv)
156{ 157{
157 struct drm_device_dma *dma = dev->dma; 158 struct drm_device_dma *dma = dev->dma;
158 int i; 159 int i;
@@ -160,7 +161,7 @@ void drm_core_reclaim_buffers(struct drm_device *dev, struct file *filp)
160 if (!dma) 161 if (!dma)
161 return; 162 return;
162 for (i = 0; i < dma->buf_count; i++) { 163 for (i = 0; i < dma->buf_count; i++) {
163 if (dma->buflist[i]->filp == filp) { 164 if (dma->buflist[i]->file_priv == file_priv) {
164 switch (dma->buflist[i]->list) { 165 switch (dma->buflist[i]->list) {
165 case DRM_LIST_NONE: 166 case DRM_LIST_NONE:
166 drm_free_buffer(dev, dma->buflist[i]); 167 drm_free_buffer(dev, dma->buflist[i]);
diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c
index 19994cd865de..e7809237c53d 100644
--- a/drivers/char/drm/drm_drv.c
+++ b/drivers/char/drm/drm_drv.c
@@ -49,7 +49,7 @@
49#include "drmP.h" 49#include "drmP.h"
50#include "drm_core.h" 50#include "drm_core.h"
51 51
52static int drm_version(struct inode *inode, struct file *filp, 52static int drm_version(struct inode *inode, struct drm_file *file_priv,
53 unsigned int cmd, unsigned long arg); 53 unsigned int cmd, unsigned long arg);
54 54
55/** Ioctl table */ 55/** Ioctl table */
@@ -224,7 +224,7 @@ int drm_lastclose(struct drm_device * dev)
224 224
225 if (dev->lock.hw_lock) { 225 if (dev->lock.hw_lock) {
226 dev->sigdata.lock = dev->lock.hw_lock = NULL; /* SHM removed */ 226 dev->sigdata.lock = dev->lock.hw_lock = NULL; /* SHM removed */
227 dev->lock.filp = NULL; 227 dev->lock.file_priv = NULL;
228 wake_up_interruptible(&dev->lock.lock_queue); 228 wake_up_interruptible(&dev->lock.lock_queue);
229 } 229 }
230 mutex_unlock(&dev->struct_mutex); 230 mutex_unlock(&dev->struct_mutex);
@@ -418,11 +418,10 @@ module_exit(drm_core_exit);
418 * 418 *
419 * Fills in the version information in \p arg. 419 * Fills in the version information in \p arg.
420 */ 420 */
421static int drm_version(struct inode *inode, struct file *filp, 421static int drm_version(struct inode *inode, struct drm_file *file_priv,
422 unsigned int cmd, unsigned long arg) 422 unsigned int cmd, unsigned long arg)
423{ 423{
424 struct drm_file *priv = filp->private_data; 424 struct drm_device *dev = file_priv->head->dev;
425 struct drm_device *dev = priv->head->dev;
426 struct drm_version __user *argp = (void __user *)arg; 425 struct drm_version __user *argp = (void __user *)arg;
427 struct drm_version version; 426 struct drm_version version;
428 int len; 427 int len;
@@ -446,7 +445,7 @@ static int drm_version(struct inode *inode, struct file *filp,
446 * Called whenever a process performs an ioctl on /dev/drm. 445 * Called whenever a process performs an ioctl on /dev/drm.
447 * 446 *
448 * \param inode device inode. 447 * \param inode device inode.
449 * \param filp file pointer. 448 * \param file_priv DRM file private.
450 * \param cmd command. 449 * \param cmd command.
451 * \param arg user argument. 450 * \param arg user argument.
452 * \return zero on success or negative number on failure. 451 * \return zero on success or negative number on failure.
@@ -457,8 +456,8 @@ static int drm_version(struct inode *inode, struct file *filp,
457int drm_ioctl(struct inode *inode, struct file *filp, 456int drm_ioctl(struct inode *inode, struct file *filp,
458 unsigned int cmd, unsigned long arg) 457 unsigned int cmd, unsigned long arg)
459{ 458{
460 struct drm_file *priv = filp->private_data; 459 struct drm_file *file_priv = filp->private_data;
461 struct drm_device *dev = priv->head->dev; 460 struct drm_device *dev = file_priv->head->dev;
462 drm_ioctl_desc_t *ioctl; 461 drm_ioctl_desc_t *ioctl;
463 drm_ioctl_t *func; 462 drm_ioctl_t *func;
464 unsigned int nr = DRM_IOCTL_NR(cmd); 463 unsigned int nr = DRM_IOCTL_NR(cmd);
@@ -466,12 +465,12 @@ int drm_ioctl(struct inode *inode, struct file *filp,
466 465
467 atomic_inc(&dev->ioctl_count); 466 atomic_inc(&dev->ioctl_count);
468 atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]); 467 atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
469 ++priv->ioctl_count; 468 ++file_priv->ioctl_count;
470 469
471 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n", 470 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
472 current->pid, cmd, nr, 471 current->pid, cmd, nr,
473 (long)old_encode_dev(priv->head->device), 472 (long)old_encode_dev(file_priv->head->device),
474 priv->authenticated); 473 file_priv->authenticated);
475 474
476 if ((nr >= DRM_CORE_IOCTL_COUNT) && 475 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
477 ((nr < DRM_COMMAND_BASE) || (nr >= DRM_COMMAND_END))) 476 ((nr < DRM_COMMAND_BASE) || (nr >= DRM_COMMAND_END)))
@@ -493,11 +492,11 @@ int drm_ioctl(struct inode *inode, struct file *filp,
493 DRM_DEBUG("no function\n"); 492 DRM_DEBUG("no function\n");
494 retcode = -EINVAL; 493 retcode = -EINVAL;
495 } else if (((ioctl->flags & DRM_ROOT_ONLY) && !capable(CAP_SYS_ADMIN)) || 494 } else if (((ioctl->flags & DRM_ROOT_ONLY) && !capable(CAP_SYS_ADMIN)) ||
496 ((ioctl->flags & DRM_AUTH) && !priv->authenticated) || 495 ((ioctl->flags & DRM_AUTH) && !file_priv->authenticated) ||
497 ((ioctl->flags & DRM_MASTER) && !priv->master)) { 496 ((ioctl->flags & DRM_MASTER) && !file_priv->master)) {
498 retcode = -EACCES; 497 retcode = -EACCES;
499 } else { 498 } else {
500 retcode = func(inode, filp, cmd, arg); 499 retcode = func(inode, file_priv, cmd, arg);
501 } 500 }
502 501
503 err_i1: 502 err_i1:
diff --git a/drivers/char/drm/drm_fops.c b/drivers/char/drm/drm_fops.c
index 7bc51bac450d..1100c51aa4d6 100644
--- a/drivers/char/drm/drm_fops.c
+++ b/drivers/char/drm/drm_fops.c
@@ -242,6 +242,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
242 242
243 memset(priv, 0, sizeof(*priv)); 243 memset(priv, 0, sizeof(*priv));
244 filp->private_data = priv; 244 filp->private_data = priv;
245 priv->filp = filp;
245 priv->uid = current->euid; 246 priv->uid = current->euid;
246 priv->pid = current->pid; 247 priv->pid = current->pid;
247 priv->minor = minor; 248 priv->minor = minor;
@@ -312,7 +313,7 @@ EXPORT_SYMBOL(drm_fasync);
312 * Release file. 313 * Release file.
313 * 314 *
314 * \param inode device inode 315 * \param inode device inode
315 * \param filp file pointer. 316 * \param file_priv DRM file private.
316 * \return zero on success or a negative number on failure. 317 * \return zero on success or a negative number on failure.
317 * 318 *
318 * If the hardware lock is held then free it, and take it again for the kernel 319 * If the hardware lock is held then free it, and take it again for the kernel
@@ -322,29 +323,28 @@ EXPORT_SYMBOL(drm_fasync);
322 */ 323 */
323int drm_release(struct inode *inode, struct file *filp) 324int drm_release(struct inode *inode, struct file *filp)
324{ 325{
325 struct drm_file *priv = filp->private_data; 326 struct drm_file *file_priv = filp->private_data;
326 struct drm_device *dev; 327 struct drm_device *dev = file_priv->head->dev;
327 int retcode = 0; 328 int retcode = 0;
328 329
329 lock_kernel(); 330 lock_kernel();
330 dev = priv->head->dev;
331 331
332 DRM_DEBUG("open_count = %d\n", dev->open_count); 332 DRM_DEBUG("open_count = %d\n", dev->open_count);
333 333
334 if (dev->driver->preclose) 334 if (dev->driver->preclose)
335 dev->driver->preclose(dev, filp); 335 dev->driver->preclose(dev, file_priv);
336 336
337 /* ======================================================== 337 /* ========================================================
338 * Begin inline drm_release 338 * Begin inline drm_release
339 */ 339 */
340 340
341 DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n", 341 DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
342 current->pid, (long)old_encode_dev(priv->head->device), 342 current->pid, (long)old_encode_dev(file_priv->head->device),
343 dev->open_count); 343 dev->open_count);
344 344
345 if (dev->driver->reclaim_buffers_locked && dev->lock.hw_lock) { 345 if (dev->driver->reclaim_buffers_locked && dev->lock.hw_lock) {
346 if (drm_i_have_hw_lock(filp)) { 346 if (drm_i_have_hw_lock(file_priv)) {
347 dev->driver->reclaim_buffers_locked(dev, filp); 347 dev->driver->reclaim_buffers_locked(dev, file_priv);
348 } else { 348 } else {
349 unsigned long _end=jiffies + 3*DRM_HZ; 349 unsigned long _end=jiffies + 3*DRM_HZ;
350 int locked = 0; 350 int locked = 0;
@@ -370,7 +370,7 @@ int drm_release(struct inode *inode, struct file *filp)
370 "\tI will go on reclaiming the buffers anyway.\n"); 370 "\tI will go on reclaiming the buffers anyway.\n");
371 } 371 }
372 372
373 dev->driver->reclaim_buffers_locked(dev, filp); 373 dev->driver->reclaim_buffers_locked(dev, file_priv);
374 drm_idlelock_release(&dev->lock); 374 drm_idlelock_release(&dev->lock);
375 } 375 }
376 } 376 }
@@ -378,12 +378,12 @@ int drm_release(struct inode *inode, struct file *filp)
378 if (dev->driver->reclaim_buffers_idlelocked && dev->lock.hw_lock) { 378 if (dev->driver->reclaim_buffers_idlelocked && dev->lock.hw_lock) {
379 379
380 drm_idlelock_take(&dev->lock); 380 drm_idlelock_take(&dev->lock);
381 dev->driver->reclaim_buffers_idlelocked(dev, filp); 381 dev->driver->reclaim_buffers_idlelocked(dev, file_priv);
382 drm_idlelock_release(&dev->lock); 382 drm_idlelock_release(&dev->lock);
383 383
384 } 384 }
385 385
386 if (drm_i_have_hw_lock(filp)) { 386 if (drm_i_have_hw_lock(file_priv)) {
387 DRM_DEBUG("File %p released, freeing lock for context %d\n", 387 DRM_DEBUG("File %p released, freeing lock for context %d\n",
388 filp, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); 388 filp, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
389 389
@@ -394,7 +394,7 @@ int drm_release(struct inode *inode, struct file *filp)
394 394
395 if (drm_core_check_feature(dev, DRIVER_HAVE_DMA) && 395 if (drm_core_check_feature(dev, DRIVER_HAVE_DMA) &&
396 !dev->driver->reclaim_buffers_locked) { 396 !dev->driver->reclaim_buffers_locked) {
397 dev->driver->reclaim_buffers(dev, filp); 397 dev->driver->reclaim_buffers(dev, file_priv);
398 } 398 }
399 399
400 drm_fasync(-1, filp, 0); 400 drm_fasync(-1, filp, 0);
@@ -404,7 +404,7 @@ int drm_release(struct inode *inode, struct file *filp)
404 struct drm_ctx_list *pos, *n; 404 struct drm_ctx_list *pos, *n;
405 405
406 list_for_each_entry_safe(pos, n, &dev->ctxlist, head) { 406 list_for_each_entry_safe(pos, n, &dev->ctxlist, head) {
407 if (pos->tag == priv && 407 if (pos->tag == file_priv &&
408 pos->handle != DRM_KERNEL_CONTEXT) { 408 pos->handle != DRM_KERNEL_CONTEXT) {
409 if (dev->driver->context_dtor) 409 if (dev->driver->context_dtor)
410 dev->driver->context_dtor(dev, 410 dev->driver->context_dtor(dev,
@@ -421,18 +421,18 @@ int drm_release(struct inode *inode, struct file *filp)
421 mutex_unlock(&dev->ctxlist_mutex); 421 mutex_unlock(&dev->ctxlist_mutex);
422 422
423 mutex_lock(&dev->struct_mutex); 423 mutex_lock(&dev->struct_mutex);
424 if (priv->remove_auth_on_close == 1) { 424 if (file_priv->remove_auth_on_close == 1) {
425 struct drm_file *temp; 425 struct drm_file *temp;
426 426
427 list_for_each_entry(temp, &dev->filelist, lhead) 427 list_for_each_entry(temp, &dev->filelist, lhead)
428 temp->authenticated = 0; 428 temp->authenticated = 0;
429 } 429 }
430 list_del(&priv->lhead); 430 list_del(&file_priv->lhead);
431 mutex_unlock(&dev->struct_mutex); 431 mutex_unlock(&dev->struct_mutex);
432 432
433 if (dev->driver->postclose) 433 if (dev->driver->postclose)
434 dev->driver->postclose(dev, priv); 434 dev->driver->postclose(dev, file_priv);
435 drm_free(priv, sizeof(*priv), DRM_MEM_FILES); 435 drm_free(file_priv, sizeof(*file_priv), DRM_MEM_FILES);
436 436
437 /* ======================================================== 437 /* ========================================================
438 * End inline drm_release 438 * End inline drm_release
diff --git a/drivers/char/drm/drm_ioc32.c b/drivers/char/drm/drm_ioc32.c
index 462f46f2049a..2286f3312c5c 100644
--- a/drivers/char/drm/drm_ioc32.c
+++ b/drivers/char/drm/drm_ioc32.c
@@ -1040,7 +1040,7 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
1040 * Called whenever a 32-bit process running under a 64-bit kernel 1040 * Called whenever a 32-bit process running under a 64-bit kernel
1041 * performs an ioctl on /dev/drm. 1041 * performs an ioctl on /dev/drm.
1042 * 1042 *
1043 * \param filp file pointer. 1043 * \param file_priv DRM file private.
1044 * \param cmd command. 1044 * \param cmd command.
1045 * \param arg user argument. 1045 * \param arg user argument.
1046 * \return zero on success or negative number on failure. 1046 * \return zero on success or negative number on failure.
diff --git a/drivers/char/drm/drm_ioctl.c b/drivers/char/drm/drm_ioctl.c
index 4eecfb9226d4..1b5d0da6566d 100644
--- a/drivers/char/drm/drm_ioctl.c
+++ b/drivers/char/drm/drm_ioctl.c
@@ -42,18 +42,17 @@
42 * Get the bus id. 42 * Get the bus id.
43 * 43 *
44 * \param inode device inode. 44 * \param inode device inode.
45 * \param filp file pointer. 45 * \param file_priv DRM file private.
46 * \param cmd command. 46 * \param cmd command.
47 * \param arg user argument, pointing to a drm_unique structure. 47 * \param arg user argument, pointing to a drm_unique structure.
48 * \return zero on success or a negative number on failure. 48 * \return zero on success or a negative number on failure.
49 * 49 *
50 * Copies the bus id from drm_device::unique into user space. 50 * Copies the bus id from drm_device::unique into user space.
51 */ 51 */
52int drm_getunique(struct inode *inode, struct file *filp, 52int drm_getunique(struct inode *inode, struct drm_file *file_priv,
53 unsigned int cmd, unsigned long arg) 53 unsigned int cmd, unsigned long arg)
54{ 54{
55 struct drm_file *priv = filp->private_data; 55 struct drm_device *dev = file_priv->head->dev;
56 struct drm_device *dev = priv->head->dev;
57 struct drm_unique __user *argp = (void __user *)arg; 56 struct drm_unique __user *argp = (void __user *)arg;
58 struct drm_unique u; 57 struct drm_unique u;
59 58
@@ -73,7 +72,7 @@ int drm_getunique(struct inode *inode, struct file *filp,
73 * Set the bus id. 72 * Set the bus id.
74 * 73 *
75 * \param inode device inode. 74 * \param inode device inode.
76 * \param filp file pointer. 75 * \param file_priv DRM file private.
77 * \param cmd command. 76 * \param cmd command.
78 * \param arg user argument, pointing to a drm_unique structure. 77 * \param arg user argument, pointing to a drm_unique structure.
79 * \return zero on success or a negative number on failure. 78 * \return zero on success or a negative number on failure.
@@ -83,11 +82,10 @@ int drm_getunique(struct inode *inode, struct file *filp,
83 * in interface version 1.1 and will return EBUSY when setversion has requested 82 * in interface version 1.1 and will return EBUSY when setversion has requested
84 * version 1.1 or greater. 83 * version 1.1 or greater.
85 */ 84 */
86int drm_setunique(struct inode *inode, struct file *filp, 85int drm_setunique(struct inode *inode, struct drm_file *file_priv,
87 unsigned int cmd, unsigned long arg) 86 unsigned int cmd, unsigned long arg)
88{ 87{
89 struct drm_file *priv = filp->private_data; 88 struct drm_device *dev = file_priv->head->dev;
90 struct drm_device *dev = priv->head->dev;
91 struct drm_unique u; 89 struct drm_unique u;
92 int domain, bus, slot, func, ret; 90 int domain, bus, slot, func, ret;
93 91
@@ -172,7 +170,7 @@ static int drm_set_busid(struct drm_device * dev)
172 * Get a mapping information. 170 * Get a mapping information.
173 * 171 *
174 * \param inode device inode. 172 * \param inode device inode.
175 * \param filp file pointer. 173 * \param file_priv DRM file private.
176 * \param cmd command. 174 * \param cmd command.
177 * \param arg user argument, pointing to a drm_map structure. 175 * \param arg user argument, pointing to a drm_map structure.
178 * 176 *
@@ -181,11 +179,10 @@ static int drm_set_busid(struct drm_device * dev)
181 * Searches for the mapping with the specified offset and copies its information 179 * Searches for the mapping with the specified offset and copies its information
182 * into userspace 180 * into userspace
183 */ 181 */
184int drm_getmap(struct inode *inode, struct file *filp, 182int drm_getmap(struct inode *inode, struct drm_file *file_priv,
185 unsigned int cmd, unsigned long arg) 183 unsigned int cmd, unsigned long arg)
186{ 184{
187 struct drm_file *priv = filp->private_data; 185 struct drm_device *dev = file_priv->head->dev;
188 struct drm_device *dev = priv->head->dev;
189 struct drm_map __user *argp = (void __user *)arg; 186 struct drm_map __user *argp = (void __user *)arg;
190 struct drm_map map; 187 struct drm_map map;
191 struct drm_map_list *r_list = NULL; 188 struct drm_map_list *r_list = NULL;
@@ -233,7 +230,7 @@ int drm_getmap(struct inode *inode, struct file *filp,
233 * Get client information. 230 * Get client information.
234 * 231 *
235 * \param inode device inode. 232 * \param inode device inode.
236 * \param filp file pointer. 233 * \param file_priv DRM file private.
237 * \param cmd command. 234 * \param cmd command.
238 * \param arg user argument, pointing to a drm_client structure. 235 * \param arg user argument, pointing to a drm_client structure.
239 * 236 *
@@ -242,11 +239,10 @@ int drm_getmap(struct inode *inode, struct file *filp,
242 * Searches for the client with the specified index and copies its information 239 * Searches for the client with the specified index and copies its information
243 * into userspace 240 * into userspace
244 */ 241 */
245int drm_getclient(struct inode *inode, struct file *filp, 242int drm_getclient(struct inode *inode, struct drm_file *file_priv,
246 unsigned int cmd, unsigned long arg) 243 unsigned int cmd, unsigned long arg)
247{ 244{
248 struct drm_file *priv = filp->private_data; 245 struct drm_device *dev = file_priv->head->dev;
249 struct drm_device *dev = priv->head->dev;
250 struct drm_client __user *argp = (struct drm_client __user *)arg; 246 struct drm_client __user *argp = (struct drm_client __user *)arg;
251 struct drm_client client; 247 struct drm_client client;
252 struct drm_file *pt; 248 struct drm_file *pt;
@@ -285,17 +281,16 @@ int drm_getclient(struct inode *inode, struct file *filp,
285 * Get statistics information. 281 * Get statistics information.
286 * 282 *
287 * \param inode device inode. 283 * \param inode device inode.
288 * \param filp file pointer. 284 * \param file_priv DRM file private.
289 * \param cmd command. 285 * \param cmd command.
290 * \param arg user argument, pointing to a drm_stats structure. 286 * \param arg user argument, pointing to a drm_stats structure.
291 * 287 *
292 * \return zero on success or a negative number on failure. 288 * \return zero on success or a negative number on failure.
293 */ 289 */
294int drm_getstats(struct inode *inode, struct file *filp, 290int drm_getstats(struct inode *inode, struct drm_file *file_priv,
295 unsigned int cmd, unsigned long arg) 291 unsigned int cmd, unsigned long arg)
296{ 292{
297 struct drm_file *priv = filp->private_data; 293 struct drm_device *dev = file_priv->head->dev;
298 struct drm_device *dev = priv->head->dev;
299 struct drm_stats stats; 294 struct drm_stats stats;
300 int i; 295 int i;
301 296
@@ -325,7 +320,7 @@ int drm_getstats(struct inode *inode, struct file *filp,
325 * Setversion ioctl. 320 * Setversion ioctl.
326 * 321 *
327 * \param inode device inode. 322 * \param inode device inode.
328 * \param filp file pointer. 323 * \param file_priv DRM file private.
329 * \param cmd command. 324 * \param cmd command.
330 * \param arg user argument, pointing to a drm_lock structure. 325 * \param arg user argument, pointing to a drm_lock structure.
331 * \return zero on success or negative number on failure. 326 * \return zero on success or negative number on failure.
@@ -381,7 +376,7 @@ int drm_setversion(DRM_IOCTL_ARGS)
381} 376}
382 377
383/** No-op ioctl. */ 378/** No-op ioctl. */
384int drm_noop(struct inode *inode, struct file *filp, unsigned int cmd, 379int drm_noop(struct inode *inode, struct drm_file *file_priv, unsigned int cmd,
385 unsigned long arg) 380 unsigned long arg)
386{ 381{
387 DRM_DEBUG("\n"); 382 DRM_DEBUG("\n");
diff --git a/drivers/char/drm/drm_irq.c b/drivers/char/drm/drm_irq.c
index 871d2fde09b3..9fdc2953c73f 100644
--- a/drivers/char/drm/drm_irq.c
+++ b/drivers/char/drm/drm_irq.c
@@ -41,7 +41,7 @@
41 * Get interrupt from bus id. 41 * Get interrupt from bus id.
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_irq_busid structure. 46 * \param arg user argument, pointing to a drm_irq_busid structure.
47 * \return zero on success or a negative number on failure. 47 * \return zero on success or a negative number on failure.
@@ -50,11 +50,10 @@
50 * This IOCTL is deprecated, and will now return EINVAL for any busid not equal 50 * This IOCTL is deprecated, and will now return EINVAL for any busid not equal
51 * to that of the device that this DRM instance attached to. 51 * to that of the device that this DRM instance attached to.
52 */ 52 */
53int drm_irq_by_busid(struct inode *inode, struct file *filp, 53int drm_irq_by_busid(struct inode *inode, struct drm_file *file_priv,
54 unsigned int cmd, unsigned long arg) 54 unsigned int cmd, unsigned long arg)
55{ 55{
56 struct drm_file *priv = filp->private_data; 56 struct drm_device *dev = file_priv->head->dev;
57 struct drm_device *dev = priv->head->dev;
58 struct drm_irq_busid __user *argp = (void __user *)arg; 57 struct drm_irq_busid __user *argp = (void __user *)arg;
59 struct drm_irq_busid p; 58 struct drm_irq_busid p;
60 59
@@ -187,18 +186,17 @@ EXPORT_SYMBOL(drm_irq_uninstall);
187 * IRQ control ioctl. 186 * IRQ control ioctl.
188 * 187 *
189 * \param inode device inode. 188 * \param inode device inode.
190 * \param filp file pointer. 189 * \param file_priv DRM file private.
191 * \param cmd command. 190 * \param cmd command.
192 * \param arg user argument, pointing to a drm_control structure. 191 * \param arg user argument, pointing to a drm_control structure.
193 * \return zero on success or a negative number on failure. 192 * \return zero on success or a negative number on failure.
194 * 193 *
195 * Calls irq_install() or irq_uninstall() according to \p arg. 194 * Calls irq_install() or irq_uninstall() according to \p arg.
196 */ 195 */
197int drm_control(struct inode *inode, struct file *filp, 196int drm_control(struct inode *inode, struct drm_file *file_priv,
198 unsigned int cmd, unsigned long arg) 197 unsigned int cmd, unsigned long arg)
199{ 198{
200 struct drm_file *priv = filp->private_data; 199 struct drm_device *dev = file_priv->head->dev;
201 struct drm_device *dev = priv->head->dev;
202 struct drm_control ctl; 200 struct drm_control ctl;
203 201
204 /* if we haven't irq we fallback for compatibility reasons - this used to be a separate function in drm_dma.h */ 202 /* if we haven't irq we fallback for compatibility reasons - this used to be a separate function in drm_dma.h */
@@ -227,7 +225,7 @@ int drm_control(struct inode *inode, struct file *filp,
227 * Wait for VBLANK. 225 * Wait for VBLANK.
228 * 226 *
229 * \param inode device inode. 227 * \param inode device inode.
230 * \param filp file pointer. 228 * \param file_priv DRM file private.
231 * \param cmd command. 229 * \param cmd command.
232 * \param data user argument, pointing to a drm_wait_vblank structure. 230 * \param data user argument, pointing to a drm_wait_vblank structure.
233 * \return zero on success or a negative number on failure. 231 * \return zero on success or a negative number on failure.
@@ -244,8 +242,7 @@ int drm_control(struct inode *inode, struct file *filp,
244 */ 242 */
245int drm_wait_vblank(DRM_IOCTL_ARGS) 243int drm_wait_vblank(DRM_IOCTL_ARGS)
246{ 244{
247 struct drm_file *priv = filp->private_data; 245 struct drm_device *dev = file_priv->head->dev;
248 struct drm_device *dev = priv->head->dev;
249 union drm_wait_vblank __user *argp = (void __user *)data; 246 union drm_wait_vblank __user *argp = (void __user *)data;
250 union drm_wait_vblank vblwait; 247 union drm_wait_vblank vblwait;
251 struct timeval now; 248 struct timeval now;
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);
diff --git a/drivers/char/drm/drm_os_linux.h b/drivers/char/drm/drm_os_linux.h
index 132c5580358b..e87dc34a6fbf 100644
--- a/drivers/char/drm/drm_os_linux.h
+++ b/drivers/char/drm/drm_os_linux.h
@@ -6,10 +6,8 @@
6#include <linux/interrupt.h> /* For task queue support */ 6#include <linux/interrupt.h> /* For task queue support */
7#include <linux/delay.h> 7#include <linux/delay.h>
8 8
9/** File pointer type */
10#define DRMFILE struct file *
11/** Ioctl arguments */ 9/** Ioctl arguments */
12#define DRM_IOCTL_ARGS struct inode *inode, struct file *filp, unsigned int cmd, unsigned long data 10#define DRM_IOCTL_ARGS struct inode *inode, struct drm_file *file_priv, unsigned int cmd, unsigned long data
13/** Current process ID */ 11/** Current process ID */
14#define DRM_CURRENTPID current->pid 12#define DRM_CURRENTPID current->pid
15#define DRM_SUSER(p) capable(CAP_SYS_ADMIN) 13#define DRM_SUSER(p) capable(CAP_SYS_ADMIN)
@@ -33,8 +31,7 @@
33/** Read/write memory barrier */ 31/** Read/write memory barrier */
34#define DRM_MEMORYBARRIER() mb() 32#define DRM_MEMORYBARRIER() mb()
35/** DRM device local declaration */ 33/** DRM device local declaration */
36#define DRM_DEVICE struct drm_file *priv = filp->private_data; \ 34#define DRM_DEVICE struct drm_device *dev = file_priv->head->dev
37 struct drm_device *dev = priv->head->dev
38 35
39/** IRQ handler arguments and return type and values */ 36/** IRQ handler arguments and return type and values */
40#define DRM_IRQ_ARGS int irq, void *arg 37#define DRM_IRQ_ARGS int irq, void *arg
@@ -93,8 +90,6 @@ static __inline__ int mtrr_del(int reg, unsigned long base, unsigned long size)
93#define DRM_GET_USER_UNCHECKED(val, uaddr) \ 90#define DRM_GET_USER_UNCHECKED(val, uaddr) \
94 __get_user(val, uaddr) 91 __get_user(val, uaddr)
95 92
96#define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) _priv = _filp->private_data
97
98#define DRM_HZ HZ 93#define DRM_HZ HZ
99 94
100#define DRM_WAIT_ON( ret, queue, timeout, condition ) \ 95#define DRM_WAIT_ON( ret, queue, timeout, condition ) \
diff --git a/drivers/char/drm/drm_scatter.c b/drivers/char/drm/drm_scatter.c
index 067d25daaf17..0c2188367e69 100644
--- a/drivers/char/drm/drm_scatter.c
+++ b/drivers/char/drm/drm_scatter.c
@@ -62,11 +62,10 @@ void drm_sg_cleanup(struct drm_sg_mem * entry)
62# define ScatterHandle(x) (unsigned int)(x) 62# define ScatterHandle(x) (unsigned int)(x)
63#endif 63#endif
64 64
65int drm_sg_alloc(struct inode *inode, struct file *filp, 65int drm_sg_alloc(struct inode *inode, struct drm_file *file_priv,
66 unsigned int cmd, unsigned long arg) 66 unsigned int cmd, unsigned long arg)
67{ 67{
68 struct drm_file *priv = filp->private_data; 68 struct drm_device *dev = file_priv->head->dev;
69 struct drm_device *dev = priv->head->dev;
70 struct drm_scatter_gather __user *argp = (void __user *)arg; 69 struct drm_scatter_gather __user *argp = (void __user *)arg;
71 struct drm_scatter_gather request; 70 struct drm_scatter_gather request;
72 struct drm_sg_mem *entry; 71 struct drm_sg_mem *entry;
@@ -198,11 +197,10 @@ int drm_sg_alloc(struct inode *inode, struct file *filp,
198 return -ENOMEM; 197 return -ENOMEM;
199} 198}
200 199
201int drm_sg_free(struct inode *inode, struct file *filp, 200int drm_sg_free(struct inode *inode, struct drm_file *file_priv,
202 unsigned int cmd, unsigned long arg) 201 unsigned int cmd, unsigned long arg)
203{ 202{
204 struct drm_file *priv = filp->private_data; 203 struct drm_device *dev = file_priv->head->dev;
205 struct drm_device *dev = priv->head->dev;
206 struct drm_scatter_gather request; 204 struct drm_scatter_gather request;
207 struct drm_sg_mem *entry; 205 struct drm_sg_mem *entry;
208 206
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c
index 68e36e51ba0c..e8d50af58201 100644
--- a/drivers/char/drm/drm_vm.c
+++ b/drivers/char/drm/drm_vm.c
@@ -463,7 +463,7 @@ static void drm_vm_close(struct vm_area_struct *vma)
463/** 463/**
464 * mmap DMA memory. 464 * mmap DMA memory.
465 * 465 *
466 * \param filp file pointer. 466 * \param file_priv DRM file private.
467 * \param vma virtual memory area. 467 * \param vma virtual memory area.
468 * \return zero on success or a negative number on failure. 468 * \return zero on success or a negative number on failure.
469 * 469 *
@@ -533,7 +533,7 @@ EXPORT_SYMBOL(drm_core_get_reg_ofs);
533/** 533/**
534 * mmap DMA memory. 534 * mmap DMA memory.
535 * 535 *
536 * \param filp file pointer. 536 * \param file_priv DRM file private.
537 * \param vma virtual memory area. 537 * \param vma virtual memory area.
538 * \return zero on success or a negative number on failure. 538 * \return zero on success or a negative number on failure.
539 * 539 *
diff --git a/drivers/char/drm/i810_dma.c b/drivers/char/drm/i810_dma.c
index bfb35ab11809..3f1aca87432f 100644
--- a/drivers/char/drm/i810_dma.c
+++ b/drivers/char/drm/i810_dma.c
@@ -120,10 +120,9 @@ static const struct file_operations i810_buffer_fops = {
120 .fasync = drm_fasync, 120 .fasync = drm_fasync,
121}; 121};
122 122
123static int i810_map_buffer(struct drm_buf * buf, struct file *filp) 123static int i810_map_buffer(struct drm_buf * buf, struct drm_file *file_priv)
124{ 124{
125 struct drm_file *priv = filp->private_data; 125 struct drm_device *dev = file_priv->head->dev;
126 struct drm_device *dev = priv->head->dev;
127 drm_i810_buf_priv_t *buf_priv = buf->dev_private; 126 drm_i810_buf_priv_t *buf_priv = buf->dev_private;
128 drm_i810_private_t *dev_priv = dev->dev_private; 127 drm_i810_private_t *dev_priv = dev->dev_private;
129 const struct file_operations *old_fops; 128 const struct file_operations *old_fops;
@@ -133,14 +132,14 @@ static int i810_map_buffer(struct drm_buf * buf, struct file *filp)
133 return -EINVAL; 132 return -EINVAL;
134 133
135 down_write(&current->mm->mmap_sem); 134 down_write(&current->mm->mmap_sem);
136 old_fops = filp->f_op; 135 old_fops = file_priv->filp->f_op;
137 filp->f_op = &i810_buffer_fops; 136 file_priv->filp->f_op = &i810_buffer_fops;
138 dev_priv->mmap_buffer = buf; 137 dev_priv->mmap_buffer = buf;
139 buf_priv->virtual = (void *)do_mmap(filp, 0, buf->total, 138 buf_priv->virtual = (void *)do_mmap(file_priv->filp, 0, buf->total,
140 PROT_READ | PROT_WRITE, 139 PROT_READ | PROT_WRITE,
141 MAP_SHARED, buf->bus_address); 140 MAP_SHARED, buf->bus_address);
142 dev_priv->mmap_buffer = NULL; 141 dev_priv->mmap_buffer = NULL;
143 filp->f_op = old_fops; 142 file_priv->filp->f_op = old_fops;
144 if (IS_ERR(buf_priv->virtual)) { 143 if (IS_ERR(buf_priv->virtual)) {
145 /* Real error */ 144 /* Real error */
146 DRM_ERROR("mmap error\n"); 145 DRM_ERROR("mmap error\n");
@@ -173,7 +172,7 @@ static int i810_unmap_buffer(struct drm_buf * buf)
173} 172}
174 173
175static int i810_dma_get_buffer(struct drm_device * dev, drm_i810_dma_t * d, 174static int i810_dma_get_buffer(struct drm_device * dev, drm_i810_dma_t * d,
176 struct file *filp) 175 struct drm_file *file_priv)
177{ 176{
178 struct drm_buf *buf; 177 struct drm_buf *buf;
179 drm_i810_buf_priv_t *buf_priv; 178 drm_i810_buf_priv_t *buf_priv;
@@ -186,13 +185,13 @@ static int i810_dma_get_buffer(struct drm_device * dev, drm_i810_dma_t * d,
186 return retcode; 185 return retcode;
187 } 186 }
188 187
189 retcode = i810_map_buffer(buf, filp); 188 retcode = i810_map_buffer(buf, file_priv);
190 if (retcode) { 189 if (retcode) {
191 i810_freelist_put(dev, buf); 190 i810_freelist_put(dev, buf);
192 DRM_ERROR("mapbuf failed, retcode %d\n", retcode); 191 DRM_ERROR("mapbuf failed, retcode %d\n", retcode);
193 return retcode; 192 return retcode;
194 } 193 }
195 buf->filp = filp; 194 buf->file_priv = file_priv;
196 buf_priv = buf->dev_private; 195 buf_priv = buf->dev_private;
197 d->granted = 1; 196 d->granted = 1;
198 d->request_idx = buf->idx; 197 d->request_idx = buf->idx;
@@ -473,11 +472,10 @@ static int i810_dma_init_compat(drm_i810_init_t * init, unsigned long arg)
473 return 0; 472 return 0;
474} 473}
475 474
476static int i810_dma_init(struct inode *inode, struct file *filp, 475static int i810_dma_init(struct inode *inode, struct drm_file *file_priv,
477 unsigned int cmd, unsigned long arg) 476 unsigned int cmd, unsigned long arg)
478{ 477{
479 struct drm_file *priv = filp->private_data; 478 struct drm_device *dev = file_priv->head->dev;
480 struct drm_device *dev = priv->head->dev;
481 drm_i810_private_t *dev_priv; 479 drm_i810_private_t *dev_priv;
482 drm_i810_init_t init; 480 drm_i810_init_t init;
483 int retcode = 0; 481 int retcode = 0;
@@ -968,7 +966,8 @@ static int i810_flush_queue(struct drm_device * dev)
968} 966}
969 967
970/* Must be called with the lock held */ 968/* Must be called with the lock held */
971static void i810_reclaim_buffers(struct drm_device * dev, struct file *filp) 969static void i810_reclaim_buffers(struct drm_device * dev,
970 struct drm_file *file_priv)
972{ 971{
973 struct drm_device_dma *dma = dev->dma; 972 struct drm_device_dma *dma = dev->dma;
974 int i; 973 int i;
@@ -986,7 +985,7 @@ static void i810_reclaim_buffers(struct drm_device * dev, struct file *filp)
986 struct drm_buf *buf = dma->buflist[i]; 985 struct drm_buf *buf = dma->buflist[i];
987 drm_i810_buf_priv_t *buf_priv = buf->dev_private; 986 drm_i810_buf_priv_t *buf_priv = buf->dev_private;
988 987
989 if (buf->filp == filp && buf_priv) { 988 if (buf->file_priv == file_priv && buf_priv) {
990 int used = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT, 989 int used = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT,
991 I810_BUF_FREE); 990 I810_BUF_FREE);
992 991
@@ -998,23 +997,21 @@ static void i810_reclaim_buffers(struct drm_device * dev, struct file *filp)
998 } 997 }
999} 998}
1000 999
1001static int i810_flush_ioctl(struct inode *inode, struct file *filp, 1000static int i810_flush_ioctl(struct inode *inode, struct drm_file *file_priv,
1002 unsigned int cmd, unsigned long arg) 1001 unsigned int cmd, unsigned long arg)
1003{ 1002{
1004 struct drm_file *priv = filp->private_data; 1003 struct drm_device *dev = file_priv->head->dev;
1005 struct drm_device *dev = priv->head->dev;
1006 1004
1007 LOCK_TEST_WITH_RETURN(dev, filp); 1005 LOCK_TEST_WITH_RETURN(dev, file_priv);
1008 1006
1009 i810_flush_queue(dev); 1007 i810_flush_queue(dev);
1010 return 0; 1008 return 0;
1011} 1009}
1012 1010
1013static int i810_dma_vertex(struct inode *inode, struct file *filp, 1011static int i810_dma_vertex(struct inode *inode, struct drm_file *file_priv,
1014 unsigned int cmd, unsigned long arg) 1012 unsigned int cmd, unsigned long arg)
1015{ 1013{
1016 struct drm_file *priv = filp->private_data; 1014 struct drm_device *dev = file_priv->head->dev;
1017 struct drm_device *dev = priv->head->dev;
1018 struct drm_device_dma *dma = dev->dma; 1015 struct drm_device_dma *dma = dev->dma;
1019 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; 1016 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
1020 u32 *hw_status = dev_priv->hw_status_page; 1017 u32 *hw_status = dev_priv->hw_status_page;
@@ -1026,7 +1023,7 @@ static int i810_dma_vertex(struct inode *inode, struct file *filp,
1026 (&vertex, (drm_i810_vertex_t __user *) arg, sizeof(vertex))) 1023 (&vertex, (drm_i810_vertex_t __user *) arg, sizeof(vertex)))
1027 return -EFAULT; 1024 return -EFAULT;
1028 1025
1029 LOCK_TEST_WITH_RETURN(dev, filp); 1026 LOCK_TEST_WITH_RETURN(dev, file_priv);
1030 1027
1031 DRM_DEBUG("i810 dma vertex, idx %d used %d discard %d\n", 1028 DRM_DEBUG("i810 dma vertex, idx %d used %d discard %d\n",
1032 vertex.idx, vertex.used, vertex.discard); 1029 vertex.idx, vertex.used, vertex.discard);
@@ -1046,18 +1043,17 @@ static int i810_dma_vertex(struct inode *inode, struct file *filp,
1046 return 0; 1043 return 0;
1047} 1044}
1048 1045
1049static int i810_clear_bufs(struct inode *inode, struct file *filp, 1046static int i810_clear_bufs(struct inode *inode, struct drm_file *file_priv,
1050 unsigned int cmd, unsigned long arg) 1047 unsigned int cmd, unsigned long arg)
1051{ 1048{
1052 struct drm_file *priv = filp->private_data; 1049 struct drm_device *dev = file_priv->head->dev;
1053 struct drm_device *dev = priv->head->dev;
1054 drm_i810_clear_t clear; 1050 drm_i810_clear_t clear;
1055 1051
1056 if (copy_from_user 1052 if (copy_from_user
1057 (&clear, (drm_i810_clear_t __user *) arg, sizeof(clear))) 1053 (&clear, (drm_i810_clear_t __user *) arg, sizeof(clear)))
1058 return -EFAULT; 1054 return -EFAULT;
1059 1055
1060 LOCK_TEST_WITH_RETURN(dev, filp); 1056 LOCK_TEST_WITH_RETURN(dev, file_priv);
1061 1057
1062 /* GH: Someone's doing nasty things... */ 1058 /* GH: Someone's doing nasty things... */
1063 if (!dev->dev_private) { 1059 if (!dev->dev_private) {
@@ -1069,25 +1065,24 @@ static int i810_clear_bufs(struct inode *inode, struct file *filp,
1069 return 0; 1065 return 0;
1070} 1066}
1071 1067
1072static int i810_swap_bufs(struct inode *inode, struct file *filp, 1068static int i810_swap_bufs(struct inode *inode, struct drm_file *file_priv,
1073 unsigned int cmd, unsigned long arg) 1069 unsigned int cmd, unsigned long arg)
1074{ 1070{
1075 struct drm_file *priv = filp->private_data; 1071 struct drm_device *dev = file_priv->head->dev;
1076 struct drm_device *dev = priv->head->dev;
1077 1072
1078 DRM_DEBUG("i810_swap_bufs\n"); 1073 DRM_DEBUG("i810_swap_bufs\n");
1079 1074
1080 LOCK_TEST_WITH_RETURN(dev, filp); 1075 LOCK_TEST_WITH_RETURN(dev, file_priv);
1081 1076
1082 i810_dma_dispatch_swap(dev); 1077 i810_dma_dispatch_swap(dev);
1083 return 0; 1078 return 0;
1084} 1079}
1085 1080
1086static int i810_getage(struct inode *inode, struct file *filp, unsigned int cmd, 1081static int i810_getage(struct inode *inode, struct drm_file *file_priv,
1082 unsigned int cmd,
1087 unsigned long arg) 1083 unsigned long arg)
1088{ 1084{
1089 struct drm_file *priv = filp->private_data; 1085 struct drm_device *dev = file_priv->head->dev;
1090 struct drm_device *dev = priv->head->dev;
1091 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; 1086 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
1092 u32 *hw_status = dev_priv->hw_status_page; 1087 u32 *hw_status = dev_priv->hw_status_page;
1093 drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) 1088 drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
@@ -1097,11 +1092,10 @@ static int i810_getage(struct inode *inode, struct file *filp, unsigned int cmd,
1097 return 0; 1092 return 0;
1098} 1093}
1099 1094
1100static int i810_getbuf(struct inode *inode, struct file *filp, unsigned int cmd, 1095static int i810_getbuf(struct inode *inode, struct drm_file *file_priv,
1101 unsigned long arg) 1096 unsigned int cmd, unsigned long arg)
1102{ 1097{
1103 struct drm_file *priv = filp->private_data; 1098 struct drm_device *dev = file_priv->head->dev;
1104 struct drm_device *dev = priv->head->dev;
1105 int retcode = 0; 1099 int retcode = 0;
1106 drm_i810_dma_t d; 1100 drm_i810_dma_t d;
1107 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; 1101 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
@@ -1112,11 +1106,11 @@ static int i810_getbuf(struct inode *inode, struct file *filp, unsigned int cmd,
1112 if (copy_from_user(&d, (drm_i810_dma_t __user *) arg, sizeof(d))) 1106 if (copy_from_user(&d, (drm_i810_dma_t __user *) arg, sizeof(d)))
1113 return -EFAULT; 1107 return -EFAULT;
1114 1108
1115 LOCK_TEST_WITH_RETURN(dev, filp); 1109 LOCK_TEST_WITH_RETURN(dev, file_priv);
1116 1110
1117 d.granted = 0; 1111 d.granted = 0;
1118 1112
1119 retcode = i810_dma_get_buffer(dev, &d, filp); 1113 retcode = i810_dma_get_buffer(dev, &d, file_priv);
1120 1114
1121 DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n", 1115 DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n",
1122 current->pid, retcode, d.granted); 1116 current->pid, retcode, d.granted);
@@ -1128,15 +1122,15 @@ static int i810_getbuf(struct inode *inode, struct file *filp, unsigned int cmd,
1128 return retcode; 1122 return retcode;
1129} 1123}
1130 1124
1131static int i810_copybuf(struct inode *inode, 1125static int i810_copybuf(struct inode *inode, struct drm_file *file_priv,
1132 struct file *filp, unsigned int cmd, unsigned long arg) 1126 unsigned int cmd, unsigned long arg)
1133{ 1127{
1134 /* Never copy - 2.4.x doesn't need it */ 1128 /* Never copy - 2.4.x doesn't need it */
1135 return 0; 1129 return 0;
1136} 1130}
1137 1131
1138static int i810_docopy(struct inode *inode, struct file *filp, unsigned int cmd, 1132static int i810_docopy(struct inode *inode, struct drm_file *file_priv,
1139 unsigned long arg) 1133 unsigned int cmd, unsigned long arg)
1140{ 1134{
1141 /* Never copy - 2.4.x doesn't need it */ 1135 /* Never copy - 2.4.x doesn't need it */
1142 return 0; 1136 return 0;
@@ -1202,11 +1196,10 @@ static void i810_dma_dispatch_mc(struct drm_device * dev, struct drm_buf * buf,
1202 ADVANCE_LP_RING(); 1196 ADVANCE_LP_RING();
1203} 1197}
1204 1198
1205static int i810_dma_mc(struct inode *inode, struct file *filp, 1199static int i810_dma_mc(struct inode *inode, struct drm_file *file_priv,
1206 unsigned int cmd, unsigned long arg) 1200 unsigned int cmd, unsigned long arg)
1207{ 1201{
1208 struct drm_file *priv = filp->private_data; 1202 struct drm_device *dev = file_priv->head->dev;
1209 struct drm_device *dev = priv->head->dev;
1210 struct drm_device_dma *dma = dev->dma; 1203 struct drm_device_dma *dma = dev->dma;
1211 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; 1204 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
1212 u32 *hw_status = dev_priv->hw_status_page; 1205 u32 *hw_status = dev_priv->hw_status_page;
@@ -1217,7 +1210,7 @@ static int i810_dma_mc(struct inode *inode, struct file *filp,
1217 if (copy_from_user(&mc, (drm_i810_mc_t __user *) arg, sizeof(mc))) 1210 if (copy_from_user(&mc, (drm_i810_mc_t __user *) arg, sizeof(mc)))
1218 return -EFAULT; 1211 return -EFAULT;
1219 1212
1220 LOCK_TEST_WITH_RETURN(dev, filp); 1213 LOCK_TEST_WITH_RETURN(dev, file_priv);
1221 1214
1222 if (mc.idx >= dma->buf_count || mc.idx < 0) 1215 if (mc.idx >= dma->buf_count || mc.idx < 0)
1223 return -EINVAL; 1216 return -EINVAL;
@@ -1233,21 +1226,19 @@ static int i810_dma_mc(struct inode *inode, struct file *filp,
1233 return 0; 1226 return 0;
1234} 1227}
1235 1228
1236static int i810_rstatus(struct inode *inode, struct file *filp, 1229static int i810_rstatus(struct inode *inode, struct drm_file *file_priv,
1237 unsigned int cmd, unsigned long arg) 1230 unsigned int cmd, unsigned long arg)
1238{ 1231{
1239 struct drm_file *priv = filp->private_data; 1232 struct drm_device *dev = file_priv->head->dev;
1240 struct drm_device *dev = priv->head->dev;
1241 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; 1233 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
1242 1234
1243 return (int)(((u32 *) (dev_priv->hw_status_page))[4]); 1235 return (int)(((u32 *) (dev_priv->hw_status_page))[4]);
1244} 1236}
1245 1237
1246static int i810_ov0_info(struct inode *inode, struct file *filp, 1238static int i810_ov0_info(struct inode *inode, struct drm_file *file_priv,
1247 unsigned int cmd, unsigned long arg) 1239 unsigned int cmd, unsigned long arg)
1248{ 1240{
1249 struct drm_file *priv = filp->private_data; 1241 struct drm_device *dev = file_priv->head->dev;
1250 struct drm_device *dev = priv->head->dev;
1251 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; 1242 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
1252 drm_i810_overlay_t data; 1243 drm_i810_overlay_t data;
1253 1244
@@ -1259,26 +1250,24 @@ static int i810_ov0_info(struct inode *inode, struct file *filp,
1259 return 0; 1250 return 0;
1260} 1251}
1261 1252
1262static int i810_fstatus(struct inode *inode, struct file *filp, 1253static int i810_fstatus(struct inode *inode, struct drm_file *file_priv,
1263 unsigned int cmd, unsigned long arg) 1254 unsigned int cmd, unsigned long arg)
1264{ 1255{
1265 struct drm_file *priv = filp->private_data; 1256 struct drm_device *dev = file_priv->head->dev;
1266 struct drm_device *dev = priv->head->dev;
1267 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; 1257 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
1268 1258
1269 LOCK_TEST_WITH_RETURN(dev, filp); 1259 LOCK_TEST_WITH_RETURN(dev, file_priv);
1270 1260
1271 return I810_READ(0x30008); 1261 return I810_READ(0x30008);
1272} 1262}
1273 1263
1274static int i810_ov0_flip(struct inode *inode, struct file *filp, 1264static int i810_ov0_flip(struct inode *inode, struct drm_file *file_priv,
1275 unsigned int cmd, unsigned long arg) 1265 unsigned int cmd, unsigned long arg)
1276{ 1266{
1277 struct drm_file *priv = filp->private_data; 1267 struct drm_device *dev = file_priv->head->dev;
1278 struct drm_device *dev = priv->head->dev;
1279 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; 1268 drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
1280 1269
1281 LOCK_TEST_WITH_RETURN(dev, filp); 1270 LOCK_TEST_WITH_RETURN(dev, file_priv);
1282 1271
1283 //Tell the overlay to update 1272 //Tell the overlay to update
1284 I810_WRITE(0x30000, dev_priv->overlay_physical | 0x80000000); 1273 I810_WRITE(0x30000, dev_priv->overlay_physical | 0x80000000);
@@ -1310,16 +1299,15 @@ static int i810_do_cleanup_pageflip(struct drm_device * dev)
1310 return 0; 1299 return 0;
1311} 1300}
1312 1301
1313static int i810_flip_bufs(struct inode *inode, struct file *filp, 1302static int i810_flip_bufs(struct inode *inode, struct drm_file *file_priv,
1314 unsigned int cmd, unsigned long arg) 1303 unsigned int cmd, unsigned long arg)
1315{ 1304{
1316 struct drm_file *priv = filp->private_data; 1305 struct drm_device *dev = file_priv->head->dev;
1317 struct drm_device *dev = priv->head->dev;
1318 drm_i810_private_t *dev_priv = dev->dev_private; 1306 drm_i810_private_t *dev_priv = dev->dev_private;
1319 1307
1320 DRM_DEBUG("%s\n", __FUNCTION__); 1308 DRM_DEBUG("%s\n", __FUNCTION__);
1321 1309
1322 LOCK_TEST_WITH_RETURN(dev, filp); 1310 LOCK_TEST_WITH_RETURN(dev, file_priv);
1323 1311
1324 if (!dev_priv->page_flipping) 1312 if (!dev_priv->page_flipping)
1325 i810_do_init_pageflip(dev); 1313 i810_do_init_pageflip(dev);
@@ -1345,7 +1333,7 @@ void i810_driver_lastclose(struct drm_device * dev)
1345 i810_dma_cleanup(dev); 1333 i810_dma_cleanup(dev);
1346} 1334}
1347 1335
1348void i810_driver_preclose(struct drm_device * dev, DRMFILE filp) 1336void i810_driver_preclose(struct drm_device * dev, struct drm_file *file_priv)
1349{ 1337{
1350 if (dev->dev_private) { 1338 if (dev->dev_private) {
1351 drm_i810_private_t *dev_priv = dev->dev_private; 1339 drm_i810_private_t *dev_priv = dev->dev_private;
@@ -1355,9 +1343,10 @@ void i810_driver_preclose(struct drm_device * dev, DRMFILE filp)
1355 } 1343 }
1356} 1344}
1357 1345
1358void i810_driver_reclaim_buffers_locked(struct drm_device * dev, struct file *filp) 1346void i810_driver_reclaim_buffers_locked(struct drm_device * dev,
1347 struct drm_file *file_priv)
1359{ 1348{
1360 i810_reclaim_buffers(dev, filp); 1349 i810_reclaim_buffers(dev, file_priv);
1361} 1350}
1362 1351
1363int i810_driver_dma_quiescent(struct drm_device * dev) 1352int i810_driver_dma_quiescent(struct drm_device * dev)
diff --git a/drivers/char/drm/i810_drv.h b/drivers/char/drm/i810_drv.h
index 648833844c7f..4095476f0f67 100644
--- a/drivers/char/drm/i810_drv.h
+++ b/drivers/char/drm/i810_drv.h
@@ -117,12 +117,13 @@ typedef struct drm_i810_private {
117 /* i810_dma.c */ 117 /* i810_dma.c */
118extern int i810_driver_dma_quiescent(struct drm_device * dev); 118extern int i810_driver_dma_quiescent(struct drm_device * dev);
119extern void i810_driver_reclaim_buffers_locked(struct drm_device * dev, 119extern void i810_driver_reclaim_buffers_locked(struct drm_device * dev,
120 struct file *filp); 120 struct drm_file *file_priv);
121extern int i810_driver_load(struct drm_device *, unsigned long flags); 121extern int i810_driver_load(struct drm_device *, unsigned long flags);
122extern void i810_driver_lastclose(struct drm_device * dev); 122extern void i810_driver_lastclose(struct drm_device * dev);
123extern void i810_driver_preclose(struct drm_device * dev, DRMFILE filp); 123extern void i810_driver_preclose(struct drm_device * dev,
124 struct drm_file *file_priv);
124extern void i810_driver_reclaim_buffers_locked(struct drm_device * dev, 125extern void i810_driver_reclaim_buffers_locked(struct drm_device * dev,
125 struct file *filp); 126 struct drm_file *file_priv);
126extern int i810_driver_device_is_agp(struct drm_device * dev); 127extern int i810_driver_device_is_agp(struct drm_device * dev);
127 128
128extern drm_ioctl_desc_t i810_ioctls[]; 129extern drm_ioctl_desc_t i810_ioctls[];
diff --git a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c
index 0bb1cbf48109..f314f8709657 100644
--- a/drivers/char/drm/i830_dma.c
+++ b/drivers/char/drm/i830_dma.c
@@ -122,10 +122,9 @@ static const struct file_operations i830_buffer_fops = {
122 .fasync = drm_fasync, 122 .fasync = drm_fasync,
123}; 123};
124 124
125static int i830_map_buffer(struct drm_buf * buf, struct file *filp) 125static int i830_map_buffer(struct drm_buf * buf, struct drm_file *file_priv)
126{ 126{
127 struct drm_file *priv = filp->private_data; 127 struct drm_device *dev = file_priv->head->dev;
128 struct drm_device *dev = priv->head->dev;
129 drm_i830_buf_priv_t *buf_priv = buf->dev_private; 128 drm_i830_buf_priv_t *buf_priv = buf->dev_private;
130 drm_i830_private_t *dev_priv = dev->dev_private; 129 drm_i830_private_t *dev_priv = dev->dev_private;
131 const struct file_operations *old_fops; 130 const struct file_operations *old_fops;
@@ -136,13 +135,13 @@ static int i830_map_buffer(struct drm_buf * buf, struct file *filp)
136 return -EINVAL; 135 return -EINVAL;
137 136
138 down_write(&current->mm->mmap_sem); 137 down_write(&current->mm->mmap_sem);
139 old_fops = filp->f_op; 138 old_fops = file_priv->filp->f_op;
140 filp->f_op = &i830_buffer_fops; 139 file_priv->filp->f_op = &i830_buffer_fops;
141 dev_priv->mmap_buffer = buf; 140 dev_priv->mmap_buffer = buf;
142 virtual = do_mmap(filp, 0, buf->total, PROT_READ | PROT_WRITE, 141 virtual = do_mmap(file_priv->filp, 0, buf->total, PROT_READ | PROT_WRITE,
143 MAP_SHARED, buf->bus_address); 142 MAP_SHARED, buf->bus_address);
144 dev_priv->mmap_buffer = NULL; 143 dev_priv->mmap_buffer = NULL;
145 filp->f_op = old_fops; 144 file_priv->filp->f_op = old_fops;
146 if (IS_ERR((void *)virtual)) { /* ugh */ 145 if (IS_ERR((void *)virtual)) { /* ugh */
147 /* Real error */ 146 /* Real error */
148 DRM_ERROR("mmap error\n"); 147 DRM_ERROR("mmap error\n");
@@ -177,7 +176,7 @@ static int i830_unmap_buffer(struct drm_buf * buf)
177} 176}
178 177
179static int i830_dma_get_buffer(struct drm_device * dev, drm_i830_dma_t * d, 178static int i830_dma_get_buffer(struct drm_device * dev, drm_i830_dma_t * d,
180 struct file *filp) 179 struct drm_file *file_priv)
181{ 180{
182 struct drm_buf *buf; 181 struct drm_buf *buf;
183 drm_i830_buf_priv_t *buf_priv; 182 drm_i830_buf_priv_t *buf_priv;
@@ -190,13 +189,13 @@ static int i830_dma_get_buffer(struct drm_device * dev, drm_i830_dma_t * d,
190 return retcode; 189 return retcode;
191 } 190 }
192 191
193 retcode = i830_map_buffer(buf, filp); 192 retcode = i830_map_buffer(buf, file_priv);
194 if (retcode) { 193 if (retcode) {
195 i830_freelist_put(dev, buf); 194 i830_freelist_put(dev, buf);
196 DRM_ERROR("mapbuf failed, retcode %d\n", retcode); 195 DRM_ERROR("mapbuf failed, retcode %d\n", retcode);
197 return retcode; 196 return retcode;
198 } 197 }
199 buf->filp = filp; 198 buf->file_priv = file_priv;
200 buf_priv = buf->dev_private; 199 buf_priv = buf->dev_private;
201 d->granted = 1; 200 d->granted = 1;
202 d->request_idx = buf->idx; 201 d->request_idx = buf->idx;
@@ -451,11 +450,10 @@ static int i830_dma_initialize(struct drm_device * dev,
451 return 0; 450 return 0;
452} 451}
453 452
454static int i830_dma_init(struct inode *inode, struct file *filp, 453static int i830_dma_init(struct inode *inode, struct drm_file *file_priv,
455 unsigned int cmd, unsigned long arg) 454 unsigned int cmd, unsigned long arg)
456{ 455{
457 struct drm_file *priv = filp->private_data; 456 struct drm_device *dev = file_priv->head->dev;
458 struct drm_device *dev = priv->head->dev;
459 drm_i830_private_t *dev_priv; 457 drm_i830_private_t *dev_priv;
460 drm_i830_init_t init; 458 drm_i830_init_t init;
461 int retcode = 0; 459 int retcode = 0;
@@ -1248,7 +1246,7 @@ static int i830_flush_queue(struct drm_device * dev)
1248} 1246}
1249 1247
1250/* Must be called with the lock held */ 1248/* Must be called with the lock held */
1251static void i830_reclaim_buffers(struct drm_device * dev, struct file *filp) 1249static void i830_reclaim_buffers(struct drm_device * dev, struct drm_file *file_priv)
1252{ 1250{
1253 struct drm_device_dma *dma = dev->dma; 1251 struct drm_device_dma *dma = dev->dma;
1254 int i; 1252 int i;
@@ -1266,7 +1264,7 @@ static void i830_reclaim_buffers(struct drm_device * dev, struct file *filp)
1266 struct drm_buf *buf = dma->buflist[i]; 1264 struct drm_buf *buf = dma->buflist[i];
1267 drm_i830_buf_priv_t *buf_priv = buf->dev_private; 1265 drm_i830_buf_priv_t *buf_priv = buf->dev_private;
1268 1266
1269 if (buf->filp == filp && buf_priv) { 1267 if (buf->file_priv == file_priv && buf_priv) {
1270 int used = cmpxchg(buf_priv->in_use, I830_BUF_CLIENT, 1268 int used = cmpxchg(buf_priv->in_use, I830_BUF_CLIENT,
1271 I830_BUF_FREE); 1269 I830_BUF_FREE);
1272 1270
@@ -1278,23 +1276,21 @@ static void i830_reclaim_buffers(struct drm_device * dev, struct file *filp)
1278 } 1276 }
1279} 1277}
1280 1278
1281static int i830_flush_ioctl(struct inode *inode, struct file *filp, 1279static int i830_flush_ioctl(struct inode *inode, struct drm_file *file_priv,
1282 unsigned int cmd, unsigned long arg) 1280 unsigned int cmd, unsigned long arg)
1283{ 1281{
1284 struct drm_file *priv = filp->private_data; 1282 struct drm_device *dev = file_priv->head->dev;
1285 struct drm_device *dev = priv->head->dev;
1286 1283
1287 LOCK_TEST_WITH_RETURN(dev, filp); 1284 LOCK_TEST_WITH_RETURN(dev, file_priv);
1288 1285
1289 i830_flush_queue(dev); 1286 i830_flush_queue(dev);
1290 return 0; 1287 return 0;
1291} 1288}
1292 1289
1293static int i830_dma_vertex(struct inode *inode, struct file *filp, 1290static int i830_dma_vertex(struct inode *inode, struct drm_file *file_priv,
1294 unsigned int cmd, unsigned long arg) 1291 unsigned int cmd, unsigned long arg)
1295{ 1292{
1296 struct drm_file *priv = filp->private_data; 1293 struct drm_device *dev = file_priv->head->dev;
1297 struct drm_device *dev = priv->head->dev;
1298 struct drm_device_dma *dma = dev->dma; 1294 struct drm_device_dma *dma = dev->dma;
1299 drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; 1295 drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private;
1300 u32 *hw_status = dev_priv->hw_status_page; 1296 u32 *hw_status = dev_priv->hw_status_page;
@@ -1306,7 +1302,7 @@ static int i830_dma_vertex(struct inode *inode, struct file *filp,
1306 (&vertex, (drm_i830_vertex_t __user *) arg, sizeof(vertex))) 1302 (&vertex, (drm_i830_vertex_t __user *) arg, sizeof(vertex)))
1307 return -EFAULT; 1303 return -EFAULT;
1308 1304
1309 LOCK_TEST_WITH_RETURN(dev, filp); 1305 LOCK_TEST_WITH_RETURN(dev, file_priv);
1310 1306
1311 DRM_DEBUG("i830 dma vertex, idx %d used %d discard %d\n", 1307 DRM_DEBUG("i830 dma vertex, idx %d used %d discard %d\n",
1312 vertex.idx, vertex.used, vertex.discard); 1308 vertex.idx, vertex.used, vertex.discard);
@@ -1324,18 +1320,17 @@ static int i830_dma_vertex(struct inode *inode, struct file *filp,
1324 return 0; 1320 return 0;
1325} 1321}
1326 1322
1327static int i830_clear_bufs(struct inode *inode, struct file *filp, 1323static int i830_clear_bufs(struct inode *inode, struct drm_file *file_priv,
1328 unsigned int cmd, unsigned long arg) 1324 unsigned int cmd, unsigned long arg)
1329{ 1325{
1330 struct drm_file *priv = filp->private_data; 1326 struct drm_device *dev = file_priv->head->dev;
1331 struct drm_device *dev = priv->head->dev;
1332 drm_i830_clear_t clear; 1327 drm_i830_clear_t clear;
1333 1328
1334 if (copy_from_user 1329 if (copy_from_user
1335 (&clear, (drm_i830_clear_t __user *) arg, sizeof(clear))) 1330 (&clear, (drm_i830_clear_t __user *) arg, sizeof(clear)))
1336 return -EFAULT; 1331 return -EFAULT;
1337 1332
1338 LOCK_TEST_WITH_RETURN(dev, filp); 1333 LOCK_TEST_WITH_RETURN(dev, file_priv);
1339 1334
1340 /* GH: Someone's doing nasty things... */ 1335 /* GH: Someone's doing nasty things... */
1341 if (!dev->dev_private) { 1336 if (!dev->dev_private) {
@@ -1348,15 +1343,14 @@ static int i830_clear_bufs(struct inode *inode, struct file *filp,
1348 return 0; 1343 return 0;
1349} 1344}
1350 1345
1351static int i830_swap_bufs(struct inode *inode, struct file *filp, 1346static int i830_swap_bufs(struct inode *inode, struct drm_file *file_priv,
1352 unsigned int cmd, unsigned long arg) 1347 unsigned int cmd, unsigned long arg)
1353{ 1348{
1354 struct drm_file *priv = filp->private_data; 1349 struct drm_device *dev = file_priv->head->dev;
1355 struct drm_device *dev = priv->head->dev;
1356 1350
1357 DRM_DEBUG("i830_swap_bufs\n"); 1351 DRM_DEBUG("i830_swap_bufs\n");
1358 1352
1359 LOCK_TEST_WITH_RETURN(dev, filp); 1353 LOCK_TEST_WITH_RETURN(dev, file_priv);
1360 1354
1361 i830_dma_dispatch_swap(dev); 1355 i830_dma_dispatch_swap(dev);
1362 return 0; 1356 return 0;
@@ -1386,16 +1380,15 @@ static int i830_do_cleanup_pageflip(struct drm_device * dev)
1386 return 0; 1380 return 0;
1387} 1381}
1388 1382
1389static int i830_flip_bufs(struct inode *inode, struct file *filp, 1383static int i830_flip_bufs(struct inode *inode, struct drm_file *file_priv,
1390 unsigned int cmd, unsigned long arg) 1384 unsigned int cmd, unsigned long arg)
1391{ 1385{
1392 struct drm_file *priv = filp->private_data; 1386 struct drm_device *dev = file_priv->head->dev;
1393 struct drm_device *dev = priv->head->dev;
1394 drm_i830_private_t *dev_priv = dev->dev_private; 1387 drm_i830_private_t *dev_priv = dev->dev_private;
1395 1388
1396 DRM_DEBUG("%s\n", __FUNCTION__); 1389 DRM_DEBUG("%s\n", __FUNCTION__);
1397 1390
1398 LOCK_TEST_WITH_RETURN(dev, filp); 1391 LOCK_TEST_WITH_RETURN(dev, file_priv);
1399 1392
1400 if (!dev_priv->page_flipping) 1393 if (!dev_priv->page_flipping)
1401 i830_do_init_pageflip(dev); 1394 i830_do_init_pageflip(dev);
@@ -1404,11 +1397,10 @@ static int i830_flip_bufs(struct inode *inode, struct file *filp,
1404 return 0; 1397 return 0;
1405} 1398}
1406 1399
1407static int i830_getage(struct inode *inode, struct file *filp, unsigned int cmd, 1400static int i830_getage(struct inode *inode, struct drm_file *file_priv, unsigned int cmd,
1408 unsigned long arg) 1401 unsigned long arg)
1409{ 1402{
1410 struct drm_file *priv = filp->private_data; 1403 struct drm_device *dev = file_priv->head->dev;
1411 struct drm_device *dev = priv->head->dev;
1412 drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; 1404 drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private;
1413 u32 *hw_status = dev_priv->hw_status_page; 1405 u32 *hw_status = dev_priv->hw_status_page;
1414 drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) 1406 drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *)
@@ -1418,11 +1410,10 @@ static int i830_getage(struct inode *inode, struct file *filp, unsigned int cmd,
1418 return 0; 1410 return 0;
1419} 1411}
1420 1412
1421static int i830_getbuf(struct inode *inode, struct file *filp, unsigned int cmd, 1413static int i830_getbuf(struct inode *inode, struct drm_file *file_priv,
1422 unsigned long arg) 1414 unsigned int cmd, unsigned long arg)
1423{ 1415{
1424 struct drm_file *priv = filp->private_data; 1416 struct drm_device *dev = file_priv->head->dev;
1425 struct drm_device *dev = priv->head->dev;
1426 int retcode = 0; 1417 int retcode = 0;
1427 drm_i830_dma_t d; 1418 drm_i830_dma_t d;
1428 drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; 1419 drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private;
@@ -1434,11 +1425,11 @@ static int i830_getbuf(struct inode *inode, struct file *filp, unsigned int cmd,
1434 if (copy_from_user(&d, (drm_i830_dma_t __user *) arg, sizeof(d))) 1425 if (copy_from_user(&d, (drm_i830_dma_t __user *) arg, sizeof(d)))
1435 return -EFAULT; 1426 return -EFAULT;
1436 1427
1437 LOCK_TEST_WITH_RETURN(dev, filp); 1428 LOCK_TEST_WITH_RETURN(dev, file_priv);
1438 1429
1439 d.granted = 0; 1430 d.granted = 0;
1440 1431
1441 retcode = i830_dma_get_buffer(dev, &d, filp); 1432 retcode = i830_dma_get_buffer(dev, &d, file_priv);
1442 1433
1443 DRM_DEBUG("i830_dma: %d returning %d, granted = %d\n", 1434 DRM_DEBUG("i830_dma: %d returning %d, granted = %d\n",
1444 current->pid, retcode, d.granted); 1435 current->pid, retcode, d.granted);
@@ -1451,23 +1442,22 @@ static int i830_getbuf(struct inode *inode, struct file *filp, unsigned int cmd,
1451} 1442}
1452 1443
1453static int i830_copybuf(struct inode *inode, 1444static int i830_copybuf(struct inode *inode,
1454 struct file *filp, unsigned int cmd, unsigned long arg) 1445 struct drm_file *file_priv, unsigned int cmd, unsigned long arg)
1455{ 1446{
1456 /* Never copy - 2.4.x doesn't need it */ 1447 /* Never copy - 2.4.x doesn't need it */
1457 return 0; 1448 return 0;
1458} 1449}
1459 1450
1460static int i830_docopy(struct inode *inode, struct file *filp, unsigned int cmd, 1451static int i830_docopy(struct inode *inode, struct drm_file *file_priv, unsigned int cmd,
1461 unsigned long arg) 1452 unsigned long arg)
1462{ 1453{
1463 return 0; 1454 return 0;
1464} 1455}
1465 1456
1466static int i830_getparam(struct inode *inode, struct file *filp, 1457static int i830_getparam(struct inode *inode, struct drm_file *file_priv,
1467 unsigned int cmd, unsigned long arg) 1458 unsigned int cmd, unsigned long arg)
1468{ 1459{
1469 struct drm_file *priv = filp->private_data; 1460 struct drm_device *dev = file_priv->head->dev;
1470 struct drm_device *dev = priv->head->dev;
1471 drm_i830_private_t *dev_priv = dev->dev_private; 1461 drm_i830_private_t *dev_priv = dev->dev_private;
1472 drm_i830_getparam_t param; 1462 drm_i830_getparam_t param;
1473 int value; 1463 int value;
@@ -1497,11 +1487,10 @@ static int i830_getparam(struct inode *inode, struct file *filp,
1497 return 0; 1487 return 0;
1498} 1488}
1499 1489
1500static int i830_setparam(struct inode *inode, struct file *filp, 1490static int i830_setparam(struct inode *inode, struct drm_file *file_priv,
1501 unsigned int cmd, unsigned long arg) 1491 unsigned int cmd, unsigned long arg)
1502{ 1492{
1503 struct drm_file *priv = filp->private_data; 1493 struct drm_device *dev = file_priv->head->dev;
1504 struct drm_device *dev = priv->head->dev;
1505 drm_i830_private_t *dev_priv = dev->dev_private; 1494 drm_i830_private_t *dev_priv = dev->dev_private;
1506 drm_i830_setparam_t param; 1495 drm_i830_setparam_t param;
1507 1496
@@ -1542,7 +1531,7 @@ void i830_driver_lastclose(struct drm_device * dev)
1542 i830_dma_cleanup(dev); 1531 i830_dma_cleanup(dev);
1543} 1532}
1544 1533
1545void i830_driver_preclose(struct drm_device * dev, DRMFILE filp) 1534void i830_driver_preclose(struct drm_device * dev, struct drm_file *file_priv)
1546{ 1535{
1547 if (dev->dev_private) { 1536 if (dev->dev_private) {
1548 drm_i830_private_t *dev_priv = dev->dev_private; 1537 drm_i830_private_t *dev_priv = dev->dev_private;
@@ -1552,9 +1541,9 @@ void i830_driver_preclose(struct drm_device * dev, DRMFILE filp)
1552 } 1541 }
1553} 1542}
1554 1543
1555void i830_driver_reclaim_buffers_locked(struct drm_device * dev, struct file *filp) 1544void i830_driver_reclaim_buffers_locked(struct drm_device * dev, struct drm_file *file_priv)
1556{ 1545{
1557 i830_reclaim_buffers(dev, filp); 1546 i830_reclaim_buffers(dev, file_priv);
1558} 1547}
1559 1548
1560int i830_driver_dma_quiescent(struct drm_device * dev) 1549int i830_driver_dma_quiescent(struct drm_device * dev)
diff --git a/drivers/char/drm/i830_drv.h b/drivers/char/drm/i830_drv.h
index ddda67956dea..615bf9f4cb4a 100644
--- a/drivers/char/drm/i830_drv.h
+++ b/drivers/char/drm/i830_drv.h
@@ -126,9 +126,9 @@ extern drm_ioctl_desc_t i830_ioctls[];
126extern int i830_max_ioctl; 126extern int i830_max_ioctl;
127 127
128/* i830_irq.c */ 128/* i830_irq.c */
129extern int i830_irq_emit(struct inode *inode, struct file *filp, 129extern int i830_irq_emit(struct inode *inode, struct drm_file *file_priv,
130 unsigned int cmd, unsigned long arg); 130 unsigned int cmd, unsigned long arg);
131extern int i830_irq_wait(struct inode *inode, struct file *filp, 131extern int i830_irq_wait(struct inode *inode, struct drm_file *file_priv,
132 unsigned int cmd, unsigned long arg); 132 unsigned int cmd, unsigned long arg);
133 133
134extern irqreturn_t i830_driver_irq_handler(DRM_IRQ_ARGS); 134extern irqreturn_t i830_driver_irq_handler(DRM_IRQ_ARGS);
@@ -136,10 +136,11 @@ extern void i830_driver_irq_preinstall(struct drm_device * dev);
136extern void i830_driver_irq_postinstall(struct drm_device * dev); 136extern void i830_driver_irq_postinstall(struct drm_device * dev);
137extern void i830_driver_irq_uninstall(struct drm_device * dev); 137extern void i830_driver_irq_uninstall(struct drm_device * dev);
138extern int i830_driver_load(struct drm_device *, unsigned long flags); 138extern int i830_driver_load(struct drm_device *, unsigned long flags);
139extern void i830_driver_preclose(struct drm_device * dev, DRMFILE filp); 139extern void i830_driver_preclose(struct drm_device * dev,
140 struct drm_file *file_priv);
140extern void i830_driver_lastclose(struct drm_device * dev); 141extern void i830_driver_lastclose(struct drm_device * dev);
141extern void i830_driver_reclaim_buffers_locked(struct drm_device * dev, 142extern void i830_driver_reclaim_buffers_locked(struct drm_device * dev,
142 struct file *filp); 143 struct drm_file *file_priv);
143extern int i830_driver_dma_quiescent(struct drm_device * dev); 144extern int i830_driver_dma_quiescent(struct drm_device * dev);
144extern int i830_driver_device_is_agp(struct drm_device * dev); 145extern int i830_driver_device_is_agp(struct drm_device * dev);
145 146
diff --git a/drivers/char/drm/i830_irq.c b/drivers/char/drm/i830_irq.c
index a1b5c63c3c3e..9c28939e2db3 100644
--- a/drivers/char/drm/i830_irq.c
+++ b/drivers/char/drm/i830_irq.c
@@ -114,16 +114,15 @@ static int i830_wait_irq(struct drm_device * dev, int irq_nr)
114 114
115/* Needs the lock as it touches the ring. 115/* Needs the lock as it touches the ring.
116 */ 116 */
117int i830_irq_emit(struct inode *inode, struct file *filp, unsigned int cmd, 117int i830_irq_emit(struct inode *inode, struct drm_file *file_priv,
118 unsigned long arg) 118 unsigned int cmd, unsigned long arg)
119{ 119{
120 struct drm_file *priv = filp->private_data; 120 struct drm_device *dev = file_priv->head->dev;
121 struct drm_device *dev = priv->head->dev;
122 drm_i830_private_t *dev_priv = dev->dev_private; 121 drm_i830_private_t *dev_priv = dev->dev_private;
123 drm_i830_irq_emit_t emit; 122 drm_i830_irq_emit_t emit;
124 int result; 123 int result;
125 124
126 LOCK_TEST_WITH_RETURN(dev, filp); 125 LOCK_TEST_WITH_RETURN(dev, file_priv);
127 126
128 if (!dev_priv) { 127 if (!dev_priv) {
129 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 128 DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
@@ -146,11 +145,10 @@ int i830_irq_emit(struct inode *inode, struct file *filp, unsigned int cmd,
146 145
147/* Doesn't need the hardware lock. 146/* Doesn't need the hardware lock.
148 */ 147 */
149int i830_irq_wait(struct inode *inode, struct file *filp, unsigned int cmd, 148int i830_irq_wait(struct inode *inode, struct drm_file *file_priv,
150 unsigned long arg) 149 unsigned int cmd, unsigned long arg)
151{ 150{
152 struct drm_file *priv = filp->private_data; 151 struct drm_device *dev = file_priv->head->dev;
153 struct drm_device *dev = priv->head->dev;
154 drm_i830_private_t *dev_priv = dev->dev_private; 152 drm_i830_private_t *dev_priv = dev->dev_private;
155 drm_i830_irq_wait_t irqwait; 153 drm_i830_irq_wait_t irqwait;
156 154
diff --git a/drivers/char/drm/i915_dma.c b/drivers/char/drm/i915_dma.c
index a7566ff1a3ea..25d8b2b9524d 100644
--- a/drivers/char/drm/i915_dma.c
+++ b/drivers/char/drm/i915_dma.c
@@ -602,7 +602,7 @@ static int i915_flush_ioctl(DRM_IOCTL_ARGS)
602{ 602{
603 DRM_DEVICE; 603 DRM_DEVICE;
604 604
605 LOCK_TEST_WITH_RETURN(dev, filp); 605 LOCK_TEST_WITH_RETURN(dev, file_priv);
606 606
607 return i915_quiescent(dev); 607 return i915_quiescent(dev);
608} 608}
@@ -628,7 +628,7 @@ static int i915_batchbuffer(DRM_IOCTL_ARGS)
628 DRM_DEBUG("i915 batchbuffer, start %x used %d cliprects %d\n", 628 DRM_DEBUG("i915 batchbuffer, start %x used %d cliprects %d\n",
629 batch.start, batch.used, batch.num_cliprects); 629 batch.start, batch.used, batch.num_cliprects);
630 630
631 LOCK_TEST_WITH_RETURN(dev, filp); 631 LOCK_TEST_WITH_RETURN(dev, file_priv);
632 632
633 if (batch.num_cliprects && DRM_VERIFYAREA_READ(batch.cliprects, 633 if (batch.num_cliprects && DRM_VERIFYAREA_READ(batch.cliprects,
634 batch.num_cliprects * 634 batch.num_cliprects *
@@ -657,7 +657,7 @@ static int i915_cmdbuffer(DRM_IOCTL_ARGS)
657 DRM_DEBUG("i915 cmdbuffer, buf %p sz %d cliprects %d\n", 657 DRM_DEBUG("i915 cmdbuffer, buf %p sz %d cliprects %d\n",
658 cmdbuf.buf, cmdbuf.sz, cmdbuf.num_cliprects); 658 cmdbuf.buf, cmdbuf.sz, cmdbuf.num_cliprects);
659 659
660 LOCK_TEST_WITH_RETURN(dev, filp); 660 LOCK_TEST_WITH_RETURN(dev, file_priv);
661 661
662 if (cmdbuf.num_cliprects && 662 if (cmdbuf.num_cliprects &&
663 DRM_VERIFYAREA_READ(cmdbuf.cliprects, 663 DRM_VERIFYAREA_READ(cmdbuf.cliprects,
@@ -683,7 +683,7 @@ static int i915_flip_bufs(DRM_IOCTL_ARGS)
683 683
684 DRM_DEBUG("%s\n", __FUNCTION__); 684 DRM_DEBUG("%s\n", __FUNCTION__);
685 685
686 LOCK_TEST_WITH_RETURN(dev, filp); 686 LOCK_TEST_WITH_RETURN(dev, file_priv);
687 687
688 return i915_dispatch_flip(dev); 688 return i915_dispatch_flip(dev);
689} 689}
@@ -821,11 +821,11 @@ void i915_driver_lastclose(struct drm_device * dev)
821 i915_dma_cleanup(dev); 821 i915_dma_cleanup(dev);
822} 822}
823 823
824void i915_driver_preclose(struct drm_device * dev, DRMFILE filp) 824void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv)
825{ 825{
826 if (dev->dev_private) { 826 if (dev->dev_private) {
827 drm_i915_private_t *dev_priv = dev->dev_private; 827 drm_i915_private_t *dev_priv = dev->dev_private;
828 i915_mem_release(dev, filp, dev_priv->agp_heap); 828 i915_mem_release(dev, file_priv, dev_priv->agp_heap);
829 } 829 }
830} 830}
831 831
diff --git a/drivers/char/drm/i915_drv.h b/drivers/char/drm/i915_drv.h
index 28b98733beb8..12fcd33dfda6 100644
--- a/drivers/char/drm/i915_drv.h
+++ b/drivers/char/drm/i915_drv.h
@@ -70,7 +70,7 @@ struct mem_block {
70 struct mem_block *prev; 70 struct mem_block *prev;
71 int start; 71 int start;
72 int size; 72 int size;
73 DRMFILE filp; /* 0: free, -1: heap, other: real files */ 73 struct drm_file *file_priv; /* NULL: free, -1: heap, other: real files */
74}; 74};
75 75
76typedef struct _drm_i915_vbl_swap { 76typedef struct _drm_i915_vbl_swap {
@@ -123,7 +123,8 @@ extern int i915_max_ioctl;
123extern void i915_kernel_lost_context(struct drm_device * dev); 123extern void i915_kernel_lost_context(struct drm_device * dev);
124extern int i915_driver_load(struct drm_device *, unsigned long flags); 124extern int i915_driver_load(struct drm_device *, unsigned long flags);
125extern void i915_driver_lastclose(struct drm_device * dev); 125extern void i915_driver_lastclose(struct drm_device * dev);
126extern void i915_driver_preclose(struct drm_device * dev, DRMFILE filp); 126extern void i915_driver_preclose(struct drm_device *dev,
127 struct drm_file *file_priv);
127extern int i915_driver_device_is_agp(struct drm_device * dev); 128extern int i915_driver_device_is_agp(struct drm_device * dev);
128extern long i915_compat_ioctl(struct file *filp, unsigned int cmd, 129extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
129 unsigned long arg); 130 unsigned long arg);
@@ -149,7 +150,7 @@ extern int i915_mem_init_heap(DRM_IOCTL_ARGS);
149extern int i915_mem_destroy_heap(DRM_IOCTL_ARGS); 150extern int i915_mem_destroy_heap(DRM_IOCTL_ARGS);
150extern void i915_mem_takedown(struct mem_block **heap); 151extern void i915_mem_takedown(struct mem_block **heap);
151extern void i915_mem_release(struct drm_device * dev, 152extern void i915_mem_release(struct drm_device * dev,
152 DRMFILE filp, struct mem_block *heap); 153 struct drm_file *file_priv, struct mem_block *heap);
153 154
154#define I915_READ(reg) DRM_READ32(dev_priv->mmio_map, (reg)) 155#define I915_READ(reg) DRM_READ32(dev_priv->mmio_map, (reg))
155#define I915_WRITE(reg,val) DRM_WRITE32(dev_priv->mmio_map, (reg), (val)) 156#define I915_WRITE(reg,val) DRM_WRITE32(dev_priv->mmio_map, (reg), (val))
diff --git a/drivers/char/drm/i915_irq.c b/drivers/char/drm/i915_irq.c
index 470e7aa81558..36be24e2e8d4 100644
--- a/drivers/char/drm/i915_irq.c
+++ b/drivers/char/drm/i915_irq.c
@@ -362,7 +362,7 @@ int i915_irq_emit(DRM_IOCTL_ARGS)
362 drm_i915_irq_emit_t emit; 362 drm_i915_irq_emit_t emit;
363 int result; 363 int result;
364 364
365 LOCK_TEST_WITH_RETURN(dev, filp); 365 LOCK_TEST_WITH_RETURN(dev, file_priv);
366 366
367 if (!dev_priv) { 367 if (!dev_priv) {
368 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 368 DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
diff --git a/drivers/char/drm/i915_mem.c b/drivers/char/drm/i915_mem.c
index d3ffad61c6b8..fa279da5be2c 100644
--- a/drivers/char/drm/i915_mem.c
+++ b/drivers/char/drm/i915_mem.c
@@ -89,7 +89,7 @@ static void mark_block(struct drm_device * dev, struct mem_block *p, int in_use)
89 */ 89 */
90 90
91static struct mem_block *split_block(struct mem_block *p, int start, int size, 91static struct mem_block *split_block(struct mem_block *p, int start, int size,
92 DRMFILE filp) 92 struct drm_file *file_priv)
93{ 93{
94 /* Maybe cut off the start of an existing block */ 94 /* Maybe cut off the start of an existing block */
95 if (start > p->start) { 95 if (start > p->start) {
@@ -99,7 +99,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
99 goto out; 99 goto out;
100 newblock->start = start; 100 newblock->start = start;
101 newblock->size = p->size - (start - p->start); 101 newblock->size = p->size - (start - p->start);
102 newblock->filp = NULL; 102 newblock->file_priv = NULL;
103 newblock->next = p->next; 103 newblock->next = p->next;
104 newblock->prev = p; 104 newblock->prev = p;
105 p->next->prev = newblock; 105 p->next->prev = newblock;
@@ -116,7 +116,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
116 goto out; 116 goto out;
117 newblock->start = start + size; 117 newblock->start = start + size;
118 newblock->size = p->size - size; 118 newblock->size = p->size - size;
119 newblock->filp = NULL; 119 newblock->file_priv = NULL;
120 newblock->next = p->next; 120 newblock->next = p->next;
121 newblock->prev = p; 121 newblock->prev = p;
122 p->next->prev = newblock; 122 p->next->prev = newblock;
@@ -126,20 +126,20 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
126 126
127 out: 127 out:
128 /* Our block is in the middle */ 128 /* Our block is in the middle */
129 p->filp = filp; 129 p->file_priv = file_priv;
130 return p; 130 return p;
131} 131}
132 132
133static struct mem_block *alloc_block(struct mem_block *heap, int size, 133static struct mem_block *alloc_block(struct mem_block *heap, int size,
134 int align2, DRMFILE filp) 134 int align2, struct drm_file *file_priv)
135{ 135{
136 struct mem_block *p; 136 struct mem_block *p;
137 int mask = (1 << align2) - 1; 137 int mask = (1 << align2) - 1;
138 138
139 for (p = heap->next; p != heap; p = p->next) { 139 for (p = heap->next; p != heap; p = p->next) {
140 int start = (p->start + mask) & ~mask; 140 int start = (p->start + mask) & ~mask;
141 if (p->filp == NULL && start + size <= p->start + p->size) 141 if (p->file_priv == NULL && start + size <= p->start + p->size)
142 return split_block(p, start, size, filp); 142 return split_block(p, start, size, file_priv);
143 } 143 }
144 144
145 return NULL; 145 return NULL;
@@ -158,12 +158,12 @@ static struct mem_block *find_block(struct mem_block *heap, int start)
158 158
159static void free_block(struct mem_block *p) 159static void free_block(struct mem_block *p)
160{ 160{
161 p->filp = NULL; 161 p->file_priv = NULL;
162 162
163 /* Assumes a single contiguous range. Needs a special filp in 163 /* Assumes a single contiguous range. Needs a special file_priv in
164 * 'heap' to stop it being subsumed. 164 * 'heap' to stop it being subsumed.
165 */ 165 */
166 if (p->next->filp == NULL) { 166 if (p->next->file_priv == NULL) {
167 struct mem_block *q = p->next; 167 struct mem_block *q = p->next;
168 p->size += q->size; 168 p->size += q->size;
169 p->next = q->next; 169 p->next = q->next;
@@ -171,7 +171,7 @@ static void free_block(struct mem_block *p)
171 drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS); 171 drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS);
172 } 172 }
173 173
174 if (p->prev->filp == NULL) { 174 if (p->prev->file_priv == NULL) {
175 struct mem_block *q = p->prev; 175 struct mem_block *q = p->prev;
176 q->size += p->size; 176 q->size += p->size;
177 q->next = p->next; 177 q->next = p->next;
@@ -197,18 +197,19 @@ static int init_heap(struct mem_block **heap, int start, int size)
197 197
198 blocks->start = start; 198 blocks->start = start;
199 blocks->size = size; 199 blocks->size = size;
200 blocks->filp = NULL; 200 blocks->file_priv = NULL;
201 blocks->next = blocks->prev = *heap; 201 blocks->next = blocks->prev = *heap;
202 202
203 memset(*heap, 0, sizeof(**heap)); 203 memset(*heap, 0, sizeof(**heap));
204 (*heap)->filp = (DRMFILE) - 1; 204 (*heap)->file_priv = (struct drm_file *) - 1;
205 (*heap)->next = (*heap)->prev = blocks; 205 (*heap)->next = (*heap)->prev = blocks;
206 return 0; 206 return 0;
207} 207}
208 208
209/* Free all blocks associated with the releasing file. 209/* Free all blocks associated with the releasing file.
210 */ 210 */
211void i915_mem_release(struct drm_device * dev, DRMFILE filp, struct mem_block *heap) 211void i915_mem_release(struct drm_device * dev, struct drm_file *file_priv,
212 struct mem_block *heap)
212{ 213{
213 struct mem_block *p; 214 struct mem_block *p;
214 215
@@ -216,17 +217,17 @@ void i915_mem_release(struct drm_device * dev, DRMFILE filp, struct mem_block *h
216 return; 217 return;
217 218
218 for (p = heap->next; p != heap; p = p->next) { 219 for (p = heap->next; p != heap; p = p->next) {
219 if (p->filp == filp) { 220 if (p->file_priv == file_priv) {
220 p->filp = NULL; 221 p->file_priv = NULL;
221 mark_block(dev, p, 0); 222 mark_block(dev, p, 0);
222 } 223 }
223 } 224 }
224 225
225 /* Assumes a single contiguous range. Needs a special filp in 226 /* Assumes a single contiguous range. Needs a special file_priv in
226 * 'heap' to stop it being subsumed. 227 * 'heap' to stop it being subsumed.
227 */ 228 */
228 for (p = heap->next; p != heap; p = p->next) { 229 for (p = heap->next; p != heap; p = p->next) {
229 while (p->filp == NULL && p->next->filp == NULL) { 230 while (p->file_priv == NULL && p->next->file_priv == NULL) {
230 struct mem_block *q = p->next; 231 struct mem_block *q = p->next;
231 p->size += q->size; 232 p->size += q->size;
232 p->next = q->next; 233 p->next = q->next;
@@ -292,7 +293,7 @@ int i915_mem_alloc(DRM_IOCTL_ARGS)
292 if (alloc.alignment < 12) 293 if (alloc.alignment < 12)
293 alloc.alignment = 12; 294 alloc.alignment = 12;
294 295
295 block = alloc_block(*heap, alloc.size, alloc.alignment, filp); 296 block = alloc_block(*heap, alloc.size, alloc.alignment, file_priv);
296 297
297 if (!block) 298 if (!block)
298 return -ENOMEM; 299 return -ENOMEM;
@@ -330,7 +331,7 @@ int i915_mem_free(DRM_IOCTL_ARGS)
330 if (!block) 331 if (!block)
331 return -EFAULT; 332 return -EFAULT;
332 333
333 if (block->filp != filp) 334 if (block->file_priv != file_priv)
334 return -EPERM; 335 return -EPERM;
335 336
336 mark_block(dev, block, 0); 337 mark_block(dev, block, 0);
diff --git a/drivers/char/drm/mga_dma.c b/drivers/char/drm/mga_dma.c
index 0f23760eb629..95ff450239dd 100644
--- a/drivers/char/drm/mga_dma.c
+++ b/drivers/char/drm/mga_dma.c
@@ -1013,7 +1013,7 @@ int mga_dma_init(DRM_IOCTL_ARGS)
1013 drm_mga_init_t init; 1013 drm_mga_init_t init;
1014 int err; 1014 int err;
1015 1015
1016 LOCK_TEST_WITH_RETURN(dev, filp); 1016 LOCK_TEST_WITH_RETURN(dev, file_priv);
1017 1017
1018 DRM_COPY_FROM_USER_IOCTL(init, (drm_mga_init_t __user *) data, 1018 DRM_COPY_FROM_USER_IOCTL(init, (drm_mga_init_t __user *) data,
1019 sizeof(init)); 1019 sizeof(init));
@@ -1042,7 +1042,7 @@ int mga_dma_flush(DRM_IOCTL_ARGS)
1042 drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; 1042 drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private;
1043 struct drm_lock lock; 1043 struct drm_lock lock;
1044 1044
1045 LOCK_TEST_WITH_RETURN(dev, filp); 1045 LOCK_TEST_WITH_RETURN(dev, file_priv);
1046 1046
1047 DRM_COPY_FROM_USER_IOCTL(lock, (struct drm_lock __user *) data, 1047 DRM_COPY_FROM_USER_IOCTL(lock, (struct drm_lock __user *) data,
1048 sizeof(lock)); 1048 sizeof(lock));
@@ -1077,7 +1077,7 @@ int mga_dma_reset(DRM_IOCTL_ARGS)
1077 DRM_DEVICE; 1077 DRM_DEVICE;
1078 drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; 1078 drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private;
1079 1079
1080 LOCK_TEST_WITH_RETURN(dev, filp); 1080 LOCK_TEST_WITH_RETURN(dev, file_priv);
1081 1081
1082 return mga_do_dma_reset(dev_priv); 1082 return mga_do_dma_reset(dev_priv);
1083} 1083}
@@ -1086,7 +1086,8 @@ int mga_dma_reset(DRM_IOCTL_ARGS)
1086 * DMA buffer management 1086 * DMA buffer management
1087 */ 1087 */
1088 1088
1089static int mga_dma_get_buffers(DRMFILE filp, struct drm_device * dev, struct drm_dma * d) 1089static int mga_dma_get_buffers(struct drm_device * dev,
1090 struct drm_file *file_priv, struct drm_dma * d)
1090{ 1091{
1091 struct drm_buf *buf; 1092 struct drm_buf *buf;
1092 int i; 1093 int i;
@@ -1096,7 +1097,7 @@ static int mga_dma_get_buffers(DRMFILE filp, struct drm_device * dev, struct drm
1096 if (!buf) 1097 if (!buf)
1097 return -EAGAIN; 1098 return -EAGAIN;
1098 1099
1099 buf->filp = filp; 1100 buf->file_priv = file_priv;
1100 1101
1101 if (DRM_COPY_TO_USER(&d->request_indices[i], 1102 if (DRM_COPY_TO_USER(&d->request_indices[i],
1102 &buf->idx, sizeof(buf->idx))) 1103 &buf->idx, sizeof(buf->idx)))
@@ -1119,7 +1120,7 @@ int mga_dma_buffers(DRM_IOCTL_ARGS)
1119 struct drm_dma d; 1120 struct drm_dma d;
1120 int ret = 0; 1121 int ret = 0;
1121 1122
1122 LOCK_TEST_WITH_RETURN(dev, filp); 1123 LOCK_TEST_WITH_RETURN(dev, file_priv);
1123 1124
1124 DRM_COPY_FROM_USER_IOCTL(d, argp, sizeof(d)); 1125 DRM_COPY_FROM_USER_IOCTL(d, argp, sizeof(d));
1125 1126
@@ -1144,7 +1145,7 @@ int mga_dma_buffers(DRM_IOCTL_ARGS)
1144 d.granted_count = 0; 1145 d.granted_count = 0;
1145 1146
1146 if (d.request_count) { 1147 if (d.request_count) {
1147 ret = mga_dma_get_buffers(filp, dev, &d); 1148 ret = mga_dma_get_buffers(dev, file_priv, &d);
1148 } 1149 }
1149 1150
1150 DRM_COPY_TO_USER_IOCTL(argp, d, sizeof(d)); 1151 DRM_COPY_TO_USER_IOCTL(argp, d, sizeof(d));
diff --git a/drivers/char/drm/mga_state.c b/drivers/char/drm/mga_state.c
index 4e9867161170..74811727595a 100644
--- a/drivers/char/drm/mga_state.c
+++ b/drivers/char/drm/mga_state.c
@@ -835,7 +835,7 @@ static int mga_dma_clear(DRM_IOCTL_ARGS)
835 drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; 835 drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
836 drm_mga_clear_t clear; 836 drm_mga_clear_t clear;
837 837
838 LOCK_TEST_WITH_RETURN(dev, filp); 838 LOCK_TEST_WITH_RETURN(dev, file_priv);
839 839
840 DRM_COPY_FROM_USER_IOCTL(clear, (drm_mga_clear_t __user *) data, 840 DRM_COPY_FROM_USER_IOCTL(clear, (drm_mga_clear_t __user *) data,
841 sizeof(clear)); 841 sizeof(clear));
@@ -860,7 +860,7 @@ static int mga_dma_swap(DRM_IOCTL_ARGS)
860 drm_mga_private_t *dev_priv = dev->dev_private; 860 drm_mga_private_t *dev_priv = dev->dev_private;
861 drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; 861 drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
862 862
863 LOCK_TEST_WITH_RETURN(dev, filp); 863 LOCK_TEST_WITH_RETURN(dev, file_priv);
864 864
865 if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS) 865 if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS)
866 sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS; 866 sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
@@ -885,7 +885,7 @@ static int mga_dma_vertex(DRM_IOCTL_ARGS)
885 drm_mga_buf_priv_t *buf_priv; 885 drm_mga_buf_priv_t *buf_priv;
886 drm_mga_vertex_t vertex; 886 drm_mga_vertex_t vertex;
887 887
888 LOCK_TEST_WITH_RETURN(dev, filp); 888 LOCK_TEST_WITH_RETURN(dev, file_priv);
889 889
890 DRM_COPY_FROM_USER_IOCTL(vertex, 890 DRM_COPY_FROM_USER_IOCTL(vertex,
891 (drm_mga_vertex_t __user *) data, 891 (drm_mga_vertex_t __user *) data,
@@ -925,7 +925,7 @@ static int mga_dma_indices(DRM_IOCTL_ARGS)
925 drm_mga_buf_priv_t *buf_priv; 925 drm_mga_buf_priv_t *buf_priv;
926 drm_mga_indices_t indices; 926 drm_mga_indices_t indices;
927 927
928 LOCK_TEST_WITH_RETURN(dev, filp); 928 LOCK_TEST_WITH_RETURN(dev, file_priv);
929 929
930 DRM_COPY_FROM_USER_IOCTL(indices, 930 DRM_COPY_FROM_USER_IOCTL(indices,
931 (drm_mga_indices_t __user *) data, 931 (drm_mga_indices_t __user *) data,
@@ -966,7 +966,7 @@ static int mga_dma_iload(DRM_IOCTL_ARGS)
966 drm_mga_iload_t iload; 966 drm_mga_iload_t iload;
967 DRM_DEBUG("\n"); 967 DRM_DEBUG("\n");
968 968
969 LOCK_TEST_WITH_RETURN(dev, filp); 969 LOCK_TEST_WITH_RETURN(dev, file_priv);
970 970
971 DRM_COPY_FROM_USER_IOCTL(iload, (drm_mga_iload_t __user *) data, 971 DRM_COPY_FROM_USER_IOCTL(iload, (drm_mga_iload_t __user *) data,
972 sizeof(iload)); 972 sizeof(iload));
@@ -1008,7 +1008,7 @@ static int mga_dma_blit(DRM_IOCTL_ARGS)
1008 drm_mga_blit_t blit; 1008 drm_mga_blit_t blit;
1009 DRM_DEBUG("\n"); 1009 DRM_DEBUG("\n");
1010 1010
1011 LOCK_TEST_WITH_RETURN(dev, filp); 1011 LOCK_TEST_WITH_RETURN(dev, file_priv);
1012 1012
1013 DRM_COPY_FROM_USER_IOCTL(blit, (drm_mga_blit_t __user *) data, 1013 DRM_COPY_FROM_USER_IOCTL(blit, (drm_mga_blit_t __user *) data,
1014 sizeof(blit)); 1014 sizeof(blit));
diff --git a/drivers/char/drm/r128_cce.c b/drivers/char/drm/r128_cce.c
index 15e873627d53..4dc8acc6eb61 100644
--- a/drivers/char/drm/r128_cce.c
+++ b/drivers/char/drm/r128_cce.c
@@ -632,7 +632,7 @@ int r128_cce_init(DRM_IOCTL_ARGS)
632 632
633 DRM_DEBUG("\n"); 633 DRM_DEBUG("\n");
634 634
635 LOCK_TEST_WITH_RETURN(dev, filp); 635 LOCK_TEST_WITH_RETURN(dev, file_priv);
636 636
637 DRM_COPY_FROM_USER_IOCTL(init, (drm_r128_init_t __user *) data, 637 DRM_COPY_FROM_USER_IOCTL(init, (drm_r128_init_t __user *) data,
638 sizeof(init)); 638 sizeof(init));
@@ -653,7 +653,7 @@ int r128_cce_start(DRM_IOCTL_ARGS)
653 drm_r128_private_t *dev_priv = dev->dev_private; 653 drm_r128_private_t *dev_priv = dev->dev_private;
654 DRM_DEBUG("\n"); 654 DRM_DEBUG("\n");
655 655
656 LOCK_TEST_WITH_RETURN(dev, filp); 656 LOCK_TEST_WITH_RETURN(dev, file_priv);
657 657
658 if (dev_priv->cce_running || dev_priv->cce_mode == R128_PM4_NONPM4) { 658 if (dev_priv->cce_running || dev_priv->cce_mode == R128_PM4_NONPM4) {
659 DRM_DEBUG("%s while CCE running\n", __FUNCTION__); 659 DRM_DEBUG("%s while CCE running\n", __FUNCTION__);
@@ -676,7 +676,7 @@ int r128_cce_stop(DRM_IOCTL_ARGS)
676 int ret; 676 int ret;
677 DRM_DEBUG("\n"); 677 DRM_DEBUG("\n");
678 678
679 LOCK_TEST_WITH_RETURN(dev, filp); 679 LOCK_TEST_WITH_RETURN(dev, file_priv);
680 680
681 DRM_COPY_FROM_USER_IOCTL(stop, (drm_r128_cce_stop_t __user *) data, 681 DRM_COPY_FROM_USER_IOCTL(stop, (drm_r128_cce_stop_t __user *) data,
682 sizeof(stop)); 682 sizeof(stop));
@@ -717,7 +717,7 @@ int r128_cce_reset(DRM_IOCTL_ARGS)
717 drm_r128_private_t *dev_priv = dev->dev_private; 717 drm_r128_private_t *dev_priv = dev->dev_private;
718 DRM_DEBUG("\n"); 718 DRM_DEBUG("\n");
719 719
720 LOCK_TEST_WITH_RETURN(dev, filp); 720 LOCK_TEST_WITH_RETURN(dev, file_priv);
721 721
722 if (!dev_priv) { 722 if (!dev_priv) {
723 DRM_DEBUG("%s called before init done\n", __FUNCTION__); 723 DRM_DEBUG("%s called before init done\n", __FUNCTION__);
@@ -738,7 +738,7 @@ int r128_cce_idle(DRM_IOCTL_ARGS)
738 drm_r128_private_t *dev_priv = dev->dev_private; 738 drm_r128_private_t *dev_priv = dev->dev_private;
739 DRM_DEBUG("\n"); 739 DRM_DEBUG("\n");
740 740
741 LOCK_TEST_WITH_RETURN(dev, filp); 741 LOCK_TEST_WITH_RETURN(dev, file_priv);
742 742
743 if (dev_priv->cce_running) { 743 if (dev_priv->cce_running) {
744 r128_do_cce_flush(dev_priv); 744 r128_do_cce_flush(dev_priv);
@@ -752,7 +752,7 @@ int r128_engine_reset(DRM_IOCTL_ARGS)
752 DRM_DEVICE; 752 DRM_DEVICE;
753 DRM_DEBUG("\n"); 753 DRM_DEBUG("\n");
754 754
755 LOCK_TEST_WITH_RETURN(dev, filp); 755 LOCK_TEST_WITH_RETURN(dev, file_priv);
756 756
757 return r128_do_engine_reset(dev); 757 return r128_do_engine_reset(dev);
758} 758}
@@ -828,7 +828,7 @@ static struct drm_buf *r128_freelist_get(struct drm_device * dev)
828 for (i = 0; i < dma->buf_count; i++) { 828 for (i = 0; i < dma->buf_count; i++) {
829 buf = dma->buflist[i]; 829 buf = dma->buflist[i];
830 buf_priv = buf->dev_private; 830 buf_priv = buf->dev_private;
831 if (buf->filp == 0) 831 if (buf->file_priv == 0)
832 return buf; 832 return buf;
833 } 833 }
834 834
@@ -886,7 +886,9 @@ int r128_wait_ring(drm_r128_private_t * dev_priv, int n)
886 return -EBUSY; 886 return -EBUSY;
887} 887}
888 888
889static int r128_cce_get_buffers(DRMFILE filp, struct drm_device * dev, struct drm_dma * d) 889static int r128_cce_get_buffers(struct drm_device * dev,
890 struct drm_file *file_priv,
891 struct drm_dma * d)
890{ 892{
891 int i; 893 int i;
892 struct drm_buf *buf; 894 struct drm_buf *buf;
@@ -896,7 +898,7 @@ static int r128_cce_get_buffers(DRMFILE filp, struct drm_device * dev, struct dr
896 if (!buf) 898 if (!buf)
897 return -EAGAIN; 899 return -EAGAIN;
898 900
899 buf->filp = filp; 901 buf->file_priv = file_priv;
900 902
901 if (DRM_COPY_TO_USER(&d->request_indices[i], &buf->idx, 903 if (DRM_COPY_TO_USER(&d->request_indices[i], &buf->idx,
902 sizeof(buf->idx))) 904 sizeof(buf->idx)))
@@ -918,7 +920,7 @@ int r128_cce_buffers(DRM_IOCTL_ARGS)
918 struct drm_dma __user *argp = (void __user *)data; 920 struct drm_dma __user *argp = (void __user *)data;
919 struct drm_dma d; 921 struct drm_dma d;
920 922
921 LOCK_TEST_WITH_RETURN(dev, filp); 923 LOCK_TEST_WITH_RETURN(dev, file_priv);
922 924
923 DRM_COPY_FROM_USER_IOCTL(d, argp, sizeof(d)); 925 DRM_COPY_FROM_USER_IOCTL(d, argp, sizeof(d));
924 926
@@ -941,7 +943,7 @@ int r128_cce_buffers(DRM_IOCTL_ARGS)
941 d.granted_count = 0; 943 d.granted_count = 0;
942 944
943 if (d.request_count) { 945 if (d.request_count) {
944 ret = r128_cce_get_buffers(filp, dev, &d); 946 ret = r128_cce_get_buffers(dev, file_priv, &d);
945 } 947 }
946 948
947 DRM_COPY_TO_USER_IOCTL(argp, d, sizeof(d)); 949 DRM_COPY_TO_USER_IOCTL(argp, d, sizeof(d));
diff --git a/drivers/char/drm/r128_drv.h b/drivers/char/drm/r128_drv.h
index 2835aa3c302f..580b182eadb1 100644
--- a/drivers/char/drm/r128_drv.h
+++ b/drivers/char/drm/r128_drv.h
@@ -156,7 +156,8 @@ extern void r128_driver_irq_preinstall(struct drm_device * dev);
156extern void r128_driver_irq_postinstall(struct drm_device * dev); 156extern void r128_driver_irq_postinstall(struct drm_device * dev);
157extern void r128_driver_irq_uninstall(struct drm_device * dev); 157extern void r128_driver_irq_uninstall(struct drm_device * dev);
158extern void r128_driver_lastclose(struct drm_device * dev); 158extern void r128_driver_lastclose(struct drm_device * dev);
159extern void r128_driver_preclose(struct drm_device * dev, DRMFILE filp); 159extern void r128_driver_preclose(struct drm_device * dev,
160 struct drm_file *file_priv);
160 161
161extern long r128_compat_ioctl(struct file *filp, unsigned int cmd, 162extern long r128_compat_ioctl(struct file *filp, unsigned int cmd,
162 unsigned long arg); 163 unsigned long arg);
diff --git a/drivers/char/drm/r128_state.c b/drivers/char/drm/r128_state.c
index f0e2571e94a9..029f63b59a7d 100644
--- a/drivers/char/drm/r128_state.c
+++ b/drivers/char/drm/r128_state.c
@@ -776,8 +776,9 @@ static void r128_cce_dispatch_indices(struct drm_device * dev,
776 sarea_priv->nbox = 0; 776 sarea_priv->nbox = 0;
777} 777}
778 778
779static int r128_cce_dispatch_blit(DRMFILE filp, 779static int r128_cce_dispatch_blit(struct drm_device * dev,
780 struct drm_device * dev, drm_r128_blit_t * blit) 780 struct drm_file *file_priv,
781 drm_r128_blit_t * blit)
781{ 782{
782 drm_r128_private_t *dev_priv = dev->dev_private; 783 drm_r128_private_t *dev_priv = dev->dev_private;
783 struct drm_device_dma *dma = dev->dma; 784 struct drm_device_dma *dma = dev->dma;
@@ -829,9 +830,9 @@ static int r128_cce_dispatch_blit(DRMFILE filp,
829 buf = dma->buflist[blit->idx]; 830 buf = dma->buflist[blit->idx];
830 buf_priv = buf->dev_private; 831 buf_priv = buf->dev_private;
831 832
832 if (buf->filp != filp) { 833 if (buf->file_priv != file_priv) {
833 DRM_ERROR("process %d using buffer owned by %p\n", 834 DRM_ERROR("process %d using buffer owned by %p\n",
834 DRM_CURRENTPID, buf->filp); 835 DRM_CURRENTPID, buf->file_priv);
835 return -EINVAL; 836 return -EINVAL;
836 } 837 }
837 if (buf->pending) { 838 if (buf->pending) {
@@ -1249,7 +1250,7 @@ static int r128_cce_clear(DRM_IOCTL_ARGS)
1249 drm_r128_clear_t clear; 1250 drm_r128_clear_t clear;
1250 DRM_DEBUG("\n"); 1251 DRM_DEBUG("\n");
1251 1252
1252 LOCK_TEST_WITH_RETURN(dev, filp); 1253 LOCK_TEST_WITH_RETURN(dev, file_priv);
1253 1254
1254 DRM_COPY_FROM_USER_IOCTL(clear, (drm_r128_clear_t __user *) data, 1255 DRM_COPY_FROM_USER_IOCTL(clear, (drm_r128_clear_t __user *) data,
1255 sizeof(clear)); 1256 sizeof(clear));
@@ -1315,7 +1316,7 @@ static int r128_cce_flip(DRM_IOCTL_ARGS)
1315 drm_r128_private_t *dev_priv = dev->dev_private; 1316 drm_r128_private_t *dev_priv = dev->dev_private;
1316 DRM_DEBUG("%s\n", __FUNCTION__); 1317 DRM_DEBUG("%s\n", __FUNCTION__);
1317 1318
1318 LOCK_TEST_WITH_RETURN(dev, filp); 1319 LOCK_TEST_WITH_RETURN(dev, file_priv);
1319 1320
1320 RING_SPACE_TEST_WITH_RETURN(dev_priv); 1321 RING_SPACE_TEST_WITH_RETURN(dev_priv);
1321 1322
@@ -1335,7 +1336,7 @@ static int r128_cce_swap(DRM_IOCTL_ARGS)
1335 drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; 1336 drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
1336 DRM_DEBUG("%s\n", __FUNCTION__); 1337 DRM_DEBUG("%s\n", __FUNCTION__);
1337 1338
1338 LOCK_TEST_WITH_RETURN(dev, filp); 1339 LOCK_TEST_WITH_RETURN(dev, file_priv);
1339 1340
1340 RING_SPACE_TEST_WITH_RETURN(dev_priv); 1341 RING_SPACE_TEST_WITH_RETURN(dev_priv);
1341 1342
@@ -1359,7 +1360,7 @@ static int r128_cce_vertex(DRM_IOCTL_ARGS)
1359 drm_r128_buf_priv_t *buf_priv; 1360 drm_r128_buf_priv_t *buf_priv;
1360 drm_r128_vertex_t vertex; 1361 drm_r128_vertex_t vertex;
1361 1362
1362 LOCK_TEST_WITH_RETURN(dev, filp); 1363 LOCK_TEST_WITH_RETURN(dev, file_priv);
1363 1364
1364 if (!dev_priv) { 1365 if (!dev_priv) {
1365 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 1366 DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
@@ -1389,9 +1390,9 @@ static int r128_cce_vertex(DRM_IOCTL_ARGS)
1389 buf = dma->buflist[vertex.idx]; 1390 buf = dma->buflist[vertex.idx];
1390 buf_priv = buf->dev_private; 1391 buf_priv = buf->dev_private;
1391 1392
1392 if (buf->filp != filp) { 1393 if (buf->file_priv != file_priv) {
1393 DRM_ERROR("process %d using buffer owned by %p\n", 1394 DRM_ERROR("process %d using buffer owned by %p\n",
1394 DRM_CURRENTPID, buf->filp); 1395 DRM_CURRENTPID, buf->file_priv);
1395 return -EINVAL; 1396 return -EINVAL;
1396 } 1397 }
1397 if (buf->pending) { 1398 if (buf->pending) {
@@ -1419,7 +1420,7 @@ static int r128_cce_indices(DRM_IOCTL_ARGS)
1419 drm_r128_indices_t elts; 1420 drm_r128_indices_t elts;
1420 int count; 1421 int count;
1421 1422
1422 LOCK_TEST_WITH_RETURN(dev, filp); 1423 LOCK_TEST_WITH_RETURN(dev, file_priv);
1423 1424
1424 if (!dev_priv) { 1425 if (!dev_priv) {
1425 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 1426 DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
@@ -1448,9 +1449,9 @@ static int r128_cce_indices(DRM_IOCTL_ARGS)
1448 buf = dma->buflist[elts.idx]; 1449 buf = dma->buflist[elts.idx];
1449 buf_priv = buf->dev_private; 1450 buf_priv = buf->dev_private;
1450 1451
1451 if (buf->filp != filp) { 1452 if (buf->file_priv != file_priv) {
1452 DRM_ERROR("process %d using buffer owned by %p\n", 1453 DRM_ERROR("process %d using buffer owned by %p\n",
1453 DRM_CURRENTPID, buf->filp); 1454 DRM_CURRENTPID, buf->file_priv);
1454 return -EINVAL; 1455 return -EINVAL;
1455 } 1456 }
1456 if (buf->pending) { 1457 if (buf->pending) {
@@ -1488,7 +1489,7 @@ static int r128_cce_blit(DRM_IOCTL_ARGS)
1488 drm_r128_blit_t blit; 1489 drm_r128_blit_t blit;
1489 int ret; 1490 int ret;
1490 1491
1491 LOCK_TEST_WITH_RETURN(dev, filp); 1492 LOCK_TEST_WITH_RETURN(dev, file_priv);
1492 1493
1493 DRM_COPY_FROM_USER_IOCTL(blit, (drm_r128_blit_t __user *) data, 1494 DRM_COPY_FROM_USER_IOCTL(blit, (drm_r128_blit_t __user *) data,
1494 sizeof(blit)); 1495 sizeof(blit));
@@ -1504,7 +1505,7 @@ static int r128_cce_blit(DRM_IOCTL_ARGS)
1504 RING_SPACE_TEST_WITH_RETURN(dev_priv); 1505 RING_SPACE_TEST_WITH_RETURN(dev_priv);
1505 VB_AGE_TEST_WITH_RETURN(dev_priv); 1506 VB_AGE_TEST_WITH_RETURN(dev_priv);
1506 1507
1507 ret = r128_cce_dispatch_blit(filp, dev, &blit); 1508 ret = r128_cce_dispatch_blit(dev, file_priv, &blit);
1508 1509
1509 COMMIT_RING(); 1510 COMMIT_RING();
1510 return ret; 1511 return ret;
@@ -1517,7 +1518,7 @@ static int r128_cce_depth(DRM_IOCTL_ARGS)
1517 drm_r128_depth_t depth; 1518 drm_r128_depth_t depth;
1518 int ret; 1519 int ret;
1519 1520
1520 LOCK_TEST_WITH_RETURN(dev, filp); 1521 LOCK_TEST_WITH_RETURN(dev, file_priv);
1521 1522
1522 DRM_COPY_FROM_USER_IOCTL(depth, (drm_r128_depth_t __user *) data, 1523 DRM_COPY_FROM_USER_IOCTL(depth, (drm_r128_depth_t __user *) data,
1523 sizeof(depth)); 1524 sizeof(depth));
@@ -1551,7 +1552,7 @@ static int r128_cce_stipple(DRM_IOCTL_ARGS)
1551 drm_r128_stipple_t stipple; 1552 drm_r128_stipple_t stipple;
1552 u32 mask[32]; 1553 u32 mask[32];
1553 1554
1554 LOCK_TEST_WITH_RETURN(dev, filp); 1555 LOCK_TEST_WITH_RETURN(dev, file_priv);
1555 1556
1556 DRM_COPY_FROM_USER_IOCTL(stipple, (drm_r128_stipple_t __user *) data, 1557 DRM_COPY_FROM_USER_IOCTL(stipple, (drm_r128_stipple_t __user *) data,
1557 sizeof(stipple)); 1558 sizeof(stipple));
@@ -1579,7 +1580,7 @@ static int r128_cce_indirect(DRM_IOCTL_ARGS)
1579 RING_LOCALS; 1580 RING_LOCALS;
1580#endif 1581#endif
1581 1582
1582 LOCK_TEST_WITH_RETURN(dev, filp); 1583 LOCK_TEST_WITH_RETURN(dev, file_priv);
1583 1584
1584 if (!dev_priv) { 1585 if (!dev_priv) {
1585 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 1586 DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
@@ -1601,9 +1602,9 @@ static int r128_cce_indirect(DRM_IOCTL_ARGS)
1601 buf = dma->buflist[indirect.idx]; 1602 buf = dma->buflist[indirect.idx];
1602 buf_priv = buf->dev_private; 1603 buf_priv = buf->dev_private;
1603 1604
1604 if (buf->filp != filp) { 1605 if (buf->file_priv != file_priv) {
1605 DRM_ERROR("process %d using buffer owned by %p\n", 1606 DRM_ERROR("process %d using buffer owned by %p\n",
1606 DRM_CURRENTPID, buf->filp); 1607 DRM_CURRENTPID, buf->file_priv);
1607 return -EINVAL; 1608 return -EINVAL;
1608 } 1609 }
1609 if (buf->pending) { 1610 if (buf->pending) {
@@ -1675,7 +1676,7 @@ static int r128_getparam(DRM_IOCTL_ARGS)
1675 return 0; 1676 return 0;
1676} 1677}
1677 1678
1678void r128_driver_preclose(struct drm_device * dev, DRMFILE filp) 1679void r128_driver_preclose(struct drm_device * dev, struct drm_file *file_priv)
1679{ 1680{
1680 if (dev->dev_private) { 1681 if (dev->dev_private) {
1681 drm_r128_private_t *dev_priv = dev->dev_private; 1682 drm_r128_private_t *dev_priv = dev->dev_private;
diff --git a/drivers/char/drm/r300_cmdbuf.c b/drivers/char/drm/r300_cmdbuf.c
index 669aee68ce24..59b2944811c5 100644
--- a/drivers/char/drm/r300_cmdbuf.c
+++ b/drivers/char/drm/r300_cmdbuf.c
@@ -780,8 +780,7 @@ static int r300_scratch(drm_radeon_private_t *dev_priv,
780 * Called by the ioctl handler function radeon_cp_cmdbuf. 780 * Called by the ioctl handler function radeon_cp_cmdbuf.
781 */ 781 */
782int r300_do_cp_cmdbuf(struct drm_device *dev, 782int r300_do_cp_cmdbuf(struct drm_device *dev,
783 DRMFILE filp, 783 struct drm_file *file_priv,
784 struct drm_file *filp_priv,
785 drm_radeon_kcmd_buffer_t *cmdbuf) 784 drm_radeon_kcmd_buffer_t *cmdbuf)
786{ 785{
787 drm_radeon_private_t *dev_priv = dev->dev_private; 786 drm_radeon_private_t *dev_priv = dev->dev_private;
@@ -884,9 +883,10 @@ int r300_do_cp_cmdbuf(struct drm_device *dev,
884 } 883 }
885 884
886 buf = dma->buflist[idx]; 885 buf = dma->buflist[idx];
887 if (buf->filp != filp || buf->pending) { 886 if (buf->file_priv != file_priv || buf->pending) {
888 DRM_ERROR("bad buffer %p %p %d\n", 887 DRM_ERROR("bad buffer %p %p %d\n",
889 buf->filp, filp, buf->pending); 888 buf->file_priv, file_priv,
889 buf->pending);
890 ret = -EINVAL; 890 ret = -EINVAL;
891 goto cleanup; 891 goto cleanup;
892 } 892 }
diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c
index a023fce3f1b1..af95b5897a0c 100644
--- a/drivers/char/drm/radeon_cp.c
+++ b/drivers/char/drm/radeon_cp.c
@@ -1828,7 +1828,7 @@ int radeon_cp_init(DRM_IOCTL_ARGS)
1828 DRM_DEVICE; 1828 DRM_DEVICE;
1829 drm_radeon_init_t init; 1829 drm_radeon_init_t init;
1830 1830
1831 LOCK_TEST_WITH_RETURN(dev, filp); 1831 LOCK_TEST_WITH_RETURN(dev, file_priv);
1832 1832
1833 DRM_COPY_FROM_USER_IOCTL(init, (drm_radeon_init_t __user *) data, 1833 DRM_COPY_FROM_USER_IOCTL(init, (drm_radeon_init_t __user *) data,
1834 sizeof(init)); 1834 sizeof(init));
@@ -1854,7 +1854,7 @@ int radeon_cp_start(DRM_IOCTL_ARGS)
1854 drm_radeon_private_t *dev_priv = dev->dev_private; 1854 drm_radeon_private_t *dev_priv = dev->dev_private;
1855 DRM_DEBUG("\n"); 1855 DRM_DEBUG("\n");
1856 1856
1857 LOCK_TEST_WITH_RETURN(dev, filp); 1857 LOCK_TEST_WITH_RETURN(dev, file_priv);
1858 1858
1859 if (dev_priv->cp_running) { 1859 if (dev_priv->cp_running) {
1860 DRM_DEBUG("%s while CP running\n", __FUNCTION__); 1860 DRM_DEBUG("%s while CP running\n", __FUNCTION__);
@@ -1882,7 +1882,7 @@ int radeon_cp_stop(DRM_IOCTL_ARGS)
1882 int ret; 1882 int ret;
1883 DRM_DEBUG("\n"); 1883 DRM_DEBUG("\n");
1884 1884
1885 LOCK_TEST_WITH_RETURN(dev, filp); 1885 LOCK_TEST_WITH_RETURN(dev, file_priv);
1886 1886
1887 DRM_COPY_FROM_USER_IOCTL(stop, (drm_radeon_cp_stop_t __user *) data, 1887 DRM_COPY_FROM_USER_IOCTL(stop, (drm_radeon_cp_stop_t __user *) data,
1888 sizeof(stop)); 1888 sizeof(stop));
@@ -1969,7 +1969,7 @@ int radeon_cp_reset(DRM_IOCTL_ARGS)
1969 drm_radeon_private_t *dev_priv = dev->dev_private; 1969 drm_radeon_private_t *dev_priv = dev->dev_private;
1970 DRM_DEBUG("\n"); 1970 DRM_DEBUG("\n");
1971 1971
1972 LOCK_TEST_WITH_RETURN(dev, filp); 1972 LOCK_TEST_WITH_RETURN(dev, file_priv);
1973 1973
1974 if (!dev_priv) { 1974 if (!dev_priv) {
1975 DRM_DEBUG("%s called before init done\n", __FUNCTION__); 1975 DRM_DEBUG("%s called before init done\n", __FUNCTION__);
@@ -1990,7 +1990,7 @@ int radeon_cp_idle(DRM_IOCTL_ARGS)
1990 drm_radeon_private_t *dev_priv = dev->dev_private; 1990 drm_radeon_private_t *dev_priv = dev->dev_private;
1991 DRM_DEBUG("\n"); 1991 DRM_DEBUG("\n");
1992 1992
1993 LOCK_TEST_WITH_RETURN(dev, filp); 1993 LOCK_TEST_WITH_RETURN(dev, file_priv);
1994 1994
1995 return radeon_do_cp_idle(dev_priv); 1995 return radeon_do_cp_idle(dev_priv);
1996} 1996}
@@ -2009,7 +2009,7 @@ int radeon_engine_reset(DRM_IOCTL_ARGS)
2009 DRM_DEVICE; 2009 DRM_DEVICE;
2010 DRM_DEBUG("\n"); 2010 DRM_DEBUG("\n");
2011 2011
2012 LOCK_TEST_WITH_RETURN(dev, filp); 2012 LOCK_TEST_WITH_RETURN(dev, file_priv);
2013 2013
2014 return radeon_do_engine_reset(dev); 2014 return radeon_do_engine_reset(dev);
2015} 2015}
@@ -2066,8 +2066,9 @@ struct drm_buf *radeon_freelist_get(struct drm_device * dev)
2066 for (i = start; i < dma->buf_count; i++) { 2066 for (i = start; i < dma->buf_count; i++) {
2067 buf = dma->buflist[i]; 2067 buf = dma->buflist[i];
2068 buf_priv = buf->dev_private; 2068 buf_priv = buf->dev_private;
2069 if (buf->filp == 0 || (buf->pending && 2069 if (buf->file_priv == NULL || (buf->pending &&
2070 buf_priv->age <= done_age)) { 2070 buf_priv->age <=
2071 done_age)) {
2071 dev_priv->stats.requested_bufs++; 2072 dev_priv->stats.requested_bufs++;
2072 buf->pending = 0; 2073 buf->pending = 0;
2073 return buf; 2074 return buf;
@@ -2106,8 +2107,9 @@ struct drm_buf *radeon_freelist_get(struct drm_device * dev)
2106 for (i = start; i < dma->buf_count; i++) { 2107 for (i = start; i < dma->buf_count; i++) {
2107 buf = dma->buflist[i]; 2108 buf = dma->buflist[i];
2108 buf_priv = buf->dev_private; 2109 buf_priv = buf->dev_private;
2109 if (buf->filp == 0 || (buf->pending && 2110 if (buf->file_priv == 0 || (buf->pending &&
2110 buf_priv->age <= done_age)) { 2111 buf_priv->age <=
2112 done_age)) {
2111 dev_priv->stats.requested_bufs++; 2113 dev_priv->stats.requested_bufs++;
2112 buf->pending = 0; 2114 buf->pending = 0;
2113 return buf; 2115 return buf;
@@ -2170,7 +2172,8 @@ int radeon_wait_ring(drm_radeon_private_t * dev_priv, int n)
2170 return -EBUSY; 2172 return -EBUSY;
2171} 2173}
2172 2174
2173static int radeon_cp_get_buffers(DRMFILE filp, struct drm_device * dev, 2175static int radeon_cp_get_buffers(struct drm_device *dev,
2176 struct drm_file *file_priv,
2174 struct drm_dma * d) 2177 struct drm_dma * d)
2175{ 2178{
2176 int i; 2179 int i;
@@ -2181,7 +2184,7 @@ static int radeon_cp_get_buffers(DRMFILE filp, struct drm_device * dev,
2181 if (!buf) 2184 if (!buf)
2182 return -EBUSY; /* NOTE: broken client */ 2185 return -EBUSY; /* NOTE: broken client */
2183 2186
2184 buf->filp = filp; 2187 buf->file_priv = file_priv;
2185 2188
2186 if (DRM_COPY_TO_USER(&d->request_indices[i], &buf->idx, 2189 if (DRM_COPY_TO_USER(&d->request_indices[i], &buf->idx,
2187 sizeof(buf->idx))) 2190 sizeof(buf->idx)))
@@ -2203,7 +2206,7 @@ int radeon_cp_buffers(DRM_IOCTL_ARGS)
2203 struct drm_dma __user *argp = (void __user *)data; 2206 struct drm_dma __user *argp = (void __user *)data;
2204 struct drm_dma d; 2207 struct drm_dma d;
2205 2208
2206 LOCK_TEST_WITH_RETURN(dev, filp); 2209 LOCK_TEST_WITH_RETURN(dev, file_priv);
2207 2210
2208 DRM_COPY_FROM_USER_IOCTL(d, argp, sizeof(d)); 2211 DRM_COPY_FROM_USER_IOCTL(d, argp, sizeof(d));
2209 2212
@@ -2226,7 +2229,7 @@ int radeon_cp_buffers(DRM_IOCTL_ARGS)
2226 d.granted_count = 0; 2229 d.granted_count = 0;
2227 2230
2228 if (d.request_count) { 2231 if (d.request_count) {
2229 ret = radeon_cp_get_buffers(filp, dev, &d); 2232 ret = radeon_cp_get_buffers(dev, file_priv, &d);
2230 } 2233 }
2231 2234
2232 DRM_COPY_TO_USER_IOCTL(argp, d, sizeof(d)); 2235 DRM_COPY_TO_USER_IOCTL(argp, d, sizeof(d));
diff --git a/drivers/char/drm/radeon_drv.h b/drivers/char/drm/radeon_drv.h
index 3b3d9357201c..160c02785b5d 100644
--- a/drivers/char/drm/radeon_drv.h
+++ b/drivers/char/drm/radeon_drv.h
@@ -188,7 +188,7 @@ struct mem_block {
188 struct mem_block *prev; 188 struct mem_block *prev;
189 int start; 189 int start;
190 int size; 190 int size;
191 DRMFILE filp; /* 0: free, -1: heap, other: real files */ 191 struct drm_file *file_priv; /* NULL: free, -1: heap, other: real files */
192}; 192};
193 193
194struct radeon_surface { 194struct radeon_surface {
@@ -203,7 +203,7 @@ struct radeon_virt_surface {
203 u32 lower; 203 u32 lower;
204 u32 upper; 204 u32 upper;
205 u32 flags; 205 u32 flags;
206 DRMFILE filp; 206 struct drm_file *file_priv;
207}; 207};
208 208
209typedef struct drm_radeon_private { 209typedef struct drm_radeon_private {
@@ -351,7 +351,8 @@ extern int radeon_mem_alloc(DRM_IOCTL_ARGS);
351extern int radeon_mem_free(DRM_IOCTL_ARGS); 351extern int radeon_mem_free(DRM_IOCTL_ARGS);
352extern int radeon_mem_init_heap(DRM_IOCTL_ARGS); 352extern int radeon_mem_init_heap(DRM_IOCTL_ARGS);
353extern void radeon_mem_takedown(struct mem_block **heap); 353extern void radeon_mem_takedown(struct mem_block **heap);
354extern void radeon_mem_release(DRMFILE filp, struct mem_block *heap); 354extern void radeon_mem_release(struct drm_file *file_priv,
355 struct mem_block *heap);
355 356
356 /* radeon_irq.c */ 357 /* radeon_irq.c */
357extern int radeon_irq_emit(DRM_IOCTL_ARGS); 358extern int radeon_irq_emit(DRM_IOCTL_ARGS);
@@ -372,7 +373,7 @@ extern int radeon_vblank_crtc_set(struct drm_device *dev, int64_t value);
372extern int radeon_driver_load(struct drm_device *dev, unsigned long flags); 373extern int radeon_driver_load(struct drm_device *dev, unsigned long flags);
373extern int radeon_driver_unload(struct drm_device *dev); 374extern int radeon_driver_unload(struct drm_device *dev);
374extern int radeon_driver_firstopen(struct drm_device *dev); 375extern int radeon_driver_firstopen(struct drm_device *dev);
375extern void radeon_driver_preclose(struct drm_device * dev, DRMFILE filp); 376extern void radeon_driver_preclose(struct drm_device * dev, struct drm_file *file_priv);
376extern void radeon_driver_postclose(struct drm_device * dev, struct drm_file * filp); 377extern void radeon_driver_postclose(struct drm_device * dev, struct drm_file * filp);
377extern void radeon_driver_lastclose(struct drm_device * dev); 378extern void radeon_driver_lastclose(struct drm_device * dev);
378extern int radeon_driver_open(struct drm_device * dev, struct drm_file * filp_priv); 379extern int radeon_driver_open(struct drm_device * dev, struct drm_file * filp_priv);
@@ -382,8 +383,8 @@ extern long radeon_compat_ioctl(struct file *filp, unsigned int cmd,
382/* r300_cmdbuf.c */ 383/* r300_cmdbuf.c */
383extern void r300_init_reg_flags(void); 384extern void r300_init_reg_flags(void);
384 385
385extern int r300_do_cp_cmdbuf(struct drm_device * dev, DRMFILE filp, 386extern int r300_do_cp_cmdbuf(struct drm_device * dev,
386 struct drm_file * filp_priv, 387 struct drm_file *file_priv,
387 drm_radeon_kcmd_buffer_t * cmdbuf); 388 drm_radeon_kcmd_buffer_t * cmdbuf);
388 389
389/* Flags for stats.boxes 390/* Flags for stats.boxes
diff --git a/drivers/char/drm/radeon_irq.c b/drivers/char/drm/radeon_irq.c
index 88d19a2e85c0..173cb06bb294 100644
--- a/drivers/char/drm/radeon_irq.c
+++ b/drivers/char/drm/radeon_irq.c
@@ -203,7 +203,7 @@ int radeon_irq_emit(DRM_IOCTL_ARGS)
203 drm_radeon_irq_emit_t emit; 203 drm_radeon_irq_emit_t emit;
204 int result; 204 int result;
205 205
206 LOCK_TEST_WITH_RETURN(dev, filp); 206 LOCK_TEST_WITH_RETURN(dev, file_priv);
207 207
208 if (!dev_priv) { 208 if (!dev_priv) {
209 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 209 DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
diff --git a/drivers/char/drm/radeon_mem.c b/drivers/char/drm/radeon_mem.c
index df5b2e0bea33..966d521cf27c 100644
--- a/drivers/char/drm/radeon_mem.c
+++ b/drivers/char/drm/radeon_mem.c
@@ -39,7 +39,7 @@
39 */ 39 */
40 40
41static struct mem_block *split_block(struct mem_block *p, int start, int size, 41static struct mem_block *split_block(struct mem_block *p, int start, int size,
42 DRMFILE filp) 42 struct drm_file *file_priv)
43{ 43{
44 /* Maybe cut off the start of an existing block */ 44 /* Maybe cut off the start of an existing block */
45 if (start > p->start) { 45 if (start > p->start) {
@@ -49,7 +49,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
49 goto out; 49 goto out;
50 newblock->start = start; 50 newblock->start = start;
51 newblock->size = p->size - (start - p->start); 51 newblock->size = p->size - (start - p->start);
52 newblock->filp = NULL; 52 newblock->file_priv = NULL;
53 newblock->next = p->next; 53 newblock->next = p->next;
54 newblock->prev = p; 54 newblock->prev = p;
55 p->next->prev = newblock; 55 p->next->prev = newblock;
@@ -66,7 +66,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
66 goto out; 66 goto out;
67 newblock->start = start + size; 67 newblock->start = start + size;
68 newblock->size = p->size - size; 68 newblock->size = p->size - size;
69 newblock->filp = NULL; 69 newblock->file_priv = NULL;
70 newblock->next = p->next; 70 newblock->next = p->next;
71 newblock->prev = p; 71 newblock->prev = p;
72 p->next->prev = newblock; 72 p->next->prev = newblock;
@@ -76,20 +76,20 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
76 76
77 out: 77 out:
78 /* Our block is in the middle */ 78 /* Our block is in the middle */
79 p->filp = filp; 79 p->file_priv = file_priv;
80 return p; 80 return p;
81} 81}
82 82
83static struct mem_block *alloc_block(struct mem_block *heap, int size, 83static struct mem_block *alloc_block(struct mem_block *heap, int size,
84 int align2, DRMFILE filp) 84 int align2, struct drm_file *file_priv)
85{ 85{
86 struct mem_block *p; 86 struct mem_block *p;
87 int mask = (1 << align2) - 1; 87 int mask = (1 << align2) - 1;
88 88
89 list_for_each(p, heap) { 89 list_for_each(p, heap) {
90 int start = (p->start + mask) & ~mask; 90 int start = (p->start + mask) & ~mask;
91 if (p->filp == 0 && start + size <= p->start + p->size) 91 if (p->file_priv == 0 && start + size <= p->start + p->size)
92 return split_block(p, start, size, filp); 92 return split_block(p, start, size, file_priv);
93 } 93 }
94 94
95 return NULL; 95 return NULL;
@@ -108,12 +108,12 @@ static struct mem_block *find_block(struct mem_block *heap, int start)
108 108
109static void free_block(struct mem_block *p) 109static void free_block(struct mem_block *p)
110{ 110{
111 p->filp = NULL; 111 p->file_priv = NULL;
112 112
113 /* Assumes a single contiguous range. Needs a special filp in 113 /* Assumes a single contiguous range. Needs a special file_priv in
114 * 'heap' to stop it being subsumed. 114 * 'heap' to stop it being subsumed.
115 */ 115 */
116 if (p->next->filp == 0) { 116 if (p->next->file_priv == 0) {
117 struct mem_block *q = p->next; 117 struct mem_block *q = p->next;
118 p->size += q->size; 118 p->size += q->size;
119 p->next = q->next; 119 p->next = q->next;
@@ -121,7 +121,7 @@ static void free_block(struct mem_block *p)
121 drm_free(q, sizeof(*q), DRM_MEM_BUFS); 121 drm_free(q, sizeof(*q), DRM_MEM_BUFS);
122 } 122 }
123 123
124 if (p->prev->filp == 0) { 124 if (p->prev->file_priv == 0) {
125 struct mem_block *q = p->prev; 125 struct mem_block *q = p->prev;
126 q->size += p->size; 126 q->size += p->size;
127 q->next = p->next; 127 q->next = p->next;
@@ -147,18 +147,18 @@ static int init_heap(struct mem_block **heap, int start, int size)
147 147
148 blocks->start = start; 148 blocks->start = start;
149 blocks->size = size; 149 blocks->size = size;
150 blocks->filp = NULL; 150 blocks->file_priv = NULL;
151 blocks->next = blocks->prev = *heap; 151 blocks->next = blocks->prev = *heap;
152 152
153 memset(*heap, 0, sizeof(**heap)); 153 memset(*heap, 0, sizeof(**heap));
154 (*heap)->filp = (DRMFILE) - 1; 154 (*heap)->file_priv = (struct drm_file *) - 1;
155 (*heap)->next = (*heap)->prev = blocks; 155 (*heap)->next = (*heap)->prev = blocks;
156 return 0; 156 return 0;
157} 157}
158 158
159/* Free all blocks associated with the releasing file. 159/* Free all blocks associated with the releasing file.
160 */ 160 */
161void radeon_mem_release(DRMFILE filp, struct mem_block *heap) 161void radeon_mem_release(struct drm_file *file_priv, struct mem_block *heap)
162{ 162{
163 struct mem_block *p; 163 struct mem_block *p;
164 164
@@ -166,15 +166,15 @@ void radeon_mem_release(DRMFILE filp, struct mem_block *heap)
166 return; 166 return;
167 167
168 list_for_each(p, heap) { 168 list_for_each(p, heap) {
169 if (p->filp == filp) 169 if (p->file_priv == file_priv)
170 p->filp = NULL; 170 p->file_priv = NULL;
171 } 171 }
172 172
173 /* Assumes a single contiguous range. Needs a special filp in 173 /* Assumes a single contiguous range. Needs a special file_priv in
174 * 'heap' to stop it being subsumed. 174 * 'heap' to stop it being subsumed.
175 */ 175 */
176 list_for_each(p, heap) { 176 list_for_each(p, heap) {
177 while (p->filp == 0 && p->next->filp == 0) { 177 while (p->file_priv == 0 && p->next->file_priv == 0) {
178 struct mem_block *q = p->next; 178 struct mem_block *q = p->next;
179 p->size += q->size; 179 p->size += q->size;
180 p->next = q->next; 180 p->next = q->next;
@@ -242,7 +242,7 @@ int radeon_mem_alloc(DRM_IOCTL_ARGS)
242 if (alloc.alignment < 12) 242 if (alloc.alignment < 12)
243 alloc.alignment = 12; 243 alloc.alignment = 12;
244 244
245 block = alloc_block(*heap, alloc.size, alloc.alignment, filp); 245 block = alloc_block(*heap, alloc.size, alloc.alignment, file_priv);
246 246
247 if (!block) 247 if (!block)
248 return -ENOMEM; 248 return -ENOMEM;
@@ -278,7 +278,7 @@ int radeon_mem_free(DRM_IOCTL_ARGS)
278 if (!block) 278 if (!block)
279 return -EFAULT; 279 return -EFAULT;
280 280
281 if (block->filp != filp) 281 if (block->file_priv != file_priv)
282 return -EPERM; 282 return -EPERM;
283 283
284 free_block(block); 284 free_block(block);
diff --git a/drivers/char/drm/radeon_state.c b/drivers/char/drm/radeon_state.c
index 4bc0909b226f..bd1aafdc3c29 100644
--- a/drivers/char/drm/radeon_state.c
+++ b/drivers/char/drm/radeon_state.c
@@ -39,7 +39,7 @@
39 39
40static __inline__ int radeon_check_and_fixup_offset(drm_radeon_private_t * 40static __inline__ int radeon_check_and_fixup_offset(drm_radeon_private_t *
41 dev_priv, 41 dev_priv,
42 struct drm_file * filp_priv, 42 struct drm_file * file_priv,
43 u32 *offset) 43 u32 *offset)
44{ 44{
45 u64 off = *offset; 45 u64 off = *offset;
@@ -71,7 +71,7 @@ static __inline__ int radeon_check_and_fixup_offset(drm_radeon_private_t *
71 * magic offset we get from SETPARAM or calculated from fb_location 71 * magic offset we get from SETPARAM or calculated from fb_location
72 */ 72 */
73 if (off < (dev_priv->fb_size + dev_priv->gart_size)) { 73 if (off < (dev_priv->fb_size + dev_priv->gart_size)) {
74 radeon_priv = filp_priv->driver_priv; 74 radeon_priv = file_priv->driver_priv;
75 off += radeon_priv->radeon_fb_delta; 75 off += radeon_priv->radeon_fb_delta;
76 } 76 }
77 77
@@ -90,13 +90,13 @@ static __inline__ int radeon_check_and_fixup_offset(drm_radeon_private_t *
90 90
91static __inline__ int radeon_check_and_fixup_packets(drm_radeon_private_t * 91static __inline__ int radeon_check_and_fixup_packets(drm_radeon_private_t *
92 dev_priv, 92 dev_priv,
93 struct drm_file * filp_priv, 93 struct drm_file *file_priv,
94 int id, u32 *data) 94 int id, u32 *data)
95{ 95{
96 switch (id) { 96 switch (id) {
97 97
98 case RADEON_EMIT_PP_MISC: 98 case RADEON_EMIT_PP_MISC:
99 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, 99 if (radeon_check_and_fixup_offset(dev_priv, file_priv,
100 &data[(RADEON_RB3D_DEPTHOFFSET - RADEON_PP_MISC) / 4])) { 100 &data[(RADEON_RB3D_DEPTHOFFSET - RADEON_PP_MISC) / 4])) {
101 DRM_ERROR("Invalid depth buffer offset\n"); 101 DRM_ERROR("Invalid depth buffer offset\n");
102 return -EINVAL; 102 return -EINVAL;
@@ -104,7 +104,7 @@ static __inline__ int radeon_check_and_fixup_packets(drm_radeon_private_t *
104 break; 104 break;
105 105
106 case RADEON_EMIT_PP_CNTL: 106 case RADEON_EMIT_PP_CNTL:
107 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, 107 if (radeon_check_and_fixup_offset(dev_priv, file_priv,
108 &data[(RADEON_RB3D_COLOROFFSET - RADEON_PP_CNTL) / 4])) { 108 &data[(RADEON_RB3D_COLOROFFSET - RADEON_PP_CNTL) / 4])) {
109 DRM_ERROR("Invalid colour buffer offset\n"); 109 DRM_ERROR("Invalid colour buffer offset\n");
110 return -EINVAL; 110 return -EINVAL;
@@ -117,7 +117,7 @@ static __inline__ int radeon_check_and_fixup_packets(drm_radeon_private_t *
117 case R200_EMIT_PP_TXOFFSET_3: 117 case R200_EMIT_PP_TXOFFSET_3:
118 case R200_EMIT_PP_TXOFFSET_4: 118 case R200_EMIT_PP_TXOFFSET_4:
119 case R200_EMIT_PP_TXOFFSET_5: 119 case R200_EMIT_PP_TXOFFSET_5:
120 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, 120 if (radeon_check_and_fixup_offset(dev_priv, file_priv,
121 &data[0])) { 121 &data[0])) {
122 DRM_ERROR("Invalid R200 texture offset\n"); 122 DRM_ERROR("Invalid R200 texture offset\n");
123 return -EINVAL; 123 return -EINVAL;
@@ -127,7 +127,7 @@ static __inline__ int radeon_check_and_fixup_packets(drm_radeon_private_t *
127 case RADEON_EMIT_PP_TXFILTER_0: 127 case RADEON_EMIT_PP_TXFILTER_0:
128 case RADEON_EMIT_PP_TXFILTER_1: 128 case RADEON_EMIT_PP_TXFILTER_1:
129 case RADEON_EMIT_PP_TXFILTER_2: 129 case RADEON_EMIT_PP_TXFILTER_2:
130 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, 130 if (radeon_check_and_fixup_offset(dev_priv, file_priv,
131 &data[(RADEON_PP_TXOFFSET_0 - RADEON_PP_TXFILTER_0) / 4])) { 131 &data[(RADEON_PP_TXOFFSET_0 - RADEON_PP_TXFILTER_0) / 4])) {
132 DRM_ERROR("Invalid R100 texture offset\n"); 132 DRM_ERROR("Invalid R100 texture offset\n");
133 return -EINVAL; 133 return -EINVAL;
@@ -143,7 +143,7 @@ static __inline__ int radeon_check_and_fixup_packets(drm_radeon_private_t *
143 int i; 143 int i;
144 for (i = 0; i < 5; i++) { 144 for (i = 0; i < 5; i++) {
145 if (radeon_check_and_fixup_offset(dev_priv, 145 if (radeon_check_and_fixup_offset(dev_priv,
146 filp_priv, 146 file_priv,
147 &data[i])) { 147 &data[i])) {
148 DRM_ERROR 148 DRM_ERROR
149 ("Invalid R200 cubic texture offset\n"); 149 ("Invalid R200 cubic texture offset\n");
@@ -159,7 +159,7 @@ static __inline__ int radeon_check_and_fixup_packets(drm_radeon_private_t *
159 int i; 159 int i;
160 for (i = 0; i < 5; i++) { 160 for (i = 0; i < 5; i++) {
161 if (radeon_check_and_fixup_offset(dev_priv, 161 if (radeon_check_and_fixup_offset(dev_priv,
162 filp_priv, 162 file_priv,
163 &data[i])) { 163 &data[i])) {
164 DRM_ERROR 164 DRM_ERROR
165 ("Invalid R100 cubic texture offset\n"); 165 ("Invalid R100 cubic texture offset\n");
@@ -264,7 +264,7 @@ static __inline__ int radeon_check_and_fixup_packets(drm_radeon_private_t *
264 264
265static __inline__ int radeon_check_and_fixup_packet3(drm_radeon_private_t * 265static __inline__ int radeon_check_and_fixup_packet3(drm_radeon_private_t *
266 dev_priv, 266 dev_priv,
267 struct drm_file *filp_priv, 267 struct drm_file *file_priv,
268 drm_radeon_kcmd_buffer_t * 268 drm_radeon_kcmd_buffer_t *
269 cmdbuf, 269 cmdbuf,
270 unsigned int *cmdsz) 270 unsigned int *cmdsz)
@@ -326,7 +326,8 @@ static __inline__ int radeon_check_and_fixup_packet3(drm_radeon_private_t *
326 i = 2; 326 i = 2;
327 while ((k < narrays) && (i < (count + 2))) { 327 while ((k < narrays) && (i < (count + 2))) {
328 i++; /* skip attribute field */ 328 i++; /* skip attribute field */
329 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, &cmd[i])) { 329 if (radeon_check_and_fixup_offset(dev_priv, file_priv,
330 &cmd[i])) {
330 DRM_ERROR 331 DRM_ERROR
331 ("Invalid offset (k=%d i=%d) in 3D_LOAD_VBPNTR packet.\n", 332 ("Invalid offset (k=%d i=%d) in 3D_LOAD_VBPNTR packet.\n",
332 k, i); 333 k, i);
@@ -337,7 +338,9 @@ static __inline__ int radeon_check_and_fixup_packet3(drm_radeon_private_t *
337 if (k == narrays) 338 if (k == narrays)
338 break; 339 break;
339 /* have one more to process, they come in pairs */ 340 /* have one more to process, they come in pairs */
340 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, &cmd[i])) { 341 if (radeon_check_and_fixup_offset(dev_priv,
342 file_priv, &cmd[i]))
343 {
341 DRM_ERROR 344 DRM_ERROR
342 ("Invalid offset (k=%d i=%d) in 3D_LOAD_VBPNTR packet.\n", 345 ("Invalid offset (k=%d i=%d) in 3D_LOAD_VBPNTR packet.\n",
343 k, i); 346 k, i);
@@ -360,7 +363,7 @@ static __inline__ int radeon_check_and_fixup_packet3(drm_radeon_private_t *
360 DRM_ERROR("Invalid 3d packet for r200-class chip\n"); 363 DRM_ERROR("Invalid 3d packet for r200-class chip\n");
361 return -EINVAL; 364 return -EINVAL;
362 } 365 }
363 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, &cmd[1])) { 366 if (radeon_check_and_fixup_offset(dev_priv, file_priv, &cmd[1])) {
364 DRM_ERROR("Invalid rndr_gen_indx offset\n"); 367 DRM_ERROR("Invalid rndr_gen_indx offset\n");
365 return -EINVAL; 368 return -EINVAL;
366 } 369 }
@@ -375,7 +378,7 @@ static __inline__ int radeon_check_and_fixup_packet3(drm_radeon_private_t *
375 DRM_ERROR("Invalid indx_buffer reg address %08X\n", cmd[1]); 378 DRM_ERROR("Invalid indx_buffer reg address %08X\n", cmd[1]);
376 return -EINVAL; 379 return -EINVAL;
377 } 380 }
378 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, &cmd[2])) { 381 if (radeon_check_and_fixup_offset(dev_priv, file_priv, &cmd[2])) {
379 DRM_ERROR("Invalid indx_buffer offset is %08X\n", cmd[2]); 382 DRM_ERROR("Invalid indx_buffer offset is %08X\n", cmd[2]);
380 return -EINVAL; 383 return -EINVAL;
381 } 384 }
@@ -389,7 +392,7 @@ static __inline__ int radeon_check_and_fixup_packet3(drm_radeon_private_t *
389 | RADEON_GMC_DST_PITCH_OFFSET_CNTL)) { 392 | RADEON_GMC_DST_PITCH_OFFSET_CNTL)) {
390 offset = cmd[2] << 10; 393 offset = cmd[2] << 10;
391 if (radeon_check_and_fixup_offset 394 if (radeon_check_and_fixup_offset
392 (dev_priv, filp_priv, &offset)) { 395 (dev_priv, file_priv, &offset)) {
393 DRM_ERROR("Invalid first packet offset\n"); 396 DRM_ERROR("Invalid first packet offset\n");
394 return -EINVAL; 397 return -EINVAL;
395 } 398 }
@@ -400,7 +403,7 @@ static __inline__ int radeon_check_and_fixup_packet3(drm_radeon_private_t *
400 (cmd[1] & RADEON_GMC_DST_PITCH_OFFSET_CNTL)) { 403 (cmd[1] & RADEON_GMC_DST_PITCH_OFFSET_CNTL)) {
401 offset = cmd[3] << 10; 404 offset = cmd[3] << 10;
402 if (radeon_check_and_fixup_offset 405 if (radeon_check_and_fixup_offset
403 (dev_priv, filp_priv, &offset)) { 406 (dev_priv, file_priv, &offset)) {
404 DRM_ERROR("Invalid second packet offset\n"); 407 DRM_ERROR("Invalid second packet offset\n");
405 return -EINVAL; 408 return -EINVAL;
406 } 409 }
@@ -439,7 +442,7 @@ static __inline__ void radeon_emit_clip_rect(drm_radeon_private_t * dev_priv,
439/* Emit 1.1 state 442/* Emit 1.1 state
440 */ 443 */
441static int radeon_emit_state(drm_radeon_private_t * dev_priv, 444static int radeon_emit_state(drm_radeon_private_t * dev_priv,
442 struct drm_file * filp_priv, 445 struct drm_file *file_priv,
443 drm_radeon_context_regs_t * ctx, 446 drm_radeon_context_regs_t * ctx,
444 drm_radeon_texture_regs_t * tex, 447 drm_radeon_texture_regs_t * tex,
445 unsigned int dirty) 448 unsigned int dirty)
@@ -448,13 +451,13 @@ static int radeon_emit_state(drm_radeon_private_t * dev_priv,
448 DRM_DEBUG("dirty=0x%08x\n", dirty); 451 DRM_DEBUG("dirty=0x%08x\n", dirty);
449 452
450 if (dirty & RADEON_UPLOAD_CONTEXT) { 453 if (dirty & RADEON_UPLOAD_CONTEXT) {
451 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, 454 if (radeon_check_and_fixup_offset(dev_priv, file_priv,
452 &ctx->rb3d_depthoffset)) { 455 &ctx->rb3d_depthoffset)) {
453 DRM_ERROR("Invalid depth buffer offset\n"); 456 DRM_ERROR("Invalid depth buffer offset\n");
454 return -EINVAL; 457 return -EINVAL;
455 } 458 }
456 459
457 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, 460 if (radeon_check_and_fixup_offset(dev_priv, file_priv,
458 &ctx->rb3d_coloroffset)) { 461 &ctx->rb3d_coloroffset)) {
459 DRM_ERROR("Invalid depth buffer offset\n"); 462 DRM_ERROR("Invalid depth buffer offset\n");
460 return -EINVAL; 463 return -EINVAL;
@@ -543,7 +546,7 @@ static int radeon_emit_state(drm_radeon_private_t * dev_priv,
543 } 546 }
544 547
545 if (dirty & RADEON_UPLOAD_TEX0) { 548 if (dirty & RADEON_UPLOAD_TEX0) {
546 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, 549 if (radeon_check_and_fixup_offset(dev_priv, file_priv,
547 &tex[0].pp_txoffset)) { 550 &tex[0].pp_txoffset)) {
548 DRM_ERROR("Invalid texture offset for unit 0\n"); 551 DRM_ERROR("Invalid texture offset for unit 0\n");
549 return -EINVAL; 552 return -EINVAL;
@@ -563,7 +566,7 @@ static int radeon_emit_state(drm_radeon_private_t * dev_priv,
563 } 566 }
564 567
565 if (dirty & RADEON_UPLOAD_TEX1) { 568 if (dirty & RADEON_UPLOAD_TEX1) {
566 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, 569 if (radeon_check_and_fixup_offset(dev_priv, file_priv,
567 &tex[1].pp_txoffset)) { 570 &tex[1].pp_txoffset)) {
568 DRM_ERROR("Invalid texture offset for unit 1\n"); 571 DRM_ERROR("Invalid texture offset for unit 1\n");
569 return -EINVAL; 572 return -EINVAL;
@@ -583,7 +586,7 @@ static int radeon_emit_state(drm_radeon_private_t * dev_priv,
583 } 586 }
584 587
585 if (dirty & RADEON_UPLOAD_TEX2) { 588 if (dirty & RADEON_UPLOAD_TEX2) {
586 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, 589 if (radeon_check_and_fixup_offset(dev_priv, file_priv,
587 &tex[2].pp_txoffset)) { 590 &tex[2].pp_txoffset)) {
588 DRM_ERROR("Invalid texture offset for unit 2\n"); 591 DRM_ERROR("Invalid texture offset for unit 2\n");
589 return -EINVAL; 592 return -EINVAL;
@@ -608,7 +611,7 @@ static int radeon_emit_state(drm_radeon_private_t * dev_priv,
608/* Emit 1.2 state 611/* Emit 1.2 state
609 */ 612 */
610static int radeon_emit_state2(drm_radeon_private_t * dev_priv, 613static int radeon_emit_state2(drm_radeon_private_t * dev_priv,
611 struct drm_file * filp_priv, 614 struct drm_file *file_priv,
612 drm_radeon_state_t * state) 615 drm_radeon_state_t * state)
613{ 616{
614 RING_LOCALS; 617 RING_LOCALS;
@@ -621,7 +624,7 @@ static int radeon_emit_state2(drm_radeon_private_t * dev_priv,
621 ADVANCE_RING(); 624 ADVANCE_RING();
622 } 625 }
623 626
624 return radeon_emit_state(dev_priv, filp_priv, &state->context, 627 return radeon_emit_state(dev_priv, file_priv, &state->context,
625 state->tex, state->dirty); 628 state->tex, state->dirty);
626} 629}
627 630
@@ -1646,13 +1649,12 @@ static void radeon_cp_dispatch_indices(struct drm_device * dev,
1646 1649
1647#define RADEON_MAX_TEXTURE_SIZE RADEON_BUFFER_SIZE 1650#define RADEON_MAX_TEXTURE_SIZE RADEON_BUFFER_SIZE
1648 1651
1649static int radeon_cp_dispatch_texture(DRMFILE filp, 1652static int radeon_cp_dispatch_texture(struct drm_device * dev,
1650 struct drm_device * dev, 1653 struct drm_file *file_priv,
1651 drm_radeon_texture_t * tex, 1654 drm_radeon_texture_t * tex,
1652 drm_radeon_tex_image_t * image) 1655 drm_radeon_tex_image_t * image)
1653{ 1656{
1654 drm_radeon_private_t *dev_priv = dev->dev_private; 1657 drm_radeon_private_t *dev_priv = dev->dev_private;
1655 struct drm_file *filp_priv;
1656 struct drm_buf *buf; 1658 struct drm_buf *buf;
1657 u32 format; 1659 u32 format;
1658 u32 *buffer; 1660 u32 *buffer;
@@ -1664,9 +1666,7 @@ static int radeon_cp_dispatch_texture(DRMFILE filp,
1664 u32 offset; 1666 u32 offset;
1665 RING_LOCALS; 1667 RING_LOCALS;
1666 1668
1667 DRM_GET_PRIV_WITH_RETURN(filp_priv, filp); 1669 if (radeon_check_and_fixup_offset(dev_priv, file_priv, &tex->offset)) {
1668
1669 if (radeon_check_and_fixup_offset(dev_priv, filp_priv, &tex->offset)) {
1670 DRM_ERROR("Invalid destination offset\n"); 1670 DRM_ERROR("Invalid destination offset\n");
1671 return -EINVAL; 1671 return -EINVAL;
1672 } 1672 }
@@ -1841,7 +1841,7 @@ static int radeon_cp_dispatch_texture(DRMFILE filp,
1841 } 1841 }
1842 1842
1843#undef RADEON_COPY_MT 1843#undef RADEON_COPY_MT
1844 buf->filp = filp; 1844 buf->file_priv = file_priv;
1845 buf->used = size; 1845 buf->used = size;
1846 offset = dev_priv->gart_buffers_offset + buf->offset; 1846 offset = dev_priv->gart_buffers_offset + buf->offset;
1847 BEGIN_RING(9); 1847 BEGIN_RING(9);
@@ -1929,7 +1929,8 @@ static void radeon_apply_surface_regs(int surf_index,
1929 * not always be available. 1929 * not always be available.
1930 */ 1930 */
1931static int alloc_surface(drm_radeon_surface_alloc_t *new, 1931static int alloc_surface(drm_radeon_surface_alloc_t *new,
1932 drm_radeon_private_t *dev_priv, DRMFILE filp) 1932 drm_radeon_private_t *dev_priv,
1933 struct drm_file *file_priv)
1933{ 1934{
1934 struct radeon_virt_surface *s; 1935 struct radeon_virt_surface *s;
1935 int i; 1936 int i;
@@ -1959,7 +1960,7 @@ static int alloc_surface(drm_radeon_surface_alloc_t *new,
1959 1960
1960 /* find a virtual surface */ 1961 /* find a virtual surface */
1961 for (i = 0; i < 2 * RADEON_MAX_SURFACES; i++) 1962 for (i = 0; i < 2 * RADEON_MAX_SURFACES; i++)
1962 if (dev_priv->virt_surfaces[i].filp == 0) 1963 if (dev_priv->virt_surfaces[i].file_priv == 0)
1963 break; 1964 break;
1964 if (i == 2 * RADEON_MAX_SURFACES) { 1965 if (i == 2 * RADEON_MAX_SURFACES) {
1965 return -1; 1966 return -1;
@@ -1977,7 +1978,7 @@ static int alloc_surface(drm_radeon_surface_alloc_t *new,
1977 s->lower = new_lower; 1978 s->lower = new_lower;
1978 s->upper = new_upper; 1979 s->upper = new_upper;
1979 s->flags = new->flags; 1980 s->flags = new->flags;
1980 s->filp = filp; 1981 s->file_priv = file_priv;
1981 dev_priv->surfaces[i].refcount++; 1982 dev_priv->surfaces[i].refcount++;
1982 dev_priv->surfaces[i].lower = s->lower; 1983 dev_priv->surfaces[i].lower = s->lower;
1983 radeon_apply_surface_regs(s->surface_index, dev_priv); 1984 radeon_apply_surface_regs(s->surface_index, dev_priv);
@@ -1993,7 +1994,7 @@ static int alloc_surface(drm_radeon_surface_alloc_t *new,
1993 s->lower = new_lower; 1994 s->lower = new_lower;
1994 s->upper = new_upper; 1995 s->upper = new_upper;
1995 s->flags = new->flags; 1996 s->flags = new->flags;
1996 s->filp = filp; 1997 s->file_priv = file_priv;
1997 dev_priv->surfaces[i].refcount++; 1998 dev_priv->surfaces[i].refcount++;
1998 dev_priv->surfaces[i].upper = s->upper; 1999 dev_priv->surfaces[i].upper = s->upper;
1999 radeon_apply_surface_regs(s->surface_index, dev_priv); 2000 radeon_apply_surface_regs(s->surface_index, dev_priv);
@@ -2009,7 +2010,7 @@ static int alloc_surface(drm_radeon_surface_alloc_t *new,
2009 s->lower = new_lower; 2010 s->lower = new_lower;
2010 s->upper = new_upper; 2011 s->upper = new_upper;
2011 s->flags = new->flags; 2012 s->flags = new->flags;
2012 s->filp = filp; 2013 s->file_priv = file_priv;
2013 dev_priv->surfaces[i].refcount = 1; 2014 dev_priv->surfaces[i].refcount = 1;
2014 dev_priv->surfaces[i].lower = s->lower; 2015 dev_priv->surfaces[i].lower = s->lower;
2015 dev_priv->surfaces[i].upper = s->upper; 2016 dev_priv->surfaces[i].upper = s->upper;
@@ -2023,7 +2024,8 @@ static int alloc_surface(drm_radeon_surface_alloc_t *new,
2023 return -1; 2024 return -1;
2024} 2025}
2025 2026
2026static int free_surface(DRMFILE filp, drm_radeon_private_t * dev_priv, 2027static int free_surface(struct drm_file *file_priv,
2028 drm_radeon_private_t * dev_priv,
2027 int lower) 2029 int lower)
2028{ 2030{
2029 struct radeon_virt_surface *s; 2031 struct radeon_virt_surface *s;
@@ -2031,8 +2033,9 @@ static int free_surface(DRMFILE filp, drm_radeon_private_t * dev_priv,
2031 /* find the virtual surface */ 2033 /* find the virtual surface */
2032 for (i = 0; i < 2 * RADEON_MAX_SURFACES; i++) { 2034 for (i = 0; i < 2 * RADEON_MAX_SURFACES; i++) {
2033 s = &(dev_priv->virt_surfaces[i]); 2035 s = &(dev_priv->virt_surfaces[i]);
2034 if (s->filp) { 2036 if (s->file_priv) {
2035 if ((lower == s->lower) && (filp == s->filp)) { 2037 if ((lower == s->lower) && (file_priv == s->file_priv))
2038 {
2036 if (dev_priv->surfaces[s->surface_index]. 2039 if (dev_priv->surfaces[s->surface_index].
2037 lower == s->lower) 2040 lower == s->lower)
2038 dev_priv->surfaces[s->surface_index]. 2041 dev_priv->surfaces[s->surface_index].
@@ -2048,7 +2051,7 @@ static int free_surface(DRMFILE filp, drm_radeon_private_t * dev_priv,
2048 refcount == 0) 2051 refcount == 0)
2049 dev_priv->surfaces[s->surface_index]. 2052 dev_priv->surfaces[s->surface_index].
2050 flags = 0; 2053 flags = 0;
2051 s->filp = NULL; 2054 s->file_priv = NULL;
2052 radeon_apply_surface_regs(s->surface_index, 2055 radeon_apply_surface_regs(s->surface_index,
2053 dev_priv); 2056 dev_priv);
2054 return 0; 2057 return 0;
@@ -2058,13 +2061,13 @@ static int free_surface(DRMFILE filp, drm_radeon_private_t * dev_priv,
2058 return 1; 2061 return 1;
2059} 2062}
2060 2063
2061static void radeon_surfaces_release(DRMFILE filp, 2064static void radeon_surfaces_release(struct drm_file *file_priv,
2062 drm_radeon_private_t * dev_priv) 2065 drm_radeon_private_t * dev_priv)
2063{ 2066{
2064 int i; 2067 int i;
2065 for (i = 0; i < 2 * RADEON_MAX_SURFACES; i++) { 2068 for (i = 0; i < 2 * RADEON_MAX_SURFACES; i++) {
2066 if (dev_priv->virt_surfaces[i].filp == filp) 2069 if (dev_priv->virt_surfaces[i].file_priv == file_priv)
2067 free_surface(filp, dev_priv, 2070 free_surface(file_priv, dev_priv,
2068 dev_priv->virt_surfaces[i].lower); 2071 dev_priv->virt_surfaces[i].lower);
2069 } 2072 }
2070} 2073}
@@ -2082,7 +2085,7 @@ static int radeon_surface_alloc(DRM_IOCTL_ARGS)
2082 (drm_radeon_surface_alloc_t __user *) data, 2085 (drm_radeon_surface_alloc_t __user *) data,
2083 sizeof(alloc)); 2086 sizeof(alloc));
2084 2087
2085 if (alloc_surface(&alloc, dev_priv, filp) == -1) 2088 if (alloc_surface(&alloc, dev_priv, file_priv) == -1)
2086 return -EINVAL; 2089 return -EINVAL;
2087 else 2090 else
2088 return 0; 2091 return 0;
@@ -2097,7 +2100,7 @@ static int radeon_surface_free(DRM_IOCTL_ARGS)
2097 DRM_COPY_FROM_USER_IOCTL(memfree, (drm_radeon_surface_free_t __user *) data, 2100 DRM_COPY_FROM_USER_IOCTL(memfree, (drm_radeon_surface_free_t __user *) data,
2098 sizeof(memfree)); 2101 sizeof(memfree));
2099 2102
2100 if (free_surface(filp, dev_priv, memfree.address)) 2103 if (free_surface(file_priv, dev_priv, memfree.address))
2101 return -EINVAL; 2104 return -EINVAL;
2102 else 2105 else
2103 return 0; 2106 return 0;
@@ -2112,7 +2115,7 @@ static int radeon_cp_clear(DRM_IOCTL_ARGS)
2112 drm_radeon_clear_rect_t depth_boxes[RADEON_NR_SAREA_CLIPRECTS]; 2115 drm_radeon_clear_rect_t depth_boxes[RADEON_NR_SAREA_CLIPRECTS];
2113 DRM_DEBUG("\n"); 2116 DRM_DEBUG("\n");
2114 2117
2115 LOCK_TEST_WITH_RETURN(dev, filp); 2118 LOCK_TEST_WITH_RETURN(dev, file_priv);
2116 2119
2117 DRM_COPY_FROM_USER_IOCTL(clear, (drm_radeon_clear_t __user *) data, 2120 DRM_COPY_FROM_USER_IOCTL(clear, (drm_radeon_clear_t __user *) data,
2118 sizeof(clear)); 2121 sizeof(clear));
@@ -2168,7 +2171,7 @@ static int radeon_cp_flip(DRM_IOCTL_ARGS)
2168 drm_radeon_private_t *dev_priv = dev->dev_private; 2171 drm_radeon_private_t *dev_priv = dev->dev_private;
2169 DRM_DEBUG("\n"); 2172 DRM_DEBUG("\n");
2170 2173
2171 LOCK_TEST_WITH_RETURN(dev, filp); 2174 LOCK_TEST_WITH_RETURN(dev, file_priv);
2172 2175
2173 RING_SPACE_TEST_WITH_RETURN(dev_priv); 2176 RING_SPACE_TEST_WITH_RETURN(dev_priv);
2174 2177
@@ -2188,7 +2191,7 @@ static int radeon_cp_swap(DRM_IOCTL_ARGS)
2188 drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; 2191 drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
2189 DRM_DEBUG("\n"); 2192 DRM_DEBUG("\n");
2190 2193
2191 LOCK_TEST_WITH_RETURN(dev, filp); 2194 LOCK_TEST_WITH_RETURN(dev, file_priv);
2192 2195
2193 RING_SPACE_TEST_WITH_RETURN(dev_priv); 2196 RING_SPACE_TEST_WITH_RETURN(dev_priv);
2194 2197
@@ -2206,16 +2209,13 @@ static int radeon_cp_vertex(DRM_IOCTL_ARGS)
2206{ 2209{
2207 DRM_DEVICE; 2210 DRM_DEVICE;
2208 drm_radeon_private_t *dev_priv = dev->dev_private; 2211 drm_radeon_private_t *dev_priv = dev->dev_private;
2209 struct drm_file *filp_priv;
2210 drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; 2212 drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
2211 struct drm_device_dma *dma = dev->dma; 2213 struct drm_device_dma *dma = dev->dma;
2212 struct drm_buf *buf; 2214 struct drm_buf *buf;
2213 drm_radeon_vertex_t vertex; 2215 drm_radeon_vertex_t vertex;
2214 drm_radeon_tcl_prim_t prim; 2216 drm_radeon_tcl_prim_t prim;
2215 2217
2216 LOCK_TEST_WITH_RETURN(dev, filp); 2218 LOCK_TEST_WITH_RETURN(dev, file_priv);
2217
2218 DRM_GET_PRIV_WITH_RETURN(filp_priv, filp);
2219 2219
2220 DRM_COPY_FROM_USER_IOCTL(vertex, (drm_radeon_vertex_t __user *) data, 2220 DRM_COPY_FROM_USER_IOCTL(vertex, (drm_radeon_vertex_t __user *) data,
2221 sizeof(vertex)); 2221 sizeof(vertex));
@@ -2238,9 +2238,9 @@ static int radeon_cp_vertex(DRM_IOCTL_ARGS)
2238 2238
2239 buf = dma->buflist[vertex.idx]; 2239 buf = dma->buflist[vertex.idx];
2240 2240
2241 if (buf->filp != filp) { 2241 if (buf->file_priv != file_priv) {
2242 DRM_ERROR("process %d using buffer owned by %p\n", 2242 DRM_ERROR("process %d using buffer owned by %p\n",
2243 DRM_CURRENTPID, buf->filp); 2243 DRM_CURRENTPID, buf->file_priv);
2244 return -EINVAL; 2244 return -EINVAL;
2245 } 2245 }
2246 if (buf->pending) { 2246 if (buf->pending) {
@@ -2254,7 +2254,7 @@ static int radeon_cp_vertex(DRM_IOCTL_ARGS)
2254 buf->used = vertex.count; /* not used? */ 2254 buf->used = vertex.count; /* not used? */
2255 2255
2256 if (sarea_priv->dirty & ~RADEON_UPLOAD_CLIPRECTS) { 2256 if (sarea_priv->dirty & ~RADEON_UPLOAD_CLIPRECTS) {
2257 if (radeon_emit_state(dev_priv, filp_priv, 2257 if (radeon_emit_state(dev_priv, file_priv,
2258 &sarea_priv->context_state, 2258 &sarea_priv->context_state,
2259 sarea_priv->tex_state, 2259 sarea_priv->tex_state,
2260 sarea_priv->dirty)) { 2260 sarea_priv->dirty)) {
@@ -2289,7 +2289,6 @@ static int radeon_cp_indices(DRM_IOCTL_ARGS)
2289{ 2289{
2290 DRM_DEVICE; 2290 DRM_DEVICE;
2291 drm_radeon_private_t *dev_priv = dev->dev_private; 2291 drm_radeon_private_t *dev_priv = dev->dev_private;
2292 struct drm_file *filp_priv;
2293 drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; 2292 drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
2294 struct drm_device_dma *dma = dev->dma; 2293 struct drm_device_dma *dma = dev->dma;
2295 struct drm_buf *buf; 2294 struct drm_buf *buf;
@@ -2297,9 +2296,7 @@ static int radeon_cp_indices(DRM_IOCTL_ARGS)
2297 drm_radeon_tcl_prim_t prim; 2296 drm_radeon_tcl_prim_t prim;
2298 int count; 2297 int count;
2299 2298
2300 LOCK_TEST_WITH_RETURN(dev, filp); 2299 LOCK_TEST_WITH_RETURN(dev, file_priv);
2301
2302 DRM_GET_PRIV_WITH_RETURN(filp_priv, filp);
2303 2300
2304 DRM_COPY_FROM_USER_IOCTL(elts, (drm_radeon_indices_t __user *) data, 2301 DRM_COPY_FROM_USER_IOCTL(elts, (drm_radeon_indices_t __user *) data,
2305 sizeof(elts)); 2302 sizeof(elts));
@@ -2322,9 +2319,9 @@ static int radeon_cp_indices(DRM_IOCTL_ARGS)
2322 2319
2323 buf = dma->buflist[elts.idx]; 2320 buf = dma->buflist[elts.idx];
2324 2321
2325 if (buf->filp != filp) { 2322 if (buf->file_priv != file_priv) {
2326 DRM_ERROR("process %d using buffer owned by %p\n", 2323 DRM_ERROR("process %d using buffer owned by %p\n",
2327 DRM_CURRENTPID, buf->filp); 2324 DRM_CURRENTPID, buf->file_priv);
2328 return -EINVAL; 2325 return -EINVAL;
2329 } 2326 }
2330 if (buf->pending) { 2327 if (buf->pending) {
@@ -2347,7 +2344,7 @@ static int radeon_cp_indices(DRM_IOCTL_ARGS)
2347 buf->used = elts.end; 2344 buf->used = elts.end;
2348 2345
2349 if (sarea_priv->dirty & ~RADEON_UPLOAD_CLIPRECTS) { 2346 if (sarea_priv->dirty & ~RADEON_UPLOAD_CLIPRECTS) {
2350 if (radeon_emit_state(dev_priv, filp_priv, 2347 if (radeon_emit_state(dev_priv, file_priv,
2351 &sarea_priv->context_state, 2348 &sarea_priv->context_state,
2352 sarea_priv->tex_state, 2349 sarea_priv->tex_state,
2353 sarea_priv->dirty)) { 2350 sarea_priv->dirty)) {
@@ -2387,7 +2384,7 @@ static int radeon_cp_texture(DRM_IOCTL_ARGS)
2387 drm_radeon_tex_image_t image; 2384 drm_radeon_tex_image_t image;
2388 int ret; 2385 int ret;
2389 2386
2390 LOCK_TEST_WITH_RETURN(dev, filp); 2387 LOCK_TEST_WITH_RETURN(dev, file_priv);
2391 2388
2392 DRM_COPY_FROM_USER_IOCTL(tex, (drm_radeon_texture_t __user *) data, 2389 DRM_COPY_FROM_USER_IOCTL(tex, (drm_radeon_texture_t __user *) data,
2393 sizeof(tex)); 2390 sizeof(tex));
@@ -2405,7 +2402,7 @@ static int radeon_cp_texture(DRM_IOCTL_ARGS)
2405 RING_SPACE_TEST_WITH_RETURN(dev_priv); 2402 RING_SPACE_TEST_WITH_RETURN(dev_priv);
2406 VB_AGE_TEST_WITH_RETURN(dev_priv); 2403 VB_AGE_TEST_WITH_RETURN(dev_priv);
2407 2404
2408 ret = radeon_cp_dispatch_texture(filp, dev, &tex, &image); 2405 ret = radeon_cp_dispatch_texture(dev, file_priv, &tex, &image);
2409 2406
2410 COMMIT_RING(); 2407 COMMIT_RING();
2411 return ret; 2408 return ret;
@@ -2418,7 +2415,7 @@ static int radeon_cp_stipple(DRM_IOCTL_ARGS)
2418 drm_radeon_stipple_t stipple; 2415 drm_radeon_stipple_t stipple;
2419 u32 mask[32]; 2416 u32 mask[32];
2420 2417
2421 LOCK_TEST_WITH_RETURN(dev, filp); 2418 LOCK_TEST_WITH_RETURN(dev, file_priv);
2422 2419
2423 DRM_COPY_FROM_USER_IOCTL(stipple, (drm_radeon_stipple_t __user *) data, 2420 DRM_COPY_FROM_USER_IOCTL(stipple, (drm_radeon_stipple_t __user *) data,
2424 sizeof(stipple)); 2421 sizeof(stipple));
@@ -2443,7 +2440,7 @@ static int radeon_cp_indirect(DRM_IOCTL_ARGS)
2443 drm_radeon_indirect_t indirect; 2440 drm_radeon_indirect_t indirect;
2444 RING_LOCALS; 2441 RING_LOCALS;
2445 2442
2446 LOCK_TEST_WITH_RETURN(dev, filp); 2443 LOCK_TEST_WITH_RETURN(dev, file_priv);
2447 2444
2448 DRM_COPY_FROM_USER_IOCTL(indirect, 2445 DRM_COPY_FROM_USER_IOCTL(indirect,
2449 (drm_radeon_indirect_t __user *) data, 2446 (drm_radeon_indirect_t __user *) data,
@@ -2460,9 +2457,9 @@ static int radeon_cp_indirect(DRM_IOCTL_ARGS)
2460 2457
2461 buf = dma->buflist[indirect.idx]; 2458 buf = dma->buflist[indirect.idx];
2462 2459
2463 if (buf->filp != filp) { 2460 if (buf->file_priv != file_priv) {
2464 DRM_ERROR("process %d using buffer owned by %p\n", 2461 DRM_ERROR("process %d using buffer owned by %p\n",
2465 DRM_CURRENTPID, buf->filp); 2462 DRM_CURRENTPID, buf->file_priv);
2466 return -EINVAL; 2463 return -EINVAL;
2467 } 2464 }
2468 if (buf->pending) { 2465 if (buf->pending) {
@@ -2507,7 +2504,6 @@ static int radeon_cp_vertex2(DRM_IOCTL_ARGS)
2507{ 2504{
2508 DRM_DEVICE; 2505 DRM_DEVICE;
2509 drm_radeon_private_t *dev_priv = dev->dev_private; 2506 drm_radeon_private_t *dev_priv = dev->dev_private;
2510 struct drm_file *filp_priv;
2511 drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; 2507 drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
2512 struct drm_device_dma *dma = dev->dma; 2508 struct drm_device_dma *dma = dev->dma;
2513 struct drm_buf *buf; 2509 struct drm_buf *buf;
@@ -2515,9 +2511,7 @@ static int radeon_cp_vertex2(DRM_IOCTL_ARGS)
2515 int i; 2511 int i;
2516 unsigned char laststate; 2512 unsigned char laststate;
2517 2513
2518 LOCK_TEST_WITH_RETURN(dev, filp); 2514 LOCK_TEST_WITH_RETURN(dev, file_priv);
2519
2520 DRM_GET_PRIV_WITH_RETURN(filp_priv, filp);
2521 2515
2522 DRM_COPY_FROM_USER_IOCTL(vertex, (drm_radeon_vertex2_t __user *) data, 2516 DRM_COPY_FROM_USER_IOCTL(vertex, (drm_radeon_vertex2_t __user *) data,
2523 sizeof(vertex)); 2517 sizeof(vertex));
@@ -2536,9 +2530,9 @@ static int radeon_cp_vertex2(DRM_IOCTL_ARGS)
2536 2530
2537 buf = dma->buflist[vertex.idx]; 2531 buf = dma->buflist[vertex.idx];
2538 2532
2539 if (buf->filp != filp) { 2533 if (buf->file_priv != file_priv) {
2540 DRM_ERROR("process %d using buffer owned by %p\n", 2534 DRM_ERROR("process %d using buffer owned by %p\n",
2541 DRM_CURRENTPID, buf->filp); 2535 DRM_CURRENTPID, buf->file_priv);
2542 return -EINVAL; 2536 return -EINVAL;
2543 } 2537 }
2544 2538
@@ -2565,7 +2559,7 @@ static int radeon_cp_vertex2(DRM_IOCTL_ARGS)
2565 sizeof(state))) 2559 sizeof(state)))
2566 return -EFAULT; 2560 return -EFAULT;
2567 2561
2568 if (radeon_emit_state2(dev_priv, filp_priv, &state)) { 2562 if (radeon_emit_state2(dev_priv, file_priv, &state)) {
2569 DRM_ERROR("radeon_emit_state2 failed\n"); 2563 DRM_ERROR("radeon_emit_state2 failed\n");
2570 return -EINVAL; 2564 return -EINVAL;
2571 } 2565 }
@@ -2603,7 +2597,7 @@ static int radeon_cp_vertex2(DRM_IOCTL_ARGS)
2603} 2597}
2604 2598
2605static int radeon_emit_packets(drm_radeon_private_t * dev_priv, 2599static int radeon_emit_packets(drm_radeon_private_t * dev_priv,
2606 struct drm_file * filp_priv, 2600 struct drm_file *file_priv,
2607 drm_radeon_cmd_header_t header, 2601 drm_radeon_cmd_header_t header,
2608 drm_radeon_kcmd_buffer_t *cmdbuf) 2602 drm_radeon_kcmd_buffer_t *cmdbuf)
2609{ 2603{
@@ -2623,7 +2617,7 @@ static int radeon_emit_packets(drm_radeon_private_t * dev_priv,
2623 return -EINVAL; 2617 return -EINVAL;
2624 } 2618 }
2625 2619
2626 if (radeon_check_and_fixup_packets(dev_priv, filp_priv, id, data)) { 2620 if (radeon_check_and_fixup_packets(dev_priv, file_priv, id, data)) {
2627 DRM_ERROR("Packet verification failed\n"); 2621 DRM_ERROR("Packet verification failed\n");
2628 return -EINVAL; 2622 return -EINVAL;
2629 } 2623 }
@@ -2729,7 +2723,7 @@ static __inline__ int radeon_emit_veclinear(drm_radeon_private_t *dev_priv,
2729} 2723}
2730 2724
2731static int radeon_emit_packet3(struct drm_device * dev, 2725static int radeon_emit_packet3(struct drm_device * dev,
2732 struct drm_file * filp_priv, 2726 struct drm_file *file_priv,
2733 drm_radeon_kcmd_buffer_t *cmdbuf) 2727 drm_radeon_kcmd_buffer_t *cmdbuf)
2734{ 2728{
2735 drm_radeon_private_t *dev_priv = dev->dev_private; 2729 drm_radeon_private_t *dev_priv = dev->dev_private;
@@ -2739,7 +2733,7 @@ static int radeon_emit_packet3(struct drm_device * dev,
2739 2733
2740 DRM_DEBUG("\n"); 2734 DRM_DEBUG("\n");
2741 2735
2742 if ((ret = radeon_check_and_fixup_packet3(dev_priv, filp_priv, 2736 if ((ret = radeon_check_and_fixup_packet3(dev_priv, file_priv,
2743 cmdbuf, &cmdsz))) { 2737 cmdbuf, &cmdsz))) {
2744 DRM_ERROR("Packet verification failed\n"); 2738 DRM_ERROR("Packet verification failed\n");
2745 return ret; 2739 return ret;
@@ -2755,7 +2749,7 @@ static int radeon_emit_packet3(struct drm_device * dev,
2755} 2749}
2756 2750
2757static int radeon_emit_packet3_cliprect(struct drm_device *dev, 2751static int radeon_emit_packet3_cliprect(struct drm_device *dev,
2758 struct drm_file *filp_priv, 2752 struct drm_file *file_priv,
2759 drm_radeon_kcmd_buffer_t *cmdbuf, 2753 drm_radeon_kcmd_buffer_t *cmdbuf,
2760 int orig_nbox) 2754 int orig_nbox)
2761{ 2755{
@@ -2769,7 +2763,7 @@ static int radeon_emit_packet3_cliprect(struct drm_device *dev,
2769 2763
2770 DRM_DEBUG("\n"); 2764 DRM_DEBUG("\n");
2771 2765
2772 if ((ret = radeon_check_and_fixup_packet3(dev_priv, filp_priv, 2766 if ((ret = radeon_check_and_fixup_packet3(dev_priv, file_priv,
2773 cmdbuf, &cmdsz))) { 2767 cmdbuf, &cmdsz))) {
2774 DRM_ERROR("Packet verification failed\n"); 2768 DRM_ERROR("Packet verification failed\n");
2775 return ret; 2769 return ret;
@@ -2849,7 +2843,6 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS)
2849{ 2843{
2850 DRM_DEVICE; 2844 DRM_DEVICE;
2851 drm_radeon_private_t *dev_priv = dev->dev_private; 2845 drm_radeon_private_t *dev_priv = dev->dev_private;
2852 struct drm_file *filp_priv;
2853 struct drm_device_dma *dma = dev->dma; 2846 struct drm_device_dma *dma = dev->dma;
2854 struct drm_buf *buf = NULL; 2847 struct drm_buf *buf = NULL;
2855 int idx; 2848 int idx;
@@ -2858,9 +2851,7 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS)
2858 int orig_nbox, orig_bufsz; 2851 int orig_nbox, orig_bufsz;
2859 char *kbuf = NULL; 2852 char *kbuf = NULL;
2860 2853
2861 LOCK_TEST_WITH_RETURN(dev, filp); 2854 LOCK_TEST_WITH_RETURN(dev, file_priv);
2862
2863 DRM_GET_PRIV_WITH_RETURN(filp_priv, filp);
2864 2855
2865 DRM_COPY_FROM_USER_IOCTL(cmdbuf, 2856 DRM_COPY_FROM_USER_IOCTL(cmdbuf,
2866 (drm_radeon_cmd_buffer_t __user *) data, 2857 (drm_radeon_cmd_buffer_t __user *) data,
@@ -2894,7 +2885,7 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS)
2894 2885
2895 if (dev_priv->microcode_version == UCODE_R300) { 2886 if (dev_priv->microcode_version == UCODE_R300) {
2896 int temp; 2887 int temp;
2897 temp = r300_do_cp_cmdbuf(dev, filp, filp_priv, &cmdbuf); 2888 temp = r300_do_cp_cmdbuf(dev, file_priv, &cmdbuf);
2898 2889
2899 if (orig_bufsz != 0) 2890 if (orig_bufsz != 0)
2900 drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER); 2891 drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER);
@@ -2913,7 +2904,7 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS)
2913 case RADEON_CMD_PACKET: 2904 case RADEON_CMD_PACKET:
2914 DRM_DEBUG("RADEON_CMD_PACKET\n"); 2905 DRM_DEBUG("RADEON_CMD_PACKET\n");
2915 if (radeon_emit_packets 2906 if (radeon_emit_packets
2916 (dev_priv, filp_priv, header, &cmdbuf)) { 2907 (dev_priv, file_priv, header, &cmdbuf)) {
2917 DRM_ERROR("radeon_emit_packets failed\n"); 2908 DRM_ERROR("radeon_emit_packets failed\n");
2918 goto err; 2909 goto err;
2919 } 2910 }
@@ -2945,9 +2936,10 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS)
2945 } 2936 }
2946 2937
2947 buf = dma->buflist[idx]; 2938 buf = dma->buflist[idx];
2948 if (buf->filp != filp || buf->pending) { 2939 if (buf->file_priv != file_priv || buf->pending) {
2949 DRM_ERROR("bad buffer %p %p %d\n", 2940 DRM_ERROR("bad buffer %p %p %d\n",
2950 buf->filp, filp, buf->pending); 2941 buf->file_priv, file_priv,
2942 buf->pending);
2951 goto err; 2943 goto err;
2952 } 2944 }
2953 2945
@@ -2956,7 +2948,7 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS)
2956 2948
2957 case RADEON_CMD_PACKET3: 2949 case RADEON_CMD_PACKET3:
2958 DRM_DEBUG("RADEON_CMD_PACKET3\n"); 2950 DRM_DEBUG("RADEON_CMD_PACKET3\n");
2959 if (radeon_emit_packet3(dev, filp_priv, &cmdbuf)) { 2951 if (radeon_emit_packet3(dev, file_priv, &cmdbuf)) {
2960 DRM_ERROR("radeon_emit_packet3 failed\n"); 2952 DRM_ERROR("radeon_emit_packet3 failed\n");
2961 goto err; 2953 goto err;
2962 } 2954 }
@@ -2965,7 +2957,7 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS)
2965 case RADEON_CMD_PACKET3_CLIP: 2957 case RADEON_CMD_PACKET3_CLIP:
2966 DRM_DEBUG("RADEON_CMD_PACKET3_CLIP\n"); 2958 DRM_DEBUG("RADEON_CMD_PACKET3_CLIP\n");
2967 if (radeon_emit_packet3_cliprect 2959 if (radeon_emit_packet3_cliprect
2968 (dev, filp_priv, &cmdbuf, orig_nbox)) { 2960 (dev, file_priv, &cmdbuf, orig_nbox)) {
2969 DRM_ERROR("radeon_emit_packet3_clip failed\n"); 2961 DRM_ERROR("radeon_emit_packet3_clip failed\n");
2970 goto err; 2962 goto err;
2971 } 2963 }
@@ -3105,18 +3097,15 @@ static int radeon_cp_setparam(DRM_IOCTL_ARGS)
3105{ 3097{
3106 DRM_DEVICE; 3098 DRM_DEVICE;
3107 drm_radeon_private_t *dev_priv = dev->dev_private; 3099 drm_radeon_private_t *dev_priv = dev->dev_private;
3108 struct drm_file *filp_priv;
3109 drm_radeon_setparam_t sp; 3100 drm_radeon_setparam_t sp;
3110 struct drm_radeon_driver_file_fields *radeon_priv; 3101 struct drm_radeon_driver_file_fields *radeon_priv;
3111 3102
3112 DRM_GET_PRIV_WITH_RETURN(filp_priv, filp);
3113
3114 DRM_COPY_FROM_USER_IOCTL(sp, (drm_radeon_setparam_t __user *) data, 3103 DRM_COPY_FROM_USER_IOCTL(sp, (drm_radeon_setparam_t __user *) data,
3115 sizeof(sp)); 3104 sizeof(sp));
3116 3105
3117 switch (sp.param) { 3106 switch (sp.param) {
3118 case RADEON_SETPARAM_FB_LOCATION: 3107 case RADEON_SETPARAM_FB_LOCATION:
3119 radeon_priv = filp_priv->driver_priv; 3108 radeon_priv = file_priv->driver_priv;
3120 radeon_priv->radeon_fb_delta = dev_priv->fb_location - sp.value; 3109 radeon_priv->radeon_fb_delta = dev_priv->fb_location - sp.value;
3121 break; 3110 break;
3122 case RADEON_SETPARAM_SWITCH_TILING: 3111 case RADEON_SETPARAM_SWITCH_TILING:
@@ -3162,14 +3151,14 @@ static int radeon_cp_setparam(DRM_IOCTL_ARGS)
3162 * 3151 *
3163 * DRM infrastructure takes care of reclaiming dma buffers. 3152 * DRM infrastructure takes care of reclaiming dma buffers.
3164 */ 3153 */
3165void radeon_driver_preclose(struct drm_device *dev, DRMFILE filp) 3154void radeon_driver_preclose(struct drm_device *dev, struct drm_file *file_priv)
3166{ 3155{
3167 if (dev->dev_private) { 3156 if (dev->dev_private) {
3168 drm_radeon_private_t *dev_priv = dev->dev_private; 3157 drm_radeon_private_t *dev_priv = dev->dev_private;
3169 dev_priv->page_flipping = 0; 3158 dev_priv->page_flipping = 0;
3170 radeon_mem_release(filp, dev_priv->gart_heap); 3159 radeon_mem_release(file_priv, dev_priv->gart_heap);
3171 radeon_mem_release(filp, dev_priv->fb_heap); 3160 radeon_mem_release(file_priv, dev_priv->fb_heap);
3172 radeon_surfaces_release(filp, dev_priv); 3161 radeon_surfaces_release(file_priv, dev_priv);
3173 } 3162 }
3174} 3163}
3175 3164
@@ -3186,7 +3175,7 @@ void radeon_driver_lastclose(struct drm_device *dev)
3186 radeon_do_release(dev); 3175 radeon_do_release(dev);
3187} 3176}
3188 3177
3189int radeon_driver_open(struct drm_device *dev, struct drm_file *filp_priv) 3178int radeon_driver_open(struct drm_device *dev, struct drm_file *file_priv)
3190{ 3179{
3191 drm_radeon_private_t *dev_priv = dev->dev_private; 3180 drm_radeon_private_t *dev_priv = dev->dev_private;
3192 struct drm_radeon_driver_file_fields *radeon_priv; 3181 struct drm_radeon_driver_file_fields *radeon_priv;
@@ -3199,7 +3188,7 @@ int radeon_driver_open(struct drm_device *dev, struct drm_file *filp_priv)
3199 if (!radeon_priv) 3188 if (!radeon_priv)
3200 return -ENOMEM; 3189 return -ENOMEM;
3201 3190
3202 filp_priv->driver_priv = radeon_priv; 3191 file_priv->driver_priv = radeon_priv;
3203 3192
3204 if (dev_priv) 3193 if (dev_priv)
3205 radeon_priv->radeon_fb_delta = dev_priv->fb_location; 3194 radeon_priv->radeon_fb_delta = dev_priv->fb_location;
@@ -3208,10 +3197,10 @@ int radeon_driver_open(struct drm_device *dev, struct drm_file *filp_priv)
3208 return 0; 3197 return 0;
3209} 3198}
3210 3199
3211void radeon_driver_postclose(struct drm_device *dev, struct drm_file *filp_priv) 3200void radeon_driver_postclose(struct drm_device *dev, struct drm_file *file_priv)
3212{ 3201{
3213 struct drm_radeon_driver_file_fields *radeon_priv = 3202 struct drm_radeon_driver_file_fields *radeon_priv =
3214 filp_priv->driver_priv; 3203 file_priv->driver_priv;
3215 3204
3216 drm_free(radeon_priv, sizeof(*radeon_priv), DRM_MEM_FILES); 3205 drm_free(radeon_priv, sizeof(*radeon_priv), DRM_MEM_FILES);
3217} 3206}
diff --git a/drivers/char/drm/savage_bci.c b/drivers/char/drm/savage_bci.c
index e1e88ca1c53c..18a3bc387817 100644
--- a/drivers/char/drm/savage_bci.c
+++ b/drivers/char/drm/savage_bci.c
@@ -933,7 +933,7 @@ static int savage_bci_init(DRM_IOCTL_ARGS)
933 DRM_DEVICE; 933 DRM_DEVICE;
934 drm_savage_init_t init; 934 drm_savage_init_t init;
935 935
936 LOCK_TEST_WITH_RETURN(dev, filp); 936 LOCK_TEST_WITH_RETURN(dev, file_priv);
937 937
938 DRM_COPY_FROM_USER_IOCTL(init, (drm_savage_init_t __user *) data, 938 DRM_COPY_FROM_USER_IOCTL(init, (drm_savage_init_t __user *) data,
939 sizeof(init)); 939 sizeof(init));
@@ -956,7 +956,7 @@ static int savage_bci_event_emit(DRM_IOCTL_ARGS)
956 956
957 DRM_DEBUG("\n"); 957 DRM_DEBUG("\n");
958 958
959 LOCK_TEST_WITH_RETURN(dev, filp); 959 LOCK_TEST_WITH_RETURN(dev, file_priv);
960 960
961 DRM_COPY_FROM_USER_IOCTL(event, (drm_savage_event_emit_t __user *) data, 961 DRM_COPY_FROM_USER_IOCTL(event, (drm_savage_event_emit_t __user *) data,
962 sizeof(event)); 962 sizeof(event));
@@ -1007,7 +1007,9 @@ static int savage_bci_event_wait(DRM_IOCTL_ARGS)
1007 * DMA buffer management 1007 * DMA buffer management
1008 */ 1008 */
1009 1009
1010static int savage_bci_get_buffers(DRMFILE filp, struct drm_device *dev, struct drm_dma *d) 1010static int savage_bci_get_buffers(struct drm_device *dev,
1011 struct drm_file *file_priv,
1012 struct drm_dma *d)
1011{ 1013{
1012 struct drm_buf *buf; 1014 struct drm_buf *buf;
1013 int i; 1015 int i;
@@ -1017,7 +1019,7 @@ static int savage_bci_get_buffers(DRMFILE filp, struct drm_device *dev, struct d
1017 if (!buf) 1019 if (!buf)
1018 return -EAGAIN; 1020 return -EAGAIN;
1019 1021
1020 buf->filp = filp; 1022 buf->file_priv = file_priv;
1021 1023
1022 if (DRM_COPY_TO_USER(&d->request_indices[i], 1024 if (DRM_COPY_TO_USER(&d->request_indices[i],
1023 &buf->idx, sizeof(buf->idx))) 1025 &buf->idx, sizeof(buf->idx)))
@@ -1038,7 +1040,7 @@ int savage_bci_buffers(DRM_IOCTL_ARGS)
1038 struct drm_dma d; 1040 struct drm_dma d;
1039 int ret = 0; 1041 int ret = 0;
1040 1042
1041 LOCK_TEST_WITH_RETURN(dev, filp); 1043 LOCK_TEST_WITH_RETURN(dev, file_priv);
1042 1044
1043 DRM_COPY_FROM_USER_IOCTL(d, (struct drm_dma __user *) data, sizeof(d)); 1045 DRM_COPY_FROM_USER_IOCTL(d, (struct drm_dma __user *) data, sizeof(d));
1044 1046
@@ -1061,7 +1063,7 @@ int savage_bci_buffers(DRM_IOCTL_ARGS)
1061 d.granted_count = 0; 1063 d.granted_count = 0;
1062 1064
1063 if (d.request_count) { 1065 if (d.request_count) {
1064 ret = savage_bci_get_buffers(filp, dev, &d); 1066 ret = savage_bci_get_buffers(dev, file_priv, &d);
1065 } 1067 }
1066 1068
1067 DRM_COPY_TO_USER_IOCTL((struct drm_dma __user *) data, d, sizeof(d)); 1069 DRM_COPY_TO_USER_IOCTL((struct drm_dma __user *) data, d, sizeof(d));
@@ -1069,7 +1071,7 @@ int savage_bci_buffers(DRM_IOCTL_ARGS)
1069 return ret; 1071 return ret;
1070} 1072}
1071 1073
1072void savage_reclaim_buffers(struct drm_device *dev, DRMFILE filp) 1074void savage_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv)
1073{ 1075{
1074 struct drm_device_dma *dma = dev->dma; 1076 struct drm_device_dma *dma = dev->dma;
1075 drm_savage_private_t *dev_priv = dev->dev_private; 1077 drm_savage_private_t *dev_priv = dev->dev_private;
@@ -1088,7 +1090,7 @@ void savage_reclaim_buffers(struct drm_device *dev, DRMFILE filp)
1088 struct drm_buf *buf = dma->buflist[i]; 1090 struct drm_buf *buf = dma->buflist[i];
1089 drm_savage_buf_priv_t *buf_priv = buf->dev_private; 1091 drm_savage_buf_priv_t *buf_priv = buf->dev_private;
1090 1092
1091 if (buf->filp == filp && buf_priv && 1093 if (buf->file_priv == file_priv && buf_priv &&
1092 buf_priv->next == NULL && buf_priv->prev == NULL) { 1094 buf_priv->next == NULL && buf_priv->prev == NULL) {
1093 uint16_t event; 1095 uint16_t event;
1094 DRM_DEBUG("reclaimed from client\n"); 1096 DRM_DEBUG("reclaimed from client\n");
@@ -1098,7 +1100,7 @@ void savage_reclaim_buffers(struct drm_device *dev, DRMFILE filp)
1098 } 1100 }
1099 } 1101 }
1100 1102
1101 drm_core_reclaim_buffers(dev, filp); 1103 drm_core_reclaim_buffers(dev, file_priv);
1102} 1104}
1103 1105
1104drm_ioctl_desc_t savage_ioctls[] = { 1106drm_ioctl_desc_t savage_ioctls[] = {
diff --git a/drivers/char/drm/savage_drv.h b/drivers/char/drm/savage_drv.h
index 5fd54de4280e..e4eac035d8fa 100644
--- a/drivers/char/drm/savage_drv.h
+++ b/drivers/char/drm/savage_drv.h
@@ -212,7 +212,8 @@ extern int savage_driver_load(struct drm_device *dev, unsigned long chipset);
212extern int savage_driver_firstopen(struct drm_device *dev); 212extern int savage_driver_firstopen(struct drm_device *dev);
213extern void savage_driver_lastclose(struct drm_device *dev); 213extern void savage_driver_lastclose(struct drm_device *dev);
214extern int savage_driver_unload(struct drm_device *dev); 214extern int savage_driver_unload(struct drm_device *dev);
215extern void savage_reclaim_buffers(struct drm_device * dev, DRMFILE filp); 215extern void savage_reclaim_buffers(struct drm_device *dev,
216 struct drm_file *file_priv);
216 217
217/* state functions */ 218/* state functions */
218extern void savage_emit_clip_rect_s3d(drm_savage_private_t * dev_priv, 219extern void savage_emit_clip_rect_s3d(drm_savage_private_t * dev_priv,
diff --git a/drivers/char/drm/savage_state.c b/drivers/char/drm/savage_state.c
index 00e59bfd658a..9a72d959084c 100644
--- a/drivers/char/drm/savage_state.c
+++ b/drivers/char/drm/savage_state.c
@@ -969,7 +969,7 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS)
969 969
970 DRM_DEBUG("\n"); 970 DRM_DEBUG("\n");
971 971
972 LOCK_TEST_WITH_RETURN(dev, filp); 972 LOCK_TEST_WITH_RETURN(dev, file_priv);
973 973
974 DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_savage_cmdbuf_t __user *) data, 974 DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_savage_cmdbuf_t __user *) data,
975 sizeof(cmdbuf)); 975 sizeof(cmdbuf));
diff --git a/drivers/char/drm/sis_drv.h b/drivers/char/drm/sis_drv.h
index 5630df874353..b19ff015f260 100644
--- a/drivers/char/drm/sis_drv.h
+++ b/drivers/char/drm/sis_drv.h
@@ -63,7 +63,8 @@ typedef struct drm_sis_private {
63} drm_sis_private_t; 63} drm_sis_private_t;
64 64
65extern int sis_idle(struct drm_device *dev); 65extern int sis_idle(struct drm_device *dev);
66extern void sis_reclaim_buffers_locked(struct drm_device *dev, struct file *filp); 66extern void sis_reclaim_buffers_locked(struct drm_device *dev,
67 struct drm_file *file_priv);
67extern void sis_lastclose(struct drm_device *dev); 68extern void sis_lastclose(struct drm_device *dev);
68 69
69extern drm_ioctl_desc_t sis_ioctls[]; 70extern drm_ioctl_desc_t sis_ioctls[];
diff --git a/drivers/char/drm/sis_mm.c b/drivers/char/drm/sis_mm.c
index 244006a107b7..cefbc3086d84 100644
--- a/drivers/char/drm/sis_mm.c
+++ b/drivers/char/drm/sis_mm.c
@@ -123,7 +123,7 @@ static int sis_fb_init(DRM_IOCTL_ARGS)
123 return 0; 123 return 0;
124} 124}
125 125
126static int sis_drm_alloc(struct drm_device *dev, struct drm_file * priv, 126static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file_priv,
127 unsigned long data, int pool) 127 unsigned long data, int pool)
128{ 128{
129 drm_sis_private_t *dev_priv = dev->dev_private; 129 drm_sis_private_t *dev_priv = dev->dev_private;
@@ -145,7 +145,7 @@ static int sis_drm_alloc(struct drm_device *dev, struct drm_file * priv,
145 145
146 mem.size = (mem.size + SIS_MM_ALIGN_MASK) >> SIS_MM_ALIGN_SHIFT; 146 mem.size = (mem.size + SIS_MM_ALIGN_MASK) >> SIS_MM_ALIGN_SHIFT;
147 item = drm_sman_alloc(&dev_priv->sman, pool, mem.size, 0, 147 item = drm_sman_alloc(&dev_priv->sman, pool, mem.size, 0,
148 (unsigned long)priv); 148 (unsigned long)file_priv);
149 149
150 mutex_unlock(&dev->struct_mutex); 150 mutex_unlock(&dev->struct_mutex);
151 if (item) { 151 if (item) {
@@ -191,7 +191,7 @@ static int sis_drm_free(DRM_IOCTL_ARGS)
191static int sis_fb_alloc(DRM_IOCTL_ARGS) 191static int sis_fb_alloc(DRM_IOCTL_ARGS)
192{ 192{
193 DRM_DEVICE; 193 DRM_DEVICE;
194 return sis_drm_alloc(dev, priv, data, VIDEO_TYPE); 194 return sis_drm_alloc(dev, file_priv, data, VIDEO_TYPE);
195} 195}
196 196
197static int sis_ioctl_agp_init(DRM_IOCTL_ARGS) 197static int sis_ioctl_agp_init(DRM_IOCTL_ARGS)
@@ -226,7 +226,7 @@ static int sis_ioctl_agp_alloc(DRM_IOCTL_ARGS)
226{ 226{
227 DRM_DEVICE; 227 DRM_DEVICE;
228 228
229 return sis_drm_alloc(dev, priv, data, AGP_TYPE); 229 return sis_drm_alloc(dev, file_priv, data, AGP_TYPE);
230} 230}
231 231
232static drm_local_map_t *sis_reg_init(struct drm_device *dev) 232static drm_local_map_t *sis_reg_init(struct drm_device *dev)
@@ -314,13 +314,13 @@ void sis_lastclose(struct drm_device *dev)
314 mutex_unlock(&dev->struct_mutex); 314 mutex_unlock(&dev->struct_mutex);
315} 315}
316 316
317void sis_reclaim_buffers_locked(struct drm_device * dev, struct file *filp) 317void sis_reclaim_buffers_locked(struct drm_device * dev,
318 struct drm_file *file_priv)
318{ 319{
319 drm_sis_private_t *dev_priv = dev->dev_private; 320 drm_sis_private_t *dev_priv = dev->dev_private;
320 struct drm_file *priv = filp->private_data;
321 321
322 mutex_lock(&dev->struct_mutex); 322 mutex_lock(&dev->struct_mutex);
323 if (drm_sman_owner_clean(&dev_priv->sman, (unsigned long)priv)) { 323 if (drm_sman_owner_clean(&dev_priv->sman, (unsigned long)file_priv)) {
324 mutex_unlock(&dev->struct_mutex); 324 mutex_unlock(&dev->struct_mutex);
325 return; 325 return;
326 } 326 }
@@ -329,7 +329,7 @@ void sis_reclaim_buffers_locked(struct drm_device * dev, struct file *filp)
329 dev->driver->dma_quiescent(dev); 329 dev->driver->dma_quiescent(dev);
330 } 330 }
331 331
332 drm_sman_owner_cleanup(&dev_priv->sman, (unsigned long)priv); 332 drm_sman_owner_cleanup(&dev_priv->sman, (unsigned long)file_priv);
333 mutex_unlock(&dev->struct_mutex); 333 mutex_unlock(&dev->struct_mutex);
334 return; 334 return;
335} 335}
diff --git a/drivers/char/drm/via_dma.c b/drivers/char/drm/via_dma.c
index 2d0035f83a7b..6d3e4eecf8f8 100644
--- a/drivers/char/drm/via_dma.c
+++ b/drivers/char/drm/via_dma.c
@@ -330,7 +330,7 @@ static int via_flush_ioctl(DRM_IOCTL_ARGS)
330{ 330{
331 DRM_DEVICE; 331 DRM_DEVICE;
332 332
333 LOCK_TEST_WITH_RETURN(dev, filp); 333 LOCK_TEST_WITH_RETURN(dev, file_priv);
334 334
335 return via_driver_dma_quiescent(dev); 335 return via_driver_dma_quiescent(dev);
336} 336}
@@ -341,7 +341,7 @@ static int via_cmdbuffer(DRM_IOCTL_ARGS)
341 drm_via_cmdbuffer_t cmdbuf; 341 drm_via_cmdbuffer_t cmdbuf;
342 int ret; 342 int ret;
343 343
344 LOCK_TEST_WITH_RETURN(dev, filp); 344 LOCK_TEST_WITH_RETURN(dev, file_priv);
345 345
346 DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_via_cmdbuffer_t __user *) data, 346 DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_via_cmdbuffer_t __user *) data,
347 sizeof(cmdbuf)); 347 sizeof(cmdbuf));
@@ -386,7 +386,7 @@ static int via_pci_cmdbuffer(DRM_IOCTL_ARGS)
386 drm_via_cmdbuffer_t cmdbuf; 386 drm_via_cmdbuffer_t cmdbuf;
387 int ret; 387 int ret;
388 388
389 LOCK_TEST_WITH_RETURN(dev, filp); 389 LOCK_TEST_WITH_RETURN(dev, file_priv);
390 390
391 DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_via_cmdbuffer_t __user *) data, 391 DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_via_cmdbuffer_t __user *) data,
392 sizeof(cmdbuf)); 392 sizeof(cmdbuf));
@@ -662,7 +662,7 @@ static int via_cmdbuf_size(DRM_IOCTL_ARGS)
662 drm_via_private_t *dev_priv; 662 drm_via_private_t *dev_priv;
663 663
664 DRM_DEBUG("via cmdbuf_size\n"); 664 DRM_DEBUG("via cmdbuf_size\n");
665 LOCK_TEST_WITH_RETURN(dev, filp); 665 LOCK_TEST_WITH_RETURN(dev, file_priv);
666 666
667 dev_priv = (drm_via_private_t *) dev->dev_private; 667 dev_priv = (drm_via_private_t *) dev->dev_private;
668 668
diff --git a/drivers/char/drm/via_drv.h b/drivers/char/drm/via_drv.h
index 576711564a11..854b393e0256 100644
--- a/drivers/char/drm/via_drv.h
+++ b/drivers/char/drm/via_drv.h
@@ -144,7 +144,7 @@ extern void via_init_futex(drm_via_private_t * dev_priv);
144extern void via_cleanup_futex(drm_via_private_t * dev_priv); 144extern void via_cleanup_futex(drm_via_private_t * dev_priv);
145extern void via_release_futex(drm_via_private_t * dev_priv, int context); 145extern void via_release_futex(drm_via_private_t * dev_priv, int context);
146 146
147extern void via_reclaim_buffers_locked(struct drm_device *dev, struct file *filp); 147extern void via_reclaim_buffers_locked(struct drm_device *dev, struct drm_file *file_priv);
148extern void via_lastclose(struct drm_device *dev); 148extern void via_lastclose(struct drm_device *dev);
149 149
150extern void via_dmablit_handler(struct drm_device *dev, int engine, int from_irq); 150extern void via_dmablit_handler(struct drm_device *dev, int engine, int from_irq);
diff --git a/drivers/char/drm/via_mm.c b/drivers/char/drm/via_mm.c
index 36f2547254f9..fe68cbbe787c 100644
--- a/drivers/char/drm/via_mm.c
+++ b/drivers/char/drm/via_mm.c
@@ -149,7 +149,7 @@ int via_mem_alloc(DRM_IOCTL_ARGS)
149 149
150 tmpSize = (mem.size + VIA_MM_ALIGN_MASK) >> VIA_MM_ALIGN_SHIFT; 150 tmpSize = (mem.size + VIA_MM_ALIGN_MASK) >> VIA_MM_ALIGN_SHIFT;
151 item = drm_sman_alloc(&dev_priv->sman, mem.type, tmpSize, 0, 151 item = drm_sman_alloc(&dev_priv->sman, mem.type, tmpSize, 0,
152 (unsigned long)priv); 152 (unsigned long)file_priv);
153 mutex_unlock(&dev->struct_mutex); 153 mutex_unlock(&dev->struct_mutex);
154 if (item) { 154 if (item) {
155 mem.offset = ((mem.type == VIA_MEM_VIDEO) ? 155 mem.offset = ((mem.type == VIA_MEM_VIDEO) ?
@@ -188,13 +188,13 @@ int via_mem_free(DRM_IOCTL_ARGS)
188} 188}
189 189
190 190
191void via_reclaim_buffers_locked(struct drm_device * dev, struct file *filp) 191void via_reclaim_buffers_locked(struct drm_device * dev,
192 struct drm_file *file_priv)
192{ 193{
193 drm_via_private_t *dev_priv = dev->dev_private; 194 drm_via_private_t *dev_priv = dev->dev_private;
194 struct drm_file *priv = filp->private_data;
195 195
196 mutex_lock(&dev->struct_mutex); 196 mutex_lock(&dev->struct_mutex);
197 if (drm_sman_owner_clean(&dev_priv->sman, (unsigned long)priv)) { 197 if (drm_sman_owner_clean(&dev_priv->sman, (unsigned long)file_priv)) {
198 mutex_unlock(&dev->struct_mutex); 198 mutex_unlock(&dev->struct_mutex);
199 return; 199 return;
200 } 200 }
@@ -203,7 +203,7 @@ void via_reclaim_buffers_locked(struct drm_device * dev, struct file *filp)
203 dev->driver->dma_quiescent(dev); 203 dev->driver->dma_quiescent(dev);
204 } 204 }
205 205
206 drm_sman_owner_cleanup(&dev_priv->sman, (unsigned long)priv); 206 drm_sman_owner_cleanup(&dev_priv->sman, (unsigned long)file_priv);
207 mutex_unlock(&dev->struct_mutex); 207 mutex_unlock(&dev->struct_mutex);
208 return; 208 return;
209} 209}