From patchwork Thu Feb 5 17:41:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 436900 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id F27F31400DD for ; Fri, 6 Feb 2015 04:44:19 +1100 (AEDT) Received: from localhost ([::1]:43522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJQTR-0005A1-WC for incoming@patchwork.ozlabs.org; Thu, 05 Feb 2015 12:44:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJQQv-0000Ed-VH for qemu-devel@nongnu.org; Thu, 05 Feb 2015 12:41:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YJQQp-0004mY-PQ for qemu-devel@nongnu.org; Thu, 05 Feb 2015 12:41:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56063) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJQQp-0004mR-HP for qemu-devel@nongnu.org; Thu, 05 Feb 2015 12:41:35 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t15HfYFp013529 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 5 Feb 2015 12:41:34 -0500 Received: from scv.usersys.redhat.com (vpn-63-201.rdu2.redhat.com [10.10.63.201]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t15HfVWP029823; Thu, 5 Feb 2015 12:41:33 -0500 From: John Snow To: qemu-devel@nongnu.org Date: Thu, 5 Feb 2015 12:41:13 -0500 Message-Id: <1423158090-25580-3-git-send-email-jsnow@redhat.com> In-Reply-To: <1423158090-25580-1-git-send-email-jsnow@redhat.com> References: <1423158090-25580-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: famz@redhat.com, mst@redhat.com, armbru@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, John Snow Subject: [Qemu-devel] [PATCH v3 02/19] libqos/ahci: Add ahci_port_clear helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add a helper that assists in clearing out potentially old error and FIS information from an AHCI port's data structures. This ensures we always start with a blank slate for interrupt and FIS receipt information. Signed-off-by: John Snow Reviewed-by: Paolo Bonzini --- tests/ahci-test.c | 9 ++------- tests/libqos/ahci.c | 16 ++++++++++++++++ tests/libqos/ahci.h | 1 + 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/tests/ahci-test.c b/tests/ahci-test.c index c689b62..90647f2 100644 --- a/tests/ahci-test.c +++ b/tests/ahci-test.c @@ -687,13 +687,8 @@ static void ahci_test_identify(AHCIQState *ahci) i = ahci_port_select(ahci); g_test_message("Selected port %u for test", i); - /* Clear out this port's interrupts (ignore the init register d2h fis) */ - reg = ahci_px_rreg(ahci, i, AHCI_PX_IS); - ahci_px_wreg(ahci, i, AHCI_PX_IS, reg); - g_assert_cmphex(ahci_px_rreg(ahci, i, AHCI_PX_IS), ==, 0); - - /* Wipe the FIS-Receive Buffer */ - qmemset(ahci->port[i].fb, 0x00, 0x100); + /* Clear out the FIS Receive area and any pending interrupts. */ + ahci_port_clear(ahci, i); /* Create a Command Table buffer. 0x80 is the smallest with a PRDTL of 0. */ /* We need at least one PRD, so round up to the nearest 0x80 multiple. */ diff --git a/tests/libqos/ahci.c b/tests/libqos/ahci.c index 8874790..af2eb97 100644 --- a/tests/libqos/ahci.c +++ b/tests/libqos/ahci.c @@ -294,3 +294,19 @@ unsigned ahci_port_select(AHCIQState *ahci) g_assert(i < 32); return i; } + +/** + * Clear a port's interrupts and status information prior to a test. + */ +void ahci_port_clear(AHCIQState *ahci, uint8_t port) +{ + uint32_t reg; + + /* Clear out this port's interrupts (ignore the init register d2h fis) */ + reg = ahci_px_rreg(ahci, port, AHCI_PX_IS); + ahci_px_wreg(ahci, port, AHCI_PX_IS, reg); + g_assert_cmphex(ahci_px_rreg(ahci, port, AHCI_PX_IS), ==, 0); + + /* Wipe the FIS-Recieve Buffer */ + qmemset(ahci->port[port].fb, 0x00, 0x100); +} diff --git a/tests/libqos/ahci.h b/tests/libqos/ahci.h index b3992e1..39ba94e 100644 --- a/tests/libqos/ahci.h +++ b/tests/libqos/ahci.h @@ -432,5 +432,6 @@ void ahci_pci_enable(AHCIQState *ahci); void start_ahci_device(AHCIQState *ahci); void ahci_hba_enable(AHCIQState *ahci); unsigned ahci_port_select(AHCIQState *ahci); +void ahci_port_clear(AHCIQState *ahci, uint8_t port); #endif