Skip to content

Commit 24132a4

Browse files
author
Christoph Hellwig
committed
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>
1 parent 254ecb1 commit 24132a4

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

arch/sparc/kernel/pci_sun4v.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static long iommu_batch_flush(struct iommu_batch *p, u64 mask)
9292
prot &= (HV_PCI_MAP_ATTR_READ | HV_PCI_MAP_ATTR_WRITE);
9393

9494
while (npages != 0) {
95-
if (mask <= DMA_BIT_MASK(32)) {
95+
if (mask <= DMA_BIT_MASK(32) || !pbm->iommu->atu) {
9696
num = pci_sun4v_iommu_map(devhandle,
9797
HV_PCI_TSBID(0, entry),
9898
npages,
@@ -208,7 +208,7 @@ static void *dma_4v_alloc_coherent(struct device *dev, size_t size,
208208
atu = iommu->atu;
209209

210210
mask = dev->coherent_dma_mask;
211-
if (mask <= DMA_BIT_MASK(32))
211+
if (mask <= DMA_BIT_MASK(32) || !atu)
212212
tbl = &iommu->tbl;
213213
else
214214
tbl = &atu->tbl;
@@ -674,21 +674,12 @@ static void dma_4v_unmap_sg(struct device *dev, struct scatterlist *sglist,
674674
static int dma_4v_supported(struct device *dev, u64 device_mask)
675675
{
676676
struct iommu *iommu = dev->archdata.iommu;
677-
u64 dma_addr_mask = iommu->dma_addr_mask;
678677

679678
if (ali_sound_dma_hack(dev, device_mask))
680679
return 1;
681-
682-
if (device_mask > DMA_BIT_MASK(32)) {
683-
if (iommu->atu)
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;
680+
if (device_mask < iommu->dma_addr_mask)
681+
return 0;
682+
return 1;
692683
}
693684

694685
static const struct dma_map_ops sun4v_dma_ops = {

0 commit comments

Comments
 (0)