aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh/adbhid.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/macintosh/adbhid.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/macintosh/adbhid.c')
-rw-r--r--drivers/macintosh/adbhid.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/drivers/macintosh/adbhid.c b/drivers/macintosh/adbhid.c
index b7fb367808d8..5066e7a8ea9c 100644
--- a/drivers/macintosh/adbhid.c
+++ b/drivers/macintosh/adbhid.c
@@ -222,7 +222,7 @@ static struct adbhid *adbhid[16];
222 222
223static void adbhid_probe(void); 223static void adbhid_probe(void);
224 224
225static void adbhid_input_keycode(int, int, int, struct pt_regs *); 225static void adbhid_input_keycode(int, int, int);
226 226
227static void init_trackpad(int id); 227static void init_trackpad(int id);
228static void init_trackball(int id); 228static void init_trackball(int id);
@@ -253,7 +253,7 @@ static struct adb_ids buttons_ids;
253#define ADBMOUSE_MACALLY2 9 /* MacAlly 2-button mouse */ 253#define ADBMOUSE_MACALLY2 9 /* MacAlly 2-button mouse */
254 254
255static void 255static void
256adbhid_keyboard_input(unsigned char *data, int nb, struct pt_regs *regs, int apoll) 256adbhid_keyboard_input(unsigned char *data, int nb, int apoll)
257{ 257{
258 int id = (data[0] >> 4) & 0x0f; 258 int id = (data[0] >> 4) & 0x0f;
259 259
@@ -266,13 +266,13 @@ adbhid_keyboard_input(unsigned char *data, int nb, struct pt_regs *regs, int apo
266 /* first check this is from register 0 */ 266 /* first check this is from register 0 */
267 if (nb != 3 || (data[0] & 3) != KEYB_KEYREG) 267 if (nb != 3 || (data[0] & 3) != KEYB_KEYREG)
268 return; /* ignore it */ 268 return; /* ignore it */
269 adbhid_input_keycode(id, data[1], 0, regs); 269 adbhid_input_keycode(id, data[1], 0);
270 if (!(data[2] == 0xff || (data[2] == 0x7f && data[1] == 0x7f))) 270 if (!(data[2] == 0xff || (data[2] == 0x7f && data[1] == 0x7f)))
271 adbhid_input_keycode(id, data[2], 0, regs); 271 adbhid_input_keycode(id, data[2], 0);
272} 272}
273 273
274static void 274static void
275adbhid_input_keycode(int id, int keycode, int repeat, struct pt_regs *regs) 275adbhid_input_keycode(int id, int keycode, int repeat)
276{ 276{
277 struct adbhid *ahid = adbhid[id]; 277 struct adbhid *ahid = adbhid[id];
278 int up_flag; 278 int up_flag;
@@ -282,7 +282,6 @@ adbhid_input_keycode(int id, int keycode, int repeat, struct pt_regs *regs)
282 282
283 switch (keycode) { 283 switch (keycode) {
284 case ADB_KEY_CAPSLOCK: /* Generate down/up events for CapsLock everytime. */ 284 case ADB_KEY_CAPSLOCK: /* Generate down/up events for CapsLock everytime. */
285 input_regs(ahid->input, regs);
286 input_report_key(ahid->input, KEY_CAPSLOCK, 1); 285 input_report_key(ahid->input, KEY_CAPSLOCK, 1);
287 input_report_key(ahid->input, KEY_CAPSLOCK, 0); 286 input_report_key(ahid->input, KEY_CAPSLOCK, 0);
288 input_sync(ahid->input); 287 input_sync(ahid->input);
@@ -338,7 +337,6 @@ adbhid_input_keycode(int id, int keycode, int repeat, struct pt_regs *regs)
338 } 337 }
339 338
340 if (adbhid[id]->keycode[keycode]) { 339 if (adbhid[id]->keycode[keycode]) {
341 input_regs(adbhid[id]->input, regs);
342 input_report_key(adbhid[id]->input, 340 input_report_key(adbhid[id]->input,
343 adbhid[id]->keycode[keycode], !up_flag); 341 adbhid[id]->keycode[keycode], !up_flag);
344 input_sync(adbhid[id]->input); 342 input_sync(adbhid[id]->input);
@@ -349,7 +347,7 @@ adbhid_input_keycode(int id, int keycode, int repeat, struct pt_regs *regs)
349} 347}
350 348
351static void 349static void
352adbhid_mouse_input(unsigned char *data, int nb, struct pt_regs *regs, int autopoll) 350adbhid_mouse_input(unsigned char *data, int nb, int autopoll)
353{ 351{
354 int id = (data[0] >> 4) & 0x0f; 352 int id = (data[0] >> 4) & 0x0f;
355 353
@@ -432,8 +430,6 @@ adbhid_mouse_input(unsigned char *data, int nb, struct pt_regs *regs, int autopo
432 break; 430 break;
433 } 431 }
434 432
435 input_regs(adbhid[id]->input, regs);
436
437 input_report_key(adbhid[id]->input, BTN_LEFT, !((data[1] >> 7) & 1)); 433 input_report_key(adbhid[id]->input, BTN_LEFT, !((data[1] >> 7) & 1));
438 input_report_key(adbhid[id]->input, BTN_MIDDLE, !((data[2] >> 7) & 1)); 434 input_report_key(adbhid[id]->input, BTN_MIDDLE, !((data[2] >> 7) & 1));
439 435
@@ -449,7 +445,7 @@ adbhid_mouse_input(unsigned char *data, int nb, struct pt_regs *regs, int autopo
449} 445}
450 446
451static void 447static void
452adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int autopoll) 448adbhid_buttons_input(unsigned char *data, int nb, int autopoll)
453{ 449{
454 int id = (data[0] >> 4) & 0x0f; 450 int id = (data[0] >> 4) & 0x0f;
455 451
@@ -458,8 +454,6 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto
458 return; 454 return;
459 } 455 }
460 456
461 input_regs(adbhid[id]->input, regs);
462
463 switch (adbhid[id]->original_handler_id) { 457 switch (adbhid[id]->original_handler_id) {
464 default: 458 default:
465 case 0x02: /* Adjustable keyboard button device */ 459 case 0x02: /* Adjustable keyboard button device */