All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
To: qemu-devel@nongnu.org, pbonzini@redhat.com, fam@euphon.net,
	laurent@vivier.eu
Subject: [PATCH 03/25] esp: fix esp_reg_read() trace event
Date: Wed, 30 Dec 2020 15:37:23 +0000	[thread overview]
Message-ID: <20201230153745.30241-4-mark.cave-ayland@ilande.co.uk> (raw)
In-Reply-To: <20201230153745.30241-1-mark.cave-ayland@ilande.co.uk>

Move the trace event to the end of the function so that it correctly reports
the returned value if it doesn't come directly from the rregs array.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/scsi/esp.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 5f2c352029..df15e3e7cf 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -595,9 +595,8 @@ static void parent_esp_reset(ESPState *s, int irq, int level)
 
 uint64_t esp_reg_read(ESPState *s, uint32_t saddr)
 {
-    uint32_t old_val;
+    uint32_t val;
 
-    trace_esp_mem_readb(saddr, s->rregs[saddr]);
     switch (saddr) {
     case ESP_FIFO:
         if ((s->rregs[ESP_RSTAT] & STAT_PIO_MASK) == 0) {
@@ -612,13 +611,14 @@ uint64_t esp_reg_read(ESPState *s, uint32_t saddr)
             s->ti_rptr = 0;
             s->ti_wptr = 0;
         }
+        val = s->rregs[ESP_FIFO];
         break;
     case ESP_RINTR:
         /*
          * Clear sequence step, interrupt register and all status bits
          * except TC
          */
-        old_val = s->rregs[ESP_RINTR];
+        val = s->rregs[ESP_RINTR];
         s->rregs[ESP_RINTR] = 0;
         s->rregs[ESP_RSTAT] &= ~STAT_TC;
         s->rregs[ESP_RSEQ] = SEQ_CD;
@@ -627,16 +627,22 @@ uint64_t esp_reg_read(ESPState *s, uint32_t saddr)
             esp_report_command_complete(s, s->deferred_status);
             s->deferred_complete = false;
         }
-        return old_val;
+        break;
     case ESP_TCHI:
         /* Return the unique id if the value has never been written */
         if (!s->tchi_written) {
-            return s->chip_id;
+            val = s->chip_id;
+        } else {
+            val = s->rregs[saddr];
         }
+        break;
     default:
+        val = s->rregs[saddr];
         break;
     }
-    return s->rregs[saddr];
+
+    trace_esp_mem_readb(saddr, val);
+    return val;
 }
 
 void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t val)
-- 
2.20.1



  parent reply	other threads:[~2020-12-30 15:43 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-30 15:37 [PATCH 00/25] esp: consolidate PDMA transfer buffers Mark Cave-Ayland
2020-12-30 15:37 ` [PATCH 01/25] esp: checkpatch fixes Mark Cave-Ayland
2021-01-01 16:53   ` Philippe Mathieu-Daudé
2020-12-30 15:37 ` [PATCH 02/25] esp: add trace event when receiving a TI command Mark Cave-Ayland
2021-01-01 16:54   ` Philippe Mathieu-Daudé
2020-12-30 15:37 ` Mark Cave-Ayland [this message]
2021-01-01 16:54   ` [PATCH 03/25] esp: fix esp_reg_read() trace event Philippe Mathieu-Daudé
2020-12-30 15:37 ` [PATCH 04/25] esp: add PDMA trace events Mark Cave-Ayland
2021-01-01 16:55   ` Philippe Mathieu-Daudé
2020-12-30 15:37 ` [PATCH 05/25] esp: determine transfer direction directly from SCSI phase Mark Cave-Ayland
2020-12-30 15:37 ` [PATCH 06/25] esp: introduce esp_get_tc() and esp_set_tc() Mark Cave-Ayland
2021-01-01 16:56   ` Philippe Mathieu-Daudé
2020-12-30 15:37 ` [PATCH 07/25] esp: introduce esp_get_stc() Mark Cave-Ayland
2020-12-30 15:37 ` [PATCH 08/25] esp: apply transfer length adjustment when STC is zero at TC load time Mark Cave-Ayland
2020-12-30 15:37 ` [PATCH 09/25] esp: remove dma_counter from ESPState Mark Cave-Ayland
2020-12-30 15:37 ` [PATCH 10/25] esp: remove dma_left " Mark Cave-Ayland
2020-12-30 15:37 ` [PATCH 11/25] esp: remove minlen restriction in handle_ti Mark Cave-Ayland
2020-12-30 15:37 ` [PATCH 12/25] esp: introduce esp_pdma_read() and esp_pdma_write() functions Mark Cave-Ayland
2020-12-30 15:37 ` [PATCH 13/25] esp: use pdma_origin directly in esp_pdma_read()/esp_pdma_write() Mark Cave-Ayland
2020-12-30 15:37 ` [PATCH 14/25] esp: move pdma_len and TC logic into esp_pdma_read()/esp_pdma_write() Mark Cave-Ayland
2020-12-30 15:37 ` [PATCH 15/25] esp: accumulate SCSI commands for PDMA transfers in cmdbuf instead of pdma_buf Mark Cave-Ayland
2020-12-30 15:37 ` [PATCH 16/25] esp: remove redundant pdma_start from ESPState Mark Cave-Ayland
2020-12-30 15:37 ` [PATCH 17/25] esp: move PDMA length adjustments into esp_pdma_read()/esp_pdma_write() Mark Cave-Ayland
2020-12-30 15:37 ` [PATCH 18/25] esp: use ti_wptr/ti_rptr to manage the current FIFO position for PDMA Mark Cave-Ayland
2020-12-30 15:37 ` [PATCH 19/25] esp: use in-built TC to determine PDMA transfer length Mark Cave-Ayland
2020-12-30 15:37 ` [PATCH 20/25] esp: remove CMD pdma_origin Mark Cave-Ayland
2020-12-30 15:37 ` [PATCH 21/25] esp: rename get_cmd_cb() to esp_select() Mark Cave-Ayland
2021-01-01 16:57   ` Philippe Mathieu-Daudé
2020-12-30 15:37 ` [PATCH 22/25] esp: fix PDMA target selection Mark Cave-Ayland
2020-12-30 15:37 ` [PATCH 23/25] esp: use FIFO for PDMA transfers between initiator and device Mark Cave-Ayland
2020-12-30 15:37 ` [PATCH 24/25] esp: remove pdma_origin from ESPState Mark Cave-Ayland
2020-12-30 15:37 ` [PATCH 25/25] esp: add 4 byte PDMA read and write transfers Mark Cave-Ayland
2021-01-06 15:18 ` [PATCH 00/25] esp: consolidate PDMA transfer buffers Mark Cave-Ayland
2021-01-13 14:39 ` Paolo Bonzini
2021-01-13 19:29   ` Mark Cave-Ayland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201230153745.30241-4-mark.cave-ayland@ilande.co.uk \
    --to=mark.cave-ayland@ilande.co.uk \
    --cc=fam@euphon.net \
    --cc=laurent@vivier.eu \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.