lkml.org 
[lkml]   [1998]   [Apr]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Constants and kmallocs passed to DMA engine
Date
> On Thu, 16 Apr 1998, Marc SCHAEFER wrote:
>
> > Hi,
> >
> > in a device driver, I have declared:
> > static const unsigned char buffer[] = { 'a', 'b', 'c', 'd' };
> >
> > If I pass virt_to_bus(buffer) to a PCI DMA, I get garbage. If
> > I kmalloc() and memcpy() the const buffer to that kmalloc()ed
> > memory, and pass do virt_to_bus(kmalloced_memory) to the PCI
> > DMA, it works like a charm (ix86 architecture).

AFAIK, when dealing with DMA, the memory _should_ be allocated under
the 16MB limit. If you are using a static buffer, there is no guarantee
that you've got it loaded under 16MB (I believe). There may also be
alignment issues with a static buffer too. I know that 16MB
is moot with the address space of PCI, but if you're using the DMA
hardware on the motherboard, it's not moot. So, I would think that
using the allocated memory (then throwing it away, as I believe you
intend to do) is a much safer option. I believe that the appropriate
flags would be GFP_DMA for kmalloc (I *think*).

--Perry

>
> Just my 0.02 EURO.
> If your driver is loaded as a module then I would think your buffer
> space is allocated using vmalloc().
> Since I never used vir_to_bus() for vmallocced memory and I never
> got problems using such an address translation, this could well be
> the cause of the problem.
>
> Just a very cheap idea. :-)
>
>
> Gerard.
>


--
Perry Harrington Linux rules all OSes. APSoft ()
email: perry@apsoft.com Think Blue. /\

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu

\
 
 \ /
  Last update: 2005-03-22 13:42    [W:0.069 / U:0.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site