Skip to contentSkip to conversation

Update the generic DMA API to take GFP_ flags on

BK-2.5 James Bottomley 3 participants 4 messages Jan 14, 2003

lore
Share & tools
lore
#0 lore raw
Quoted 2 lines

What about platforms that can only use GFP_ATOMIC due to implementation side issues? Is that "OK"?

Yes.

A GFP_KERNEL request is safely implemented as GFP_ATOMIC as long as the caller checks return for NULL. for dma_alloc_coherent return checking is a requirement because the system may return NULL anyway if it is out of mappings even with a GFP_KERNEL flag.

James

#1 lore raw

From: James Bottomley <[email protected]>
Date: Tue, 14 Jan 2003 10:30:15 -0500

A GFP_KERNEL request is safely implemented as GFP_ATOMIC as long as the caller checks return for NULL. for dma_alloc_coherent return checking is a requirement because the system may return NULL anyway if it is out of mappings even with a GFP_KERNEL flag.

Now what about the corollary, a platform that needs to sleep to setup the cpu mapings in a race-free manner?

It could not ever honor GFP_ATOMIC in that case.

#2 lore raw
Quoted 2 lines · [email protected] said:

Now what about the corollary, a platform that needs to sleep to setup the cpu mapings in a race-free manner?

This one is the big bug bear. The DMA-mapping.txt doc says pci_alloc_consistent "may be called in interrupt context". Thus if the dma_alloc with GFP_ATOMIC uses the same code path, it should be safe. However, there are indications that pci_alloc_consistent wasn't interrupt safe on certain platforms (see other email re PA-RISC).

In any event, we're no worse off than we were with the pci_ API. Passing in the flags will hopefully allow us to create GFP_ATOMIC safe paths in the arch implementations which look iffy.

James

#3 lore raw
In reply to David S. Miller
Quoted 8 lines · David S. Miller

From: James Bottomley <[email protected]>
Date: Tue, 14 Jan 2003 10:30:15 -0500

A GFP_KERNEL request is safely implemented as GFP_ATOMIC as long as the caller checks return for NULL. for dma_alloc_coherent return checking is a requirement because the system may return NULL anyway if it is out of mappings even with a GFP_KERNEL flag.

Quoted 4 lines

Now what about the corollary, a platform that needs to sleep to setup the cpu mapings in a race-free manner?

It could not ever honor GFP_ATOMIC in that case.

That got solved in recent 2.5, albiet with limit of 2MB of consistent / coherent allocations at any one time. We return NULL if we run out of space, and _all_ callers must check the return code of pci_alloc_consistent and/or dma_alloc_coherent no matter what flags they pass in.

Signature · 2 lines
Russell King ([email protected])                The developer of ARM Linux
             http://www.arm.linux.org.uk/personal/aboutme.html