LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/7] dw_dmac: Remove compilation dependency from AVR32
@ 2011-02-17  7:24 Viresh Kumar
  2011-02-17  7:24 ` [PATCH 2/7] dw_dmac: Move single descriptor from dwc->queue to dwc->active_list in dwc_complete_all Viresh Kumar
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Viresh Kumar @ 2011-02-17  7:24 UTC (permalink / raw)
  To: dan.j.williams, linux-kernel
  Cc: shiraz.hashim, amit.goel, armando.visconti, Viresh Kumar

This will be used in SPEAr, ARM family.

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
 drivers/dma/Kconfig |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 1c28816..95c7db7 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -82,7 +82,6 @@ config INTEL_IOP_ADMA
 
 config DW_DMAC
 	tristate "Synopsys DesignWare AHB DMA support"
-	depends on AVR32
 	select DMA_ENGINE
 	default y if CPU_AT32AP7000
 	help
-- 
1.7.2.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/7] dw_dmac: Move single descriptor from dwc->queue to dwc->active_list in dwc_complete_all
  2011-02-17  7:24 [PATCH 1/7] dw_dmac: Remove compilation dependency from AVR32 Viresh Kumar
@ 2011-02-17  7:24 ` Viresh Kumar
  2011-02-17  7:24 ` [PATCH 3/7] dw_dmac: call dwc_scan_descriptor from dwc_issue_pending only if active list is empty Viresh Kumar
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2011-02-17  7:24 UTC (permalink / raw)
  To: dan.j.williams, linux-kernel
  Cc: shiraz.hashim, amit.goel, armando.visconti, Viresh KUMAR

From: Viresh KUMAR <viresh.kumar@st.com>

dwc_complete_all and other routines was removing all descriptors from dwc->queue
and pushing them to dwc->active_list. Only one was required to be removed. Also
we are calling dwc_dostart, once list is fixed.

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
 drivers/dma/dw_dmac.c |   20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index a3991ab..6dd03b0 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -84,11 +84,6 @@ static struct dw_desc *dwc_first_active(struct dw_dma_chan *dwc)
 	return list_entry(dwc->active_list.next, struct dw_desc, desc_node);
 }
 
-static struct dw_desc *dwc_first_queued(struct dw_dma_chan *dwc)
-{
-	return list_entry(dwc->queue.next, struct dw_desc, desc_node);
-}
-
 static struct dw_desc *dwc_desc_get(struct dw_dma_chan *dwc)
 {
 	struct dw_desc *desc, *_desc;
@@ -259,10 +254,11 @@ static void dwc_complete_all(struct dw_dma *dw, struct dw_dma_chan *dwc)
 	 * Submit queued descriptors ASAP, i.e. before we go through
 	 * the completed ones.
 	 */
-	if (!list_empty(&dwc->queue))
-		dwc_dostart(dwc, dwc_first_queued(dwc));
 	list_splice_init(&dwc->active_list, &list);
-	list_splice_init(&dwc->queue, &dwc->active_list);
+	if (!list_empty(&dwc->queue)) {
+		list_move(dwc->queue.next, &dwc->active_list);
+		dwc_dostart(dwc, dwc_first_active(dwc));
+	}
 
 	list_for_each_entry_safe(desc, _desc, &list, desc_node)
 		dwc_descriptor_complete(dwc, desc);
@@ -319,8 +315,8 @@ static void dwc_scan_descriptors(struct dw_dma *dw, struct dw_dma_chan *dwc)
 		cpu_relax();
 
 	if (!list_empty(&dwc->queue)) {
-		dwc_dostart(dwc, dwc_first_queued(dwc));
-		list_splice_init(&dwc->queue, &dwc->active_list);
+		list_move(dwc->queue.next, &dwc->active_list);
+		dwc_dostart(dwc, dwc_first_active(dwc));
 	}
 }
 
@@ -346,7 +342,7 @@ static void dwc_handle_error(struct dw_dma *dw, struct dw_dma_chan *dwc)
 	 */
 	bad_desc = dwc_first_active(dwc);
 	list_del_init(&bad_desc->desc_node);
-	list_splice_init(&dwc->queue, dwc->active_list.prev);
+	list_move(dwc->queue.next, dwc->active_list.prev);
 
 	/* Clear the error flag and try to restart the controller */
 	dma_writel(dw, CLEAR.ERROR, dwc->mask);
@@ -541,8 +537,8 @@ static dma_cookie_t dwc_tx_submit(struct dma_async_tx_descriptor *tx)
 	if (list_empty(&dwc->active_list)) {
 		dev_vdbg(chan2dev(tx->chan), "tx_submit: started %u\n",
 				desc->txd.cookie);
-		dwc_dostart(dwc, desc);
 		list_add_tail(&desc->desc_node, &dwc->active_list);
+		dwc_dostart(dwc, dwc_first_active(dwc));
 	} else {
 		dev_vdbg(chan2dev(tx->chan), "tx_submit: queued %u\n",
 				desc->txd.cookie);
-- 
1.7.2.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/7] dw_dmac: call dwc_scan_descriptor from dwc_issue_pending only if active list is empty
  2011-02-17  7:24 [PATCH 1/7] dw_dmac: Remove compilation dependency from AVR32 Viresh Kumar
  2011-02-17  7:24 ` [PATCH 2/7] dw_dmac: Move single descriptor from dwc->queue to dwc->active_list in dwc_complete_all Viresh Kumar
