aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ati_pcigart.c
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2009-04-05 02:14:15 -0400
committerLen Brown <len.brown@intel.com>2009-04-05 02:14:15 -0400
commit478c6a43fcbc6c11609f8cee7c7b57223907754f (patch)
treea7f7952099da60d33032aed6de9c0c56c9f8779e /drivers/gpu/drm/ati_pcigart.c
parent8a3f257c704e02aee9869decd069a806b45be3f1 (diff)
parent6bb597507f9839b13498781e481f5458aea33620 (diff)
Merge branch 'linus' into release
Conflicts: arch/x86/kernel/cpu/cpufreq/longhaul.c Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/gpu/drm/ati_pcigart.c')
-rw-r--r--drivers/gpu/drm/ati_pcigart.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/drivers/gpu/drm/ati_pcigart.c b/drivers/gpu/drm/ati_pcigart.c
index c533d0c9ec61..628eae3e9b83 100644
--- a/drivers/gpu/drm/ati_pcigart.c
+++ b/drivers/gpu/drm/ati_pcigart.c
@@ -77,7 +77,7 @@ int drm_ati_pcigart_cleanup(struct drm_device *dev, struct drm_ati_pcigart_info
77 if (!entry->busaddr[i]) 77 if (!entry->busaddr[i])
78 break; 78 break;
79 pci_unmap_page(dev->pdev, entry->busaddr[i], 79 pci_unmap_page(dev->pdev, entry->busaddr[i],
80 PAGE_SIZE, PCI_DMA_TODEVICE); 80 PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
81 } 81 }
82 82
83 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) 83 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN)
@@ -95,13 +95,14 @@ EXPORT_SYMBOL(drm_ati_pcigart_cleanup);
95 95
96int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info) 96int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info)
97{ 97{
98 struct drm_local_map *map = &gart_info->mapping;
98 struct drm_sg_mem *entry = dev->sg; 99 struct drm_sg_mem *entry = dev->sg;
99 void *address = NULL; 100 void *address = NULL;
100 unsigned long pages; 101 unsigned long pages;
101 u32 *pci_gart, page_base; 102 u32 *pci_gart = NULL, page_base, gart_idx;
102 dma_addr_t bus_address = 0; 103 dma_addr_t bus_address = 0;
103 int i, j, ret = 0; 104 int i, j, ret = 0;
104 int max_pages; 105 int max_ati_pages, max_real_pages;
105 106
106 if (!entry) { 107 if (!entry) {
107 DRM_ERROR("no scatter/gather memory!\n"); 108 DRM_ERROR("no scatter/gather memory!\n");
@@ -117,6 +118,7 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga
117 goto done; 118 goto done;
118 } 119 }
119 120
121 pci_gart = gart_info->table_handle->vaddr;
120 address = gart_info->table_handle->vaddr; 122 address = gart_info->table_handle->vaddr;
121 bus_address = gart_info->table_handle->busaddr; 123 bus_address = gart_info->table_handle->busaddr;
122 } else { 124 } else {
@@ -127,18 +129,23 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga
127 (unsigned long)address); 129 (unsigned long)address);
128 } 130 }
129 131
130 pci_gart = (u32 *) address;
131 132
132 max_pages = (gart_info->table_size / sizeof(u32)); 133 max_ati_pages = (gart_info->table_size / sizeof(u32));
133 pages = (entry->pages <= max_pages) 134 max_real_pages = max_ati_pages / (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE);
134 ? entry->pages : max_pages; 135 pages = (entry->pages <= max_real_pages)
136 ? entry->pages : max_real_pages;
135 137
136 memset(pci_gart, 0, max_pages * sizeof(u32)); 138 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) {
139 memset(pci_gart, 0, max_ati_pages * sizeof(u32));
140 } else {
141 memset_io((void __iomem *)map->handle, 0, max_ati_pages * sizeof(u32));
142 }
137 143
144 gart_idx = 0;
138 for (i = 0; i < pages; i++) { 145 for (i = 0; i < pages; i++) {
139 /* we need to support large memory configurations */ 146 /* we need to support large memory configurations */
140 entry->busaddr[i] = pci_map_page(dev->pdev, entry->pagelist[i], 147 entry->busaddr[i] = pci_map_page(dev->pdev, entry->pagelist[i],
141 0, PAGE_SIZE, PCI_DMA_TODEVICE); 148 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
142 if (entry->busaddr[i] == 0) { 149 if (entry->busaddr[i] == 0) {
143 DRM_ERROR("unable to map PCIGART pages!\n"); 150 DRM_ERROR("unable to map PCIGART pages!\n");
144 drm_ati_pcigart_cleanup(dev, gart_info); 151 drm_ati_pcigart_cleanup(dev, gart_info);
@@ -149,19 +156,26 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga
149 page_base = (u32) entry->busaddr[i]; 156 page_base = (u32) entry->busaddr[i];
150 157
151 for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) { 158 for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) {
159 u32 val;
160
152 switch(gart_info->gart_reg_if) { 161 switch(gart_info->gart_reg_if) {
153 case DRM_ATI_GART_IGP: 162 case DRM_ATI_GART_IGP:
154 *pci_gart = cpu_to_le32((page_base) | 0xc); 163 val = page_base | 0xc;
155 break; 164 break;
156 case DRM_ATI_GART_PCIE: 165 case DRM_ATI_GART_PCIE:
157 *pci_gart = cpu_to_le32((page_base >> 8) | 0xc); 166 val = (page_base >> 8) | 0xc;
158 break; 167 break;
159 default: 168 default:
160 case DRM_ATI_GART_PCI: 169 case DRM_ATI_GART_PCI:
161 *pci_gart = cpu_to_le32(page_base); 170 val = page_base;
162 break; 171 break;
163 } 172 }
164 pci_gart++; 173 if (gart_info->gart_table_location ==
174 DRM_ATI_GART_MAIN)
175 pci_gart[gart_idx] = cpu_to_le32(val);
176 else
177 DRM_WRITE32(map, gart_idx * sizeof(u32), val);
178 gart_idx++;
165 page_base += ATI_PCIGART_PAGE_SIZE; 179 page_base += ATI_PCIGART_PAGE_SIZE;
166 } 180 }
167 } 181 }