Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-8]: src/sys Pull up following revision(s) (requested by msaitoh i...



details:   https://anonhg.NetBSD.org/src/rev/7af87a74add2
branches:  netbsd-8
changeset: 434486:7af87a74add2
user:      snj <snj%NetBSD.org@localhost>
date:      Sun Dec 10 10:10:23 2017 +0000

description:
Pull up following revision(s) (requested by msaitoh in ticket #427):
        sys/arch/amiga/dev/if_bah_zbus.c: 1.17
        sys/arch/arm/broadcom/bcm53xx_eth.c: 1.30
        sys/arch/powerpc/booke/dev/pq3etsec.c: 1.32
        sys/arch/usermode/dev/if_veth.c: 1.9
        sys/dev/ic/an.c: 1.66
        sys/dev/ic/athn.c: 1.17
        sys/dev/ic/atw.c: 1.162
        sys/dev/ic/bwi.c: 1.33
        sys/dev/ic/dwc_gmac.c: 1.41-1.42
        sys/dev/ic/malo.c: 1.10
        sys/dev/ic/rt2560.c: 1.31
        sys/dev/ic/rt2661.c: 1.36
        sys/dev/ic/rt2860.c: 1.29
        sys/dev/ic/rtw.c: 1.127
        sys/dev/ic/rtwvar.h: 1.46
        sys/dev/ic/smc90cx6.c: 1.71
        sys/dev/ic/smc90cx6var.h: 1.12
        sys/dev/ic/wi.c: 1.244
        sys/dev/pci/if_ipw.c: 1.66
        sys/dev/pci/if_iwi.c: 1.104
        sys/dev/pci/if_iwm.c: 1.76
        sys/dev/pci/if_iwn.c: 1.86
        sys/dev/pci/if_rtwn.c: 1.13
        sys/dev/pci/if_wm.c: 1.541
        sys/dev/pci/if_wpi.c: 1.79
        sys/dev/pci/ixgbe/ixgbe.c: 1.106
        sys/dev/pci/ixgbe/ixv.c: 1.73 via patch
        sys/dev/pcmcia/if_malo_pcmcia.c: 1.15
        sys/dev/scsipi/if_se.c: 1.95
        sys/dev/usb/if_upl.c: 1.60
        sys/net/if.c: 1.396
        sys/net/if.h: 1.241
        sys/net/if_arc.h: 1.23
        sys/net/if_arcsubr.c: 1.78
        sys/net/if_bridge.c: 1.136-1.137
        sys/net/if_etherip.c: 1.39
        sys/net/if_faith.c: 1.56
        sys/net/if_gif.c: 1.131
        sys/net/if_loop.c: 1.96
        sys/net/if_mpls.c: 1.30
        sys/net/if_pppoe.c: 1.129
        sys/net/if_srt.c: 1.27
        sys/net/if_stf.c: 1.102
        sys/net/if_tap.c: 1.100
        sys/net/if_vlan.c: 1.105
        sys/netinet/ip_carp.c: 1.91
        sys/rump/net/lib/libshmif/if_shmem.c: 1.73-1.74
        sys/rump/net/lib/libvirtif/if_virt.c: 1.55-1.56
 if_initalize() and if_attach() failed when resource allocation failed
(e.g. allocating softint). Without this change, it panics. It's bad because
resource shortage really occured when a lot of pseudo interface is created.
To avoid this problem, don't panic and change return value of if_initialize()
and if_attach() to int. Caller fanction will be recover from error cleanly by
checking the return value.
 Return if bah_attach_subr() failed.
 If if_attach() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add some missing frees in bridge_clone_destroy().
- KNF
 If error occured in bcmeth_ccb_attach(), free resources and return.
 If error occured in pq3etsec_attach(), free resources and return.
 If error occured in the attach function, free resources and return.
- If if_initialize() failed in athn_attach(), free resources and return.
- Add missing pmf_event_deregister() in athn_detach().
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.
 If if_initialize() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add missing dwc_gmac_free_dma_rings() and mutex_destroy() when attach
   failed.
- If if_initialize() failed in the attach function, free resources and return.
- ifp is always not NULL in iwi_detach(). Check correctly with ifp->if_softc.
- If if_initialize() failed in the attach function, free resources and return.
- Fix error path in the attach function correctly.
 If if_initialize() failed in the attach function, free resources and return.
 If if_attach() failed in the attach function, free resources and return.
 - If if_initialize() failed in the attach function, free resources and return.
 - KNF
 - If if_attach() failed in the attach function, free resources and return.
 - KNF
 Fix compile error.
 Fix compile error.
We don't need '&mii', but just 'mii' for mii_detach().
Don't free sc_rthash twice

diffstat:

 sys/arch/amiga/dev/if_bah_zbus.c      |   11 ++-
 sys/arch/arm/broadcom/bcm53xx_eth.c   |   40 +++++++++--
 sys/arch/powerpc/booke/dev/pq3etsec.c |   61 +++++++++++++---
 sys/arch/usermode/dev/if_veth.c       |   13 ++-
 sys/dev/ic/an.c                       |   40 +++++++----
 sys/dev/ic/athn.c                     |   18 ++++-
 sys/dev/ic/atw.c                      |   30 +++++---
 sys/dev/ic/bwi.c                      |   11 ++-
 sys/dev/ic/dwc_gmac.c                 |   18 ++++-
 sys/dev/ic/malo.c                     |   17 +++-
 sys/dev/ic/rt2560.c                   |   12 ++-
 sys/dev/ic/rt2661.c                   |   12 ++-
 sys/dev/ic/rt2860.c                   |   24 ++++++-
 sys/dev/ic/rtw.c                      |   12 ++-
 sys/dev/ic/rtwvar.h                   |    6 +-
 sys/dev/ic/smc90cx6.c                 |   13 ++-
 sys/dev/ic/smc90cx6var.h              |    4 +-
 sys/dev/ic/wi.c                       |   15 +++-
 sys/dev/pci/if_ipw.c                  |   12 ++-
 sys/dev/pci/if_iwi.c                  |   25 ++++---
 sys/dev/pci/if_iwm.c                  |   19 +++--
 sys/dev/pci/if_iwn.c                  |   12 ++-
 sys/dev/pci/if_rtwn.c                 |   18 +++-
 sys/dev/pci/if_wm.c                   |   11 ++-
 sys/dev/pci/if_wpi.c                  |   12 ++-
 sys/dev/pci/ixgbe/ixgbe.c             |    9 ++-
 sys/dev/pci/ixgbe/ixv.c               |   21 ++++-
 sys/dev/pcmcia/if_malo_pcmcia.c       |   24 +++++-
 sys/dev/scsipi/if_se.c                |   13 ++-
 sys/dev/usb/if_upl.c                  |   12 ++-
 sys/net/if.c                          |   38 ++++++++--
 sys/net/if.h                          |    7 +-
 sys/net/if_arc.h                      |    4 +-
 sys/net/if_arcsubr.c                  |   14 ++-
 sys/net/if_bridge.c                   |  119 ++++++++++++++++++---------------
 sys/net/if_etherip.c                  |   12 ++-
 sys/net/if_faith.c                    |   11 ++-
 sys/net/if_gif.c                      |   26 +++++--
 sys/net/if_loop.c                     |   11 ++-
 sys/net/if_mpls.c                     |   12 ++-
 sys/net/if_pppoe.c                    |   43 +++++++----
 sys/net/if_srt.c                      |   36 ++++++----
 sys/net/if_stf.c                      |   23 ++++--
 sys/net/if_tap.c                      |   22 ++++-
 sys/net/if_vlan.c                     |   26 ++++++-
 sys/netinet/ip_carp.c                 |   15 +++-
 sys/rump/net/lib/libshmif/if_shmem.c  |   15 +++-
 sys/rump/net/lib/libvirtif/if_virt.c  |   22 +++++-
 48 files changed, 707 insertions(+), 294 deletions(-)

diffs (truncated from 3039 to 300 lines):

diff -r 07ca726abccd -r 7af87a74add2 sys/arch/amiga/dev/if_bah_zbus.c
--- a/sys/arch/amiga/dev/if_bah_zbus.c  Sun Dec 10 09:50:59 2017 +0000
+++ b/sys/arch/amiga/dev/if_bah_zbus.c  Sun Dec 10 10:10:23 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_bah_zbus.c,v 1.16 2015/10/30 12:19:08 phx Exp $ */
+/*     $NetBSD: if_bah_zbus.c,v 1.16.10.1 2017/12/10 10:10:23 snj Exp $ */
 
 /*-
  * Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bah_zbus.c,v 1.16 2015/10/30 12:19:08 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bah_zbus.c,v 1.16.10.1 2017/12/10 10:10:23 snj Exp $");
 
 /*
  * Driver frontend for the Commodore Busines Machines and the
@@ -98,6 +98,7 @@
        struct bah_zbus_softc *bsc = device_private(self);
        struct bah_softc *sc = &bsc->sc_bah;
        struct zbus_args *zap = aux;
+       int rv;
 
        sc->sc_dev = self;
 #if (defined(BAH_DEBUG) && (BAH_DEBUG > 2))
@@ -115,7 +116,11 @@
 
        sc->sc_reset = bah_zbus_reset;
 
-       bah_attach_subr(sc);
+       rv = bah_attach_subr(sc);
+       if (rv != 0) {
+               aprint_error_dev(self, "bah_attach_subr failed(%d)\n", rv);
+               return;
+       }
 
        bsc->sc_isr.isr_intr = bahintr;
        bsc->sc_isr.isr_arg = sc;
diff -r 07ca726abccd -r 7af87a74add2 sys/arch/arm/broadcom/bcm53xx_eth.c
--- a/sys/arch/arm/broadcom/bcm53xx_eth.c       Sun Dec 10 09:50:59 2017 +0000
+++ b/sys/arch/arm/broadcom/bcm53xx_eth.c       Sun Dec 10 10:10:23 2017 +0000
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: bcm53xx_eth.c,v 1.29 2016/12/15 09:28:02 ozaki-r Exp $");
+__KERNEL_RCSID(1, "$NetBSD: bcm53xx_eth.c,v 1.29.8.1 2017/12/10 10:10:23 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -321,45 +321,52 @@
        error = bcmeth_rxq_attach(sc, &sc->sc_rxq, 0);
        if (error) {
                aprint_error(": failed to init rxq: %d\n", error);
-               return;
+               goto fail_1;
        }
 
        error = bcmeth_txq_attach(sc, &sc->sc_txq, 0);
        if (error) {
                aprint_error(": failed to init txq: %d\n", error);
-               return;
+               goto fail_1;
        }
 
        error = bcmeth_mapcache_create(sc, &sc->sc_rx_mapcache, 
            BCMETH_MAXRXMBUFS, MCLBYTES, BCMETH_NRXSEGS);
        if (error) {
                aprint_error(": failed to allocate rx dmamaps: %d\n", error);
-               return;
+               goto fail_1;
        }
 
        error = bcmeth_mapcache_create(sc, &sc->sc_tx_mapcache, 
            BCMETH_MAXTXMBUFS, MCLBYTES, BCMETH_NTXSEGS);
        if (error) {
                aprint_error(": failed to allocate tx dmamaps: %d\n", error);
-               return;
+               goto fail_1;
        }
 
        error = workqueue_create(&sc->sc_workq, xname, bcmeth_worker, sc,
            (PRI_USER + MAXPRI_USER) / 2, IPL_NET, WQ_MPSAFE|WQ_PERCPU);
        if (error) {
                aprint_error(": failed to create workqueue: %d\n", error);
-               return;
+               goto fail_2;
        }
 
        sc->sc_soft_ih = softint_establish(SOFTINT_MPSAFE | SOFTINT_NET,
            bcmeth_soft_intr, sc);
 
+       if (sc->sc_ih == NULL) {
+               aprint_error_dev(self, "failed to establish interrupt %d\n",
+                    loc->loc_intrs[0]);
+               goto fail_3;
+       }
+
        sc->sc_ih = intr_establish(loc->loc_intrs[0], IPL_VM, IST_LEVEL,
            bcmeth_intr, sc);
 
        if (sc->sc_ih == NULL) {
                aprint_error_dev(self, "failed to establish interrupt %d\n",
                     loc->loc_intrs[0]);
+               goto fail_4;
        } else {
                aprint_normal_dev(self, "interrupting on irq %d\n",
                     loc->loc_intrs[0]);
@@ -401,7 +408,12 @@
        /*
         * Attach the interface.
         */
-       if_initialize(ifp);
+       error = if_initialize(ifp);
+       if (error != 0) {
+               aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n",
+                   error);
+               goto fail_5;
+       }
        ether_ifattach(ifp, sc->sc_enaddr);
        if_register(ifp);
 
@@ -419,6 +431,20 @@
        evcnt_attach_dynamic(&sc->sc_ev_rx_badmagic_hi, EVCNT_TYPE_MISC,
            NULL, xname, "rx badmagic hi");
 #endif
+
+       return;
+
+fail_5:
+       ifmedia_removeall(&sc->sc_media);
+fail_4:
+       intr_disestablish(sc->sc_ih);
+fail_3:
+       softint_disestablish(sc->sc_soft_ih);
+fail_2:        
+       workqueue_destroy(sc->sc_workq);
+fail_1:        
+       mutex_obj_free(sc->sc_lock);
+       mutex_obj_free(sc->sc_hwlock);
 }
 
 static int
