aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/input/usbtouchscreen.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/usbtouchscreen.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/usbtouchscreen.c')
-rw-r--r--drivers/usb/input/usbtouchscreen.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/usb/input/usbtouchscreen.c b/drivers/usb/input/usbtouchscreen.c
index 923e22db18d4..f26c1cd1129f 100644
--- a/drivers/usb/input/usbtouchscreen.c
+++ b/drivers/usb/input/usbtouchscreen.c
@@ -61,7 +61,7 @@ struct usbtouch_device_info {
61 int rept_size; 61 int rept_size;
62 int flags; 62 int flags;
63 63
64 void (*process_pkt) (struct usbtouch_usb *usbtouch, struct pt_regs *regs, unsigned char *pkt, int len); 64 void (*process_pkt) (struct usbtouch_usb *usbtouch, unsigned char *pkt, int len);
65 int (*get_pkt_len) (unsigned char *pkt, int len); 65 int (*get_pkt_len) (unsigned char *pkt, int len);
66 int (*read_data) (unsigned char *pkt, int *x, int *y, int *touch, int *press); 66 int (*read_data) (unsigned char *pkt, int *x, int *y, int *touch, int *press);
67 int (*init) (struct usbtouch_usb *usbtouch); 67 int (*init) (struct usbtouch_usb *usbtouch);
@@ -91,7 +91,6 @@ struct usbtouch_usb {
91 91
92#ifdef MULTI_PACKET 92#ifdef MULTI_PACKET
93static void usbtouch_process_multi(struct usbtouch_usb *usbtouch, 93static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
94 struct pt_regs *regs,
95 unsigned char *pkt, int len); 94 unsigned char *pkt, int len);
96#endif 95#endif
97 96
@@ -397,7 +396,7 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
397 * Generic Part 396 * Generic Part
398 */ 397 */
399static void usbtouch_process_pkt(struct usbtouch_usb *usbtouch, 398static void usbtouch_process_pkt(struct usbtouch_usb *usbtouch,
400 struct pt_regs *regs, unsigned char *pkt, int len) 399 unsigned char *pkt, int len)
401{ 400{
402 int x, y, touch, press; 401 int x, y, touch, press;
403 struct usbtouch_device_info *type = usbtouch->type; 402 struct usbtouch_device_info *type = usbtouch->type;
@@ -405,7 +404,6 @@ static void usbtouch_process_pkt(struct usbtouch_usb *usbtouch,
405 if (!type->read_data(pkt, &x, &y, &touch, &press)) 404 if (!type->read_data(pkt, &x, &y, &touch, &press))
406 return; 405 return;
407 406
408 input_regs(usbtouch->input, regs);
409 input_report_key(usbtouch->input, BTN_TOUCH, touch); 407 input_report_key(usbtouch->input, BTN_TOUCH, touch);
410 408
411 if (swap_xy) { 409 if (swap_xy) {
@@ -423,7 +421,6 @@ static void usbtouch_process_pkt(struct usbtouch_usb *usbtouch,
423 421
424#ifdef MULTI_PACKET 422#ifdef MULTI_PACKET
425static void usbtouch_process_multi(struct usbtouch_usb *usbtouch, 423static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
426 struct pt_regs *regs,
427 unsigned char *pkt, int len) 424 unsigned char *pkt, int len)
428{ 425{
429 unsigned char *buffer; 426 unsigned char *buffer;
@@ -460,7 +457,7 @@ static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
460 if (usbtouch->buf_len + tmp >= usbtouch->type->rept_size) 457 if (usbtouch->buf_len + tmp >= usbtouch->type->rept_size)
461 goto out_flush_buf; 458 goto out_flush_buf;
462 memcpy(usbtouch->buffer + usbtouch->buf_len, pkt, tmp); 459 memcpy(usbtouch->buffer + usbtouch->buf_len, pkt, tmp);
463 usbtouch_process_pkt(usbtouch, regs, usbtouch->buffer, pkt_len); 460 usbtouch_process_pkt(usbtouch, usbtouch->buffer, pkt_len);
464 461
465 buffer = pkt + tmp; 462 buffer = pkt + tmp;
466 buf_len = len - tmp; 463 buf_len = len - tmp;
@@ -481,7 +478,7 @@ static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
481 478
482 /* full packet: process */ 479 /* full packet: process */
483 if (likely((pkt_len > 0) && (pkt_len <= buf_len - pos))) { 480 if (likely((pkt_len > 0) && (pkt_len <= buf_len - pos))) {
484 usbtouch_process_pkt(usbtouch, regs, buffer + pos, pkt_len); 481 usbtouch_process_pkt(usbtouch, buffer + pos, pkt_len);
485 } else { 482 } else {
486 /* incomplete packet: save in buffer */ 483 /* incomplete packet: save in buffer */
487 memcpy(usbtouch->buffer, buffer + pos, buf_len - pos); 484 memcpy(usbtouch->buffer, buffer + pos, buf_len - pos);
@@ -498,7 +495,7 @@ out_flush_buf:
498#endif 495#endif
499 496
500 497
501static void usbtouch_irq(struct urb *urb, struct pt_regs *regs) 498static void usbtouch_irq(struct urb *urb)
502{ 499{
503 struct usbtouch_usb *usbtouch = urb->context; 500 struct usbtouch_usb *usbtouch = urb->context;
504 int retval; 501 int retval;
@@ -525,7 +522,7 @@ static void usbtouch_irq(struct urb *urb, struct pt_regs *regs)
525 goto exit; 522 goto exit;
526 } 523 }
527 524
528 usbtouch->type->process_pkt(usbtouch, regs, usbtouch->data, urb->actual_length); 525 usbtouch->type->process_pkt(usbtouch, usbtouch->data, urb->actual_length);
529 526
530exit: 527exit:
531 retval = usb_submit_urb(urb, GFP_ATOMIC); 528 retval = usb_submit_urb(urb, GFP_ATOMIC);