Patchwork [5/6] powerpc: Rearrange and fix show_interrupts() for sparse irq_descs

login
register
mail settings
Submitter Michael Ellerman
Date Oct. 14, 2009, 5:45 a.m.
Message ID <1dec053fee540bd474f88d4850d4ab213ea7215d.1255499081.git.michael@ellerman.id.au>
Download mbox | patch
Permalink /patch/35918/
State Accepted, archived
Commit 750ab112919220a1d14491ae210b689bcb7d6d66
Delegated to: Benjamin Herrenschmidt
Headers show

Comments

Michael Ellerman - Oct. 14, 2009, 5:45 a.m.
Move the default case out of the if, ie. when we're just displaying
an irq. And consolidate all the odd cases at the top, ie. printing
the header and footer.

And in the process cope with sparse irq_descs.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/kernel/irq.c |   64 ++++++++++++++++++++++++++-------------------
 1 files changed, 37 insertions(+), 27 deletions(-)
Grant Likely - Oct. 14, 2009, 6:37 p.m.
On Tue, Oct 13, 2009 at 11:45 PM, Michael Ellerman
<michael@ellerman.id.au> wrote:
> Move the default case out of the if, ie. when we're just displaying
> an irq. And consolidate all the odd cases at the top, ie. printing
> the header and footer.
>
> And in the process cope with sparse irq_descs.
>
> Signed-off-by: Michael Ellerman <michael@ellerman.id.au>

Looks reasonable to me
Acked-by: Grant Likely <grant.likely@secretlab.ca>

> ---
>  arch/powerpc/kernel/irq.c |   64 ++++++++++++++++++++++++++-------------------
>  1 files changed, 37 insertions(+), 27 deletions(-)
>
> diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
> index baa49eb..63e27d5 100644
> --- a/arch/powerpc/kernel/irq.c
> +++ b/arch/powerpc/kernel/irq.c
> @@ -187,33 +187,7 @@ int show_interrupts(struct seq_file *p, void *v)
>                for_each_online_cpu(j)
>                        seq_printf(p, "CPU%d       ", j);
>                seq_putc(p, '\n');
> -       }
> -
> -       if (i < NR_IRQS) {
> -               desc = irq_to_desc(i);
> -               spin_lock_irqsave(&desc->lock, flags);
> -               action = desc->action;
> -               if (!action || !action->handler)
> -                       goto skip;
> -               seq_printf(p, "%3d: ", i);
> -#ifdef CONFIG_SMP
> -               for_each_online_cpu(j)
> -                       seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
> -#else
> -               seq_printf(p, "%10u ", kstat_irqs(i));
> -#endif /* CONFIG_SMP */
> -               if (desc->chip)
> -                       seq_printf(p, " %s ", desc->chip->typename);
> -               else
> -                       seq_puts(p, "  None      ");
> -               seq_printf(p, "%s", (desc->status & IRQ_LEVEL) ? "Level " : "Edge  ");
> -               seq_printf(p, "    %s", action->name);
> -               for (action = action->next; action; action = action->next)
> -                       seq_printf(p, ", %s", action->name);
> -               seq_putc(p, '\n');
> -skip:
> -               spin_unlock_irqrestore(&desc->lock, flags);
> -       } else if (i == NR_IRQS) {
> +       } else if (i == nr_irqs) {
>  #if defined(CONFIG_PPC32) && defined(CONFIG_TAU_INT)
>                if (tau_initialized){
>                        seq_puts(p, "TAU: ");
> @@ -223,7 +197,43 @@ skip:
>                }
>  #endif /* CONFIG_PPC32 && CONFIG_TAU_INT*/
>                seq_printf(p, "BAD: %10u\n", ppc_spurious_interrupts);
> +
> +               return 0;
>        }
> +
> +       desc = irq_to_desc(i);
> +       if (!desc)
> +               return 0;
> +
> +       spin_lock_irqsave(&desc->lock, flags);
> +
> +       action = desc->action;
> +       if (!action || !action->handler)
> +               goto skip;
> +
> +       seq_printf(p, "%3d: ", i);
> +#ifdef CONFIG_SMP
> +       for_each_online_cpu(j)
> +               seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
> +#else
> +       seq_printf(p, "%10u ", kstat_irqs(i));
> +#endif /* CONFIG_SMP */
> +
> +       if (desc->chip)
> +               seq_printf(p, " %s ", desc->chip->typename);
> +       else
> +               seq_puts(p, "  None      ");
> +
> +       seq_printf(p, "%s", (desc->status & IRQ_LEVEL) ? "Level " : "Edge  ");
> +       seq_printf(p, "    %s", action->name);
> +
> +       for (action = action->next; action; action = action->next)
> +               seq_printf(p, ", %s", action->name);
> +       seq_putc(p, '\n');
> +
> +skip:
> +       spin_unlock_irqrestore(&desc->lock, flags);
> +
>        return 0;
>  }
>
> --
> 1.6.2.1
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>