diff -r 07ca726abccd -r 7af87a74add2 sys/arch/powerpc/booke/dev/pq3etsec.c
--- a/sys/arch/powerpc/booke/dev/pq3etsec.c     Sun Dec 10 09:50:59 2017 +0000
+++ b/sys/arch/powerpc/booke/dev/pq3etsec.c     Sun Dec 10 10:10:23 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pq3etsec.c,v 1.29.8.1 2017/10/24 08:38:58 snj Exp $    */
+/*     $NetBSD: pq3etsec.c,v 1.29.8.2 2017/12/10 10:10:23 snj Exp $    */
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -41,7 +41,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.29.8.1 2017/10/24 08:38:58 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.29.8.2 2017/12/10 10:10:23 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -648,27 +648,27 @@
        error = pq3etsec_rxq_attach(sc, &sc->sc_rxq, 0);
        if (error) {
                aprint_error(": failed to init rxq: %d\n", error);
-               return;
+               goto fail_1;
        }
 
        error = pq3etsec_txq_attach(sc, &sc->sc_txq, 0);
        if (error) {
                aprint_error(": failed to init txq: %d\n", error);
-               return;
+               goto fail_2;
        }
 
        error = pq3etsec_mapcache_create(sc, &sc->sc_rx_mapcache, 
            ETSEC_MAXRXMBUFS, MCLBYTES, ETSEC_NRXSEGS);
        if (error) {
                aprint_error(": failed to allocate rx dmamaps: %d\n", error);
-               return;
+               goto fail_3;
        }
 
        error = pq3etsec_mapcache_create(sc, &sc->sc_tx_mapcache, 
            ETSEC_MAXTXMBUFS, MCLBYTES, ETSEC_NTXSEGS);
        if (error) {
                aprint_error(": failed to allocate tx dmamaps: %d\n", error);
-               return;
+               goto fail_4;
        }
 
        sc->sc_tx_ih = intr_establish(cnl->cnl_intrs[0], IPL_VM, IST_ONCHIP,
@@ -676,7 +676,7 @@
        if (sc->sc_tx_ih == NULL) {
                aprint_error(": failed to establish tx interrupt: %d\n",
                    cnl->cnl_intrs[0]);
-               return;
+               goto fail_5;
        }
 
        sc->sc_rx_ih = intr_establish(cnl->cnl_intrs[1], IPL_VM, IST_ONCHIP,
@@ -684,7 +684,7 @@
        if (sc->sc_rx_ih == NULL) {
                aprint_error(": failed to establish rx interrupt: %d\n",
                    cnl->cnl_intrs[1]);
-               return;
+               goto fail_6;
        }
 
        sc->sc_error_ih = intr_establish(cnl->cnl_intrs[2], IPL_VM, IST_ONCHIP,
@@ -692,7 +692,7 @@
        if (sc->sc_error_ih == NULL) {
                aprint_error(": failed to establish error interrupt: %d\n",
                    cnl->cnl_intrs[2]);
-               return;
+               goto fail_7;
        }
 
        int softint_flags = SOFTINT_NET;
@@ -703,7 +703,7 @@
            pq3etsec_soft_intr, sc);
        if (sc->sc_soft_ih == NULL) {
                aprint_error(": failed to establish soft interrupt\n");
-               return;
+               goto fail_8;
        }
 
        /*
@@ -719,7 +719,7 @@
                sc->sc_mdio_dev = device_find_by_driver_unit("mdio", mdio);
                if (sc->sc_mdio_dev == NULL) {
                        aprint_error(": failed to locate mdio device\n");
-                       return;
+                       goto fail_9;
                }
                aprint_normal("\n");
        }
@@ -734,7 +734,6 @@
        sc->sc_ic_tx_count = 16;
        pq3etsec_set_ic_rx(sc);
        pq3etsec_set_ic_tx(sc);
-       pq3etsec_sysctl_setup(NULL, sc);
 
        char enaddr[ETHER_ADDR_LEN] = {
            [0] = sc->sc_macstnaddr2 >> 16,
@@ -794,7 +793,13 @@
        /*
         * Attach the interface.
         */
-       if_initialize(ifp);
+       error = if_initialize(ifp);
+       if (error != 0) {
+               aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n",
+                   error);
+               goto fail_10;
+       }
+       pq3etsec_sysctl_setup(NULL, sc);
        ether_ifattach(ifp, enaddr);
        if_register(ifp);
 
@@ -818,6 +823,36 @@
            NULL, xname, "rx pause");
        evcnt_attach_dynamic(&sc->sc_ev_mii_ticks, EVCNT_TYPE_MISC,
            NULL, xname, "mii ticks");
