linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* pl330 endian fix and two fixups
@ 2015-03-16 11:52 Ben Dooks
  2015-03-16 11:52 ` [PATCH 1/3] dmaengine: pl330: fix issues with big-endian armv7 Ben Dooks
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ben Dooks @ 2015-03-16 11:52 UTC (permalink / raw)
  To: linux-arm-kernel

When getting the pl330 driver to work on an Xilinx Zynq working in
big-endian the first patch is needed to get the dmatest suite to
pass.

The second and third patches are warning fixes from sparse, of
which the third may not be the complete solution. It works for me.

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

* [PATCH 1/3] dmaengine: pl330: fix issues with big-endian armv7
  2015-03-16 11:52 pl330 endian fix and two fixups Ben Dooks
@ 2015-03-16 11:52 ` Ben Dooks
  2015-03-16 11:52 ` [PATCH 2/3] dmaengine: pl330: make unexported functions static Ben Dooks
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Ben Dooks @ 2015-03-16 11:52 UTC (permalink / raw)
  To: linux-arm-kernel

When running Xilinx Zynq in big-endian mode the pl330 driver
fails to pass the dmatest suite. To fix this, ensure all non
byte values are written in little endian.

As a note, the documentation does not mention if it will do
big-endian descriptor fetches, only that it will swap the
data in flight.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
--
Vinod Koul <vinod.koul@intel.com>
Dan Williams <dan.j.williams@intel.com>
DMA List <dmaengine@vger.kernel.org>
Maxime Ripard <maxime.ripard@free-electrons.com>
Jassi Brar <jassisinghbrar@gmail.com>
Liviu Dudau <Liviu.Dudau@arm.com>
Linux ARM Kernel <linux-arm-kernel@lists.infradead.org>
---
 drivers/dma/pl330.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 0e1f567..f76c94c 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -556,7 +556,7 @@ static inline u32 _emit_ADDH(unsigned dry_run, u8 buf[],
 
 	buf[0] = CMD_DMAADDH;
 	buf[0] |= (da << 1);
-	*((u16 *)&buf[1]) = val;
+	*((__le16 *)&buf[1]) = cpu_to_le16(val);
 
 	PL330_DBGCMD_DUMP(SZ_DMAADDH, "\tDMAADDH %s %u\n",
 		da == 1 ? "DA" : "SA", val);
@@ -710,7 +710,7 @@ static inline u32 _emit_MOV(unsigned dry_run, u8 buf[],
 
 	buf[0] = CMD_DMAMOV;
 	buf[1] = dst;
-	*((u32 *)&buf[2]) = val;
+	*((__le32 *)&buf[2]) = cpu_to_le32(val);
 
 	PL330_DBGCMD_DUMP(SZ_DMAMOV, "\tDMAMOV %s 0x%x\n",
 		dst == SAR ? "SAR" : (dst == DAR ? "DAR" : "CCR"), val);
@@ -888,7 +888,7 @@ static inline u32 _emit_GO(unsigned dry_run, u8 buf[],
 
 	buf[1] = chan & 0x7;
 
-	*((u32 *)&buf[2]) = addr;
+	*((__le32 *)&buf[2]) = cpu_to_le32(addr);
 
 	return SZ_DMAGO;
 }
@@ -928,7 +928,7 @@ static inline void _execute_DBGINSN(struct pl330_thread *thrd,
 	}
 	writel(val, regs + DBGINST0);
 
-	val = *((u32 *)&insn[2]);
+	val = le32_to_cpu(*((__le32 *)&insn[2]));
 	writel(val, regs + DBGINST1);
 
 	/* If timed out due to halted state-machine */
-- 
2.1.4

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

* [PATCH 2/3] dmaengine: pl330: make unexported functions static
  2015-03-16 11:52 pl330 endian fix and two fixups Ben Dooks
  2015-03-16 11:52 ` [PATCH 1/3] dmaengine: pl330: fix issues with big-endian armv7 Ben Dooks
