Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Nov 2015 16:41:50 +0100
From:      =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= <royger@FreeBSD.org>
To:        Hans Petter Selasky <hps@selasky.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r290610 - head/sys/x86/x86
Message-ID:  <5640BEBE.3070805@FreeBSD.org>
In-Reply-To: <564091FF.8090605@selasky.org>
References:  <201511091219.tA9CJwe7067036@repo.freebsd.org> <564091FF.8090605@selasky.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Hello,

El 09/11/15 a les 13.30, Hans Petter Selasky ha escrit:
> On 11/09/15 13:19, Roger Pau Monné wrote:
>> +    if (dmat->common.flags & BUS_DMA_KEEP_PG_OFFSET) {
>> +        /*
>> +         * If we have to keep the offset of each page this function
>> +         * is not suitable, switch back to bus_dmamap_load_ma_triv
>> +         * which is going to do the right thing in this case.
>> +         */
>> +        error = bus_dmamap_load_ma_triv(dmat, map, ma, buflen, ma_offs,
>> +            flags, segs, segp);
>> +        return (error);
>> +    }
> 
> Hi,
> 
> There has been an update made to the USB stack, which is currently the
> only client of "BUS_DMA_KEEP_PG_OFFSET", which means this check can

The only in-tree client. We don't know if there are other clients out of
the tree.

> probably be skipped or relaxed a bit. The condition which must be
> fullfilled is:

So you basically want a contiguous bounce buffer. I don't think we can
just change BUS_DMA_KEEP_PG_OFFSET to mean "use a contiguous bounce
buffer". Maybe a new flag could be introduced to describe this new
requirement and the old one deprecated.

> #ifdef USB_DEBUG
>         if (nseg > 1 &&
>             ((segs->ds_addr + segs->ds_len) & (USB_PAGE_SIZE - 1)) !=
>             ((segs + 1)->ds_addr & (USB_PAGE_SIZE - 1))) {
>                 /*
>                  * This check verifies there is no page offset hole
>                  * between the first and second segment. See the
>                  * BUS_DMA_KEEP_PG_OFFSET flag.
>                  */
>                 DPRINTFN(0, "Page offset was not preserved\n");
>                 error = 1;
>                 goto done;
>         }
> #endif

AFAICT with the current bounce implementation on x86 you would have to
specify an alignment of PAGE_SIZE in order to have this guarantee
without specifying BUS_DMA_KEEP_PG_OFFSET.

IMHO, we should change all the current bounce buffer code and switch to
use memdescs for everything (ie: bios and mbufs should use a memdesc
internally). Then each arch should provide functions to copy from the
different kinds of memdescs (either memdescs containing physical or
virtual memory), so the bounce code could be unified between all arches.
Of course that's easier said than done...

Roger.



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