Skip to content

Commit

Permalink
[POWERPC] Fix potential cell IOMMU bug when switching back to default…
Browse files Browse the repository at this point in the history
… DMA ops

If we get a 64-bit dma mask we switch to the fixed ops and call
cell_dma_dev_setup().  If the driver then switches back to a 32-bit dma
mask for any reason we don't call cell_dma_dev_setup() again, which
has the potential to leave bogus data in dev->archdata.dma_data.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
Michael Ellerman authored and Paul Mackerras committed Feb 8, 2008
1 parent 0e0b47a commit 4a8df15
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions arch/powerpc/platforms/cell/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -841,19 +841,18 @@ static int dma_set_mask_and_switch(struct device *dev, u64 dma_mask)
if (!dev->dma_mask || !dma_supported(dev, dma_mask))
return -EIO;

if (dma_mask == DMA_BIT_MASK(64)) {
if (cell_iommu_get_fixed_address(dev) == OF_BAD_ADDR)
dev_dbg(dev, "iommu: 64-bit OK, but bad addr\n");
else {
dev_dbg(dev, "iommu: 64-bit OK, using fixed ops\n");
set_dma_ops(dev, &dma_iommu_fixed_ops);
cell_dma_dev_setup(dev);
}
if (dma_mask == DMA_BIT_MASK(64) &&
cell_iommu_get_fixed_address(dev) != OF_BAD_ADDR)
{
dev_dbg(dev, "iommu: 64-bit OK, using fixed ops\n");
set_dma_ops(dev, &dma_iommu_fixed_ops);
} else {
dev_dbg(dev, "iommu: not 64-bit, using default ops\n");
set_dma_ops(dev, get_pci_dma_ops());
}

cell_dma_dev_setup(dev);

*dev->dma_mask = dma_mask;

return 0;
Expand Down

0 comments on commit 4a8df15

Please sign in to comment.