b3cc05f
From: Mark Langsdorf <mlangsdo@redhat.com>
b3cc05f
Date: Wed, 25 Mar 2015 14:12:51 -0400
6b80640
Subject: [PATCH] usb: make xhci platform driver use 64 bit or 32 bit DMA
b3cc05f
b3cc05f
The xhci platform driver needs to work on systems that either only
b3cc05f
support 64-bit DMA or only support 32-bit DMA. Attempt to set a
b3cc05f
coherent dma mask for 64-bit DMA, and attempt again with 32-bit
b3cc05f
DMA if that fails.
b3cc05f
b3cc05f
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
b3cc05f
---
b3cc05f
 drivers/usb/host/xhci-plat.c | 15 +++++++--------
b3cc05f
 1 file changed, 7 insertions(+), 8 deletions(-)
b3cc05f
b3cc05f
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
6b80640
index 0e11d61408ff..cc5ca2cac706 100644
b3cc05f
--- a/drivers/usb/host/xhci-plat.c
b3cc05f
+++ b/drivers/usb/host/xhci-plat.c
b3cc05f
@@ -83,14 +83,13 @@ static int xhci_plat_probe(struct platform_device *pdev)
b3cc05f
 	if (irq < 0)
b3cc05f
 		return -ENODEV;
b3cc05f
 
b3cc05f
-	/* Initialize dma_mask and coherent_dma_mask to 32-bits */
b3cc05f
-	ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
b3cc05f
-	if (ret)
b3cc05f
-		return ret;
b3cc05f
-	if (!pdev->dev.dma_mask)
b3cc05f
-		pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
b3cc05f
-	else
b3cc05f
-		dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
b3cc05f
+	/* Try setting the coherent_dma_mask to 64 bits, then try 32 bits */
b3cc05f
+	ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
b3cc05f
+	if (ret) {
b3cc05f
+		ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
b3cc05f
+		if (ret)
b3cc05f
+			return ret;
b3cc05f
+	}
b3cc05f
 
b3cc05f
 	hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
b3cc05f
 	if (!hcd)