aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlistair Popple <alistair@popple.id.au>2017-07-26 01:26:40 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2017-07-28 09:02:55 -0400
commit253fd51e2f533552ae35a0c661705da6c4842c1b (patch)
tree7165717bcfc44642ddf21a3fd5afa7877fb59840
parent65c5ec11c25eff6ba6e9b1cbfff014875fddd1e0 (diff)
powerpc/powernv/pci: Return failure for some uses of dma_set_mask()
Commit 8e3f1b1d8255 ("powerpc/powernv/pci: Enable 64-bit devices to access >4GB DMA space") introduced the ability for PCI device drivers to request a DMA mask between 64 and 32 bits and actually get a mask greater than 32-bits. However currently if certain machine configuration dependent conditions are not meet the code silently falls back to a 32-bit mask. This makes it hard for device drivers to detect which mask they actually got. Instead we should return an error when the request could not be fulfilled which allows drivers to either fallback or implement other workarounds as documented in DMA-API-HOWTO.txt. Signed-off-by: Alistair Popple <alistair@popple.id.au> Acked-by: Russell Currey <ruscur@russell.cc> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r--arch/powerpc/platforms/powernv/pci-ioda.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 437613588df1..b900eb1d5e17 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1852,6 +1852,14 @@ static int pnv_pci_ioda_dma_set_mask(struct pci_dev *pdev, u64 dma_mask)
1852 /* 4GB offset bypasses 32-bit space */ 1852 /* 4GB offset bypasses 32-bit space */
1853 set_dma_offset(&pdev->dev, (1ULL << 32)); 1853 set_dma_offset(&pdev->dev, (1ULL << 32));
1854 set_dma_ops(&pdev->dev, &dma_direct_ops); 1854 set_dma_ops(&pdev->dev, &dma_direct_ops);
1855 } else if (dma_mask >> 32 && dma_mask != DMA_BIT_MASK(64)) {
1856 /*
1857 * Fail the request if a DMA mask between 32 and 64 bits
1858 * was requested but couldn't be fulfilled. Ideally we
1859 * would do this for 64-bits but historically we have
1860 * always fallen back to 32-bits.
1861 */
1862 return -ENOMEM;
1855 } else { 1863 } else {
1856 dev_info(&pdev->dev, "Using 32-bit DMA via iommu\n"); 1864 dev_info(&pdev->dev, "Using 32-bit DMA via iommu\n");
1857 set_dma_ops(&pdev->dev, &dma_iommu_ops); 1865 set_dma_ops(&pdev->dev, &dma_iommu_ops);