All of lore.kernel.org
 help / color / mirror / Atom feed
From: "David Wang" <00107082@163.com>
To: "Oliver Neukum" <oneukum@suse.com>
Cc: mathias.nyman@intel.com, gregkh@linuxfoundation.org,
	stern@rowland.harvard.edu, surenb@google.com,
	kent.overstreet@linux.dev, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] USB: core: add a memory pool to urb for host-controller private data
Date: Tue, 13 May 2025 16:53:05 +0800 (CST)	[thread overview]
Message-ID: <2c2d065e.8320.196c8d8f9c0.Coremail.00107082@163.com> (raw)
In-Reply-To: <b07c7d9f-a20a-49bc-adbc-d43326b2d2df@suse.com>


At 2025-05-13 16:46:39, "Oliver Neukum" <oneukum@suse.com> wrote:
>On 13.05.25 10:23, David Wang wrote:
>
>Hi,
>  > Thanks for reviewing this.  The memory flag thing do raise concern.
>> I think I can make adjustment:  realloc the memory if flag changed.
>
>I am sorry. I have been unclear. Here comes a detailed explanation:
>
>What we call "gfp_t" is a combination of flags. They describe
>
>A - the type of memory (always valid)
>B - the way the memory can be allocated (valid only at a specific time)
>
>The URB is a generic data structure to be processed by the CPU, _not_
>the HC. It is always generic kernel memory. Flags of type A make no sense
>to pass.
>In fact you may not know for which device an URB will be used when you
>allocate it. The only valid mem_flags you can pass to usb_alloc_urb()
>are GFP_KERNEL, GFP_NOIO or GFP_ATOMIC.
>
>If you need to reallocate memory for private data you _must_ use
>the flags passed with usb_submit_urb(). A HCD can modify them by adding
>flags of type A, but you cannot change flags of type B.
>For example, if usb_alloc_urb() used GFP_KERNEL to allocate the URB,
>but uses GFP_ATOMIC in usb_submit_urb(), you will deadlock if you save
>and reuse the GFP_KERNEL.
>
>	HTH
>		Oliver
>  
Thanks for explaining this.   I will adjust code to handle mem_flags changes,
and update soon after I made some tests.

David

  reply	other threads:[~2025-05-13  8:53 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-12 15:07 [RFC] USB: core/xhci: add a buffer in urb for host controller private data David Wang
2025-05-12 15:34 ` Alan Stern
2025-05-12 16:19   ` David Wang
2025-05-13  5:54 ` [PATCH 1/2] USB: core: add a memory pool to urb for host-controller " David Wang
2025-05-13  8:11   ` Oliver Neukum
2025-05-13  8:23     ` David Wang
2025-05-13  8:46       ` Oliver Neukum
2025-05-13  8:53         ` David Wang [this message]
2025-05-13  9:49         ` David Wang
2025-05-13 11:02           ` Oliver Neukum
2025-05-13 11:12             ` David Wang
2025-05-13  5:55 ` [PATCH 2/2] USB: xhci: use urb hcpriv mempool for " David Wang
2025-05-13  8:21   ` Oliver Neukum
2025-05-13  8:31     ` David Wang
2025-05-13  9:00       ` Oliver Neukum
2025-05-13  9:27 ` [RFC] USB: core/xhci: add a buffer in urb for host controller " Mathias Nyman
2025-05-13  9:41   ` David Wang
2025-05-13 11:38 ` [PATCH v2 1/2] USB: core: add a memory pool to urb for host-controller " David Wang
2025-05-13 14:25   ` Alan Stern
2025-05-13 14:41     ` David Wang
2025-05-13 15:37       ` Alan Stern
2025-05-13 16:35         ` David Wang
2025-05-13 18:21           ` Alan Stern
2025-05-13 18:48             ` David Wang
2025-05-13 19:46               ` Alan Stern
2025-05-14 11:27     ` Oliver Neukum
2025-05-14  6:44   ` David Wang
2025-05-14  7:29     ` Greg KH
2025-05-14  8:50       ` David Wang
2025-05-14  9:34       ` Oliver Neukum
2025-05-17  9:09         ` David Wang
2025-05-14 11:23   ` Oliver Neukum
2025-05-14 11:51     ` David Wang
2025-05-14 12:03       ` Oliver Neukum
2025-05-14 12:14         ` David Wang
2025-05-16 17:13         ` David Wang
2025-05-13 11:38 ` [PATCH v2 2/2] USB: xhci: use urb hcpriv mempool for " David Wang

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=2c2d065e.8320.196c8d8f9c0.Coremail.00107082@163.com \
    --to=00107082@163.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kent.overstreet@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=oneukum@suse.com \
    --cc=stern@rowland.harvard.edu \
    --cc=surenb@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.