dmaengine: Pl08x and dw_dmac updates
Subsystems (14)
v2 cover dmaengine: Pl08x and dw_dmac updates
Hi Vinod/Dan,
This patchset does following:
- Includes earlier patchset sent by Rajeev for cleanly applying this patchset
- Adds device_fc (device flow control) field in struct DMA_SLAVE_CONFIG
- Fixes existing users of DMAENGINE for device_fc.
- Updates pl08x driver according to that
- Fixes few issues/bugs in dw_dmac driver
- Adds DMA_SLAVE_CONFIG for dw_dmac driver
- Fixes existing users of dw_dmac driver
Change History:
Since V1:
- used dev_get_platdata() instead of platform_get_drvdata(), as that was incorrect
- Lots of fixes in: dmaengine/dw_dmac: Add support for DMA_SLAVE_CONFIG
- Additional patches:
- dmaengine/dw_dmac: Add 64 bit access width support for slave xfers on mem side
- Fix other kernel driver for device_fc and dw_dmac changes.
Rebased-on:
commit 3506c0d507144d9b0f19efd5a56d289f70611179
Author: Tushar Behera <[email protected]> Date: Tue Dec 6 16:15:54 2011 +0530
DMA: PL330: Remove pm_runtime_xxx calls from pl330 probe/remove
Rajeev KUMAR (1):
dmaengine/dw_dmac: Hibernation support in dw_dmac
Viresh Kumar (11):
dmaengine: Add flow controller information to dma_slave_config
dmaengine: Pass dma_slave_config .device_fc = NULL for all existing
users
dmaengine/amba-pl08x: Take flow controller info from DMA_SLAVE_CONFIG dmaengine/dw_dmac: Don't use magic number for total number of
channels
dmaengine/dw_dmac: Use dev_get_platdata() instead of accessing dev
directly
dmaengine/dw_dmac: Don't handle block interrupts dmaengine/dw_dmac: Unmap all memory buffers after completion of slave
transfers
dmaengine/dw_dmac: Add 64 bit access width support for slave xfers on
mem side
dmaengine/dw_dmac: Add support for DMA_SLAVE_CONFIG dmaengine/dw_dmac: Fix dw_dmac user drivers to adapt to slave_config
changes
dmaengine/dw_dmac: Remove unused fields in struct dw_dma_slave
arch/avr32/mach-at32ap/at32ap700x.c | 13 -- arch/avr32/mach-at32ap/include/mach/atmel-mci.h | 7 - drivers/dma/amba-pl08x.c | 4 +- drivers/dma/dw_dmac.c | 232 +++++++++++++++-------- drivers/dma/dw_dmac_regs.h | 15 ++ drivers/mmc/host/atmel-mci.c | 24 ++- drivers/mmc/host/mmci.c | 2 + drivers/mmc/host/mxcmmc.c | 2 + drivers/spi/spi-dw-mid.c | 3 + drivers/spi/spi-pl022.c | 2 + drivers/tty/serial/amba-pl011.c | 3 + drivers/usb/musb/ux500_dma.c | 1 + include/linux/amba/pl08x.h | 8 +- include/linux/dmaengine.h | 5 + include/linux/dw_dmac.h | 38 ---- sound/atmel/abdac.c | 18 ++- sound/atmel/ac97c.c | 41 ++++- sound/soc/imx/imx-pcm-dma-mx2.c | 3 + 18 files changed, 255 insertions(+), 166 deletions(-)
Signature · 1 line
1.7.8.110.g4cb5d
PATCH v2 1/12 dmaengine/dw_dmac: Hibernation support in dw_dmac
From: Rajeev KUMAR <[email protected]>
The suspend and resume implementation is through dev_pm_ops in dmac. So in order to support hibernation, freeze, thaw, restore and poweroff features are required.
--- drivers/dma/dw_dmac.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/dma/dw_dmac.c +4 -0
@@ -1562,6 +1562,10 @@ static int dw_resume_noirq(struct device *dev)static const struct dev_pm_ops dw_dev_pm_ops = { .suspend_noirq = dw_suspend_noirq, .resume_noirq = dw_resume_noirq, + .freeze_noirq = dw_suspend_noirq, + .thaw_noirq = dw_resume_noirq, + .restore_noirq = dw_resume_noirq, + .poweroff_noirq = dw_suspend_noirq, };static struct platform_driver dw_driver = {
Signature · 1 line
1.7.8.110.g4cb5d
PATCH v2 2/12 dmaengine: Add flow controller information to dma_slave_config
In reply to Viresh KumarFlow controller is programmable for few controllers and there are few intelligent peripherals like, Synopsys JPEG controller, that needs to be a flow controller of DMA transfers on dest side.
For this, currently two drivers, pl08x and dw_dmac, support flow controller to be passed from platform to these drivers.
Perhaps, this should be a part of struct dma_slave_config. This patch adds another field device_fc to this structure. User drivers must pass this as true if they want to be flow controller of certain transfers.
--- include/linux/dmaengine.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
include/linux/dmaengine.h +5 -0
@@ -25,6 +25,7 @@#include <linux/uio.h> #include <linux/scatterlist.h> #include <linux/bitmap.h> +#include <linux/types.h> #include <asm/page.h> /**
@@ -330,6 +331,9 @@ enum dma_slave_buswidth {* may or may not be applicable on memory sources. * @dst_maxburst: same as src_maxburst but for destination target * mutatis mutandis. +* @device_fc: Flow Controller Settings for ccfg register. Only valid for slave +* channels. Fill with 'true' if peripheral should be flow controller. Direction +* will be selected at Runtime. * * This struct is passed in as configuration data to a DMA engine * in order to set up a certain channel for DMA transport at runtime.
@@ -356,6 +360,7 @@ struct dma_slave_config {enum dma_slave_buswidth dst_addr_width;u32 src_maxburst;u32 dst_maxburst; +bool device_fc; };static inline const char *dma_chan_name (struct dma_chan *chan)
Signature · 1 line
1.7.8.110.g4cb5d
Re: [PATCH V2 02/12] dmaengine: Add flow controller information to dma_slave_config
Quoted 4 lines · Viresh Kumar
Flow controller is programmable for few controllers and there are few intelligent peripherals like, Synopsys JPEG controller, that needs to be a flow controller of DMA transfers on dest side.
Quoted 8 lines
For this, currently two drivers, pl08x and
dw_dmac, support flow controller to be passed from platform to these drivers.Perhaps, this should be a part of struct
dma_slave_config. This patch adds another fielddevice_fcto this structure. User drivers must pass this as true if they want to be flow controller of certain transfers.Signed-off-by Viresh Kumar <[email protected]>
Thanks Viresh,
Linus Walleij
Re: [PATCH V2 02/12] dmaengine: Add flow controller information to dma_slave_config
In reply to Viresh KumarQuoted 29 lines · Viresh Kumar
Flow controller is programmable for few controllers and there are few intelligent peripherals like, Synopsys JPEG controller, that needs to be a flow controller of DMA transfers on dest side.
For this, currently two drivers, pl08x and
dw_dmac, support flow controller to be passed from platform to these drivers.Perhaps, this should be a part of struct
dma_slave_config. This patch adds another fielddevice_fcto this structure. User drivers must pass this as true if they want to be flow controller of certain transfers.Signed-off-by Viresh Kumar <[email protected]>--- include/linux/dmaengine.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)include/linux/dmaengine.h +1
-0@@ -25,6 +25,7 @@#include <linux/uio.h> #include <linux/scatterlist.h> #include <linux/bitmap.h> +#include <linux/types.h> #include <asm/page.h> /**
include/linux/dmaengine.h enum dma_slave_buswidth { · line 334
Quoted 4 lines
include/linux/dmaengine.h +1
-0@@ -330,6 +331,9 @@ enum dma_slave_buswidth {* may or may not be applicable on memory sources. * @dst_maxburst: same as src_maxburst but for destination target * mutatis mutandis. +* @device_fc: Flow Controller Settings for ccfg register. Only valid for slave
ccfg maybe true for your controller, not others...
Quoted 13 lines
include/linux/dmaengine.h +3
-0+* channels. Fill with 'true' if peripheral should be flow controller. Direction +* will be selected at Runtime. * * This struct is passed in as configuration data to a DMA engine * in order to set up a certain channel for DMA transport at runtime. @@ -356,6 +360,7 @@ struct dma_slave_config {enum dma_slave_buswidth dst_addr_width;u32 src_maxburst;u32 dst_maxburst; +bool device_fc; };static inline const char *dma_chan_name (struct dma_chan *chan)
Signature · 1 line
~Vinod
PATCH v2 2/12 dmaengine: Add flow controller information to dma_slave_config
Quoted 3 lines · Vinod Koul
Quoted 1 line
Quoted 1 line
+ * @device_fc: Flow Controller Settings for ccfg register. Only valid for slave
ccfg maybe true for your controller, not others...
:(
Will fix the comment.
Signature · 1 line
viresh
PATCH v2 3/12 dmaengine: Pass dma_slave_config .device_fc = NULL for all existing users
In reply to Viresh Kumar.device_fc is added in struct dma_slave_config recently. All user drivers, which want DMA to be the flow controller must pass this field as false. As earlier driver don't look to use this feature, mark it false for now.
--- drivers/mmc/host/mmci.c | 2 ++ drivers/mmc/host/mxcmmc.c | 2 ++ drivers/spi/spi-dw-mid.c | 3 +++ drivers/spi/spi-pl022.c | 2 ++ drivers/tty/serial/amba-pl011.c | 3 +++ drivers/usb/musb/ux500_dma.c | 1 + sound/soc/imx/imx-pcm-dma-mx2.c | 3 +++ 7 files changed, 16 insertions(+), 0 deletions(-)
drivers/mmc/host/mmci.c +2 -0
@@ -30,6 +30,7 @@#include <linux/dma-mapping.h> #include <linux/amba/mmci.h> #include <linux/pm_runtime.h> +#include <linux/types.h> #include <asm/div64.h> #include <asm/io.h>
@@ -370,6 +371,7 @@ static int mmci_dma_prep_data(struct mmci_host *host, struct mmc_data *data, .dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, .src_maxburst = variant->fifohalfsize >> 2, /* # of words */ .dst_maxburst = variant->fifohalfsize >> 2, /* # of words */ + .device_fc = false, };struct dma_chan *chan;struct dma_device *device;
drivers/mmc/host/mxcmmc.c +2 -0
@@ -33,6 +33,7 @@#include <linux/gpio.h> #include <linux/regulator/consumer.h> #include <linux/dmaengine.h> +#include <linux/types.h> #include <asm/dma.h> #include <asm/irq.h>
@@ -710,6 +711,7 @@ static int mxcmci_setup_dma(struct mmc_host *mmc) config->src_addr_width =4 ; config->dst_maxburst = host->burstlen; config->src_maxburst = host->burstlen; + config->device_fc = false;return dmaengine_slave_config (host->dma, config); }
drivers/spi/spi-dw-mid.c +3 -0
@@ -22,6 +22,7 @@#include <linux/interrupt.h> #include <linux/slab.h> #include <linux/spi/spi.h> +#include <linux/types.h> #include "spi-dw.h"
@@ -136,6 +137,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change) txconf.dst_maxburst =LNW_DMA_MSIZE_16 ; txconf.src_addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ; txconf.dst_addr_width =DMA_SLAVE_BUSWIDTH_2_BYTES ; + txconf.device_fc = false; txchan->device->device_control (txchan,DMA_SLAVE_CONFIG , (unsigned long ) &txconf);
@@ -158,6 +160,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change) rxconf.src_maxburst =LNW_DMA_MSIZE_16 ; rxconf.dst_addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ; rxconf.src_addr_width =DMA_SLAVE_BUSWIDTH_2_BYTES ; + rxconf.device_fc = false; rxchan->device->device_control (rxchan,DMA_SLAVE_CONFIG , (unsigned long ) &rxconf);
drivers/spi/spi-pl022.c +2 -0
@@ -905,10 +905,12 @@ static int configure_dma(struct pl022 *pl022)struct dma_slave_config rx_conf = { .src_addr =SSP_DR (pl022->phybase), .direction =DMA_DEV_TO_MEM , + .device_fc = false, };struct dma_slave_config tx_conf = { .dst_addr =SSP_DR (pl022->phybase), .direction =DMA_MEM_TO_DEV , + .device_fc = false, };unsigned int pages;int ret;
drivers/tty/serial/amba-pl011.c +3 -0
@@ -51,6 +51,7 @@#include <linux/dma-mapping.h> #include <linux/scatterlist.h> #include <linux/delay.h> +#include <linux/types.h> #include <asm/io.h> #include <asm/sizes.h>
@@ -270,6 +271,7 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap) .dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE, .direction = DMA_MEM_TO_DEV, .dst_maxburst = uap->fifosize >> 1, + .device_fc = false, };struct dma_chan *chan;dma_cap_mask_t mask;
@@ -303,6 +305,7 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap) .src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE, .direction = DMA_DEV_TO_MEM, .src_maxburst = uap->fifosize >> 1, + .device_fc = false, }; chan =dma_request_channel (mask, plat->dma_filter, plat->dma_rx_param);
drivers/usb/musb/ux500_dma.c +1 -0
@@ -143,6 +143,7 @@ static bool ux500_configure_channel(struct dma_channel *channel, slave_conf.dst_addr = usb_fifo_addr; slave_conf.dst_addr_width = addr_width; slave_conf.dst_maxburst =16 ; + slave_conf.device_fc = false; dma_chan->device->device_control (dma_chan,DMA_SLAVE_CONFIG , (unsigned long ) &slave_conf);
sound/soc/imx/imx-pcm-dma-mx2.c +3 -0
@@ -21,6 +21,7 @@#include <linux/platform_device.h> #include <linux/slab.h> #include <linux/dmaengine.h> +#include <linux/types.h> #include <sound/core.h> #include <sound/initval.h>
@@ -106,6 +107,8 @@ static int imx_ssi_dma_alloc(struct snd_pcm_substream *substream,return 0 ; } + slave_config.device_fc = false; +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { slave_config.direction =DMA_MEM_TO_DEV ; slave_config.dst_addr = dma_params->dma_addr;
Signature · 1 line
1.7.8.110.g4cb5d
Re: [PATCH V2 03/12] dmaengine: Pass dma_slave_config .device_fc = NULL for all existing users
Quoted 5 lines · Viresh Kumar
.device_fc is added in struct
dma_slave_configrecently. All user drivers, which want DMA to be the flow controller must pass this field as false. As earlier driver don't look to use this feature, mark it false for now.Signed-off-by Viresh Kumar <[email protected]>
Thanks Viresh,
Linus Walleij
PATCH v2 4/12 dmaengine/amba-pl08x: Take flow controller info from DMA_SLAVE_CONFIG
In reply to Viresh KumarFlow controller information is passed now from DMA_SLAVE_CONFIG option. This patch makes changes in pl08x driver to use device_fc from it instead of platform data.
--- drivers/dma/amba-pl08x.c | 4 +++- include/linux/amba/pl08x.h | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-)
drivers/dma/amba-pl08x.c +3 -1
@@ -1139,6 +1139,8 @@ static int dma_set_runtime_config(struct dma_chan *chan, cctl |= burst <<PL080_CONTROL_SB_SIZE_SHIFT ; cctl |= burst <<PL080_CONTROL_DB_SIZE_SHIFT ; + plchan->device_fc = config->device_fc; +if (plchan->runtime_direction ==DMA_DEV_TO_MEM ) { plchan->src_addr = config->src_addr; plchan->src_cctl = pl08x_cctl(cctl) | PL080_CONTROL_DST_INCR |
@@ -1370,7 +1372,7 @@ static struct dma_async_tx_descriptor *pl08x_prep_slave_sg(return NULL ; } -if (plchan->cd->device_fc) +if (plchan->device_fc) tmp = (direction ==DMA_MEM_TO_DEV ) ?PL080_FLOW_MEM2PER_PER :PL080_FLOW_PER2MEM_PER ;else
include/linux/amba/pl08x.h +4 -4
@@ -47,9 +47,6 @@ enum {* @muxval: a number usually used to poke into some mux regiser to * mux in the signal to this channel * @cctl_opt: default options for the channel control register -* @device_fc: Flow Controller Settings for ccfg register. Only valid for slave -* channels. Fill with 'true' if peripheral should be flow controller. Direction -* will be selected at Runtime. * @addr: source/target address in physical memory for this DMA channel, * can be the address of a FIFO register for burst requests for example. * This can be left undefined if the PrimeCell API is used for configuring
@@ -68,7 +65,6 @@ struct pl08x_channel_data {int max_signal;u32 muxval;u32 cctl; -bool device_fc;dma_addr_t addr;bool circular_buffer;bool single;
@@ -183,6 +179,9 @@ enum pl08x_dma_chan_state {* @host: a pointer to the host (internal use) * @state: whether the channel is idle, paused, running etc * @slave: whether this channel is a device (slave) or for memcpy +* @device_fc: Flow Controller Settings for ccfg register. Only valid for slave +* channels. Fill with 'true' if peripheral should be flow controller. Direction +* will be selected at Runtime. * @waiting: a TX descriptor on this channel which is waiting for a physical * channel to become available */
@@ -205,6 +204,7 @@ struct pl08x_dma_chan {struct pl08x_driver_data *host;enum pl08x_dma_chan_state state;bool slave; +bool device_fc;struct pl08x_txd *waiting; };
Signature · 1 line
1.7.8.110.g4cb5d
Re: [PATCH V2 04/12] dmaengine/amba-pl08x: Take flow controller info from DMA_SLAVE_CONFIG
Quoted 5 lines · Viresh Kumar
Flow controller information is passed now from
DMA_SLAVE_CONFIGoption. This patch makes changes in pl08x driver to usedevice_fcfrom it instead of platform data.Signed-off-by Viresh Kumar <[email protected]>
Thanks Viresh,
Linus Walleij
PATCH v2 5/12 dmaengine/dw_dmac: Don't use magic number for total number of channels
In reply to Viresh KumarTotal number of channels is passed in pdata->nr_channels variable, thus we must not use magic number '7' for total number of channels.
--- drivers/dma/dw_dmac.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/dma/dw_dmac.c +1 -1
@@ -1432,7 +1432,7 @@ static int __init dw_probe(struct platform_device *pdev)/* 7 is highest priority & 0 is lowest. */ if (pdata->chan_priority ==CHAN_PRIORITY_ASCENDING ) - dwc->priority =7 - i; + dwc->priority = pdata->nr_channels - i -1 ;else dwc->priority = i;
Signature · 1 line
1.7.8.110.g4cb5d
PATCH v2 6/12 dmaengine/dw_dmac: Use dev_get_platdata() instead of accessing dev directly
In reply to Viresh KumarUse already defined function dev_get_platdata() instead of accessing pdev->dev.data.
--- drivers/dma/dw_dmac.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/dma/dw_dmac.c +1 -1
@@ -1369,7 +1369,7 @@ static int __init dw_probe(struct platform_device *pdev)int err;int i; - pdata = pdev->dev.platform_data; + pdata =dev_get_platdata (&pdev->dev);if (!pdata || pdata->nr_channels >DW_DMA_MAX_NR_CHANNELS )return -EINVAL ;
Signature · 1 line
1.7.8.110.g4cb5d
PATCH v2 7/12 dmaengine/dw_dmac: Don't handle block interrupts
In reply to Viresh KumarBlock interrupts give interrupt on completion of every LLI, which is actually too much interrupts. This is just not required for current functioning of dw_dmac.
So, just don't handle them at all.
--- drivers/dma/dw_dmac.c | 36 ++++++------------------------------ 1 files changed, 6 insertions(+), 30 deletions(-)
drivers/dma/dw_dmac.c +6 -30
@@ -192,7 +192,6 @@ static void dwc_initialize(struct dw_dma_chan *dwc)/* Enable interrupts */ channel_set_bit (dw,MASK .XFER, dwc->mask); -channel_set_bit (dw,MASK .BLOCK, dwc->mask);channel_set_bit (dw,MASK .ERROR, dwc->mask); dwc->initialized = true;
@@ -329,12 +328,6 @@ static void dwc_scan_descriptors(struct dw_dma *dw, struct dw_dma_chan *dwc)unsigned long flags;spin_lock_irqsave (&dwc->lock, flags); -/* -* Clear block interrupt flag before scanning so that we don't -* miss any, and read LLP before RAW_XFER to ensure it is -* valid if we decide to scan the list. -*/ -dma_writel (dw,CLEAR .BLOCK, dwc->mask); llp =channel_readl (dwc,LLP ); status_xfer =dma_readl (dw,RAW .XFER);
@@ -470,17 +463,16 @@ EXPORT_SYMBOL(dw_dma_get_dst_addr);/* called with dwc->lock held and all DMAC interrupts disabled */ static void dwc_handle_cyclic (struct dw_dma *dw,struct dw_dma_chan *dwc, -u32 status_block,u32 status_err,u32 status_xfer) +u32 status_err,u32 status_xfer) {unsigned long flags; -if (status_block & dwc->mask) { +if (dwc->mask) {void (*callback)(void *param);void *callback_param;dev_vdbg (chan2dev (&dwc->chan),"new cyclic period llp 0x%08x\n" ,channel_readl (dwc,LLP )); -dma_writel (dw,CLEAR .BLOCK, dwc->mask); callback = dwc->cdesc->period_callback; callback_param = dwc->cdesc->period_callback_param;
@@ -520,7 +512,6 @@ static void dwc_handle_cyclic(struct dw_dma *dw, struct dw_dma_chan *dwc,channel_writel (dwc,CTL_LO ,0 );channel_writel (dwc,CTL_HI ,0 ); -dma_writel (dw,CLEAR .BLOCK, dwc->mask);dma_writel (dw,CLEAR .ERROR, dwc->mask);dma_writel (dw,CLEAR .XFER, dwc->mask);
@@ -537,36 +528,29 @@ static void dw_dma_tasklet(unsigned long data) {struct dw_dma *dw = (struct dw_dma *)data;struct dw_dma_chan *dwc; -u32 status_block;u32 status_xfer;u32 status_err;int i; - status_block =dma_readl (dw,RAW .BLOCK); status_xfer =dma_readl (dw,RAW .XFER); status_err =dma_readl (dw,RAW .ERROR); -dev_vdbg (dw->dma.dev,"tasklet: status_block=%x status_err=%x\n" , - status_block, status_err); +dev_vdbg (dw->dma.dev,"tasklet: status_err=%x\n" , status_err);for (i =0 ; i < dw->dma.chancnt; i++) { dwc = &dw->chan[i];if (test_bit (DW_DMA_IS_CYCLIC , &dwc->flags)) -dwc_handle_cyclic (dw, dwc, status_block, status_err, - status_xfer); +dwc_handle_cyclic (dw, dwc, status_err, status_xfer);else if (status_err & (1 << i))dwc_handle_error (dw, dwc); -else if ((status_block | status_xfer) & (1 << i)) +else if (status_xfer & (1 << i))dwc_scan_descriptors (dw, dwc); }/* -* Re-enable interrupts. Block Complete interrupts are only -* enabled if the INT_EN bit in the descriptor is set. This -* will trigger a scan before the whole list is done. +* Re-enable interrupts. */ channel_set_bit (dw,MASK .XFER, dw->all_chan_mask); -channel_set_bit (dw,MASK .BLOCK, dw->all_chan_mask);channel_set_bit (dw,MASK .ERROR, dw->all_chan_mask); }
@@ -583,7 +567,6 @@ static irqreturn_t dw_dma_interrupt(int irq, void *dev_id)* softirq handler. */ channel_clear_bit (dw,MASK .XFER, dw->all_chan_mask); -channel_clear_bit (dw,MASK .BLOCK, dw->all_chan_mask);channel_clear_bit (dw,MASK .ERROR, dw->all_chan_mask); status =dma_readl (dw,STATUS_INT );
@@ -594,7 +577,6 @@ static irqreturn_t dw_dma_interrupt(int irq, void *dev_id)/* Try to recover */ channel_clear_bit (dw,MASK .XFER, (1 <<8 ) -1 ); -channel_clear_bit (dw,MASK .BLOCK, (1 <<8 ) -1 );channel_clear_bit (dw,MASK .SRC_TRAN, (1 <<8 ) -1 );channel_clear_bit (dw,MASK .DST_TRAN, (1 <<8 ) -1 );channel_clear_bit (dw,MASK .ERROR, (1 <<8 ) -1 );
@@ -1068,7 +1050,6 @@ static void dwc_free_chan_resources(struct dma_chan *chan)/* Disable interrupts */ channel_clear_bit (dw,MASK .XFER, dwc->mask); -channel_clear_bit (dw,MASK .BLOCK, dwc->mask);channel_clear_bit (dw,MASK .ERROR, dwc->mask);spin_unlock_irqrestore (&dwc->lock, flags);
@@ -1120,7 +1101,6 @@ int dw_dma_cyclic_start(struct dma_chan *chan)return -EBUSY ; } -dma_writel (dw,CLEAR .BLOCK, dwc->mask);dma_writel (dw,CLEAR .ERROR, dwc->mask);dma_writel (dw,CLEAR .XFER, dwc->mask);
@@ -1322,7 +1302,6 @@ void dw_dma_cyclic_free(struct dma_chan *chan)while (dma_readl (dw,CH_EN ) & dwc->mask)cpu_relax (); -dma_writel (dw,CLEAR .BLOCK, dwc->mask);dma_writel (dw,CLEAR .ERROR, dwc->mask);dma_writel (dw,CLEAR .XFER, dwc->mask);
@@ -1347,7 +1326,6 @@ static void dw_dma_off(struct dw_dma *dw)dma_writel (dw,CFG ,0 );channel_clear_bit (dw,MASK .XFER, dw->all_chan_mask); -channel_clear_bit (dw,MASK .BLOCK, dw->all_chan_mask);channel_clear_bit (dw,MASK .SRC_TRAN, dw->all_chan_mask);channel_clear_bit (dw,MASK .DST_TRAN, dw->all_chan_mask);channel_clear_bit (dw,MASK .ERROR, dw->all_chan_mask);
@@ -1449,13 +1427,11 @@ static int __init dw_probe(struct platform_device *pdev)/* Clear/disable all interrupts on all channels. */ dma_writel (dw,CLEAR .XFER, dw->all_chan_mask); -dma_writel (dw,CLEAR .BLOCK, dw->all_chan_mask);dma_writel (dw,CLEAR .SRC_TRAN, dw->all_chan_mask);dma_writel (dw,CLEAR .DST_TRAN, dw->all_chan_mask);dma_writel (dw,CLEAR .ERROR, dw->all_chan_mask);channel_clear_bit (dw,MASK .XFER, dw->all_chan_mask); -channel_clear_bit (dw,MASK .BLOCK, dw->all_chan_mask);channel_clear_bit (dw,MASK .SRC_TRAN, dw->all_chan_mask);channel_clear_bit (dw,MASK .DST_TRAN, dw->all_chan_mask);channel_clear_bit (dw,MASK .ERROR, dw->all_chan_mask);
Signature · 1 line
1.7.8.110.g4cb5d
PATCH v2 8/12 dmaengine/dw_dmac: Unmap all memory buffers after completion of slave transfers
In reply to Viresh KumarCurrently, after completion of transfer, source address or destination address of only the first LLI descriptor is unmapped. And length passed for unmap is total length of all descriptors in the list. Which means unmapping code assumed that the memory buffers pointed to by the descriptors will be physically contiguous, which might not be the case. It is possible for other drivers to pass sglist to slave_sg(), in which all buffers are scattered throughout the memory.
This patch intends to fix this wrong expectation of dw_dmac. Now, first desc will not contain total length of transfer. But individual descriptors will contain their individual lengths. Finally, we will call unmap for all descriptors.
--- drivers/dma/dw_dmac.c | 49 +++++++++++++++++++++++++++++++------------------ 1 files changed, 31 insertions(+), 18 deletions(-)
drivers/dma/dw_dmac.c +31 -18
@@ -231,6 +231,14 @@ static void dwc_dostart(struct dw_dma_chan *dwc, struct dw_desc *first)/*----------------------------------------------------------------------*/ +#define dw_dmac_unmap (utype, _desc, _child, _buf, _dir) \ +do { \ + list_for_each_entry(_child, &_desc->tx_list, desc_node) \ + dma_unmap_##utype(parent, _child->lli._buf, \ + _child->len, _dir); \ + dma_unmap_##utype(parent, _desc->lli._buf, _desc->len, _dir); \ +} while (0) +static void dwc_descriptor_complete (struct dw_dma_chan *dwc,struct dw_desc *desc,bool callback_required)
@@ -264,19 +272,19 @@ dwc_descriptor_complete(struct dw_dma_chan *dwc, struct dw_desc *desc,struct device *parent =chan2parent (&dwc->chan);if (!(txd->flags &DMA_COMPL_SKIP_DEST_UNMAP )) {if (txd->flags &DMA_COMPL_DEST_UNMAP_SINGLE ) -dma_unmap_single (parent, desc->lli.dar, - desc->len,DMA_FROM_DEVICE ); +dw_dmac_unmap (single, desc, child, dar, +DMA_FROM_DEVICE );else -dma_unmap_page (parent, desc->lli.dar, - desc->len,DMA_FROM_DEVICE ); +dw_dmac_unmap (page, desc, child, dar, +DMA_FROM_DEVICE ); }if (!(txd->flags &DMA_COMPL_SKIP_SRC_UNMAP )) {if (txd->flags &DMA_COMPL_SRC_UNMAP_SINGLE ) -dma_unmap_single (parent, desc->lli.sar, - desc->len,DMA_TO_DEVICE ); +dw_dmac_unmap (single, desc, child, sar, +DMA_TO_DEVICE );else -dma_unmap_page (parent, desc->lli.sar, - desc->len,DMA_TO_DEVICE ); +dw_dmac_unmap (page, desc, child, sar, +DMA_TO_DEVICE ); } }
@@ -676,6 +684,7 @@ dwc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src, desc->lli.dar = dest + offset; desc->lli.ctllo = ctllo; desc->lli.ctlhi = xfer_count; + desc->len = xfer_count << src_width;if (!first) { first = desc;
@@ -701,7 +710,6 @@ dwc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src, DMA_TO_DEVICE); first->txd.flags = flags; - first->len = len;return &first->txd;
@@ -725,7 +733,6 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,unsigned int mem_width;unsigned int i;struct scatterlist *sg; -size_t total_len =0 ;dev_vdbg (chan2dev (chan),"prep_dma_slave\n" );
@@ -774,6 +781,7 @@ slave_sg_todev_fill_desc: } desc->lli.ctlhi = dlen >> mem_width; + desc->len = dlen;if (!first) { first = desc;
@@ -787,7 +795,6 @@ slave_sg_todev_fill_desc: &first->tx_list); } prev = desc; - total_len += dlen;if (len) goto slave_sg_todev_fill_desc;
@@ -831,6 +838,7 @@ slave_sg_fromdev_fill_desc: len =0 ; } desc->lli.ctlhi = dlen >> reg_width; + desc->len = dlen;if (!first) { first = desc;
@@ -844,7 +852,6 @@ slave_sg_fromdev_fill_desc: &first->tx_list); } prev = desc; - total_len += dlen;if (len) goto slave_sg_fromdev_fill_desc;
@@ -863,8 +870,6 @@ slave_sg_fromdev_fill_desc: prev->txd.phys,sizeof (prev->lli), DMA_TO_DEVICE); - first->len = total_len; -return &first->txd; err_desc_get:
@@ -950,11 +955,19 @@ dwc_tx_status(struct dma_chan *chan, ret =dma_async_is_complete (cookie, last_complete, last_used); } -if (ret !=DMA_SUCCESS ) -dma_set_tx_state (txstate, last_complete, last_used, -dwc_first_active (dwc)->len); -else +if (ret !=DMA_SUCCESS ) { +struct dw_desc *desc, *child; +unsigned int len; + + desc =dwc_first_active (dwc); + len = desc->len; +list_for_each_entry (child, &desc->tx_list, desc_node) + len += child->len; + +dma_set_tx_state (txstate, last_complete, last_used, len); + }else {dma_set_tx_state (txstate, last_complete, last_used,0 ); + }if (dwc->paused)return DMA_PAUSED ;
Signature · 1 line
1.7.8.110.g4cb5d
Re: [PATCH V2 08/12] dmaengine/dw_dmac: Unmap all memory buffers after completion of slave transfers
Quoted 8 lines · Viresh Kumar
Currently, after completion of transfer, source address or destination address of only the first LLI descriptor is unmapped. And length passed for unmap is total length of all descriptors in the list. Which means unmapping code assumed that the memory buffers pointed to by the descriptors will be physically contiguous, which might not be the case. It is possible for other drivers to pass sglist to
slave_sg(), in which all buffers are scattered throughout the memory.
Quoted 4 lines
This patch intends to fix this wrong expectation of
dw_dmac. Now, first desc will not contain total length of transfer. But individual descriptors will contain their individual lengths. Finally, we will call unmap for all descriptors.
NAK. For reasons stated previously and subsequently ignored.
PATCH v2 8/12 dmaengine/dw_dmac: Unmap all memory buffers after completion of slave transfers
Quoted 4 lines · Russell King - ARM Linux
On Wed, Jan 18, 2012 at 02:41:55PM +0530, Viresh Kumar wrote:
NAK. For reasons stated previously and subsequently ignored. .
Quoted 5 lines · Russell King - ARM Linux
Quoted 4 lines
Quoted 4 lines
You implemented similar stuff in amba-pl08x :) .
if (!plchan->slave)
pl08x_unmap_buffers(txd);Take a look at that. "If *NOT* slave, unmap the buffers".
[Following is picked from current implementation of dw_dmac:]
if (!dwc->chan.private) {
struct device *parent = chan2parent(&dwc->chan);
if (!(txd->flags & DMA_COMPL_SKIP_DEST_UNMAP)) {Sorry, I missed the most straight forward looking code. :( Actually, dw_dmac is also doing the same, i.e. unmapping only for non-slave transfers.
The same patch is still applicable, after fixing message subject and log. I will resend it, with message log fixed, once i get more feedbacks on V2.
Signature · 1 line
viresh
PATCH v2 8/12 dmaengine/dw_dmac: Unmap all memory buffers after completion of slave transfers
Quoted 2 lines · Viresh Kumar
Actually,
dw_dmacis also doing the same, i.e. unmapping only for non-slave transfers.
Problem solved :-)
Yours,
Linus Walleij
PATCH v2 8/12 dmaengine/dw_dmac: Unmap all memory buffers after completion of slave transfers
In reply to Viresh KumarQuoted 19 lines · Viresh Kumar
Quoted 4 lines · Russell King - ARM Linux
On Wed, Jan 18, 2012 at 02:41:55PM +0530, Viresh Kumar wrote:
NAK. For reasons stated previously and subsequently ignored. .Quoted 5 lines · Russell King - ARM Linux
Quoted 4 lines
Quoted 4 lines
You implemented similar stuff in amba-pl08x :) .
if (!plchan->slave)
pl08x_unmap_buffers(txd);Take a look at that. "If *NOT* slave, unmap the buffers".
[Following is picked from current implementation of
dw_dmac:]if (!dwc->chan.private) { struct device *parent = chan2parent(&dwc->chan); if (!(txd->flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
Quoted 7 lines
Sorry, I missed the most straight forward looking code. :( Actually,
dw_dmacis also doing the same, i.e. unmapping only for non-slave transfers.The same patch is still applicable, after fixing message subject and log. I will resend it, with message log fixed, once i get more feedbacks on V2.
But this patch seems to unmap for *all* descriptors, so you need to fix that as well, apart from the ones stated above.
Signature · 1 line
~Vinod
PATCH v2 8/12 dmaengine/dw_dmac: Unmap all memory buffers after completion of slave transfers
Quoted 8 lines · Vinod Koul
Quoted 8 lines
Quoted 8 lines
if (!dwc->chan.private) { struct device *parent = chan2parent(&dwc->chan); if (!(txd->flags & DMA_COMPL_SKIP_DEST_UNMAP)) {Sorry, I missed the most straight forward looking code. :( Actually,
dw_dmacis also doing the same, i.e. unmapping only for non-slave transfers.
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
The same patch is still applicable, after fixing message subject and log. I will resend it, with message log fixed, once i get more feedbacks on V2.
But this patch seems to unmap for *all* descriptors, so you need to fix that as well, apart from the ones stated above.
What do you mean by *all* here? All type of transfers ? If that's the question, then the answer is NO.
I am unmapping all descriptors of current transfer only for non-slave transfers.
Signature · 1 line
viresh
PATCH v2 8/12 dmaengine/dw_dmac: Unmap all memory buffers after completion of slave transfers
Quoted 12 lines · Viresh Kumar
Quoted 11 lines · Vinod Koul
Quoted 11 lines
Quoted 11 lines
if (!dwc->chan.private) { struct device *parent = chan2parent(&dwc->chan); if (!(txd->flags & DMA_COMPL_SKIP_DEST_UNMAP)) {Sorry, I missed the most straight forward looking code. :( Actually,
dw_dmacis also doing the same, i.e. unmapping only for non-slave transfers.The same patch is still applicable, after fixing message subject and log. I will resend it, with message log fixed, once i get more feedbacks on V2.
Quoted 7 lines
Quoted 2 lines
But this patch seems to unmap for *all* descriptors, so you need to fix that as well, apart from the ones stated above.
What do you mean by *all* here? All type of transfers ? If that's the question, then the answer is NO.
I am unmapping all descriptors of current transfer only for non-slave transfers.
Yes missed that
Btw, can you also fix the driver not to use chan->private?
Signature · 1 line
~Vinod
PATCH v2 8/12 dmaengine/dw_dmac: Unmap all memory buffers after completion of slave transfers
Quoted 1 line · Vinod Koul
Btw, can you also fix the driver not to use
chan->private?
Ya sure, but i am not in sync with the issue. :(
Why do we need to remove code dependency on chan->private, something dmaengine specific has changed?
Signature · 1 line
viresh
PATCH v2 8/12 dmaengine/dw_dmac: Unmap all memory buffers after completion of slave transfers
Quoted 7 lines · Viresh Kumar
Quoted 1 line · Vinod Koul
Btw, can you also fix the driver not to use
chan->private?Ya sure, but i am not in sync with the issue. :(
Why do we need to remove code dependency onchan->private, something dmaengine specific has changed?
its deprecated :)
You should be using dma_slave_config instead to pass the required parameters
Signature · 1 line
~Vinod
PATCH v2 8/12 dmaengine/dw_dmac: Unmap all memory buffers after completion of slave transfers
Quoted 3 lines · Vinod Koul
its deprecated :)
You should be usingdma_slave_configinstead to pass the required parameters
Aah, i knew it. Silly question.
I have this in my todo list, will do it as soon as i get some spare time.
Signature · 1 line
viresh
PATCH v2 9/12 dmaengine/dw_dmac: Add 64 bit access width support for slave xfers on mem side
In reply to Viresh Kumar64 bit transfers are possible on both sides in slave transfers (memory as well as peripherals). This patch adds support for it memory side 64 bit transfers.
--- drivers/dma/dw_dmac.c | 20 ++++++++++++++++---- 1 files changed, 16 insertions(+), 4 deletions(-)
drivers/dma/dw_dmac.c +16 -4
@@ -756,8 +756,14 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, mem =sg_phys (sg); len =sg_dma_len (sg); - mem_width =2 ; -if (unlikely (mem &3 || len &3 )) + +if (!((mem | len) &7 )) + mem_width =3 ; +else if (!((mem | len) &3 )) + mem_width =2 ; +else if (!((mem | len) &1 )) + mem_width =1 ; +else mem_width =0 ; slave_sg_todev_fill_desc:
@@ -814,8 +820,14 @@ slave_sg_todev_fill_desc: mem =sg_phys (sg); len =sg_dma_len (sg); - mem_width =2 ; -if (unlikely (mem &3 || len &3 )) + +if (!((mem | len) &7 )) + mem_width =3 ; +else if (!((mem | len) &3 )) + mem_width =2 ; +else if (!((mem | len) &1 )) + mem_width =1 ; +else mem_width =0 ; slave_sg_fromdev_fill_desc:
Signature · 1 line
1.7.8.110.g4cb5d
PATCH v2 10/12 dmaengine/dw_dmac: Add support for DMA_SLAVE_CONFIG
In reply to Viresh KumarThis patch adds support for DMA_SLAVE_CONFIG in dwc DMAC controller. Fields in struct dw_dma_slave for passing similar data are preserved in this patch untill all existing users are fixed.
That will be handled later in this patchset.
--- drivers/dma/dw_dmac.c | 119 +++++++++++++++++++++++++++++++++----------- drivers/dma/dw_dmac_regs.h | 3 + 2 files changed, 93 insertions(+), 29 deletions(-)
drivers/dma/dw_dmac.c +90 -29
@@ -9,6 +9,7 @@* it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ +#include <linux/bitops.h> #include <linux/clk.h> #include <linux/delay.h> #include <linux/dmaengine.h>
@@ -33,19 +34,23 @@* which does not support descriptor writeback. */ -#define DWC_DEFAULT_CTLLO (private) ({ \ - struct dw_dma_slave *__slave = (private); \ - int dms = __slave ? __slave->dst_master : 0; \ - int sms = __slave ? __slave->src_master : 1; \ - u8 smsize = __slave ? __slave->src_msize : DW_DMA_MSIZE_16; \ - u8 dmsize = __slave ? __slave->dst_msize : DW_DMA_MSIZE_16; \ +#define DWC_DEFAULT_CTLLO (_chan) ({ \ + struct dw_dma_slave *__slave = (_chan->private); \ + struct dw_dma_chan *_dwc = to_dw_dma_chan(_chan); \ + struct dma_slave_config *_sconfig = &_dwc->dma_sconfig; \ + int _dms = __slave ? __slave->dst_master : 0; \ + int _sms = __slave ? __slave->src_master : 1; \ + u8 _smsize = __slave ? _sconfig->src_maxburst : \ + DW_DMA_MSIZE_16; \ + u8 _dmsize = __slave ? _sconfig->dst_maxburst : \ + DW_DMA_MSIZE_16; \ \ - (DWC_CTLL_DST_MSIZE(dmsize) \ - | DWC_CTLL_SRC_MSIZE(smsize) \ + (DWC_CTLL_DST_MSIZE(_dmsize) \ + | DWC_CTLL_SRC_MSIZE(_smsize) \ | DWC_CTLL_LLP_D_EN \ | DWC_CTLL_LLP_S_EN \ - | DWC_CTLL_DMS(dms) \ - | DWC_CTLL_SMS(sms)); \ + | DWC_CTLL_DMS(_dms) \ + | DWC_CTLL_SMS(_sms)); \ })/*
@@ -664,7 +669,7 @@ dwc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,else src_width = dst_width =0 ; - ctllo =DWC_DEFAULT_CTLLO (chan->private) + ctllo =DWC_DEFAULT_CTLLO (chan) |DWC_CTLL_DST_WIDTH (dst_width) |DWC_CTLL_SRC_WIDTH (src_width) |DWC_CTLL_DST_INC
@@ -725,6 +730,7 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, {struct dw_dma_chan *dwc =to_dw_dma_chan (chan);struct dw_dma_slave *dws = chan->private; +struct dma_slave_config *sconfig = &dwc->dma_sconfig;struct dw_desc *prev;struct dw_desc *first;u32 ctllo;
@@ -739,17 +745,20 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,if (unlikely (!dws || !sg_len))return NULL ; - reg_width = dws->reg_width; prev = first =NULL ;switch (direction) {case DMA_MEM_TO_DEV : - ctllo = (DWC_DEFAULT_CTLLO (chan->private) + reg_width =__fls (sconfig->dst_addr_width); + reg = sconfig->dst_addr; + ctllo = (DWC_DEFAULT_CTLLO (chan) |DWC_CTLL_DST_WIDTH (reg_width) |DWC_CTLL_DST_FIX - |DWC_CTLL_SRC_INC - |DWC_CTLL_FC (dws->fc)); - reg = dws->tx_reg; + |DWC_CTLL_SRC_INC ); + + ctllo |= sconfig->device_fc ?DWC_CTLL_FC (DW_DMA_FC_P_M2P ) : +DWC_CTLL_FC (DW_DMA_FC_D_M2P ); +for_each_sg (sgl, sg, sg_len, i) {struct dw_desc *desc;u32 len, dlen, mem;
@@ -807,13 +816,16 @@ slave_sg_todev_fill_desc: }break ;case DMA_DEV_TO_MEM : - ctllo = (DWC_DEFAULT_CTLLO (chan->private) + reg_width =__fls (sconfig->src_addr_width); + reg = sconfig->src_addr; + ctllo = (DWC_DEFAULT_CTLLO (chan) |DWC_CTLL_SRC_WIDTH (reg_width) |DWC_CTLL_DST_INC - |DWC_CTLL_SRC_FIX - |DWC_CTLL_FC (dws->fc)); + |DWC_CTLL_SRC_FIX ); + + ctllo |= sconfig->device_fc ?DWC_CTLL_FC (DW_DMA_FC_P_P2M ) : +DWC_CTLL_FC (DW_DMA_FC_D_P2M ); - reg = dws->rx_reg;for_each_sg (sgl, sg, sg_len, i) {struct dw_desc *desc;u32 len, dlen, mem;
@@ -889,6 +901,39 @@ err_desc_get:return NULL ; } +/* +* Fix sconfig's burst size according to dw_dmac. We need to convert them as: +* 1 -> 0, 4 -> 1, 8 -> 2, 16 -> 3. +* +* NOTE: burst size 2 is not supported by controller. +* +* This can be done by finding least significant bit set: n & (n - 1) +*/ +static inline void convert_burst (u32 *maxburst) +{ +if (*maxburst >1 ) + *maxburst =fls (*maxburst) -2 ; +else + *maxburst =0 ; +} + +static int +set_runtime_config (struct dma_chan *chan,struct dma_slave_config *sconfig) +{ +struct dw_dma_chan *dwc =to_dw_dma_chan (chan); + +/* Check if it is chan is configured for slave transfers */ +if (!chan->private) +return -EINVAL ; + +memcpy (&dwc->dma_sconfig, sconfig,sizeof (*sconfig)); + +convert_burst (&dwc->dma_sconfig.src_maxburst); +convert_burst (&dwc->dma_sconfig.dst_maxburst); + +return 0 ; +} +static int dwc_control (struct dma_chan *chan,enum dma_ctrl_cmd cmd,unsigned long arg) {
@@ -938,8 +983,11 @@ static int dwc_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,/* Flush all pending and queued descriptors */ list_for_each_entry_safe (desc, _desc, &list, desc_node)dwc_descriptor_complete (dwc, desc, false); - }else + }else if (cmd ==DMA_SLAVE_CONFIG ) { +return set_runtime_config (chan, (struct dma_slave_config *)arg); + }else {return -ENXIO ; + }return 0 ; }
@@ -1180,11 +1228,11 @@ struct dw_cyclic_desc *dw_dma_cyclic_prep(struct dma_chan *chan, enum dma_transfer_direction direction) {struct dw_dma_chan *dwc =to_dw_dma_chan (chan); +struct dma_slave_config *sconfig = &dwc->dma_sconfig;struct dw_cyclic_desc *cdesc;struct dw_cyclic_desc *retval =NULL ;struct dw_desc *desc;struct dw_desc *last =NULL ; -struct dw_dma_slave *dws = chan->private;unsigned long was_cyclic;unsigned int reg_width;unsigned int periods;
@@ -1208,7 +1256,12 @@ struct dw_cyclic_desc *dw_dma_cyclic_prep(struct dma_chan *chan, } retval =ERR_PTR (-EINVAL ); - reg_width = dws->reg_width; + +if (direction ==DMA_MEM_TO_DEV ) + reg_width =__ffs (sconfig->dst_addr_width); +else + reg_width =__ffs (sconfig->src_addr_width); + periods = buf_len / period_len;/* Check for too big/unaligned periods and unaligned DMA buffer. */
@@ -1241,26 +1294,34 @@ struct dw_cyclic_desc *dw_dma_cyclic_prep(struct dma_chan *chan,switch (direction) {case DMA_MEM_TO_DEV : - desc->lli.dar = dws->tx_reg; + desc->lli.dar = sconfig->dst_addr; desc->lli.sar = buf_addr + (period_len * i); - desc->lli.ctllo = (DWC_DEFAULT_CTLLO (chan->private) + desc->lli.ctllo = (DWC_DEFAULT_CTLLO (chan) |DWC_CTLL_DST_WIDTH (reg_width) |DWC_CTLL_SRC_WIDTH (reg_width) |DWC_CTLL_DST_FIX |DWC_CTLL_SRC_INC - |DWC_CTLL_FC (dws->fc) |DWC_CTLL_INT_EN ); + + desc->lli.ctllo |= sconfig->device_fc ? +DWC_CTLL_FC (DW_DMA_FC_P_M2P ) : +DWC_CTLL_FC (DW_DMA_FC_D_M2P ); +break ;case DMA_DEV_TO_MEM : desc->lli.dar = buf_addr + (period_len * i); - desc->lli.sar = dws->rx_reg; - desc->lli.ctllo = (DWC_DEFAULT_CTLLO (chan->private) + desc->lli.sar = sconfig->src_addr; + desc->lli.ctllo = (DWC_DEFAULT_CTLLO (chan) |DWC_CTLL_SRC_WIDTH (reg_width) |DWC_CTLL_DST_WIDTH (reg_width) |DWC_CTLL_DST_INC |DWC_CTLL_SRC_FIX - |DWC_CTLL_FC (dws->fc) |DWC_CTLL_INT_EN ); + + desc->lli.ctllo |= sconfig->device_fc ? +DWC_CTLL_FC (DW_DMA_FC_P_P2M ) : +DWC_CTLL_FC (DW_DMA_FC_D_P2M ); +break ;default :break ;
drivers/dma/dw_dmac_regs.h +3 -0
@@ -153,6 +153,9 @@ struct dw_dma_chan {struct dw_cyclic_desc *cdesc;unsigned int descs_allocated; + +/* configuration passed via DMA_SLAVE_CONFIG */ +struct dma_slave_config dma_sconfig; }; static inline struct dw_dma_chan_regs __iomem *
Signature · 1 line
1.7.8.110.g4cb5d
PATCH v2 11/12 dmaengine/dw_dmac: Fix dw_dmac user drivers to adapt to slave_config changes
In reply to Viresh KumarThere are few existing user drivers of dw_dmac. They will break as soon as we remove unused fields from struct dw_dma_slave. This patch focuses to fix these user drivers to use dma_slave_config() routine.
--- arch/avr32/mach-at32ap/at32ap700x.c | 13 ------- arch/avr32/mach-at32ap/include/mach/atmel-mci.h | 7 ---- drivers/mmc/host/atmel-mci.c | 24 +++++++++---- sound/atmel/abdac.c | 18 ++++++++-- sound/atmel/ac97c.c | 41 ++++++++++++++++++---- 5 files changed, 63 insertions(+), 40 deletions(-)
arch/avr32/mach-at32ap/at32ap700x.c +0 -13
@@ -1353,7 +1353,6 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data) goto fail; slave->sdata.dma_dev = &dw_dmac0_device.dev; - slave->sdata.reg_width =DW_DMA_SLAVE_WIDTH_32BIT ; slave->sdata.cfg_hi = (DWC_CFGH_SRC_PER (0 ) |DWC_CFGH_DST_PER (1 )); slave->sdata.cfg_lo &= ~(DWC_CFGL_HS_DST_POL
@@ -2048,27 +2047,19 @@ at32_add_device_ac97c(unsigned int id, struct ac97c_platform_data *data,/* Check if DMA slave interface for capture should be configured. */ if (flags &AC97C_CAPTURE ) { rx_dws->dma_dev = &dw_dmac0_device.dev; - rx_dws->reg_width =DW_DMA_SLAVE_WIDTH_16BIT ; rx_dws->cfg_hi =DWC_CFGH_SRC_PER (3 ); rx_dws->cfg_lo &= ~(DWC_CFGL_HS_DST_POL |DWC_CFGL_HS_SRC_POL ); rx_dws->src_master =0 ; rx_dws->dst_master =1 ; - rx_dws->src_msize =DW_DMA_MSIZE_1 ; - rx_dws->dst_msize =DW_DMA_MSIZE_1 ; - rx_dws->fc =DW_DMA_FC_D_P2M ; }/* Check if DMA slave interface for playback should be configured. */ if (flags &AC97C_PLAYBACK ) { tx_dws->dma_dev = &dw_dmac0_device.dev; - tx_dws->reg_width =DW_DMA_SLAVE_WIDTH_16BIT ; tx_dws->cfg_hi =DWC_CFGH_DST_PER (4 ); tx_dws->cfg_lo &= ~(DWC_CFGL_HS_DST_POL |DWC_CFGL_HS_SRC_POL ); tx_dws->src_master =0 ; tx_dws->dst_master =1 ; - tx_dws->src_msize =DW_DMA_MSIZE_1 ; - tx_dws->dst_msize =DW_DMA_MSIZE_1 ; - tx_dws->fc =DW_DMA_FC_D_M2P ; } if (platform_device_add_data(pdev, data,
@@ -2138,14 +2129,10 @@ at32_add_device_abdac(unsigned int id, struct atmel_abdac_pdata *data) dws = &data->dws; dws->dma_dev = &dw_dmac0_device.dev; - dws->reg_width =DW_DMA_SLAVE_WIDTH_32BIT ; dws->cfg_hi =DWC_CFGH_DST_PER (2 ); dws->cfg_lo &= ~(DWC_CFGL_HS_DST_POL |DWC_CFGL_HS_SRC_POL ); dws->src_master =0 ; dws->dst_master =1 ; - dws->src_msize =DW_DMA_MSIZE_1 ; - dws->dst_msize =DW_DMA_MSIZE_1 ; - dws->fc =DW_DMA_FC_D_M2P ;if (platform_device_add_data (pdev, data,sizeof (struct atmel_abdac_pdata )))
arch/avr32/mach-at32ap/include/mach/atmel-mci.h +0 -7
@@ -14,11 +14,4 @@ struct mci_dma_data {#define slave_data_ptr (s) (&(s)->sdata)#define find_slave_dev (s) ((s)->sdata.dma_dev) -#define setup_dma_addr (s, t, r) do { \ - if (s) { \ - (s)->sdata.tx_reg = (t); \ - (s)->sdata.rx_reg = (r); \ - } \ -} while (0) -#endif /* __MACH_ATMEL_MCI_H */
drivers/mmc/host/atmel-mci.c +16 -8
@@ -24,6 +24,7 @@#include <linux/seq_file.h> #include <linux/slab.h> #include <linux/stat.h> +#include <linux/types.h> #include <linux/mmc/host.h> #include <linux/mmc/sdio.h>
@@ -173,6 +174,7 @@ struct atmel_mci {struct atmel_mci_dma dma;struct dma_chan *data_chan; +struct dma_slave_config dma_conf;u32 cmd_status;u32 data_status;
@@ -863,15 +865,16 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)if (data->flags &MMC_DATA_READ ) { direction =DMA_FROM_DEVICE ; - slave_dirn =DMA_DEV_TO_MEM ; + host->dma_conf.direction = slave_dirn =DMA_DEV_TO_MEM ; }else { direction =DMA_TO_DEVICE ; - slave_dirn =DMA_MEM_TO_DEV ; + host->dma_conf.direction = slave_dirn =DMA_MEM_TO_DEV ; } sglen =dma_map_sg (chan->device->dev, data->sg, data->sg_len, direction); +dmaengine_slave_config (chan, &host->dma_conf); desc = chan->device->device_prep_slave_sg (chan, data->sg, sglen, slave_dirn,DMA_PREP_INTERRUPT |DMA_CTRL_ACK );
@@ -1957,22 +1960,27 @@ static void atmci_configure_dma(struct atmel_mci *host)if (pdata &&find_slave_dev (pdata->dma_slave)) {dma_cap_mask_t mask; -setup_dma_addr (pdata->dma_slave, - host->mapbase +ATMCI_TDR , - host->mapbase +ATMCI_RDR ); -/* Try to grab a DMA channel */ dma_cap_zero (mask);dma_cap_set (DMA_SLAVE , mask); host->dma.chan =dma_request_channel (mask, atmci_filter, pdata->dma_slave); } -if (!host->dma.chan) +if (!host->dma.chan) {dev_notice (&host->pdev->dev,"DMA not available, using PIO\n" ); -else + }else {dev_info (&host->pdev->dev,"Using %s for DMA transfers\n" ,dma_chan_name (host->dma.chan)); + + host->dma_conf.src_addr = host->mapbase +ATMCI_RDR ; + host->dma_conf.src_addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ; + host->dma_conf.src_maxburst =1 ; + host->dma_conf.dst_addr = host->mapbase +ATMCI_TDR ; + host->dma_conf.dst_addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ; + host->dma_conf.dst_maxburst =1 ; + host->dma_conf.device_fc = false; + } }static inline unsigned int atmci_get_version (struct atmel_mci *host)
sound/atmel/abdac.c +14 -4
@@ -16,6 +16,7 @@#include <linux/interrupt.h> #include <linux/module.h> #include <linux/platform_device.h> +#include <linux/types.h> #include <linux/io.h> #include <sound/core.h>
@@ -467,15 +468,24 @@ static int __devinit atmel_abdac_probe(struct platform_device *pdev)snd_card_set_dev (card, &pdev->dev);if (pdata->dws.dma_dev) { -struct dw_dma_slave *dws = &pdata->dws;dma_cap_mask_t mask; - dws->tx_reg = regs->start +DAC_DATA ; -dma_cap_zero (mask);dma_cap_set (DMA_SLAVE , mask); - dac->dma.chan =dma_request_channel (mask, filter, dws); + dac->dma.chan =dma_request_channel (mask, filter, &pdata->dws); +if (dac->dma.chan) { +struct dma_slave_config dma_conf = { + .dst_addr = regs->start +DAC_DATA , + .dst_addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES , + .src_maxburst =1 , + .dst_maxburst =1 , + .direction =DMA_MEM_TO_DEV , + .device_fc = false, + }; + +dmaengine_slave_config (dac->dma.chan, &dma_conf); + } }if (!pdata->dws.dma_dev || !dac->dma.chan) {dev_dbg (&pdev->dev,"DMA not available\n" );
sound/atmel/ac97c.c +33 -8
71 lines not on this page · raw message
Signature · 1 line
1.7.8.110.g4cb5d
PATCH v2 12/12 dmaengine/dw_dmac: Remove unused fields in struct dw_dma_slave
In reply to Viresh Kumar--- drivers/dma/dw_dmac_regs.h | 12 ++++++++++++ include/linux/dw_dmac.h | 38 -------------------------------------- 2 files changed, 12 insertions(+), 38 deletions(-)
drivers/dma/dw_dmac_regs.h +12 -0
@@ -13,6 +13,18 @@#define DW_DMA_MAX_NR_CHANNELS 8 +/* flow controller */ +enum dw_dma_fc { +DW_DMA_FC_D_M2M , +DW_DMA_FC_D_M2P , +DW_DMA_FC_D_P2M , +DW_DMA_FC_D_P2P , +DW_DMA_FC_P_P2M , +DW_DMA_FC_SP_P2P , +DW_DMA_FC_P_M2P , +DW_DMA_FC_DP_P2P , +}; +/* * Redefine this macro to handle differences between 32- and 64-bit * addressing, big vs. little endian, etc.
include/linux/dw_dmac.h +0 -38
@@ -31,18 +31,6 @@ struct dw_dma_platform_data {unsigned char chan_priority; }; -/** -* enum dw_dma_slave_width - DMA slave register access width. -* @DMA_SLAVE_WIDTH_8BIT: Do 8-bit slave register accesses -* @DMA_SLAVE_WIDTH_16BIT: Do 16-bit slave register accesses -* @DMA_SLAVE_WIDTH_32BIT: Do 32-bit slave register accesses -*/ -enum dw_dma_slave_width { -DW_DMA_SLAVE_WIDTH_8BIT , -DW_DMA_SLAVE_WIDTH_16BIT , -DW_DMA_SLAVE_WIDTH_32BIT , -}; -/* bursts size */ enum dw_dma_msize {DW_DMA_MSIZE_1 ,
@@ -55,47 +43,21 @@ enum dw_dma_msize { DW_DMA_MSIZE_256, }; -/* flow controller */ -enum dw_dma_fc { -DW_DMA_FC_D_M2M , -DW_DMA_FC_D_M2P , -DW_DMA_FC_D_P2M , -DW_DMA_FC_D_P2P , -DW_DMA_FC_P_P2M , -DW_DMA_FC_SP_P2P , -DW_DMA_FC_P_M2P , -DW_DMA_FC_DP_P2P , -}; -/** * struct dw_dma_slave - Controller-specific information about a slave * * @dma_dev: required DMA master device -* @tx_reg: physical address of data register used for -* memory-to-peripheral transfers -* @rx_reg: physical address of data register used for -* peripheral-to-memory transfers -* @reg_width: peripheral register width * @cfg_hi: Platform-specific initializer for the CFG_HI register * @cfg_lo: Platform-specific initializer for the CFG_LO register * @src_master: src master for transfers on allocated channel. * @dst_master: dest master for transfers on allocated channel. -* @src_msize: src burst size. -* @dst_msize: dest burst size. -* @fc: flow controller for DMA transfer */ struct dw_dma_slave {struct device *dma_dev; -dma_addr_t tx_reg; -dma_addr_t rx_reg; -enum dw_dma_slave_width reg_width;u32 cfg_hi;u32 cfg_lo;u8 src_master;u8 dst_master; -u8 src_msize; -u8 dst_msize; -u8 fc; };/* Platform-configurable bits in CFG_HI */
Signature · 1 line
1.7.8.110.g4cb5d