@ 2015-03-16 11:52 ` Ben Dooks
  2015-03-16 11:52 ` [PATCH 3/3] dmaengine: pl330: fix return status on pending transfers Ben Dooks
  2015-03-18 17:12 ` pl330 endian fix and two fixups Vinod Koul
  3 siblings, 0 replies; 5+ messages in thread
From: Ben Dooks @ 2015-03-16 11:52 UTC (permalink / raw)
  To: linux-arm-kernel

Whilst running sparse on pl330 driver it was noticed there are
two functions that are not static but not exported to any other
users in the kernel.

Fix the following warnings by making 'pl330_pause' and the
'pl330_get_current_xferred_count' static:

pl330.c:2165:5: warning: symbol 'pl330_pause' was not declared. Should it be static?
pl330.c:2206:5: warning: symbol 'pl330_get_current_xferred_count' was not declared. Should it be static?

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
--
Vinod Koul <vinod.koul@intel.com>
Dan Williams <dan.j.williams@intel.com>
DMA List <dmaengine@vger.kernel.org>
Maxime Ripard <maxime.ripard@free-electrons.com>
Jassi Brar <jassisinghbrar@gmail.com>
Liviu Dudau <Liviu.Dudau@arm.com>
Linux ARM Kernel <linux-arm-kernel@lists.infradead.org>
---
 drivers/dma/pl330.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index f76c94c..d6f677e 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -2162,7 +2162,7 @@ static int pl330_terminate_all(struct dma_chan *chan)
  * DMA transfer again. This pause feature was implemented to
  * allow safely read residue before channel termination.
  */
-int pl330_pause(struct dma_chan *chan)
+static int pl330_pause(struct dma_chan *chan)
 {
 	struct dma_pl330_chan *pch = to_pchan(chan);
 	struct pl330_dmac *pl330 = pch->dmac;
@@ -2203,8 +2203,8 @@ static void pl330_free_chan_resources(struct dma_chan *chan)
 	pm_runtime_put_autosuspend(pch->dmac->ddma.dev);
 }
 
-int pl330_get_current_xferred_count(struct dma_pl330_chan *pch,
-		struct dma_pl330_desc *desc)
+static int pl330_get_current_xferred_count(struct dma_pl330_chan *pch,
+					   struct dma_pl330_desc *desc)
 {
 	struct pl330_thread *thrd = pch->thread;
 	struct pl330_dmac *pl330 = pch->dmac;
-- 
2.1.4

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

* [PATCH 3/3] dmaengine: pl330: fix return status on pending transfers
  2015-03-16 11:52 pl330 endian fix and two fixups Ben Dooks
  2015-03-16 11:52 ` [PATCH 1/3] dmaengine: pl330: fix issues with big-endian armv7 Ben Dooks
  2015-03-16 11:52 ` [PATCH 2/3] dmaengine: pl330: make unexported functions static Ben Dooks
@ 2015-03-16 11:52 ` Ben Dooks
  2015-03-18 17:12 ` pl330 endian fix and two fixups Vinod Koul
  3 siblings, 0 replies; 5+ messages in thread
From: Ben Dooks @ 2015-03-16 11:52 UTC (permalink / raw)
  To: linux-arm-kernel

The pl330_tx_status() function returns the desc->status if the
dma_cookie_status() call does indicate the cookie completed,
however the desc->status is not look directly compatible. Sparse
throws the following warning:

pl330.c:2262:35: warning: mixing different enum types
pl330.c:2262:35:     int enum desc_status  versus
pl330.c:2262:35:     int enum dma_status

Attempt to fix this by adding a switch statement to turn the
desc->status into a dma_status.

Note, this has only been tested with the dmatest suite.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
--
Vinod Koul <vinod.koul@intel.com>
Dan Williams <dan.j.williams@intel.com>
DMA List <dmaengine@vger.kernel.org>
Maxime Ripard <maxime.ripard@free-electrons.com>
Jassi Brar <jassisinghbrar@gmail.com>
Liviu Dudau <Liviu.Dudau@arm.com>
Linux ARM Kernel <linux-arm-kernel@lists.infradead.org>
---
 drivers/dma/pl330.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index d6f677e..a7d9d30 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -2259,7 +2259,17 @@ pl330_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
 			transferred = 0;
 		residual += desc->bytes_requested - transferred;
 		if (desc->txd.cookie == cookie) {
-			ret = desc->status;
+			switch (desc->status) {
+			case DONE:
+				ret = DMA_COMPLETE;
+				break;
+			case PREP:
+			case BUSY:
+				ret = DMA_IN_PROGRESS;
+				break;
+			default:
+				WARN_ON(1);
+			}
 			break;
 		}
 		if (desc->last)
-- 
2.1.4

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

* pl330 endian fix and two fixups
  2015-03-16 11:52 pl330 endian fix and two fixups Ben Dooks
                   ` (2 preceding siblings ...)
  2015-03-16 11:52 ` [PATCH 3/3] dmaengine: pl330: fix return status on pending transfers Ben Dooks
@ 2015-03-18 17:12 ` Vinod Koul
  3 siblings, 0 replies; 5+ messages in thread
From: Vinod Koul @ 2015-03-18 17:12 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 16, 2015 at 11:52:42AM +0000, Ben Dooks wrote:
> When getting the pl330 driver to work on an Xilinx Zynq working in
> big-endian the first patch is needed to get the dmatest suite to
> pass.
> 
> The second and third patches are warning fixes from sparse, of
> which the third may not be the complete solution. It works for me.

Applied, thanks

-- 
~Vinod

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

end of thread, other threads:[~2015-03-18 17:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-16 11:52 pl330 endian fix and two fixups Ben Dooks
2015-03-16 11:52 ` [PATCH 1/3] dmaengine: pl330: fix issues with big-endian armv7 Ben Dooks
2015-03-16 11:52 ` [PATCH 2/3] dmaengine: pl330: make unexported functions static Ben Dooks
2015-03-16 11:52 ` [PATCH 3/3] dmaengine: pl330: fix return status on pending transfers Ben Dooks
2015-03-18 17:12 ` pl330 endian fix and two fixups Vinod Koul

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).