Received: from eggs.gnu.org ([2001:4830:134:3::10]:35398) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UmNSW-0004zo-C3 for qemu-devel@nongnu.org; Tue, 11 Jun 2013 08:13:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UmNSV-00061O-0b for qemu-devel@nongnu.org; Tue, 11 Jun 2013 08:13:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:21594) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UmNSU-000619-P8 for qemu-devel@nongnu.org; Tue, 11 Jun 2013 08:13:54 -0400 Date: Tue, 11 Jun 2013 14:13:37 +0200 From: Kevin Wolf Message-ID: <20130611121337.GG2379@dhcp-200-207.str.redhat.com> References: <1370888600-25388-1-git-send-email-mdroth@linux.vnet.ibm.com> <51B6F660.5090004@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <51B6F660.5090004@suse.de> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] ide-test: fix failure for test_flush List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?iso-8859-1?Q?F=E4rber?= Cc: stefanha@redhat.com, Michael Roth , Anthony Liguori , qemu-devel@nongnu.org Am 11.06.2013 um 12:05 hat Andreas F=E4rber geschrieben: > 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 settin= g > > 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 unse= t. > >=20 > > 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. > >=20 > > 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 g= uest > > would determine whether or not the device is still busy. > >=20 > > Signed-off-by: Michael Roth > > --- > > tests/ide-test.c | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > >=20 > > 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 =3D inb(IDE_BASE + reg_device); > > g_assert_cmpint(data & DEV, =3D=3D, 0); > > =20 > > - data =3D inb(IDE_BASE + reg_status); > > + do { > > + data =3D inb(IDE_BASE + reg_status); > > + } while (data & BSY); >=20 > 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? FWIW, the floppy test already has a busy wait for IRQs, which results in the same failure mode. I think it's okay for a test case, but if someone felt like implementing timeouts, that would be great and we could apply them on top. Kevin