qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Alistair Francis <alistair.francis@xilinx.com>,
	"Edgar E . Iglesias" <edgar.iglesias@xilinx.com>,
	Prasad J Pandit <pjp@fedoraproject.org>,
	Peter Maydell <peter.maydell@linaro.org>,
	Andrew Baumann <Andrew.Baumann@microsoft.com>,
	Andrey Smirnov <andrew.smirnov@gmail.com>,
	Andrey Yurovsky <yurovsky@gmail.com>,
	Clement Deschamps <clement.deschamps@antfield.fr>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	qemu-devel@nongnu.org,
	"Peter Crosthwaite" <crosthwaite.peter@gmail.com>,
	"Sai Pavan Boddu" <saipava@xilinx.com>
Subject: [Qemu-devel] [PATCH 03/11] sdbus: add trace events
Date: Wed, 13 Dec 2017 17:44:28 -0300	[thread overview]
Message-ID: <20171213204436.5379-4-f4bug@amsat.org> (raw)
In-Reply-To: <20171213204436.5379-1-f4bug@amsat.org>

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/sd/core.c       | 25 +++++++++++++++++++++----
 hw/sd/trace-events |  6 ++++++
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/hw/sd/core.c b/hw/sd/core.c
index bd9350d21c..eda595973b 100644
--- a/hw/sd/core.c
+++ b/hw/sd/core.c
@@ -21,7 +21,14 @@
 
 #include "qemu/osdep.h"
 #include "hw/sd/sd.h"
+#include "qemu/cutils.h"
 #include "sd-internal.h"
+#include "trace.h"
+
+static inline const char *sdbus_name(SDBus *sdbus)
+{
+    return sdbus->qbus.name;
+}
 
 static SDState *get_card(SDBus *sdbus)
 {
@@ -37,20 +44,28 @@ static SDState *get_card(SDBus *sdbus)
 int sdbus_do_command(SDBus *sdbus, SDRequest *req, uint8_t *response)
 {
     SDState *card = get_card(sdbus);
+    int sz = 0;
+    char *hexbuf;
 
+    trace_sdbus_command(sdbus_name(sdbus), req->cmd, req->arg, req->crc);
     if (card) {
         SDCardClass *sc = SD_CARD_GET_CLASS(card);
 
-        return sc->do_command(card, req, response);
+        sz = sc->do_command(card, req, response);
+        hexbuf = qemu_hexbuf_strdup(response, sz, NULL, "resp: ");
+        trace_sdbus_command_response(sdbus_name(sdbus),
+                                     req->cmd, req->arg, hexbuf);
+        g_free(hexbuf);
     }
 
-    return 0;
+    return sz;
 }
 
 void sdbus_write_data(SDBus *sdbus, uint8_t value)
 {
     SDState *card = get_card(sdbus);
 
+    trace_sdbus_write(sdbus_name(sdbus), value);
     if (card) {
         SDCardClass *sc = SD_CARD_GET_CLASS(card);
 
@@ -61,14 +76,16 @@ void sdbus_write_data(SDBus *sdbus, uint8_t value)
 uint8_t sdbus_read_data(SDBus *sdbus)
 {
     SDState *card = get_card(sdbus);
+    uint8_t value = 0;
 
     if (card) {
         SDCardClass *sc = SD_CARD_GET_CLASS(card);
 
-        return sc->read_data(card);
+        value = sc->read_data(card);
     }
+    trace_sdbus_read(sdbus_name(sdbus), value);
 
-    return 0;
+    return value;
 }
 
 bool sdbus_data_ready(SDBus *sdbus)
diff --git a/hw/sd/trace-events b/hw/sd/trace-events
index 11f8fa4fc1..6b1dc7380f 100644
--- a/hw/sd/trace-events
+++ b/hw/sd/trace-events
@@ -1,5 +1,11 @@
 # See docs/devel/tracing.txt for syntax documentation.
 
+# hw/sd/core.c
+sdbus_command(const char *bus_name, uint8_t cmd, uint32_t arg, uint8_t crc) "@%s CMD%02d arg 0x%08x crc 0x%02x"
+sdbus_command_response(const char *bus_name, uint8_t cmd, uint32_t arg, const char *hexdump) "@%s CMD%02d arg 0x%08x %s"
+sdbus_read(const char *bus_name, uint8_t value) "@%s value 0x%02x"
+sdbus_write(const char *bus_name, uint8_t value) "@%s value 0x%02x"
+
 # hw/sd/sdhci.c
 sdhci_set_inserted(const char *level) "card state changed: %s"
 sdhci_send_command(uint8_t cmd, uint32_t arg) "sending CMD%02u ARG[0x%08x]"
-- 
2.15.1

  parent reply	other threads:[~2017-12-13 20:45 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-13 20:44 [Qemu-devel] [PATCH 00/11] QOM'ify SDBus, housekeeping Philippe Mathieu-Daudé
2017-12-13 20:44 ` [Qemu-devel] [RFC PATCH 01/11] util/cutils: add qemu_hexbuf_strdup(), yet another hexdump() Philippe Mathieu-Daudé
2017-12-13 20:44 ` [Qemu-devel] [PATCH 02/11] bcm2835_peripherals: move GPIO 'sdbus' property link from init() -> realize() Philippe Mathieu-Daudé
2017-12-15  0:58   ` Alistair Francis
2017-12-13 20:44 ` Philippe Mathieu-Daudé [this message]
2017-12-13 20:44 ` [Qemu-devel] [PATCH 04/11] sdbus: add sdbus_create_bus() to replace qbus_create_inplace() Philippe Mathieu-Daudé
2017-12-15  1:02   ` Alistair Francis
2017-12-13 20:44 ` [Qemu-devel] [PATCH 05/11] sdbus: add sdbus_create_slave() Philippe Mathieu-Daudé
2017-12-15  1:03   ` Alistair Francis
2017-12-13 20:44 ` [Qemu-devel] [PATCH 06/11] sdbus: rename SDCardClass -> SDSlaveClass Philippe Mathieu-Daudé
2017-12-15  1:04   ` Alistair Francis
2017-12-13 20:44 ` [Qemu-devel] [PATCH 07/11] sdbus: add a SD_BUS_SLAVE interface Philippe Mathieu-Daudé
2017-12-20 17:31   ` Philippe Mathieu-Daudé
2017-12-13 20:44 ` [Qemu-devel] [PATCH 08/11] sdbus: add a SD_BUS_MASTER interface Philippe Mathieu-Daudé
2017-12-13 20:44 ` [Qemu-devel] [PATCH 09/11] sdhci: implement the " Philippe Mathieu-Daudé
2017-12-13 20:44 ` [Qemu-devel] [PATCH 10/11] hw/sd/pxa2xx: " Philippe Mathieu-Daudé
2017-12-13 20:44 ` [Qemu-devel] [PATCH 11/11] hw/arm/xilinx_zynq: use sdbus_create_slave() to name the different SD busses Philippe Mathieu-Daudé

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=20171213204436.5379-4-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=Andrew.Baumann@microsoft.com \
    --cc=alistair.francis@xilinx.com \
    --cc=andrew.smirnov@gmail.com \
    --cc=clement.deschamps@antfield.fr \
    --cc=crosthwaite.peter@gmail.com \
    --cc=edgar.iglesias@xilinx.com \
    --cc=peter.maydell@linaro.org \
    --cc=pjp@fedoraproject.org \
    --cc=qemu-devel@nongnu.org \
    --cc=saipava@xilinx.com \
    --cc=yurovsky@gmail.com \
    /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 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).