Skip to contentSkip to conversation

xilinx_spips: Make dma transactions as per dma_burst_size

PATCH Superseded Sai Pavan Boddu 3 participants 3 messages Jun 14, 2018 – Jun 19, 2018 Arm/Zynq architecture

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xilinx_spips: Make dma transactions as per dma_burst_size

Qspi dma has a burst length of 64 bytes, So limit transaction length to 64 max.

---
 hw/ssi/xilinx_spips.c         | 18 +++++++++++++++---
 include/hw/ssi/xilinx_spips.h |  3 ++-
 2 files changed, 17 insertions(+), 4 deletions(-)
hw/ssi/xilinx_spips.c +15 -3
index 03f5fae..ea006c4 100644
@@ -851,12 +851,17 @@ static void xlnx_zynqmp_qspips_notify(void *opaque)
     {
         size_t ret;
         uint32_t num;
-        const void *rxd = pop_buf(recv_fifo, 4, &num);
+        const void *rxd;
+        int len;
+
+        len = recv_fifo->num >= rq->dma_burst_size ? rq->dma_burst_size :
+                                                   recv_fifo->num;
+        rxd = pop_buf(recv_fifo, len, &num);
 
         memcpy(rq->dma_buf, rxd, num);
 
-        ret = stream_push(rq->dma, rq->dma_buf, 4);
-        assert(ret == 4);
+        ret = stream_push(rq->dma, rq->dma_buf, num);
+        assert(ret == num);
         xlnx_zynqmp_qspips_check_flush(rq);
     }
 }
@@ -1337,6 +1342,7 @@ static void xlnx_zynqmp_qspips_realize(DeviceState *dev, Error **errp)
     fifo8_create(&s->rx_fifo_g, xsc->rx_fifo_size);
     fifo8_create(&s->tx_fifo_g, xsc->tx_fifo_size);
     fifo32_create(&s->fifo_g, 32);
+    s->dma_buf = g_new0(uint8_t, s->dma_burst_size);
 }
 
 static void xlnx_zynqmp_qspips_init(Object *obj)
@@ -1411,6 +1417,11 @@ static const VMStateDescription vmstate_xlnx_zynqmp_qspips = {
     }
 };
 
