qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: qemu-ppc@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	programmingkidx@gmail.com, mark.cave-ayland@ilande.co.uk,
	qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 05/17] PPC: Mac: Add debug prints in macio and dbdma code
Date: Mon,  1 Jul 2013 02:13:30 +0200	[thread overview]
Message-ID: <1372637622-50697-6-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1372637622-50697-1-git-send-email-agraf@suse.de>

The macio code is basically undebuggable as it stands today, with no
debug prints anywhere whatsoever. DBDMA was better, but I needed a
few more to create reasonable logs that tell me where breakage is.

Add a DPRINTF macro in the macio source file and add a bunch of debug
prints that are all disabled by default of course.

Signed-off-by: Alexander Graf <agraf@suse.de>

---

v1 -> v2:

  - use non-bitrotting DPRINTF for macio
  - clean up
---
 hw/ide/macio.c            | 43 ++++++++++++++++++++++++++++++++++++++++---
 hw/misc/macio/mac_dbdma.c | 14 +++++++++++---
 2 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/hw/ide/macio.c b/hw/ide/macio.c
index 82409dc..fceadfe 100644
--- a/hw/ide/macio.c
+++ b/hw/ide/macio.c
@@ -30,6 +30,22 @@
 
 #include <hw/ide/internal.h>
 
+/* debug MACIO */
+// #define DEBUG_MACIO
+
+#ifdef DEBUG_MACIO
+static const int debug_macio = 1;
+#else
+static const int debug_macio = 0;
+#endif
+
+#define MACIO_DPRINTF(fmt, ...) do { \
+        if (debug_macio) { \
+            printf(fmt , ## __VA_ARGS__); \
+        } \
+    } while (0)
+
+
 /***********************************************************/
 /* MacIO based PowerPC IDE */
 
@@ -48,6 +64,8 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret)
         goto done;
     }
 
+    MACIO_DPRINTF("io_buffer_size = %#x\n", s->io_buffer_size);
+
     if (s->io_buffer_size > 0) {
         m->aiocb = NULL;
         qemu_sglist_destroy(&s->sg);
@@ -59,15 +77,20 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret)
         s->io_buffer_index &= 0x7ff;
     }
 
-    if (s->packet_transfer_size <= 0)
+    if (s->packet_transfer_size <= 0) {
+        MACIO_DPRINTF("end of transfer\n");
         ide_atapi_cmd_ok(s);
+    }
 
     if (io->len == 0) {
+        MACIO_DPRINTF("end of DMA\n");
         goto done;
     }
 
     /* launch next transfer */
 
+    MACIO_DPRINTF("io->len = %#x\n", io->len);
+
     s->io_buffer_size = io->len;
 
     qemu_sglist_init(&s->sg, io->len / MACIO_PAGE_SIZE + 1,
@@ -76,12 +99,17 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret)
     io->addr += io->len;
     io->len = 0;
 
+    MACIO_DPRINTF("sector_num=%d size=%d, cmd_cmd=%d\n",
+                  (s->lba << 2) + (s->io_buffer_index >> 9),
+                  s->packet_transfer_size, s->dma_cmd);
+
     m->aiocb = dma_bdrv_read(s->bs, &s->sg,
                              (int64_t)(s->lba << 2) + (s->io_buffer_index >> 9),
                              pmac_ide_atapi_transfer_cb, io);
     return;
 
 done:
+    MACIO_DPRINTF("done DMA\n");
     bdrv_acct_done(s->bs, &s->acct);
     io->dma_end(opaque);
 }
@@ -95,6 +123,7 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)
     int64_t sector_num;
 
     if (ret < 0) {
+        MACIO_DPRINTF("DMA error\n");
         m->aiocb = NULL;
         qemu_sglist_destroy(&s->sg);
         ide_dma_error(s);
@@ -102,6 +131,7 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)
     }
 
     sector_num = ide_get_sector(s);
+    MACIO_DPRINTF("io_buffer_size = %#x\n", s->io_buffer_size);
     if (s->io_buffer_size > 0) {
         m->aiocb = NULL;
         qemu_sglist_destroy(&s->sg);
@@ -111,14 +141,14 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)
         s->nsector -= n;
     }
 
-    /* end of transfer ? */
     if (s->nsector == 0) {
+        MACIO_DPRINTF("end of transfer\n");
         s->status = READY_STAT | SEEK_STAT;
         ide_set_irq(s->bus);
     }
 
-    /* end of DMA ? */
     if (io->len == 0) {
+        MACIO_DPRINTF("end of DMA\n");
         goto done;
     }
 
@@ -127,12 +157,17 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)
     s->io_buffer_index = 0;
     s->io_buffer_size = io->len;
 
+    MACIO_DPRINTF("io->len = %#x\n", io->len);
+
     qemu_sglist_init(&s->sg, io->len / MACIO_PAGE_SIZE + 1,
                      &address_space_memory);
     qemu_sglist_add(&s->sg, io->addr, io->len);
     io->addr += io->len;
     io->len = 0;
 