@ 2011-02-17  7:24 ` Viresh Kumar
  2011-02-17  7:24 ` [PATCH 4/7] dw_dmac: calling dwc_scan_descriptors from dwc_tx_status() after taking lock Viresh Kumar
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2011-02-17  7:24 UTC (permalink / raw)
  To: dan.j.williams, linux-kernel
  Cc: shiraz.hashim, amit.goel, armando.visconti, Viresh KUMAR

From: Viresh KUMAR <viresh.kumar@st.com>

dwc_scan_descriptor was called even when there were descriptors in active list.
Checking if active list is empty or not.

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
 drivers/dma/dw_dmac.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index 6dd03b0..3bf4772 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -848,7 +848,7 @@ static void dwc_issue_pending(struct dma_chan *chan)
 	struct dw_dma_chan	*dwc = to_dw_dma_chan(chan);
 
 	spin_lock_bh(&dwc->lock);
-	if (!list_empty(&dwc->queue))
+	if (!list_empty(&dwc->queue) && list_empty(&dwc->active_list))
 		dwc_scan_descriptors(to_dw_dma(chan->device), dwc);
 	spin_unlock_bh(&dwc->lock);
 }
-- 
1.7.2.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 4/7] dw_dmac: calling dwc_scan_descriptors from dwc_tx_status() after taking lock
  2011-02-17  7:24 [PATCH 1/7] dw_dmac: Remove compilation dependency from AVR32 Viresh Kumar
  2011-02-17  7:24 ` [PATCH 2/7] dw_dmac: Move single descriptor from dwc->queue to dwc->active_list in dwc_complete_all Viresh Kumar
  2011-02-17  7:24 ` [PATCH 3/7] dw_dmac: call dwc_scan_descriptor from dwc_issue_pending only if active list is empty Viresh Kumar
