aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon/radeon_cs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_cs.c')
-rw-r--r--drivers/gpu/drm/radeon/radeon_cs.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index fae00c0d75aa..29afd71e0840 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -93,7 +93,7 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
93{ 93{
94 struct drm_radeon_cs *cs = data; 94 struct drm_radeon_cs *cs = data;
95 uint64_t *chunk_array_ptr; 95 uint64_t *chunk_array_ptr;
96 unsigned size, i; 96 unsigned size, i, flags = 0;
97 97
98 if (!cs->num_chunks) { 98 if (!cs->num_chunks) {
99 return 0; 99 return 0;
@@ -140,6 +140,10 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
140 if (p->chunks[i].length_dw == 0) 140 if (p->chunks[i].length_dw == 0)
141 return -EINVAL; 141 return -EINVAL;
142 } 142 }
143 if (p->chunks[i].chunk_id == RADEON_CHUNK_ID_FLAGS &&
144 !p->chunks[i].length_dw) {
145 return -EINVAL;
146 }
143 147
144 p->chunks[i].length_dw = user_chunk.length_dw; 148 p->chunks[i].length_dw = user_chunk.length_dw;
145 p->chunks[i].user_ptr = (void __user *)(unsigned long)user_chunk.chunk_data; 149 p->chunks[i].user_ptr = (void __user *)(unsigned long)user_chunk.chunk_data;
@@ -155,6 +159,9 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
155 p->chunks[i].user_ptr, size)) { 159 p->chunks[i].user_ptr, size)) {
156 return -EFAULT; 160 return -EFAULT;
157 } 161 }
162 if (p->chunks[i].chunk_id == RADEON_CHUNK_ID_FLAGS) {
163 flags = p->chunks[i].kdata[0];
164 }
158 } else { 165 } else {
159 p->chunks[i].kpage[0] = kmalloc(PAGE_SIZE, GFP_KERNEL); 166 p->chunks[i].kpage[0] = kmalloc(PAGE_SIZE, GFP_KERNEL);
160 p->chunks[i].kpage[1] = kmalloc(PAGE_SIZE, GFP_KERNEL); 167 p->chunks[i].kpage[1] = kmalloc(PAGE_SIZE, GFP_KERNEL);
@@ -174,6 +181,8 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
174 p->chunks[p->chunk_ib_idx].length_dw); 181 p->chunks[p->chunk_ib_idx].length_dw);
175 return -EINVAL; 182 return -EINVAL;
176 } 183 }
184
185 p->keep_tiling_flags = (flags & RADEON_CS_KEEP_TILING_FLAGS) != 0;
177 return 0; 186 return 0;
178} 187}
179 188
@@ -222,7 +231,7 @@ int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
222 struct radeon_cs_chunk *ib_chunk; 231 struct radeon_cs_chunk *ib_chunk;
223 int r; 232 int r;
224 233
225 mutex_lock(&rdev->cs_mutex); 234 radeon_mutex_lock(&rdev->cs_mutex);
226 /* initialize parser */ 235 /* initialize parser */
227 memset(&parser, 0, sizeof(struct radeon_cs_parser)); 236 memset(&parser, 0, sizeof(struct radeon_cs_parser));
228 parser.filp = filp; 237 parser.filp = filp;
@@ -233,14 +242,14 @@ int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
233 if (r) { 242 if (r) {
234 DRM_ERROR("Failed to initialize parser !\n"); 243 DRM_ERROR("Failed to initialize parser !\n");
235 radeon_cs_parser_fini(&parser, r); 244 radeon_cs_parser_fini(&parser, r);
236 mutex_unlock(&rdev->cs_mutex); 245 radeon_mutex_unlock(&rdev->cs_mutex);
237 return r; 246 return r;
238 } 247 }
239 r = radeon_ib_get(rdev, &parser.ib); 248 r = radeon_ib_get(rdev, &parser.ib);
240 if (r) { 249 if (r) {
241 DRM_ERROR("Failed to get ib !\n"); 250 DRM_ERROR("Failed to get ib !\n");
242 radeon_cs_parser_fini(&parser, r); 251 radeon_cs_parser_fini(&parser, r);
243 mutex_unlock(&rdev->cs_mutex); 252 radeon_mutex_unlock(&rdev->cs_mutex);
244 return r; 253 return r;
245 } 254 }
246 r = radeon_cs_parser_relocs(&parser); 255 r = radeon_cs_parser_relocs(&parser);
@@ -248,7 +257,7 @@ int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
248 if (r != -ERESTARTSYS) 257 if (r != -ERESTARTSYS)
249 DRM_ERROR("Failed to parse relocation %d!\n", r); 258 DRM_ERROR("Failed to parse relocation %d!\n", r);
250 radeon_cs_parser_fini(&parser, r); 259 radeon_cs_parser_fini(&parser, r);
251 mutex_unlock(&rdev->cs_mutex); 260 radeon_mutex_unlock(&rdev->cs_mutex);
252 return r; 261 return r;
253 } 262 }
254 /* Copy the packet into the IB, the parser will read from the 263 /* Copy the packet into the IB, the parser will read from the
@@ -260,14 +269,14 @@ int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
260 if (r || parser.parser_error) { 269 if (r || parser.parser_error) {
261 DRM_ERROR("Invalid command stream !\n"); 270 DRM_ERROR("Invalid command stream !\n");
262 radeon_cs_parser_fini(&parser, r); 271 radeon_cs_parser_fini(&parser, r);
263 mutex_unlock(&rdev->cs_mutex); 272 radeon_mutex_unlock(&rdev->cs_mutex);
264 return r; 273 return r;
265 } 274 }
266 r = radeon_cs_finish_pages(&parser); 275 r = radeon_cs_finish_pages(&parser);
267 if (r) { 276 if (r) {
268 DRM_ERROR("Invalid command stream !\n"); 277 DRM_ERROR("Invalid command stream !\n");
269 radeon_cs_parser_fini(&parser, r); 278 radeon_cs_parser_fini(&parser, r);
270 mutex_unlock(&rdev->cs_mutex); 279 radeon_mutex_unlock(&rdev->cs_mutex);
271 return r; 280 return r;
272 } 281 }
273 r = radeon_ib_schedule(rdev, parser.ib); 282 r = radeon_ib_schedule(rdev, parser.ib);
@@ -275,7 +284,7 @@ int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
275 DRM_ERROR("Failed to schedule IB !\n"); 284 DRM_ERROR("Failed to schedule IB !\n");
276 } 285 }
277 radeon_cs_parser_fini(&parser, r); 286 radeon_cs_parser_fini(&parser, r);
278 mutex_unlock(&rdev->cs_mutex); 287 radeon_mutex_unlock(&rdev->cs_mutex);
279 return r; 288 return r;
280} 289}
281 290