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/i915_dma.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/i915_dma.c')
-rw-r--r-- | drivers/char/drm/i915_dma.c | 144 |
1 files changed, 63 insertions, 81 deletions
diff --git a/drivers/char/drm/i915_dma.c b/drivers/char/drm/i915_dma.c index 25d8b2b9524d..e61a43e5b3ac 100644 --- a/drivers/char/drm/i915_dma.c +++ b/drivers/char/drm/i915_dma.c | |||
@@ -251,23 +251,20 @@ static int i915_dma_resume(struct drm_device * dev) | |||
251 | return 0; | 251 | return 0; |
252 | } | 252 | } |
253 | 253 | ||
254 | static int i915_dma_init(DRM_IOCTL_ARGS) | 254 | static int i915_dma_init(struct drm_device *dev, void *data, |
255 | struct drm_file *file_priv) | ||
255 | { | 256 | { |
256 | DRM_DEVICE; | ||
257 | drm_i915_private_t *dev_priv; | 257 | drm_i915_private_t *dev_priv; |
258 | drm_i915_init_t init; | 258 | drm_i915_init_t *init = data; |
259 | int retcode = 0; | 259 | int retcode = 0; |
260 | 260 | ||
261 | DRM_COPY_FROM_USER_IOCTL(init, (drm_i915_init_t __user *) data, | 261 | switch (init->func) { |
262 | sizeof(init)); | ||
263 | |||
264 | switch (init.func) { | ||
265 | case I915_INIT_DMA: | 262 | case I915_INIT_DMA: |
266 | dev_priv = drm_alloc(sizeof(drm_i915_private_t), | 263 | dev_priv = drm_alloc(sizeof(drm_i915_private_t), |
267 | DRM_MEM_DRIVER); | 264 | DRM_MEM_DRIVER); |
268 | if (dev_priv == NULL) | 265 | if (dev_priv == NULL) |
269 | return -ENOMEM; | 266 | return -ENOMEM; |
270 | retcode = i915_initialize(dev, dev_priv, &init); | 267 | retcode = i915_initialize(dev, dev_priv, init); |
271 | break; | 268 | break; |
272 | case I915_CLEANUP_DMA: | 269 | case I915_CLEANUP_DMA: |
273 | retcode = i915_dma_cleanup(dev); | 270 | retcode = i915_dma_cleanup(dev); |
@@ -598,23 +595,22 @@ static int i915_quiescent(struct drm_device * dev) | |||
598 | return i915_wait_ring(dev, dev_priv->ring.Size - 8, __FUNCTION__); | 595 | return i915_wait_ring(dev, dev_priv->ring.Size - 8, __FUNCTION__); |
599 | } | 596 | } |
600 | 597 | ||
601 | static int i915_flush_ioctl(DRM_IOCTL_ARGS) | 598 | static int i915_flush_ioctl(struct drm_device *dev, void *data, |
599 | struct drm_file *file_priv) | ||
602 | { | 600 | { |
603 | DRM_DEVICE; | ||
604 | |||
605 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 601 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
606 | 602 | ||
607 | return i915_quiescent(dev); | 603 | return i915_quiescent(dev); |
608 | } | 604 | } |
609 | 605 | ||
610 | static int i915_batchbuffer(DRM_IOCTL_ARGS) | 606 | static int i915_batchbuffer(struct drm_device *dev, void *data, |
607 | struct drm_file *file_priv) | ||
611 | { | 608 | { |
612 | DRM_DEVICE; | ||
613 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; | 609 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
614 | u32 *hw_status = dev_priv->hw_status_page; | 610 | u32 *hw_status = dev_priv->hw_status_page; |
615 | drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *) | 611 | drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *) |
616 | dev_priv->sarea_priv; | 612 | dev_priv->sarea_priv; |
617 | drm_i915_batchbuffer_t batch; | 613 | drm_i915_batchbuffer_t *batch = data; |
618 | int ret; | 614 | int ret; |
619 | 615 | ||
620 | if (!dev_priv->allow_batchbuffer) { | 616 | if (!dev_priv->allow_batchbuffer) { |
@@ -622,52 +618,46 @@ static int i915_batchbuffer(DRM_IOCTL_ARGS) | |||
622 | return -EINVAL; | 618 | return -EINVAL; |
623 | } | 619 | } |
624 | 620 | ||
625 | DRM_COPY_FROM_USER_IOCTL(batch, (drm_i915_batchbuffer_t __user *) data, | ||
626 | sizeof(batch)); | ||
627 | |||
628 | DRM_DEBUG("i915 batchbuffer, start %x used %d cliprects %d\n", | 621 | DRM_DEBUG("i915 batchbuffer, start %x used %d cliprects %d\n", |
629 | batch.start, batch.used, batch.num_cliprects); | 622 | batch->start, batch->used, batch->num_cliprects); |
630 | 623 | ||
631 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 624 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
632 | 625 | ||
633 | if (batch.num_cliprects && DRM_VERIFYAREA_READ(batch.cliprects, | 626 | if (batch->num_cliprects && DRM_VERIFYAREA_READ(batch->cliprects, |
634 | batch.num_cliprects * | 627 | batch->num_cliprects * |
635 | sizeof(struct drm_clip_rect))) | 628 | sizeof(struct drm_clip_rect))) |
636 | return -EFAULT; | 629 | return -EFAULT; |
637 | 630 | ||
638 | ret = i915_dispatch_batchbuffer(dev, &batch); | 631 | ret = i915_dispatch_batchbuffer(dev, batch); |
639 | 632 | ||
640 | sarea_priv->last_dispatch = (int)hw_status[5]; | 633 | sarea_priv->last_dispatch = (int)hw_status[5]; |
641 | return ret; | 634 | return ret; |
642 | } | 635 | } |
643 | 636 | ||
644 | static int i915_cmdbuffer(DRM_IOCTL_ARGS) | 637 | static int i915_cmdbuffer(struct drm_device *dev, void *data, |
638 | struct drm_file *file_priv) | ||
645 | { | 639 | { |
646 | DRM_DEVICE; | ||
647 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; | 640 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
648 | u32 *hw_status = dev_priv->hw_status_page; | 641 | u32 *hw_status = dev_priv->hw_status_page; |
649 | drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *) | 642 | drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *) |
650 | dev_priv->sarea_priv; | 643 | dev_priv->sarea_priv; |
651 | drm_i915_cmdbuffer_t cmdbuf; | 644 | drm_i915_cmdbuffer_t *cmdbuf = data; |
652 | int ret; | 645 | int ret; |
653 | 646 | ||
654 | DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_i915_cmdbuffer_t __user *) data, | ||
655 | sizeof(cmdbuf)); | ||
656 | |||
657 | DRM_DEBUG("i915 cmdbuffer, buf %p sz %d cliprects %d\n", | 647 | DRM_DEBUG("i915 cmdbuffer, buf %p sz %d cliprects %d\n", |
658 | cmdbuf.buf, cmdbuf.sz, cmdbuf.num_cliprects); | 648 | cmdbuf->buf, cmdbuf->sz, cmdbuf->num_cliprects); |
659 | 649 | ||
660 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 650 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
661 | 651 | ||
662 | if (cmdbuf.num_cliprects && | 652 | if (cmdbuf->num_cliprects && |
663 | DRM_VERIFYAREA_READ(cmdbuf.cliprects, | 653 | DRM_VERIFYAREA_READ(cmdbuf->cliprects, |
664 | cmdbuf.num_cliprects * | 654 | cmdbuf->num_cliprects * |
665 | sizeof(struct drm_clip_rect))) { | 655 | sizeof(struct drm_clip_rect))) { |
666 | DRM_ERROR("Fault accessing cliprects\n"); | 656 | DRM_ERROR("Fault accessing cliprects\n"); |
667 | return -EFAULT; | 657 | return -EFAULT; |
668 | } | 658 | } |
669 | 659 | ||
670 | ret = i915_dispatch_cmdbuffer(dev, &cmdbuf); | 660 | ret = i915_dispatch_cmdbuffer(dev, cmdbuf); |
671 | if (ret) { | 661 | if (ret) { |
672 | DRM_ERROR("i915_dispatch_cmdbuffer failed\n"); | 662 | DRM_ERROR("i915_dispatch_cmdbuffer failed\n"); |
673 | return ret; | 663 | return ret; |
@@ -677,10 +667,9 @@ static int i915_cmdbuffer(DRM_IOCTL_ARGS) | |||
677 | return 0; | 667 | return 0; |
678 | } | 668 | } |
679 | 669 | ||
680 | static int i915_flip_bufs(DRM_IOCTL_ARGS) | 670 | static int i915_flip_bufs(struct drm_device *dev, void *data, |
671 | struct drm_file *file_priv) | ||
681 | { | 672 | { |
682 | DRM_DEVICE; | ||
683 | |||
684 | DRM_DEBUG("%s\n", __FUNCTION__); | 673 | DRM_DEBUG("%s\n", __FUNCTION__); |
685 | 674 | ||
686 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 675 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
@@ -688,11 +677,11 @@ static int i915_flip_bufs(DRM_IOCTL_ARGS) | |||
688 | return i915_dispatch_flip(dev); | 677 | return i915_dispatch_flip(dev); |
689 | } | 678 | } |
690 | 679 | ||
691 | static int i915_getparam(DRM_IOCTL_ARGS) | 680 | static int i915_getparam(struct drm_device *dev, void *data, |
681 | struct drm_file *file_priv) | ||
692 | { | 682 | { |
693 | DRM_DEVICE; | ||
694 | drm_i915_private_t *dev_priv = dev->dev_private; | 683 | drm_i915_private_t *dev_priv = dev->dev_private; |
695 | drm_i915_getparam_t param; | 684 | drm_i915_getparam_t *param = data; |
696 | int value; | 685 | int value; |
697 | 686 | ||
698 | if (!dev_priv) { | 687 | if (!dev_priv) { |
@@ -700,10 +689,7 @@ static int i915_getparam(DRM_IOCTL_ARGS) | |||
700 | return -EINVAL; | 689 | return -EINVAL; |
701 | } | 690 | } |
702 | 691 | ||
703 | DRM_COPY_FROM_USER_IOCTL(param, (drm_i915_getparam_t __user *) data, | 692 | switch (param->param) { |
704 | sizeof(param)); | ||
705 | |||
706 | switch (param.param) { | ||
707 | case I915_PARAM_IRQ_ACTIVE: | 693 | case I915_PARAM_IRQ_ACTIVE: |
708 | value = dev->irq ? 1 : 0; | 694 | value = dev->irq ? 1 : 0; |
709 | break; | 695 | break; |
@@ -714,11 +700,11 @@ static int i915_getparam(DRM_IOCTL_ARGS) | |||
714 | value = READ_BREADCRUMB(dev_priv); | 700 | value = READ_BREADCRUMB(dev_priv); |
715 | break; | 701 | break; |
716 | default: | 702 | default: |
717 | DRM_ERROR("Unknown parameter %d\n", param.param); | 703 | DRM_ERROR("Unknown parameter %d\n", param->param); |
718 | return -EINVAL; | 704 | return -EINVAL; |
719 | } | 705 | } |
720 | 706 | ||
721 | if (DRM_COPY_TO_USER(param.value, &value, sizeof(int))) { | 707 | if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) { |
722 | DRM_ERROR("DRM_COPY_TO_USER failed\n"); | 708 | DRM_ERROR("DRM_COPY_TO_USER failed\n"); |
723 | return -EFAULT; | 709 | return -EFAULT; |
724 | } | 710 | } |
@@ -726,56 +712,52 @@ static int i915_getparam(DRM_IOCTL_ARGS) | |||
726 | return 0; | 712 | return 0; |
727 | } | 713 | } |
728 | 714 | ||
729 | static int i915_setparam(DRM_IOCTL_ARGS) | 715 | static int i915_setparam(struct drm_device *dev, void *data, |
716 | struct drm_file *file_priv) | ||
730 | { | 717 | { |
731 | DRM_DEVICE; | ||
732 | drm_i915_private_t *dev_priv = dev->dev_private; | 718 | drm_i915_private_t *dev_priv = dev->dev_private; |
733 | drm_i915_setparam_t param; | 719 | drm_i915_setparam_t *param = data; |
734 | 720 | ||
735 | if (!dev_priv) { | 721 | if (!dev_priv) { |
736 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); | 722 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); |
737 | return -EINVAL; | 723 | return -EINVAL; |
738 | } | 724 | } |
739 | 725 | ||
740 | DRM_COPY_FROM_USER_IOCTL(param, (drm_i915_setparam_t __user *) data, | 726 | switch (param->param) { |
741 | sizeof(param)); | ||
742 | |||
743 | switch (param.param) { | ||
744 | case I915_SETPARAM_USE_MI_BATCHBUFFER_START: | 727 | case I915_SETPARAM_USE_MI_BATCHBUFFER_START: |
745 | if (!IS_I965G(dev)) | 728 | if (!IS_I965G(dev)) |
746 | dev_priv->use_mi_batchbuffer_start = param.value; | 729 | dev_priv->use_mi_batchbuffer_start = param->value; |
747 | break; | 730 | break; |
748 | case I915_SETPARAM_TEX_LRU_LOG_GRANULARITY: | 731 | case I915_SETPARAM_TEX_LRU_LOG_GRANULARITY: |
749 | dev_priv->tex_lru_log_granularity = param.value; | 732 | dev_priv->tex_lru_log_granularity = param->value; |
750 | break; | 733 | break; |
751 | case I915_SETPARAM_ALLOW_BATCHBUFFER: | 734 | case I915_SETPARAM_ALLOW_BATCHBUFFER: |
752 | dev_priv->allow_batchbuffer = param.value; | 735 | dev_priv->allow_batchbuffer = param->value; |
753 | break; | 736 | break; |
754 | default: | 737 | default: |
755 | DRM_ERROR("unknown parameter %d\n", param.param); | 738 | DRM_ERROR("unknown parameter %d\n", param->param); |
756 | return -EINVAL; | 739 | return -EINVAL; |
757 | } | 740 | } |
758 | 741 | ||
759 | return 0; | 742 | return 0; |
760 | } | 743 | } |
761 | 744 | ||
762 | static int i915_set_status_page(DRM_IOCTL_ARGS) | 745 | static int i915_set_status_page(struct drm_device *dev, void *data, |
746 | struct drm_file *file_priv) | ||
763 | { | 747 | { |
764 | DRM_DEVICE; | ||
765 | drm_i915_private_t *dev_priv = dev->dev_private; | 748 | drm_i915_private_t *dev_priv = dev->dev_private; |
766 | drm_i915_hws_addr_t hws; | 749 | drm_i915_hws_addr_t *hws = data; |
767 | 750 | ||
768 | if (!dev_priv) { | 751 | if (!dev_priv) { |
769 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); | 752 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); |
770 | return -EINVAL; | 753 | return -EINVAL; |
771 | } | 754 | } |
772 | DRM_COPY_FROM_USER_IOCTL(hws, (drm_i915_hws_addr_t __user *) data, | ||
773 | sizeof(hws)); | ||
774 | printk(KERN_DEBUG "set status page addr 0x%08x\n", (u32)hws.addr); | ||
775 | 755 | ||
776 | dev_priv->status_gfx_addr = hws.addr & (0x1ffff<<12); | 756 | printk(KERN_DEBUG "set status page addr 0x%08x\n", (u32)hws->addr); |
757 | |||
758 | dev_priv->status_gfx_addr = hws->addr & (0x1ffff<<12); | ||
777 | 759 | ||
778 | dev_priv->hws_map.offset = dev->agp->agp_info.aper_base + hws.addr; | 760 | dev_priv->hws_map.offset = dev->agp->agp_info.aper_base + hws->addr; |
779 | dev_priv->hws_map.size = 4*1024; | 761 | dev_priv->hws_map.size = 4*1024; |
780 | dev_priv->hws_map.type = 0; | 762 | dev_priv->hws_map.type = 0; |
781 | dev_priv->hws_map.flags = 0; | 763 | dev_priv->hws_map.flags = 0; |
@@ -829,24 +811,24 @@ void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv) | |||
829 | } | 811 | } |
830 | } | 812 | } |
831 | 813 | ||
832 | drm_ioctl_desc_t i915_ioctls[] = { | 814 | struct drm_ioctl_desc i915_ioctls[] = { |
833 | [DRM_IOCTL_NR(DRM_I915_INIT)] = {i915_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 815 | DRM_IOCTL_DEF(DRM_I915_INIT, i915_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
834 | [DRM_IOCTL_NR(DRM_I915_FLUSH)] = {i915_flush_ioctl, DRM_AUTH}, | 816 | DRM_IOCTL_DEF(DRM_I915_FLUSH, i915_flush_ioctl, DRM_AUTH), |
835 | [DRM_IOCTL_NR(DRM_I915_FLIP)] = {i915_flip_bufs, DRM_AUTH}, | 817 | DRM_IOCTL_DEF(DRM_I915_FLIP, i915_flip_bufs, DRM_AUTH), |
836 | [DRM_IOCTL_NR(DRM_I915_BATCHBUFFER)] = {i915_batchbuffer, DRM_AUTH}, | 818 | DRM_IOCTL_DEF(DRM_I915_BATCHBUFFER, i915_batchbuffer, DRM_AUTH), |
837 | [DRM_IOCTL_NR(DRM_I915_IRQ_EMIT)] = {i915_irq_emit, DRM_AUTH}, | 819 | DRM_IOCTL_DEF(DRM_I915_IRQ_EMIT, i915_irq_emit, DRM_AUTH), |
838 | [DRM_IOCTL_NR(DRM_I915_IRQ_WAIT)] = {i915_irq_wait, DRM_AUTH}, | 820 | DRM_IOCTL_DEF(DRM_I915_IRQ_WAIT, i915_irq_wait, DRM_AUTH), |
839 | [DRM_IOCTL_NR(DRM_I915_GETPARAM)] = {i915_getparam, DRM_AUTH}, | 821 | DRM_IOCTL_DEF(DRM_I915_GETPARAM, i915_getparam, DRM_AUTH), |
840 | [DRM_IOCTL_NR(DRM_I915_SETPARAM)] = {i915_setparam, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 822 | DRM_IOCTL_DEF(DRM_I915_SETPARAM, i915_setparam, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
841 | [DRM_IOCTL_NR(DRM_I915_ALLOC)] = {i915_mem_alloc, DRM_AUTH}, | 823 | DRM_IOCTL_DEF(DRM_I915_ALLOC, i915_mem_alloc, DRM_AUTH), |
842 | [DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, DRM_AUTH}, | 824 | DRM_IOCTL_DEF(DRM_I915_FREE, i915_mem_free, DRM_AUTH), |
843 | [DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 825 | DRM_IOCTL_DEF(DRM_I915_INIT_HEAP, i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
844 | [DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, DRM_AUTH}, | 826 | DRM_IOCTL_DEF(DRM_I915_CMDBUFFER, i915_cmdbuffer, DRM_AUTH), |
845 | [DRM_IOCTL_NR(DRM_I915_DESTROY_HEAP)] = { i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }, | 827 | DRM_IOCTL_DEF(DRM_I915_DESTROY_HEAP, i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY ), |
846 | [DRM_IOCTL_NR(DRM_I915_SET_VBLANK_PIPE)] = { i915_vblank_pipe_set, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }, | 828 | DRM_IOCTL_DEF(DRM_I915_SET_VBLANK_PIPE, i915_vblank_pipe_set, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY ), |
847 | [DRM_IOCTL_NR(DRM_I915_GET_VBLANK_PIPE)] = { i915_vblank_pipe_get, DRM_AUTH }, | 829 | DRM_IOCTL_DEF(DRM_I915_GET_VBLANK_PIPE, i915_vblank_pipe_get, DRM_AUTH ), |
848 | [DRM_IOCTL_NR(DRM_I915_VBLANK_SWAP)] = {i915_vblank_swap, DRM_AUTH}, | 830 | DRM_IOCTL_DEF(DRM_I915_VBLANK_SWAP, i915_vblank_swap, DRM_AUTH), |
849 | [DRM_IOCTL_NR(DRM_I915_HWS_ADDR)] = {i915_set_status_page, DRM_AUTH}, | 831 | DRM_IOCTL_DEF(DRM_I915_HWS_ADDR, i915_set_status_page, DRM_AUTH), |
850 | }; | 832 | }; |
851 | 833 | ||
852 | int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); | 834 | int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); |