@ 2011-02-17  7:24 ` Viresh Kumar
  2011-02-17  7:24 ` [PATCH 5/7] dw_dmac: adding support for 64 bit access width for memcpy xfers Viresh Kumar
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2011-02-17  7:24 UTC (permalink / raw)
  To: dan.j.williams, linux-kernel
  Cc: shiraz.hashim, amit.goel, armando.visconti, Viresh Kumar

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
 drivers/dma/dw_dmac.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index 3bf4772..5cc5abf 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -830,7 +830,9 @@ dwc_tx_status(struct dma_chan *chan,
 
 	ret = dma_async_is_complete(cookie, last_complete, last_used);
 	if (ret != DMA_SUCCESS) {
+		spin_lock_bh(&dwc->lock);
 		dwc_scan_descriptors(to_dw_dma(chan->device), dwc);
+		spin_unlock_bh(&dwc->lock);
 
 		last_complete = dwc->completed;
 		last_used = chan->cookie;
-- 
1.7.2.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 5/7] dw_dmac: adding support for 64 bit access width for memcpy xfers
  2011-02-17  7:24 [PATCH 1/7] dw_dmac: Remove compilation dependency from AVR32 Viresh Kumar
                   ` (2 preceding siblings ...)
  2011-02-17  7:24 ` [PATCH 4/7] dw_dmac: calling dwc_scan_descriptors from dwc_tx_status() after taking lock Viresh Kumar
@ 2011-02-17  7:24 ` Viresh Kumar
  2011-02-17  7:24 ` [PATCH 6/7] dw_dmac: Mark all tx_descriptors with DMA_CRTL_ACK after xfer finish Viresh Kumar
  2011-02-17  7:24 ` [PATCH 7/7] dw_dmac.c: Pass Channel Allocation Priority from platform_data Viresh Kumar
  5 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2011-02-17  7:24 UTC (permalink / raw)
  To: dan.j.williams, linux-kernel
  Cc: shiraz.hashim, amit.goel, armando.visconti, Viresh KUMAR

From: Viresh KUMAR <viresh.kumar@st.com>

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
 drivers/dma/dw_dmac.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index 5cc5abf..c40b89f 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -577,7 +577,9 @@ dwc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
 	 * We can be a lot more clever here, but this should take care
 	 * of the most common optimization.
 	 */
-	if (!((src | dest  | len) & 3))
+	if (!((src | dest  | len) & 7))
+		src_width = dst_width = 3;
+	else if (!((src | dest  | len) & 3))
 		src_width = dst_width = 2;
 	else if (!((src | dest | len) & 1))
 		src_width = dst_width = 1;
-- 
1.7.2.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 6/7] dw_dmac: Mark all tx_descriptors with DMA_CRTL_ACK after xfer finish
  2011-02-17  7:24 [PATCH 1/7] dw_dmac: Remove compilation dependency from AVR32 Viresh Kumar
                   ` (3 preceding siblings ...)
  2011-02-17  7:24 ` [PATCH 5/7] dw_dmac: adding support for 64 bit access width for memcpy xfers Viresh Kumar
@ 2011-02-17  7:24 ` Viresh Kumar
  2011-02-17  7:24 ` [PATCH 7/7] dw_dmac.c: Pass Channel Allocation Priority from platform_data Viresh Kumar
  5 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2011-02-17  7:24 UTC (permalink / raw)
  To: dan.j.williams, linux-kernel
  Cc: shiraz.hashim, amit.goel, armando.visconti, Viresh Kumar

dwc_desc_get checks all descriptors for DMA_CTRL_ACK before allocating them for
transfers. And descriptors are not marked with DMA_CRTL_ACK after transfer
finishes. Thus descriptor once used is not usable again. This patch marks
descriptors with DMA_CRTL_ACK after dma xfer finishes

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
 drivers/dma/dw_dmac.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index c40b89f..01f783d 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -196,6 +196,7 @@ dwc_descriptor_complete(struct dw_dma_chan *dwc, struct dw_desc *desc)
 	dma_async_tx_callback		callback;
 	void				*param;
 	struct dma_async_tx_descriptor	*txd = &desc->txd;
+	struct dw_desc	*child;
 
 	dev_vdbg(chan2dev(&dwc->chan), "descriptor %u complete\n", txd->cookie);
 
@@ -204,6 +205,12 @@ dwc_descriptor_complete(struct dw_dma_chan *dwc, struct dw_desc *desc)
 	param = txd->callback_param;
 
 	dwc_sync_desc_for_cpu(dwc, desc);
+
+	/* async_tx_ack */
+	list_for_each_entry(child, &desc->tx_list, desc_node)
+		async_tx_ack(&child->txd);
+	async_tx_ack(&desc->txd);
+
 	list_splice_init(&desc->tx_list, &dwc->free_list);
 	list_move(&desc->desc_node, &dwc->free_list);
 
-- 
1.7.2.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 7/7] dw_dmac.c: Pass Channel Allocation Priority from platform_data
  2011-02-17  7:24 [PATCH 1/7] dw_dmac: Remove compilation dependency from AVR32 Viresh Kumar
                   ` (4 preceding siblings ...)
  2011-02-17  7:24 ` [PATCH 6/7] dw_dmac: Mark all tx_descriptors with DMA_CRTL_ACK after xfer finish Viresh Kumar
@ 2011-02-17  7:24 ` Viresh Kumar
  5 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2011-02-17  7:24 UTC (permalink / raw)
  To: dan.j.williams, linux-kernel
  Cc: shiraz.hashim, amit.goel, armando.visconti, Viresh KUMAR

From: Viresh KUMAR <viresh.kumar@st.com>

In SPEAr Platform channels 4-7 have more Fifo depth. So we must get better
channel first. This patch introduces concept of channel allocation priority in
dw_dmac. If user doesn't paas anything or 0, than normal (ascending) channel
allocation will follow, else channels will be allocated in descending order.

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
 drivers/dma/dw_dmac.c   |    6 +++++-
 include/linux/dw_dmac.h |    3 +++
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index 01f783d..d4bf956 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -1314,7 +1314,11 @@ static int __init dw_probe(struct platform_device *pdev)
 		dwc->chan.device = &dw->dma;
 		dwc->chan.cookie = dwc->completed = 1;
 		dwc->chan.chan_id = i;
-		list_add_tail(&dwc->chan.device_node, &dw->dma.channels);
+		if (pdata->chan_priority == CHAN_PRIO_ASCENDING)
+			list_add_tail(&dwc->chan.device_node,
+					&dw->dma.channels);
+		else
+			list_add(&dwc->chan.device_node, &dw->dma.channels);
 
 		dwc->ch_regs = &__dw_regs(dw)->CHAN[i];
 		spin_lock_init(&dwc->lock);
diff --git a/include/linux/dw_dmac.h b/include/linux/dw_dmac.h
index c8aad71..b1ab0b9 100644
--- a/include/linux/dw_dmac.h
+++ b/include/linux/dw_dmac.h
@@ -19,6 +19,9 @@
  */
 struct dw_dma_platform_data {
 	unsigned int	nr_channels;
+#define CHAN_PRIO_ASCENDING	0	/* zero to seven */
+#define CHAN_PRIO_DESCENDING	1	/* seven to zero */
+	unsigned int	chan_priority;
 };
 
 /**
-- 
1.7.2.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-02-17  7:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-17  7:24 [PATCH 1/7] dw_dmac: Remove compilation dependency from AVR32 Viresh Kumar
2011-02-17  7:24 ` [PATCH 2/7] dw_dmac: Move single descriptor from dwc->queue to dwc->active_list in dwc_complete_all Viresh Kumar
2011-02-17  7:24 ` [PATCH 3/7] dw_dmac: call dwc_scan_descriptor from dwc_issue_pending only if active list is empty Viresh Kumar
2011-02-17  7:24 ` [PATCH 4/7] dw_dmac: calling dwc_scan_descriptors from dwc_tx_status() after taking lock Viresh Kumar
2011-02-17  7:24 ` [PATCH 5/7] dw_dmac: adding support for 64 bit access width for memcpy xfers Viresh Kumar
2011-02-17  7:24 ` [PATCH 6/7] dw_dmac: Mark all tx_descriptors with DMA_CRTL_ACK after xfer finish Viresh Kumar
2011-02-17  7:24 ` [PATCH 7/7] dw_dmac.c: Pass Channel Allocation Priority from platform_data Viresh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).