[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 6 Jun 2021 17:43:39 +0200
From: Arnd Bergmann <arnd@...db.de>
To: Sven Peter <sven@...npeter.dev>
Cc: USB list <linux-usb@...r.kernel.org>,
Felipe Balbi <balbi@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] usb: dwc3: support 64 bit DMA in platform driver
On Sun, Jun 6, 2021 at 12:36 PM Sven Peter <sven@...npeter.dev> wrote:
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index b6e53d8212cd..4930541a8984 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -1545,6 +1545,21 @@ static int dwc3_probe(struct platform_device *pdev)
>
> dwc3_get_properties(dwc);
>
> + /* Try to set 64-bit DMA first */
> + if (!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));
> +
> + /* 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;
> + }
Please drop the dma_coerce_mask_and_coherent() code path as well: if
the device is marked as non-DMA capable in the platform, it's better have
it not be usable at all than to assume a particular bus property that may
or may not be present on that bus.
The 32-bit mask is the default on all buses you might see a dwc3 controller
on, so you can drop that as well, and just leave the
dma_set_mask_and_coherent().
Arnd
Powered by blists - more mailing lists