diff mbox

[v7,15/15] vmw_pvscsi: remove unnecessary internal msi state flag

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

Commit Message

Cao jin June 6, 2016, 8:01 a.m. UTC
Internal flag msi_used is uncesessary, msi_uninit() could be called
directly, msi_enabled() is enough to check device msi state.

cc: Paolo Bonzini <pbonzini@redhat.com>
cc: Dmitry Fleytman <dmitry@daynix.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/scsi/vmw_pvscsi.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

Comments

Markus Armbruster June 9, 2016, 3:48 p.m. UTC | #1
Cao jin <caoj.fnst@cn.fujitsu.com> writes:

> Internal flag msi_used is uncesessary, msi_uninit() could be called
> directly, msi_enabled() is enough to check device msi state.
>
> cc: Paolo Bonzini <pbonzini@redhat.com>
> cc: Dmitry Fleytman <dmitry@daynix.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/scsi/vmw_pvscsi.c | 14 +++-----------
>  1 file changed, 3 insertions(+), 11 deletions(-)
>
> diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c
> index c384442..9838fa5 100644
> --- a/hw/scsi/vmw_pvscsi.c
> +++ b/hw/scsi/vmw_pvscsi.c
> @@ -121,8 +121,6 @@ typedef struct {
>      uint8_t msg_ring_info_valid;         /* Whether message ring initialized */
>      uint8_t use_msg;                     /* Whether to use message ring      */
>  
> -    uint8_t msi_used;    /* Whether MSI support was installed successfully   */
> -
>      PVSCSIRingInfo rings;                /* Data transfer rings manager      */
>      uint32_t resetting;                  /* Reset in progress                */
>  
> @@ -351,7 +349,7 @@ pvscsi_update_irq_status(PVSCSIState *s)
>      trace_pvscsi_update_irq_level(should_raise, s->reg_interrupt_enabled,
>                                    s->reg_interrupt_status);
>  
> -    if (s->msi_used && msi_enabled(d)) {
> +    if (msi_enabled(d)) {
>          if (should_raise) {
>              trace_pvscsi_update_irq_msi();
>              msi_notify(d, PVSCSI_VECTOR_COMPLETION);
> @@ -1049,12 +1047,9 @@ pvscsi_init_msi(PVSCSIState *s)
>  
>      res = msi_init(d, PVSCSI_MSI_OFFSET(s), PVSCSI_MSIX_NUM_VECTORS,
>                     PVSCSI_USE_64BIT, PVSCSI_PER_VECTOR_MASK, &err);
> -    if (res < 0) {
> +    if (res) {

I'd leave this alone.

>          trace_pvscsi_init_msi_fail(res);
>          error_free(err);
> -        s->msi_used = false;
> -    } else {
> -        s->msi_used = true;
>      }
>  }
>  
> @@ -1063,9 +1058,7 @@ pvscsi_cleanup_msi(PVSCSIState *s)
>  {
>      PCIDevice *d = PCI_DEVICE(s);
>  
> -    if (s->msi_used) {
> -        msi_uninit(d);
> -    }
> +    msi_uninit(d);
>  }
>  
>  static const MemoryRegionOps pvscsi_ops = {
> @@ -1208,7 +1201,6 @@ static const VMStateDescription vmstate_pvscsi = {
>          VMSTATE_STRUCT_TEST(parent_obj, PVSCSIState,
>                              pvscsi_vmstate_test_pci_device, 0,
>                              vmstate_pci_device, PCIDevice),
> -        VMSTATE_UINT8(msi_used, PVSCSIState),
>          VMSTATE_UINT32(resetting, PVSCSIState),
>          VMSTATE_UINT64(reg_interrupt_status, PVSCSIState),
>          VMSTATE_UINT64(reg_interrupt_enabled, PVSCSIState),
diff mbox

Patch

diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c
index c384442..9838fa5 100644
--- a/hw/scsi/vmw_pvscsi.c
+++ b/hw/scsi/vmw_pvscsi.c
@@ -121,8 +121,6 @@  typedef struct {
     uint8_t msg_ring_info_valid;         /* Whether message ring initialized */
     uint8_t use_msg;                     /* Whether to use message ring      */
 
-    uint8_t msi_used;    /* Whether MSI support was installed successfully   */
-
     PVSCSIRingInfo rings;                /* Data transfer rings manager      */
     uint32_t resetting;                  /* Reset in progress                */
 
@@ -351,7 +349,7 @@  pvscsi_update_irq_status(PVSCSIState *s)
     trace_pvscsi_update_irq_level(should_raise, s->reg_interrupt_enabled,
                                   s->reg_interrupt_status);
 
-    if (s->msi_used && msi_enabled(d)) {
+    if (msi_enabled(d)) {
         if (should_raise) {
             trace_pvscsi_update_irq_msi();
             msi_notify(d, PVSCSI_VECTOR_COMPLETION);
@@ -1049,12 +1047,9 @@  pvscsi_init_msi(PVSCSIState *s)
 
     res = msi_init(d, PVSCSI_MSI_OFFSET(s), PVSCSI_MSIX_NUM_VECTORS,
                    PVSCSI_USE_64BIT, PVSCSI_PER_VECTOR_MASK, &err);
-    if (res < 0) {
+    if (res) {
         trace_pvscsi_init_msi_fail(res);
         error_free(err);
-        s->msi_used = false;
-    } else {
-        s->msi_used = true;
     }
 }
 
@@ -1063,9 +1058,7 @@  pvscsi_cleanup_msi(PVSCSIState *s)
 {
     PCIDevice *d = PCI_DEVICE(s);
 
-    if (s->msi_used) {
-        msi_uninit(d);
-    }
+    msi_uninit(d);
 }
 
 static const MemoryRegionOps pvscsi_ops = {
@@ -1208,7 +1201,6 @@  static const VMStateDescription vmstate_pvscsi = {
         VMSTATE_STRUCT_TEST(parent_obj, PVSCSIState,
                             pvscsi_vmstate_test_pci_device, 0,
                             vmstate_pci_device, PCIDevice),
-        VMSTATE_UINT8(msi_used, PVSCSIState),
         VMSTATE_UINT32(resetting, PVSCSIState),
         VMSTATE_UINT64(reg_interrupt_status, PVSCSIState),
         VMSTATE_UINT64(reg_interrupt_enabled, PVSCSIState),