Skip to content

Commit 0ebbe39

Browse files
dhdanggregkh
authored andcommitted
usb: make xhci platform driver use 64 bit or 32 bit DMA
The xhci platform driver needs to work on systems that either only support 64-bit DMA or only support 32-bit DMA. Attempt to set a coherent dma mask for 64-bit DMA, and attempt again with 32-bit DMA if that fails. [dhdang: regenerate the patch over v4.3-rc1 and address new comments] Signed-off-by: Mark Langsdorf <[email protected]> Tested-by: Mark Salter <[email protected]> Signed-off-by: Duc Dang <[email protected]> Acked-by: Arnd Bergmann <[email protected]> Signed-off-by: Mathias Nyman <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8451a34 commit 0ebbe39

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

drivers/usb/host/xhci-plat.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,20 @@ static int xhci_plat_probe(struct platform_device *pdev)
9393
if (irq < 0)
9494
return -ENODEV;
9595

96-
/* Initialize dma_mask and coherent_dma_mask to 32-bits */
97-
ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
98-
if (ret)
99-
return ret;
100-
if (!pdev->dev.dma_mask)
101-
pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
96+
/* Try to set 64-bit DMA first */
97+
if (WARN_ON(!pdev->dev.dma_mask))
98+
/* Platform did not initialize dma_mask */
99+
ret = dma_coerce_mask_and_coherent(&pdev->dev,
100+
DMA_BIT_MASK(64));
102101
else
103-
dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
102+
ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
103+
104+
/* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask */
105+
if (ret) {
106+
ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
107+
if (ret)
108+
return ret;
109+
}
104110

105111
hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
106112
if (!hcd)

0 commit comments

Comments
 (0)