diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2011-12-08 21:06:14 +0000 |
---|---|---|
committer | Stefan Reinauer <reinauer@chromium.org> | 2011-12-20 16:52:31 -0800 |
commit | 74e96dbcd1a384f6540d08bec1000ee0e64d59ac (patch) | |
tree | c37cb25a3be8213b723e21aa3df33a7edbc6a812 /lib | |
parent | c64225be59d7f12f38bf9b6a721a4ce82ecdfd19 (diff) |
CHROMIUMOS: optimize USB mass storage detection
Instead of doing USB enumeration in a tight loop,
let's check first if anything has changed first,
then do the enumeration only if needed.
This saves time (the full enumeration currently takes 1.2s while the
insertion/removal detection runs in 19ms), and will allow to do the
keypress detection on USB keyboard in parallel.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BUG=chrome-os-partner:5752 chrome-os-partner:6344
TEST=on Lumpy, insert and remove a USB key in recovery mode.
Change-Id: I3ba084caa41234c8629771e9dd8b06b811712cdb
Reviewed-on: https://gerrit.chromium.org/gerrit/13250
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
Tested-by: Stefan Reinauer <reinauer@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vbexport/boot_device_usb.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/vbexport/boot_device_usb.c b/lib/vbexport/boot_device_usb.c index d261e4e964..e8872e2c4e 100644 --- a/lib/vbexport/boot_device_usb.c +++ b/lib/vbexport/boot_device_usb.c @@ -15,20 +15,35 @@ #include <vboot_api.h> +static int is_enumerated; + static int boot_device_usb_start(uint32_t disk_flags) { + int enumerate = 1; + /* If we aren't looking for removable disks, skip USB */ if (!(disk_flags & VB_DISK_FLAG_REMOVABLE)) return 0; /* - * We should stop all USB devices first. Otherwise we can't detect any - * new devices. + * if the USB devices have already been enumerated, redo it + * only if something has been plugged on unplugged. */ - usb_stop(); + if (is_enumerated) + enumerate = usb_detect_change(); - if (usb_init() >= 0) - usb_stor_scan(/*mode=*/1); + if (enumerate) { + /* + * We should stop all USB devices first. Otherwise we can't + * detect any new devices. + */ + usb_stop(); + + if (usb_init() >= 0) { + usb_stor_scan(/*mode=*/1); + is_enumerated = 1; + } + } return 1; } |