Example PPC-4xx DMA scatter/gather usage

David Hawkins dwh at ovro.caltech.edu
Thu Feb 9 08:31:59 EST 2006


Buhler, Greg wrote:
> Does anyone have any example code they could provide me that shows 
> correct usage of the Linux 2.6.x PPC-4xx scatter/gather DMA 
> functionality? None of the mainline kernel tree sources or module 
> sources seem to use this functionality.
> 
> I am working on a driver that runs on an embedded PPC-405gp running 
> linux 2.4.21.  The driver relies extensively on the PPC’s DMA controller 
> using all 4 channels simultaneously.  After some research I determined 
> that the version of the dma code that was in 2.4.21 had been 
> significantly modified in more recent kernel trees. As a result I have 
> merged in the 2.6.x version of this code, but am running into some 
> trouble with sg transfers.  Specifically, after setting up an sgl the 
> way I used to with the 2.4.21 kernel, and then kicking off the transfer, 
> nothing seems to get transferred. When I attempt to remove sg elements 
> from the sgl, the kernel complains saying that I’m trying to remove an 
> element from an already empty sgl.
> 
> Any help, advice, or examples would be greatly appreciated. Thanks.

Hey Greg,

I haven't tried to use any of the kernel source for DMA control.
I started by writing a simple driver that provides a page of
SDRAM (basically copied the nopage driver from Rubini's 3rd Ed).
Then wrote another driver that provided access to the DCRs.
Using the DCR driver and page driver, I manually loaded the
DMA controller DCRs and triggered transfers.

I know its not something that you'd use in real-life, but
it allowed me to manually think-out what needs to be done
for DMA transfers, and allowed me to control when the transfer
occurred, so that I could capture PCI bus transactions.
It wouldn't take too much to manually setup an S-G DMA with
a couple of smaller-than-a-page transfers.

Let me know if you want the code, for the SDRAM page driver,
and DCRs driver and I'll email it to you.

Once you have the DMA S-G programming interface confirmed, then go
back to the DMA API and see if that conforms to the requirements.
I need to finish some single DMA benchmarks using the manual
method (to check the EBC performance), and then I'll start
looking at the proper way to use DMA within kernel drivers.

Please send updates to the list on your progress.

Cheers
Dave








More information about the Linuxppc-embedded mailing list