Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: Patch to align the various USB timers to fire at the same time

This patch modifies the USB regular 250ms timer to be "perfectly aligned" to
the second and quarters thereof. This change is there to make sure that if
you have multiple USB ports, the timers for all these ports will fire at the
same time rather than all spread out. All spread out wakes the CPU up from
power saving idle a lot more than needed...


Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Arjan van de Ven and committed by
Greg Kroah-Hartman
01cd0819 fc4cbd75

+6 -4
+6 -4
drivers/usb/core/hcd.c
··· 582 582 } 583 583 584 584 /* The USB 2.0 spec says 256 ms. This is close enough and won't 585 - * exceed that limit if HZ is 100. */ 585 + * exceed that limit if HZ is 100. The math is more clunky than 586 + * maybe expected, this is to make sure that all timers for USB devices 587 + * fire at the same time to give the CPU a break inbetween */ 586 588 if (hcd->uses_new_polling ? hcd->poll_rh : 587 589 (length == 0 && hcd->status_urb != NULL)) 588 - mod_timer (&hcd->rh_timer, jiffies + msecs_to_jiffies(250)); 590 + mod_timer (&hcd->rh_timer, (jiffies/(HZ/4) + 1) * (HZ/4)); 589 591 } 590 592 EXPORT_SYMBOL_GPL(usb_hcd_poll_rh_status); 591 593 ··· 616 614 urb->hcpriv = hcd; /* indicate it's queued */ 617 615 618 616 if (!hcd->uses_new_polling) 619 - mod_timer (&hcd->rh_timer, jiffies + 620 - msecs_to_jiffies(250)); 617 + mod_timer (&hcd->rh_timer, 618 + (jiffies/(HZ/4) + 1) * (HZ/4)); 621 619 622 620 /* If a status change has already occurred, report it ASAP */ 623 621 else if (hcd->poll_pending)