diff mbox

[v8,16/17] vmxnet3: remove unnecessary internal msi state flag

Message ID 1465552478-5540-17-git-send-email-caoj.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Cao jin June 10, 2016, 9:54 a.m. UTC
Internal flag msi_used is unnecessary, it has the same effect as msi_enabled().
msi_uninit() could be called directly without risk.

cc: Dmitry Fleytman <dmitry@daynix.com>
cc: Jason Wang <jasowang@redhat.com>
cc: Markus Armbruster <armbru@redhat.com>
cc: Marcel Apfelbaum <marcel@redhat.com>
cc: Michael S. Tsirkin <mst@redhat.com>

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
---
 hw/net/vmxnet3.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

Comments

Markus Armbruster June 13, 2016, 8:47 a.m. UTC | #1
Cao jin <caoj.fnst@cn.fujitsu.com> writes:

> Internal flag msi_used is unnecessary, it has the same effect as msi_enabled().
> msi_uninit() could be called directly without risk.
>
> cc: Dmitry Fleytman <dmitry@daynix.com>
> cc: Jason Wang <jasowang@redhat.com>
> cc: Markus Armbruster <armbru@redhat.com>
> cc: Marcel Apfelbaum <marcel@redhat.com>
> cc: Michael S. Tsirkin <mst@redhat.com>
>
> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
> ---
>  hw/net/vmxnet3.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
> index 63f8904..3ed4335 100644
> --- a/hw/net/vmxnet3.c
> +++ b/hw/net/vmxnet3.c
> @@ -280,8 +280,6 @@ typedef struct {
>  
>          /* Whether MSI-X support was installed successfully */
>          bool msix_used;
> -        /* Whether MSI support was installed successfully */
> -        bool msi_used;
>          hwaddr drv_shmem;
>          hwaddr temp_shared_guest_driver_memory;
>  
> @@ -363,7 +361,7 @@ static bool _vmxnet3_assert_interrupt_line(VMXNET3State *s, uint32_t int_idx)
>          msix_notify(d, int_idx);
>          return false;
>      }
> -    if (s->msi_used && msi_enabled(d)) {
> +    if (msi_enabled(d)) {
>          VMW_IRPRN("Sending MSI notification for vector %u", int_idx);
>          msi_notify(d, int_idx);
>          return false;
> @@ -387,7 +385,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->msi_used || !msi_enabled(d));
> +    assert(!msi_enabled(d));
>  
>      VMW_IRPRN("Deasserting line for interrupt %u", lidx);
>      pci_irq_deassert(d);
> @@ -424,7 +422,7 @@ static void vmxnet3_trigger_interrupt(VMXNET3State *s, int lidx)
>          goto do_automask;
>      }
>  
> -    if (s->msi_used && msi_enabled(d) && s->auto_int_masking) {
> +    if (msi_enabled(d) && s->auto_int_masking) {
>          goto do_automask;
>      }
>  
> @@ -1409,7 +1407,7 @@ static void vmxnet3_update_features(VMXNET3State *s)
>  
>  static bool vmxnet3_verify_intx(VMXNET3State *s, int intx)
>  {
> -    return s->msix_used || s->msi_used || (intx ==
> +    return s->msix_used || msi_enabled(PCI_DEVICE(s)) || (intx ==
>             (pci_get_byte(s->parent_obj.config + PCI_INTERRUPT_PIN) - 1));

If you need to respin for some other reason, you could clean up the
distasteful line break here, and drop the superfluous parenthesis:

    return s->msix_used || msi_enabled(PCI_DEVICE(s))
        || intx == pci_get_byte(s->parent_obj.config + PCI_INTERRUPT_PIN) - 1;

>  }
>  
> @@ -2202,9 +2200,7 @@ vmxnet3_cleanup_msi(VMXNET3State *s)
>  {
>      PCIDevice *d = PCI_DEVICE(s);
>  
> -    if (s->msi_used) {
> -        msi_uninit(d);
> -    }
> +    msi_uninit(d);
>  }
>  
>  static void
> @@ -2295,7 +2291,6 @@ static void vmxnet3_pci_realize(PCIDevice *pci_dev, Error **errp)
>      /* Any error other than -ENOTSUP(board's MSI support is broken)
>       * is a programming error. Fall back to INTx silently on -ENOTSUP */
>      assert(!ret || ret == -ENOTSUP);
> -    s->msi_used = !ret;
>  
>      if (!vmxnet3_init_msix(s)) {
>          VMW_WRPRN("Failed to initialize MSI-X, configuration is inconsistent.");
diff mbox

Patch

diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 63f8904..3ed4335 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -280,8 +280,6 @@  typedef struct {
 
         /* Whether MSI-X support was installed successfully */
         bool msix_used;
-        /* Whether MSI support was installed successfully */
-        bool msi_used;
         hwaddr drv_shmem;
         hwaddr temp_shared_guest_driver_memory;
 
@@ -363,7 +361,7 @@  static bool _vmxnet3_assert_interrupt_line(VMXNET3State *s, uint32_t int_idx)
         msix_notify(d, int_idx);
         return false;
     }
-    if (s->msi_used && msi_enabled(d)) {
+    if (msi_enabled(d)) {
         VMW_IRPRN("Sending MSI notification for vector %u", int_idx);
         msi_notify(d, int_idx);
         return false;
@@ -387,7 +385,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->msi_used || !msi_enabled(d));
+    assert(!msi_enabled(d));
 
     VMW_IRPRN("Deasserting line for interrupt %u", lidx);
     pci_irq_deassert(d);
@@ -424,7 +422,7 @@  static void vmxnet3_trigger_interrupt(VMXNET3State *s, int lidx)
         goto do_automask;
     }
 
-    if (s->msi_used && msi_enabled(d) && s->auto_int_masking) {
+    if (msi_enabled(d) && s->auto_int_masking) {
         goto do_automask;
     }
 
@@ -1409,7 +1407,7 @@  static void vmxnet3_update_features(VMXNET3State *s)
 
 static bool vmxnet3_verify_intx(VMXNET3State *s, int intx)
 {
-    return s->msix_used || s->msi_used || (intx ==
+    return s->msix_used || msi_enabled(PCI_DEVICE(s)) || (intx ==
            (pci_get_byte(s->parent_obj.config + PCI_INTERRUPT_PIN) - 1));
 }
 
@@ -2202,9 +2200,7 @@  vmxnet3_cleanup_msi(VMXNET3State *s)
 {
     PCIDevice *d = PCI_DEVICE(s);
 
-    if (s->msi_used) {
-        msi_uninit(d);
-    }
+    msi_uninit(d);
 }
 
 static void
@@ -2295,7 +2291,6 @@  static void vmxnet3_pci_realize(PCIDevice *pci_dev, Error **errp)
     /* Any error other than -ENOTSUP(board's MSI support is broken)
      * is a programming error. Fall back to INTx silently on -ENOTSUP */
     assert(!ret || ret == -ENOTSUP);
-    s->msi_used = !ret;
 
     if (!vmxnet3_init_msix(s)) {
         VMW_WRPRN("Failed to initialize MSI-X, configuration is inconsistent.");