Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Apr 2008 16:01:51 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        Hans Petter Selasky <hselasky@c2i.net>
Cc:        freebsd-embedded@freebsd.org, freebsd-usb@freebsd.org, Geoffrey Mainland <mainland@eecs.harvard.edu>
Subject:   Re: Soekris 4826 USB failure on FreeBSD 7.0
Message-ID:  <200804241601.51441.jhb@freebsd.org>
In-Reply-To: <200804241738.09805.hselasky@c2i.net>
References:  <20080421171305.GA19840@eecs.harvard.edu> <200804240806.54354.jhb@freebsd.org> <200804241738.09805.hselasky@c2i.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday 24 April 2008 11:38:09 am Hans Petter Selasky wrote:
> On Thursday 24 April 2008, John Baldwin wrote:
> >
> > This would indicate a bug in the bus_dmamap_load() call (wrong length?) 
and
> > that is going to hose you when you do the bus_dmamap_sync() for systems
> > with bounce pages (not enough data will get copied back and forth?).  You
> > need to track down the real bug and fix it rather than adding a hack in
> > your callback routine.
> 
> Hi John,
> 
> The minimum segment size is PAGE_SIZE bytes in my DMA-tag. Bus-dma starts 
> counting at the memory location of the allocation. And not the memory 
> location aligned to PAGE_SIZE bytes.
> 
> Memory pages:  |--------------|--------------|
> My allocation: |---------XXXXXXXXXXXXX-------|
> 
> Sometimes when I allocate DMA memory I can end up having an allocation 
> crossing two contiguous memory pages in physical memory. In those cases 
> bus_dma does not give me the segment address of the second page in the 
> segment list, because the allocation is less than PAGE_SIZE bytes. It fits 
> within the values specified in the DMA tag. But in other cases, where the 
> pages are not contiguous in RAM, bus_dma will return two different segment 
> addresses.
> 
> The question is: Is this a bug or is it a feature?

If you can't have a S/G element cross a page boundary, then use a 'boundary' 
of PAGE_SIZE when you create your tag.  As it is, you are (correctly for the 
tag you are creating) getting a single S/G entry that spans the entire 
region.  It sounds like you want two regions that is split on the page 
boundary.  If so, that is what the 'boundary' argument to bus_dmatag_create() 
is for.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200804241601.51441.jhb>