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 panic due to aquire an adaptive mutex with s...



details:   https://anonhg.NetBSD.org/src/rev/ef2312046024
branches:  trunk
changeset: 745990:ef2312046024
user:      yamaguchi <yamaguchi%NetBSD.org@localhost>
date:      Thu Mar 19 03:11:23 2020 +0000

description:
Fix panic due to aquire an adaptive mutex with spin mutex held

The panic is caused by the spin mutex held in ifmedia before
calling callbacks. ixl(4) registers the adaptive mutex used in
the callbacks at initialization to prevent the panic.

diffstat:

 sys/dev/pci/if_ixl.c |  12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diffs (42 lines):

diff -r e4eee1a9318d -r ef2312046024 sys/dev/pci/if_ixl.c
--- a/sys/dev/pci/if_ixl.c      Thu Mar 19 02:58:54 2020 +0000
+++ b/sys/dev/pci/if_ixl.c      Thu Mar 19 03:11:23 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ixl.c,v 1.64 2020/03/13 05:49:52 yamaguchi Exp $    */
+/*     $NetBSD: if_ixl.c,v 1.65 2020/03/19 03:11:23 yamaguchi Exp $    */
 
 /*
  * Copyright (c) 2013-2015, Intel Corporation
@@ -74,7 +74,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ixl.c,v 1.64 2020/03/13 05:49:52 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ixl.c,v 1.65 2020/03/19 03:11:23 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1395,8 +1395,8 @@
        sc->sc_cur_ec_capenable = sc->sc_ec.ec_capenable;
 
        sc->sc_ec.ec_ifmedia = &sc->sc_media;
-       ifmedia_init(&sc->sc_media, IFM_IMASK, ixl_media_change,
-           ixl_media_status);
+       ifmedia_init_with_lock(&sc->sc_media, IFM_IMASK, ixl_media_change,
+           ixl_media_status, &sc->sc_cfg_lock);
 
        ixl_media_add(sc);
        ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_AUTO, 0, NULL);
@@ -1692,10 +1692,10 @@
 {
        struct ixl_softc *sc = ifp->if_softc;
 
-       mutex_enter(&sc->sc_cfg_lock);
+       KASSERT(mutex_owned(&sc->sc_cfg_lock));
+
        ifmr->ifm_status = sc->sc_media_status;
        ifmr->ifm_active = sc->sc_media_active;
-       mutex_exit(&sc->sc_cfg_lock);
 }
 
 static int



Home | Main Index | Thread Index | Old Index