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: 45d39448b4 ("usb: dwc3: support 64 bit DMA in platform driver")
Cc: stable <stable@kernel.org>
Reviewed-by: Sven Peter <sven@svenpeter.dev>
Signed-off-by: William Wu <william.wu@rock-chips.com>
Link: https://lore.kernel.org/r/20220901083446.3799754-1-william.wu@rock-chips.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
William Wu 2022-09-01 16:34:46 +08:00 коммит произвёл Greg Kroah-Hartman
Родитель 766a96dc55
Коммит 91062e663b
1 изменённых файлов: 7 добавлений и 6 удалений

Просмотреть файл

@ -1752,12 +1752,6 @@ static int dwc3_probe(struct platform_device *pdev)
dwc3_get_properties(dwc); dwc3_get_properties(dwc);
if (!dwc->sysdev_is_parent) {
ret = dma_set_mask_and_coherent(dwc->sysdev, DMA_BIT_MASK(64));
if (ret)
return ret;
}
dwc->reset = devm_reset_control_array_get_optional_shared(dev); dwc->reset = devm_reset_control_array_get_optional_shared(dev);
if (IS_ERR(dwc->reset)) if (IS_ERR(dwc->reset))
return PTR_ERR(dwc->reset); return PTR_ERR(dwc->reset);
@ -1823,6 +1817,13 @@ static int dwc3_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dwc); platform_set_drvdata(pdev, dwc);
dwc3_cache_hwparams(dwc); dwc3_cache_hwparams(dwc);
if (!dwc->sysdev_is_parent &&
DWC3_GHWPARAMS0_AWIDTH(dwc->hwparams.hwparams0) == 64) {
ret = dma_set_mask_and_coherent(dwc->sysdev, DMA_BIT_MASK(64));
if (ret)
goto disable_clks;
}
spin_lock_init(&dwc->lock); spin_lock_init(&dwc->lock);
mutex_init(&dwc->mutex); mutex_init(&dwc->mutex);