aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon/r600_cs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/radeon/r600_cs.c')
-rw-r--r--drivers/gpu/drm/radeon/r600_cs.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/gpu/drm/radeon/r600_cs.c b/drivers/gpu/drm/radeon/r600_cs.c
index c629b5aa4a3f..dd009da0e7a0 100644
--- a/drivers/gpu/drm/radeon/r600_cs.c
+++ b/drivers/gpu/drm/radeon/r600_cs.c
@@ -220,9 +220,11 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
220 unsigned i; 220 unsigned i;
221 unsigned start_reg, end_reg, reg; 221 unsigned start_reg, end_reg, reg;
222 int r; 222 int r;
223 u32 idx_value;
223 224
224 ib = p->ib->ptr; 225 ib = p->ib->ptr;
225 idx = pkt->idx + 1; 226 idx = pkt->idx + 1;
227 idx_value = radeon_get_ib_value(p, idx);
226 228
227 switch (pkt->opcode) { 229 switch (pkt->opcode) {
228 case PACKET3_START_3D_CMDBUF: 230 case PACKET3_START_3D_CMDBUF:
@@ -254,7 +256,7 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
254 DRM_ERROR("bad DRAW_INDEX\n"); 256 DRM_ERROR("bad DRAW_INDEX\n");
255 return -EINVAL; 257 return -EINVAL;
256 } 258 }
257 ib[idx+0] += (u32)(reloc->lobj.gpu_offset & 0xffffffff); 259 ib[idx+0] = idx_value + (u32)(reloc->lobj.gpu_offset & 0xffffffff);
258 ib[idx+1] = upper_32_bits(reloc->lobj.gpu_offset) & 0xff; 260 ib[idx+1] = upper_32_bits(reloc->lobj.gpu_offset) & 0xff;
259 break; 261 break;
260 case PACKET3_DRAW_INDEX_AUTO: 262 case PACKET3_DRAW_INDEX_AUTO:
@@ -276,7 +278,7 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
276 return -EINVAL; 278 return -EINVAL;
277 } 279 }
278 /* bit 4 is reg (0) or mem (1) */ 280 /* bit 4 is reg (0) or mem (1) */
279 if (radeon_get_ib_value(p, idx) & 0x10) { 281 if (idx_value & 0x10) {
280 r = r600_cs_packet_next_reloc(p, &reloc); 282 r = r600_cs_packet_next_reloc(p, &reloc);
281 if (r) { 283 if (r) {
282 DRM_ERROR("bad WAIT_REG_MEM\n"); 284 DRM_ERROR("bad WAIT_REG_MEM\n");
@@ -331,7 +333,7 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
331 ib[idx+2] |= upper_32_bits(reloc->lobj.gpu_offset) & 0xff; 333 ib[idx+2] |= upper_32_bits(reloc->lobj.gpu_offset) & 0xff;
332 break; 334 break;
333 case PACKET3_SET_CONFIG_REG: 335 case PACKET3_SET_CONFIG_REG:
334 start_reg = (ib[idx+0] << 2) + PACKET3_SET_CONFIG_REG_OFFSET; 336 start_reg = (idx_value << 2) + PACKET3_SET_CONFIG_REG_OFFSET;
335 end_reg = 4 * pkt->count + start_reg - 4; 337 end_reg = 4 * pkt->count + start_reg - 4;
336 if ((start_reg < PACKET3_SET_CONFIG_REG_OFFSET) || 338 if ((start_reg < PACKET3_SET_CONFIG_REG_OFFSET) ||
337 (start_reg >= PACKET3_SET_CONFIG_REG_END) || 339 (start_reg >= PACKET3_SET_CONFIG_REG_END) ||
@@ -351,7 +353,7 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
351 } 353 }
352 break; 354 break;
353 case PACKET3_SET_CONTEXT_REG: 355 case PACKET3_SET_CONTEXT_REG:
354 start_reg = (ib[idx+0] << 2) + PACKET3_SET_CONTEXT_REG_OFFSET; 356 start_reg = (idx_value << 2) + PACKET3_SET_CONTEXT_REG_OFFSET;
355 end_reg = 4 * pkt->count + start_reg - 4; 357 end_reg = 4 * pkt->count + start_reg - 4;
356 if ((start_reg < PACKET3_SET_CONTEXT_REG_OFFSET) || 358 if ((start_reg < PACKET3_SET_CONTEXT_REG_OFFSET) ||
357 (start_reg >= PACKET3_SET_CONTEXT_REG_END) || 359 (start_reg >= PACKET3_SET_CONTEXT_REG_END) ||
@@ -416,7 +418,7 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
416 DRM_ERROR("bad SET_RESOURCE\n"); 418 DRM_ERROR("bad SET_RESOURCE\n");
417 return -EINVAL; 419 return -EINVAL;
418 } 420 }
419 start_reg = (ib[idx+0] << 2) + PACKET3_SET_RESOURCE_OFFSET; 421 start_reg = (idx_value << 2) + PACKET3_SET_RESOURCE_OFFSET;
420 end_reg = 4 * pkt->count + start_reg - 4; 422 end_reg = 4 * pkt->count + start_reg - 4;
421 if ((start_reg < PACKET3_SET_RESOURCE_OFFSET) || 423 if ((start_reg < PACKET3_SET_RESOURCE_OFFSET) ||
422 (start_reg >= PACKET3_SET_RESOURCE_END) || 424 (start_reg >= PACKET3_SET_RESOURCE_END) ||
@@ -425,7 +427,7 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
425 return -EINVAL; 427 return -EINVAL;
426 } 428 }
427 for (i = 0; i < (pkt->count / 7); i++) { 429 for (i = 0; i < (pkt->count / 7); i++) {
428 switch (G__SQ_VTX_CONSTANT_TYPE(ib[idx+(i*7)+6+1])) { 430 switch (G__SQ_VTX_CONSTANT_TYPE(radeon_get_ib_value(p, idx+(i*7)+6+1))) {
429 case SQ_TEX_VTX_VALID_TEXTURE: 431 case SQ_TEX_VTX_VALID_TEXTURE:
430 /* tex base */ 432 /* tex base */
431 r = r600_cs_packet_next_reloc(p, &reloc); 433 r = r600_cs_packet_next_reloc(p, &reloc);
@@ -461,7 +463,7 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
461 } 463 }
462 break; 464 break;
463 case PACKET3_SET_ALU_CONST: 465 case PACKET3_SET_ALU_CONST:
464 start_reg = (ib[idx+0] << 2) + PACKET3_SET_ALU_CONST_OFFSET; 466 start_reg = (idx_value << 2) + PACKET3_SET_ALU_CONST_OFFSET;
465 end_reg = 4 * pkt->count + start_reg - 4; 467 end_reg = 4 * pkt->count + start_reg - 4;
466 if ((start_reg < PACKET3_SET_ALU_CONST_OFFSET) || 468 if ((start_reg < PACKET3_SET_ALU_CONST_OFFSET) ||
467 (start_reg >= PACKET3_SET_ALU_CONST_END) || 469 (start_reg >= PACKET3_SET_ALU_CONST_END) ||
@@ -471,7 +473,7 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
471 } 473 }
472 break; 474 break;
473 case PACKET3_SET_BOOL_CONST: 475 case PACKET3_SET_BOOL_CONST:
474 start_reg = (ib[idx+0] << 2) + PACKET3_SET_BOOL_CONST_OFFSET; 476 start_reg = (idx_value << 2) + PACKET3_SET_BOOL_CONST_OFFSET;
475 end_reg = 4 * pkt->count + start_reg - 4; 477 end_reg = 4 * pkt->count + start_reg - 4;
476 if ((start_reg < PACKET3_SET_BOOL_CONST_OFFSET) || 478 if ((start_reg < PACKET3_SET_BOOL_CONST_OFFSET) ||
477 (start_reg >= PACKET3_SET_BOOL_CONST_END) || 479 (start_reg >= PACKET3_SET_BOOL_CONST_END) ||
@@ -481,7 +483,7 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
481 } 483 }
482 break; 484 break;
483 case PACKET3_SET_LOOP_CONST: 485 case PACKET3_SET_LOOP_CONST:
484 start_reg = (ib[idx+0] << 2) + PACKET3_SET_LOOP_CONST_OFFSET; 486 start_reg = (idx_value << 2) + PACKET3_SET_LOOP_CONST_OFFSET;
485 end_reg = 4 * pkt->count + start_reg - 4; 487 end_reg = 4 * pkt->count + start_reg - 4;
486 if ((start_reg < PACKET3_SET_LOOP_CONST_OFFSET) || 488 if ((start_reg < PACKET3_SET_LOOP_CONST_OFFSET) ||
487 (start_reg >= PACKET3_SET_LOOP_CONST_END) || 489 (start_reg >= PACKET3_SET_LOOP_CONST_END) ||
@@ -491,7 +493,7 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
491 } 493 }
492 break; 494 break;
493 case PACKET3_SET_CTL_CONST: 495 case PACKET3_SET_CTL_CONST:
494 start_reg = (ib[idx+0] << 2) + PACKET3_SET_CTL_CONST_OFFSET; 496 start_reg = (idx_value << 2) + PACKET3_SET_CTL_CONST_OFFSET;
495 end_reg = 4 * pkt->count + start_reg - 4; 497 end_reg = 4 * pkt->count + start_reg - 4;
496 if ((start_reg < PACKET3_SET_CTL_CONST_OFFSET) || 498 if ((start_reg < PACKET3_SET_CTL_CONST_OFFSET) ||
497 (start_reg >= PACKET3_SET_CTL_CONST_END) || 499 (start_reg >= PACKET3_SET_CTL_CONST_END) ||
@@ -505,7 +507,7 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
505 DRM_ERROR("bad SET_SAMPLER\n"); 507 DRM_ERROR("bad SET_SAMPLER\n");
506 return -EINVAL; 508 return -EINVAL;
507 } 509 }
508 start_reg = (ib[idx+0] << 2) + PACKET3_SET_SAMPLER_OFFSET; 510 start_reg = (idx_value << 2) + PACKET3_SET_SAMPLER_OFFSET;
509 end_reg = 4 * pkt->count + start_reg - 4; 511 end_reg = 4 * pkt->count + start_reg - 4;
510 if ((start_reg < PACKET3_SET_SAMPLER_OFFSET) || 512 if ((start_reg < PACKET3_SET_SAMPLER_OFFSET) ||
511 (start_reg >= PACKET3_SET_SAMPLER_END) || 513 (start_reg >= PACKET3_SET_SAMPLER_END) ||