Commit 24132a41 authored by Christoph Hellwig's avatar Christoph Hellwig

sparc64/pci_sun4v: allow large DMA masks

We've been moving to a model where the device just sets the DMA mask
supported by it, instead of having to fallback to something it thinks
the platform might support.  Sparc64 is the remaining holdout forcing
drivers to supply a matching mask.  Change dma_4v_supported to just
check if the supplied dma mask is large enough. and adjust the mapping
code to check ATU presence in addition to the DMA mask to decide on
the mapping method.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 254ecb16
...@@ -92,7 +92,7 @@ static long iommu_batch_flush(struct iommu_batch *p, u64 mask) ...@@ -92,7 +92,7 @@ static long iommu_batch_flush(struct iommu_batch *p, u64 mask)
prot &= (HV_PCI_MAP_ATTR_READ | HV_PCI_MAP_ATTR_WRITE); prot &= (HV_PCI_MAP_ATTR_READ | HV_PCI_MAP_ATTR_WRITE);
while (npages != 0) { while (npages != 0) {
if (mask <= DMA_BIT_MASK(32)) { if (mask <= DMA_BIT_MASK(32) || !pbm->iommu->atu) {
num = pci_sun4v_iommu_map(devhandle, num = pci_sun4v_iommu_map(devhandle,
HV_PCI_TSBID(0, entry), HV_PCI_TSBID(0, entry),
npages, npages,
...@@ -208,7 +208,7 @@ static void *dma_4v_alloc_coherent(struct device *dev, size_t size, ...@@ -208,7 +208,7 @@ static void *dma_4v_alloc_coherent(struct device *dev, size_t size,
atu = iommu->atu; atu = iommu->atu;
mask = dev->coherent_dma_mask; mask = dev->coherent_dma_mask;
if (mask <= DMA_BIT_MASK(32)) if (mask <= DMA_BIT_MASK(32) || !atu)
tbl = &iommu->tbl; tbl = &iommu->tbl;
else else
tbl = &atu->tbl; tbl = &atu->tbl;
...@@ -674,21 +674,12 @@ static void dma_4v_unmap_sg(struct device *dev, struct scatterlist *sglist, ...@@ -674,21 +674,12 @@ static void dma_4v_unmap_sg(struct device *dev, struct scatterlist *sglist,
static int dma_4v_supported(struct device *dev, u64 device_mask) static int dma_4v_supported(struct device *dev, u64 device_mask)
{ {
struct iommu *iommu = dev->archdata.iommu; struct iommu *iommu = dev->archdata.iommu;
u64 dma_addr_mask = iommu->dma_addr_mask;
if (ali_sound_dma_hack(dev, device_mask)) if (ali_sound_dma_hack(dev, device_mask))
return 1; return 1;
if (device_mask < iommu->dma_addr_mask)
if (device_mask > DMA_BIT_MASK(32)) { return 0;
if (iommu->atu) return 1;
dma_addr_mask = iommu->atu->dma_addr_mask;
else
return 0;
}
if ((device_mask & dma_addr_mask) == dma_addr_mask)
return 1;
return 0;
} }
static const struct dma_map_ops sun4v_dma_ops = { static const struct dma_map_ops sun4v_dma_ops = {
......
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