> > Should I write a short summary on how to decide what a driver needs ?
>
> That would be great, I'll put that in the usb_submit_urb()
> documentation.

How to decide which mem_flags to pass to usb_submit_urb

Basically the rules are the same as for kmalloc ;-)

Now let me go to the details.
There are four different possible values: GFP_KERNEL, GFP_NOFS, GFP_NOIO
and GFP_ATOMIC. GFP_NOFS has as yet no field of application.

There are three situations you must use GFP_ATOMIC.
a) you are inside a completion handler, an interrupt, bottom half, tasklet or timer
b) you are holding a spinlock or rwlock (does not apply to semaphores)
b) current->state != TASK_RUNNING, this is the case only after you've changed it

GFP_NOIO is used in the block io path and error handling of storage devices.
Anything else uses GFP_KERNEL.

Specific uses (or rules of thumb ;-) ):
-start_xmit and timeout methods of network drivers must use GFP_ATOMIC (spinlock)
-queuecommand methods of scsi drivers must use GFP_ATOMIC (spinlock)
-If you use a kernel thread with a network driver you must use GFP_NOIO,
unless b) or c) apply
-After you have done a down() you use GFP_KERNEL, unless b) or c) apply
or your are in a storage driver's block io path
-probe and disconnect use GFP_KERNEL unless b) or c) apply
-Changing firmware on a running storage or net device uses GFP_NOIO,
unless b) or c) apply

        HTH
                Oliver

_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to