Patch

diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index baa49eb..63e27d5 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -187,33 +187,7 @@  int show_interrupts(struct seq_file *p, void *v)
 		for_each_online_cpu(j)
 			seq_printf(p, "CPU%d       ", j);
 		seq_putc(p, '\n');
-	}
-
-	if (i < NR_IRQS) {
-		desc = irq_to_desc(i);
-		spin_lock_irqsave(&desc->lock, flags);
-		action = desc->action;
-		if (!action || !action->handler)
-			goto skip;
-		seq_printf(p, "%3d: ", i);
-#ifdef CONFIG_SMP
-		for_each_online_cpu(j)
-			seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
-#else
-		seq_printf(p, "%10u ", kstat_irqs(i));
-#endif /* CONFIG_SMP */
-		if (desc->chip)
-			seq_printf(p, " %s ", desc->chip->typename);
-		else
-			seq_puts(p, "  None      ");
-		seq_printf(p, "%s", (desc->status & IRQ_LEVEL) ? "Level " : "Edge  ");
-		seq_printf(p, "    %s", action->name);
-		for (action = action->next; action; action = action->next)
-			seq_printf(p, ", %s", action->name);
-		seq_putc(p, '\n');
-skip:
-		spin_unlock_irqrestore(&desc->lock, flags);
-	} else if (i == NR_IRQS) {
+	} else if (i == nr_irqs) {
 #if defined(CONFIG_PPC32) && defined(CONFIG_TAU_INT)
 		if (tau_initialized){
 			seq_puts(p, "TAU: ");
@@ -223,7 +197,43 @@  skip:
 		}
 #endif /* CONFIG_PPC32 && CONFIG_TAU_INT*/
 		seq_printf(p, "BAD: %10u\n", ppc_spurious_interrupts);
+
+		return 0;
 	}
+
+	desc = irq_to_desc(i);
+	if (!desc)
+		return 0;
+
+	spin_lock_irqsave(&desc->lock, flags);
+
+	action = desc->action;
+	if (!action || !action->handler)
+		goto skip;
+
+	seq_printf(p, "%3d: ", i);
+#ifdef CONFIG_SMP
+	for_each_online_cpu(j)
+		seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
+#else
+	seq_printf(p, "%10u ", kstat_irqs(i));
+#endif /* CONFIG_SMP */
+
+	if (desc->chip)
+		seq_printf(p, " %s ", desc->chip->typename);
+	else
+		seq_puts(p, "  None      ");
+
+	seq_printf(p, "%s", (desc->status & IRQ_LEVEL) ? "Level " : "Edge  ");
+	seq_printf(p, "    %s", action->name);
+
+	for (action = action->next; action; action = action->next)
+		seq_printf(p, ", %s", action->name);
+	seq_putc(p, '\n');
+
+skip:
+	spin_unlock_irqrestore(&desc->lock, flags);
+
 	return 0;
 }