Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Don't write to read-only VIRTIO_NET_S_LINK_UP bit
details: https://anonhg.NetBSD.org/src/rev/071a547df888
branches: trunk
changeset: 352361:071a547df888
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Tue Mar 28 04:09:52 2017 +0000
description:
Don't write to read-only VIRTIO_NET_S_LINK_UP bit
The bit is defined as read-only in the Virtio PCI Card Specification.
The fix is inspired by FreeBSD.
PR kern/52103 by s-yamaguchi@IIJ
diffstat:
sys/dev/pci/if_vioif.c | 44 +++++++++++++++++---------------------------
1 files changed, 17 insertions(+), 27 deletions(-)
diffs (103 lines):
diff -r 32b17c4fe6c2 -r 071a547df888 sys/dev/pci/if_vioif.c
--- a/sys/dev/pci/if_vioif.c Tue Mar 28 03:19:20 2017 +0000
+++ b/sys/dev/pci/if_vioif.c Tue Mar 28 04:09:52 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_vioif.c,v 1.32 2017/03/25 18:02:06 jdolecek Exp $ */
+/* $NetBSD: if_vioif.c,v 1.33 2017/03/28 04:09:52 ozaki-r Exp $ */
/*
* Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.32 2017/03/25 18:02:06 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.33 2017/03/28 04:09:52 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_net_mpsafe.h"
@@ -269,7 +269,6 @@
static void vioif_tx_drain(struct vioif_softc *);
/* other control */
-static int vioif_updown(struct vioif_softc *, bool);
static int vioif_ctrl_rx(struct vioif_softc *, int, bool);
static int vioif_set_promisc(struct vioif_softc *, bool);
static int vioif_set_allmulti(struct vioif_softc *, bool);
@@ -719,9 +718,18 @@
vioif_init(struct ifnet *ifp)
{
struct vioif_softc *sc = ifp->if_softc;
+ struct virtio_softc *vsc = sc->sc_virtio;
vioif_stop(ifp, 0);
+ virtio_reinit_start(vsc);
+ virtio_negotiate_features(vsc, virtio_features(vsc));
+ virtio_start_vq_intr(vsc, &sc->sc_vq[VQ_RX]);
+ virtio_stop_vq_intr(vsc, &sc->sc_vq[VQ_TX]);
+ if (sc->sc_has_ctrl)
+ virtio_start_vq_intr(vsc, &sc->sc_vq[VQ_CTRL]);
+ virtio_reinit_end(vsc);
+
if (!sc->sc_deferred_init_done) {
sc->sc_deferred_init_done = 1;
if (sc->sc_has_ctrl)
@@ -733,7 +741,6 @@
vioif_populate_rx_mbufs(sc);
- vioif_updown(sc, true);
ifp->if_flags |= IFF_RUNNING;
ifp->if_flags &= ~IFF_OACTIVE;
vioif_rx_filter(sc);
@@ -754,6 +761,12 @@
VIOIF_RX_UNLOCK(sc);
VIOIF_TX_UNLOCK(sc);
+ /* disable interrupts */
+ virtio_stop_vq_intr(vsc, &sc->sc_vq[VQ_RX]);
+ virtio_stop_vq_intr(vsc, &sc->sc_vq[VQ_TX]);
+ if (sc->sc_has_ctrl)
+ virtio_stop_vq_intr(vsc, &sc->sc_vq[VQ_CTRL]);
+
/* only way to stop I/O and DMA is resetting... */
virtio_reset(vsc);
vioif_rx_deq(sc);
@@ -762,15 +775,6 @@
if (disable)
vioif_rx_drain(sc);
-
- virtio_reinit_start(vsc);
- virtio_negotiate_features(vsc, virtio_features(vsc));
- virtio_start_vq_intr(vsc, &sc->sc_vq[VQ_RX]);
- virtio_stop_vq_intr(vsc, &sc->sc_vq[VQ_TX]);
- if (sc->sc_has_ctrl)
- virtio_start_vq_intr(vsc, &sc->sc_vq[VQ_CTRL]);
- virtio_reinit_end(vsc);
- vioif_updown(sc, false);
}
static void
@@ -1499,20 +1503,6 @@
return r;
}
-/* change link status */
-static int
-vioif_updown(struct vioif_softc *sc, bool isup)
-{
- struct virtio_softc *vsc = sc->sc_virtio;
-
- if (!(virtio_features(vsc) & VIRTIO_NET_F_STATUS))
- return ENODEV;
- virtio_write_device_config_1(vsc,
- VIRTIO_NET_CONFIG_STATUS,
- isup?VIRTIO_NET_S_LINK_UP:0);
- return 0;
-}
-
MODULE(MODULE_CLASS_DRIVER, if_vioif, "virtio");
#ifdef _MODULE
Home |
Main Index |
Thread Index |
Old Index