qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL v1 0/3] Xilinx DMA/Ethernet updates
@ 2024-06-18 15:49 Edgar E. Iglesias
  2024-06-18 15:49 ` [PULL v1 1/3] hw/dma: Enhance error handling in loading description Edgar E. Iglesias
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Edgar E. Iglesias @ 2024-06-18 15:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: richard.henderson, edgar.iglesias

From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>

The following changes since commit 900536d3e97aed7fdd9cb4dadd3bf7023360e819:

  Merge tag 'dirtylimit-dirtyrate-pull-request-20240617' of https://github.com/newfriday/qemu into staging (2024-06-17 11:40:24 -0700)

are available in the Git repository at:

  https://gitlab.com/edgar.iglesias/qemu.git tags/edgar/xilinx-queue-2024-06-17.for-upstream

for you to fetch changes up to 3a6d374b754b4b345195ff6846eeaffedc96a7c5:

  hw/net: Fix the transmission return size (2024-06-18 14:52:05 +0200)

----------------------------------------------------------------
Xilinx queue:

hw/dma: Add error handling for loading descriptions failing (Fea Wang)

----------------------------------------------------------------
Fea.Wang (3):
      hw/dma: Enhance error handling in loading description
      hw/dma: Add a trace log for a description loading failure
      hw/net: Fix the transmission return size

 hw/dma/trace-events     |  3 +++
 hw/dma/xilinx_axidma.c  | 33 +++++++++++++++++++++++++++++----
 hw/net/xilinx_axienet.c |  2 +-
 3 files changed, 33 insertions(+), 5 deletions(-)

-- 
2.43.0



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

* [PULL v1 1/3] hw/dma: Enhance error handling in loading description
  2024-06-18 15:49 [PULL v1 0/3] Xilinx DMA/Ethernet updates Edgar E. Iglesias
@ 2024-06-18 15:49 ` Edgar E. Iglesias
  2024-06-18 15:49 ` [PULL v1 2/3] hw/dma: Add a trace log for a description loading failure Edgar E. Iglesias
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Edgar E. Iglesias @ 2024-06-18 15:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: richard.henderson, edgar.iglesias, Fea.Wang, Frank Chang,
	Edgar E. Iglesias, Alistair Francis, Peter Maydell, qemu-arm

From: "Fea.Wang" <fea.wang@sifive.com>

Loading a description from memory may cause a bus-error. In this
case, the DMA should stop working, set the error flag, and return
the failure value.

When calling the loading a description function, it should be noticed
that the function may return a failure value. Breaking the loop in this
case is one of the possible ways to handle it.

Signed-off-by: Fea.Wang <fea.wang@sifive.com>
Reviewed-by: Frank Chang <frank.chang@sifive.com>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
---
 hw/dma/xilinx_axidma.c | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
index 0ae056ed06..ad307994c2 100644
--- a/hw/dma/xilinx_axidma.c
+++ b/hw/dma/xilinx_axidma.c
@@ -71,8 +71,11 @@ enum {
 enum {
     DMASR_HALTED = 1,
     DMASR_IDLE  = 2,
+    DMASR_SLVERR = 1 << 5,
+    DMASR_DECERR = 1 << 6,
     DMASR_IOC_IRQ  = 1 << 12,
     DMASR_DLY_IRQ  = 1 << 13,
+    DMASR_ERR_IRQ  = 1 << 14,
 
     DMASR_IRQ_MASK = 7 << 12
 };
@@ -190,17 +193,32 @@ static inline int streamid_from_addr(hwaddr addr)
     return sid;
 }
 
-static void stream_desc_load(struct Stream *s, hwaddr addr)
+static MemTxResult stream_desc_load(struct Stream *s, hwaddr addr)
 {
     struct SDesc *d = &s->desc;
 
-    address_space_read(&s->dma->as, addr, MEMTXATTRS_UNSPECIFIED, d, sizeof *d);
+    MemTxResult result = address_space_read(&s->dma->as,
+                                            addr, MEMTXATTRS_UNSPECIFIED,
+                                            d, sizeof *d);
+    if (result != MEMTX_OK) {
+        if (result == MEMTX_DECODE_ERROR) {
+            s->regs[R_DMASR] |= DMASR_DECERR;
+        } else {
+            s->regs[R_DMASR] |= DMASR_SLVERR;
+        }
+
+        s->regs[R_DMACR] &= ~DMACR_RUNSTOP;
+        s->regs[R_DMASR] |= DMASR_HALTED;
+        s->regs[R_DMASR] |= DMASR_ERR_IRQ;
+        return result;
+    }
 
     /* Convert from LE into host endianness.  */
     d->buffer_address = le64_to_cpu(d->buffer_address);
     d->nxtdesc = le64_to_cpu(d->nxtdesc);
     d->control = le32_to_cpu(d->control);
     d->status = le32_to_cpu(d->status);
+    return result;
 }
 
 static void stream_desc_store(struct Stream *s, hwaddr addr)
@@ -279,7 +297,9 @@ static void stream_process_mem2s(struct Stream *s, StreamSink *tx_data_dev,
     }
 
     while (1) {
-        stream_desc_load(s, s->regs[R_CURDESC]);
+        if (MEMTX_OK != stream_desc_load(s, s->regs[R_CURDESC])) {
+            break;
+        }
 
         if (s->desc.status & SDESC_STATUS_COMPLETE) {
             s->regs[R_DMASR] |= DMASR_HALTED;
@@ -336,7 +356,9 @@ static size_t stream_process_s2mem(struct Stream *s, unsigned char *buf,
     }
 
     while (len) {
-        stream_desc_load(s, s->regs[R_CURDESC]);
+        if (MEMTX_OK != stream_desc_load(s, s->regs[R_CURDESC])) {
+            break;
+        }
 
         if (s->desc.status & SDESC_STATUS_COMPLETE) {
             s->regs[R_DMASR] |= DMASR_HALTED;
-- 
2.43.0



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

* [PULL v1 2/3] hw/dma: Add a trace log for a description loading failure
  2024-06-18 15:49 [PULL v1 0/3] Xilinx DMA/Ethernet updates Edgar E. Iglesias
  2024-06-18 15:49 ` [PULL v1 1/3] hw/dma: Enhance error handling in loading description Edgar E. Iglesias
@ 2024-06-18 15:49 ` Edgar E. Iglesias
  2024-06-18 15:49 ` [PULL v1 3/3] hw/net: Fix the transmission return size Edgar E. Iglesias
  2024-06-19  2:44 ` [PULL v1 0/3] Xilinx DMA/Ethernet updates Richard Henderson
  3 siblings, 0 replies; 5+ messages in thread
From: Edgar E. Iglesias @ 2024-06-18 15:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: richard.henderson, edgar.iglesias, Fea.Wang, Frank Chang,
	Philippe Mathieu-Daudé, Edgar E. Iglesias, Alistair Francis,
	Peter Maydell, qemu-arm

From: "Fea.Wang" <fea.wang@sifive.com>

Due to a description loading failure, adding a trace log makes observing
the DMA behavior easy.

Signed-off-by: Fea.Wang <fea.wang@sifive.com>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
Reviewed-by: Frank Chang <frank.chang@sifive.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
---
 hw/dma/trace-events    | 3 +++
 hw/dma/xilinx_axidma.c | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/hw/dma/trace-events b/hw/dma/trace-events
index 3c47df54e4..4c09790f9a 100644
--- a/hw/dma/trace-events
+++ b/hw/dma/trace-events
@@ -44,3 +44,6 @@ pl330_debug_exec_stall(void) "stall of debug instruction not implemented"
 pl330_iomem_write(uint32_t offset, uint32_t value) "addr: 0x%08"PRIx32" data: 0x%08"PRIx32
 pl330_iomem_write_clr(int i) "event interrupt lowered %d"
 pl330_iomem_read(uint32_t addr, uint32_t data) "addr: 0x%08"PRIx32" data: 0x%08"PRIx32
+
+# xilinx_axidma.c
+xilinx_axidma_loading_desc_fail(uint32_t res) "error:%u"
diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
index ad307994c2..c9cfc3169b 100644
--- a/hw/dma/xilinx_axidma.c
+++ b/hw/dma/xilinx_axidma.c
@@ -36,6 +36,7 @@
 #include "sysemu/dma.h"
 #include "hw/stream.h"
 #include "qom/object.h"
+#include "trace.h"
 
 #define D(x)
 
@@ -201,6 +202,8 @@ static MemTxResult stream_desc_load(struct Stream *s, hwaddr addr)
                                             addr, MEMTXATTRS_UNSPECIFIED,
                                             d, sizeof *d);
     if (result != MEMTX_OK) {
+        trace_xilinx_axidma_loading_desc_fail(result);
+
         if (result == MEMTX_DECODE_ERROR) {
             s->regs[R_DMASR] |= DMASR_DECERR;
         } else {
-- 
2.43.0



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

* [PULL v1 3/3] hw/net: Fix the transmission return size
  2024-06-18 15:49 [PULL v1 0/3] Xilinx DMA/Ethernet updates Edgar E. Iglesias
  2024-06-18 15:49 ` [PULL v1 1/3] hw/dma: Enhance error handling in loading description Edgar E. Iglesias
  2024-06-18 15:49 ` [PULL v1 2/3] hw/dma: Add a trace log for a description loading failure Edgar E. Iglesias
@ 2024-06-18 15:49 ` Edgar E. Iglesias
  2024-06-19  2:44 ` [PULL v1 0/3] Xilinx DMA/Ethernet updates Richard Henderson
  3 siblings, 0 replies; 5+ messages in thread
From: Edgar E. Iglesias @ 2024-06-18 15:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: richard.henderson, edgar.iglesias, Fea.Wang, Frank Chang,
	Edgar E. Iglesias, Alistair Francis, Peter Maydell, Jason Wang,
	qemu-arm

From: "Fea.Wang" <fea.wang@sifive.com>

Fix the transmission return size because not all bytes could be
transmitted successfully. So, return a successful length instead of a
constant value.

Signed-off-by: Fea.Wang <fea.wang@sifive.com>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
Reviewed-by: Frank Chang <frank.chang@sifive.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
---
 hw/net/xilinx_axienet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/net/xilinx_axienet.c b/hw/net/xilinx_axienet.c
index 7d1fd37b4a..05d41bd548 100644
--- a/hw/net/xilinx_axienet.c
+++ b/hw/net/xilinx_axienet.c
@@ -847,7 +847,7 @@ static ssize_t eth_rx(NetClientState *nc, const uint8_t *buf, size_t size)
     axienet_eth_rx_notify(s);
 
     enet_update_irq(s);
-    return size;
+    return s->rxpos;
 }
 
 static size_t
-- 
2.43.0



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

* Re: [PULL v1 0/3] Xilinx DMA/Ethernet updates
  2024-06-18 15:49 [PULL v1 0/3] Xilinx DMA/Ethernet updates Edgar E. Iglesias
                   ` (2 preceding siblings ...)
  2024-06-18 15:49 ` [PULL v1 3/3] hw/net: Fix the transmission return size Edgar E. Iglesias
@ 2024-06-19  2:44 ` Richard Henderson
  3 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2024-06-19  2:44 UTC (permalink / raw)
  To: Edgar E. Iglesias, qemu-devel; +Cc: edgar.iglesias

