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/drm_scatter.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/drm_scatter.c')
-rw-r--r-- | drivers/char/drm/drm_scatter.c | 46 |
1 files changed, 19 insertions, 27 deletions
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); |