* [PATCH] dmaengine: xgene-dma: Fix overwritting DMA tx ring
@ 2015-09-16 8:03 Rameshwar Prasad Sahu
[not found] ` <1442390603-21129-1-git-send-email-rsahu-qTEPVZfXA3Y@public.gmane.org>
2015-09-30 8:05 ` Vinod Koul
0 siblings, 2 replies; 3+ messages in thread
From: Rameshwar Prasad Sahu @ 2015-09-16 8:03 UTC (permalink / raw)
To: vinod.koul, dan.j.williams
Cc: dmaengine, arnd, linux-kernel, devicetree, linux-arm-kernel, jcm,
patches, Rameshwar Prasad Sahu
This patch fixes an over flow issue with the TX ring descriptor. Each
descriptor is 32B in size and an operation requires 2 of these
descriptors.
Signed-off-by: Rameshwar Prasad Sahu <rsahu@apm.com>
---
drivers/dma/xgene-dma.c | 37 +++++++++++--------------------------
1 file changed, 11 insertions(+), 26 deletions(-)
diff --git a/drivers/dma/xgene-dma.c b/drivers/dma/xgene-dma.c
index b23e8d5..21ba2cc 100644
--- a/drivers/dma/xgene-dma.c
+++ b/drivers/dma/xgene-dma.c
@@ -59,7 +59,6 @@
#define XGENE_DMA_RING_MEM_RAM_SHUTDOWN 0xD070
#define XGENE_DMA_RING_BLK_MEM_RDY 0xD074
#define XGENE_DMA_RING_BLK_MEM_RDY_VAL 0xFFFFFFFF
-#define XGENE_DMA_RING_DESC_CNT(v) (((v) & 0x0001FFFE) >> 1)
#define XGENE_DMA_RING_ID_GET(owner, num) (((owner) << 6) | (num))
#define XGENE_DMA_RING_DST_ID(v) ((1 << 10) | (v))
#define XGENE_DMA_RING_CMD_OFFSET 0x2C
@@ -379,14 +378,6 @@ static u8 xgene_dma_encode_xor_flyby(u32 src_cnt)
return flyby_type[src_cnt];
}
-static u32 xgene_dma_ring_desc_cnt(struct xgene_dma_ring *ring)
-{
- u32 __iomem *cmd_base = ring->cmd_base;
- u32 ring_state = ioread32(&cmd_base[1]);
-
- return XGENE_DMA_RING_DESC_CNT(ring_state);
-}
-
static void xgene_dma_set_src_buffer(__le64 *ext8, size_t *len,
dma_addr_t *paddr)
{
@@ -659,15 +650,12 @@ static void xgene_dma_clean_running_descriptor(struct xgene_dma_chan *chan,
dma_pool_free(chan->desc_pool, desc, desc->tx.phys);
}
-static int xgene_chan_xfer_request(struct xgene_dma_ring *ring,
- struct xgene_dma_desc_sw *desc_sw)
+static void xgene_chan_xfer_request(struct xgene_dma_chan *chan,
+ struct xgene_dma_desc_sw *desc_sw)
{
+ struct xgene_dma_ring *ring = &chan->tx_ring;
struct xgene_dma_desc_hw *desc_hw;
- /* Check if can push more descriptor to hw for execution */
- if (xgene_dma_ring_desc_cnt(ring) > (ring->slots - 2))
- return -EBUSY;
-
/* Get hw descriptor from DMA tx ring */
desc_hw = &ring->desc_hw[ring->head];
@@ -694,11 +682,13 @@ static int xgene_chan_xfer_request(struct xgene_dma_ring *ring,
memcpy(desc_hw, &desc_sw->desc2, sizeof(*desc_hw));
}
+ /* Increment the pending transaction count */
+ chan->pending += ((desc_sw->flags &
+ XGENE_DMA_FLAG_64B_DESC) ? 2 : 1);
+
/* Notify the hw that we have descriptor ready for execution */
iowrite32((desc_sw->flags & XGENE_DMA_FLAG_64B_DESC) ?
2 : 1, ring->cmd);
-
- return 0;
}
/**
@@ -710,7 +700,6 @@ static int xgene_chan_xfer_request(struct xgene_dma_ring *ring,
static void xgene_chan_xfer_ld_pending(struct xgene_dma_chan *chan)
{
struct xgene_dma_desc_sw *desc_sw, *_desc_sw;
- int ret;
/*
* If the list of pending descriptors is empty, then we
@@ -735,18 +724,13 @@ static void xgene_chan_xfer_ld_pending(struct xgene_dma_chan *chan)
if (chan->pending >= chan->max_outstanding)
return;
- ret = xgene_chan_xfer_request(&chan->tx_ring, desc_sw);
- if (ret)
- return;
+ xgene_chan_xfer_request(chan, desc_sw);
/*
* Delete this element from ld pending queue and append it to
* ld running queue
*/
list_move_tail(&desc_sw->node, &chan->ld_running);
-
- /* Increment the pending transaction count */
- chan->pending++;
}
}
@@ -821,7 +805,8 @@ static void xgene_dma_cleanup_descriptors(struct xgene_dma_chan *chan)
* Decrement the pending transaction count
* as we have processed one
*/
- chan->pending--;
+ chan->pending -= ((desc_sw->flags &
+ XGENE_DMA_FLAG_64B_DESC) ? 2 : 1);
/*
* Delete this node from ld running queue and append it to
@@ -1482,7 +1467,7 @@ static int xgene_dma_create_chan_rings(struct xgene_dma_chan *chan)
tx_ring->id, tx_ring->num, tx_ring->desc_vaddr);
/* Set the max outstanding request possible to this channel */
- chan->max_outstanding = rx_ring->slots;
+ chan->max_outstanding = tx_ring->slots;
return ret;
}
--
1.8.2.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
[parent not found: <1442390603-21129-1-git-send-email-rsahu-qTEPVZfXA3Y@public.gmane.org>]
* Re: [PATCH] dmaengine: xgene-dma: Fix overwritting DMA tx ring
[not found] ` <1442390603-21129-1-git-send-email-rsahu-qTEPVZfXA3Y@public.gmane.org>
@ 2015-09-25 7:18 ` Rameshwar Sahu
0 siblings, 0 replies; 3+ messages in thread
From: Rameshwar Sahu @ 2015-09-25 7:18 UTC (permalink / raw)
To: Vinod Koul, dan.j.williams-ral2JQCrhuEAvxtiuMwx3w
Cc: dmaengine-u79uwXL29TY76Z2rM5mHXA, Arnd Bergmann,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
jcm-H+wXaHxf7aLQT0dZR+AlfA, patches-qTEPVZfXA3Y,
Rameshwar Prasad Sahu
Hi Vinod,
On Wed, Sep 16, 2015 at 1:33 PM, Rameshwar Prasad Sahu <rsahu-qTEPVZfXA3Y@public.gmane.org> wrote:
> This patch fixes an over flow issue with the TX ring descriptor. Each
> descriptor is 32B in size and an operation requires 2 of these
> descriptors.
>
> Signed-off-by: Rameshwar Prasad Sahu <rsahu-qTEPVZfXA3Y@public.gmane.org>
> ---
> drivers/dma/xgene-dma.c | 37 +++++++++++--------------------------
> 1 file changed, 11 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/dma/xgene-dma.c b/drivers/dma/xgene-dma.c
> index b23e8d5..21ba2cc 100644
> --- a/drivers/dma/xgene-dma.c
> +++ b/drivers/dma/xgene-dma.c
> @@ -59,7 +59,6 @@
> #define XGENE_DMA_RING_MEM_RAM_SHUTDOWN 0xD070
> #define XGENE_DMA_RING_BLK_MEM_RDY 0xD074
> #define XGENE_DMA_RING_BLK_MEM_RDY_VAL 0xFFFFFFFF
> -#define XGENE_DMA_RING_DESC_CNT(v) (((v) & 0x0001FFFE) >> 1)
> #define XGENE_DMA_RING_ID_GET(owner, num) (((owner) << 6) | (num))
> #define XGENE_DMA_RING_DST_ID(v) ((1 << 10) | (v))
> #define XGENE_DMA_RING_CMD_OFFSET 0x2C
> @@ -379,14 +378,6 @@ static u8 xgene_dma_encode_xor_flyby(u32 src_cnt)
> return flyby_type[src_cnt];
> }
>
> -static u32 xgene_dma_ring_desc_cnt(struct xgene_dma_ring *ring)
> -{
> - u32 __iomem *cmd_base = ring->cmd_base;
> - u32 ring_state = ioread32(&cmd_base[1]);
> -
> - return XGENE_DMA_RING_DESC_CNT(ring_state);
> -}
> -
> static void xgene_dma_set_src_buffer(__le64 *ext8, size_t *len,
> dma_addr_t *paddr)
> {
> @@ -659,15 +650,12 @@ static void xgene_dma_clean_running_descriptor(struct xgene_dma_chan *chan,
> dma_pool_free(chan->desc_pool, desc, desc->tx.phys);
> }
>
> -static int xgene_chan_xfer_request(struct xgene_dma_ring *ring,
> - struct xgene_dma_desc_sw *desc_sw)
> +static void xgene_chan_xfer_request(struct xgene_dma_chan *chan,
> + struct xgene_dma_desc_sw *desc_sw)
> {
> + struct xgene_dma_ring *ring = &chan->tx_ring;
> struct xgene_dma_desc_hw *desc_hw;
>
> - /* Check if can push more descriptor to hw for execution */
> - if (xgene_dma_ring_desc_cnt(ring) > (ring->slots - 2))
> - return -EBUSY;
> -
> /* Get hw descriptor from DMA tx ring */
> desc_hw = &ring->desc_hw[ring->head];
>
> @@ -694,11 +682,13 @@ static int xgene_chan_xfer_request(struct xgene_dma_ring *ring,
> memcpy(desc_hw, &desc_sw->desc2, sizeof(*desc_hw));
> }
>
> + /* Increment the pending transaction count */
> + chan->pending += ((desc_sw->flags &
> + XGENE_DMA_FLAG_64B_DESC) ? 2 : 1);
> +
> /* Notify the hw that we have descriptor ready for execution */
> iowrite32((desc_sw->flags & XGENE_DMA_FLAG_64B_DESC) ?
> 2 : 1, ring->cmd);
> -
> - return 0;
> }
>
> /**
> @@ -710,7 +700,6 @@ static int xgene_chan_xfer_request(struct xgene_dma_ring *ring,
> static void xgene_chan_xfer_ld_pending(struct xgene_dma_chan *chan)
> {
> struct xgene_dma_desc_sw *desc_sw, *_desc_sw;
> - int ret;
>
> /*
> * If the list of pending descriptors is empty, then we
> @@ -735,18 +724,13 @@ static void xgene_chan_xfer_ld_pending(struct xgene_dma_chan *chan)
> if (chan->pending >= chan->max_outstanding)
> return;
>
> - ret = xgene_chan_xfer_request(&chan->tx_ring, desc_sw);
> - if (ret)
> - return;
> + xgene_chan_xfer_request(chan, desc_sw);
>
> /*
> * Delete this element from ld pending queue and append it to
> * ld running queue
> */
> list_move_tail(&desc_sw->node, &chan->ld_running);
> -
> - /* Increment the pending transaction count */
> - chan->pending++;
> }
> }
>
> @@ -821,7 +805,8 @@ static void xgene_dma_cleanup_descriptors(struct xgene_dma_chan *chan)
> * Decrement the pending transaction count
> * as we have processed one
> */
> - chan->pending--;
> + chan->pending -= ((desc_sw->flags &
> + XGENE_DMA_FLAG_64B_DESC) ? 2 : 1);
>
> /*
> * Delete this node from ld running queue and append it to
> @@ -1482,7 +1467,7 @@ static int xgene_dma_create_chan_rings(struct xgene_dma_chan *chan)
> tx_ring->id, tx_ring->num, tx_ring->desc_vaddr);
>
> /* Set the max outstanding request possible to this channel */
> - chan->max_outstanding = rx_ring->slots;
> + chan->max_outstanding = tx_ring->slots;
>
> return ret;
> }
> --
> 1.8.2.1
>
Any comments on above patch ??
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dmaengine: xgene-dma: Fix overwritting DMA tx ring
2015-09-16 8:03 [PATCH] dmaengine: xgene-dma: Fix overwritting DMA tx ring Rameshwar Prasad Sahu
[not found] ` <1442390603-21129-1-git-send-email-rsahu-qTEPVZfXA3Y@public.gmane.org>
@ 2015-09-30 8:05 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2015-09-30 8:05 UTC (permalink / raw)
To: Rameshwar Prasad Sahu
Cc: dan.j.williams, dmaengine, arnd, linux-kernel, devicetree,
linux-arm-kernel, jcm, patches
On Wed, Sep 16, 2015 at 01:33:23PM +0530, Rameshwar Prasad Sahu wrote:
> This patch fixes an over flow issue with the TX ring descriptor. Each
> descriptor is 32B in size and an operation requires 2 of these
> descriptors.
Applied, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-09-30 8:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-16 8:03 [PATCH] dmaengine: xgene-dma: Fix overwritting DMA tx ring Rameshwar Prasad Sahu
[not found] ` <1442390603-21129-1-git-send-email-rsahu-qTEPVZfXA3Y@public.gmane.org>
2015-09-25 7:18 ` Rameshwar Sahu
2015-09-30 8:05 ` 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).