xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: xen-devel@lists.xen.org
Cc: Ian Campbell <ian.campbell@citrix.com>,
	Anup Patel <anup.patel@linaro.org>,
	stefano.stabellini@eu.citrix.com, julien.grall@linaro.org,
	tim@xen.org, pranavkumar@linaro.org
Subject: [PATCH v2 13/15] xen: arm: Add debug keyhandler to dump the physical GIC state.
Date: Fri, 22 Nov 2013 16:24:32 +0000	[thread overview]
Message-ID: <1385137474-31245-13-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <foo>

Rename the existing gic_dump_info to gic_dump_info_guest reduce confusion.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
v2: s/gic_dump_info/gic_dump_info_guest/
---
 xen/arch/arm/domain.c     |    2 +-
 xen/arch/arm/gic.c        |   77 ++++++++++++++++++++++++++++++++++++++++++++-
 xen/include/asm-arm/gic.h |    2 +-
 3 files changed, 78 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 52d2403..59eea75 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -713,7 +713,7 @@ void arch_dump_domain_info(struct domain *d)
 
     for_each_vcpu ( d, v )
     {
-        gic_dump_info(v);
+        gic_dump_info_guest(v);
     }
 }
 
diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index 9711f5d..1f32e99 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -28,6 +28,7 @@
 #include <xen/softirq.h>
 #include <xen/list.h>
 #include <xen/device_tree.h>
+#include <xen/keyhandler.h>
 #include <asm/p2m.h>
 #include <asm/domain.h>
 #include <asm/platform.h>
@@ -386,6 +387,77 @@ int gic_irq_xlate(const u32 *intspec, unsigned int intsize,
     return 0;
 }
 
+
+static void do_dump_gic(unsigned char key)
+{
+    int irq;
+    printk("'%c' pressed -> dumping GIC state\n", key);
+
+    for ( irq = 0; irq < gic.lines; irq++ )
+    {
+        const char *type;
+        int type_nr, enable, pend, active, priority, target;
+        struct irq_desc *desc = irq_to_desc(irq);
+        uint8_t *bytereg;
+        uint32_t wordreg;
+
+        bytereg = (uint8_t *) (GICD + GICD_ITARGETSR);
+        target = bytereg[irq];
+
+        bytereg = (uint8_t *) (GICD + GICD_IPRIORITYR);
+        priority = bytereg[irq];
+
+        switch ( irq )
+        {
+        case 0 ... 15:
+            type = "SGI";
+            type_nr = irq;
+            target = 0x00; /* these are per-CPU */
+            break;
+        case 16 ... 31:
+            type = "PPI";
+            type_nr = irq - 16;
+            break;
+        default:
+            type = "SPI";
+            type_nr = irq - 32;
+            break;
+        }
+
+        wordreg = GICD[GICD_ISENABLER + irq / 32];
+        enable = !!(wordreg & (1u << (irq % 32)));
+        wordreg = GICD[GICD_ISPENDR + irq / 32];
+        pend = !!(wordreg & (1u << (irq % 32)));
+        wordreg = GICD[GICD_ISACTIVER + irq / 32];
+        active = !!(wordreg & (1u << (irq % 32)));
+
+        printk("IRQ%d %s%d: %c%c%c pri:%02x tgt:%02x ",
+               irq, type, type_nr,
+               enable ? 'e' : '-',
+               pend   ? 'p' : '-',
+               active ? 'a' : '-',
+               priority, target);
+
+        if ( desc->status & IRQ_GUEST )
+        {
+            struct domain *d = desc->action->dev_id;
+            printk("dom%d %s", d->domain_id, desc->action->name);
+        }
+        else
+        {
+            printk("Xen");
+        }
+        printk("\n");
+    }
+
+}
+
+static struct keyhandler dump_gic_keyhandler = {
+    .irq_callback = 0,
+    .u.fn = do_dump_gic,
+    .desc = "dump GIC state"
+};
+
 /* Set up the GIC */
 void __init gic_init(void)
 {
@@ -460,6 +532,9 @@ void __init gic_init(void)
     gic_hyp_init();
 
     spin_unlock(&gic.lock);
+
+    register_keyhandler('G', &dump_gic_keyhandler);
+
 }
 
 void send_SGI_mask(const cpumask_t *cpumask, enum gic_sgi sgi)
@@ -913,7 +988,7 @@ static void maintenance_interrupt(int irq, void *dev_id, struct cpu_user_regs *r
     }
 }
 
