]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/of/device.c
of: fix DMA mask generation
[karo-tx-linux.git] / drivers / of / device.c
index 9416d052cb89474e811d8c4e8ca5ca3a81732fbb..e0a28ea341fe95e84a866559dad8e317c8056401 100644 (file)
@@ -89,6 +89,7 @@ int of_dma_configure(struct device *dev, struct device_node *np)
        bool coherent;
        unsigned long offset;
        const struct iommu_ops *iommu;
+       u64 mask;
 
        /*
         * Set default coherent_dma_mask to 32 bit.  Drivers are expected to
@@ -134,18 +135,17 @@ int of_dma_configure(struct device *dev, struct device_node *np)
         * Limit coherent and dma mask based on size and default mask
         * set by the driver.
         */
-       dev->coherent_dma_mask = min(dev->coherent_dma_mask,
-                                    DMA_BIT_MASK(ilog2(dma_addr + size)));
-       *dev->dma_mask = min((*dev->dma_mask),
-                            DMA_BIT_MASK(ilog2(dma_addr + size)));
+       mask = DMA_BIT_MASK(ilog2(dma_addr + size - 1) + 1);
+       dev->coherent_dma_mask &= mask;
+       *dev->dma_mask &= mask;
 
        coherent = of_dma_is_coherent(np);
        dev_dbg(dev, "device is%sdma coherent\n",
                coherent ? " " : " not ");
 
        iommu = of_iommu_configure(dev, np);
-       if (IS_ERR(iommu))
-               return PTR_ERR(iommu);
+       if (IS_ERR(iommu) && PTR_ERR(iommu) == -EPROBE_DEFER)
+               return -EPROBE_DEFER;
 
        dev_dbg(dev, "device is%sbehind an iommu\n",
                iommu ? " " : " not ");