aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64')
-rw-r--r--arch/x86_64/kernel/pci-calgary.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/arch/x86_64/kernel/pci-calgary.c b/arch/x86_64/kernel/pci-calgary.c
index 7218b5b51e08..a2828e156c3d 100644
--- a/arch/x86_64/kernel/pci-calgary.c
+++ b/arch/x86_64/kernel/pci-calgary.c
@@ -344,6 +344,15 @@ static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
344 spin_unlock_irqrestore(&tbl->it_lock, flags); 344 spin_unlock_irqrestore(&tbl->it_lock, flags);
345} 345}
346 346
347static inline struct iommu_table *find_iommu_table(struct device *dev)
348{
349 struct iommu_table *tbl;
350
351 tbl = to_pci_dev(dev)->bus->self->sysdata;
352
353 return tbl;
354}
355
347static void __calgary_unmap_sg(struct iommu_table *tbl, 356static void __calgary_unmap_sg(struct iommu_table *tbl,
348 struct scatterlist *sglist, int nelems, int direction) 357 struct scatterlist *sglist, int nelems, int direction)
349{ 358{
@@ -365,7 +374,7 @@ void calgary_unmap_sg(struct device *dev, struct scatterlist *sglist,
365 int nelems, int direction) 374 int nelems, int direction)
366{ 375{
367 unsigned long flags; 376 unsigned long flags;
368 struct iommu_table *tbl = to_pci_dev(dev)->bus->self->sysdata; 377 struct iommu_table *tbl = find_iommu_table(dev);
369 378
370 if (!translate_phb(to_pci_dev(dev))) 379 if (!translate_phb(to_pci_dev(dev)))
371 return; 380 return;
@@ -394,7 +403,7 @@ static int calgary_nontranslate_map_sg(struct device* dev,
394int calgary_map_sg(struct device *dev, struct scatterlist *sg, 403int calgary_map_sg(struct device *dev, struct scatterlist *sg,
395 int nelems, int direction) 404 int nelems, int direction)
396{ 405{
397 struct iommu_table *tbl = to_pci_dev(dev)->bus->self->sysdata; 406 struct iommu_table *tbl = find_iommu_table(dev);
398 unsigned long flags; 407 unsigned long flags;
399 unsigned long vaddr; 408 unsigned long vaddr;
400 unsigned int npages; 409 unsigned int npages;
@@ -448,7 +457,7 @@ dma_addr_t calgary_map_single(struct device *dev, void *vaddr,
448 dma_addr_t dma_handle = bad_dma_address; 457 dma_addr_t dma_handle = bad_dma_address;
449 unsigned long uaddr; 458 unsigned long uaddr;
450 unsigned int npages; 459 unsigned int npages;
451 struct iommu_table *tbl = to_pci_dev(dev)->bus->self->sysdata; 460 struct iommu_table *tbl = find_iommu_table(dev);
452 461
453 uaddr = (unsigned long)vaddr; 462 uaddr = (unsigned long)vaddr;
454 npages = num_dma_pages(uaddr, size); 463 npages = num_dma_pages(uaddr, size);
@@ -464,7 +473,7 @@ dma_addr_t calgary_map_single(struct device *dev, void *vaddr,
464void calgary_unmap_single(struct device *dev, dma_addr_t dma_handle, 473void calgary_unmap_single(struct device *dev, dma_addr_t dma_handle,
465 size_t size, int direction) 474 size_t size, int direction)
466{ 475{
467 struct iommu_table *tbl = to_pci_dev(dev)->bus->self->sysdata; 476 struct iommu_table *tbl = find_iommu_table(dev);
468 unsigned int npages; 477 unsigned int npages;
469 478
470 if (!translate_phb(to_pci_dev(dev))) 479 if (!translate_phb(to_pci_dev(dev)))
@@ -480,9 +489,7 @@ void* calgary_alloc_coherent(struct device *dev, size_t size,
480 void *ret = NULL; 489 void *ret = NULL;
481 dma_addr_t mapping; 490 dma_addr_t mapping;
482 unsigned int npages, order; 491 unsigned int npages, order;
483 struct iommu_table *tbl; 492 struct iommu_table *tbl = find_iommu_table(dev);
484
485 tbl = to_pci_dev(dev)->bus->self->sysdata;
486 493
487 size = PAGE_ALIGN(size); /* size rounded up to full pages */ 494 size = PAGE_ALIGN(size); /* size rounded up to full pages */
488 npages = size >> PAGE_SHIFT; 495 npages = size >> PAGE_SHIFT;