From patchwork Wed Sep 14 07:51:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cao jin X-Patchwork-Id: 9330783 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 247B960231 for ; Wed, 14 Sep 2016 08:03:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1425629A9A for ; Wed, 14 Sep 2016 08:03:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07A2229A9D; Wed, 14 Sep 2016 08:03:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3FC7829A9A for ; Wed, 14 Sep 2016 08:03:38 +0000 (UTC) Received: from localhost ([::1]:54042 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bk5AP-0000R1-6o for patchwork-qemu-devel@patchwork.kernel.org; Wed, 14 Sep 2016 04:03:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bk4yG-00088A-QQ for qemu-devel@nongnu.org; Wed, 14 Sep 2016 03:51:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bk4yF-0002ee-15 for qemu-devel@nongnu.org; Wed, 14 Sep 2016 03:51:04 -0400 Received: from [59.151.112.132] (port=55931 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bk4yE-0002bL-KR for qemu-devel@nongnu.org; Wed, 14 Sep 2016 03:51:02 -0400 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="10970210" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 14 Sep 2016 15:50:57 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id 99E514042406; Wed, 14 Sep 2016 15:50:53 +0800 (CST) Received: from G08FNSTD140223.g08.fujitsu.local (10.167.226.69) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.279.2; Wed, 14 Sep 2016 15:50:52 +0800 From: Cao jin To: Date: Wed, 14 Sep 2016 15:51:04 +0800 Message-ID: <1473839464-8670-9-git-send-email-caoj.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1473839464-8670-1-git-send-email-caoj.fnst@cn.fujitsu.com> References: <1473839464-8670-1-git-send-email-caoj.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.69] X-yoursite-MailScanner-ID: 99E514042406.A8C57 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: caoj.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH v3 8/8] vmxnet3: remove unnecessary internal msix state flag X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Fleytman , Marcel Apfelbaum , Jason Wang , Markus Armbruster , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The corresponding msi flag is already dropped in commit 1070048e. CC: Dmitry Fleytman CC: Jason Wang CC: Michael S. Tsirkin CC: Markus Armbruster CC: Marcel Apfelbaum Signed-off-by: Cao jin --- hw/net/vmxnet3.c | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index 7d44af1..1decb53 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -281,8 +281,6 @@ typedef struct { Vmxnet3RxqDescr rxq_descr[VMXNET3_DEVICE_MAX_RX_QUEUES]; Vmxnet3TxqDescr txq_descr[VMXNET3_DEVICE_MAX_TX_QUEUES]; - /* Whether MSI-X support was installed successfully */ - bool msix_used; hwaddr drv_shmem; hwaddr temp_shared_guest_driver_memory; @@ -359,7 +357,7 @@ static bool _vmxnet3_assert_interrupt_line(VMXNET3State *s, uint32_t int_idx) { PCIDevice *d = PCI_DEVICE(s); - if (s->msix_used && msix_enabled(d)) { + if (msix_enabled(d)) { VMW_IRPRN("Sending MSI-X notification for vector %u", int_idx); msix_notify(d, int_idx); return false; @@ -383,7 +381,7 @@ static void _vmxnet3_deassert_interrupt_line(VMXNET3State *s, int lidx) * This function should never be called for MSI(X) interrupts * because deassertion never required for message interrupts */ - assert(!s->msix_used || !msix_enabled(d)); + assert(!msix_enabled(d)); /* * This function should never be called for MSI(X) interrupts * because deassertion never required for message interrupts @@ -421,7 +419,7 @@ static void vmxnet3_trigger_interrupt(VMXNET3State *s, int lidx) s->interrupt_states[lidx].is_pending = true; vmxnet3_update_interrupt_line_state(s, lidx); - if (s->msix_used && msix_enabled(d) && s->auto_int_masking) { + if (msix_enabled(d) && s->auto_int_masking) { goto do_automask; } @@ -1427,7 +1425,7 @@ static void vmxnet3_update_features(VMXNET3State *s) static bool vmxnet3_verify_intx(VMXNET3State *s, int intx) { - return s->msix_used || msi_enabled(PCI_DEVICE(s)) + return msix_enabled(PCI_DEVICE(s)) || msi_enabled(PCI_DEVICE(s)) || intx == pci_get_byte(s->parent_obj.config + PCI_INTERRUPT_PIN) - 1; } @@ -1444,18 +1442,18 @@ static void vmxnet3_validate_interrupts(VMXNET3State *s) int i; VMW_CFPRN("Verifying event interrupt index (%d)", s->event_int_idx); - vmxnet3_validate_interrupt_idx(s->msix_used, s->event_int_idx); + vmxnet3_validate_interrupt_idx(msix_enabled(PCI_DEVICE(s)), s->event_int_idx); for (i = 0; i < s->txq_num; i++) { int idx = s->txq_descr[i].intr_idx; VMW_CFPRN("Verifying TX queue %d interrupt index (%d)", i, idx); - vmxnet3_validate_interrupt_idx(s->msix_used, idx); + vmxnet3_validate_interrupt_idx(msix_enabled(PCI_DEVICE(s)), idx); } for (i = 0; i < s->rxq_num; i++) { int idx = s->rxq_descr[i].intr_idx; VMW_CFPRN("Verifying RX queue %d interrupt index (%d)", i, idx); - vmxnet3_validate_interrupt_idx(s->msix_used, idx); + vmxnet3_validate_interrupt_idx(msix_enabled(PCI_DEVICE(s)), idx); } } @@ -2184,6 +2182,7 @@ vmxnet3_use_msix_vectors(VMXNET3State *s, int num_vectors) static bool vmxnet3_init_msix(VMXNET3State *s) { + bool msix; PCIDevice *d = PCI_DEVICE(s); int res = msix_init(d, VMXNET3_MAX_INTRS, &s->msix_bar, @@ -2198,17 +2197,18 @@ vmxnet3_init_msix(VMXNET3State *s) if (0 > res) { VMW_WRPRN("Failed to initialize MSI-X, board's MSI support is broken"); - s->msix_used = false; + msix = false; } else { if (!vmxnet3_use_msix_vectors(s, VMXNET3_MAX_INTRS)) { VMW_WRPRN("Failed to use MSI-X vectors, error %d", res); msix_uninit(d, &s->msix_bar, &s->msix_bar); - s->msix_used = false; + msix = false; } else { - s->msix_used = true; + msix = true; } } - return s->msix_used; + + return msix; } static void @@ -2216,7 +2216,7 @@ vmxnet3_cleanup_msix(VMXNET3State *s) { PCIDevice *d = PCI_DEVICE(s); - if (s->msix_used) { + if (msix_enabled(d)) { vmxnet3_unuse_msix_vectors(s, VMXNET3_MAX_INTRS); msix_uninit(d, &s->msix_bar, &s->msix_bar); } @@ -2551,21 +2551,11 @@ static void vmxnet3_put_rxq_descr(QEMUFile *f, void *pv, size_t size) static int vmxnet3_post_load(void *opaque, int version_id) { VMXNET3State *s = opaque; - PCIDevice *d = PCI_DEVICE(s); net_tx_pkt_init(&s->tx_pkt, PCI_DEVICE(s), s->max_tx_frags, s->peer_has_vhdr); net_rx_pkt_init(&s->rx_pkt, s->peer_has_vhdr); - if (s->msix_used) { - if (!vmxnet3_use_msix_vectors(s, VMXNET3_MAX_INTRS)) { - VMW_WRPRN("Failed to re-use MSI-X vectors"); - msix_uninit(d, &s->msix_bar, &s->msix_bar); - s->msix_used = false; - return -1; - } - } - vmxnet3_validate_queues(s); vmxnet3_validate_interrupts(s);