Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rapidio/tsi721_dma: add channel mask and queue size parameters

Add module parameters to allow load time configuration of DMA channels.

Depending on application, performance of DMA data transfers can benefit
from adjusted sizes of buffer descriptor ring and/or transaction
requests queue.

Having HW DMA channel selector mask allows to define which channels
(from seven available) are controlled by the mport device driver and
reserve some of them for direct use by other drivers.

Link: http://lkml.kernel.org/r/1469125134-16523-5-git-send-email-alexandre.bounine@idt.com
Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com>
Tested-by: Barry Wood <barry.wood@idt.com>
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: Andre van Herk <andre.van.herk@prodrive-technologies.com>
Cc: Barry Wood <barry.wood@idt.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexandre Bounine and committed by
Linus Torvalds
4498c31a f8e3a68c

+32 -10
+14
Documentation/rapidio/tsi721.txt
··· 25 25 This parameter can be changed dynamically. 26 26 Use CONFIG_RAPIDIO_DEBUG=y to enable debug output at the top level. 27 27 28 + - 'dma_desc_per_channel' - This parameter defines number of hardware buffer 29 + descriptors allocated for each registered Tsi721 DMA channel. 30 + Its default value is 128. 31 + 32 + - 'dma_txqueue_sz' - DMA transactions queue size. Defines number of pending 33 + transaction requests that can be accepted by each DMA channel. 34 + Default value is 16. 35 + 36 + - 'dma_sel' - DMA channel selection mask. Bitmask that defines which hardware 37 + DMA channels (0 ... 6) will be registered with DmaEngine core. 38 + If bit is set to 1, the corresponding DMA channel will be registered. 39 + DMA channels not selected by this mask will not be used by this device 40 + driver. Default value is 0x7f (use all channels). 41 + 28 42 II. Known problems 29 43 30 44 None.
+1 -1
drivers/rapidio/devices/tsi721.h
··· 661 661 */ 662 662 #define TSI721_DMA_CHNUM TSI721_DMA_MAXCH 663 663 664 - #define TSI721_DMACH_MAINT 0 /* DMA channel for maint requests */ 664 + #define TSI721_DMACH_MAINT 7 /* DMA channel for maint requests */ 665 665 #define TSI721_DMACH_MAINT_NBD 32 /* Number of BDs for maint requests */ 666 666 667 667 #define TSI721_DMACH_DMA 1 /* DMA channel for data transfers */
+17 -9
drivers/rapidio/devices/tsi721_dma.c
··· 36 36 37 37 #include "tsi721.h" 38 38 39 - #define TSI721_DMA_TX_QUEUE_SZ 16 /* number of transaction descriptors */ 40 - 41 39 #ifdef CONFIG_PCI_MSI 42 40 static irqreturn_t tsi721_bdma_msix(int irq, void *ptr); 43 41 #endif 44 42 static int tsi721_submit_sg(struct tsi721_tx_desc *desc); 45 43 46 44 static unsigned int dma_desc_per_channel = 128; 47 - module_param(dma_desc_per_channel, uint, S_IWUSR | S_IRUGO); 45 + module_param(dma_desc_per_channel, uint, S_IRUGO); 48 46 MODULE_PARM_DESC(dma_desc_per_channel, 49 47 "Number of DMA descriptors per channel (default: 128)"); 48 + 49 + static unsigned int dma_txqueue_sz = 16; 50 + module_param(dma_txqueue_sz, uint, S_IRUGO); 51 + MODULE_PARM_DESC(dma_txqueue_sz, 52 + "DMA Transactions Queue Size (default: 16)"); 53 + 54 + static u8 dma_sel = 0x7f; 55 + module_param(dma_sel, byte, S_IRUGO); 56 + MODULE_PARM_DESC(dma_sel, 57 + "DMA Channel Selection Mask (default: 0x7f = all)"); 50 58 51 59 static inline struct tsi721_bdma_chan *to_tsi721_chan(struct dma_chan *chan) 52 60 { ··· 740 732 tsi_debug(DMA, &dchan->dev->device, "DMAC%d", bdma_chan->id); 741 733 742 734 if (bdma_chan->bd_base) 743 - return TSI721_DMA_TX_QUEUE_SZ; 735 + return dma_txqueue_sz; 744 736 745 737 /* Initialize BDMA channel */ 746 738 if (tsi721_bdma_ch_init(bdma_chan, dma_desc_per_channel)) { ··· 750 742 } 751 743 752 744 /* Allocate queue of transaction descriptors */ 753 - desc = kcalloc(TSI721_DMA_TX_QUEUE_SZ, sizeof(struct tsi721_tx_desc), 745 + desc = kcalloc(dma_txqueue_sz, sizeof(struct tsi721_tx_desc), 754 746 GFP_ATOMIC); 755 747 if (!desc) { 756 748 tsi_err(&dchan->dev->device, ··· 762 754 763 755 bdma_chan->tx_desc = desc; 764 756 765 - for (i = 0; i < TSI721_DMA_TX_QUEUE_SZ; i++) { 757 + for (i = 0; i < dma_txqueue_sz; i++) { 766 758 dma_async_tx_descriptor_init(&desc[i].txd, dchan); 767 759 desc[i].txd.tx_submit = tsi721_tx_submit; 768 760 desc[i].txd.flags = DMA_CTRL_ACK; ··· 774 766 bdma_chan->active = true; 775 767 tsi721_bdma_interrupt_enable(bdma_chan, 1); 776 768 777 - return TSI721_DMA_TX_QUEUE_SZ; 769 + return dma_txqueue_sz; 778 770 } 779 771 780 772 static void tsi721_sync_dma_irq(struct tsi721_bdma_chan *bdma_chan) ··· 970 962 int i; 971 963 972 964 for (i = 0; i < TSI721_DMA_MAXCH; i++) { 973 - if (i != TSI721_DMACH_MAINT) 965 + if ((i != TSI721_DMACH_MAINT) && (dma_sel & (1 << i))) 974 966 tsi721_dma_stop(&priv->bdma[i]); 975 967 } 976 968 } ··· 987 979 for (i = 0; i < TSI721_DMA_MAXCH; i++) { 988 980 struct tsi721_bdma_chan *bdma_chan = &priv->bdma[i]; 989 981 990 - if (i == TSI721_DMACH_MAINT) 982 + if ((i == TSI721_DMACH_MAINT) || (dma_sel & (1 << i)) == 0) 991 983 continue; 992 984 993 985 bdma_chan->regs = priv->regs + TSI721_DMAC_BASE(i);