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/char/drm/via_mm.c | |
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/char/drm/via_mm.c')
-rw-r--r-- | drivers/char/drm/via_mm.c | 67 |
1 files changed, 26 insertions, 41 deletions
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 | } |