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/sl811-hcd.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/sl811-hcd.c')
-rw-r--r-- | drivers/usb/host/sl811-hcd.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index 3a586aab3939..5fa5647ea095 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c | |||
@@ -428,7 +428,6 @@ static void finish_request( | |||
428 | struct sl811 *sl811, | 428 | struct sl811 *sl811, |
429 | struct sl811h_ep *ep, | 429 | struct sl811h_ep *ep, |
430 | struct urb *urb, | 430 | struct urb *urb, |
431 | struct pt_regs *regs, | ||
432 | int status | 431 | int status |
433 | ) __releases(sl811->lock) __acquires(sl811->lock) | 432 | ) __releases(sl811->lock) __acquires(sl811->lock) |
434 | { | 433 | { |
@@ -444,7 +443,7 @@ static void finish_request( | |||
444 | spin_unlock(&urb->lock); | 443 | spin_unlock(&urb->lock); |
445 | 444 | ||
446 | spin_unlock(&sl811->lock); | 445 | spin_unlock(&sl811->lock); |
447 | usb_hcd_giveback_urb(sl811_to_hcd(sl811), urb, regs); | 446 | usb_hcd_giveback_urb(sl811_to_hcd(sl811), urb); |
448 | spin_lock(&sl811->lock); | 447 | spin_lock(&sl811->lock); |
449 | 448 | ||
450 | /* leave active endpoints in the schedule */ | 449 | /* leave active endpoints in the schedule */ |
@@ -484,7 +483,7 @@ static void finish_request( | |||
484 | } | 483 | } |
485 | 484 | ||
486 | static void | 485 | static void |
487 | done(struct sl811 *sl811, struct sl811h_ep *ep, u8 bank, struct pt_regs *regs) | 486 | done(struct sl811 *sl811, struct sl811h_ep *ep, u8 bank) |
488 | { | 487 | { |
489 | u8 status; | 488 | u8 status; |
490 | struct urb *urb; | 489 | struct urb *urb; |
@@ -608,7 +607,7 @@ done(struct sl811 *sl811, struct sl811h_ep *ep, u8 bank, struct pt_regs *regs) | |||
608 | } | 607 | } |
609 | 608 | ||
610 | if (urb && (urbstat != -EINPROGRESS || urb->status != -EINPROGRESS)) | 609 | if (urb && (urbstat != -EINPROGRESS || urb->status != -EINPROGRESS)) |
611 | finish_request(sl811, ep, urb, regs, urbstat); | 610 | finish_request(sl811, ep, urb, urbstat); |
612 | } | 611 | } |
613 | 612 | ||
614 | static inline u8 checkdone(struct sl811 *sl811) | 613 | static inline u8 checkdone(struct sl811 *sl811) |
@@ -641,7 +640,7 @@ static inline u8 checkdone(struct sl811 *sl811) | |||
641 | return irqstat; | 640 | return irqstat; |
642 | } | 641 | } |
643 | 642 | ||
644 | static irqreturn_t sl811h_irq(struct usb_hcd *hcd, struct pt_regs *regs) | 643 | static irqreturn_t sl811h_irq(struct usb_hcd *hcd) |
645 | { | 644 | { |
646 | struct sl811 *sl811 = hcd_to_sl811(hcd); | 645 | struct sl811 *sl811 = hcd_to_sl811(hcd); |
647 | u8 irqstat; | 646 | u8 irqstat; |
@@ -670,13 +669,13 @@ retry: | |||
670 | * issued ... that's fine if they're different endpoints. | 669 | * issued ... that's fine if they're different endpoints. |
671 | */ | 670 | */ |
672 | if (irqstat & SL11H_INTMASK_DONE_A) { | 671 | if (irqstat & SL11H_INTMASK_DONE_A) { |
673 | done(sl811, sl811->active_a, SL811_EP_A(SL811_HOST_BUF), regs); | 672 | done(sl811, sl811->active_a, SL811_EP_A(SL811_HOST_BUF)); |
674 | sl811->active_a = NULL; | 673 | sl811->active_a = NULL; |
675 | sl811->stat_a++; | 674 | sl811->stat_a++; |
676 | } | 675 | } |
677 | #ifdef USE_B | 676 | #ifdef USE_B |
678 | if (irqstat & SL11H_INTMASK_DONE_B) { | 677 | if (irqstat & SL11H_INTMASK_DONE_B) { |
679 | done(sl811, sl811->active_b, SL811_EP_B(SL811_HOST_BUF), regs); | 678 | done(sl811, sl811->active_b, SL811_EP_B(SL811_HOST_BUF)); |
680 | sl811->active_b = NULL; | 679 | sl811->active_b = NULL; |
681 | sl811->stat_b++; | 680 | sl811->stat_b++; |
682 | } | 681 | } |
@@ -723,7 +722,7 @@ retry: | |||
723 | container_of(sl811->active_a | 722 | container_of(sl811->active_a |
724 | ->hep->urb_list.next, | 723 | ->hep->urb_list.next, |
725 | struct urb, urb_list), | 724 | struct urb, urb_list), |
726 | NULL, -ESHUTDOWN); | 725 | -ESHUTDOWN); |
727 | sl811->active_a = NULL; | 726 | sl811->active_a = NULL; |
728 | } | 727 | } |
729 | #ifdef USE_B | 728 | #ifdef USE_B |
@@ -957,7 +956,7 @@ static int sl811h_urb_enqueue( | |||
957 | spin_lock(&urb->lock); | 956 | spin_lock(&urb->lock); |
958 | if (urb->status != -EINPROGRESS) { | 957 | if (urb->status != -EINPROGRESS) { |
959 | spin_unlock(&urb->lock); | 958 | spin_unlock(&urb->lock); |
960 | finish_request(sl811, ep, urb, NULL, 0); | 959 | finish_request(sl811, ep, urb, 0); |
961 | retval = 0; | 960 | retval = 0; |
962 | goto fail; | 961 | goto fail; |
963 | } | 962 | } |
@@ -1026,7 +1025,7 @@ static int sl811h_urb_dequeue(struct usb_hcd *hcd, struct urb *urb) | |||
1026 | } | 1025 | } |
1027 | 1026 | ||
1028 | if (urb) | 1027 | if (urb) |
1029 | finish_request(sl811, ep, urb, NULL, 0); | 1028 | finish_request(sl811, ep, urb, 0); |
1030 | else | 1029 | else |
1031 | VDBG("dequeue, urb %p active %s; wait4irq\n", urb, | 1030 | VDBG("dequeue, urb %p active %s; wait4irq\n", urb, |
1032 | (sl811->active_a == ep) ? "A" : "B"); | 1031 | (sl811->active_a == ep) ? "A" : "B"); |
@@ -1083,7 +1082,7 @@ sl811h_hub_status_data(struct usb_hcd *hcd, char *buf) | |||
1083 | */ | 1082 | */ |
1084 | local_irq_save(flags); | 1083 | local_irq_save(flags); |
1085 | if (!timer_pending(&sl811->timer)) { | 1084 | if (!timer_pending(&sl811->timer)) { |
1086 | if (sl811h_irq( /* ~0, */ hcd, NULL) != IRQ_NONE) | 1085 | if (sl811h_irq( /* ~0, */ hcd) != IRQ_NONE) |
1087 | sl811->stat_lost++; | 1086 | sl811->stat_lost++; |
1088 | } | 1087 | } |
1089 | local_irq_restore(flags); | 1088 | local_irq_restore(flags); |