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