+    MACIO_DPRINTF("sector_num=%" PRId64 " n=%d, nsector=%d, cmd_cmd=%d\n",
+                  sector_num, n, s->nsector, s->dma_cmd);
+
     switch (s->dma_cmd) {
     case IDE_DMA_READ:
         m->aiocb = dma_bdrv_read(s->bs, &s->sg, sector_num,
@@ -162,6 +197,8 @@ static void pmac_ide_transfer(DBDMA_io *io)
     MACIOIDEState *m = io->opaque;
     IDEState *s = idebus_active_if(&m->bus);
 
+    MACIO_DPRINTF("\n");
+
     s->io_buffer_size = 0;
     if (s->drive_kind == IDE_CD) {
         bdrv_acct_start(s->bs, &s->acct, io->len, BDRV_ACCT_READ);
diff --git a/hw/misc/macio/mac_dbdma.c b/hw/misc/macio/mac_dbdma.c
index ab174f5..1963b47 100644
--- a/hw/misc/macio/mac_dbdma.c
+++ b/hw/misc/macio/mac_dbdma.c
@@ -224,7 +224,7 @@ static void conditional_interrupt(DBDMA_channel *ch)
     uint32_t status;
     int cond;
 
-    DBDMA_DPRINTF("conditional_interrupt\n");
+    DBDMA_DPRINTF("%s\n", __func__);
 
     intr = le16_to_cpu(current->command) & INTR_MASK;
 
@@ -233,6 +233,7 @@ static void conditional_interrupt(DBDMA_channel *ch)
         return;
     case INTR_ALWAYS: /* always interrupt */
         qemu_irq_raise(ch->irq);
+        DBDMA_DPRINTF("%s: raise\n", __func__);
         return;
     }
 
@@ -245,12 +246,16 @@ static void conditional_interrupt(DBDMA_channel *ch)
 
     switch(intr) {
     case INTR_IFSET:  /* intr if condition bit is 1 */
-        if (cond)
+        if (cond) {
             qemu_irq_raise(ch->irq);
+            DBDMA_DPRINTF("%s: raise\n", __func__);
+        }
         return;
     case INTR_IFCLR:  /* intr if condition bit is 0 */
-        if (!cond)
+        if (!cond) {
             qemu_irq_raise(ch->irq);
+            DBDMA_DPRINTF("%s: raise\n", __func__);
+        }
         return;
     }
 }
@@ -368,6 +373,8 @@ static void dbdma_end(DBDMA_io *io)
     DBDMA_channel *ch = io->channel;
     dbdma_cmd *current = &ch->current;
 
+    DBDMA_DPRINTF("%s\n", __func__);
+
     if (conditional_wait(ch))
         goto wait;
 
@@ -422,6 +429,7 @@ static void start_input(DBDMA_channel *ch, int key, uint32_t addr,
      * are not implemented in the mac-io chip
      */
 
+    DBDMA_DPRINTF("addr 0x%x key 0x%x\n", addr, key);
     if (!addr || key > KEY_STREAM3) {
         kill_channel(ch);
         return;
-- 
1.8.1.4

  parent reply	other threads:[~2013-07-01  0:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-01  0:13 [Qemu-devel] [PATCH 00/17] PPC: Mac OS X guest bringup v2 Alexander Graf
2013-07-01  0:13 ` [Qemu-devel] [PATCH 01/17] PPC: Mac: Fix guest exported tbfreq values Alexander Graf
2013-07-01  0:13 ` [Qemu-devel] [PATCH 02/17] PPC: g3beige: Move secondary IDE bus to mac-io Alexander Graf
2013-07-01  0:13 ` [Qemu-devel] [PATCH 03/17] PPC: Macio: Replace tabs with spaces Alexander Graf
2013-07-01  0:13 ` [Qemu-devel] [PATCH 04/17] PPC: dbdma: " Alexander Graf
2013-07-01  0:13 ` Alexander Graf [this message]
2013-07-01  0:13 ` [Qemu-devel] [PATCH 06/17] PPC: dbdma: Fix debug print Alexander Graf
2013-07-01  0:13 ` [Qemu-devel] [PATCH 07/17] PPC: dbdma: Allow new commands in RUN state Alexander Graf
2013-07-01  0:13 ` [Qemu-devel] [PATCH 08/17] PPC: dbdma: Move defines into header file Alexander Graf
2013-07-01  0:13 ` [Qemu-devel] [PATCH 09/17] PPC: dbdma: Introduce kick function Alexander Graf
2013-07-01  0:13 ` [Qemu-devel] [PATCH 10/17] PPC: dbdma: Move static bh variable to device struct Alexander Graf
2013-07-01  0:13 ` [Qemu-devel] [PATCH 11/17] PPC: dbdma: macio: Add DMA callback Alexander Graf
2013-07-01  0:13 ` [Qemu-devel] [PATCH 12/17] PPC: dbdma: Move processing to io Alexander Graf
2013-07-01  0:13 ` [Qemu-devel] [PATCH 13/17] PPC: dbdma: Wait for DMA until we have data Alexander Graf
2013-07-01  0:13 ` [Qemu-devel] [PATCH 14/17] PPC: dbdma: Support unaligned DMA access Alexander Graf
2013-07-17  9:09   ` Kevin Wolf
2013-07-01  0:13 ` [Qemu-devel] [PATCH 15/17] PPC: Add timer handler for newworld mac-io Alexander Graf
2013-07-01  0:13 ` [Qemu-devel] [PATCH 17/17] PPC: dbdma: Support more multi-issue DMA requests Alexander Graf
2013-07-11 14:22 ` [Qemu-devel] [Qemu-ppc] [PATCH 00/17] PPC: Mac OS X guest bringup v2 Alexander Graf

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=1372637622-50697-6-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --cc=kwolf@redhat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=programmingkidx@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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 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).