diff options
author | Muli Ben-Yehuda <muli@il.ibm.com> | 2007-07-21 11:10:51 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-21 21:37:11 -0400 |
commit | 35b6dfa08736e8a362b9d41ff52ffa1eb36505a9 (patch) | |
tree | 773586a7d26873b4b180242118ab7f94e9c4485d /arch/x86_64/kernel/pci-calgary.c | |
parent | ff297b8c081bdc60507eaeb1838996e0c67141c8 (diff) |
x86_64: abstract how we find the iommu_table for a device
... in preparation for doing it differently for CalIOC2.
Signed-off-by: Muli Ben-Yehuda <muli@il.ibm.com>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/x86_64/kernel/pci-calgary.c')
-rw-r--r-- | arch/x86_64/kernel/pci-calgary.c | 21 |
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 | ||
347 | static 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 | |||
347 | static void __calgary_unmap_sg(struct iommu_table *tbl, | 356 | static 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, | |||
394 | int calgary_map_sg(struct device *dev, struct scatterlist *sg, | 403 | int 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, | |||
464 | void calgary_unmap_single(struct device *dev, dma_addr_t dma_handle, | 473 | void 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; |