51
51
#include <asm/x86_init.h>
52
52
#include <asm/iommu_table.h>
53
53
54
- #define CALGARY_MAPPING_ERROR 0
55
-
56
54
#ifdef CONFIG_CALGARY_IOMMU_ENABLED_BY_DEFAULT
57
55
int use_calgary __read_mostly = 1 ;
58
56
#else
@@ -157,8 +155,6 @@ static const unsigned long phb_debug_offsets[] = {
157
155
158
156
#define PHB_DEBUG_STUFF_OFFSET 0x0020
159
157
160
- #define EMERGENCY_PAGES 32 /* = 128KB */
161
-
162
158
unsigned int specified_table_size = TCE_TABLE_SIZE_UNSPECIFIED ;
163
159
static int translate_empty_slots __read_mostly = 0 ;
164
160
static int calgary_detected __read_mostly = 0 ;
@@ -255,7 +251,7 @@ static unsigned long iommu_range_alloc(struct device *dev,
255
251
if (panic_on_overflow )
256
252
panic ("Calgary: fix the allocator.\n" );
257
253
else
258
- return CALGARY_MAPPING_ERROR ;
254
+ return DMA_MAPPING_ERROR ;
259
255
}
260
256
}
261
257
@@ -274,11 +270,10 @@ static dma_addr_t iommu_alloc(struct device *dev, struct iommu_table *tbl,
274
270
dma_addr_t ret ;
275
271
276
272
entry = iommu_range_alloc (dev , tbl , npages );
277
-
278
- if (unlikely (entry == CALGARY_MAPPING_ERROR )) {
273
+ if (unlikely (entry == DMA_MAPPING_ERROR )) {
279
274
pr_warn ("failed to allocate %u pages in iommu %p\n" ,
280
275
npages , tbl );
281
- return CALGARY_MAPPING_ERROR ;
276
+ return DMA_MAPPING_ERROR ;
282
277
}
283
278
284
279
/* set the return dma address */
@@ -294,12 +289,10 @@ static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
294
289
unsigned int npages )
295
290
{
296
291
unsigned long entry ;
297
- unsigned long badend ;
298
292
unsigned long flags ;
299
293
300
294
/* were we called with bad_dma_address? */
301
- badend = CALGARY_MAPPING_ERROR + (EMERGENCY_PAGES * PAGE_SIZE );
302
- if (unlikely (dma_addr < badend )) {
295
+ if (unlikely (dma_addr == DMA_MAPPING_ERROR )) {
303
296
WARN (1 , KERN_ERR "Calgary: driver tried unmapping bad DMA "
304
297
"address 0x%Lx\n" , dma_addr );
305
298
return ;
@@ -383,7 +376,7 @@ static int calgary_map_sg(struct device *dev, struct scatterlist *sg,
383
376
npages = iommu_num_pages (vaddr , s -> length , PAGE_SIZE );
384
377
385
378
entry = iommu_range_alloc (dev , tbl , npages );
386
- if (entry == CALGARY_MAPPING_ERROR ) {
379
+ if (entry == DMA_MAPPING_ERROR ) {
387
380
/* makes sure unmap knows to stop */
388
381
s -> dma_length = 0 ;
389
382
goto error ;
@@ -401,7 +394,7 @@ static int calgary_map_sg(struct device *dev, struct scatterlist *sg,
401
394
error :
402
395
calgary_unmap_sg (dev , sg , nelems , dir , 0 );
403
396
for_each_sg (sg , s , nelems , i ) {
404
- sg -> dma_address = CALGARY_MAPPING_ERROR ;
397
+ sg -> dma_address = DMA_MAPPING_ERROR ;
405
398
sg -> dma_length = 0 ;
406
399
}
407
400
return 0 ;
@@ -454,7 +447,7 @@ static void* calgary_alloc_coherent(struct device *dev, size_t size,
454
447
455
448
/* set up tces to cover the allocated range */
456
449
mapping = iommu_alloc (dev , tbl , ret , npages , DMA_BIDIRECTIONAL );
457
- if (mapping == CALGARY_MAPPING_ERROR )
450
+ if (mapping == DMA_MAPPING_ERROR )
458
451
goto free ;
459
452
* dma_handle = mapping ;
460
453
return ret ;
@@ -479,19 +472,13 @@ static void calgary_free_coherent(struct device *dev, size_t size,
479
472
free_pages ((unsigned long )vaddr , get_order (size ));
480
473
}
481
474
482
- static int calgary_mapping_error (struct device * dev , dma_addr_t dma_addr )
483
- {
484
- return dma_addr == CALGARY_MAPPING_ERROR ;
485
- }
486
-
487
475
static const struct dma_map_ops calgary_dma_ops = {
488
476
.alloc = calgary_alloc_coherent ,
489
477
.free = calgary_free_coherent ,
490
478
.map_sg = calgary_map_sg ,
491
479
.unmap_sg = calgary_unmap_sg ,
492
480
.map_page = calgary_map_page ,
493
481
.unmap_page = calgary_unmap_page ,
494
- .mapping_error = calgary_mapping_error ,
495
482
.dma_supported = dma_direct_supported ,
496
483
};
497
484
@@ -739,9 +726,6 @@ static void __init calgary_reserve_regions(struct pci_dev *dev)
739
726
u64 start ;
740
727
struct iommu_table * tbl = pci_iommu (dev -> bus );
741
728
742
- /* reserve EMERGENCY_PAGES from bad_dma_address and up */
743
- iommu_range_reserve (tbl , CALGARY_MAPPING_ERROR , EMERGENCY_PAGES );
744
-
745
729
/* avoid the BIOS/VGA first 640KB-1MB region */
746
730
/* for CalIOC2 - avoid the entire first MB */
747
731
if (is_calgary (dev -> device )) {
0 commit comments