Use nanosleep() for long, imprecise delays

There are some areas in flashrom where we delay for very long
periods of time, like 1sec. These are isolated cases that do not
require a high level of precision like in the loops that are
directly involved with sending commands.

The profiling team noticed that flashrom has an abnormally high
overhead due to the way delays are handled when we use the busy
loop instead of trusting nanosleep(). This patch attempts to
alleviate some of that overhead by using nanosleep() for long delay
periods where a small extra delay won't matter.

BUG=b:19454925
BRANCH=none
TEST=benchmarked on Storm, Peppy, and Speedy, checked that
read and erase/write times stayed fairly consistent.

Signed-off-by: David Hendricks <dhendrix@chromium.org>
Change-Id: I10da3fd21df926948bce63219da2625c4b10e149
Reviewed-on: https://chromium-review.googlesource.com/263796
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
1 file changed