aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/input/ati_remote2.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2006-10-05 09:55:46 -0400
committerDavid Howells <dhowells@warthog.cambridge.redhat.com>2006-10-05 10:10:12 -0400
commit7d12e780e003f93433d49ce78cfedf4b4c52adc5 (patch)
tree6748550400445c11a306b132009f3001e3525df8 /drivers/usb/input/ati_remote2.c
parentda482792a6d1a3fbaaa25fae867b343fb4db3246 (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/input/ati_remote2.c')
-rw-r--r--drivers/usb/input/ati_remote2.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/usb/input/ati_remote2.c b/drivers/usb/input/ati_remote2.c
index ea71de81ca6b..f982a2b4a7f9 100644
--- a/drivers/usb/input/ati_remote2.c
+++ b/drivers/usb/input/ati_remote2.c
@@ -142,7 +142,7 @@ static void ati_remote2_close(struct input_dev *idev)
142 usb_kill_urb(ar2->urb[1]); 142 usb_kill_urb(ar2->urb[1]);
143} 143}
144 144
145static void ati_remote2_input_mouse(struct ati_remote2 *ar2, struct pt_regs *regs) 145static void ati_remote2_input_mouse(struct ati_remote2 *ar2)
146{ 146{
147 struct input_dev *idev = ar2->idev; 147 struct input_dev *idev = ar2->idev;
148 u8 *data = ar2->buf[0]; 148 u8 *data = ar2->buf[0];
@@ -157,7 +157,6 @@ static void ati_remote2_input_mouse(struct ati_remote2 *ar2, struct pt_regs *reg
157 if (!((1 << data[0]) & mode_mask)) 157 if (!((1 << data[0]) & mode_mask))
158 return; 158 return;
159 159
160 input_regs(idev, regs);
161 input_event(idev, EV_REL, REL_X, (s8) data[1]); 160 input_event(idev, EV_REL, REL_X, (s8) data[1]);
162 input_event(idev, EV_REL, REL_Y, (s8) data[2]); 161 input_event(idev, EV_REL, REL_Y, (s8) data[2]);
163 input_sync(idev); 162 input_sync(idev);
@@ -174,7 +173,7 @@ static int ati_remote2_lookup(unsigned int hw_code)
174 return -1; 173 return -1;
175} 174}
176 175
177static void ati_remote2_input_key(struct ati_remote2 *ar2, struct pt_regs *regs) 176static void ati_remote2_input_key(struct ati_remote2 *ar2)
178{ 177{
179 struct input_dev *idev = ar2->idev; 178 struct input_dev *idev = ar2->idev;
180 u8 *data = ar2->buf[1]; 179 u8 *data = ar2->buf[1];
@@ -245,19 +244,18 @@ static void ati_remote2_input_key(struct ati_remote2 *ar2, struct pt_regs *regs)
245 return; 244 return;
246 } 245 }
247 246
248 input_regs(idev, regs);
249 input_event(idev, EV_KEY, ati_remote2_key_table[index].key_code, data[1]); 247 input_event(idev, EV_KEY, ati_remote2_key_table[index].key_code, data[1]);
250 input_sync(idev); 248 input_sync(idev);
251} 249}
252 250
253static void ati_remote2_complete_mouse(struct urb *urb, struct pt_regs *regs) 251static void ati_remote2_complete_mouse(struct urb *urb)
254{ 252{
255 struct ati_remote2 *ar2 = urb->context; 253 struct ati_remote2 *ar2 = urb->context;
256 int r; 254 int r;
257 255
258 switch (urb->status) { 256 switch (urb->status) {
259 case 0: 257 case 0:
260 ati_remote2_input_mouse(ar2, regs); 258 ati_remote2_input_mouse(ar2);
261 break; 259 break;
262 case -ENOENT: 260 case -ENOENT:
263 case -EILSEQ: 261 case -EILSEQ:
@@ -277,14 +275,14 @@ static void ati_remote2_complete_mouse(struct urb *urb, struct pt_regs *regs)
277 "%s(): usb_submit_urb() = %d\n", __FUNCTION__, r); 275 "%s(): usb_submit_urb() = %d\n", __FUNCTION__, r);
278} 276}
279 277
280static void ati_remote2_complete_key(struct urb *urb, struct pt_regs *regs) 278static void ati_remote2_complete_key(struct urb *urb)
281{ 279{
282 struct ati_remote2 *ar2 = urb->context; 280 struct ati_remote2 *ar2 = urb->context;
283 int r; 281 int r;
284 282
285 switch (urb->status) { 283 switch (urb->status) {
286 case 0: 284 case 0:
287 ati_remote2_input_key(ar2, regs); 285 ati_remote2_input_key(ar2);
288 break; 286 break;
289 case -ENOENT: 287 case -ENOENT:
290 case -EILSEQ: 288 case -EILSEQ: