diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2008-05-20 16:59:33 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-05-29 16:59:04 -0400 |
commit | fa38dfcc56b5f6cce787f9aaa5d1830509213802 (patch) | |
tree | af6c68e248233434cce1b8a4bcf361039aa5ef8f /drivers | |
parent | b40e43fcc532fa44a375a37d592e32cd0d50fe7a (diff) |
USB: EHCI: fix performance regression
This patch (as1099) fixes a performance regression in ehci-hcd. The
fundamental problem is that queue headers get removed from the
schedule too quickly, since the code checks for a counter advancing
rather than making an actual time-based check. The latency involved
in removing the queue header and then relinking it can severely
degrade certain kinds of workloads.
The patch replaces a simple counter with a timestamp derived from the
controller's uframe value. In addition, the delay for unlinking an
idle queue header is increased from 5 ms to 10 ms; since some
controllers (nVidia) have a latency of up to 1 ms for unlinking, this
reduces the relative impact from 20% to 10%.
Finally, a logical error left over from the IAA watchdog-timer
conversion is corrected. Now the driver will always either unlink an
idle queue header or set up a timer to unlink it later. The old code
would sometimes fail to do either.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: David Brownell <david-b@pacbell.net>
Cc: Leonid <leonidv11@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/host/ehci-hcd.c | 3 | ||||
-rw-r--r-- | drivers/usb/host/ehci-q.c | 15 |
2 files changed, 10 insertions, 8 deletions
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 369a8a5ea7bb..3e3c5d3ea0ad 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -84,7 +84,8 @@ static const char hcd_name [] = "ehci_hcd"; | |||
84 | #define EHCI_IAA_MSECS 10 /* arbitrary */ | 84 | #define EHCI_IAA_MSECS 10 /* arbitrary */ |
85 | #define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */ | 85 | #define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */ |
86 | #define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */ | 86 | #define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */ |
87 | #define EHCI_SHRINK_JIFFIES (HZ/200) /* async qh unlink delay */ | 87 | #define EHCI_SHRINK_JIFFIES (HZ/100) /* async qh unlink delay */ |
88 | #define EHCI_SHRINK_UFRAMES (10*8) /* same value in uframes */ | ||
88 | 89 | ||
89 | /* Initial IRQ latency: faster than hw default */ | 90 | /* Initial IRQ latency: faster than hw default */ |
90 | static int log2_irq_thresh = 0; // 0 to 6 | 91 | static int log2_irq_thresh = 0; // 0 to 6 |
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index b85b54160cda..5200481deb27 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c | |||
@@ -1116,8 +1116,7 @@ static void scan_async (struct ehci_hcd *ehci) | |||
1116 | struct ehci_qh *qh; | 1116 | struct ehci_qh *qh; |
1117 | enum ehci_timer_action action = TIMER_IO_WATCHDOG; | 1117 | enum ehci_timer_action action = TIMER_IO_WATCHDOG; |
1118 | 1118 | ||
1119 | if (!++(ehci->stamp)) | 1119 | ehci->stamp = ehci_readl(ehci, &ehci->regs->frame_index); |
1120 | ehci->stamp++; | ||
1121 | timer_action_done (ehci, TIMER_ASYNC_SHRINK); | 1120 | timer_action_done (ehci, TIMER_ASYNC_SHRINK); |
1122 | rescan: | 1121 | rescan: |
1123 | qh = ehci->async->qh_next.qh; | 1122 | qh = ehci->async->qh_next.qh; |
@@ -1148,12 +1147,14 @@ rescan: | |||
1148 | * doesn't stay idle for long. | 1147 | * doesn't stay idle for long. |
1149 | * (plus, avoids some kind of re-activation race.) | 1148 | * (plus, avoids some kind of re-activation race.) |
1150 | */ | 1149 | */ |
1151 | if (list_empty (&qh->qtd_list)) { | 1150 | if (list_empty(&qh->qtd_list) && |
1152 | if (qh->stamp == ehci->stamp) | 1151 | qh->qh_state == QH_STATE_LINKED) { |
1152 | if (!ehci->reclaim && | ||
1153 | ((ehci->stamp - qh->stamp) & 8191) >= | ||
1154 | EHCI_SHRINK_UFRAMES) | ||
1155 | start_unlink_async(ehci, qh); | ||
1156 | else | ||
1153 | action = TIMER_ASYNC_SHRINK; | 1157 | action = TIMER_ASYNC_SHRINK; |
1154 | else if (!ehci->reclaim | ||
1155 | && qh->qh_state == QH_STATE_LINKED) | ||
1156 | start_unlink_async (ehci, qh); | ||
1157 | } | 1158 | } |
1158 | 1159 | ||
1159 | qh = qh->qh_next.qh; | 1160 | qh = qh->qh_next.qh; |