Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Fix wm(4) create too many workqueue. Pointed ou...



details:   https://anonhg.NetBSD.org/src/rev/1c3c5f5067d1
branches:  trunk
changeset: 968891:1c3c5f5067d1
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Fri Jan 31 12:03:23 2020 +0000

description:
Fix wm(4) create too many workqueue.  Pointed out by msaitoh@n.o

diffstat:

 sys/dev/pci/if_wm.c |  54 ++++++++++++++++++++++------------------------------
 1 files changed, 23 insertions(+), 31 deletions(-)

diffs (118 lines):

diff -r 5dfcb823d8c5 -r 1c3c5f5067d1 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Fri Jan 31 09:23:58 2020 +0000
+++ b/sys/dev/pci/if_wm.c       Fri Jan 31 12:03:23 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.663 2020/01/29 06:44:27 thorpej Exp $      */
+/*     $NetBSD: if_wm.c,v 1.664 2020/01/31 12:03:23 knakahara Exp $    */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.663 2020/01/29 06:44:27 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.664 2020/01/31 12:03:23 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -750,7 +750,7 @@
 static void    wm_adjust_qnum(struct wm_softc *, int);
 static inline bool     wm_is_using_msix(struct wm_softc *);
 static inline bool     wm_is_using_multiqueue(struct wm_softc *);
-static int     wm_softhandler_establish(struct wm_softc *, int, int);
+static int     wm_softint_establish(struct wm_softc *, int, int);
 static int     wm_setup_legacy(struct wm_softc *);
 static int     wm_setup_msix(struct wm_softc *);
 static int     wm_init(struct ifnet *);
@@ -1822,6 +1822,7 @@
        prop_number_t pn;
        uint8_t enaddr[ETHER_ADDR_LEN];
        char buf[256];
+       char wqname[MAXCOMLEN];
        uint16_t cfg1, cfg2, swdpin, nvmword;
        pcireg_t preg, memtype;
        uint16_t eeprom_data, apme_mask;
@@ -2055,6 +2056,16 @@
                }
        }
 
+       snprintf(wqname, sizeof(wqname), "%sTxRx", device_xname(sc->sc_dev));
+       error = workqueue_create(&sc->sc_queue_wq, wqname,
+           wm_handle_queue_work, sc, WM_WORKQUEUE_PRI, IPL_NET,
+           WM_WORKQUEUE_FLAGS);
+       if (error) {
+               aprint_error_dev(sc->sc_dev,
+                   "unable to create workqueue\n");
+               goto out;
+       }
+
        /*
         * Check the function ID (unit number of the chip).
         */
@@ -5415,11 +5426,9 @@
 }
 
 static int
-wm_softhandler_establish(struct wm_softc *sc, int qidx, int intr_idx)
-{
-       char wqname[MAXCOMLEN];
+wm_softint_establish(struct wm_softc *sc, int qidx, int intr_idx)
+{
        struct wm_queue *wmq = &sc->sc_queue[qidx];
-       int error;
 
        wmq->wmq_id = qidx;
        wmq->wmq_intr_idx = intr_idx;
@@ -5428,28 +5437,11 @@
            | SOFTINT_MPSAFE
 #endif
            , wm_handle_queue, wmq);
-       if (wmq->wmq_si == NULL) {
-               aprint_error_dev(sc->sc_dev,
-                   "unable to establish queue[%d] softint handler\n",
-                   wmq->wmq_id);
-               goto err;
-       }
-
-       snprintf(wqname, sizeof(wqname), "%sTxRx", device_xname(sc->sc_dev));
-       error = workqueue_create(&sc->sc_queue_wq, wqname,
-           wm_handle_queue_work, sc, WM_WORKQUEUE_PRI, IPL_NET,
-           WM_WORKQUEUE_FLAGS);
-       if (error) {
-               softint_disestablish(wmq->wmq_si);
-               aprint_error_dev(sc->sc_dev,
-                   "unable to create queue[%d] workqueue\n",
-                   wmq->wmq_id);
-               goto err;
-       }
-
-       return 0;
-
-err:
+       if (wmq->wmq_si != NULL)
+               return 0;
+
+       aprint_error_dev(sc->sc_dev, "unable to establish queue[%d] handler\n",
+           wmq->wmq_id);
        pci_intr_disestablish(sc->sc_pc, sc->sc_ihs[wmq->wmq_intr_idx]);
        sc->sc_ihs[wmq->wmq_intr_idx] = NULL;
        return ENOMEM;
@@ -5489,7 +5481,7 @@
        aprint_normal_dev(sc->sc_dev, "interrupting at %s\n", intrstr);
        sc->sc_nintrs = 1;
 
-       return wm_softhandler_establish(sc, 0, 0);
+       return wm_softint_establish(sc, 0, 0);
 }
 
 static int
@@ -5567,7 +5559,7 @@
                            "for TX and RX interrupting at %s\n", intrstr);
                }
                sc->sc_ihs[intr_idx] = vih;
-               if (wm_softhandler_establish(sc, qidx, intr_idx) != 0)
+               if (wm_softint_establish(sc, qidx, intr_idx) != 0)
                        goto fail;
                txrx_established++;
                intr_idx++;



Home | Main Index | Thread Index | Old Index