From 61cb6c90769cfb040a30d8f4657f141d612c2fe5 Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Sun, 15 Aug 2010 20:34:51 +0000 Subject: [PATCH] wakeup is required if the adapter lock is released anywhere during init and not just for the may_sleep case. Pointed out by: Isilon MFC after: 3 days --- sys/dev/cxgb/cxgb_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/dev/cxgb/cxgb_main.c b/sys/dev/cxgb/cxgb_main.c index fc66d605dd4..2dd29ac65a7 100644 --- a/sys/dev/cxgb/cxgb_main.c +++ b/sys/dev/cxgb/cxgb_main.c @@ -1778,11 +1778,12 @@ cxgb_init_locked(struct port_info *p) struct adapter *sc = p->adapter; struct ifnet *ifp = p->ifp; struct cmac *mac = &p->mac; - int i, rc = 0, may_sleep = 0; + int i, rc = 0, may_sleep = 0, gave_up_lock = 0; ADAPTER_LOCK_ASSERT_OWNED(sc); while (!IS_DOOMED(p) && IS_BUSY(sc)) { + gave_up_lock = 1; if (mtx_sleep(&sc->flags, &sc->lock, PCATCH, "cxgbinit", 0)) { rc = EINTR; goto done; @@ -1802,6 +1803,7 @@ cxgb_init_locked(struct port_info *p) if (may_sleep) { SET_BUSY(sc); + gave_up_lock = 1; ADAPTER_UNLOCK(sc); } @@ -1849,8 +1851,9 @@ done: ADAPTER_LOCK(sc); KASSERT(IS_BUSY(sc), ("%s: controller not busy.", __func__)); CLR_BUSY(sc); - wakeup_one(&sc->flags); } + if (gave_up_lock) + wakeup_one(&sc->flags); ADAPTER_UNLOCK(sc); return (rc); }