Re: [PATCH] usb: dwc3: support 64 bit DMA in platform driver

From: Christoph Hellwig
Date: Mon Jun 07 2021 - 05:25:09 EST


On Sun, Jun 06, 2021 at 11:36:29AM +0200, Sven Peter wrote:
> + /* Try to set 64-bit DMA first */
> + if (WARN_ON(!dwc->sysdev->dma_mask))
> + /* Platform did not initialize dma_mask */
> + ret = dma_coerce_mask_and_coherent(dwc->sysdev,
> + DMA_BIT_MASK(64));
> + else
> + ret = dma_set_mask_and_coherent(dwc->sysdev, DMA_BIT_MASK(64));

WARN_ON + fallback seems weird. I'd suggest to just error out for the
warn case.

> + /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask */
> + if (ret) {
> + ret = dma_set_mask_and_coherent(dwc->sysdev, DMA_BIT_MASK(32));
> + if (ret)
> + return ret;
> + }

Setting a 64-bit mask will not fail. No need for the fallback.