-void gic_dump_info(struct vcpu *v)
+void gic_dump_info_guest(struct vcpu *v)
 {
     int i;
     struct pending_irq *p;
diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h
index 41f0b3b..e6369fa 100644
--- a/xen/include/asm-arm/gic.h
+++ b/xen/include/asm-arm/gic.h
@@ -189,7 +189,7 @@ extern void send_SGI_self(enum gic_sgi sgi);
 extern void send_SGI_allbutself(enum gic_sgi sgi);
 
 /* print useful debug info */
-extern void gic_dump_info(struct vcpu *v);
+extern void gic_dump_info_guest(struct vcpu *v);
 
 /* Number of interrupt lines */
 extern unsigned int gic_number_lines(void);
-- 
1.7.10.4

  parent reply	other threads:[~2013-11-22 16:24 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <foo>
2013-11-22 16:24 ` [PATCH v2 01/15] xen: arm64: Add 8250 earlyprintk support Ian Campbell
2013-11-22 16:27   ` [PATCH 00/15] xen: arm initial support for xgene arm64 platform Ian Campbell
2013-11-22 17:02     ` George Dunlap
2013-11-22 17:09       ` Ian Campbell
2013-11-29 10:30         ` Ian Campbell
2013-11-22 16:29   ` [PATCH v2 01/15] xen: arm64: Add 8250 earlyprintk support Julien Grall
2013-11-22 16:24 ` [PATCH v2 02/15] xen: arm64: Add Basic Platform support for APM X-Gene Storm Ian Campbell
2013-11-22 16:35   ` Julien Grall
2013-11-22 16:43     ` Ian Campbell
2013-11-22 16:24 ` [PATCH v2 03/15] xen: arm64: Add APM implementor id to processor implementers Ian Campbell
2013-11-22 16:24 ` [PATCH v2 04/15] xen: arm: add a quirk to handle platforms with unusual GIC layout Ian Campbell
2013-11-22 16:46   ` Julien Grall
2013-11-22 17:03     ` Ian Campbell
2013-11-22 17:10       ` Julien Grall
2013-11-22 17:16         ` Ian Campbell
2013-11-22 16:46   ` George Dunlap
2013-11-22 16:24 ` [PATCH v2 05/15] xen: arm: allow platform code to select dom0 event channel irq Ian Campbell
2013-11-22 16:48   ` George Dunlap
2013-11-22 17:01   ` Julien Grall
2013-11-22 16:24 ` [PATCH v2 06/15] xen: arm64: Map xgene PCI memory regions and interrupts to dom0 Ian Campbell
2013-11-22 16:50   ` George Dunlap
2013-11-22 16:59   ` Julien Grall
2013-11-22 17:13     ` Ian Campbell
2013-11-22 17:17       ` Julien Grall
2013-11-22 16:24 ` [PATCH v2 07/15] xen: arm: include ns16550 driver on arm64 too Ian Campbell
2013-11-22 16:24 ` [PATCH v2 08/15] xen: arm: early logging of command line Ian Campbell
2013-11-22 17:04   ` Ian Campbell
2013-11-22 16:24 ` [PATCH v2 09/15] xen: arm: Handle cpus nodes with #address-cells > 1 Ian Campbell
2013-11-22 16:59   ` George Dunlap
2013-11-22 17:22   ` Julien Grall
2013-11-22 17:50     ` Ian Campbell
2013-11-22 16:24 ` [PATCH v2 10/15] xen: arm: Make register bit definitions unsigned Ian Campbell
2013-11-22 17:23   ` Julien Grall
2013-11-22 16:24 ` [PATCH v2 11/15] xen: arm: explicitly map 64 bit release address Ian Campbell
2013-11-22 16:24 ` [PATCH v2 12/15] xen: arm: enable synchronous console while starting secondary CPUs Ian Campbell
2013-11-22 17:36   ` Julien Grall
2013-11-22 17:49     ` Ian Campbell
2013-11-22 16:24 ` Ian Campbell [this message]
2013-11-22 16:37   ` [PATCH v2 13/15] xen: arm: Add debug keyhandler to dump the physical GIC state Ian Campbell
2013-11-22 16:24 ` [PATCH v2 14/15] xen: arm: improve early memory map readability Ian Campbell
2013-11-22 16:24 ` [PATCH v2 15/15] xen: arm: handle 40-bit addresses in the p2m Ian Campbell
2013-11-28 17:41   ` Stefano Stabellini
2013-11-28 17:45     ` Ian Campbell

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=1385137474-31245-13-git-send-email-ian.campbell@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=anup.patel@linaro.org \
    --cc=julien.grall@linaro.org \
    --cc=pranavkumar@linaro.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.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).