On 6/18/24 08:49, Edgar E. Iglesias wrote:
> From: "Edgar E. Iglesias"<edgar.iglesias@amd.com>
> 
> The following changes since commit 900536d3e97aed7fdd9cb4dadd3bf7023360e819:
> 
>    Merge tag 'dirtylimit-dirtyrate-pull-request-20240617' ofhttps://github.com/newfriday/qemu  into staging (2024-06-17 11:40:24 -0700)
> 
> are available in the Git repository at:
> 
>    https://gitlab.com/edgar.iglesias/qemu.git  tags/edgar/xilinx-queue-2024-06-17.for-upstream
> 
> for you to fetch changes up to 3a6d374b754b4b345195ff6846eeaffedc96a7c5:
> 
>    hw/net: Fix the transmission return size (2024-06-18 14:52:05 +0200)
> 
> ----------------------------------------------------------------
> Xilinx queue:
> 
> hw/dma: Add error handling for loading descriptions failing (Fea Wang)

Applied, thanks.  Please update https://wiki.qemu.org/ChangeLog/9.1 as appropriate.


r~



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

end of thread, other threads:[~2024-06-19  2:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-18 15:49 [PULL v1 0/3] Xilinx DMA/Ethernet updates Edgar E. Iglesias
2024-06-18 15:49 ` [PULL v1 1/3] hw/dma: Enhance error handling in loading description Edgar E. Iglesias
2024-06-18 15:49 ` [PULL v1 2/3] hw/dma: Add a trace log for a description loading failure Edgar E. Iglesias
2024-06-18 15:49 ` [PULL v1 3/3] hw/net: Fix the transmission return size Edgar E. Iglesias
2024-06-19  2:44 ` [PULL v1 0/3] Xilinx DMA/Ethernet updates Richard Henderson

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