diff options
Diffstat (limited to 'drivers/char/drm/savage_state.c')
-rw-r--r-- | drivers/char/drm/savage_state.c | 200 |
1 files changed, 99 insertions, 101 deletions
diff --git a/drivers/char/drm/savage_state.c b/drivers/char/drm/savage_state.c index 77497841478a..bf8e0e10fe21 100644 --- a/drivers/char/drm/savage_state.c +++ b/drivers/char/drm/savage_state.c | |||
@@ -83,7 +83,7 @@ static int savage_verify_texaddr(drm_savage_private_t * dev_priv, int unit, | |||
83 | { | 83 | { |
84 | if ((addr & 6) != 2) { /* reserved bits */ | 84 | if ((addr & 6) != 2) { /* reserved bits */ |
85 | DRM_ERROR("bad texAddr%d %08x (reserved bits)\n", unit, addr); | 85 | DRM_ERROR("bad texAddr%d %08x (reserved bits)\n", unit, addr); |
86 | return DRM_ERR(EINVAL); | 86 | return -EINVAL; |
87 | } | 87 | } |
88 | if (!(addr & 1)) { /* local */ | 88 | if (!(addr & 1)) { /* local */ |
89 | addr &= ~7; | 89 | addr &= ~7; |
@@ -92,13 +92,13 @@ static int savage_verify_texaddr(drm_savage_private_t * dev_priv, int unit, | |||
92 | DRM_ERROR | 92 | DRM_ERROR |
93 | ("bad texAddr%d %08x (local addr out of range)\n", | 93 | ("bad texAddr%d %08x (local addr out of range)\n", |
94 | unit, addr); | 94 | unit, addr); |
95 | return DRM_ERR(EINVAL); | 95 | return -EINVAL; |
96 | } | 96 | } |
97 | } else { /* AGP */ | 97 | } else { /* AGP */ |
98 | if (!dev_priv->agp_textures) { | 98 | if (!dev_priv->agp_textures) { |
99 | DRM_ERROR("bad texAddr%d %08x (AGP not available)\n", | 99 | DRM_ERROR("bad texAddr%d %08x (AGP not available)\n", |
100 | unit, addr); | 100 | unit, addr); |
101 | return DRM_ERR(EINVAL); | 101 | return -EINVAL; |
102 | } | 102 | } |
103 | addr &= ~7; | 103 | addr &= ~7; |
104 | if (addr < dev_priv->agp_textures->offset || | 104 | if (addr < dev_priv->agp_textures->offset || |
@@ -107,7 +107,7 @@ static int savage_verify_texaddr(drm_savage_private_t * dev_priv, int unit, | |||
107 | DRM_ERROR | 107 | DRM_ERROR |
108 | ("bad texAddr%d %08x (AGP addr out of range)\n", | 108 | ("bad texAddr%d %08x (AGP addr out of range)\n", |
109 | unit, addr); | 109 | unit, addr); |
110 | return DRM_ERR(EINVAL); | 110 | return -EINVAL; |
111 | } | 111 | } |
112 | } | 112 | } |
113 | return 0; | 113 | return 0; |
@@ -133,7 +133,7 @@ static int savage_verify_state_s3d(drm_savage_private_t * dev_priv, | |||
133 | start + count - 1 > SAVAGE_DESTTEXRWWATERMARK_S3D) { | 133 | start + count - 1 > SAVAGE_DESTTEXRWWATERMARK_S3D) { |
134 | DRM_ERROR("invalid register range (0x%04x-0x%04x)\n", | 134 | DRM_ERROR("invalid register range (0x%04x-0x%04x)\n", |
135 | start, start + count - 1); | 135 | start, start + count - 1); |
136 | return DRM_ERR(EINVAL); | 136 | return -EINVAL; |
137 | } | 137 | } |
138 | 138 | ||
139 | SAVE_STATE_MASK(SAVAGE_SCSTART_S3D, s3d.new_scstart, | 139 | SAVE_STATE_MASK(SAVAGE_SCSTART_S3D, s3d.new_scstart, |
@@ -165,7 +165,7 @@ static int savage_verify_state_s4(drm_savage_private_t * dev_priv, | |||
165 | start + count - 1 > SAVAGE_TEXBLENDCOLOR_S4) { | 165 | start + count - 1 > SAVAGE_TEXBLENDCOLOR_S4) { |
166 | DRM_ERROR("invalid register range (0x%04x-0x%04x)\n", | 166 | DRM_ERROR("invalid register range (0x%04x-0x%04x)\n", |
167 | start, start + count - 1); | 167 | start, start + count - 1); |
168 | return DRM_ERR(EINVAL); | 168 | return -EINVAL; |
169 | } | 169 | } |
170 | 170 | ||
171 | SAVE_STATE_MASK(SAVAGE_DRAWCTRL0_S4, s4.new_drawctrl0, | 171 | SAVE_STATE_MASK(SAVAGE_DRAWCTRL0_S4, s4.new_drawctrl0, |
@@ -289,7 +289,7 @@ static int savage_dispatch_dma_prim(drm_savage_private_t * dev_priv, | |||
289 | 289 | ||
290 | if (!dmabuf) { | 290 | if (!dmabuf) { |
291 | DRM_ERROR("called without dma buffers!\n"); | 291 | DRM_ERROR("called without dma buffers!\n"); |
292 | return DRM_ERR(EINVAL); | 292 | return -EINVAL; |
293 | } | 293 | } |
294 | 294 | ||
295 | if (!n) | 295 | if (!n) |
@@ -303,7 +303,7 @@ static int savage_dispatch_dma_prim(drm_savage_private_t * dev_priv, | |||
303 | if (n % 3 != 0) { | 303 | if (n % 3 != 0) { |
304 | DRM_ERROR("wrong number of vertices %u in TRILIST\n", | 304 | DRM_ERROR("wrong number of vertices %u in TRILIST\n", |
305 | n); | 305 | n); |
306 | return DRM_ERR(EINVAL); | 306 | return -EINVAL; |
307 | } | 307 | } |
308 | break; | 308 | break; |
309 | case SAVAGE_PRIM_TRISTRIP: | 309 | case SAVAGE_PRIM_TRISTRIP: |
@@ -312,18 +312,18 @@ static int savage_dispatch_dma_prim(drm_savage_private_t * dev_priv, | |||
312 | DRM_ERROR | 312 | DRM_ERROR |
313 | ("wrong number of vertices %u in TRIFAN/STRIP\n", | 313 | ("wrong number of vertices %u in TRIFAN/STRIP\n", |
314 | n); | 314 | n); |
315 | return DRM_ERR(EINVAL); | 315 | return -EINVAL; |
316 | } | 316 | } |
317 | break; | 317 | break; |
318 | default: | 318 | default: |
319 | DRM_ERROR("invalid primitive type %u\n", prim); | 319 | DRM_ERROR("invalid primitive type %u\n", prim); |
320 | return DRM_ERR(EINVAL); | 320 | return -EINVAL; |
321 | } | 321 | } |
322 | 322 | ||
323 | if (S3_SAVAGE3D_SERIES(dev_priv->chipset)) { | 323 | if (S3_SAVAGE3D_SERIES(dev_priv->chipset)) { |
324 | if (skip != 0) { | 324 | if (skip != 0) { |
325 | DRM_ERROR("invalid skip flags 0x%04x for DMA\n", skip); | 325 | DRM_ERROR("invalid skip flags 0x%04x for DMA\n", skip); |
326 | return DRM_ERR(EINVAL); | 326 | return -EINVAL; |
327 | } | 327 | } |
328 | } else { | 328 | } else { |
329 | unsigned int size = 10 - (skip & 1) - (skip >> 1 & 1) - | 329 | unsigned int size = 10 - (skip & 1) - (skip >> 1 & 1) - |
@@ -331,18 +331,18 @@ static int savage_dispatch_dma_prim(drm_savage_private_t * dev_priv, | |||
331 | (skip >> 5 & 1) - (skip >> 6 & 1) - (skip >> 7 & 1); | 331 | (skip >> 5 & 1) - (skip >> 6 & 1) - (skip >> 7 & 1); |
332 | if (skip > SAVAGE_SKIP_ALL_S4 || size != 8) { | 332 | if (skip > SAVAGE_SKIP_ALL_S4 || size != 8) { |
333 | DRM_ERROR("invalid skip flags 0x%04x for DMA\n", skip); | 333 | DRM_ERROR("invalid skip flags 0x%04x for DMA\n", skip); |
334 | return DRM_ERR(EINVAL); | 334 | return -EINVAL; |
335 | } | 335 | } |
336 | if (reorder) { | 336 | if (reorder) { |
337 | DRM_ERROR("TRILIST_201 used on Savage4 hardware\n"); | 337 | DRM_ERROR("TRILIST_201 used on Savage4 hardware\n"); |
338 | return DRM_ERR(EINVAL); | 338 | return -EINVAL; |
339 | } | 339 | } |
340 | } | 340 | } |
341 | 341 | ||
342 | if (start + n > dmabuf->total / 32) { | 342 | if (start + n > dmabuf->total / 32) { |
343 | DRM_ERROR("vertex indices (%u-%u) out of range (0-%u)\n", | 343 | DRM_ERROR("vertex indices (%u-%u) out of range (0-%u)\n", |
344 | start, start + n - 1, dmabuf->total / 32); | 344 | start, start + n - 1, dmabuf->total / 32); |
345 | return DRM_ERR(EINVAL); | 345 | return -EINVAL; |
346 | } | 346 | } |
347 | 347 | ||
348 | /* Vertex DMA doesn't work with command DMA at the same time, | 348 | /* Vertex DMA doesn't work with command DMA at the same time, |
@@ -440,7 +440,7 @@ static int savage_dispatch_vb_prim(drm_savage_private_t * dev_priv, | |||
440 | if (n % 3 != 0) { | 440 | if (n % 3 != 0) { |
441 | DRM_ERROR("wrong number of vertices %u in TRILIST\n", | 441 | DRM_ERROR("wrong number of vertices %u in TRILIST\n", |
442 | n); | 442 | n); |
443 | return DRM_ERR(EINVAL); | 443 | return -EINVAL; |
444 | } | 444 | } |
445 | break; | 445 | break; |
446 | case SAVAGE_PRIM_TRISTRIP: | 446 | case SAVAGE_PRIM_TRISTRIP: |
@@ -449,24 +449,24 @@ static int savage_dispatch_vb_prim(drm_savage_private_t * dev_priv, | |||
449 | DRM_ERROR | 449 | DRM_ERROR |
450 | ("wrong number of vertices %u in TRIFAN/STRIP\n", | 450 | ("wrong number of vertices %u in TRIFAN/STRIP\n", |
451 | n); | 451 | n); |
452 | return DRM_ERR(EINVAL); | 452 | return -EINVAL; |
453 | } | 453 | } |
454 | break; | 454 | break; |
455 | default: | 455 | default: |
456 | DRM_ERROR("invalid primitive type %u\n", prim); | 456 | DRM_ERROR("invalid primitive type %u\n", prim); |
457 | return DRM_ERR(EINVAL); | 457 | return -EINVAL; |
458 | } | 458 | } |
459 | 459 | ||
460 | if (S3_SAVAGE3D_SERIES(dev_priv->chipset)) { | 460 | if (S3_SAVAGE3D_SERIES(dev_priv->chipset)) { |
461 | if (skip > SAVAGE_SKIP_ALL_S3D) { | 461 | if (skip > SAVAGE_SKIP_ALL_S3D) { |
462 | DRM_ERROR("invalid skip flags 0x%04x\n", skip); | 462 | DRM_ERROR("invalid skip flags 0x%04x\n", skip); |
463 | return DRM_ERR(EINVAL); | 463 | return -EINVAL; |
464 | } | 464 | } |
465 | vtx_size = 8; /* full vertex */ | 465 | vtx_size = 8; /* full vertex */ |
466 | } else { | 466 | } else { |
467 | if (skip > SAVAGE_SKIP_ALL_S4) { | 467 | if (skip > SAVAGE_SKIP_ALL_S4) { |
468 | DRM_ERROR("invalid skip flags 0x%04x\n", skip); | 468 | DRM_ERROR("invalid skip flags 0x%04x\n", skip); |
469 | return DRM_ERR(EINVAL); | 469 | return -EINVAL; |
470 | } | 470 | } |
471 | vtx_size = 10; /* full vertex */ | 471 | vtx_size = 10; /* full vertex */ |
472 | } | 472 | } |
@@ -478,13 +478,13 @@ static int savage_dispatch_vb_prim(drm_savage_private_t * dev_priv, | |||
478 | if (vtx_size > vb_stride) { | 478 | if (vtx_size > vb_stride) { |
479 | DRM_ERROR("vertex size greater than vb stride (%u > %u)\n", | 479 | DRM_ERROR("vertex size greater than vb stride (%u > %u)\n", |
480 | vtx_size, vb_stride); | 480 | vtx_size, vb_stride); |
481 | return DRM_ERR(EINVAL); | 481 | return -EINVAL; |
482 | } | 482 | } |
483 | 483 | ||
484 | if (start + n > vb_size / (vb_stride * 4)) { | 484 | if (start + n > vb_size / (vb_stride * 4)) { |
485 | DRM_ERROR("vertex indices (%u-%u) out of range (0-%u)\n", | 485 | DRM_ERROR("vertex indices (%u-%u) out of range (0-%u)\n", |
486 | start, start + n - 1, vb_size / (vb_stride * 4)); | 486 | start, start + n - 1, vb_size / (vb_stride * 4)); |
487 | return DRM_ERR(EINVAL); | 487 | return -EINVAL; |
488 | } | 488 | } |
489 | 489 | ||
490 | prim <<= 25; | 490 | prim <<= 25; |
@@ -547,7 +547,7 @@ static int savage_dispatch_dma_idx(drm_savage_private_t * dev_priv, | |||
547 | 547 | ||
548 | if (!dmabuf) { | 548 | if (!dmabuf) { |
549 | DRM_ERROR("called without dma buffers!\n"); | 549 | DRM_ERROR("called without dma buffers!\n"); |
550 | return DRM_ERR(EINVAL); | 550 | return -EINVAL; |
551 | } | 551 | } |
552 | 552 | ||
553 | if (!n) | 553 | if (!n) |
@@ -560,7 +560,7 @@ static int savage_dispatch_dma_idx(drm_savage_private_t * dev_priv, | |||
560 | case SAVAGE_PRIM_TRILIST: | 560 | case SAVAGE_PRIM_TRILIST: |
561 | if (n % 3 != 0) { | 561 | if (n % 3 != 0) { |
562 | DRM_ERROR("wrong number of indices %u in TRILIST\n", n); | 562 | DRM_ERROR("wrong number of indices %u in TRILIST\n", n); |
563 | return DRM_ERR(EINVAL); | 563 | return -EINVAL; |
564 | } | 564 | } |
565 | break; | 565 | break; |
566 | case SAVAGE_PRIM_TRISTRIP: | 566 | case SAVAGE_PRIM_TRISTRIP: |
@@ -568,18 +568,18 @@ static int savage_dispatch_dma_idx(drm_savage_private_t * dev_priv, | |||
568 | if (n < 3) { | 568 | if (n < 3) { |
569 | DRM_ERROR | 569 | DRM_ERROR |
570 | ("wrong number of indices %u in TRIFAN/STRIP\n", n); | 570 | ("wrong number of indices %u in TRIFAN/STRIP\n", n); |
571 | return DRM_ERR(EINVAL); | 571 | return -EINVAL; |
572 | } | 572 | } |
573 | break; | 573 | break; |
574 | default: | 574 | default: |
575 | DRM_ERROR("invalid primitive type %u\n", prim); | 575 | DRM_ERROR("invalid primitive type %u\n", prim); |
576 | return DRM_ERR(EINVAL); | 576 | return -EINVAL; |
577 | } | 577 | } |
578 | 578 | ||
579 | if (S3_SAVAGE3D_SERIES(dev_priv->chipset)) { | 579 | if (S3_SAVAGE3D_SERIES(dev_priv->chipset)) { |
580 | if (skip != 0) { | 580 | if (skip != 0) { |
581 | DRM_ERROR("invalid skip flags 0x%04x for DMA\n", skip); | 581 | DRM_ERROR("invalid skip flags 0x%04x for DMA\n", skip); |
582 | return DRM_ERR(EINVAL); | 582 | return -EINVAL; |
583 | } | 583 | } |
584 | } else { | 584 | } else { |
585 | unsigned int size = 10 - (skip & 1) - (skip >> 1 & 1) - | 585 | unsigned int size = 10 - (skip & 1) - (skip >> 1 & 1) - |
@@ -587,11 +587,11 @@ static int savage_dispatch_dma_idx(drm_savage_private_t * dev_priv, | |||
587 | (skip >> 5 & 1) - (skip >> 6 & 1) - (skip >> 7 & 1); | 587 | (skip >> 5 & 1) - (skip >> 6 & 1) - (skip >> 7 & 1); |
588 | if (skip > SAVAGE_SKIP_ALL_S4 || size != 8) { | 588 | if (skip > SAVAGE_SKIP_ALL_S4 || size != 8) { |
589 | DRM_ERROR("invalid skip flags 0x%04x for DMA\n", skip); | 589 | DRM_ERROR("invalid skip flags 0x%04x for DMA\n", skip); |
590 | return DRM_ERR(EINVAL); | 590 | return -EINVAL; |
591 | } | 591 | } |
592 | if (reorder) { | 592 | if (reorder) { |
593 | DRM_ERROR("TRILIST_201 used on Savage4 hardware\n"); | 593 | DRM_ERROR("TRILIST_201 used on Savage4 hardware\n"); |
594 | return DRM_ERR(EINVAL); | 594 | return -EINVAL; |
595 | } | 595 | } |
596 | } | 596 | } |
597 | 597 | ||
@@ -628,7 +628,7 @@ static int savage_dispatch_dma_idx(drm_savage_private_t * dev_priv, | |||
628 | if (idx[i] > dmabuf->total / 32) { | 628 | if (idx[i] > dmabuf->total / 32) { |
629 | DRM_ERROR("idx[%u]=%u out of range (0-%u)\n", | 629 | DRM_ERROR("idx[%u]=%u out of range (0-%u)\n", |
630 | i, idx[i], dmabuf->total / 32); | 630 | i, idx[i], dmabuf->total / 32); |
631 | return DRM_ERR(EINVAL); | 631 | return -EINVAL; |
632 | } | 632 | } |
633 | } | 633 | } |
634 | 634 | ||
@@ -698,7 +698,7 @@ static int savage_dispatch_vb_idx(drm_savage_private_t * dev_priv, | |||
698 | case SAVAGE_PRIM_TRILIST: | 698 | case SAVAGE_PRIM_TRILIST: |
699 | if (n % 3 != 0) { | 699 | if (n % 3 != 0) { |
700 | DRM_ERROR("wrong number of indices %u in TRILIST\n", n); | 700 | DRM_ERROR("wrong number of indices %u in TRILIST\n", n); |
701 | return DRM_ERR(EINVAL); | 701 | return -EINVAL; |
702 | } | 702 | } |
703 | break; | 703 | break; |
704 | case SAVAGE_PRIM_TRISTRIP: | 704 | case SAVAGE_PRIM_TRISTRIP: |
@@ -706,24 +706,24 @@ static int savage_dispatch_vb_idx(drm_savage_private_t * dev_priv, | |||
706 | if (n < 3) { | 706 | if (n < 3) { |
707 | DRM_ERROR | 707 | DRM_ERROR |
708 | ("wrong number of indices %u in TRIFAN/STRIP\n", n); | 708 | ("wrong number of indices %u in TRIFAN/STRIP\n", n); |
709 | return DRM_ERR(EINVAL); | 709 | return -EINVAL; |
710 | } | 710 | } |
711 | break; | 711 | break; |
712 | default: | 712 | default: |
713 | DRM_ERROR("invalid primitive type %u\n", prim); | 713 | DRM_ERROR("invalid primitive type %u\n", prim); |
714 | return DRM_ERR(EINVAL); | 714 | return -EINVAL; |
715 | } | 715 | } |
716 | 716 | ||
717 | if (S3_SAVAGE3D_SERIES(dev_priv->chipset)) { | 717 | if (S3_SAVAGE3D_SERIES(dev_priv->chipset)) { |
718 | if (skip > SAVAGE_SKIP_ALL_S3D) { | 718 | if (skip > SAVAGE_SKIP_ALL_S3D) { |
719 | DRM_ERROR("invalid skip flags 0x%04x\n", skip); | 719 | DRM_ERROR("invalid skip flags 0x%04x\n", skip); |
720 | return DRM_ERR(EINVAL); | 720 | return -EINVAL; |
721 | } | 721 | } |
722 | vtx_size = 8; /* full vertex */ | 722 | vtx_size = 8; /* full vertex */ |
723 | } else { | 723 | } else { |
724 | if (skip > SAVAGE_SKIP_ALL_S4) { | 724 | if (skip > SAVAGE_SKIP_ALL_S4) { |
725 | DRM_ERROR("invalid skip flags 0x%04x\n", skip); | 725 | DRM_ERROR("invalid skip flags 0x%04x\n", skip); |
726 | return DRM_ERR(EINVAL); | 726 | return -EINVAL; |
727 | } | 727 | } |
728 | vtx_size = 10; /* full vertex */ | 728 | vtx_size = 10; /* full vertex */ |
729 | } | 729 | } |
@@ -735,7 +735,7 @@ static int savage_dispatch_vb_idx(drm_savage_private_t * dev_priv, | |||
735 | if (vtx_size > vb_stride) { | 735 | if (vtx_size > vb_stride) { |
736 | DRM_ERROR("vertex size greater than vb stride (%u > %u)\n", | 736 | DRM_ERROR("vertex size greater than vb stride (%u > %u)\n", |
737 | vtx_size, vb_stride); | 737 | vtx_size, vb_stride); |
738 | return DRM_ERR(EINVAL); | 738 | return -EINVAL; |
739 | } | 739 | } |
740 | 740 | ||
741 | prim <<= 25; | 741 | prim <<= 25; |
@@ -748,7 +748,7 @@ static int savage_dispatch_vb_idx(drm_savage_private_t * dev_priv, | |||
748 | if (idx[i] > vb_size / (vb_stride * 4)) { | 748 | if (idx[i] > vb_size / (vb_stride * 4)) { |
749 | DRM_ERROR("idx[%u]=%u out of range (0-%u)\n", | 749 | DRM_ERROR("idx[%u]=%u out of range (0-%u)\n", |
750 | i, idx[i], vb_size / (vb_stride * 4)); | 750 | i, idx[i], vb_size / (vb_stride * 4)); |
751 | return DRM_ERR(EINVAL); | 751 | return -EINVAL; |
752 | } | 752 | } |
753 | } | 753 | } |
754 | 754 | ||
@@ -942,7 +942,7 @@ static int savage_dispatch_draw(drm_savage_private_t * dev_priv, | |||
942 | DRM_ERROR("IMPLEMENTATION ERROR: " | 942 | DRM_ERROR("IMPLEMENTATION ERROR: " |
943 | "non-drawing-command %d\n", | 943 | "non-drawing-command %d\n", |
944 | cmd_header.cmd.cmd); | 944 | cmd_header.cmd.cmd); |
945 | return DRM_ERR(EINVAL); | 945 | return -EINVAL; |
946 | } | 946 | } |
947 | 947 | ||
948 | if (ret != 0) | 948 | if (ret != 0) |
@@ -953,13 +953,12 @@ static int savage_dispatch_draw(drm_savage_private_t * dev_priv, | |||
953 | return 0; | 953 | return 0; |
954 | } | 954 | } |
955 | 955 | ||
956 | int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | 956 | int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_priv) |
957 | { | 957 | { |
958 | DRM_DEVICE; | ||
959 | drm_savage_private_t *dev_priv = dev->dev_private; | 958 | drm_savage_private_t *dev_priv = dev->dev_private; |
960 | struct drm_device_dma *dma = dev->dma; | 959 | struct drm_device_dma *dma = dev->dma; |
961 | struct drm_buf *dmabuf; | 960 | struct drm_buf *dmabuf; |
962 | drm_savage_cmdbuf_t cmdbuf; | 961 | drm_savage_cmdbuf_t *cmdbuf = data; |
963 | drm_savage_cmd_header_t *kcmd_addr = NULL; | 962 | drm_savage_cmd_header_t *kcmd_addr = NULL; |
964 | drm_savage_cmd_header_t *first_draw_cmd; | 963 | drm_savage_cmd_header_t *first_draw_cmd; |
965 | unsigned int *kvb_addr = NULL; | 964 | unsigned int *kvb_addr = NULL; |
@@ -969,19 +968,16 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | |||
969 | 968 | ||
970 | DRM_DEBUG("\n"); | 969 | DRM_DEBUG("\n"); |
971 | 970 | ||
972 | LOCK_TEST_WITH_RETURN(dev, filp); | 971 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
973 | |||
974 | DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_savage_cmdbuf_t __user *) data, | ||
975 | sizeof(cmdbuf)); | ||
976 | 972 | ||
977 | if (dma && dma->buflist) { | 973 | if (dma && dma->buflist) { |
978 | if (cmdbuf.dma_idx > dma->buf_count) { | 974 | if (cmdbuf->dma_idx > dma->buf_count) { |
979 | DRM_ERROR | 975 | DRM_ERROR |
980 | ("vertex buffer index %u out of range (0-%u)\n", | 976 | ("vertex buffer index %u out of range (0-%u)\n", |
981 | cmdbuf.dma_idx, dma->buf_count - 1); | 977 | cmdbuf->dma_idx, dma->buf_count - 1); |
982 | return DRM_ERR(EINVAL); | 978 | return -EINVAL; |
983 | } | 979 | } |
984 | dmabuf = dma->buflist[cmdbuf.dma_idx]; | 980 | dmabuf = dma->buflist[cmdbuf->dma_idx]; |
985 | } else { | 981 | } else { |
986 | dmabuf = NULL; | 982 | dmabuf = NULL; |
987 | } | 983 | } |
@@ -991,47 +987,47 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | |||
991 | * COPY_FROM_USER_UNCHECKED when done in other drivers, and is correct | 987 | * COPY_FROM_USER_UNCHECKED when done in other drivers, and is correct |
992 | * for locking on FreeBSD. | 988 | * for locking on FreeBSD. |
993 | */ | 989 | */ |
994 | if (cmdbuf.size) { | 990 | if (cmdbuf->size) { |
995 | kcmd_addr = drm_alloc(cmdbuf.size * 8, DRM_MEM_DRIVER); | 991 | kcmd_addr = drm_alloc(cmdbuf->size * 8, DRM_MEM_DRIVER); |
996 | if (kcmd_addr == NULL) | 992 | if (kcmd_addr == NULL) |
997 | return DRM_ERR(ENOMEM); | 993 | return -ENOMEM; |
998 | 994 | ||
999 | if (DRM_COPY_FROM_USER(kcmd_addr, cmdbuf.cmd_addr, | 995 | if (DRM_COPY_FROM_USER(kcmd_addr, cmdbuf->cmd_addr, |
1000 | cmdbuf.size * 8)) | 996 | cmdbuf->size * 8)) |
1001 | { | 997 | { |
1002 | drm_free(kcmd_addr, cmdbuf.size * 8, DRM_MEM_DRIVER); | 998 | drm_free(kcmd_addr, cmdbuf->size * 8, DRM_MEM_DRIVER); |
1003 | return DRM_ERR(EFAULT); | 999 | return -EFAULT; |
1004 | } | 1000 | } |
1005 | cmdbuf.cmd_addr = kcmd_addr; | 1001 | cmdbuf->cmd_addr = kcmd_addr; |
1006 | } | 1002 | } |
1007 | if (cmdbuf.vb_size) { | 1003 | if (cmdbuf->vb_size) { |
1008 | kvb_addr = drm_alloc(cmdbuf.vb_size, DRM_MEM_DRIVER); | 1004 | kvb_addr = drm_alloc(cmdbuf->vb_size, DRM_MEM_DRIVER); |
1009 | if (kvb_addr == NULL) { | 1005 | if (kvb_addr == NULL) { |
1010 | ret = DRM_ERR(ENOMEM); | 1006 | ret = -ENOMEM; |
1011 | goto done; | 1007 | goto done; |
1012 | } | 1008 | } |
1013 | 1009 | ||
1014 | if (DRM_COPY_FROM_USER(kvb_addr, cmdbuf.vb_addr, | 1010 | if (DRM_COPY_FROM_USER(kvb_addr, cmdbuf->vb_addr, |
1015 | cmdbuf.vb_size)) { | 1011 | cmdbuf->vb_size)) { |
1016 | ret = DRM_ERR(EFAULT); | 1012 | ret = -EFAULT; |
1017 | goto done; | 1013 | goto done; |
1018 | } | 1014 | } |
1019 | cmdbuf.vb_addr = kvb_addr; | 1015 | cmdbuf->vb_addr = kvb_addr; |
1020 | } | 1016 | } |
1021 | if (cmdbuf.nbox) { | 1017 | if (cmdbuf->nbox) { |
1022 | kbox_addr = drm_alloc(cmdbuf.nbox * sizeof(struct drm_clip_rect), | 1018 | kbox_addr = drm_alloc(cmdbuf->nbox * sizeof(struct drm_clip_rect), |
1023 | DRM_MEM_DRIVER); | 1019 | DRM_MEM_DRIVER); |
1024 | if (kbox_addr == NULL) { | 1020 | if (kbox_addr == NULL) { |
1025 | ret = DRM_ERR(ENOMEM); | 1021 | ret = -ENOMEM; |
1026 | goto done; | 1022 | goto done; |
1027 | } | 1023 | } |
1028 | 1024 | ||
1029 | if (DRM_COPY_FROM_USER(kbox_addr, cmdbuf.box_addr, | 1025 | if (DRM_COPY_FROM_USER(kbox_addr, cmdbuf->box_addr, |
1030 | cmdbuf.nbox * sizeof(struct drm_clip_rect))) { | 1026 | cmdbuf->nbox * sizeof(struct drm_clip_rect))) { |
1031 | ret = DRM_ERR(EFAULT); | 1027 | ret = -EFAULT; |
1032 | goto done; | 1028 | goto done; |
1033 | } | 1029 | } |
1034 | cmdbuf.box_addr = kbox_addr; | 1030 | cmdbuf->box_addr = kbox_addr; |
1035 | } | 1031 | } |
1036 | 1032 | ||
1037 | /* Make sure writes to DMA buffers are finished before sending | 1033 | /* Make sure writes to DMA buffers are finished before sending |
@@ -1044,10 +1040,10 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | |||
1044 | 1040 | ||
1045 | i = 0; | 1041 | i = 0; |
1046 | first_draw_cmd = NULL; | 1042 | first_draw_cmd = NULL; |
1047 | while (i < cmdbuf.size) { | 1043 | while (i < cmdbuf->size) { |
1048 | drm_savage_cmd_header_t cmd_header; | 1044 | drm_savage_cmd_header_t cmd_header; |
1049 | cmd_header = *(drm_savage_cmd_header_t *)cmdbuf.cmd_addr; | 1045 | cmd_header = *(drm_savage_cmd_header_t *)cmdbuf->cmd_addr; |
1050 | cmdbuf.cmd_addr++; | 1046 | cmdbuf->cmd_addr++; |
1051 | i++; | 1047 | i++; |
1052 | 1048 | ||
1053 | /* Group drawing commands with same state to minimize | 1049 | /* Group drawing commands with same state to minimize |
@@ -1057,28 +1053,28 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | |||
1057 | case SAVAGE_CMD_DMA_IDX: | 1053 | case SAVAGE_CMD_DMA_IDX: |
1058 | case SAVAGE_CMD_VB_IDX: | 1054 | case SAVAGE_CMD_VB_IDX: |
1059 | j = (cmd_header.idx.count + 3) / 4; | 1055 | j = (cmd_header.idx.count + 3) / 4; |
1060 | if (i + j > cmdbuf.size) { | 1056 | if (i + j > cmdbuf->size) { |
1061 | DRM_ERROR("indexed drawing command extends " | 1057 | DRM_ERROR("indexed drawing command extends " |
1062 | "beyond end of command buffer\n"); | 1058 | "beyond end of command buffer\n"); |
1063 | DMA_FLUSH(); | 1059 | DMA_FLUSH(); |
1064 | return DRM_ERR(EINVAL); | 1060 | return -EINVAL; |
1065 | } | 1061 | } |
1066 | /* fall through */ | 1062 | /* fall through */ |
1067 | case SAVAGE_CMD_DMA_PRIM: | 1063 | case SAVAGE_CMD_DMA_PRIM: |
1068 | case SAVAGE_CMD_VB_PRIM: | 1064 | case SAVAGE_CMD_VB_PRIM: |
1069 | if (!first_draw_cmd) | 1065 | if (!first_draw_cmd) |
1070 | first_draw_cmd = cmdbuf.cmd_addr - 1; | 1066 | first_draw_cmd = cmdbuf->cmd_addr - 1; |
1071 | cmdbuf.cmd_addr += j; | 1067 | cmdbuf->cmd_addr += j; |
1072 | i += j; | 1068 | i += j; |
1073 | break; | 1069 | break; |
1074 | default: | 1070 | default: |
1075 | if (first_draw_cmd) { | 1071 | if (first_draw_cmd) { |
1076 | ret = savage_dispatch_draw( | 1072 | ret = savage_dispatch_draw( |
1077 | dev_priv, first_draw_cmd, | 1073 | dev_priv, first_draw_cmd, |
1078 | cmdbuf.cmd_addr - 1, | 1074 | cmdbuf->cmd_addr - 1, |
1079 | dmabuf, cmdbuf.vb_addr, cmdbuf.vb_size, | 1075 | dmabuf, cmdbuf->vb_addr, cmdbuf->vb_size, |
1080 | cmdbuf.vb_stride, | 1076 | cmdbuf->vb_stride, |
1081 | cmdbuf.nbox, cmdbuf.box_addr); | 1077 | cmdbuf->nbox, cmdbuf->box_addr); |
1082 | if (ret != 0) | 1078 | if (ret != 0) |
1083 | return ret; | 1079 | return ret; |
1084 | first_draw_cmd = NULL; | 1080 | first_draw_cmd = NULL; |
@@ -1090,40 +1086,42 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | |||
1090 | switch (cmd_header.cmd.cmd) { | 1086 | switch (cmd_header.cmd.cmd) { |
1091 | case SAVAGE_CMD_STATE: | 1087 | case SAVAGE_CMD_STATE: |
1092 | j = (cmd_header.state.count + 1) / 2; | 1088 | j = (cmd_header.state.count + 1) / 2; |
1093 | if (i + j > cmdbuf.size) { | 1089 | if (i + j > cmdbuf->size) { |
1094 | DRM_ERROR("command SAVAGE_CMD_STATE extends " | 1090 | DRM_ERROR("command SAVAGE_CMD_STATE extends " |
1095 | "beyond end of command buffer\n"); | 1091 | "beyond end of command buffer\n"); |
1096 | DMA_FLUSH(); | 1092 | DMA_FLUSH(); |
1097 | ret = DRM_ERR(EINVAL); | 1093 | ret = -EINVAL; |
1098 | goto done; | 1094 | goto done; |
1099 | } | 1095 | } |
1100 | ret = savage_dispatch_state(dev_priv, &cmd_header, | 1096 | ret = savage_dispatch_state(dev_priv, &cmd_header, |
1101 | (const uint32_t *)cmdbuf.cmd_addr); | 1097 | (const uint32_t *)cmdbuf->cmd_addr); |
1102 | cmdbuf.cmd_addr += j; | 1098 | cmdbuf->cmd_addr += j; |
1103 | i += j; | 1099 | i += j; |
1104 | break; | 1100 | break; |
1105 | case SAVAGE_CMD_CLEAR: | 1101 | case SAVAGE_CMD_CLEAR: |
1106 | if (i + 1 > cmdbuf.size) { | 1102 | if (i + 1 > cmdbuf->size) { |
1107 | DRM_ERROR("command SAVAGE_CMD_CLEAR extends " | 1103 | DRM_ERROR("command SAVAGE_CMD_CLEAR extends " |
1108 | "beyond end of command buffer\n"); | 1104 | "beyond end of command buffer\n"); |
1109 | DMA_FLUSH(); | 1105 | DMA_FLUSH(); |
1110 | ret = DRM_ERR(EINVAL); | 1106 | ret = -EINVAL; |
1111 | goto done; | 1107 | goto done; |
1112 | } | 1108 | } |
1113 | ret = savage_dispatch_clear(dev_priv, &cmd_header, | 1109 | ret = savage_dispatch_clear(dev_priv, &cmd_header, |
1114 | cmdbuf.cmd_addr, | 1110 | cmdbuf->cmd_addr, |
1115 | cmdbuf.nbox, cmdbuf.box_addr); | 1111 | cmdbuf->nbox, |
1116 | cmdbuf.cmd_addr++; | 1112 | cmdbuf->box_addr); |
1113 | cmdbuf->cmd_addr++; | ||
1117 | i++; | 1114 | i++; |
1118 | break; | 1115 | break; |
1119 | case SAVAGE_CMD_SWAP: | 1116 | case SAVAGE_CMD_SWAP: |
1120 | ret = savage_dispatch_swap(dev_priv, cmdbuf.nbox, | 1117 | ret = savage_dispatch_swap(dev_priv, cmdbuf->nbox, |
1121 | cmdbuf.box_addr); | 1118 | cmdbuf->box_addr); |
1122 | break; | 1119 | break; |
1123 | default: | 1120 | default: |
1124 | DRM_ERROR("invalid command 0x%x\n", cmd_header.cmd.cmd); | 1121 | DRM_ERROR("invalid command 0x%x\n", |
1122 | cmd_header.cmd.cmd); | ||
1125 | DMA_FLUSH(); | 1123 | DMA_FLUSH(); |
1126 | ret = DRM_ERR(EINVAL); | 1124 | ret = -EINVAL; |
1127 | goto done; | 1125 | goto done; |
1128 | } | 1126 | } |
1129 | 1127 | ||
@@ -1135,9 +1133,9 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | |||
1135 | 1133 | ||
1136 | if (first_draw_cmd) { | 1134 | if (first_draw_cmd) { |
1137 | ret = savage_dispatch_draw ( | 1135 | ret = savage_dispatch_draw ( |
1138 | dev_priv, first_draw_cmd, cmdbuf.cmd_addr, dmabuf, | 1136 | dev_priv, first_draw_cmd, cmdbuf->cmd_addr, dmabuf, |
1139 | cmdbuf.vb_addr, cmdbuf.vb_size, cmdbuf.vb_stride, | 1137 | cmdbuf->vb_addr, cmdbuf->vb_size, cmdbuf->vb_stride, |
1140 | cmdbuf.nbox, cmdbuf.box_addr); | 1138 | cmdbuf->nbox, cmdbuf->box_addr); |
1141 | if (ret != 0) { | 1139 | if (ret != 0) { |
1142 | DMA_FLUSH(); | 1140 | DMA_FLUSH(); |
1143 | goto done; | 1141 | goto done; |
@@ -1146,7 +1144,7 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | |||
1146 | 1144 | ||
1147 | DMA_FLUSH(); | 1145 | DMA_FLUSH(); |
1148 | 1146 | ||
1149 | if (dmabuf && cmdbuf.discard) { | 1147 | if (dmabuf && cmdbuf->discard) { |
1150 | drm_savage_buf_priv_t *buf_priv = dmabuf->dev_private; | 1148 | drm_savage_buf_priv_t *buf_priv = dmabuf->dev_private; |
1151 | uint16_t event; | 1149 | uint16_t event; |
1152 | event = savage_bci_emit_event(dev_priv, SAVAGE_WAIT_3D); | 1150 | event = savage_bci_emit_event(dev_priv, SAVAGE_WAIT_3D); |
@@ -1156,9 +1154,9 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS) | |||
1156 | 1154 | ||
1157 | done: | 1155 | done: |
1158 | /* If we didn't need to allocate them, these'll be NULL */ | 1156 | /* If we didn't need to allocate them, these'll be NULL */ |
1159 | drm_free(kcmd_addr, cmdbuf.size * 8, DRM_MEM_DRIVER); | 1157 | drm_free(kcmd_addr, cmdbuf->size * 8, DRM_MEM_DRIVER); |
1160 | drm_free(kvb_addr, cmdbuf.vb_size, DRM_MEM_DRIVER); | 1158 | drm_free(kvb_addr, cmdbuf->vb_size, DRM_MEM_DRIVER); |
1161 | drm_free(kbox_addr, cmdbuf.nbox * sizeof(struct drm_clip_rect), | 1159 | drm_free(kbox_addr, cmdbuf->nbox * sizeof(struct drm_clip_rect), |
1162 | DRM_MEM_DRIVER); | 1160 | DRM_MEM_DRIVER); |
1163 | 1161 | ||
1164 | return ret; | 1162 | return ret; |