aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2008-03-28 17:23:07 -0400
committerDave Airlie <airlied@linux.ie>2008-03-29 17:57:57 -0400
commit6876b3bacaaa4c73fb8752b47c84b2b7fad5422a (patch)
treeb3f0a1795a3c0c66de99642ba0e1c233c872823c /drivers/char
parent2b46278b6af0a4df43016f01a0741d8e0a76bfd4 (diff)
drm: fix for non-coherent DMA PowerPC
This patch fixes bits of the DRM so to make the radeon DRI work on non-cache coherent PCI DMA variants of the PowerPC processors. It moves the few places that needs change to wrappers to that other architectures with similar issues can easily add their own changes to those wrappers, at least until we have more useful generic kernel API. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: "Luck, Tony" <tony.luck@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/drm/ati_pcigart.c6
-rw-r--r--drivers/char/drm/drm_scatter.c11
-rw-r--r--drivers/char/drm/drm_vm.c20
3 files changed, 31 insertions, 6 deletions
diff --git a/drivers/char/drm/ati_pcigart.c b/drivers/char/drm/ati_pcigart.c
index 35d25d821c38..141f4dfa0a11 100644
--- a/drivers/char/drm/ati_pcigart.c
+++ b/drivers/char/drm/ati_pcigart.c
@@ -168,6 +168,12 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga
168 } 168 }
169 } 169 }
170 170
171 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN)
172 dma_sync_single_for_device(&dev->pdev->dev,
173 bus_address,
174 max_pages * sizeof(u32),
175 PCI_DMA_TODEVICE);
176
171 ret = 1; 177 ret = 1;
172 178
173#if defined(__i386__) || defined(__x86_64__) 179#if defined(__i386__) || defined(__x86_64__)
diff --git a/drivers/char/drm/drm_scatter.c b/drivers/char/drm/drm_scatter.c
index 26d8f675ed5d..b2b0f3d41714 100644
--- a/drivers/char/drm/drm_scatter.c
+++ b/drivers/char/drm/drm_scatter.c
@@ -36,6 +36,15 @@
36 36
37#define DEBUG_SCATTER 0 37#define DEBUG_SCATTER 0
38 38
39static inline void *drm_vmalloc_dma(unsigned long size)
40{
41#if defined(__powerpc__) && defined(CONFIG_NOT_COHERENT_CACHE)
42 return __vmalloc(size, GFP_KERNEL, PAGE_KERNEL | _PAGE_NO_CACHE);
43#else
44 return vmalloc_32(size);
45#endif
46}
47
39void drm_sg_cleanup(struct drm_sg_mem * entry) 48void drm_sg_cleanup(struct drm_sg_mem * entry)
40{ 49{
41 struct page *page; 50 struct page *page;
@@ -104,7 +113,7 @@ int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request)
104 } 113 }
105 memset((void *)entry->busaddr, 0, pages * sizeof(*entry->busaddr)); 114 memset((void *)entry->busaddr, 0, pages * sizeof(*entry->busaddr));
106 115
107 entry->virtual = vmalloc_32(pages << PAGE_SHIFT); 116 entry->virtual = drm_vmalloc_dma(pages << PAGE_SHIFT);
108 if (!entry->virtual) { 117 if (!entry->virtual) {
109 drm_free(entry->busaddr, 118 drm_free(entry->busaddr,
110 entry->pages * sizeof(*entry->busaddr), DRM_MEM_PAGES); 119 entry->pages * sizeof(*entry->busaddr), DRM_MEM_PAGES);
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c
index 3d65c4dcd0c6..945df72a51a9 100644
--- a/drivers/char/drm/drm_vm.c
+++ b/drivers/char/drm/drm_vm.c
@@ -54,13 +54,24 @@ static pgprot_t drm_io_prot(uint32_t map_type, struct vm_area_struct *vma)
54 pgprot_val(tmp) |= _PAGE_NO_CACHE; 54 pgprot_val(tmp) |= _PAGE_NO_CACHE;
55 if (map_type == _DRM_REGISTERS) 55 if (map_type == _DRM_REGISTERS)
56 pgprot_val(tmp) |= _PAGE_GUARDED; 56 pgprot_val(tmp) |= _PAGE_GUARDED;
57#endif 57#elif defined(__ia64__)
58#if defined(__ia64__)
59 if (efi_range_is_wc(vma->vm_start, vma->vm_end - 58 if (efi_range_is_wc(vma->vm_start, vma->vm_end -
60 vma->vm_start)) 59 vma->vm_start))
61 tmp = pgprot_writecombine(tmp); 60 tmp = pgprot_writecombine(tmp);
62 else 61 else
63 tmp = pgprot_noncached(tmp); 62 tmp = pgprot_noncached(tmp);
63#elif defined(__sparc__)
64 tmp = pgprot_noncached(tmp);
65#endif
66 return tmp;
67}
68
69static pgprot_t drm_dma_prot(uint32_t map_type, struct vm_area_struct *vma)
70{
71 pgprot_t tmp = vm_get_page_prot(vma->vm_flags);
72
73#if defined(__powerpc__) && defined(CONFIG_NOT_COHERENT_CACHE)
74 tmp |= _PAGE_NO_CACHE;
64#endif 75#endif
65 return tmp; 76 return tmp;
66} 77}
@@ -603,9 +614,6 @@ static int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
603 offset = dev->driver->get_reg_ofs(dev); 614 offset = dev->driver->get_reg_ofs(dev);
604 vma->vm_flags |= VM_IO; /* not in core dump */ 615 vma->vm_flags |= VM_IO; /* not in core dump */
605 vma->vm_page_prot = drm_io_prot(map->type, vma); 616 vma->vm_page_prot = drm_io_prot(map->type, vma);
606#ifdef __sparc__
607 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
608#endif
609 if (io_remap_pfn_range(vma, vma->vm_start, 617 if (io_remap_pfn_range(vma, vma->vm_start,
610 (map->offset + offset) >> PAGE_SHIFT, 618 (map->offset + offset) >> PAGE_SHIFT,
611 vma->vm_end - vma->vm_start, 619 vma->vm_end - vma->vm_start,
@@ -624,6 +632,7 @@ static int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
624 page_to_pfn(virt_to_page(map->handle)), 632 page_to_pfn(virt_to_page(map->handle)),
625 vma->vm_end - vma->vm_start, vma->vm_page_prot)) 633 vma->vm_end - vma->vm_start, vma->vm_page_prot))
626 return -EAGAIN; 634 return -EAGAIN;
635 vma->vm_page_prot = drm_dma_prot(map->type, vma);
627 /* fall through to _DRM_SHM */ 636 /* fall through to _DRM_SHM */
628 case _DRM_SHM: 637 case _DRM_SHM:
629 vma->vm_ops = &drm_vm_shm_ops; 638 vma->vm_ops = &drm_vm_shm_ops;
@@ -631,6 +640,7 @@ static int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
631 /* Don't let this area swap. Change when 640 /* Don't let this area swap. Change when
632 DRM_KERNEL advisory is supported. */ 641 DRM_KERNEL advisory is supported. */
633 vma->vm_flags |= VM_RESERVED; 642 vma->vm_flags |= VM_RESERVED;
643 vma->vm_page_prot = drm_dma_prot(map->type, vma);
634 break; 644 break;
635 case _DRM_SCATTER_GATHER: 645 case _DRM_SCATTER_GATHER:
636 vma->vm_ops = &drm_vm_sg_ops; 646 vma->vm_ops = &drm_vm_sg_ops;