From: stsp Date: Mon, 31 May 2021 08:40:41 +0000 (+0000) Subject: Avoid "mac clock not ready" panic in iwm(4). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=cf2767f3dc2db66785a9b33f20e8f15af4fe45ba;p=openbsd Avoid "mac clock not ready" panic in iwm(4). The point of iwm_nic_assert_locked() is to verify that iwm_nic_lock() has been called somewhere up in the call stack. Checking our own lock counter is sufficient for this purpose. If locking the device worked then these registers had the expected state at that time and our lock counter was incremented. Apparently if the device runs into some issue later the state of these registers may change and trigger these panics. Instead we want to handle such failures gracefully and reset the device. problem reported by steven@ ok kettenis@ --- diff --git a/sys/dev/pci/if_iwm.c b/sys/dev/pci/if_iwm.c index 4b502468fea..2d1b4f46e3a 100644 --- a/sys/dev/pci/if_iwm.c +++ b/sys/dev/pci/if_iwm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwm.c,v 1.325 2021/05/16 15:10:20 deraadt Exp $ */ +/* $OpenBSD: if_iwm.c,v 1.326 2021/05/31 08:40:41 stsp Exp $ */ /* * Copyright (c) 2014, 2016 genua gmbh @@ -1069,11 +1069,6 @@ iwm_nic_lock(struct iwm_softc *sc) void iwm_nic_assert_locked(struct iwm_softc *sc) { - uint32_t reg = IWM_READ(sc, IWM_CSR_GP_CNTRL); - if ((reg & IWM_CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY) == 0) - panic("%s: mac clock not ready", DEVNAME(sc)); - if (reg & IWM_CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP) - panic("%s: mac gone to sleep", DEVNAME(sc)); if (sc->sc_nic_locks <= 0) panic("%s: nic locks counter %d", DEVNAME(sc), sc->sc_nic_locks); }