diff options
author | Muli Ben-Yehuda <muli@il.ibm.com> | 2007-10-17 12:04:35 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@inhelltoy.tec.linutronix.de> | 2007-10-17 14:15:45 -0400 |
commit | d588ba8c09aa2516a06512d8ba065a05f9620ee0 (patch) | |
tree | 7a9f5f1435540e86577a26b6649a185ce0e3e6f5 /arch/x86/kernel/pci-calgary_64.c | |
parent | 84e0fdb1754d066dd0a8b257de7299f392d1e727 (diff) |
x86: Calgary: fix disable busnum for CalIOC2
The old check we used based on dev->bus->number is wrong for devices on
CalIOC2. Instead look whether we have an IOMMU table for that bus - if
not, translation is disabled.
Thanks to Murillo Fernandes Bernardes <bernarde@br.ibm.com> for
spotting, suggesting a fix and testing.
Signed-off-by: Muli Ben-Yehuda <muli@il.ibm.com>
Acked-by: Murillo Fernandes Bernardes <bernarde@br.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/pci-calgary_64.c')
-rw-r--r-- | arch/x86/kernel/pci-calgary_64.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c index a50b787b3bfa..ef05cc32a3a9 100644 --- a/arch/x86/kernel/pci-calgary_64.c +++ b/arch/x86/kernel/pci-calgary_64.c | |||
@@ -222,6 +222,12 @@ static inline unsigned int num_dma_pages(unsigned long dma, unsigned int dmalen) | |||
222 | return npages; | 222 | return npages; |
223 | } | 223 | } |
224 | 224 | ||
225 | static inline int translation_enabled(struct iommu_table *tbl) | ||
226 | { | ||
227 | /* only PHBs with translation enabled have an IOMMU table */ | ||
228 | return (tbl != NULL); | ||
229 | } | ||
230 | |||
225 | static inline int translate_phb(struct pci_dev* dev) | 231 | static inline int translate_phb(struct pci_dev* dev) |
226 | { | 232 | { |
227 | int disabled = bus_info[dev->bus->number].translation_disabled; | 233 | int disabled = bus_info[dev->bus->number].translation_disabled; |
@@ -388,7 +394,7 @@ static void calgary_unmap_sg(struct device *dev, | |||
388 | struct scatterlist *s; | 394 | struct scatterlist *s; |
389 | int i; | 395 | int i; |
390 | 396 | ||
391 | if (!translate_phb(to_pci_dev(dev))) | 397 | if (!translate_enabled(tbl)) |
392 | return; | 398 | return; |
393 | 399 | ||
394 | for_each_sg(sglist, s, nelems, i) { | 400 | for_each_sg(sglist, s, nelems, i) { |
@@ -428,7 +434,7 @@ static int calgary_map_sg(struct device *dev, struct scatterlist *sg, | |||
428 | unsigned long entry; | 434 | unsigned long entry; |
429 | int i; | 435 | int i; |
430 | 436 | ||
431 | if (!translate_phb(to_pci_dev(dev))) | 437 | if (!translation_enabled(tbl)) |
432 | return calgary_nontranslate_map_sg(dev, sg, nelems, direction); | 438 | return calgary_nontranslate_map_sg(dev, sg, nelems, direction); |
433 | 439 | ||
434 | for_each_sg(sg, s, nelems, i) { | 440 | for_each_sg(sg, s, nelems, i) { |
@@ -474,7 +480,7 @@ static dma_addr_t calgary_map_single(struct device *dev, void *vaddr, | |||
474 | uaddr = (unsigned long)vaddr; | 480 | uaddr = (unsigned long)vaddr; |
475 | npages = num_dma_pages(uaddr, size); | 481 | npages = num_dma_pages(uaddr, size); |
476 | 482 | ||
477 | if (translate_phb(to_pci_dev(dev))) | 483 | if (translation_enabled(tbl)) |
478 | dma_handle = iommu_alloc(tbl, vaddr, npages, direction); | 484 | dma_handle = iommu_alloc(tbl, vaddr, npages, direction); |
479 | else | 485 | else |
480 | dma_handle = virt_to_bus(vaddr); | 486 | dma_handle = virt_to_bus(vaddr); |
@@ -488,7 +494,7 @@ static void calgary_unmap_single(struct device *dev, dma_addr_t dma_handle, | |||
488 | struct iommu_table *tbl = find_iommu_table(dev); | 494 | struct iommu_table *tbl = find_iommu_table(dev); |
489 | unsigned int npages; | 495 | unsigned int npages; |
490 | 496 | ||
491 | if (!translate_phb(to_pci_dev(dev))) | 497 | if (!translation_enabled(tbl)) |
492 | return; | 498 | return; |
493 | 499 | ||
494 | npages = num_dma_pages(dma_handle, size); | 500 | npages = num_dma_pages(dma_handle, size); |
@@ -513,7 +519,7 @@ static void* calgary_alloc_coherent(struct device *dev, size_t size, | |||
513 | goto error; | 519 | goto error; |
514 | memset(ret, 0, size); | 520 | memset(ret, 0, size); |
515 | 521 | ||
516 | if (translate_phb(to_pci_dev(dev))) { | 522 | if (translation_enabled(tbl)) { |
517 | /* set up tces to cover the allocated range */ | 523 | /* set up tces to cover the allocated range */ |
518 | mapping = iommu_alloc(tbl, ret, npages, DMA_BIDIRECTIONAL); | 524 | mapping = iommu_alloc(tbl, ret, npages, DMA_BIDIRECTIONAL); |
519 | if (mapping == bad_dma_address) | 525 | if (mapping == bad_dma_address) |