+       return;
+
+fail_10:
+       ifmedia_removeall(&sc->sc_mii.mii_media);
+       mii_detach(&sc->sc_mii, sc->sc_phy_addr, MII_OFFSET_ANY);
+fail_9:
+       softint_disestablish(sc->sc_soft_ih);
+fail_8:
+       intr_disestablish(sc->sc_error_ih);
+fail_7:
+       intr_disestablish(sc->sc_rx_ih);
+fail_6:
+       intr_disestablish(sc->sc_tx_ih);
+fail_5:
+       pq3etsec_mapcache_destroy(sc, sc->sc_tx_mapcache);
+fail_4:
+       pq3etsec_mapcache_destroy(sc, sc->sc_rx_mapcache);
+fail_3:
+#if 0 /* notyet */
+       pq3etsec_txq_detach(sc);
+#endif
+fail_2:
+#if 0 /* notyet */
+       pq3etsec_rxq_detach(sc);
+#endif
+fail_1:
+       callout_destroy(&sc->sc_mii_callout);
+       mutex_obj_free(sc->sc_lock);
+       mutex_obj_free(sc->sc_hwlock);
+       bus_space_unmap(sc->sc_bst, sc->sc_bsh, cnl->cnl_size);
 }
 
 static uint64_t
diff -r 07ca726abccd -r 7af87a74add2 sys/arch/usermode/dev/if_veth.c



Home | Main Index | Thread Index | Old Index