svn commit: r290610 - head/sys/x86/x86

Roger Pau Monné royger at FreeBSD.org
Mon Nov 9 15:42:01 UTC 2015


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.


More information about the svn-src-head mailing list