diff options
author | Eric Anholt <eric@anholt.net> | 2007-09-02 22:06:45 -0400 |
---|---|---|
committer | Dave Airlie <airlied@optimus.(none)> | 2007-10-14 20:38:20 -0400 |
commit | c153f45f9b7e30289157bba3ff5682291df16caa (patch) | |
tree | 33f21e1ebd83ec548751f3d490afe6230ab99972 /drivers | |
parent | b589ee5943a9610ebaea6e4e3433f2ae4d812b0b (diff) |
drm: Replace DRM_IOCTL_ARGS with (dev, data, file_priv) and remove DRM_DEVICE.
The data is now in kernel space, copied in/out as appropriate according to t
This results in DRM_COPY_{TO,FROM}_USER going away, and error paths to deal
with those failures. This also means that XFree86 4.2.0 support for i810 DR
is lost.
Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers')
45 files changed, 1489 insertions, 2146 deletions
diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h index 9c53b8883139..9dd0760dd87a 100644 --- a/drivers/char/drm/drmP.h +++ b/drivers/char/drm/drmP.h | |||
@@ -34,8 +34,6 @@ | |||
34 | #ifndef _DRM_P_H_ | 34 | #ifndef _DRM_P_H_ |
35 | #define _DRM_P_H_ | 35 | #define _DRM_P_H_ |
36 | 36 | ||
37 | struct drm_file; | ||
38 | |||
39 | /* If you want the memory alloc debug functionality, change define below */ | 37 | /* If you want the memory alloc debug functionality, change define below */ |
40 | /* #define DEBUG_MEMORY */ | 38 | /* #define DEBUG_MEMORY */ |
41 | 39 | ||
@@ -82,6 +80,9 @@ struct drm_file; | |||
82 | #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE))) | 80 | #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE))) |
83 | #define __OS_HAS_MTRR (defined(CONFIG_MTRR)) | 81 | #define __OS_HAS_MTRR (defined(CONFIG_MTRR)) |
84 | 82 | ||
83 | struct drm_file; | ||
84 | struct drm_device; | ||
85 | |||
85 | #include "drm_os_linux.h" | 86 | #include "drm_os_linux.h" |
86 | #include "drm_hashtab.h" | 87 | #include "drm_hashtab.h" |
87 | 88 | ||
@@ -233,12 +234,13 @@ struct drm_file; | |||
233 | * \param dev DRM device. | 234 | * \param dev DRM device. |
234 | * \param filp file pointer of the caller. | 235 | * \param filp file pointer of the caller. |
235 | */ | 236 | */ |
236 | #define LOCK_TEST_WITH_RETURN( dev, filp ) \ | 237 | #define LOCK_TEST_WITH_RETURN( dev, file_priv ) \ |
237 | do { \ | 238 | do { \ |
238 | if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \ | 239 | if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \ |
239 | dev->lock.filp != filp ) { \ | 240 | dev->lock.file_priv != file_priv ) { \ |
240 | DRM_ERROR( "%s called without lock held\n", \ | 241 | DRM_ERROR( "%s called without lock held, held %d owner %p %p\n",\ |
241 | __FUNCTION__ ); \ | 242 | __FUNCTION__, _DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ),\ |
243 | dev->lock.file_priv, file_priv ); \ | ||
242 | return -EINVAL; \ | 244 | return -EINVAL; \ |
243 | } \ | 245 | } \ |
244 | } while (0) | 246 | } while (0) |
@@ -263,8 +265,8 @@ do { \ | |||
263 | * \param cmd command. | 265 | * \param cmd command. |
264 | * \param arg argument. | 266 | * \param arg argument. |
265 | */ | 267 | */ |
266 | typedef int drm_ioctl_t(struct inode *inode, struct drm_file *file_priv, | 268 | typedef int drm_ioctl_t(struct drm_device *dev, void *data, |
267 | unsigned int cmd, unsigned long arg); | 269 | struct drm_file *file_priv); |
268 | 270 | ||
269 | typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd, | 271 | typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd, |
270 | unsigned long arg); | 272 | unsigned long arg); |
@@ -273,10 +275,18 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd, | |||
273 | #define DRM_MASTER 0x2 | 275 | #define DRM_MASTER 0x2 |
274 | #define DRM_ROOT_ONLY 0x4 | 276 | #define DRM_ROOT_ONLY 0x4 |
275 | 277 | ||
276 | typedef struct drm_ioctl_desc { | 278 | struct drm_ioctl_desc { |
279 | unsigned int cmd; | ||
277 | drm_ioctl_t *func; | 280 | drm_ioctl_t *func; |
278 | int flags; | 281 | int flags; |
279 | } drm_ioctl_desc_t; | 282 | }; |
283 | |||
284 | /** | ||
285 | * Creates a driver or general drm_ioctl_desc array entry for the given | ||
286 | * ioctl, for use by drm_ioctl(). | ||
287 | */ | ||
288 | #define DRM_IOCTL_DEF(ioctl, func, flags) \ | ||
289 | [DRM_IOCTL_NR(ioctl)] = {ioctl, func, flags} | ||
280 | 290 | ||
281 | struct drm_magic_entry { | 291 | struct drm_magic_entry { |
282 | struct list_head head; | 292 | struct list_head head; |
@@ -559,7 +569,7 @@ struct drm_driver { | |||
559 | void (*postclose) (struct drm_device *, struct drm_file *); | 569 | void (*postclose) (struct drm_device *, struct drm_file *); |
560 | void (*lastclose) (struct drm_device *); | 570 | void (*lastclose) (struct drm_device *); |
561 | int (*unload) (struct drm_device *); | 571 | int (*unload) (struct drm_device *); |
562 | int (*dma_ioctl) (DRM_IOCTL_ARGS); | 572 | int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv); |
563 | void (*dma_ready) (struct drm_device *); | 573 | void (*dma_ready) (struct drm_device *); |
564 | int (*dma_quiescent) (struct drm_device *); | 574 | int (*dma_quiescent) (struct drm_device *); |
565 | int (*context_ctor) (struct drm_device *dev, int context); | 575 | int (*context_ctor) (struct drm_device *dev, int context); |
@@ -610,7 +620,7 @@ struct drm_driver { | |||
610 | 620 | ||
611 | u32 driver_features; | 621 | u32 driver_features; |
612 | int dev_priv_size; | 622 | int dev_priv_size; |
613 | drm_ioctl_desc_t *ioctls; | 623 | struct drm_ioctl_desc *ioctls; |
614 | int num_ioctls; | 624 | int num_ioctls; |
615 | struct file_operations fops; | 625 | struct file_operations fops; |
616 | struct pci_driver pci_driver; | 626 | struct pci_driver pci_driver; |
@@ -854,70 +864,70 @@ extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start); | |||
854 | extern int drm_unbind_agp(DRM_AGP_MEM * handle); | 864 | extern int drm_unbind_agp(DRM_AGP_MEM * handle); |
855 | 865 | ||
856 | /* Misc. IOCTL support (drm_ioctl.h) */ | 866 | /* Misc. IOCTL support (drm_ioctl.h) */ |
857 | extern int drm_irq_by_busid(struct inode *inode, struct drm_file *file_priv, | 867 | extern int drm_irq_by_busid(struct drm_device *dev, void *data, |
858 | unsigned int cmd, unsigned long arg); | 868 | struct drm_file *file_priv); |
859 | extern int drm_getunique(struct inode *inode, struct drm_file *file_priv, | 869 | extern int drm_getunique(struct drm_device *dev, void *data, |
860 | unsigned int cmd, unsigned long arg); | 870 | struct drm_file *file_priv); |
861 | extern int drm_setunique(struct inode *inode, struct drm_file *file_priv, | 871 | extern int drm_setunique(struct drm_device *dev, void *data, |
862 | unsigned int cmd, unsigned long arg); | 872 | struct drm_file *file_priv); |
863 | extern int drm_getmap(struct inode *inode, struct drm_file *file_priv, | 873 | extern int drm_getmap(struct drm_device *dev, void *data, |
864 | unsigned int cmd, unsigned long arg); | 874 | struct drm_file *file_priv); |
865 | extern int drm_getclient(struct inode *inode, struct drm_file *file_priv, | 875 | extern int drm_getclient(struct drm_device *dev, void *data, |
866 | unsigned int cmd, unsigned long arg); | 876 | struct drm_file *file_priv); |
867 | extern int drm_getstats(struct inode *inode, struct drm_file *file_priv, | 877 | extern int drm_getstats(struct drm_device *dev, void *data, |
868 | unsigned int cmd, unsigned long arg); | 878 | struct drm_file *file_priv); |
869 | extern int drm_setversion(struct inode *inode, struct drm_file *file_priv, | 879 | extern int drm_setversion(struct drm_device *dev, void *data, |
870 | unsigned int cmd, unsigned long arg); | 880 | struct drm_file *file_priv); |
871 | extern int drm_noop(struct inode *inode, struct drm_file *file_priv, | 881 | extern int drm_noop(struct drm_device *dev, void *data, |
872 | unsigned int cmd, unsigned long arg); | 882 | struct drm_file *file_priv); |
873 | 883 | ||
874 | /* Context IOCTL support (drm_context.h) */ | 884 | /* Context IOCTL support (drm_context.h) */ |
875 | extern int drm_resctx(struct inode *inode, struct drm_file *file_priv, | 885 | extern int drm_resctx(struct drm_device *dev, void *data, |
876 | unsigned int cmd, unsigned long arg); | 886 | struct drm_file *file_priv); |
877 | extern int drm_addctx(struct inode *inode, struct drm_file *file_priv, | 887 | extern int drm_addctx(struct drm_device *dev, void *data, |
878 | unsigned int cmd, unsigned long arg); | 888 | struct drm_file *file_priv); |
879 | extern int drm_modctx(struct inode *inode, struct drm_file *file_priv, | 889 | extern int drm_modctx(struct drm_device *dev, void *data, |
880 | unsigned int cmd, unsigned long arg); | 890 | struct drm_file *file_priv); |
881 | extern int drm_getctx(struct inode *inode, struct drm_file *file_priv, | 891 | extern int drm_getctx(struct drm_device *dev, void *data, |
882 | unsigned int cmd, unsigned long arg); | 892 | struct drm_file *file_priv); |
883 | extern int drm_switchctx(struct inode *inode, struct drm_file *file_priv, | 893 | extern int drm_switchctx(struct drm_device *dev, void *data, |
884 | unsigned int cmd, unsigned long arg); | 894 | struct drm_file *file_priv); |
885 | extern int drm_newctx(struct inode *inode, struct drm_file *file_priv, | 895 | extern int drm_newctx(struct drm_device *dev, void *data, |
886 | unsigned int cmd, unsigned long arg); | 896 | struct drm_file *file_priv); |
887 | extern int drm_rmctx(struct inode *inode, struct drm_file *file_priv, | 897 | extern int drm_rmctx(struct drm_device *dev, void *data, |
888 | unsigned int cmd, unsigned long arg); | 898 | struct drm_file *file_priv); |
889 | 899 | ||
890 | extern int drm_ctxbitmap_init(struct drm_device *dev); | 900 | extern int drm_ctxbitmap_init(struct drm_device *dev); |
891 | extern void drm_ctxbitmap_cleanup(struct drm_device *dev); | 901 | extern void drm_ctxbitmap_cleanup(struct drm_device *dev); |
892 | extern void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle); | 902 | extern void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle); |
893 | 903 | ||
894 | extern int drm_setsareactx(struct inode *inode, struct drm_file *file_priv, | 904 | extern int drm_setsareactx(struct drm_device *dev, void *data, |
895 | unsigned int cmd, unsigned long arg); | 905 | struct drm_file *file_priv); |
896 | extern int drm_getsareactx(struct inode *inode, struct drm_file *file_priv, | 906 | extern int drm_getsareactx(struct drm_device *dev, void *data, |
897 | unsigned int cmd, unsigned long arg); | 907 | struct drm_file *file_priv); |
898 | 908 | ||
899 | /* Drawable IOCTL support (drm_drawable.h) */ | 909 | /* Drawable IOCTL support (drm_drawable.h) */ |
900 | extern int drm_adddraw(struct inode *inode, struct drm_file *file_priv, | 910 | extern int drm_adddraw(struct drm_device *dev, void *data, |
901 | unsigned int cmd, unsigned long arg); | 911 | struct drm_file *file_priv); |
902 | extern int drm_rmdraw(struct inode *inode, struct drm_file *file_priv, | 912 | extern int drm_rmdraw(struct drm_device *dev, void *data, |
903 | unsigned int cmd, unsigned long arg); | 913 | struct drm_file *file_priv); |
904 | extern int drm_update_drawable_info(struct inode *inode, struct drm_file *file_priv, | 914 | extern int drm_update_drawable_info(struct drm_device *dev, void *data, |
905 | unsigned int cmd, unsigned long arg); | 915 | struct drm_file *file_priv); |
906 | extern struct drm_drawable_info *drm_get_drawable_info(struct drm_device *dev, | 916 | extern struct drm_drawable_info *drm_get_drawable_info(struct drm_device *dev, |
907 | drm_drawable_t id); | 917 | drm_drawable_t id); |
908 | extern void drm_drawable_free_all(struct drm_device *dev); | 918 | extern void drm_drawable_free_all(struct drm_device *dev); |
909 | 919 | ||
910 | /* Authentication IOCTL support (drm_auth.h) */ | 920 | /* Authentication IOCTL support (drm_auth.h) */ |
911 | extern int drm_getmagic(struct inode *inode, struct drm_file *file_priv, | 921 | extern int drm_getmagic(struct drm_device *dev, void *data, |
912 | unsigned int cmd, unsigned long arg); | 922 | struct drm_file *file_priv); |
913 | extern int drm_authmagic(struct inode *inode, struct drm_file *file_priv, | 923 | extern int drm_authmagic(struct drm_device *dev, void *data, |
914 | unsigned int cmd, unsigned long arg); | 924 | struct drm_file *file_priv); |
915 | 925 | ||
916 | /* Locking IOCTL support (drm_lock.h) */ | 926 | /* Locking IOCTL support (drm_lock.h) */ |
917 | extern int drm_lock(struct inode *inode, struct drm_file *file_priv, | 927 | extern int drm_lock(struct drm_device *dev, void *data, |
918 | unsigned int cmd, unsigned long arg); | 928 | struct drm_file *file_priv); |
919 | extern int drm_unlock(struct inode *inode, struct drm_file *file_priv, | 929 | extern int drm_unlock(struct drm_device *dev, void *data, |
920 | unsigned int cmd, unsigned long arg); | 930 | struct drm_file *file_priv); |
921 | extern int drm_lock_take(struct drm_lock_data *lock_data, unsigned int context); | 931 | extern int drm_lock_take(struct drm_lock_data *lock_data, unsigned int context); |
922 | extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context); | 932 | extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context); |
923 | extern void drm_idlelock_take(struct drm_lock_data *lock_data); | 933 | extern void drm_idlelock_take(struct drm_lock_data *lock_data); |
@@ -928,7 +938,7 @@ extern void drm_idlelock_release(struct drm_lock_data *lock_data); | |||
928 | * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. | 938 | * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. |
929 | */ | 939 | */ |
930 | 940 | ||
931 | extern int drm_i_have_hw_lock(struct drm_file *file_priv); | 941 | extern int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv); |
932 | 942 | ||
933 | /* Buffer management support (drm_bufs.h) */ | 943 | /* Buffer management support (drm_bufs.h) */ |
934 | extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request); | 944 | extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request); |
@@ -936,24 +946,23 @@ extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request | |||
936 | extern int drm_addmap(struct drm_device *dev, unsigned int offset, | 946 | extern int drm_addmap(struct drm_device *dev, unsigned int offset, |
937 | unsigned int size, enum drm_map_type type, | 947 | unsigned int size, enum drm_map_type type, |
938 | enum drm_map_flags flags, drm_local_map_t ** map_ptr); | 948 | enum drm_map_flags flags, drm_local_map_t ** map_ptr); |
939 | extern int drm_addmap_ioctl(struct inode *inode, struct drm_file *file_priv, | 949 | extern int drm_addmap_ioctl(struct drm_device *dev, void *data, |
940 | unsigned int cmd, unsigned long arg); | 950 | struct drm_file *file_priv); |
941 | extern int drm_rmmap(struct drm_device *dev, drm_local_map_t * map); | 951 | extern int drm_rmmap(struct drm_device *dev, drm_local_map_t *map); |
942 | extern int drm_rmmap_locked(struct drm_device *dev, drm_local_map_t * map); | 952 | extern int drm_rmmap_locked(struct drm_device *dev, drm_local_map_t *map); |
943 | extern int drm_rmmap_ioctl(struct inode *inode, struct drm_file *file_priv, | 953 | extern int drm_rmmap_ioctl(struct drm_device *dev, void *data, |
944 | unsigned int cmd, unsigned long arg); | 954 | struct drm_file *file_priv); |
945 | 955 | extern int drm_addbufs(struct drm_device *dev, void *data, | |
956 | struct drm_file *file_priv); | ||
957 | extern int drm_infobufs(struct drm_device *dev, void *data, | ||
958 | struct drm_file *file_priv); | ||
959 | extern int drm_markbufs(struct drm_device *dev, void *data, | ||
960 | struct drm_file *file_priv); | ||
961 | extern int drm_freebufs(struct drm_device *dev, void *data, | ||
962 | struct drm_file *file_priv); | ||
963 | extern int drm_mapbufs(struct drm_device *dev, void *data, | ||
964 | struct drm_file *file_priv); | ||
946 | extern int drm_order(unsigned long size); | 965 | extern int drm_order(unsigned long size); |
947 | extern int drm_addbufs(struct inode *inode, struct drm_file *file_priv, | ||
948 | unsigned int cmd, unsigned long arg); | ||
949 | extern int drm_infobufs(struct inode *inode, struct drm_file *file_priv, | ||
950 | unsigned int cmd, unsigned long arg); | ||
951 | extern int drm_markbufs(struct inode *inode, struct drm_file *file_priv, | ||
952 | unsigned int cmd, unsigned long arg); | ||
953 | extern int drm_freebufs(struct inode *inode, struct drm_file *file_priv, | ||
954 | unsigned int cmd, unsigned long arg); | ||
955 | extern int drm_mapbufs(struct inode *inode, struct drm_file *file_priv, | ||
956 | unsigned int cmd, unsigned long arg); | ||
957 | extern unsigned long drm_get_resource_start(struct drm_device *dev, | 966 | extern unsigned long drm_get_resource_start(struct drm_device *dev, |
958 | unsigned int resource); | 967 | unsigned int resource); |
959 | extern unsigned long drm_get_resource_len(struct drm_device *dev, | 968 | extern unsigned long drm_get_resource_len(struct drm_device *dev, |
@@ -967,16 +976,16 @@ extern void drm_core_reclaim_buffers(struct drm_device *dev, | |||
967 | struct drm_file *filp); | 976 | struct drm_file *filp); |
968 | 977 | ||
969 | /* IRQ support (drm_irq.h) */ | 978 | /* IRQ support (drm_irq.h) */ |
970 | extern int drm_control(struct inode *inode, struct drm_file *file_priv, | 979 | extern int drm_control(struct drm_device *dev, void *data, |
971 | unsigned int cmd, unsigned long arg); | 980 | struct drm_file *file_priv); |
972 | extern irqreturn_t drm_irq_handler(DRM_IRQ_ARGS); | 981 | extern irqreturn_t drm_irq_handler(DRM_IRQ_ARGS); |
973 | extern int drm_irq_uninstall(struct drm_device *dev); | 982 | extern int drm_irq_uninstall(struct drm_device *dev); |
974 | extern void drm_driver_irq_preinstall(struct drm_device *dev); | 983 | extern void drm_driver_irq_preinstall(struct drm_device *dev); |
975 | extern void drm_driver_irq_postinstall(struct drm_device *dev); | 984 | extern void drm_driver_irq_postinstall(struct drm_device *dev); |
976 | extern void drm_driver_irq_uninstall(struct drm_device *dev); | 985 | extern void drm_driver_irq_uninstall(struct drm_device *dev); |
977 | 986 | ||
978 | extern int drm_wait_vblank(struct inode *inode, struct drm_file *file_priv, | 987 | extern int drm_wait_vblank(struct drm_device *dev, void *data, |
979 | unsigned int cmd, unsigned long arg); | 988 | struct drm_file *file_priv); |
980 | extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq); | 989 | extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq); |
981 | extern void drm_vbl_send_signals(struct drm_device *dev); | 990 | extern void drm_vbl_send_signals(struct drm_device *dev); |
982 | extern void drm_locked_tasklet(struct drm_device *dev, void(*func)(struct drm_device*)); | 991 | extern void drm_locked_tasklet(struct drm_device *dev, void(*func)(struct drm_device*)); |
@@ -984,31 +993,30 @@ extern void drm_locked_tasklet(struct drm_device *dev, void(*func)(struct drm_de | |||
984 | /* AGP/GART support (drm_agpsupport.h) */ | 993 | /* AGP/GART support (drm_agpsupport.h) */ |
985 | extern struct drm_agp_head *drm_agp_init(struct drm_device *dev); | 994 | extern struct drm_agp_head *drm_agp_init(struct drm_device *dev); |
986 | extern int drm_agp_acquire(struct drm_device *dev); | 995 | extern int drm_agp_acquire(struct drm_device *dev); |
987 | extern int drm_agp_acquire_ioctl(struct inode *inode, struct drm_file *file_priv, | 996 | extern int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, |
988 | unsigned int cmd, unsigned long arg); | 997 | struct drm_file *file_priv); |
989 | extern int drm_agp_release(struct drm_device *dev); | 998 | extern int drm_agp_release(struct drm_device *dev); |
990 | extern int drm_agp_release_ioctl(struct inode *inode, struct drm_file *file_priv, | 999 | extern int drm_agp_release_ioctl(struct drm_device *dev, void *data, |
991 | unsigned int cmd, unsigned long arg); | 1000 | struct drm_file *file_priv); |
992 | extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode); | 1001 | extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode); |
993 | extern int drm_agp_enable_ioctl(struct inode *inode, struct drm_file *file_priv, | 1002 | extern int drm_agp_enable_ioctl(struct drm_device *dev, void *data, |
994 | unsigned int cmd, unsigned long arg); | 1003 | struct drm_file *file_priv); |
995 | extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info * info); | 1004 | extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info); |
996 | extern int drm_agp_info_ioctl(struct inode *inode, struct drm_file *file_priv, | 1005 | extern int drm_agp_info_ioctl(struct drm_device *dev, void *data, |
997 | unsigned int cmd, unsigned long arg); | 1006 | struct drm_file *file_priv); |
998 | extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request); | 1007 | extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request); |
999 | extern int drm_agp_alloc_ioctl(struct inode *inode, struct drm_file *file_priv, | 1008 | extern int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, |
1000 | unsigned int cmd, unsigned long arg); | 1009 | struct drm_file *file_priv); |
1001 | extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request); | 1010 | extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request); |
1002 | extern int drm_agp_free_ioctl(struct inode *inode, struct drm_file *file_priv, | 1011 | extern int drm_agp_free_ioctl(struct drm_device *dev, void *data, |
1003 | unsigned int cmd, unsigned long arg); | 1012 | struct drm_file *file_priv); |
1004 | extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request); | 1013 | extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request); |
1005 | extern int drm_agp_unbind_ioctl(struct inode *inode, struct drm_file *file_priv, | 1014 | extern int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, |
1006 | unsigned int cmd, unsigned long arg); | 1015 | struct drm_file *file_priv); |
1007 | extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request); | 1016 | extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request); |
1008 | extern int drm_agp_bind_ioctl(struct inode *inode, struct drm_file *file_priv, | 1017 | extern int drm_agp_bind_ioctl(struct drm_device *dev, void *data, |
1009 | unsigned int cmd, unsigned long arg); | 1018 | struct drm_file *file_priv); |
1010 | extern DRM_AGP_MEM *drm_agp_allocate_memory(struct agp_bridge_data *bridge, | 1019 | extern DRM_AGP_MEM *drm_agp_allocate_memory(struct agp_bridge_data *bridge, size_t pages, u32 type); |
1011 | size_t pages, u32 type); | ||
1012 | extern int drm_agp_free_memory(DRM_AGP_MEM * handle); | 1020 | extern int drm_agp_free_memory(DRM_AGP_MEM * handle); |
1013 | extern int drm_agp_bind_memory(DRM_AGP_MEM * handle, off_t start); | 1021 | extern int drm_agp_bind_memory(DRM_AGP_MEM * handle, off_t start); |
1014 | extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle); | 1022 | extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle); |
@@ -1037,10 +1045,11 @@ extern int drm_proc_cleanup(int minor, | |||
1037 | 1045 | ||
1038 | /* Scatter Gather Support (drm_scatter.h) */ | 1046 | /* Scatter Gather Support (drm_scatter.h) */ |
1039 | extern void drm_sg_cleanup(struct drm_sg_mem * entry); | 1047 | extern void drm_sg_cleanup(struct drm_sg_mem * entry); |
1040 | extern int drm_sg_alloc(struct inode *inode, struct drm_file *file_priv, | 1048 | extern int drm_sg_alloc_ioctl(struct drm_device *dev, void *data, |
1041 | unsigned int cmd, unsigned long arg); | 1049 | struct drm_file *file_priv); |
1042 | extern int drm_sg_free(struct inode *inode, struct drm_file *file_priv, | 1050 | extern int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request); |
1043 | unsigned int cmd, unsigned long arg); | 1051 | extern int drm_sg_free(struct drm_device *dev, void *data, |
1052 | struct drm_file *file_priv); | ||
1044 | 1053 | ||
1045 | /* ATI PCIGART support (ati_pcigart.h) */ | 1054 | /* ATI PCIGART support (ati_pcigart.h) */ |
1046 | extern int drm_ati_pcigart_init(struct drm_device *dev, | 1055 | extern int drm_ati_pcigart_init(struct drm_device *dev, |
diff --git a/drivers/char/drm/drm_agpsupport.c b/drivers/char/drm/drm_agpsupport.c index 6d7a69abdc62..214f4fbcba73 100644 --- a/drivers/char/drm/drm_agpsupport.c +++ b/drivers/char/drm/drm_agpsupport.c | |||
@@ -71,19 +71,16 @@ int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info) | |||
71 | 71 | ||
72 | EXPORT_SYMBOL(drm_agp_info); | 72 | EXPORT_SYMBOL(drm_agp_info); |
73 | 73 | ||
74 | int drm_agp_info_ioctl(struct inode *inode, struct drm_file *file_priv, | 74 | int drm_agp_info_ioctl(struct drm_device *dev, void *data, |
75 | unsigned int cmd, unsigned long arg) | 75 | struct drm_file *file_priv) |
76 | { | 76 | { |
77 | struct drm_device *dev = file_priv->head->dev; | 77 | struct drm_agp_info *info = data; |
78 | struct drm_agp_info info; | ||
79 | int err; | 78 | int err; |
80 | 79 | ||
81 | err = drm_agp_info(dev, &info); | 80 | err = drm_agp_info(dev, info); |
82 | if (err) | 81 | if (err) |
83 | return err; | 82 | return err; |
84 | 83 | ||
85 | if (copy_to_user((struct drm_agp_info __user *) arg, &info, sizeof(info))) | ||
86 | return -EFAULT; | ||
87 | return 0; | 84 | return 0; |
88 | } | 85 | } |
89 | 86 | ||
@@ -122,8 +119,8 @@ EXPORT_SYMBOL(drm_agp_acquire); | |||
122 | * Verifies the AGP device hasn't been acquired before and calls | 119 | * Verifies the AGP device hasn't been acquired before and calls |
123 | * \c agp_backend_acquire. | 120 | * \c agp_backend_acquire. |
124 | */ | 121 | */ |
125 | int drm_agp_acquire_ioctl(struct inode *inode, struct drm_file *file_priv, | 122 | int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, |
126 | unsigned int cmd, unsigned long arg) | 123 | struct drm_file *file_priv) |
127 | { | 124 | { |
128 | return drm_agp_acquire((struct drm_device *) file_priv->head->dev); | 125 | return drm_agp_acquire((struct drm_device *) file_priv->head->dev); |
129 | } | 126 | } |
@@ -146,11 +143,9 @@ int drm_agp_release(struct drm_device * dev) | |||
146 | } | 143 | } |
147 | EXPORT_SYMBOL(drm_agp_release); | 144 | EXPORT_SYMBOL(drm_agp_release); |
148 | 145 | ||
149 | int drm_agp_release_ioctl(struct inode *inode, struct drm_file *file_priv, | 146 | int drm_agp_release_ioctl(struct drm_device *dev, void *data, |
150 | unsigned int cmd, unsigned long arg) | 147 | struct drm_file *file_priv) |
151 | { | 148 | { |
152 | struct drm_device *dev = file_priv->head->dev; | ||
153 | |||
154 | return drm_agp_release(dev); | 149 | return drm_agp_release(dev); |
155 | } | 150 | } |
156 | 151 | ||
@@ -178,16 +173,12 @@ int drm_agp_enable(struct drm_device * dev, struct drm_agp_mode mode) | |||
178 | 173 | ||
179 | EXPORT_SYMBOL(drm_agp_enable); | 174 | EXPORT_SYMBOL(drm_agp_enable); |
180 | 175 | ||
181 | int drm_agp_enable_ioctl(struct inode *inode, struct drm_file *file_priv, | 176 | int drm_agp_enable_ioctl(struct drm_device *dev, void *data, |
182 | unsigned int cmd, unsigned long arg) | 177 | struct drm_file *file_priv) |
183 | { | 178 | { |
184 | struct drm_device *dev = file_priv->head->dev; | 179 | struct drm_agp_mode *mode = data; |
185 | struct drm_agp_mode mode; | ||
186 | |||
187 | if (copy_from_user(&mode, (struct drm_agp_mode __user *) arg, sizeof(mode))) | ||
188 | return -EFAULT; | ||
189 | 180 | ||
190 | return drm_agp_enable(dev, mode); | 181 | return drm_agp_enable(dev, *mode); |
191 | } | 182 | } |
192 | 183 | ||
193 | /** | 184 | /** |
@@ -236,34 +227,13 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request) | |||
236 | } | 227 | } |
237 | EXPORT_SYMBOL(drm_agp_alloc); | 228 | EXPORT_SYMBOL(drm_agp_alloc); |
238 | 229 | ||
239 | int drm_agp_alloc_ioctl(struct inode *inode, struct drm_file *file_priv, | ||
240 | unsigned int cmd, unsigned long arg) | ||
241 | { | ||
242 | struct drm_device *dev = file_priv->head->dev; | ||
243 | struct drm_agp_buffer request; | ||
244 | struct drm_agp_buffer __user *argp = (void __user *)arg; | ||
245 | int err; | ||
246 | |||
247 | if (copy_from_user(&request, argp, sizeof(request))) | ||
248 | return -EFAULT; | ||
249 | 230 | ||
250 | err = drm_agp_alloc(dev, &request); | 231 | int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, |
251 | if (err) | 232 | struct drm_file *file_priv) |
252 | return err; | 233 | { |
253 | 234 | struct drm_agp_buffer *request = data; | |
254 | if (copy_to_user(argp, &request, sizeof(request))) { | ||
255 | struct drm_agp_mem *entry; | ||
256 | list_for_each_entry(entry, &dev->agp->memory, head) { | ||
257 | if (entry->handle == request.handle) | ||
258 | break; | ||
259 | } | ||
260 | list_del(&entry->head); | ||
261 | drm_free_agp(entry->memory, entry->pages); | ||
262 | drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); | ||
263 | return -EFAULT; | ||
264 | } | ||
265 | 235 | ||
266 | return 0; | 236 | return drm_agp_alloc(dev, request); |
267 | } | 237 | } |
268 | 238 | ||
269 | /** | 239 | /** |
@@ -317,17 +287,13 @@ int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request) | |||
317 | } | 287 | } |
318 | EXPORT_SYMBOL(drm_agp_unbind); | 288 | EXPORT_SYMBOL(drm_agp_unbind); |
319 | 289 | ||
320 | int drm_agp_unbind_ioctl(struct inode *inode, struct drm_file *file_priv, | ||
321 | unsigned int cmd, unsigned long arg) | ||
322 | { | ||
323 | struct drm_device *dev = file_priv->head->dev; | ||
324 | struct drm_agp_binding request; | ||
325 | 290 | ||
326 | if (copy_from_user | 291 | int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, |
327 | (&request, (struct drm_agp_binding __user *) arg, sizeof(request))) | 292 | struct drm_file *file_priv) |
328 | return -EFAULT; | 293 | { |
294 | struct drm_agp_binding *request = data; | ||
329 | 295 | ||
330 | return drm_agp_unbind(dev, &request); | 296 | return drm_agp_unbind(dev, request); |
331 | } | 297 | } |
332 | 298 | ||
333 | /** | 299 | /** |
@@ -365,17 +331,13 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request) | |||
365 | } | 331 | } |
366 | EXPORT_SYMBOL(drm_agp_bind); | 332 | EXPORT_SYMBOL(drm_agp_bind); |
367 | 333 | ||
368 | int drm_agp_bind_ioctl(struct inode *inode, struct drm_file *file_priv, | ||
369 | unsigned int cmd, unsigned long arg) | ||
370 | { | ||
371 | struct drm_device *dev = file_priv->head->dev; | ||
372 | struct drm_agp_binding request; | ||
373 | 334 | ||
374 | if (copy_from_user | 335 | int drm_agp_bind_ioctl(struct drm_device *dev, void *data, |
375 | (&request, (struct drm_agp_binding __user *) arg, sizeof(request))) | 336 | struct drm_file *file_priv) |
376 | return -EFAULT; | 337 | { |
338 | struct drm_agp_binding *request = data; | ||
377 | 339 | ||
378 | return drm_agp_bind(dev, &request); | 340 | return drm_agp_bind(dev, request); |
379 | } | 341 | } |
380 | 342 | ||
381 | /** | 343 | /** |
@@ -411,17 +373,14 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request) | |||
411 | } | 373 | } |
412 | EXPORT_SYMBOL(drm_agp_free); | 374 | EXPORT_SYMBOL(drm_agp_free); |
413 | 375 | ||
414 | int drm_agp_free_ioctl(struct inode *inode, struct drm_file *file_priv, | ||
415 | unsigned int cmd, unsigned long arg) | ||
416 | { | ||
417 | struct drm_device *dev = file_priv->head->dev; | ||
418 | struct drm_agp_buffer request; | ||
419 | 376 | ||
420 | if (copy_from_user | ||
421 | (&request, (struct drm_agp_buffer __user *) arg, sizeof(request))) | ||
422 | return -EFAULT; | ||
423 | 377 | ||
424 | return drm_agp_free(dev, &request); | 378 | int drm_agp_free_ioctl(struct drm_device *dev, void *data, |
379 | struct drm_file *file_priv) | ||
380 | { | ||
381 | struct drm_agp_buffer *request = data; | ||
382 | |||
383 | return drm_agp_free(dev, request); | ||
425 | } | 384 | } |
426 | 385 | ||
427 | /** | 386 | /** |
diff --git a/drivers/char/drm/drm_auth.c b/drivers/char/drm/drm_auth.c index dc66cfef7ec3..a73462723d2d 100644 --- a/drivers/char/drm/drm_auth.c +++ b/drivers/char/drm/drm_auth.c | |||
@@ -137,32 +137,29 @@ static int drm_remove_magic(struct drm_device * dev, drm_magic_t magic) | |||
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 | * file_priv. | 138 | * file_priv. |
139 | */ | 139 | */ |
140 | int drm_getmagic(struct inode *inode, struct drm_file *file_priv, | 140 | int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv) |
141 | unsigned int cmd, unsigned long arg) | ||
142 | { | 141 | { |
143 | static drm_magic_t sequence = 0; | 142 | static drm_magic_t sequence = 0; |
144 | static DEFINE_SPINLOCK(lock); | 143 | static DEFINE_SPINLOCK(lock); |
145 | struct drm_device *dev = file_priv->head->dev; | 144 | struct drm_auth *auth = data; |
146 | struct drm_auth auth; | ||
147 | 145 | ||
148 | /* Find unique magic */ | 146 | /* Find unique magic */ |
149 | if (file_priv->magic) { | 147 | if (file_priv->magic) { |
150 | auth.magic = file_priv->magic; | 148 | auth->magic = file_priv->magic; |
151 | } else { | 149 | } else { |
152 | do { | 150 | do { |
153 | spin_lock(&lock); | 151 | spin_lock(&lock); |
154 | if (!sequence) | 152 | if (!sequence) |
155 | ++sequence; /* reserve 0 */ | 153 | ++sequence; /* reserve 0 */ |
156 | auth.magic = sequence++; | 154 | auth->magic = sequence++; |
157 | spin_unlock(&lock); | 155 | spin_unlock(&lock); |
158 | } while (drm_find_file(dev, auth.magic)); | 156 | } while (drm_find_file(dev, auth->magic)); |
159 | file_priv->magic = auth.magic; | 157 | file_priv->magic = auth->magic; |
160 | drm_add_magic(dev, file_priv, auth.magic); | 158 | drm_add_magic(dev, file_priv, auth->magic); |
161 | } | 159 | } |
162 | 160 | ||
163 | DRM_DEBUG("%u\n", auth.magic); | 161 | DRM_DEBUG("%u\n", auth->magic); |
164 | if (copy_to_user((struct drm_auth __user *) arg, &auth, sizeof(auth))) | 162 | |
165 | return -EFAULT; | ||
166 | return 0; | 163 | return 0; |
167 | } | 164 | } |
168 | 165 | ||
@@ -177,19 +174,16 @@ int drm_getmagic(struct inode *inode, struct drm_file *file_priv, | |||
177 | * | 174 | * |
178 | * Checks if \p file_priv is associated with the magic number passed in \arg. | 175 | * Checks if \p file_priv is associated with the magic number passed in \arg. |
179 | */ | 176 | */ |
180 | int drm_authmagic(struct inode *inode, struct drm_file *file_priv, | 177 | int drm_authmagic(struct drm_device *dev, void *data, |
181 | unsigned int cmd, unsigned long arg) | 178 | struct drm_file *file_priv) |
182 | { | 179 | { |
183 | struct drm_device *dev = file_priv->head->dev; | 180 | struct drm_auth *auth = data; |
184 | struct drm_auth auth; | ||
185 | struct drm_file *file; | 181 | struct drm_file *file; |
186 | 182 | ||
187 | if (copy_from_user(&auth, (struct drm_auth __user *) arg, sizeof(auth))) | 183 | DRM_DEBUG("%u\n", auth->magic); |
188 | return -EFAULT; | 184 | if ((file = drm_find_file(dev, auth->magic))) { |
189 | DRM_DEBUG("%u\n", auth.magic); | ||
190 | if ((file = drm_find_file(dev, auth.magic))) { | ||
191 | file->authenticated = 1; | 185 | file->authenticated = 1; |
192 | drm_remove_magic(dev, auth.magic); | 186 | drm_remove_magic(dev, auth->magic); |
193 | return 0; | 187 | return 0; |
194 | } | 188 | } |
195 | return -EINVAL; | 189 | return -EINVAL; |
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c index e7253874fa8f..856774fbe025 100644 --- a/drivers/char/drm/drm_bufs.c +++ b/drivers/char/drm/drm_bufs.c | |||
@@ -332,34 +332,24 @@ int drm_addmap(struct drm_device * dev, unsigned int offset, | |||
332 | 332 | ||
333 | EXPORT_SYMBOL(drm_addmap); | 333 | EXPORT_SYMBOL(drm_addmap); |
334 | 334 | ||
335 | int drm_addmap_ioctl(struct inode *inode, struct drm_file *file_priv, | 335 | int drm_addmap_ioctl(struct drm_device *dev, void *data, |
336 | unsigned int cmd, unsigned long arg) | 336 | struct drm_file *file_priv) |
337 | { | 337 | { |
338 | struct drm_device *dev = file_priv->head->dev; | 338 | struct drm_map *map = data; |
339 | struct drm_map map; | ||
340 | struct drm_map_list *maplist; | 339 | struct drm_map_list *maplist; |
341 | struct drm_map __user *argp = (void __user *)arg; | ||
342 | int err; | 340 | int err; |
343 | 341 | ||
344 | if (copy_from_user(&map, argp, sizeof(map))) { | 342 | if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP)) |
345 | return -EFAULT; | ||
346 | } | ||
347 | |||
348 | if (!(capable(CAP_SYS_ADMIN) || map.type == _DRM_AGP)) | ||
349 | return -EPERM; | 343 | return -EPERM; |
350 | 344 | ||
351 | err = drm_addmap_core(dev, map.offset, map.size, map.type, map.flags, | 345 | err = drm_addmap_core(dev, map->offset, map->size, map->type, |
352 | &maplist); | 346 | map->flags, &maplist); |
353 | 347 | ||
354 | if (err) | 348 | if (err) |
355 | return err; | 349 | return err; |
356 | 350 | ||
357 | if (copy_to_user(argp, maplist->map, sizeof(struct drm_map))) | ||
358 | return -EFAULT; | ||
359 | |||
360 | /* avoid a warning on 64-bit, this casting isn't very nice, but the API is set so too late */ | 351 | /* avoid a warning on 64-bit, this casting isn't very nice, but the API is set so too late */ |
361 | if (put_user((void *)(unsigned long)maplist->user_token, &argp->handle)) | 352 | map->handle = (void *)(unsigned long)maplist->user_token; |
362 | return -EFAULT; | ||
363 | return 0; | 353 | return 0; |
364 | } | 354 | } |
365 | 355 | ||
@@ -449,23 +439,18 @@ int drm_rmmap(struct drm_device *dev, drm_local_map_t *map) | |||
449 | * gets used by drivers that the server doesn't need to care about. This seems | 439 | * gets used by drivers that the server doesn't need to care about. This seems |
450 | * unlikely. | 440 | * unlikely. |
451 | */ | 441 | */ |
452 | int drm_rmmap_ioctl(struct inode *inode, struct drm_file *file_priv, | 442 | int drm_rmmap_ioctl(struct drm_device *dev, void *data, |
453 | unsigned int cmd, unsigned long arg) | 443 | struct drm_file *file_priv) |
454 | { | 444 | { |
455 | struct drm_device *dev = file_priv->head->dev; | 445 | struct drm_map *request = data; |
456 | struct drm_map request; | ||
457 | drm_local_map_t *map = NULL; | 446 | drm_local_map_t *map = NULL; |
458 | struct drm_map_list *r_list; | 447 | struct drm_map_list *r_list; |
459 | int ret; | 448 | int ret; |
460 | 449 | ||
461 | if (copy_from_user(&request, (struct drm_map __user *) arg, sizeof(request))) { | ||
462 | return -EFAULT; | ||
463 | } | ||
464 | |||
465 | mutex_lock(&dev->struct_mutex); | 450 | mutex_lock(&dev->struct_mutex); |
466 | list_for_each_entry(r_list, &dev->maplist, head) { | 451 | list_for_each_entry(r_list, &dev->maplist, head) { |
467 | if (r_list->map && | 452 | if (r_list->map && |
468 | r_list->user_token == (unsigned long)request.handle && | 453 | r_list->user_token == (unsigned long)request->handle && |
469 | r_list->map->flags & _DRM_REMOVABLE) { | 454 | r_list->map->flags & _DRM_REMOVABLE) { |
470 | map = r_list->map; | 455 | map = r_list->map; |
471 | break; | 456 | break; |
@@ -1280,37 +1265,27 @@ static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request | |||
1280 | * addbufs_sg() or addbufs_pci() for AGP, scatter-gather or consistent | 1265 | * addbufs_sg() or addbufs_pci() for AGP, scatter-gather or consistent |
1281 | * PCI memory respectively. | 1266 | * PCI memory respectively. |
1282 | */ | 1267 | */ |
1283 | int drm_addbufs(struct inode *inode, struct drm_file *file_priv, | 1268 | int drm_addbufs(struct drm_device *dev, void *data, |
1284 | unsigned int cmd, unsigned long arg) | 1269 | struct drm_file *file_priv) |
1285 | { | 1270 | { |
1286 | struct drm_buf_desc request; | 1271 | struct drm_buf_desc *request = data; |
1287 | struct drm_device *dev = file_priv->head->dev; | ||
1288 | int ret; | 1272 | int ret; |
1289 | 1273 | ||
1290 | if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA)) | 1274 | if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA)) |
1291 | return -EINVAL; | 1275 | return -EINVAL; |
1292 | 1276 | ||
1293 | if (copy_from_user(&request, (struct drm_buf_desc __user *) arg, | ||
1294 | sizeof(request))) | ||
1295 | return -EFAULT; | ||
1296 | |||
1297 | #if __OS_HAS_AGP | 1277 | #if __OS_HAS_AGP |
1298 | if (request.flags & _DRM_AGP_BUFFER) | 1278 | if (request->flags & _DRM_AGP_BUFFER) |
1299 | ret = drm_addbufs_agp(dev, &request); | 1279 | ret = drm_addbufs_agp(dev, request); |
1300 | else | 1280 | else |
1301 | #endif | 1281 | #endif |
1302 | if (request.flags & _DRM_SG_BUFFER) | 1282 | if (request->flags & _DRM_SG_BUFFER) |
1303 | ret = drm_addbufs_sg(dev, &request); | 1283 | ret = drm_addbufs_sg(dev, request); |
1304 | else if (request.flags & _DRM_FB_BUFFER) | 1284 | else if (request->flags & _DRM_FB_BUFFER) |
1305 | ret = drm_addbufs_fb(dev, &request); | 1285 | ret = drm_addbufs_fb(dev, request); |
1306 | else | 1286 | else |
1307 | ret = drm_addbufs_pci(dev, &request); | 1287 | ret = drm_addbufs_pci(dev, request); |
1308 | 1288 | ||
1309 | if (ret == 0) { | ||
1310 | if (copy_to_user((void __user *)arg, &request, sizeof(request))) { | ||
1311 | ret = -EFAULT; | ||
1312 | } | ||
1313 | } | ||
1314 | return ret; | 1289 | return ret; |
1315 | } | 1290 | } |
1316 | 1291 | ||
@@ -1331,13 +1306,11 @@ int drm_addbufs(struct inode *inode, struct drm_file *file_priv, | |||
1331 | * lock, preventing of allocating more buffers after this call. Information | 1306 | * lock, preventing of allocating more buffers after this call. Information |
1332 | * about each requested buffer is then copied into user space. | 1307 | * about each requested buffer is then copied into user space. |
1333 | */ | 1308 | */ |
1334 | int drm_infobufs(struct inode *inode, struct drm_file *file_priv, | 1309 | int drm_infobufs(struct drm_device *dev, void *data, |
1335 | unsigned int cmd, unsigned long arg) | 1310 | struct drm_file *file_priv) |
1336 | { | 1311 | { |
1337 | struct drm_device *dev = file_priv->head->dev; | ||
1338 | struct drm_device_dma *dma = dev->dma; | 1312 | struct drm_device_dma *dma = dev->dma; |
1339 | struct drm_buf_info request; | 1313 | struct drm_buf_info *request = data; |
1340 | struct drm_buf_info __user *argp = (void __user *)arg; | ||
1341 | int i; | 1314 | int i; |
1342 | int count; | 1315 | int count; |
1343 | 1316 | ||
@@ -1355,9 +1328,6 @@ int drm_infobufs(struct inode *inode, struct drm_file *file_priv, | |||
1355 | ++dev->buf_use; /* Can't allocate more after this call */ | 1328 | ++dev->buf_use; /* Can't allocate more after this call */ |
1356 | spin_unlock(&dev->count_lock); | 1329 | spin_unlock(&dev->count_lock); |
1357 | 1330 | ||
1358 | if (copy_from_user(&request, argp, sizeof(request))) | ||
1359 | return -EFAULT; | ||
1360 | |||
1361 | for (i = 0, count = 0; i < DRM_MAX_ORDER + 1; i++) { | 1331 | for (i = 0, count = 0; i < DRM_MAX_ORDER + 1; i++) { |
1362 | if (dma->bufs[i].buf_count) | 1332 | if (dma->bufs[i].buf_count) |
1363 | ++count; | 1333 | ++count; |
@@ -1365,11 +1335,11 @@ int drm_infobufs(struct inode *inode, struct drm_file *file_priv, | |||
1365 | 1335 | ||
1366 | DRM_DEBUG("count = %d\n", count); | 1336 | DRM_DEBUG("count = %d\n", count); |
1367 | 1337 | ||
1368 | if (request.count >= count) { | 1338 | if (request->count >= count) { |
1369 | for (i = 0, count = 0; i < DRM_MAX_ORDER + 1; i++) { | 1339 | for (i = 0, count = 0; i < DRM_MAX_ORDER + 1; i++) { |
1370 | if (dma->bufs[i].buf_count) { | 1340 | if (dma->bufs[i].buf_count) { |
1371 | struct drm_buf_desc __user *to = | 1341 | struct drm_buf_desc __user *to = |
1372 | &request.list[count]; | 1342 | &request->list[count]; |
1373 | struct drm_buf_entry *from = &dma->bufs[i]; | 1343 | struct drm_buf_entry *from = &dma->bufs[i]; |
1374 | struct drm_freelist *list = &dma->bufs[i].freelist; | 1344 | struct drm_freelist *list = &dma->bufs[i].freelist; |
1375 | if (copy_to_user(&to->count, | 1345 | if (copy_to_user(&to->count, |
@@ -1396,10 +1366,7 @@ int drm_infobufs(struct inode *inode, struct drm_file *file_priv, | |||
1396 | } | 1366 | } |
1397 | } | 1367 | } |
1398 | } | 1368 | } |
1399 | request.count = count; | 1369 | request->count = count; |
1400 | |||
1401 | if (copy_to_user(argp, &request, sizeof(request))) | ||
1402 | return -EFAULT; | ||
1403 | 1370 | ||
1404 | return 0; | 1371 | return 0; |
1405 | } | 1372 | } |
@@ -1418,12 +1385,11 @@ int drm_infobufs(struct inode *inode, struct drm_file *file_priv, | |||
1418 | * | 1385 | * |
1419 | * \note This ioctl is deprecated and mostly never used. | 1386 | * \note This ioctl is deprecated and mostly never used. |
1420 | */ | 1387 | */ |
1421 | int drm_markbufs(struct inode *inode, struct drm_file *file_priv, | 1388 | int drm_markbufs(struct drm_device *dev, void *data, |
1422 | unsigned int cmd, unsigned long arg) | 1389 | struct drm_file *file_priv) |
1423 | { | 1390 | { |
1424 | struct drm_device *dev = file_priv->head->dev; | ||
1425 | struct drm_device_dma *dma = dev->dma; | 1391 | struct drm_device_dma *dma = dev->dma; |
1426 | struct drm_buf_desc request; | 1392 | struct drm_buf_desc *request = data; |
1427 | int order; | 1393 | int order; |
1428 | struct drm_buf_entry *entry; | 1394 | struct drm_buf_entry *entry; |
1429 | 1395 | ||
@@ -1433,24 +1399,20 @@ int drm_markbufs(struct inode *inode, struct drm_file *file_priv, | |||
1433 | if (!dma) | 1399 | if (!dma) |
1434 | return -EINVAL; | 1400 | return -EINVAL; |
1435 | 1401 | ||
1436 | if (copy_from_user(&request, | ||
1437 | (struct drm_buf_desc __user *) arg, sizeof(request))) | ||
1438 | return -EFAULT; | ||
1439 | |||
1440 | DRM_DEBUG("%d, %d, %d\n", | 1402 | DRM_DEBUG("%d, %d, %d\n", |
1441 | request.size, request.low_mark, request.high_mark); | 1403 | request->size, request->low_mark, request->high_mark); |
1442 | order = drm_order(request.size); | 1404 | order = drm_order(request->size); |
1443 | if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) | 1405 | if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) |
1444 | return -EINVAL; | 1406 | return -EINVAL; |
1445 | entry = &dma->bufs[order]; | 1407 | entry = &dma->bufs[order]; |
1446 | 1408 | ||
1447 | if (request.low_mark < 0 || request.low_mark > entry->buf_count) | 1409 | if (request->low_mark < 0 || request->low_mark > entry->buf_count) |
1448 | return -EINVAL; | 1410 | return -EINVAL; |
1449 | if (request.high_mark < 0 || request.high_mark > entry->buf_count) | 1411 | if (request->high_mark < 0 || request->high_mark > entry->buf_count) |
1450 | return -EINVAL; | 1412 | return -EINVAL; |
1451 | 1413 | ||
1452 | entry->freelist.low_mark = request.low_mark; | 1414 | entry->freelist.low_mark = request->low_mark; |
1453 | entry->freelist.high_mark = request.high_mark; | 1415 | entry->freelist.high_mark = request->high_mark; |
1454 | 1416 | ||
1455 | return 0; | 1417 | return 0; |
1456 | } | 1418 | } |
@@ -1467,12 +1429,11 @@ int drm_markbufs(struct inode *inode, struct drm_file *file_priv, | |||
1467 | * Calls free_buffer() for each used buffer. | 1429 | * Calls free_buffer() for each used buffer. |
1468 | * This function is primarily used for debugging. | 1430 | * This function is primarily used for debugging. |
1469 | */ | 1431 | */ |
1470 | int drm_freebufs(struct inode *inode, struct drm_file *file_priv, | 1432 | int drm_freebufs(struct drm_device *dev, void *data, |
1471 | unsigned int cmd, unsigned long arg) | 1433 | struct drm_file *file_priv) |
1472 | { | 1434 | { |
1473 | struct drm_device *dev = file_priv->head->dev; | ||
1474 | struct drm_device_dma *dma = dev->dma; | 1435 | struct drm_device_dma *dma = dev->dma; |
1475 | struct drm_buf_free request; | 1436 | struct drm_buf_free *request = data; |
1476 | int i; | 1437 | int i; |
1477 | int idx; | 1438 | int idx; |
1478 | struct drm_buf *buf; | 1439 | struct drm_buf *buf; |
@@ -1483,13 +1444,9 @@ int drm_freebufs(struct inode *inode, struct drm_file *file_priv, | |||
1483 | if (!dma) | 1444 | if (!dma) |
1484 | return -EINVAL; | 1445 | return -EINVAL; |
1485 | 1446 | ||
1486 | if (copy_from_user(&request, | 1447 | DRM_DEBUG("%d\n", request->count); |
1487 | (struct drm_buf_free __user *) arg, sizeof(request))) | 1448 | for (i = 0; i < request->count; i++) { |
1488 | return -EFAULT; | 1449 | if (copy_from_user(&idx, &request->list[i], sizeof(idx))) |
1489 | |||
1490 | DRM_DEBUG("%d\n", request.count); | ||
1491 | for (i = 0; i < request.count; i++) { | ||
1492 | if (copy_from_user(&idx, &request.list[i], sizeof(idx))) | ||
1493 | return -EFAULT; | 1450 | return -EFAULT; |
1494 | if (idx < 0 || idx >= dma->buf_count) { | 1451 | if (idx < 0 || idx >= dma->buf_count) { |
1495 | DRM_ERROR("Index %d (of %d max)\n", | 1452 | DRM_ERROR("Index %d (of %d max)\n", |
@@ -1522,17 +1479,15 @@ int drm_freebufs(struct inode *inode, struct drm_file *file_priv, | |||
1522 | * offset equal to 0, which drm_mmap() interpretes as PCI buffers and calls | 1479 | * offset equal to 0, which drm_mmap() interpretes as PCI buffers and calls |
1523 | * drm_mmap_dma(). | 1480 | * drm_mmap_dma(). |
1524 | */ | 1481 | */ |
1525 | int drm_mapbufs(struct inode *inode, struct drm_file *file_priv, | 1482 | int drm_mapbufs(struct drm_device *dev, void *data, |
1526 | unsigned int cmd, unsigned long arg) | 1483 | struct drm_file *file_priv) |
1527 | { | 1484 | { |
1528 | struct drm_device *dev = file_priv->head->dev; | ||
1529 | struct drm_device_dma *dma = dev->dma; | 1485 | struct drm_device_dma *dma = dev->dma; |
1530 | struct drm_buf_map __user *argp = (void __user *)arg; | ||
1531 | int retcode = 0; | 1486 | int retcode = 0; |
1532 | const int zero = 0; | 1487 | const int zero = 0; |
1533 | unsigned long virtual; | 1488 | unsigned long virtual; |
1534 | unsigned long address; | 1489 | unsigned long address; |
1535 | struct drm_buf_map request; | 1490 | struct drm_buf_map *request = data; |
1536 | int i; | 1491 | int i; |
1537 | 1492 | ||
1538 | if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA)) | 1493 | if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA)) |
@@ -1549,10 +1504,7 @@ int drm_mapbufs(struct inode *inode, struct drm_file *file_priv, | |||
1549 | dev->buf_use++; /* Can't allocate more after this call */ | 1504 | dev->buf_use++; /* Can't allocate more after this call */ |
1550 | spin_unlock(&dev->count_lock); | 1505 | spin_unlock(&dev->count_lock); |
1551 | 1506 | ||
1552 | if (copy_from_user(&request, argp, sizeof(request))) | 1507 | if (request->count >= dma->buf_count) { |
1553 | return -EFAULT; | ||
1554 | |||
1555 | if (request.count >= dma->buf_count) { | ||
1556 | if ((drm_core_has_AGP(dev) && (dma->flags & _DRM_DMA_USE_AGP)) | 1508 | if ((drm_core_has_AGP(dev) && (dma->flags & _DRM_DMA_USE_AGP)) |
1557 | || (drm_core_check_feature(dev, DRIVER_SG) | 1509 | || (drm_core_check_feature(dev, DRIVER_SG) |
1558 | && (dma->flags & _DRM_DMA_USE_SG)) | 1510 | && (dma->flags & _DRM_DMA_USE_SG)) |
@@ -1565,11 +1517,11 @@ int drm_mapbufs(struct inode *inode, struct drm_file *file_priv, | |||
1565 | retcode = -EINVAL; | 1517 | retcode = -EINVAL; |
1566 | goto done; | 1518 | goto done; |
1567 | } | 1519 | } |
1568 | |||
1569 | down_write(¤t->mm->mmap_sem); | 1520 | down_write(¤t->mm->mmap_sem); |
1570 | virtual = do_mmap(file_priv->filp, 0, map->size, | 1521 | virtual = do_mmap(file_priv->filp, 0, map->size, |
1571 | PROT_READ | PROT_WRITE, | 1522 | PROT_READ | PROT_WRITE, |
1572 | MAP_SHARED, token); | 1523 | MAP_SHARED, |
1524 | token); | ||
1573 | up_write(¤t->mm->mmap_sem); | 1525 | up_write(¤t->mm->mmap_sem); |
1574 | } else { | 1526 | } else { |
1575 | down_write(¤t->mm->mmap_sem); | 1527 | down_write(¤t->mm->mmap_sem); |
@@ -1583,28 +1535,28 @@ int drm_mapbufs(struct inode *inode, struct drm_file *file_priv, | |||
1583 | retcode = (signed long)virtual; | 1535 | retcode = (signed long)virtual; |
1584 | goto done; | 1536 | goto done; |
1585 | } | 1537 | } |
1586 | request.virtual = (void __user *)virtual; | 1538 | request->virtual = (void __user *)virtual; |
1587 | 1539 | ||
1588 | for (i = 0; i < dma->buf_count; i++) { | 1540 | for (i = 0; i < dma->buf_count; i++) { |
1589 | if (copy_to_user(&request.list[i].idx, | 1541 | if (copy_to_user(&request->list[i].idx, |
1590 | &dma->buflist[i]->idx, | 1542 | &dma->buflist[i]->idx, |
1591 | sizeof(request.list[0].idx))) { | 1543 | sizeof(request->list[0].idx))) { |
1592 | retcode = -EFAULT; | 1544 | retcode = -EFAULT; |
1593 | goto done; | 1545 | goto done; |
1594 | } | 1546 | } |
1595 | if (copy_to_user(&request.list[i].total, | 1547 | if (copy_to_user(&request->list[i].total, |
1596 | &dma->buflist[i]->total, | 1548 | &dma->buflist[i]->total, |
1597 | sizeof(request.list[0].total))) { | 1549 | sizeof(request->list[0].total))) { |
1598 | retcode = -EFAULT; | 1550 | retcode = -EFAULT; |
1599 | goto done; | 1551 | goto done; |
1600 | } | 1552 | } |
1601 | if (copy_to_user(&request.list[i].used, | 1553 | if (copy_to_user(&request->list[i].used, |
1602 | &zero, sizeof(zero))) { | 1554 | &zero, sizeof(zero))) { |
1603 | retcode = -EFAULT; | 1555 | retcode = -EFAULT; |
1604 | goto done; | 1556 | goto done; |
1605 | } | 1557 | } |
1606 | address = virtual + dma->buflist[i]->offset; /* *** */ | 1558 | address = virtual + dma->buflist[i]->offset; /* *** */ |
1607 | if (copy_to_user(&request.list[i].address, | 1559 | if (copy_to_user(&request->list[i].address, |
1608 | &address, sizeof(address))) { | 1560 | &address, sizeof(address))) { |
1609 | retcode = -EFAULT; | 1561 | retcode = -EFAULT; |
1610 | goto done; | 1562 | goto done; |
@@ -1612,11 +1564,8 @@ int drm_mapbufs(struct inode *inode, struct drm_file *file_priv, | |||
1612 | } | 1564 | } |
1613 | } | 1565 | } |
1614 | done: | 1566 | done: |
1615 | request.count = dma->buf_count; | 1567 | request->count = dma->buf_count; |
1616 | DRM_DEBUG("%d buffers, retcode = %d\n", request.count, retcode); | 1568 | DRM_DEBUG("%d buffers, retcode = %d\n", request->count, retcode); |
1617 | |||
1618 | if (copy_to_user(argp, &request, sizeof(request))) | ||
1619 | return -EFAULT; | ||
1620 | 1569 | ||
1621 | return retcode; | 1570 | return retcode; |
1622 | } | 1571 | } |
diff --git a/drivers/char/drm/drm_context.c b/drivers/char/drm/drm_context.c index 4037a3602f1e..17fe69e7bfc1 100644 --- a/drivers/char/drm/drm_context.c +++ b/drivers/char/drm/drm_context.c | |||
@@ -139,21 +139,16 @@ 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 | */ |
142 | int drm_getsareactx(struct inode *inode, struct drm_file *file_priv, | 142 | int drm_getsareactx(struct drm_device *dev, void *data, |
143 | unsigned int cmd, unsigned long arg) | 143 | struct drm_file *file_priv) |
144 | { | 144 | { |
145 | struct drm_device *dev = file_priv->head->dev; | 145 | struct drm_ctx_priv_map *request = data; |
146 | struct drm_ctx_priv_map __user *argp = (void __user *)arg; | ||
147 | struct drm_ctx_priv_map request; | ||
148 | struct drm_map *map; | 146 | struct drm_map *map; |
149 | struct drm_map_list *_entry; | 147 | struct drm_map_list *_entry; |
150 | 148 | ||
151 | if (copy_from_user(&request, argp, sizeof(request))) | ||
152 | return -EFAULT; | ||
153 | |||
154 | mutex_lock(&dev->struct_mutex); | 149 | mutex_lock(&dev->struct_mutex); |
155 | 150 | ||
156 | map = idr_find(&dev->ctx_idr, request.ctx_id); | 151 | map = idr_find(&dev->ctx_idr, request->ctx_id); |
157 | if (!map) { | 152 | if (!map) { |
158 | mutex_unlock(&dev->struct_mutex); | 153 | mutex_unlock(&dev->struct_mutex); |
159 | return -EINVAL; | 154 | return -EINVAL; |
@@ -161,19 +156,17 @@ int drm_getsareactx(struct inode *inode, struct drm_file *file_priv, | |||
161 | 156 | ||
162 | mutex_unlock(&dev->struct_mutex); | 157 | mutex_unlock(&dev->struct_mutex); |
163 | 158 | ||
164 | request.handle = NULL; | 159 | request->handle = NULL; |
165 | list_for_each_entry(_entry, &dev->maplist, head) { | 160 | list_for_each_entry(_entry, &dev->maplist, head) { |
166 | if (_entry->map == map) { | 161 | if (_entry->map == map) { |
167 | request.handle = | 162 | request->handle = |
168 | (void *)(unsigned long)_entry->user_token; | 163 | (void *)(unsigned long)_entry->user_token; |
169 | break; | 164 | break; |
170 | } | 165 | } |
171 | } | 166 | } |
172 | if (request.handle == NULL) | 167 | if (request->handle == NULL) |
173 | return -EINVAL; | 168 | return -EINVAL; |
174 | 169 | ||
175 | if (copy_to_user(argp, &request, sizeof(request))) | ||
176 | return -EFAULT; | ||
177 | return 0; | 170 | return 0; |
178 | } | 171 | } |
179 | 172 | ||
@@ -189,23 +182,17 @@ int drm_getsareactx(struct inode *inode, struct drm_file *file_priv, | |||
189 | * Searches the mapping specified in \p arg and update the entry in | 182 | * Searches the mapping specified in \p arg and update the entry in |
190 | * drm_device::ctx_idr with it. | 183 | * drm_device::ctx_idr with it. |
191 | */ | 184 | */ |
192 | int drm_setsareactx(struct inode *inode, struct drm_file *file_priv, | 185 | int drm_setsareactx(struct drm_device *dev, void *data, |
193 | unsigned int cmd, unsigned long arg) | 186 | struct drm_file *file_priv) |
194 | { | 187 | { |
195 | struct drm_device *dev = file_priv->head->dev; | 188 | struct drm_ctx_priv_map *request = data; |
196 | struct drm_ctx_priv_map request; | ||
197 | struct drm_map *map = NULL; | 189 | struct drm_map *map = NULL; |
198 | struct drm_map_list *r_list = NULL; | 190 | struct drm_map_list *r_list = NULL; |
199 | 191 | ||
200 | if (copy_from_user(&request, | ||
201 | (struct drm_ctx_priv_map __user *) arg, | ||
202 | sizeof(request))) | ||
203 | return -EFAULT; | ||
204 | |||
205 | mutex_lock(&dev->struct_mutex); | 192 | mutex_lock(&dev->struct_mutex); |
206 | list_for_each_entry(r_list, &dev->maplist, head) { | 193 | list_for_each_entry(r_list, &dev->maplist, head) { |
207 | if (r_list->map | 194 | if (r_list->map |
208 | && r_list->user_token == (unsigned long)request.handle) | 195 | && r_list->user_token == (unsigned long) request->handle) |
209 | goto found; | 196 | goto found; |
210 | } | 197 | } |
211 | bad: | 198 | bad: |
@@ -217,10 +204,11 @@ int drm_setsareactx(struct inode *inode, struct drm_file *file_priv, | |||
217 | if (!map) | 204 | if (!map) |
218 | goto bad; | 205 | goto bad; |
219 | 206 | ||
220 | if (IS_ERR(idr_replace(&dev->ctx_idr, map, request.ctx_id))) | 207 | if (IS_ERR(idr_replace(&dev->ctx_idr, map, request->ctx_id))) |
221 | goto bad; | 208 | goto bad; |
222 | 209 | ||
223 | mutex_unlock(&dev->struct_mutex); | 210 | mutex_unlock(&dev->struct_mutex); |
211 | |||
224 | return 0; | 212 | return 0; |
225 | } | 213 | } |
226 | 214 | ||
@@ -295,29 +283,23 @@ static int drm_context_switch_complete(struct drm_device * dev, int new) | |||
295 | * \param arg user argument pointing to a drm_ctx_res structure. | 283 | * \param arg user argument pointing to a drm_ctx_res structure. |
296 | * \return zero on success or a negative number on failure. | 284 | * \return zero on success or a negative number on failure. |
297 | */ | 285 | */ |
298 | int drm_resctx(struct inode *inode, struct drm_file *file_priv, | 286 | int drm_resctx(struct drm_device *dev, void *data, |
299 | unsigned int cmd, unsigned long arg) | 287 | struct drm_file *file_priv) |
300 | { | 288 | { |
301 | struct drm_ctx_res res; | 289 | struct drm_ctx_res *res = data; |
302 | struct drm_ctx_res __user *argp = (void __user *)arg; | ||
303 | struct drm_ctx ctx; | 290 | struct drm_ctx ctx; |
304 | int i; | 291 | int i; |
305 | 292 | ||
306 | if (copy_from_user(&res, argp, sizeof(res))) | 293 | if (res->count >= DRM_RESERVED_CONTEXTS) { |
307 | return -EFAULT; | ||
308 | |||
309 | if (res.count >= DRM_RESERVED_CONTEXTS) { | ||
310 | memset(&ctx, 0, sizeof(ctx)); | 294 | memset(&ctx, 0, sizeof(ctx)); |
311 | for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { | 295 | for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { |
312 | ctx.handle = i; | 296 | ctx.handle = i; |
313 | if (copy_to_user(&res.contexts[i], &ctx, sizeof(ctx))) | 297 | if (copy_to_user(&res->contexts[i], &ctx, sizeof(ctx))) |
314 | return -EFAULT; | 298 | return -EFAULT; |
315 | } | 299 | } |
316 | } | 300 | } |
317 | res.count = DRM_RESERVED_CONTEXTS; | 301 | res->count = DRM_RESERVED_CONTEXTS; |
318 | 302 | ||
319 | if (copy_to_user(argp, &res, sizeof(res))) | ||
320 | return -EFAULT; | ||
321 | return 0; | 303 | return 0; |
322 | } | 304 | } |
323 | 305 | ||
@@ -332,32 +314,27 @@ int drm_resctx(struct inode *inode, struct drm_file *file_priv, | |||
332 | * | 314 | * |
333 | * Get a new handle for the context and copy to userspace. | 315 | * Get a new handle for the context and copy to userspace. |
334 | */ | 316 | */ |
335 | int drm_addctx(struct inode *inode, struct drm_file *file_priv, | 317 | int drm_addctx(struct drm_device *dev, void *data, |
336 | unsigned int cmd, unsigned long arg) | 318 | struct drm_file *file_priv) |
337 | { | 319 | { |
338 | struct drm_device *dev = file_priv->head->dev; | ||
339 | struct drm_ctx_list *ctx_entry; | 320 | struct drm_ctx_list *ctx_entry; |
340 | struct drm_ctx __user *argp = (void __user *)arg; | 321 | struct drm_ctx *ctx = data; |
341 | struct drm_ctx ctx; | ||
342 | |||
343 | if (copy_from_user(&ctx, argp, sizeof(ctx))) | ||
344 | return -EFAULT; | ||
345 | 322 | ||
346 | ctx.handle = drm_ctxbitmap_next(dev); | 323 | ctx->handle = drm_ctxbitmap_next(dev); |
347 | if (ctx.handle == DRM_KERNEL_CONTEXT) { | 324 | if (ctx->handle == DRM_KERNEL_CONTEXT) { |
348 | /* Skip kernel's context and get a new one. */ | 325 | /* Skip kernel's context and get a new one. */ |
349 | ctx.handle = drm_ctxbitmap_next(dev); | 326 | ctx->handle = drm_ctxbitmap_next(dev); |
350 | } | 327 | } |
351 | DRM_DEBUG("%d\n", ctx.handle); | 328 | DRM_DEBUG("%d\n", ctx->handle); |
352 | if (ctx.handle == -1) { | 329 | if (ctx->handle == -1) { |
353 | DRM_DEBUG("Not enough free contexts.\n"); | 330 | DRM_DEBUG("Not enough free contexts.\n"); |
354 | /* Should this return -EBUSY instead? */ | 331 | /* Should this return -EBUSY instead? */ |
355 | return -ENOMEM; | 332 | return -ENOMEM; |
356 | } | 333 | } |
357 | 334 | ||
358 | if (ctx.handle != DRM_KERNEL_CONTEXT) { | 335 | if (ctx->handle != DRM_KERNEL_CONTEXT) { |
359 | if (dev->driver->context_ctor) | 336 | if (dev->driver->context_ctor) |
360 | if (!dev->driver->context_ctor(dev, ctx.handle)) { | 337 | if (!dev->driver->context_ctor(dev, ctx->handle)) { |
361 | DRM_DEBUG("Running out of ctxs or memory.\n"); | 338 | DRM_DEBUG("Running out of ctxs or memory.\n"); |
362 | return -ENOMEM; | 339 | return -ENOMEM; |
363 | } | 340 | } |
@@ -370,7 +347,7 @@ int drm_addctx(struct inode *inode, struct drm_file *file_priv, | |||
370 | } | 347 | } |
371 | 348 | ||
372 | INIT_LIST_HEAD(&ctx_entry->head); | 349 | INIT_LIST_HEAD(&ctx_entry->head); |
373 | ctx_entry->handle = ctx.handle; | 350 | ctx_entry->handle = ctx->handle; |
374 | ctx_entry->tag = file_priv; | 351 | ctx_entry->tag = file_priv; |
375 | 352 | ||
376 | mutex_lock(&dev->ctxlist_mutex); | 353 | mutex_lock(&dev->ctxlist_mutex); |
@@ -378,13 +355,10 @@ int drm_addctx(struct inode *inode, struct drm_file *file_priv, | |||
378 | ++dev->ctx_count; | 355 | ++dev->ctx_count; |
379 | mutex_unlock(&dev->ctxlist_mutex); | 356 | mutex_unlock(&dev->ctxlist_mutex); |
380 | 357 | ||
381 | if (copy_to_user(argp, &ctx, sizeof(ctx))) | ||
382 | return -EFAULT; | ||
383 | return 0; | 358 | return 0; |
384 | } | 359 | } |
385 | 360 | ||
386 | int drm_modctx(struct inode *inode, struct drm_file *file_priv, | 361 | int drm_modctx(struct drm_device *dev, void *data, struct drm_file *file_priv) |
387 | unsigned int cmd, unsigned long arg) | ||
388 | { | 362 | { |
389 | /* This does nothing */ | 363 | /* This does nothing */ |
390 | return 0; | 364 | return 0; |
@@ -399,20 +373,13 @@ int drm_modctx(struct inode *inode, struct drm_file *file_priv, | |||
399 | * \param arg user argument pointing to a drm_ctx structure. | 373 | * \param arg user argument pointing to a drm_ctx structure. |
400 | * \return zero on success or a negative number on failure. | 374 | * \return zero on success or a negative number on failure. |
401 | */ | 375 | */ |
402 | int drm_getctx(struct inode *inode, struct drm_file *file_priv, | 376 | int drm_getctx(struct drm_device *dev, void *data, struct drm_file *file_priv) |
403 | unsigned int cmd, unsigned long arg) | ||
404 | { | 377 | { |
405 | struct drm_ctx __user *argp = (void __user *)arg; | 378 | struct drm_ctx *ctx = data; |
406 | struct drm_ctx ctx; | ||
407 | |||
408 | if (copy_from_user(&ctx, argp, sizeof(ctx))) | ||
409 | return -EFAULT; | ||
410 | 379 | ||
411 | /* This is 0, because we don't handle any context flags */ | 380 | /* This is 0, because we don't handle any context flags */ |
412 | ctx.flags = 0; | 381 | ctx->flags = 0; |
413 | 382 | ||
414 | if (copy_to_user(argp, &ctx, sizeof(ctx))) | ||
415 | return -EFAULT; | ||
416 | return 0; | 383 | return 0; |
417 | } | 384 | } |
418 | 385 | ||
@@ -427,17 +394,13 @@ int drm_getctx(struct inode *inode, struct drm_file *file_priv, | |||
427 | * | 394 | * |
428 | * Calls context_switch(). | 395 | * Calls context_switch(). |
429 | */ | 396 | */ |
430 | int drm_switchctx(struct inode *inode, struct drm_file *file_priv, | 397 | int drm_switchctx(struct drm_device *dev, void *data, |
431 | unsigned int cmd, unsigned long arg) | 398 | struct drm_file *file_priv) |
432 | { | 399 | { |
433 | struct drm_device *dev = file_priv->head->dev; | 400 | struct drm_ctx *ctx = data; |
434 | struct drm_ctx ctx; | ||
435 | 401 | ||
436 | if (copy_from_user(&ctx, (struct drm_ctx __user *) arg, sizeof(ctx))) | 402 | DRM_DEBUG("%d\n", ctx->handle); |
437 | return -EFAULT; | 403 | return drm_context_switch(dev, dev->last_context, ctx->handle); |
438 | |||
439 | DRM_DEBUG("%d\n", ctx.handle); | ||
440 | return drm_context_switch(dev, dev->last_context, ctx.handle); | ||
441 | } | 404 | } |
442 | 405 | ||
443 | /** | 406 | /** |
@@ -451,17 +414,13 @@ int drm_switchctx(struct inode *inode, struct drm_file *file_priv, | |||
451 | * | 414 | * |
452 | * Calls context_switch_complete(). | 415 | * Calls context_switch_complete(). |
453 | */ | 416 | */ |
454 | int drm_newctx(struct inode *inode, struct drm_file *file_priv, | 417 | int drm_newctx(struct drm_device *dev, void *data, |
455 | unsigned int cmd, unsigned long arg) | 418 | struct drm_file *file_priv) |
456 | { | 419 | { |
457 | struct drm_device *dev = file_priv->head->dev; | 420 | struct drm_ctx *ctx = data; |
458 | struct drm_ctx ctx; | ||
459 | 421 | ||
460 | if (copy_from_user(&ctx, (struct drm_ctx __user *) arg, sizeof(ctx))) | 422 | DRM_DEBUG("%d\n", ctx->handle); |
461 | return -EFAULT; | 423 | drm_context_switch_complete(dev, ctx->handle); |
462 | |||
463 | DRM_DEBUG("%d\n", ctx.handle); | ||
464 | drm_context_switch_complete(dev, ctx.handle); | ||
465 | 424 | ||
466 | return 0; | 425 | return 0; |
467 | } | 426 | } |
@@ -477,23 +436,19 @@ int drm_newctx(struct inode *inode, struct drm_file *file_priv, | |||
477 | * | 436 | * |
478 | * If not the special kernel context, calls ctxbitmap_free() to free the specified context. | 437 | * If not the special kernel context, calls ctxbitmap_free() to free the specified context. |
479 | */ | 438 | */ |
480 | int drm_rmctx(struct inode *inode, struct drm_file *file_priv, | 439 | int drm_rmctx(struct drm_device *dev, void *data, |
481 | unsigned int cmd, unsigned long arg) | 440 | struct drm_file *file_priv) |
482 | { | 441 | { |
483 | struct drm_device *dev = file_priv->head->dev; | 442 | struct drm_ctx *ctx = data; |
484 | struct drm_ctx ctx; | ||
485 | |||
486 | if (copy_from_user(&ctx, (struct drm_ctx __user *) arg, sizeof(ctx))) | ||
487 | return -EFAULT; | ||
488 | 443 | ||
489 | DRM_DEBUG("%d\n", ctx.handle); | 444 | DRM_DEBUG("%d\n", ctx->handle); |
490 | if (ctx.handle == DRM_KERNEL_CONTEXT + 1) { | 445 | if (ctx->handle == DRM_KERNEL_CONTEXT + 1) { |
491 | file_priv->remove_auth_on_close = 1; | 446 | file_priv->remove_auth_on_close = 1; |
492 | } | 447 | } |
493 | if (ctx.handle != DRM_KERNEL_CONTEXT) { | 448 | if (ctx->handle != DRM_KERNEL_CONTEXT) { |
494 | if (dev->driver->context_dtor) | 449 | if (dev->driver->context_dtor) |
495 | dev->driver->context_dtor(dev, ctx.handle); | 450 | dev->driver->context_dtor(dev, ctx->handle); |
496 | drm_ctxbitmap_free(dev, ctx.handle); | 451 | drm_ctxbitmap_free(dev, ctx->handle); |
497 | } | 452 | } |
498 | 453 | ||
499 | mutex_lock(&dev->ctxlist_mutex); | 454 | mutex_lock(&dev->ctxlist_mutex); |
@@ -501,7 +456,7 @@ int drm_rmctx(struct inode *inode, struct drm_file *file_priv, | |||
501 | struct drm_ctx_list *pos, *n; | 456 | struct drm_ctx_list *pos, *n; |
502 | 457 | ||
503 | list_for_each_entry_safe(pos, n, &dev->ctxlist, head) { | 458 | list_for_each_entry_safe(pos, n, &dev->ctxlist, head) { |
504 | if (pos->handle == ctx.handle) { | 459 | if (pos->handle == ctx->handle) { |
505 | list_del(&pos->head); | 460 | list_del(&pos->head); |
506 | drm_free(pos, sizeof(*pos), DRM_MEM_CTXLIST); | 461 | drm_free(pos, sizeof(*pos), DRM_MEM_CTXLIST); |
507 | --dev->ctx_count; | 462 | --dev->ctx_count; |
diff --git a/drivers/char/drm/drm_drawable.c b/drivers/char/drm/drm_drawable.c index 2787c9a3ab44..1839c57663c5 100644 --- a/drivers/char/drm/drm_drawable.c +++ b/drivers/char/drm/drm_drawable.c | |||
@@ -40,11 +40,10 @@ | |||
40 | /** | 40 | /** |
41 | * Allocate drawable ID and memory to store information about it. | 41 | * Allocate drawable ID and memory to store information about it. |
42 | */ | 42 | */ |
43 | int drm_adddraw(DRM_IOCTL_ARGS) | 43 | int drm_adddraw(struct drm_device *dev, void *data, struct drm_file *file_priv) |
44 | { | 44 | { |
45 | DRM_DEVICE; | ||
46 | unsigned long irqflags; | 45 | unsigned long irqflags; |
47 | struct drm_draw draw; | 46 | struct drm_draw *draw = data; |
48 | int new_id = 0; | 47 | int new_id = 0; |
49 | int ret; | 48 | int ret; |
50 | 49 | ||
@@ -63,11 +62,9 @@ again: | |||
63 | 62 | ||
64 | spin_unlock_irqrestore(&dev->drw_lock, irqflags); | 63 | spin_unlock_irqrestore(&dev->drw_lock, irqflags); |
65 | 64 | ||
66 | draw.handle = new_id; | 65 | draw->handle = new_id; |
67 | 66 | ||
68 | DRM_DEBUG("%d\n", draw.handle); | 67 | DRM_DEBUG("%d\n", draw->handle); |
69 | |||
70 | DRM_COPY_TO_USER_IOCTL((struct drm_draw __user *)data, draw, sizeof(draw)); | ||
71 | 68 | ||
72 | return 0; | 69 | return 0; |
73 | } | 70 | } |
@@ -75,69 +72,61 @@ again: | |||
75 | /** | 72 | /** |
76 | * Free drawable ID and memory to store information about it. | 73 | * Free drawable ID and memory to store information about it. |
77 | */ | 74 | */ |
78 | int drm_rmdraw(DRM_IOCTL_ARGS) | 75 | int drm_rmdraw(struct drm_device *dev, void *data, struct drm_file *file_priv) |
79 | { | 76 | { |
80 | DRM_DEVICE; | 77 | struct drm_draw *draw = data; |
81 | struct drm_draw draw; | ||
82 | unsigned long irqflags; | 78 | unsigned long irqflags; |
83 | 79 | ||
84 | DRM_COPY_FROM_USER_IOCTL(draw, (struct drm_draw __user *) data, | ||
85 | sizeof(draw)); | ||
86 | |||
87 | spin_lock_irqsave(&dev->drw_lock, irqflags); | 80 | spin_lock_irqsave(&dev->drw_lock, irqflags); |
88 | 81 | ||
89 | drm_free(drm_get_drawable_info(dev, draw.handle), | 82 | drm_free(drm_get_drawable_info(dev, draw->handle), |
90 | sizeof(struct drm_drawable_info), DRM_MEM_BUFS); | 83 | sizeof(struct drm_drawable_info), DRM_MEM_BUFS); |
91 | 84 | ||
92 | idr_remove(&dev->drw_idr, draw.handle); | 85 | idr_remove(&dev->drw_idr, draw->handle); |
93 | 86 | ||
94 | spin_unlock_irqrestore(&dev->drw_lock, irqflags); | 87 | spin_unlock_irqrestore(&dev->drw_lock, irqflags); |
95 | DRM_DEBUG("%d\n", draw.handle); | 88 | DRM_DEBUG("%d\n", draw->handle); |
96 | return 0; | 89 | return 0; |
97 | } | 90 | } |
98 | 91 | ||
99 | int drm_update_drawable_info(DRM_IOCTL_ARGS) | 92 | int drm_update_drawable_info(struct drm_device *dev, void *data, struct drm_file *file_priv) |
100 | { | 93 | { |
101 | DRM_DEVICE; | 94 | struct drm_update_draw *update = data; |
102 | struct drm_update_draw update; | ||
103 | unsigned long irqflags; | 95 | unsigned long irqflags; |
104 | struct drm_clip_rect *rects; | 96 | struct drm_clip_rect *rects; |
105 | struct drm_drawable_info *info; | 97 | struct drm_drawable_info *info; |
106 | int err; | 98 | int err; |
107 | 99 | ||
108 | DRM_COPY_FROM_USER_IOCTL(update, (struct drm_update_draw __user *) data, | 100 | info = idr_find(&dev->drw_idr, update->handle); |
109 | sizeof(update)); | ||
110 | |||
111 | info = idr_find(&dev->drw_idr, update.handle); | ||
112 | if (!info) { | 101 | if (!info) { |
113 | info = drm_calloc(1, sizeof(*info), DRM_MEM_BUFS); | 102 | info = drm_calloc(1, sizeof(*info), DRM_MEM_BUFS); |
114 | if (!info) | 103 | if (!info) |
115 | return -ENOMEM; | 104 | return -ENOMEM; |
116 | if (IS_ERR(idr_replace(&dev->drw_idr, info, update.handle))) { | 105 | if (IS_ERR(idr_replace(&dev->drw_idr, info, update->handle))) { |
117 | DRM_ERROR("No such drawable %d\n", update.handle); | 106 | DRM_ERROR("No such drawable %d\n", update->handle); |
118 | drm_free(info, sizeof(*info), DRM_MEM_BUFS); | 107 | drm_free(info, sizeof(*info), DRM_MEM_BUFS); |
119 | return -EINVAL; | 108 | return -EINVAL; |
120 | } | 109 | } |
121 | } | 110 | } |
122 | 111 | ||
123 | switch (update.type) { | 112 | switch (update->type) { |
124 | case DRM_DRAWABLE_CLIPRECTS: | 113 | case DRM_DRAWABLE_CLIPRECTS: |
125 | if (update.num != info->num_rects) { | 114 | if (update->num != info->num_rects) { |
126 | rects = drm_alloc(update.num * sizeof(struct drm_clip_rect), | 115 | rects = drm_alloc(update->num * sizeof(struct drm_clip_rect), |
127 | DRM_MEM_BUFS); | 116 | DRM_MEM_BUFS); |
128 | } else | 117 | } else |
129 | rects = info->rects; | 118 | rects = info->rects; |
130 | 119 | ||
131 | if (update.num && !rects) { | 120 | if (update->num && !rects) { |
132 | DRM_ERROR("Failed to allocate cliprect memory\n"); | 121 | DRM_ERROR("Failed to allocate cliprect memory\n"); |
133 | err = -ENOMEM; | 122 | err = -ENOMEM; |
134 | goto error; | 123 | goto error; |
135 | } | 124 | } |
136 | 125 | ||
137 | if (update.num && DRM_COPY_FROM_USER(rects, | 126 | if (update->num && DRM_COPY_FROM_USER(rects, |
138 | (struct drm_clip_rect __user *) | 127 | (struct drm_clip_rect __user *) |
139 | (unsigned long)update.data, | 128 | (unsigned long)update->data, |
140 | update.num * | 129 | update->num * |
141 | sizeof(*rects))) { | 130 | sizeof(*rects))) { |
142 | DRM_ERROR("Failed to copy cliprects from userspace\n"); | 131 | DRM_ERROR("Failed to copy cliprects from userspace\n"); |
143 | err = -EFAULT; | 132 | err = -EFAULT; |
@@ -152,15 +141,15 @@ int drm_update_drawable_info(DRM_IOCTL_ARGS) | |||
152 | } | 141 | } |
153 | 142 | ||
154 | info->rects = rects; | 143 | info->rects = rects; |
155 | info->num_rects = update.num; | 144 | info->num_rects = update->num; |
156 | 145 | ||
157 | spin_unlock_irqrestore(&dev->drw_lock, irqflags); | 146 | spin_unlock_irqrestore(&dev->drw_lock, irqflags); |
158 | 147 | ||
159 | DRM_DEBUG("Updated %d cliprects for drawable %d\n", | 148 | DRM_DEBUG("Updated %d cliprects for drawable %d\n", |
160 | info->num_rects, update.handle); | 149 | info->num_rects, update->handle); |
161 | break; | 150 | break; |
162 | default: | 151 | default: |
163 | DRM_ERROR("Invalid update type %d\n", update.type); | 152 | DRM_ERROR("Invalid update type %d\n", update->type); |
164 | return -EINVAL; | 153 | return -EINVAL; |
165 | } | 154 | } |
166 | 155 | ||
@@ -168,7 +157,7 @@ int drm_update_drawable_info(DRM_IOCTL_ARGS) | |||
168 | 157 | ||
169 | error: | 158 | error: |
170 | if (rects != info->rects) | 159 | if (rects != info->rects) |
171 | drm_free(rects, update.num * sizeof(struct drm_clip_rect), | 160 | drm_free(rects, update->num * sizeof(struct drm_clip_rect), |
172 | DRM_MEM_BUFS); | 161 | DRM_MEM_BUFS); |
173 | 162 | ||
174 | return err; | 163 | return err; |
diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c index e7809237c53d..72668b15e5ce 100644 --- a/drivers/char/drm/drm_drv.c +++ b/drivers/char/drm/drm_drv.c | |||
@@ -49,73 +49,74 @@ | |||
49 | #include "drmP.h" | 49 | #include "drmP.h" |
50 | #include "drm_core.h" | 50 | #include "drm_core.h" |
51 | 51 | ||
52 | static int drm_version(struct inode *inode, struct drm_file *file_priv, | 52 | static int drm_version(struct drm_device *dev, void *data, |
53 | unsigned int cmd, unsigned long arg); | 53 | struct drm_file *file_priv); |
54 | 54 | ||
55 | /** Ioctl table */ | 55 | /** Ioctl table */ |
56 | static drm_ioctl_desc_t drm_ioctls[] = { | 56 | static struct drm_ioctl_desc drm_ioctls[] = { |
57 | [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = {drm_version, 0}, | 57 | DRM_IOCTL_DEF(DRM_IOCTL_VERSION, drm_version, 0), |
58 | [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = {drm_getunique, 0}, | 58 | DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0), |
59 | [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = {drm_getmagic, 0}, | 59 | DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, 0), |
60 | [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = {drm_irq_by_busid, DRM_MASTER|DRM_ROOT_ONLY}, | 60 | DRM_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_irq_by_busid, DRM_MASTER|DRM_ROOT_ONLY), |
61 | [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = {drm_getmap, 0}, | 61 | DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_getmap, 0), |
62 | [DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = {drm_getclient, 0}, | 62 | DRM_IOCTL_DEF(DRM_IOCTL_GET_CLIENT, drm_getclient, 0), |
63 | [DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = {drm_getstats, 0}, | 63 | DRM_IOCTL_DEF(DRM_IOCTL_GET_STATS, drm_getstats, 0), |
64 | [DRM_IOCTL_NR(DRM_IOCTL_SET_VERSION)] = {drm_setversion, DRM_MASTER|DRM_ROOT_ONLY}, | 64 | DRM_IOCTL_DEF(DRM_IOCTL_SET_VERSION, drm_setversion, DRM_MASTER|DRM_ROOT_ONLY), |
65 | [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = {drm_setunique, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 65 | |
66 | [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = {drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 66 | DRM_IOCTL_DEF(DRM_IOCTL_SET_UNIQUE, drm_setunique, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
67 | [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = {drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 67 | DRM_IOCTL_DEF(DRM_IOCTL_BLOCK, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
68 | [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = {drm_authmagic, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 68 | DRM_IOCTL_DEF(DRM_IOCTL_UNBLOCK, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
69 | 69 | DRM_IOCTL_DEF(DRM_IOCTL_AUTH_MAGIC, drm_authmagic, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), | |
70 | [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = {drm_addmap_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 70 | |
71 | [DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = {drm_rmmap_ioctl, DRM_AUTH}, | 71 | DRM_IOCTL_DEF(DRM_IOCTL_ADD_MAP, drm_addmap_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
72 | 72 | DRM_IOCTL_DEF(DRM_IOCTL_RM_MAP, drm_rmmap_ioctl, DRM_AUTH), | |
73 | [DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = {drm_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 73 | |
74 | [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = {drm_getsareactx, DRM_AUTH}, | 74 | DRM_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
75 | 75 | DRM_IOCTL_DEF(DRM_IOCTL_GET_SAREA_CTX, drm_getsareactx, DRM_AUTH), | |
76 | [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = {drm_addctx, DRM_AUTH|DRM_ROOT_ONLY}, | 76 | |
77 | [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = {drm_rmctx, DRM_AUTH|DRM_ROOT_ONLY}, | 77 | DRM_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_addctx, DRM_AUTH|DRM_ROOT_ONLY), |
78 | [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = {drm_modctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 78 | DRM_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
79 | [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = {drm_getctx, DRM_AUTH}, | 79 | DRM_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_modctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
80 | [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = {drm_switchctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 80 | DRM_IOCTL_DEF(DRM_IOCTL_GET_CTX, drm_getctx, DRM_AUTH), |
81 | [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = {drm_newctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 81 | DRM_IOCTL_DEF(DRM_IOCTL_SWITCH_CTX, drm_switchctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
82 | [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = {drm_resctx, DRM_AUTH}, | 82 | DRM_IOCTL_DEF(DRM_IOCTL_NEW_CTX, drm_newctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
83 | 83 | DRM_IOCTL_DEF(DRM_IOCTL_RES_CTX, drm_resctx, DRM_AUTH), | |
84 | [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = {drm_adddraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 84 | |
85 | [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = {drm_rmdraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 85 | DRM_IOCTL_DEF(DRM_IOCTL_ADD_DRAW, drm_adddraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
86 | 86 | DRM_IOCTL_DEF(DRM_IOCTL_RM_DRAW, drm_rmdraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), | |
87 | [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = {drm_lock, DRM_AUTH}, | 87 | |
88 | [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = {drm_unlock, DRM_AUTH}, | 88 | DRM_IOCTL_DEF(DRM_IOCTL_LOCK, drm_lock, DRM_AUTH), |
89 | 89 | DRM_IOCTL_DEF(DRM_IOCTL_UNLOCK, drm_unlock, DRM_AUTH), | |
90 | [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = {drm_noop, DRM_AUTH}, | 90 | |
91 | 91 | DRM_IOCTL_DEF(DRM_IOCTL_FINISH, drm_noop, DRM_AUTH), | |
92 | [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = {drm_addbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 92 | |
93 | [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = {drm_markbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 93 | DRM_IOCTL_DEF(DRM_IOCTL_ADD_BUFS, drm_addbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
94 | [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = {drm_infobufs, DRM_AUTH}, | 94 | DRM_IOCTL_DEF(DRM_IOCTL_MARK_BUFS, drm_markbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
95 | [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = {drm_mapbufs, DRM_AUTH}, | 95 | DRM_IOCTL_DEF(DRM_IOCTL_INFO_BUFS, drm_infobufs, DRM_AUTH), |
96 | [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = {drm_freebufs, DRM_AUTH}, | 96 | DRM_IOCTL_DEF(DRM_IOCTL_MAP_BUFS, drm_mapbufs, DRM_AUTH), |
97 | DRM_IOCTL_DEF(DRM_IOCTL_FREE_BUFS, drm_freebufs, DRM_AUTH), | ||
97 | /* The DRM_IOCTL_DMA ioctl should be defined by the driver. */ | 98 | /* The DRM_IOCTL_DMA ioctl should be defined by the driver. */ |
98 | [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = {NULL, DRM_AUTH}, | 99 | DRM_IOCTL_DEF(DRM_IOCTL_DMA, NULL, DRM_AUTH), |
99 | 100 | ||
100 | [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = {drm_control, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 101 | DRM_IOCTL_DEF(DRM_IOCTL_CONTROL, drm_control, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
101 | 102 | ||
102 | #if __OS_HAS_AGP | 103 | #if __OS_HAS_AGP |
103 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = {drm_agp_acquire_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 104 | DRM_IOCTL_DEF(DRM_IOCTL_AGP_ACQUIRE, drm_agp_acquire_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
104 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = {drm_agp_release_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 105 | DRM_IOCTL_DEF(DRM_IOCTL_AGP_RELEASE, drm_agp_release_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
105 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = {drm_agp_enable_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 106 | DRM_IOCTL_DEF(DRM_IOCTL_AGP_ENABLE, drm_agp_enable_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
106 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = {drm_agp_info_ioctl, DRM_AUTH}, | 107 | DRM_IOCTL_DEF(DRM_IOCTL_AGP_INFO, drm_agp_info_ioctl, DRM_AUTH), |
107 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = {drm_agp_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 108 | DRM_IOCTL_DEF(DRM_IOCTL_AGP_ALLOC, drm_agp_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
108 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = {drm_agp_free_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 109 | DRM_IOCTL_DEF(DRM_IOCTL_AGP_FREE, drm_agp_free_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
109 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = {drm_agp_bind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 110 | DRM_IOCTL_DEF(DRM_IOCTL_AGP_BIND, drm_agp_bind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
110 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = {drm_agp_unbind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 111 | DRM_IOCTL_DEF(DRM_IOCTL_AGP_UNBIND, drm_agp_unbind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
111 | #endif | 112 | #endif |
112 | 113 | ||
113 | [DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = {drm_sg_alloc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 114 | DRM_IOCTL_DEF(DRM_IOCTL_SG_ALLOC, drm_sg_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
114 | [DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = {drm_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 115 | DRM_IOCTL_DEF(DRM_IOCTL_SG_FREE, drm_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
115 | 116 | ||
116 | [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = {drm_wait_vblank, 0}, | 117 | DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank, 0), |
117 | 118 | ||
118 | [DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW)] = {drm_update_drawable_info, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 119 | DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_update_drawable_info, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
119 | }; | 120 | }; |
120 | 121 | ||
121 | #define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls ) | 122 | #define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls ) |
@@ -418,26 +419,19 @@ module_exit(drm_core_exit); | |||
418 | * | 419 | * |
419 | * Fills in the version information in \p arg. | 420 | * Fills in the version information in \p arg. |
420 | */ | 421 | */ |
421 | static int drm_version(struct inode *inode, struct drm_file *file_priv, | 422 | static int drm_version(struct drm_device *dev, void *data, |
422 | unsigned int cmd, unsigned long arg) | 423 | struct drm_file *file_priv) |
423 | { | 424 | { |
424 | struct drm_device *dev = file_priv->head->dev; | 425 | struct drm_version *version = data; |
425 | struct drm_version __user *argp = (void __user *)arg; | ||
426 | struct drm_version version; | ||
427 | int len; | 426 | int len; |
428 | 427 | ||
429 | if (copy_from_user(&version, argp, sizeof(version))) | 428 | version->version_major = dev->driver->major; |
430 | return -EFAULT; | 429 | version->version_minor = dev->driver->minor; |
431 | 430 | version->version_patchlevel = dev->driver->patchlevel; | |
432 | version.version_major = dev->driver->major; | 431 | DRM_COPY(version->name, dev->driver->name); |
433 | version.version_minor = dev->driver->minor; | 432 | DRM_COPY(version->date, dev->driver->date); |
434 | version.version_patchlevel = dev->driver->patchlevel; | 433 | DRM_COPY(version->desc, dev->driver->desc); |
435 | DRM_COPY(version.name, dev->driver->name); | ||
436 | DRM_COPY(version.date, dev->driver->date); | ||
437 | DRM_COPY(version.desc, dev->driver->desc); | ||
438 | 434 | ||
439 | if (copy_to_user(argp, &version, sizeof(version))) | ||
440 | return -EFAULT; | ||
441 | return 0; | 435 | return 0; |
442 | } | 436 | } |
443 | 437 | ||
@@ -458,10 +452,11 @@ int drm_ioctl(struct inode *inode, struct file *filp, | |||
458 | { | 452 | { |
459 | struct drm_file *file_priv = filp->private_data; | 453 | struct drm_file *file_priv = filp->private_data; |
460 | struct drm_device *dev = file_priv->head->dev; | 454 | struct drm_device *dev = file_priv->head->dev; |
461 | drm_ioctl_desc_t *ioctl; | 455 | struct drm_ioctl_desc *ioctl; |
462 | drm_ioctl_t *func; | 456 | drm_ioctl_t *func; |
463 | unsigned int nr = DRM_IOCTL_NR(cmd); | 457 | unsigned int nr = DRM_IOCTL_NR(cmd); |
464 | int retcode = -EINVAL; | 458 | int retcode = -EINVAL; |
459 | char *kdata = NULL; | ||
465 | 460 | ||
466 | atomic_inc(&dev->ioctl_count); | 461 | atomic_inc(&dev->ioctl_count); |
467 | atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]); | 462 | atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]); |
@@ -488,6 +483,7 @@ int drm_ioctl(struct inode *inode, struct file *filp, | |||
488 | if ((nr == DRM_IOCTL_NR(DRM_IOCTL_DMA)) && dev->driver->dma_ioctl) | 483 | if ((nr == DRM_IOCTL_NR(DRM_IOCTL_DMA)) && dev->driver->dma_ioctl) |
489 | func = dev->driver->dma_ioctl; | 484 | func = dev->driver->dma_ioctl; |
490 | 485 | ||
486 | |||
491 | if (!func) { | 487 | if (!func) { |
492 | DRM_DEBUG("no function\n"); | 488 | DRM_DEBUG("no function\n"); |
493 | retcode = -EINVAL; | 489 | retcode = -EINVAL; |
@@ -496,10 +492,31 @@ int drm_ioctl(struct inode *inode, struct file *filp, | |||
496 | ((ioctl->flags & DRM_MASTER) && !file_priv->master)) { | 492 | ((ioctl->flags & DRM_MASTER) && !file_priv->master)) { |
497 | retcode = -EACCES; | 493 | retcode = -EACCES; |
498 | } else { | 494 | } else { |
499 | retcode = func(inode, file_priv, cmd, arg); | 495 | if (cmd & (IOC_IN | IOC_OUT)) { |
496 | kdata = kmalloc(_IOC_SIZE(cmd), GFP_KERNEL); | ||
497 | if (!kdata) | ||
498 | return -ENOMEM; | ||
499 | } | ||
500 | |||
501 | if (cmd & IOC_IN) { | ||
502 | if (copy_from_user(kdata, (void __user *)arg, | ||
503 | _IOC_SIZE(cmd)) != 0) { | ||
504 | retcode = -EACCES; | ||
505 | goto err_i1; | ||
506 | } | ||
507 | } | ||
508 | retcode = func(dev, kdata, file_priv); | ||
509 | |||
510 | if (cmd & IOC_OUT) { | ||
511 | if (copy_to_user((void __user *)arg, kdata, | ||
512 | _IOC_SIZE(cmd)) != 0) | ||
513 | retcode = -EACCES; | ||
514 | } | ||
500 | } | 515 | } |
501 | 516 | ||
502 | err_i1: | 517 | err_i1: |
518 | if (kdata) | ||
519 | kfree(kdata); | ||
503 | atomic_dec(&dev->ioctl_count); | 520 | atomic_dec(&dev->ioctl_count); |
504 | if (retcode) | 521 | if (retcode) |
505 | DRM_DEBUG("ret = %x\n", retcode); | 522 | DRM_DEBUG("ret = %x\n", retcode); |
diff --git a/drivers/char/drm/drm_fops.c b/drivers/char/drm/drm_fops.c index 1100c51aa4d6..f383fc37190c 100644 --- a/drivers/char/drm/drm_fops.c +++ b/drivers/char/drm/drm_fops.c | |||
@@ -343,7 +343,7 @@ int drm_release(struct inode *inode, struct file *filp) | |||
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(file_priv)) { | 346 | if (drm_i_have_hw_lock(dev, file_priv)) { |
347 | dev->driver->reclaim_buffers_locked(dev, file_priv); | 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; |
@@ -383,7 +383,7 @@ int drm_release(struct inode *inode, struct file *filp) | |||
383 | 383 | ||
384 | } | 384 | } |
385 | 385 | ||
386 | if (drm_i_have_hw_lock(file_priv)) { | 386 | if (drm_i_have_hw_lock(dev, 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 | ||
diff --git a/drivers/char/drm/drm_ioctl.c b/drivers/char/drm/drm_ioctl.c index 1b5d0da6566d..d9be14624526 100644 --- a/drivers/char/drm/drm_ioctl.c +++ b/drivers/char/drm/drm_ioctl.c | |||
@@ -49,22 +49,17 @@ | |||
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 | */ |
52 | int drm_getunique(struct inode *inode, struct drm_file *file_priv, | 52 | int drm_getunique(struct drm_device *dev, void *data, |
53 | unsigned int cmd, unsigned long arg) | 53 | struct drm_file *file_priv) |
54 | { | 54 | { |
55 | struct drm_device *dev = file_priv->head->dev; | 55 | struct drm_unique *u = data; |
56 | struct drm_unique __user *argp = (void __user *)arg; | ||
57 | struct drm_unique u; | ||
58 | 56 | ||
59 | if (copy_from_user(&u, argp, sizeof(u))) | 57 | if (u->unique_len >= dev->unique_len) { |
60 | return -EFAULT; | 58 | if (copy_to_user(u->unique, dev->unique, dev->unique_len)) |
61 | if (u.unique_len >= dev->unique_len) { | ||
62 | if (copy_to_user(u.unique, dev->unique, dev->unique_len)) | ||
63 | return -EFAULT; | 59 | return -EFAULT; |
64 | } | 60 | } |
65 | u.unique_len = dev->unique_len; | 61 | u->unique_len = dev->unique_len; |
66 | if (copy_to_user(argp, &u, sizeof(u))) | 62 | |
67 | return -EFAULT; | ||
68 | return 0; | 63 | return 0; |
69 | } | 64 | } |
70 | 65 | ||
@@ -82,27 +77,23 @@ int drm_getunique(struct inode *inode, struct drm_file *file_priv, | |||
82 | * in interface version 1.1 and will return EBUSY when setversion has requested | 77 | * in interface version 1.1 and will return EBUSY when setversion has requested |
83 | * version 1.1 or greater. | 78 | * version 1.1 or greater. |
84 | */ | 79 | */ |
85 | int drm_setunique(struct inode *inode, struct drm_file *file_priv, | 80 | int drm_setunique(struct drm_device *dev, void *data, |
86 | unsigned int cmd, unsigned long arg) | 81 | struct drm_file *file_priv) |
87 | { | 82 | { |
88 | struct drm_device *dev = file_priv->head->dev; | 83 | struct drm_unique *u = data; |
89 | struct drm_unique u; | ||
90 | int domain, bus, slot, func, ret; | 84 | int domain, bus, slot, func, ret; |
91 | 85 | ||
92 | if (dev->unique_len || dev->unique) | 86 | if (dev->unique_len || dev->unique) |
93 | return -EBUSY; | 87 | return -EBUSY; |
94 | 88 | ||
95 | if (copy_from_user(&u, (struct drm_unique __user *) arg, sizeof(u))) | 89 | if (!u->unique_len || u->unique_len > 1024) |
96 | return -EFAULT; | ||
97 | |||
98 | if (!u.unique_len || u.unique_len > 1024) | ||
99 | return -EINVAL; | 90 | return -EINVAL; |
100 | 91 | ||
101 | dev->unique_len = u.unique_len; | 92 | dev->unique_len = u->unique_len; |
102 | dev->unique = drm_alloc(u.unique_len + 1, DRM_MEM_DRIVER); | 93 | dev->unique = drm_alloc(u->unique_len + 1, DRM_MEM_DRIVER); |
103 | if (!dev->unique) | 94 | if (!dev->unique) |
104 | return -ENOMEM; | 95 | return -ENOMEM; |
105 | if (copy_from_user(dev->unique, u.unique, dev->unique_len)) | 96 | if (copy_from_user(dev->unique, u->unique, dev->unique_len)) |
106 | return -EFAULT; | 97 | return -EFAULT; |
107 | 98 | ||
108 | dev->unique[dev->unique_len] = '\0'; | 99 | dev->unique[dev->unique_len] = '\0'; |
@@ -179,20 +170,16 @@ static int drm_set_busid(struct drm_device * dev) | |||
179 | * Searches for the mapping with the specified offset and copies its information | 170 | * Searches for the mapping with the specified offset and copies its information |
180 | * into userspace | 171 | * into userspace |
181 | */ | 172 | */ |
182 | int drm_getmap(struct inode *inode, struct drm_file *file_priv, | 173 | int drm_getmap(struct drm_device *dev, void *data, |
183 | unsigned int cmd, unsigned long arg) | 174 | struct drm_file *file_priv) |
184 | { | 175 | { |
185 | struct drm_device *dev = file_priv->head->dev; | 176 | struct drm_map *map = data; |
186 | struct drm_map __user *argp = (void __user *)arg; | ||
187 | struct drm_map map; | ||
188 | struct drm_map_list *r_list = NULL; | 177 | struct drm_map_list *r_list = NULL; |
189 | struct list_head *list; | 178 | struct list_head *list; |
190 | int idx; | 179 | int idx; |
191 | int i; | 180 | int i; |
192 | 181 | ||
193 | if (copy_from_user(&map, argp, sizeof(map))) | 182 | idx = map->offset; |
194 | return -EFAULT; | ||
195 | idx = map.offset; | ||
196 | 183 | ||
197 | mutex_lock(&dev->struct_mutex); | 184 | mutex_lock(&dev->struct_mutex); |
198 | if (idx < 0) { | 185 | if (idx < 0) { |
@@ -213,16 +200,14 @@ int drm_getmap(struct inode *inode, struct drm_file *file_priv, | |||
213 | return -EINVAL; | 200 | return -EINVAL; |
214 | } | 201 | } |
215 | 202 | ||
216 | map.offset = r_list->map->offset; | 203 | map->offset = r_list->map->offset; |
217 | map.size = r_list->map->size; | 204 | map->size = r_list->map->size; |
218 | map.type = r_list->map->type; | 205 | map->type = r_list->map->type; |
219 | map.flags = r_list->map->flags; | 206 | map->flags = r_list->map->flags; |
220 | map.handle = (void *)(unsigned long)r_list->user_token; | 207 | map->handle = (void *)(unsigned long) r_list->user_token; |
221 | map.mtrr = r_list->map->mtrr; | 208 | map->mtrr = r_list->map->mtrr; |
222 | mutex_unlock(&dev->struct_mutex); | 209 | mutex_unlock(&dev->struct_mutex); |
223 | 210 | ||
224 | if (copy_to_user(argp, &map, sizeof(map))) | ||
225 | return -EFAULT; | ||
226 | return 0; | 211 | return 0; |
227 | } | 212 | } |
228 | 213 | ||
@@ -239,19 +224,15 @@ int drm_getmap(struct inode *inode, struct drm_file *file_priv, | |||
239 | * Searches for the client with the specified index and copies its information | 224 | * Searches for the client with the specified index and copies its information |
240 | * into userspace | 225 | * into userspace |
241 | */ | 226 | */ |
242 | int drm_getclient(struct inode *inode, struct drm_file *file_priv, | 227 | int drm_getclient(struct drm_device *dev, void *data, |
243 | unsigned int cmd, unsigned long arg) | 228 | struct drm_file *file_priv) |
244 | { | 229 | { |
245 | struct drm_device *dev = file_priv->head->dev; | 230 | struct drm_client *client = data; |
246 | struct drm_client __user *argp = (struct drm_client __user *)arg; | ||
247 | struct drm_client client; | ||
248 | struct drm_file *pt; | 231 | struct drm_file *pt; |
249 | int idx; | 232 | int idx; |
250 | int i; | 233 | int i; |
251 | 234 | ||
252 | if (copy_from_user(&client, argp, sizeof(client))) | 235 | idx = client->idx; |
253 | return -EFAULT; | ||
254 | idx = client.idx; | ||
255 | mutex_lock(&dev->struct_mutex); | 236 | mutex_lock(&dev->struct_mutex); |
256 | 237 | ||
257 | if (list_empty(&dev->filelist)) { | 238 | if (list_empty(&dev->filelist)) { |
@@ -265,15 +246,13 @@ int drm_getclient(struct inode *inode, struct drm_file *file_priv, | |||
265 | break; | 246 | break; |
266 | } | 247 | } |
267 | 248 | ||
268 | client.auth = pt->authenticated; | 249 | client->auth = pt->authenticated; |
269 | client.pid = pt->pid; | 250 | client->pid = pt->pid; |
270 | client.uid = pt->uid; | 251 | client->uid = pt->uid; |
271 | client.magic = pt->magic; | 252 | client->magic = pt->magic; |
272 | client.iocs = pt->ioctl_count; | 253 | client->iocs = pt->ioctl_count; |
273 | mutex_unlock(&dev->struct_mutex); | 254 | mutex_unlock(&dev->struct_mutex); |
274 | 255 | ||
275 | if (copy_to_user(argp, &client, sizeof(client))) | ||
276 | return -EFAULT; | ||
277 | return 0; | 256 | return 0; |
278 | } | 257 | } |
279 | 258 | ||
@@ -287,32 +266,29 @@ int drm_getclient(struct inode *inode, struct drm_file *file_priv, | |||
287 | * | 266 | * |
288 | * \return zero on success or a negative number on failure. | 267 | * \return zero on success or a negative number on failure. |
289 | */ | 268 | */ |
290 | int drm_getstats(struct inode *inode, struct drm_file *file_priv, | 269 | int drm_getstats(struct drm_device *dev, void *data, |
291 | unsigned int cmd, unsigned long arg) | 270 | struct drm_file *file_priv) |
292 | { | 271 | { |
293 | struct drm_device *dev = file_priv->head->dev; | 272 | struct drm_stats *stats = data; |
294 | struct drm_stats stats; | ||
295 | int i; | 273 | int i; |
296 | 274 | ||
297 | memset(&stats, 0, sizeof(stats)); | 275 | memset(stats, 0, sizeof(stats)); |
298 | 276 | ||
299 | mutex_lock(&dev->struct_mutex); | 277 | mutex_lock(&dev->struct_mutex); |
300 | 278 | ||
301 | for (i = 0; i < dev->counters; i++) { | 279 | for (i = 0; i < dev->counters; i++) { |
302 | if (dev->types[i] == _DRM_STAT_LOCK) | 280 | if (dev->types[i] == _DRM_STAT_LOCK) |
303 | stats.data[i].value | 281 | stats->data[i].value = |
304 | = (dev->lock.hw_lock ? dev->lock.hw_lock->lock : 0); | 282 | (dev->lock.hw_lock ? dev->lock.hw_lock->lock : 0); |
305 | else | 283 | else |
306 | stats.data[i].value = atomic_read(&dev->counts[i]); | 284 | stats->data[i].value = atomic_read(&dev->counts[i]); |
307 | stats.data[i].type = dev->types[i]; | 285 | stats->data[i].type = dev->types[i]; |
308 | } | 286 | } |
309 | 287 | ||
310 | stats.count = dev->counters; | 288 | stats->count = dev->counters; |
311 | 289 | ||
312 | mutex_unlock(&dev->struct_mutex); | 290 | mutex_unlock(&dev->struct_mutex); |
313 | 291 | ||
314 | if (copy_to_user((struct drm_stats __user *) arg, &stats, sizeof(stats))) | ||
315 | return -EFAULT; | ||
316 | return 0; | 292 | return 0; |
317 | } | 293 | } |
318 | 294 | ||
@@ -327,57 +303,52 @@ int drm_getstats(struct inode *inode, struct drm_file *file_priv, | |||
327 | * | 303 | * |
328 | * Sets the requested interface version | 304 | * Sets the requested interface version |
329 | */ | 305 | */ |
330 | int drm_setversion(DRM_IOCTL_ARGS) | 306 | int drm_setversion(struct drm_device *dev, void *data, struct drm_file *file_priv) |
331 | { | 307 | { |
332 | DRM_DEVICE; | 308 | struct drm_set_version *sv = data; |
333 | struct drm_set_version sv; | 309 | int if_version, retcode = 0; |
334 | struct drm_set_version retv; | 310 | |
335 | int if_version; | 311 | if (sv->drm_di_major != -1) { |
336 | struct drm_set_version __user *argp = (void __user *)data; | 312 | if (sv->drm_di_major != DRM_IF_MAJOR || |
337 | int ret; | 313 | sv->drm_di_minor < 0 || sv->drm_di_minor > DRM_IF_MINOR) { |
338 | 314 | retcode = -EINVAL; | |
339 | if (copy_from_user(&sv, argp, sizeof(sv))) | 315 | goto done; |
340 | return -EFAULT; | 316 | } |
341 | 317 | if_version = DRM_IF_VERSION(sv->drm_di_major, | |
342 | retv.drm_di_major = DRM_IF_MAJOR; | 318 | sv->drm_di_minor); |
343 | retv.drm_di_minor = DRM_IF_MINOR; | ||
344 | retv.drm_dd_major = dev->driver->major; | ||
345 | retv.drm_dd_minor = dev->driver->minor; | ||
346 | |||
347 | if (copy_to_user(argp, &retv, sizeof(retv))) | ||
348 | return -EFAULT; | ||
349 | |||
350 | if (sv.drm_di_major != -1) { | ||
351 | if (sv.drm_di_major != DRM_IF_MAJOR || | ||
352 | sv.drm_di_minor < 0 || sv.drm_di_minor > DRM_IF_MINOR) | ||
353 | return -EINVAL; | ||
354 | if_version = DRM_IF_VERSION(sv.drm_di_major, sv.drm_di_minor); | ||
355 | dev->if_version = max(if_version, dev->if_version); | 319 | dev->if_version = max(if_version, dev->if_version); |
356 | if (sv.drm_di_minor >= 1) { | 320 | if (sv->drm_di_minor >= 1) { |
357 | /* | 321 | /* |
358 | * Version 1.1 includes tying of DRM to specific device | 322 | * Version 1.1 includes tying of DRM to specific device |
359 | */ | 323 | */ |
360 | ret = drm_set_busid(dev); | 324 | drm_set_busid(dev); |
361 | if (ret) | ||
362 | return ret; | ||
363 | } | 325 | } |
364 | } | 326 | } |
365 | 327 | ||
366 | if (sv.drm_dd_major != -1) { | 328 | if (sv->drm_dd_major != -1) { |
367 | if (sv.drm_dd_major != dev->driver->major || | 329 | if (sv->drm_dd_major != dev->driver->major || |
368 | sv.drm_dd_minor < 0 | 330 | sv->drm_dd_minor < 0 || sv->drm_dd_minor > |
369 | || sv.drm_dd_minor > dev->driver->minor) | 331 | dev->driver->minor) { |
370 | return -EINVAL; | 332 | retcode = -EINVAL; |
333 | goto done; | ||
334 | } | ||
371 | 335 | ||
372 | if (dev->driver->set_version) | 336 | if (dev->driver->set_version) |
373 | dev->driver->set_version(dev, &sv); | 337 | dev->driver->set_version(dev, sv); |
374 | } | 338 | } |
375 | return 0; | 339 | |
340 | done: | ||
341 | sv->drm_di_major = DRM_IF_MAJOR; | ||
342 | sv->drm_di_minor = DRM_IF_MINOR; | ||
343 | sv->drm_dd_major = dev->driver->major; | ||
344 | sv->drm_dd_minor = dev->driver->minor; | ||
345 | |||
346 | return retcode; | ||
376 | } | 347 | } |
377 | 348 | ||
378 | /** No-op ioctl. */ | 349 | /** No-op ioctl. */ |
379 | int drm_noop(struct inode *inode, struct drm_file *file_priv, unsigned int cmd, | 350 | int drm_noop(struct drm_device *dev, void *data, |
380 | unsigned long arg) | 351 | struct drm_file *file_priv) |
381 | { | 352 | { |
382 | DRM_DEBUG("\n"); | 353 | DRM_DEBUG("\n"); |
383 | return 0; | 354 | return 0; |
diff --git a/drivers/char/drm/drm_irq.c b/drivers/char/drm/drm_irq.c index 9fdc2953c73f..05eae63f85ba 100644 --- a/drivers/char/drm/drm_irq.c +++ b/drivers/char/drm/drm_irq.c | |||
@@ -50,29 +50,24 @@ | |||
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 | */ |
53 | int drm_irq_by_busid(struct inode *inode, struct drm_file *file_priv, | 53 | int drm_irq_by_busid(struct drm_device *dev, void *data, |
54 | unsigned int cmd, unsigned long arg) | 54 | struct drm_file *file_priv) |
55 | { | 55 | { |
56 | struct drm_device *dev = file_priv->head->dev; | 56 | struct drm_irq_busid *p = data; |
57 | struct drm_irq_busid __user *argp = (void __user *)arg; | ||
58 | struct drm_irq_busid p; | ||
59 | 57 | ||
60 | if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) | 58 | if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) |
61 | return -EINVAL; | 59 | return -EINVAL; |
62 | 60 | ||
63 | if (copy_from_user(&p, argp, sizeof(p))) | 61 | if ((p->busnum >> 8) != drm_get_pci_domain(dev) || |
64 | return -EFAULT; | 62 | (p->busnum & 0xff) != dev->pdev->bus->number || |
65 | 63 | p->devnum != PCI_SLOT(dev->pdev->devfn) || p->funcnum != PCI_FUNC(dev->pdev->devfn)) | |
66 | if ((p.busnum >> 8) != drm_get_pci_domain(dev) || | ||
67 | (p.busnum & 0xff) != dev->pdev->bus->number || | ||
68 | p.devnum != PCI_SLOT(dev->pdev->devfn) || p.funcnum != PCI_FUNC(dev->pdev->devfn)) | ||
69 | return -EINVAL; | 64 | return -EINVAL; |
70 | 65 | ||
71 | p.irq = dev->irq; | 66 | p->irq = dev->irq; |
67 | |||
68 | DRM_DEBUG("%d:%d:%d => IRQ %d\n", p->busnum, p->devnum, p->funcnum, | ||
69 | p->irq); | ||
72 | 70 | ||
73 | DRM_DEBUG("%d:%d:%d => IRQ %d\n", p.busnum, p.devnum, p.funcnum, p.irq); | ||
74 | if (copy_to_user(argp, &p, sizeof(p))) | ||
75 | return -EFAULT; | ||
76 | return 0; | 71 | return 0; |
77 | } | 72 | } |
78 | 73 | ||
@@ -193,23 +188,20 @@ EXPORT_SYMBOL(drm_irq_uninstall); | |||
193 | * | 188 | * |
194 | * Calls irq_install() or irq_uninstall() according to \p arg. | 189 | * Calls irq_install() or irq_uninstall() according to \p arg. |
195 | */ | 190 | */ |
196 | int drm_control(struct inode *inode, struct drm_file *file_priv, | 191 | int drm_control(struct drm_device *dev, void *data, |
197 | unsigned int cmd, unsigned long arg) | 192 | struct drm_file *file_priv) |
198 | { | 193 | { |
199 | struct drm_device *dev = file_priv->head->dev; | 194 | struct drm_control *ctl = data; |
200 | struct drm_control ctl; | ||
201 | 195 | ||
202 | /* if we haven't irq we fallback for compatibility reasons - this used to be a separate function in drm_dma.h */ | 196 | /* if we haven't irq we fallback for compatibility reasons - this used to be a separate function in drm_dma.h */ |
203 | 197 | ||
204 | if (copy_from_user(&ctl, (struct drm_control __user *) arg, sizeof(ctl))) | ||
205 | return -EFAULT; | ||
206 | 198 | ||
207 | switch (ctl.func) { | 199 | switch (ctl->func) { |
208 | case DRM_INST_HANDLER: | 200 | case DRM_INST_HANDLER: |
209 | if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) | 201 | if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) |
210 | return 0; | 202 | return 0; |
211 | if (dev->if_version < DRM_IF_VERSION(1, 2) && | 203 | if (dev->if_version < DRM_IF_VERSION(1, 2) && |
212 | ctl.irq != dev->irq) | 204 | ctl->irq != dev->irq) |
213 | return -EINVAL; | 205 | return -EINVAL; |
214 | return drm_irq_install(dev); | 206 | return drm_irq_install(dev); |
215 | case DRM_UNINST_HANDLER: | 207 | case DRM_UNINST_HANDLER: |
@@ -240,30 +232,25 @@ int drm_control(struct inode *inode, struct drm_file *file_priv, | |||
240 | * | 232 | * |
241 | * If a signal is not requested, then calls vblank_wait(). | 233 | * If a signal is not requested, then calls vblank_wait(). |
242 | */ | 234 | */ |
243 | int drm_wait_vblank(DRM_IOCTL_ARGS) | 235 | int drm_wait_vblank(struct drm_device *dev, void *data, struct drm_file *file_priv) |
244 | { | 236 | { |
245 | struct drm_device *dev = file_priv->head->dev; | 237 | union drm_wait_vblank *vblwait = data; |
246 | union drm_wait_vblank __user *argp = (void __user *)data; | ||
247 | union drm_wait_vblank vblwait; | ||
248 | struct timeval now; | 238 | struct timeval now; |
249 | int ret = 0; | 239 | int ret = 0; |
250 | unsigned int flags, seq; | 240 | unsigned int flags, seq; |
251 | 241 | ||
252 | if (!dev->irq) | 242 | if ((!dev->irq) || (!dev->irq_enabled)) |
253 | return -EINVAL; | 243 | return -EINVAL; |
254 | 244 | ||
255 | if (copy_from_user(&vblwait, argp, sizeof(vblwait))) | 245 | if (vblwait->request.type & |
256 | return -EFAULT; | ||
257 | |||
258 | if (vblwait.request.type & | ||
259 | ~(_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK)) { | 246 | ~(_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK)) { |
260 | DRM_ERROR("Unsupported type value 0x%x, supported mask 0x%x\n", | 247 | DRM_ERROR("Unsupported type value 0x%x, supported mask 0x%x\n", |
261 | vblwait.request.type, | 248 | vblwait->request.type, |
262 | (_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK)); | 249 | (_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK)); |
263 | return -EINVAL; | 250 | return -EINVAL; |
264 | } | 251 | } |
265 | 252 | ||
266 | flags = vblwait.request.type & _DRM_VBLANK_FLAGS_MASK; | 253 | flags = vblwait->request.type & _DRM_VBLANK_FLAGS_MASK; |
267 | 254 | ||
268 | if (!drm_core_check_feature(dev, (flags & _DRM_VBLANK_SECONDARY) ? | 255 | if (!drm_core_check_feature(dev, (flags & _DRM_VBLANK_SECONDARY) ? |
269 | DRIVER_IRQ_VBL2 : DRIVER_IRQ_VBL)) | 256 | DRIVER_IRQ_VBL2 : DRIVER_IRQ_VBL)) |
@@ -272,10 +259,10 @@ int drm_wait_vblank(DRM_IOCTL_ARGS) | |||
272 | seq = atomic_read((flags & _DRM_VBLANK_SECONDARY) ? &dev->vbl_received2 | 259 | seq = atomic_read((flags & _DRM_VBLANK_SECONDARY) ? &dev->vbl_received2 |
273 | : &dev->vbl_received); | 260 | : &dev->vbl_received); |
274 | 261 | ||
275 | switch (vblwait.request.type & _DRM_VBLANK_TYPES_MASK) { | 262 | switch (vblwait->request.type & _DRM_VBLANK_TYPES_MASK) { |
276 | case _DRM_VBLANK_RELATIVE: | 263 | case _DRM_VBLANK_RELATIVE: |
277 | vblwait.request.sequence += seq; | 264 | vblwait->request.sequence += seq; |
278 | vblwait.request.type &= ~_DRM_VBLANK_RELATIVE; | 265 | vblwait->request.type &= ~_DRM_VBLANK_RELATIVE; |
279 | case _DRM_VBLANK_ABSOLUTE: | 266 | case _DRM_VBLANK_ABSOLUTE: |
280 | break; | 267 | break; |
281 | default: | 268 | default: |
@@ -283,8 +270,8 @@ int drm_wait_vblank(DRM_IOCTL_ARGS) | |||
283 | } | 270 | } |
284 | 271 | ||
285 | if ((flags & _DRM_VBLANK_NEXTONMISS) && | 272 | if ((flags & _DRM_VBLANK_NEXTONMISS) && |
286 | (seq - vblwait.request.sequence) <= (1<<23)) { | 273 | (seq - vblwait->request.sequence) <= (1<<23)) { |
287 | vblwait.request.sequence = seq + 1; | 274 | vblwait->request.sequence = seq + 1; |
288 | } | 275 | } |
289 | 276 | ||
290 | if (flags & _DRM_VBLANK_SIGNAL) { | 277 | if (flags & _DRM_VBLANK_SIGNAL) { |
@@ -300,12 +287,13 @@ int drm_wait_vblank(DRM_IOCTL_ARGS) | |||
300 | * that case | 287 | * that case |
301 | */ | 288 | */ |
302 | list_for_each_entry(vbl_sig, vbl_sigs, head) { | 289 | list_for_each_entry(vbl_sig, vbl_sigs, head) { |
303 | if (vbl_sig->sequence == vblwait.request.sequence | 290 | if (vbl_sig->sequence == vblwait->request.sequence |
304 | && vbl_sig->info.si_signo == vblwait.request.signal | 291 | && vbl_sig->info.si_signo == |
292 | vblwait->request.signal | ||
305 | && vbl_sig->task == current) { | 293 | && vbl_sig->task == current) { |
306 | spin_unlock_irqrestore(&dev->vbl_lock, | 294 | spin_unlock_irqrestore(&dev->vbl_lock, |
307 | irqflags); | 295 | irqflags); |
308 | vblwait.reply.sequence = seq; | 296 | vblwait->reply.sequence = seq; |
309 | goto done; | 297 | goto done; |
310 | } | 298 | } |
311 | } | 299 | } |
@@ -327,8 +315,8 @@ int drm_wait_vblank(DRM_IOCTL_ARGS) | |||
327 | 315 | ||
328 | memset((void *)vbl_sig, 0, sizeof(*vbl_sig)); | 316 | memset((void *)vbl_sig, 0, sizeof(*vbl_sig)); |
329 | 317 | ||
330 | vbl_sig->sequence = vblwait.request.sequence; | 318 | vbl_sig->sequence = vblwait->request.sequence; |
331 | vbl_sig->info.si_signo = vblwait.request.signal; | 319 | vbl_sig->info.si_signo = vblwait->request.signal; |
332 | vbl_sig->task = current; | 320 | vbl_sig->task = current; |
333 | 321 | ||
334 | spin_lock_irqsave(&dev->vbl_lock, irqflags); | 322 | spin_lock_irqsave(&dev->vbl_lock, irqflags); |
@@ -337,25 +325,22 @@ int drm_wait_vblank(DRM_IOCTL_ARGS) | |||
337 | 325 | ||
338 | spin_unlock_irqrestore(&dev->vbl_lock, irqflags); | 326 | spin_unlock_irqrestore(&dev->vbl_lock, irqflags); |
339 | 327 | ||
340 | vblwait.reply.sequence = seq; | 328 | vblwait->reply.sequence = seq; |
341 | } else { | 329 | } else { |
342 | if (flags & _DRM_VBLANK_SECONDARY) { | 330 | if (flags & _DRM_VBLANK_SECONDARY) { |
343 | if (dev->driver->vblank_wait2) | 331 | if (dev->driver->vblank_wait2) |
344 | ret = dev->driver->vblank_wait2(dev, &vblwait.request.sequence); | 332 | ret = dev->driver->vblank_wait2(dev, &vblwait->request.sequence); |
345 | } else if (dev->driver->vblank_wait) | 333 | } else if (dev->driver->vblank_wait) |
346 | ret = | 334 | ret = |
347 | dev->driver->vblank_wait(dev, | 335 | dev->driver->vblank_wait(dev, |
348 | &vblwait.request.sequence); | 336 | &vblwait->request.sequence); |
349 | 337 | ||
350 | do_gettimeofday(&now); | 338 | do_gettimeofday(&now); |
351 | vblwait.reply.tval_sec = now.tv_sec; | 339 | vblwait->reply.tval_sec = now.tv_sec; |
352 | vblwait.reply.tval_usec = now.tv_usec; | 340 | vblwait->reply.tval_usec = now.tv_usec; |
353 | } | 341 | } |
354 | 342 | ||
355 | done: | 343 | done: |
356 | if (copy_to_user(argp, &vblwait, sizeof(vblwait))) | ||
357 | return -EFAULT; | ||
358 | |||
359 | return ret; | 344 | return ret; |
360 | } | 345 | } |
361 | 346 | ||
diff --git a/drivers/char/drm/drm_lock.c b/drivers/char/drm/drm_lock.c index 57c4306f4cb4..c6b73e744d67 100644 --- a/drivers/char/drm/drm_lock.c +++ b/drivers/char/drm/drm_lock.c | |||
@@ -48,31 +48,26 @@ static int drm_notifier(void *priv); | |||
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 | */ |
51 | int drm_lock(struct inode *inode, struct drm_file *file_priv, | 51 | int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv) |
52 | unsigned int cmd, unsigned long arg) | ||
53 | { | 52 | { |
54 | struct drm_device *dev = file_priv->head->dev; | ||
55 | DECLARE_WAITQUEUE(entry, current); | 53 | DECLARE_WAITQUEUE(entry, current); |
56 | struct drm_lock lock; | 54 | struct drm_lock *lock = data; |
57 | int ret = 0; | 55 | int ret = 0; |
58 | 56 | ||
59 | ++file_priv->lock_count; | 57 | ++file_priv->lock_count; |
60 | 58 | ||
61 | if (copy_from_user(&lock, (struct drm_lock __user *) arg, sizeof(lock))) | 59 | if (lock->context == DRM_KERNEL_CONTEXT) { |
62 | return -EFAULT; | ||
63 | |||
64 | if (lock.context == DRM_KERNEL_CONTEXT) { | ||
65 | DRM_ERROR("Process %d using kernel context %d\n", | 60 | DRM_ERROR("Process %d using kernel context %d\n", |
66 | current->pid, lock.context); | 61 | current->pid, lock->context); |
67 | return -EINVAL; | 62 | return -EINVAL; |
68 | } | 63 | } |
69 | 64 | ||
70 | DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n", | 65 | DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n", |
71 | lock.context, current->pid, | 66 | lock->context, current->pid, |
72 | dev->lock.hw_lock->lock, lock.flags); | 67 | dev->lock.hw_lock->lock, lock->flags); |
73 | 68 | ||
74 | if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE)) | 69 | if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE)) |
75 | if (lock.context < 0) | 70 | if (lock->context < 0) |
76 | return -EINVAL; | 71 | return -EINVAL; |
77 | 72 | ||
78 | add_wait_queue(&dev->lock.lock_queue, &entry); | 73 | add_wait_queue(&dev->lock.lock_queue, &entry); |
@@ -86,7 +81,7 @@ int drm_lock(struct inode *inode, struct drm_file *file_priv, | |||
86 | ret = -EINTR; | 81 | ret = -EINTR; |
87 | break; | 82 | break; |
88 | } | 83 | } |
89 | if (drm_lock_take(&dev->lock, lock.context)) { | 84 | if (drm_lock_take(&dev->lock, lock->context)) { |
90 | dev->lock.file_priv = file_priv; | 85 | dev->lock.file_priv = file_priv; |
91 | dev->lock.lock_time = jiffies; | 86 | dev->lock.lock_time = jiffies; |
92 | atomic_inc(&dev->counts[_DRM_STAT_LOCKS]); | 87 | atomic_inc(&dev->counts[_DRM_STAT_LOCKS]); |
@@ -106,7 +101,8 @@ int drm_lock(struct inode *inode, struct drm_file *file_priv, | |||
106 | __set_current_state(TASK_RUNNING); | 101 | __set_current_state(TASK_RUNNING); |
107 | remove_wait_queue(&dev->lock.lock_queue, &entry); | 102 | remove_wait_queue(&dev->lock.lock_queue, &entry); |
108 | 103 | ||
109 | DRM_DEBUG( "%d %s\n", lock.context, ret ? "interrupted" : "has lock" ); | 104 | DRM_DEBUG("%d %s\n", lock->context, |
105 | ret ? "interrupted" : "has lock"); | ||
110 | if (ret) return ret; | 106 | if (ret) return ret; |
111 | 107 | ||
112 | sigemptyset(&dev->sigmask); | 108 | sigemptyset(&dev->sigmask); |
@@ -114,24 +110,26 @@ int drm_lock(struct inode *inode, struct drm_file *file_priv, | |||
114 | sigaddset(&dev->sigmask, SIGTSTP); | 110 | sigaddset(&dev->sigmask, SIGTSTP); |
115 | sigaddset(&dev->sigmask, SIGTTIN); | 111 | sigaddset(&dev->sigmask, SIGTTIN); |
116 | sigaddset(&dev->sigmask, SIGTTOU); | 112 | sigaddset(&dev->sigmask, SIGTTOU); |
117 | dev->sigdata.context = lock.context; | 113 | dev->sigdata.context = lock->context; |
118 | dev->sigdata.lock = dev->lock.hw_lock; | 114 | dev->sigdata.lock = dev->lock.hw_lock; |
119 | block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask); | 115 | block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask); |
120 | 116 | ||
121 | if (dev->driver->dma_ready && (lock.flags & _DRM_LOCK_READY)) | 117 | if (dev->driver->dma_ready && (lock->flags & _DRM_LOCK_READY)) |
122 | dev->driver->dma_ready(dev); | 118 | dev->driver->dma_ready(dev); |
123 | 119 | ||
124 | if (dev->driver->dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT)) { | 120 | if (dev->driver->dma_quiescent && (lock->flags & _DRM_LOCK_QUIESCENT)) |
121 | { | ||
125 | if (dev->driver->dma_quiescent(dev)) { | 122 | if (dev->driver->dma_quiescent(dev)) { |
126 | DRM_DEBUG("%d waiting for DMA quiescent\n", lock.context); | 123 | DRM_DEBUG("%d waiting for DMA quiescent\n", |
124 | lock->context); | ||
127 | return -EBUSY; | 125 | return -EBUSY; |
128 | } | 126 | } |
129 | } | 127 | } |
130 | 128 | ||
131 | if (dev->driver->kernel_context_switch && | 129 | if (dev->driver->kernel_context_switch && |
132 | dev->last_context != lock.context) { | 130 | dev->last_context != lock->context) { |
133 | dev->driver->kernel_context_switch(dev, dev->last_context, | 131 | dev->driver->kernel_context_switch(dev, dev->last_context, |
134 | lock.context); | 132 | lock->context); |
135 | } | 133 | } |
136 | 134 | ||
137 | return 0; | 135 | return 0; |
@@ -148,19 +146,14 @@ int drm_lock(struct inode *inode, struct drm_file *file_priv, | |||
148 | * | 146 | * |
149 | * Transfer and free the lock. | 147 | * Transfer and free the lock. |
150 | */ | 148 | */ |
151 | int drm_unlock(struct inode *inode, struct drm_file *file_priv, | 149 | int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv) |
152 | unsigned int cmd, unsigned long arg) | ||
153 | { | 150 | { |
154 | struct drm_device *dev = file_priv->head->dev; | 151 | struct drm_lock *lock = data; |
155 | struct drm_lock lock; | ||
156 | unsigned long irqflags; | 152 | unsigned long irqflags; |
157 | 153 | ||
158 | if (copy_from_user(&lock, (struct drm_lock __user *) arg, sizeof(lock))) | 154 | if (lock->context == DRM_KERNEL_CONTEXT) { |
159 | return -EFAULT; | ||
160 | |||
161 | if (lock.context == DRM_KERNEL_CONTEXT) { | ||
162 | DRM_ERROR("Process %d using kernel context %d\n", | 155 | DRM_ERROR("Process %d using kernel context %d\n", |
163 | current->pid, lock.context); | 156 | current->pid, lock->context); |
164 | return -EINVAL; | 157 | return -EINVAL; |
165 | } | 158 | } |
166 | 159 | ||
@@ -182,7 +175,7 @@ int drm_unlock(struct inode *inode, struct drm_file *file_priv, | |||
182 | if (dev->driver->kernel_context_switch_unlock) | 175 | if (dev->driver->kernel_context_switch_unlock) |
183 | dev->driver->kernel_context_switch_unlock(dev); | 176 | dev->driver->kernel_context_switch_unlock(dev); |
184 | else { | 177 | else { |
185 | if (drm_lock_free(&dev->lock,lock.context)) { | 178 | if (drm_lock_free(&dev->lock,lock->context)) { |
186 | /* FIXME: Should really bail out here. */ | 179 | /* FIXME: Should really bail out here. */ |
187 | } | 180 | } |
188 | } | 181 | } |
@@ -388,10 +381,8 @@ void drm_idlelock_release(struct drm_lock_data *lock_data) | |||
388 | EXPORT_SYMBOL(drm_idlelock_release); | 381 | EXPORT_SYMBOL(drm_idlelock_release); |
389 | 382 | ||
390 | 383 | ||
391 | int drm_i_have_hw_lock(struct drm_file *file_priv) | 384 | int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv) |
392 | { | 385 | { |
393 | DRM_DEVICE; | ||
394 | |||
395 | return (file_priv->lock_count && dev->lock.hw_lock && | 386 | return (file_priv->lock_count && dev->lock.hw_lock && |
396 | _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) && | 387 | _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) && |
397 | dev->lock.file_priv == file_priv); | 388 | dev->lock.file_priv == file_priv); |
diff --git a/drivers/char/drm/drm_os_linux.h b/drivers/char/drm/drm_os_linux.h index e87dc34a6fbf..114e54e0f61b 100644 --- a/drivers/char/drm/drm_os_linux.h +++ b/drivers/char/drm/drm_os_linux.h | |||
@@ -6,8 +6,6 @@ | |||
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 | /** Ioctl arguments */ | ||
10 | #define DRM_IOCTL_ARGS struct inode *inode, struct drm_file *file_priv, unsigned int cmd, unsigned long data | ||
11 | /** Current process ID */ | 9 | /** Current process ID */ |
12 | #define DRM_CURRENTPID current->pid | 10 | #define DRM_CURRENTPID current->pid |
13 | #define DRM_SUSER(p) capable(CAP_SYS_ADMIN) | 11 | #define DRM_SUSER(p) capable(CAP_SYS_ADMIN) |
@@ -30,8 +28,6 @@ | |||
30 | #define DRM_WRITEMEMORYBARRIER() wmb() | 28 | #define DRM_WRITEMEMORYBARRIER() wmb() |
31 | /** Read/write memory barrier */ | 29 | /** Read/write memory barrier */ |
32 | #define DRM_MEMORYBARRIER() mb() | 30 | #define DRM_MEMORYBARRIER() mb() |
33 | /** DRM device local declaration */ | ||
34 | #define DRM_DEVICE struct drm_device *dev = file_priv->head->dev | ||
35 | 31 | ||
36 | /** IRQ handler arguments and return type and values */ | 32 | /** IRQ handler arguments and return type and values */ |
37 | #define DRM_IRQ_ARGS int irq, void *arg | 33 | #define DRM_IRQ_ARGS int irq, void *arg |
diff --git a/drivers/char/drm/drm_scatter.c b/drivers/char/drm/drm_scatter.c index 0c2188367e69..eb7fa437355e 100644 --- a/drivers/char/drm/drm_scatter.c +++ b/drivers/char/drm/drm_scatter.c | |||
@@ -62,12 +62,8 @@ 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 | ||
65 | int drm_sg_alloc(struct inode *inode, struct drm_file *file_priv, | 65 | int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request) |
66 | unsigned int cmd, unsigned long arg) | ||
67 | { | 66 | { |
68 | struct drm_device *dev = file_priv->head->dev; | ||
69 | struct drm_scatter_gather __user *argp = (void __user *)arg; | ||
70 | struct drm_scatter_gather request; | ||
71 | struct drm_sg_mem *entry; | 67 | struct drm_sg_mem *entry; |
72 | unsigned long pages, i, j; | 68 | unsigned long pages, i, j; |
73 | 69 | ||
@@ -79,17 +75,13 @@ int drm_sg_alloc(struct inode *inode, struct drm_file *file_priv, | |||
79 | if (dev->sg) | 75 | if (dev->sg) |
80 | return -EINVAL; | 76 | return -EINVAL; |
81 | 77 | ||
82 | if (copy_from_user(&request, argp, sizeof(request))) | ||
83 | return -EFAULT; | ||
84 | |||
85 | entry = drm_alloc(sizeof(*entry), DRM_MEM_SGLISTS); | 78 | entry = drm_alloc(sizeof(*entry), DRM_MEM_SGLISTS); |
86 | if (!entry) | 79 | if (!entry) |
87 | return -ENOMEM; | 80 | return -ENOMEM; |
88 | 81 | ||
89 | memset(entry, 0, sizeof(*entry)); | 82 | memset(entry, 0, sizeof(*entry)); |
90 | 83 | pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE; | |
91 | pages = (request.size + PAGE_SIZE - 1) / PAGE_SIZE; | 84 | DRM_DEBUG("sg size=%ld pages=%ld\n", request->size, pages); |
92 | DRM_DEBUG("sg size=%ld pages=%ld\n", request.size, pages); | ||
93 | 85 | ||
94 | entry->pages = pages; | 86 | entry->pages = pages; |
95 | entry->pagelist = drm_alloc(pages * sizeof(*entry->pagelist), | 87 | entry->pagelist = drm_alloc(pages * sizeof(*entry->pagelist), |
@@ -141,12 +133,7 @@ int drm_sg_alloc(struct inode *inode, struct drm_file *file_priv, | |||
141 | SetPageReserved(entry->pagelist[j]); | 133 | SetPageReserved(entry->pagelist[j]); |
142 | } | 134 | } |
143 | 135 | ||
144 | request.handle = entry->handle; | 136 | request->handle = entry->handle; |
145 | |||
146 | if (copy_to_user(argp, &request, sizeof(request))) { | ||
147 | drm_sg_cleanup(entry); | ||
148 | return -EFAULT; | ||
149 | } | ||
150 | 137 | ||
151 | dev->sg = entry; | 138 | dev->sg = entry; |
152 | 139 | ||
@@ -196,26 +183,31 @@ int drm_sg_alloc(struct inode *inode, struct drm_file *file_priv, | |||
196 | drm_sg_cleanup(entry); | 183 | drm_sg_cleanup(entry); |
197 | return -ENOMEM; | 184 | return -ENOMEM; |
198 | } | 185 | } |
186 | EXPORT_SYMBOL(drm_sg_alloc); | ||
187 | |||
199 | 188 | ||
200 | int drm_sg_free(struct inode *inode, struct drm_file *file_priv, | 189 | int drm_sg_alloc_ioctl(struct drm_device *dev, void *data, |
201 | unsigned int cmd, unsigned long arg) | 190 | struct drm_file *file_priv) |
202 | { | 191 | { |
203 | struct drm_device *dev = file_priv->head->dev; | 192 | struct drm_scatter_gather *request = data; |
204 | struct drm_scatter_gather request; | 193 | |
194 | return drm_sg_alloc(dev, request); | ||
195 | |||
196 | } | ||
197 | |||
198 | int drm_sg_free(struct drm_device *dev, void *data, | ||
199 | struct drm_file *file_priv) | ||
200 | { | ||
201 | struct drm_scatter_gather *request = data; | ||
205 | struct drm_sg_mem *entry; | 202 | struct drm_sg_mem *entry; |
206 | 203 | ||
207 | if (!drm_core_check_feature(dev, DRIVER_SG)) | 204 | if (!drm_core_check_feature(dev, DRIVER_SG)) |
208 | return -EINVAL; | 205 | return -EINVAL; |
209 | 206 | ||
210 | if (copy_from_user(&request, | ||
211 | (struct drm_scatter_gather __user *) arg, | ||
212 | sizeof(request))) | ||
213 | return -EFAULT; | ||
214 | |||
215 | entry = dev->sg; | 207 | entry = dev->sg; |
216 | dev->sg = NULL; | 208 | dev->sg = NULL; |
217 | 209 | ||
218 | if (!entry || entry->handle != request.handle) | 210 | if (!entry || entry->handle != request->handle) |
219 | return -EINVAL; | 211 | return -EINVAL; |
220 | 212 | ||
221 | DRM_DEBUG("sg free virtual = %p\n", entry->virtual); | 213 | DRM_DEBUG("sg free virtual = %p\n", entry->virtual); |
diff --git a/drivers/char/drm/i810_dma.c b/drivers/char/drm/i810_dma.c index 3f1aca87432f..8e841bdee6dc 100644 --- a/drivers/char/drm/i810_dma.c +++ b/drivers/char/drm/i810_dma.c | |||
@@ -429,98 +429,29 @@ static int i810_dma_initialize(struct drm_device * dev, | |||
429 | return 0; | 429 | return 0; |
430 | } | 430 | } |
431 | 431 | ||
432 | /* i810 DRM version 1.1 used a smaller init structure with different | 432 | static int i810_dma_init(struct drm_device *dev, void *data, |
433 | * ordering of values than is currently used (drm >= 1.2). There is | 433 | struct drm_file *file_priv) |
434 | * no defined way to detect the XFree version to correct this problem, | ||
435 | * however by checking using this procedure we can detect the correct | ||
436 | * thing to do. | ||
437 | * | ||
438 | * #1 Read the Smaller init structure from user-space | ||
439 | * #2 Verify the overlay_physical is a valid physical address, or NULL | ||
440 | * If it isn't then we have a v1.1 client. Fix up params. | ||
441 | * If it is, then we have a 1.2 client... get the rest of the data. | ||
442 | */ | ||
443 | static int i810_dma_init_compat(drm_i810_init_t * init, unsigned long arg) | ||
444 | { | ||
445 | |||
446 | /* Get v1.1 init data */ | ||
447 | if (copy_from_user(init, (drm_i810_pre12_init_t __user *) arg, | ||
448 | sizeof(drm_i810_pre12_init_t))) { | ||
449 | return -EFAULT; | ||
450 | } | ||
451 | |||
452 | if ((!init->overlay_physical) || (init->overlay_physical > 4096)) { | ||
453 | |||
454 | /* This is a v1.2 client, just get the v1.2 init data */ | ||
455 | DRM_INFO("Using POST v1.2 init.\n"); | ||
456 | if (copy_from_user(init, (drm_i810_init_t __user *) arg, | ||
457 | sizeof(drm_i810_init_t))) { | ||
458 | return -EFAULT; | ||
459 | } | ||
460 | } else { | ||
461 | |||
462 | /* This is a v1.1 client, fix the params */ | ||
463 | DRM_INFO("Using PRE v1.2 init.\n"); | ||
464 | init->pitch_bits = init->h; | ||
465 | init->pitch = init->w; | ||
466 | init->h = init->overlay_physical; | ||
467 | init->w = init->overlay_offset; | ||
468 | init->overlay_physical = 0; | ||
469 | init->overlay_offset = 0; | ||
470 | } | ||
471 | |||
472 | return 0; | ||
473 | } | ||
474 | |||
475 | static int i810_dma_init(struct inode *inode, struct drm_file *file_priv, | ||
476 | unsigned int cmd, unsigned long arg) | ||
477 | { | 434 | { |
478 | struct drm_device *dev = file_priv->head->dev; | ||
479 | drm_i810_private_t *dev_priv; | 435 | drm_i810_private_t *dev_priv; |
480 | drm_i810_init_t init; | 436 | drm_i810_init_t *init = data; |
481 | int retcode = 0; | 437 | int retcode = 0; |
482 | 438 | ||
483 | /* Get only the init func */ | 439 | switch (init->func) { |
484 | if (copy_from_user | ||
485 | (&init, (void __user *)arg, sizeof(drm_i810_init_func_t))) | ||
486 | return -EFAULT; | ||
487 | |||
488 | switch (init.func) { | ||
489 | case I810_INIT_DMA: | ||
490 | /* This case is for backward compatibility. It | ||
491 | * handles XFree 4.1.0 and 4.2.0, and has to | ||
492 | * do some parameter checking as described below. | ||
493 | * It will someday go away. | ||
494 | */ | ||
495 | retcode = i810_dma_init_compat(&init, arg); | ||
496 | if (retcode) | ||
497 | return retcode; | ||
498 | |||
499 | dev_priv = drm_alloc(sizeof(drm_i810_private_t), | ||
500 | DRM_MEM_DRIVER); | ||
501 | if (dev_priv == NULL) | ||
502 | return -ENOMEM; | ||
503 | retcode = i810_dma_initialize(dev, dev_priv, &init); | ||
504 | break; | ||
505 | |||
506 | default: | ||
507 | case I810_INIT_DMA_1_4: | 440 | case I810_INIT_DMA_1_4: |
508 | DRM_INFO("Using v1.4 init.\n"); | 441 | DRM_INFO("Using v1.4 init.\n"); |
509 | if (copy_from_user(&init, (drm_i810_init_t __user *) arg, | ||
510 | sizeof(drm_i810_init_t))) { | ||
511 | return -EFAULT; | ||
512 | } | ||
513 | dev_priv = drm_alloc(sizeof(drm_i810_private_t), | 442 | dev_priv = drm_alloc(sizeof(drm_i810_private_t), |
514 | DRM_MEM_DRIVER); | 443 | DRM_MEM_DRIVER); |
515 | if (dev_priv == NULL) | 444 | if (dev_priv == NULL) |
516 | return -ENOMEM; | 445 | return -ENOMEM; |
517 | retcode = i810_dma_initialize(dev, dev_priv, &init); | 446 | retcode = i810_dma_initialize(dev, dev_priv, init); |
518 | break; | 447 | break; |
519 | 448 | ||
520 | case I810_CLEANUP_DMA: | 449 | case I810_CLEANUP_DMA: |
521 | DRM_INFO("DMA Cleanup\n"); | 450 | DRM_INFO("DMA Cleanup\n"); |
522 | retcode = i810_dma_cleanup(dev); | 451 | retcode = i810_dma_cleanup(dev); |
523 | break; | 452 | break; |
453 | default: | ||
454 | return -EINVAL; | ||
524 | } | 455 | } |
525 | 456 | ||
526 | return retcode; | 457 | return retcode; |
@@ -997,45 +928,38 @@ static void i810_reclaim_buffers(struct drm_device * dev, | |||
997 | } | 928 | } |
998 | } | 929 | } |
999 | 930 | ||
1000 | static int i810_flush_ioctl(struct inode *inode, struct drm_file *file_priv, | 931 | static int i810_flush_ioctl(struct drm_device *dev, void *data, |
1001 | unsigned int cmd, unsigned long arg) | 932 | struct drm_file *file_priv) |
1002 | { | 933 | { |
1003 | struct drm_device *dev = file_priv->head->dev; | ||
1004 | |||
1005 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 934 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1006 | 935 | ||
1007 | i810_flush_queue(dev); | 936 | i810_flush_queue(dev); |
1008 | return 0; | 937 | return 0; |
1009 | } | 938 | } |
1010 | 939 | ||
1011 | static int i810_dma_vertex(struct inode *inode, struct drm_file *file_priv, | 940 | static int i810_dma_vertex(struct drm_device *dev, void *data, |
1012 | unsigned int cmd, unsigned long arg) | 941 | struct drm_file *file_priv) |
1013 | { | 942 | { |
1014 | struct drm_device *dev = file_priv->head->dev; | ||
1015 | struct drm_device_dma *dma = dev->dma; | 943 | struct drm_device_dma *dma = dev->dma; |
1016 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; | 944 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; |
1017 | u32 *hw_status = dev_priv->hw_status_page; | 945 | u32 *hw_status = dev_priv->hw_status_page; |
1018 | drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) | 946 | drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) |
1019 | dev_priv->sarea_priv; | 947 | dev_priv->sarea_priv; |
1020 | drm_i810_vertex_t vertex; | 948 | drm_i810_vertex_t *vertex = data; |
1021 | |||
1022 | if (copy_from_user | ||
1023 | (&vertex, (drm_i810_vertex_t __user *) arg, sizeof(vertex))) | ||
1024 | return -EFAULT; | ||
1025 | 949 | ||
1026 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 950 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1027 | 951 | ||
1028 | DRM_DEBUG("i810 dma vertex, idx %d used %d discard %d\n", | 952 | DRM_DEBUG("i810 dma vertex, idx %d used %d discard %d\n", |
1029 | vertex.idx, vertex.used, vertex.discard); | 953 | vertex->idx, vertex->used, vertex->discard); |
1030 | 954 | ||
1031 | if (vertex.idx < 0 || vertex.idx > dma->buf_count) | 955 | if (vertex->idx < 0 || vertex->idx > dma->buf_count) |
1032 | return -EINVAL; | 956 | return -EINVAL; |
1033 | 957 | ||
1034 | i810_dma_dispatch_vertex(dev, | 958 | i810_dma_dispatch_vertex(dev, |
1035 | dma->buflist[vertex.idx], | 959 | dma->buflist[vertex->idx], |
1036 | vertex.discard, vertex.used); | 960 | vertex->discard, vertex->used); |
1037 | 961 | ||
1038 | atomic_add(vertex.used, &dev->counts[_DRM_STAT_SECONDARY]); | 962 | atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]); |
1039 | atomic_inc(&dev->counts[_DRM_STAT_DMA]); | 963 | atomic_inc(&dev->counts[_DRM_STAT_DMA]); |
1040 | sarea_priv->last_enqueue = dev_priv->counter - 1; | 964 | sarea_priv->last_enqueue = dev_priv->counter - 1; |
1041 | sarea_priv->last_dispatch = (int)hw_status[5]; | 965 | sarea_priv->last_dispatch = (int)hw_status[5]; |
@@ -1043,15 +967,10 @@ static int i810_dma_vertex(struct inode *inode, struct drm_file *file_priv, | |||
1043 | return 0; | 967 | return 0; |
1044 | } | 968 | } |
1045 | 969 | ||
1046 | static int i810_clear_bufs(struct inode *inode, struct drm_file *file_priv, | 970 | static int i810_clear_bufs(struct drm_device *dev, void *data, |
1047 | unsigned int cmd, unsigned long arg) | 971 | struct drm_file *file_priv) |
1048 | { | 972 | { |
1049 | struct drm_device *dev = file_priv->head->dev; | 973 | drm_i810_clear_t *clear = data; |
1050 | drm_i810_clear_t clear; | ||
1051 | |||
1052 | if (copy_from_user | ||
1053 | (&clear, (drm_i810_clear_t __user *) arg, sizeof(clear))) | ||
1054 | return -EFAULT; | ||
1055 | 974 | ||
1056 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 975 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1057 | 976 | ||
@@ -1060,16 +979,14 @@ static int i810_clear_bufs(struct inode *inode, struct drm_file *file_priv, | |||
1060 | return -EINVAL; | 979 | return -EINVAL; |
1061 | } | 980 | } |
1062 | 981 | ||
1063 | i810_dma_dispatch_clear(dev, clear.flags, | 982 | i810_dma_dispatch_clear(dev, clear->flags, |
1064 | clear.clear_color, clear.clear_depth); | 983 | clear->clear_color, clear->clear_depth); |
1065 | return 0; | 984 | return 0; |
1066 | } | 985 | } |
1067 | 986 | ||
1068 | static int i810_swap_bufs(struct inode *inode, struct drm_file *file_priv, | 987 | static int i810_swap_bufs(struct drm_device *dev, void *data, |
1069 | unsigned int cmd, unsigned long arg) | 988 | struct drm_file *file_priv) |
1070 | { | 989 | { |
1071 | struct drm_device *dev = file_priv->head->dev; | ||
1072 | |||
1073 | DRM_DEBUG("i810_swap_bufs\n"); | 990 | DRM_DEBUG("i810_swap_bufs\n"); |
1074 | 991 | ||
1075 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 992 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
@@ -1078,11 +995,9 @@ static int i810_swap_bufs(struct inode *inode, struct drm_file *file_priv, | |||
1078 | return 0; | 995 | return 0; |
1079 | } | 996 | } |
1080 | 997 | ||
1081 | static int i810_getage(struct inode *inode, struct drm_file *file_priv, | 998 | static int i810_getage(struct drm_device *dev, void *data, |
1082 | unsigned int cmd, | 999 | struct drm_file *file_priv) |
1083 | unsigned long arg) | ||
1084 | { | 1000 | { |
1085 | struct drm_device *dev = file_priv->head->dev; | ||
1086 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; | 1001 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; |
1087 | u32 *hw_status = dev_priv->hw_status_page; | 1002 | u32 *hw_status = dev_priv->hw_status_page; |
1088 | drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) | 1003 | drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) |
@@ -1092,45 +1007,39 @@ static int i810_getage(struct inode *inode, struct drm_file *file_priv, | |||
1092 | return 0; | 1007 | return 0; |
1093 | } | 1008 | } |
1094 | 1009 | ||
1095 | static int i810_getbuf(struct inode *inode, struct drm_file *file_priv, | 1010 | static int i810_getbuf(struct drm_device *dev, void *data, |
1096 | unsigned int cmd, unsigned long arg) | 1011 | struct drm_file *file_priv) |
1097 | { | 1012 | { |
1098 | struct drm_device *dev = file_priv->head->dev; | ||
1099 | int retcode = 0; | 1013 | int retcode = 0; |
1100 | drm_i810_dma_t d; | 1014 | drm_i810_dma_t *d = data; |
1101 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; | 1015 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; |
1102 | u32 *hw_status = dev_priv->hw_status_page; | 1016 | u32 *hw_status = dev_priv->hw_status_page; |
1103 | drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) | 1017 | drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) |
1104 | dev_priv->sarea_priv; | 1018 | dev_priv->sarea_priv; |
1105 | 1019 | ||
1106 | if (copy_from_user(&d, (drm_i810_dma_t __user *) arg, sizeof(d))) | ||
1107 | return -EFAULT; | ||
1108 | |||
1109 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1020 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1110 | 1021 | ||
1111 | d.granted = 0; | 1022 | d->granted = 0; |
1112 | 1023 | ||
1113 | retcode = i810_dma_get_buffer(dev, &d, file_priv); | 1024 | retcode = i810_dma_get_buffer(dev, d, file_priv); |
1114 | 1025 | ||
1115 | DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n", | 1026 | DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n", |
1116 | current->pid, retcode, d.granted); | 1027 | current->pid, retcode, d->granted); |
1117 | 1028 | ||
1118 | if (copy_to_user((void __user *) arg, &d, sizeof(d))) | ||
1119 | return -EFAULT; | ||
1120 | sarea_priv->last_dispatch = (int)hw_status[5]; | 1029 | sarea_priv->last_dispatch = (int)hw_status[5]; |
1121 | 1030 | ||
1122 | return retcode; | 1031 | return retcode; |
1123 | } | 1032 | } |
1124 | 1033 | ||
1125 | static int i810_copybuf(struct inode *inode, struct drm_file *file_priv, | 1034 | static int i810_copybuf(struct drm_device *dev, void *data, |
1126 | unsigned int cmd, unsigned long arg) | 1035 | struct drm_file *file_priv) |
1127 | { | 1036 | { |
1128 | /* Never copy - 2.4.x doesn't need it */ | 1037 | /* Never copy - 2.4.x doesn't need it */ |
1129 | return 0; | 1038 | return 0; |
1130 | } | 1039 | } |
1131 | 1040 | ||
1132 | static int i810_docopy(struct inode *inode, struct drm_file *file_priv, | 1041 | static int i810_docopy(struct drm_device *dev, void *data, |
1133 | unsigned int cmd, unsigned long arg) | 1042 | struct drm_file *file_priv) |
1134 | { | 1043 | { |
1135 | /* Never copy - 2.4.x doesn't need it */ | 1044 | /* Never copy - 2.4.x doesn't need it */ |
1136 | return 0; | 1045 | return 0; |
@@ -1196,29 +1105,25 @@ static void i810_dma_dispatch_mc(struct drm_device * dev, struct drm_buf * buf, | |||
1196 | ADVANCE_LP_RING(); | 1105 | ADVANCE_LP_RING(); |
1197 | } | 1106 | } |
1198 | 1107 | ||
1199 | static int i810_dma_mc(struct inode *inode, struct drm_file *file_priv, | 1108 | static int i810_dma_mc(struct drm_device *dev, void *data, |
1200 | unsigned int cmd, unsigned long arg) | 1109 | struct drm_file *file_priv) |
1201 | { | 1110 | { |
1202 | struct drm_device *dev = file_priv->head->dev; | ||
1203 | struct drm_device_dma *dma = dev->dma; | 1111 | struct drm_device_dma *dma = dev->dma; |
1204 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; | 1112 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; |
1205 | u32 *hw_status = dev_priv->hw_status_page; | 1113 | u32 *hw_status = dev_priv->hw_status_page; |
1206 | drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) | 1114 | drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) |
1207 | dev_priv->sarea_priv; | 1115 | dev_priv->sarea_priv; |
1208 | drm_i810_mc_t mc; | 1116 | drm_i810_mc_t *mc = data; |
1209 | |||
1210 | if (copy_from_user(&mc, (drm_i810_mc_t __user *) arg, sizeof(mc))) | ||
1211 | return -EFAULT; | ||
1212 | 1117 | ||
1213 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1118 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1214 | 1119 | ||
1215 | if (mc.idx >= dma->buf_count || mc.idx < 0) | 1120 | if (mc->idx >= dma->buf_count || mc->idx < 0) |
1216 | return -EINVAL; | 1121 | return -EINVAL; |
1217 | 1122 | ||
1218 | i810_dma_dispatch_mc(dev, dma->buflist[mc.idx], mc.used, | 1123 | i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used, |
1219 | mc.last_render); | 1124 | mc->last_render); |
1220 | 1125 | ||
1221 | atomic_add(mc.used, &dev->counts[_DRM_STAT_SECONDARY]); | 1126 | atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]); |
1222 | atomic_inc(&dev->counts[_DRM_STAT_DMA]); | 1127 | atomic_inc(&dev->counts[_DRM_STAT_DMA]); |
1223 | sarea_priv->last_enqueue = dev_priv->counter - 1; | 1128 | sarea_priv->last_enqueue = dev_priv->counter - 1; |
1224 | sarea_priv->last_dispatch = (int)hw_status[5]; | 1129 | sarea_priv->last_dispatch = (int)hw_status[5]; |
@@ -1226,45 +1131,38 @@ static int i810_dma_mc(struct inode *inode, struct drm_file *file_priv, | |||
1226 | return 0; | 1131 | return 0; |
1227 | } | 1132 | } |
1228 | 1133 | ||
1229 | static int i810_rstatus(struct inode *inode, struct drm_file *file_priv, | 1134 | static int i810_rstatus(struct drm_device *dev, void *data, |
1230 | unsigned int cmd, unsigned long arg) | 1135 | struct drm_file *file_priv) |
1231 | { | 1136 | { |
1232 | struct drm_device *dev = file_priv->head->dev; | ||
1233 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; | 1137 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; |
1234 | 1138 | ||
1235 | return (int)(((u32 *) (dev_priv->hw_status_page))[4]); | 1139 | return (int)(((u32 *) (dev_priv->hw_status_page))[4]); |
1236 | } | 1140 | } |
1237 | 1141 | ||
1238 | static int i810_ov0_info(struct inode *inode, struct drm_file *file_priv, | 1142 | static int i810_ov0_info(struct drm_device *dev, void *data, |
1239 | unsigned int cmd, unsigned long arg) | 1143 | struct drm_file *file_priv) |
1240 | { | 1144 | { |
1241 | struct drm_device *dev = file_priv->head->dev; | ||
1242 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; | 1145 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; |
1243 | drm_i810_overlay_t data; | 1146 | drm_i810_overlay_t *ov = data; |
1147 | |||
1148 | ov->offset = dev_priv->overlay_offset; | ||
1149 | ov->physical = dev_priv->overlay_physical; | ||
1244 | 1150 | ||
1245 | data.offset = dev_priv->overlay_offset; | ||
1246 | data.physical = dev_priv->overlay_physical; | ||
1247 | if (copy_to_user | ||
1248 | ((drm_i810_overlay_t __user *) arg, &data, sizeof(data))) | ||
1249 | return -EFAULT; | ||
1250 | return 0; | 1151 | return 0; |
1251 | } | 1152 | } |
1252 | 1153 | ||
1253 | static int i810_fstatus(struct inode *inode, struct drm_file *file_priv, | 1154 | static int i810_fstatus(struct drm_device *dev, void *data, |
1254 | unsigned int cmd, unsigned long arg) | 1155 | struct drm_file *file_priv) |
1255 | { | 1156 | { |
1256 | struct drm_device *dev = file_priv->head->dev; | ||
1257 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; | 1157 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; |
1258 | 1158 | ||
1259 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1159 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1260 | |||
1261 | return I810_READ(0x30008); | 1160 | return I810_READ(0x30008); |
1262 | } | 1161 | } |
1263 | 1162 | ||
1264 | static int i810_ov0_flip(struct inode *inode, struct drm_file *file_priv, | 1163 | static int i810_ov0_flip(struct drm_device *dev, void *data, |
1265 | unsigned int cmd, unsigned long arg) | 1164 | struct drm_file *file_priv) |
1266 | { | 1165 | { |
1267 | struct drm_device *dev = file_priv->head->dev; | ||
1268 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; | 1166 | drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private; |
1269 | 1167 | ||
1270 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1168 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
@@ -1299,10 +1197,9 @@ static int i810_do_cleanup_pageflip(struct drm_device * dev) | |||
1299 | return 0; | 1197 | return 0; |
1300 | } | 1198 | } |
1301 | 1199 | ||
1302 | static int i810_flip_bufs(struct inode *inode, struct drm_file *file_priv, | 1200 | static int i810_flip_bufs(struct drm_device *dev, void *data, |
1303 | unsigned int cmd, unsigned long arg) | 1201 | struct drm_file *file_priv) |
1304 | { | 1202 | { |
1305 | struct drm_device *dev = file_priv->head->dev; | ||
1306 | drm_i810_private_t *dev_priv = dev->dev_private; | 1203 | drm_i810_private_t *dev_priv = dev->dev_private; |
1307 | 1204 | ||
1308 | DRM_DEBUG("%s\n", __FUNCTION__); | 1205 | DRM_DEBUG("%s\n", __FUNCTION__); |
@@ -1355,22 +1252,22 @@ int i810_driver_dma_quiescent(struct drm_device * dev) | |||
1355 | return 0; | 1252 | return 0; |
1356 | } | 1253 | } |
1357 | 1254 | ||
1358 | drm_ioctl_desc_t i810_ioctls[] = { | 1255 | struct drm_ioctl_desc i810_ioctls[] = { |
1359 | [DRM_IOCTL_NR(DRM_I810_INIT)] = {i810_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 1256 | DRM_IOCTL_DEF(DRM_I810_INIT, i810_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
1360 | [DRM_IOCTL_NR(DRM_I810_VERTEX)] = {i810_dma_vertex, DRM_AUTH}, | 1257 | DRM_IOCTL_DEF(DRM_I810_VERTEX, i810_dma_vertex, DRM_AUTH), |
1361 | [DRM_IOCTL_NR(DRM_I810_CLEAR)] = {i810_clear_bufs, DRM_AUTH}, | 1258 | DRM_IOCTL_DEF(DRM_I810_CLEAR, i810_clear_bufs, DRM_AUTH), |
1362 | [DRM_IOCTL_NR(DRM_I810_FLUSH)] = {i810_flush_ioctl, DRM_AUTH}, | 1259 | DRM_IOCTL_DEF(DRM_I810_FLUSH, i810_flush_ioctl, DRM_AUTH), |
1363 | [DRM_IOCTL_NR(DRM_I810_GETAGE)] = {i810_getage, DRM_AUTH}, | 1260 | DRM_IOCTL_DEF(DRM_I810_GETAGE, i810_getage, DRM_AUTH), |
1364 | [DRM_IOCTL_NR(DRM_I810_GETBUF)] = {i810_getbuf, DRM_AUTH}, | 1261 | DRM_IOCTL_DEF(DRM_I810_GETBUF, i810_getbuf, DRM_AUTH), |
1365 | [DRM_IOCTL_NR(DRM_I810_SWAP)] = {i810_swap_bufs, DRM_AUTH}, | 1262 | DRM_IOCTL_DEF(DRM_I810_SWAP, i810_swap_bufs, DRM_AUTH), |
1366 | [DRM_IOCTL_NR(DRM_I810_COPY)] = {i810_copybuf, DRM_AUTH}, | 1263 | DRM_IOCTL_DEF(DRM_I810_COPY, i810_copybuf, DRM_AUTH), |
1367 | [DRM_IOCTL_NR(DRM_I810_DOCOPY)] = {i810_docopy, DRM_AUTH}, | 1264 | DRM_IOCTL_DEF(DRM_I810_DOCOPY, i810_docopy, DRM_AUTH), |
1368 | [DRM_IOCTL_NR(DRM_I810_OV0INFO)] = {i810_ov0_info, DRM_AUTH}, | 1265 | DRM_IOCTL_DEF(DRM_I810_OV0INFO, i810_ov0_info, DRM_AUTH), |
1369 | [DRM_IOCTL_NR(DRM_I810_FSTATUS)] = {i810_fstatus, DRM_AUTH}, | 1266 | DRM_IOCTL_DEF(DRM_I810_FSTATUS, i810_fstatus, DRM_AUTH), |
1370 | [DRM_IOCTL_NR(DRM_I810_OV0FLIP)] = {i810_ov0_flip, DRM_AUTH}, | 1267 | DRM_IOCTL_DEF(DRM_I810_OV0FLIP, i810_ov0_flip, DRM_AUTH), |
1371 | [DRM_IOCTL_NR(DRM_I810_MC)] = {i810_dma_mc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 1268 | DRM_IOCTL_DEF(DRM_I810_MC, i810_dma_mc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
1372 | [DRM_IOCTL_NR(DRM_I810_RSTATUS)] = {i810_rstatus, DRM_AUTH}, | 1269 | DRM_IOCTL_DEF(DRM_I810_RSTATUS, i810_rstatus, DRM_AUTH), |
1373 | [DRM_IOCTL_NR(DRM_I810_FLIP)] = {i810_flip_bufs, DRM_AUTH} | 1270 | DRM_IOCTL_DEF(DRM_I810_FLIP, i810_flip_bufs, DRM_AUTH) |
1374 | }; | 1271 | }; |
1375 | 1272 | ||
1376 | int i810_max_ioctl = DRM_ARRAY_SIZE(i810_ioctls); | 1273 | int i810_max_ioctl = DRM_ARRAY_SIZE(i810_ioctls); |
diff --git a/drivers/char/drm/i810_drv.h b/drivers/char/drm/i810_drv.h index 4095476f0f67..0af45872f67e 100644 --- a/drivers/char/drm/i810_drv.h +++ b/drivers/char/drm/i810_drv.h | |||
@@ -126,7 +126,7 @@ extern void i810_driver_reclaim_buffers_locked(struct drm_device * dev, | |||
126 | struct drm_file *file_priv); | 126 | struct drm_file *file_priv); |
127 | extern int i810_driver_device_is_agp(struct drm_device * dev); | 127 | extern int i810_driver_device_is_agp(struct drm_device * dev); |
128 | 128 | ||
129 | extern drm_ioctl_desc_t i810_ioctls[]; | 129 | extern struct drm_ioctl_desc i810_ioctls[]; |
130 | extern int i810_max_ioctl; | 130 | extern int i810_max_ioctl; |
131 | 131 | ||
132 | #define I810_BASE(reg) ((unsigned long) \ | 132 | #define I810_BASE(reg) ((unsigned long) \ |
diff --git a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c index f314f8709657..43a1f78712d6 100644 --- a/drivers/char/drm/i830_dma.c +++ b/drivers/char/drm/i830_dma.c | |||
@@ -450,24 +450,20 @@ static int i830_dma_initialize(struct drm_device * dev, | |||
450 | return 0; | 450 | return 0; |
451 | } | 451 | } |
452 | 452 | ||
453 | static int i830_dma_init(struct inode *inode, struct drm_file *file_priv, | 453 | static int i830_dma_init(struct drm_device *dev, void *data, |
454 | unsigned int cmd, unsigned long arg) | 454 | struct drm_file *file_priv) |
455 | { | 455 | { |
456 | struct drm_device *dev = file_priv->head->dev; | ||
457 | drm_i830_private_t *dev_priv; | 456 | drm_i830_private_t *dev_priv; |
458 | drm_i830_init_t init; | 457 | drm_i830_init_t *init = data; |
459 | int retcode = 0; | 458 | int retcode = 0; |
460 | 459 | ||
461 | if (copy_from_user(&init, (void *__user)arg, sizeof(init))) | 460 | switch (init->func) { |
462 | return -EFAULT; | ||
463 | |||
464 | switch (init.func) { | ||
465 | case I830_INIT_DMA: | 461 | case I830_INIT_DMA: |
466 | dev_priv = drm_alloc(sizeof(drm_i830_private_t), | 462 | dev_priv = drm_alloc(sizeof(drm_i830_private_t), |
467 | DRM_MEM_DRIVER); | 463 | DRM_MEM_DRIVER); |
468 | if (dev_priv == NULL) | 464 | if (dev_priv == NULL) |
469 | return -ENOMEM; | 465 | return -ENOMEM; |
470 | retcode = i830_dma_initialize(dev, dev_priv, &init); | 466 | retcode = i830_dma_initialize(dev, dev_priv, init); |
471 | break; | 467 | break; |
472 | case I830_CLEANUP_DMA: | 468 | case I830_CLEANUP_DMA: |
473 | retcode = i830_dma_cleanup(dev); | 469 | retcode = i830_dma_cleanup(dev); |
@@ -1276,43 +1272,36 @@ static void i830_reclaim_buffers(struct drm_device * dev, struct drm_file *file_ | |||
1276 | } | 1272 | } |
1277 | } | 1273 | } |
1278 | 1274 | ||
1279 | static int i830_flush_ioctl(struct inode *inode, struct drm_file *file_priv, | 1275 | static int i830_flush_ioctl(struct drm_device *dev, void *data, |
1280 | unsigned int cmd, unsigned long arg) | 1276 | struct drm_file *file_priv) |
1281 | { | 1277 | { |
1282 | struct drm_device *dev = file_priv->head->dev; | ||
1283 | |||
1284 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1278 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1285 | 1279 | ||
1286 | i830_flush_queue(dev); | 1280 | i830_flush_queue(dev); |
1287 | return 0; | 1281 | return 0; |
1288 | } | 1282 | } |
1289 | 1283 | ||
1290 | static int i830_dma_vertex(struct inode *inode, struct drm_file *file_priv, | 1284 | static int i830_dma_vertex(struct drm_device *dev, void *data, |
1291 | unsigned int cmd, unsigned long arg) | 1285 | struct drm_file *file_priv) |
1292 | { | 1286 | { |
1293 | struct drm_device *dev = file_priv->head->dev; | ||
1294 | struct drm_device_dma *dma = dev->dma; | 1287 | struct drm_device_dma *dma = dev->dma; |
1295 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; | 1288 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; |
1296 | u32 *hw_status = dev_priv->hw_status_page; | 1289 | u32 *hw_status = dev_priv->hw_status_page; |
1297 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) | 1290 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) |
1298 | dev_priv->sarea_priv; | 1291 | dev_priv->sarea_priv; |
1299 | drm_i830_vertex_t vertex; | 1292 | drm_i830_vertex_t *vertex = data; |
1300 | |||
1301 | if (copy_from_user | ||
1302 | (&vertex, (drm_i830_vertex_t __user *) arg, sizeof(vertex))) | ||
1303 | return -EFAULT; | ||
1304 | 1293 | ||
1305 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1294 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1306 | 1295 | ||
1307 | DRM_DEBUG("i830 dma vertex, idx %d used %d discard %d\n", | 1296 | DRM_DEBUG("i830 dma vertex, idx %d used %d discard %d\n", |
1308 | vertex.idx, vertex.used, vertex.discard); | 1297 | vertex->idx, vertex->used, vertex->discard); |
1309 | 1298 | ||
1310 | if (vertex.idx < 0 || vertex.idx > dma->buf_count) | 1299 | if (vertex->idx < 0 || vertex->idx > dma->buf_count) |
1311 | return -EINVAL; | 1300 | return -EINVAL; |
1312 | 1301 | ||
1313 | i830_dma_dispatch_vertex(dev, | 1302 | i830_dma_dispatch_vertex(dev, |
1314 | dma->buflist[vertex.idx], | 1303 | dma->buflist[vertex->idx], |
1315 | vertex.discard, vertex.used); | 1304 | vertex->discard, vertex->used); |
1316 | 1305 | ||
1317 | sarea_priv->last_enqueue = dev_priv->counter - 1; | 1306 | sarea_priv->last_enqueue = dev_priv->counter - 1; |
1318 | sarea_priv->last_dispatch = (int)hw_status[5]; | 1307 | sarea_priv->last_dispatch = (int)hw_status[5]; |
@@ -1320,15 +1309,10 @@ static int i830_dma_vertex(struct inode *inode, struct drm_file *file_priv, | |||
1320 | return 0; | 1309 | return 0; |
1321 | } | 1310 | } |
1322 | 1311 | ||
1323 | static int i830_clear_bufs(struct inode *inode, struct drm_file *file_priv, | 1312 | static int i830_clear_bufs(struct drm_device *dev, void *data, |
1324 | unsigned int cmd, unsigned long arg) | 1313 | struct drm_file *file_priv) |
1325 | { | 1314 | { |
1326 | struct drm_device *dev = file_priv->head->dev; | 1315 | drm_i830_clear_t *clear = data; |
1327 | drm_i830_clear_t clear; | ||
1328 | |||
1329 | if (copy_from_user | ||
1330 | (&clear, (drm_i830_clear_t __user *) arg, sizeof(clear))) | ||
1331 | return -EFAULT; | ||
1332 | 1316 | ||
1333 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1317 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1334 | 1318 | ||
@@ -1337,17 +1321,15 @@ static int i830_clear_bufs(struct inode *inode, struct drm_file *file_priv, | |||
1337 | return -EINVAL; | 1321 | return -EINVAL; |
1338 | } | 1322 | } |
1339 | 1323 | ||
1340 | i830_dma_dispatch_clear(dev, clear.flags, | 1324 | i830_dma_dispatch_clear(dev, clear->flags, |
1341 | clear.clear_color, | 1325 | clear->clear_color, |
1342 | clear.clear_depth, clear.clear_depthmask); | 1326 | clear->clear_depth, clear->clear_depthmask); |
1343 | return 0; | 1327 | return 0; |
1344 | } | 1328 | } |
1345 | 1329 | ||
1346 | static int i830_swap_bufs(struct inode *inode, struct drm_file *file_priv, | 1330 | static int i830_swap_bufs(struct drm_device *dev, void *data, |
1347 | unsigned int cmd, unsigned long arg) | 1331 | struct drm_file *file_priv) |
1348 | { | 1332 | { |
1349 | struct drm_device *dev = file_priv->head->dev; | ||
1350 | |||
1351 | DRM_DEBUG("i830_swap_bufs\n"); | 1333 | DRM_DEBUG("i830_swap_bufs\n"); |
1352 | 1334 | ||
1353 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1335 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
@@ -1380,10 +1362,9 @@ static int i830_do_cleanup_pageflip(struct drm_device * dev) | |||
1380 | return 0; | 1362 | return 0; |
1381 | } | 1363 | } |
1382 | 1364 | ||
1383 | static int i830_flip_bufs(struct inode *inode, struct drm_file *file_priv, | 1365 | static int i830_flip_bufs(struct drm_device *dev, void *data, |
1384 | unsigned int cmd, unsigned long arg) | 1366 | struct drm_file *file_priv) |
1385 | { | 1367 | { |
1386 | struct drm_device *dev = file_priv->head->dev; | ||
1387 | drm_i830_private_t *dev_priv = dev->dev_private; | 1368 | drm_i830_private_t *dev_priv = dev->dev_private; |
1388 | 1369 | ||
1389 | DRM_DEBUG("%s\n", __FUNCTION__); | 1370 | DRM_DEBUG("%s\n", __FUNCTION__); |
@@ -1397,10 +1378,9 @@ static int i830_flip_bufs(struct inode *inode, struct drm_file *file_priv, | |||
1397 | return 0; | 1378 | return 0; |
1398 | } | 1379 | } |
1399 | 1380 | ||
1400 | static int i830_getage(struct inode *inode, struct drm_file *file_priv, unsigned int cmd, | 1381 | static int i830_getage(struct drm_device *dev, void *data, |
1401 | unsigned long arg) | 1382 | struct drm_file *file_priv) |
1402 | { | 1383 | { |
1403 | struct drm_device *dev = file_priv->head->dev; | ||
1404 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; | 1384 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; |
1405 | u32 *hw_status = dev_priv->hw_status_page; | 1385 | u32 *hw_status = dev_priv->hw_status_page; |
1406 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) | 1386 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) |
@@ -1410,56 +1390,50 @@ static int i830_getage(struct inode *inode, struct drm_file *file_priv, unsigned | |||
1410 | return 0; | 1390 | return 0; |
1411 | } | 1391 | } |
1412 | 1392 | ||
1413 | static int i830_getbuf(struct inode *inode, struct drm_file *file_priv, | 1393 | static int i830_getbuf(struct drm_device *dev, void *data, |
1414 | unsigned int cmd, unsigned long arg) | 1394 | struct drm_file *file_priv) |
1415 | { | 1395 | { |
1416 | struct drm_device *dev = file_priv->head->dev; | ||
1417 | int retcode = 0; | 1396 | int retcode = 0; |
1418 | drm_i830_dma_t d; | 1397 | drm_i830_dma_t *d = data; |
1419 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; | 1398 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; |
1420 | u32 *hw_status = dev_priv->hw_status_page; | 1399 | u32 *hw_status = dev_priv->hw_status_page; |
1421 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) | 1400 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) |
1422 | dev_priv->sarea_priv; | 1401 | dev_priv->sarea_priv; |
1423 | 1402 | ||
1424 | DRM_DEBUG("getbuf\n"); | 1403 | DRM_DEBUG("getbuf\n"); |
1425 | if (copy_from_user(&d, (drm_i830_dma_t __user *) arg, sizeof(d))) | ||
1426 | return -EFAULT; | ||
1427 | 1404 | ||
1428 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1405 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1429 | 1406 | ||
1430 | d.granted = 0; | 1407 | d->granted = 0; |
1431 | 1408 | ||
1432 | retcode = i830_dma_get_buffer(dev, &d, file_priv); | 1409 | retcode = i830_dma_get_buffer(dev, d, file_priv); |
1433 | 1410 | ||
1434 | DRM_DEBUG("i830_dma: %d returning %d, granted = %d\n", | 1411 | DRM_DEBUG("i830_dma: %d returning %d, granted = %d\n", |
1435 | current->pid, retcode, d.granted); | 1412 | current->pid, retcode, d->granted); |
1436 | 1413 | ||
1437 | if (copy_to_user((void __user *) arg, &d, sizeof(d))) | ||
1438 | return -EFAULT; | ||
1439 | sarea_priv->last_dispatch = (int)hw_status[5]; | 1414 | sarea_priv->last_dispatch = (int)hw_status[5]; |
1440 | 1415 | ||
1441 | return retcode; | 1416 | return retcode; |
1442 | } | 1417 | } |
1443 | 1418 | ||
1444 | static int i830_copybuf(struct inode *inode, | 1419 | static int i830_copybuf(struct drm_device *dev, void *data, |
1445 | struct drm_file *file_priv, unsigned int cmd, unsigned long arg) | 1420 | struct drm_file *file_priv) |
1446 | { | 1421 | { |
1447 | /* Never copy - 2.4.x doesn't need it */ | 1422 | /* Never copy - 2.4.x doesn't need it */ |
1448 | return 0; | 1423 | return 0; |
1449 | } | 1424 | } |
1450 | 1425 | ||
1451 | static int i830_docopy(struct inode *inode, struct drm_file *file_priv, unsigned int cmd, | 1426 | static int i830_docopy(struct drm_device *dev, void *data, |
1452 | unsigned long arg) | 1427 | struct drm_file *file_priv) |
1453 | { | 1428 | { |
1454 | return 0; | 1429 | return 0; |
1455 | } | 1430 | } |
1456 | 1431 | ||
1457 | static int i830_getparam(struct inode *inode, struct drm_file *file_priv, | 1432 | static int i830_getparam(struct drm_device *dev, void *data, |
1458 | unsigned int cmd, unsigned long arg) | 1433 | struct drm_file *file_priv) |
1459 | { | 1434 | { |
1460 | struct drm_device *dev = file_priv->head->dev; | ||
1461 | drm_i830_private_t *dev_priv = dev->dev_private; | 1435 | drm_i830_private_t *dev_priv = dev->dev_private; |
1462 | drm_i830_getparam_t param; | 1436 | drm_i830_getparam_t *param = data; |
1463 | int value; | 1437 | int value; |
1464 | 1438 | ||
1465 | if (!dev_priv) { | 1439 | if (!dev_priv) { |
@@ -1467,11 +1441,7 @@ static int i830_getparam(struct inode *inode, struct drm_file *file_priv, | |||
1467 | return -EINVAL; | 1441 | return -EINVAL; |
1468 | } | 1442 | } |
1469 | 1443 | ||
1470 | if (copy_from_user | 1444 | switch (param->param) { |
1471 | (¶m, (drm_i830_getparam_t __user *) arg, sizeof(param))) | ||
1472 | return -EFAULT; | ||
1473 | |||
1474 | switch (param.param) { | ||
1475 | case I830_PARAM_IRQ_ACTIVE: | 1445 | case I830_PARAM_IRQ_ACTIVE: |
1476 | value = dev->irq_enabled; | 1446 | value = dev->irq_enabled; |
1477 | break; | 1447 | break; |
@@ -1479,7 +1449,7 @@ static int i830_getparam(struct inode *inode, struct drm_file *file_priv, | |||
1479 | return -EINVAL; | 1449 | return -EINVAL; |
1480 | } | 1450 | } |
1481 | 1451 | ||
1482 | if (copy_to_user(param.value, &value, sizeof(int))) { | 1452 | if (copy_to_user(param->value, &value, sizeof(int))) { |
1483 | DRM_ERROR("copy_to_user\n"); | 1453 | DRM_ERROR("copy_to_user\n"); |
1484 | return -EFAULT; | 1454 | return -EFAULT; |
1485 | } | 1455 | } |
@@ -1487,25 +1457,20 @@ static int i830_getparam(struct inode *inode, struct drm_file *file_priv, | |||
1487 | return 0; | 1457 | return 0; |
1488 | } | 1458 | } |
1489 | 1459 | ||
1490 | static int i830_setparam(struct inode *inode, struct drm_file *file_priv, | 1460 | static int i830_setparam(struct drm_device *dev, void *data, |
1491 | unsigned int cmd, unsigned long arg) | 1461 | struct drm_file *file_priv) |
1492 | { | 1462 | { |
1493 | struct drm_device *dev = file_priv->head->dev; | ||
1494 | drm_i830_private_t *dev_priv = dev->dev_private; | 1463 | drm_i830_private_t *dev_priv = dev->dev_private; |
1495 | drm_i830_setparam_t param; | 1464 | drm_i830_setparam_t *param = data; |
1496 | 1465 | ||
1497 | if (!dev_priv) { | 1466 | if (!dev_priv) { |
1498 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); | 1467 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); |
1499 | return -EINVAL; | 1468 | return -EINVAL; |
1500 | } | 1469 | } |
1501 | 1470 | ||
1502 | if (copy_from_user | 1471 | switch (param->param) { |
1503 | (¶m, (drm_i830_setparam_t __user *) arg, sizeof(param))) | ||
1504 | return -EFAULT; | ||
1505 | |||
1506 | switch (param.param) { | ||
1507 | case I830_SETPARAM_USE_MI_BATCHBUFFER_START: | 1472 | case I830_SETPARAM_USE_MI_BATCHBUFFER_START: |
1508 | dev_priv->use_mi_batchbuffer_start = param.value; | 1473 | dev_priv->use_mi_batchbuffer_start = param->value; |
1509 | break; | 1474 | break; |
1510 | default: | 1475 | default: |
1511 | return -EINVAL; | 1476 | return -EINVAL; |
@@ -1552,21 +1517,21 @@ int i830_driver_dma_quiescent(struct drm_device * dev) | |||
1552 | return 0; | 1517 | return 0; |
1553 | } | 1518 | } |
1554 | 1519 | ||
1555 | drm_ioctl_desc_t i830_ioctls[] = { | 1520 | struct drm_ioctl_desc i830_ioctls[] = { |
1556 | [DRM_IOCTL_NR(DRM_I830_INIT)] = {i830_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 1521 | DRM_IOCTL_DEF(DRM_I830_INIT, i830_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
1557 | [DRM_IOCTL_NR(DRM_I830_VERTEX)] = {i830_dma_vertex, DRM_AUTH}, | 1522 | DRM_IOCTL_DEF(DRM_I830_VERTEX, i830_dma_vertex, DRM_AUTH), |
1558 | [DRM_IOCTL_NR(DRM_I830_CLEAR)] = {i830_clear_bufs, DRM_AUTH}, | 1523 | DRM_IOCTL_DEF(DRM_I830_CLEAR, i830_clear_bufs, DRM_AUTH), |
1559 | [DRM_IOCTL_NR(DRM_I830_FLUSH)] = {i830_flush_ioctl, DRM_AUTH}, | 1524 | DRM_IOCTL_DEF(DRM_I830_FLUSH, i830_flush_ioctl, DRM_AUTH), |
1560 | [DRM_IOCTL_NR(DRM_I830_GETAGE)] = {i830_getage, DRM_AUTH}, | 1525 | DRM_IOCTL_DEF(DRM_I830_GETAGE, i830_getage, DRM_AUTH), |
1561 | [DRM_IOCTL_NR(DRM_I830_GETBUF)] = {i830_getbuf, DRM_AUTH}, | 1526 | DRM_IOCTL_DEF(DRM_I830_GETBUF, i830_getbuf, DRM_AUTH), |
1562 | [DRM_IOCTL_NR(DRM_I830_SWAP)] = {i830_swap_bufs, DRM_AUTH}, | 1527 | DRM_IOCTL_DEF(DRM_I830_SWAP, i830_swap_bufs, DRM_AUTH), |
1563 | [DRM_IOCTL_NR(DRM_I830_COPY)] = {i830_copybuf, DRM_AUTH}, | 1528 | DRM_IOCTL_DEF(DRM_I830_COPY, i830_copybuf, DRM_AUTH), |
1564 | [DRM_IOCTL_NR(DRM_I830_DOCOPY)] = {i830_docopy, DRM_AUTH}, | 1529 | DRM_IOCTL_DEF(DRM_I830_DOCOPY, i830_docopy, DRM_AUTH), |
1565 | [DRM_IOCTL_NR(DRM_I830_FLIP)] = {i830_flip_bufs, DRM_AUTH}, | 1530 | DRM_IOCTL_DEF(DRM_I830_FLIP, i830_flip_bufs, DRM_AUTH), |
1566 | [DRM_IOCTL_NR(DRM_I830_IRQ_EMIT)] = {i830_irq_emit, DRM_AUTH}, | 1531 | DRM_IOCTL_DEF(DRM_I830_IRQ_EMIT, i830_irq_emit, DRM_AUTH), |
1567 | [DRM_IOCTL_NR(DRM_I830_IRQ_WAIT)] = {i830_irq_wait, DRM_AUTH}, | 1532 | DRM_IOCTL_DEF(DRM_I830_IRQ_WAIT, i830_irq_wait, DRM_AUTH), |
1568 | [DRM_IOCTL_NR(DRM_I830_GETPARAM)] = {i830_getparam, DRM_AUTH}, | 1533 | DRM_IOCTL_DEF(DRM_I830_GETPARAM, i830_getparam, DRM_AUTH), |
1569 | [DRM_IOCTL_NR(DRM_I830_SETPARAM)] = {i830_setparam, DRM_AUTH} | 1534 | DRM_IOCTL_DEF(DRM_I830_SETPARAM, i830_setparam, DRM_AUTH) |
1570 | }; | 1535 | }; |
1571 | 1536 | ||
1572 | int i830_max_ioctl = DRM_ARRAY_SIZE(i830_ioctls); | 1537 | int i830_max_ioctl = DRM_ARRAY_SIZE(i830_ioctls); |
diff --git a/drivers/char/drm/i830_drv.h b/drivers/char/drm/i830_drv.h index 615bf9f4cb4a..db3a9fa83960 100644 --- a/drivers/char/drm/i830_drv.h +++ b/drivers/char/drm/i830_drv.h | |||
@@ -122,14 +122,14 @@ typedef struct drm_i830_private { | |||
122 | 122 | ||
123 | } drm_i830_private_t; | 123 | } drm_i830_private_t; |
124 | 124 | ||
125 | extern drm_ioctl_desc_t i830_ioctls[]; | 125 | extern struct drm_ioctl_desc i830_ioctls[]; |
126 | extern int i830_max_ioctl; | 126 | extern int i830_max_ioctl; |
127 | 127 | ||
128 | /* i830_irq.c */ | 128 | /* i830_irq.c */ |
129 | extern int i830_irq_emit(struct inode *inode, struct drm_file *file_priv, | 129 | extern int i830_irq_emit(struct drm_device *dev, void *data, |
130 | unsigned int cmd, unsigned long arg); | 130 | struct drm_file *file_priv); |
131 | extern int i830_irq_wait(struct inode *inode, struct drm_file *file_priv, | 131 | extern int i830_irq_wait(struct drm_device *dev, void *data, |
132 | unsigned int cmd, unsigned long arg); | 132 | struct drm_file *file_priv); |
133 | 133 | ||
134 | extern irqreturn_t i830_driver_irq_handler(DRM_IRQ_ARGS); | 134 | extern irqreturn_t i830_driver_irq_handler(DRM_IRQ_ARGS); |
135 | extern void i830_driver_irq_preinstall(struct drm_device * dev); | 135 | extern void i830_driver_irq_preinstall(struct drm_device * dev); |
diff --git a/drivers/char/drm/i830_irq.c b/drivers/char/drm/i830_irq.c index 9c28939e2db3..76403f4b6200 100644 --- a/drivers/char/drm/i830_irq.c +++ b/drivers/char/drm/i830_irq.c | |||
@@ -114,12 +114,11 @@ 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 | */ |
117 | int i830_irq_emit(struct inode *inode, struct drm_file *file_priv, | 117 | int i830_irq_emit(struct drm_device *dev, void *data, |
118 | unsigned int cmd, unsigned long arg) | 118 | struct drm_file *file_priv) |
119 | { | 119 | { |
120 | struct drm_device *dev = file_priv->head->dev; | ||
121 | drm_i830_private_t *dev_priv = dev->dev_private; | 120 | drm_i830_private_t *dev_priv = dev->dev_private; |
122 | drm_i830_irq_emit_t emit; | 121 | drm_i830_irq_emit_t *emit = data; |
123 | int result; | 122 | int result; |
124 | 123 | ||
125 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 124 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
@@ -129,13 +128,9 @@ int i830_irq_emit(struct inode *inode, struct drm_file *file_priv, | |||
129 | return -EINVAL; | 128 | return -EINVAL; |
130 | } | 129 | } |
131 | 130 | ||
132 | if (copy_from_user | ||
133 | (&emit, (drm_i830_irq_emit_t __user *) arg, sizeof(emit))) | ||
134 | return -EFAULT; | ||
135 | |||
136 | result = i830_emit_irq(dev); | 131 | result = i830_emit_irq(dev); |
137 | 132 | ||
138 | if (copy_to_user(emit.irq_seq, &result, sizeof(int))) { | 133 | if (copy_to_user(emit->irq_seq, &result, sizeof(int))) { |
139 | DRM_ERROR("copy_to_user\n"); | 134 | DRM_ERROR("copy_to_user\n"); |
140 | return -EFAULT; | 135 | return -EFAULT; |
141 | } | 136 | } |
@@ -145,23 +140,18 @@ int i830_irq_emit(struct inode *inode, struct drm_file *file_priv, | |||
145 | 140 | ||
146 | /* Doesn't need the hardware lock. | 141 | /* Doesn't need the hardware lock. |
147 | */ | 142 | */ |
148 | int i830_irq_wait(struct inode *inode, struct drm_file *file_priv, | 143 | int i830_irq_wait(struct drm_device *dev, void *data, |
149 | unsigned int cmd, unsigned long arg) | 144 | struct drm_file *file_priv) |
150 | { | 145 | { |
151 | struct drm_device *dev = file_priv->head->dev; | ||
152 | drm_i830_private_t *dev_priv = dev->dev_private; | 146 | drm_i830_private_t *dev_priv = dev->dev_private; |
153 | drm_i830_irq_wait_t irqwait; | 147 | drm_i830_irq_wait_t *irqwait = data; |
154 | 148 | ||
155 | if (!dev_priv) { | 149 | if (!dev_priv) { |
156 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); | 150 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); |
157 | return -EINVAL; | 151 | return -EINVAL; |
158 | } | 152 | } |
159 | 153 | ||
160 | if (copy_from_user(&irqwait, (drm_i830_irq_wait_t __user *) arg, | 154 | return i830_wait_irq(dev, irqwait->irq_seq); |
161 | sizeof(irqwait))) | ||
162 | return -EFAULT; | ||
163 | |||
164 | return i830_wait_irq(dev, irqwait.irq_seq); | ||
165 | } | 155 | } |
166 | 156 | ||
167 | /* drm_dma.h hooks | 157 | /* drm_dma.h hooks |
diff --git a/drivers/char/drm/i915_dma.c b/drivers/char/drm/i915_dma.c index 25d8b2b9524d..e61a43e5b3ac 100644 --- a/drivers/char/drm/i915_dma.c +++ b/drivers/char/drm/i915_dma.c | |||
@@ -251,23 +251,20 @@ static int i915_dma_resume(struct drm_device * dev) | |||
251 | return 0; | 251 | return 0; |
252 | } | 252 | } |
253 | 253 | ||
254 | static int i915_dma_init(DRM_IOCTL_ARGS) | 254 | static int i915_dma_init(struct drm_device *dev, void *data, |
255 | struct drm_file *file_priv) | ||
255 | { | 256 | { |
256 | DRM_DEVICE; | ||
257 | drm_i915_private_t *dev_priv; | 257 | drm_i915_private_t *dev_priv; |
258 | drm_i915_init_t init; | 258 | drm_i915_init_t *init = data; |
259 | int retcode = 0; | 259 | int retcode = 0; |
260 | 260 | ||
261 | DRM_COPY_FROM_USER_IOCTL(init, (drm_i915_init_t __user *) data, | 261 | switch (init->func) { |
262 | sizeof(init)); | ||
263 | |||
264 | switch (init.func) { | ||
265 | case I915_INIT_DMA: | 262 | case I915_INIT_DMA: |
266 | dev_priv = drm_alloc(sizeof(drm_i915_private_t), | 263 | dev_priv = drm_alloc(sizeof(drm_i915_private_t), |
267 | DRM_MEM_DRIVER); | 264 | DRM_MEM_DRIVER); |
268 | if (dev_priv == NULL) | 265 | if (dev_priv == NULL) |
269 | return -ENOMEM; | 266 | return -ENOMEM; |
270 | retcode = i915_initialize(dev, dev_priv, &init); | 267 | retcode = i915_initialize(dev, dev_priv, init); |
271 | break; | 268 | break; |
272 | case I915_CLEANUP_DMA: | 269 | case I915_CLEANUP_DMA: |
273 | retcode = i915_dma_cleanup(dev); | 270 | retcode = i915_dma_cleanup(dev); |
@@ -598,23 +595,22 @@ static int i915_quiescent(struct drm_device * dev) | |||
598 | return i915_wait_ring(dev, dev_priv->ring.Size - 8, __FUNCTION__); | 595 | return i915_wait_ring(dev, dev_priv->ring.Size - 8, __FUNCTION__); |
599 | } | 596 | } |
600 | 597 | ||
601 | static int i915_flush_ioctl(DRM_IOCTL_ARGS) | 598 | static int i915_flush_ioctl(struct drm_device *dev, void *data, |
599 | struct drm_file *file_priv) | ||
602 | { | 600 | { |
603 | DRM_DEVICE; | ||
604 | |||
605 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 601 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
606 | 602 | ||
607 | return i915_quiescent(dev); | 603 | return i915_quiescent(dev); |
608 | } | 604 | } |
609 | 605 | ||
610 | static int i915_batchbuffer(DRM_IOCTL_ARGS) | 606 | static int i915_batchbuffer(struct drm_device *dev, void *data, |
607 | struct drm_file *file_priv) | ||
611 | { | 608 | { |
612 | DRM_DEVICE; | ||
613 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; | 609 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
614 | u32 *hw_status = dev_priv->hw_status_page; | 610 | u32 *hw_status = dev_priv->hw_status_page; |
615 | drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *) | 611 | drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *) |
616 | dev_priv->sarea_priv; | 612 | dev_priv->sarea_priv; |
617 | drm_i915_batchbuffer_t batch; | 613 | drm_i915_batchbuffer_t *batch = data; |
618 | int ret; | 614 | int ret; |
619 | 615 | ||
620 | if (!dev_priv->allow_batchbuffer) { | 616 | if (!dev_priv->allow_batchbuffer) { |
@@ -622,52 +618,46 @@ static int i915_batchbuffer(DRM_IOCTL_ARGS) | |||
622 | return -EINVAL; | 618 | return -EINVAL; |
623 | } | 619 | } |
624 | 620 | ||
625 | DRM_COPY_FROM_USER_IOCTL(batch, (drm_i915_batchbuffer_t __user *) data, | ||
626 | sizeof(batch)); | ||
627 | |||
628 | DRM_DEBUG("i915 batchbuffer, start %x used %d cliprects %d\n", | 621 | DRM_DEBUG("i915 batchbuffer, start %x used %d cliprects %d\n", |
629 | batch.start, batch.used, batch.num_cliprects); | 622 | batch->start, batch->used, batch->num_cliprects); |
630 | 623 | ||
631 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 624 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
632 | 625 | ||
633 | if (batch.num_cliprects && DRM_VERIFYAREA_READ(batch.cliprects, | 626 | if (batch->num_cliprects && DRM_VERIFYAREA_READ(batch->cliprects, |
634 | batch.num_cliprects * | 627 | batch->num_cliprects * |
635 | sizeof(struct drm_clip_rect))) | 628 | sizeof(struct drm_clip_rect))) |
636 | return -EFAULT; | 629 | return -EFAULT; |
637 | 630 | ||
638 | ret = i915_dispatch_batchbuffer(dev, &batch); | 631 | ret = i915_dispatch_batchbuffer(dev, batch); |
639 | 632 | ||
640 | sarea_priv->last_dispatch = (int)hw_status[5]; | 633 | sarea_priv->last_dispatch = (int)hw_status[5]; |
641 | return ret; | 634 | return ret; |
642 | } | 635 | } |
643 | 636 | ||
644 | static int i915_cmdbuffer(DRM_IOCTL_ARGS) | 637 | static int i915_cmdbuffer(struct drm_device *dev, void *data, |
638 | struct drm_file *file_priv) | ||
645 | { | 639 | { |
646 | DRM_DEVICE; | ||
647 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; | 640 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
648 | u32 *hw_status = dev_priv->hw_status_page; | 641 | u32 *hw_status = dev_priv->hw_status_page; |
649 | drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *) | 642 | drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *) |
650 | dev_priv->sarea_priv; | 643 | dev_priv->sarea_priv; |
651 | drm_i915_cmdbuffer_t cmdbuf; | 644 | drm_i915_cmdbuffer_t *cmdbuf = data; |
652 | int ret; | 645 | int ret; |
653 | 646 | ||
654 | DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_i915_cmdbuffer_t __user *) data, | ||
655 | sizeof(cmdbuf)); | ||
656 | |||
657 | DRM_DEBUG("i915 cmdbuffer, buf %p sz %d cliprects %d\n", | 647 | DRM_DEBUG("i915 cmdbuffer, buf %p sz %d cliprects %d\n", |
658 | cmdbuf.buf, cmdbuf.sz, cmdbuf.num_cliprects); | 648 | cmdbuf->buf, cmdbuf->sz, cmdbuf->num_cliprects); |
659 | 649 | ||
660 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 650 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
661 | 651 | ||
662 | if (cmdbuf.num_cliprects && | 652 | if (cmdbuf->num_cliprects && |
663 | DRM_VERIFYAREA_READ(cmdbuf.cliprects, | 653 | DRM_VERIFYAREA_READ(cmdbuf->cliprects, |
664 | cmdbuf.num_cliprects * | 654 | cmdbuf->num_cliprects * |
665 | sizeof(struct drm_clip_rect))) { | 655 | sizeof(struct drm_clip_rect))) { |
666 | DRM_ERROR("Fault accessing cliprects\n"); | 656 | DRM_ERROR("Fault accessing cliprects\n"); |
667 | return -EFAULT; | 657 | return -EFAULT; |
668 | } | 658 | } |
669 | 659 | ||
670 | ret = i915_dispatch_cmdbuffer(dev, &cmdbuf); | 660 | ret = i915_dispatch_cmdbuffer(dev, cmdbuf); |
671 | if (ret) { | 661 | if (ret) { |
672 | DRM_ERROR("i915_dispatch_cmdbuffer failed\n"); | 662 | DRM_ERROR("i915_dispatch_cmdbuffer failed\n"); |
673 | return ret; | 663 | return ret; |
@@ -677,10 +667,9 @@ static int i915_cmdbuffer(DRM_IOCTL_ARGS) | |||
677 | return 0; | 667 | return 0; |
678 | } | 668 | } |
679 | 669 | ||
680 | static int i915_flip_bufs(DRM_IOCTL_ARGS) | 670 | static int i915_flip_bufs(struct drm_device *dev, void *data, |
671 | struct drm_file *file_priv) | ||
681 | { | 672 | { |
682 | DRM_DEVICE; | ||
683 | |||
684 | DRM_DEBUG("%s\n", __FUNCTION__); | 673 | DRM_DEBUG("%s\n", __FUNCTION__); |
685 | 674 | ||
686 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 675 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
@@ -688,11 +677,11 @@ static int i915_flip_bufs(DRM_IOCTL_ARGS) | |||
688 | return i915_dispatch_flip(dev); | 677 | return i915_dispatch_flip(dev); |
689 | } | 678 | } |
690 | 679 | ||
691 | static int i915_getparam(DRM_IOCTL_ARGS) | 680 | static int i915_getparam(struct drm_device *dev, void *data, |
681 | struct drm_file *file_priv) | ||
692 | { | 682 | { |
693 | DRM_DEVICE; | ||
694 | drm_i915_private_t *dev_priv = dev->dev_private; | 683 | drm_i915_private_t *dev_priv = dev->dev_private; |
695 | drm_i915_getparam_t param; | 684 | drm_i915_getparam_t *param = data; |
696 | int value; | 685 | int value; |
697 | 686 | ||
698 | if (!dev_priv) { | 687 | if (!dev_priv) { |
@@ -700,10 +689,7 @@ static int i915_getparam(DRM_IOCTL_ARGS) | |||
700 | return -EINVAL; | 689 | return -EINVAL; |
701 | } | 690 | } |
702 | 691 | ||
703 | DRM_COPY_FROM_USER_IOCTL(param, (drm_i915_getparam_t __user *) data, | 692 | switch (param->param) { |
704 | sizeof(param)); | ||
705 | |||
706 | switch (param.param) { | ||
707 | case I915_PARAM_IRQ_ACTIVE: | 693 | case I915_PARAM_IRQ_ACTIVE: |
708 | value = dev->irq ? 1 : 0; | 694 | value = dev->irq ? 1 : 0; |
709 | break; | 695 | break; |
@@ -714,11 +700,11 @@ static int i915_getparam(DRM_IOCTL_ARGS) | |||
714 | value = READ_BREADCRUMB(dev_priv); | 700 | value = READ_BREADCRUMB(dev_priv); |
715 | break; | 701 | break; |
716 | default: | 702 | default: |
717 | DRM_ERROR("Unknown parameter %d\n", param.param); | 703 | DRM_ERROR("Unknown parameter %d\n", param->param); |
718 | return -EINVAL; | 704 | return -EINVAL; |
719 | } | 705 | } |
720 | 706 | ||
721 | if (DRM_COPY_TO_USER(param.value, &value, sizeof(int))) { | 707 | if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) { |
722 | DRM_ERROR("DRM_COPY_TO_USER failed\n"); | 708 | DRM_ERROR("DRM_COPY_TO_USER failed\n"); |
723 | return -EFAULT; | 709 | return -EFAULT; |
724 | } | 710 | } |
@@ -726,56 +712,52 @@ static int i915_getparam(DRM_IOCTL_ARGS) | |||
726 | return 0; | 712 | return 0; |
727 | } | 713 | } |
728 | 714 | ||
729 | static int i915_setparam(DRM_IOCTL_ARGS) | 715 | static int i915_setparam(struct drm_device *dev, void *data, |
716 | struct drm_file *file_priv) | ||
730 | { | 717 | { |
731 | DRM_DEVICE; | ||
732 | drm_i915_private_t *dev_priv = dev->dev_private; | 718 | drm_i915_private_t *dev_priv = dev->dev_private; |
733 | drm_i915_setparam_t param; | 719 | drm_i915_setparam_t *param = data; |
734 | 720 | ||
735 | if (!dev_priv) { | 721 | if (!dev_priv) { |
736 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); | 722 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); |
737 | return -EINVAL; | 723 | return -EINVAL; |
738 | } | 724 | } |
739 | 725 | ||
740 | DRM_COPY_FROM_USER_IOCTL(param, (drm_i915_setparam_t __user *) data, | 726 | switch (param->param) { |
741 | sizeof(param)); | ||
742 | |||
743 | switch (param.param) { | ||
744 | case I915_SETPARAM_USE_MI_BATCHBUFFER_START: | 727 | case I915_SETPARAM_USE_MI_BATCHBUFFER_START: |
745 | if (!IS_I965G(dev)) | 728 | if (!IS_I965G(dev)) |
746 | dev_priv->use_mi_batchbuffer_start = param.value; | 729 | dev_priv->use_mi_batchbuffer_start = param->value; |
747 | break; | 730 | break; |
748 | case I915_SETPARAM_TEX_LRU_LOG_GRANULARITY: | 731 | case I915_SETPARAM_TEX_LRU_LOG_GRANULARITY: |
749 | dev_priv->tex_lru_log_granularity = param.value; | 732 | dev_priv->tex_lru_log_granularity = param->value; |
750 | break; | 733 | break; |
751 | case I915_SETPARAM_ALLOW_BATCHBUFFER: | 734 | case I915_SETPARAM_ALLOW_BATCHBUFFER: |
752 | dev_priv->allow_batchbuffer = param.value; | 735 | dev_priv->allow_batchbuffer = param->value; |
753 | break; | 736 | break; |
754 | default: | 737 | default: |
755 | DRM_ERROR("unknown parameter %d\n", param.param); | 738 | DRM_ERROR("unknown parameter %d\n", param->param); |
756 | return -EINVAL; | 739 | return -EINVAL; |
757 | } | 740 | } |
758 | 741 | ||
759 | return 0; | 742 | return 0; |
760 | } | 743 | } |
761 | 744 | ||
762 | static int i915_set_status_page(DRM_IOCTL_ARGS) | 745 | static int i915_set_status_page(struct drm_device *dev, void *data, |
746 | struct drm_file *file_priv) | ||
763 | { | 747 | { |
764 | DRM_DEVICE; | ||
765 | drm_i915_private_t *dev_priv = dev->dev_private; | 748 | drm_i915_private_t *dev_priv = dev->dev_private; |
766 | drm_i915_hws_addr_t hws; | 749 | drm_i915_hws_addr_t *hws = data; |
767 | 750 | ||
768 | if (!dev_priv) { | 751 | if (!dev_priv) { |
769 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); | 752 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); |
770 | return -EINVAL; | 753 | return -EINVAL; |
771 | } | 754 | } |
772 | DRM_COPY_FROM_USER_IOCTL(hws, (drm_i915_hws_addr_t __user *) data, | ||
773 | sizeof(hws)); | ||
774 | printk(KERN_DEBUG "set status page addr 0x%08x\n", (u32)hws.addr); | ||
775 | 755 | ||
776 | dev_priv->status_gfx_addr = hws.addr & (0x1ffff<<12); | 756 | printk(KERN_DEBUG "set status page addr 0x%08x\n", (u32)hws->addr); |
757 | |||
758 | dev_priv->status_gfx_addr = hws->addr & (0x1ffff<<12); | ||
777 | 759 | ||
778 | dev_priv->hws_map.offset = dev->agp->agp_info.aper_base + hws.addr; | 760 | dev_priv->hws_map.offset = dev->agp->agp_info.aper_base + hws->addr; |
779 | dev_priv->hws_map.size = 4*1024; | 761 | dev_priv->hws_map.size = 4*1024; |
780 | dev_priv->hws_map.type = 0; | 762 | dev_priv->hws_map.type = 0; |
781 | dev_priv->hws_map.flags = 0; | 763 | dev_priv->hws_map.flags = 0; |
@@ -829,24 +811,24 @@ void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv) | |||
829 | } | 811 | } |
830 | } | 812 | } |
831 | 813 | ||
832 | drm_ioctl_desc_t i915_ioctls[] = { | 814 | struct drm_ioctl_desc i915_ioctls[] = { |
833 | [DRM_IOCTL_NR(DRM_I915_INIT)] = {i915_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 815 | DRM_IOCTL_DEF(DRM_I915_INIT, i915_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
834 | [DRM_IOCTL_NR(DRM_I915_FLUSH)] = {i915_flush_ioctl, DRM_AUTH}, | 816 | DRM_IOCTL_DEF(DRM_I915_FLUSH, i915_flush_ioctl, DRM_AUTH), |
835 | [DRM_IOCTL_NR(DRM_I915_FLIP)] = {i915_flip_bufs, DRM_AUTH}, | 817 | DRM_IOCTL_DEF(DRM_I915_FLIP, i915_flip_bufs, DRM_AUTH), |
836 | [DRM_IOCTL_NR(DRM_I915_BATCHBUFFER)] = {i915_batchbuffer, DRM_AUTH}, | 818 | DRM_IOCTL_DEF(DRM_I915_BATCHBUFFER, i915_batchbuffer, DRM_AUTH), |
837 | [DRM_IOCTL_NR(DRM_I915_IRQ_EMIT)] = {i915_irq_emit, DRM_AUTH}, | 819 | DRM_IOCTL_DEF(DRM_I915_IRQ_EMIT, i915_irq_emit, DRM_AUTH), |
838 | [DRM_IOCTL_NR(DRM_I915_IRQ_WAIT)] = {i915_irq_wait, DRM_AUTH}, | 820 | DRM_IOCTL_DEF(DRM_I915_IRQ_WAIT, i915_irq_wait, DRM_AUTH), |
839 | [DRM_IOCTL_NR(DRM_I915_GETPARAM)] = {i915_getparam, DRM_AUTH}, | 821 | DRM_IOCTL_DEF(DRM_I915_GETPARAM, i915_getparam, DRM_AUTH), |
840 | [DRM_IOCTL_NR(DRM_I915_SETPARAM)] = {i915_setparam, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 822 | DRM_IOCTL_DEF(DRM_I915_SETPARAM, i915_setparam, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
841 | [DRM_IOCTL_NR(DRM_I915_ALLOC)] = {i915_mem_alloc, DRM_AUTH}, | 823 | DRM_IOCTL_DEF(DRM_I915_ALLOC, i915_mem_alloc, DRM_AUTH), |
842 | [DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, DRM_AUTH}, | 824 | DRM_IOCTL_DEF(DRM_I915_FREE, i915_mem_free, DRM_AUTH), |
843 | [DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 825 | DRM_IOCTL_DEF(DRM_I915_INIT_HEAP, i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
844 | [DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, DRM_AUTH}, | 826 | DRM_IOCTL_DEF(DRM_I915_CMDBUFFER, i915_cmdbuffer, DRM_AUTH), |
845 | [DRM_IOCTL_NR(DRM_I915_DESTROY_HEAP)] = { i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }, | 827 | DRM_IOCTL_DEF(DRM_I915_DESTROY_HEAP, i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY ), |
846 | [DRM_IOCTL_NR(DRM_I915_SET_VBLANK_PIPE)] = { i915_vblank_pipe_set, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }, | 828 | DRM_IOCTL_DEF(DRM_I915_SET_VBLANK_PIPE, i915_vblank_pipe_set, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY ), |
847 | [DRM_IOCTL_NR(DRM_I915_GET_VBLANK_PIPE)] = { i915_vblank_pipe_get, DRM_AUTH }, | 829 | DRM_IOCTL_DEF(DRM_I915_GET_VBLANK_PIPE, i915_vblank_pipe_get, DRM_AUTH ), |
848 | [DRM_IOCTL_NR(DRM_I915_VBLANK_SWAP)] = {i915_vblank_swap, DRM_AUTH}, | 830 | DRM_IOCTL_DEF(DRM_I915_VBLANK_SWAP, i915_vblank_swap, DRM_AUTH), |
849 | [DRM_IOCTL_NR(DRM_I915_HWS_ADDR)] = {i915_set_status_page, DRM_AUTH}, | 831 | DRM_IOCTL_DEF(DRM_I915_HWS_ADDR, i915_set_status_page, DRM_AUTH), |
850 | }; | 832 | }; |
851 | 833 | ||
852 | int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); | 834 | int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); |
diff --git a/drivers/char/drm/i915_drv.h b/drivers/char/drm/i915_drv.h index 12fcd33dfda6..e064292e703a 100644 --- a/drivers/char/drm/i915_drv.h +++ b/drivers/char/drm/i915_drv.h | |||
@@ -116,7 +116,7 @@ typedef struct drm_i915_private { | |||
116 | unsigned int swaps_pending; | 116 | unsigned int swaps_pending; |
117 | } drm_i915_private_t; | 117 | } drm_i915_private_t; |
118 | 118 | ||
119 | extern drm_ioctl_desc_t i915_ioctls[]; | 119 | extern struct drm_ioctl_desc i915_ioctls[]; |
120 | extern int i915_max_ioctl; | 120 | extern int i915_max_ioctl; |
121 | 121 | ||
122 | /* i915_dma.c */ | 122 | /* i915_dma.c */ |
@@ -130,8 +130,10 @@ extern long i915_compat_ioctl(struct file *filp, unsigned int cmd, | |||
130 | unsigned long arg); | 130 | unsigned long arg); |
131 | 131 | ||
132 | /* i915_irq.c */ | 132 | /* i915_irq.c */ |
133 | extern int i915_irq_emit(DRM_IOCTL_ARGS); | 133 | extern int i915_irq_emit(struct drm_device *dev, void *data, |
134 | extern int i915_irq_wait(DRM_IOCTL_ARGS); | 134 | struct drm_file *file_priv); |
135 | extern int i915_irq_wait(struct drm_device *dev, void *data, | ||
136 | struct drm_file *file_priv); | ||
135 | 137 | ||
136 | extern int i915_driver_vblank_wait(struct drm_device *dev, unsigned int *sequence); | 138 | extern int i915_driver_vblank_wait(struct drm_device *dev, unsigned int *sequence); |
137 | extern int i915_driver_vblank_wait2(struct drm_device *dev, unsigned int *sequence); | 139 | extern int i915_driver_vblank_wait2(struct drm_device *dev, unsigned int *sequence); |
@@ -139,15 +141,22 @@ extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS); | |||
139 | extern void i915_driver_irq_preinstall(struct drm_device * dev); | 141 | extern void i915_driver_irq_preinstall(struct drm_device * dev); |
140 | extern void i915_driver_irq_postinstall(struct drm_device * dev); | 142 | extern void i915_driver_irq_postinstall(struct drm_device * dev); |
141 | extern void i915_driver_irq_uninstall(struct drm_device * dev); | 143 | extern void i915_driver_irq_uninstall(struct drm_device * dev); |
142 | extern int i915_vblank_pipe_set(DRM_IOCTL_ARGS); | 144 | extern int i915_vblank_pipe_set(struct drm_device *dev, void *data, |
143 | extern int i915_vblank_pipe_get(DRM_IOCTL_ARGS); | 145 | struct drm_file *file_priv); |
144 | extern int i915_vblank_swap(DRM_IOCTL_ARGS); | 146 | extern int i915_vblank_pipe_get(struct drm_device *dev, void *data, |
147 | struct drm_file *file_priv); | ||
148 | extern int i915_vblank_swap(struct drm_device *dev, void *data, | ||
149 | struct drm_file *file_priv); | ||
145 | 150 | ||
146 | /* i915_mem.c */ | 151 | /* i915_mem.c */ |
147 | extern int i915_mem_alloc(DRM_IOCTL_ARGS); | 152 | extern int i915_mem_alloc(struct drm_device *dev, void *data, |
148 | extern int i915_mem_free(DRM_IOCTL_ARGS); | 153 | struct drm_file *file_priv); |
149 | extern int i915_mem_init_heap(DRM_IOCTL_ARGS); | 154 | extern int i915_mem_free(struct drm_device *dev, void *data, |
150 | extern int i915_mem_destroy_heap(DRM_IOCTL_ARGS); | 155 | struct drm_file *file_priv); |
156 | extern int i915_mem_init_heap(struct drm_device *dev, void *data, | ||
157 | struct drm_file *file_priv); | ||
158 | extern int i915_mem_destroy_heap(struct drm_device *dev, void *data, | ||
159 | struct drm_file *file_priv); | ||
151 | extern void i915_mem_takedown(struct mem_block **heap); | 160 | extern void i915_mem_takedown(struct mem_block **heap); |
152 | extern void i915_mem_release(struct drm_device * dev, | 161 | extern void i915_mem_release(struct drm_device * dev, |
153 | struct drm_file *file_priv, struct mem_block *heap); | 162 | struct drm_file *file_priv, struct mem_block *heap); |
diff --git a/drivers/char/drm/i915_irq.c b/drivers/char/drm/i915_irq.c index 36be24e2e8d4..380c3f387218 100644 --- a/drivers/char/drm/i915_irq.c +++ b/drivers/char/drm/i915_irq.c | |||
@@ -355,11 +355,11 @@ int i915_driver_vblank_wait2(struct drm_device *dev, unsigned int *sequence) | |||
355 | 355 | ||
356 | /* Needs the lock as it touches the ring. | 356 | /* Needs the lock as it touches the ring. |
357 | */ | 357 | */ |
358 | int i915_irq_emit(DRM_IOCTL_ARGS) | 358 | int i915_irq_emit(struct drm_device *dev, void *data, |
359 | struct drm_file *file_priv) | ||
359 | { | 360 | { |
360 | DRM_DEVICE; | ||
361 | drm_i915_private_t *dev_priv = dev->dev_private; | 361 | drm_i915_private_t *dev_priv = dev->dev_private; |
362 | drm_i915_irq_emit_t emit; | 362 | drm_i915_irq_emit_t *emit = data; |
363 | int result; | 363 | int result; |
364 | 364 | ||
365 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 365 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
@@ -369,12 +369,9 @@ int i915_irq_emit(DRM_IOCTL_ARGS) | |||
369 | return -EINVAL; | 369 | return -EINVAL; |
370 | } | 370 | } |
371 | 371 | ||
372 | DRM_COPY_FROM_USER_IOCTL(emit, (drm_i915_irq_emit_t __user *) data, | ||
373 | sizeof(emit)); | ||
374 | |||
375 | result = i915_emit_irq(dev); | 372 | result = i915_emit_irq(dev); |
376 | 373 | ||
377 | if (DRM_COPY_TO_USER(emit.irq_seq, &result, sizeof(int))) { | 374 | if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) { |
378 | DRM_ERROR("copy_to_user\n"); | 375 | DRM_ERROR("copy_to_user\n"); |
379 | return -EFAULT; | 376 | return -EFAULT; |
380 | } | 377 | } |
@@ -384,21 +381,18 @@ int i915_irq_emit(DRM_IOCTL_ARGS) | |||
384 | 381 | ||
385 | /* Doesn't need the hardware lock. | 382 | /* Doesn't need the hardware lock. |
386 | */ | 383 | */ |
387 | int i915_irq_wait(DRM_IOCTL_ARGS) | 384 | int i915_irq_wait(struct drm_device *dev, void *data, |
385 | struct drm_file *file_priv) | ||
388 | { | 386 | { |
389 | DRM_DEVICE; | ||
390 | drm_i915_private_t *dev_priv = dev->dev_private; | 387 | drm_i915_private_t *dev_priv = dev->dev_private; |
391 | drm_i915_irq_wait_t irqwait; | 388 | drm_i915_irq_wait_t *irqwait = data; |
392 | 389 | ||
393 | if (!dev_priv) { | 390 | if (!dev_priv) { |
394 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); | 391 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); |
395 | return -EINVAL; | 392 | return -EINVAL; |
396 | } | 393 | } |
397 | 394 | ||
398 | DRM_COPY_FROM_USER_IOCTL(irqwait, (drm_i915_irq_wait_t __user *) data, | 395 | return i915_wait_irq(dev, irqwait->irq_seq); |
399 | sizeof(irqwait)); | ||
400 | |||
401 | return i915_wait_irq(dev, irqwait.irq_seq); | ||
402 | } | 396 | } |
403 | 397 | ||
404 | static void i915_enable_interrupt (struct drm_device *dev) | 398 | static void i915_enable_interrupt (struct drm_device *dev) |
@@ -417,38 +411,35 @@ static void i915_enable_interrupt (struct drm_device *dev) | |||
417 | 411 | ||
418 | /* Set the vblank monitor pipe | 412 | /* Set the vblank monitor pipe |
419 | */ | 413 | */ |
420 | int i915_vblank_pipe_set(DRM_IOCTL_ARGS) | 414 | int i915_vblank_pipe_set(struct drm_device *dev, void *data, |
415 | struct drm_file *file_priv) | ||
421 | { | 416 | { |
422 | DRM_DEVICE; | ||
423 | drm_i915_private_t *dev_priv = dev->dev_private; | 417 | drm_i915_private_t *dev_priv = dev->dev_private; |
424 | drm_i915_vblank_pipe_t pipe; | 418 | drm_i915_vblank_pipe_t *pipe = data; |
425 | 419 | ||
426 | if (!dev_priv) { | 420 | if (!dev_priv) { |
427 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); | 421 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); |
428 | return -EINVAL; | 422 | return -EINVAL; |
429 | } | 423 | } |
430 | 424 | ||
431 | DRM_COPY_FROM_USER_IOCTL(pipe, (drm_i915_vblank_pipe_t __user *) data, | 425 | if (pipe->pipe & ~(DRM_I915_VBLANK_PIPE_A|DRM_I915_VBLANK_PIPE_B)) { |
432 | sizeof(pipe)); | ||
433 | |||
434 | if (pipe.pipe & ~(DRM_I915_VBLANK_PIPE_A|DRM_I915_VBLANK_PIPE_B)) { | ||
435 | DRM_ERROR("%s called with invalid pipe 0x%x\n", | 426 | DRM_ERROR("%s called with invalid pipe 0x%x\n", |
436 | __FUNCTION__, pipe.pipe); | 427 | __FUNCTION__, pipe->pipe); |
437 | return -EINVAL; | 428 | return -EINVAL; |
438 | } | 429 | } |
439 | 430 | ||
440 | dev_priv->vblank_pipe = pipe.pipe; | 431 | dev_priv->vblank_pipe = pipe->pipe; |
441 | 432 | ||
442 | i915_enable_interrupt (dev); | 433 | i915_enable_interrupt (dev); |
443 | 434 | ||
444 | return 0; | 435 | return 0; |
445 | } | 436 | } |
446 | 437 | ||
447 | int i915_vblank_pipe_get(DRM_IOCTL_ARGS) | 438 | int i915_vblank_pipe_get(struct drm_device *dev, void *data, |
439 | struct drm_file *file_priv) | ||
448 | { | 440 | { |
449 | DRM_DEVICE; | ||
450 | drm_i915_private_t *dev_priv = dev->dev_private; | 441 | drm_i915_private_t *dev_priv = dev->dev_private; |
451 | drm_i915_vblank_pipe_t pipe; | 442 | drm_i915_vblank_pipe_t *pipe = data; |
452 | u16 flag; | 443 | u16 flag; |
453 | 444 | ||
454 | if (!dev_priv) { | 445 | if (!dev_priv) { |
@@ -457,24 +448,23 @@ int i915_vblank_pipe_get(DRM_IOCTL_ARGS) | |||
457 | } | 448 | } |
458 | 449 | ||
459 | flag = I915_READ(I915REG_INT_ENABLE_R); | 450 | flag = I915_READ(I915REG_INT_ENABLE_R); |
460 | pipe.pipe = 0; | 451 | pipe->pipe = 0; |
461 | if (flag & VSYNC_PIPEA_FLAG) | 452 | if (flag & VSYNC_PIPEA_FLAG) |
462 | pipe.pipe |= DRM_I915_VBLANK_PIPE_A; | 453 | pipe->pipe |= DRM_I915_VBLANK_PIPE_A; |
463 | if (flag & VSYNC_PIPEB_FLAG) | 454 | if (flag & VSYNC_PIPEB_FLAG) |
464 | pipe.pipe |= DRM_I915_VBLANK_PIPE_B; | 455 | pipe->pipe |= DRM_I915_VBLANK_PIPE_B; |
465 | DRM_COPY_TO_USER_IOCTL((drm_i915_vblank_pipe_t __user *) data, pipe, | 456 | |
466 | sizeof(pipe)); | ||
467 | return 0; | 457 | return 0; |
468 | } | 458 | } |
469 | 459 | ||
470 | /** | 460 | /** |
471 | * Schedule buffer swap at given vertical blank. | 461 | * Schedule buffer swap at given vertical blank. |
472 | */ | 462 | */ |
473 | int i915_vblank_swap(DRM_IOCTL_ARGS) | 463 | int i915_vblank_swap(struct drm_device *dev, void *data, |
464 | struct drm_file *file_priv) | ||
474 | { | 465 | { |
475 | DRM_DEVICE; | ||
476 | drm_i915_private_t *dev_priv = dev->dev_private; | 466 | drm_i915_private_t *dev_priv = dev->dev_private; |
477 | drm_i915_vblank_swap_t swap; | 467 | drm_i915_vblank_swap_t *swap = data; |
478 | drm_i915_vbl_swap_t *vbl_swap; | 468 | drm_i915_vbl_swap_t *vbl_swap; |
479 | unsigned int pipe, seqtype, curseq; | 469 | unsigned int pipe, seqtype, curseq; |
480 | unsigned long irqflags; | 470 | unsigned long irqflags; |
@@ -490,18 +480,15 @@ int i915_vblank_swap(DRM_IOCTL_ARGS) | |||
490 | return -EINVAL; | 480 | return -EINVAL; |
491 | } | 481 | } |
492 | 482 | ||
493 | DRM_COPY_FROM_USER_IOCTL(swap, (drm_i915_vblank_swap_t __user *) data, | 483 | if (swap->seqtype & ~(_DRM_VBLANK_RELATIVE | _DRM_VBLANK_ABSOLUTE | |
494 | sizeof(swap)); | ||
495 | |||
496 | if (swap.seqtype & ~(_DRM_VBLANK_RELATIVE | _DRM_VBLANK_ABSOLUTE | | ||
497 | _DRM_VBLANK_SECONDARY | _DRM_VBLANK_NEXTONMISS)) { | 484 | _DRM_VBLANK_SECONDARY | _DRM_VBLANK_NEXTONMISS)) { |
498 | DRM_ERROR("Invalid sequence type 0x%x\n", swap.seqtype); | 485 | DRM_ERROR("Invalid sequence type 0x%x\n", swap->seqtype); |
499 | return -EINVAL; | 486 | return -EINVAL; |
500 | } | 487 | } |
501 | 488 | ||
502 | pipe = (swap.seqtype & _DRM_VBLANK_SECONDARY) ? 1 : 0; | 489 | pipe = (swap->seqtype & _DRM_VBLANK_SECONDARY) ? 1 : 0; |
503 | 490 | ||
504 | seqtype = swap.seqtype & (_DRM_VBLANK_RELATIVE | _DRM_VBLANK_ABSOLUTE); | 491 | seqtype = swap->seqtype & (_DRM_VBLANK_RELATIVE | _DRM_VBLANK_ABSOLUTE); |
505 | 492 | ||
506 | if (!(dev_priv->vblank_pipe & (1 << pipe))) { | 493 | if (!(dev_priv->vblank_pipe & (1 << pipe))) { |
507 | DRM_ERROR("Invalid pipe %d\n", pipe); | 494 | DRM_ERROR("Invalid pipe %d\n", pipe); |
@@ -510,9 +497,9 @@ int i915_vblank_swap(DRM_IOCTL_ARGS) | |||
510 | 497 | ||
511 | spin_lock_irqsave(&dev->drw_lock, irqflags); | 498 | spin_lock_irqsave(&dev->drw_lock, irqflags); |
512 | 499 | ||
513 | if (!drm_get_drawable_info(dev, swap.drawable)) { | 500 | if (!drm_get_drawable_info(dev, swap->drawable)) { |
514 | spin_unlock_irqrestore(&dev->drw_lock, irqflags); | 501 | spin_unlock_irqrestore(&dev->drw_lock, irqflags); |
515 | DRM_DEBUG("Invalid drawable ID %d\n", swap.drawable); | 502 | DRM_DEBUG("Invalid drawable ID %d\n", swap->drawable); |
516 | return -EINVAL; | 503 | return -EINVAL; |
517 | } | 504 | } |
518 | 505 | ||
@@ -521,11 +508,11 @@ int i915_vblank_swap(DRM_IOCTL_ARGS) | |||
521 | curseq = atomic_read(pipe ? &dev->vbl_received2 : &dev->vbl_received); | 508 | curseq = atomic_read(pipe ? &dev->vbl_received2 : &dev->vbl_received); |
522 | 509 | ||
523 | if (seqtype == _DRM_VBLANK_RELATIVE) | 510 | if (seqtype == _DRM_VBLANK_RELATIVE) |
524 | swap.sequence += curseq; | 511 | swap->sequence += curseq; |
525 | 512 | ||
526 | if ((curseq - swap.sequence) <= (1<<23)) { | 513 | if ((curseq - swap->sequence) <= (1<<23)) { |
527 | if (swap.seqtype & _DRM_VBLANK_NEXTONMISS) { | 514 | if (swap->seqtype & _DRM_VBLANK_NEXTONMISS) { |
528 | swap.sequence = curseq + 1; | 515 | swap->sequence = curseq + 1; |
529 | } else { | 516 | } else { |
530 | DRM_DEBUG("Missed target sequence\n"); | 517 | DRM_DEBUG("Missed target sequence\n"); |
531 | return -EINVAL; | 518 | return -EINVAL; |
@@ -537,9 +524,9 @@ int i915_vblank_swap(DRM_IOCTL_ARGS) | |||
537 | list_for_each(list, &dev_priv->vbl_swaps.head) { | 524 | list_for_each(list, &dev_priv->vbl_swaps.head) { |
538 | vbl_swap = list_entry(list, drm_i915_vbl_swap_t, head); | 525 | vbl_swap = list_entry(list, drm_i915_vbl_swap_t, head); |
539 | 526 | ||
540 | if (vbl_swap->drw_id == swap.drawable && | 527 | if (vbl_swap->drw_id == swap->drawable && |
541 | vbl_swap->pipe == pipe && | 528 | vbl_swap->pipe == pipe && |
542 | vbl_swap->sequence == swap.sequence) { | 529 | vbl_swap->sequence == swap->sequence) { |
543 | spin_unlock_irqrestore(&dev_priv->swaps_lock, irqflags); | 530 | spin_unlock_irqrestore(&dev_priv->swaps_lock, irqflags); |
544 | DRM_DEBUG("Already scheduled\n"); | 531 | DRM_DEBUG("Already scheduled\n"); |
545 | return 0; | 532 | return 0; |
@@ -562,9 +549,9 @@ int i915_vblank_swap(DRM_IOCTL_ARGS) | |||
562 | 549 | ||
563 | DRM_DEBUG("\n"); | 550 | DRM_DEBUG("\n"); |
564 | 551 | ||
565 | vbl_swap->drw_id = swap.drawable; | 552 | vbl_swap->drw_id = swap->drawable; |
566 | vbl_swap->pipe = pipe; | 553 | vbl_swap->pipe = pipe; |
567 | vbl_swap->sequence = swap.sequence; | 554 | vbl_swap->sequence = swap->sequence; |
568 | 555 | ||
569 | spin_lock_irqsave(&dev_priv->swaps_lock, irqflags); | 556 | spin_lock_irqsave(&dev_priv->swaps_lock, irqflags); |
570 | 557 | ||
@@ -573,9 +560,6 @@ int i915_vblank_swap(DRM_IOCTL_ARGS) | |||
573 | 560 | ||
574 | spin_unlock_irqrestore(&dev_priv->swaps_lock, irqflags); | 561 | spin_unlock_irqrestore(&dev_priv->swaps_lock, irqflags); |
575 | 562 | ||
576 | DRM_COPY_TO_USER_IOCTL((drm_i915_vblank_swap_t __user *) data, swap, | ||
577 | sizeof(swap)); | ||
578 | |||
579 | return 0; | 563 | return 0; |
580 | } | 564 | } |
581 | 565 | ||
diff --git a/drivers/char/drm/i915_mem.c b/drivers/char/drm/i915_mem.c index fa279da5be2c..56fb9b30a5d7 100644 --- a/drivers/char/drm/i915_mem.c +++ b/drivers/char/drm/i915_mem.c | |||
@@ -268,11 +268,11 @@ static struct mem_block **get_heap(drm_i915_private_t * dev_priv, int region) | |||
268 | 268 | ||
269 | /* IOCTL HANDLERS */ | 269 | /* IOCTL HANDLERS */ |
270 | 270 | ||
271 | int i915_mem_alloc(DRM_IOCTL_ARGS) | 271 | int i915_mem_alloc(struct drm_device *dev, void *data, |
272 | struct drm_file *file_priv) | ||
272 | { | 273 | { |
273 | DRM_DEVICE; | ||
274 | drm_i915_private_t *dev_priv = dev->dev_private; | 274 | drm_i915_private_t *dev_priv = dev->dev_private; |
275 | drm_i915_mem_alloc_t alloc; | 275 | drm_i915_mem_alloc_t *alloc = data; |
276 | struct mem_block *block, **heap; | 276 | struct mem_block *block, **heap; |
277 | 277 | ||
278 | if (!dev_priv) { | 278 | if (!dev_priv) { |
@@ -280,27 +280,25 @@ int i915_mem_alloc(DRM_IOCTL_ARGS) | |||
280 | return -EINVAL; | 280 | return -EINVAL; |
281 | } | 281 | } |
282 | 282 | ||
283 | DRM_COPY_FROM_USER_IOCTL(alloc, (drm_i915_mem_alloc_t __user *) data, | 283 | heap = get_heap(dev_priv, alloc->region); |
284 | sizeof(alloc)); | ||
285 | |||
286 | heap = get_heap(dev_priv, alloc.region); | ||
287 | if (!heap || !*heap) | 284 | if (!heap || !*heap) |
288 | return -EFAULT; | 285 | return -EFAULT; |
289 | 286 | ||
290 | /* Make things easier on ourselves: all allocations at least | 287 | /* Make things easier on ourselves: all allocations at least |
291 | * 4k aligned. | 288 | * 4k aligned. |
292 | */ | 289 | */ |
293 | if (alloc.alignment < 12) | 290 | if (alloc->alignment < 12) |
294 | alloc.alignment = 12; | 291 | alloc->alignment = 12; |
295 | 292 | ||
296 | block = alloc_block(*heap, alloc.size, alloc.alignment, file_priv); | 293 | block = alloc_block(*heap, alloc->size, alloc->alignment, file_priv); |
297 | 294 | ||
298 | if (!block) | 295 | if (!block) |
299 | return -ENOMEM; | 296 | return -ENOMEM; |
300 | 297 | ||
301 | mark_block(dev, block, 1); | 298 | mark_block(dev, block, 1); |
302 | 299 | ||
303 | if (DRM_COPY_TO_USER(alloc.region_offset, &block->start, sizeof(int))) { | 300 | if (DRM_COPY_TO_USER(alloc->region_offset, &block->start, |
301 | sizeof(int))) { | ||
304 | DRM_ERROR("copy_to_user\n"); | 302 | DRM_ERROR("copy_to_user\n"); |
305 | return -EFAULT; | 303 | return -EFAULT; |
306 | } | 304 | } |
@@ -308,11 +306,11 @@ int i915_mem_alloc(DRM_IOCTL_ARGS) | |||
308 | return 0; | 306 | return 0; |
309 | } | 307 | } |
310 | 308 | ||
311 | int i915_mem_free(DRM_IOCTL_ARGS) | 309 | int i915_mem_free(struct drm_device *dev, void *data, |
310 | struct drm_file *file_priv) | ||
312 | { | 311 | { |
313 | DRM_DEVICE; | ||
314 | drm_i915_private_t *dev_priv = dev->dev_private; | 312 | drm_i915_private_t *dev_priv = dev->dev_private; |
315 | drm_i915_mem_free_t memfree; | 313 | drm_i915_mem_free_t *memfree = data; |
316 | struct mem_block *block, **heap; | 314 | struct mem_block *block, **heap; |
317 | 315 | ||
318 | if (!dev_priv) { | 316 | if (!dev_priv) { |
@@ -320,14 +318,11 @@ int i915_mem_free(DRM_IOCTL_ARGS) | |||
320 | return -EINVAL; | 318 | return -EINVAL; |
321 | } | 319 | } |
322 | 320 | ||
323 | DRM_COPY_FROM_USER_IOCTL(memfree, (drm_i915_mem_free_t __user *) data, | 321 | heap = get_heap(dev_priv, memfree->region); |
324 | sizeof(memfree)); | ||
325 | |||
326 | heap = get_heap(dev_priv, memfree.region); | ||
327 | if (!heap || !*heap) | 322 | if (!heap || !*heap) |
328 | return -EFAULT; | 323 | return -EFAULT; |
329 | 324 | ||
330 | block = find_block(*heap, memfree.region_offset); | 325 | block = find_block(*heap, memfree->region_offset); |
331 | if (!block) | 326 | if (!block) |
332 | return -EFAULT; | 327 | return -EFAULT; |
333 | 328 | ||
@@ -339,11 +334,11 @@ int i915_mem_free(DRM_IOCTL_ARGS) | |||
339 | return 0; | 334 | return 0; |
340 | } | 335 | } |
341 | 336 | ||
342 | int i915_mem_init_heap(DRM_IOCTL_ARGS) | 337 | int i915_mem_init_heap(struct drm_device *dev, void *data, |
338 | struct drm_file *file_priv) | ||
343 | { | 339 | { |
344 | DRM_DEVICE; | ||
345 | drm_i915_private_t *dev_priv = dev->dev_private; | 340 | drm_i915_private_t *dev_priv = dev->dev_private; |
346 | drm_i915_mem_init_heap_t initheap; | 341 | drm_i915_mem_init_heap_t *initheap = data; |
347 | struct mem_block **heap; | 342 | struct mem_block **heap; |
348 | 343 | ||
349 | if (!dev_priv) { | 344 | if (!dev_priv) { |
@@ -351,11 +346,7 @@ int i915_mem_init_heap(DRM_IOCTL_ARGS) | |||
351 | return -EINVAL; | 346 | return -EINVAL; |
352 | } | 347 | } |
353 | 348 | ||
354 | DRM_COPY_FROM_USER_IOCTL(initheap, | 349 | heap = get_heap(dev_priv, initheap->region); |
355 | (drm_i915_mem_init_heap_t __user *) data, | ||
356 | sizeof(initheap)); | ||
357 | |||
358 | heap = get_heap(dev_priv, initheap.region); | ||
359 | if (!heap) | 350 | if (!heap) |
360 | return -EFAULT; | 351 | return -EFAULT; |
361 | 352 | ||
@@ -364,14 +355,14 @@ int i915_mem_init_heap(DRM_IOCTL_ARGS) | |||
364 | return -EFAULT; | 355 | return -EFAULT; |
365 | } | 356 | } |
366 | 357 | ||
367 | return init_heap(heap, initheap.start, initheap.size); | 358 | return init_heap(heap, initheap->start, initheap->size); |
368 | } | 359 | } |
369 | 360 | ||
370 | int i915_mem_destroy_heap( DRM_IOCTL_ARGS ) | 361 | int i915_mem_destroy_heap( struct drm_device *dev, void *data, |
362 | struct drm_file *file_priv ) | ||
371 | { | 363 | { |
372 | DRM_DEVICE; | ||
373 | drm_i915_private_t *dev_priv = dev->dev_private; | 364 | drm_i915_private_t *dev_priv = dev->dev_private; |
374 | drm_i915_mem_destroy_heap_t destroyheap; | 365 | drm_i915_mem_destroy_heap_t *destroyheap = data; |
375 | struct mem_block **heap; | 366 | struct mem_block **heap; |
376 | 367 | ||
377 | if ( !dev_priv ) { | 368 | if ( !dev_priv ) { |
@@ -379,10 +370,7 @@ int i915_mem_destroy_heap( DRM_IOCTL_ARGS ) | |||
379 | return -EINVAL; | 370 | return -EINVAL; |
380 | } | 371 | } |
381 | 372 | ||
382 | DRM_COPY_FROM_USER_IOCTL( destroyheap, (drm_i915_mem_destroy_heap_t *)data, | 373 | heap = get_heap( dev_priv, destroyheap->region ); |
383 | sizeof(destroyheap) ); | ||
384 | |||
385 | heap = get_heap( dev_priv, destroyheap.region ); | ||
386 | if (!heap) { | 374 | if (!heap) { |
387 | DRM_ERROR("get_heap failed"); | 375 | DRM_ERROR("get_heap failed"); |
388 | return -EFAULT; | 376 | return -EFAULT; |
diff --git a/drivers/char/drm/mga_dma.c b/drivers/char/drm/mga_dma.c index 95ff450239dd..c567c34cda78 100644 --- a/drivers/char/drm/mga_dma.c +++ b/drivers/char/drm/mga_dma.c | |||
@@ -759,36 +759,30 @@ static int mga_do_dma_bootstrap(struct drm_device * dev, | |||
759 | return err; | 759 | return err; |
760 | } | 760 | } |
761 | 761 | ||
762 | int mga_dma_bootstrap(DRM_IOCTL_ARGS) | 762 | int mga_dma_bootstrap(struct drm_device *dev, void *data, |
763 | struct drm_file *file_priv) | ||
763 | { | 764 | { |
764 | DRM_DEVICE; | 765 | drm_mga_dma_bootstrap_t *bootstrap = data; |
765 | drm_mga_dma_bootstrap_t bootstrap; | ||
766 | int err; | 766 | int err; |
767 | static const int modes[] = { 0, 1, 2, 2, 4, 4, 4, 4 }; | 767 | static const int modes[] = { 0, 1, 2, 2, 4, 4, 4, 4 }; |
768 | const drm_mga_private_t *const dev_priv = | 768 | const drm_mga_private_t *const dev_priv = |
769 | (drm_mga_private_t *) dev->dev_private; | 769 | (drm_mga_private_t *) dev->dev_private; |
770 | 770 | ||
771 | DRM_COPY_FROM_USER_IOCTL(bootstrap, | 771 | err = mga_do_dma_bootstrap(dev, bootstrap); |
772 | (drm_mga_dma_bootstrap_t __user *) data, | ||
773 | sizeof(bootstrap)); | ||
774 | |||
775 | err = mga_do_dma_bootstrap(dev, &bootstrap); | ||
776 | if (err) { | 772 | if (err) { |
777 | mga_do_cleanup_dma(dev, FULL_CLEANUP); | 773 | mga_do_cleanup_dma(dev, FULL_CLEANUP); |
778 | return err; | 774 | return err; |
779 | } | 775 | } |
780 | 776 | ||
781 | if (dev_priv->agp_textures != NULL) { | 777 | if (dev_priv->agp_textures != NULL) { |
782 | bootstrap.texture_handle = dev_priv->agp_textures->offset; | 778 | bootstrap->texture_handle = dev_priv->agp_textures->offset; |
783 | bootstrap.texture_size = dev_priv->agp_textures->size; | 779 | bootstrap->texture_size = dev_priv->agp_textures->size; |
784 | } else { | 780 | } else { |
785 | bootstrap.texture_handle = 0; | 781 | bootstrap->texture_handle = 0; |
786 | bootstrap.texture_size = 0; | 782 | bootstrap->texture_size = 0; |
787 | } | 783 | } |
788 | 784 | ||
789 | bootstrap.agp_mode = modes[bootstrap.agp_mode & 0x07]; | 785 | bootstrap->agp_mode = modes[bootstrap->agp_mode & 0x07]; |
790 | DRM_COPY_TO_USER_IOCTL((drm_mga_dma_bootstrap_t __user *)data, | ||
791 | bootstrap, sizeof(bootstrap)); | ||
792 | 786 | ||
793 | return err; | 787 | return err; |
794 | } | 788 | } |
@@ -1007,20 +1001,17 @@ static int mga_do_cleanup_dma(struct drm_device *dev, int full_cleanup) | |||
1007 | return 0; | 1001 | return 0; |
1008 | } | 1002 | } |
1009 | 1003 | ||
1010 | int mga_dma_init(DRM_IOCTL_ARGS) | 1004 | int mga_dma_init(struct drm_device *dev, void *data, |
1005 | struct drm_file *file_priv) | ||
1011 | { | 1006 | { |
1012 | DRM_DEVICE; | 1007 | drm_mga_init_t *init = data; |
1013 | drm_mga_init_t init; | ||
1014 | int err; | 1008 | int err; |
1015 | 1009 | ||
1016 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1010 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1017 | 1011 | ||
1018 | DRM_COPY_FROM_USER_IOCTL(init, (drm_mga_init_t __user *) data, | 1012 | switch (init->func) { |
1019 | sizeof(init)); | ||
1020 | |||
1021 | switch (init.func) { | ||
1022 | case MGA_INIT_DMA: | 1013 | case MGA_INIT_DMA: |
1023 | err = mga_do_init_dma(dev, &init); | 1014 | err = mga_do_init_dma(dev, init); |
1024 | if (err) { | 1015 | if (err) { |
1025 | (void)mga_do_cleanup_dma(dev, FULL_CLEANUP); | 1016 | (void)mga_do_cleanup_dma(dev, FULL_CLEANUP); |
1026 | } | 1017 | } |
@@ -1036,29 +1027,26 @@ int mga_dma_init(DRM_IOCTL_ARGS) | |||
1036 | * Primary DMA stream management | 1027 | * Primary DMA stream management |
1037 | */ | 1028 | */ |
1038 | 1029 | ||
1039 | int mga_dma_flush(DRM_IOCTL_ARGS) | 1030 | int mga_dma_flush(struct drm_device *dev, void *data, |
1031 | struct drm_file *file_priv) | ||
1040 | { | 1032 | { |
1041 | DRM_DEVICE; | ||
1042 | drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; | 1033 | drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; |
1043 | struct drm_lock lock; | 1034 | struct drm_lock *lock = data; |
1044 | 1035 | ||
1045 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1036 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1046 | 1037 | ||
1047 | DRM_COPY_FROM_USER_IOCTL(lock, (struct drm_lock __user *) data, | ||
1048 | sizeof(lock)); | ||
1049 | |||
1050 | DRM_DEBUG("%s%s%s\n", | 1038 | DRM_DEBUG("%s%s%s\n", |
1051 | (lock.flags & _DRM_LOCK_FLUSH) ? "flush, " : "", | 1039 | (lock->flags & _DRM_LOCK_FLUSH) ? "flush, " : "", |
1052 | (lock.flags & _DRM_LOCK_FLUSH_ALL) ? "flush all, " : "", | 1040 | (lock->flags & _DRM_LOCK_FLUSH_ALL) ? "flush all, " : "", |
1053 | (lock.flags & _DRM_LOCK_QUIESCENT) ? "idle, " : ""); | 1041 | (lock->flags & _DRM_LOCK_QUIESCENT) ? "idle, " : ""); |
1054 | 1042 | ||
1055 | WRAP_WAIT_WITH_RETURN(dev_priv); | 1043 | WRAP_WAIT_WITH_RETURN(dev_priv); |
1056 | 1044 | ||
1057 | if (lock.flags & (_DRM_LOCK_FLUSH | _DRM_LOCK_FLUSH_ALL)) { | 1045 | if (lock->flags & (_DRM_LOCK_FLUSH | _DRM_LOCK_FLUSH_ALL)) { |
1058 | mga_do_dma_flush(dev_priv); | 1046 | mga_do_dma_flush(dev_priv); |
1059 | } | 1047 | } |
1060 | 1048 | ||
1061 | if (lock.flags & _DRM_LOCK_QUIESCENT) { | 1049 | if (lock->flags & _DRM_LOCK_QUIESCENT) { |
1062 | #if MGA_DMA_DEBUG | 1050 | #if MGA_DMA_DEBUG |
1063 | int ret = mga_do_wait_for_idle(dev_priv); | 1051 | int ret = mga_do_wait_for_idle(dev_priv); |
1064 | if (ret < 0) | 1052 | if (ret < 0) |
@@ -1072,9 +1060,9 @@ int mga_dma_flush(DRM_IOCTL_ARGS) | |||
1072 | } | 1060 | } |
1073 | } | 1061 | } |
1074 | 1062 | ||
1075 | int mga_dma_reset(DRM_IOCTL_ARGS) | 1063 | int mga_dma_reset(struct drm_device *dev, void *data, |
1064 | struct drm_file *file_priv) | ||
1076 | { | 1065 | { |
1077 | DRM_DEVICE; | ||
1078 | drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; | 1066 | drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; |
1079 | 1067 | ||
1080 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1068 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
@@ -1111,45 +1099,40 @@ static int mga_dma_get_buffers(struct drm_device * dev, | |||
1111 | return 0; | 1099 | return 0; |
1112 | } | 1100 | } |
1113 | 1101 | ||
1114 | int mga_dma_buffers(DRM_IOCTL_ARGS) | 1102 | int mga_dma_buffers(struct drm_device *dev, void *data, |
1103 | struct drm_file *file_priv) | ||
1115 | { | 1104 | { |
1116 | DRM_DEVICE; | ||
1117 | struct drm_device_dma *dma = dev->dma; | 1105 | struct drm_device_dma *dma = dev->dma; |
1118 | drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; | 1106 | drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; |
1119 | struct drm_dma __user *argp = (void __user *)data; | 1107 | struct drm_dma *d = data; |
1120 | struct drm_dma d; | ||
1121 | int ret = 0; | 1108 | int ret = 0; |
1122 | 1109 | ||
1123 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1110 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1124 | 1111 | ||
1125 | DRM_COPY_FROM_USER_IOCTL(d, argp, sizeof(d)); | ||
1126 | |||
1127 | /* Please don't send us buffers. | 1112 | /* Please don't send us buffers. |
1128 | */ | 1113 | */ |
1129 | if (d.send_count != 0) { | 1114 | if (d->send_count != 0) { |
1130 | DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n", | 1115 | DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n", |
1131 | DRM_CURRENTPID, d.send_count); | 1116 | DRM_CURRENTPID, d->send_count); |
1132 | return -EINVAL; | 1117 | return -EINVAL; |
1133 | } | 1118 | } |
1134 | 1119 | ||
1135 | /* We'll send you buffers. | 1120 | /* We'll send you buffers. |
1136 | */ | 1121 | */ |
1137 | if (d.request_count < 0 || d.request_count > dma->buf_count) { | 1122 | if (d->request_count < 0 || d->request_count > dma->buf_count) { |
1138 | DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", | 1123 | DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", |
1139 | DRM_CURRENTPID, d.request_count, dma->buf_count); | 1124 | DRM_CURRENTPID, d->request_count, dma->buf_count); |
1140 | return -EINVAL; | 1125 | return -EINVAL; |
1141 | } | 1126 | } |
1142 | 1127 | ||
1143 | WRAP_TEST_WITH_RETURN(dev_priv); | 1128 | WRAP_TEST_WITH_RETURN(dev_priv); |
1144 | 1129 | ||
1145 | d.granted_count = 0; | 1130 | d->granted_count = 0; |
1146 | 1131 | ||
1147 | if (d.request_count) { | 1132 | if (d->request_count) { |
1148 | ret = mga_dma_get_buffers(dev, file_priv, &d); | 1133 | ret = mga_dma_get_buffers(dev, file_priv, d); |
1149 | } | 1134 | } |
1150 | 1135 | ||
1151 | DRM_COPY_TO_USER_IOCTL(argp, d, sizeof(d)); | ||
1152 | |||
1153 | return ret; | 1136 | return ret; |
1154 | } | 1137 | } |
1155 | 1138 | ||
diff --git a/drivers/char/drm/mga_drv.h b/drivers/char/drm/mga_drv.h index 7bf59113fca6..cd94c04e31c0 100644 --- a/drivers/char/drm/mga_drv.h +++ b/drivers/char/drm/mga_drv.h | |||
@@ -148,15 +148,20 @@ typedef struct drm_mga_private { | |||
148 | unsigned int agp_size; | 148 | unsigned int agp_size; |
149 | } drm_mga_private_t; | 149 | } drm_mga_private_t; |
150 | 150 | ||
151 | extern drm_ioctl_desc_t mga_ioctls[]; | 151 | extern struct drm_ioctl_desc mga_ioctls[]; |
152 | extern int mga_max_ioctl; | 152 | extern int mga_max_ioctl; |
153 | 153 | ||
154 | /* mga_dma.c */ | 154 | /* mga_dma.c */ |
155 | extern int mga_dma_bootstrap(DRM_IOCTL_ARGS); | 155 | extern int mga_dma_bootstrap(struct drm_device *dev, void *data, |
156 | extern int mga_dma_init(DRM_IOCTL_ARGS); | 156 | struct drm_file *file_priv); |
157 | extern int mga_dma_flush(DRM_IOCTL_ARGS); | 157 | extern int mga_dma_init(struct drm_device *dev, void *data, |
158 | extern int mga_dma_reset(DRM_IOCTL_ARGS); | 158 | struct drm_file *file_priv); |
159 | extern int mga_dma_buffers(DRM_IOCTL_ARGS); | 159 | extern int mga_dma_flush(struct drm_device *dev, void *data, |
160 | struct drm_file *file_priv); | ||
161 | extern int mga_dma_reset(struct drm_device *dev, void *data, | ||
162 | struct drm_file *file_priv); | ||
163 | extern int mga_dma_buffers(struct drm_device *dev, void *data, | ||
164 | struct drm_file *file_priv); | ||
160 | extern int mga_driver_load(struct drm_device *dev, unsigned long flags); | 165 | extern int mga_driver_load(struct drm_device *dev, unsigned long flags); |
161 | extern int mga_driver_unload(struct drm_device * dev); | 166 | extern int mga_driver_unload(struct drm_device * dev); |
162 | extern void mga_driver_lastclose(struct drm_device * dev); | 167 | extern void mga_driver_lastclose(struct drm_device * dev); |
diff --git a/drivers/char/drm/mga_state.c b/drivers/char/drm/mga_state.c index 74811727595a..5ec8b61c5d45 100644 --- a/drivers/char/drm/mga_state.c +++ b/drivers/char/drm/mga_state.c | |||
@@ -828,24 +828,20 @@ static void mga_dma_dispatch_blit(struct drm_device * dev, drm_mga_blit_t * blit | |||
828 | * | 828 | * |
829 | */ | 829 | */ |
830 | 830 | ||
831 | static int mga_dma_clear(DRM_IOCTL_ARGS) | 831 | static int mga_dma_clear(struct drm_device *dev, void *data, struct drm_file *file_priv) |
832 | { | 832 | { |
833 | DRM_DEVICE; | ||
834 | drm_mga_private_t *dev_priv = dev->dev_private; | 833 | drm_mga_private_t *dev_priv = dev->dev_private; |
835 | drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; | 834 | drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; |
836 | drm_mga_clear_t clear; | 835 | drm_mga_clear_t *clear = data; |
837 | 836 | ||
838 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 837 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
839 | 838 | ||
840 | DRM_COPY_FROM_USER_IOCTL(clear, (drm_mga_clear_t __user *) data, | ||
841 | sizeof(clear)); | ||
842 | |||
843 | if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS) | 839 | if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS) |
844 | sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS; | 840 | sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS; |
845 | 841 | ||
846 | WRAP_TEST_WITH_RETURN(dev_priv); | 842 | WRAP_TEST_WITH_RETURN(dev_priv); |
847 | 843 | ||
848 | mga_dma_dispatch_clear(dev, &clear); | 844 | mga_dma_dispatch_clear(dev, clear); |
849 | 845 | ||
850 | /* Make sure we restore the 3D state next time. | 846 | /* Make sure we restore the 3D state next time. |
851 | */ | 847 | */ |
@@ -854,9 +850,8 @@ static int mga_dma_clear(DRM_IOCTL_ARGS) | |||
854 | return 0; | 850 | return 0; |
855 | } | 851 | } |
856 | 852 | ||
857 | static int mga_dma_swap(DRM_IOCTL_ARGS) | 853 | static int mga_dma_swap(struct drm_device *dev, void *data, struct drm_file *file_priv) |
858 | { | 854 | { |
859 | DRM_DEVICE; | ||
860 | drm_mga_private_t *dev_priv = dev->dev_private; | 855 | drm_mga_private_t *dev_priv = dev->dev_private; |
861 | drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; | 856 | drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; |
862 | 857 | ||
@@ -876,31 +871,26 @@ static int mga_dma_swap(DRM_IOCTL_ARGS) | |||
876 | return 0; | 871 | return 0; |
877 | } | 872 | } |
878 | 873 | ||
879 | static int mga_dma_vertex(DRM_IOCTL_ARGS) | 874 | static int mga_dma_vertex(struct drm_device *dev, void *data, struct drm_file *file_priv) |
880 | { | 875 | { |
881 | DRM_DEVICE; | ||
882 | drm_mga_private_t *dev_priv = dev->dev_private; | 876 | drm_mga_private_t *dev_priv = dev->dev_private; |
883 | struct drm_device_dma *dma = dev->dma; | 877 | struct drm_device_dma *dma = dev->dma; |
884 | struct drm_buf *buf; | 878 | struct drm_buf *buf; |
885 | drm_mga_buf_priv_t *buf_priv; | 879 | drm_mga_buf_priv_t *buf_priv; |
886 | drm_mga_vertex_t vertex; | 880 | drm_mga_vertex_t *vertex = data; |
887 | 881 | ||
888 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 882 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
889 | 883 | ||
890 | DRM_COPY_FROM_USER_IOCTL(vertex, | 884 | if (vertex->idx < 0 || vertex->idx > dma->buf_count) |
891 | (drm_mga_vertex_t __user *) data, | ||
892 | sizeof(vertex)); | ||
893 | |||
894 | if (vertex.idx < 0 || vertex.idx > dma->buf_count) | ||
895 | return -EINVAL; | 885 | return -EINVAL; |
896 | buf = dma->buflist[vertex.idx]; | 886 | buf = dma->buflist[vertex->idx]; |
897 | buf_priv = buf->dev_private; | 887 | buf_priv = buf->dev_private; |
898 | 888 | ||
899 | buf->used = vertex.used; | 889 | buf->used = vertex->used; |
900 | buf_priv->discard = vertex.discard; | 890 | buf_priv->discard = vertex->discard; |
901 | 891 | ||
902 | if (!mga_verify_state(dev_priv)) { | 892 | if (!mga_verify_state(dev_priv)) { |
903 | if (vertex.discard) { | 893 | if (vertex->discard) { |
904 | if (buf_priv->dispatched == 1) | 894 | if (buf_priv->dispatched == 1) |
905 | AGE_BUFFER(buf_priv); | 895 | AGE_BUFFER(buf_priv); |
906 | buf_priv->dispatched = 0; | 896 | buf_priv->dispatched = 0; |
@@ -916,31 +906,26 @@ static int mga_dma_vertex(DRM_IOCTL_ARGS) | |||
916 | return 0; | 906 | return 0; |
917 | } | 907 | } |
918 | 908 | ||
919 | static int mga_dma_indices(DRM_IOCTL_ARGS) | 909 | static int mga_dma_indices(struct drm_device *dev, void *data, struct drm_file *file_priv) |
920 | { | 910 | { |
921 | DRM_DEVICE; | ||
922 | drm_mga_private_t *dev_priv = dev->dev_private; | 911 | drm_mga_private_t *dev_priv = dev->dev_private; |
923 | struct drm_device_dma *dma = dev->dma; | 912 | struct drm_device_dma *dma = dev->dma; |
924 | struct drm_buf *buf; | 913 | struct drm_buf *buf; |
925 | drm_mga_buf_priv_t *buf_priv; | 914 | drm_mga_buf_priv_t *buf_priv; |
926 | drm_mga_indices_t indices; | 915 | drm_mga_indices_t *indices = data; |
927 | 916 | ||
928 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 917 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
929 | 918 | ||
930 | DRM_COPY_FROM_USER_IOCTL(indices, | 919 | if (indices->idx < 0 || indices->idx > dma->buf_count) |
931 | (drm_mga_indices_t __user *) data, | ||
932 | sizeof(indices)); | ||
933 | |||
934 | if (indices.idx < 0 || indices.idx > dma->buf_count) | ||
935 | return -EINVAL; | 920 | return -EINVAL; |
936 | 921 | ||
937 | buf = dma->buflist[indices.idx]; | 922 | buf = dma->buflist[indices->idx]; |
938 | buf_priv = buf->dev_private; | 923 | buf_priv = buf->dev_private; |
939 | 924 | ||
940 | buf_priv->discard = indices.discard; | 925 | buf_priv->discard = indices->discard; |
941 | 926 | ||
942 | if (!mga_verify_state(dev_priv)) { | 927 | if (!mga_verify_state(dev_priv)) { |
943 | if (indices.discard) { | 928 | if (indices->discard) { |
944 | if (buf_priv->dispatched == 1) | 929 | if (buf_priv->dispatched == 1) |
945 | AGE_BUFFER(buf_priv); | 930 | AGE_BUFFER(buf_priv); |
946 | buf_priv->dispatched = 0; | 931 | buf_priv->dispatched = 0; |
@@ -951,26 +936,22 @@ static int mga_dma_indices(DRM_IOCTL_ARGS) | |||
951 | 936 | ||
952 | WRAP_TEST_WITH_RETURN(dev_priv); | 937 | WRAP_TEST_WITH_RETURN(dev_priv); |
953 | 938 | ||
954 | mga_dma_dispatch_indices(dev, buf, indices.start, indices.end); | 939 | mga_dma_dispatch_indices(dev, buf, indices->start, indices->end); |
955 | 940 | ||
956 | return 0; | 941 | return 0; |
957 | } | 942 | } |
958 | 943 | ||
959 | static int mga_dma_iload(DRM_IOCTL_ARGS) | 944 | static int mga_dma_iload(struct drm_device *dev, void *data, struct drm_file *file_priv) |
960 | { | 945 | { |
961 | DRM_DEVICE; | ||
962 | struct drm_device_dma *dma = dev->dma; | 946 | struct drm_device_dma *dma = dev->dma; |
963 | drm_mga_private_t *dev_priv = dev->dev_private; | 947 | drm_mga_private_t *dev_priv = dev->dev_private; |
964 | struct drm_buf *buf; | 948 | struct drm_buf *buf; |
965 | drm_mga_buf_priv_t *buf_priv; | 949 | drm_mga_buf_priv_t *buf_priv; |
966 | drm_mga_iload_t iload; | 950 | drm_mga_iload_t *iload = data; |
967 | DRM_DEBUG("\n"); | 951 | DRM_DEBUG("\n"); |
968 | 952 | ||
969 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 953 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
970 | 954 | ||
971 | DRM_COPY_FROM_USER_IOCTL(iload, (drm_mga_iload_t __user *) data, | ||
972 | sizeof(iload)); | ||
973 | |||
974 | #if 0 | 955 | #if 0 |
975 | if (mga_do_wait_for_idle(dev_priv) < 0) { | 956 | if (mga_do_wait_for_idle(dev_priv) < 0) { |
976 | if (MGA_DMA_DEBUG) | 957 | if (MGA_DMA_DEBUG) |
@@ -978,20 +959,20 @@ static int mga_dma_iload(DRM_IOCTL_ARGS) | |||
978 | return -EBUSY; | 959 | return -EBUSY; |
979 | } | 960 | } |
980 | #endif | 961 | #endif |
981 | if (iload.idx < 0 || iload.idx > dma->buf_count) | 962 | if (iload->idx < 0 || iload->idx > dma->buf_count) |
982 | return -EINVAL; | 963 | return -EINVAL; |
983 | 964 | ||
984 | buf = dma->buflist[iload.idx]; | 965 | buf = dma->buflist[iload->idx]; |
985 | buf_priv = buf->dev_private; | 966 | buf_priv = buf->dev_private; |
986 | 967 | ||
987 | if (mga_verify_iload(dev_priv, iload.dstorg, iload.length)) { | 968 | if (mga_verify_iload(dev_priv, iload->dstorg, iload->length)) { |
988 | mga_freelist_put(dev, buf); | 969 | mga_freelist_put(dev, buf); |
989 | return -EINVAL; | 970 | return -EINVAL; |
990 | } | 971 | } |
991 | 972 | ||
992 | WRAP_TEST_WITH_RETURN(dev_priv); | 973 | WRAP_TEST_WITH_RETURN(dev_priv); |
993 | 974 | ||
994 | mga_dma_dispatch_iload(dev, buf, iload.dstorg, iload.length); | 975 | mga_dma_dispatch_iload(dev, buf, iload->dstorg, iload->length); |
995 | 976 | ||
996 | /* Make sure we restore the 3D state next time. | 977 | /* Make sure we restore the 3D state next time. |
997 | */ | 978 | */ |
@@ -1000,28 +981,24 @@ static int mga_dma_iload(DRM_IOCTL_ARGS) | |||
1000 | return 0; | 981 | return 0; |
1001 | } | 982 | } |
1002 | 983 | ||
1003 | static int mga_dma_blit(DRM_IOCTL_ARGS) | 984 | static int mga_dma_blit(struct drm_device *dev, void *data, struct drm_file *file_priv) |
1004 | { | 985 | { |
1005 | DRM_DEVICE; | ||
1006 | drm_mga_private_t *dev_priv = dev->dev_private; | 986 | drm_mga_private_t *dev_priv = dev->dev_private; |
1007 | drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; | 987 | drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; |
1008 | drm_mga_blit_t blit; | 988 | drm_mga_blit_t *blit = data; |
1009 | DRM_DEBUG("\n"); | 989 | DRM_DEBUG("\n"); |
1010 | 990 | ||
1011 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 991 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1012 | 992 | ||
1013 | DRM_COPY_FROM_USER_IOCTL(blit, (drm_mga_blit_t __user *) data, | ||
1014 | sizeof(blit)); | ||
1015 | |||
1016 | if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS) | 993 | if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS) |
1017 | sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS; | 994 | sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS; |
1018 | 995 | ||
1019 | if (mga_verify_blit(dev_priv, blit.srcorg, blit.dstorg)) | 996 | if (mga_verify_blit(dev_priv, blit->srcorg, blit->dstorg)) |
1020 | return -EINVAL; | 997 | return -EINVAL; |
1021 | 998 | ||
1022 | WRAP_TEST_WITH_RETURN(dev_priv); | 999 | WRAP_TEST_WITH_RETURN(dev_priv); |
1023 | 1000 | ||
1024 | mga_dma_dispatch_blit(dev, &blit); | 1001 | mga_dma_dispatch_blit(dev, blit); |
1025 | 1002 | ||
1026 | /* Make sure we restore the 3D state next time. | 1003 | /* Make sure we restore the 3D state next time. |
1027 | */ | 1004 | */ |
@@ -1030,11 +1007,10 @@ static int mga_dma_blit(DRM_IOCTL_ARGS) | |||
1030 | return 0; | 1007 | return 0; |
1031 | } | 1008 | } |
1032 | 1009 | ||
1033 | static int mga_getparam(DRM_IOCTL_ARGS) | 1010 | static int mga_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv) |
1034 | { | 1011 | { |
1035 | DRM_DEVICE; | ||
1036 | drm_mga_private_t *dev_priv = dev->dev_private; | 1012 | drm_mga_private_t *dev_priv = dev->dev_private; |
1037 | drm_mga_getparam_t param; | 1013 | drm_mga_getparam_t *param = data; |
1038 | int value; | 1014 | int value; |
1039 | 1015 | ||
1040 | if (!dev_priv) { | 1016 | if (!dev_priv) { |
@@ -1042,12 +1018,9 @@ static int mga_getparam(DRM_IOCTL_ARGS) | |||
1042 | return -EINVAL; | 1018 | return -EINVAL; |
1043 | } | 1019 | } |
1044 | 1020 | ||
1045 | DRM_COPY_FROM_USER_IOCTL(param, (drm_mga_getparam_t __user *) data, | ||
1046 | sizeof(param)); | ||
1047 | |||
1048 | DRM_DEBUG("pid=%d\n", DRM_CURRENTPID); | 1021 | DRM_DEBUG("pid=%d\n", DRM_CURRENTPID); |
1049 | 1022 | ||
1050 | switch (param.param) { | 1023 | switch (param->param) { |
1051 | case MGA_PARAM_IRQ_NR: | 1024 | case MGA_PARAM_IRQ_NR: |
1052 | value = dev->irq; | 1025 | value = dev->irq; |
1053 | break; | 1026 | break; |
@@ -1058,7 +1031,7 @@ static int mga_getparam(DRM_IOCTL_ARGS) | |||
1058 | return -EINVAL; | 1031 | return -EINVAL; |
1059 | } | 1032 | } |
1060 | 1033 | ||
1061 | if (DRM_COPY_TO_USER(param.value, &value, sizeof(int))) { | 1034 | if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) { |
1062 | DRM_ERROR("copy_to_user\n"); | 1035 | DRM_ERROR("copy_to_user\n"); |
1063 | return -EFAULT; | 1036 | return -EFAULT; |
1064 | } | 1037 | } |
@@ -1066,11 +1039,10 @@ static int mga_getparam(DRM_IOCTL_ARGS) | |||
1066 | return 0; | 1039 | return 0; |
1067 | } | 1040 | } |
1068 | 1041 | ||
1069 | static int mga_set_fence(DRM_IOCTL_ARGS) | 1042 | static int mga_set_fence(struct drm_device *dev, void *data, struct drm_file *file_priv) |
1070 | { | 1043 | { |
1071 | DRM_DEVICE; | ||
1072 | drm_mga_private_t *dev_priv = dev->dev_private; | 1044 | drm_mga_private_t *dev_priv = dev->dev_private; |
1073 | u32 temp; | 1045 | u32 *fence = data; |
1074 | DMA_LOCALS; | 1046 | DMA_LOCALS; |
1075 | 1047 | ||
1076 | if (!dev_priv) { | 1048 | if (!dev_priv) { |
@@ -1080,11 +1052,11 @@ static int mga_set_fence(DRM_IOCTL_ARGS) | |||
1080 | 1052 | ||
1081 | DRM_DEBUG("pid=%d\n", DRM_CURRENTPID); | 1053 | DRM_DEBUG("pid=%d\n", DRM_CURRENTPID); |
1082 | 1054 | ||
1083 | /* I would normal do this assignment in the declaration of temp, | 1055 | /* I would normal do this assignment in the declaration of fence, |
1084 | * but dev_priv may be NULL. | 1056 | * but dev_priv may be NULL. |
1085 | */ | 1057 | */ |
1086 | 1058 | ||
1087 | temp = dev_priv->next_fence_to_post; | 1059 | *fence = dev_priv->next_fence_to_post; |
1088 | dev_priv->next_fence_to_post++; | 1060 | dev_priv->next_fence_to_post++; |
1089 | 1061 | ||
1090 | BEGIN_DMA(1); | 1062 | BEGIN_DMA(1); |
@@ -1093,53 +1065,40 @@ static int mga_set_fence(DRM_IOCTL_ARGS) | |||
1093 | MGA_DMAPAD, 0x00000000, MGA_SOFTRAP, 0x00000000); | 1065 | MGA_DMAPAD, 0x00000000, MGA_SOFTRAP, 0x00000000); |
1094 | ADVANCE_DMA(); | 1066 | ADVANCE_DMA(); |
1095 | 1067 | ||
1096 | if (DRM_COPY_TO_USER((u32 __user *) data, &temp, sizeof(u32))) { | ||
1097 | DRM_ERROR("copy_to_user\n"); | ||
1098 | return -EFAULT; | ||
1099 | } | ||
1100 | |||
1101 | return 0; | 1068 | return 0; |
1102 | } | 1069 | } |
1103 | 1070 | ||
1104 | static int mga_wait_fence(DRM_IOCTL_ARGS) | 1071 | static int mga_wait_fence(struct drm_device *dev, void *data, struct drm_file * |
1072 | file_priv) | ||
1105 | { | 1073 | { |
1106 | DRM_DEVICE; | ||
1107 | drm_mga_private_t *dev_priv = dev->dev_private; | 1074 | drm_mga_private_t *dev_priv = dev->dev_private; |
1108 | u32 fence; | 1075 | u32 *fence = data; |
1109 | 1076 | ||
1110 | if (!dev_priv) { | 1077 | if (!dev_priv) { |
1111 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); | 1078 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); |
1112 | return -EINVAL; | 1079 | return -EINVAL; |
1113 | } | 1080 | } |
1114 | 1081 | ||
1115 | DRM_COPY_FROM_USER_IOCTL(fence, (u32 __user *) data, sizeof(u32)); | ||
1116 | |||
1117 | DRM_DEBUG("pid=%d\n", DRM_CURRENTPID); | 1082 | DRM_DEBUG("pid=%d\n", DRM_CURRENTPID); |
1118 | 1083 | ||
1119 | mga_driver_fence_wait(dev, &fence); | 1084 | mga_driver_fence_wait(dev, fence); |
1120 | |||
1121 | if (DRM_COPY_TO_USER((u32 __user *) data, &fence, sizeof(u32))) { | ||
1122 | DRM_ERROR("copy_to_user\n"); | ||
1123 | return -EFAULT; | ||
1124 | } | ||
1125 | |||
1126 | return 0; | 1085 | return 0; |
1127 | } | 1086 | } |
1128 | 1087 | ||
1129 | drm_ioctl_desc_t mga_ioctls[] = { | 1088 | struct drm_ioctl_desc mga_ioctls[] = { |
1130 | [DRM_IOCTL_NR(DRM_MGA_INIT)] = {mga_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 1089 | DRM_IOCTL_DEF(DRM_MGA_INIT, mga_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
1131 | [DRM_IOCTL_NR(DRM_MGA_FLUSH)] = {mga_dma_flush, DRM_AUTH}, | 1090 | DRM_IOCTL_DEF(DRM_MGA_FLUSH, mga_dma_flush, DRM_AUTH), |
1132 | [DRM_IOCTL_NR(DRM_MGA_RESET)] = {mga_dma_reset, DRM_AUTH}, | 1091 | DRM_IOCTL_DEF(DRM_MGA_RESET, mga_dma_reset, DRM_AUTH), |
1133 | [DRM_IOCTL_NR(DRM_MGA_SWAP)] = {mga_dma_swap, DRM_AUTH}, | 1092 | DRM_IOCTL_DEF(DRM_MGA_SWAP, mga_dma_swap, DRM_AUTH), |
1134 | [DRM_IOCTL_NR(DRM_MGA_CLEAR)] = {mga_dma_clear, DRM_AUTH}, | 1093 | DRM_IOCTL_DEF(DRM_MGA_CLEAR, mga_dma_clear, DRM_AUTH), |
1135 | [DRM_IOCTL_NR(DRM_MGA_VERTEX)] = {mga_dma_vertex, DRM_AUTH}, | 1094 | DRM_IOCTL_DEF(DRM_MGA_VERTEX, mga_dma_vertex, DRM_AUTH), |
1136 | [DRM_IOCTL_NR(DRM_MGA_INDICES)] = {mga_dma_indices, DRM_AUTH}, | 1095 | DRM_IOCTL_DEF(DRM_MGA_INDICES, mga_dma_indices, DRM_AUTH), |
1137 | [DRM_IOCTL_NR(DRM_MGA_ILOAD)] = {mga_dma_iload, DRM_AUTH}, | 1096 | DRM_IOCTL_DEF(DRM_MGA_ILOAD, mga_dma_iload, DRM_AUTH), |
1138 | [DRM_IOCTL_NR(DRM_MGA_BLIT)] = {mga_dma_blit, DRM_AUTH}, | 1097 | DRM_IOCTL_DEF(DRM_MGA_BLIT, mga_dma_blit, DRM_AUTH), |
1139 | [DRM_IOCTL_NR(DRM_MGA_GETPARAM)] = {mga_getparam, DRM_AUTH}, | 1098 | DRM_IOCTL_DEF(DRM_MGA_GETPARAM, mga_getparam, DRM_AUTH), |
1140 | [DRM_IOCTL_NR(DRM_MGA_SET_FENCE)] = {mga_set_fence, DRM_AUTH}, | 1099 | DRM_IOCTL_DEF(DRM_MGA_SET_FENCE, mga_set_fence, DRM_AUTH), |
1141 | [DRM_IOCTL_NR(DRM_MGA_WAIT_FENCE)] = {mga_wait_fence, DRM_AUTH}, | 1100 | DRM_IOCTL_DEF(DRM_MGA_WAIT_FENCE, mga_wait_fence, DRM_AUTH), |
1142 | [DRM_IOCTL_NR(DRM_MGA_DMA_BOOTSTRAP)] = {mga_dma_bootstrap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 1101 | DRM_IOCTL_DEF(DRM_MGA_DMA_BOOTSTRAP, mga_dma_bootstrap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
1143 | }; | 1102 | }; |
1144 | 1103 | ||
1145 | int mga_max_ioctl = DRM_ARRAY_SIZE(mga_ioctls); | 1104 | int mga_max_ioctl = DRM_ARRAY_SIZE(mga_ioctls); |
diff --git a/drivers/char/drm/r128_cce.c b/drivers/char/drm/r128_cce.c index 4dc8acc6eb61..7d550aba165e 100644 --- a/drivers/char/drm/r128_cce.c +++ b/drivers/char/drm/r128_cce.c | |||
@@ -625,21 +625,17 @@ int r128_do_cleanup_cce(struct drm_device * dev) | |||
625 | return 0; | 625 | return 0; |
626 | } | 626 | } |
627 | 627 | ||
628 | int r128_cce_init(DRM_IOCTL_ARGS) | 628 | int r128_cce_init(struct drm_device *dev, void *data, struct drm_file *file_priv) |
629 | { | 629 | { |
630 | DRM_DEVICE; | 630 | drm_r128_init_t *init = data; |
631 | drm_r128_init_t init; | ||
632 | 631 | ||
633 | DRM_DEBUG("\n"); | 632 | DRM_DEBUG("\n"); |
634 | 633 | ||
635 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 634 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
636 | 635 | ||
637 | DRM_COPY_FROM_USER_IOCTL(init, (drm_r128_init_t __user *) data, | 636 | switch (init->func) { |
638 | sizeof(init)); | ||
639 | |||
640 | switch (init.func) { | ||
641 | case R128_INIT_CCE: | 637 | case R128_INIT_CCE: |
642 | return r128_do_init_cce(dev, &init); | 638 | return r128_do_init_cce(dev, init); |
643 | case R128_CLEANUP_CCE: | 639 | case R128_CLEANUP_CCE: |
644 | return r128_do_cleanup_cce(dev); | 640 | return r128_do_cleanup_cce(dev); |
645 | } | 641 | } |
@@ -647,9 +643,8 @@ int r128_cce_init(DRM_IOCTL_ARGS) | |||
647 | return -EINVAL; | 643 | return -EINVAL; |
648 | } | 644 | } |
649 | 645 | ||
650 | int r128_cce_start(DRM_IOCTL_ARGS) | 646 | int r128_cce_start(struct drm_device *dev, void *data, struct drm_file *file_priv) |
651 | { | 647 | { |
652 | DRM_DEVICE; | ||
653 | drm_r128_private_t *dev_priv = dev->dev_private; | 648 | drm_r128_private_t *dev_priv = dev->dev_private; |
654 | DRM_DEBUG("\n"); | 649 | DRM_DEBUG("\n"); |
655 | 650 | ||
@@ -668,30 +663,26 @@ int r128_cce_start(DRM_IOCTL_ARGS) | |||
668 | /* Stop the CCE. The engine must have been idled before calling this | 663 | /* Stop the CCE. The engine must have been idled before calling this |
669 | * routine. | 664 | * routine. |
670 | */ | 665 | */ |
671 | int r128_cce_stop(DRM_IOCTL_ARGS) | 666 | int r128_cce_stop(struct drm_device *dev, void *data, struct drm_file *file_priv) |
672 | { | 667 | { |
673 | DRM_DEVICE; | ||
674 | drm_r128_private_t *dev_priv = dev->dev_private; | 668 | drm_r128_private_t *dev_priv = dev->dev_private; |
675 | drm_r128_cce_stop_t stop; | 669 | drm_r128_cce_stop_t *stop = data; |
676 | int ret; | 670 | int ret; |
677 | DRM_DEBUG("\n"); | 671 | DRM_DEBUG("\n"); |
678 | 672 | ||
679 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 673 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
680 | 674 | ||
681 | DRM_COPY_FROM_USER_IOCTL(stop, (drm_r128_cce_stop_t __user *) data, | ||
682 | sizeof(stop)); | ||
683 | |||
684 | /* Flush any pending CCE commands. This ensures any outstanding | 675 | /* Flush any pending CCE commands. This ensures any outstanding |
685 | * commands are exectuted by the engine before we turn it off. | 676 | * commands are exectuted by the engine before we turn it off. |
686 | */ | 677 | */ |
687 | if (stop.flush) { | 678 | if (stop->flush) { |
688 | r128_do_cce_flush(dev_priv); | 679 | r128_do_cce_flush(dev_priv); |
689 | } | 680 | } |
690 | 681 | ||
691 | /* If we fail to make the engine go idle, we return an error | 682 | /* If we fail to make the engine go idle, we return an error |
692 | * code so that the DRM ioctl wrapper can try again. | 683 | * code so that the DRM ioctl wrapper can try again. |
693 | */ | 684 | */ |
694 | if (stop.idle) { | 685 | if (stop->idle) { |
695 | ret = r128_do_cce_idle(dev_priv); | 686 | ret = r128_do_cce_idle(dev_priv); |
696 | if (ret) | 687 | if (ret) |
697 | return ret; | 688 | return ret; |
@@ -711,9 +702,8 @@ int r128_cce_stop(DRM_IOCTL_ARGS) | |||
711 | 702 | ||
712 | /* Just reset the CCE ring. Called as part of an X Server engine reset. | 703 | /* Just reset the CCE ring. Called as part of an X Server engine reset. |
713 | */ | 704 | */ |
714 | int r128_cce_reset(DRM_IOCTL_ARGS) | 705 | int r128_cce_reset(struct drm_device *dev, void *data, struct drm_file *file_priv) |
715 | { | 706 | { |
716 | DRM_DEVICE; | ||
717 | drm_r128_private_t *dev_priv = dev->dev_private; | 707 | drm_r128_private_t *dev_priv = dev->dev_private; |
718 | DRM_DEBUG("\n"); | 708 | DRM_DEBUG("\n"); |
719 | 709 | ||
@@ -732,9 +722,8 @@ int r128_cce_reset(DRM_IOCTL_ARGS) | |||
732 | return 0; | 722 | return 0; |
733 | } | 723 | } |
734 | 724 | ||
735 | int r128_cce_idle(DRM_IOCTL_ARGS) | 725 | int r128_cce_idle(struct drm_device *dev, void *data, struct drm_file *file_priv) |
736 | { | 726 | { |
737 | DRM_DEVICE; | ||
738 | drm_r128_private_t *dev_priv = dev->dev_private; | 727 | drm_r128_private_t *dev_priv = dev->dev_private; |
739 | DRM_DEBUG("\n"); | 728 | DRM_DEBUG("\n"); |
740 | 729 | ||
@@ -747,9 +736,8 @@ int r128_cce_idle(DRM_IOCTL_ARGS) | |||
747 | return r128_do_cce_idle(dev_priv); | 736 | return r128_do_cce_idle(dev_priv); |
748 | } | 737 | } |
749 | 738 | ||
750 | int r128_engine_reset(DRM_IOCTL_ARGS) | 739 | int r128_engine_reset(struct drm_device *dev, void *data, struct drm_file *file_priv) |
751 | { | 740 | { |
752 | DRM_DEVICE; | ||
753 | DRM_DEBUG("\n"); | 741 | DRM_DEBUG("\n"); |
754 | 742 | ||
755 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 743 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
@@ -757,7 +745,7 @@ int r128_engine_reset(DRM_IOCTL_ARGS) | |||
757 | return r128_do_engine_reset(dev); | 745 | return r128_do_engine_reset(dev); |
758 | } | 746 | } |
759 | 747 | ||
760 | int r128_fullscreen(DRM_IOCTL_ARGS) | 748 | int r128_fullscreen(struct drm_device *dev, void *data, struct drm_file *file_priv) |
761 | { | 749 | { |
762 | return -EINVAL; | 750 | return -EINVAL; |
763 | } | 751 | } |
@@ -912,41 +900,35 @@ static int r128_cce_get_buffers(struct drm_device * dev, | |||
912 | return 0; | 900 | return 0; |
913 | } | 901 | } |
914 | 902 | ||
915 | int r128_cce_buffers(DRM_IOCTL_ARGS) | 903 | int r128_cce_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv) |
916 | { | 904 | { |
917 | DRM_DEVICE; | ||
918 | struct drm_device_dma *dma = dev->dma; | 905 | struct drm_device_dma *dma = dev->dma; |
919 | int ret = 0; | 906 | int ret = 0; |
920 | struct drm_dma __user *argp = (void __user *)data; | 907 | struct drm_dma *d = data; |
921 | struct drm_dma d; | ||
922 | 908 | ||
923 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 909 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
924 | 910 | ||
925 | DRM_COPY_FROM_USER_IOCTL(d, argp, sizeof(d)); | ||
926 | |||
927 | /* Please don't send us buffers. | 911 | /* Please don't send us buffers. |
928 | */ | 912 | */ |
929 | if (d.send_count != 0) { | 913 | if (d->send_count != 0) { |
930 | DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n", | 914 | DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n", |
931 | DRM_CURRENTPID, d.send_count); | 915 | DRM_CURRENTPID, d->send_count); |
932 | return -EINVAL; | 916 | return -EINVAL; |
933 | } | 917 | } |
934 | 918 | ||
935 | /* We'll send you buffers. | 919 | /* We'll send you buffers. |
936 | */ | 920 | */ |
937 | if (d.request_count < 0 || d.request_count > dma->buf_count) { | 921 | if (d->request_count < 0 || d->request_count > dma->buf_count) { |
938 | DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", | 922 | DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", |
939 | DRM_CURRENTPID, d.request_count, dma->buf_count); | 923 | DRM_CURRENTPID, d->request_count, dma->buf_count); |
940 | return -EINVAL; | 924 | return -EINVAL; |
941 | } | 925 | } |
942 | 926 | ||
943 | d.granted_count = 0; | 927 | d->granted_count = 0; |
944 | 928 | ||
945 | if (d.request_count) { | 929 | if (d->request_count) { |
946 | ret = r128_cce_get_buffers(dev, file_priv, &d); | 930 | ret = r128_cce_get_buffers(dev, file_priv, d); |
947 | } | 931 | } |
948 | 932 | ||
949 | DRM_COPY_TO_USER_IOCTL(argp, d, sizeof(d)); | ||
950 | |||
951 | return ret; | 933 | return ret; |
952 | } | 934 | } |
diff --git a/drivers/char/drm/r128_drv.h b/drivers/char/drm/r128_drv.h index 580b182eadb1..250d2aa46581 100644 --- a/drivers/char/drm/r128_drv.h +++ b/drivers/char/drm/r128_drv.h | |||
@@ -129,18 +129,18 @@ typedef struct drm_r128_buf_priv { | |||
129 | drm_r128_freelist_t *list_entry; | 129 | drm_r128_freelist_t *list_entry; |
130 | } drm_r128_buf_priv_t; | 130 | } drm_r128_buf_priv_t; |
131 | 131 | ||
132 | extern drm_ioctl_desc_t r128_ioctls[]; | 132 | extern struct drm_ioctl_desc r128_ioctls[]; |
133 | extern int r128_max_ioctl; | 133 | extern int r128_max_ioctl; |
134 | 134 | ||
135 | /* r128_cce.c */ | 135 | /* r128_cce.c */ |
136 | extern int r128_cce_init(DRM_IOCTL_ARGS); | 136 | extern int r128_cce_init(struct drm_device *dev, void *data, struct drm_file *file_priv); |
137 | extern int r128_cce_start(DRM_IOCTL_ARGS); | 137 | extern int r128_cce_start(struct drm_device *dev, void *data, struct drm_file *file_priv); |
138 | extern int r128_cce_stop(DRM_IOCTL_ARGS); | 138 | extern int r128_cce_stop(struct drm_device *dev, void *data, struct drm_file *file_priv); |
139 | extern int r128_cce_reset(DRM_IOCTL_ARGS); | 139 | extern int r128_cce_reset(struct drm_device *dev, void *data, struct drm_file *file_priv); |
140 | extern int r128_cce_idle(DRM_IOCTL_ARGS); | 140 | extern int r128_cce_idle(struct drm_device *dev, void *data, struct drm_file *file_priv); |
141 | extern int r128_engine_reset(DRM_IOCTL_ARGS); | 141 | extern int r128_engine_reset(struct drm_device *dev, void *data, struct drm_file *file_priv); |
142 | extern int r128_fullscreen(DRM_IOCTL_ARGS); | 142 | extern int r128_fullscreen(struct drm_device *dev, void *data, struct drm_file *file_priv); |
143 | extern int r128_cce_buffers(DRM_IOCTL_ARGS); | 143 | extern int r128_cce_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv); |
144 | 144 | ||
145 | extern void r128_freelist_reset(struct drm_device * dev); | 145 | extern void r128_freelist_reset(struct drm_device * dev); |
146 | 146 | ||
diff --git a/drivers/char/drm/r128_state.c b/drivers/char/drm/r128_state.c index 029f63b59a7d..b7f483cac6d4 100644 --- a/drivers/char/drm/r128_state.c +++ b/drivers/char/drm/r128_state.c | |||
@@ -1242,25 +1242,21 @@ static void r128_cce_dispatch_stipple(struct drm_device * dev, u32 * stipple) | |||
1242 | * IOCTL functions | 1242 | * IOCTL functions |
1243 | */ | 1243 | */ |
1244 | 1244 | ||
1245 | static int r128_cce_clear(DRM_IOCTL_ARGS) | 1245 | static int r128_cce_clear(struct drm_device *dev, void *data, struct drm_file *file_priv) |
1246 | { | 1246 | { |
1247 | DRM_DEVICE; | ||
1248 | drm_r128_private_t *dev_priv = dev->dev_private; | 1247 | drm_r128_private_t *dev_priv = dev->dev_private; |
1249 | drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; | 1248 | drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; |
1250 | drm_r128_clear_t clear; | 1249 | drm_r128_clear_t *clear = data; |
1251 | DRM_DEBUG("\n"); | 1250 | DRM_DEBUG("\n"); |
1252 | 1251 | ||
1253 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1252 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1254 | 1253 | ||
1255 | DRM_COPY_FROM_USER_IOCTL(clear, (drm_r128_clear_t __user *) data, | ||
1256 | sizeof(clear)); | ||
1257 | |||
1258 | RING_SPACE_TEST_WITH_RETURN(dev_priv); | 1254 | RING_SPACE_TEST_WITH_RETURN(dev_priv); |
1259 | 1255 | ||
1260 | if (sarea_priv->nbox > R128_NR_SAREA_CLIPRECTS) | 1256 | if (sarea_priv->nbox > R128_NR_SAREA_CLIPRECTS) |
1261 | sarea_priv->nbox = R128_NR_SAREA_CLIPRECTS; | 1257 | sarea_priv->nbox = R128_NR_SAREA_CLIPRECTS; |
1262 | 1258 | ||
1263 | r128_cce_dispatch_clear(dev, &clear); | 1259 | r128_cce_dispatch_clear(dev, clear); |
1264 | COMMIT_RING(); | 1260 | COMMIT_RING(); |
1265 | 1261 | ||
1266 | /* Make sure we restore the 3D state next time. | 1262 | /* Make sure we restore the 3D state next time. |
@@ -1310,9 +1306,8 @@ static int r128_do_cleanup_pageflip(struct drm_device * dev) | |||
1310 | * They can & should be intermixed to support multiple 3d windows. | 1306 | * They can & should be intermixed to support multiple 3d windows. |
1311 | */ | 1307 | */ |
1312 | 1308 | ||
1313 | static int r128_cce_flip(DRM_IOCTL_ARGS) | 1309 | static int r128_cce_flip(struct drm_device *dev, void *data, struct drm_file *file_priv) |
1314 | { | 1310 | { |
1315 | DRM_DEVICE; | ||
1316 | drm_r128_private_t *dev_priv = dev->dev_private; | 1311 | drm_r128_private_t *dev_priv = dev->dev_private; |
1317 | DRM_DEBUG("%s\n", __FUNCTION__); | 1312 | DRM_DEBUG("%s\n", __FUNCTION__); |
1318 | 1313 | ||
@@ -1329,9 +1324,8 @@ static int r128_cce_flip(DRM_IOCTL_ARGS) | |||
1329 | return 0; | 1324 | return 0; |
1330 | } | 1325 | } |
1331 | 1326 | ||
1332 | static int r128_cce_swap(DRM_IOCTL_ARGS) | 1327 | static int r128_cce_swap(struct drm_device *dev, void *data, struct drm_file *file_priv) |
1333 | { | 1328 | { |
1334 | DRM_DEVICE; | ||
1335 | drm_r128_private_t *dev_priv = dev->dev_private; | 1329 | drm_r128_private_t *dev_priv = dev->dev_private; |
1336 | drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; | 1330 | drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; |
1337 | DRM_DEBUG("%s\n", __FUNCTION__); | 1331 | DRM_DEBUG("%s\n", __FUNCTION__); |
@@ -1351,14 +1345,13 @@ static int r128_cce_swap(DRM_IOCTL_ARGS) | |||
1351 | return 0; | 1345 | return 0; |
1352 | } | 1346 | } |
1353 | 1347 | ||
1354 | static int r128_cce_vertex(DRM_IOCTL_ARGS) | 1348 | static int r128_cce_vertex(struct drm_device *dev, void *data, struct drm_file *file_priv) |
1355 | { | 1349 | { |
1356 | DRM_DEVICE; | ||
1357 | drm_r128_private_t *dev_priv = dev->dev_private; | 1350 | drm_r128_private_t *dev_priv = dev->dev_private; |
1358 | struct drm_device_dma *dma = dev->dma; | 1351 | struct drm_device_dma *dma = dev->dma; |
1359 | struct drm_buf *buf; | 1352 | struct drm_buf *buf; |
1360 | drm_r128_buf_priv_t *buf_priv; | 1353 | drm_r128_buf_priv_t *buf_priv; |
1361 | drm_r128_vertex_t vertex; | 1354 | drm_r128_vertex_t *vertex = data; |
1362 | 1355 | ||
1363 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1356 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1364 | 1357 | ||
@@ -1367,27 +1360,24 @@ static int r128_cce_vertex(DRM_IOCTL_ARGS) | |||
1367 | return -EINVAL; | 1360 | return -EINVAL; |
1368 | } | 1361 | } |
1369 | 1362 | ||
1370 | DRM_COPY_FROM_USER_IOCTL(vertex, (drm_r128_vertex_t __user *) data, | ||
1371 | sizeof(vertex)); | ||
1372 | |||
1373 | DRM_DEBUG("pid=%d index=%d count=%d discard=%d\n", | 1363 | DRM_DEBUG("pid=%d index=%d count=%d discard=%d\n", |
1374 | DRM_CURRENTPID, vertex.idx, vertex.count, vertex.discard); | 1364 | DRM_CURRENTPID, vertex->idx, vertex->count, vertex->discard); |
1375 | 1365 | ||
1376 | if (vertex.idx < 0 || vertex.idx >= dma->buf_count) { | 1366 | if (vertex->idx < 0 || vertex->idx >= dma->buf_count) { |
1377 | DRM_ERROR("buffer index %d (of %d max)\n", | 1367 | DRM_ERROR("buffer index %d (of %d max)\n", |
1378 | vertex.idx, dma->buf_count - 1); | 1368 | vertex->idx, dma->buf_count - 1); |
1379 | return -EINVAL; | 1369 | return -EINVAL; |
1380 | } | 1370 | } |
1381 | if (vertex.prim < 0 || | 1371 | if (vertex->prim < 0 || |
1382 | vertex.prim > R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2) { | 1372 | vertex->prim > R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2) { |
1383 | DRM_ERROR("buffer prim %d\n", vertex.prim); | 1373 | DRM_ERROR("buffer prim %d\n", vertex->prim); |
1384 | return -EINVAL; | 1374 | return -EINVAL; |
1385 | } | 1375 | } |
1386 | 1376 | ||
1387 | RING_SPACE_TEST_WITH_RETURN(dev_priv); | 1377 | RING_SPACE_TEST_WITH_RETURN(dev_priv); |
1388 | VB_AGE_TEST_WITH_RETURN(dev_priv); | 1378 | VB_AGE_TEST_WITH_RETURN(dev_priv); |
1389 | 1379 | ||
1390 | buf = dma->buflist[vertex.idx]; | 1380 | buf = dma->buflist[vertex->idx]; |
1391 | buf_priv = buf->dev_private; | 1381 | buf_priv = buf->dev_private; |
1392 | 1382 | ||
1393 | if (buf->file_priv != file_priv) { | 1383 | if (buf->file_priv != file_priv) { |
@@ -1396,13 +1386,13 @@ static int r128_cce_vertex(DRM_IOCTL_ARGS) | |||
1396 | return -EINVAL; | 1386 | return -EINVAL; |
1397 | } | 1387 | } |
1398 | if (buf->pending) { | 1388 | if (buf->pending) { |
1399 | DRM_ERROR("sending pending buffer %d\n", vertex.idx); | 1389 | DRM_ERROR("sending pending buffer %d\n", vertex->idx); |
1400 | return -EINVAL; | 1390 | return -EINVAL; |
1401 | } | 1391 | } |
1402 | 1392 | ||
1403 | buf->used = vertex.count; | 1393 | buf->used = vertex->count; |
1404 | buf_priv->prim = vertex.prim; | 1394 | buf_priv->prim = vertex->prim; |
1405 | buf_priv->discard = vertex.discard; | 1395 | buf_priv->discard = vertex->discard; |
1406 | 1396 | ||
1407 | r128_cce_dispatch_vertex(dev, buf); | 1397 | r128_cce_dispatch_vertex(dev, buf); |
1408 | 1398 | ||
@@ -1410,14 +1400,13 @@ static int r128_cce_vertex(DRM_IOCTL_ARGS) | |||
1410 | return 0; | 1400 | return 0; |
1411 | } | 1401 | } |
1412 | 1402 | ||
1413 | static int r128_cce_indices(DRM_IOCTL_ARGS) | 1403 | static int r128_cce_indices(struct drm_device *dev, void *data, struct drm_file *file_priv) |
1414 | { | 1404 | { |
1415 | DRM_DEVICE; | ||
1416 | drm_r128_private_t *dev_priv = dev->dev_private; | 1405 | drm_r128_private_t *dev_priv = dev->dev_private; |
1417 | struct drm_device_dma *dma = dev->dma; | 1406 | struct drm_device_dma *dma = dev->dma; |
1418 | struct drm_buf *buf; | 1407 | struct drm_buf *buf; |
1419 | drm_r128_buf_priv_t *buf_priv; | 1408 | drm_r128_buf_priv_t *buf_priv; |
1420 | drm_r128_indices_t elts; | 1409 | drm_r128_indices_t *elts = data; |
1421 | int count; | 1410 | int count; |
1422 | 1411 | ||
1423 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1412 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
@@ -1427,26 +1416,24 @@ static int r128_cce_indices(DRM_IOCTL_ARGS) | |||
1427 | return -EINVAL; | 1416 | return -EINVAL; |
1428 | } | 1417 | } |
1429 | 1418 | ||
1430 | DRM_COPY_FROM_USER_IOCTL(elts, (drm_r128_indices_t __user *) data, | ||
1431 | sizeof(elts)); | ||
1432 | |||
1433 | DRM_DEBUG("pid=%d buf=%d s=%d e=%d d=%d\n", DRM_CURRENTPID, | 1419 | DRM_DEBUG("pid=%d buf=%d s=%d e=%d d=%d\n", DRM_CURRENTPID, |
1434 | elts.idx, elts.start, elts.end, elts.discard); | 1420 | elts->idx, elts->start, elts->end, elts->discard); |
1435 | 1421 | ||
1436 | if (elts.idx < 0 || elts.idx >= dma->buf_count) { | 1422 | if (elts->idx < 0 || elts->idx >= dma->buf_count) { |
1437 | DRM_ERROR("buffer index %d (of %d max)\n", | 1423 | DRM_ERROR("buffer index %d (of %d max)\n", |
1438 | elts.idx, dma->buf_count - 1); | 1424 | elts->idx, dma->buf_count - 1); |
1439 | return -EINVAL; | 1425 | return -EINVAL; |
1440 | } | 1426 | } |
1441 | if (elts.prim < 0 || elts.prim > R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2) { | 1427 | if (elts->prim < 0 || |
1442 | DRM_ERROR("buffer prim %d\n", elts.prim); | 1428 | elts->prim > R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2) { |
1429 | DRM_ERROR("buffer prim %d\n", elts->prim); | ||
1443 | return -EINVAL; | 1430 | return -EINVAL; |
1444 | } | 1431 | } |
1445 | 1432 | ||
1446 | RING_SPACE_TEST_WITH_RETURN(dev_priv); | 1433 | RING_SPACE_TEST_WITH_RETURN(dev_priv); |
1447 | VB_AGE_TEST_WITH_RETURN(dev_priv); | 1434 | VB_AGE_TEST_WITH_RETURN(dev_priv); |
1448 | 1435 | ||
1449 | buf = dma->buflist[elts.idx]; | 1436 | buf = dma->buflist[elts->idx]; |
1450 | buf_priv = buf->dev_private; | 1437 | buf_priv = buf->dev_private; |
1451 | 1438 | ||
1452 | if (buf->file_priv != file_priv) { | 1439 | if (buf->file_priv != file_priv) { |
@@ -1455,89 +1442,81 @@ static int r128_cce_indices(DRM_IOCTL_ARGS) | |||
1455 | return -EINVAL; | 1442 | return -EINVAL; |
1456 | } | 1443 | } |
1457 | if (buf->pending) { | 1444 | if (buf->pending) { |
1458 | DRM_ERROR("sending pending buffer %d\n", elts.idx); | 1445 | DRM_ERROR("sending pending buffer %d\n", elts->idx); |
1459 | return -EINVAL; | 1446 | return -EINVAL; |
1460 | } | 1447 | } |
1461 | 1448 | ||
1462 | count = (elts.end - elts.start) / sizeof(u16); | 1449 | count = (elts->end - elts->start) / sizeof(u16); |
1463 | elts.start -= R128_INDEX_PRIM_OFFSET; | 1450 | elts->start -= R128_INDEX_PRIM_OFFSET; |
1464 | 1451 | ||
1465 | if (elts.start & 0x7) { | 1452 | if (elts->start & 0x7) { |
1466 | DRM_ERROR("misaligned buffer 0x%x\n", elts.start); | 1453 | DRM_ERROR("misaligned buffer 0x%x\n", elts->start); |
1467 | return -EINVAL; | 1454 | return -EINVAL; |
1468 | } | 1455 | } |
1469 | if (elts.start < buf->used) { | 1456 | if (elts->start < buf->used) { |
1470 | DRM_ERROR("no header 0x%x - 0x%x\n", elts.start, buf->used); | 1457 | DRM_ERROR("no header 0x%x - 0x%x\n", elts->start, buf->used); |
1471 | return -EINVAL; | 1458 | return -EINVAL; |
1472 | } | 1459 | } |
1473 | 1460 | ||
1474 | buf->used = elts.end; | 1461 | buf->used = elts->end; |
1475 | buf_priv->prim = elts.prim; | 1462 | buf_priv->prim = elts->prim; |
1476 | buf_priv->discard = elts.discard; | 1463 | buf_priv->discard = elts->discard; |
1477 | 1464 | ||
1478 | r128_cce_dispatch_indices(dev, buf, elts.start, elts.end, count); | 1465 | r128_cce_dispatch_indices(dev, buf, elts->start, elts->end, count); |
1479 | 1466 | ||
1480 | COMMIT_RING(); | 1467 | COMMIT_RING(); |
1481 | return 0; | 1468 | return 0; |
1482 | } | 1469 | } |
1483 | 1470 | ||
1484 | static int r128_cce_blit(DRM_IOCTL_ARGS) | 1471 | static int r128_cce_blit(struct drm_device *dev, void *data, struct drm_file *file_priv) |
1485 | { | 1472 | { |
1486 | DRM_DEVICE; | ||
1487 | struct drm_device_dma *dma = dev->dma; | 1473 | struct drm_device_dma *dma = dev->dma; |
1488 | drm_r128_private_t *dev_priv = dev->dev_private; | 1474 | drm_r128_private_t *dev_priv = dev->dev_private; |
1489 | drm_r128_blit_t blit; | 1475 | drm_r128_blit_t *blit = data; |
1490 | int ret; | 1476 | int ret; |
1491 | 1477 | ||
1492 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1478 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1493 | 1479 | ||
1494 | DRM_COPY_FROM_USER_IOCTL(blit, (drm_r128_blit_t __user *) data, | 1480 | DRM_DEBUG("pid=%d index=%d\n", DRM_CURRENTPID, blit->idx); |
1495 | sizeof(blit)); | ||
1496 | |||
1497 | DRM_DEBUG("pid=%d index=%d\n", DRM_CURRENTPID, blit.idx); | ||
1498 | 1481 | ||
1499 | if (blit.idx < 0 || blit.idx >= dma->buf_count) { | 1482 | if (blit->idx < 0 || blit->idx >= dma->buf_count) { |
1500 | DRM_ERROR("buffer index %d (of %d max)\n", | 1483 | DRM_ERROR("buffer index %d (of %d max)\n", |
1501 | blit.idx, dma->buf_count - 1); | 1484 | blit->idx, dma->buf_count - 1); |
1502 | return -EINVAL; | 1485 | return -EINVAL; |
1503 | } | 1486 | } |
1504 | 1487 | ||
1505 | RING_SPACE_TEST_WITH_RETURN(dev_priv); | 1488 | RING_SPACE_TEST_WITH_RETURN(dev_priv); |
1506 | VB_AGE_TEST_WITH_RETURN(dev_priv); | 1489 | VB_AGE_TEST_WITH_RETURN(dev_priv); |
1507 | 1490 | ||
1508 | ret = r128_cce_dispatch_blit(dev, file_priv, &blit); | 1491 | ret = r128_cce_dispatch_blit(dev, file_priv, blit); |
1509 | 1492 | ||
1510 | COMMIT_RING(); | 1493 | COMMIT_RING(); |
1511 | return ret; | 1494 | return ret; |
1512 | } | 1495 | } |
1513 | 1496 | ||
1514 | static int r128_cce_depth(DRM_IOCTL_ARGS) | 1497 | static int r128_cce_depth(struct drm_device *dev, void *data, struct drm_file *file_priv) |
1515 | { | 1498 | { |
1516 | DRM_DEVICE; | ||
1517 | drm_r128_private_t *dev_priv = dev->dev_private; | 1499 | drm_r128_private_t *dev_priv = dev->dev_private; |
1518 | drm_r128_depth_t depth; | 1500 | drm_r128_depth_t *depth = data; |
1519 | int ret; | 1501 | int ret; |
1520 | 1502 | ||
1521 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1503 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1522 | 1504 | ||
1523 | DRM_COPY_FROM_USER_IOCTL(depth, (drm_r128_depth_t __user *) data, | ||
1524 | sizeof(depth)); | ||
1525 | |||
1526 | RING_SPACE_TEST_WITH_RETURN(dev_priv); | 1505 | RING_SPACE_TEST_WITH_RETURN(dev_priv); |
1527 | 1506 | ||
1528 | ret = -EINVAL; | 1507 | ret = -EINVAL; |
1529 | switch (depth.func) { | 1508 | switch (depth->func) { |
1530 | case R128_WRITE_SPAN: | 1509 | case R128_WRITE_SPAN: |
1531 | ret = r128_cce_dispatch_write_span(dev, &depth); | 1510 | ret = r128_cce_dispatch_write_span(dev, depth); |
1532 | break; | 1511 | break; |
1533 | case R128_WRITE_PIXELS: | 1512 | case R128_WRITE_PIXELS: |
1534 | ret = r128_cce_dispatch_write_pixels(dev, &depth); | 1513 | ret = r128_cce_dispatch_write_pixels(dev, depth); |
1535 | break; | 1514 | break; |
1536 | case R128_READ_SPAN: | 1515 | case R128_READ_SPAN: |
1537 | ret = r128_cce_dispatch_read_span(dev, &depth); | 1516 | ret = r128_cce_dispatch_read_span(dev, depth); |
1538 | break; | 1517 | break; |
1539 | case R128_READ_PIXELS: | 1518 | case R128_READ_PIXELS: |
1540 | ret = r128_cce_dispatch_read_pixels(dev, &depth); | 1519 | ret = r128_cce_dispatch_read_pixels(dev, depth); |
1541 | break; | 1520 | break; |
1542 | } | 1521 | } |
1543 | 1522 | ||
@@ -1545,19 +1524,15 @@ static int r128_cce_depth(DRM_IOCTL_ARGS) | |||
1545 | return ret; | 1524 | return ret; |
1546 | } | 1525 | } |
1547 | 1526 | ||
1548 | static int r128_cce_stipple(DRM_IOCTL_ARGS) | 1527 | static int r128_cce_stipple(struct drm_device *dev, void *data, struct drm_file *file_priv) |
1549 | { | 1528 | { |
1550 | DRM_DEVICE; | ||
1551 | drm_r128_private_t *dev_priv = dev->dev_private; | 1529 | drm_r128_private_t *dev_priv = dev->dev_private; |
1552 | drm_r128_stipple_t stipple; | 1530 | drm_r128_stipple_t *stipple = data; |
1553 | u32 mask[32]; | 1531 | u32 mask[32]; |
1554 | 1532 | ||
1555 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1533 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1556 | 1534 | ||
1557 | DRM_COPY_FROM_USER_IOCTL(stipple, (drm_r128_stipple_t __user *) data, | 1535 | if (DRM_COPY_FROM_USER(&mask, stipple->mask, 32 * sizeof(u32))) |
1558 | sizeof(stipple)); | ||
1559 | |||
1560 | if (DRM_COPY_FROM_USER(&mask, stipple.mask, 32 * sizeof(u32))) | ||
1561 | return -EFAULT; | 1536 | return -EFAULT; |
1562 | 1537 | ||
1563 | RING_SPACE_TEST_WITH_RETURN(dev_priv); | 1538 | RING_SPACE_TEST_WITH_RETURN(dev_priv); |
@@ -1568,14 +1543,13 @@ static int r128_cce_stipple(DRM_IOCTL_ARGS) | |||
1568 | return 0; | 1543 | return 0; |
1569 | } | 1544 | } |
1570 | 1545 | ||
1571 | static int r128_cce_indirect(DRM_IOCTL_ARGS) | 1546 | static int r128_cce_indirect(struct drm_device *dev, void *data, struct drm_file *file_priv) |
1572 | { | 1547 | { |
1573 | DRM_DEVICE; | ||
1574 | drm_r128_private_t *dev_priv = dev->dev_private; | 1548 | drm_r128_private_t *dev_priv = dev->dev_private; |
1575 | struct drm_device_dma *dma = dev->dma; | 1549 | struct drm_device_dma *dma = dev->dma; |
1576 | struct drm_buf *buf; | 1550 | struct drm_buf *buf; |
1577 | drm_r128_buf_priv_t *buf_priv; | 1551 | drm_r128_buf_priv_t *buf_priv; |
1578 | drm_r128_indirect_t indirect; | 1552 | drm_r128_indirect_t *indirect = data; |
1579 | #if 0 | 1553 | #if 0 |
1580 | RING_LOCALS; | 1554 | RING_LOCALS; |
1581 | #endif | 1555 | #endif |
@@ -1587,19 +1561,17 @@ static int r128_cce_indirect(DRM_IOCTL_ARGS) | |||
1587 | return -EINVAL; | 1561 | return -EINVAL; |
1588 | } | 1562 | } |
1589 | 1563 | ||
1590 | DRM_COPY_FROM_USER_IOCTL(indirect, (drm_r128_indirect_t __user *) data, | ||
1591 | sizeof(indirect)); | ||
1592 | |||
1593 | DRM_DEBUG("indirect: idx=%d s=%d e=%d d=%d\n", | 1564 | DRM_DEBUG("indirect: idx=%d s=%d e=%d d=%d\n", |
1594 | indirect.idx, indirect.start, indirect.end, indirect.discard); | 1565 | indirect->idx, indirect->start, indirect->end, |
1566 | indirect->discard); | ||
1595 | 1567 | ||
1596 | if (indirect.idx < 0 || indirect.idx >= dma->buf_count) { | 1568 | if (indirect->idx < 0 || indirect->idx >= dma->buf_count) { |
1597 | DRM_ERROR("buffer index %d (of %d max)\n", | 1569 | DRM_ERROR("buffer index %d (of %d max)\n", |
1598 | indirect.idx, dma->buf_count - 1); | 1570 | indirect->idx, dma->buf_count - 1); |
1599 | return -EINVAL; | 1571 | return -EINVAL; |
1600 | } | 1572 | } |
1601 | 1573 | ||
1602 | buf = dma->buflist[indirect.idx]; | 1574 | buf = dma->buflist[indirect->idx]; |
1603 | buf_priv = buf->dev_private; | 1575 | buf_priv = buf->dev_private; |
1604 | 1576 | ||
1605 | if (buf->file_priv != file_priv) { | 1577 | if (buf->file_priv != file_priv) { |
@@ -1608,21 +1580,21 @@ static int r128_cce_indirect(DRM_IOCTL_ARGS) | |||
1608 | return -EINVAL; | 1580 | return -EINVAL; |
1609 | } | 1581 | } |
1610 | if (buf->pending) { | 1582 | if (buf->pending) { |
1611 | DRM_ERROR("sending pending buffer %d\n", indirect.idx); | 1583 | DRM_ERROR("sending pending buffer %d\n", indirect->idx); |
1612 | return -EINVAL; | 1584 | return -EINVAL; |
1613 | } | 1585 | } |
1614 | 1586 | ||
1615 | if (indirect.start < buf->used) { | 1587 | if (indirect->start < buf->used) { |
1616 | DRM_ERROR("reusing indirect: start=0x%x actual=0x%x\n", | 1588 | DRM_ERROR("reusing indirect: start=0x%x actual=0x%x\n", |
1617 | indirect.start, buf->used); | 1589 | indirect->start, buf->used); |
1618 | return -EINVAL; | 1590 | return -EINVAL; |
1619 | } | 1591 | } |
1620 | 1592 | ||
1621 | RING_SPACE_TEST_WITH_RETURN(dev_priv); | 1593 | RING_SPACE_TEST_WITH_RETURN(dev_priv); |
1622 | VB_AGE_TEST_WITH_RETURN(dev_priv); | 1594 | VB_AGE_TEST_WITH_RETURN(dev_priv); |
1623 | 1595 | ||
1624 | buf->used = indirect.end; | 1596 | buf->used = indirect->end; |
1625 | buf_priv->discard = indirect.discard; | 1597 | buf_priv->discard = indirect->discard; |
1626 | 1598 | ||
1627 | #if 0 | 1599 | #if 0 |
1628 | /* Wait for the 3D stream to idle before the indirect buffer | 1600 | /* Wait for the 3D stream to idle before the indirect buffer |
@@ -1637,17 +1609,16 @@ static int r128_cce_indirect(DRM_IOCTL_ARGS) | |||
1637 | * X server. This is insecure and is thus only available to | 1609 | * X server. This is insecure and is thus only available to |
1638 | * privileged clients. | 1610 | * privileged clients. |
1639 | */ | 1611 | */ |
1640 | r128_cce_dispatch_indirect(dev, buf, indirect.start, indirect.end); | 1612 | r128_cce_dispatch_indirect(dev, buf, indirect->start, indirect->end); |
1641 | 1613 | ||
1642 | COMMIT_RING(); | 1614 | COMMIT_RING(); |
1643 | return 0; | 1615 | return 0; |
1644 | } | 1616 | } |
1645 | 1617 | ||
1646 | static int r128_getparam(DRM_IOCTL_ARGS) | 1618 | static int r128_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv) |
1647 | { | 1619 | { |
1648 | DRM_DEVICE; | ||
1649 | drm_r128_private_t *dev_priv = dev->dev_private; | 1620 | drm_r128_private_t *dev_priv = dev->dev_private; |
1650 | drm_r128_getparam_t param; | 1621 | drm_r128_getparam_t *param = data; |
1651 | int value; | 1622 | int value; |
1652 | 1623 | ||
1653 | if (!dev_priv) { | 1624 | if (!dev_priv) { |
@@ -1655,12 +1626,9 @@ static int r128_getparam(DRM_IOCTL_ARGS) | |||
1655 | return -EINVAL; | 1626 | return -EINVAL; |
1656 | } | 1627 | } |
1657 | 1628 | ||
1658 | DRM_COPY_FROM_USER_IOCTL(param, (drm_r128_getparam_t __user *) data, | ||
1659 | sizeof(param)); | ||
1660 | |||
1661 | DRM_DEBUG("pid=%d\n", DRM_CURRENTPID); | 1629 | DRM_DEBUG("pid=%d\n", DRM_CURRENTPID); |
1662 | 1630 | ||
1663 | switch (param.param) { | 1631 | switch (param->param) { |
1664 | case R128_PARAM_IRQ_NR: | 1632 | case R128_PARAM_IRQ_NR: |
1665 | value = dev->irq; | 1633 | value = dev->irq; |
1666 | break; | 1634 | break; |
@@ -1668,7 +1636,7 @@ static int r128_getparam(DRM_IOCTL_ARGS) | |||
1668 | return -EINVAL; | 1636 | return -EINVAL; |
1669 | } | 1637 | } |
1670 | 1638 | ||
1671 | if (DRM_COPY_TO_USER(param.value, &value, sizeof(int))) { | 1639 | if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) { |
1672 | DRM_ERROR("copy_to_user\n"); | 1640 | DRM_ERROR("copy_to_user\n"); |
1673 | return -EFAULT; | 1641 | return -EFAULT; |
1674 | } | 1642 | } |
@@ -1691,24 +1659,24 @@ void r128_driver_lastclose(struct drm_device * dev) | |||
1691 | r128_do_cleanup_cce(dev); | 1659 | r128_do_cleanup_cce(dev); |
1692 | } | 1660 | } |
1693 | 1661 | ||
1694 | drm_ioctl_desc_t r128_ioctls[] = { | 1662 | struct drm_ioctl_desc r128_ioctls[] = { |
1695 | [DRM_IOCTL_NR(DRM_R128_INIT)] = {r128_cce_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 1663 | DRM_IOCTL_DEF(DRM_R128_INIT, r128_cce_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
1696 | [DRM_IOCTL_NR(DRM_R128_CCE_START)] = {r128_cce_start, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 1664 | DRM_IOCTL_DEF(DRM_R128_CCE_START, r128_cce_start, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
1697 | [DRM_IOCTL_NR(DRM_R128_CCE_STOP)] = {r128_cce_stop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 1665 | DRM_IOCTL_DEF(DRM_R128_CCE_STOP, r128_cce_stop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
1698 | [DRM_IOCTL_NR(DRM_R128_CCE_RESET)] = {r128_cce_reset, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 1666 | DRM_IOCTL_DEF(DRM_R128_CCE_RESET, r128_cce_reset, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
1699 | [DRM_IOCTL_NR(DRM_R128_CCE_IDLE)] = {r128_cce_idle, DRM_AUTH}, | 1667 | DRM_IOCTL_DEF(DRM_R128_CCE_IDLE, r128_cce_idle, DRM_AUTH), |
1700 | [DRM_IOCTL_NR(DRM_R128_RESET)] = {r128_engine_reset, DRM_AUTH}, | 1668 | DRM_IOCTL_DEF(DRM_R128_RESET, r128_engine_reset, DRM_AUTH), |
1701 | [DRM_IOCTL_NR(DRM_R128_FULLSCREEN)] = {r128_fullscreen, DRM_AUTH}, | 1669 | DRM_IOCTL_DEF(DRM_R128_FULLSCREEN, r128_fullscreen, DRM_AUTH), |
1702 | [DRM_IOCTL_NR(DRM_R128_SWAP)] = {r128_cce_swap, DRM_AUTH}, | 1670 | DRM_IOCTL_DEF(DRM_R128_SWAP, r128_cce_swap, DRM_AUTH), |
1703 | [DRM_IOCTL_NR(DRM_R128_FLIP)] = {r128_cce_flip, DRM_AUTH}, | 1671 | DRM_IOCTL_DEF(DRM_R128_FLIP, r128_cce_flip, DRM_AUTH), |
1704 | [DRM_IOCTL_NR(DRM_R128_CLEAR)] = {r128_cce_clear, DRM_AUTH}, | 1672 | DRM_IOCTL_DEF(DRM_R128_CLEAR, r128_cce_clear, DRM_AUTH), |
1705 | [DRM_IOCTL_NR(DRM_R128_VERTEX)] = {r128_cce_vertex, DRM_AUTH}, | 1673 | DRM_IOCTL_DEF(DRM_R128_VERTEX, r128_cce_vertex, DRM_AUTH), |
1706 | [DRM_IOCTL_NR(DRM_R128_INDICES)] = {r128_cce_indices, DRM_AUTH}, | 1674 | DRM_IOCTL_DEF(DRM_R128_INDICES, r128_cce_indices, DRM_AUTH), |
1707 | [DRM_IOCTL_NR(DRM_R128_BLIT)] = {r128_cce_blit, DRM_AUTH}, | 1675 | DRM_IOCTL_DEF(DRM_R128_BLIT, r128_cce_blit, DRM_AUTH), |
1708 | [DRM_IOCTL_NR(DRM_R128_DEPTH)] = {r128_cce_depth, DRM_AUTH}, | 1676 | DRM_IOCTL_DEF(DRM_R128_DEPTH, r128_cce_depth, DRM_AUTH), |
1709 | [DRM_IOCTL_NR(DRM_R128_STIPPLE)] = {r128_cce_stipple, DRM_AUTH}, | 1677 | DRM_IOCTL_DEF(DRM_R128_STIPPLE, r128_cce_stipple, DRM_AUTH), |
1710 | [DRM_IOCTL_NR(DRM_R128_INDIRECT)] = {r128_cce_indirect, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 1678 | DRM_IOCTL_DEF(DRM_R128_INDIRECT, r128_cce_indirect, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
1711 | [DRM_IOCTL_NR(DRM_R128_GETPARAM)] = {r128_getparam, DRM_AUTH}, | 1679 | DRM_IOCTL_DEF(DRM_R128_GETPARAM, r128_getparam, DRM_AUTH), |
1712 | }; | 1680 | }; |
1713 | 1681 | ||
1714 | int r128_max_ioctl = DRM_ARRAY_SIZE(r128_ioctls); | 1682 | int r128_max_ioctl = DRM_ARRAY_SIZE(r128_ioctls); |
diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c index af95b5897a0c..335423c5c186 100644 --- a/drivers/char/drm/radeon_cp.c +++ b/drivers/char/drm/radeon_cp.c | |||
@@ -1823,24 +1823,20 @@ static int radeon_do_resume_cp(struct drm_device * dev) | |||
1823 | return 0; | 1823 | return 0; |
1824 | } | 1824 | } |
1825 | 1825 | ||
1826 | int radeon_cp_init(DRM_IOCTL_ARGS) | 1826 | int radeon_cp_init(struct drm_device *dev, void *data, struct drm_file *file_priv) |
1827 | { | 1827 | { |
1828 | DRM_DEVICE; | 1828 | drm_radeon_init_t *init = data; |
1829 | drm_radeon_init_t init; | ||
1830 | 1829 | ||
1831 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1830 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1832 | 1831 | ||
1833 | DRM_COPY_FROM_USER_IOCTL(init, (drm_radeon_init_t __user *) data, | 1832 | if (init->func == RADEON_INIT_R300_CP) |
1834 | sizeof(init)); | ||
1835 | |||
1836 | if (init.func == RADEON_INIT_R300_CP) | ||
1837 | r300_init_reg_flags(); | 1833 | r300_init_reg_flags(); |
1838 | 1834 | ||
1839 | switch (init.func) { | 1835 | switch (init->func) { |
1840 | case RADEON_INIT_CP: | 1836 | case RADEON_INIT_CP: |
1841 | case RADEON_INIT_R200_CP: | 1837 | case RADEON_INIT_R200_CP: |
1842 | case RADEON_INIT_R300_CP: | 1838 | case RADEON_INIT_R300_CP: |
1843 | return radeon_do_init_cp(dev, &init); | 1839 | return radeon_do_init_cp(dev, init); |
1844 | case RADEON_CLEANUP_CP: | 1840 | case RADEON_CLEANUP_CP: |
1845 | return radeon_do_cleanup_cp(dev); | 1841 | return radeon_do_cleanup_cp(dev); |
1846 | } | 1842 | } |
@@ -1848,9 +1844,8 @@ int radeon_cp_init(DRM_IOCTL_ARGS) | |||
1848 | return -EINVAL; | 1844 | return -EINVAL; |
1849 | } | 1845 | } |
1850 | 1846 | ||
1851 | int radeon_cp_start(DRM_IOCTL_ARGS) | 1847 | int radeon_cp_start(struct drm_device *dev, void *data, struct drm_file *file_priv) |
1852 | { | 1848 | { |
1853 | DRM_DEVICE; | ||
1854 | drm_radeon_private_t *dev_priv = dev->dev_private; | 1849 | drm_radeon_private_t *dev_priv = dev->dev_private; |
1855 | DRM_DEBUG("\n"); | 1850 | DRM_DEBUG("\n"); |
1856 | 1851 | ||
@@ -1874,33 +1869,29 @@ int radeon_cp_start(DRM_IOCTL_ARGS) | |||
1874 | /* Stop the CP. The engine must have been idled before calling this | 1869 | /* Stop the CP. The engine must have been idled before calling this |
1875 | * routine. | 1870 | * routine. |
1876 | */ | 1871 | */ |
1877 | int radeon_cp_stop(DRM_IOCTL_ARGS) | 1872 | int radeon_cp_stop(struct drm_device *dev, void *data, struct drm_file *file_priv) |
1878 | { | 1873 | { |
1879 | DRM_DEVICE; | ||
1880 | drm_radeon_private_t *dev_priv = dev->dev_private; | 1874 | drm_radeon_private_t *dev_priv = dev->dev_private; |
1881 | drm_radeon_cp_stop_t stop; | 1875 | drm_radeon_cp_stop_t *stop = data; |
1882 | int ret; | 1876 | int ret; |
1883 | DRM_DEBUG("\n"); | 1877 | DRM_DEBUG("\n"); |
1884 | 1878 | ||
1885 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1879 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1886 | 1880 | ||
1887 | DRM_COPY_FROM_USER_IOCTL(stop, (drm_radeon_cp_stop_t __user *) data, | ||
1888 | sizeof(stop)); | ||
1889 | |||
1890 | if (!dev_priv->cp_running) | 1881 | if (!dev_priv->cp_running) |
1891 | return 0; | 1882 | return 0; |
1892 | 1883 | ||
1893 | /* Flush any pending CP commands. This ensures any outstanding | 1884 | /* Flush any pending CP commands. This ensures any outstanding |
1894 | * commands are exectuted by the engine before we turn it off. | 1885 | * commands are exectuted by the engine before we turn it off. |
1895 | */ | 1886 | */ |
1896 | if (stop.flush) { | 1887 | if (stop->flush) { |
1897 | radeon_do_cp_flush(dev_priv); | 1888 | radeon_do_cp_flush(dev_priv); |
1898 | } | 1889 | } |
1899 | 1890 | ||
1900 | /* If we fail to make the engine go idle, we return an error | 1891 | /* If we fail to make the engine go idle, we return an error |
1901 | * code so that the DRM ioctl wrapper can try again. | 1892 | * code so that the DRM ioctl wrapper can try again. |
1902 | */ | 1893 | */ |
1903 | if (stop.idle) { | 1894 | if (stop->idle) { |
1904 | ret = radeon_do_cp_idle(dev_priv); | 1895 | ret = radeon_do_cp_idle(dev_priv); |
1905 | if (ret) | 1896 | if (ret) |
1906 | return ret; | 1897 | return ret; |
@@ -1963,9 +1954,8 @@ void radeon_do_release(struct drm_device * dev) | |||
1963 | 1954 | ||
1964 | /* Just reset the CP ring. Called as part of an X Server engine reset. | 1955 | /* Just reset the CP ring. Called as part of an X Server engine reset. |
1965 | */ | 1956 | */ |
1966 | int radeon_cp_reset(DRM_IOCTL_ARGS) | 1957 | int radeon_cp_reset(struct drm_device *dev, void *data, struct drm_file *file_priv) |
1967 | { | 1958 | { |
1968 | DRM_DEVICE; | ||
1969 | drm_radeon_private_t *dev_priv = dev->dev_private; | 1959 | drm_radeon_private_t *dev_priv = dev->dev_private; |
1970 | DRM_DEBUG("\n"); | 1960 | DRM_DEBUG("\n"); |
1971 | 1961 | ||
@@ -1984,9 +1974,8 @@ int radeon_cp_reset(DRM_IOCTL_ARGS) | |||
1984 | return 0; | 1974 | return 0; |
1985 | } | 1975 | } |
1986 | 1976 | ||
1987 | int radeon_cp_idle(DRM_IOCTL_ARGS) | 1977 | int radeon_cp_idle(struct drm_device *dev, void *data, struct drm_file *file_priv) |
1988 | { | 1978 | { |
1989 | DRM_DEVICE; | ||
1990 | drm_radeon_private_t *dev_priv = dev->dev_private; | 1979 | drm_radeon_private_t *dev_priv = dev->dev_private; |
1991 | DRM_DEBUG("\n"); | 1980 | DRM_DEBUG("\n"); |
1992 | 1981 | ||
@@ -1997,16 +1986,14 @@ int radeon_cp_idle(DRM_IOCTL_ARGS) | |||
1997 | 1986 | ||
1998 | /* Added by Charl P. Botha to call radeon_do_resume_cp(). | 1987 | /* Added by Charl P. Botha to call radeon_do_resume_cp(). |
1999 | */ | 1988 | */ |
2000 | int radeon_cp_resume(DRM_IOCTL_ARGS) | 1989 | int radeon_cp_resume(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2001 | { | 1990 | { |
2002 | DRM_DEVICE; | ||
2003 | 1991 | ||
2004 | return radeon_do_resume_cp(dev); | 1992 | return radeon_do_resume_cp(dev); |
2005 | } | 1993 | } |
2006 | 1994 | ||
2007 | int radeon_engine_reset(DRM_IOCTL_ARGS) | 1995 | int radeon_engine_reset(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2008 | { | 1996 | { |
2009 | DRM_DEVICE; | ||
2010 | DRM_DEBUG("\n"); | 1997 | DRM_DEBUG("\n"); |
2011 | 1998 | ||
2012 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1999 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
@@ -2020,7 +2007,7 @@ int radeon_engine_reset(DRM_IOCTL_ARGS) | |||
2020 | 2007 | ||
2021 | /* KW: Deprecated to say the least: | 2008 | /* KW: Deprecated to say the least: |
2022 | */ | 2009 | */ |
2023 | int radeon_fullscreen(DRM_IOCTL_ARGS) | 2010 | int radeon_fullscreen(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2024 | { | 2011 | { |
2025 | return 0; | 2012 | return 0; |
2026 | } | 2013 | } |
@@ -2198,42 +2185,36 @@ static int radeon_cp_get_buffers(struct drm_device *dev, | |||
2198 | return 0; | 2185 | return 0; |
2199 | } | 2186 | } |
2200 | 2187 | ||
2201 | int radeon_cp_buffers(DRM_IOCTL_ARGS) | 2188 | int radeon_cp_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2202 | { | 2189 | { |
2203 | DRM_DEVICE; | ||
2204 | struct drm_device_dma *dma = dev->dma; | 2190 | struct drm_device_dma *dma = dev->dma; |
2205 | int ret = 0; | 2191 | int ret = 0; |
2206 | struct drm_dma __user *argp = (void __user *)data; | 2192 | struct drm_dma *d = data; |
2207 | struct drm_dma d; | ||
2208 | 2193 | ||
2209 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 2194 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
2210 | 2195 | ||
2211 | DRM_COPY_FROM_USER_IOCTL(d, argp, sizeof(d)); | ||
2212 | |||
2213 | /* Please don't send us buffers. | 2196 | /* Please don't send us buffers. |
2214 | */ | 2197 | */ |
2215 | if (d.send_count != 0) { | 2198 | if (d->send_count != 0) { |
2216 | DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n", | 2199 | DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n", |
2217 | DRM_CURRENTPID, d.send_count); | 2200 | DRM_CURRENTPID, d->send_count); |
2218 | return -EINVAL; | 2201 | return -EINVAL; |
2219 | } | 2202 | } |
2220 | 2203 | ||
2221 | /* We'll send you buffers. | 2204 | /* We'll send you buffers. |
2222 | */ | 2205 | */ |
2223 | if (d.request_count < 0 || d.request_count > dma->buf_count) { | 2206 | if (d->request_count < 0 || d->request_count > dma->buf_count) { |
2224 | DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", | 2207 | DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", |
2225 | DRM_CURRENTPID, d.request_count, dma->buf_count); | 2208 | DRM_CURRENTPID, d->request_count, dma->buf_count); |
2226 | return -EINVAL; | 2209 | return -EINVAL; |
2227 | } | 2210 | } |
2228 | 2211 | ||
2229 | d.granted_count = 0; | 2212 | d->granted_count = 0; |
2230 | 2213 | ||
2231 | if (d.request_count) { | 2214 | if (d->request_count) { |
2232 | ret = radeon_cp_get_buffers(dev, file_priv, &d); | 2215 | ret = radeon_cp_get_buffers(dev, file_priv, d); |
2233 | } | 2216 | } |
2234 | 2217 | ||
2235 | DRM_COPY_TO_USER_IOCTL(argp, d, sizeof(d)); | ||
2236 | |||
2237 | return ret; | 2218 | return ret; |
2238 | } | 2219 | } |
2239 | 2220 | ||
diff --git a/drivers/char/drm/radeon_drv.h b/drivers/char/drm/radeon_drv.h index 160c02785b5d..e4077bc212b3 100644 --- a/drivers/char/drm/radeon_drv.h +++ b/drivers/char/drm/radeon_drv.h | |||
@@ -307,7 +307,7 @@ typedef struct drm_radeon_kcmd_buffer { | |||
307 | } drm_radeon_kcmd_buffer_t; | 307 | } drm_radeon_kcmd_buffer_t; |
308 | 308 | ||
309 | extern int radeon_no_wb; | 309 | extern int radeon_no_wb; |
310 | extern drm_ioctl_desc_t radeon_ioctls[]; | 310 | extern struct drm_ioctl_desc radeon_ioctls[]; |
311 | extern int radeon_max_ioctl; | 311 | extern int radeon_max_ioctl; |
312 | 312 | ||
313 | /* Check whether the given hardware address is inside the framebuffer or the | 313 | /* Check whether the given hardware address is inside the framebuffer or the |
@@ -326,15 +326,15 @@ static __inline__ int radeon_check_offset(drm_radeon_private_t *dev_priv, | |||
326 | } | 326 | } |
327 | 327 | ||
328 | /* radeon_cp.c */ | 328 | /* radeon_cp.c */ |
329 | extern int radeon_cp_init(DRM_IOCTL_ARGS); | 329 | extern int radeon_cp_init(struct drm_device *dev, void *data, struct drm_file *file_priv); |
330 | extern int radeon_cp_start(DRM_IOCTL_ARGS); | 330 | extern int radeon_cp_start(struct drm_device *dev, void *data, struct drm_file *file_priv); |
331 | extern int radeon_cp_stop(DRM_IOCTL_ARGS); | 331 | extern int radeon_cp_stop(struct drm_device *dev, void *data, struct drm_file *file_priv); |
332 | extern int radeon_cp_reset(DRM_IOCTL_ARGS); | 332 | extern int radeon_cp_reset(struct drm_device *dev, void *data, struct drm_file *file_priv); |
333 | extern int radeon_cp_idle(DRM_IOCTL_ARGS); | 333 | extern int radeon_cp_idle(struct drm_device *dev, void *data, struct drm_file *file_priv); |
334 | extern int radeon_cp_resume(DRM_IOCTL_ARGS); | 334 | extern int radeon_cp_resume(struct drm_device *dev, void *data, struct drm_file *file_priv); |
335 | extern int radeon_engine_reset(DRM_IOCTL_ARGS); | 335 | extern int radeon_engine_reset(struct drm_device *dev, void *data, struct drm_file *file_priv); |
336 | extern int radeon_fullscreen(DRM_IOCTL_ARGS); | 336 | extern int radeon_fullscreen(struct drm_device *dev, void *data, struct drm_file *file_priv); |
337 | extern int radeon_cp_buffers(DRM_IOCTL_ARGS); | 337 | extern int radeon_cp_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv); |
338 | 338 | ||
339 | extern void radeon_freelist_reset(struct drm_device * dev); | 339 | extern void radeon_freelist_reset(struct drm_device * dev); |
340 | extern struct drm_buf *radeon_freelist_get(struct drm_device * dev); | 340 | extern struct drm_buf *radeon_freelist_get(struct drm_device * dev); |
@@ -347,16 +347,16 @@ extern int radeon_driver_preinit(struct drm_device *dev, unsigned long flags); | |||
347 | extern int radeon_presetup(struct drm_device *dev); | 347 | extern int radeon_presetup(struct drm_device *dev); |
348 | extern int radeon_driver_postcleanup(struct drm_device *dev); | 348 | extern int radeon_driver_postcleanup(struct drm_device *dev); |
349 | 349 | ||
350 | extern int radeon_mem_alloc(DRM_IOCTL_ARGS); | 350 | extern int radeon_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv); |
351 | extern int radeon_mem_free(DRM_IOCTL_ARGS); | 351 | extern int radeon_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv); |
352 | extern int radeon_mem_init_heap(DRM_IOCTL_ARGS); | 352 | extern int radeon_mem_init_heap(struct drm_device *dev, void *data, struct drm_file *file_priv); |
353 | extern void radeon_mem_takedown(struct mem_block **heap); | 353 | extern void radeon_mem_takedown(struct mem_block **heap); |
354 | extern void radeon_mem_release(struct drm_file *file_priv, | 354 | extern void radeon_mem_release(struct drm_file *file_priv, |
355 | struct mem_block *heap); | 355 | struct mem_block *heap); |
356 | 356 | ||
357 | /* radeon_irq.c */ | 357 | /* radeon_irq.c */ |
358 | extern int radeon_irq_emit(DRM_IOCTL_ARGS); | 358 | extern int radeon_irq_emit(struct drm_device *dev, void *data, struct drm_file *file_priv); |
359 | extern int radeon_irq_wait(DRM_IOCTL_ARGS); | 359 | extern int radeon_irq_wait(struct drm_device *dev, void *data, struct drm_file *file_priv); |
360 | 360 | ||
361 | extern void radeon_do_release(struct drm_device * dev); | 361 | extern void radeon_do_release(struct drm_device * dev); |
362 | extern int radeon_driver_vblank_wait(struct drm_device * dev, | 362 | extern int radeon_driver_vblank_wait(struct drm_device * dev, |
diff --git a/drivers/char/drm/radeon_irq.c b/drivers/char/drm/radeon_irq.c index 173cb06bb294..f89e57665b64 100644 --- a/drivers/char/drm/radeon_irq.c +++ b/drivers/char/drm/radeon_irq.c | |||
@@ -196,11 +196,10 @@ int radeon_driver_vblank_wait2(struct drm_device *dev, unsigned int *sequence) | |||
196 | 196 | ||
197 | /* Needs the lock as it touches the ring. | 197 | /* Needs the lock as it touches the ring. |
198 | */ | 198 | */ |
199 | int radeon_irq_emit(DRM_IOCTL_ARGS) | 199 | int radeon_irq_emit(struct drm_device *dev, void *data, struct drm_file *file_priv) |
200 | { | 200 | { |
201 | DRM_DEVICE; | ||
202 | drm_radeon_private_t *dev_priv = dev->dev_private; | 201 | drm_radeon_private_t *dev_priv = dev->dev_private; |
203 | drm_radeon_irq_emit_t emit; | 202 | drm_radeon_irq_emit_t *emit = data; |
204 | int result; | 203 | int result; |
205 | 204 | ||
206 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 205 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
@@ -210,12 +209,9 @@ int radeon_irq_emit(DRM_IOCTL_ARGS) | |||
210 | return -EINVAL; | 209 | return -EINVAL; |
211 | } | 210 | } |
212 | 211 | ||
213 | DRM_COPY_FROM_USER_IOCTL(emit, (drm_radeon_irq_emit_t __user *) data, | ||
214 | sizeof(emit)); | ||
215 | |||
216 | result = radeon_emit_irq(dev); | 212 | result = radeon_emit_irq(dev); |
217 | 213 | ||
218 | if (DRM_COPY_TO_USER(emit.irq_seq, &result, sizeof(int))) { | 214 | if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) { |
219 | DRM_ERROR("copy_to_user\n"); | 215 | DRM_ERROR("copy_to_user\n"); |
220 | return -EFAULT; | 216 | return -EFAULT; |
221 | } | 217 | } |
@@ -225,21 +221,17 @@ int radeon_irq_emit(DRM_IOCTL_ARGS) | |||
225 | 221 | ||
226 | /* Doesn't need the hardware lock. | 222 | /* Doesn't need the hardware lock. |
227 | */ | 223 | */ |
228 | int radeon_irq_wait(DRM_IOCTL_ARGS) | 224 | int radeon_irq_wait(struct drm_device *dev, void *data, struct drm_file *file_priv) |
229 | { | 225 | { |
230 | DRM_DEVICE; | ||
231 | drm_radeon_private_t *dev_priv = dev->dev_private; | 226 | drm_radeon_private_t *dev_priv = dev->dev_private; |
232 | drm_radeon_irq_wait_t irqwait; | 227 | drm_radeon_irq_wait_t *irqwait = data; |
233 | 228 | ||
234 | if (!dev_priv) { | 229 | if (!dev_priv) { |
235 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); | 230 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); |
236 | return -EINVAL; | 231 | return -EINVAL; |
237 | } | 232 | } |
238 | 233 | ||
239 | DRM_COPY_FROM_USER_IOCTL(irqwait, (drm_radeon_irq_wait_t __user *) data, | 234 | return radeon_wait_irq(dev, irqwait->irq_seq); |
240 | sizeof(irqwait)); | ||
241 | |||
242 | return radeon_wait_irq(dev, irqwait.irq_seq); | ||
243 | } | 235 | } |
244 | 236 | ||
245 | static void radeon_enable_interrupt(struct drm_device *dev) | 237 | static void radeon_enable_interrupt(struct drm_device *dev) |
diff --git a/drivers/char/drm/radeon_mem.c b/drivers/char/drm/radeon_mem.c index 966d521cf27c..a29acfe2f973 100644 --- a/drivers/char/drm/radeon_mem.c +++ b/drivers/char/drm/radeon_mem.c | |||
@@ -217,11 +217,10 @@ static struct mem_block **get_heap(drm_radeon_private_t * dev_priv, int region) | |||
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
220 | int radeon_mem_alloc(DRM_IOCTL_ARGS) | 220 | int radeon_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv) |
221 | { | 221 | { |
222 | DRM_DEVICE; | ||
223 | drm_radeon_private_t *dev_priv = dev->dev_private; | 222 | drm_radeon_private_t *dev_priv = dev->dev_private; |
224 | drm_radeon_mem_alloc_t alloc; | 223 | drm_radeon_mem_alloc_t *alloc = data; |
225 | struct mem_block *block, **heap; | 224 | struct mem_block *block, **heap; |
226 | 225 | ||
227 | if (!dev_priv) { | 226 | if (!dev_priv) { |
@@ -229,25 +228,23 @@ int radeon_mem_alloc(DRM_IOCTL_ARGS) | |||
229 | return -EINVAL; | 228 | return -EINVAL; |
230 | } | 229 | } |
231 | 230 | ||
232 | DRM_COPY_FROM_USER_IOCTL(alloc, (drm_radeon_mem_alloc_t __user *) data, | 231 | heap = get_heap(dev_priv, alloc->region); |
233 | sizeof(alloc)); | ||
234 | |||
235 | heap = get_heap(dev_priv, alloc.region); | ||
236 | if (!heap || !*heap) | 232 | if (!heap || !*heap) |
237 | return -EFAULT; | 233 | return -EFAULT; |
238 | 234 | ||
239 | /* Make things easier on ourselves: all allocations at least | 235 | /* Make things easier on ourselves: all allocations at least |
240 | * 4k aligned. | 236 | * 4k aligned. |
241 | */ | 237 | */ |
242 | if (alloc.alignment < 12) | 238 | if (alloc->alignment < 12) |
243 | alloc.alignment = 12; | 239 | alloc->alignment = 12; |
244 | 240 | ||
245 | block = alloc_block(*heap, alloc.size, alloc.alignment, file_priv); | 241 | block = alloc_block(*heap, alloc->size, alloc->alignment, file_priv); |
246 | 242 | ||
247 | if (!block) | 243 | if (!block) |
248 | return -ENOMEM; | 244 | return -ENOMEM; |
249 | 245 | ||
250 | if (DRM_COPY_TO_USER(alloc.region_offset, &block->start, sizeof(int))) { | 246 | if (DRM_COPY_TO_USER(alloc->region_offset, &block->start, |
247 | sizeof(int))) { | ||
251 | DRM_ERROR("copy_to_user\n"); | 248 | DRM_ERROR("copy_to_user\n"); |
252 | return -EFAULT; | 249 | return -EFAULT; |
253 | } | 250 | } |
@@ -255,11 +252,10 @@ int radeon_mem_alloc(DRM_IOCTL_ARGS) | |||
255 | return 0; | 252 | return 0; |
256 | } | 253 | } |
257 | 254 | ||
258 | int radeon_mem_free(DRM_IOCTL_ARGS) | 255 | int radeon_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv) |
259 | { | 256 | { |
260 | DRM_DEVICE; | ||
261 | drm_radeon_private_t *dev_priv = dev->dev_private; | 257 | drm_radeon_private_t *dev_priv = dev->dev_private; |
262 | drm_radeon_mem_free_t memfree; | 258 | drm_radeon_mem_free_t *memfree = data; |
263 | struct mem_block *block, **heap; | 259 | struct mem_block *block, **heap; |
264 | 260 | ||
265 | if (!dev_priv) { | 261 | if (!dev_priv) { |
@@ -267,14 +263,11 @@ int radeon_mem_free(DRM_IOCTL_ARGS) | |||
267 | return -EINVAL; | 263 | return -EINVAL; |
268 | } | 264 | } |
269 | 265 | ||
270 | DRM_COPY_FROM_USER_IOCTL(memfree, (drm_radeon_mem_free_t __user *) data, | 266 | heap = get_heap(dev_priv, memfree->region); |
271 | sizeof(memfree)); | ||
272 | |||
273 | heap = get_heap(dev_priv, memfree.region); | ||
274 | if (!heap || !*heap) | 267 | if (!heap || !*heap) |
275 | return -EFAULT; | 268 | return -EFAULT; |
276 | 269 | ||
277 | block = find_block(*heap, memfree.region_offset); | 270 | block = find_block(*heap, memfree->region_offset); |
278 | if (!block) | 271 | if (!block) |
279 | return -EFAULT; | 272 | return -EFAULT; |
280 | 273 | ||
@@ -285,11 +278,10 @@ int radeon_mem_free(DRM_IOCTL_ARGS) | |||
285 | return 0; | 278 | return 0; |
286 | } | 279 | } |
287 | 280 | ||
288 | int radeon_mem_init_heap(DRM_IOCTL_ARGS) | 281 | int radeon_mem_init_heap(struct drm_device *dev, void *data, struct drm_file *file_priv) |
289 | { | 282 | { |
290 | DRM_DEVICE; | ||
291 | drm_radeon_private_t *dev_priv = dev->dev_private; | 283 | drm_radeon_private_t *dev_priv = dev->dev_private; |
292 | drm_radeon_mem_init_heap_t initheap; | 284 | drm_radeon_mem_init_heap_t *initheap = data; |
293 | struct mem_block **heap; | 285 | struct mem_block **heap; |
294 | 286 | ||
295 | if (!dev_priv) { | 287 | if (!dev_priv) { |
@@ -297,11 +289,7 @@ int radeon_mem_init_heap(DRM_IOCTL_ARGS) | |||
297 | return -EINVAL; | 289 | return -EINVAL; |
298 | } | 290 | } |
299 | 291 | ||
300 | DRM_COPY_FROM_USER_IOCTL(initheap, | 292 | heap = get_heap(dev_priv, initheap->region); |
301 | (drm_radeon_mem_init_heap_t __user *) data, | ||
302 | sizeof(initheap)); | ||
303 | |||
304 | heap = get_heap(dev_priv, initheap.region); | ||
305 | if (!heap) | 293 | if (!heap) |
306 | return -EFAULT; | 294 | return -EFAULT; |
307 | 295 | ||
@@ -310,5 +298,5 @@ int radeon_mem_init_heap(DRM_IOCTL_ARGS) | |||
310 | return -EFAULT; | 298 | return -EFAULT; |
311 | } | 299 | } |
312 | 300 | ||
313 | return init_heap(heap, initheap.start, initheap.size); | 301 | return init_heap(heap, initheap->start, initheap->size); |
314 | } | 302 | } |
diff --git a/drivers/char/drm/radeon_state.c b/drivers/char/drm/radeon_state.c index bd1aafdc3c29..ada820717ade 100644 --- a/drivers/char/drm/radeon_state.c +++ b/drivers/char/drm/radeon_state.c | |||
@@ -2075,61 +2075,48 @@ static void radeon_surfaces_release(struct drm_file *file_priv, | |||
2075 | /* ================================================================ | 2075 | /* ================================================================ |
2076 | * IOCTL functions | 2076 | * IOCTL functions |
2077 | */ | 2077 | */ |
2078 | static int radeon_surface_alloc(DRM_IOCTL_ARGS) | 2078 | static int radeon_surface_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2079 | { | 2079 | { |
2080 | DRM_DEVICE; | ||
2081 | drm_radeon_private_t *dev_priv = dev->dev_private; | 2080 | drm_radeon_private_t *dev_priv = dev->dev_private; |
2082 | drm_radeon_surface_alloc_t alloc; | 2081 | drm_radeon_surface_alloc_t *alloc = data; |
2083 | 2082 | ||
2084 | DRM_COPY_FROM_USER_IOCTL(alloc, | 2083 | if (alloc_surface(alloc, dev_priv, file_priv) == -1) |
2085 | (drm_radeon_surface_alloc_t __user *) data, | ||
2086 | sizeof(alloc)); | ||
2087 | |||
2088 | if (alloc_surface(&alloc, dev_priv, file_priv) == -1) | ||
2089 | return -EINVAL; | 2084 | return -EINVAL; |
2090 | else | 2085 | else |
2091 | return 0; | 2086 | return 0; |
2092 | } | 2087 | } |
2093 | 2088 | ||
2094 | static int radeon_surface_free(DRM_IOCTL_ARGS) | 2089 | static int radeon_surface_free(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2095 | { | 2090 | { |
2096 | DRM_DEVICE; | ||
2097 | drm_radeon_private_t *dev_priv = dev->dev_private; | 2091 | drm_radeon_private_t *dev_priv = dev->dev_private; |
2098 | drm_radeon_surface_free_t memfree; | 2092 | drm_radeon_surface_free_t *memfree = data; |
2099 | |||
2100 | DRM_COPY_FROM_USER_IOCTL(memfree, (drm_radeon_surface_free_t __user *) data, | ||
2101 | sizeof(memfree)); | ||
2102 | 2093 | ||
2103 | if (free_surface(file_priv, dev_priv, memfree.address)) | 2094 | if (free_surface(file_priv, dev_priv, memfree->address)) |
2104 | return -EINVAL; | 2095 | return -EINVAL; |
2105 | else | 2096 | else |
2106 | return 0; | 2097 | return 0; |
2107 | } | 2098 | } |
2108 | 2099 | ||
2109 | static int radeon_cp_clear(DRM_IOCTL_ARGS) | 2100 | static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2110 | { | 2101 | { |
2111 | DRM_DEVICE; | ||
2112 | drm_radeon_private_t *dev_priv = dev->dev_private; | 2102 | drm_radeon_private_t *dev_priv = dev->dev_private; |
2113 | drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; | 2103 | drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; |
2114 | drm_radeon_clear_t clear; | 2104 | drm_radeon_clear_t *clear = data; |
2115 | drm_radeon_clear_rect_t depth_boxes[RADEON_NR_SAREA_CLIPRECTS]; | 2105 | drm_radeon_clear_rect_t depth_boxes[RADEON_NR_SAREA_CLIPRECTS]; |
2116 | DRM_DEBUG("\n"); | 2106 | DRM_DEBUG("\n"); |
2117 | 2107 | ||
2118 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 2108 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
2119 | 2109 | ||
2120 | DRM_COPY_FROM_USER_IOCTL(clear, (drm_radeon_clear_t __user *) data, | ||
2121 | sizeof(clear)); | ||
2122 | |||
2123 | RING_SPACE_TEST_WITH_RETURN(dev_priv); | 2110 | RING_SPACE_TEST_WITH_RETURN(dev_priv); |
2124 | 2111 | ||
2125 | if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS) | 2112 | if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS) |
2126 | sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS; | 2113 | sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS; |
2127 | 2114 | ||
2128 | if (DRM_COPY_FROM_USER(&depth_boxes, clear.depth_boxes, | 2115 | if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes, |
2129 | sarea_priv->nbox * sizeof(depth_boxes[0]))) | 2116 | sarea_priv->nbox * sizeof(depth_boxes[0]))) |
2130 | return -EFAULT; | 2117 | return -EFAULT; |
2131 | 2118 | ||
2132 | radeon_cp_dispatch_clear(dev, &clear, depth_boxes); | 2119 | radeon_cp_dispatch_clear(dev, clear, depth_boxes); |
2133 | 2120 | ||
2134 | COMMIT_RING(); | 2121 | COMMIT_RING(); |
2135 | return 0; | 2122 | return 0; |
@@ -2165,9 +2152,8 @@ static int radeon_do_init_pageflip(struct drm_device * dev) | |||
2165 | /* Swapping and flipping are different operations, need different ioctls. | 2152 | /* Swapping and flipping are different operations, need different ioctls. |
2166 | * They can & should be intermixed to support multiple 3d windows. | 2153 | * They can & should be intermixed to support multiple 3d windows. |
2167 | */ | 2154 | */ |
2168 | static int radeon_cp_flip(DRM_IOCTL_ARGS) | 2155 | static int radeon_cp_flip(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2169 | { | 2156 | { |
2170 | DRM_DEVICE; | ||
2171 | drm_radeon_private_t *dev_priv = dev->dev_private; | 2157 | drm_radeon_private_t *dev_priv = dev->dev_private; |
2172 | DRM_DEBUG("\n"); | 2158 | DRM_DEBUG("\n"); |
2173 | 2159 | ||
@@ -2184,9 +2170,8 @@ static int radeon_cp_flip(DRM_IOCTL_ARGS) | |||
2184 | return 0; | 2170 | return 0; |
2185 | } | 2171 | } |
2186 | 2172 | ||
2187 | static int radeon_cp_swap(DRM_IOCTL_ARGS) | 2173 | static int radeon_cp_swap(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2188 | { | 2174 | { |
2189 | DRM_DEVICE; | ||
2190 | drm_radeon_private_t *dev_priv = dev->dev_private; | 2175 | drm_radeon_private_t *dev_priv = dev->dev_private; |
2191 | drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; | 2176 | drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; |
2192 | DRM_DEBUG("\n"); | 2177 | DRM_DEBUG("\n"); |
@@ -2205,38 +2190,34 @@ static int radeon_cp_swap(DRM_IOCTL_ARGS) | |||
2205 | return 0; | 2190 | return 0; |
2206 | } | 2191 | } |
2207 | 2192 | ||
2208 | static int radeon_cp_vertex(DRM_IOCTL_ARGS) | 2193 | static int radeon_cp_vertex(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2209 | { | 2194 | { |
2210 | DRM_DEVICE; | ||
2211 | drm_radeon_private_t *dev_priv = dev->dev_private; | 2195 | drm_radeon_private_t *dev_priv = dev->dev_private; |
2212 | drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; | 2196 | drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; |
2213 | struct drm_device_dma *dma = dev->dma; | 2197 | struct drm_device_dma *dma = dev->dma; |
2214 | struct drm_buf *buf; | 2198 | struct drm_buf *buf; |
2215 | drm_radeon_vertex_t vertex; | 2199 | drm_radeon_vertex_t *vertex = data; |
2216 | drm_radeon_tcl_prim_t prim; | 2200 | drm_radeon_tcl_prim_t prim; |
2217 | 2201 | ||
2218 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 2202 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
2219 | 2203 | ||
2220 | DRM_COPY_FROM_USER_IOCTL(vertex, (drm_radeon_vertex_t __user *) data, | ||
2221 | sizeof(vertex)); | ||
2222 | |||
2223 | DRM_DEBUG("pid=%d index=%d count=%d discard=%d\n", | 2204 | DRM_DEBUG("pid=%d index=%d count=%d discard=%d\n", |
2224 | DRM_CURRENTPID, vertex.idx, vertex.count, vertex.discard); | 2205 | DRM_CURRENTPID, vertex->idx, vertex->count, vertex->discard); |
2225 | 2206 | ||
2226 | if (vertex.idx < 0 || vertex.idx >= dma->buf_count) { | 2207 | if (vertex->idx < 0 || vertex->idx >= dma->buf_count) { |
2227 | DRM_ERROR("buffer index %d (of %d max)\n", | 2208 | DRM_ERROR("buffer index %d (of %d max)\n", |
2228 | vertex.idx, dma->buf_count - 1); | 2209 | vertex->idx, dma->buf_count - 1); |
2229 | return -EINVAL; | 2210 | return -EINVAL; |
2230 | } | 2211 | } |
2231 | if (vertex.prim < 0 || vertex.prim > RADEON_PRIM_TYPE_3VRT_LINE_LIST) { | 2212 | if (vertex->prim < 0 || vertex->prim > RADEON_PRIM_TYPE_3VRT_LINE_LIST) { |
2232 | DRM_ERROR("buffer prim %d\n", vertex.prim); | 2213 | DRM_ERROR("buffer prim %d\n", vertex->prim); |
2233 | return -EINVAL; | 2214 | return -EINVAL; |
2234 | } | 2215 | } |
2235 | 2216 | ||
2236 | RING_SPACE_TEST_WITH_RETURN(dev_priv); | 2217 | RING_SPACE_TEST_WITH_RETURN(dev_priv); |
2237 | VB_AGE_TEST_WITH_RETURN(dev_priv); | 2218 | VB_AGE_TEST_WITH_RETURN(dev_priv); |
2238 | 2219 | ||
2239 | buf = dma->buflist[vertex.idx]; | 2220 | buf = dma->buflist[vertex->idx]; |
2240 | 2221 | ||
2241 | if (buf->file_priv != file_priv) { | 2222 | if (buf->file_priv != file_priv) { |
2242 | DRM_ERROR("process %d using buffer owned by %p\n", | 2223 | DRM_ERROR("process %d using buffer owned by %p\n", |
@@ -2244,14 +2225,14 @@ static int radeon_cp_vertex(DRM_IOCTL_ARGS) | |||
2244 | return -EINVAL; | 2225 | return -EINVAL; |
2245 | } | 2226 | } |
2246 | if (buf->pending) { | 2227 | if (buf->pending) { |
2247 | DRM_ERROR("sending pending buffer %d\n", vertex.idx); | 2228 | DRM_ERROR("sending pending buffer %d\n", vertex->idx); |
2248 | return -EINVAL; | 2229 | return -EINVAL; |
2249 | } | 2230 | } |
2250 | 2231 | ||
2251 | /* Build up a prim_t record: | 2232 | /* Build up a prim_t record: |
2252 | */ | 2233 | */ |
2253 | if (vertex.count) { | 2234 | if (vertex->count) { |
2254 | buf->used = vertex.count; /* not used? */ | 2235 | buf->used = vertex->count; /* not used? */ |
2255 | 2236 | ||
2256 | if (sarea_priv->dirty & ~RADEON_UPLOAD_CLIPRECTS) { | 2237 | if (sarea_priv->dirty & ~RADEON_UPLOAD_CLIPRECTS) { |
2257 | if (radeon_emit_state(dev_priv, file_priv, | 2238 | if (radeon_emit_state(dev_priv, file_priv, |
@@ -2269,15 +2250,15 @@ static int radeon_cp_vertex(DRM_IOCTL_ARGS) | |||
2269 | } | 2250 | } |
2270 | 2251 | ||
2271 | prim.start = 0; | 2252 | prim.start = 0; |
2272 | prim.finish = vertex.count; /* unused */ | 2253 | prim.finish = vertex->count; /* unused */ |
2273 | prim.prim = vertex.prim; | 2254 | prim.prim = vertex->prim; |
2274 | prim.numverts = vertex.count; | 2255 | prim.numverts = vertex->count; |
2275 | prim.vc_format = dev_priv->sarea_priv->vc_format; | 2256 | prim.vc_format = dev_priv->sarea_priv->vc_format; |
2276 | 2257 | ||
2277 | radeon_cp_dispatch_vertex(dev, buf, &prim); | 2258 | radeon_cp_dispatch_vertex(dev, buf, &prim); |
2278 | } | 2259 | } |
2279 | 2260 | ||
2280 | if (vertex.discard) { | 2261 | if (vertex->discard) { |
2281 | radeon_cp_discard_buffer(dev, buf); | 2262 | radeon_cp_discard_buffer(dev, buf); |
2282 | } | 2263 | } |
2283 | 2264 | ||
@@ -2285,39 +2266,36 @@ static int radeon_cp_vertex(DRM_IOCTL_ARGS) | |||
2285 | return 0; | 2266 | return 0; |
2286 | } | 2267 | } |
2287 | 2268 | ||
2288 | static int radeon_cp_indices(DRM_IOCTL_ARGS) | 2269 | static int radeon_cp_indices(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2289 | { | 2270 | { |
2290 | DRM_DEVICE; | ||
2291 | drm_radeon_private_t *dev_priv = dev->dev_private; | 2271 | drm_radeon_private_t *dev_priv = dev->dev_private; |
2292 | drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; | 2272 | drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; |
2293 | struct drm_device_dma *dma = dev->dma; | 2273 | struct drm_device_dma *dma = dev->dma; |
2294 | struct drm_buf *buf; | 2274 | struct drm_buf *buf; |
2295 | drm_radeon_indices_t elts; | 2275 | drm_radeon_indices_t *elts = data; |
2296 | drm_radeon_tcl_prim_t prim; | 2276 | drm_radeon_tcl_prim_t prim; |
2297 | int count; | 2277 | int count; |
2298 | 2278 | ||
2299 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 2279 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
2300 | 2280 | ||
2301 | DRM_COPY_FROM_USER_IOCTL(elts, (drm_radeon_indices_t __user *) data, | ||
2302 | sizeof(elts)); | ||
2303 | |||
2304 | DRM_DEBUG("pid=%d index=%d start=%d end=%d discard=%d\n", | 2281 | DRM_DEBUG("pid=%d index=%d start=%d end=%d discard=%d\n", |
2305 | DRM_CURRENTPID, elts.idx, elts.start, elts.end, elts.discard); | 2282 | DRM_CURRENTPID, elts->idx, elts->start, elts->end, |
2283 | elts->discard); | ||
2306 | 2284 | ||
2307 | if (elts.idx < 0 || elts.idx >= dma->buf_count) { | 2285 | if (elts->idx < 0 || elts->idx >= dma->buf_count) { |
2308 | DRM_ERROR("buffer index %d (of %d max)\n", | 2286 | DRM_ERROR("buffer index %d (of %d max)\n", |
2309 | elts.idx, dma->buf_count - 1); | 2287 | elts->idx, dma->buf_count - 1); |
2310 | return -EINVAL; | 2288 | return -EINVAL; |
2311 | } | 2289 | } |
2312 | if (elts.prim < 0 || elts.prim > RADEON_PRIM_TYPE_3VRT_LINE_LIST) { | 2290 | if (elts->prim < 0 || elts->prim > RADEON_PRIM_TYPE_3VRT_LINE_LIST) { |
2313 | DRM_ERROR("buffer prim %d\n", elts.prim); | 2291 | DRM_ERROR("buffer prim %d\n", elts->prim); |
2314 | return -EINVAL; | 2292 | return -EINVAL; |
2315 | } | 2293 | } |
2316 | 2294 | ||
2317 | RING_SPACE_TEST_WITH_RETURN(dev_priv); | 2295 | RING_SPACE_TEST_WITH_RETURN(dev_priv); |
2318 | VB_AGE_TEST_WITH_RETURN(dev_priv); | 2296 | VB_AGE_TEST_WITH_RETURN(dev_priv); |
2319 | 2297 | ||
2320 | buf = dma->buflist[elts.idx]; | 2298 | buf = dma->buflist[elts->idx]; |
2321 | 2299 | ||
2322 | if (buf->file_priv != file_priv) { | 2300 | if (buf->file_priv != file_priv) { |
2323 | DRM_ERROR("process %d using buffer owned by %p\n", | 2301 | DRM_ERROR("process %d using buffer owned by %p\n", |
@@ -2325,23 +2303,23 @@ static int radeon_cp_indices(DRM_IOCTL_ARGS) | |||
2325 | return -EINVAL; | 2303 | return -EINVAL; |
2326 | } | 2304 | } |
2327 | if (buf->pending) { | 2305 | if (buf->pending) { |
2328 | DRM_ERROR("sending pending buffer %d\n", elts.idx); | 2306 | DRM_ERROR("sending pending buffer %d\n", elts->idx); |
2329 | return -EINVAL; | 2307 | return -EINVAL; |
2330 | } | 2308 | } |
2331 | 2309 | ||
2332 | count = (elts.end - elts.start) / sizeof(u16); | 2310 | count = (elts->end - elts->start) / sizeof(u16); |
2333 | elts.start -= RADEON_INDEX_PRIM_OFFSET; | 2311 | elts->start -= RADEON_INDEX_PRIM_OFFSET; |
2334 | 2312 | ||
2335 | if (elts.start & 0x7) { | 2313 | if (elts->start & 0x7) { |
2336 | DRM_ERROR("misaligned buffer 0x%x\n", elts.start); | 2314 | DRM_ERROR("misaligned buffer 0x%x\n", elts->start); |
2337 | return -EINVAL; | 2315 | return -EINVAL; |
2338 | } | 2316 | } |
2339 | if (elts.start < buf->used) { | 2317 | if (elts->start < buf->used) { |
2340 | DRM_ERROR("no header 0x%x - 0x%x\n", elts.start, buf->used); | 2318 | DRM_ERROR("no header 0x%x - 0x%x\n", elts->start, buf->used); |
2341 | return -EINVAL; | 2319 | return -EINVAL; |
2342 | } | 2320 | } |
2343 | 2321 | ||
2344 | buf->used = elts.end; | 2322 | buf->used = elts->end; |
2345 | 2323 | ||
2346 | if (sarea_priv->dirty & ~RADEON_UPLOAD_CLIPRECTS) { | 2324 | if (sarea_priv->dirty & ~RADEON_UPLOAD_CLIPRECTS) { |
2347 | if (radeon_emit_state(dev_priv, file_priv, | 2325 | if (radeon_emit_state(dev_priv, file_priv, |
@@ -2360,15 +2338,15 @@ static int radeon_cp_indices(DRM_IOCTL_ARGS) | |||
2360 | 2338 | ||
2361 | /* Build up a prim_t record: | 2339 | /* Build up a prim_t record: |
2362 | */ | 2340 | */ |
2363 | prim.start = elts.start; | 2341 | prim.start = elts->start; |
2364 | prim.finish = elts.end; | 2342 | prim.finish = elts->end; |
2365 | prim.prim = elts.prim; | 2343 | prim.prim = elts->prim; |
2366 | prim.offset = 0; /* offset from start of dma buffers */ | 2344 | prim.offset = 0; /* offset from start of dma buffers */ |
2367 | prim.numverts = RADEON_MAX_VB_VERTS; /* duh */ | 2345 | prim.numverts = RADEON_MAX_VB_VERTS; /* duh */ |
2368 | prim.vc_format = dev_priv->sarea_priv->vc_format; | 2346 | prim.vc_format = dev_priv->sarea_priv->vc_format; |
2369 | 2347 | ||
2370 | radeon_cp_dispatch_indices(dev, buf, &prim); | 2348 | radeon_cp_dispatch_indices(dev, buf, &prim); |
2371 | if (elts.discard) { | 2349 | if (elts->discard) { |
2372 | radeon_cp_discard_buffer(dev, buf); | 2350 | radeon_cp_discard_buffer(dev, buf); |
2373 | } | 2351 | } |
2374 | 2352 | ||
@@ -2376,51 +2354,43 @@ static int radeon_cp_indices(DRM_IOCTL_ARGS) | |||
2376 | return 0; | 2354 | return 0; |
2377 | } | 2355 | } |
2378 | 2356 | ||
2379 | static int radeon_cp_texture(DRM_IOCTL_ARGS) | 2357 | static int radeon_cp_texture(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2380 | { | 2358 | { |
2381 | DRM_DEVICE; | ||
2382 | drm_radeon_private_t *dev_priv = dev->dev_private; | 2359 | drm_radeon_private_t *dev_priv = dev->dev_private; |
2383 | drm_radeon_texture_t tex; | 2360 | drm_radeon_texture_t *tex = data; |
2384 | drm_radeon_tex_image_t image; | 2361 | drm_radeon_tex_image_t image; |
2385 | int ret; | 2362 | int ret; |
2386 | 2363 | ||
2387 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 2364 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
2388 | 2365 | ||
2389 | DRM_COPY_FROM_USER_IOCTL(tex, (drm_radeon_texture_t __user *) data, | 2366 | if (tex->image == NULL) { |
2390 | sizeof(tex)); | ||
2391 | |||
2392 | if (tex.image == NULL) { | ||
2393 | DRM_ERROR("null texture image!\n"); | 2367 | DRM_ERROR("null texture image!\n"); |
2394 | return -EINVAL; | 2368 | return -EINVAL; |
2395 | } | 2369 | } |
2396 | 2370 | ||
2397 | if (DRM_COPY_FROM_USER(&image, | 2371 | if (DRM_COPY_FROM_USER(&image, |
2398 | (drm_radeon_tex_image_t __user *) tex.image, | 2372 | (drm_radeon_tex_image_t __user *) tex->image, |
2399 | sizeof(image))) | 2373 | sizeof(image))) |
2400 | return -EFAULT; | 2374 | return -EFAULT; |
2401 | 2375 | ||
2402 | RING_SPACE_TEST_WITH_RETURN(dev_priv); | 2376 | RING_SPACE_TEST_WITH_RETURN(dev_priv); |
2403 | VB_AGE_TEST_WITH_RETURN(dev_priv); | 2377 | VB_AGE_TEST_WITH_RETURN(dev_priv); |
2404 | 2378 | ||
2405 | ret = radeon_cp_dispatch_texture(dev, file_priv, &tex, &image); | 2379 | ret = radeon_cp_dispatch_texture(dev, file_priv, tex, &image); |
2406 | 2380 | ||
2407 | COMMIT_RING(); | 2381 | COMMIT_RING(); |
2408 | return ret; | 2382 | return ret; |
2409 | } | 2383 | } |
2410 | 2384 | ||
2411 | static int radeon_cp_stipple(DRM_IOCTL_ARGS) | 2385 | static int radeon_cp_stipple(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2412 | { | 2386 | { |
2413 | DRM_DEVICE; | ||
2414 | drm_radeon_private_t *dev_priv = dev->dev_private; | 2387 | drm_radeon_private_t *dev_priv = dev->dev_private; |
2415 | drm_radeon_stipple_t stipple; | 2388 | drm_radeon_stipple_t *stipple = data; |
2416 | u32 mask[32]; | 2389 | u32 mask[32]; |
2417 | 2390 | ||
2418 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 2391 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
2419 | 2392 | ||
2420 | DRM_COPY_FROM_USER_IOCTL(stipple, (drm_radeon_stipple_t __user *) data, | 2393 | if (DRM_COPY_FROM_USER(&mask, stipple->mask, 32 * sizeof(u32))) |
2421 | sizeof(stipple)); | ||
2422 | |||
2423 | if (DRM_COPY_FROM_USER(&mask, stipple.mask, 32 * sizeof(u32))) | ||
2424 | return -EFAULT; | 2394 | return -EFAULT; |
2425 | 2395 | ||
2426 | RING_SPACE_TEST_WITH_RETURN(dev_priv); | 2396 | RING_SPACE_TEST_WITH_RETURN(dev_priv); |
@@ -2431,31 +2401,27 @@ static int radeon_cp_stipple(DRM_IOCTL_ARGS) | |||
2431 | return 0; | 2401 | return 0; |
2432 | } | 2402 | } |
2433 | 2403 | ||
2434 | static int radeon_cp_indirect(DRM_IOCTL_ARGS) | 2404 | static int radeon_cp_indirect(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2435 | { | 2405 | { |
2436 | DRM_DEVICE; | ||
2437 | drm_radeon_private_t *dev_priv = dev->dev_private; | 2406 | drm_radeon_private_t *dev_priv = dev->dev_private; |
2438 | struct drm_device_dma *dma = dev->dma; | 2407 | struct drm_device_dma *dma = dev->dma; |
2439 | struct drm_buf *buf; | 2408 | struct drm_buf *buf; |
2440 | drm_radeon_indirect_t indirect; | 2409 | drm_radeon_indirect_t *indirect = data; |
2441 | RING_LOCALS; | 2410 | RING_LOCALS; |
2442 | 2411 | ||
2443 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 2412 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
2444 | 2413 | ||
2445 | DRM_COPY_FROM_USER_IOCTL(indirect, | ||
2446 | (drm_radeon_indirect_t __user *) data, | ||
2447 | sizeof(indirect)); | ||
2448 | |||
2449 | DRM_DEBUG("indirect: idx=%d s=%d e=%d d=%d\n", | 2414 | DRM_DEBUG("indirect: idx=%d s=%d e=%d d=%d\n", |
2450 | indirect.idx, indirect.start, indirect.end, indirect.discard); | 2415 | indirect->idx, indirect->start, indirect->end, |
2416 | indirect->discard); | ||
2451 | 2417 | ||
2452 | if (indirect.idx < 0 || indirect.idx >= dma->buf_count) { | 2418 | if (indirect->idx < 0 || indirect->idx >= dma->buf_count) { |
2453 | DRM_ERROR("buffer index %d (of %d max)\n", | 2419 | DRM_ERROR("buffer index %d (of %d max)\n", |
2454 | indirect.idx, dma->buf_count - 1); | 2420 | indirect->idx, dma->buf_count - 1); |
2455 | return -EINVAL; | 2421 | return -EINVAL; |
2456 | } | 2422 | } |
2457 | 2423 | ||
2458 | buf = dma->buflist[indirect.idx]; | 2424 | buf = dma->buflist[indirect->idx]; |
2459 | 2425 | ||
2460 | if (buf->file_priv != file_priv) { | 2426 | if (buf->file_priv != file_priv) { |
2461 | DRM_ERROR("process %d using buffer owned by %p\n", | 2427 | DRM_ERROR("process %d using buffer owned by %p\n", |
@@ -2463,20 +2429,20 @@ static int radeon_cp_indirect(DRM_IOCTL_ARGS) | |||
2463 | return -EINVAL; | 2429 | return -EINVAL; |
2464 | } | 2430 | } |
2465 | if (buf->pending) { | 2431 | if (buf->pending) { |
2466 | DRM_ERROR("sending pending buffer %d\n", indirect.idx); | 2432 | DRM_ERROR("sending pending buffer %d\n", indirect->idx); |
2467 | return -EINVAL; | 2433 | return -EINVAL; |
2468 | } | 2434 | } |
2469 | 2435 | ||
2470 | if (indirect.start < buf->used) { | 2436 | if (indirect->start < buf->used) { |
2471 | DRM_ERROR("reusing indirect: start=0x%x actual=0x%x\n", | 2437 | DRM_ERROR("reusing indirect: start=0x%x actual=0x%x\n", |
2472 | indirect.start, buf->used); | 2438 | indirect->start, buf->used); |
2473 | return -EINVAL; | 2439 | return -EINVAL; |
2474 | } | 2440 | } |
2475 | 2441 | ||
2476 | RING_SPACE_TEST_WITH_RETURN(dev_priv); | 2442 | RING_SPACE_TEST_WITH_RETURN(dev_priv); |
2477 | VB_AGE_TEST_WITH_RETURN(dev_priv); | 2443 | VB_AGE_TEST_WITH_RETURN(dev_priv); |
2478 | 2444 | ||
2479 | buf->used = indirect.end; | 2445 | buf->used = indirect->end; |
2480 | 2446 | ||
2481 | /* Wait for the 3D stream to idle before the indirect buffer | 2447 | /* Wait for the 3D stream to idle before the indirect buffer |
2482 | * containing 2D acceleration commands is processed. | 2448 | * containing 2D acceleration commands is processed. |
@@ -2491,8 +2457,8 @@ static int radeon_cp_indirect(DRM_IOCTL_ARGS) | |||
2491 | * X server. This is insecure and is thus only available to | 2457 | * X server. This is insecure and is thus only available to |
2492 | * privileged clients. | 2458 | * privileged clients. |
2493 | */ | 2459 | */ |
2494 | radeon_cp_dispatch_indirect(dev, buf, indirect.start, indirect.end); | 2460 | radeon_cp_dispatch_indirect(dev, buf, indirect->start, indirect->end); |
2495 | if (indirect.discard) { | 2461 | if (indirect->discard) { |
2496 | radeon_cp_discard_buffer(dev, buf); | 2462 | radeon_cp_discard_buffer(dev, buf); |
2497 | } | 2463 | } |
2498 | 2464 | ||
@@ -2500,35 +2466,31 @@ static int radeon_cp_indirect(DRM_IOCTL_ARGS) | |||
2500 | return 0; | 2466 | return 0; |
2501 | } | 2467 | } |
2502 | 2468 | ||
2503 | static int radeon_cp_vertex2(DRM_IOCTL_ARGS) | 2469 | static int radeon_cp_vertex2(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2504 | { | 2470 | { |
2505 | DRM_DEVICE; | ||
2506 | drm_radeon_private_t *dev_priv = dev->dev_private; | 2471 | drm_radeon_private_t *dev_priv = dev->dev_private; |
2507 | drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; | 2472 | drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; |
2508 | struct drm_device_dma *dma = dev->dma; | 2473 | struct drm_device_dma *dma = dev->dma; |
2509 | struct drm_buf *buf; | 2474 | struct drm_buf *buf; |
2510 | drm_radeon_vertex2_t vertex; | 2475 | drm_radeon_vertex2_t *vertex = data; |
2511 | int i; | 2476 | int i; |
2512 | unsigned char laststate; | 2477 | unsigned char laststate; |
2513 | 2478 | ||
2514 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 2479 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
2515 | 2480 | ||
2516 | DRM_COPY_FROM_USER_IOCTL(vertex, (drm_radeon_vertex2_t __user *) data, | ||
2517 | sizeof(vertex)); | ||
2518 | |||
2519 | DRM_DEBUG("pid=%d index=%d discard=%d\n", | 2481 | DRM_DEBUG("pid=%d index=%d discard=%d\n", |
2520 | DRM_CURRENTPID, vertex.idx, vertex.discard); | 2482 | DRM_CURRENTPID, vertex->idx, vertex->discard); |
2521 | 2483 | ||
2522 | if (vertex.idx < 0 || vertex.idx >= dma->buf_count) { | 2484 | if (vertex->idx < 0 || vertex->idx >= dma->buf_count) { |
2523 | DRM_ERROR("buffer index %d (of %d max)\n", | 2485 | DRM_ERROR("buffer index %d (of %d max)\n", |
2524 | vertex.idx, dma->buf_count - 1); | 2486 | vertex->idx, dma->buf_count - 1); |
2525 | return -EINVAL; | 2487 | return -EINVAL; |
2526 | } | 2488 | } |
2527 | 2489 | ||
2528 | RING_SPACE_TEST_WITH_RETURN(dev_priv); | 2490 | RING_SPACE_TEST_WITH_RETURN(dev_priv); |
2529 | VB_AGE_TEST_WITH_RETURN(dev_priv); | 2491 | VB_AGE_TEST_WITH_RETURN(dev_priv); |
2530 | 2492 | ||
2531 | buf = dma->buflist[vertex.idx]; | 2493 | buf = dma->buflist[vertex->idx]; |
2532 | 2494 | ||
2533 | if (buf->file_priv != file_priv) { | 2495 | if (buf->file_priv != file_priv) { |
2534 | DRM_ERROR("process %d using buffer owned by %p\n", | 2496 | DRM_ERROR("process %d using buffer owned by %p\n", |
@@ -2537,25 +2499,25 @@ static int radeon_cp_vertex2(DRM_IOCTL_ARGS) | |||
2537 | } | 2499 | } |
2538 | 2500 | ||
2539 | if (buf->pending) { | 2501 | if (buf->pending) { |
2540 | DRM_ERROR("sending pending buffer %d\n", vertex.idx); | 2502 | DRM_ERROR("sending pending buffer %d\n", vertex->idx); |
2541 | return -EINVAL; | 2503 | return -EINVAL; |
2542 | } | 2504 | } |
2543 | 2505 | ||
2544 | if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS) | 2506 | if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS) |
2545 | return -EINVAL; | 2507 | return -EINVAL; |
2546 | 2508 | ||
2547 | for (laststate = 0xff, i = 0; i < vertex.nr_prims; i++) { | 2509 | for (laststate = 0xff, i = 0; i < vertex->nr_prims; i++) { |
2548 | drm_radeon_prim_t prim; | 2510 | drm_radeon_prim_t prim; |
2549 | drm_radeon_tcl_prim_t tclprim; | 2511 | drm_radeon_tcl_prim_t tclprim; |
2550 | 2512 | ||
2551 | if (DRM_COPY_FROM_USER(&prim, &vertex.prim[i], sizeof(prim))) | 2513 | if (DRM_COPY_FROM_USER(&prim, &vertex->prim[i], sizeof(prim))) |
2552 | return -EFAULT; | 2514 | return -EFAULT; |
2553 | 2515 | ||
2554 | if (prim.stateidx != laststate) { | 2516 | if (prim.stateidx != laststate) { |
2555 | drm_radeon_state_t state; | 2517 | drm_radeon_state_t state; |
2556 | 2518 | ||
2557 | if (DRM_COPY_FROM_USER(&state, | 2519 | if (DRM_COPY_FROM_USER(&state, |
2558 | &vertex.state[prim.stateidx], | 2520 | &vertex->state[prim.stateidx], |
2559 | sizeof(state))) | 2521 | sizeof(state))) |
2560 | return -EFAULT; | 2522 | return -EFAULT; |
2561 | 2523 | ||
@@ -2588,7 +2550,7 @@ static int radeon_cp_vertex2(DRM_IOCTL_ARGS) | |||
2588 | sarea_priv->nbox = 0; | 2550 | sarea_priv->nbox = 0; |
2589 | } | 2551 | } |
2590 | 2552 | ||
2591 | if (vertex.discard) { | 2553 | if (vertex->discard) { |
2592 | radeon_cp_discard_buffer(dev, buf); | 2554 | radeon_cp_discard_buffer(dev, buf); |
2593 | } | 2555 | } |
2594 | 2556 | ||
@@ -2839,28 +2801,23 @@ static int radeon_emit_wait(struct drm_device * dev, int flags) | |||
2839 | return 0; | 2801 | return 0; |
2840 | } | 2802 | } |
2841 | 2803 | ||
2842 | static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS) | 2804 | static int radeon_cp_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_priv) |
2843 | { | 2805 | { |
2844 | DRM_DEVICE; | ||
2845 | drm_radeon_private_t *dev_priv = dev->dev_private; | 2806 | drm_radeon_private_t *dev_priv = dev->dev_private; |
2846 | struct drm_device_dma *dma = dev->dma; | 2807 | struct drm_device_dma *dma = dev->dma; |
2847 | struct drm_buf *buf = NULL; | 2808 | struct drm_buf *buf = NULL; |
2848 | int idx; | 2809 | int idx; |
2849 | drm_radeon_kcmd_buffer_t cmdbuf; | 2810 | drm_radeon_kcmd_buffer_t *cmdbuf = data; |
2850 | drm_radeon_cmd_header_t header; | 2811 | drm_radeon_cmd_header_t header; |
2851 | int orig_nbox, orig_bufsz; | 2812 | int orig_nbox, orig_bufsz; |
2852 | char *kbuf = NULL; | 2813 | char *kbuf = NULL; |
2853 | 2814 | ||
2854 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 2815 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
2855 | 2816 | ||
2856 | DRM_COPY_FROM_USER_IOCTL(cmdbuf, | ||
2857 | (drm_radeon_cmd_buffer_t __user *) data, | ||
2858 | sizeof(cmdbuf)); | ||
2859 | |||
2860 | RING_SPACE_TEST_WITH_RETURN(dev_priv); | 2817 | RING_SPACE_TEST_WITH_RETURN(dev_priv); |
2861 | VB_AGE_TEST_WITH_RETURN(dev_priv); | 2818 | VB_AGE_TEST_WITH_RETURN(dev_priv); |
2862 | 2819 | ||
2863 | if (cmdbuf.bufsz > 64 * 1024 || cmdbuf.bufsz < 0) { | 2820 | if (cmdbuf->bufsz > 64 * 1024 || cmdbuf->bufsz < 0) { |
2864 | return -EINVAL; | 2821 | return -EINVAL; |
2865 | } | 2822 | } |
2866 | 2823 | ||
@@ -2868,24 +2825,24 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS) | |||
2868 | * races between checking values and using those values in other code, | 2825 | * races between checking values and using those values in other code, |
2869 | * and simply to avoid a lot of function calls to copy in data. | 2826 | * and simply to avoid a lot of function calls to copy in data. |
2870 | */ | 2827 | */ |
2871 | orig_bufsz = cmdbuf.bufsz; | 2828 | orig_bufsz = cmdbuf->bufsz; |
2872 | if (orig_bufsz != 0) { | 2829 | if (orig_bufsz != 0) { |
2873 | kbuf = drm_alloc(cmdbuf.bufsz, DRM_MEM_DRIVER); | 2830 | kbuf = drm_alloc(cmdbuf->bufsz, DRM_MEM_DRIVER); |
2874 | if (kbuf == NULL) | 2831 | if (kbuf == NULL) |
2875 | return -ENOMEM; | 2832 | return -ENOMEM; |
2876 | if (DRM_COPY_FROM_USER(kbuf, (void __user *)cmdbuf.buf, | 2833 | if (DRM_COPY_FROM_USER(kbuf, (void __user *)cmdbuf->buf, |
2877 | cmdbuf.bufsz)) { | 2834 | cmdbuf->bufsz)) { |
2878 | drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER); | 2835 | drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER); |
2879 | return -EFAULT; | 2836 | return -EFAULT; |
2880 | } | 2837 | } |
2881 | cmdbuf.buf = kbuf; | 2838 | cmdbuf->buf = kbuf; |
2882 | } | 2839 | } |
2883 | 2840 | ||
2884 | orig_nbox = cmdbuf.nbox; | 2841 | orig_nbox = cmdbuf->nbox; |
2885 | 2842 | ||
2886 | if (dev_priv->microcode_version == UCODE_R300) { | 2843 | if (dev_priv->microcode_version == UCODE_R300) { |
2887 | int temp; | 2844 | int temp; |
2888 | temp = r300_do_cp_cmdbuf(dev, file_priv, &cmdbuf); | 2845 | temp = r300_do_cp_cmdbuf(dev, file_priv, cmdbuf); |
2889 | 2846 | ||
2890 | if (orig_bufsz != 0) | 2847 | if (orig_bufsz != 0) |
2891 | drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER); | 2848 | drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER); |
@@ -2894,17 +2851,17 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS) | |||
2894 | } | 2851 | } |
2895 | 2852 | ||
2896 | /* microcode_version != r300 */ | 2853 | /* microcode_version != r300 */ |
2897 | while (cmdbuf.bufsz >= sizeof(header)) { | 2854 | while (cmdbuf->bufsz >= sizeof(header)) { |
2898 | 2855 | ||
2899 | header.i = *(int *)cmdbuf.buf; | 2856 | header.i = *(int *)cmdbuf->buf; |
2900 | cmdbuf.buf += sizeof(header); | 2857 | cmdbuf->buf += sizeof(header); |
2901 | cmdbuf.bufsz -= sizeof(header); | 2858 | cmdbuf->bufsz -= sizeof(header); |
2902 | 2859 | ||
2903 | switch (header.header.cmd_type) { | 2860 | switch (header.header.cmd_type) { |
2904 | case RADEON_CMD_PACKET: | 2861 | case RADEON_CMD_PACKET: |
2905 | DRM_DEBUG("RADEON_CMD_PACKET\n"); | 2862 | DRM_DEBUG("RADEON_CMD_PACKET\n"); |
2906 | if (radeon_emit_packets | 2863 | if (radeon_emit_packets |
2907 | (dev_priv, file_priv, header, &cmdbuf)) { | 2864 | (dev_priv, file_priv, header, cmdbuf)) { |
2908 | DRM_ERROR("radeon_emit_packets failed\n"); | 2865 | DRM_ERROR("radeon_emit_packets failed\n"); |
2909 | goto err; | 2866 | goto err; |
2910 | } | 2867 | } |
@@ -2912,7 +2869,7 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS) | |||
2912 | 2869 | ||
2913 | case RADEON_CMD_SCALARS: | 2870 | case RADEON_CMD_SCALARS: |
2914 | DRM_DEBUG("RADEON_CMD_SCALARS\n"); | 2871 | DRM_DEBUG("RADEON_CMD_SCALARS\n"); |
2915 | if (radeon_emit_scalars(dev_priv, header, &cmdbuf)) { | 2872 | if (radeon_emit_scalars(dev_priv, header, cmdbuf)) { |
2916 | DRM_ERROR("radeon_emit_scalars failed\n"); | 2873 | DRM_ERROR("radeon_emit_scalars failed\n"); |
2917 | goto err; | 2874 | goto err; |
2918 | } | 2875 | } |
@@ -2920,7 +2877,7 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS) | |||
2920 | 2877 | ||
2921 | case RADEON_CMD_VECTORS: | 2878 | case RADEON_CMD_VECTORS: |
2922 | DRM_DEBUG("RADEON_CMD_VECTORS\n"); | 2879 | DRM_DEBUG("RADEON_CMD_VECTORS\n"); |
2923 | if (radeon_emit_vectors(dev_priv, header, &cmdbuf)) { | 2880 | if (radeon_emit_vectors(dev_priv, header, cmdbuf)) { |
2924 | DRM_ERROR("radeon_emit_vectors failed\n"); | 2881 | DRM_ERROR("radeon_emit_vectors failed\n"); |
2925 | goto err; | 2882 | goto err; |
2926 | } | 2883 | } |
@@ -2948,7 +2905,7 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS) | |||
2948 | 2905 | ||
2949 | case RADEON_CMD_PACKET3: | 2906 | case RADEON_CMD_PACKET3: |
2950 | DRM_DEBUG("RADEON_CMD_PACKET3\n"); | 2907 | DRM_DEBUG("RADEON_CMD_PACKET3\n"); |
2951 | if (radeon_emit_packet3(dev, file_priv, &cmdbuf)) { | 2908 | if (radeon_emit_packet3(dev, file_priv, cmdbuf)) { |
2952 | DRM_ERROR("radeon_emit_packet3 failed\n"); | 2909 | DRM_ERROR("radeon_emit_packet3 failed\n"); |
2953 | goto err; | 2910 | goto err; |
2954 | } | 2911 | } |
@@ -2957,7 +2914,7 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS) | |||
2957 | case RADEON_CMD_PACKET3_CLIP: | 2914 | case RADEON_CMD_PACKET3_CLIP: |
2958 | DRM_DEBUG("RADEON_CMD_PACKET3_CLIP\n"); | 2915 | DRM_DEBUG("RADEON_CMD_PACKET3_CLIP\n"); |
2959 | if (radeon_emit_packet3_cliprect | 2916 | if (radeon_emit_packet3_cliprect |
2960 | (dev, file_priv, &cmdbuf, orig_nbox)) { | 2917 | (dev, file_priv, cmdbuf, orig_nbox)) { |
2961 | DRM_ERROR("radeon_emit_packet3_clip failed\n"); | 2918 | DRM_ERROR("radeon_emit_packet3_clip failed\n"); |
2962 | goto err; | 2919 | goto err; |
2963 | } | 2920 | } |
@@ -2965,7 +2922,7 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS) | |||
2965 | 2922 | ||
2966 | case RADEON_CMD_SCALARS2: | 2923 | case RADEON_CMD_SCALARS2: |
2967 | DRM_DEBUG("RADEON_CMD_SCALARS2\n"); | 2924 | DRM_DEBUG("RADEON_CMD_SCALARS2\n"); |
2968 | if (radeon_emit_scalars2(dev_priv, header, &cmdbuf)) { | 2925 | if (radeon_emit_scalars2(dev_priv, header, cmdbuf)) { |
2969 | DRM_ERROR("radeon_emit_scalars2 failed\n"); | 2926 | DRM_ERROR("radeon_emit_scalars2 failed\n"); |
2970 | goto err; | 2927 | goto err; |
2971 | } | 2928 | } |
@@ -2980,7 +2937,7 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS) | |||
2980 | break; | 2937 | break; |
2981 | case RADEON_CMD_VECLINEAR: | 2938 | case RADEON_CMD_VECLINEAR: |
2982 | DRM_DEBUG("RADEON_CMD_VECLINEAR\n"); | 2939 | DRM_DEBUG("RADEON_CMD_VECLINEAR\n"); |
2983 | if (radeon_emit_veclinear(dev_priv, header, &cmdbuf)) { | 2940 | if (radeon_emit_veclinear(dev_priv, header, cmdbuf)) { |
2984 | DRM_ERROR("radeon_emit_veclinear failed\n"); | 2941 | DRM_ERROR("radeon_emit_veclinear failed\n"); |
2985 | goto err; | 2942 | goto err; |
2986 | } | 2943 | } |
@@ -2989,7 +2946,7 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS) | |||
2989 | default: | 2946 | default: |
2990 | DRM_ERROR("bad cmd_type %d at %p\n", | 2947 | DRM_ERROR("bad cmd_type %d at %p\n", |
2991 | header.header.cmd_type, | 2948 | header.header.cmd_type, |
2992 | cmdbuf.buf - sizeof(header)); | 2949 | cmdbuf->buf - sizeof(header)); |
2993 | goto err; | 2950 | goto err; |
2994 | } | 2951 | } |
2995 | } | 2952 | } |
@@ -3007,19 +2964,15 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS) | |||
3007 | return -EINVAL; | 2964 | return -EINVAL; |
3008 | } | 2965 | } |
3009 | 2966 | ||
3010 | static int radeon_cp_getparam(DRM_IOCTL_ARGS) | 2967 | static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv) |
3011 | { | 2968 | { |
3012 | DRM_DEVICE; | ||
3013 | drm_radeon_private_t *dev_priv = dev->dev_private; | 2969 | drm_radeon_private_t *dev_priv = dev->dev_private; |
3014 | drm_radeon_getparam_t param; | 2970 | drm_radeon_getparam_t *param = data; |
3015 | int value; | 2971 | int value; |
3016 | 2972 | ||
3017 | DRM_COPY_FROM_USER_IOCTL(param, (drm_radeon_getparam_t __user *) data, | ||
3018 | sizeof(param)); | ||
3019 | |||
3020 | DRM_DEBUG("pid=%d\n", DRM_CURRENTPID); | 2973 | DRM_DEBUG("pid=%d\n", DRM_CURRENTPID); |
3021 | 2974 | ||
3022 | switch (param.param) { | 2975 | switch (param->param) { |
3023 | case RADEON_PARAM_GART_BUFFER_OFFSET: | 2976 | case RADEON_PARAM_GART_BUFFER_OFFSET: |
3024 | value = dev_priv->gart_buffers_offset; | 2977 | value = dev_priv->gart_buffers_offset; |
3025 | break; | 2978 | break; |
@@ -3081,11 +3034,11 @@ static int radeon_cp_getparam(DRM_IOCTL_ARGS) | |||
3081 | value = radeon_vblank_crtc_get(dev); | 3034 | value = radeon_vblank_crtc_get(dev); |
3082 | break; | 3035 | break; |
3083 | default: | 3036 | default: |
3084 | DRM_DEBUG("Invalid parameter %d\n", param.param); | 3037 | DRM_DEBUG("Invalid parameter %d\n", param->param); |
3085 | return -EINVAL; | 3038 | return -EINVAL; |
3086 | } | 3039 | } |
3087 | 3040 | ||
3088 | if (DRM_COPY_TO_USER(param.value, &value, sizeof(int))) { | 3041 | if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) { |
3089 | DRM_ERROR("copy_to_user\n"); | 3042 | DRM_ERROR("copy_to_user\n"); |
3090 | return -EFAULT; | 3043 | return -EFAULT; |
3091 | } | 3044 | } |
@@ -3093,28 +3046,25 @@ static int radeon_cp_getparam(DRM_IOCTL_ARGS) | |||
3093 | return 0; | 3046 | return 0; |
3094 | } | 3047 | } |
3095 | 3048 | ||
3096 | static int radeon_cp_setparam(DRM_IOCTL_ARGS) | 3049 | static int radeon_cp_setparam(struct drm_device *dev, void *data, struct drm_file *file_priv) |
3097 | { | 3050 | { |
3098 | DRM_DEVICE; | ||
3099 | drm_radeon_private_t *dev_priv = dev->dev_private; | 3051 | drm_radeon_private_t *dev_priv = dev->dev_private; |
3100 | drm_radeon_setparam_t sp; | 3052 | drm_radeon_setparam_t *sp = data; |
3101 | struct drm_radeon_driver_file_fields *radeon_priv; | 3053 | struct drm_radeon_driver_file_fields *radeon_priv; |
3102 | 3054 | ||
3103 | DRM_COPY_FROM_USER_IOCTL(sp, (drm_radeon_setparam_t __user *) data, | 3055 | switch (sp->param) { |
3104 | sizeof(sp)); | ||
3105 | |||
3106 | switch (sp.param) { | ||
3107 | case RADEON_SETPARAM_FB_LOCATION: | 3056 | case RADEON_SETPARAM_FB_LOCATION: |
3108 | radeon_priv = file_priv->driver_priv; | 3057 | radeon_priv = file_priv->driver_priv; |
3109 | radeon_priv->radeon_fb_delta = dev_priv->fb_location - sp.value; | 3058 | radeon_priv->radeon_fb_delta = dev_priv->fb_location - |
3059 | sp->value; | ||
3110 | break; | 3060 | break; |
3111 | case RADEON_SETPARAM_SWITCH_TILING: | 3061 | case RADEON_SETPARAM_SWITCH_TILING: |
3112 | if (sp.value == 0) { | 3062 | if (sp->value == 0) { |
3113 | DRM_DEBUG("color tiling disabled\n"); | 3063 | DRM_DEBUG("color tiling disabled\n"); |
3114 | dev_priv->front_pitch_offset &= ~RADEON_DST_TILE_MACRO; | 3064 | dev_priv->front_pitch_offset &= ~RADEON_DST_TILE_MACRO; |
3115 | dev_priv->back_pitch_offset &= ~RADEON_DST_TILE_MACRO; | 3065 | dev_priv->back_pitch_offset &= ~RADEON_DST_TILE_MACRO; |
3116 | dev_priv->sarea_priv->tiling_enabled = 0; | 3066 | dev_priv->sarea_priv->tiling_enabled = 0; |
3117 | } else if (sp.value == 1) { | 3067 | } else if (sp->value == 1) { |
3118 | DRM_DEBUG("color tiling enabled\n"); | 3068 | DRM_DEBUG("color tiling enabled\n"); |
3119 | dev_priv->front_pitch_offset |= RADEON_DST_TILE_MACRO; | 3069 | dev_priv->front_pitch_offset |= RADEON_DST_TILE_MACRO; |
3120 | dev_priv->back_pitch_offset |= RADEON_DST_TILE_MACRO; | 3070 | dev_priv->back_pitch_offset |= RADEON_DST_TILE_MACRO; |
@@ -3122,22 +3072,22 @@ static int radeon_cp_setparam(DRM_IOCTL_ARGS) | |||
3122 | } | 3072 | } |
3123 | break; | 3073 | break; |
3124 | case RADEON_SETPARAM_PCIGART_LOCATION: | 3074 | case RADEON_SETPARAM_PCIGART_LOCATION: |
3125 | dev_priv->pcigart_offset = sp.value; | 3075 | dev_priv->pcigart_offset = sp->value; |
3126 | dev_priv->pcigart_offset_set = 1; | 3076 | dev_priv->pcigart_offset_set = 1; |
3127 | break; | 3077 | break; |
3128 | case RADEON_SETPARAM_NEW_MEMMAP: | 3078 | case RADEON_SETPARAM_NEW_MEMMAP: |
3129 | dev_priv->new_memmap = sp.value; | 3079 | dev_priv->new_memmap = sp->value; |
3130 | break; | 3080 | break; |
3131 | case RADEON_SETPARAM_PCIGART_TABLE_SIZE: | 3081 | case RADEON_SETPARAM_PCIGART_TABLE_SIZE: |
3132 | dev_priv->gart_info.table_size = sp.value; | 3082 | dev_priv->gart_info.table_size = sp->value; |
3133 | if (dev_priv->gart_info.table_size < RADEON_PCIGART_TABLE_SIZE) | 3083 | if (dev_priv->gart_info.table_size < RADEON_PCIGART_TABLE_SIZE) |
3134 | dev_priv->gart_info.table_size = RADEON_PCIGART_TABLE_SIZE; | 3084 | dev_priv->gart_info.table_size = RADEON_PCIGART_TABLE_SIZE; |
3135 | break; | 3085 | break; |
3136 | case RADEON_SETPARAM_VBLANK_CRTC: | 3086 | case RADEON_SETPARAM_VBLANK_CRTC: |
3137 | return radeon_vblank_crtc_set(dev, sp.value); | 3087 | return radeon_vblank_crtc_set(dev, sp->value); |
3138 | break; | 3088 | break; |
3139 | default: | 3089 | default: |
3140 | DRM_DEBUG("Invalid parameter %d\n", sp.param); | 3090 | DRM_DEBUG("Invalid parameter %d\n", sp->param); |
3141 | return -EINVAL; | 3091 | return -EINVAL; |
3142 | } | 3092 | } |
3143 | 3093 | ||
@@ -3205,34 +3155,34 @@ void radeon_driver_postclose(struct drm_device *dev, struct drm_file *file_priv) | |||
3205 | drm_free(radeon_priv, sizeof(*radeon_priv), DRM_MEM_FILES); | 3155 | drm_free(radeon_priv, sizeof(*radeon_priv), DRM_MEM_FILES); |
3206 | } | 3156 | } |
3207 | 3157 | ||
3208 | drm_ioctl_desc_t radeon_ioctls[] = { | 3158 | struct drm_ioctl_desc radeon_ioctls[] = { |
3209 | [DRM_IOCTL_NR(DRM_RADEON_CP_INIT)] = {radeon_cp_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 3159 | DRM_IOCTL_DEF(DRM_RADEON_CP_INIT, radeon_cp_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
3210 | [DRM_IOCTL_NR(DRM_RADEON_CP_START)] = {radeon_cp_start, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 3160 | DRM_IOCTL_DEF(DRM_RADEON_CP_START, radeon_cp_start, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
3211 | [DRM_IOCTL_NR(DRM_RADEON_CP_STOP)] = {radeon_cp_stop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 3161 | DRM_IOCTL_DEF(DRM_RADEON_CP_STOP, radeon_cp_stop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
3212 | [DRM_IOCTL_NR(DRM_RADEON_CP_RESET)] = {radeon_cp_reset, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 3162 | DRM_IOCTL_DEF(DRM_RADEON_CP_RESET, radeon_cp_reset, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
3213 | [DRM_IOCTL_NR(DRM_RADEON_CP_IDLE)] = {radeon_cp_idle, DRM_AUTH}, | 3163 | DRM_IOCTL_DEF(DRM_RADEON_CP_IDLE, radeon_cp_idle, DRM_AUTH), |
3214 | [DRM_IOCTL_NR(DRM_RADEON_CP_RESUME)] = {radeon_cp_resume, DRM_AUTH}, | 3164 | DRM_IOCTL_DEF(DRM_RADEON_CP_RESUME, radeon_cp_resume, DRM_AUTH), |
3215 | [DRM_IOCTL_NR(DRM_RADEON_RESET)] = {radeon_engine_reset, DRM_AUTH}, | 3165 | DRM_IOCTL_DEF(DRM_RADEON_RESET, radeon_engine_reset, DRM_AUTH), |
3216 | [DRM_IOCTL_NR(DRM_RADEON_FULLSCREEN)] = {radeon_fullscreen, DRM_AUTH}, | 3166 | DRM_IOCTL_DEF(DRM_RADEON_FULLSCREEN, radeon_fullscreen, DRM_AUTH), |
3217 | [DRM_IOCTL_NR(DRM_RADEON_SWAP)] = {radeon_cp_swap, DRM_AUTH}, | 3167 | DRM_IOCTL_DEF(DRM_RADEON_SWAP, radeon_cp_swap, DRM_AUTH), |
3218 | [DRM_IOCTL_NR(DRM_RADEON_CLEAR)] = {radeon_cp_clear, DRM_AUTH}, | 3168 | DRM_IOCTL_DEF(DRM_RADEON_CLEAR, radeon_cp_clear, DRM_AUTH), |
3219 | [DRM_IOCTL_NR(DRM_RADEON_VERTEX)] = {radeon_cp_vertex, DRM_AUTH}, | 3169 | DRM_IOCTL_DEF(DRM_RADEON_VERTEX, radeon_cp_vertex, DRM_AUTH), |
3220 | [DRM_IOCTL_NR(DRM_RADEON_INDICES)] = {radeon_cp_indices, DRM_AUTH}, | 3170 | DRM_IOCTL_DEF(DRM_RADEON_INDICES, radeon_cp_indices, DRM_AUTH), |
3221 | [DRM_IOCTL_NR(DRM_RADEON_TEXTURE)] = {radeon_cp_texture, DRM_AUTH}, | 3171 | DRM_IOCTL_DEF(DRM_RADEON_TEXTURE, radeon_cp_texture, DRM_AUTH), |
3222 | [DRM_IOCTL_NR(DRM_RADEON_STIPPLE)] = {radeon_cp_stipple, DRM_AUTH}, | 3172 | DRM_IOCTL_DEF(DRM_RADEON_STIPPLE, radeon_cp_stipple, DRM_AUTH), |
3223 | [DRM_IOCTL_NR(DRM_RADEON_INDIRECT)] = {radeon_cp_indirect, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 3173 | DRM_IOCTL_DEF(DRM_RADEON_INDIRECT, radeon_cp_indirect, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
3224 | [DRM_IOCTL_NR(DRM_RADEON_VERTEX2)] = {radeon_cp_vertex2, DRM_AUTH}, | 3174 | DRM_IOCTL_DEF(DRM_RADEON_VERTEX2, radeon_cp_vertex2, DRM_AUTH), |
3225 | [DRM_IOCTL_NR(DRM_RADEON_CMDBUF)] = {radeon_cp_cmdbuf, DRM_AUTH}, | 3175 | DRM_IOCTL_DEF(DRM_RADEON_CMDBUF, radeon_cp_cmdbuf, DRM_AUTH), |
3226 | [DRM_IOCTL_NR(DRM_RADEON_GETPARAM)] = {radeon_cp_getparam, DRM_AUTH}, | 3176 | DRM_IOCTL_DEF(DRM_RADEON_GETPARAM, radeon_cp_getparam, DRM_AUTH), |
3227 | [DRM_IOCTL_NR(DRM_RADEON_FLIP)] = {radeon_cp_flip, DRM_AUTH}, | 3177 | DRM_IOCTL_DEF(DRM_RADEON_FLIP, radeon_cp_flip, DRM_AUTH), |
3228 | [DRM_IOCTL_NR(DRM_RADEON_ALLOC)] = {radeon_mem_alloc, DRM_AUTH}, | 3178 | DRM_IOCTL_DEF(DRM_RADEON_ALLOC, radeon_mem_alloc, DRM_AUTH), |
3229 | [DRM_IOCTL_NR(DRM_RADEON_FREE)] = {radeon_mem_free, DRM_AUTH}, | 3179 | DRM_IOCTL_DEF(DRM_RADEON_FREE, radeon_mem_free, DRM_AUTH), |
3230 | [DRM_IOCTL_NR(DRM_RADEON_INIT_HEAP)] = {radeon_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 3180 | DRM_IOCTL_DEF(DRM_RADEON_INIT_HEAP, radeon_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
3231 | [DRM_IOCTL_NR(DRM_RADEON_IRQ_EMIT)] = {radeon_irq_emit, DRM_AUTH}, | 3181 | DRM_IOCTL_DEF(DRM_RADEON_IRQ_EMIT, radeon_irq_emit, DRM_AUTH), |
3232 | [DRM_IOCTL_NR(DRM_RADEON_IRQ_WAIT)] = {radeon_irq_wait, DRM_AUTH}, | 3182 | DRM_IOCTL_DEF(DRM_RADEON_IRQ_WAIT, radeon_irq_wait, DRM_AUTH), |
3233 | [DRM_IOCTL_NR(DRM_RADEON_SETPARAM)] = {radeon_cp_setparam, DRM_AUTH}, | 3183 | DRM_IOCTL_DEF(DRM_RADEON_SETPARAM, radeon_cp_setparam, DRM_AUTH), |
3234 | [DRM_IOCTL_NR(DRM_RADEON_SURF_ALLOC)] = {radeon_surface_alloc, DRM_AUTH}, | 3184 | DRM_IOCTL_DEF(DRM_RADEON_SURF_ALLOC, radeon_surface_alloc, DRM_AUTH), |
3235 | [DRM_IOCTL_NR(DRM_RADEON_SURF_FREE)] = {radeon_surface_free, DRM_AUTH} | 3185 | DRM_IOCTL_DEF(DRM_RADEON_SURF_FREE, radeon_surface_free, DRM_AUTH) |
3236 | }; | 3186 | }; |
3237 | 3187 | ||
3238 | int radeon_max_ioctl = DRM_ARRAY_SIZE(radeon_ioctls); | 3188 | int radeon_max_ioctl = DRM_ARRAY_SIZE(radeon_ioctls); |
diff --git a/drivers/char/drm/savage_bci.c b/drivers/char/drm/savage_bci.c index 18a3bc387817..59484d56b333 100644 --- a/drivers/char/drm/savage_bci.c +++ b/drivers/char/drm/savage_bci.c | |||
@@ -928,19 +928,15 @@ static int savage_do_cleanup_bci(struct drm_device * dev) | |||
928 | return 0; | 928 | return 0; |
929 | } | 929 | } |
930 | 930 | ||
931 | static int savage_bci_init(DRM_IOCTL_ARGS) | 931 | static int savage_bci_init(struct drm_device *dev, void *data, struct drm_file *file_priv) |
932 | { | 932 | { |
933 | DRM_DEVICE; | 933 | drm_savage_init_t *init = data; |
934 | drm_savage_init_t init; | ||
935 | 934 | ||
936 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 935 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
937 | 936 | ||
938 | DRM_COPY_FROM_USER_IOCTL(init, (drm_savage_init_t __user *) data, | 937 | switch (init->func) { |
939 | sizeof(init)); | ||
940 | |||
941 | switch (init.func) { | ||
942 | case SAVAGE_INIT_BCI: | 938 | case SAVAGE_INIT_BCI: |
943 | return savage_do_init_bci(dev, &init); | 939 | return savage_do_init_bci(dev, init); |
944 | case SAVAGE_CLEANUP_BCI: | 940 | case SAVAGE_CLEANUP_BCI: |
945 | return savage_do_cleanup_bci(dev); | 941 | return savage_do_cleanup_bci(dev); |
946 | } | 942 | } |
@@ -948,31 +944,25 @@ static int savage_bci_init(DRM_IOCTL_ARGS) | |||
948 | return -EINVAL; | 944 | return -EINVAL; |
949 | } | 945 | } |
950 | 946 | ||
951 | static int savage_bci_event_emit(DRM_IOCTL_ARGS) | 947 | static int savage_bci_event_emit(struct drm_device *dev, void *data, struct drm_file *file_priv) |
952 | { | 948 | { |
953 | DRM_DEVICE; | ||
954 | drm_savage_private_t *dev_priv = dev->dev_private; | 949 | drm_savage_private_t *dev_priv = dev->dev_private; |
955 | drm_savage_event_emit_t event; | 950 | drm_savage_event_emit_t *event = data; |
956 | 951 | ||
957 | DRM_DEBUG("\n"); | 952 | DRM_DEBUG("\n"); |
958 | 953 | ||
959 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 954 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
960 | 955 | ||
961 | DRM_COPY_FROM_USER_IOCTL(event, (drm_savage_event_emit_t __user *) data, | 956 | event->count = savage_bci_emit_event(dev_priv, event->flags); |
962 | sizeof(event)); | 957 | event->count |= dev_priv->event_wrap << 16; |
963 | 958 | ||
964 | event.count = savage_bci_emit_event(dev_priv, event.flags); | ||
965 | event.count |= dev_priv->event_wrap << 16; | ||
966 | DRM_COPY_TO_USER_IOCTL((drm_savage_event_emit_t __user *) data, | ||
967 | event, sizeof(event)); | ||
968 | return 0; | 959 | return 0; |
969 | } | 960 | } |
970 | 961 | ||
971 | static int savage_bci_event_wait(DRM_IOCTL_ARGS) | 962 | static int savage_bci_event_wait(struct drm_device *dev, void *data, struct drm_file *file_priv) |
972 | { | 963 | { |
973 | DRM_DEVICE; | ||
974 | drm_savage_private_t *dev_priv = dev->dev_private; | 964 | drm_savage_private_t *dev_priv = dev->dev_private; |
975 | drm_savage_event_wait_t event; | 965 | drm_savage_event_wait_t *event = data; |
976 | unsigned int event_e, hw_e; | 966 | unsigned int event_e, hw_e; |
977 | unsigned int event_w, hw_w; | 967 | unsigned int event_w, hw_w; |
978 | 968 | ||
@@ -990,8 +980,8 @@ static int savage_bci_event_wait(DRM_IOCTL_ARGS) | |||
990 | if (hw_e > dev_priv->event_counter) | 980 | if (hw_e > dev_priv->event_counter) |
991 | hw_w--; /* hardware hasn't passed the last wrap yet */ | 981 | hw_w--; /* hardware hasn't passed the last wrap yet */ |
992 | 982 | ||
993 | event_e = event.count & 0xffff; | 983 | event_e = event->count & 0xffff; |
994 | event_w = event.count >> 16; | 984 | event_w = event->count >> 16; |
995 | 985 | ||
996 | /* Don't need to wait if | 986 | /* Don't need to wait if |
997 | * - event counter wrapped since the event was emitted or | 987 | * - event counter wrapped since the event was emitted or |
@@ -1033,41 +1023,36 @@ static int savage_bci_get_buffers(struct drm_device *dev, | |||
1033 | return 0; | 1023 | return 0; |
1034 | } | 1024 | } |
1035 | 1025 | ||
1036 | int savage_bci_buffers(DRM_IOCTL_ARGS) | 1026 | int savage_bci_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv) |
1037 | { | 1027 | { |
1038 | DRM_DEVICE; | ||
1039 | struct drm_device_dma *dma = dev->dma; | 1028 | struct drm_device_dma *dma = dev->dma; |
1040 | struct drm_dma d; | 1029 | struct drm_dma *d = data; |
1041 | int ret = 0; | 1030 | int ret = 0; |
1042 | 1031 | ||
1043 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1032 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1044 | 1033 | ||
1045 | DRM_COPY_FROM_USER_IOCTL(d, (struct drm_dma __user *) data, sizeof(d)); | ||
1046 | |||
1047 | /* Please don't send us buffers. | 1034 | /* Please don't send us buffers. |
1048 | */ | 1035 | */ |
1049 | if (d.send_count != 0) { | 1036 | if (d->send_count != 0) { |
1050 | DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n", | 1037 | DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n", |
1051 | DRM_CURRENTPID, d.send_count); | 1038 | DRM_CURRENTPID, d->send_count); |
1052 | return -EINVAL; | 1039 | return -EINVAL; |
1053 | } | 1040 | } |
1054 | 1041 | ||
1055 | /* We'll send you buffers. | 1042 | /* We'll send you buffers. |
1056 | */ | 1043 | */ |
1057 | if (d.request_count < 0 || d.request_count > dma->buf_count) { | 1044 | if (d->request_count < 0 || d->request_count > dma->buf_count) { |
1058 | DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", | 1045 | DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", |
1059 | DRM_CURRENTPID, d.request_count, dma->buf_count); | 1046 | DRM_CURRENTPID, d->request_count, dma->buf_count); |
1060 | return -EINVAL; | 1047 | return -EINVAL; |
1061 | } | 1048 | } |
1062 | 1049 | ||
1063 | d.granted_count = 0; | 1050 | d->granted_count = 0; |
1064 | 1051 | ||
1065 | if (d.request_count) { | 1052 | if (d->request_count) { |
1066 | ret = savage_bci_get_buffers(dev, file_priv, &d); | 1053 | ret = savage_bci_get_buffers(dev, file_priv, d); |
1067 | } | 1054 | } |
1068 | 1055 | ||
1069 | DRM_COPY_TO_USER_IOCTL((struct drm_dma __user *) data, d, sizeof(d)); | ||
1070 | |||
1071 | return ret; | 1056 | return ret; |
1072 | } | 1057 | } |
1073 | 1058 | ||
@@ -1103,11 +1088,11 @@ void savage_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv) | |||
1103 | drm_core_reclaim_buffers(dev, file_priv); | 1088 | drm_core_reclaim_buffers(dev, file_priv); |
1104 | } | 1089 | } |
1105 | 1090 | ||
1106 | drm_ioctl_desc_t savage_ioctls[] = { | 1091 | struct drm_ioctl_desc savage_ioctls[] = { |
1107 | [DRM_IOCTL_NR(DRM_SAVAGE_BCI_INIT)] = {savage_bci_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 1092 | DRM_IOCTL_DEF(DRM_SAVAGE_BCI_INIT, savage_bci_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
1108 | [DRM_IOCTL_NR(DRM_SAVAGE_BCI_CMDBUF)] = {savage_bci_cmdbuf, DRM_AUTH}, | 1093 | DRM_IOCTL_DEF(DRM_SAVAGE_BCI_CMDBUF, savage_bci_cmdbuf, DRM_AUTH), |
1109 | [DRM_IOCTL_NR(DRM_SAVAGE_BCI_EVENT_EMIT)] = {savage_bci_event_emit, DRM_AUTH}, | 1094 | DRM_IOCTL_DEF(DRM_SAVAGE_BCI_EVENT_EMIT, savage_bci_event_emit, DRM_AUTH), |
1110 | [DRM_IOCTL_NR(DRM_SAVAGE_BCI_EVENT_WAIT)] = {savage_bci_event_wait, DRM_AUTH}, | 1095 | DRM_IOCTL_DEF(DRM_SAVAGE_BCI_EVENT_WAIT, savage_bci_event_wait, DRM_AUTH), |
1111 | }; | 1096 | }; |
1112 | 1097 | ||
1113 | int savage_max_ioctl = DRM_ARRAY_SIZE(savage_ioctls); | 1098 | int savage_max_ioctl = DRM_ARRAY_SIZE(savage_ioctls); |
diff --git a/drivers/char/drm/savage_drv.h b/drivers/char/drm/savage_drv.h index e4eac035d8fa..df2aac6636f7 100644 --- a/drivers/char/drm/savage_drv.h +++ b/drivers/char/drm/savage_drv.h | |||
@@ -104,7 +104,7 @@ enum savage_family { | |||
104 | S3_LAST | 104 | S3_LAST |
105 | }; | 105 | }; |
106 | 106 | ||
107 | extern drm_ioctl_desc_t savage_ioctls[]; | 107 | extern struct drm_ioctl_desc savage_ioctls[]; |
108 | extern int savage_max_ioctl; | 108 | extern int savage_max_ioctl; |
109 | 109 | ||
110 | #define S3_SAVAGE3D_SERIES(chip) ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE_MX)) | 110 | #define S3_SAVAGE3D_SERIES(chip) ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE_MX)) |
@@ -197,8 +197,8 @@ typedef struct drm_savage_private { | |||
197 | } drm_savage_private_t; | 197 | } drm_savage_private_t; |
198 | 198 | ||
199 | /* ioctls */ | 199 | /* ioctls */ |
200 | extern int savage_bci_cmdbuf(DRM_IOCTL_ARGS); | 200 | extern int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_priv); |
201 | extern int savage_bci_buffers(DRM_IOCTL_ARGS); | 201 | extern int savage_bci_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv); |
202 | 202 | ||
203 | /* BCI functions */ | 203 | /* BCI functions */ |
204 | extern uint16_t savage_bci_emit_event(drm_savage_private_t * dev_priv, | 204 | extern uint16_t savage_bci_emit_event(drm_savage_private_t * dev_priv, |
diff --git a/drivers/char/drm/savage_state.c b/drivers/char/drm/savage_state.c index 9a72d959084c..bf8e0e10fe21 100644 --- a/drivers/char/drm/savage_state.c +++ b/drivers/char/drm/savage_state.c | |||
@@ -953,13 +953,12 @@ static int savage_dispatch_draw(drm_savage_private_t * dev_priv, | |||
953 | return 0; | 953 | return 0; |
954 | } | 954 | } |
955 | 955 | ||
956 | int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | 956 | int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_priv) |
957 | { | 957 | { |
958 | DRM_DEVICE; | ||
959 | drm_savage_private_t *dev_priv = dev->dev_private; | 958 | drm_savage_private_t *dev_priv = dev->dev_private; |
960 | struct drm_device_dma *dma = dev->dma; | 959 | struct drm_device_dma *dma = dev->dma; |
961 | struct drm_buf *dmabuf; | 960 | struct drm_buf *dmabuf; |
962 | drm_savage_cmdbuf_t cmdbuf; | 961 | drm_savage_cmdbuf_t *cmdbuf = data; |
963 | drm_savage_cmd_header_t *kcmd_addr = NULL; | 962 | drm_savage_cmd_header_t *kcmd_addr = NULL; |
964 | drm_savage_cmd_header_t *first_draw_cmd; | 963 | drm_savage_cmd_header_t *first_draw_cmd; |
965 | unsigned int *kvb_addr = NULL; | 964 | unsigned int *kvb_addr = NULL; |
@@ -971,17 +970,14 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | |||
971 | 970 | ||
972 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 971 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
973 | 972 | ||
974 | DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_savage_cmdbuf_t __user *) data, | ||
975 | sizeof(cmdbuf)); | ||
976 | |||
977 | if (dma && dma->buflist) { | 973 | if (dma && dma->buflist) { |
978 | if (cmdbuf.dma_idx > dma->buf_count) { | 974 | if (cmdbuf->dma_idx > dma->buf_count) { |
979 | DRM_ERROR | 975 | DRM_ERROR |
980 | ("vertex buffer index %u out of range (0-%u)\n", | 976 | ("vertex buffer index %u out of range (0-%u)\n", |
981 | cmdbuf.dma_idx, dma->buf_count - 1); | 977 | cmdbuf->dma_idx, dma->buf_count - 1); |
982 | return -EINVAL; | 978 | return -EINVAL; |
983 | } | 979 | } |
984 | dmabuf = dma->buflist[cmdbuf.dma_idx]; | 980 | dmabuf = dma->buflist[cmdbuf->dma_idx]; |
985 | } else { | 981 | } else { |
986 | dmabuf = NULL; | 982 | dmabuf = NULL; |
987 | } | 983 | } |
@@ -991,47 +987,47 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | |||
991 | * COPY_FROM_USER_UNCHECKED when done in other drivers, and is correct | 987 | * COPY_FROM_USER_UNCHECKED when done in other drivers, and is correct |
992 | * for locking on FreeBSD. | 988 | * for locking on FreeBSD. |
993 | */ | 989 | */ |
994 | if (cmdbuf.size) { | 990 | if (cmdbuf->size) { |
995 | kcmd_addr = drm_alloc(cmdbuf.size * 8, DRM_MEM_DRIVER); | 991 | kcmd_addr = drm_alloc(cmdbuf->size * 8, DRM_MEM_DRIVER); |
996 | if (kcmd_addr == NULL) | 992 | if (kcmd_addr == NULL) |
997 | return -ENOMEM; | 993 | return -ENOMEM; |
998 | 994 | ||
999 | if (DRM_COPY_FROM_USER(kcmd_addr, cmdbuf.cmd_addr, | 995 | if (DRM_COPY_FROM_USER(kcmd_addr, cmdbuf->cmd_addr, |
1000 | cmdbuf.size * 8)) | 996 | cmdbuf->size * 8)) |
1001 | { | 997 | { |
1002 | drm_free(kcmd_addr, cmdbuf.size * 8, DRM_MEM_DRIVER); | 998 | drm_free(kcmd_addr, cmdbuf->size * 8, DRM_MEM_DRIVER); |
1003 | return -EFAULT; | 999 | return -EFAULT; |
1004 | } | 1000 | } |
1005 | cmdbuf.cmd_addr = kcmd_addr; | 1001 | cmdbuf->cmd_addr = kcmd_addr; |
1006 | } | 1002 | } |
1007 | if (cmdbuf.vb_size) { | 1003 | if (cmdbuf->vb_size) { |
1008 | kvb_addr = drm_alloc(cmdbuf.vb_size, DRM_MEM_DRIVER); | 1004 | kvb_addr = drm_alloc(cmdbuf->vb_size, DRM_MEM_DRIVER); |
1009 | if (kvb_addr == NULL) { | 1005 | if (kvb_addr == NULL) { |
1010 | ret = -ENOMEM; | 1006 | ret = -ENOMEM; |
1011 | goto done; | 1007 | goto done; |
1012 | } | 1008 | } |
1013 | 1009 | ||
1014 | if (DRM_COPY_FROM_USER(kvb_addr, cmdbuf.vb_addr, | 1010 | if (DRM_COPY_FROM_USER(kvb_addr, cmdbuf->vb_addr, |
1015 | cmdbuf.vb_size)) { | 1011 | cmdbuf->vb_size)) { |
1016 | ret = -EFAULT; | 1012 | ret = -EFAULT; |
1017 | goto done; | 1013 | goto done; |
1018 | } | 1014 | } |
1019 | cmdbuf.vb_addr = kvb_addr; | 1015 | cmdbuf->vb_addr = kvb_addr; |
1020 | } | 1016 | } |
1021 | if (cmdbuf.nbox) { | 1017 | if (cmdbuf->nbox) { |
1022 | kbox_addr = drm_alloc(cmdbuf.nbox * sizeof(struct drm_clip_rect), | 1018 | kbox_addr = drm_alloc(cmdbuf->nbox * sizeof(struct drm_clip_rect), |
1023 | DRM_MEM_DRIVER); | 1019 | DRM_MEM_DRIVER); |
1024 | if (kbox_addr == NULL) { | 1020 | if (kbox_addr == NULL) { |
1025 | ret = -ENOMEM; | 1021 | ret = -ENOMEM; |
1026 | goto done; | 1022 | goto done; |
1027 | } | 1023 | } |
1028 | 1024 | ||
1029 | if (DRM_COPY_FROM_USER(kbox_addr, cmdbuf.box_addr, | 1025 | if (DRM_COPY_FROM_USER(kbox_addr, cmdbuf->box_addr, |
1030 | cmdbuf.nbox * sizeof(struct drm_clip_rect))) { | 1026 | cmdbuf->nbox * sizeof(struct drm_clip_rect))) { |
1031 | ret = -EFAULT; | 1027 | ret = -EFAULT; |
1032 | goto done; | 1028 | goto done; |
1033 | } | 1029 | } |
1034 | cmdbuf.box_addr = kbox_addr; | 1030 | cmdbuf->box_addr = kbox_addr; |
1035 | } | 1031 | } |
1036 | 1032 | ||
1037 | /* Make sure writes to DMA buffers are finished before sending | 1033 | /* Make sure writes to DMA buffers are finished before sending |
@@ -1044,10 +1040,10 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | |||
1044 | 1040 | ||
1045 | i = 0; | 1041 | i = 0; |
1046 | first_draw_cmd = NULL; | 1042 | first_draw_cmd = NULL; |
1047 | while (i < cmdbuf.size) { | 1043 | while (i < cmdbuf->size) { |
1048 | drm_savage_cmd_header_t cmd_header; | 1044 | drm_savage_cmd_header_t cmd_header; |
1049 | cmd_header = *(drm_savage_cmd_header_t *)cmdbuf.cmd_addr; | 1045 | cmd_header = *(drm_savage_cmd_header_t *)cmdbuf->cmd_addr; |
1050 | cmdbuf.cmd_addr++; | 1046 | cmdbuf->cmd_addr++; |
1051 | i++; | 1047 | i++; |
1052 | 1048 | ||
1053 | /* Group drawing commands with same state to minimize | 1049 | /* Group drawing commands with same state to minimize |
@@ -1057,7 +1053,7 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | |||
1057 | case SAVAGE_CMD_DMA_IDX: | 1053 | case SAVAGE_CMD_DMA_IDX: |
1058 | case SAVAGE_CMD_VB_IDX: | 1054 | case SAVAGE_CMD_VB_IDX: |
1059 | j = (cmd_header.idx.count + 3) / 4; | 1055 | j = (cmd_header.idx.count + 3) / 4; |
1060 | if (i + j > cmdbuf.size) { | 1056 | if (i + j > cmdbuf->size) { |
1061 | DRM_ERROR("indexed drawing command extends " | 1057 | DRM_ERROR("indexed drawing command extends " |
1062 | "beyond end of command buffer\n"); | 1058 | "beyond end of command buffer\n"); |
1063 | DMA_FLUSH(); | 1059 | DMA_FLUSH(); |
@@ -1067,18 +1063,18 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | |||
1067 | case SAVAGE_CMD_DMA_PRIM: | 1063 | case SAVAGE_CMD_DMA_PRIM: |
1068 | case SAVAGE_CMD_VB_PRIM: | 1064 | case SAVAGE_CMD_VB_PRIM: |
1069 | if (!first_draw_cmd) | 1065 | if (!first_draw_cmd) |
1070 | first_draw_cmd = cmdbuf.cmd_addr - 1; | 1066 | first_draw_cmd = cmdbuf->cmd_addr - 1; |
1071 | cmdbuf.cmd_addr += j; | 1067 | cmdbuf->cmd_addr += j; |
1072 | i += j; | 1068 | i += j; |
1073 | break; | 1069 | break; |
1074 | default: | 1070 | default: |
1075 | if (first_draw_cmd) { | 1071 | if (first_draw_cmd) { |
1076 | ret = savage_dispatch_draw( | 1072 | ret = savage_dispatch_draw( |
1077 | dev_priv, first_draw_cmd, | 1073 | dev_priv, first_draw_cmd, |
1078 | cmdbuf.cmd_addr - 1, | 1074 | cmdbuf->cmd_addr - 1, |
1079 | dmabuf, cmdbuf.vb_addr, cmdbuf.vb_size, | 1075 | dmabuf, cmdbuf->vb_addr, cmdbuf->vb_size, |
1080 | cmdbuf.vb_stride, | 1076 | cmdbuf->vb_stride, |
1081 | cmdbuf.nbox, cmdbuf.box_addr); | 1077 | cmdbuf->nbox, cmdbuf->box_addr); |
1082 | if (ret != 0) | 1078 | if (ret != 0) |
1083 | return ret; | 1079 | return ret; |
1084 | first_draw_cmd = NULL; | 1080 | first_draw_cmd = NULL; |
@@ -1090,7 +1086,7 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | |||
1090 | switch (cmd_header.cmd.cmd) { | 1086 | switch (cmd_header.cmd.cmd) { |
1091 | case SAVAGE_CMD_STATE: | 1087 | case SAVAGE_CMD_STATE: |
1092 | j = (cmd_header.state.count + 1) / 2; | 1088 | j = (cmd_header.state.count + 1) / 2; |
1093 | if (i + j > cmdbuf.size) { | 1089 | if (i + j > cmdbuf->size) { |
1094 | DRM_ERROR("command SAVAGE_CMD_STATE extends " | 1090 | DRM_ERROR("command SAVAGE_CMD_STATE extends " |
1095 | "beyond end of command buffer\n"); | 1091 | "beyond end of command buffer\n"); |
1096 | DMA_FLUSH(); | 1092 | DMA_FLUSH(); |
@@ -1098,12 +1094,12 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | |||
1098 | goto done; | 1094 | goto done; |
1099 | } | 1095 | } |
1100 | ret = savage_dispatch_state(dev_priv, &cmd_header, | 1096 | ret = savage_dispatch_state(dev_priv, &cmd_header, |
1101 | (const uint32_t *)cmdbuf.cmd_addr); | 1097 | (const uint32_t *)cmdbuf->cmd_addr); |
1102 | cmdbuf.cmd_addr += j; | 1098 | cmdbuf->cmd_addr += j; |
1103 | i += j; | 1099 | i += j; |
1104 | break; | 1100 | break; |
1105 | case SAVAGE_CMD_CLEAR: | 1101 | case SAVAGE_CMD_CLEAR: |
1106 | if (i + 1 > cmdbuf.size) { | 1102 | if (i + 1 > cmdbuf->size) { |
1107 | DRM_ERROR("command SAVAGE_CMD_CLEAR extends " | 1103 | DRM_ERROR("command SAVAGE_CMD_CLEAR extends " |
1108 | "beyond end of command buffer\n"); | 1104 | "beyond end of command buffer\n"); |
1109 | DMA_FLUSH(); | 1105 | DMA_FLUSH(); |
@@ -1111,17 +1107,19 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | |||
1111 | goto done; | 1107 | goto done; |
1112 | } | 1108 | } |
1113 | ret = savage_dispatch_clear(dev_priv, &cmd_header, | 1109 | ret = savage_dispatch_clear(dev_priv, &cmd_header, |
1114 | cmdbuf.cmd_addr, | 1110 | cmdbuf->cmd_addr, |
1115 | cmdbuf.nbox, cmdbuf.box_addr); | 1111 | cmdbuf->nbox, |
1116 | cmdbuf.cmd_addr++; | 1112 | cmdbuf->box_addr); |
1113 | cmdbuf->cmd_addr++; | ||
1117 | i++; | 1114 | i++; |
1118 | break; | 1115 | break; |
1119 | case SAVAGE_CMD_SWAP: | 1116 | case SAVAGE_CMD_SWAP: |
1120 | ret = savage_dispatch_swap(dev_priv, cmdbuf.nbox, | 1117 | ret = savage_dispatch_swap(dev_priv, cmdbuf->nbox, |
1121 | cmdbuf.box_addr); | 1118 | cmdbuf->box_addr); |
1122 | break; | 1119 | break; |
1123 | default: | 1120 | default: |
1124 | DRM_ERROR("invalid command 0x%x\n", cmd_header.cmd.cmd); | 1121 | DRM_ERROR("invalid command 0x%x\n", |
1122 | cmd_header.cmd.cmd); | ||
1125 | DMA_FLUSH(); | 1123 | DMA_FLUSH(); |
1126 | ret = -EINVAL; | 1124 | ret = -EINVAL; |
1127 | goto done; | 1125 | goto done; |
@@ -1135,9 +1133,9 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | |||
1135 | 1133 | ||
1136 | if (first_draw_cmd) { | 1134 | if (first_draw_cmd) { |
1137 | ret = savage_dispatch_draw ( | 1135 | ret = savage_dispatch_draw ( |
1138 | dev_priv, first_draw_cmd, cmdbuf.cmd_addr, dmabuf, | 1136 | dev_priv, first_draw_cmd, cmdbuf->cmd_addr, dmabuf, |
1139 | cmdbuf.vb_addr, cmdbuf.vb_size, cmdbuf.vb_stride, | 1137 | cmdbuf->vb_addr, cmdbuf->vb_size, cmdbuf->vb_stride, |
1140 | cmdbuf.nbox, cmdbuf.box_addr); | 1138 | cmdbuf->nbox, cmdbuf->box_addr); |
1141 | if (ret != 0) { | 1139 | if (ret != 0) { |
1142 | DMA_FLUSH(); | 1140 | DMA_FLUSH(); |
1143 | goto done; | 1141 | goto done; |
@@ -1146,7 +1144,7 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | |||
1146 | 1144 | ||
1147 | DMA_FLUSH(); | 1145 | DMA_FLUSH(); |
1148 | 1146 | ||
1149 | if (dmabuf && cmdbuf.discard) { | 1147 | if (dmabuf && cmdbuf->discard) { |
1150 | drm_savage_buf_priv_t *buf_priv = dmabuf->dev_private; | 1148 | drm_savage_buf_priv_t *buf_priv = dmabuf->dev_private; |
1151 | uint16_t event; | 1149 | uint16_t event; |
1152 | event = savage_bci_emit_event(dev_priv, SAVAGE_WAIT_3D); | 1150 | event = savage_bci_emit_event(dev_priv, SAVAGE_WAIT_3D); |
@@ -1156,9 +1154,9 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | |||
1156 | 1154 | ||
1157 | done: | 1155 | done: |
1158 | /* If we didn't need to allocate them, these'll be NULL */ | 1156 | /* If we didn't need to allocate them, these'll be NULL */ |
1159 | drm_free(kcmd_addr, cmdbuf.size * 8, DRM_MEM_DRIVER); | 1157 | drm_free(kcmd_addr, cmdbuf->size * 8, DRM_MEM_DRIVER); |
1160 | drm_free(kvb_addr, cmdbuf.vb_size, DRM_MEM_DRIVER); | 1158 | drm_free(kvb_addr, cmdbuf->vb_size, DRM_MEM_DRIVER); |
1161 | drm_free(kbox_addr, cmdbuf.nbox * sizeof(struct drm_clip_rect), | 1159 | drm_free(kbox_addr, cmdbuf->nbox * sizeof(struct drm_clip_rect), |
1162 | DRM_MEM_DRIVER); | 1160 | DRM_MEM_DRIVER); |
1163 | 1161 | ||
1164 | return ret; | 1162 | return ret; |
diff --git a/drivers/char/drm/sis_drv.h b/drivers/char/drm/sis_drv.h index b19ff015f260..ef940bad63f7 100644 --- a/drivers/char/drm/sis_drv.h +++ b/drivers/char/drm/sis_drv.h | |||
@@ -67,7 +67,7 @@ extern void sis_reclaim_buffers_locked(struct drm_device *dev, | |||
67 | struct drm_file *file_priv); | 67 | struct drm_file *file_priv); |
68 | extern void sis_lastclose(struct drm_device *dev); | 68 | extern void sis_lastclose(struct drm_device *dev); |
69 | 69 | ||
70 | extern drm_ioctl_desc_t sis_ioctls[]; | 70 | extern struct drm_ioctl_desc sis_ioctls[]; |
71 | extern int sis_max_ioctl; | 71 | extern int sis_max_ioctl; |
72 | 72 | ||
73 | #endif | 73 | #endif |
diff --git a/drivers/char/drm/sis_mm.c b/drivers/char/drm/sis_mm.c index cefbc3086d84..8c66838ff515 100644 --- a/drivers/char/drm/sis_mm.c +++ b/drivers/char/drm/sis_mm.c | |||
@@ -82,15 +82,12 @@ static unsigned long sis_sman_mm_offset(void *private, void *ref) | |||
82 | 82 | ||
83 | #endif /* CONFIG_FB_SIS */ | 83 | #endif /* CONFIG_FB_SIS */ |
84 | 84 | ||
85 | static int sis_fb_init(DRM_IOCTL_ARGS) | 85 | static int sis_fb_init(struct drm_device *dev, void *data, struct drm_file *file_priv) |
86 | { | 86 | { |
87 | DRM_DEVICE; | ||
88 | drm_sis_private_t *dev_priv = dev->dev_private; | 87 | drm_sis_private_t *dev_priv = dev->dev_private; |
89 | drm_sis_fb_t fb; | 88 | drm_sis_fb_t *fb = data; |
90 | int ret; | 89 | int ret; |
91 | 90 | ||
92 | DRM_COPY_FROM_USER_IOCTL(fb, (drm_sis_fb_t __user *) data, sizeof(fb)); | ||
93 | |||
94 | mutex_lock(&dev->struct_mutex); | 91 | mutex_lock(&dev->struct_mutex); |
95 | #if defined(CONFIG_FB_SIS) | 92 | #if defined(CONFIG_FB_SIS) |
96 | { | 93 | { |
@@ -105,7 +102,7 @@ static int sis_fb_init(DRM_IOCTL_ARGS) | |||
105 | } | 102 | } |
106 | #else | 103 | #else |
107 | ret = drm_sman_set_range(&dev_priv->sman, VIDEO_TYPE, 0, | 104 | ret = drm_sman_set_range(&dev_priv->sman, VIDEO_TYPE, 0, |
108 | fb.size >> SIS_MM_ALIGN_SHIFT); | 105 | fb->size >> SIS_MM_ALIGN_SHIFT); |
109 | #endif | 106 | #endif |
110 | 107 | ||
111 | if (ret) { | 108 | if (ret) { |
@@ -115,25 +112,22 @@ static int sis_fb_init(DRM_IOCTL_ARGS) | |||
115 | } | 112 | } |
116 | 113 | ||
117 | dev_priv->vram_initialized = 1; | 114 | dev_priv->vram_initialized = 1; |
118 | dev_priv->vram_offset = fb.offset; | 115 | dev_priv->vram_offset = fb->offset; |
119 | 116 | ||
120 | mutex_unlock(&dev->struct_mutex); | 117 | mutex_unlock(&dev->struct_mutex); |
121 | DRM_DEBUG("offset = %u, size = %u", fb.offset, fb.size); | 118 | DRM_DEBUG("offset = %u, size = %u", fb->offset, fb->size); |
122 | 119 | ||
123 | return 0; | 120 | return 0; |
124 | } | 121 | } |
125 | 122 | ||
126 | static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file_priv, | 123 | static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file_priv, |
127 | unsigned long data, int pool) | 124 | void *data, int pool) |
128 | { | 125 | { |
129 | drm_sis_private_t *dev_priv = dev->dev_private; | 126 | drm_sis_private_t *dev_priv = dev->dev_private; |
130 | drm_sis_mem_t __user *argp = (drm_sis_mem_t __user *) data; | 127 | drm_sis_mem_t *mem = data; |
131 | drm_sis_mem_t mem; | ||
132 | int retval = 0; | 128 | int retval = 0; |
133 | struct drm_memblock_item *item; | 129 | struct drm_memblock_item *item; |
134 | 130 | ||
135 | DRM_COPY_FROM_USER_IOCTL(mem, argp, sizeof(mem)); | ||
136 | |||
137 | mutex_lock(&dev->struct_mutex); | 131 | mutex_lock(&dev->struct_mutex); |
138 | 132 | ||
139 | if (0 == ((pool == 0) ? dev_priv->vram_initialized : | 133 | if (0 == ((pool == 0) ? dev_priv->vram_initialized : |
@@ -143,70 +137,62 @@ static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file_priv, | |||
143 | return -EINVAL; | 137 | return -EINVAL; |
144 | } | 138 | } |
145 | 139 | ||
146 | mem.size = (mem.size + SIS_MM_ALIGN_MASK) >> SIS_MM_ALIGN_SHIFT; | 140 | mem->size = (mem->size + SIS_MM_ALIGN_MASK) >> SIS_MM_ALIGN_SHIFT; |
147 | item = drm_sman_alloc(&dev_priv->sman, pool, mem.size, 0, | 141 | item = drm_sman_alloc(&dev_priv->sman, pool, mem->size, 0, |
148 | (unsigned long)file_priv); | 142 | (unsigned long)file_priv); |
149 | 143 | ||
150 | mutex_unlock(&dev->struct_mutex); | 144 | mutex_unlock(&dev->struct_mutex); |
151 | if (item) { | 145 | if (item) { |
152 | mem.offset = ((pool == 0) ? | 146 | mem->offset = ((pool == 0) ? |
153 | dev_priv->vram_offset : dev_priv->agp_offset) + | 147 | dev_priv->vram_offset : dev_priv->agp_offset) + |
154 | (item->mm-> | 148 | (item->mm-> |
155 | offset(item->mm, item->mm_info) << SIS_MM_ALIGN_SHIFT); | 149 | offset(item->mm, item->mm_info) << SIS_MM_ALIGN_SHIFT); |
156 | mem.free = item->user_hash.key; | 150 | mem->free = item->user_hash.key; |
157 | mem.size = mem.size << SIS_MM_ALIGN_SHIFT; | 151 | mem->size = mem->size << SIS_MM_ALIGN_SHIFT; |
158 | } else { | 152 | } else { |
159 | mem.offset = 0; | 153 | mem->offset = 0; |
160 | mem.size = 0; | 154 | mem->size = 0; |
161 | mem.free = 0; | 155 | mem->free = 0; |
162 | retval = -ENOMEM; | 156 | retval = -ENOMEM; |
163 | } | 157 | } |
164 | 158 | ||
165 | DRM_COPY_TO_USER_IOCTL(argp, mem, sizeof(mem)); | 159 | DRM_DEBUG("alloc %d, size = %d, offset = %d\n", pool, mem->size, |
166 | 160 | mem->offset); | |
167 | DRM_DEBUG("alloc %d, size = %d, offset = %d\n", pool, mem.size, | ||
168 | mem.offset); | ||
169 | 161 | ||
170 | return retval; | 162 | return retval; |
171 | } | 163 | } |
172 | 164 | ||
173 | static int sis_drm_free(DRM_IOCTL_ARGS) | 165 | static int sis_drm_free(struct drm_device *dev, void *data, struct drm_file *file_priv) |
174 | { | 166 | { |
175 | DRM_DEVICE; | ||
176 | drm_sis_private_t *dev_priv = dev->dev_private; | 167 | drm_sis_private_t *dev_priv = dev->dev_private; |
177 | drm_sis_mem_t mem; | 168 | drm_sis_mem_t *mem = data; |
178 | int ret; | 169 | int ret; |
179 | 170 | ||
180 | DRM_COPY_FROM_USER_IOCTL(mem, (drm_sis_mem_t __user *) data, | ||
181 | sizeof(mem)); | ||
182 | |||
183 | mutex_lock(&dev->struct_mutex); | 171 | mutex_lock(&dev->struct_mutex); |
184 | ret = drm_sman_free_key(&dev_priv->sman, mem.free); | 172 | ret = drm_sman_free_key(&dev_priv->sman, mem->free); |
185 | mutex_unlock(&dev->struct_mutex); | 173 | mutex_unlock(&dev->struct_mutex); |
186 | DRM_DEBUG("free = 0x%lx\n", mem.free); | 174 | DRM_DEBUG("free = 0x%lx\n", mem->free); |
187 | 175 | ||
188 | return ret; | 176 | return ret; |
189 | } | 177 | } |
190 | 178 | ||
191 | static int sis_fb_alloc(DRM_IOCTL_ARGS) | 179 | static int sis_fb_alloc(struct drm_device *dev, void *data, |
180 | struct drm_file *file_priv) | ||
192 | { | 181 | { |
193 | DRM_DEVICE; | ||
194 | return sis_drm_alloc(dev, file_priv, data, VIDEO_TYPE); | 182 | return sis_drm_alloc(dev, file_priv, data, VIDEO_TYPE); |
195 | } | 183 | } |
196 | 184 | ||
197 | static int sis_ioctl_agp_init(DRM_IOCTL_ARGS) | 185 | static int sis_ioctl_agp_init(struct drm_device *dev, void *data, |
186 | struct drm_file *file_priv) | ||
198 | { | 187 | { |
199 | DRM_DEVICE; | ||
200 | drm_sis_private_t *dev_priv = dev->dev_private; | 188 | drm_sis_private_t *dev_priv = dev->dev_private; |
201 | drm_sis_agp_t agp; | 189 | drm_sis_agp_t *agp = data; |
202 | int ret; | 190 | int ret; |
203 | dev_priv = dev->dev_private; | 191 | dev_priv = dev->dev_private; |
204 | 192 | ||
205 | DRM_COPY_FROM_USER_IOCTL(agp, (drm_sis_agp_t __user *) data, | ||
206 | sizeof(agp)); | ||
207 | mutex_lock(&dev->struct_mutex); | 193 | mutex_lock(&dev->struct_mutex); |
208 | ret = drm_sman_set_range(&dev_priv->sman, AGP_TYPE, 0, | 194 | ret = drm_sman_set_range(&dev_priv->sman, AGP_TYPE, 0, |
209 | agp.size >> SIS_MM_ALIGN_SHIFT); | 195 | agp->size >> SIS_MM_ALIGN_SHIFT); |
210 | 196 | ||
211 | if (ret) { | 197 | if (ret) { |
212 | DRM_ERROR("AGP memory manager initialisation error\n"); | 198 | DRM_ERROR("AGP memory manager initialisation error\n"); |
@@ -215,16 +201,16 @@ static int sis_ioctl_agp_init(DRM_IOCTL_ARGS) | |||
215 | } | 201 | } |
216 | 202 | ||
217 | dev_priv->agp_initialized = 1; | 203 | dev_priv->agp_initialized = 1; |
218 | dev_priv->agp_offset = agp.offset; | 204 | dev_priv->agp_offset = agp->offset; |
219 | mutex_unlock(&dev->struct_mutex); | 205 | mutex_unlock(&dev->struct_mutex); |
220 | 206 | ||
221 | DRM_DEBUG("offset = %u, size = %u", agp.offset, agp.size); | 207 | DRM_DEBUG("offset = %u, size = %u", agp->offset, agp->size); |
222 | return 0; | 208 | return 0; |
223 | } | 209 | } |
224 | 210 | ||
225 | static int sis_ioctl_agp_alloc(DRM_IOCTL_ARGS) | 211 | static int sis_ioctl_agp_alloc(struct drm_device *dev, void *data, |
212 | struct drm_file *file_priv) | ||
226 | { | 213 | { |
227 | DRM_DEVICE; | ||
228 | 214 | ||
229 | return sis_drm_alloc(dev, file_priv, data, AGP_TYPE); | 215 | return sis_drm_alloc(dev, file_priv, data, AGP_TYPE); |
230 | } | 216 | } |
@@ -334,15 +320,13 @@ void sis_reclaim_buffers_locked(struct drm_device * dev, | |||
334 | return; | 320 | return; |
335 | } | 321 | } |
336 | 322 | ||
337 | drm_ioctl_desc_t sis_ioctls[] = { | 323 | struct drm_ioctl_desc sis_ioctls[] = { |
338 | [DRM_IOCTL_NR(DRM_SIS_FB_ALLOC)] = {sis_fb_alloc, DRM_AUTH}, | 324 | DRM_IOCTL_DEF(DRM_SIS_FB_ALLOC, sis_fb_alloc, DRM_AUTH), |
339 | [DRM_IOCTL_NR(DRM_SIS_FB_FREE)] = {sis_drm_free, DRM_AUTH}, | 325 | DRM_IOCTL_DEF(DRM_SIS_FB_FREE, sis_drm_free, DRM_AUTH), |
340 | [DRM_IOCTL_NR(DRM_SIS_AGP_INIT)] = | 326 | DRM_IOCTL_DEF(DRM_SIS_AGP_INIT, sis_ioctl_agp_init, DRM_AUTH | DRM_MASTER | DRM_ROOT_ONLY), |
341 | {sis_ioctl_agp_init, DRM_AUTH | DRM_MASTER | DRM_ROOT_ONLY}, | 327 | DRM_IOCTL_DEF(DRM_SIS_AGP_ALLOC, sis_ioctl_agp_alloc, DRM_AUTH), |
342 | [DRM_IOCTL_NR(DRM_SIS_AGP_ALLOC)] = {sis_ioctl_agp_alloc, DRM_AUTH}, | 328 | DRM_IOCTL_DEF(DRM_SIS_AGP_FREE, sis_drm_free, DRM_AUTH), |
343 | [DRM_IOCTL_NR(DRM_SIS_AGP_FREE)] = {sis_drm_free, DRM_AUTH}, | 329 | DRM_IOCTL_DEF(DRM_SIS_FB_INIT, sis_fb_init, DRM_AUTH | DRM_MASTER | DRM_ROOT_ONLY), |
344 | [DRM_IOCTL_NR(DRM_SIS_FB_INIT)] = | ||
345 | {sis_fb_init, DRM_AUTH | DRM_MASTER | DRM_ROOT_ONLY} | ||
346 | }; | 330 | }; |
347 | 331 | ||
348 | int sis_max_ioctl = DRM_ARRAY_SIZE(sis_ioctls); | 332 | int sis_max_ioctl = DRM_ARRAY_SIZE(sis_ioctls); |
diff --git a/drivers/char/drm/via_dma.c b/drivers/char/drm/via_dma.c index 6d3e4eecf8f8..75d6b748c2c0 100644 --- a/drivers/char/drm/via_dma.c +++ b/drivers/char/drm/via_dma.c | |||
@@ -227,22 +227,18 @@ static int via_initialize(struct drm_device * dev, | |||
227 | return 0; | 227 | return 0; |
228 | } | 228 | } |
229 | 229 | ||
230 | static int via_dma_init(DRM_IOCTL_ARGS) | 230 | static int via_dma_init(struct drm_device *dev, void *data, struct drm_file *file_priv) |
231 | { | 231 | { |
232 | DRM_DEVICE; | ||
233 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; | 232 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; |
234 | drm_via_dma_init_t init; | 233 | drm_via_dma_init_t *init = data; |
235 | int retcode = 0; | 234 | int retcode = 0; |
236 | 235 | ||
237 | DRM_COPY_FROM_USER_IOCTL(init, (drm_via_dma_init_t __user *) data, | 236 | switch (init->func) { |
238 | sizeof(init)); | ||
239 | |||
240 | switch (init.func) { | ||
241 | case VIA_INIT_DMA: | 237 | case VIA_INIT_DMA: |
242 | if (!DRM_SUSER(DRM_CURPROC)) | 238 | if (!DRM_SUSER(DRM_CURPROC)) |
243 | retcode = -EPERM; | 239 | retcode = -EPERM; |
244 | else | 240 | else |
245 | retcode = via_initialize(dev, dev_priv, &init); | 241 | retcode = via_initialize(dev, dev_priv, init); |
246 | break; | 242 | break; |
247 | case VIA_CLEANUP_DMA: | 243 | case VIA_CLEANUP_DMA: |
248 | if (!DRM_SUSER(DRM_CURPROC)) | 244 | if (!DRM_SUSER(DRM_CURPROC)) |
@@ -326,29 +322,25 @@ int via_driver_dma_quiescent(struct drm_device * dev) | |||
326 | return 0; | 322 | return 0; |
327 | } | 323 | } |
328 | 324 | ||
329 | static int via_flush_ioctl(DRM_IOCTL_ARGS) | 325 | static int via_flush_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) |
330 | { | 326 | { |
331 | DRM_DEVICE; | ||
332 | 327 | ||
333 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 328 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
334 | 329 | ||
335 | return via_driver_dma_quiescent(dev); | 330 | return via_driver_dma_quiescent(dev); |
336 | } | 331 | } |
337 | 332 | ||
338 | static int via_cmdbuffer(DRM_IOCTL_ARGS) | 333 | static int via_cmdbuffer(struct drm_device *dev, void *data, struct drm_file *file_priv) |
339 | { | 334 | { |
340 | DRM_DEVICE; | 335 | drm_via_cmdbuffer_t *cmdbuf = data; |
341 | drm_via_cmdbuffer_t cmdbuf; | ||
342 | int ret; | 336 | int ret; |
343 | 337 | ||
344 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 338 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
345 | 339 | ||
346 | DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_via_cmdbuffer_t __user *) data, | 340 | DRM_DEBUG("via cmdbuffer, buf %p size %lu\n", cmdbuf->buf, |
347 | sizeof(cmdbuf)); | 341 | cmdbuf->size); |
348 | |||
349 | DRM_DEBUG("via cmdbuffer, buf %p size %lu\n", cmdbuf.buf, cmdbuf.size); | ||
350 | 342 | ||
351 | ret = via_dispatch_cmdbuffer(dev, &cmdbuf); | 343 | ret = via_dispatch_cmdbuffer(dev, cmdbuf); |
352 | if (ret) { | 344 | if (ret) { |
353 | return ret; | 345 | return ret; |
354 | } | 346 | } |
@@ -380,21 +372,17 @@ static int via_dispatch_pci_cmdbuffer(struct drm_device * dev, | |||
380 | return ret; | 372 | return ret; |
381 | } | 373 | } |
382 | 374 | ||
383 | static int via_pci_cmdbuffer(DRM_IOCTL_ARGS) | 375 | static int via_pci_cmdbuffer(struct drm_device *dev, void *data, struct drm_file *file_priv) |
384 | { | 376 | { |
385 | DRM_DEVICE; | 377 | drm_via_cmdbuffer_t *cmdbuf = data; |
386 | drm_via_cmdbuffer_t cmdbuf; | ||
387 | int ret; | 378 | int ret; |
388 | 379 | ||
389 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 380 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
390 | 381 | ||
391 | DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_via_cmdbuffer_t __user *) data, | 382 | DRM_DEBUG("via_pci_cmdbuffer, buf %p size %lu\n", cmdbuf->buf, |
392 | sizeof(cmdbuf)); | 383 | cmdbuf->size); |
393 | 384 | ||
394 | DRM_DEBUG("via_pci_cmdbuffer, buf %p size %lu\n", cmdbuf.buf, | 385 | ret = via_dispatch_pci_cmdbuffer(dev, cmdbuf); |
395 | cmdbuf.size); | ||
396 | |||
397 | ret = via_dispatch_pci_cmdbuffer(dev, &cmdbuf); | ||
398 | if (ret) { | 386 | if (ret) { |
399 | return ret; | 387 | return ret; |
400 | } | 388 | } |
@@ -653,10 +641,9 @@ static void via_cmdbuf_reset(drm_via_private_t * dev_priv) | |||
653 | * User interface to the space and lag functions. | 641 | * User interface to the space and lag functions. |
654 | */ | 642 | */ |
655 | 643 | ||
656 | static int via_cmdbuf_size(DRM_IOCTL_ARGS) | 644 | static int via_cmdbuf_size(struct drm_device *dev, void *data, struct drm_file *file_priv) |
657 | { | 645 | { |
658 | DRM_DEVICE; | 646 | drm_via_cmdbuf_size_t *d_siz = data; |
659 | drm_via_cmdbuf_size_t d_siz; | ||
660 | int ret = 0; | 647 | int ret = 0; |
661 | uint32_t tmp_size, count; | 648 | uint32_t tmp_size, count; |
662 | drm_via_private_t *dev_priv; | 649 | drm_via_private_t *dev_priv; |
@@ -672,16 +659,13 @@ static int via_cmdbuf_size(DRM_IOCTL_ARGS) | |||
672 | return -EFAULT; | 659 | return -EFAULT; |
673 | } | 660 | } |
674 | 661 | ||
675 | DRM_COPY_FROM_USER_IOCTL(d_siz, (drm_via_cmdbuf_size_t __user *) data, | ||
676 | sizeof(d_siz)); | ||
677 | |||
678 | count = 1000000; | 662 | count = 1000000; |
679 | tmp_size = d_siz.size; | 663 | tmp_size = d_siz->size; |
680 | switch (d_siz.func) { | 664 | switch (d_siz->func) { |
681 | case VIA_CMDBUF_SPACE: | 665 | case VIA_CMDBUF_SPACE: |
682 | while (((tmp_size = via_cmdbuf_space(dev_priv)) < d_siz.size) | 666 | while (((tmp_size = via_cmdbuf_space(dev_priv)) < d_siz->size) |
683 | && count--) { | 667 | && count--) { |
684 | if (!d_siz.wait) { | 668 | if (!d_siz->wait) { |
685 | break; | 669 | break; |
686 | } | 670 | } |
687 | } | 671 | } |
@@ -691,9 +675,9 @@ static int via_cmdbuf_size(DRM_IOCTL_ARGS) | |||
691 | } | 675 | } |
692 | break; | 676 | break; |
693 | case VIA_CMDBUF_LAG: | 677 | case VIA_CMDBUF_LAG: |
694 | while (((tmp_size = via_cmdbuf_lag(dev_priv)) > d_siz.size) | 678 | while (((tmp_size = via_cmdbuf_lag(dev_priv)) > d_siz->size) |
695 | && count--) { | 679 | && count--) { |
696 | if (!d_siz.wait) { | 680 | if (!d_siz->wait) { |
697 | break; | 681 | break; |
698 | } | 682 | } |
699 | } | 683 | } |
@@ -705,28 +689,26 @@ static int via_cmdbuf_size(DRM_IOCTL_ARGS) | |||
705 | default: | 689 | default: |
706 | ret = -EFAULT; | 690 | ret = -EFAULT; |
707 | } | 691 | } |
708 | d_siz.size = tmp_size; | 692 | d_siz->size = tmp_size; |
709 | 693 | ||
710 | DRM_COPY_TO_USER_IOCTL((drm_via_cmdbuf_size_t __user *) data, d_siz, | ||
711 | sizeof(d_siz)); | ||
712 | return ret; | 694 | return ret; |
713 | } | 695 | } |
714 | 696 | ||
715 | drm_ioctl_desc_t via_ioctls[] = { | 697 | struct drm_ioctl_desc via_ioctls[] = { |
716 | [DRM_IOCTL_NR(DRM_VIA_ALLOCMEM)] = {via_mem_alloc, DRM_AUTH}, | 698 | DRM_IOCTL_DEF(DRM_VIA_ALLOCMEM, via_mem_alloc, DRM_AUTH), |
717 | [DRM_IOCTL_NR(DRM_VIA_FREEMEM)] = {via_mem_free, DRM_AUTH}, | 699 | DRM_IOCTL_DEF(DRM_VIA_FREEMEM, via_mem_free, DRM_AUTH), |
718 | [DRM_IOCTL_NR(DRM_VIA_AGP_INIT)] = {via_agp_init, DRM_AUTH|DRM_MASTER}, | 700 | DRM_IOCTL_DEF(DRM_VIA_AGP_INIT, via_agp_init, DRM_AUTH|DRM_MASTER), |
719 | [DRM_IOCTL_NR(DRM_VIA_FB_INIT)] = {via_fb_init, DRM_AUTH|DRM_MASTER}, | 701 | DRM_IOCTL_DEF(DRM_VIA_FB_INIT, via_fb_init, DRM_AUTH|DRM_MASTER), |
720 | [DRM_IOCTL_NR(DRM_VIA_MAP_INIT)] = {via_map_init, DRM_AUTH|DRM_MASTER}, | 702 | DRM_IOCTL_DEF(DRM_VIA_MAP_INIT, via_map_init, DRM_AUTH|DRM_MASTER), |
721 | [DRM_IOCTL_NR(DRM_VIA_DEC_FUTEX)] = {via_decoder_futex, DRM_AUTH}, | 703 | DRM_IOCTL_DEF(DRM_VIA_DEC_FUTEX, via_decoder_futex, DRM_AUTH), |
722 | [DRM_IOCTL_NR(DRM_VIA_DMA_INIT)] = {via_dma_init, DRM_AUTH}, | 704 | DRM_IOCTL_DEF(DRM_VIA_DMA_INIT, via_dma_init, DRM_AUTH), |
723 | [DRM_IOCTL_NR(DRM_VIA_CMDBUFFER)] = {via_cmdbuffer, DRM_AUTH}, | 705 | DRM_IOCTL_DEF(DRM_VIA_CMDBUFFER, via_cmdbuffer, DRM_AUTH), |
724 | [DRM_IOCTL_NR(DRM_VIA_FLUSH)] = {via_flush_ioctl, DRM_AUTH}, | 706 | DRM_IOCTL_DEF(DRM_VIA_FLUSH, via_flush_ioctl, DRM_AUTH), |
725 | [DRM_IOCTL_NR(DRM_VIA_PCICMD)] = {via_pci_cmdbuffer, DRM_AUTH}, | 707 | DRM_IOCTL_DEF(DRM_VIA_PCICMD, via_pci_cmdbuffer, DRM_AUTH), |
726 | [DRM_IOCTL_NR(DRM_VIA_CMDBUF_SIZE)] = {via_cmdbuf_size, DRM_AUTH}, | 708 | DRM_IOCTL_DEF(DRM_VIA_CMDBUF_SIZE, via_cmdbuf_size, DRM_AUTH), |
727 | [DRM_IOCTL_NR(DRM_VIA_WAIT_IRQ)] = {via_wait_irq, DRM_AUTH}, | 709 | DRM_IOCTL_DEF(DRM_VIA_WAIT_IRQ, via_wait_irq, DRM_AUTH), |
728 | [DRM_IOCTL_NR(DRM_VIA_DMA_BLIT)] = {via_dma_blit, DRM_AUTH}, | 710 | DRM_IOCTL_DEF(DRM_VIA_DMA_BLIT, via_dma_blit, DRM_AUTH), |
729 | [DRM_IOCTL_NR(DRM_VIA_BLIT_SYNC)] = {via_dma_blit_sync, DRM_AUTH} | 711 | DRM_IOCTL_DEF(DRM_VIA_BLIT_SYNC, via_dma_blit_sync, DRM_AUTH) |
730 | }; | 712 | }; |
731 | 713 | ||
732 | int via_max_ioctl = DRM_ARRAY_SIZE(via_ioctls); | 714 | int via_max_ioctl = DRM_ARRAY_SIZE(via_ioctls); |
diff --git a/drivers/char/drm/via_dmablit.c b/drivers/char/drm/via_dmablit.c index cd204f35eced..c6fd16f3cb43 100644 --- a/drivers/char/drm/via_dmablit.c +++ b/drivers/char/drm/via_dmablit.c | |||
@@ -781,18 +781,15 @@ via_dmablit(struct drm_device *dev, drm_via_dmablit_t *xfer) | |||
781 | */ | 781 | */ |
782 | 782 | ||
783 | int | 783 | int |
784 | via_dma_blit_sync( DRM_IOCTL_ARGS ) | 784 | via_dma_blit_sync( struct drm_device *dev, void *data, struct drm_file *file_priv ) |
785 | { | 785 | { |
786 | drm_via_blitsync_t sync; | 786 | drm_via_blitsync_t *sync = data; |
787 | int err; | 787 | int err; |
788 | DRM_DEVICE; | ||
789 | 788 | ||
790 | DRM_COPY_FROM_USER_IOCTL(sync, (drm_via_blitsync_t *)data, sizeof(sync)); | 789 | if (sync->engine >= VIA_NUM_BLIT_ENGINES) |
791 | |||
792 | if (sync.engine >= VIA_NUM_BLIT_ENGINES) | ||
793 | return -EINVAL; | 790 | return -EINVAL; |
794 | 791 | ||
795 | err = via_dmablit_sync(dev, sync.sync_handle, sync.engine); | 792 | err = via_dmablit_sync(dev, sync->sync_handle, sync->engine); |
796 | 793 | ||
797 | if (-EINTR == err) | 794 | if (-EINTR == err) |
798 | err = -EAGAIN; | 795 | err = -EAGAIN; |
@@ -808,17 +805,12 @@ via_dma_blit_sync( DRM_IOCTL_ARGS ) | |||
808 | */ | 805 | */ |
809 | 806 | ||
810 | int | 807 | int |
811 | via_dma_blit( DRM_IOCTL_ARGS ) | 808 | via_dma_blit( struct drm_device *dev, void *data, struct drm_file *file_priv ) |
812 | { | 809 | { |
813 | drm_via_dmablit_t xfer; | 810 | drm_via_dmablit_t *xfer = data; |
814 | int err; | 811 | int err; |
815 | DRM_DEVICE; | ||
816 | |||
817 | DRM_COPY_FROM_USER_IOCTL(xfer, (drm_via_dmablit_t __user *)data, sizeof(xfer)); | ||
818 | |||
819 | err = via_dmablit(dev, &xfer); | ||
820 | 812 | ||
821 | DRM_COPY_TO_USER_IOCTL((void __user *)data, xfer, sizeof(xfer)); | 813 | err = via_dmablit(dev, xfer); |
822 | 814 | ||
823 | return err; | 815 | return err; |
824 | } | 816 | } |
diff --git a/drivers/char/drm/via_drv.h b/drivers/char/drm/via_drv.h index 854b393e0256..2daae81874cd 100644 --- a/drivers/char/drm/via_drv.h +++ b/drivers/char/drm/via_drv.h | |||
@@ -110,18 +110,18 @@ enum via_family { | |||
110 | #define VIA_READ8(reg) DRM_READ8(VIA_BASE, reg) | 110 | #define VIA_READ8(reg) DRM_READ8(VIA_BASE, reg) |
111 | #define VIA_WRITE8(reg,val) DRM_WRITE8(VIA_BASE, reg, val) | 111 | #define VIA_WRITE8(reg,val) DRM_WRITE8(VIA_BASE, reg, val) |
112 | 112 | ||
113 | extern drm_ioctl_desc_t via_ioctls[]; | 113 | extern struct drm_ioctl_desc via_ioctls[]; |
114 | extern int via_max_ioctl; | 114 | extern int via_max_ioctl; |
115 | 115 | ||
116 | extern int via_fb_init(DRM_IOCTL_ARGS); | 116 | extern int via_fb_init(struct drm_device *dev, void *data, struct drm_file *file_priv); |
117 | extern int via_mem_alloc(DRM_IOCTL_ARGS); | 117 | extern int via_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv); |
118 | extern int via_mem_free(DRM_IOCTL_ARGS); | 118 | extern int via_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv); |
119 | extern int via_agp_init(DRM_IOCTL_ARGS); | 119 | extern int via_agp_init(struct drm_device *dev, void *data, struct drm_file *file_priv); |
120 | extern int via_map_init(DRM_IOCTL_ARGS); | 120 | extern int via_map_init(struct drm_device *dev, void *data, struct drm_file *file_priv); |
121 | extern int via_decoder_futex(DRM_IOCTL_ARGS); | 121 | extern int via_decoder_futex(struct drm_device *dev, void *data, struct drm_file *file_priv); |
122 | extern int via_wait_irq(DRM_IOCTL_ARGS); | 122 | extern int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv); |
123 | extern int via_dma_blit_sync( DRM_IOCTL_ARGS ); | 123 | extern int via_dma_blit_sync( struct drm_device *dev, void *data, struct drm_file *file_priv ); |
124 | extern int via_dma_blit( DRM_IOCTL_ARGS ); | 124 | extern int via_dma_blit( struct drm_device *dev, void *data, struct drm_file *file_priv ); |
125 | 125 | ||
126 | extern int via_driver_load(struct drm_device *dev, unsigned long chipset); | 126 | extern int via_driver_load(struct drm_device *dev, unsigned long chipset); |
127 | extern int via_driver_unload(struct drm_device *dev); | 127 | extern int via_driver_unload(struct drm_device *dev); |
diff --git a/drivers/char/drm/via_irq.c b/drivers/char/drm/via_irq.c index a5297e70f94a..9c1d52bc92d7 100644 --- a/drivers/char/drm/via_irq.c +++ b/drivers/char/drm/via_irq.c | |||
@@ -331,11 +331,9 @@ void via_driver_irq_uninstall(struct drm_device * dev) | |||
331 | } | 331 | } |
332 | } | 332 | } |
333 | 333 | ||
334 | int via_wait_irq(DRM_IOCTL_ARGS) | 334 | int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv) |
335 | { | 335 | { |
336 | DRM_DEVICE; | 336 | drm_via_irqwait_t *irqwait = data; |
337 | drm_via_irqwait_t __user *argp = (void __user *)data; | ||
338 | drm_via_irqwait_t irqwait; | ||
339 | struct timeval now; | 337 | struct timeval now; |
340 | int ret = 0; | 338 | int ret = 0; |
341 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; | 339 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; |
@@ -345,40 +343,37 @@ int via_wait_irq(DRM_IOCTL_ARGS) | |||
345 | if (!dev->irq) | 343 | if (!dev->irq) |
346 | return -EINVAL; | 344 | return -EINVAL; |
347 | 345 | ||
348 | DRM_COPY_FROM_USER_IOCTL(irqwait, argp, sizeof(irqwait)); | 346 | if (irqwait->request.irq >= dev_priv->num_irqs) { |
349 | if (irqwait.request.irq >= dev_priv->num_irqs) { | ||
350 | DRM_ERROR("%s Trying to wait on unknown irq %d\n", __FUNCTION__, | 347 | DRM_ERROR("%s Trying to wait on unknown irq %d\n", __FUNCTION__, |
351 | irqwait.request.irq); | 348 | irqwait->request.irq); |
352 | return -EINVAL; | 349 | return -EINVAL; |
353 | } | 350 | } |
354 | 351 | ||
355 | cur_irq += irqwait.request.irq; | 352 | cur_irq += irqwait->request.irq; |
356 | 353 | ||
357 | switch (irqwait.request.type & ~VIA_IRQ_FLAGS_MASK) { | 354 | switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) { |
358 | case VIA_IRQ_RELATIVE: | 355 | case VIA_IRQ_RELATIVE: |
359 | irqwait.request.sequence += atomic_read(&cur_irq->irq_received); | 356 | irqwait->request.sequence += atomic_read(&cur_irq->irq_received); |
360 | irqwait.request.type &= ~_DRM_VBLANK_RELATIVE; | 357 | irqwait->request.type &= ~_DRM_VBLANK_RELATIVE; |
361 | case VIA_IRQ_ABSOLUTE: | 358 | case VIA_IRQ_ABSOLUTE: |
362 | break; | 359 | break; |
363 | default: | 360 | default: |
364 | return -EINVAL; | 361 | return -EINVAL; |
365 | } | 362 | } |
366 | 363 | ||
367 | if (irqwait.request.type & VIA_IRQ_SIGNAL) { | 364 | if (irqwait->request.type & VIA_IRQ_SIGNAL) { |
368 | DRM_ERROR("%s Signals on Via IRQs not implemented yet.\n", | 365 | DRM_ERROR("%s Signals on Via IRQs not implemented yet.\n", |
369 | __FUNCTION__); | 366 | __FUNCTION__); |
370 | return -EINVAL; | 367 | return -EINVAL; |
371 | } | 368 | } |
372 | 369 | ||
373 | force_sequence = (irqwait.request.type & VIA_IRQ_FORCE_SEQUENCE); | 370 | force_sequence = (irqwait->request.type & VIA_IRQ_FORCE_SEQUENCE); |
374 | 371 | ||
375 | ret = via_driver_irq_wait(dev, irqwait.request.irq, force_sequence, | 372 | ret = via_driver_irq_wait(dev, irqwait->request.irq, force_sequence, |
376 | &irqwait.request.sequence); | 373 | &irqwait->request.sequence); |
377 | do_gettimeofday(&now); | 374 | do_gettimeofday(&now); |
378 | irqwait.reply.tval_sec = now.tv_sec; | 375 | irqwait->reply.tval_sec = now.tv_sec; |
379 | irqwait.reply.tval_usec = now.tv_usec; | 376 | irqwait->reply.tval_usec = now.tv_usec; |
380 | |||
381 | DRM_COPY_TO_USER_IOCTL(argp, irqwait, sizeof(irqwait)); | ||
382 | 377 | ||
383 | return ret; | 378 | return ret; |
384 | } | 379 | } |
diff --git a/drivers/char/drm/via_map.c b/drivers/char/drm/via_map.c index 6345c86e1f5e..10091507a0dc 100644 --- a/drivers/char/drm/via_map.c +++ b/drivers/char/drm/via_map.c | |||
@@ -75,19 +75,15 @@ int via_do_cleanup_map(struct drm_device * dev) | |||
75 | return 0; | 75 | return 0; |
76 | } | 76 | } |
77 | 77 | ||
78 | int via_map_init(DRM_IOCTL_ARGS) | 78 | int via_map_init(struct drm_device *dev, void *data, struct drm_file *file_priv) |
79 | { | 79 | { |
80 | DRM_DEVICE; | 80 | drm_via_init_t *init = data; |
81 | drm_via_init_t init; | ||
82 | 81 | ||
83 | DRM_DEBUG("%s\n", __FUNCTION__); | 82 | DRM_DEBUG("%s\n", __FUNCTION__); |
84 | 83 | ||
85 | DRM_COPY_FROM_USER_IOCTL(init, (drm_via_init_t __user *) data, | 84 | switch (init->func) { |
86 | sizeof(init)); | ||
87 | |||
88 | switch (init.func) { | ||
89 | case VIA_INIT_MAP: | 85 | case VIA_INIT_MAP: |
90 | return via_do_init_map(dev, &init); | 86 | return via_do_init_map(dev, init); |
91 | case VIA_CLEANUP_MAP: | 87 | case VIA_CLEANUP_MAP: |
92 | return via_do_cleanup_map(dev); | 88 | return via_do_cleanup_map(dev); |
93 | } | 89 | } |
diff --git a/drivers/char/drm/via_mm.c b/drivers/char/drm/via_mm.c index fe68cbbe787c..9afc1684348d 100644 --- a/drivers/char/drm/via_mm.c +++ b/drivers/char/drm/via_mm.c | |||
@@ -33,18 +33,15 @@ | |||
33 | #define VIA_MM_ALIGN_SHIFT 4 | 33 | #define VIA_MM_ALIGN_SHIFT 4 |
34 | #define VIA_MM_ALIGN_MASK ( (1 << VIA_MM_ALIGN_SHIFT) - 1) | 34 | #define VIA_MM_ALIGN_MASK ( (1 << VIA_MM_ALIGN_SHIFT) - 1) |
35 | 35 | ||
36 | int via_agp_init(DRM_IOCTL_ARGS) | 36 | int via_agp_init(struct drm_device *dev, void *data, struct drm_file *file_priv) |
37 | { | 37 | { |
38 | DRM_DEVICE; | 38 | drm_via_agp_t *agp = data; |
39 | drm_via_agp_t agp; | ||
40 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; | 39 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; |
41 | int ret; | 40 | int ret; |
42 | 41 | ||
43 | DRM_COPY_FROM_USER_IOCTL(agp, (drm_via_agp_t __user *) data, | ||
44 | sizeof(agp)); | ||
45 | mutex_lock(&dev->struct_mutex); | 42 | mutex_lock(&dev->struct_mutex); |
46 | ret = drm_sman_set_range(&dev_priv->sman, VIA_MEM_AGP, 0, | 43 | ret = drm_sman_set_range(&dev_priv->sman, VIA_MEM_AGP, 0, |
47 | agp.size >> VIA_MM_ALIGN_SHIFT); | 44 | agp->size >> VIA_MM_ALIGN_SHIFT); |
48 | 45 | ||
49 | if (ret) { | 46 | if (ret) { |
50 | DRM_ERROR("AGP memory manager initialisation error\n"); | 47 | DRM_ERROR("AGP memory manager initialisation error\n"); |
@@ -53,25 +50,22 @@ int via_agp_init(DRM_IOCTL_ARGS) | |||
53 | } | 50 | } |
54 | 51 | ||
55 | dev_priv->agp_initialized = 1; | 52 | dev_priv->agp_initialized = 1; |
56 | dev_priv->agp_offset = agp.offset; | 53 | dev_priv->agp_offset = agp->offset; |
57 | mutex_unlock(&dev->struct_mutex); | 54 | mutex_unlock(&dev->struct_mutex); |
58 | 55 | ||
59 | DRM_DEBUG("offset = %u, size = %u", agp.offset, agp.size); | 56 | DRM_DEBUG("offset = %u, size = %u", agp->offset, agp->size); |
60 | return 0; | 57 | return 0; |
61 | } | 58 | } |
62 | 59 | ||
63 | int via_fb_init(DRM_IOCTL_ARGS) | 60 | int via_fb_init(struct drm_device *dev, void *data, struct drm_file *file_priv) |
64 | { | 61 | { |
65 | DRM_DEVICE; | 62 | drm_via_fb_t *fb = data; |
66 | drm_via_fb_t fb; | ||
67 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; | 63 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; |
68 | int ret; | 64 | int ret; |
69 | 65 | ||
70 | DRM_COPY_FROM_USER_IOCTL(fb, (drm_via_fb_t __user *) data, sizeof(fb)); | ||
71 | |||
72 | mutex_lock(&dev->struct_mutex); | 66 | mutex_lock(&dev->struct_mutex); |
73 | ret = drm_sman_set_range(&dev_priv->sman, VIA_MEM_VIDEO, 0, | 67 | ret = drm_sman_set_range(&dev_priv->sman, VIA_MEM_VIDEO, 0, |
74 | fb.size >> VIA_MM_ALIGN_SHIFT); | 68 | fb->size >> VIA_MM_ALIGN_SHIFT); |
75 | 69 | ||
76 | if (ret) { | 70 | if (ret) { |
77 | DRM_ERROR("VRAM memory manager initialisation error\n"); | 71 | DRM_ERROR("VRAM memory manager initialisation error\n"); |
@@ -80,10 +74,10 @@ int via_fb_init(DRM_IOCTL_ARGS) | |||
80 | } | 74 | } |
81 | 75 | ||
82 | dev_priv->vram_initialized = 1; | 76 | dev_priv->vram_initialized = 1; |
83 | dev_priv->vram_offset = fb.offset; | 77 | dev_priv->vram_offset = fb->offset; |
84 | 78 | ||
85 | mutex_unlock(&dev->struct_mutex); | 79 | mutex_unlock(&dev->struct_mutex); |
86 | DRM_DEBUG("offset = %u, size = %u", fb.offset, fb.size); | 80 | DRM_DEBUG("offset = %u, size = %u", fb->offset, fb->size); |
87 | 81 | ||
88 | return 0; | 82 | return 0; |
89 | 83 | ||
@@ -121,25 +115,21 @@ void via_lastclose(struct drm_device *dev) | |||
121 | mutex_unlock(&dev->struct_mutex); | 115 | mutex_unlock(&dev->struct_mutex); |
122 | } | 116 | } |
123 | 117 | ||
124 | int via_mem_alloc(DRM_IOCTL_ARGS) | 118 | int via_mem_alloc(struct drm_device *dev, void *data, |
119 | struct drm_file *file_priv) | ||
125 | { | 120 | { |
126 | DRM_DEVICE; | 121 | drm_via_mem_t *mem = data; |
127 | |||
128 | drm_via_mem_t mem; | ||
129 | int retval = 0; | 122 | int retval = 0; |
130 | struct drm_memblock_item *item; | 123 | struct drm_memblock_item *item; |
131 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; | 124 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; |
132 | unsigned long tmpSize; | 125 | unsigned long tmpSize; |
133 | 126 | ||
134 | DRM_COPY_FROM_USER_IOCTL(mem, (drm_via_mem_t __user *) data, | 127 | if (mem->type > VIA_MEM_AGP) { |
135 | sizeof(mem)); | ||
136 | |||
137 | if (mem.type > VIA_MEM_AGP) { | ||
138 | DRM_ERROR("Unknown memory type allocation\n"); | 128 | DRM_ERROR("Unknown memory type allocation\n"); |
139 | return -EINVAL; | 129 | return -EINVAL; |
140 | } | 130 | } |
141 | mutex_lock(&dev->struct_mutex); | 131 | mutex_lock(&dev->struct_mutex); |
142 | if (0 == ((mem.type == VIA_MEM_VIDEO) ? dev_priv->vram_initialized : | 132 | if (0 == ((mem->type == VIA_MEM_VIDEO) ? dev_priv->vram_initialized : |
143 | dev_priv->agp_initialized)) { | 133 | dev_priv->agp_initialized)) { |
144 | DRM_ERROR | 134 | DRM_ERROR |
145 | ("Attempt to allocate from uninitialized memory manager.\n"); | 135 | ("Attempt to allocate from uninitialized memory manager.\n"); |
@@ -147,42 +137,37 @@ int via_mem_alloc(DRM_IOCTL_ARGS) | |||
147 | return -EINVAL; | 137 | return -EINVAL; |
148 | } | 138 | } |
149 | 139 | ||
150 | tmpSize = (mem.size + VIA_MM_ALIGN_MASK) >> VIA_MM_ALIGN_SHIFT; | 140 | tmpSize = (mem->size + VIA_MM_ALIGN_MASK) >> VIA_MM_ALIGN_SHIFT; |
151 | item = drm_sman_alloc(&dev_priv->sman, mem.type, tmpSize, 0, | 141 | item = drm_sman_alloc(&dev_priv->sman, mem->type, tmpSize, 0, |
152 | (unsigned long)file_priv); | 142 | (unsigned long)file_priv); |
153 | mutex_unlock(&dev->struct_mutex); | 143 | mutex_unlock(&dev->struct_mutex); |
154 | if (item) { | 144 | if (item) { |
155 | mem.offset = ((mem.type == VIA_MEM_VIDEO) ? | 145 | mem->offset = ((mem->type == VIA_MEM_VIDEO) ? |
156 | dev_priv->vram_offset : dev_priv->agp_offset) + | 146 | dev_priv->vram_offset : dev_priv->agp_offset) + |
157 | (item->mm-> | 147 | (item->mm-> |
158 | offset(item->mm, item->mm_info) << VIA_MM_ALIGN_SHIFT); | 148 | offset(item->mm, item->mm_info) << VIA_MM_ALIGN_SHIFT); |
159 | mem.index = item->user_hash.key; | 149 | mem->index = item->user_hash.key; |
160 | } else { | 150 | } else { |
161 | mem.offset = 0; | 151 | mem->offset = 0; |
162 | mem.size = 0; | 152 | mem->size = 0; |
163 | mem.index = 0; | 153 | mem->index = 0; |
164 | DRM_DEBUG("Video memory allocation failed\n"); | 154 | DRM_DEBUG("Video memory allocation failed\n"); |
165 | retval = -ENOMEM; | 155 | retval = -ENOMEM; |
166 | } | 156 | } |
167 | DRM_COPY_TO_USER_IOCTL((drm_via_mem_t __user *) data, mem, sizeof(mem)); | ||
168 | 157 | ||
169 | return retval; | 158 | return retval; |
170 | } | 159 | } |
171 | 160 | ||
172 | int via_mem_free(DRM_IOCTL_ARGS) | 161 | int via_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv) |
173 | { | 162 | { |
174 | DRM_DEVICE; | ||
175 | drm_via_private_t *dev_priv = dev->dev_private; | 163 | drm_via_private_t *dev_priv = dev->dev_private; |
176 | drm_via_mem_t mem; | 164 | drm_via_mem_t *mem = data; |
177 | int ret; | 165 | int ret; |
178 | 166 | ||
179 | DRM_COPY_FROM_USER_IOCTL(mem, (drm_via_mem_t __user *) data, | ||
180 | sizeof(mem)); | ||
181 | |||
182 | mutex_lock(&dev->struct_mutex); | 167 | mutex_lock(&dev->struct_mutex); |
183 | ret = drm_sman_free_key(&dev_priv->sman, mem.index); | 168 | ret = drm_sman_free_key(&dev_priv->sman, mem->index); |
184 | mutex_unlock(&dev->struct_mutex); | 169 | mutex_unlock(&dev->struct_mutex); |
185 | DRM_DEBUG("free = 0x%lx\n", mem.index); | 170 | DRM_DEBUG("free = 0x%lx\n", mem->index); |
186 | 171 | ||
187 | return ret; | 172 | return ret; |
188 | } | 173 | } |
diff --git a/drivers/char/drm/via_video.c b/drivers/char/drm/via_video.c index 300ac61b09ed..c15e75b54cb1 100644 --- a/drivers/char/drm/via_video.c +++ b/drivers/char/drm/via_video.c | |||
@@ -65,10 +65,9 @@ void via_release_futex(drm_via_private_t * dev_priv, int context) | |||
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | int via_decoder_futex(DRM_IOCTL_ARGS) | 68 | int via_decoder_futex(struct drm_device *dev, void *data, struct drm_file *file_priv) |
69 | { | 69 | { |
70 | DRM_DEVICE; | 70 | drm_via_futex_t *fx = data; |
71 | drm_via_futex_t fx; | ||
72 | volatile int *lock; | 71 | volatile int *lock; |
73 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; | 72 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; |
74 | drm_via_sarea_t *sAPriv = dev_priv->sarea_priv; | 73 | drm_via_sarea_t *sAPriv = dev_priv->sarea_priv; |
@@ -76,21 +75,18 @@ int via_decoder_futex(DRM_IOCTL_ARGS) | |||
76 | 75 | ||
77 | DRM_DEBUG("%s\n", __FUNCTION__); | 76 | DRM_DEBUG("%s\n", __FUNCTION__); |
78 | 77 | ||
79 | DRM_COPY_FROM_USER_IOCTL(fx, (drm_via_futex_t __user *) data, | 78 | if (fx->lock > VIA_NR_XVMC_LOCKS) |
80 | sizeof(fx)); | ||
81 | |||
82 | if (fx.lock > VIA_NR_XVMC_LOCKS) | ||
83 | return -EFAULT; | 79 | return -EFAULT; |
84 | 80 | ||
85 | lock = (volatile int *)XVMCLOCKPTR(sAPriv, fx.lock); | 81 | lock = (volatile int *)XVMCLOCKPTR(sAPriv, fx->lock); |
86 | 82 | ||
87 | switch (fx.func) { | 83 | switch (fx->func) { |
88 | case VIA_FUTEX_WAIT: | 84 | case VIA_FUTEX_WAIT: |
89 | DRM_WAIT_ON(ret, dev_priv->decoder_queue[fx.lock], | 85 | DRM_WAIT_ON(ret, dev_priv->decoder_queue[fx->lock], |
90 | (fx.ms / 10) * (DRM_HZ / 100), *lock != fx.val); | 86 | (fx->ms / 10) * (DRM_HZ / 100), *lock != fx->val); |
91 | return ret; | 87 | return ret; |
92 | case VIA_FUTEX_WAKE: | 88 | case VIA_FUTEX_WAKE: |
93 | DRM_WAKEUP(&(dev_priv->decoder_queue[fx.lock])); | 89 | DRM_WAKEUP(&(dev_priv->decoder_queue[fx->lock])); |
94 | return 0; | 90 | return 0; |
95 | } | 91 | } |
96 | return 0; | 92 | return 0; |