diff options
Diffstat (limited to 'drivers/char/drm/i915_dma.c')
-rw-r--r-- | drivers/char/drm/i915_dma.c | 87 |
1 files changed, 70 insertions, 17 deletions
diff --git a/drivers/char/drm/i915_dma.c b/drivers/char/drm/i915_dma.c index 730dfeea042d..ea52740af4f6 100644 --- a/drivers/char/drm/i915_dma.c +++ b/drivers/char/drm/i915_dma.c | |||
@@ -38,6 +38,10 @@ | |||
38 | dev->pci_device == 0x2A02 || \ | 38 | dev->pci_device == 0x2A02 || \ |
39 | dev->pci_device == 0x2A12) | 39 | dev->pci_device == 0x2A12) |
40 | 40 | ||
41 | #define IS_G33(dev) (dev->pci_device == 0x29b2 || \ | ||
42 | dev->pci_device == 0x29c2 || \ | ||
43 | dev->pci_device == 0x29d2) | ||
44 | |||
41 | /* Really want an OS-independent resettable timer. Would like to have | 45 | /* Really want an OS-independent resettable timer. Would like to have |
42 | * this loop run for (eg) 3 sec, but have the timer reset every time | 46 | * this loop run for (eg) 3 sec, but have the timer reset every time |
43 | * the head pointer changes, so that EBUSY only happens if the ring | 47 | * the head pointer changes, so that EBUSY only happens if the ring |
@@ -107,6 +111,12 @@ static int i915_dma_cleanup(drm_device_t * dev) | |||
107 | I915_WRITE(0x02080, 0x1ffff000); | 111 | I915_WRITE(0x02080, 0x1ffff000); |
108 | } | 112 | } |
109 | 113 | ||
114 | if (dev_priv->status_gfx_addr) { | ||
115 | dev_priv->status_gfx_addr = 0; | ||
116 | drm_core_ioremapfree(&dev_priv->hws_map, dev); | ||
117 | I915_WRITE(0x2080, 0x1ffff000); | ||
118 | } | ||
119 | |||
110 | drm_free(dev->dev_private, sizeof(drm_i915_private_t), | 120 | drm_free(dev->dev_private, sizeof(drm_i915_private_t), |
111 | DRM_MEM_DRIVER); | 121 | DRM_MEM_DRIVER); |
112 | 122 | ||
@@ -180,26 +190,24 @@ static int i915_initialize(drm_device_t * dev, | |||
180 | dev_priv->allow_batchbuffer = 1; | 190 | dev_priv->allow_batchbuffer = 1; |
181 | 191 | ||
182 | /* Program Hardware Status Page */ | 192 | /* Program Hardware Status Page */ |
183 | dev_priv->status_page_dmah = drm_pci_alloc(dev, PAGE_SIZE, PAGE_SIZE, | 193 | if (!IS_G33(dev)) { |
184 | 0xffffffff); | 194 | dev_priv->status_page_dmah = |
195 | drm_pci_alloc(dev, PAGE_SIZE, PAGE_SIZE, 0xffffffff); | ||
196 | |||
197 | if (!dev_priv->status_page_dmah) { | ||
198 | dev->dev_private = (void *)dev_priv; | ||
199 | i915_dma_cleanup(dev); | ||
200 | DRM_ERROR("Can not allocate hardware status page\n"); | ||
201 | return DRM_ERR(ENOMEM); | ||
202 | } | ||
203 | dev_priv->hw_status_page = dev_priv->status_page_dmah->vaddr; | ||
204 | dev_priv->dma_status_page = dev_priv->status_page_dmah->busaddr; | ||
185 | 205 | ||
186 | if (!dev_priv->status_page_dmah) { | 206 | memset(dev_priv->hw_status_page, 0, PAGE_SIZE); |
187 | dev->dev_private = (void *)dev_priv; | 207 | I915_WRITE(0x02080, dev_priv->dma_status_page); |
188 | i915_dma_cleanup(dev); | ||
189 | DRM_ERROR("Can not allocate hardware status page\n"); | ||
190 | return DRM_ERR(ENOMEM); | ||
191 | } | 208 | } |
192 | dev_priv->hw_status_page = dev_priv->status_page_dmah->vaddr; | ||
193 | dev_priv->dma_status_page = dev_priv->status_page_dmah->busaddr; | ||
194 | |||
195 | memset(dev_priv->hw_status_page, 0, PAGE_SIZE); | ||
196 | DRM_DEBUG("hw status page @ %p\n", dev_priv->hw_status_page); | ||
197 | |||
198 | I915_WRITE(0x02080, dev_priv->dma_status_page); | ||
199 | DRM_DEBUG("Enabled hardware status page\n"); | 209 | DRM_DEBUG("Enabled hardware status page\n"); |
200 | |||
201 | dev->dev_private = (void *)dev_priv; | 210 | dev->dev_private = (void *)dev_priv; |
202 | |||
203 | return 0; | 211 | return 0; |
204 | } | 212 | } |
205 | 213 | ||
@@ -232,7 +240,10 @@ static int i915_dma_resume(drm_device_t * dev) | |||
232 | } | 240 | } |
233 | DRM_DEBUG("hw status page @ %p\n", dev_priv->hw_status_page); | 241 | DRM_DEBUG("hw status page @ %p\n", dev_priv->hw_status_page); |
234 | 242 | ||
235 | I915_WRITE(0x02080, dev_priv->dma_status_page); | 243 | if (dev_priv->status_gfx_addr != 0) |
244 | I915_WRITE(0x02080, dev_priv->status_gfx_addr); | ||
245 | else | ||
246 | I915_WRITE(0x02080, dev_priv->dma_status_page); | ||
236 | DRM_DEBUG("Enabled hardware status page\n"); | 247 | DRM_DEBUG("Enabled hardware status page\n"); |
237 | 248 | ||
238 | return 0; | 249 | return 0; |
@@ -740,6 +751,47 @@ static int i915_setparam(DRM_IOCTL_ARGS) | |||
740 | return 0; | 751 | return 0; |
741 | } | 752 | } |
742 | 753 | ||
754 | static int i915_set_status_page(DRM_IOCTL_ARGS) | ||
755 | { | ||
756 | DRM_DEVICE; | ||
757 | drm_i915_private_t *dev_priv = dev->dev_private; | ||
758 | drm_i915_hws_addr_t hws; | ||
759 | |||
760 | if (!dev_priv) { | ||
761 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); | ||
762 | return DRM_ERR(EINVAL); | ||
763 | } | ||
764 | DRM_COPY_FROM_USER_IOCTL(hws, (drm_i915_hws_addr_t __user *) data, | ||
765 | sizeof(hws)); | ||
766 | printk(KERN_DEBUG "set status page addr 0x%08x\n", (u32)hws.addr); | ||
767 | |||
768 | dev_priv->status_gfx_addr = hws.addr & (0x1ffff<<12); | ||
769 | |||
770 | dev_priv->hws_map.offset = dev->agp->agp_info.aper_base + hws.addr; | ||
771 | dev_priv->hws_map.size = 4*1024; | ||
772 | dev_priv->hws_map.type = 0; | ||
773 | dev_priv->hws_map.flags = 0; | ||
774 | dev_priv->hws_map.mtrr = 0; | ||
775 | |||
776 | drm_core_ioremap(&dev_priv->hws_map, dev); | ||
777 | if (dev_priv->hws_map.handle == NULL) { | ||
778 | dev->dev_private = (void *)dev_priv; | ||
779 | i915_dma_cleanup(dev); | ||
780 | dev_priv->status_gfx_addr = 0; | ||
781 | DRM_ERROR("can not ioremap virtual address for" | ||
782 | " G33 hw status page\n"); | ||
783 | return DRM_ERR(ENOMEM); | ||
784 | } | ||
785 | dev_priv->hw_status_page = dev_priv->hws_map.handle; | ||
786 | |||
787 | memset(dev_priv->hw_status_page, 0, PAGE_SIZE); | ||
788 | I915_WRITE(0x02080, dev_priv->status_gfx_addr); | ||
789 | DRM_DEBUG("load hws 0x2080 with gfx mem 0x%x\n", | ||
790 | dev_priv->status_gfx_addr); | ||
791 | DRM_DEBUG("load hws at %p\n", dev_priv->hw_status_page); | ||
792 | return 0; | ||
793 | } | ||
794 | |||
743 | int i915_driver_load(drm_device_t *dev, unsigned long flags) | 795 | int i915_driver_load(drm_device_t *dev, unsigned long flags) |
744 | { | 796 | { |
745 | /* i915 has 4 more counters */ | 797 | /* i915 has 4 more counters */ |
@@ -786,6 +838,7 @@ drm_ioctl_desc_t i915_ioctls[] = { | |||
786 | [DRM_IOCTL_NR(DRM_I915_SET_VBLANK_PIPE)] = { i915_vblank_pipe_set, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }, | 838 | [DRM_IOCTL_NR(DRM_I915_SET_VBLANK_PIPE)] = { i915_vblank_pipe_set, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }, |
787 | [DRM_IOCTL_NR(DRM_I915_GET_VBLANK_PIPE)] = { i915_vblank_pipe_get, DRM_AUTH }, | 839 | [DRM_IOCTL_NR(DRM_I915_GET_VBLANK_PIPE)] = { i915_vblank_pipe_get, DRM_AUTH }, |
788 | [DRM_IOCTL_NR(DRM_I915_VBLANK_SWAP)] = {i915_vblank_swap, DRM_AUTH}, | 840 | [DRM_IOCTL_NR(DRM_I915_VBLANK_SWAP)] = {i915_vblank_swap, DRM_AUTH}, |
841 | [DRM_IOCTL_NR(DRM_I915_HWS_ADDR)] = {i915_set_status_page, DRM_AUTH}, | ||
789 | }; | 842 | }; |
790 | 843 | ||
791 | int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); | 844 | int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); |