From: "Sven Peter" <sven@svenpeter.dev>
To: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, "Felipe Balbi" <balbi@kernel.org>,
linux-kernel@vger.kernel.org, "Arnd Bergmann" <arnd@arndb.de>
Subject: Re: [PATCH] usb: dwc3: support 64 bit DMA in platform driver
Date: Sun, 06 Jun 2021 12:08:25 +0200 [thread overview]
Message-ID: <1f06cf8b-9651-47f2-802c-0bcc3963fea1@www.fastmail.com> (raw)
In-Reply-To: <YLya4UG3nFBv798l@kroah.com>
On Sun, Jun 6, 2021, at 11:52, Greg Kroah-Hartman wrote:
> On Sun, Jun 06, 2021 at 11:36:29AM +0200, Sven Peter wrote:
> > 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 using the same logic already present in xhci-plat.c:
> > First, try to set a coherent dma mask for 64-bit, and then attempt
> > again with a 32-bit mask if this fails.
> >
> > Signed-off-by: Sven Peter <sven@svenpeter.dev>
> > ---
> >
> > I have taken the code directly from the xhci-plat.c driver so
> > I 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
> >
> > drivers/usb/dwc3/core.c | 15 +++++++++++++++
> > 1 file changed, 15 insertions(+)
> >
> > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> > index b6e53d8212cd..ef6bb6aaffd8 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 (WARN_ON(!dwc->sysdev->dma_mask))
>
> This will cause systems to reboot if they have panic-on-warn set. Are
> you sure you want that to happen?
Probably not :) I'll remove the WARN_ON.
thanks,
Sven
next prev parent reply other threads:[~2021-06-06 10:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-06 9:36 Sven Peter
2021-06-06 9:52 ` Greg Kroah-Hartman
2021-06-06 10:08 ` Sven Peter [this message]
2021-06-07 9:24 ` Christoph Hellwig
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=1f06cf8b-9651-47f2-802c-0bcc3963fea1@www.fastmail.com \
--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
all inboxes | Powered by JetHome®