qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] ide-test: fix failure for test_flush


From: Andreas Färber
Subject: Re: [Qemu-devel] [PATCH] ide-test: fix failure for test_flush
Date: Tue, 11 Jun 2013 12:05:20 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6

Am 10.06.2013 20:23, schrieb Michael Roth:
> bd07684aacfb61668ae2c25b7dd00b64f3d7c7f3 added a test to ensure BSY
> flag is set when a flush request is in flight. It does this by setting
> a blkdebug breakpoint on flush_to_os before issuing a CMD_FLUSH_CACHE.
> It then resumes CMD_FLUSH_CACHE operation and checks that BSY is unset.
> 
> The actual unsetting of BSY does not occur until ide_flush_cb gets
> called in a bh, however, so in some cases this check will race with
> the actual completion.
> 
> Fix this by polling the ide status register until BSY flag gets unset
> before we do our final sanity checks. According to
> f68ec8379e88502b4841a110c070e9b118d3151c this is in line with how a guest
> would determine whether or not the device is still busy.
> 
> Signed-off-by: Michael Roth <address@hidden>
> ---
>  tests/ide-test.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/ide-test.c b/tests/ide-test.c
> index 828e71a..7e2eb94 100644
> --- a/tests/ide-test.c
> +++ b/tests/ide-test.c
> @@ -455,7 +455,10 @@ static void test_flush(void)
>      data = inb(IDE_BASE + reg_device);
>      g_assert_cmpint(data & DEV, ==, 0);
>  
> -    data = inb(IDE_BASE + reg_status);
> +    do {
> +        data = inb(IDE_BASE + reg_status);
> +    } while (data & BSY);

Is a busy loop really a good idea for a qtest? CC'ing Anthony.
For the theoretical case that BSY is not cleared it might be better to
terminate the loop with some timeout to get an assertion failure or at
least use some form of sleep() to yield the thread while waiting?

> +
>      assert_bit_set(data, DRDY);
>      assert_bit_clear(data, BSY | DF | ERR | DRQ);

This BSY clear assertion will always be true now due to the above while
condition; it won't if we change it though.

Regards,
Andreas

>  

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



reply via email to

[Prev in Thread] Current Thread [Next in Thread]