Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Jan 2005 20:04:02 -0700
From:      Scott Long <scottl@freebsd.org>
To:        Doug White <dwhite@gumbysoft.com>
Cc:        vkashyap@amcc.com
Subject:   Re: bus_dmamap_create() breakage (alias 3Ware driver problems)
Message-ID:  <41FC4EA2.40603@freebsd.org>
In-Reply-To: <20050129121051.X85926@carver.gumbysoft.com>
References:  <20050128100151.GA43728@fit.vutbr.cz> <20050129121051.X85926@carver.gumbysoft.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Doug White wrote:

> Hello Petr,
> 
> Thanks for the analysis on this.
> 
> On Fri, 28 Jan 2005, Petr Lampa wrote:
> 
> 
>>I have got similar problems with the new 3Ware driver like others,
>>but on the second controller. After some debugging and playing with
>>bus_dma_tag_create() etc. arguments (new driver is using 3 busdma_tags
>>instead 1 in old driver), I have located source of failure
>>in bus_dmamap_create(). Here is the trouble spot:
>>
>>$FreeBSD: src/sys/i386/i386/busdma_machdep.c,v 1.59.2.3 2004/12/04 05:
>>55:10 scottl Exp $
>>
>>bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
>>{
>>...
>>	maxpages = MIN(MAX_BPAGES, Maxmem - atop(dmat->lowaddr));
>>	if ((dmat->flags & BUS_DMA_MIN_ALLOC_COMP) == 0
>>	    || (dmat->map_count > 0 && total_bpages < maxpages)) {
>>		int pages;
>>		...
>>		pages = MAX(atop(dmat->maxsize), 1);
>>
>>At this location maxpages=512, total_bpages=513, dmat->maxsize=131072, pages=32
>>
>>		pages = MIN(maxpages - total_bpages, pages);
>>
>>Here pages=-1!
> 
> 
> Ooh, thats not so good.
> 
> Could you bundle up your changes into a patch? Its a lot easier to follow
> and compare your changes, as well as test :)  Also, can you please submit
> a PR with the patch so it doesn't get lost? scottl is out for the weekend
> but I'll bring this to his attention when he returns.
> 
> Thanks!
> 

There is a fundamental problem with how busdma counts and pre-allocates
bounce pages, and it's leading to some interesting problems like this
(which is why I never merged the 4GB+ fixes to RELENG_5_3).  Basically,
I think that too many bounce pages are being allocated for fixing up
alignment constraints.  I need a few hours to sit in front of a
white-board and think it all through again.  However, someone want to
help, either by fixing the underlying problems or by tying up these edge
cases, I'd be happy to discuss it some more.

Scott



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