aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2019-02-15 03:30:28 -0500
committerChristoph Hellwig <hch@lst.de>2019-02-20 09:29:10 -0500
commit24132a419c68f1d69eb8ecc91b3c80d730ecbb59 (patch)
treee9bf0b2d4290cedc1884cfed177ed0587bd843a8
parent254ecb1601ebbdf0eeda4156f4c55254cb9addaf (diff)
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: Christoph Hellwig <hch@lst.de> Acked-by: David S. Miller <davem@davemloft.net>
-rw-r--r--arch/sparc/kernel/pci_sun4v.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c
index d30eb22b6e11..a8af6023c126 100644
--- a/arch/sparc/kernel/pci_sun4v.c
+++ b/arch/sparc/kernel/pci_sun4v.c
@@ -92,7 +92,7 @@ static long iommu_batch_flush(struct iommu_batch *p, u64 mask)
92 prot &= (HV_PCI_MAP_ATTR_READ | HV_PCI_MAP_ATTR_WRITE); 92 prot &= (HV_PCI_MAP_ATTR_READ | HV_PCI_MAP_ATTR_WRITE);
93 93
94 while (npages != 0) { 94 while (npages != 0) {
95 if (mask <= DMA_BIT_MASK(32)) { 95 if (mask <= DMA_BIT_MASK(32) || !pbm->iommu->atu) {
96 num = pci_sun4v_iommu_map(devhandle, 96 num = pci_sun4v_iommu_map(devhandle,
97 HV_PCI_TSBID(0, entry), 97 HV_PCI_TSBID(0, entry),
98 npages, 98 npages,
@@ -208,7 +208,7 @@ static void *dma_4v_alloc_coherent(struct device *dev, size_t size,
208 atu = iommu->atu; 208 atu = iommu->atu;
209 209
210 mask = dev->coherent_dma_mask; 210 mask = dev->coherent_dma_mask;
211 if (mask <= DMA_BIT_MASK(32)) 211 if (mask <= DMA_BIT_MASK(32) || !atu)
212 tbl = &iommu->tbl; 212 tbl = &iommu->tbl;
213 else 213 else
214 tbl = &atu->tbl; 214 tbl = &atu->tbl;
@@ -674,21 +674,12 @@ static void dma_4v_unmap_sg(struct device *dev, struct scatterlist *sglist,
674static int dma_4v_supported(struct device *dev, u64 device_mask) 674static int dma_4v_supported(struct device *dev, u64 device_mask)
675{ 675{
676 struct iommu *iommu = dev->archdata.iommu; 676 struct iommu *iommu = dev->archdata.iommu;
677 u64 dma_addr_mask = iommu->dma_addr_mask;
678 677
679 if (ali_sound_dma_hack(dev, device_mask)) 678 if (ali_sound_dma_hack(dev, device_mask))
680 return 1; 679 return 1;
681 680 if (device_mask < iommu->dma_addr_mask)
682 if (device_mask > DMA_BIT_MASK(32)) { 681 return 0;
683 if (iommu->atu) 682 return 1;
684 dma_addr_mask = iommu->atu->dma_addr_mask;
685 else
686 return 0;
687 }
688
689 if ((device_mask & dma_addr_mask) == dma_addr_mask)
690 return 1;
691 return 0;
692} 683}
693 684
694static const struct dma_map_ops sun4v_dma_ops = { 685static const struct dma_map_ops sun4v_dma_ops = {