+static Property xilinx_zynqmp_qspips_properties[] = {
+    DEFINE_PROP_UINT32("dma-burst-size", XlnxZynqMPQSPIPS, dma_burst_size, 64),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static Property xilinx_qspips_properties[] = {
     /* We had to turn this off for 2.10 as it is not compatible with migration.
      * It can be enabled but will prevent the device to be migrated.
@@ -1463,6 +1474,7 @@ static void xlnx_zynqmp_qspips_class_init(ObjectClass *klass, void * data)
     dc->realize = xlnx_zynqmp_qspips_realize;
     dc->reset = xlnx_zynqmp_qspips_reset;
     dc->vmsd = &vmstate_xlnx_zynqmp_qspips;
+    dc->props = xilinx_zynqmp_qspips_properties;
     xsc->reg_ops = &xlnx_zynqmp_qspips_ops;
     xsc->rx_fifo_size = RXFF_A_Q;
     xsc->tx_fifo_size = TXFF_A_Q;
include/hw/ssi/xilinx_spips.h +2 -1
index d398a4e..cca1813 100644
@@ -95,7 +95,8 @@ typedef struct {
     XilinxQSPIPS parent_obj;
 
     StreamSlave *dma;
-    uint8_t dma_buf[4];
+    uint8_t *dma_buf;
+    uint32_t dma_burst_size;
     int gqspi_irqline;
 
     uint32_t regs[XLNX_ZYNQMP_SPIPS_R_MAX];
Signature · 1 line
2.7.4
#1 lore raw
Quoted 2 lines · Sai Pavan Boddu

Qspi dma has a burst length of 64 bytes, So limit transaction length to 64 max.

Hi Sai,

Is this a v2 or a resend?

Quoted 33 lines
---
 hw/ssi/xilinx_spips.c         | 18 +++++++++++++++---
 include/hw/ssi/xilinx_spips.h |  3 ++-
 2 files changed, 17 insertions(+), 4 deletions(-)
hw/ssi/xilinx_spips.c +8 -3
index 03f5fae..ea006c4 100644
@@ -851,12 +851,17 @@ static void xlnx_zynqmp_qspips_notify(void *opaque)
     {
         size_t ret;
         uint32_t num;
-        const void *rxd = pop_buf(recv_fifo, 4, &num);
+        const void *rxd;
+        int len;
+
+        len = recv_fifo->num >= rq->dma_burst_size ? rq->dma_burst_size :
+                                                   recv_fifo->num;
+        rxd = pop_buf(recv_fifo, len, &num);
 
         memcpy(rq->dma_buf, rxd, num);
 
-        ret = stream_push(rq->dma, rq->dma_buf, 4);
-        assert(ret == 4);
+        ret = stream_push(rq->dma, rq->dma_buf, num);
+        assert(ret == num);
         xlnx_zynqmp_qspips_check_flush(rq);
     }
 }

hw/ssi/xilinx_spips.c static void xlnx_zynqmp_qspips_realize(DeviceState *dev, Error **errp) · line 1345

Quoted 4 lines
hw/ssi/xilinx_spips.c +1 -0
@@ -1337,6 +1342,7 @@ static void xlnx_zynqmp_qspips_realize(DeviceState *dev, Error **errp)
     fifo8_create(&s->rx_fifo_g, xsc->rx_fifo_size);
     fifo8_create(&s->tx_fifo_g, xsc->tx_fifo_size);
     fifo32_create(&s->fifo_g, 32);
+    s->dma_buf = g_new0(uint8_t, s->dma_burst_size);

This would need to be free'd somewhere.
But I think you should put a reasonably small limit on the burst size that users can configure and then you can allocate this as an array in XlnxZynqMPQSPIPS.

hw/ssi/xilinx_spips.c static const VMStateDescription vmstate_xlnx_zynqmp_qspips = { · line 1421

Quoted 9 lines
hw/ssi/xilinx_spips.c +2 -0
 }
 
 static void xlnx_zynqmp_qspips_init(Object *obj)
@@ -1411,6 +1417,11 @@ static const VMStateDescription vmstate_xlnx_zynqmp_qspips = {
     }
 };
 
+static Property xilinx_zynqmp_qspips_properties[] = {
+    DEFINE_PROP_UINT32("dma-burst-size", XlnxZynqMPQSPIPS, dma_burst_size, 64),

You need to limit this so users dont pick 4G. Perhaps 2 or 4K max.

Cheers,
Edgar

Quoted 31 lines
hw/ssi/xilinx_spips.c +4 -0
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static Property xilinx_qspips_properties[] = {
     /* We had to turn this off for 2.10 as it is not compatible with migration.
      * It can be enabled but will prevent the device to be migrated.
@@ -1463,6 +1474,7 @@ static void xlnx_zynqmp_qspips_class_init(ObjectClass *klass, void * data)
     dc->realize = xlnx_zynqmp_qspips_realize;
     dc->reset = xlnx_zynqmp_qspips_reset;
     dc->vmsd = &vmstate_xlnx_zynqmp_qspips;
+    dc->props = xilinx_zynqmp_qspips_properties;
     xsc->reg_ops = &xlnx_zynqmp_qspips_ops;
     xsc->rx_fifo_size = RXFF_A_Q;
     xsc->tx_fifo_size = TXFF_A_Q;
include/hw/ssi/xilinx_spips.h +2 -1
index d398a4e..cca1813 100644
@@ -95,7 +95,8 @@ typedef struct {
     XilinxQSPIPS parent_obj;
 
     StreamSlave *dma;
-    uint8_t dma_buf[4];
+    uint8_t *dma_buf;
+    uint32_t dma_burst_size;
     int gqspi_irqline;
 
     uint32_t regs[XLNX_ZYNQMP_SPIPS_R_MAX];
Signature · 1 line
2.7.4
#2 lore raw

Hi Edgar,

I got your suggestion below. Will be sending a V2 asap.

Thanks,
Sai Pavan

Quoted 114 lines

-----Original Message-----
From: Edgar E. Iglesias [mailto:[email protected]]
Sent: Thursday, June 14, 2018 4:55 PM
To: Sai Pavan Boddu <[email protected]>
Cc: [email protected]; Alistair Francis <[email protected]>; Peter Crosthwaite <[email protected]>; Peter Maydell <[email protected]>; Francisco Iglesias <[email protected]>
Subject: Re: [PATCH] xilinx_spips: Make dma transactions as per dma_burst_size

Quoted 3 lines · Sai Pavan Boddu

Qspi dma has a burst length of 64 bytes, So limit transaction length to
64 max.

Hi Sai,

Is this a v2 or a resend?

hw/ssi/xilinx_spips.c static void xlnx_zynqmp_qspips_notify(void

Quoted 12 lines
---
 hw/ssi/xilinx_spips.c         | 18 +++++++++++++++---
 include/hw/ssi/xilinx_spips.h |  3 ++-
 2 files changed, 17 insertions(+), 4 deletions(-)
hw/ssi/xilinx_spips.c index renamed from hw/ssi/xilinx_spips.c +0 -0

03f5fae..ea006c4 100644

hw/ssi/xilinx_spips.c +0 -0
@@ -851,12 +851,17 @@ static void xlnx_zynqmp_qspips_notify(void

*opaque)

hw/ssi/xilinx_spips.c static void xlnx_zynqmp_qspips_realize(DeviceState

Quoted 21 lines
hw/ssi/xilinx_spips.c +8 -3
     {
         size_t ret;
         uint32_t num;
-        const void *rxd = pop_buf(recv_fifo, 4, &num);
+        const void *rxd;
+        int len;
+
+        len = recv_fifo->num >= rq->dma_burst_size ? rq->dma_burst_size :
+                                                   recv_fifo->num;
+        rxd = pop_buf(recv_fifo, len, &num);
 
         memcpy(rq->dma_buf, rxd, num);
 
-        ret = stream_push(rq->dma, rq->dma_buf, 4);
-        assert(ret == 4);
+        ret = stream_push(rq->dma, rq->dma_buf, num);
+        assert(ret == num);
         xlnx_zynqmp_qspips_check_flush(rq);
     }
 }
@@ -1337,6 +1342,7 @@ static void xlnx_zynqmp_qspips_realize(DeviceState

*dev, Error **errp)

hw/ssi/xilinx_spips.c static void xlnx_zynqmp_qspips_realize(DeviceState *dev, Error **errp) · line 1345

Quoted 4 lines
hw/ssi/xilinx_spips.c +1 -0
     fifo8_create(&s->rx_fifo_g, xsc->rx_fifo_size);
     fifo8_create(&s->tx_fifo_g, xsc->tx_fifo_size);
     fifo32_create(&s->fifo_g, 32);
+    s->dma_buf = g_new0(uint8_t, s->dma_burst_size);

This would need to be free'd somewhere.
But I think you should put a reasonably small limit on the burst size that users can configure and then you can allocate this as an array in XlnxZynqMPQSPIPS.

hw/ssi/xilinx_spips.c

Quoted 10 lines
hw/ssi/xilinx_spips.c +0 -0
 }
 
 static void xlnx_zynqmp_qspips_init(Object *obj) @@ -1411,6 +1417,11
@@ static const VMStateDescription vmstate_xlnx_zynqmp_qspips = {
     }

};

hw/ssi/xilinx_spips.c +3 -0
+static Property xilinx_zynqmp_qspips_properties[] = {
+    DEFINE_PROP_UINT32("dma-burst-size", XlnxZynqMPQSPIPS,
+dma_burst_size, 64),

You need to limit this so users dont pick 4G. Perhaps 2 or 4K max.

Cheers,
Edgar

hw/ssi/xilinx_spips.c static void

Quoted 7 lines
hw/ssi/xilinx_spips.c +3 -0
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static Property xilinx_qspips_properties[] = {
     /* We had to turn this off for 2.10 as it is not compatible with migration.
      * It can be enabled but will prevent the device to be migrated.
@@ -1463,6 +1474,7 @@ static void

xlnx_zynqmp_qspips_class_init(ObjectClass *klass, void * data)

Quoted 24 lines
hw/ssi/xilinx_spips.c +1 -0
     dc->realize = xlnx_zynqmp_qspips_realize;
     dc->reset = xlnx_zynqmp_qspips_reset;
     dc->vmsd = &vmstate_xlnx_zynqmp_qspips;
+    dc->props = xilinx_zynqmp_qspips_properties;
     xsc->reg_ops = &xlnx_zynqmp_qspips_ops;
     xsc->rx_fifo_size = RXFF_A_Q;
     xsc->tx_fifo_size = TXFF_A_Q;
(quoted diff) +0 -0

b/include/hw/ssi/xilinx_spips.h index d398a4e..cca1813 100644

include/hw/ssi/xilinx_spips.h +2 -2
@@ -95,7 +95,8 @@ typedef struct {
     XilinxQSPIPS parent_obj;
 
     StreamSlave *dma;
-    uint8_t dma_buf[4];
+    uint8_t *dma_buf;
+    uint32_t dma_burst_size;
     int gqspi_irqline;
 
     uint32_t regs[XLNX_ZYNQMP_SPIPS_R_MAX];
--

2.7.4