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

dmaengine: Introduce DMA-device device_caps callback

There are DMA devices (like ours version of Synopsys DW DMAC) which have
DMA capabilities non-uniformly redistributed between the device channels.
In order to provide a way of exposing the channel-specific parameters to
the DMA engine consumers, we introduce a new DMA-device callback. In case
if provided it gets called from the dma_get_slave_caps() method and is
able to override the generic DMA-device capabilities.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20200723005848.31907-6-Sergey.Semin@baikalelectronics.ru
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Serge Semin and committed by
Vinod Koul
3b6d694e b1b40b8f

+14
+10
drivers/dma/dmaengine.c
··· 601 601 caps->cmd_resume = !!device->device_resume; 602 602 caps->cmd_terminate = !!device->device_terminate_all; 603 603 604 + /* 605 + * DMA engine device might be configured with non-uniformly 606 + * distributed slave capabilities per device channels. In this 607 + * case the corresponding driver may provide the device_caps 608 + * callback to override the generic capabilities with 609 + * channel-specific ones. 610 + */ 611 + if (device->device_caps) 612 + device->device_caps(chan, caps); 613 + 604 614 return 0; 605 615 } 606 616 EXPORT_SYMBOL_GPL(dma_get_slave_caps);
+4
include/linux/dmaengine.h
··· 801 801 * be called after period_len bytes have been transferred. 802 802 * @device_prep_interleaved_dma: Transfer expression in a generic way. 803 803 * @device_prep_dma_imm_data: DMA's 8 byte immediate data to the dst address 804 + * @device_caps: May be used to override the generic DMA slave capabilities 805 + * with per-channel specific ones 804 806 * @device_config: Pushes a new configuration to a channel, return 0 or an error 805 807 * code 806 808 * @device_pause: Pauses any transfer happening on a channel. Returns ··· 903 901 struct dma_chan *chan, dma_addr_t dst, u64 data, 904 902 unsigned long flags); 905 903 904 + void (*device_caps)(struct dma_chan *chan, 905 + struct dma_slave_caps *caps); 906 906 int (*device_config)(struct dma_chan *chan, 907 907 struct dma_slave_config *config); 908 908 int (*device_pause)(struct dma_chan *chan);