[CUWiN-Dev] a couple of netbsd patches
David Young
dyoung at pobox.com
Sun Aug 21 17:11:34 CDT 2005
I added some debug messages as I tried to track down the source of
"ath0: hardware error; resetting". The debug messages have not shown
me any obvious problem, but they do seriously slow down some nodes,
so I am taking them out.
Apply these patches to your NetBSD sources. They take out the noisy
debug messages:
Apply ath-undo-1 in sys/dev/ic/, ath-undo-2 in sys/dev/:
% cd your-netbsd-sources/src/sys/dev/ic
% patch < ath-undo-1
% cd -
% cd your-netbsd-sources/src/sys/dev
% patch < ath-undo-2
Dave
--
David Young OJC Technologies
dyoung at ojctech.com Urbana, IL * (217) 278-3933
-------------- next part --------------
Index: ath.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/ath.c,v
retrieving revision 1.57
diff -u -u -r1.57 ath.c
--- ath.c 27 Jul 2005 21:22:57 -0000 1.57
+++ ath.c 21 Aug 2005 00:22:32 -0000
@@ -449,6 +449,7 @@
error = EIO;
goto bad2;
}
+ printf("%s: beacon queue %u\n", __func__, sc->sc_bhalq);
sc->sc_cabq = ath_txq_setup(sc, HAL_TX_QUEUE_CAB, 0);
if (sc->sc_cabq == NULL) {
if_printf(ifp, "unable to setup CAB xmit queue!\n");
@@ -554,8 +555,10 @@
/*
* Query the hal to figure out h/w crypto support.
*/
+#if 0
if (ath_hal_ciphersupported(ah, HAL_CIPHER_WEP))
ic->ic_caps |= IEEE80211_C_WEP;
+#endif
if (ath_hal_ciphersupported(ah, HAL_CIPHER_AES_OCB))
ic->ic_caps |= IEEE80211_C_AES;
if (ath_hal_ciphersupported(ah, HAL_CIPHER_AES_CCM))
@@ -1135,6 +1138,8 @@
ath_hal_intrset(ah, 0); /* disable interrupts */
ath_draintxq(sc); /* stop xmit side */
ath_stoprecv(sc); /* stop recv side */
+ if (sc->sc_bus_reset != NULL)
+ (*sc->sc_bus_reset)(sc);
/* NB: indicate channel change so we do a full reset */
if (!ath_hal_reset(ah, ic->ic_opmode, &sc->sc_curchan, AH_TRUE, &status))
if_printf(ifp, "%s: unable to reset hardware; hal status %u\n",
@@ -1944,6 +1949,8 @@
sc->sc_stats.ast_be_nombuf++;
return ENOMEM;
}
+ KASSERT((uintptr_t)m->m_data % 4 == 0,
+ ("beacon data buffer %p must be 32-bit aligned", m->m_data));
error = bus_dmamap_load_mbuf(sc->sc_dmat, bf->bf_dmamap, m,
BUS_DMA_NOWAIT);
if (error == 0) {
@@ -4000,7 +3990,7 @@
ATH_TXQ_REMOVE_HEAD(txq, bf_list);
ATH_TXQ_UNLOCK(txq);
#ifdef AR_DEBUG
- if (sc->sc_debug & ATH_DEBUG_RESET)
+ if (sc->sc_debug & (ATH_DEBUG_RESET|ATH_DEBUG_FATAL))
ath_printtxbuf(bf,
ath_hal_txprocdesc(ah, bf->bf_desc) == HAL_OK);
#endif /* AR_DEBUG */
@@ -4027,7 +4017,8 @@
struct ath_hal *ah = sc->sc_ah;
(void) ath_hal_stoptxdma(ah, txq->axq_qnum);
- DPRINTF(sc, ATH_DEBUG_RESET, "%s: tx queue [%u] %p, link %p\n",
+ DPRINTF(sc, ATH_DEBUG_FATAL|ATH_DEBUG_RESET,
+ "%s: tx queue [%u] %p, link %p\n",
__func__, txq->axq_qnum,
(caddr_t)(uintptr_t) ath_hal_gettxbuf(ah, txq->axq_qnum),
txq->axq_link);
@@ -4047,9 +4038,15 @@
if (!sc->sc_invalid) {
/* don't touch the hardware if marked invalid */
(void) ath_hal_stoptxdma(ah, sc->sc_bhalq);
- DPRINTF(sc, ATH_DEBUG_RESET,
+ DPRINTF(sc, ATH_DEBUG_FATAL|ATH_DEBUG_RESET,
"%s: beacon queue %p\n", __func__,
(caddr_t)(uintptr_t) ath_hal_gettxbuf(ah, sc->sc_bhalq));
+
+ if (sc->sc_debug & (ATH_DEBUG_FATAL|ATH_DEBUG_RESET)) {
+ struct ath_buf *bf;
+ STAILQ_FOREACH(bf, &sc->sc_bbuf, bf_list)
+ ath_printtxbuf(bf, 0);
+ }
for (i = 0; i < HAL_NUM_TX_QUEUES; i++)
if (ATH_TXQ_SETUP(sc, i))
ath_tx_stopdma(sc, &sc->sc_txq[i]);
@@ -4728,33 +4725,59 @@
static void
ath_printrxbuf(struct ath_buf *bf, int done)
{
+ struct mbuf *m;
struct ath_desc *ds;
int i;
+ boolean_t pmap_ok;
+ paddr_t pa;
- for (i = 0, ds = bf->bf_desc; i < bf->bf_nseg; i++, ds++) {
- printf("R%d (%p %p) %08x %08x %08x %08x %08x %08x %c\n",
- i, ds, (struct ath_desc *)bf->bf_daddr + i,
+ for (m = bf->bf_m, i = 0, ds = bf->bf_desc;
+ i < bf->bf_nseg && m != NULL; i++, ds++, m = m->m_next) {
+ pmap_ok = pmap_extract(pmap_kernel(), (vaddr_t)m->m_data, &pa);
+ printf("R%d [%p, %u] (%p %p) %08x %08x "
+ "%08x %08x %08x %08x %c %c\n",
+ i, m->m_data, m->m_len,
+ ds, (struct ath_desc *)bf->bf_daddr + i,
ds->ds_link, ds->ds_data,
ds->ds_ctl0, ds->ds_ctl1,
ds->ds_hw[0], ds->ds_hw[1],
- !done ? ' ' : (ds->ds_rxstat.rs_status == 0) ? '*' : '!');
+ !done ? ' ' : (ds->ds_rxstat.rs_status == 0) ? '*' : '!',
+ (pmap_ok && ds->ds_data == pa) ? 'o' : 'x');
+ if (pmap_ok && ds->ds_data != pa)
+ printf("data %08x pa %08lx\n", ds->ds_data, pa);
}
+ if ((m == NULL) != (i == bf->bf_nseg))
+ printf("!!! mbuf chain length mismatches segment count\n");
}
static void
ath_printtxbuf(struct ath_buf *bf, int done)
{
+ static uint8_t buf[3000];
+ struct mbuf *m;
struct ath_desc *ds;
int i;
+ boolean_t pmap_ok;
+ paddr_t pa;
- for (i = 0, ds = bf->bf_desc; i < bf->bf_nseg; i++, ds++) {
- printf("T%d (%p %p) %08x %08x %08x %08x %08x %08x %08x %08x %c\n",
- i, ds, (struct ath_desc *)bf->bf_daddr + i,
- ds->ds_link, ds->ds_data,
- ds->ds_ctl0, ds->ds_ctl1,
- ds->ds_hw[0], ds->ds_hw[1], ds->ds_hw[2], ds->ds_hw[3],
- !done ? ' ' : (ds->ds_txstat.ts_status == 0) ? '*' : '!');
+ for (m = bf->bf_m, i = 0, ds = bf->bf_desc;
+ i < bf->bf_nseg && m != NULL; i++, ds++, m = m->m_next) {
+ pmap_ok = pmap_extract(pmap_kernel(), (vaddr_t)m->m_data, &pa);
+ printf("T%d [%p %u] (%p %p) %08x %08x "
+ "%08x %08x %08x %08x %08x %08x %c %c\n",
+ i, m->m_data, m->m_len,
+ ds, (struct ath_desc *)bf->bf_daddr + i,
+ ds->ds_link, ds->ds_data,
+ ds->ds_ctl0, ds->ds_ctl1,
+ ds->ds_hw[0], ds->ds_hw[1], ds->ds_hw[2], ds->ds_hw[3],
+ !done? ' ' : (ds->ds_txstat.ts_status == 0) ? '*' : '!',
+ (pmap_ok && ds->ds_data == pa) ? 'o' : 'x');
+ (void)memcpy(buf, m->m_data, MIN(sizeof(buf), m->m_len));
+ if (pmap_ok && ds->ds_data != pa)
+ printf("data %08x pa %08lx\n", ds->ds_data, pa);
}
+ if ((m == NULL) != (i == bf->bf_nseg))
+ printf("!!! mbuf chain length mismatches segment count\n");
}
#endif /* AR_DEBUG */
Index: athvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/athvar.h,v
retrieving revision 1.13
diff -u -u -r1.13 athvar.h
--- athvar.h 26 Jul 2005 22:52:48 -0000 1.13
+++ athvar.h 21 Aug 2005 00:22:32 -0000
@@ -287,6 +287,7 @@
void *sc_sdhook; /* shutdown hook */
void *sc_powerhook; /* power management hook */
u_int sc_flags; /* misc flags */
+ void (*sc_bus_reset)(struct ath_softc *);
};
#define sc_if sc_ec.ec_if
#define sc_tx_th u_tx_rt.th
-------------- next part --------------
Index: pci/if_ath_pci.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_ath_pci.c,v
retrieving revision 1.10
diff -u -u -r1.10 if_ath_pci.c
--- pci/if_ath_pci.c 22 Jun 2005 22:07:48 -0000 1.10
+++ pci/if_ath_pci.c 21 Aug 2005 02:07:22 -0000
@@ -91,6 +91,7 @@
struct ath_pci_softc {
struct ath_softc sc_sc;
pci_chipset_tag_t sc_pc;
+ pcitag_t sc_tag;
void *sc_ih; /* interrupt handler */
};
@@ -122,6 +123,18 @@
return 0;
}
+static void
+ath_pci_reset(struct ath_softc *sc)
+{
+ struct ath_pci_softc *psc = (void *)sc;
+ pcireg_t status;
+
+ status = pci_conf_read(psc->sc_pc, psc->sc_tag, PCI_COMMAND_STATUS_REG);
+ printf("%s: PCI status = %" PRIx16 "\n", sc->sc_dev.dv_xname,
+ (status >> PCI_STATUS_SHIFT) & PCI_STATUS_MASK);
+ pci_conf_write(psc->sc_pc, psc->sc_tag, PCI_COMMAND_STATUS_REG, status);
+}
+
static int
ath_pci_setup(struct pci_attach_args *pa)
{
@@ -169,6 +182,7 @@
const char *intrstr = NULL;
psc->sc_pc = pc;
+ psc->sc_tag = pa->pa_tag;
if (!ath_pci_setup(pa))
goto bad;
@@ -183,6 +197,7 @@
}
sc->sc_st = iot;
sc->sc_sh = ioh;
+ sc->sc_bus_reset = ath_pci_reset;
sc->sc_invalid = 1;
More information about the CU-Wireless-Dev
mailing list