Skip to contentSkip to conversation

pl330 endian fix and two fixups

PATCH New Ben Dooks 2 participants 5 messages Mar 16, 2015 – Mar 18, 2015 dmaengine

lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

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.

author
#1 lore raw

PATCH 1/3 dmaengine: pl330: fix issues with big-endian armv7

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.

--
Vinod Koul <[email protected]>
Dan Williams <[email protected]>
DMA List <[email protected]>
Maxime Ripard <[email protected]> Jassi Brar <[email protected]>
Liviu Dudau <[email protected]>
Linux ARM Kernel <[email protected]>

---
 drivers/dma/pl330.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/dma/pl330.c +4 -4
index 0e1f567..f76c94c 100644
@@ -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 */
Signature · 1 line
2.1.4
author
#2 lore raw

PATCH 2/3 dmaengine: pl330: make unexported functions static

In reply to Ben Dooks

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?

--
Vinod Koul <[email protected]>
Dan Williams <[email protected]>
DMA List <[email protected]>
Maxime Ripard <[email protected]> Jassi Brar <[email protected]>
Liviu Dudau <[email protected]>
Linux ARM Kernel <[email protected]>

---
 drivers/dma/pl330.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/dma/pl330.c +3 -3
index f76c94c..d6f677e 100644
@@ -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;
Signature · 1 line
2.1.4
author
#3 lore raw

PATCH 3/3 dmaengine: pl330: fix return status on pending transfers

In reply to Ben Dooks

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.

--
Vinod Koul <[email protected]>
Dan Williams <[email protected]>
DMA List <[email protected]>
Maxime Ripard <[email protected]> Jassi Brar <[email protected]>
Liviu Dudau <[email protected]>
Linux ARM Kernel <[email protected]>

---
 drivers/dma/pl330.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/dma/pl330.c +11 -1
index d6f677e..a7d9d30 100644
@@ -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)
Signature · 1 line
2.1.4
Applied
#4 lore raw
In reply to Ben Dooks
Quoted 6 lines · Ben Dooks

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

Signature · 1 line
~Vinod