duplex bounce buffers

Dear All,

I have a DMA device that is only capable of addressing 32bit physical memory.
I have setup a WDF DMA that is working correct. When the memory buffer
is above the 4G boundary Windows creates bounce buffers and I am able
to either send to or receive date from my device.

For one case I need that my device reads and writes to the same
physical buffer. I thought I can use WdfDmaProfileScatterGatherDuplex
for that purpose, but WdfDmaTransactionInitialize only supports either
WdfDmaDirectionWriteToDevice or WdfDmaDirectionReadFromDevice but not
both directions. How can duplex access be achieved other than creating
my own bounce buffers and copying the data in and out by myself?

I also have a firewire device, which uses the same technique. I create
a REQUEST_ALLOCATE_ADDRESS_RANGE with the buffer mdl as backing store.
Again as long as the buffer is below the 4G boundary duplex access
works, but as soon as Windows creates a bounce buffer only device read
access can be achieved. Needless to say that the
AllocateAddressRange.fulAccessType is set to
ACCESS_FLAGS_TYPE_WRITE|ACCESS_FLAGS_TYPE_READ.

Any hint how to achieve duplex IO in these cases are appreciated,
Thanks and best regards,
Hagen.

That’s a rather unusual driver architecture. Whenever I’ve seen DMA in both directions simultaneously, it hasn’t been “packet based” but rather “on demand”, and therefore would use a common buffer type scheme. I’m not saying you’re design is wrong – just that it’s really unusual.

“Duplex” in the WDF sense simply means “both read and write active simultaneously.” It definitely doesn’t mean “read and write active to the SAME BUFFER” simultaneously.

The easiest way that *I* can think of to do this is for you to use a Common Buffer for the I/O, and do the copy yourself. There are alternatives that could avoid the copy but would almost certainly require changes to the application interface, such as your driver creating the buffer with physical addressing restrictions, and then supplying the buffer to the user. Again, this would entail a common buffer scheme.

Peter
OSR

If you’d used DMA_ADAPTER functions GetScatterGatherList/PutScatterGatherList, you could specify WriteToDevice FALSE in Get, and TRUE in Put. This is what STORPORT does for passing the WMI request buffer to the miniport. Coincidentally, this is why a WMI request size is limited by the miniport maximum transfer size.

Thanks Peter,

thats inplace processing. But maybe a better solution is to provide separate in and out buffer.

Unfortunately this does not fix the bounce buffers for firewire. That really seems broken to me.

Thanks,
Hagen.

Thanks Alex,

I am evaluating the use of DMA_ADAPTER (though we just switched to WDF…).

Hagen.

>you could specify WriteToDevice FALSE in Get, and TRUE in Put

Correction: make that the other way around.