Skip to contentSkip to conversation

e1000e: remove internal interrupt flag

PATCH In review Cao jin 5 participants 7 messages Aug 18, 2016 – Aug 19, 2016

lore
Share & tools
lore

Cao jin

author
#0 lore raw

PATCH 1/1 e1000e: remove internal interrupt flag

Commit 66bf7d58 removed internal msi state flag E1000E_USE_MSI, E1000E_USE_MSIX is not necessary too, remove it now. And interrupt flag field intr_state also can be removed now.

CC Dmitry Fleytman <[email protected]>
CC Jason Wang <[email protected]>
CC Markus Armbruster <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Michael S. Tsirkin <[email protected]>
CC Paolo Bonzini <[email protected]>
---
 hw/net/e1000e.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
hw/net/e1000e.c +1 -7
index 82a7be1..72aad21 100644
@@ -69,7 +69,6 @@ typedef struct E1000EState {
     uint16_t subsys_ven_used;
     uint16_t subsys_used;
 
-    uint32_t intr_state;
     bool disable_vnet;
 
     E1000ECore core;
@@ -89,8 +88,6 @@ typedef struct E1000EState {
 #define E1000E_MSIX_TABLE   (0x0000)
 #define E1000E_MSIX_PBA     (0x2000)
 
-#define E1000E_USE_MSIX    BIT(0)
-
 static uint64_t
 e1000e_mmio_read(void *opaque, hwaddr addr, unsigned size)
 {
@@ -302,8 +299,6 @@ e1000e_init_msix(E1000EState *s)
     } else {
         if (!e1000e_use_msix_vectors(s, E1000E_MSIX_VEC_NUM)) {
             msix_uninit(d, &s->msix, &s->msix);
-        } else {
-            s->intr_state |= E1000E_USE_MSIX;
         }
     }
 }
@@ -311,7 +306,7 @@ e1000e_init_msix(E1000EState *s)
 static void
 e1000e_cleanup_msix(E1000EState *s)
 {
-    if (s->intr_state & E1000E_USE_MSIX) {
+    if (msix_enabled(PCI_DEVICE(s))) {
         e1000e_unuse_msix_vectors(s, E1000E_MSIX_VEC_NUM);
         msix_uninit(PCI_DEVICE(s), &s->msix, &s->msix);
     }
@@ -601,7 +596,6 @@ static const VMStateDescription e1000e_vmstate = {
         VMSTATE_MSIX(parent_obj, E1000EState),
 
         VMSTATE_UINT32(ioaddr, E1000EState),
-        VMSTATE_UINT32(intr_state, E1000EState),
         VMSTATE_UINT32(core.rxbuf_min_shift, E1000EState),
         VMSTATE_UINT8(core.rx_desc_len, E1000EState),
         VMSTATE_UINT32_ARRAY(core.rxbuf_sizes, E1000EState,
Signature · 1 line
2.1.0
#1 lore raw
Quoted 40 lines · Cao jin

Commit 66bf7d58 removed internal msi state flag E1000E_USE_MSI, E1000E_USE_MSIX is not necessary too, remove it now. And interrupt flag field intr_state also can be removed now.

CC Dmitry Fleytman <[email protected]>
CC Jason Wang <[email protected]>
CC Markus Armbruster <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Michael S. Tsirkin <[email protected]>
CC Paolo Bonzini <[email protected]>

---
hw/net/e1000e.c | 8 +-------

1 file changed, 1 insertion(+), 7 deletions(-)
hw/net/e1000e.c +0 -3
index 82a7be1..72aad21 100644
@@ -69,7 +69,6 @@ typedef struct E1000EState {
    uint16_t subsys_ven_used;
    uint16_t subsys_used;
 
-    uint32_t intr_state;
    bool disable_vnet;
 
    E1000ECore core;
@@ -89,8 +88,6 @@ typedef struct E1000EState {
 #define E1000E_MSIX_TABLE   (0x0000)
 #define E1000E_MSIX_PBA     (0x2000)
 
-#define E1000E_USE_MSIX    BIT(0)
-

static uint64_t
e1000e_mmio_read(void *opaque, hwaddr addr, unsigned size) {

hw/net/e1000e.c e1000e_init_msix(E1000EState *s) · line 306

Quoted 5 lines
hw/net/e1000e.c +0 -2
@@ -302,8 +299,6 @@ e1000e_init_msix(E1000EState *s)
    } else {
        if (!e1000e_use_msix_vectors(s, E1000E_MSIX_VEC_NUM)) {
            msix_uninit(d, &s->msix, &s->msix);
-        } else {
-            s->intr_state |= E1000E_USE_MSIX;

So you are removing error handling here. But what if e1000e_use_msix_vectors fails?

Quoted 25 lines
hw/net/e1000e.c +0 -0
        }
    }
 }
@@ -311,7 +306,7 @@ e1000e_init_msix(E1000EState *s)

static void
e1000e_cleanup_msix(E1000EState *s)
{

hw/net/e1000e.c +1 -2
-    if (s->intr_state & E1000E_USE_MSIX) {
+    if (msix_enabled(PCI_DEVICE(s))) {
        e1000e_unuse_msix_vectors(s, E1000E_MSIX_VEC_NUM);
        msix_uninit(PCI_DEVICE(s), &s->msix, &s->msix);
    }
@@ -601,7 +596,6 @@ static const VMStateDescription e1000e_vmstate = {
        VMSTATE_MSIX(parent_obj, E1000EState),
 
        VMSTATE_UINT32(ioaddr, E1000EState),
-        VMSTATE_UINT32(intr_state, E1000EState),
        VMSTATE_UINT32(core.rxbuf_min_shift, E1000EState),
        VMSTATE_UINT8(core.rx_desc_len, E1000EState),
        VMSTATE_UINT32_ARRAY(core.rxbuf_sizes, E1000EState,
Signature · 1 line
2.1.0
Reviewed-by
#2 lore raw
Quoted 33 lines · Dmitry Fleytman
Quoted 33 lines · Cao jin

Commit 66bf7d58 removed internal msi state flag E1000E_USE_MSI, E1000E_USE_MSIX is not necessary too, remove it now. And interrupt flag field intr_state also can be removed now.

CC Dmitry Fleytman <[email protected]>
CC Jason Wang <[email protected]>
CC Markus Armbruster <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Michael S. Tsirkin <[email protected]>
CC Paolo Bonzini <[email protected]>

---
hw/net/e1000e.c | 8 +-------

1 file changed, 1 insertion(+), 7 deletions(-)
hw/net/e1000e.c +0 -1
index 82a7be1..72aad21 100644
@@ -69,7 +69,6 @@ typedef struct E1000EState {
    uint16_t subsys_ven_used;
    uint16_t subsys_used;
 
-    uint32_t intr_state;
    bool disable_vnet;
 
    E1000ECore core;
@@ -89,8 +88,6 @@ typedef struct E1000EState {
 #define E1000E_MSIX_TABLE   (0x0000)
 #define E1000E_MSIX_PBA     (0x2000)
 
Quoted 13 lines

hw/net/e1000e.c e1000e_init_msix(E1000EState *s) · line 306

Quoted 11 lines
hw/net/e1000e.c +0 -2
-#define E1000E_USE_MSIX    BIT(0)
-

static uint64_t
e1000e_mmio_read(void *opaque, hwaddr addr, unsigned size) {

hw/net/e1000e.c +0 -2
@@ -302,8 +299,6 @@ e1000e_init_msix(E1000EState *s)
    } else {
        if (!e1000e_use_msix_vectors(s, E1000E_MSIX_VEC_NUM)) {
            msix_uninit(d, &s->msix, &s->msix);
-        } else {
-            s->intr_state |= E1000E_USE_MSIX;

So you are removing error handling here. But what if e1000e_use_msix_vectors fails?

Before the patch, E1000E_USE_MSIX is set exactly when MSI-X was enabled successfully. It's only use is in MSI-X cleanup (next hunk): cleanup is skipped when the flag isn't set.

The flag is pointless, because we can just as well test whether MSI-X is enabled directly. That's what the patch does.

Quoted 16 lines
Quoted 16 lines
hw/net/e1000e.c +0 -0
        }
    }
 }
@@ -311,7 +306,7 @@ e1000e_init_msix(E1000EState *s)

static void
e1000e_cleanup_msix(E1000EState *s)
{

hw/net/e1000e.c +1 -1
-    if (s->intr_state & E1000E_USE_MSIX) {
+    if (msix_enabled(PCI_DEVICE(s))) {
        e1000e_unuse_msix_vectors(s, E1000E_MSIX_VEC_NUM);
        msix_uninit(PCI_DEVICE(s), &s->msix, &s->msix);
    }
@@ -601,7 +596,6 @@ static const VMStateDescription e1000e_vmstate = {
        VMSTATE_MSIX(parent_obj, E1000EState),
 
Quoted 2 lines

hw/net/e1000e.c static const VMStateDescription e1000e_vmstate = { · line 604

Quoted 2 lines
hw/net/e1000e.c +0 -1
        VMSTATE_UINT32(ioaddr, E1000EState),
-       VMSTATE_UINT32(intr_state, E1000EState),

We can still do this, because as Paolo pointed out, no released version of QEMU had this device.

Quoted 5 lines
Quoted 5 lines
hw/net/e1000e.c +0 -0
        VMSTATE_UINT32(core.rxbuf_min_shift, E1000EState),
        VMSTATE_UINT8(core.rx_desc_len, E1000EState),
        VMSTATE_UINT32_ARRAY(core.rxbuf_sizes, E1000EState,
Signature · 1 line
2.1.0
#3 lore raw
Quoted 3 lines · Markus Armbruster
Quoted 1 line · Dmitry Fleytman
Quoted 1 line · Cao jin

[...]

Quoted 8 lines
Quoted 5 lines

hw/net/e1000e.c static const VMStateDescription e1000e_vmstate = { · line 604

Quoted 5 lines
hw/net/e1000e.c +0 -1
@@ -601,7 +596,6 @@ static const VMStateDescription e1000e_vmstate = {
        VMSTATE_MSIX(parent_obj, E1000EState),
 
        VMSTATE_UINT32(ioaddr, E1000EState),
-       VMSTATE_UINT32(intr_state, E1000EState),

We can still do this, because as Paolo pointed out, no released version of QEMU had this device.

Which means we better get this into 2.7.0. Thoughts?

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
hw/net/e1000e.c +0 -0
        VMSTATE_UINT32(core.rxbuf_min_shift, E1000EState),
        VMSTATE_UINT8(core.rx_desc_len, E1000EState),
        VMSTATE_UINT32_ARRAY(core.rxbuf_sizes, E1000EState,
Signature · 1 line
2.1.0
#4 lore raw
In reply to Markus Armbruster
Quoted 53 lines · Markus Armbruster
Quoted 33 lines · Dmitry Fleytman
Quoted 33 lines · Cao jin

Commit 66bf7d58 removed internal msi state flag E1000E_USE_MSI, E1000E_USE_MSIX is not necessary too, remove it now. And interrupt flag field intr_state also can be removed now.

CC Dmitry Fleytman <[email protected]>
CC Jason Wang <[email protected]>
CC Markus Armbruster <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Michael S. Tsirkin <[email protected]>
CC Paolo Bonzini <[email protected]>

---
hw/net/e1000e.c | 8 +-------

1 file changed, 1 insertion(+), 7 deletions(-)
hw/net/e1000e.c +0 -1
index 82a7be1..72aad21 100644
@@ -69,7 +69,6 @@ typedef struct E1000EState {
   uint16_t subsys_ven_used;
   uint16_t subsys_used;
 
-    uint32_t intr_state;
   bool disable_vnet;
 
   E1000ECore core;
@@ -89,8 +88,6 @@ typedef struct E1000EState {
 #define E1000E_MSIX_TABLE   (0x0000)
 #define E1000E_MSIX_PBA     (0x2000)
 
Quoted 13 lines

hw/net/e1000e.c e1000e_init_msix(E1000EState *s) · line 306

Quoted 11 lines
hw/net/e1000e.c +0 -2
-#define E1000E_USE_MSIX    BIT(0)
-

static uint64_t
e1000e_mmio_read(void *opaque, hwaddr addr, unsigned size) {

hw/net/e1000e.c +0 -2
@@ -302,8 +299,6 @@ e1000e_init_msix(E1000EState *s)
   } else {
       if (!e1000e_use_msix_vectors(s, E1000E_MSIX_VEC_NUM)) {
           msix_uninit(d, &s->msix, &s->msix);
-        } else {
-            s->intr_state |= E1000E_USE_MSIX;

So you are removing error handling here. But what if e1000e_use_msix_vectors fails?

Quoted 6 lines

Before the patch, E1000E_USE_MSIX is set exactly when MSI-X was enabled successfully. It's only use is in MSI-X cleanup (next hunk): cleanup is skipped when the flag isn't set.

The flag is pointless, because we can just as well test whether MSI-X is enabled directly. That's what the patch does.

I see.

Quoted 30 lines
Quoted 17 lines
Quoted 17 lines
hw/net/e1000e.c +0 -0
       }
   }
 }
@@ -311,7 +306,7 @@ e1000e_init_msix(E1000EState *s)

static void
e1000e_cleanup_msix(E1000EState *s)
{

hw/net/e1000e.c +1 -1
-    if (s->intr_state & E1000E_USE_MSIX) {
+    if (msix_enabled(PCI_DEVICE(s))) {
       e1000e_unuse_msix_vectors(s, E1000E_MSIX_VEC_NUM);
       msix_uninit(PCI_DEVICE(s), &s->msix, &s->msix);
   }
@@ -601,7 +596,6 @@ static const VMStateDescription e1000e_vmstate = {
       VMSTATE_MSIX(parent_obj, E1000EState),
 
Quoted 2 lines

hw/net/e1000e.c static const VMStateDescription e1000e_vmstate = { · line 604

Quoted 2 lines
hw/net/e1000e.c +0 -1
       VMSTATE_UINT32(ioaddr, E1000EState),
-       VMSTATE_UINT32(intr_state, E1000EState),

We can still do this, because as Paolo pointed out, no released version of QEMU had this device.

Quoted 5 lines
Quoted 5 lines
hw/net/e1000e.c +0 -0
       VMSTATE_UINT32(core.rxbuf_min_shift, E1000EState),
       VMSTATE_UINT8(core.rx_desc_len, E1000EState),
       VMSTATE_UINT32_ARRAY(core.rxbuf_sizes, E1000EState,
Signature · 1 line
2.1.0
Reviewed-by on v1 1/1
#5 lore raw
In reply to Cao jin
Quoted 56 lines · Cao jin

Commit 66bf7d58 removed internal msi state flag E1000E_USE_MSI, E1000E_USE_MSIX is not necessary too, remove it now. And interrupt flag field intr_state also can be removed now.

CC Dmitry Fleytman <[email protected]>
CC Jason Wang <[email protected]>
CC Markus Armbruster <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Michael S. Tsirkin <[email protected]>
CC Paolo Bonzini <[email protected]>
---
 hw/net/e1000e.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
hw/net/e1000e.c +1 -6
index 82a7be1..72aad21 100644
@@ -69,7 +69,6 @@ typedef struct E1000EState {
     uint16_t subsys_ven_used;
     uint16_t subsys_used;
 
-    uint32_t intr_state;
     bool disable_vnet;
 
     E1000ECore core;
@@ -89,8 +88,6 @@ typedef struct E1000EState {
 #define E1000E_MSIX_TABLE   (0x0000)
 #define E1000E_MSIX_PBA     (0x2000)
 
-#define E1000E_USE_MSIX    BIT(0)
-
 static uint64_t
 e1000e_mmio_read(void *opaque, hwaddr addr, unsigned size)
 {
@@ -302,8 +299,6 @@ e1000e_init_msix(E1000EState *s)
     } else {
         if (!e1000e_use_msix_vectors(s, E1000E_MSIX_VEC_NUM)) {
             msix_uninit(d, &s->msix, &s->msix);
-        } else {
-            s->intr_state |= E1000E_USE_MSIX;
         }
     }
 }
@@ -311,7 +306,7 @@ e1000e_init_msix(E1000EState *s)
 static void
 e1000e_cleanup_msix(E1000EState *s)
 {
-    if (s->intr_state & E1000E_USE_MSIX) {
+    if (msix_enabled(PCI_DEVICE(s))) {
         e1000e_unuse_msix_vectors(s, E1000E_MSIX_VEC_NUM);
         msix_uninit(PCI_DEVICE(s), &s->msix, &s->msix);
     }

hw/net/e1000e.c static const VMStateDescription e1000e_vmstate = { · line 601

Quoted 7 lines
hw/net/e1000e.c +0 -1
@@ -601,7 +596,6 @@ static const VMStateDescription e1000e_vmstate = {
         VMSTATE_MSIX(parent_obj, E1000EState),
 
         VMSTATE_UINT32(ioaddr, E1000EState),
-        VMSTATE_UINT32(intr_state, E1000EState),
         VMSTATE_UINT32(core.rxbuf_min_shift, E1000EState),
         VMSTATE_UINT8(core.rx_desc_len, E1000EState),
         VMSTATE_UINT32_ARRAY(core.rxbuf_sizes, E1000EState,

If there's time to get this in 2.7, it would be good. Jason?

#6 lore raw
Quoted 59 lines · Paolo Bonzini
Quoted 57 lines · Cao jin

Commit 66bf7d58 removed internal msi state flag E1000E_USE_MSI, E1000E_USE_MSIX is not necessary too, remove it now. And interrupt flag field intr_state also can be removed now.

CC Dmitry Fleytman <[email protected]>
CC Jason Wang <[email protected]>
CC Markus Armbruster <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Michael S. Tsirkin <[email protected]>
CC Paolo Bonzini <[email protected]>
---
  hw/net/e1000e.c | 8 +-------
  1 file changed, 1 insertion(+), 7 deletions(-)
hw/net/e1000e.c +1 -6
index 82a7be1..72aad21 100644
@@ -69,7 +69,6 @@ typedef struct E1000EState {
      uint16_t subsys_ven_used;
      uint16_t subsys_used;
 
-    uint32_t intr_state;
      bool disable_vnet;
 
      E1000ECore core;
@@ -89,8 +88,6 @@ typedef struct E1000EState {
  #define E1000E_MSIX_TABLE   (0x0000)
  #define E1000E_MSIX_PBA     (0x2000)
 
-#define E1000E_USE_MSIX    BIT(0)
-
  static uint64_t
  e1000e_mmio_read(void *opaque, hwaddr addr, unsigned size)
  {
@@ -302,8 +299,6 @@ e1000e_init_msix(E1000EState *s)
      } else {
          if (!e1000e_use_msix_vectors(s, E1000E_MSIX_VEC_NUM)) {
              msix_uninit(d, &s->msix, &s->msix);
-        } else {
-            s->intr_state |= E1000E_USE_MSIX;
          }
      }
  }
@@ -311,7 +306,7 @@ e1000e_init_msix(E1000EState *s)
  static void
  e1000e_cleanup_msix(E1000EState *s)
  {
-    if (s->intr_state & E1000E_USE_MSIX) {
+    if (msix_enabled(PCI_DEVICE(s))) {
          e1000e_unuse_msix_vectors(s, E1000E_MSIX_VEC_NUM);
          msix_uninit(PCI_DEVICE(s), &s->msix, &s->msix);
      }
@@ -601,7 +596,6 @@ static const VMStateDescription e1000e_vmstate = {
          VMSTATE_MSIX(parent_obj, E1000EState),
 
Quoted 7 lines

hw/net/e1000e.c static const VMStateDescription e1000e_vmstate = { · line 601

Quoted 6 lines
hw/net/e1000e.c +0 -1
          VMSTATE_UINT32(ioaddr, E1000EState),
-        VMSTATE_UINT32(intr_state, E1000EState),
          VMSTATE_UINT32(core.rxbuf_min_shift, E1000EState),
          VMSTATE_UINT8(core.rx_desc_len, E1000EState),
          VMSTATE_UINT32_ARRAY(core.rxbuf_sizes, E1000EState,

If there's time to get this in 2.7, it would be good. Jason?

Yes, will send a pull request with this today.

Quoted 2 lines

Thanks and applied to -net.