diff options
author | Thomas Pugliese <thomas.pugliese@gmail.com> | 2013-06-06 11:40:49 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-06-06 14:19:27 -0400 |
commit | 7d9852a88cb76b102b60b31949d5777e645f1421 (patch) | |
tree | d71cf9993bffb9b892c45ac2aef784f7bec06991 /drivers/usb/wusbcore | |
parent | d9ea21a779278da06d0cbe989594bf542ed213d7 (diff) |
wusbcore: reduce keepalive threshold from timeout/2 to timeout/3
This patch reduces the keepalive threshold of WUSB host controllers from
timeout/2 to timeout/3. The keepalive timer fires every timeout/2 ms, but
due to rounding errors and jitter, the host may decide not to send a
keepalive at timeout/2. By the time the next timer fires, a full timeout
period may have expired causing the device to be disconnected without ever
having been sent a keepalive. Changing the keepalive threshold to
timeout/3 ensures that at least one keepalive will be sent before a device
is disconnected. The patch also updates the code to use msecs_to_jiffies
consistently.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/wusbcore')
-rw-r--r-- | drivers/usb/wusbcore/devconnect.c | 6 | ||||
-rw-r--r-- | drivers/usb/wusbcore/wusbhc.c | 5 |
2 files changed, 5 insertions, 6 deletions
diff --git a/drivers/usb/wusbcore/devconnect.c b/drivers/usb/wusbcore/devconnect.c index 1d365316960c..33a12788f9ca 100644 --- a/drivers/usb/wusbcore/devconnect.c +++ b/drivers/usb/wusbcore/devconnect.c | |||
@@ -455,8 +455,8 @@ static void __wusbhc_keep_alive(struct wusbhc *wusbhc) | |||
455 | dev_err(dev, "KEEPALIVE: device %u timed out\n", | 455 | dev_err(dev, "KEEPALIVE: device %u timed out\n", |
456 | wusb_dev->addr); | 456 | wusb_dev->addr); |
457 | __wusbhc_dev_disconnect(wusbhc, wusb_port); | 457 | __wusbhc_dev_disconnect(wusbhc, wusb_port); |
458 | } else if (time_after(jiffies, wusb_dev->entry_ts + tt/2)) { | 458 | } else if (time_after(jiffies, wusb_dev->entry_ts + tt/3)) { |
459 | /* Approaching timeout cut out, need to refresh */ | 459 | /* Approaching timeout cut off, need to refresh */ |
460 | ie->bDeviceAddress[keep_alives++] = wusb_dev->addr; | 460 | ie->bDeviceAddress[keep_alives++] = wusb_dev->addr; |
461 | } | 461 | } |
462 | } | 462 | } |
@@ -1062,7 +1062,7 @@ int wusbhc_devconnect_start(struct wusbhc *wusbhc) | |||
1062 | wusbhc->wuie_host_info = hi; | 1062 | wusbhc->wuie_host_info = hi; |
1063 | 1063 | ||
1064 | queue_delayed_work(wusbd, &wusbhc->keep_alive_timer, | 1064 | queue_delayed_work(wusbd, &wusbhc->keep_alive_timer, |
1065 | (wusbhc->trust_timeout*CONFIG_HZ)/1000/2); | 1065 | msecs_to_jiffies(wusbhc->trust_timeout / 2)); |
1066 | 1066 | ||
1067 | return 0; | 1067 | return 0; |
1068 | 1068 | ||
diff --git a/drivers/usb/wusbcore/wusbhc.c b/drivers/usb/wusbcore/wusbhc.c index 0faca16df765..c35ee4394810 100644 --- a/drivers/usb/wusbcore/wusbhc.c +++ b/drivers/usb/wusbcore/wusbhc.c | |||
@@ -75,12 +75,11 @@ static ssize_t wusb_trust_timeout_store(struct device *dev, | |||
75 | result = -EINVAL; | 75 | result = -EINVAL; |
76 | goto out; | 76 | goto out; |
77 | } | 77 | } |
78 | /* FIXME: maybe we should check for range validity? */ | 78 | wusbhc->trust_timeout = min_t(unsigned, trust_timeout, 500); |
79 | wusbhc->trust_timeout = trust_timeout; | ||
80 | cancel_delayed_work(&wusbhc->keep_alive_timer); | 79 | cancel_delayed_work(&wusbhc->keep_alive_timer); |
81 | flush_workqueue(wusbd); | 80 | flush_workqueue(wusbd); |
82 | queue_delayed_work(wusbd, &wusbhc->keep_alive_timer, | 81 | queue_delayed_work(wusbd, &wusbhc->keep_alive_timer, |
83 | (trust_timeout * CONFIG_HZ)/1000/2); | 82 | msecs_to_jiffies(wusbhc->trust_timeout / 2)); |
84 | out: | 83 | out: |
85 | return result < 0 ? result : size; | 84 | return result < 0 ? result : size; |
86 | } | 85 | } |