Using DMA API in linux kernel but channel is never

2019-08-07 11:51发布

问题:

I am trying to use dmatest.c to test DMA in intel xeon server and regular laptop with i7 processor. It is never been able to get a channel - I found this out by debugging the dmatest.c itself. Line 854 below is always executed (I put my own printk there).

Is there anything I should do to get this API to work before executing (such as dma modules or anything?)
Or, do I use wrong API set? On the Xeon server, I did research and it has ioatdma.ko module that can be loaded. modprobe ioatdma and some files available at /sys/class/dma after that, such as dma0channel0, dma1channel0 .... etc

However, running dmatest code, it still can't get any channel.

Any help or hint is appreciated.

       836 static void request_channels(struct dmatest_info *info,
       837                              enum dma_transaction_type type)
       838 {
       839         dma_cap_mask_t mask;
       840 
       841         dma_cap_zero(mask);
       842         dma_cap_set(type, mask);
       843         for (;;) {
       844                 struct dmatest_params *params = &info->params;
       845                 struct dma_chan *chan;
       846 
       847                 chan = dma_request_channel(mask, filter, params);
       848                 if (chan) {
       849                         if (dmatest_add_channel(info, chan)) {
       850                                 dma_release_channel(chan);
       851                                 break; /* add_channel failed, punt */
       852                         }
       853                 } else
       854                         break; /* no more channels available */

The test commands that I used (following dmatest.txt document in kernel doc):

% echo dma0chan0 > /sys/kernel/debug/dmatest/channel
% echo 2000 > /sys/kernel/debug/dmatest/timeout
% echo 1 > /sys/kernel/debug/dmatest/iterations
% echo 1 > /sys/kernel/debug/dmatest/run