Commit b3c73856ae47d43d0d181f9de1c1c6c0820c4515

Authored by Nishanth Aravamudan
Committed by Benjamin Herrenschmidt
1 parent 56d8adc569

powerpc/iommu: Use coherent_dma_mask for alloc_coherent

The IOMMU code has been passing the dma-mask instead of the
coherent_dma_mask to the iommu allocator.  Coherent allocations should
be made using the coherent_dma_mask.

Also update the vio code to ensure the coherent_dma_mask is set. Without
this change drivers, such as ibmvscsi, fail to load with the corrected
dma_iommu_alloc_coherent().

Signed-off-by: Milton Miller <miltonm@bga.com>
Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Showing 2 changed files with 5 additions and 1 deletions Side-by-side Diff

arch/powerpc/kernel/dma-iommu.c
... ... @@ -19,7 +19,7 @@
19 19 dma_addr_t *dma_handle, gfp_t flag)
20 20 {
21 21 return iommu_alloc_coherent(dev, get_iommu_table_base(dev), size,
22   - dma_handle, device_to_mask(dev), flag,
  22 + dma_handle, dev->coherent_dma_mask, flag,
23 23 dev_to_node(dev));
24 24 }
25 25  
arch/powerpc/kernel/vio.c
... ... @@ -1257,6 +1257,10 @@
1257 1257 viodev->dev.parent = &vio_bus_device.dev;
1258 1258 viodev->dev.bus = &vio_bus_type;
1259 1259 viodev->dev.release = vio_dev_release;
  1260 + /* needed to ensure proper operation of coherent allocations
  1261 + * later, in case driver doesn't set it explicitly */
  1262 + dma_set_mask(&viodev->dev, DMA_BIT_MASK(64));
  1263 + dma_set_coherent_mask(&viodev->dev, DMA_BIT_MASK(64));
1260 1264  
1261 1265 /* register with generic device framework */
1262 1266 if (device_register(&viodev->dev)) {