diff options
Diffstat (limited to 'drivers/char/drm/r300_cmdbuf.c')
-rw-r--r-- | drivers/char/drm/r300_cmdbuf.c | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/drivers/char/drm/r300_cmdbuf.c b/drivers/char/drm/r300_cmdbuf.c index 4e5aca6ba59a..669aee68ce24 100644 --- a/drivers/char/drm/r300_cmdbuf.c +++ b/drivers/char/drm/r300_cmdbuf.c | |||
@@ -74,7 +74,7 @@ static int r300_emit_cliprects(drm_radeon_private_t *dev_priv, | |||
74 | if (DRM_COPY_FROM_USER_UNCHECKED | 74 | if (DRM_COPY_FROM_USER_UNCHECKED |
75 | (&box, &cmdbuf->boxes[n + i], sizeof(box))) { | 75 | (&box, &cmdbuf->boxes[n + i], sizeof(box))) { |
76 | DRM_ERROR("copy cliprect faulted\n"); | 76 | DRM_ERROR("copy cliprect faulted\n"); |
77 | return DRM_ERR(EFAULT); | 77 | return -EFAULT; |
78 | } | 78 | } |
79 | 79 | ||
80 | box.x1 = | 80 | box.x1 = |
@@ -263,7 +263,7 @@ static __inline__ int r300_emit_carefully_checked_packet0(drm_radeon_private_t * | |||
263 | DRM_ERROR | 263 | DRM_ERROR |
264 | ("Cannot emit more than 64 values at a time (reg=%04x sz=%d)\n", | 264 | ("Cannot emit more than 64 values at a time (reg=%04x sz=%d)\n", |
265 | reg, sz); | 265 | reg, sz); |
266 | return DRM_ERR(EINVAL); | 266 | return -EINVAL; |
267 | } | 267 | } |
268 | for (i = 0; i < sz; i++) { | 268 | for (i = 0; i < sz; i++) { |
269 | values[i] = ((int *)cmdbuf->buf)[i]; | 269 | values[i] = ((int *)cmdbuf->buf)[i]; |
@@ -275,13 +275,13 @@ static __inline__ int r300_emit_carefully_checked_packet0(drm_radeon_private_t * | |||
275 | DRM_ERROR | 275 | DRM_ERROR |
276 | ("Offset failed range check (reg=%04x sz=%d)\n", | 276 | ("Offset failed range check (reg=%04x sz=%d)\n", |
277 | reg, sz); | 277 | reg, sz); |
278 | return DRM_ERR(EINVAL); | 278 | return -EINVAL; |
279 | } | 279 | } |
280 | break; | 280 | break; |
281 | default: | 281 | default: |
282 | DRM_ERROR("Register %04x failed check as flag=%02x\n", | 282 | DRM_ERROR("Register %04x failed check as flag=%02x\n", |
283 | reg + i * 4, r300_reg_flags[(reg >> 2) + i]); | 283 | reg + i * 4, r300_reg_flags[(reg >> 2) + i]); |
284 | return DRM_ERR(EINVAL); | 284 | return -EINVAL; |
285 | } | 285 | } |
286 | } | 286 | } |
287 | 287 | ||
@@ -317,12 +317,12 @@ static __inline__ int r300_emit_packet0(drm_radeon_private_t *dev_priv, | |||
317 | return 0; | 317 | return 0; |
318 | 318 | ||
319 | if (sz * 4 > cmdbuf->bufsz) | 319 | if (sz * 4 > cmdbuf->bufsz) |
320 | return DRM_ERR(EINVAL); | 320 | return -EINVAL; |
321 | 321 | ||
322 | if (reg + sz * 4 >= 0x10000) { | 322 | if (reg + sz * 4 >= 0x10000) { |
323 | DRM_ERROR("No such registers in hardware reg=%04x sz=%d\n", reg, | 323 | DRM_ERROR("No such registers in hardware reg=%04x sz=%d\n", reg, |
324 | sz); | 324 | sz); |
325 | return DRM_ERR(EINVAL); | 325 | return -EINVAL; |
326 | } | 326 | } |
327 | 327 | ||
328 | if (r300_check_range(reg, sz)) { | 328 | if (r300_check_range(reg, sz)) { |
@@ -362,7 +362,7 @@ static __inline__ int r300_emit_vpu(drm_radeon_private_t *dev_priv, | |||
362 | if (!sz) | 362 | if (!sz) |
363 | return 0; | 363 | return 0; |
364 | if (sz * 16 > cmdbuf->bufsz) | 364 | if (sz * 16 > cmdbuf->bufsz) |
365 | return DRM_ERR(EINVAL); | 365 | return -EINVAL; |
366 | 366 | ||
367 | BEGIN_RING(5 + sz * 4); | 367 | BEGIN_RING(5 + sz * 4); |
368 | /* Wait for VAP to come to senses.. */ | 368 | /* Wait for VAP to come to senses.. */ |
@@ -391,7 +391,7 @@ static __inline__ int r300_emit_clear(drm_radeon_private_t *dev_priv, | |||
391 | RING_LOCALS; | 391 | RING_LOCALS; |
392 | 392 | ||
393 | if (8 * 4 > cmdbuf->bufsz) | 393 | if (8 * 4 > cmdbuf->bufsz) |
394 | return DRM_ERR(EINVAL); | 394 | return -EINVAL; |
395 | 395 | ||
396 | BEGIN_RING(10); | 396 | BEGIN_RING(10); |
397 | OUT_RING(CP_PACKET3(R200_3D_DRAW_IMMD_2, 8)); | 397 | OUT_RING(CP_PACKET3(R200_3D_DRAW_IMMD_2, 8)); |
@@ -421,7 +421,7 @@ static __inline__ int r300_emit_3d_load_vbpntr(drm_radeon_private_t *dev_priv, | |||
421 | if ((count + 1) > MAX_ARRAY_PACKET) { | 421 | if ((count + 1) > MAX_ARRAY_PACKET) { |
422 | DRM_ERROR("Too large payload in 3D_LOAD_VBPNTR (count=%d)\n", | 422 | DRM_ERROR("Too large payload in 3D_LOAD_VBPNTR (count=%d)\n", |
423 | count); | 423 | count); |
424 | return DRM_ERR(EINVAL); | 424 | return -EINVAL; |
425 | } | 425 | } |
426 | memset(payload, 0, MAX_ARRAY_PACKET * 4); | 426 | memset(payload, 0, MAX_ARRAY_PACKET * 4); |
427 | memcpy(payload, cmdbuf->buf + 4, (count + 1) * 4); | 427 | memcpy(payload, cmdbuf->buf + 4, (count + 1) * 4); |
@@ -437,7 +437,7 @@ static __inline__ int r300_emit_3d_load_vbpntr(drm_radeon_private_t *dev_priv, | |||
437 | DRM_ERROR | 437 | DRM_ERROR |
438 | ("Offset failed range check (k=%d i=%d) while processing 3D_LOAD_VBPNTR packet.\n", | 438 | ("Offset failed range check (k=%d i=%d) while processing 3D_LOAD_VBPNTR packet.\n", |
439 | k, i); | 439 | k, i); |
440 | return DRM_ERR(EINVAL); | 440 | return -EINVAL; |
441 | } | 441 | } |
442 | k++; | 442 | k++; |
443 | i++; | 443 | i++; |
@@ -448,7 +448,7 @@ static __inline__ int r300_emit_3d_load_vbpntr(drm_radeon_private_t *dev_priv, | |||
448 | DRM_ERROR | 448 | DRM_ERROR |
449 | ("Offset failed range check (k=%d i=%d) while processing 3D_LOAD_VBPNTR packet.\n", | 449 | ("Offset failed range check (k=%d i=%d) while processing 3D_LOAD_VBPNTR packet.\n", |
450 | k, i); | 450 | k, i); |
451 | return DRM_ERR(EINVAL); | 451 | return -EINVAL; |
452 | } | 452 | } |
453 | k++; | 453 | k++; |
454 | i++; | 454 | i++; |
@@ -458,7 +458,7 @@ static __inline__ int r300_emit_3d_load_vbpntr(drm_radeon_private_t *dev_priv, | |||
458 | DRM_ERROR | 458 | DRM_ERROR |
459 | ("Malformed 3D_LOAD_VBPNTR packet (k=%d i=%d narrays=%d count+1=%d).\n", | 459 | ("Malformed 3D_LOAD_VBPNTR packet (k=%d i=%d narrays=%d count+1=%d).\n", |
460 | k, i, narrays, count + 1); | 460 | k, i, narrays, count + 1); |
461 | return DRM_ERR(EINVAL); | 461 | return -EINVAL; |
462 | } | 462 | } |
463 | 463 | ||
464 | /* all clear, output packet */ | 464 | /* all clear, output packet */ |
@@ -492,7 +492,7 @@ static __inline__ int r300_emit_bitblt_multi(drm_radeon_private_t *dev_priv, | |||
492 | ret = !radeon_check_offset(dev_priv, offset); | 492 | ret = !radeon_check_offset(dev_priv, offset); |
493 | if (ret) { | 493 | if (ret) { |
494 | DRM_ERROR("Invalid bitblt first offset is %08X\n", offset); | 494 | DRM_ERROR("Invalid bitblt first offset is %08X\n", offset); |
495 | return DRM_ERR(EINVAL); | 495 | return -EINVAL; |
496 | } | 496 | } |
497 | } | 497 | } |
498 | 498 | ||
@@ -502,7 +502,7 @@ static __inline__ int r300_emit_bitblt_multi(drm_radeon_private_t *dev_priv, | |||
502 | ret = !radeon_check_offset(dev_priv, offset); | 502 | ret = !radeon_check_offset(dev_priv, offset); |
503 | if (ret) { | 503 | if (ret) { |
504 | DRM_ERROR("Invalid bitblt second offset is %08X\n", offset); | 504 | DRM_ERROR("Invalid bitblt second offset is %08X\n", offset); |
505 | return DRM_ERR(EINVAL); | 505 | return -EINVAL; |
506 | } | 506 | } |
507 | 507 | ||
508 | } | 508 | } |
@@ -530,12 +530,12 @@ static __inline__ int r300_emit_indx_buffer(drm_radeon_private_t *dev_priv, | |||
530 | 530 | ||
531 | if ((cmd[1] & 0x8000ffff) != 0x80000810) { | 531 | if ((cmd[1] & 0x8000ffff) != 0x80000810) { |
532 | DRM_ERROR("Invalid indx_buffer reg address %08X\n", cmd[1]); | 532 | DRM_ERROR("Invalid indx_buffer reg address %08X\n", cmd[1]); |
533 | return DRM_ERR(EINVAL); | 533 | return -EINVAL; |
534 | } | 534 | } |
535 | ret = !radeon_check_offset(dev_priv, cmd[2]); | 535 | ret = !radeon_check_offset(dev_priv, cmd[2]); |
536 | if (ret) { | 536 | if (ret) { |
537 | DRM_ERROR("Invalid indx_buffer offset is %08X\n", cmd[2]); | 537 | DRM_ERROR("Invalid indx_buffer offset is %08X\n", cmd[2]); |
538 | return DRM_ERR(EINVAL); | 538 | return -EINVAL; |
539 | } | 539 | } |
540 | 540 | ||
541 | BEGIN_RING(count+2); | 541 | BEGIN_RING(count+2); |
@@ -557,7 +557,7 @@ static __inline__ int r300_emit_raw_packet3(drm_radeon_private_t *dev_priv, | |||
557 | RING_LOCALS; | 557 | RING_LOCALS; |
558 | 558 | ||
559 | if (4 > cmdbuf->bufsz) | 559 | if (4 > cmdbuf->bufsz) |
560 | return DRM_ERR(EINVAL); | 560 | return -EINVAL; |
561 | 561 | ||
562 | /* Fixme !! This simply emits a packet without much checking. | 562 | /* Fixme !! This simply emits a packet without much checking. |
563 | We need to be smarter. */ | 563 | We need to be smarter. */ |
@@ -568,7 +568,7 @@ static __inline__ int r300_emit_raw_packet3(drm_radeon_private_t *dev_priv, | |||
568 | /* Is it packet 3 ? */ | 568 | /* Is it packet 3 ? */ |
569 | if ((header >> 30) != 0x3) { | 569 | if ((header >> 30) != 0x3) { |
570 | DRM_ERROR("Not a packet3 header (0x%08x)\n", header); | 570 | DRM_ERROR("Not a packet3 header (0x%08x)\n", header); |
571 | return DRM_ERR(EINVAL); | 571 | return -EINVAL; |
572 | } | 572 | } |
573 | 573 | ||
574 | count = (header >> 16) & 0x3fff; | 574 | count = (header >> 16) & 0x3fff; |
@@ -578,7 +578,7 @@ static __inline__ int r300_emit_raw_packet3(drm_radeon_private_t *dev_priv, | |||
578 | DRM_ERROR | 578 | DRM_ERROR |
579 | ("Expected packet3 of length %d but have only %d bytes left\n", | 579 | ("Expected packet3 of length %d but have only %d bytes left\n", |
580 | (count + 2) * 4, cmdbuf->bufsz); | 580 | (count + 2) * 4, cmdbuf->bufsz); |
581 | return DRM_ERR(EINVAL); | 581 | return -EINVAL; |
582 | } | 582 | } |
583 | 583 | ||
584 | /* Is it a packet type we know about ? */ | 584 | /* Is it a packet type we know about ? */ |
@@ -600,7 +600,7 @@ static __inline__ int r300_emit_raw_packet3(drm_radeon_private_t *dev_priv, | |||
600 | break; | 600 | break; |
601 | default: | 601 | default: |
602 | DRM_ERROR("Unknown packet3 header (0x%08x)\n", header); | 602 | DRM_ERROR("Unknown packet3 header (0x%08x)\n", header); |
603 | return DRM_ERR(EINVAL); | 603 | return -EINVAL; |
604 | } | 604 | } |
605 | 605 | ||
606 | BEGIN_RING(count + 2); | 606 | BEGIN_RING(count + 2); |
@@ -664,7 +664,7 @@ static __inline__ int r300_emit_packet3(drm_radeon_private_t *dev_priv, | |||
664 | DRM_ERROR("bad packet3 type %i at %p\n", | 664 | DRM_ERROR("bad packet3 type %i at %p\n", |
665 | header.packet3.packet, | 665 | header.packet3.packet, |
666 | cmdbuf->buf - sizeof(header)); | 666 | cmdbuf->buf - sizeof(header)); |
667 | return DRM_ERR(EINVAL); | 667 | return -EINVAL; |
668 | } | 668 | } |
669 | 669 | ||
670 | n += R300_SIMULTANEOUS_CLIPRECTS; | 670 | n += R300_SIMULTANEOUS_CLIPRECTS; |
@@ -726,11 +726,11 @@ static int r300_scratch(drm_radeon_private_t *dev_priv, | |||
726 | 726 | ||
727 | if (cmdbuf->bufsz < | 727 | if (cmdbuf->bufsz < |
728 | (sizeof(u64) + header.scratch.n_bufs * sizeof(buf_idx))) { | 728 | (sizeof(u64) + header.scratch.n_bufs * sizeof(buf_idx))) { |
729 | return DRM_ERR(EINVAL); | 729 | return -EINVAL; |
730 | } | 730 | } |
731 | 731 | ||
732 | if (header.scratch.reg >= 5) { | 732 | if (header.scratch.reg >= 5) { |
733 | return DRM_ERR(EINVAL); | 733 | return -EINVAL; |
734 | } | 734 | } |
735 | 735 | ||
736 | dev_priv->scratch_ages[header.scratch.reg]++; | 736 | dev_priv->scratch_ages[header.scratch.reg]++; |
@@ -745,21 +745,21 @@ static int r300_scratch(drm_radeon_private_t *dev_priv, | |||
745 | buf_idx *= 2; /* 8 bytes per buf */ | 745 | buf_idx *= 2; /* 8 bytes per buf */ |
746 | 746 | ||
747 | if (DRM_COPY_TO_USER(ref_age_base + buf_idx, &dev_priv->scratch_ages[header.scratch.reg], sizeof(u32))) { | 747 | if (DRM_COPY_TO_USER(ref_age_base + buf_idx, &dev_priv->scratch_ages[header.scratch.reg], sizeof(u32))) { |
748 | return DRM_ERR(EINVAL); | 748 | return -EINVAL; |
749 | } | 749 | } |
750 | 750 | ||
751 | if (DRM_COPY_FROM_USER(&h_pending, ref_age_base + buf_idx + 1, sizeof(u32))) { | 751 | if (DRM_COPY_FROM_USER(&h_pending, ref_age_base + buf_idx + 1, sizeof(u32))) { |
752 | return DRM_ERR(EINVAL); | 752 | return -EINVAL; |
753 | } | 753 | } |
754 | 754 | ||
755 | if (h_pending == 0) { | 755 | if (h_pending == 0) { |
756 | return DRM_ERR(EINVAL); | 756 | return -EINVAL; |
757 | } | 757 | } |
758 | 758 | ||
759 | h_pending--; | 759 | h_pending--; |
760 | 760 | ||
761 | if (DRM_COPY_TO_USER(ref_age_base + buf_idx + 1, &h_pending, sizeof(u32))) { | 761 | if (DRM_COPY_TO_USER(ref_age_base + buf_idx + 1, &h_pending, sizeof(u32))) { |
762 | return DRM_ERR(EINVAL); | 762 | return -EINVAL; |
763 | } | 763 | } |
764 | 764 | ||
765 | cmdbuf->buf += sizeof(buf_idx); | 765 | cmdbuf->buf += sizeof(buf_idx); |
@@ -879,7 +879,7 @@ int r300_do_cp_cmdbuf(struct drm_device *dev, | |||
879 | if (idx < 0 || idx >= dma->buf_count) { | 879 | if (idx < 0 || idx >= dma->buf_count) { |
880 | DRM_ERROR("buffer index %d (of %d max)\n", | 880 | DRM_ERROR("buffer index %d (of %d max)\n", |
881 | idx, dma->buf_count - 1); | 881 | idx, dma->buf_count - 1); |
882 | ret = DRM_ERR(EINVAL); | 882 | ret = -EINVAL; |
883 | goto cleanup; | 883 | goto cleanup; |
884 | } | 884 | } |
885 | 885 | ||
@@ -887,7 +887,7 @@ int r300_do_cp_cmdbuf(struct drm_device *dev, | |||
887 | if (buf->filp != filp || buf->pending) { | 887 | if (buf->filp != filp || buf->pending) { |
888 | DRM_ERROR("bad buffer %p %p %d\n", | 888 | DRM_ERROR("bad buffer %p %p %d\n", |
889 | buf->filp, filp, buf->pending); | 889 | buf->filp, filp, buf->pending); |
890 | ret = DRM_ERR(EINVAL); | 890 | ret = -EINVAL; |
891 | goto cleanup; | 891 | goto cleanup; |
892 | } | 892 | } |
893 | 893 | ||
@@ -924,7 +924,7 @@ int r300_do_cp_cmdbuf(struct drm_device *dev, | |||
924 | DRM_ERROR("bad cmd_type %i at %p\n", | 924 | DRM_ERROR("bad cmd_type %i at %p\n", |
925 | header.header.cmd_type, | 925 | header.header.cmd_type, |
926 | cmdbuf->buf - sizeof(header)); | 926 | cmdbuf->buf - sizeof(header)); |
927 | ret = DRM_ERR(EINVAL); | 927 | ret = -EINVAL; |
928 | goto cleanup; | 928 | goto cleanup; |
929 | } | 929 | } |
930 | } | 930 | } |