From 65b8e5cbdddc86474372bdb48dc233b06710a576 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Mon, 14 May 2012 13:47:20 -0400 Subject: [PATCH] USB: EHCI: improve full-speed isochronous scheduling routine This patch (as1555) improves the code ehci-hcd uses while checking the periodic schedule for isochronous transfers to full-speed devices. In addition to making sure that a new transfer does not violate the restrictions on the high-speed schedule, it also has to check the restrictions on the full-speed part of the bus, i.e., the part beyond the Transaction Translator (TT). It does this by calling tt_available() (or tt_no_collision() if CONFIG_USB_EHCI_TT_NEWSCHED isn't enabled). However it calls that routine on each pass through a loop over the frames being modified, which is an unnecessary expense because tt_available() (or tt_no_collision) already does its own loop over frames. It is sufficient to do the check just once, before starting the loop. In addition, the function calls incorrectly converted the transfer's period from microframes to frames by doing a left shift instead of a right shift. The patch fixes this while moving the calls. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ehci-sched.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index cb76679..33182c6 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c @@ -1331,34 +1331,36 @@ sitd_slot_ok ( if (mask & ~0xffff) return 0; + /* check bandwidth */ + uframe %= period_uframes; + frame = uframe >> 3; + +#ifdef CONFIG_USB_EHCI_TT_NEWSCHED + /* The tt's fullspeed bus bandwidth must be available. + * tt_available scheduling guarantees 10+% for control/bulk. + */ + uf = uframe & 7; + if (!tt_available(ehci, period_uframes >> 3, + stream->udev, frame, uf, stream->tt_usecs)) + return 0; +#else + /* tt must be idle for start(s), any gap, and csplit. + * assume scheduling slop leaves 10+% for control/bulk. + */ + if (!tt_no_collision(ehci, period_uframes >> 3, + stream->udev, frame, mask)) + return 0; +#endif + /* this multi-pass logic is simple, but performance may * suffer when the schedule data isn't cached. */ - - /* check bandwidth */ - uframe %= period_uframes; do { u32 max_used; frame = uframe >> 3; uf = uframe & 7; -#ifdef CONFIG_USB_EHCI_TT_NEWSCHED - /* The tt's fullspeed bus bandwidth must be available. - * tt_available scheduling guarantees 10+% for control/bulk. - */ - if (!tt_available (ehci, period_uframes << 3, - stream->udev, frame, uf, stream->tt_usecs)) - return 0; -#else - /* tt must be idle for start(s), any gap, and csplit. - * assume scheduling slop leaves 10+% for control/bulk. - */ - if (!tt_no_collision (ehci, period_uframes << 3, - stream->udev, frame, mask)) - return 0; -#endif - /* check starts (OUT uses more than one) */ max_used = ehci->uframe_periodic_max - stream->usecs; for (tmp = stream->raw_mask & 0xff; tmp; tmp >>= 1, uf++) { -- 2.7.4