Skip to content

Commit 2ad6714

Browse files
tndavedavem330
authored andcommitted
SPARC64: Fix sun4v DMA panic
64bit DMA only supported on sun4v equipped with ATU IOMMU HW. 'Commit b02c2b0 ("sparc: remove arch specific dma_supported implementations")' introduced a code that incorrectly allow dma_supported() to succeed for 64bit dma mask even if system doesn't have ATU IOMMU. This results into panic. Fix it. Reported-by: Meelis Roos <mroos@linux.ee> Signed-off-by: Tushar Dave <tushar.n.dave@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3b06b1a commit 2ad6714

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

arch/sparc/kernel/pci_sun4v.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -673,12 +673,14 @@ static void dma_4v_unmap_sg(struct device *dev, struct scatterlist *sglist,
673673
static int dma_4v_supported(struct device *dev, u64 device_mask)
674674
{
675675
struct iommu *iommu = dev->archdata.iommu;
676-
u64 dma_addr_mask;
676+
u64 dma_addr_mask = iommu->dma_addr_mask;
677677

678-
if (device_mask > DMA_BIT_MASK(32) && iommu->atu)
679-
dma_addr_mask = iommu->atu->dma_addr_mask;
680-
else
681-
dma_addr_mask = iommu->dma_addr_mask;
678+
if (device_mask > DMA_BIT_MASK(32)) {
679+
if (iommu->atu)
680+
dma_addr_mask = iommu->atu->dma_addr_mask;
681+
else
682+
return 0;
683+
}
682684

683685
if ((device_mask & dma_addr_mask) == dma_addr_mask)
684686
return 1;

0 commit comments

Comments
 (0)