Skip to content

Commit 91062e6

Browse files
wuliangfenggregkh
authored andcommitted
usb: dwc3: core: leave default DMA if the controller does not support 64-bit DMA
On some DWC3 controllers (e.g. Rockchip SoCs), the DWC3 core doesn't support 64-bit DMA address width. In this case, this driver should use the default 32-bit mask. Otherwise, the DWC3 controller will break if it runs on above 4GB physical memory environment. This patch reads the DWC_USB3_AWIDTH bits of GHWPARAMS0 which used for the DMA address width, and only configure 64-bit DMA mask if the DWC_USB3_AWIDTH is 64. Fixes: 45d3944 ("usb: dwc3: support 64 bit DMA in platform driver") Cc: stable <[email protected]> Reviewed-by: Sven Peter <[email protected]> Signed-off-by: William Wu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 766a96d commit 91062e6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

drivers/usb/dwc3/core.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,12 +1752,6 @@ static int dwc3_probe(struct platform_device *pdev)
17521752

17531753
dwc3_get_properties(dwc);
17541754

1755-
if (!dwc->sysdev_is_parent) {
1756-
ret = dma_set_mask_and_coherent(dwc->sysdev, DMA_BIT_MASK(64));
1757-
if (ret)
1758-
return ret;
1759-
}
1760-
17611755
dwc->reset = devm_reset_control_array_get_optional_shared(dev);
17621756
if (IS_ERR(dwc->reset))
17631757
return PTR_ERR(dwc->reset);
@@ -1823,6 +1817,13 @@ static int dwc3_probe(struct platform_device *pdev)
18231817
platform_set_drvdata(pdev, dwc);
18241818
dwc3_cache_hwparams(dwc);
18251819

1820+
if (!dwc->sysdev_is_parent &&
1821+
DWC3_GHWPARAMS0_AWIDTH(dwc->hwparams.hwparams0) == 64) {
1822+
ret = dma_set_mask_and_coherent(dwc->sysdev, DMA_BIT_MASK(64));
1823+
if (ret)
1824+
goto disable_clks;
1825+
}
1826+
18261827
spin_lock_init(&dwc->lock);
18271828
mutex_init(&dwc->mutex);
18281829

0 commit comments

Comments
 (0)