public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] genirq/debugfs: Print irqdomain flags as human-readable strings
@ 2024-05-28  9:09 Jinjie Ruan
  2024-05-29  8:10 ` Thomas Gleixner
  0 siblings, 1 reply; 2+ messages in thread
From: Jinjie Ruan @ 2024-05-28  9:09 UTC (permalink / raw)
  To: tglx, linux-kernel; +Cc: ruanjinjie

This patch improves the readability of irqdomain debugging information in
debugfs by printing the flags field of domain files as human-readable
strings instead of a raw bitmask, which aligned with the existing style
used for irqchip flags in the irq debug files.

Before:
	#cat :cpus:cpu@0:interrupt-controller
	name:   :cpus:cpu@0:interrupt-controller
	 size:   0
	 mapped: 2
	 flags:  0x00000003

After:
	#cat :cpus:cpu@0:interrupt-controller
	name:   :cpus:cpu@0:interrupt-controller
	 size:   0
	 mapped: 3
	 flags:  0x00000003
	            IRQ_DOMAIN_FLAG_HIERARCHY
	            IRQ_DOMAIN_NAME_ALLOCATED

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 kernel/irq/debugfs.c   | 17 -----------------
 kernel/irq/internals.h | 19 +++++++++++++++++++
 kernel/irq/irqdomain.c | 15 +++++++++++++++
 3 files changed, 34 insertions(+), 17 deletions(-)

diff --git a/kernel/irq/debugfs.c b/kernel/irq/debugfs.c
index aae0402507ed..61a21a4c43ac 100644
--- a/kernel/irq/debugfs.c
+++ b/kernel/irq/debugfs.c
@@ -9,23 +9,6 @@
 
 static struct dentry *irq_dir;
 
-struct irq_bit_descr {
-	unsigned int	mask;
-	char		*name;
-};
-#define BIT_MASK_DESCR(m)	{ .mask = m, .name = #m }
-
-static void irq_debug_show_bits(struct seq_file *m, int ind, unsigned int state,
-				const struct irq_bit_descr *sd, int size)
-{
-	int i;
-
-	for (i = 0; i < size; i++, sd++) {
-		if (state & sd->mask)
-			seq_printf(m, "%*s%s\n", ind + 12, "", sd->name);
-	}
-}
-
 #ifdef CONFIG_SMP
 static void irq_debug_show_masks(struct seq_file *m, struct irq_desc *desc)
 {
diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h
index ed28059e9849..e2ea3f6917ac 100644
--- a/kernel/irq/internals.h
+++ b/kernel/irq/internals.h
@@ -501,6 +501,25 @@ static inline struct irq_data *irqd_get_parent_data(struct irq_data *irqd)
 #ifdef CONFIG_GENERIC_IRQ_DEBUGFS
 #include <linux/debugfs.h>
 
+struct irq_bit_descr {
+	unsigned int	mask;
+	char		*name;
+};
+
+#define BIT_MASK_DESCR(m)	{ .mask = m, .name = #m }
+
+static inline void irq_debug_show_bits(struct seq_file *m, int ind,
+				       unsigned int state,
+				       const struct irq_bit_descr *sd, int size)
+{
+	int i;
+
+	for (i = 0; i < size; i++, sd++) {
+		if (state & sd->mask)
+			seq_printf(m, "%*s%s\n", ind + 12, "", sd->name);
+	}
+}
+
 void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc);
 static inline void irq_remove_debugfs_entry(struct irq_desc *desc)
 {
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index c5832caf24cd..ba5c5cc90c3d 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -1927,6 +1927,19 @@ static void irq_domain_free_one_irq(struct irq_domain *domain, unsigned int virq
 
 static struct dentry *domain_dir;
 
+static const struct irq_bit_descr irqdomain_flags[] = {
+	BIT_MASK_DESCR(IRQ_DOMAIN_FLAG_HIERARCHY),
+	BIT_MASK_DESCR(IRQ_DOMAIN_NAME_ALLOCATED),
+	BIT_MASK_DESCR(IRQ_DOMAIN_FLAG_IPI_PER_CPU),
+	BIT_MASK_DESCR(IRQ_DOMAIN_FLAG_IPI_SINGLE),
+	BIT_MASK_DESCR(IRQ_DOMAIN_FLAG_MSI),
+	BIT_MASK_DESCR(IRQ_DOMAIN_FLAG_ISOLATED_MSI),
+	BIT_MASK_DESCR(IRQ_DOMAIN_FLAG_NO_MAP),
+	BIT_MASK_DESCR(IRQ_DOMAIN_FLAG_MSI_PARENT),
+	BIT_MASK_DESCR(IRQ_DOMAIN_FLAG_MSI_DEVICE),
+	BIT_MASK_DESCR(IRQ_DOMAIN_FLAG_NONCORE),
+};
+
 static void
 irq_domain_debug_show_one(struct seq_file *m, struct irq_domain *d, int ind)
 {
@@ -1934,6 +1947,8 @@ irq_domain_debug_show_one(struct seq_file *m, struct irq_domain *d, int ind)
 	seq_printf(m, "%*ssize:   %u\n", ind + 1, "", d->revmap_size);
 	seq_printf(m, "%*smapped: %u\n", ind + 1, "", d->mapcount);
 	seq_printf(m, "%*sflags:  0x%08x\n", ind +1 , "", d->flags);
+	irq_debug_show_bits(m, ind, d->flags, irqdomain_flags,
+			    ARRAY_SIZE(irqdomain_flags));
 	if (d->ops && d->ops->debug_show)
 		d->ops->debug_show(m, d, NULL, ind + 1);
 #ifdef	CONFIG_IRQ_DOMAIN_HIERARCHY
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] genirq/debugfs: Print irqdomain flags as human-readable strings
  2024-05-28  9:09 [PATCH] genirq/debugfs: Print irqdomain flags as human-readable strings Jinjie Ruan
@ 2024-05-29  8:10 ` Thomas Gleixner
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2024-05-29  8:10 UTC (permalink / raw)
  To: Jinjie Ruan, linux-kernel; +Cc: ruanjinjie

On Tue, May 28 2024 at 09:09, Jinjie Ruan wrote:
> This patch improves the readability of irqdomain debugging information in

git grep 'This patch' Documentation/process/

> debugfs by printing the flags field of domain files as human-readable
> strings instead of a raw bitmask, which aligned with the existing style
> used for irqchip flags in the irq debug files.
>  
> +struct irq_bit_descr {
> +	unsigned int	mask;
> +	char		*name;
> +};
> +
> +#define BIT_MASK_DESCR(m)	{ .mask = m, .name = #m }
> +
> +static inline void irq_debug_show_bits(struct seq_file *m, int ind,
> +				       unsigned int state,
> +				       const struct irq_bit_descr *sd, int size)
> +{
> +	int i;
> +
> +	for (i = 0; i < size; i++, sd++) {
> +		if (state & sd->mask)
> +			seq_printf(m, "%*s%s\n", ind + 12, "", sd->name);
> +	}
> +}

There is no point to inline this. Just keep it in debugfs.c and remove
the static.

Thanks,

        tglx

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-29  8:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-28  9:09 [PATCH] genirq/debugfs: Print irqdomain flags as human-readable strings Jinjie Ruan
2024-05-29  8:10 ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox