linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Sven Peter" <sven@svenpeter.dev>
To: "Arnd Bergmann" <arnd@arndb.de>
Cc: "USB list" <linux-usb@vger.kernel.org>,
	"Felipe Balbi" <balbi@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] usb: dwc3: support 64 bit DMA in platform driver
Date: Mon, 07 Jun 2021 10:01:50 +0200	[thread overview]
Message-ID: <23348bfc-aad7-4e5f-83b1-e69463e618e5@www.fastmail.com> (raw)
In-Reply-To: <CAK8P3a0vbyq-90pUQ6-0Ed=DadR3Pnf0juupLQ70psQSuu_1nw@mail.gmail.com>



On Mon, Jun 7, 2021, at 09:25, Arnd Bergmann wrote:
> On Mon, Jun 7, 2021 at 8:18 AM Sven Peter <sven@svenpeter.dev> 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 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 think this is almost good, but there is still one small issue:
> 
> > 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;
> 
> This will now  fail on machines with dwc3 connected to a 32-bit bus (or a
> bus that is accidentally not annotated as supporting 64-bit) when there is
> some memory that is not addressable through that bus.
> 
> If dma_set_mask_and_coherent() fails, the platform should just fall back to
> 32-bit addressing as it did before your change. dma_alloc_*() will do that
> implicitly by allocating from ZONE_DMA32, while dma_map_*() fails
> on any non-addressable memory, or falls back to swiotlb if that is available.


Makes sense, but just to make sure I understand this correctly:
All that needs to be done is call dma_set_mask_and_coherent with a 64 bit
mask and then just ignore the return value?


Thanks,

Sven

  reply	other threads:[~2021-06-07  8:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-07  6:17 [PATCH v3] usb: dwc3: support 64 bit DMA in platform driver Sven Peter
2021-06-07  7:25 ` Arnd Bergmann
2021-06-07  8:01   ` Sven Peter [this message]
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=23348bfc-aad7-4e5f-83b1-e69463e618e5@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;
as well as URLs for NNTP newsgroup(s).