[Cbe-oss-dev] [patch 08/16] powerpc and x86_64: Initial port of PCIe endpoint device driver for Axon

Arnd Bergmann arnd at arndb.de
Fri Mar 14 09:33:34 EST 2008


On Thursday 13 March 2008, Murali Iyer wrote:
> On Thu, 2008-03-13 at 10:11 -0500, Jesse P Arroyo wrote:
> > Murali Iyer <mniyer at vnet.ibm.com> wrote on 03/13/2008 10:04:29 AM:
> > > > Nothing in the kernel guarantees that the memory returned from
> > > > dma_alloc_coherent() is aligned. Even if it is, the DMA address
> > > > may not be aligned in the same way. If you require strict alignment,
> > > > your best option would be to allocate an extra 64kb and manually
> > > > align on the bus address.
> > > I suspect it has to be aligned 16 bytes boundary.. need to check.
> > > 
> > According to the spec, the mailbox FIFO buffer must be aligned on a
> > sizeof(buffer) due to the hardware wrapping logic.
> > So, if we have a 64kB buffer, we need it aligned to a 64kB address.
>        if ((u64)mbx_p->mbx_buf & 0xffff) {
>                 printk(KERN_ERR "Mailbox buffer not 64KB aligned.\n");
>                 return -ENOMEM;
>         }
> Looks like we are checking and not seen any failures so far but what
> Arnd saying is that dma_alloc_coherent may not return aligned..

The slab allocator usually does align its objects, though this is not
guaranteed. If you switch on CONFIG_SLAB_DEBUG, you probably see
unaligned allocations. It's usually a good idea to switch on debugging
options like that anyway, while the code is not completed.

Most of these options help exposing bugs that are normally hidden.

	Arnd <><



More information about the cbe-oss-dev mailing list