From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, jsnow@redhat.com
Subject: [Qemu-devel] [PULL 4/4] ide-test: fix timeouts
Date: Wed, 25 Nov 2015 15:25:42 -0500 [thread overview]
Message-ID: <1448483142-32658-5-git-send-email-jsnow@redhat.com> (raw)
In-Reply-To: <1448483142-32658-1-git-send-email-jsnow@redhat.com>
Use explicit timeouts instead of trying to approximate it by counting
the cumulative duration of nsleep calls.
In practice, the timeout if inb() dwarfed the nsleep delays, and as a
result the real timeout value became a lot larger than 5 seconds.
So: change the semantics from "Not sooner than 5 seconds" to "no more
than 5 seconds" to ensure we don't hang the tester for very long.
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1448393771-15483-2-git-send-email-jsnow@redhat.com
---
tests/ide-test.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/tests/ide-test.c b/tests/ide-test.c
index 46763db..c3aacd2 100644
--- a/tests/ide-test.c
+++ b/tests/ide-test.c
@@ -642,15 +642,19 @@ static void nsleep(int64_t nsecs)
static uint8_t ide_wait_clear(uint8_t flag)
{
- int i;
uint8_t data;
+ time_t st;
/* Wait with a 5 second timeout */
- for (i = 0; i <= 12500000; i++) {
+ time(&st);
+ while (true) {
data = inb(IDE_BASE + reg_status);
if (!(data & flag)) {
return data;
}
+ if (difftime(time(NULL), st) > 5.0) {
+ break;
+ }
nsleep(400);
}
g_assert_not_reached();
@@ -658,14 +662,18 @@ static uint8_t ide_wait_clear(uint8_t flag)
static void ide_wait_intr(int irq)
{
- int i;
+ time_t st;
bool intr;
- for (i = 0; i <= 12500000; i++) {
+ time(&st);
+ while (true) {
intr = get_irq(irq);
if (intr) {
return;
}
+ if (difftime(time(NULL), st) > 5.0) {
+ break;
+ }
nsleep(400);
}
--
2.4.3
next prev parent reply other threads:[~2015-11-25 20:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-25 20:25 [Qemu-devel] [PULL 0/4] Ide patches John Snow
2015-11-25 20:25 ` [Qemu-devel] [PULL 1/4] ide-test: cdrom_pio_impl fixup John Snow
2015-11-25 20:25 ` [Qemu-devel] [PULL 2/4] atapi: Account for failed and invalid operations in cd_read_sector() John Snow
2015-11-25 20:25 ` [Qemu-devel] [PULL 3/4] atapi: Fix code indentation John Snow
2015-11-25 20:25 ` John Snow [this message]
2015-11-26 10:23 ` [Qemu-devel] [PULL 0/4] Ide patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1448483142-32658-5-git-send-email-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).