FRV: Use the generic IRQ stuff
PATCH 1/1 FRV: Use the generic IRQ stuff
From: David Howells <[email protected]>
Make the FRV arch use the generic IRQ code rather than having its own routines for doing so.
---
arch/frv/Kconfig | 8 arch/frv/kernel/Makefile | 5 arch/frv/kernel/irq-mb93091.c | 157 +++++-- arch/frv/kernel/irq-mb93093.c | 115 +++-- arch/frv/kernel/irq-mb93493.c | 167 +++++--- arch/frv/kernel/irq-routing.c | 291 -------------- arch/frv/kernel/irq.c | 750 +++++------------------------------ arch/frv/kernel/setup.c | 1 arch/frv/kernel/time.c | 1 arch/frv/mb93090-mb00/pci-irq.c | 1 include/asm-frv/cpu-irqs.h | 54 +-- include/asm-frv/hardirq.h | 5 include/asm-frv/irq-routing.h | 70 --- include/asm-frv/irq.h | 26 - include/asm-frv/mb93091-fpga-irqs.h | 6 include/asm-frv/mb93093-fpga-irqs.h | 6 include/asm-frv/mb93493-irqs.h | 6 include/asm-frv/mb93493-regs.h | 2 18 files changed, 450 insertions(+), 1221 deletions(-)
arch/frv/Kconfig +7 -1
@@ -27,7 +27,7 @@ config GENERIC_CALIBRATE_DELAY config GENERIC_HARDIRQS bool - default n + default y config GENERIC_TIME bool
@@ -259,6 +259,12 @@ config MB93091_NO_MB endchoice endif +config FUJITSU_MB93493 + bool "MB93493 Multimedia chip" + help + Select this option if the MB93493 multimedia chip is going to be + used. + choice prompt "GP-Relative data support" default GPREL_DATA_8
arch/frv/kernel/Makefile +2 -3
@@ -10,15 +10,14 @@ extra-y:= head.o init_task.o vmlinux.lds obj-y := $(heads-y) entry.o entry-table.o break.o switch_to.o kernel_thread.o \ process.o traps.o ptrace.o signal.o dma.o \ sys_frv.o time.o semaphore.o setup.o frv_ksyms.o \ - debug-stub.o irq.o irq-routing.o sleep.o uaccess.o atomic-ops.o + debug-stub.o irq.o sleep.o uaccess.o atomic-ops.o obj-$(CONFIG_GDBSTUB) += gdb-stub.o gdb-io.o obj-$(CONFIG_MB93091_VDK) += irq-mb93091.o -obj-$(CONFIG_MB93093_PDK) += irq-mb93093.o -obj-$(CONFIG_FUJITSU_MB93493) += irq-mb93493.o obj-$(CONFIG_PM) += pm.o cmode.o obj-$(CONFIG_MB93093_PDK) += pm-mb93093.o +obj-$(CONFIG_FUJITSU_MB93493) += irq-mb93493.o obj-$(CONFIG_SYSCTL) += sysctl.o obj-$(CONFIG_FUTEX) += futex.o obj-$(CONFIG_MODULES) += module.o
arch/frv/kernel/irq-mb93091.c +101 -56
191 lines not on this page · raw message
arch/frv/kernel/irq-mb93093.c +74 -41
153 lines not on this page · raw message
arch/frv/kernel/irq-mb93493.c +108 -59
198 lines not on this page · raw message
arch/frv/kernel/irq-routing.c deleted +0 -291
291 lines not on this page · raw message
arch/frv/kernel/irq.c +113 -637
829 lines not on this page · raw message
arch/frv/kernel/setup.c +0 -1
@@ -43,7 +43,6 @@ #include <asm/spr-regs.h>#include <asm/mb-regs.h> #include <asm/mb93493-regs.h> #include <asm/gdb-stub.h> -#include <asm/irq-routing.h> #include <asm/io.h> #ifdef CONFIG_BLK_DEV_INITRD
arch/frv/kernel/time.c +0 -1
@@ -26,7 +26,6 @@ #include <asm/io.h>#include <asm/timer-regs.h> #include <asm/mb-regs.h> #include <asm/mb86943a.h> -#include <asm/irq-routing.h> #include <linux/timex.h>
arch/frv/mb93090-mb00/pci-irq.c +0 -1
@@ -15,7 +15,6 @@ #include <linux/irq.h>#include <asm/io.h> #include <asm/smp.h> -#include <asm/irq-routing.h> #include "pci-frv.h"
include/asm-frv/cpu-irqs.h +24 -30
66 lines not on this page · raw message
include/asm-frv/hardirq.h +5 -0
@@ -26,5 +26,10 @@ #ifdef CONFIG_SMP#error SMP not available on FR-V#endif /* CONFIG_SMP */ +extern atomic_t irq_err_count; +static inline void ack_bad_irq (int irq) +{ +atomic_inc (&irq_err_count); +}#endif
include/asm-frv/irq-routing.h deleted +0 -70
70 lines not on this page · raw message
include/asm-frv/irq.h +8 -18
@@ -1,6 +1,6 @@/* irq.h: FRV IRQ definitions * -* Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. +* Copyright (C) 2006 Red Hat, Inc. All Rights Reserved. * Written by David Howells ([email protected]) * * This program is free software; you can redistribute it and/or
@@ -12,32 +12,22 @@#ifndef _ASM_IRQ_H_#define _ASM_IRQ_H_ - -/* -* the system has an on-CPU PIC and another PIC on the FPGA and other PICs on other peripherals, -* so we do some routing in irq-routing.[ch] to reduce the number of false-positives seen by -* drivers -*/ -/* this number is used when no interrupt has been assigned */ #define NO_IRQ (-1) -#define NR_IRQ_LOG2_ACTIONS_PER_GROUP 5 -#define NR_IRQ_ACTIONS_PER_GROUP (1 << NR_IRQ_LOG2_ACTIONS_PER_GROUP) -#define NR_IRQ_GROUPS 4 -#define NR_IRQS (NR_IRQ_ACTIONS_PER_GROUP * NR_IRQ_GROUPS) +#define NR_IRQS 48 +#define IRQ_BASE_CPU (0 * 16) +#define IRQ_BASE_FPGA (1 * 16) +#define IRQ_BASE_MB93493 (2 * 16)/* probe returns a 32-bit IRQ mask:-/ */ -#define MIN_PROBE_IRQ (NR_IRQS - 32) +#define MIN_PROBE_IRQ (NR_IRQS - 32) +#ifndef __ASSEMBLY__static inline int irq_canonicalize (int irq) {return irq; } - -extern void disable_irq_nosync (unsigned int irq); -extern void disable_irq (unsigned int irq); -extern void enable_irq (unsigned int irq); - +#endif #endif /* _ASM_IRQ_H_ */
include/asm-frv/mb93091-fpga-irqs.h +2 -4
@@ -12,11 +12,9 @@#ifndef _ASM_MB93091_FPGA_IRQS_H#define _ASM_MB93091_FPGA_IRQS_H -#ifndef __ASSEMBLY__ - -#include <asm/irq-routing.h> +#include <asm/irq.h> -#define IRQ_BASE_FPGA (NR_IRQ_ACTIONS_PER_GROUP * 1) +#ifndef __ASSEMBLY__/* IRQ IDs presented to drivers */ enum {
include/asm-frv/mb93093-fpga-irqs.h +2 -4
@@ -12,11 +12,9 @@#ifndef _ASM_MB93093_FPGA_IRQS_H#define _ASM_MB93093_FPGA_IRQS_H -#ifndef __ASSEMBLY__ - -#include <asm/irq-routing.h> +#include <asm/irq.h> -#define IRQ_BASE_FPGA (NR_IRQ_ACTIONS_PER_GROUP * 1) +#ifndef __ASSEMBLY__/* IRQ IDs presented to drivers */ enum {
include/asm-frv/mb93493-irqs.h +2 -4
@@ -12,11 +12,9 @@#ifndef _ASM_MB93493_IRQS_H#define _ASM_MB93493_IRQS_H -#ifndef __ASSEMBLY__ - -#include <asm/irq-routing.h> +#include <asm/irq.h> -#define IRQ_BASE_MB93493 (NR_IRQ_ACTIONS_PER_GROUP * 2) +#ifndef __ASSEMBLY__/* IRQ IDs presented to drivers */ enum {
include/asm-frv/mb93493-regs.h +2 -0
@@ -15,6 +15,7 @@ #define _ASM_MB93493_REGS_H#include <asm/mb-regs.h> #include <asm/mb93493-irqs.h> +#define __addr_MB93493 (X ) ((volatile unsigned long *)(__region_CS3 + (X)))#define __get_MB93493 (X ) ({ *(volatile unsigned long *)(__region_CS3 + (X)); })#define __set_MB93493 (X ,V ) \
@@ -26,6 +27,7 @@ #define __get_MB93493_STSR(X) __get_MB93#define __set_MB93493_STSR (X ,V ) __set_MB93493(0x3c0 + (X) * 4, (V))#define MB93493_STSR_EN +#define __addr_MB93493_IQSR (X ) __addr_MB93493(0x3d0 + (X) * 4)#define __get_MB93493_IQSR (X ) __get_MB93493(0x3d0 + (X) * 4)#define __set_MB93493_IQSR (X ,V ) __set_MB93493(0x3d0 + (X) * 4, (V))
Quoted 80 lines
#define
__reg16(ADDR)(*(volatile unsigned short *)(ADDR))arch/frv/kernel/irq-mb93091.c +17
-43@@ -33,83 +32,129 @@ #define __set_IMR(M) do { __reg16(0xffc0#define __get_IFR () ({ __reg16(0xffc0000c); })#define __clr_IFR (M ) do { __reg16(0xffc0000c) = ~(M); wmb(); } while(0) -static void frv_fpga_doirq (struct irq_source *source); -static void frv_fpga_control (struct irq_group *group,int irq,int on); -/*****************************************************************************/ /* -* FPGA IRQ multiplexor +* on-motherboard FPGA PIC operations */ -static struct irq_source frv_fpga[4 ] = { -#define __FPGA(X, M) \ - [X] = { \ - .muxname = "fpga."#X, \ - .irqmask = M, \ - .doirq = frv_fpga_doirq, \ - } +static void frv_fpga_enable (unsigned int irq) +{ +uint16_t imr =__get_IMR (); -__FPGA (0 ,0x0028 ), -__FPGA (1 ,0x0050 ), -__FPGA (2 ,0x1c00 ), -__FPGA (3 ,0x6386 ), -}; - -static struct irq_group frv_fpga_irqs = { - .first_irq =IRQ_BASE_FPGA , - .control = frv_fpga_control, - .sources = { - [1 ] = &frv_fpga[3 ], - [2 ] = &frv_fpga[3 ], - [3 ] = &frv_fpga[0 ], - [4 ] = &frv_fpga[1 ], - [5 ] = &frv_fpga[0 ], - [6 ] = &frv_fpga[1 ], - [7 ] = &frv_fpga[3 ], - [8 ] = &frv_fpga[3 ], - [9 ] = &frv_fpga[3 ], - [10 ] = &frv_fpga[2 ], - [11 ] = &frv_fpga[2 ], - [12 ] = &frv_fpga[2 ], - [13 ] = &frv_fpga[3 ], - [14 ] = &frv_fpga[3 ], - }, -}; + imr &= ~(1 << (irq -IRQ_BASE_FPGA )); +__set_IMR (imr); +} -static void frv_fpga_control (struct irq_group *group,int index,int on) +static void frv_fpga_disable (unsigned int irq) {uint16_t imr =__get_IMR (); -if (on) - imr &= ~(1 << index); -else - imr |=1 << index; + imr |=1 << (irq -IRQ_BASE_FPGA );__set_IMR (imr); } -static void frv_fpga_doirq (struct irq_source *source) +static void frv_fpga_ack (unsigned int irq) +{ +__clr_IFR (1 << (irq -IRQ_BASE_FPGA )); +} + +static void frv_fpga_end (unsigned int irq) +{ +}
arch/frv/kernel/irq-mb93091.c #define __set_IMR(M) do { __reg16(0xffc0 · line 74
Quoted 10 lines
arch/frv/kernel/irq-mb93091.c +10
-0+ +static struct irq_chip frv_fpga_pic = { + .name ="mb93091" , + .enable = frv_fpga_enable, + .disable = frv_fpga_disable, + .ack = frv_fpga_ack, + .mask = frv_fpga_disable, + .unmask = frv_fpga_enable, + .end = frv_fpga_end, +};
Why do you have a end() handler ? (and an empty one....) Your FPGA interrupts ase using the level generic flow handler right ? That doesn't call end(). Though you might want to have a mask_ack() "combined" callback to avoid two indirect calls (it's an optional optimisation).
Quoted 19 lines
arch/frv/kernel/irq-mb93091.c +9
-7+/* +* FPGA PIC interrupt handler +*/ +static irqreturn_t fpga_interrupt (int irq,void *_mask,struct pt_regs *regs) { -uint16_t mask, imr; +uint16_t imr, mask = (unsigned long ) _mask; +irqreturn_t iret =0 ; imr =__get_IMR (); - mask = source->irqmask & ~imr &__get_IFR (); -if (mask) { -__set_IMR (imr | mask); -__clr_IFR (mask); -distribute_irqs (&frv_fpga_irqs, mask); -__set_IMR (imr); + mask = mask & ~imr &__get_IFR (); + +/* poll all the triggered IRQs */
arch/frv/kernel/irq-mb93091.c #define __set_IMR(M) do { __reg16(0xffc0 · line 97
Quoted 10 lines
arch/frv/kernel/irq-mb93091.c +9
-0+while (mask) { +int irq; + + asm("scan %1,gr0,%0" :"=r" (irq) :"r" (mask)); + irq =31 - irq; + mask &= ~(1 << irq); + +if (__do_IRQ (IRQ_BASE_FPGA + irq, regs)) + iret |=IRQ_HANDLED ; }
Ahem... __do_IRQ()... That's probably part of your bloat... With a conversion to genirq, you shouldn't use __do_IRQ() anymore (and thus it shouldn't be compiled in). In fact, that defeats genirq completely as you aren't calling the new handlers at all there. You should call generic_handle_irq() instead.
Quoted 5 lines
arch/frv/kernel/irq-mb93091.c +3
-0+return iret; } +/* +* define an interrupt action for each FPGA PIC output
arch/frv/kernel/irq-mb93091.c #define __set_IMR(M) do { __reg16(0xffc0 · line 113
Quoted 10 lines
arch/frv/kernel/irq-mb93091.c +10
-0+* - use dev_id to indicate the FPGA PIC input to output mappings +*/ +static struct irqaction fpga_irq[4 ] = { + [0 ] = { + .handler = fpga_interrupt, + .flags =IRQF_DISABLED |IRQF_SHARED , + .mask =CPU_MASK_NONE , + .name ="fpga.0" , + .dev_id = (void *)0x0028UL , + },
.../...
Quoted 21 lines
arch/frv/kernel/irq-mb93091.c +11
-5+}; + +/* +* initialise the motherboard FPGA's PIC +*/ void __init fpga_init (void ) { +int irq; + +/* all PIC inputs are all set to be low-level driven, apart from the +* NMI button (15) which is fixed at falling-edge +*/ __set_IMR (0x7ffe );__clr_IFR (0x0000 ); -frv_irq_route_external (&frv_fpga[0 ],IRQ_CPU_EXTERNAL0 ); -frv_irq_route_external (&frv_fpga[1 ],IRQ_CPU_EXTERNAL1 ); -frv_irq_route_external (&frv_fpga[2 ],IRQ_CPU_EXTERNAL2 ); -frv_irq_route_external (&frv_fpga[3 ],IRQ_CPU_EXTERNAL3 ); -frv_irq_set_group (&frv_fpga_irqs); +for (irq =IRQ_BASE_FPGA +1 ; irq <=IRQ_BASE_FPGA +14 ; irq++)
arch/frv/kernel/irq-mb93091.c #define __set_IMR(M) do { __reg16(0xffc0 · line 160
Quoted 10 lines
arch/frv/kernel/irq-mb93091.c +9
-0+set_irq_chip_and_handler (irq, &frv_fpga_pic, handle_level_irq); + +set_irq_chip_and_handler (IRQ_FPGA_NMI , &frv_fpga_pic, handle_edge_irq); + +/* the FPGA drives the first four external IRQ inputs on the CPU PIC */ +setup_irq (IRQ_CPU_EXTERNAL0 , &fpga_irq[0 ]); +setup_irq (IRQ_CPU_EXTERNAL1 , &fpga_irq[1 ]); +setup_irq (IRQ_CPU_EXTERNAL2 , &fpga_irq[2 ]); +setup_irq (IRQ_CPU_EXTERNAL3 , &fpga_irq[3 ]); }
Your approach to cascades might be wrong here. Instead of setting up an irq handler, you could just attach a chained flow handler. Much less overhead.
arch/frv/kernel/irq-mb93093.c #define __set_IMR(M) do { __reg16(0x0a) · line 73
Quoted 13 lines
arch/frv/kernel/irq-mb93093.c +13
-0+static void frv_fpga_end (unsigned int irq) +{ +} + +static struct irq_chip frv_fpga_pic = { + .name ="mb93093" , + .enable = frv_fpga_enable, + .disable = frv_fpga_disable, + .ack = frv_fpga_ack, + .mask = frv_fpga_disable, + .unmask = frv_fpga_enable, + .end = frv_fpga_end, +};
SImilar comments. Also, you are using enable/disable here. Just leave them NULL and the generic code will call your mask/unmask.
Quoted 22 lines
arch/frv/kernel/irq-mb93091.c +12
-7+/* +* FPGA PIC interrupt handler +*/ +static irqreturn_t fpga_interrupt (int irq,void *_mask,struct pt_regs *regs) { -uint16_t mask, imr; +uint16_t imr, mask = (unsigned long ) _mask; +irqreturn_t iret =0 ; imr =__get_IMR (); - mask = source->irqmask & ~imr &__get_IFR (); -if (mask) { -__set_IMR (imr | mask); -__clr_IFR (mask); -distribute_irqs (&frv_fpga_irqs, mask); -__set_IMR (imr); + mask = mask & ~imr &__get_IFR (); + +/* poll all the triggered IRQs */ +while (mask) { +int irq; +
arch/frv/kernel/irq-mb93091.c #define __set_IMR(M) do { __reg16(0xffc0 · line 100
Quoted 10 lines
arch/frv/kernel/irq-mb93091.c +8
-0+ asm("scan %1,gr0,%0" :"=r" (irq) :"r" (mask)); + irq =31 - irq; + mask &= ~(1 << irq); + +if (__do_IRQ (IRQ_BASE_FPGA + irq, regs)) + iret |=IRQ_HANDLED ; } + +return iret; }
Same comment as before. Don't call __do_IRQ()
Quoted 23 lines
arch/frv/kernel/irq-mb93093.c +20
-0+/* +* define an interrupt action for each FPGA PIC output +* - use dev_id to indicate the FPGA PIC input to output mappings +*/ +static struct irqaction fpga_irq[1 ] = { + [0 ] = { + .handler = fpga_interrupt, + .flags =IRQF_DISABLED , + .mask =CPU_MASK_NONE , + .name ="fpga.0" , + .dev_id = (void *)0x0700UL , + } +}; + +/* +* initialise the motherboard FPGA's PIC +*/ void __init fpga_init (void ) { +int irq; + +/* all PIC inputs are all set to be edge triggered */ __set_IMR (0x0700 );
arch/frv/kernel/irq-mb93093.c #define __set_IMR(M) do { __reg16(0x0a) · line 131
Quoted 10 lines
arch/frv/kernel/irq-mb93093.c +5
-2__clr_IFR (0x0000 ); -frv_irq_route_external (&frv_fpga[0 ],IRQ_CPU_EXTERNAL2 ); -frv_irq_set_group (&frv_fpga_irqs); +for (irq =IRQ_BASE_FPGA +8 ; irq <=IRQ_BASE_FPGA +10 ; irq++) +set_irq_chip_and_handler (irq, &frv_fpga_pic, handle_edge_irq); + +/* the FPGA drives external IRQ input #2 on the CPU PIC */ +setup_irq (IRQ_CPU_EXTERNAL2 , &fpga_irq[0 ]); }
And same comment as before vs. using a flow handler.
You do that in another one at least... And I have to go now so I can't finish reviewing your patch :) But it looks like you aren't properly "converting" to the genirq code and thus not getting all of the benefit, like faster code path to cascade handlers, etc... and you aren't getting rid of __do_IRQ() so at the end of the day, you aren't using the new stuff and still link in the old one :)
Ben.
Quoted 7 lines · Benjamin Herrenschmidt
Review
Quoted 2 lines
(quoted diff) +2
-0+ .end = frv_fpga_end, +};Why do you have a
end()handler ? (and an empty one....) Your FPGA interrupts ase using the level generic flow handler right ? That doesn't callend(). Though you might want to have amask_ack()"combined" callback to avoid two indirect calls (it's an optional optimisation).
This is called unconditionally from __do_IRQ(). It's also not listed in genericirq.tmpl, though ack(), mask(), etc. are. The header file (irq.h) doesn't say that it is optional, though it does say that startup(), shutdown(), etc. are, therefore the assumption would be that it isn't optional.
Quoted 5 lines
Ahem...
__do_IRQ()... That's probably part of your bloat... With a conversion to genirq, you shouldn't use__do_IRQ()anymore (and thus it shouldn't be compiled in). In fact, that defeats genirq completely as you aren't calling the new handlers at all there. You should callgeneric_handle_irq()instead.
It's not mentioned in the docs:
warthog>grep generic_handle_irq Documentation/DocBook/genericirq.tmpl warthog1>
Looking at the code itself, generic_handle_irq() is a wrapper around __do_IRQ():
static inline void generic_handle_irq(unsigned int irq,
struct pt_regs *regs)
{
struct irq_desc *desc = irq_desc + irq;
if (likely(desc->handle_irq))
desc->handle_irq(irq, desc, regs);
else
__do_IRQ(irq, regs);
}So I don't see how it can help but make the code larger. The if-statement in it can't be optimised down because its condition depends on a value held in memory and is not subject to compile-time evaluation.
It will make things quicker, probably, since it bypasses __do_IRQ() when possible, but if it can't, it will make things slower as you'll have this check, the condition will fail against expectations, and then you'll still have to do __do_IRQ() anyway.
Quoted 3 lines
Quoted 1 line
+static struct irqaction fpga_irq[4] = {
...
.../...
Can you rephrase your comment?
Quoted 9 lines
arch/frv/kernel/irq-mb93091.c #define __set_IMR(M) do { __reg16(0xffc0 · line 160
Quoted 5 lines
arch/frv/kernel/irq-mb93091.c +4
-0+setup_irq (IRQ_CPU_EXTERNAL0 , &fpga_irq[0 ]); +setup_irq (IRQ_CPU_EXTERNAL1 , &fpga_irq[1 ]); +setup_irq (IRQ_CPU_EXTERNAL2 , &fpga_irq[2 ]); +setup_irq (IRQ_CPU_EXTERNAL3 , &fpga_irq[3 ]); }Your approach to cascades might be wrong here. Instead of setting up an irq handler, you could just attach a chained flow handler. Much less overhead.
That's an undocumented feature:
warthog>grep -i chain Documentation/DocBook/genericirq.tmpl warthog1>
Quoted 10 lines
arch/frv/kernel/irq-mb93091.c #define __set_IMR(M) do { __reg16(0xffc0 · line 74
Quoted 7 lines
arch/frv/kernel/irq-mb93091.c +7
-0+ .enable = frv_fpga_enable, + .disable = frv_fpga_disable, + .ack = frv_fpga_ack, + .mask = frv_fpga_disable, + .unmask = frv_fpga_enable, + .end = frv_fpga_end, +};SImilar comments. Also, you are using enable/disable here. Just leave them NULL and the generic code will call your mask/unmask.
Hmmm... I see that irq_chip_set_defaults() installs intermediary functions in the chip ops table for anything it doesn't have. Surely it'd be better to require people to fill in the appropriate default functions directly as you could then make the table const. That's what you've got documentation for, right?
Quoted 6 lines
You do that in another one at least... And I have to go now so I can't finish reviewing your patch :) But it looks like you aren't properly "converting" to the genirq code and thus not getting all of the benefit, like faster code path to cascade handlers, etc... and you aren't getting rid of
__do_IRQ()so at the end of the day, you aren't using the new stuff and still link in the old one :)
Documentation/DocBook/genericirq.tmpl doesn't do a very good job of explaining it. The comments in include/linux/irq.h also need a check as some of them are out of date.
Take the comment at the head of struct irq_desc for example, it mentions fields that are absent in the structure, the HTML doc generator spits out warnings in relation to linux/irq.h.
I would also recommend that a line be added to the banner comments at the top of linux/irq.h to point to the documentation, just like is done in the .c files implementing genirq.
David
Quoted 10 lines · David Howells
Quoted 7 lines · Benjamin Herrenschmidt
Review
Quoted 2 lines
(quoted diff) +2
-0+ .end = frv_fpga_end, +};Why do you have a
end()handler ? (and an empty one....) Your FPGA interrupts ase using the level generic flow handler right ? That doesn't callend(). Though you might want to have amask_ack()"combined" callback to avoid two indirect calls (it's an optional optimisation).
Quoted 4 lines
This is called unconditionally from
__do_IRQ(). It's also not listed in genericirq.tmpl, thoughack(),mask(), etc. are. The header file (irq.h) doesn't say that it is optional, though it does say thatstartup(),shutdown(), etc. are, therefore the assumption would be that it isn't optional.
Well, you shoud not use __do_IRQ if you use the genirq stuff... the callbacks that are needed depend on which flow handler you use.
Quoted 6 lines
Quoted 5 lines
Ahem...
__do_IRQ()... That's probably part of your bloat... With a conversion to genirq, you shouldn't use__do_IRQ()anymore (and thus it shouldn't be compiled in). In fact, that defeats genirq completely as you aren't calling the new handlers at all there. You should callgeneric_handle_irq()instead.
Quoted 8 lines
It's not mentioned in the docs:
warthog>grep
generic_handle_irqDocumentation/DocBook/genericirq.tmplwarthog1>Looking at the code itself,
generic_handle_irq()is a wrapper around__do_IRQ():
No, it's a wrapper around desc->handler_irq, which is the flow handler you install. The fallback to __do_IRQ is only if you don't implement a flow handler (still have one of your PICs not using it). However, that means that if you use generic_handle_irq(), then __do_IRQ will have to be linked in, that's a good point, we might want to provide a different wrapper for archs that have done a total conversion...
Quoted 11 lines
static inline void generic_handle_irq(unsigned int irq,
struct pt_regs *regs)
{
struct irq_desc *desc = irq_desc + irq;
if (likely(desc->handle_irq))
desc->handle_irq(irq, desc, regs);
else
__do_IRQ(irq, regs);
}Quoted 3 lines
So I don't see how it can help but make the code larger. The if-statement in it can't be optimised down because its condition depends on a value held in memory and is not subject to compile-time evaluation.
That helper is my fault :) It's mostly because at one point, I had a partial conversion and some of my PICs were still using __do_IRQ(). Ingo initial design wants you to call desc->handle_irq() directly.
Quoted 4 lines
It will make things quicker, probably, since it bypasses
__do_IRQ()when possible, but if it can't, it will make things slower as you'll have this check, the condition will fail against expectations, and then you'll still have to do__do_IRQ()anyway.
Yes, we can avoid it though as I just wrote.
Quoted 16 lines
Quoted 3 lines
Quoted 1 line
+static struct irqaction fpga_irq[4] = {
...
.../...Can you rephrase your comment?
Quoted 9 lines
arch/frv/kernel/irq-mb93091.c #define __set_IMR(M) do { __reg16(0xffc0 · line 160
Quoted 5 lines
arch/frv/kernel/irq-mb93091.c +4
-0+setup_irq (IRQ_CPU_EXTERNAL0 , &fpga_irq[0 ]); +setup_irq (IRQ_CPU_EXTERNAL1 , &fpga_irq[1 ]); +setup_irq (IRQ_CPU_EXTERNAL2 , &fpga_irq[2 ]); +setup_irq (IRQ_CPU_EXTERNAL3 , &fpga_irq[3 ]); }Your approach to cascades might be wrong here. Instead of setting up an irq handler, you could just attach a chained flow handler. Much less overhead.
Quoted 1 line
That's an undocumented feature:
I haven't checked the docs. I suggest you look how I did it on powerpc. I'll see if I can improve the doc next week.
Quoted 14 lines
warthog>grep -i chain
Documentation/DocBook/genericirq.tmplwarthog1>Quoted 10 lines
arch/frv/kernel/irq-mb93091.c #define __set_IMR(M) do { __reg16(0xffc0 · line 74
Quoted 7 lines
arch/frv/kernel/irq-mb93091.c +7
-0+ .enable = frv_fpga_enable, + .disable = frv_fpga_disable, + .ack = frv_fpga_ack, + .mask = frv_fpga_disable, + .unmask = frv_fpga_enable, + .end = frv_fpga_end, +};SImilar comments. Also, you are using enable/disable here. Just leave them NULL and the generic code will call your mask/unmask.
Quoted 5 lines
Hmmm... I see that
irq_chip_set_defaults()installs intermediary functions in the chip ops table for anything it doesn't have. Surely it'd be better to require people to fill in the appropriate default functions directly as you could then make the table const. That's what you've got documentation for, right?
Well... enable/disable are higher level than mask/umask... it's not completely clear to me if we should keep them under control of the irq_chip at all ... It's mostly useful for thigns that haven't yet been ported...
Quoted 11 lines
Quoted 6 lines
You do that in another one at least... And I have to go now so I can't finish reviewing your patch :) But it looks like you aren't properly "converting" to the genirq code and thus not getting all of the benefit, like faster code path to cascade handlers, etc... and you aren't getting rid of
__do_IRQ()so at the end of the day, you aren't using the new stuff and still link in the old one :)
Documentation/DocBook/genericirq.tmpldoesn't do a very good job of explaining it. The comments ininclude/linux/irq.halso need a check as some of them are out of date.
Quoted 7 lines
Take the comment at the head of struct
irq_descfor example, it mentions fields that are absent in the structure, the HTML doc generator spits out warnings in relation tolinux/irq.h.I would also recommend that a line be added to the banner comments at the top of
linux/irq.hto point to the documentation, just like is done in the .c files implementing genirq.
We should indeed improve the documentation.
Cheers,
Ben.
Okay... I've got some timings for FRV using my non-genirq code and using the generic IRQ code.
Adding the attached patch (or similar) into the kernel, I see the following timings:
do_IRQ->timer_int timer_int->do_IRQ Cache Cycles Time Cycles Time =============== ======= ======================= ===================== non-genirq Cold 380 1.1uS 216 600nS Warm 114 320nS 96 270nS genirq Cold 503 1.4uS 409 1.1uS Warm 87 240nS 99 270nS
The TIMERL counter increments at core clock speed (360MHz), so each cycle is approx 2.8nS. Each cycle executes on instruction or one pair of packed instructions under ideal circumstances. Misjudged branches cost 4 clock cycles.
So the genirq patch bites you on a cold cache, probably due to all the little bits of unpredictable icache it's got to collect (chip ops and suchlike dangling off function pointers), but wins a bit on the warm cache front.
The genirq timings above are with __do_IRQ() removed from the kernel.
I used gdb to collect the timings. The times are initially very high, but quickly settle to constant lower values.
David
---
arch/frv/kernel/irq.c +10 -0
@@ -134,6 +134,10 @@ static struct irq_chip frv_cpu_pic = { .end = frv_cpupic_end, }; +unsigned long irq_entered_at; +unsigned long irq_handler_entered_at; +unsigned long irq_exited_at; +/* * handles all normal device IRQ's * - registers are referred to by the __frame variable (GR28)
@@ -142,9 +146,15 @@ static struct irq_chip frv_cpu_pic = {*/ asmlinkage void do_IRQ(void) { + asmvolatile ("bar" :::"memory" ); + asmvolatile ("movsg timerl,%0" :"=r" (irq_entered_at) ::"memory" );irq_enter ();generic_handle_irq (__get_IRL (), __frame);irq_exit (); + asmvolatile ("bar" :::"memory" ); + asmvolatile ("movsg timerl,%0" :"=r" (irq_exited_at) ::"memory" ); + asmvolatile ("bar" :::"memory" ); + asmvolatile ("break" :::"memory" ); }/*
arch/frv/kernel/time.c +7 -0
@@ -52,12 +52,18 @@ static inline int set_rtc_mmss(unsignedreturn -1 ; } +extern unsigned long irq_handler_entered_at; +/* * timer_interrupt() needs to keep up the real-time clock, * as well as call the "do_timer()" routine every clocktick */ static irqreturn_t timer_interrupt (int irq,void *dummy,struct pt_regs * regs) { + asmvolatile ("movsg timerl,%0" :"=r" (irq_handler_entered_at) ::"memory" ); +return IRQ_HANDLED ; + +#if 0 /* last time the cmos clock got updated */ static long last_rtc_update =0 ;
@@ -98,6 +104,7 @@ #endif /* CONFIG_HEARTBEAT */write_sequnlock (&xtime_lock);return IRQ_HANDLED ; +#endif }void time_divisor_init (void )