Re: bus_dmamap_create() breakage (alias 3Ware driver problems)

From: Scott Long <scottl_at_freebsd.org>
Date: Sat, 29 Jan 2005 20:04:02 -0700
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
Received on Sun Jan 30 2005 - 02:04:19 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:27 UTC