From: Chen Gong <g.chen@freescale.com>
To: paulus@samba.org, galak@kernel.crashing.org
Cc: linuxppc-dev@ozlabs.org, Chen Gong <g.chen@freescale.com>,
Chen Gong <G.Chen@freescale.com>
Subject: [PATCH 3/3] Add irq debugfs and virq_mapping for getting the virq
Date: Mon, 23 Jul 2007 19:13:50 +0800 [thread overview]
Message-ID: <11851892333882-git-send-email-g.chen@freescale.com> (raw)
In-Reply-To: <11851892322112-git-send-email-g.chen@freescale.com>
This patch adds irq debugfs and virq_mapping for getting the virq.
The virq_mapping node is in powerpc/irq directory of the root debugfs.
Signed-off-by: Zhang Wei <wei.zhang@freescale.com>
Signed-off-by: Chen Gong <G.Chen@freescale.com>
---
arch/powerpc/Kconfig.debug | 7 ++
arch/powerpc/kernel/Makefile | 1 +
arch/powerpc/kernel/irq_debugfs.c | 140 +++++++++++++++++++++++++++++++++++++
3 files changed, 148 insertions(+), 0 deletions(-)
create mode 100644 arch/powerpc/kernel/irq_debugfs.c
diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
index 346cd3b..7ae8df1 100644
--- a/arch/powerpc/Kconfig.debug
+++ b/arch/powerpc/Kconfig.debug
@@ -2,6 +2,13 @@ menu "Kernel hacking"
source "lib/Kconfig.debug"
+config PPC_VIRQ_DEBUGFS
+ bool "Check virqs mapping"
+ depends on DEBUG_FS
+ help
+ This option will show the mapping relationship between hardware irq
+ and virtual irq based on debugfs
+
config DEBUG_STACKOVERFLOW
bool "Check for stack overflows"
depends on DEBUG_KERNEL
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 42c42ec..cc3e1e5 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -15,6 +15,7 @@ obj-y := semaphore.o cputable.o ptrace.o syscalls.o \
init_task.o process.o systbl.o idle.o \
signal.o
obj-y += vdso32/
+obj-$(CONFIG_PPC_VIRQ_DEBUGFS) += irq_debugfs.o
obj-$(CONFIG_PPC64) += setup_64.o binfmt_elf32.o sys_ppc32.o \
signal_64.o ptrace32.o \
paca.o cpu_setup_ppc970.o \
diff --git a/arch/powerpc/kernel/irq_debugfs.c b/arch/powerpc/kernel/irq_debugfs.c
new file mode 100644
index 0000000..53ac12e
--- /dev/null
+++ b/arch/powerpc/kernel/irq_debugfs.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+ *
+ * Auther: Zhang Wei <wei.zhang@freescale.com>
+ *
+ * Description:
+ * This file is used for debug the irq. It will create 'irq' directory
+ * in the powerpc directory of debugfs.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/threads.h>
+#include <linux/kernel_stat.h>
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/ptrace.h>
+#include <linux/ioport.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/seq_file.h>
+#include <linux/mutex.h>
+#include <linux/list.h>
+
+#include <asm/uaccess.h>
+#include <asm/system.h>
+#include <asm/irq.h>
+#include <asm/pgtable.h>
+#include <asm/prom.h>
+
+extern struct dentry *powerpc_debugfs_root;
+
+static void *irq_dbg_start(struct seq_file *m, loff_t *pos)
+{
+ return (*pos <= NR_IRQS) ? pos : NULL;
+}
+
+static void *irq_dbg_next(struct seq_file *m, void *p, loff_t * pos)
+{
+ (*pos)++;
+
+ return (*pos <= NR_IRQS) ? pos : NULL;
+}
+
+static void irq_dbg_stop(struct seq_file *m, void *p)
+{
+ /* Nothing to do */
+}
+
+static int irq_dbg_show(struct seq_file *m, void *p)
+{
+ int i = *(loff_t *)p;
+ struct irqaction *action;
+ irq_desc_t *desc;
+ unsigned long flags;
+
+ if (i == 0)
+ seq_puts(m, "VIRQ HWIRQ Chip Name Host Name\n");
+
+ if (i < NR_IRQS) {
+ desc = get_irq_desc(i);
+ spin_lock_irqsave(&desc->lock, flags);
+ action = desc->action;
+ if (!action || !action->handler)
+ goto skip;
+ seq_printf(m, "%3d: ", i);
+
+ seq_printf(m, " %3d ", (irq_map[i].host->revmap_type == IRQ_HOST_MAP_LEGACY) ? i : virq_to_hw(i));
+
+ if (desc->chip)
+ seq_printf(m, " %s ", desc->chip->typename);
+ else
+ seq_puts(m, " None ");
+
+ seq_printf(m, " %s ", (irq_map[i].host->name) ? irq_map[i].host->name : " None ");
+ seq_putc(m, '\n');
+skip:
+ spin_unlock_irqrestore(&desc->lock, flags);
+ } else if (i == NR_IRQS) {
+#ifdef CONFIG_PPC32
+#ifdef CONFIG_TAU_INT
+ if (tau_initialized)
+ seq_puts(m, "TAU: PowerPC Thermal Assist (cpu temp)\n");
+#endif
+#endif /* CONFIG_PPC32 */
+ }
+
+ return 0;
+}
+
+static struct seq_operations irq_dbg_seq_ops = {
+ .start = irq_dbg_start,
+ .next = irq_dbg_next,
+ .stop = irq_dbg_stop,
+ .show = irq_dbg_show
+};
+
+static int irq_dbg_seq_open(struct inode *inode, struct file *file)
+{
+ int rc;
+ struct seq_file *seq;
+
+ rc = seq_open(file, &irq_dbg_seq_ops);
+ seq = file->private_data;
+ seq->private = file->f_path.dentry->d_inode->i_private;
+
+ return rc;
+}
+
+static const struct file_operations irq_dbg_seq_fops = {
+ .open = irq_dbg_seq_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = seq_release,
+};
+
+static int __init irq_debugfs_init(void)
+{
+ struct dentry *irq_root;
+ struct dentry *irq_file;
+
+ if (!powerpc_debugfs_root)
+ return 1;
+
+ irq_root = debugfs_create_dir("irq", powerpc_debugfs_root);
+ if (!irq_root)
+ return -ENOMEM;
+
+ irq_file = debugfs_create_file("virq_mapping", S_IRUGO,
+ irq_root, NULL, &irq_dbg_seq_fops);
+ if (!irq_file)
+ return -ENOMEM;
+
+ return 0;
+}
+__initcall(irq_debugfs_init);
--
1.5.1
next prev parent reply other threads:[~2007-07-23 11:05 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-23 11:13 [PATCH 0/3] Add virq mapping debugfs for PowerPC Chen Gong
2007-07-23 11:13 ` [PATCH 1/3] Add a new member name to structure irq_host Chen Gong
2007-07-23 11:13 ` [PATCH 2/3] Add irq host name for all powerpc interrupt controllors Chen Gong
2007-07-23 11:13 ` Chen Gong [this message]
2007-07-23 22:04 ` [PATCH 1/3] Add a new member name to structure irq_host Benjamin Herrenschmidt
2007-07-23 23:22 ` Michael Ellerman
2007-07-23 23:36 ` Benjamin Herrenschmidt
2007-07-24 4:06 ` Chen Gong-B11801
2007-07-24 4:33 ` Benjamin Herrenschmidt
2007-07-24 9:25 ` Zhang Wei-r63237
2007-07-24 9:36 ` Benjamin Herrenschmidt
2007-07-25 7:03 ` Zhang Wei-r63237
2007-07-31 19:42 ` Segher Boessenkool
2007-07-31 21:44 ` Benjamin Herrenschmidt
2007-07-31 22:13 ` Segher Boessenkool
2007-07-31 23:06 ` Michael Ellerman
2007-07-31 23:42 ` Segher Boessenkool
2007-07-23 11:55 ` [PATCH 0/3] Add virq mapping debugfs for PowerPC Stephen Rothwell
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=11851892333882-git-send-email-g.chen@freescale.com \
--to=g.chen@freescale.com \
--cc=galak@kernel.crashing.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.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).