diff options
Diffstat (limited to 'drivers/gpu/drm/i915/i915_dma.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_dma.c | 94 |
1 files changed, 76 insertions, 18 deletions
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 63c6803d471b..f167ff68a4bf 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c | |||
@@ -170,24 +170,31 @@ static int i915_initialize(struct drm_device * dev, drm_i915_init_t * init) | |||
170 | dev_priv->sarea_priv = (drm_i915_sarea_t *) | 170 | dev_priv->sarea_priv = (drm_i915_sarea_t *) |
171 | ((u8 *) dev_priv->sarea->handle + init->sarea_priv_offset); | 171 | ((u8 *) dev_priv->sarea->handle + init->sarea_priv_offset); |
172 | 172 | ||
173 | dev_priv->ring.Start = init->ring_start; | 173 | if (init->ring_size != 0) { |
174 | dev_priv->ring.End = init->ring_end; | 174 | if (dev_priv->ring.ring_obj != NULL) { |
175 | dev_priv->ring.Size = init->ring_size; | 175 | i915_dma_cleanup(dev); |
176 | dev_priv->ring.tail_mask = dev_priv->ring.Size - 1; | 176 | DRM_ERROR("Client tried to initialize ringbuffer in " |
177 | "GEM mode\n"); | ||
178 | return -EINVAL; | ||
179 | } | ||
177 | 180 | ||
178 | dev_priv->ring.map.offset = init->ring_start; | 181 | dev_priv->ring.Size = init->ring_size; |
179 | dev_priv->ring.map.size = init->ring_size; | 182 | dev_priv->ring.tail_mask = dev_priv->ring.Size - 1; |
180 | dev_priv->ring.map.type = 0; | ||
181 | dev_priv->ring.map.flags = 0; | ||
182 | dev_priv->ring.map.mtrr = 0; | ||
183 | 183 | ||
184 | drm_core_ioremap(&dev_priv->ring.map, dev); | 184 | dev_priv->ring.map.offset = init->ring_start; |
185 | dev_priv->ring.map.size = init->ring_size; | ||
186 | dev_priv->ring.map.type = 0; | ||
187 | dev_priv->ring.map.flags = 0; | ||
188 | dev_priv->ring.map.mtrr = 0; | ||
185 | 189 | ||
186 | if (dev_priv->ring.map.handle == NULL) { | 190 | drm_core_ioremap(&dev_priv->ring.map, dev); |
187 | i915_dma_cleanup(dev); | 191 | |
188 | DRM_ERROR("can not ioremap virtual address for" | 192 | if (dev_priv->ring.map.handle == NULL) { |
189 | " ring buffer\n"); | 193 | i915_dma_cleanup(dev); |
190 | return -ENOMEM; | 194 | DRM_ERROR("can not ioremap virtual address for" |
195 | " ring buffer\n"); | ||
196 | return -ENOMEM; | ||
197 | } | ||
191 | } | 198 | } |
192 | 199 | ||
193 | dev_priv->ring.virtual_start = dev_priv->ring.map.handle; | 200 | dev_priv->ring.virtual_start = dev_priv->ring.map.handle; |
@@ -377,9 +384,10 @@ static int i915_emit_cmds(struct drm_device * dev, int __user * buffer, int dwor | |||
377 | return 0; | 384 | return 0; |
378 | } | 385 | } |
379 | 386 | ||
380 | static int i915_emit_box(struct drm_device * dev, | 387 | int |
381 | struct drm_clip_rect __user * boxes, | 388 | i915_emit_box(struct drm_device *dev, |
382 | int i, int DR1, int DR4) | 389 | struct drm_clip_rect __user *boxes, |
390 | int i, int DR1, int DR4) | ||
383 | { | 391 | { |
384 | drm_i915_private_t *dev_priv = dev->dev_private; | 392 | drm_i915_private_t *dev_priv = dev->dev_private; |
385 | struct drm_clip_rect box; | 393 | struct drm_clip_rect box; |
@@ -681,6 +689,9 @@ static int i915_getparam(struct drm_device *dev, void *data, | |||
681 | case I915_PARAM_LAST_DISPATCH: | 689 | case I915_PARAM_LAST_DISPATCH: |
682 | value = READ_BREADCRUMB(dev_priv); | 690 | value = READ_BREADCRUMB(dev_priv); |
683 | break; | 691 | break; |
692 | case I915_PARAM_HAS_GEM: | ||
693 | value = 1; | ||
694 | break; | ||
684 | default: | 695 | default: |
685 | DRM_ERROR("Unknown parameter %d\n", param->param); | 696 | DRM_ERROR("Unknown parameter %d\n", param->param); |
686 | return -EINVAL; | 697 | return -EINVAL; |
@@ -784,6 +795,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) | |||
784 | memset(dev_priv, 0, sizeof(drm_i915_private_t)); | 795 | memset(dev_priv, 0, sizeof(drm_i915_private_t)); |
785 | 796 | ||
786 | dev->dev_private = (void *)dev_priv; | 797 | dev->dev_private = (void *)dev_priv; |
798 | dev_priv->dev = dev; | ||
787 | 799 | ||
788 | /* Add register map (needed for suspend/resume) */ | 800 | /* Add register map (needed for suspend/resume) */ |
789 | base = drm_get_resource_start(dev, mmio_bar); | 801 | base = drm_get_resource_start(dev, mmio_bar); |
@@ -793,6 +805,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) | |||
793 | _DRM_KERNEL | _DRM_DRIVER, | 805 | _DRM_KERNEL | _DRM_DRIVER, |
794 | &dev_priv->mmio_map); | 806 | &dev_priv->mmio_map); |
795 | 807 | ||
808 | i915_gem_load(dev); | ||
809 | |||
796 | /* Init HWS */ | 810 | /* Init HWS */ |
797 | if (!I915_NEED_GFX_HWS(dev)) { | 811 | if (!I915_NEED_GFX_HWS(dev)) { |
798 | ret = i915_init_phys_hws(dev); | 812 | ret = i915_init_phys_hws(dev); |
@@ -838,6 +852,25 @@ int i915_driver_unload(struct drm_device *dev) | |||
838 | return 0; | 852 | return 0; |
839 | } | 853 | } |
840 | 854 | ||
855 | int i915_driver_open(struct drm_device *dev, struct drm_file *file_priv) | ||
856 | { | ||
857 | struct drm_i915_file_private *i915_file_priv; | ||
858 | |||
859 | DRM_DEBUG("\n"); | ||
860 | i915_file_priv = (struct drm_i915_file_private *) | ||
861 | drm_alloc(sizeof(*i915_file_priv), DRM_MEM_FILES); | ||
862 | |||
863 | if (!i915_file_priv) | ||
864 | return -ENOMEM; | ||
865 | |||
866 | file_priv->driver_priv = i915_file_priv; | ||
867 | |||
868 | i915_file_priv->mm.last_gem_seqno = 0; | ||
869 | i915_file_priv->mm.last_gem_throttle_seqno = 0; | ||
870 | |||
871 | return 0; | ||
872 | } | ||
873 | |||
841 | void i915_driver_lastclose(struct drm_device * dev) | 874 | void i915_driver_lastclose(struct drm_device * dev) |
842 | { | 875 | { |
843 | drm_i915_private_t *dev_priv = dev->dev_private; | 876 | drm_i915_private_t *dev_priv = dev->dev_private; |
@@ -845,6 +878,8 @@ void i915_driver_lastclose(struct drm_device * dev) | |||
845 | if (!dev_priv) | 878 | if (!dev_priv) |
846 | return; | 879 | return; |
847 | 880 | ||
881 | i915_gem_lastclose(dev); | ||
882 | |||
848 | if (dev_priv->agp_heap) | 883 | if (dev_priv->agp_heap) |
849 | i915_mem_takedown(&(dev_priv->agp_heap)); | 884 | i915_mem_takedown(&(dev_priv->agp_heap)); |
850 | 885 | ||
@@ -857,6 +892,13 @@ void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv) | |||
857 | i915_mem_release(dev, file_priv, dev_priv->agp_heap); | 892 | i915_mem_release(dev, file_priv, dev_priv->agp_heap); |
858 | } | 893 | } |
859 | 894 | ||
895 | void i915_driver_postclose(struct drm_device *dev, struct drm_file *file_priv) | ||
896 | { | ||
897 | struct drm_i915_file_private *i915_file_priv = file_priv->driver_priv; | ||
898 | |||
899 | drm_free(i915_file_priv, sizeof(*i915_file_priv), DRM_MEM_FILES); | ||
900 | } | ||
901 | |||
860 | struct drm_ioctl_desc i915_ioctls[] = { | 902 | struct drm_ioctl_desc i915_ioctls[] = { |
861 | DRM_IOCTL_DEF(DRM_I915_INIT, i915_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), | 903 | DRM_IOCTL_DEF(DRM_I915_INIT, i915_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
862 | DRM_IOCTL_DEF(DRM_I915_FLUSH, i915_flush_ioctl, DRM_AUTH), | 904 | DRM_IOCTL_DEF(DRM_I915_FLUSH, i915_flush_ioctl, DRM_AUTH), |
@@ -875,6 +917,22 @@ struct drm_ioctl_desc i915_ioctls[] = { | |||
875 | DRM_IOCTL_DEF(DRM_I915_GET_VBLANK_PIPE, i915_vblank_pipe_get, DRM_AUTH ), | 917 | DRM_IOCTL_DEF(DRM_I915_GET_VBLANK_PIPE, i915_vblank_pipe_get, DRM_AUTH ), |
876 | DRM_IOCTL_DEF(DRM_I915_VBLANK_SWAP, i915_vblank_swap, DRM_AUTH), | 918 | DRM_IOCTL_DEF(DRM_I915_VBLANK_SWAP, i915_vblank_swap, DRM_AUTH), |
877 | DRM_IOCTL_DEF(DRM_I915_HWS_ADDR, i915_set_status_page, DRM_AUTH), | 919 | DRM_IOCTL_DEF(DRM_I915_HWS_ADDR, i915_set_status_page, DRM_AUTH), |
920 | DRM_IOCTL_DEF(DRM_I915_GEM_INIT, i915_gem_init_ioctl, DRM_AUTH), | ||
921 | DRM_IOCTL_DEF(DRM_I915_GEM_EXECBUFFER, i915_gem_execbuffer, DRM_AUTH), | ||
922 | DRM_IOCTL_DEF(DRM_I915_GEM_PIN, i915_gem_pin_ioctl, DRM_AUTH|DRM_ROOT_ONLY), | ||
923 | DRM_IOCTL_DEF(DRM_I915_GEM_UNPIN, i915_gem_unpin_ioctl, DRM_AUTH|DRM_ROOT_ONLY), | ||
924 | DRM_IOCTL_DEF(DRM_I915_GEM_BUSY, i915_gem_busy_ioctl, DRM_AUTH), | ||
925 | DRM_IOCTL_DEF(DRM_I915_GEM_THROTTLE, i915_gem_throttle_ioctl, DRM_AUTH), | ||
926 | DRM_IOCTL_DEF(DRM_I915_GEM_ENTERVT, i915_gem_entervt_ioctl, DRM_AUTH), | ||
927 | DRM_IOCTL_DEF(DRM_I915_GEM_LEAVEVT, i915_gem_leavevt_ioctl, DRM_AUTH), | ||
928 | DRM_IOCTL_DEF(DRM_I915_GEM_CREATE, i915_gem_create_ioctl, 0), | ||
929 | DRM_IOCTL_DEF(DRM_I915_GEM_PREAD, i915_gem_pread_ioctl, 0), | ||
930 | DRM_IOCTL_DEF(DRM_I915_GEM_PWRITE, i915_gem_pwrite_ioctl, 0), | ||
931 | DRM_IOCTL_DEF(DRM_I915_GEM_MMAP, i915_gem_mmap_ioctl, 0), | ||
932 | DRM_IOCTL_DEF(DRM_I915_GEM_SET_DOMAIN, i915_gem_set_domain_ioctl, 0), | ||
933 | DRM_IOCTL_DEF(DRM_I915_GEM_SW_FINISH, i915_gem_sw_finish_ioctl, 0), | ||
934 | DRM_IOCTL_DEF(DRM_I915_GEM_SET_TILING, i915_gem_set_tiling, 0), | ||
935 | DRM_IOCTL_DEF(DRM_I915_GEM_GET_TILING, i915_gem_get_tiling, 0), | ||
878 | }; | 936 | }; |
879 | 937 | ||
880 | int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); | 938 | int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); |