linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [BK-2.5] Update the generic DMA API to take GFP_ flags on
@ 2003-01-14 15:30 James Bottomley
  2003-01-14 15:30 ` David S. Miller
  0 siblings, 1 reply; 4+ messages in thread
From: James Bottomley @ 2003-01-14 15:30 UTC (permalink / raw)
  To: David S. Miller; +Cc: James.Bottomley, linux-kernel

> 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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BK-2.5] Update the generic DMA API to take GFP_ flags on
  2003-01-14 15:30 [BK-2.5] Update the generic DMA API to take GFP_ flags on James Bottomley
@ 2003-01-14 15:30 ` David S. Miller
  2003-01-14 15:51   ` James Bottomley
  2003-01-14 15:51   ` Russell King
  0 siblings, 2 replies; 4+ messages in thread
From: David S. Miller @ 2003-01-14 15:30 UTC (permalink / raw)
  To: James.Bottomley; +Cc: linux-kernel

   From: James Bottomley <James.Bottomley@steeleye.com>
   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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BK-2.5] Update the generic DMA API to take GFP_ flags on
  2003-01-14 15:30 ` David S. Miller
@ 2003-01-14 15:51   ` James Bottomley
  2003-01-14 15:51   ` Russell King
  1 sibling, 0 replies; 4+ messages in thread
From: James Bottomley @ 2003-01-14 15:51 UTC (permalink / raw)
  To: David S. Miller; +Cc: James.Bottomley, linux-kernel

davem@redhat.com 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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BK-2.5] Update the generic DMA API to take GFP_ flags on
  2003-01-14 15:30 ` David S. Miller
  2003-01-14 15:51   ` James Bottomley
@ 2003-01-14 15:51   ` Russell King
  1 sibling, 0 replies; 4+ messages in thread
From: Russell King @ 2003-01-14 15:51 UTC (permalink / raw)
  To: David S. Miller; +Cc: James.Bottomley, linux-kernel

On Tue, Jan 14, 2003 at 07:30:23AM -0800, David S. Miller wrote:
>    From: James Bottomley <James.Bottomley@steeleye.com>
>    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.

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.

-- 
Russell King (rmk@arm.linux.org.uk)                The developer of ARM Linux
             http://www.arm.linux.org.uk/personal/aboutme.html


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-01-14 15:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-14 15:30 [BK-2.5] Update the generic DMA API to take GFP_ flags on James Bottomley
2003-01-14 15:30 ` David S. Miller
2003-01-14 15:51   ` James Bottomley
2003-01-14 15:51   ` Russell King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).