From 7d12e780e003f93433d49ce78cfedf4b4c52adc5 Mon Sep 17 00:00:00 2001 From: David Howells Date: Thu, 5 Oct 2006 14:55:46 +0100 Subject: IRQ: Maintain regs pointer globally rather than passing to IRQ handlers Maintain a per-CPU global "struct pt_regs *" variable which can be used instead of passing regs around manually through all ~1800 interrupt handlers in the Linux kernel. The regs pointer is used in few places, but it potentially costs both stack space and code to pass it around. On the FRV arch, removing the regs parameter from all the genirq function results in a 20% speed up of the IRQ exit path (ie: from leaving timer_interrupt() to leaving do_IRQ()). Where appropriate, an arch may override the generic storage facility and do something different with the variable. On FRV, for instance, the address is maintained in GR28 at all times inside the kernel as part of general exception handling. Having looked over the code, it appears that the parameter may be handed down through up to twenty or so layers of functions. Consider a USB character device attached to a USB hub, attached to a USB controller that posts its interrupts through a cascaded auxiliary interrupt controller. A character device driver may want to pass regs to the sysrq handler through the input layer which adds another few layers of parameter passing. I've build this code with allyesconfig for x86_64 and i386. I've runtested the main part of the code on FRV and i386, though I can't test most of the drivers. I've also done partial conversion for powerpc and MIPS - these at least compile with minimal configurations. This will affect all archs. Mostly the changes should be relatively easy. Take do_IRQ(), store the regs pointer at the beginning, saving the old one: struct pt_regs *old_regs = set_irq_regs(regs); And put the old one back at the end: set_irq_regs(old_regs); Don't pass regs through to generic_handle_irq() or __do_IRQ(). In timer_interrupt(), this sort of change will be necessary: - update_process_times(user_mode(regs)); - profile_tick(CPU_PROFILING, regs); + update_process_times(user_mode(get_irq_regs())); + profile_tick(CPU_PROFILING); I'd like to move update_process_times()'s use of get_irq_regs() into itself, except that i386, alone of the archs, uses something other than user_mode(). Some notes on the interrupt handling in the drivers: (*) input_dev() is now gone entirely. The regs pointer is no longer stored in the input_dev struct. (*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does something different depending on whether it's been supplied with a regs pointer or not. (*) Various IRQ handler function pointers have been moved to type irq_handler_t. Signed-Off-By: David Howells (cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit) --- drivers/input/keyboard/amikbd.c | 4 +--- drivers/input/keyboard/atkbd.c | 4 +--- drivers/input/keyboard/corgikbd.c | 9 +++------ drivers/input/keyboard/hil_kbd.c | 2 +- drivers/input/keyboard/hilkbd.c | 2 +- drivers/input/keyboard/lkkbd.c | 5 +---- drivers/input/keyboard/locomokbd.c | 8 +++----- drivers/input/keyboard/newtonkbd.c | 3 +-- drivers/input/keyboard/omap-keypad.c | 3 +-- drivers/input/keyboard/spitzkbd.c | 10 ++++------ drivers/input/keyboard/stowaway.c | 3 +-- drivers/input/keyboard/sunkbd.c | 3 +-- drivers/input/keyboard/xtkbd.c | 3 +-- 13 files changed, 20 insertions(+), 39 deletions(-) (limited to 'drivers/input/keyboard') diff --git a/drivers/input/keyboard/amikbd.c b/drivers/input/keyboard/amikbd.c index f1f9db9d282c..8abdbd0ee8f9 100644 --- a/drivers/input/keyboard/amikbd.c +++ b/drivers/input/keyboard/amikbd.c @@ -158,7 +158,7 @@ static const char *amikbd_messages[8] = { static struct input_dev *amikbd_dev; -static irqreturn_t amikbd_interrupt(int irq, void *dummy, struct pt_regs *fp) +static irqreturn_t amikbd_interrupt(int irq, void *dummy) { unsigned char scancode, down; @@ -171,8 +171,6 @@ static irqreturn_t amikbd_interrupt(int irq, void *dummy, struct pt_regs *fp) scancode >>= 1; if (scancode < 0x78) { /* scancodes < 0x78 are keys */ - input_regs(amikbd_dev, fp); - if (scancode == 98) { /* CapsLock is a toggle switch key on Amiga */ input_report_key(amikbd_dev, scancode, 1); input_report_key(amikbd_dev, scancode, 0); diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 40244d4ce0f1..b6ef9eaad1dc 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c @@ -318,7 +318,7 @@ static unsigned int atkbd_compat_scancode(struct atkbd *atkbd, unsigned int code */ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, - unsigned int flags, struct pt_regs *regs) + unsigned int flags) { struct atkbd *atkbd = serio_get_drvdata(serio); struct input_dev *dev = atkbd->dev; @@ -458,7 +458,6 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, atkbd->time = jiffies + msecs_to_jiffies(dev->rep[REP_DELAY]) / 2; } - input_regs(dev, regs); input_event(dev, EV_KEY, keycode, value); input_sync(dev); @@ -469,7 +468,6 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, } if (atkbd->scroll) { - input_regs(dev, regs); if (click != -1) input_report_key(dev, BTN_MIDDLE, click); input_report_rel(dev, REL_WHEEL, scroll); diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c index 1e03153b9bca..cb70970625b5 100644 --- a/drivers/input/keyboard/corgikbd.c +++ b/drivers/input/keyboard/corgikbd.c @@ -129,7 +129,7 @@ static inline void corgikbd_reset_col(int col) */ /* Scan the hardware keyboard and push any changes up through the input layer */ -static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data, struct pt_regs *regs) +static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data) { unsigned int row, col, rowd; unsigned long flags; @@ -140,9 +140,6 @@ static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data, struct pt_regs spin_lock_irqsave(&corgikbd_data->lock, flags); - if (regs) - input_regs(corgikbd_data->input, regs); - num_pressed = 0; for (col = 0; col < KB_COLS; col++) { /* @@ -191,14 +188,14 @@ static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data, struct pt_regs /* * corgi keyboard interrupt handler. */ -static irqreturn_t corgikbd_interrupt(int irq, void *dev_id, struct pt_regs *regs) +static irqreturn_t corgikbd_interrupt(int irq, void *dev_id) { struct corgikbd *corgikbd_data = dev_id; if (!timer_pending(&corgikbd_data->timer)) { /** wait chattering delay **/ udelay(20); - corgikbd_scankeyboard(corgikbd_data, regs); + corgikbd_scankeyboard(corgikbd_data); } return IRQ_HANDLED; diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c index 2e4abdc26367..c9b0b8978cd8 100644 --- a/drivers/input/keyboard/hil_kbd.c +++ b/drivers/input/keyboard/hil_kbd.c @@ -198,7 +198,7 @@ static void hil_kbd_process_err(struct hil_kbd *kbd) { } static irqreturn_t hil_kbd_interrupt(struct serio *serio, - unsigned char data, unsigned int flags, struct pt_regs *regs) + unsigned char data, unsigned int flags) { struct hil_kbd *kbd; hil_packet packet; diff --git a/drivers/input/keyboard/hilkbd.c b/drivers/input/keyboard/hilkbd.c index d22c7c624296..54bc569db4b0 100644 --- a/drivers/input/keyboard/hilkbd.c +++ b/drivers/input/keyboard/hilkbd.c @@ -150,7 +150,7 @@ static inline void handle_data(unsigned char s, unsigned char c) /* * Handle HIL interrupts. */ -static irqreturn_t hil_interrupt(int irq, void *handle, struct pt_regs *regs) +static irqreturn_t hil_interrupt(int irq, void *handle) { unsigned char s, c; diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c index 5174224cadb4..708d5a1bc3d2 100644 --- a/drivers/input/keyboard/lkkbd.c +++ b/drivers/input/keyboard/lkkbd.c @@ -453,8 +453,7 @@ lkkbd_detection_done (struct lkkbd *lk) * is received. */ static irqreturn_t -lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags, - struct pt_regs *regs) +lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags) { struct lkkbd *lk = serio_get_drvdata (serio); int i; @@ -473,7 +472,6 @@ lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags, switch (data) { case LK_ALL_KEYS_UP: - input_regs (lk->dev, regs); for (i = 0; i < ARRAY_SIZE (lkkbd_keycode); i++) if (lk->keycode[i] != KEY_RESERVED) input_report_key (lk->dev, lk->keycode[i], 0); @@ -501,7 +499,6 @@ lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags, default: if (lk->keycode[data] != KEY_RESERVED) { - input_regs (lk->dev, regs); if (!test_bit (lk->keycode[data], lk->dev->key)) input_report_key (lk->dev, lk->keycode[data], 1); else diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c index 83906f80ba21..fd33c9cc3272 100644 --- a/drivers/input/keyboard/locomokbd.c +++ b/drivers/input/keyboard/locomokbd.c @@ -126,7 +126,7 @@ static inline void locomokbd_reset_col(unsigned long membase, int col) */ /* Scan the hardware keyboard and push any changes up through the input layer */ -static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs *regs) +static void locomokbd_scankeyboard(struct locomokbd *locomokbd) { unsigned int row, col, rowd, scancode; unsigned long flags; @@ -135,8 +135,6 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs * spin_lock_irqsave(&locomokbd->lock, flags); - input_regs(locomokbd->input, regs); - locomokbd_charge_all(membase); num_pressed = 0; @@ -171,13 +169,13 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs * /* * LoCoMo keyboard interrupt handler. */ -static irqreturn_t locomokbd_interrupt(int irq, void *dev_id, struct pt_regs *regs) +static irqreturn_t locomokbd_interrupt(int irq, void *dev_id) { struct locomokbd *locomokbd = dev_id; /** wait chattering delay **/ udelay(100); - locomokbd_scankeyboard(locomokbd, regs); + locomokbd_scankeyboard(locomokbd); return IRQ_HANDLED; } diff --git a/drivers/input/keyboard/newtonkbd.c b/drivers/input/keyboard/newtonkbd.c index 40a3f551247e..9282e4e082bd 100644 --- a/drivers/input/keyboard/newtonkbd.c +++ b/drivers/input/keyboard/newtonkbd.c @@ -65,13 +65,12 @@ struct nkbd { }; static irqreturn_t nkbd_interrupt(struct serio *serio, - unsigned char data, unsigned int flags, struct pt_regs *regs) + unsigned char data, unsigned int flags) { struct nkbd *nkbd = serio_get_drvdata(serio); /* invalid scan codes are probably the init sequence, so we ignore them */ if (nkbd->keycode[data & NKBD_KEY]) { - input_regs(nkbd->dev, regs); input_report_key(nkbd->dev, nkbd->keycode[data & NKBD_KEY], data & NKBD_PRESS); input_sync(nkbd->dev); } diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c index d436287d1d2e..5680a6d95b2b 100644 --- a/drivers/input/keyboard/omap-keypad.c +++ b/drivers/input/keyboard/omap-keypad.c @@ -97,8 +97,7 @@ static u8 get_row_gpio_val(struct omap_kp *omap_kp) #define get_row_gpio_val(x) 0 #endif -static irqreturn_t omap_kp_interrupt(int irq, void *dev_id, - struct pt_regs *regs) +static irqreturn_t omap_kp_interrupt(int irq, void *dev_id) { struct omap_kp *omap_kp = dev_id; diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c index e385710233f4..8b18c009e3e0 100644 --- a/drivers/input/keyboard/spitzkbd.c +++ b/drivers/input/keyboard/spitzkbd.c @@ -176,7 +176,7 @@ static inline int spitzkbd_get_row_status(int col) */ /* Scan the hardware keyboard and push any changes up through the input layer */ -static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data, struct pt_regs *regs) +static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data) { unsigned int row, col, rowd; unsigned long flags; @@ -187,8 +187,6 @@ static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data, struct pt_regs spin_lock_irqsave(&spitzkbd_data->lock, flags); - input_regs(spitzkbd_data->input, regs); - num_pressed = 0; for (col = 0; col < KB_COLS; col++) { /* @@ -239,14 +237,14 @@ static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data, struct pt_regs /* * spitz keyboard interrupt handler. */ -static irqreturn_t spitzkbd_interrupt(int irq, void *dev_id, struct pt_regs *regs) +static irqreturn_t spitzkbd_interrupt(int irq, void *dev_id) { struct spitzkbd *spitzkbd_data = dev_id; if (!timer_pending(&spitzkbd_data->timer)) { /** wait chattering delay **/ udelay(20); - spitzkbd_scankeyboard(spitzkbd_data, regs); + spitzkbd_scankeyboard(spitzkbd_data); } return IRQ_HANDLED; @@ -267,7 +265,7 @@ static void spitzkbd_timer_callback(unsigned long data) * We debounce the switches and pass them to the input system. */ -static irqreturn_t spitzkbd_hinge_isr(int irq, void *dev_id, struct pt_regs *regs) +static irqreturn_t spitzkbd_hinge_isr(int irq, void *dev_id) { struct spitzkbd *spitzkbd_data = dev_id; diff --git a/drivers/input/keyboard/stowaway.c b/drivers/input/keyboard/stowaway.c index 04c54c57f25c..e60937d17b1c 100644 --- a/drivers/input/keyboard/stowaway.c +++ b/drivers/input/keyboard/stowaway.c @@ -71,13 +71,12 @@ struct skbd { }; static irqreturn_t skbd_interrupt(struct serio *serio, unsigned char data, - unsigned int flags, struct pt_regs *regs) + unsigned int flags) { struct skbd *skbd = serio_get_drvdata(serio); struct input_dev *dev = skbd->dev; if (skbd->keycode[data & SKBD_KEY_MASK]) { - input_regs(dev, regs); input_report_key(dev, skbd->keycode[data & SKBD_KEY_MASK], !(data & SKBD_RELEASE)); input_sync(dev); diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c index 9dbd7b85686d..cac4781103c3 100644 --- a/drivers/input/keyboard/sunkbd.c +++ b/drivers/input/keyboard/sunkbd.c @@ -94,7 +94,7 @@ struct sunkbd { */ static irqreturn_t sunkbd_interrupt(struct serio *serio, - unsigned char data, unsigned int flags, struct pt_regs *regs) + unsigned char data, unsigned int flags) { struct sunkbd* sunkbd = serio_get_drvdata(serio); @@ -129,7 +129,6 @@ static irqreturn_t sunkbd_interrupt(struct serio *serio, break; if (sunkbd->keycode[data & SUNKBD_KEY]) { - input_regs(sunkbd->dev, regs); input_report_key(sunkbd->dev, sunkbd->keycode[data & SUNKBD_KEY], !(data & SUNKBD_RELEASE)); input_sync(sunkbd->dev); } else { diff --git a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c index 0821d53cf0c1..8c11dc935454 100644 --- a/drivers/input/keyboard/xtkbd.c +++ b/drivers/input/keyboard/xtkbd.c @@ -64,7 +64,7 @@ struct xtkbd { }; static irqreturn_t xtkbd_interrupt(struct serio *serio, - unsigned char data, unsigned int flags, struct pt_regs *regs) + unsigned char data, unsigned int flags) { struct xtkbd *xtkbd = serio_get_drvdata(serio); @@ -75,7 +75,6 @@ static irqreturn_t xtkbd_interrupt(struct serio *serio, default: if (xtkbd->keycode[data & XTKBD_KEY]) { - input_regs(xtkbd->dev, regs); input_report_key(xtkbd->dev, xtkbd->keycode[data & XTKBD_KEY], !(data & XTKBD_RELEASE)); input_sync(xtkbd->dev); } else { -- cgit v1.2.3