From: Petr Tesarik <ptesarik@suse.com>
To: Oliver Neukum <oneukum@suse.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] usb: core: warn if a GFP zone flag is passed to hcd_buffer_alloc()
Date: Wed, 16 Apr 2025 09:48:07 +0200 [thread overview]
Message-ID: <20250416094807.2545efd8@mordecai> (raw)
In-Reply-To: <522b3049-8e7f-41d4-a811-3385992a4d46@suse.com>
On Tue, 15 Apr 2025 09:53:24 +0200
Oliver Neukum <oneukum@suse.com> wrote:
> On 14.04.25 09:02, Petr Tesarik wrote:
>
> Hi,
>
> > That's the point. AFAICS there are _no_ in-tree callers that would pass
> > GFP_DMA or GFP_DMA32 to hcd_buffer_alloc(), directly or indirectly. But
> > nobody should be tempted to add the flag, because I cannot imagine how
> > that would ever be the right thing to do.
>
> You do not dream about putting USB onto PCMCIA over Thunderbolt?
Oh, I do, and that's precisely why these GFP flags are no good. The
address (and other) constraints imposed by different buses may not
(and often do not) match any existing memory zone.
However, zone address ranges are determined statically at compile time,
or latest at boot time (e.g. arm64). It's too late to adjust the limits
when you hotplug a more constrained bus at run-time. And I haven't even
mentioned bus bridges which add a non-zero offset to the address...
> > I can change it back to mem_flags &= ~GFP_ZONEMASK to fix it silently;
> > I simply thought that driver authors may appreciate a warning that
> > they're trying to do something silly.
>
> People rarely appreciate warnings. I think we should limit them
> to cases where something goes wrong or something unexpected happens.
I'm certainly no expert on what is expected to happen if you include
GFP_DMA in your HCD buffer allocation flags, but the current code will
*ignore* it, unless the HCD uses PIO.
I thought this was rather unexpected.
> > Whatever works for you, but please keep in mind that there seems to be
> > agreement among mm people that DMA and DMA32 zones should be removed
> > from the kernel eventually.
>
> Well, if somebody finds a legitimate use case for these flags, the mm
> people should deal with it. They are likelier to find a good solution than
> all driver writers being forced into finding individual solutions.
My goal is to provide an allocator that is a better match for the
constraints defined by dma_mask, coherent_dma_mask and bus_dma_limit.
For now, I'm trying to clean up some users of GFP_DMA and GFP_DMA32
flags which look obviously incorrect.
Petr T
next prev parent reply other threads:[~2025-04-16 7:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-20 15:47 [PATCH] usb: core: do not allocate buffers from a DMA zone unnecessarily Petr Tesarik
2025-03-25 13:40 ` [PATCH v2] usb: core: warn if a GFP zone flag is passed to hcd_buffer_alloc() Petr Tesarik
2025-03-25 13:54 ` Petr Tesarik
2025-04-09 15:40 ` Petr Tesařík
2025-04-10 6:10 ` Greg Kroah-Hartman
2025-04-11 13:57 ` Greg Kroah-Hartman
2025-04-14 7:02 ` Petr Tesarik
2025-04-14 7:12 ` Greg Kroah-Hartman
2025-04-14 7:57 ` Petr Tesarik
2025-04-15 7:53 ` Oliver Neukum
2025-04-16 7:48 ` Petr Tesarik [this message]
2025-04-16 8:45 ` Oliver Neukum
2025-04-16 10:47 ` Petr Tesarik
2025-04-16 13:08 ` Oliver Neukum
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=20250416094807.2545efd8@mordecai \
--to=ptesarik@suse.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=oneukum@suse.com \
/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