From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUlNZ-00069M-3n for qemu-devel@nongnu.org; Thu, 18 Sep 2014 19:44:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XUlNC-0003cp-FG for qemu-devel@nongnu.org; Thu, 18 Sep 2014 19:44:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41693) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUlNC-0003Sf-6l for qemu-devel@nongnu.org; Thu, 18 Sep 2014 19:44:26 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8INiKrb014491 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 18 Sep 2014 19:44:20 -0400 From: John Snow Date: Thu, 18 Sep 2014 19:43:32 -0400 Message-Id: <1411083819-9284-9-git-send-email-jsnow@redhat.com> In-Reply-To: <1411083819-9284-1-git-send-email-jsnow@redhat.com> References: <1411083819-9284-1-git-send-email-jsnow@redhat.com> Subject: [Qemu-devel] [PATCH 08/15] qtest/ahci: Add issue_command helper List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, mst@redhat.com, armbru@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, John Snow issue_command is a small routine that informs the AHCI device that we have finalized our command and we'd wish for the device to begin processing it. issue_command polls the AHCI device waiting for the device to finish, in order to achieve a synchronous effect. Signed-off-by: John Snow --- tests/ahci-test.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/tests/ahci-test.c b/tests/ahci-test.c index fcf5ffb..4615681 100644 --- a/tests/ahci-test.c +++ b/tests/ahci-test.c @@ -1343,6 +1343,26 @@ static void set_command_header(AHCIState *ahci, uint8_t px, memwrite(ba, cmd, sizeof(AHCICommand)); } +/** + * Issue Command #cx via PxCI and, if ncq is true, PxSACT + */ +static void issue_command(AHCIState *ahci, uint8_t px, + uint8_t cx, bool ncq) +{ + if (ncq) { + PX_WREG(px, AHCI_PX_SACT, (1 << cx)); + } + + PX_WREG(px, AHCI_PX_CI, (1 << cx)); + /* We can't rely on STS_BSY until the command has started processing. + * Therefore, we also use the Command Issue bit as indication of + * a command in-flight. */ + while (BITSET(PX_RREG(px, AHCI_PX_TFD), AHCI_PX_TFD_STS_BSY) || + BITSET(PX_RREG(px, AHCI_PX_CI), (1 << cx))) { + usleep(50); + } +} + static void destroy_command(AHCIState *ahci, uint8_t px, uint8_t cx) { AHCICommand cmd; @@ -1541,10 +1561,7 @@ static void ahci_test_identify(AHCIState *ahci) g_assert_cmphex(PX_RREG(i, AHCI_PX_IS), ==, 0); /* Issue Command #cx via PxCI */ - PX_WREG(i, AHCI_PX_CI, (1 << cx)); - while (BITSET(PX_RREG(i, AHCI_PX_TFD), AHCI_PX_TFD_STS_BSY)) { - usleep(50); - } + issue_command(ahci, i, cx, 0); port_check_error(ahci, i); /* Check for expected interrupts */ -- 1.9.3