diff options
author | David Howells <dhowells@redhat.com> | 2006-10-05 09:55:46 -0400 |
---|---|---|
committer | David Howells <dhowells@warthog.cambridge.redhat.com> | 2006-10-05 10:10:12 -0400 |
commit | 7d12e780e003f93433d49ce78cfedf4b4c52adc5 (patch) | |
tree | 6748550400445c11a306b132009f3001e3525df8 /drivers/serial/sh-sci.c | |
parent | da482792a6d1a3fbaaa25fae867b343fb4db3246 (diff) |
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 <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
Diffstat (limited to 'drivers/serial/sh-sci.c')
-rw-r--r-- | drivers/serial/sh-sci.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c index 5c025d1190c1..266aa325569e 100644 --- a/drivers/serial/sh-sci.c +++ b/drivers/serial/sh-sci.c | |||
@@ -446,8 +446,7 @@ static void sci_transmit_chars(struct uart_port *port) | |||
446 | /* On SH3, SCIF may read end-of-break as a space->mark char */ | 446 | /* On SH3, SCIF may read end-of-break as a space->mark char */ |
447 | #define STEPFN(c) ({int __c=(c); (((__c-1)|(__c)) == -1); }) | 447 | #define STEPFN(c) ({int __c=(c); (((__c-1)|(__c)) == -1); }) |
448 | 448 | ||
449 | static inline void sci_receive_chars(struct uart_port *port, | 449 | static inline void sci_receive_chars(struct uart_port *port) |
450 | struct pt_regs *regs) | ||
451 | { | 450 | { |
452 | struct sci_port *sci_port = (struct sci_port *)port; | 451 | struct sci_port *sci_port = (struct sci_port *)port; |
453 | struct tty_struct *tty = port->info->tty; | 452 | struct tty_struct *tty = port->info->tty; |
@@ -476,7 +475,7 @@ static inline void sci_receive_chars(struct uart_port *port, | |||
476 | 475 | ||
477 | if (port->type == PORT_SCI) { | 476 | if (port->type == PORT_SCI) { |
478 | char c = sci_in(port, SCxRDR); | 477 | char c = sci_in(port, SCxRDR); |
479 | if (uart_handle_sysrq_char(port, c, regs) || sci_port->break_flag) | 478 | if (uart_handle_sysrq_char(port, c) || sci_port->break_flag) |
480 | count = 0; | 479 | count = 0; |
481 | else { | 480 | else { |
482 | tty_insert_flip_char(tty, c, TTY_NORMAL); | 481 | tty_insert_flip_char(tty, c, TTY_NORMAL); |
@@ -504,7 +503,7 @@ static inline void sci_receive_chars(struct uart_port *port, | |||
504 | } | 503 | } |
505 | } | 504 | } |
506 | #endif /* CONFIG_CPU_SH3 */ | 505 | #endif /* CONFIG_CPU_SH3 */ |
507 | if (uart_handle_sysrq_char(port, c, regs)) { | 506 | if (uart_handle_sysrq_char(port, c)) { |
508 | count--; i--; | 507 | count--; i--; |
509 | continue; | 508 | continue; |
510 | } | 509 | } |
@@ -652,18 +651,18 @@ static inline int sci_handle_breaks(struct uart_port *port) | |||
652 | return copied; | 651 | return copied; |
653 | } | 652 | } |
654 | 653 | ||
655 | static irqreturn_t sci_rx_interrupt(int irq, void *port, struct pt_regs *regs) | 654 | static irqreturn_t sci_rx_interrupt(int irq, void *port) |
656 | { | 655 | { |
657 | /* I think sci_receive_chars has to be called irrespective | 656 | /* I think sci_receive_chars has to be called irrespective |
658 | * of whether the I_IXOFF is set, otherwise, how is the interrupt | 657 | * of whether the I_IXOFF is set, otherwise, how is the interrupt |
659 | * to be disabled? | 658 | * to be disabled? |
660 | */ | 659 | */ |
661 | sci_receive_chars(port, regs); | 660 | sci_receive_chars(port); |
662 | 661 | ||
663 | return IRQ_HANDLED; | 662 | return IRQ_HANDLED; |
664 | } | 663 | } |
665 | 664 | ||
666 | static irqreturn_t sci_tx_interrupt(int irq, void *ptr, struct pt_regs *regs) | 665 | static irqreturn_t sci_tx_interrupt(int irq, void *ptr) |
667 | { | 666 | { |
668 | struct uart_port *port = ptr; | 667 | struct uart_port *port = ptr; |
669 | 668 | ||
@@ -674,7 +673,7 @@ static irqreturn_t sci_tx_interrupt(int irq, void *ptr, struct pt_regs *regs) | |||
674 | return IRQ_HANDLED; | 673 | return IRQ_HANDLED; |
675 | } | 674 | } |
676 | 675 | ||
677 | static irqreturn_t sci_er_interrupt(int irq, void *ptr, struct pt_regs *regs) | 676 | static irqreturn_t sci_er_interrupt(int irq, void *ptr) |
678 | { | 677 | { |
679 | struct uart_port *port = ptr; | 678 | struct uart_port *port = ptr; |
680 | 679 | ||
@@ -696,18 +695,18 @@ static irqreturn_t sci_er_interrupt(int irq, void *ptr, struct pt_regs *regs) | |||
696 | pr_debug("scif: overrun error\n"); | 695 | pr_debug("scif: overrun error\n"); |
697 | } | 696 | } |
698 | #endif | 697 | #endif |
699 | sci_rx_interrupt(irq, ptr, regs); | 698 | sci_rx_interrupt(irq, ptr); |
700 | } | 699 | } |
701 | 700 | ||
702 | sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port)); | 701 | sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port)); |
703 | 702 | ||
704 | /* Kick the transmission */ | 703 | /* Kick the transmission */ |
705 | sci_tx_interrupt(irq, ptr, regs); | 704 | sci_tx_interrupt(irq, ptr); |
706 | 705 | ||
707 | return IRQ_HANDLED; | 706 | return IRQ_HANDLED; |
708 | } | 707 | } |
709 | 708 | ||
710 | static irqreturn_t sci_br_interrupt(int irq, void *ptr, struct pt_regs *regs) | 709 | static irqreturn_t sci_br_interrupt(int irq, void *ptr) |
711 | { | 710 | { |
712 | struct uart_port *port = ptr; | 711 | struct uart_port *port = ptr; |
713 | 712 | ||
@@ -724,7 +723,7 @@ static irqreturn_t sci_br_interrupt(int irq, void *ptr, struct pt_regs *regs) | |||
724 | return IRQ_HANDLED; | 723 | return IRQ_HANDLED; |
725 | } | 724 | } |
726 | 725 | ||
727 | static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr, struct pt_regs *regs) | 726 | static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr) |
728 | { | 727 | { |
729 | unsigned short ssr_status, scr_status; | 728 | unsigned short ssr_status, scr_status; |
730 | struct uart_port *port = ptr; | 729 | struct uart_port *port = ptr; |
@@ -734,16 +733,16 @@ static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr, struct pt_regs *regs) | |||
734 | 733 | ||
735 | /* Tx Interrupt */ | 734 | /* Tx Interrupt */ |
736 | if ((ssr_status & 0x0020) && (scr_status & 0x0080)) | 735 | if ((ssr_status & 0x0020) && (scr_status & 0x0080)) |
737 | sci_tx_interrupt(irq, ptr, regs); | 736 | sci_tx_interrupt(irq, ptr); |
738 | /* Rx Interrupt */ | 737 | /* Rx Interrupt */ |
739 | if ((ssr_status & 0x0002) && (scr_status & 0x0040)) | 738 | if ((ssr_status & 0x0002) && (scr_status & 0x0040)) |
740 | sci_rx_interrupt(irq, ptr, regs); | 739 | sci_rx_interrupt(irq, ptr); |
741 | /* Error Interrupt */ | 740 | /* Error Interrupt */ |
742 | if ((ssr_status & 0x0080) && (scr_status & 0x0400)) | 741 | if ((ssr_status & 0x0080) && (scr_status & 0x0400)) |
743 | sci_er_interrupt(irq, ptr, regs); | 742 | sci_er_interrupt(irq, ptr); |
744 | /* Break Interrupt */ | 743 | /* Break Interrupt */ |
745 | if ((ssr_status & 0x0010) && (scr_status & 0x0200)) | 744 | if ((ssr_status & 0x0010) && (scr_status & 0x0200)) |
746 | sci_br_interrupt(irq, ptr, regs); | 745 | sci_br_interrupt(irq, ptr); |
747 | 746 | ||
748 | return IRQ_HANDLED; | 747 | return IRQ_HANDLED; |
749 | } | 748 | } |
@@ -795,7 +794,7 @@ static struct notifier_block sci_nb = { &sci_notifier, NULL, 0 }; | |||
795 | static int sci_request_irq(struct sci_port *port) | 794 | static int sci_request_irq(struct sci_port *port) |
796 | { | 795 | { |
797 | int i; | 796 | int i; |
798 | irqreturn_t (*handlers[4])(int irq, void *ptr, struct pt_regs *regs) = { | 797 | irqreturn_t (*handlers[4])(int irq, void *ptr) = { |
799 | sci_er_interrupt, sci_rx_interrupt, sci_tx_interrupt, | 798 | sci_er_interrupt, sci_rx_interrupt, sci_tx_interrupt, |
800 | sci_br_interrupt, | 799 | sci_br_interrupt, |
801 | }; | 800 | }; |