Commit d588ba8c authored by Muli Ben-Yehuda's avatar Muli Ben-Yehuda Committed by Thomas Gleixner

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: default avatarMuli Ben-Yehuda <muli@il.ibm.com>
Acked-by: default avatarMurillo Fernandes Bernardes <bernarde@br.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 84e0fdb1
...@@ -222,6 +222,12 @@ static inline unsigned int num_dma_pages(unsigned long dma, unsigned int dmalen) ...@@ -222,6 +222,12 @@ static inline unsigned int num_dma_pages(unsigned long dma, unsigned int dmalen)
return npages; return npages;
} }
static inline int translation_enabled(struct iommu_table *tbl)
{
/* only PHBs with translation enabled have an IOMMU table */
return (tbl != NULL);
}
static inline int translate_phb(struct pci_dev* dev) static inline int translate_phb(struct pci_dev* dev)
{ {
int disabled = bus_info[dev->bus->number].translation_disabled; int disabled = bus_info[dev->bus->number].translation_disabled;
...@@ -388,7 +394,7 @@ static void calgary_unmap_sg(struct device *dev, ...@@ -388,7 +394,7 @@ static void calgary_unmap_sg(struct device *dev,
struct scatterlist *s; struct scatterlist *s;
int i; int i;
if (!translate_phb(to_pci_dev(dev))) if (!translate_enabled(tbl))
return; return;
for_each_sg(sglist, s, nelems, i) { for_each_sg(sglist, s, nelems, i) {
...@@ -428,7 +434,7 @@ static int calgary_map_sg(struct device *dev, struct scatterlist *sg, ...@@ -428,7 +434,7 @@ static int calgary_map_sg(struct device *dev, struct scatterlist *sg,
unsigned long entry; unsigned long entry;
int i; int i;
if (!translate_phb(to_pci_dev(dev))) if (!translation_enabled(tbl))
return calgary_nontranslate_map_sg(dev, sg, nelems, direction); return calgary_nontranslate_map_sg(dev, sg, nelems, direction);
for_each_sg(sg, s, nelems, i) { for_each_sg(sg, s, nelems, i) {
...@@ -474,7 +480,7 @@ static dma_addr_t calgary_map_single(struct device *dev, void *vaddr, ...@@ -474,7 +480,7 @@ static dma_addr_t calgary_map_single(struct device *dev, void *vaddr,
uaddr = (unsigned long)vaddr; uaddr = (unsigned long)vaddr;
npages = num_dma_pages(uaddr, size); npages = num_dma_pages(uaddr, size);
if (translate_phb(to_pci_dev(dev))) if (translation_enabled(tbl))
dma_handle = iommu_alloc(tbl, vaddr, npages, direction); dma_handle = iommu_alloc(tbl, vaddr, npages, direction);
else else
dma_handle = virt_to_bus(vaddr); dma_handle = virt_to_bus(vaddr);
...@@ -488,7 +494,7 @@ static void calgary_unmap_single(struct device *dev, dma_addr_t dma_handle, ...@@ -488,7 +494,7 @@ static void calgary_unmap_single(struct device *dev, dma_addr_t dma_handle,
struct iommu_table *tbl = find_iommu_table(dev); struct iommu_table *tbl = find_iommu_table(dev);
unsigned int npages; unsigned int npages;
if (!translate_phb(to_pci_dev(dev))) if (!translation_enabled(tbl))
return; return;
npages = num_dma_pages(dma_handle, size); npages = num_dma_pages(dma_handle, size);
...@@ -513,7 +519,7 @@ static void* calgary_alloc_coherent(struct device *dev, size_t size, ...@@ -513,7 +519,7 @@ static void* calgary_alloc_coherent(struct device *dev, size_t size,
goto error; goto error;
memset(ret, 0, size); memset(ret, 0, size);
if (translate_phb(to_pci_dev(dev))) { if (translation_enabled(tbl)) {
/* set up tces to cover the allocated range */ /* set up tces to cover the allocated range */
mapping = iommu_alloc(tbl, ret, npages, DMA_BIDIRECTIONAL); mapping = iommu_alloc(tbl, ret, npages, DMA_BIDIRECTIONAL);
if (mapping == bad_dma_address) if (mapping == bad_dma_address)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment