DaVinci DMA engine conversion
Subsystems (3)
v3 cover DaVinci DMA engine conversion
Changes since v1:
- Add virt-dma support. Better error checks and simplified descriptor handling.
- Fix support for multiple EDMA controllers Tested on AM18x EVM with WL12xx on MMC1
Changes since v2:
- Set default Kconfig state to off
- Fix whitespace and indent issues
- Simplify struct device * assignments
- Remove unneeded chcnt in edma_chan_init
- Remove unneeded conditional assignment of prep_slave_sg
- Fix devm_* usage
This series begins the conversion of the DaVinci private EDMA API implementation to a DMA engine driver and converts two of the three in-kernel users of the private EDMA API to DMA engine.
The approach taken is similar to the recent OMAP DMA Engine conversion. The EDMA DMA Engine driver is a wrapper around the existing private EDMA implementation and registers the platform device within the driver. This allows the conversion series to stand alone with just the drivers and no changes to platform code. It also allows peripheral drivers to continue to use the private EDMA implementation until they are converted.
The EDMA DMA Engine driver supports slave transfers only at this time. It is planned to add cyclic transfers in support of audio peripherals.
There are three users of the private EDMA API in the kernel now:davinci_mmc, spi-davinci, and davinci-mcasp. This series provides DMA Engine conversions for the davinci_mmc and spi-davinci drivers which use the supported slave transfers.
This series has been tested on an AM18x EVM and Hawkboard with driver performance comparable to that of the private EDMA API implementations. Both MMC0 and MMC1 are tested which handles the DA850/OMAP-L138/AM18x specific case where MMC1 uses DMA channels on a second EDMA channel controller. All other platforms have a simpler design with just a single EDMA channel controller.
For those wanting to easily test this series, I've pushed a branch for each version to my github tree at https://github.com/ohporter/linux. The current branch is edma-dmaengine-v3.
After this series, the current plan is to complete the mcasp driver conversion which includes adding cyclic dma support. This will then enable the removal and refactoring of the private EDMA API functionality into the EDMA DMA Engine driver. Since EDMA is also used on the AM33xx family of parts in mach-omap2/, the plan is to enable this driver on that platform as well.
Matt Porter (3):
dmaengine: add TI EDMA DMA engine driver
mmc: davinci_mmc: convert to DMA engine API
spi: spi-davinci: convert to DMA engine API
drivers/dma/Kconfig | 10 + drivers/dma/Makefile | 1 + drivers/dma/edma.c | 671 ++++++++++++++++++++++++++++++++++++++++ drivers/mmc/host/davinci_mmc.c | 271 +++++----------- drivers/spi/spi-davinci.c | 292 ++++++++--------- include/linux/edma.h | 29 ++ 6 files changed, 923 insertions(+), 351 deletions(-) create mode 100644 drivers/dma/edma.c create mode 100644 include/linux/edma.h
Signature · 1 line
1.7.9.5
PATCH v3 1/3 dmaengine: add TI EDMA DMA engine driver
Add a DMA engine driver for the TI EDMA controller. This driver is implemented as a wrapper around the existing DaVinci private DMA implementation. This approach allows for incremental conversion of each peripheral driver to the DMA engine API. The EDMA driver supports slave transfers but does not yet support cyclic transfers.
--- drivers/dma/Kconfig | 10 + drivers/dma/Makefile | 1 + drivers/dma/edma.c | 671 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/edma.h | 29 +++ 4 files changed, 711 insertions(+) create mode 100644 drivers/dma/edma.c create mode 100644 include/linux/edma.h
drivers/dma/Kconfig +10 -0
@@ -208,6 +208,16 @@ config SIRF_DMA help Enable support for the CSR SiRFprimaII DMA engine. +config TI_EDMA + tristate "TI EDMA support" + depends on ARCH_DAVINCI + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + default n + help + Enable support for the TI EDMA controller. This DMA + engine is found on TI DaVinci and AM33xx parts. + config ARCH_HAS_ASYNC_TX_FIND_CHANNEL bool
drivers/dma/Makefile +1 -0
@@ -23,6 +23,7 @@ obj-$(CONFIG_IMX_DMA) += imx-dma.o obj-$(CONFIG_MXS_DMA) += mxs-dma.o obj-$(CONFIG_TIMB_DMA) += timb_dma.o obj-$(CONFIG_SIRF_DMA) += sirf-dma.o +obj-$(CONFIG_TI_EDMA) += edma.o obj-$(CONFIG_STE_DMA40) += ste_dma40.o ste_dma40_ll.o obj-$(CONFIG_TEGRA20_APB_DMA) += tegra20-apb-dma.o obj-$(CONFIG_PL330_DMA) += pl330.o
drivers/dma/edma.c new file +671 -0
671 lines not on this page · raw message
include/linux/edma.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* TI EDMA DMA engine driver +* +* Copyright 2012 Texas Instruments +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation version 2. +* +* This program is distributed "as is" WITHOUT ANY WARRANTY of any +* kind, whether express or implied; without even the implied warranty +* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ +#ifndef __LINUX_EDMA_H +#define __LINUX_EDMA_H + +struct dma_chan ; + +#if defined(CONFIG_TI_EDMA ) || defined(CONFIG_TI_EDMA_MODULE ) +bool edma_filter_fn (struct dma_chan *,void *); +#else +static inline bool edma_filter_fn (struct dma_chan *chan,void *param) +{ +return false; +} +#endif + +#endif
Signature · 1 line
1.7.9.5
PATCH v3 2/3 mmc: davinci_mmc: convert to DMA engine API
In reply to Matt PorterRemoves use of the DaVinci EDMA private DMA API and replaces it with use of the DMA engine API.
--- drivers/mmc/host/davinci_mmc.c | 271 ++++++++++++---------------------------- 1 file changed, 82 insertions(+), 189 deletions(-)
drivers/mmc/host/davinci_mmc.c +82 -189
@@ -30,11 +30,12 @@#include <linux/io.h> #include <linux/irq.h> #include <linux/delay.h> +#include <linux/dmaengine.h> #include <linux/dma-mapping.h> +#include <linux/edma.h> #include <linux/mmc/mmc.h> #include <mach/mmc.h> -#include <mach/edma.h> /* * Register Definitions
@@ -200,21 +201,13 @@ struct mmc_davinci_host {u32 bytes_left;u32 rxdma, txdma; +struct dma_chan *dma_tx; +struct dma_chan *dma_rx;bool use_dma;bool do_dma;bool sdio_int;bool active_request; -/* Scatterlist DMA uses one or more parameter RAM entries: -* the main one (associated with rxdma or txdma) plus zero or -* more links. The entries for a given transfer differ only -* by memory buffer (address, length) and link field. -*/ -struct edmacc_param tx_template; -struct edmacc_param rx_template; -unsigned n_link; -u32 links[MAX_NR_SG -1 ]; -/* For PIO we walk scatterlists one segment at a time. */ unsigned int sg_len;struct scatterlist *sg;
@@ -410,153 +403,74 @@ static void mmc_davinci_start_command(struct mmc_davinci_host *host,static void davinci_abort_dma (struct mmc_davinci_host *host) { -int sync_dev; +struct dma_chan *sync_dev;if (host->data_dir ==DAVINCI_MMC_DATADIR_READ ) - sync_dev = host->rxdma; + sync_dev = host->dma_rx;else - sync_dev = host->txdma; - -edma_stop (sync_dev); -edma_clean_channel (sync_dev); -} - -static void -mmc_davinci_xfer_done (struct mmc_davinci_host *host,struct mmc_data *data); - -static void mmc_davinci_dma_cb (unsigned channel,u16 ch_status,void *data) -{ -if (DMA_COMPLETE != ch_status) { -struct mmc_davinci_host *host = data; - -/* Currently means: DMA Event Missed, or "null" transfer -* request was seen. In the future, TC errors (like bad -* addresses) might be presented too. -*/ -dev_warn (mmc_dev (host->mmc),"DMA %s error\n" , - (host->data->flags &MMC_DATA_WRITE ) - ?"write" :"read" ); - host->data->error = -EIO ; -mmc_davinci_xfer_done (host, host->data); - } -} - -/* Set up tx or rx template, to be modified and updated later */ -static void __init mmc_davinci_dma_setup (struct mmc_davinci_host *host, -bool tx,struct edmacc_param *template) -{ -unsigned sync_dev; -const u16 acnt =4 ; -const u16 bcnt = rw_threshold >>2 ; -const u16 ccnt =0 ; -u32 src_port =0 ; -u32 dst_port =0 ; -s16 src_bidx, dst_bidx; -s16 src_cidx, dst_cidx; - -/* -* A-B Sync transfer: each DMA request is for one "frame" of -* rw_threshold bytes, broken into "acnt"-size chunks repeated -* "bcnt" times. Each segment needs "ccnt" such frames; since -* we tell the block layer our mmc->max_seg_size limit, we can -* trust (later) that it's within bounds. -* -* The FIFOs are read/written in 4-byte chunks (acnt == 4) and -* EDMA will optimize memory operations to use larger bursts. -*/ -if (tx) { - sync_dev = host->txdma; - -/* src_prt, ccnt, and link to be set up later */ - src_bidx = acnt; - src_cidx = acnt * bcnt; - - dst_port = host->mem_res->start +DAVINCI_MMCDXR ; - dst_bidx =0 ; - dst_cidx =0 ; - }else { - sync_dev = host->rxdma; - - src_port = host->mem_res->start +DAVINCI_MMCDRR ; - src_bidx =0 ; - src_cidx =0 ; - -/* dst_prt, ccnt, and link to be set up later */ - dst_bidx = acnt; - dst_cidx = acnt * bcnt; - } - -/* -* We can't use FIFO mode for the FIFOs because MMC FIFO addresses -* are not 256-bit (32-byte) aligned. So we use INCR, and the W8BIT -* parameter is ignored. -*/ -edma_set_src (sync_dev, src_port,INCR ,W8BIT ); -edma_set_dest (sync_dev, dst_port,INCR ,W8BIT ); + sync_dev = host->dma_tx; -edma_set_src_index (sync_dev, src_bidx, src_cidx); -edma_set_dest_index (sync_dev, dst_bidx, dst_cidx); - -edma_set_transfer_params (sync_dev, acnt, bcnt, ccnt,8 ,ABSYNC ); - -edma_read_slot (sync_dev, template); - -/* don't bother with irqs or chaining */ - template->opt |=EDMA_CHAN_SLOT (sync_dev) <<12 ; +dmaengine_terminate_all (sync_dev); } -static void mmc_davinci_send_dma_request (struct mmc_davinci_host *host, +static int mmc_davinci_send_dma_request (struct mmc_davinci_host *host,struct mmc_data *data) { -struct edmacc_param *template; -int channel, slot; -unsigned link; -struct scatterlist *sg; -unsigned sg_len; -unsigned bytes_left = host->bytes_left; -const unsigned shift =ffs (rw_threshold) -1 ; +struct dma_chan *chan; +struct dma_async_tx_descriptor *desc; +int ret =0 ;if (host->data_dir ==DAVINCI_MMC_DATADIR_WRITE ) { - template = &host->tx_template; - channel = host->txdma; +struct dma_slave_config dma_tx_conf = { + .direction =DMA_MEM_TO_DEV , + .dst_addr = host->mem_res->start +DAVINCI_MMCDXR , + .dst_addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES , + .dst_maxburst = + rw_threshold /DMA_SLAVE_BUSWIDTH_4_BYTES , + }; + chan = host->dma_tx; +dmaengine_slave_config (host->dma_tx, &dma_tx_conf); + + desc =dmaengine_prep_slave_sg (host->dma_tx, + data->sg, + host->sg_len, +DMA_MEM_TO_DEV , +DMA_PREP_INTERRUPT |DMA_CTRL_ACK ); +if (!desc) { +dev_dbg (mmc_dev (host->mmc), +"failed to allocate DMA TX descriptor" ); + ret =-1 ; + goto out; + } }else { - template = &host->rx_template; - channel = host->rxdma; - } - -/* We know sg_len and ccnt will never be out of range because -* we told the mmc layer which in turn tells the block layer -* to ensure that it only hands us one scatterlist segment -* per EDMA PARAM entry. Update the PARAM -* entries needed for each segment of this scatterlist. -*/ -for (slot = channel, link =0 , sg = data->sg, sg_len = host->sg_len; - sg_len-- !=0 && bytes_left; - sg =sg_next (sg), slot = host->links[link++]) { -u32 buf =sg_dma_address (sg); -unsigned count =sg_dma_len (sg); - - template->link_bcntrld = sg_len - ? (EDMA_CHAN_SLOT (host->links[link]) <<5 ) - :0xffff ; - -if (count > bytes_left) - count = bytes_left; - bytes_left -= count; - -if (host->data_dir ==DAVINCI_MMC_DATADIR_WRITE ) - template->src = buf; -else - template->dst = buf; - template->ccnt = count >> shift; - -edma_write_slot (slot, template); +struct dma_slave_config dma_rx_conf = { + .direction =DMA_DEV_TO_MEM , + .src_addr = host->mem_res->start +DAVINCI_MMCDRR , + .src_addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES , + .src_maxburst = + rw_threshold /DMA_SLAVE_BUSWIDTH_4_BYTES , + }; + chan = host->dma_rx; +dmaengine_slave_config (host->dma_rx, &dma_rx_conf); + + desc =dmaengine_prep_slave_sg (host->dma_rx, + data->sg, + host->sg_len, +DMA_DEV_TO_MEM , +DMA_PREP_INTERRUPT |DMA_CTRL_ACK ); +if (!desc) { +dev_dbg (mmc_dev (host->mmc), +"failed to allocate DMA RX descriptor" ); + ret =-1 ; + goto out; + } } -if (host->version ==MMC_CTLR_VERSION_2 ) -edma_clear_event (channel); +dmaengine_submit (desc); +dma_async_issue_pending (chan); -edma_start (channel); +out: +return ret; } static int mmc_davinci_start_dma_transfer(struct mmc_davinci_host *host,
@@ -564,6 +478,7 @@ static int mmc_davinci_start_dma_transfer(struct mmc_davinci_host *host, {int i;int mask = rw_threshold -1 ; +int ret =0 ; host->sg_len = dma_map_sg(mmc_dev(host->mmc), data->sg, data->sg_len, ((data->flags & MMC_DATA_WRITE)
@@ -583,70 +498,48 @@ static int mmc_davinci_start_dma_transfer(struct mmc_davinci_host *host, } host->do_dma =1 ; -mmc_davinci_send_dma_request (host, data); + ret =mmc_davinci_send_dma_request (host, data); -return 0 ; +return ret; } static void __init_or_moduledavinci_release_dma_channels (struct mmc_davinci_host *host) { -unsigned i; -if (!host->use_dma)return ; -for (i =0 ; i < host->n_link; i++) -edma_free_slot (host->links[i]); - -edma_free_channel (host->txdma); -edma_free_channel (host->rxdma); +dma_release_channel (host->dma_tx); +dma_release_channel (host->dma_rx); }static int __init davinci_acquire_dma_channels (struct mmc_davinci_host *host) { -u32 link_size; -int r, i; - -/* Acquire master DMA write channel */ - r =edma_alloc_channel (host->txdma, mmc_davinci_dma_cb, host, -EVENTQ_DEFAULT ); -if (r <0 ) { -dev_warn (mmc_dev (host->mmc),"alloc %s channel err %d\n" , -"tx" , r); -return r; - } -mmc_davinci_dma_setup (host, true, &host->tx_template); - -/* Acquire master DMA read channel */ - r =edma_alloc_channel (host->rxdma, mmc_davinci_dma_cb, host, -EVENTQ_DEFAULT ); -if (r <0 ) { -dev_warn (mmc_dev (host->mmc),"alloc %s channel err %d\n" , -"rx" , r); - goto free_master_write; +int r; +dma_cap_mask_t mask; + +dma_cap_zero (mask); +dma_cap_set (DMA_SLAVE , mask); + + host->dma_tx = +dma_request_channel (mask, edma_filter_fn, &host->txdma); +if (!host->dma_tx) { +dev_err (mmc_dev (host->mmc),"Can't get dma_tx channel\n" ); +return -ENODEV ; } -mmc_davinci_dma_setup (host, false, &host->rx_template); -/* Allocate parameter RAM slots, which will later be bound to a -* channel as needed to handle a scatterlist. -*/ - link_size =min_t (unsigned, host->nr_sg,ARRAY_SIZE (host->links)); -for (i =0 ; i < link_size; i++) { - r =edma_alloc_slot (EDMA_CTLR (host->txdma),EDMA_SLOT_ANY ); -if (r <0 ) { -dev_dbg (mmc_dev (host->mmc),"dma PaRAM alloc --> %d\n" , - r); -break ; - } - host->links[i] = r; + host->dma_rx = +dma_request_channel (mask, edma_filter_fn, &host->rxdma); +if (!host->dma_rx) { +dev_err (mmc_dev (host->mmc),"Can't get dma_rx channel\n" ); + r = -ENODEV ; + goto free_master_write; } - host->n_link = i;return 0 ; free_master_write: -edma_free_channel (host->txdma); +dma_release_channel (host->dma_tx);return r; }
@@ -1359,7 +1252,7 @@ static int __init davinci_mmcsd_probe(struct platform_device *pdev)* Each hw_seg uses one EDMA parameter RAM slot, always one * channel and then usually some linked slots. */ - mmc->max_segs =1 + host->n_link; + mmc->max_segs =MAX_NR_SG ;/* EDMA limit per hw segment (one or two MBytes) */ mmc->max_seg_size =MAX_CCNT * rw_threshold;
Signature · 1 line
1.7.9.5
PATCH v3 3/3 spi: spi-davinci: convert to DMA engine API
In reply to Matt PorterRemoves use of the DaVinci EDMA private DMA API and replaces it with use of the DMA engine API.
--- drivers/spi/spi-davinci.c | 292 ++++++++++++++++++++------------------------- 1 file changed, 130 insertions(+), 162 deletions(-)
drivers/spi/spi-davinci.c +130 -162
@@ -25,13 +25,14 @@#include <linux/platform_device.h> #include <linux/err.h> #include <linux/clk.h> +#include <linux/dmaengine.h> #include <linux/dma-mapping.h> +#include <linux/edma.h> #include <linux/spi/spi.h> #include <linux/spi/spi_bitbang.h> #include <linux/slab.h> #include <mach/spi.h> -#include <mach/edma.h> #define SPI_NO_RESOURCE ((resource_size_t)-1)
@@ -113,14 +114,6 @@#define SPIDEF 0x4c#define SPIFMT0 0x50 -/* We have 2 DMA channels per CS, one for RX and one for TX */ -struct davinci_spi_dma { -int tx_channel; -int rx_channel; -int dummy_param_slot; -enum dma_event_q eventq; -}; -/* SPI Controller driver's private data. */ struct davinci_spi {struct spi_bitbang bitbang;
@@ -134,11 +127,14 @@ struct davinci_spi {const void *tx;void *rx; -#define SPI_TMP_BUFSZ (SMP_CACHE_BYTES + 1) -u8 rx_tmp_buf[SPI_TMP_BUFSZ ];int rcount;int wcount; -struct davinci_spi_dma dma; + +struct dma_chan *dma_rx; +struct dma_chan *dma_tx; +int dma_rx_chnum; +int dma_tx_chnum; +struct davinci_spi_platform_data *pdata;void (*get_rx)(u32 rx_data,struct davinci_spi *);
@@ -496,21 +492,23 @@ out:return errors; } -static void davinci_spi_dma_callback (unsigned lch,u16 status,void *data) +static void davinci_spi_dma_rx_callback (void *data) { -struct davinci_spi *dspi = data; -struct davinci_spi_dma *dma = &dspi->dma; +struct davinci_spi *dspi = (struct davinci_spi *)data; -edma_stop (lch); + dspi->rcount =0 ; -if (status ==DMA_COMPLETE ) { -if (lch == dma->rx_channel) - dspi->rcount =0 ; -if (lch == dma->tx_channel) - dspi->wcount =0 ; - } +if (!dspi->wcount && !dspi->rcount) +complete (&dspi->done); +} -if ((!dspi->wcount && !dspi->rcount) || (status !=DMA_COMPLETE )) +static void davinci_spi_dma_tx_callback (void *data) +{ +struct davinci_spi *dspi = (struct davinci_spi *)data; + + dspi->wcount =0 ; + +if (!dspi->wcount && !dspi->rcount)complete (&dspi->done); }
@@ -526,20 +524,20 @@ static void davinci_spi_dma_callback(unsigned lch, u16 status, void *data)static int davinci_spi_bufs (struct spi_device *spi,struct spi_transfer *t) {struct davinci_spi *dspi; -int data_type, ret; +int data_type, ret = -ENOMEM ;u32 tx_data, spidat1;u32 errors =0 ;struct davinci_spi_config *spicfg;struct davinci_spi_platform_data *pdata;unsigned uninitialized_var (rx_buf_count ); -struct device *sdev; +void *dummy_buf =NULL ; +struct scatterlist sg_rx, sg_tx; dspi =spi_master_get_devdata (spi->master); pdata = dspi->pdata; spicfg = (struct davinci_spi_config *)spi->controller_data;if (!spicfg) spicfg = &davinci_spi_default_cfg; - sdev = dspi->bitbang.master->dev.parent;/* convert len to words based on bits_per_word */ data_type = dspi->bytes_per_word[spi->chip_select];
@@ -567,112 +565,83 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) spidat1 |= tx_data &0xFFFF ;iowrite32 (spidat1, dspi->base +SPIDAT1 ); }else { -struct davinci_spi_dma *dma; -unsigned long tx_reg, rx_reg; -struct edmacc_param param; -void *rx_buf; -int b, c; - - dma = &dspi->dma; - - tx_reg = (unsigned long )dspi->pbase +SPIDAT1 ; - rx_reg = (unsigned long )dspi->pbase +SPIBUF ; - -/* -* Transmit DMA setup -* -* If there is transmit data, map the transmit buffer, set it -* as the source of data and set the source B index to data -* size. If there is no transmit data, set the transmit register -* as the source of data, and set the source B index to zero. -* -* The destination is always the transmit register itself. And -* the destination never increments. -*/ - -if (t->tx_buf) { - t->tx_dma =dma_map_single (&spi->dev, (void *)t->tx_buf, - t->len,DMA_TO_DEVICE ); -if (dma_mapping_error (&spi->dev, t->tx_dma)) { -dev_dbg (sdev,"Unable to DMA map %d bytes" -"TX buffer\n" , t->len); -return -ENOMEM ; - } - } - -/* -* If number of words is greater than 65535, then we need -* to configure a 3 dimension transfer. Use the BCNTRLD -* feature to allow for transfers that aren't even multiples -* of 65535 (or any other possible b size) by first transferring -* the remainder amount then grabbing the next N blocks of -* 65535 words. -*/ - - c = dspi->wcount / (SZ_64K -1 );/* N 65535 Blocks */ - b = dspi->wcount - c * (SZ_64K -1 );/* Remainder */ -if (b) - c++; +struct dma_slave_config dma_rx_conf = { + .direction =DMA_DEV_TO_MEM , + .src_addr = (unsigned long )dspi->pbase +SPIBUF , + .src_addr_width = data_type, + .src_maxburst =1 , + }; +struct dma_slave_config dma_tx_conf = { + .direction =DMA_MEM_TO_DEV , + .dst_addr = (unsigned long )dspi->pbase +SPIDAT1 , + .dst_addr_width = data_type, + .dst_maxburst =1 , + }; +struct dma_async_tx_descriptor *rxdesc; +struct dma_async_tx_descriptor *txdesc; +void *buf; + + dummy_buf =kzalloc (t->len,GFP_KERNEL ); +if (!dummy_buf) + goto err_alloc_dummy_buf; + +dmaengine_slave_config (dspi->dma_rx, &dma_rx_conf); +dmaengine_slave_config (dspi->dma_tx, &dma_tx_conf); + +sg_init_table (&sg_rx,1 ); +if (!t->rx_buf) + buf = dummy_buf;else - b =SZ_64K -1 ; - - param.opt =TCINTEN |EDMA_TCC (dma->tx_channel); - param.src = t->tx_buf ? t->tx_dma : tx_reg; - param.a_b_cnt = b <<16 | data_type; - param.dst = tx_reg; - param.src_dst_bidx = t->tx_buf ? data_type :0 ; - param.link_bcntrld =0xffffffff ; - param.src_dst_cidx = t->tx_buf ? data_type :0 ; - param.ccnt = c; -edma_write_slot (dma->tx_channel, ¶m); -edma_link (dma->tx_channel, dma->dummy_param_slot); - -/* -* Receive DMA setup -* -* If there is receive buffer, use it to receive data. If there -* is none provided, use a temporary receive buffer. Set the -* destination B index to 0 so effectively only one byte is used -* in the temporary buffer (address does not increment). -* -* The source of receive data is the receive data register. The -* source address never increments. -*/ - -if (t->rx_buf) { - rx_buf = t->rx_buf; - rx_buf_count = t->len; - }else { - rx_buf = dspi->rx_tmp_buf; - rx_buf_count =sizeof (dspi->rx_tmp_buf); + buf = t->rx_buf; + t->rx_dma =dma_map_single (&spi->dev, buf, + t->len,DMA_FROM_DEVICE ); +if (!t->rx_dma) { + ret = -EFAULT ; + goto err_rx_map; } +sg_dma_address (&sg_rx) = t->rx_dma; +sg_dma_len (&sg_rx) = t->len; - t->rx_dma =dma_map_single (&spi->dev, rx_buf, rx_buf_count, -DMA_FROM_DEVICE ); -if (dma_mapping_error (&spi->dev, t->rx_dma)) { -dev_dbg (sdev,"Couldn't DMA map a %d bytes RX buffer\n" , - rx_buf_count); -if (t->tx_buf) -dma_unmap_single (&spi->dev, t->tx_dma, t->len, -DMA_TO_DEVICE ); -return -ENOMEM ; +sg_init_table (&sg_tx,1 ); +if (!t->tx_buf) + buf = dummy_buf; +else + buf = (void *)t->tx_buf; + t->tx_dma =dma_map_single (&spi->dev, buf, + t->len,DMA_FROM_DEVICE ); +if (!t->tx_dma) { + ret = -EFAULT ; + goto err_tx_map; } - - param.opt =TCINTEN |EDMA_TCC (dma->rx_channel); - param.src = rx_reg; - param.a_b_cnt = b <<16 | data_type; - param.dst = t->rx_dma; - param.src_dst_bidx = (t->rx_buf ? data_type :0 ) <<16 ; - param.link_bcntrld =0xffffffff ; - param.src_dst_cidx = (t->rx_buf ? data_type :0 ) <<16 ; - param.ccnt = c; -edma_write_slot (dma->rx_channel, ¶m); +sg_dma_address (&sg_tx) = t->tx_dma; +sg_dma_len (&sg_tx) = t->len; + + rxdesc =dmaengine_prep_slave_sg (dspi->dma_rx, + &sg_rx,1 ,DMA_DEV_TO_MEM , +DMA_PREP_INTERRUPT |DMA_CTRL_ACK ); +if (!rxdesc) + goto err_desc; + + txdesc =dmaengine_prep_slave_sg (dspi->dma_tx, + &sg_tx,1 ,DMA_MEM_TO_DEV , +DMA_PREP_INTERRUPT |DMA_CTRL_ACK ); +if (!txdesc) + goto err_desc; + + rxdesc->callback = davinci_spi_dma_rx_callback; + rxdesc->callback_param = (void *)dspi; + txdesc->callback = davinci_spi_dma_tx_callback; + txdesc->callback_param = (void *)dspi;if (pdata->cshold_bug)iowrite16 (spidat1 >>16 , dspi->base +SPIDAT1 +2 ); -edma_start (dma->rx_channel); -edma_start (dma->tx_channel); +dmaengine_submit (rxdesc); +dmaengine_submit (txdesc); + +dma_async_issue_pending (dspi->dma_rx); +dma_async_issue_pending (dspi->dma_tx); +set_io_bits (dspi->base +SPIINT ,SPIINT_DMA_REQ_EN ); }
@@ -690,15 +659,13 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)clear_io_bits (dspi->base +SPIINT ,SPIINT_MASKALL );if (spicfg->io_type ==SPI_IO_TYPE_DMA ) { - -if (t->tx_buf) -dma_unmap_single (&spi->dev, t->tx_dma, t->len, -DMA_TO_DEVICE ); - -dma_unmap_single (&spi->dev, t->rx_dma, rx_buf_count, -DMA_FROM_DEVICE ); -clear_io_bits (dspi->base +SPIINT ,SPIINT_DMA_REQ_EN ); + +dma_unmap_single (&spi->dev, t->rx_dma, + t->len,DMA_FROM_DEVICE ); +dma_unmap_single (&spi->dev, t->tx_dma, + t->len,DMA_TO_DEVICE ); +kfree (dummy_buf); }clear_io_bits (dspi->base +SPIGCR1 ,SPIGCR1_SPIENA_MASK );
@@ -716,11 +683,20 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) }if (dspi->rcount !=0 || dspi->wcount !=0 ) { -dev_err (sdev,"SPI data transfer error\n" ); +dev_err (&spi->dev,"SPI data transfer error\n" );return -EIO ; }return t->len; + +err_desc: +dma_unmap_single (&spi->dev, t->tx_dma, t->len,DMA_TO_DEVICE ); +err_tx_map: +dma_unmap_single (&spi->dev, t->rx_dma, t->len,DMA_FROM_DEVICE ); +err_rx_map: +kfree (dummy_buf); +err_alloc_dummy_buf: +return ret; }/**
@@ -751,39 +727,33 @@ static irqreturn_t davinci_spi_irq(s32 irq, void *data)static int davinci_spi_request_dma (struct davinci_spi *dspi) { +dma_cap_mask_t mask; +struct device *sdev = dspi->bitbang.master->dev.parent;int r; -struct davinci_spi_dma *dma = &dspi->dma; - r =edma_alloc_channel (dma->rx_channel, davinci_spi_dma_callback, dspi, - dma->eventq); -if (r <0 ) { -pr_err ("Unable to request DMA channel for SPI RX\n" ); - r = -EAGAIN ; +dma_cap_zero (mask); +dma_cap_set (DMA_SLAVE , mask); + + dspi->dma_rx =dma_request_channel (mask, edma_filter_fn, + &dspi->dma_rx_chnum); +if (!dspi->dma_rx) { +dev_err (sdev,"request RX DMA channel failed\n" ); + r = -ENODEV ; goto rx_dma_failed; } - r =edma_alloc_channel (dma->tx_channel, davinci_spi_dma_callback, dspi, - dma->eventq); -if (r <0 ) { -pr_err ("Unable to request DMA channel for SPI TX\n" ); - r = -EAGAIN ; + dspi->dma_tx =dma_request_channel (mask, edma_filter_fn, + &dspi->dma_tx_chnum); +if (!dspi->dma_tx) { +dev_err (sdev,"request TX DMA channel failed\n" ); + r = -ENODEV ; goto tx_dma_failed; } - r =edma_alloc_slot (EDMA_CTLR (dma->tx_channel),EDMA_SLOT_ANY ); -if (r <0 ) { -pr_err ("Unable to request SPI TX DMA param slot\n" ); - r = -EAGAIN ; - goto param_failed; - } - dma->dummy_param_slot = r; -edma_link (dma->dummy_param_slot, dma->dummy_param_slot); -return 0 ; -param_failed: -edma_free_channel (dma->tx_channel); + tx_dma_failed: -edma_free_channel (dma->rx_channel); +dma_release_channel (dspi->dma_rx); rx_dma_failed:return r; }
@@ -898,9 +868,8 @@ static int __devinit davinci_spi_probe(struct platform_device *pdev) dspi->bitbang.txrx_bufs = davinci_spi_bufs;if (dma_rx_chan !=SPI_NO_RESOURCE && dma_tx_chan !=SPI_NO_RESOURCE ) { - dspi->dma.rx_channel = dma_rx_chan; - dspi->dma.tx_channel = dma_tx_chan; - dspi->dma.eventq = pdata->dma_event_q; + dspi->dma_rx_chnum = dma_rx_chan; + dspi->dma_tx_chnum = dma_tx_chan; ret =davinci_spi_request_dma (dspi);if (ret)
@@ -955,9 +924,8 @@ static int __devinit davinci_spi_probe(struct platform_device *pdev)return ret; free_dma: -edma_free_channel (dspi->dma.tx_channel); -edma_free_channel (dspi->dma.rx_channel); -edma_free_slot (dspi->dma.dummy_param_slot); +dma_release_channel (dspi->dma_rx); +dma_release_channel (dspi->dma_tx); free_clk:clk_disable (dspi->clk);clk_put (dspi->clk);
Signature · 1 line
1.7.9.5
Re: [PATCH v3 3/3] spi: spi-davinci: convert to DMA engine API
Hi Matt,
Quoted 4 lines · Matt Porter
Removes use of the DaVinci EDMA private DMA API and replaces it with use of the DMA engine API.
Signed-off-by Matt Porter <[email protected]>
I tried testing this patch on my OMAP-L138 EVM, but SPI fails to initialize after applying the patch.
root at arago:~# dmesg | grep -i spi spi_davinci spi_davinci.1: request RX DMA channel failed
without these 3 patches, SPI flash is detected fine (same kernel configuration):
root at arago:~# dmesg | grep spispi_davinci spi_davinci.1: DMA: supportedspi_davinci spi_davinci.1: DMA: RX channel: 18, TX channel: 19, event queue: 0 spi_davinci spi_davinci.1: master is unqueued, this is deprecated m25p80 spi1.0: m25p64 (8192 Kbytes)spi_davinci spi_davinci.1: Controller at 0xfef0e000
Any idea what could be wrong? This is v3.6-rc3 kernel. I can provide full bootlogs or any other debug information if that helps.
Thanks,
Sekhar
Re: [PATCH v3 3/3] spi: spi-davinci: convert to DMA engine API
Quoted 6 lines · Sekhar Nori
Hi Matt,
Quoted 3 lines · Matt Porter
Removes use of the DaVinci EDMA private DMA API and replaces it with use of the DMA engine API.
Quoted 7 lines
Quoted 1 line
Signed-off-by Matt Porter <[email protected]>I tried testing this patch on my OMAP-L138 EVM, but SPI fails to initialize after applying the patch.
root@arago:~# dmesg | grep -i spi spi_davinci spi_davinci.1: request RX DMA channel failed
Hi Sekhar,
Most likely CONFIG_TI_EDMA is off as it defaults to off in the v3 series. Try enabling this and if it's the problem then this error path can be fixed to properly fallback to PIO only or fail to initialize as needed.
-Matt
Re: [PATCH v3 3/3] spi: spi-davinci: convert to DMA engine API
Quoted 15 lines · Matt Porter
Quoted 6 lines · Sekhar Nori
Hi Matt,
Quoted 3 lines · Matt Porter
Removes use of the DaVinci EDMA private DMA API and replaces it with use of the DMA engine API.
Quoted 7 lines
Quoted 1 line
Signed-off-by Matt Porter <[email protected]>I tried testing this patch on my OMAP-L138 EVM, but SPI fails to initialize after applying the patch.
root@arago:~# dmesg | grep -i spi spi_davinci spi_davinci.1: request RX DMA channel failed
Quoted 6 lines
Hi Sekhar,
Most likely
CONFIG_TI_EDMAis off as it defaults to off in the v3 series. Try enabling this and if it's the problem then this error path can be fixed to properly fallback to PIO only or fail to initialize as needed.
I didnt see any update on this one, is it okay, if so care to send a tested-by?
Signature · 2 lines
~Vinod Koul Intel Corp.
Sekhar Nori
Tested-byRe: [PATCH v3 3/3] spi: spi-davinci: convert to DMA engine API
In reply to Matt PorterHi Matt,
Quoted 15 lines · Matt Porter
Quoted 6 lines · Sekhar Nori
Hi Matt,
Quoted 3 lines · Matt Porter
Removes use of the DaVinci EDMA private DMA API and replaces it with use of the DMA engine API.
Quoted 7 lines
Quoted 1 line
Signed-off-by Matt Porter <[email protected]>I tried testing this patch on my OMAP-L138 EVM, but SPI fails to initialize after applying the patch.
root at arago:~# dmesg | grep -i spi
spi_davincispi_davinci.1: request RX DMA channel failed
Quoted 6 lines
Hi Sekhar,
Most likely
CONFIG_TI_EDMAis off as it defaults to off in the v3 series. Try enabling this and if it's the problem then this error path can be fixed to properly fallback to PIO only or fail to initialize as needed.
Yes, this was the problem. Since the SPI driver now depends on CONFIG_TI_EDMA for basic operation may be select CONFIG_TI_EDMA in Kconfig if SPI is enabled? That should do until the fallback to PIO is implemented.
With that fixed, I tested SPI on OMAP-L138 EVM and it works great. Tested a JFFS2 mount as well as some raw chardev read/write tests.
Thanks,
Sekhar
Re: [PATCH v3 3/3] spi: spi-davinci: convert to DMA engine API
Quoted 25 lines · Sekhar Nori
Hi Matt,
Quoted 15 lines · Matt Porter
Quoted 6 lines · Sekhar Nori
Hi Matt,
Quoted 3 lines · Matt Porter
Removes use of the DaVinci EDMA private DMA API and replaces it with use of the DMA engine API.
Quoted 7 lines
Quoted 1 line
Signed-off-by Matt Porter <[email protected]>I tried testing this patch on my OMAP-L138 EVM, but SPI fails to initialize after applying the patch.
root@arago:~# dmesg | grep -i spi spi_davinci spi_davinci.1: request RX DMA channel failedQuoted 6 lines
Hi Sekhar,
Most likely
CONFIG_TI_EDMAis off as it defaults to off in the v3 series. Try enabling this and if it's the problem then this error path can be fixed to properly fallback to PIO only or fail to initialize as needed.
Quoted 4 lines
Yes, this was the problem. Since the SPI driver now depends on
CONFIG_TI_EDMAfor basic operation may be selectCONFIG_TI_EDMAinKconfigif SPI is enabled? That should do until the fallback to PIO is implemented.
Then this should be enabled for SPI. Care to send a patch
Quoted 13 lines
With that fixed, I tested SPI on OMAP-L138 EVM and it works great. Tested a JFFS2 mount as well as some raw chardev read/write tests.
Tested-by Sekhar Nori <[email protected]>Thanks,
Sekhar
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 2 lines
~Vinod Koul Intel Corp.
Re: [PATCH v3 3/3] spi: spi-davinci: convert to DMA engine API
Quoted 26 lines · Vinod Koul
Quoted 25 lines · Sekhar Nori
Hi Matt,
Quoted 21 lines · Matt Porter
Quoted 6 lines · Sekhar Nori
Hi Matt,
Quoted 3 lines · Matt Porter
Removes use of the DaVinci EDMA private DMA API and replaces it with use of the DMA engine API.
Quoted 7 lines
Quoted 1 line
Signed-off-by Matt Porter <[email protected]>I tried testing this patch on my OMAP-L138 EVM, but SPI fails to initialize after applying the patch.
root at arago:~# dmesg | grep -i spi
spi_davincispi_davinci.1: request RX DMA channel failedHi Sekhar,
Most likely
CONFIG_TI_EDMAis off as it defaults to off in the v3 series. Try enabling this and if it's the problem then this error path can be fixed to properly fallback to PIO only or fail to initialize as needed.
Quoted 5 lines
Quoted 4 lines
Yes, this was the problem. Since the SPI driver now depends on
CONFIG_TI_EDMAfor basic operation may be selectCONFIG_TI_EDMAinKconfigif SPI is enabled? That should do until the fallback to PIO is implemented.Then this should be enabled for SPI. Care to send a patch
By 'this' you mean the Kconfig select? Then there should be no need of a new patch for this. It can be part of this patch itself, no?
Thanks,
Sekhar
Re: [PATCH v3 3/3] spi: spi-davinci: convert to DMA engine API
Quoted 10 lines · Sekhar Nori
Quoted 3 lines
Quoted 3 lines
Yes, this was the problem. Since the SPI driver now depends on
CONFIG_TI_EDMAfor basic operation may be selectCONFIG_TI_EDMAinKconfigif SPI is enabled? That should do until the fallback to PIOis
Quoted 2 lines
Quoted 1 line
implemented.
Then this should be enabled for SPI. Care to send a patch
By 'this' you mean the
Kconfigselect? Then there should be no need of a
new patch for this. It can be part of this patch itself, no?
Either way is okay for me.
Signature · 2 lines
~Vinod Koul Intel Corp.
Re: [PATCH v3 3/3] spi: spi-davinci: convert to DMA engine API
Quoted 4 lines · Vinod Koul
Quoted 3 lines · Sekhar Nori
Quoted 3 lines
Quoted 3 lines
Yes, this was the problem. Since the SPI driver now depends on
CONFIG_TI_EDMAfor basic operation may be selectCONFIG_TI_EDMAinKconfigif SPI is enabled? That should do until the fallback to PIO
Quoted 8 lines
Quoted 7 lines
is
Quoted 2 lines
Quoted 1 line
implemented.
Then this should be enabled for SPI. Care to send a patch
By 'this' you mean the
Kconfigselect? Then there should be no need of a
new patch for this. It can be part of this patch itself, no?Either way is okay for me.
And am in good mood :)
Applied all with this as well
Quoted 1 line
From
b5f14330590118e6a0659255476c0f24ab681e05Mon Sep 17 00:00:00 2001
From: Vinod Koul <[email protected]>
Date: Sat, 1 Sep 2012 06:29:22 +0530
Subject: [PATCH] spi: davici - make davinci select edma
--- drivers/spi/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/spi/Kconfig +0 -0
@@ -134,6 +134,7 @@ config SPI_DAVINCI tristate "Texas Instruments DaVinci/DA8x/OMAP-L/AM1x SoC SPI
controller"
depends on ARCH_DAVINCI
select SPI_BITBANG
+ select TI_EDMA
help
SPI master controller for DaVinci/DA8x/OMAP-L/AM1x SPI modules.
Signature · 7 lines
1.7.9.5 -- ~Vinod Koul Intel Corp.
Re: [PATCH v3 3/3] spi: spi-davinci: convert to DMA engine API
Quoted 6 lines · Vinod Koul
Quoted 5 lines · Vinod Koul
Quoted 4 lines · Sekhar Nori
Quoted 3 lines
Quoted 3 lines
Yes, this was the problem. Since the SPI driver now depends on
CONFIG_TI_EDMAfor basic operation may be selectCONFIG_TI_EDMAinKconfigif SPI is enabled? That should do until the fallback to PIOis
Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
implemented.
Then this should be enabled for SPI. Care to send a patch
By 'this' you mean the
Kconfigselect? Then there should be no need of a
new patch for this. It can be part of this patch itself, no?Either way is okay for me.
And am in good mood :)
I am as well...thanks for taking care of the patch to address the Kconfig issue and applying. It's nice to return from holiday and not have to do anything with this series. :)
-Matt
Quoted 39 lines
Applied all with this as well
Quoted 1 line
From
b5f14330590118e6a0659255476c0f24ab681e05Mon Sep 17 00:00:00 2001From: Vinod Koul <[email protected]>
Date: Sat, 1 Sep 2012 06:29:22 +0530
Subject: [PATCH] spi: davici - make davinci select edmaReported-by Sekhar Nori <[email protected]>Signed-off-by Vinod Koul <[email protected]>--- drivers/spi/Kconfig | 1 + 1 file changed, 1 insertion(+)drivers/spi/Kconfig +0
-0@@ -134,6 +134,7 @@ config SPI_DAVINCI tristate "Texas Instruments DaVinci/DA8x/OMAP-L/AM1x SoC SPIcontroller"
drivers/spi/Kconfig +1
-0depends on ARCH_DAVINCI select SPI_BITBANG + select TI_EDMA help SPI master controller for DaVinci/DA8x/OMAP-L/AM1x SPI modules.Signature · 13 lines
-- 1.7.9.5 -- ~Vinod Koul Intel Corp. _______________________________________________ Davinci-linux-open-source mailing list [email protected] http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
On Wed, Aug 22, 2012 at 09:09:33PM -0400, Matt Porter wrote:
[snip]
Quoted 5 lines
Matt Porter (3):
dmaengine: add TI EDMA DMA engine driver
mmc:davinci_mmc: convert to DMA engine API
spi: spi-davinci: convert to DMA engine API
Quoted 9 lines
drivers/dma/Kconfig | 10 + drivers/dma/Makefile | 1 + drivers/dma/edma.c | 671 ++++++++++++++++++++++++++++++++++++++++ drivers/mmc/host/davinci_mmc.c | 271 +++++----------- drivers/spi/spi-davinci.c | 292 ++++++++--------- include/linux/edma.h | 29 ++ 6 files changed, 923 insertions(+), 351 deletions(-) create mode 100644 drivers/dma/edma.c create mode 100644 include/linux/edma.h
On the Logic PD AM1808 EVM:
mmc0 rootfs: http://pastebin.com/HKVdmA0G
jffs2 on the SPI flash rootfs: http://pastebin.com/cpAHgdug
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120822/41135f2d/attachment.sig>
Hi Matt,
Quoted 31 lines · Matt Porter
This series begins the conversion of the DaVinci private EDMA API implementation to a DMA engine driver and converts two of the three in-kernel users of the private EDMA API to DMA engine.
The approach taken is similar to the recent OMAP DMA Engine conversion. The EDMA DMA Engine driver is a wrapper around the existing private EDMA implementation and registers the platform device within the driver. This allows the conversion series to stand alone with just the drivers and no changes to platform code. It also allows peripheral drivers to continue to use the private EDMA implementation until they are converted.
The EDMA DMA Engine driver supports slave transfers only at this time. It is planned to add cyclic transfers in support of audio peripherals.
There are three users of the private EDMA API in the kernel now:
davinci_mmc, spi-davinci, and davinci-mcasp. This series provides DMA Engine conversions for thedavinci_mmcand spi-davinci drivers which use the supported slave transfers.This series has been tested on an AM18x EVM and Hawkboard with driver performance comparable to that of the private EDMA API implementations. Both MMC0 and MMC1 are tested which handles the DA850/OMAP-L138/AM18x specific case where MMC1 uses DMA channels on a second EDMA channel controller. All other platforms have a simpler design with just a single EDMA channel controller.
For those wanting to easily test this series, I've pushed a branch for each version to my github tree at https://github.com/ohporter/linux. The current branch is edma-dmaengine-v3.
Quoted 6 lines
After this series, the current plan is to complete the mcasp driver conversion which includes adding cyclic dma support. This will then enable the removal and refactoring of the private EDMA API functionality into the EDMA DMA Engine driver. Since EDMA is also used on the AM33xx family of parts in mach-omap2/, the plan is to enable this driver on that platform as well.
Once you have a patch for the McASP driver conversion, I can happily test this on a AM33xx board, together with Gururaja's latest McASP refactoring series. Let me know how I can help you here.
Thanks,
Daniel
Hi Matt,
Quoted 39 lines · Daniel Mack
Quoted 31 lines · Matt Porter
This series begins the conversion of the DaVinci private EDMA API implementation to a DMA engine driver and converts two of the three in-kernel users of the private EDMA API to DMA engine.
The approach taken is similar to the recent OMAP DMA Engine conversion. The EDMA DMA Engine driver is a wrapper around the existing private EDMA implementation and registers the platform device within the driver. This allows the conversion series to stand alone with just the drivers and no changes to platform code. It also allows peripheral drivers to continue to use the private EDMA implementation until they are converted.
The EDMA DMA Engine driver supports slave transfers only at this time. It is planned to add cyclic transfers in support of audio peripherals.
There are three users of the private EDMA API in the kernel now:
davinci_mmc, spi-davinci, and davinci-mcasp. This series provides DMA Engine conversions for thedavinci_mmcand spi-davinci drivers which use the supported slave transfers.This series has been tested on an AM18x EVM and Hawkboard with driver performance comparable to that of the private EDMA API implementations. Both MMC0 and MMC1 are tested which handles the DA850/OMAP-L138/AM18x specific case where MMC1 uses DMA channels on a second EDMA channel controller. All other platforms have a simpler design with just a single EDMA channel controller.
For those wanting to easily test this series, I've pushed a branch for each version to my github tree at https://github.com/ohporter/linux. The current branch is edma-dmaengine-v3.
Quoted 6 lines
After this series, the current plan is to complete the mcasp driver conversion which includes adding cyclic dma support. This will then enable the removal and refactoring of the private EDMA API functionality into the EDMA DMA Engine driver. Since EDMA is also used on the AM33xx family of parts in mach-omap2/, the plan is to enable this driver on that platform as well.
Quoted 3 lines
Once you have a patch for the McASP driver conversion, I can happily test this on a AM33xx board, together with Gururaja's latest McASP refactoring series. Let me know how I can help you here.
Did you find some time yet to continue on this side? I don't want to appear pushy, but as I need to finish some DT transition on a AM33xx-based board, I would much like to help out here, in case I can do anything to help speed things along.
Many thanks for your work!
Daniel
Quoted 46 lines · Daniel Mack
Hi Matt,
Quoted 39 lines · Daniel Mack
Quoted 31 lines · Matt Porter
This series begins the conversion of the DaVinci private EDMA API implementation to a DMA engine driver and converts two of the three in-kernel users of the private EDMA API to DMA engine.
The approach taken is similar to the recent OMAP DMA Engine conversion. The EDMA DMA Engine driver is a wrapper around the existing private EDMA implementation and registers the platform device within the driver. This allows the conversion series to stand alone with just the drivers and no changes to platform code. It also allows peripheral drivers to continue to use the private EDMA implementation until they are converted.
The EDMA DMA Engine driver supports slave transfers only at this time. It is planned to add cyclic transfers in support of audio peripherals.
There are three users of the private EDMA API in the kernel now:
davinci_mmc, spi-davinci, and davinci-mcasp. This series provides DMA Engine conversions for thedavinci_mmcand spi-davinci drivers which use the supported slave transfers.This series has been tested on an AM18x EVM and Hawkboard with driver performance comparable to that of the private EDMA API implementations. Both MMC0 and MMC1 are tested which handles the DA850/OMAP-L138/AM18x specific case where MMC1 uses DMA channels on a second EDMA channel controller. All other platforms have a simpler design with just a single EDMA channel controller.
For those wanting to easily test this series, I've pushed a branch for each version to my github tree at https://github.com/ohporter/linux. The current branch is edma-dmaengine-v3.
Quoted 6 lines
After this series, the current plan is to complete the mcasp driver conversion which includes adding cyclic dma support. This will then enable the removal and refactoring of the private EDMA API functionality into the EDMA DMA Engine driver. Since EDMA is also used on the AM33xx family of parts in mach-omap2/, the plan is to enable this driver on that platform as well.
Quoted 3 lines
Once you have a patch for the McASP driver conversion, I can happily test this on a AM33xx board, together with Gururaja's latest McASP refactoring series. Let me know how I can help you here.
Quoted 7 lines
Did you find some time yet to continue on this side? I don't want to appear pushy, but as I need to finish some DT transition on a AM33xx-based board, I would much like to help out here, in case I can do anything to help speed things along.
Many thanks for your work!
Hi Daniel,
I'm working on porting this driver work to AM33xx right now. You can take a look at an ugly but functional WIP version at the above repo in the WIP/edma-dmaengine-am335x-v3.6-rc4-cpufreq branch. When I say ugly, I mean ugly...there's a few hacks I'm resolving before I plan to post an RFC series. However, I've been putting the slave sg transfer through a workout on hsmmc and mcspi and it is solid now.
I don't expect to start on MCASP conversion until I get this AM33xx enablement series posted. There's a couple things you could help with here. First, I have done some preliminary work in understanding the various "old" platforms in mach-davinci/ that we are going to have to avoid breaking. The first big issue is that we have a split in h/w capabilities between the old platforms that have no AFIFO and our newer ones that do. Unless someone can convince me otherwise, the biggest (and possibly *only*) driver behind the need for SRAM-based ping-pong buffering. This SRAM-based ping-pong buffering is a PITA to deal with atm mostly because we need to encapsulate this behind the cyclic dma api. It's also IMHO, unneeded if you have one of the modern platforms that added the AFIFO since you aren't having to feed the serializer at an unreasonable rate...i.e. we can do fifo bursts.
Now, we *can* handle SRAM ping-pong buffering within the dmaengine driver, however in the short-term it's a bit of a pain because of the way the wrapper driver is instantiated and I'd like to avoid any complication of having to feed it platform data until we absolutely have to. That is, with SRAM ping-pong buffering, we now have to have platform-specific data about the SRAM we can allocate. This is complicated by the fact that 1) the ARM SRAM consolidation series seemingly died last year...which btw, left some orphaned mcasp sram ping pong enablement patch out of tree for mach-davinci/ 2) the latest SRAM driver effort is specifically tied around DT atm which makes it short-term problematic to leverage on mach-davinci/ platforms where we really need it.
My best idea at this point is to approach the McASP conversion in a couple stages. The first is to support cyclic dma in the dmaengine wrapper driver in continuous mode such that only platforms with AFIFO support (DA8xx/L138/AM180x and AM33xx/TI81xx to my knowledge) can utilize it. Also part of the first stage, of course, is the mcasp driver refactoring so that ping-pong buffering is an optional sub-config option for those old Davinci boards and continues to use the private EDMA API for now. I'm ok with this partially because those old platform seem to be unmaintained (nobody stepped up to test DM644x etc) and the SRAM ping-pong buffering code is completely unused in mainline right now. If those !AFIFO platforms were removed from the kernel then we wouldn't even have to deal with it.
There's a few things you can help with:
1) testing the WIP driver
2) add cyclic dma support
3) do the sram-less mcasp conversion
I'll get to #2 and #3 next, but I have no problem if you beat me to it.
-Matt