Patchwork [2/2] rtl8139: preserve link state across device reset

login
register
mail settings
Submitter Amos Kong
Date Dec. 28, 2012, 9:29 a.m.
Message ID <1356686951-20305-3-git-send-email-akong@redhat.com>
Download mbox | patch
Permalink /patch/208425/
State New
Headers show

Comments

Amos Kong - Dec. 28, 2012, 9:29 a.m.
A device reset does not affect the link state, only set_link does.

Signed-off-by: Amos Kong <akong@redhat.com>
---
 hw/rtl8139.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Jan Kiszka - Jan. 22, 2013, 5:11 p.m.
On 2012-12-28 10:29, Amos Kong wrote:
> A device reset does not affect the link state, only set_link does.
> 
> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
>  hw/rtl8139.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/rtl8139.c b/hw/rtl8139.c
> index c59ec6b..3e08062 100644
> --- a/hw/rtl8139.c
> +++ b/hw/rtl8139.c
> @@ -1258,7 +1258,8 @@ static void rtl8139_reset(DeviceState *d)
>      s->BasicModeStatus  = 0x7809;
>      //s->BasicModeStatus |= 0x0040; /* UTP medium */
>      s->BasicModeStatus |= 0x0020; /* autonegotiation completed */
> -    s->BasicModeStatus |= 0x0004; /* link is up */
> +    /* preserve link state */
> +    s->BasicModeStatus |= s->nic->nc.link_down ? 0 : 0x04;

This would have been more readable

    if (!s->nic->nc.link_down) {
        s->BasicModeStatus |= 0x0004; /* link is up */
    }

but it's applied now.

Jan

Patch

diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index c59ec6b..3e08062 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -1258,7 +1258,8 @@  static void rtl8139_reset(DeviceState *d)
     s->BasicModeStatus  = 0x7809;
     //s->BasicModeStatus |= 0x0040; /* UTP medium */
     s->BasicModeStatus |= 0x0020; /* autonegotiation completed */
-    s->BasicModeStatus |= 0x0004; /* link is up */
+    /* preserve link state */
+    s->BasicModeStatus |= s->nic->nc.link_down ? 0 : 0x04;
 
     s->NWayAdvert    = 0x05e1; /* all modes, full duplex */
     s->NWayLPAR      = 0x05e1; /* all modes, full duplex */