From c6abdfb497d8d9d8c45dbb102bfe57d8cb97c29b Mon Sep 17 00:00:00 2001 From: stsp Date: Thu, 19 Aug 2021 06:02:04 +0000 Subject: [PATCH] Hide detailed firmware error reports from iwn/iwm/iwx by default. These drivers will now report "fatal firmware error" on a single line by default and provide the full trace when debugging has been enabled with e.g. 'ifconfig iwm0 debug'. ok sthen@ kevlo@ --- sys/dev/pci/if_iwm.c | 36 +++++++++++----------- sys/dev/pci/if_iwn.c | 13 ++------ sys/dev/pci/if_iwx.c | 73 ++++++++++++++++++++------------------------ 3 files changed, 53 insertions(+), 69 deletions(-) diff --git a/sys/dev/pci/if_iwm.c b/sys/dev/pci/if_iwm.c index 00212d2924e..f76a648473f 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.357 2021/07/20 16:00:47 stsp Exp $ */ +/* $OpenBSD: if_iwm.c,v 1.358 2021/08/19 06:02:04 stsp Exp $ */ /* * Copyright (c) 2014, 2016 genua gmbh @@ -517,12 +517,10 @@ void iwm_start(struct ifnet *); void iwm_stop(struct ifnet *); void iwm_watchdog(struct ifnet *); int iwm_ioctl(struct ifnet *, u_long, caddr_t); -#if 1 const char *iwm_desc_lookup(uint32_t); void iwm_nic_error(struct iwm_softc *); void iwm_dump_driver_status(struct iwm_softc *); void iwm_nic_umac_error(struct iwm_softc *); -#endif void iwm_rx_mpdu(struct iwm_softc *, struct mbuf *, void *, size_t, struct mbuf_list *); void iwm_flip_address(uint8_t *); @@ -9933,10 +9931,10 @@ iwm_watchdog(struct ifnet *ifp) if (sc->sc_tx_timer > 0) { if (--sc->sc_tx_timer == 0) { printf("%s: device timeout\n", DEVNAME(sc)); -#if 1 - iwm_nic_error(sc); - iwm_dump_driver_status(sc); -#endif + if (ifp->if_flags & IFF_DEBUG) { + iwm_nic_error(sc); + iwm_dump_driver_status(sc); + } if ((sc->sc_flags & IWM_FLAG_SHUTDOWN) == 0) task_add(systq, &sc->init_task); ifp->if_oerrors++; @@ -10001,7 +9999,6 @@ iwm_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) return err; } -#if 1 /* * Note: This structure is read from the device with IO accesses, * and the reading already does the endian conversion. As it is @@ -10268,7 +10265,6 @@ iwm_dump_driver_status(struct iwm_softc *sc) printf(" 802.11 state %s\n", ieee80211_state_name[sc->sc_ic.ic_state]); } -#endif #define SYNC_RESP_STRUCT(_var_, _pkt_) \ do { \ @@ -10701,6 +10697,8 @@ int iwm_intr(void *arg) { struct iwm_softc *sc = arg; + struct ieee80211com *ic = &sc->sc_ic; + struct ifnet *ifp = IC2IFP(ic); int handled = 0; int rv = 0; uint32_t r1, r2; @@ -10763,11 +10761,10 @@ iwm_intr(void *arg) } if (r1 & IWM_CSR_INT_BIT_SW_ERR) { -#if 1 - iwm_nic_error(sc); - iwm_dump_driver_status(sc); -#endif - + if (ifp->if_flags & IFF_DEBUG) { + iwm_nic_error(sc); + iwm_dump_driver_status(sc); + } printf("%s: fatal firmware error\n", DEVNAME(sc)); if ((sc->sc_flags & IWM_FLAG_SHUTDOWN) == 0) task_add(systq, &sc->init_task); @@ -10836,6 +10833,8 @@ int iwm_intr_msix(void *arg) { struct iwm_softc *sc = arg; + struct ieee80211com *ic = &sc->sc_ic; + struct ifnet *ifp = IC2IFP(ic); uint32_t inta_fh, inta_hw; int vector = 0; @@ -10860,11 +10859,10 @@ iwm_intr_msix(void *arg) if ((inta_fh & IWM_MSIX_FH_INT_CAUSES_FH_ERR) || (inta_hw & IWM_MSIX_HW_INT_CAUSES_REG_SW_ERR) || (inta_hw & IWM_MSIX_HW_INT_CAUSES_REG_SW_ERR_V2)) { -#if 1 - iwm_nic_error(sc); - iwm_dump_driver_status(sc); -#endif - + if (ifp->if_flags & IFF_DEBUG) { + iwm_nic_error(sc); + iwm_dump_driver_status(sc); + } printf("%s: fatal firmware error\n", DEVNAME(sc)); if ((sc->sc_flags & IWM_FLAG_SHUTDOWN) == 0) task_add(systq, &sc->init_task); diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c index a5a78bfcf86..2870256d837 100644 --- a/sys/dev/pci/if_iwn.c +++ b/sys/dev/pci/if_iwn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwn.c,v 1.248 2021/04/29 21:43:47 stsp Exp $ */ +/* $OpenBSD: if_iwn.c,v 1.249 2021/08/19 06:02:04 stsp Exp $ */ /*- * Copyright (c) 2007-2010 Damien Bergamini @@ -904,8 +904,6 @@ iwn_mem_write_2(struct iwn_softc *sc, uint32_t addr, uint16_t data) iwn_mem_write(sc, addr & ~3, tmp); } -#ifdef IWN_DEBUG - static __inline void iwn_mem_read_region_4(struct iwn_softc *sc, uint32_t addr, uint32_t *data, int count) @@ -914,8 +912,6 @@ iwn_mem_read_region_4(struct iwn_softc *sc, uint32_t addr, uint32_t *data, *data++ = iwn_mem_read(sc, addr); } -#endif - static __inline void iwn_mem_set_region_4(struct iwn_softc *sc, uint32_t addr, uint32_t val, int count) @@ -3075,7 +3071,6 @@ iwn_wakeup_intr(struct iwn_softc *sc) } } -#ifdef IWN_DEBUG /* * Dump the error log of the firmware when a firmware panic occurs. Although * we can't debug the firmware because it is neither open source nor free, it @@ -3135,7 +3130,6 @@ iwn_fatal_intr(struct iwn_softc *sc) printf(" rx ring: cur=%d\n", sc->rxq.cur); printf(" 802.11 state %d\n", sc->sc_ic.ic_state); } -#endif int iwn_intr(void *arg) @@ -3197,9 +3191,8 @@ iwn_intr(void *arg) sc->sc_flags &= ~IWN_FLAG_CALIB_DONE; /* Dump firmware error log and stop. */ -#ifdef IWN_DEBUG - iwn_fatal_intr(sc); -#endif + if (ifp->if_flags & IFF_DEBUG) + iwn_fatal_intr(sc); iwn_stop(ifp); task_add(systq, &sc->init_task); return 1; diff --git a/sys/dev/pci/if_iwx.c b/sys/dev/pci/if_iwx.c index a214f1eef6f..e43ee9d51e5 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.91 2021/08/16 14:54:50 kevlo Exp $ */ +/* $OpenBSD: if_iwx.c,v 1.92 2021/08/19 06:02:04 stsp Exp $ */ /* * Copyright (c) 2014, 2016 genua gmbh @@ -462,6 +462,7 @@ void iwx_watchdog(struct ifnet *); int iwx_ioctl(struct ifnet *, u_long, caddr_t); const char *iwx_desc_lookup(uint32_t); void iwx_nic_error(struct iwx_softc *); +void iwx_dump_driver_status(struct iwx_softc *); void iwx_nic_umac_error(struct iwx_softc *); int iwx_detect_duplicate(struct iwx_softc *, struct mbuf *, struct iwx_rx_mpdu_desc *, struct ieee80211_rxinfo *); @@ -8145,9 +8146,10 @@ iwx_watchdog(struct ifnet *ifp) if (sc->sc_tx_timer > 0) { if (--sc->sc_tx_timer == 0) { printf("%s: device timeout\n", DEVNAME(sc)); -#ifdef IWX_DEBUG - iwx_nic_error(sc); -#endif + if (ifp->if_flags & IFF_DEBUG) { + iwx_nic_error(sc); + iwx_dump_driver_status(sc); + } if ((sc->sc_flags & IWX_FLAG_SHUTDOWN) == 0) task_add(systq, &sc->init_task); ifp->if_oerrors++; @@ -8212,7 +8214,6 @@ iwx_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) return err; } -#if 1 /* usually #ifdef IWX_DEBUG but always enabled for now */ /* * Note: This structure is read from the device with IO accesses, * and the reading already does the endian conversion. As it is @@ -8462,7 +8463,23 @@ iwx_nic_error(struct iwx_softc *sc) if (sc->sc_uc.uc_umac_error_event_table) iwx_nic_umac_error(sc); } -#endif + +void +iwx_dump_driver_status(struct iwx_softc *sc) +{ + int i; + + printf("driver status:\n"); + for (i = 0; i < IWX_MAX_QUEUES; i++) { + struct iwx_tx_ring *ring = &sc->txq[i]; + printf(" tx ring %2d: qid=%-2d cur=%-3d " + "queued=%-3d\n", + i, ring->qid, ring->cur, ring->queued); + } + printf(" rx ring: cur=%d\n", sc->rxq.cur); + printf(" 802.11 state %s\n", + ieee80211_state_name[sc->sc_ic.ic_state]); +} #define SYNC_RESP_STRUCT(_var_, _pkt_) \ do { \ @@ -8874,6 +8891,8 @@ int iwx_intr(void *arg) { struct iwx_softc *sc = arg; + struct ieee80211com *ic = &sc->sc_ic; + struct ifnet *ifp = IC2IFP(ic); int handled = 0; int r1, r2, rv = 0; @@ -8938,24 +8957,10 @@ iwx_intr(void *arg) } if (r1 & IWX_CSR_INT_BIT_SW_ERR) { -#if 1 /* usually #ifdef IWX_DEBUG but always enabled for now */ - int i; - - iwx_nic_error(sc); - - /* Dump driver status (TX and RX rings) while we're here. */ - printf("driver status:\n"); - for (i = 0; i < IWX_MAX_QUEUES; i++) { - struct iwx_tx_ring *ring = &sc->txq[i]; - printf(" tx ring %2d: qid=%-2d cur=%-3d " - "queued=%-3d\n", - i, ring->qid, ring->cur, ring->queued); + if (ifp->if_flags & IFF_DEBUG) { + iwx_nic_error(sc); + iwx_dump_driver_status(sc); } - printf(" rx ring: cur=%d\n", sc->rxq.cur); - printf(" 802.11 state %s\n", - ieee80211_state_name[sc->sc_ic.ic_state]); -#endif - printf("%s: fatal firmware error\n", DEVNAME(sc)); if ((sc->sc_flags & IWX_FLAG_SHUTDOWN) == 0) task_add(systq, &sc->init_task); @@ -9024,6 +9029,8 @@ int iwx_intr_msix(void *arg) { struct iwx_softc *sc = arg; + struct ieee80211com *ic = &sc->sc_ic; + struct ifnet *ifp = IC2IFP(ic); uint32_t inta_fh, inta_hw; int vector = 0; @@ -9048,24 +9055,10 @@ iwx_intr_msix(void *arg) if ((inta_fh & IWX_MSIX_FH_INT_CAUSES_FH_ERR) || (inta_hw & IWX_MSIX_HW_INT_CAUSES_REG_SW_ERR) || (inta_hw & IWX_MSIX_HW_INT_CAUSES_REG_SW_ERR_V2)) { -#if 1 /* usually #ifdef IWX_DEBUG but always enabled for now */ - int i; - - iwx_nic_error(sc); - - /* Dump driver status (TX and RX rings) while we're here. */ - printf("driver status:\n"); - for (i = 0; i < IWX_MAX_QUEUES; i++) { - struct iwx_tx_ring *ring = &sc->txq[i]; - printf(" tx ring %2d: qid=%-2d cur=%-3d " - "queued=%-3d\n", - i, ring->qid, ring->cur, ring->queued); + if (ifp->if_flags & IFF_DEBUG) { + iwx_nic_error(sc); + iwx_dump_driver_status(sc); } - printf(" rx ring: cur=%d\n", sc->rxq.cur); - printf(" 802.11 state %s\n", - ieee80211_state_name[sc->sc_ic.ic_state]); -#endif - printf("%s: fatal firmware error\n", DEVNAME(sc)); if ((sc->sc_flags & IWX_FLAG_SHUTDOWN) == 0) task_add(systq, &sc->init_task); -- 2.20.1