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