From 2f384bdb033dd3776bc3ef4c45c082dc8204272a Mon Sep 17 00:00:00 2001 From: stsp Date: Mon, 31 May 2021 08:43:07 +0000 Subject: [PATCH] Avoid "mac clock not ready" panic in iwx(4). The same change was just made 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@ --- sys/dev/pci/if_iwx.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/sys/dev/pci/if_iwx.c b/sys/dev/pci/if_iwx.c index a37ba57c905..603040437b7 100644 --- a/sys/dev/pci/if_iwx.c +++ b/sys/dev/pci/if_iwx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwx.c,v 1.56 2021/05/16 15:10:20 deraadt Exp $ */ +/* $OpenBSD: if_iwx.c,v 1.57 2021/05/31 08:43:07 stsp Exp $ */ /* * Copyright (c) 2014, 2016 genua gmbh @@ -1454,11 +1454,6 @@ iwx_nic_lock(struct iwx_softc *sc) void iwx_nic_assert_locked(struct iwx_softc *sc) { - uint32_t reg = IWX_READ(sc, IWX_CSR_GP_CNTRL); - if ((reg & IWX_CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY) == 0) - panic("%s: mac clock not ready", DEVNAME(sc)); - if (reg & IWX_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); } -- 2.20.1