aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/pci-calgary_64.c
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2009-11-15 07:19:53 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-17 01:53:21 -0500
commit8fd524b355daef0945692227e726fb444cebcd4f (patch)
treed9c067e6e2693d46b70010a4ed2910205a59c92d /arch/x86/kernel/pci-calgary_64.c
parent42109197eb7c01080eea6d9cd48ca23cbc3c566c (diff)
x86: Kill bad_dma_address variable
This kills bad_dma_address variable, the old mechanism to enable IOMMU drivers to make dma_mapping_error() work in IOMMU's specific way. bad_dma_address variable was introduced to enable IOMMU drivers to make dma_mapping_error() work in IOMMU's specific way. However, it can't handle systems that use both swiotlb and HW IOMMU. SO we introduced dma_map_ops->mapping_error to solve that case. Intel VT-d, GART, and swiotlb already use dma_map_ops->mapping_error. Calgary, AMD IOMMU, and nommu use zero for an error dma address. This adds DMA_ERROR_CODE and converts them to use it (as SPARC and POWER does). Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org> Cc: muli@il.ibm.com Cc: joerg.roedel@amd.com LKML-Reference: <1258287594-8777-3-git-send-email-fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/pci-calgary_64.c')
-rw-r--r--arch/x86/kernel/pci-calgary_64.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index c84ad037f586..af9f436096a2 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -245,7 +245,7 @@ static unsigned long iommu_range_alloc(struct device *dev,
245 if (panic_on_overflow) 245 if (panic_on_overflow)
246 panic("Calgary: fix the allocator.\n"); 246 panic("Calgary: fix the allocator.\n");
247 else 247 else
248 return bad_dma_address; 248 return DMA_ERROR_CODE;
249 } 249 }
250 } 250 }
251 251
@@ -261,11 +261,11 @@ static dma_addr_t iommu_alloc(struct device *dev, struct iommu_table *tbl,
261 void *vaddr, unsigned int npages, int direction) 261 void *vaddr, unsigned int npages, int direction)
262{ 262{
263 unsigned long entry; 263 unsigned long entry;
264 dma_addr_t ret = bad_dma_address; 264 dma_addr_t ret = DMA_ERROR_CODE;
265 265
266 entry = iommu_range_alloc(dev, tbl, npages); 266 entry = iommu_range_alloc(dev, tbl, npages);
267 267
268 if (unlikely(entry == bad_dma_address)) 268 if (unlikely(entry == DMA_ERROR_CODE))
269 goto error; 269 goto error;
270 270
271 /* set the return dma address */ 271 /* set the return dma address */
@@ -280,7 +280,7 @@ static dma_addr_t iommu_alloc(struct device *dev, struct iommu_table *tbl,
280error: 280error:
281 printk(KERN_WARNING "Calgary: failed to allocate %u pages in " 281 printk(KERN_WARNING "Calgary: failed to allocate %u pages in "
282 "iommu %p\n", npages, tbl); 282 "iommu %p\n", npages, tbl);
283 return bad_dma_address; 283 return DMA_ERROR_CODE;
284} 284}
285 285
286static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr, 286static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
@@ -291,8 +291,8 @@ static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
291 unsigned long flags; 291 unsigned long flags;
292 292
293 /* were we called with bad_dma_address? */ 293 /* were we called with bad_dma_address? */
294 badend = bad_dma_address + (EMERGENCY_PAGES * PAGE_SIZE); 294 badend = DMA_ERROR_CODE + (EMERGENCY_PAGES * PAGE_SIZE);
295 if (unlikely((dma_addr >= bad_dma_address) && (dma_addr < badend))) { 295 if (unlikely((dma_addr >= DMA_ERROR_CODE) && (dma_addr < badend))) {
296 WARN(1, KERN_ERR "Calgary: driver tried unmapping bad DMA " 296 WARN(1, KERN_ERR "Calgary: driver tried unmapping bad DMA "
297 "address 0x%Lx\n", dma_addr); 297 "address 0x%Lx\n", dma_addr);
298 return; 298 return;
@@ -374,7 +374,7 @@ static int calgary_map_sg(struct device *dev, struct scatterlist *sg,
374 npages = iommu_num_pages(vaddr, s->length, PAGE_SIZE); 374 npages = iommu_num_pages(vaddr, s->length, PAGE_SIZE);
375 375
376 entry = iommu_range_alloc(dev, tbl, npages); 376 entry = iommu_range_alloc(dev, tbl, npages);
377 if (entry == bad_dma_address) { 377 if (entry == DMA_ERROR_CODE) {
378 /* makes sure unmap knows to stop */ 378 /* makes sure unmap knows to stop */
379 s->dma_length = 0; 379 s->dma_length = 0;
380 goto error; 380 goto error;
@@ -392,7 +392,7 @@ static int calgary_map_sg(struct device *dev, struct scatterlist *sg,
392error: 392error:
393 calgary_unmap_sg(dev, sg, nelems, dir, NULL); 393 calgary_unmap_sg(dev, sg, nelems, dir, NULL);
394 for_each_sg(sg, s, nelems, i) { 394 for_each_sg(sg, s, nelems, i) {
395 sg->dma_address = bad_dma_address; 395 sg->dma_address = DMA_ERROR_CODE;
396 sg->dma_length = 0; 396 sg->dma_length = 0;
397 } 397 }
398 return 0; 398 return 0;
@@ -447,7 +447,7 @@ static void* calgary_alloc_coherent(struct device *dev, size_t size,
447 447
448 /* set up tces to cover the allocated range */ 448 /* set up tces to cover the allocated range */
449 mapping = iommu_alloc(dev, tbl, ret, npages, DMA_BIDIRECTIONAL); 449 mapping = iommu_alloc(dev, tbl, ret, npages, DMA_BIDIRECTIONAL);
450 if (mapping == bad_dma_address) 450 if (mapping == DMA_ERROR_CODE)
451 goto free; 451 goto free;
452 *dma_handle = mapping; 452 *dma_handle = mapping;
453 return ret; 453 return ret;
@@ -728,7 +728,7 @@ static void __init calgary_reserve_regions(struct pci_dev *dev)
728 struct iommu_table *tbl = pci_iommu(dev->bus); 728 struct iommu_table *tbl = pci_iommu(dev->bus);
729 729
730 /* reserve EMERGENCY_PAGES from bad_dma_address and up */ 730 /* reserve EMERGENCY_PAGES from bad_dma_address and up */
731 iommu_range_reserve(tbl, bad_dma_address, EMERGENCY_PAGES); 731 iommu_range_reserve(tbl, DMA_ERROR_CODE, EMERGENCY_PAGES);
732 732
733 /* avoid the BIOS/VGA first 640KB-1MB region */ 733 /* avoid the BIOS/VGA first 640KB-1MB region */
734 /* for CalIOC2 - avoid the entire first MB */ 734 /* for CalIOC2 - avoid the entire first MB */
@@ -1359,8 +1359,6 @@ static int __init calgary_iommu_init(void)
1359 return ret; 1359 return ret;
1360 } 1360 }
1361 1361
1362 bad_dma_address = 0x0;
1363
1364 return 0; 1362 return 0;
1365} 1363}
1366 1364