All of lore.kernel.org
 help / color / mirror / Atom feed
From: stillcompiling@gmail.com (Joshua Clayton)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 02/10] dma: imx-sdma: pass sdma engine into functions
Date: Mon, 15 Jun 2015 09:18:57 -0700	[thread overview]
Message-ID: <1434385144-4432-3-git-send-email-stillcompiling@gmail.com> (raw)
In-Reply-To: <1434385144-4432-1-git-send-email-stillcompiling@gmail.com>

Some ostensibly dma channel centric functions do their work
either exclusively or primarily on the sdma engine struct.
Change these functions to pass a struct sdma_engine and integer channel

Signed-off-by: Joshua Clayton <stillcompiling@gmail.com>
---
 drivers/dma/imx-sdma.c | 65 +++++++++++++++++++++++---------------------------
 1 file changed, 30 insertions(+), 35 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 0671d6d..c255664 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -467,11 +467,9 @@ static inline u32 chnenbl_ofs(struct sdma_engine *sdma, unsigned int event)
 	return chnenbl0 + event * 4;
 }
 
-static int sdma_config_ownership(struct sdma_channel *sdmac,
+static int sdma_config_ownership(struct sdma_engine *sdma, int channel,
 		bool event_override, bool mcu_override, bool dsp_override)
 {
-	struct sdma_engine *sdma = sdmac->sdma;
-	int channel = sdmac->channel;
 	unsigned long evt, mcu, dsp;
 
 	if (event_override && mcu_override && dsp_override)
@@ -569,10 +567,9 @@ static int sdma_load_script(struct sdma_engine *sdma, void *buf, int size,
 	return ret;
 }
 
-static void sdma_event_enable(struct sdma_channel *sdmac, unsigned int event)
+static void sdma_event_enable(struct sdma_engine *sdma, int channel,
+			unsigned int event)
 {
-	struct sdma_engine *sdma = sdmac->sdma;
-	int channel = sdmac->channel;
 	unsigned long val;
 	u32 chnenbl = chnenbl_ofs(sdma, event);
 
@@ -581,10 +578,9 @@ static void sdma_event_enable(struct sdma_channel *sdmac, unsigned int event)
 	writel_relaxed(val, sdma->regs + chnenbl);
 }
 
-static void sdma_event_disable(struct sdma_channel *sdmac, unsigned int event)
+static void sdma_event_disable(struct sdma_engine *sdma, int channel,
+		unsigned int event)
 {
-	struct sdma_engine *sdma = sdmac->sdma;
-	int channel = sdmac->channel;
 	u32 chnenbl = chnenbl_ofs(sdma, event);
 	unsigned long val;
 
@@ -830,20 +826,19 @@ static int sdma_load_context(struct sdma_channel *sdmac)
 	return ret;
 }
 
-static void sdma_disable_channel(struct sdma_channel *sdmac)
+static void sdma_disable_channel(struct sdma_engine *sdma, int channel)
 {
-	struct sdma_engine *sdma = sdmac->sdma;
-	int channel = sdmac->channel;
-
 	writel_relaxed(BIT(channel), sdma->regs + SDMA_H_STATSTOP);
-	sdmac->status = DMA_ERROR;
+	sdma->channel[channel].status = DMA_ERROR;
 }
 
 static int sdma_config_channel(struct sdma_channel *sdmac)
 {
 	int ret;
+	int channel = sdmac->channel;
+	struct sdma_engine *sdma = sdmac->sdma;
 
-	sdma_disable_channel(sdmac);
+	sdma_disable_channel(sdma, channel);
 
 	sdmac->event_mask[0] = 0;
 	sdmac->event_mask[1] = 0;
@@ -851,20 +846,20 @@ static int sdma_config_channel(struct sdma_channel *sdmac)
 	sdmac->per_addr = 0;
 
 	if (sdmac->event_id0) {
-		if (sdmac->event_id0 >= sdmac->sdma->drvdata->num_events)
+		if (sdmac->event_id0 >= sdma->drvdata->num_events)
 			return -EINVAL;
-		sdma_event_enable(sdmac, sdmac->event_id0);
+		sdma_event_enable(sdma, channel, sdmac->event_id0);
 	}
 
 	switch (sdmac->peripheral_type) {
 	case IMX_DMATYPE_DSP:
-		sdma_config_ownership(sdmac, false, true, true);
+		sdma_config_ownership(sdma, channel, false, true, true);
 		break;
 	case IMX_DMATYPE_MEMORY:
-		sdma_config_ownership(sdmac, false, true, false);
+		sdma_config_ownership(sdma, channel, false, true, false);
 		break;
 	default:
-		sdma_config_ownership(sdmac, true, true, false);
+		sdma_config_ownership(sdma, channel, true, true, false);
 		break;
 	}
 
@@ -896,12 +891,9 @@ static int sdma_config_channel(struct sdma_channel *sdmac)
 	return ret;
 }
 
-static int sdma_set_channel_priority(struct sdma_channel *sdmac,
+static int sdma_set_channel_priority(struct sdma_engine *sdma, int channel,
 		unsigned int priority)
 {
-	struct sdma_engine *sdma = sdmac->sdma;
-	int channel = sdmac->channel;
-
 	if (priority < MXC_SDMA_MIN_PRIORITY
 	    || priority > MXC_SDMA_MAX_PRIORITY) {
 		return -EINVAL;
@@ -928,7 +920,7 @@ static int sdma_request_channel(struct sdma_channel *sdmac)
 	sdma->channel_control[channel].base_bd_ptr = sdmac->bd_phys;
 	sdma->channel_control[channel].current_bd_ptr = sdmac->bd_phys;
 
-	sdma_set_channel_priority(sdmac, MXC_SDMA_DEFAULT_PRIORITY);
+	sdma_set_channel_priority(sdma, channel, MXC_SDMA_DEFAULT_PRIORITY);
 	return 0;
 out:
 
@@ -958,6 +950,7 @@ static dma_cookie_t sdma_tx_submit(struct dma_async_tx_descriptor *tx)
 static int sdma_alloc_chan_resources(struct dma_chan *chan)
 {
 	struct sdma_channel *sdmac = to_sdma_chan(chan);
+	struct sdma_engine *sdma = sdmac->sdma;
 	struct imx_dma_data *data = chan->private;
 	int prio, ret;
 
@@ -980,14 +973,14 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan)
 	sdmac->peripheral_type = data->peripheral_type;
 	sdmac->event_id0 = data->dma_request;
 
-	clk_enable(sdmac->sdma->clk_ipg);
-	clk_enable(sdmac->sdma->clk_ahb);
+	clk_enable(sdma->clk_ipg);
+	clk_enable(sdma->clk_ahb);
 
 	ret = sdma_request_channel(sdmac);
 	if (ret)
 		return ret;
 
-	ret = sdma_set_channel_priority(sdmac, prio);
+	ret = sdma_set_channel_priority(sdma, sdmac->channel, prio);
 	if (ret)
 		return ret;
 
@@ -1003,18 +996,19 @@ static void sdma_free_chan_resources(struct dma_chan *chan)
 {
 	struct sdma_channel *sdmac = to_sdma_chan(chan);
 	struct sdma_engine *sdma = sdmac->sdma;
+	int channel = sdmac->channel;
 
-	sdma_disable_channel(sdmac);
+	sdma_disable_channel(sdma, channel);
 
 	if (sdmac->event_id0)
-		sdma_event_disable(sdmac, sdmac->event_id0);
+		sdma_event_disable(sdma, channel, sdmac->event_id0);
 	if (sdmac->event_id1)
-		sdma_event_disable(sdmac, sdmac->event_id1);
+		sdma_event_disable(sdma, channel, sdmac->event_id1);
 
 	sdmac->event_id0 = 0;
 	sdmac->event_id1 = 0;
 
-	sdma_set_channel_priority(sdmac, 0);
+	sdma_set_channel_priority(sdma, channel, 0);
 
 	dma_free_coherent(NULL, PAGE_SIZE, sdmac->bd, sdmac->bd_phys);
 
@@ -1207,11 +1201,12 @@ static int sdma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
 		unsigned long arg)
 {
 	struct sdma_channel *sdmac = to_sdma_chan(chan);
+	struct sdma_engine *sdma = sdmac->sdma;
 	struct dma_slave_config *dmaengine_cfg = (void *)arg;
 
 	switch (cmd) {
 	case DMA_TERMINATE_ALL:
-		sdma_disable_channel(sdmac);
+		sdma_disable_channel(sdma, sdmac->channel);
 		return 0;
 	case DMA_SLAVE_CONFIG:
 		if (dmaengine_cfg->direction == DMA_DEV_TO_MEM) {
@@ -1390,7 +1385,7 @@ static int sdma_init(struct sdma_engine *sdma)
 	if (ret)
 		goto err_dma_alloc;
 
-	sdma_config_ownership(&sdma->channel[0], false, true, false);
+	sdma_config_ownership(sdma, 0, false, true, false);
 
 	/* Set Command Channel (Channel Zero) */
 	writel_relaxed(0x4050, sdma->regs + SDMA_CHN0ADDR);
@@ -1405,7 +1400,7 @@ static int sdma_init(struct sdma_engine *sdma)
 	writel_relaxed(SDMA_H_CONFIG_CSM, sdma->regs + SDMA_H_CONFIG);
 
 	/* Initializes channel's priorities */
-	sdma_set_channel_priority(&sdma->channel[0], 7);
+	sdma_set_channel_priority(sdma, 0, 7);
 
 	clk_disable(sdma->clk_ipg);
 	clk_disable(sdma->clk_ahb);
-- 
2.1.4

WARNING: multiple messages have this Message-ID (diff)
From: Joshua Clayton <stillcompiling@gmail.com>
To: Vinod Koul <vinod.koul@intel.com>
Cc: Joshua Clayton <stillcompiling@gmail.com>,
	Dan Williams <dan.j.williams@intel.com>,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Shawn Guo <shawn.guo@linaro.org>
Subject: [PATCH 02/10] dma: imx-sdma: pass sdma engine into functions
Date: Mon, 15 Jun 2015 09:18:57 -0700	[thread overview]
Message-ID: <1434385144-4432-3-git-send-email-stillcompiling@gmail.com> (raw)
In-Reply-To: <1434385144-4432-1-git-send-email-stillcompiling@gmail.com>

Some ostensibly dma channel centric functions do their work
either exclusively or primarily on the sdma engine struct.
Change these functions to pass a struct sdma_engine and integer channel

Signed-off-by: Joshua Clayton <stillcompiling@gmail.com>
---
 drivers/dma/imx-sdma.c | 65 +++++++++++++++++++++++---------------------------
 1 file changed, 30 insertions(+), 35 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 0671d6d..c255664 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -467,11 +467,9 @@ static inline u32 chnenbl_ofs(struct sdma_engine *sdma, unsigned int event)
 	return chnenbl0 + event * 4;
 }
 
-static int sdma_config_ownership(struct sdma_channel *sdmac,
+static int sdma_config_ownership(struct sdma_engine *sdma, int channel,
 		bool event_override, bool mcu_override, bool dsp_override)
 {
-	struct sdma_engine *sdma = sdmac->sdma;
-	int channel = sdmac->channel;
 	unsigned long evt, mcu, dsp;
 
 	if (event_override && mcu_override && dsp_override)
@@ -569,10 +567,9 @@ static int sdma_load_script(struct sdma_engine *sdma, void *buf, int size,
 	return ret;
 }
 
-static void sdma_event_enable(struct sdma_channel *sdmac, unsigned int event)
+static void sdma_event_enable(struct sdma_engine *sdma, int channel,
+			unsigned int event)
 {
-	struct sdma_engine *sdma = sdmac->sdma;
-	int channel = sdmac->channel;
 	unsigned long val;
 	u32 chnenbl = chnenbl_ofs(sdma, event);
 
@@ -581,10 +578,9 @@ static void sdma_event_enable(struct sdma_channel *sdmac, unsigned int event)
 	writel_relaxed(val, sdma->regs + chnenbl);
 }
 
-static void sdma_event_disable(struct sdma_channel *sdmac, unsigned int event)
+static void sdma_event_disable(struct sdma_engine *sdma, int channel,
+		unsigned int event)
 {
-	struct sdma_engine *sdma = sdmac->sdma;
-	int channel = sdmac->channel;
 	u32 chnenbl = chnenbl_ofs(sdma, event);
 	unsigned long val;
 
@@ -830,20 +826,19 @@ static int sdma_load_context(struct sdma_channel *sdmac)
 	return ret;
 }
 
-static void sdma_disable_channel(struct sdma_channel *sdmac)
+static void sdma_disable_channel(struct sdma_engine *sdma, int channel)
 {
-	struct sdma_engine *sdma = sdmac->sdma;
-	int channel = sdmac->channel;
-
 	writel_relaxed(BIT(channel), sdma->regs + SDMA_H_STATSTOP);
-	sdmac->status = DMA_ERROR;
+	sdma->channel[channel].status = DMA_ERROR;
 }
 
 static int sdma_config_channel(struct sdma_channel *sdmac)
 {
 	int ret;
+	int channel = sdmac->channel;
+	struct sdma_engine *sdma = sdmac->sdma;
 
-	sdma_disable_channel(sdmac);
+	sdma_disable_channel(sdma, channel);
 
 	sdmac->event_mask[0] = 0;
 	sdmac->event_mask[1] = 0;
@@ -851,20 +846,20 @@ static int sdma_config_channel(struct sdma_channel *sdmac)
 	sdmac->per_addr = 0;
 
 	if (sdmac->event_id0) {
-		if (sdmac->event_id0 >= sdmac->sdma->drvdata->num_events)
+		if (sdmac->event_id0 >= sdma->drvdata->num_events)
 			return -EINVAL;
-		sdma_event_enable(sdmac, sdmac->event_id0);
+		sdma_event_enable(sdma, channel, sdmac->event_id0);
 	}
 
 	switch (sdmac->peripheral_type) {
 	case IMX_DMATYPE_DSP:
-		sdma_config_ownership(sdmac, false, true, true);
+		sdma_config_ownership(sdma, channel, false, true, true);
 		break;
 	case IMX_DMATYPE_MEMORY:
-		sdma_config_ownership(sdmac, false, true, false);
+		sdma_config_ownership(sdma, channel, false, true, false);
 		break;
 	default:
-		sdma_config_ownership(sdmac, true, true, false);
+		sdma_config_ownership(sdma, channel, true, true, false);
 		break;
 	}
 
@@ -896,12 +891,9 @@ static int sdma_config_channel(struct sdma_channel *sdmac)
 	return ret;
 }
 
-static int sdma_set_channel_priority(struct sdma_channel *sdmac,
+static int sdma_set_channel_priority(struct sdma_engine *sdma, int channel,
 		unsigned int priority)
 {
-	struct sdma_engine *sdma = sdmac->sdma;
-	int channel = sdmac->channel;
-
 	if (priority < MXC_SDMA_MIN_PRIORITY
 	    || priority > MXC_SDMA_MAX_PRIORITY) {
 		return -EINVAL;
@@ -928,7 +920,7 @@ static int sdma_request_channel(struct sdma_channel *sdmac)
 	sdma->channel_control[channel].base_bd_ptr = sdmac->bd_phys;
 	sdma->channel_control[channel].current_bd_ptr = sdmac->bd_phys;
 
-	sdma_set_channel_priority(sdmac, MXC_SDMA_DEFAULT_PRIORITY);
+	sdma_set_channel_priority(sdma, channel, MXC_SDMA_DEFAULT_PRIORITY);
 	return 0;
 out:
 
@@ -958,6 +950,7 @@ static dma_cookie_t sdma_tx_submit(struct dma_async_tx_descriptor *tx)
 static int sdma_alloc_chan_resources(struct dma_chan *chan)
 {
 	struct sdma_channel *sdmac = to_sdma_chan(chan);
+	struct sdma_engine *sdma = sdmac->sdma;
 	struct imx_dma_data *data = chan->private;
 	int prio, ret;
 
@@ -980,14 +973,14 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan)
 	sdmac->peripheral_type = data->peripheral_type;
 	sdmac->event_id0 = data->dma_request;
 
-	clk_enable(sdmac->sdma->clk_ipg);
-	clk_enable(sdmac->sdma->clk_ahb);
+	clk_enable(sdma->clk_ipg);
+	clk_enable(sdma->clk_ahb);
 
 	ret = sdma_request_channel(sdmac);
 	if (ret)
 		return ret;
 
-	ret = sdma_set_channel_priority(sdmac, prio);
+	ret = sdma_set_channel_priority(sdma, sdmac->channel, prio);
 	if (ret)
 		return ret;
 
@@ -1003,18 +996,19 @@ static void sdma_free_chan_resources(struct dma_chan *chan)
 {
 	struct sdma_channel *sdmac = to_sdma_chan(chan);
 	struct sdma_engine *sdma = sdmac->sdma;
+	int channel = sdmac->channel;
 
-	sdma_disable_channel(sdmac);
+	sdma_disable_channel(sdma, channel);
 
 	if (sdmac->event_id0)
-		sdma_event_disable(sdmac, sdmac->event_id0);
+		sdma_event_disable(sdma, channel, sdmac->event_id0);
 	if (sdmac->event_id1)
-		sdma_event_disable(sdmac, sdmac->event_id1);
+		sdma_event_disable(sdma, channel, sdmac->event_id1);
 
 	sdmac->event_id0 = 0;
 	sdmac->event_id1 = 0;
 
-	sdma_set_channel_priority(sdmac, 0);
+	sdma_set_channel_priority(sdma, channel, 0);
 
 	dma_free_coherent(NULL, PAGE_SIZE, sdmac->bd, sdmac->bd_phys);
 
@@ -1207,11 +1201,12 @@ static int sdma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
 		unsigned long arg)
 {
 	struct sdma_channel *sdmac = to_sdma_chan(chan);
+	struct sdma_engine *sdma = sdmac->sdma;
 	struct dma_slave_config *dmaengine_cfg = (void *)arg;
 
 	switch (cmd) {
 	case DMA_TERMINATE_ALL:
-		sdma_disable_channel(sdmac);
+		sdma_disable_channel(sdma, sdmac->channel);
 		return 0;
 	case DMA_SLAVE_CONFIG:
 		if (dmaengine_cfg->direction == DMA_DEV_TO_MEM) {
@@ -1390,7 +1385,7 @@ static int sdma_init(struct sdma_engine *sdma)
 	if (ret)
 		goto err_dma_alloc;
 
-	sdma_config_ownership(&sdma->channel[0], false, true, false);
+	sdma_config_ownership(sdma, 0, false, true, false);
 
 	/* Set Command Channel (Channel Zero) */
 	writel_relaxed(0x4050, sdma->regs + SDMA_CHN0ADDR);
@@ -1405,7 +1400,7 @@ static int sdma_init(struct sdma_engine *sdma)
 	writel_relaxed(SDMA_H_CONFIG_CSM, sdma->regs + SDMA_H_CONFIG);
 
 	/* Initializes channel's priorities */
-	sdma_set_channel_priority(&sdma->channel[0], 7);
+	sdma_set_channel_priority(sdma, 0, 7);
 
 	clk_disable(sdma->clk_ipg);
 	clk_disable(sdma->clk_ahb);
-- 
2.1.4


  parent reply	other threads:[~2015-06-15 16:18 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-15 16:18 [PATCH 00/10] imx-sdma cleanup Joshua Clayton
2015-06-15 16:18 ` Joshua Clayton
2015-06-15 16:18 ` [PATCH 01/10] dma: imx-sdma: constify local structs Joshua Clayton
2015-06-15 16:18   ` Joshua Clayton
2015-06-15 16:18 ` Joshua Clayton [this message]
2015-06-15 16:18   ` [PATCH 02/10] dma: imx-sdma: pass sdma engine into functions Joshua Clayton
2015-06-15 16:18 ` [PATCH 03/10] dma: imx-sdma: use a container_of function Joshua Clayton
2015-06-15 16:18   ` Joshua Clayton
2015-06-15 16:18 ` [PATCH 04/10] dma: sdma-imx set dma script address directly Joshua Clayton
2015-06-15 16:18   ` Joshua Clayton
2015-06-15 16:19 ` [PATCH 05/10] dma: sdma-imx: print an error when context load fails Joshua Clayton
2015-06-15 16:19   ` Joshua Clayton
2015-06-15 16:19 ` [PATCH 06/10] dma: imx-sdma: config in sdma_config_channel() Joshua Clayton
2015-06-15 16:19   ` Joshua Clayton
2015-06-15 16:19 ` [PATCH 07/10] dma: imx-sdma: validate word size when set Joshua Clayton
2015-06-15 16:19   ` Joshua Clayton
2015-06-15 16:19 ` [PATCH 08/10] dma: imx-sdma: extract common sdma prep code Joshua Clayton
2015-06-15 16:19   ` Joshua Clayton
2015-06-15 16:19 ` [PATCH 09/10] dma: imx-sdma: use a for loop Joshua Clayton
2015-06-15 16:19   ` Joshua Clayton
2015-06-16 14:57 ` [PATCH 00/10] imx-sdma cleanup Joshua Clayton
2015-06-16 14:57   ` Joshua Clayton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1434385144-4432-3-git-send-email-stillcompiling@gmail.com \
    --to=stillcompiling@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.