From: Sven Peter <sven@svenpeter.dev>
To: linux-usb@vger.kernel.org
Cc: Felipe Balbi <balbi@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
Sven Peter <sven@svenpeter.dev>
Subject: [PATCH v3] usb: dwc3: support 64 bit DMA in platform driver
Date: Mon, 7 Jun 2021 08:17:51 +0200 [thread overview]
Message-ID: <20210607061751.89752-1-sven@svenpeter.dev> (raw)
Currently, the dwc3 platform driver does not explicitly ask for
a DMA mask. This makes it fall back to the default 32-bit mask which
breaks the driver on systems that only have RAM starting above the
first 4G like the Apple M1 SoC.
Fix this by calling dma_set_mask_and_coherent with a 64bit mask.
Signed-off-by: Sven Peter <sven@svenpeter.dev>
---
Third time's a charm I hope - this time much simpler :)
I still think this change should be fairly low risk.
Unfortunately I only have the Apple M1 to test this on but here
the driver still works with the iommu enabled which limits the
address space to 32 bit. It also enables to use this with the iommu
in bypass mode which requires 64 bit addresses.
I believe this has been working fine so far since the dwc3 driver
only uses a few very small buffers in host mode which might still
fit within the first 4G of address space on many devices. The
majority of DMA buffers are allocated inside the xhci driver which
will already call dma_set_mask_and_coherent.
Best,
Sven
changes from v2:
- remove both dma_coerce_mask_and_coherent and the 32 bit
dma_set_mask_and_coherent as pointed out by Arnd Bergmann
changes from v1:
- removed WARN_ON around !dwc->sysdev->dma_mask; pointed out by greg k-h
drivers/usb/dwc3/core.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index b6e53d8212cd..ba4792b6a98f 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1545,6 +1545,10 @@ static int dwc3_probe(struct platform_device *pdev)
dwc3_get_properties(dwc);
+ 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);
if (IS_ERR(dwc->reset))
return PTR_ERR(dwc->reset);
--
2.25.1
next reply other threads:[~2021-06-07 6:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-07 6:17 Sven Peter [this message]
2021-06-07 7:25 ` [PATCH v3] usb: dwc3: support 64 bit DMA in platform driver Arnd Bergmann
2021-06-07 8:01 ` Sven Peter
2021-06-07 8:22 ` Arnd Bergmann
2021-06-07 9:06 ` Sven Peter
2021-06-07 9:17 ` Arnd Bergmann
2021-06-07 10:04 ` Christoph Hellwig
2021-06-07 10:05 ` Christoph Hellwig
2021-06-10 9:24 ` Felipe Balbi
2021-06-10 15:24 ` Sven Peter
2021-06-11 13:17 ` Felipe Balbi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210607061751.89752-1-sven@svenpeter.dev \
--to=sven@svenpeter.dev \
--cc=arnd@arndb.de \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox