public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* pci_alloc_consistent from interrupt == BAD
@ 2002-01-18 19:02 Troy Benjegerdes
  2002-01-18 19:22 ` Dan Malek
  2002-01-18 20:21 ` Gérard Roudier
  0 siblings, 2 replies; 19+ messages in thread
From: Troy Benjegerdes @ 2002-01-18 19:02 UTC (permalink / raw)
  To: David S. Miller, linux-kernel, Gerard Roudier
  Cc: Alan Cox, Russell King, Dan Malek, mattl

Somehow the docs in DMA-mappings.txt say pci_alloc_consistent is allowed from 
interrupt, but this is a "bad thing" on at least arm and PPC non-cache 
coherent cpus.

On these cpus we have to allocate page tables for consistent_alloc.. I really 
dont' think we want to be doing this during interrupt context.

This also causes the sym53c8xx_2 driver to not work on some embedded ppc 4xx 
boards, and in general, seems to be a 'bad thing' to allow.

For example, in the arch/arm/consistent.c:

/*
 * This allocates one page of cache-coherent memory space and returns
 * both the virtual and a "dma" address to that space.  It is not clear
 * whether this could be called from an interrupt context or not.  For
 * now, we expressly forbid it, especially as some of the stuff we do
 * here is not interrupt context safe.
 *
 * Note that this does *not* zero the allocated area!
 */
void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle)

(arm's pci_alloc_consistent always calls consistent_alloc).

The PPC version calls a similiar function when CONFIG_NOT_COHERENT_CACHE is 
defined. On 'regular' ppc machines, it's just a __get_free_pages, which is 
why no one from the pmac crowd has screamed.


-- 
Troy Benjegerdes | master of mispeeling | 'da hozer' |  hozer@drgw.net
-----"If this message isn't misspelled, I didn't write it" -- Me -----
"Why do musicians compose symphonies and poets write poems? They do it
because life wouldn't have any meaning for them if they didn't. That's 
why I draw cartoons. It's my life." -- Charles Schulz

^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: pci_alloc_consistent from interrupt == BAD
@ 2002-01-19 17:21 David Brownell
  0 siblings, 0 replies; 19+ messages in thread
From: David Brownell @ 2002-01-19 17:21 UTC (permalink / raw)
  To: Russell King; +Cc: lkml

"> > " == David Miller
"> " == Russell King

> > BTW, the USB host controller drivers do this (allocate potentially
> > from interrupts) so anyone using USB on ARM...
> 
> Well, I've got a BUG() in there that'll trigger when pci_alloc_consistent()
> is called from IRQ, and so far no one has reported an incidence of
> that occuring, despite there being USB OHCI controllers available on ARM.

Yes, that'd be rare -- but legal.

The USB host controller drivers would do that primarily in the
case where (a) some driver submitted a new URB in_interrupt(),
so the HCD needed to queue new requests to the hardware,
and (b) the pools of endpoint or transfer descriptors didn't have
enough free entries.

The main reason for (a) is that the last URB just completed, and
freed its resources, and a new request for that endpoint needs to
get submitted.  As for (b), endpoint descriptors are normally
preserved until the device is disconnected.  That leaves transport
descriptors (TDs).  OHCI (and EHCI) don't need many of those;
typically one per request.  So if one was just put back into the pool,
it'd typically still be available.  UHCI needs more memory, but
the same general rules apply.

- Dave



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

end of thread, other threads:[~2002-01-22  0:21 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-01-18 19:02 pci_alloc_consistent from interrupt == BAD Troy Benjegerdes
2002-01-18 19:22 ` Dan Malek
2002-01-18 20:32   ` David S. Miller
2002-01-18 21:29     ` Russell King
2002-01-18 21:33       ` David S. Miller
2002-01-18 21:42         ` Russell King
2002-01-18 21:46       ` Dan Malek
2002-01-18 21:55         ` Russell King
2002-01-18 22:13           ` Dan Malek
2002-01-18 21:43     ` Dan Malek
2002-01-18 20:50   ` Gérard Roudier
     [not found]   ` <mailman.1011386221.24072.linux-kernel2news@redhat.com>
2002-01-21 23:52     ` Pete Zaitcev
2002-01-22  0:08       ` David S. Miller
2002-01-22  0:20         ` Pete Zaitcev
2002-01-18 20:21 ` Gérard Roudier
2002-01-18 20:38   ` David S. Miller
2002-01-18 21:07     ` Gérard Roudier
2002-01-18 21:13       ` David S. Miller
  -- strict thread matches above, loose matches on Subject: below --
2002-01-19 17:21 David Brownell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox