Subject: Re: FreeBSD Bus DMA (was Re: AdvanSys board support)
To: Noriyuki Soda <email@example.com>
From: Justin T. Gibbs <firstname.lastname@example.org>
Date: 06/11/1998 15:44:44
>> 2) The concept of dma tags has been extended to be more hierarchical than
>> in the NetBSD implementation. In a typical FreeBSD driver, a parent tag
>> is provided
>It seems that current FreeBSD's bus_dma_tag_create() and bus_dmamap_create()
>interface are not correct.
>bus_dma_tag_create() takes "nsegments" (AHC_NSEG in ahc driver) and
>"maxsegsz" (AHC_MAXTRANSFER_SIZE in ahc driver) arguments. But these values
>should be treated by bus_dma map, not bus_dma tag.
I think this concern stems from a misunderstanding of the semantics of a
tag in FreeBSD. The tag indicates all limits on a dma transaction
including the maximum number of segments allowed in maps allocated from
that tag. A driver should have a tag for each mapping type that has
different constraints. This allows the implementation to leverage off of
data in the tag that is shared amongst all dma maps that have been
allocated from it.
>For example, in ahc driver,
The ahc driver is a poor example. The CAM bt driver is the only driver
that has been "fully" bus dma'ed. I believe that if you reference the bt
driver, most of your concerns will be addressed/explained. I plan to go
back through and fix up the other drivers that were developed before or
during the development of the FreeBSD bus dma interface after USENIX.
>"hscb" and "ahc_dmaphys" should be bus_dma'fied, too.
Yup, they should.
>But these structures should not be scatter/gather'ed (i.e. AHC_NSEG
>and AHC_MAXTRANSFER_SIZE only affect actual scsi data transfer, but
>don't affect hscb and ahc_dmaphys.)
And for these allocations a tag with different constraints will be
allocated. See the bt driver for an example.
>So, AHC_NSEG and AHC_MAXTRANSFER_SIZE should be treated on dma map layer,
>not dma tag layer.
I don't agree as this imposes additional, per map, allocation requirements
on the implementation. The number of allocated maps is usually much
greater than the number of tags allocated, so it makes sense to put common
information in the tag.
>Please note that bus_dma interface is also used for cache flush and cache
>invalidatation on architecture other than i386.
I'm aware of this. I make no excuse other than a lack of time for the fact
that the ahc driver is deficient in it's use of the bus dma interfaces, but
I still maintain that there is nothing missing from the FreeBSD API that
would prevent it from working in these situations.
>About bus_dmamap_callback_t, I think that reducing bounce memory size
>is certainly good thing. But it is pain if we must use callback in all
>cases. (Think about hardware_scb in ahc driver.)
It's not that much of a pain. I use the callback to allocated bt_ccb and
S/G array space in the bt driver and I didn't find it unweildy.
>I think NetBSD's interface is more convenient than FreeBSD's.
>Isn't there other way to reduce bounce memory ?
I'm open to suggestions.