Skip to contentSkip to conversation

e1000: Do reset when E1000_CTRL_RST bit is set.

PATCH In review Anthony PERARD 4 participants 6 messages Aug 5, 2011 – Aug 9, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 e1000: Do reset when E1000_CTRL_RST bit is set.

---
 hw/e1000.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
hw/e1000.c +8 -2
index 96d84f9..a1388e9 100644
@@ -150,6 +150,8 @@ static const char phy_regcap[0x20] = {
     [PHY_ID2] = PHY_R,		[M88E1000_PHY_SPEC_STATUS] = PHY_R
 };
 
+static void e1000_reset(void *opaque);
+
 static void
 ioport_map(PCIDevice *pci_dev, int region_num, pcibus_t addr,
            pcibus_t size, int type)
@@ -202,8 +204,12 @@ rxbufsize(uint32_t v)
 static void
 set_ctrl(E1000State *s, int index, uint32_t val)
 {
-    /* RST is self clearing */
-    s->mac_reg[CTRL] = val & ~E1000_CTRL_RST;
+    DBGOUT(IO, "set ctrl = %08x\n", val);
+    if (val & E1000_CTRL_RST) {
+        e1000_reset(s);
+        return;
+    }
+    s->mac_reg[CTRL] = val;
 }
 
 static void
Signature · 1 line
Anthony PERARD
#1 lore raw
Quoted 19 lines · Anthony PERARD
---
  hw/e1000.c |   10 ++++++++--
  1 files changed, 8 insertions(+), 2 deletions(-)
hw/e1000.c +2 -0
index 96d84f9..a1388e9 100644
@@ -150,6 +150,8 @@ static const char phy_regcap[0x20] = {
      [PHY_ID2] = PHY_R,		[M88E1000_PHY_SPEC_STATUS] = PHY_R
  };
 
+static void e1000_reset(void *opaque);
+
  static void
  ioport_map(PCIDevice *pci_dev, int region_num, pcibus_t addr,
             pcibus_t size, int type)

hw/e1000.c rxbufsize(uint32_t v) · line 208

Quoted 7 lines
hw/e1000.c +2 -2
@@ -202,8 +204,12 @@ rxbufsize(uint32_t v)
  static void
  set_ctrl(E1000State *s, int index, uint32_t val)
  {
-    /* RST is self clearing */
-    s->mac_reg[CTRL] = val&  ~E1000_CTRL_RST;
+    DBGOUT(IO, "set ctrl = %08x\n", val);
+    if (val&  E1000_CTRL_RST) {

You'll break some GCCs with -Wall -Werror with this. Please do:

if ((val & E1000_CTRL_RST)) {

Regards,

Anthony Liguori

Quoted 7 lines
hw/e1000.c +4 -0
+        e1000_reset(s);
+        return;
+    }
+    s->mac_reg[CTRL] = val;
  }
 
  static void
#2 lore raw
Quoted 5 lines · Anthony Liguori
Quoted 1 line

+ if (val& E1000_CTRL_RST) {

You'll break some GCCs with -Wall -Werror with this. Please do:

if ((val & E1000_CTRL_RST)) {

Err, really? What versions?

I don't recall that ever being true.

r~

#3 lore raw
In reply to Anthony Liguori
Quoted 3 lines · Anthony Liguori

You'll break some GCCs with -Wall -Werror with this.  Please do:

if ((val & E1000_CTRL_RST)) {

Hmm? There's lots of examples of that in the codebase:

$ git grep 'if ([a-zA-Z]* & ' | wc -l
1558

'=' (assignment) needs those extra braces, but logical ops don't AFAIK.

-- PMM

#4 lore raw
In reply to Anthony Liguori
Quoted 4 lines · Anthony Liguori

You'll break some GCCs with -Wall -Werror with this.  Please do:

if ((val & E1000_CTRL_RST)) {

:(, I never heard of this. But OK, I will do that.

Signature · 1 line
Anthony PERARD
#5 lore raw
Quoted 7 lines · Anthony PERARD
Quoted 4 lines · Anthony Liguori

You'll break some GCCs with -Wall -Werror with this.  Please do:

if ((val & E1000_CTRL_RST)) {

:(, I never heard of this. But OK, I will do that.

Please don't unless Anthony L can actually demonstrate a compiler which has this property and doesn't already complain about all the existing equivalent code in qemu...

-- PMM