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/usb/host/ehci-sched.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/usb/host/ehci-sched.c')
-rw-r--r-- | drivers/usb/host/ehci-sched.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index e5e9c653c907..65c402a0fa7a 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c | |||
@@ -1553,8 +1553,7 @@ itd_link_urb ( | |||
1553 | static unsigned | 1553 | static unsigned |
1554 | itd_complete ( | 1554 | itd_complete ( |
1555 | struct ehci_hcd *ehci, | 1555 | struct ehci_hcd *ehci, |
1556 | struct ehci_itd *itd, | 1556 | struct ehci_itd *itd |
1557 | struct pt_regs *regs | ||
1558 | ) { | 1557 | ) { |
1559 | struct urb *urb = itd->urb; | 1558 | struct urb *urb = itd->urb; |
1560 | struct usb_iso_packet_descriptor *desc; | 1559 | struct usb_iso_packet_descriptor *desc; |
@@ -1613,7 +1612,7 @@ itd_complete ( | |||
1613 | 1612 | ||
1614 | /* give urb back to the driver ... can be out-of-order */ | 1613 | /* give urb back to the driver ... can be out-of-order */ |
1615 | dev = urb->dev; | 1614 | dev = urb->dev; |
1616 | ehci_urb_done (ehci, urb, regs); | 1615 | ehci_urb_done (ehci, urb); |
1617 | urb = NULL; | 1616 | urb = NULL; |
1618 | 1617 | ||
1619 | /* defer stopping schedule; completion can submit */ | 1618 | /* defer stopping schedule; completion can submit */ |
@@ -1930,8 +1929,7 @@ sitd_link_urb ( | |||
1930 | static unsigned | 1929 | static unsigned |
1931 | sitd_complete ( | 1930 | sitd_complete ( |
1932 | struct ehci_hcd *ehci, | 1931 | struct ehci_hcd *ehci, |
1933 | struct ehci_sitd *sitd, | 1932 | struct ehci_sitd *sitd |
1934 | struct pt_regs *regs | ||
1935 | ) { | 1933 | ) { |
1936 | struct urb *urb = sitd->urb; | 1934 | struct urb *urb = sitd->urb; |
1937 | struct usb_iso_packet_descriptor *desc; | 1935 | struct usb_iso_packet_descriptor *desc; |
@@ -1978,7 +1976,7 @@ sitd_complete ( | |||
1978 | 1976 | ||
1979 | /* give urb back to the driver */ | 1977 | /* give urb back to the driver */ |
1980 | dev = urb->dev; | 1978 | dev = urb->dev; |
1981 | ehci_urb_done (ehci, urb, regs); | 1979 | ehci_urb_done (ehci, urb); |
1982 | urb = NULL; | 1980 | urb = NULL; |
1983 | 1981 | ||
1984 | /* defer stopping schedule; completion can submit */ | 1982 | /* defer stopping schedule; completion can submit */ |
@@ -2065,8 +2063,7 @@ sitd_submit (struct ehci_hcd *ehci, struct urb *urb, gfp_t mem_flags) | |||
2065 | static inline unsigned | 2063 | static inline unsigned |
2066 | sitd_complete ( | 2064 | sitd_complete ( |
2067 | struct ehci_hcd *ehci, | 2065 | struct ehci_hcd *ehci, |
2068 | struct ehci_sitd *sitd, | 2066 | struct ehci_sitd *sitd |
2069 | struct pt_regs *regs | ||
2070 | ) { | 2067 | ) { |
2071 | ehci_err (ehci, "sitd_complete %p?\n", sitd); | 2068 | ehci_err (ehci, "sitd_complete %p?\n", sitd); |
2072 | return 0; | 2069 | return 0; |
@@ -2077,7 +2074,7 @@ sitd_complete ( | |||
2077 | /*-------------------------------------------------------------------------*/ | 2074 | /*-------------------------------------------------------------------------*/ |
2078 | 2075 | ||
2079 | static void | 2076 | static void |
2080 | scan_periodic (struct ehci_hcd *ehci, struct pt_regs *regs) | 2077 | scan_periodic (struct ehci_hcd *ehci) |
2081 | { | 2078 | { |
2082 | unsigned frame, clock, now_uframe, mod; | 2079 | unsigned frame, clock, now_uframe, mod; |
2083 | unsigned modified; | 2080 | unsigned modified; |
@@ -2131,7 +2128,7 @@ restart: | |||
2131 | temp.qh = qh_get (q.qh); | 2128 | temp.qh = qh_get (q.qh); |
2132 | type = Q_NEXT_TYPE (q.qh->hw_next); | 2129 | type = Q_NEXT_TYPE (q.qh->hw_next); |
2133 | q = q.qh->qh_next; | 2130 | q = q.qh->qh_next; |
2134 | modified = qh_completions (ehci, temp.qh, regs); | 2131 | modified = qh_completions (ehci, temp.qh); |
2135 | if (unlikely (list_empty (&temp.qh->qtd_list))) | 2132 | if (unlikely (list_empty (&temp.qh->qtd_list))) |
2136 | intr_deschedule (ehci, temp.qh); | 2133 | intr_deschedule (ehci, temp.qh); |
2137 | qh_put (temp.qh); | 2134 | qh_put (temp.qh); |
@@ -2169,7 +2166,7 @@ restart: | |||
2169 | *hw_p = q.itd->hw_next; | 2166 | *hw_p = q.itd->hw_next; |
2170 | type = Q_NEXT_TYPE (q.itd->hw_next); | 2167 | type = Q_NEXT_TYPE (q.itd->hw_next); |
2171 | wmb(); | 2168 | wmb(); |
2172 | modified = itd_complete (ehci, q.itd, regs); | 2169 | modified = itd_complete (ehci, q.itd); |
2173 | q = *q_p; | 2170 | q = *q_p; |
2174 | break; | 2171 | break; |
2175 | case Q_TYPE_SITD: | 2172 | case Q_TYPE_SITD: |
@@ -2185,7 +2182,7 @@ restart: | |||
2185 | *hw_p = q.sitd->hw_next; | 2182 | *hw_p = q.sitd->hw_next; |
2186 | type = Q_NEXT_TYPE (q.sitd->hw_next); | 2183 | type = Q_NEXT_TYPE (q.sitd->hw_next); |
2187 | wmb(); | 2184 | wmb(); |
2188 | modified = sitd_complete (ehci, q.sitd, regs); | 2185 | modified = sitd_complete (ehci, q.sitd); |
2189 | q = *q_p; | 2186 | q = *q_p; |
2190 | break; | 2187 | break; |
2191 | default: | 2188 | default: |