Hi Adrian,

This:

+#ifdef ARGE_DEBUG
+       for (i = 0; i < 32; i++) {
+               if (status & (1 << i)) {
+                       sc->intr_stats.count[1 << i]++;
+               }
+       }
+#endif

looks wrong.

If "status" has value 0x0080, then the above will try to increment index 128, 
which is past the end of the array. I think you just meant the index to be "i", 
not "1 << i".

Thanks,

Ravi


-----Original Message-----

>Date: Wed, 28 Oct 2015 05:11:06 +0000 (UTC)
>From: Adrian Chadd <adr...@freebsd.org>
>To: src-committ...@freebsd.org, svn-src-...@freebsd.org,
>       svn-src-head@freebsd.org
>Subject: svn commit: r290090 - head/sys/mips/atheros
>Message-ID: <201510280511.t9s5b6es009...@repo.freebsd.org>
>Content-Type: text/plain; charset=UTF-8
>
>Author: adrian
>Date: Wed Oct 28 05:11:06 2015
>New Revision: 290090
>URL: https://svnweb.freebsd.org/changeset/base/290090
>
>Log:
>  Add some debugging code (under ARGE_DEBUG) that counts each interrupt source.
>  
>  This should make it easier to track down interrupt storms from arge.
>  
>  Tested:
>  
>  * AP135 (QCA955x) SoC - defaults to ARGE_DEBUG enabled
>  * Carambola2 (AR9331 SoC) - defaults to ARGE_DEBUG disabled
>
>Modified:
>  head/sys/mips/atheros/if_arge.c
>  head/sys/mips/atheros/if_argevar.h
>
>Modified: head/sys/mips/atheros/if_arge.c
>==============================================================================
>--- head/sys/mips/atheros/if_arge.c    Wed Oct 28 03:43:24 2015        
>(r290089)
>+++ head/sys/mips/atheros/if_arge.c    Wed Oct 28 05:11:06 2015        
>(r290090)
>@@ -277,6 +277,28 @@ arge_probe(device_t dev)
>       return (BUS_PROBE_NOWILDCARD);
> }
> 
>+#ifdef        ARGE_DEBUG
>+static void
>+arge_attach_intr_sysctl(device_t dev, struct sysctl_oid_list *parent)
>+{
>+      struct arge_softc *sc = device_get_softc(dev);
>+      struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(dev);
>+      struct sysctl_oid *tree = device_get_sysctl_tree(dev);
>+      struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
>+      char sn[8];
>+      int i;
>+
>+      tree = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO, "intr",
>+          CTLFLAG_RD, NULL, "Interrupt statistics");
>+      child = SYSCTL_CHILDREN(tree);
>+      for (i = 0; i < 32; i++) {
>+              snprintf(sn, sizeof(sn), "%d", i);
>+              SYSCTL_ADD_UINT(ctx, child, OID_AUTO, sn, CTLFLAG_RD,
>+                  &sc->intr_stats.count[i], 0, "");
>+      }
>+}
>+#endif
>+
> static void
> arge_attach_sysctl(device_t dev)
> {
>@@ -288,6 +310,7 @@ arge_attach_sysctl(device_t dev)
>       SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
>               "debug", CTLFLAG_RW, &sc->arge_debug, 0,
>               "arge interface debugging flags");
>+      arge_attach_intr_sysctl(dev, SYSCTL_CHILDREN(tree));
> #endif
> 
>       SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
>@@ -2440,6 +2463,9 @@ arge_intr(void *arg)
>       struct arge_softc       *sc = arg;
>       uint32_t                status;
>       struct ifnet            *ifp = sc->arge_ifp;
>+#ifdef        ARGE_DEBUG
>+      int i;
>+#endif
> 
>       status = ARGE_READ(sc, AR71XX_DMA_INTR_STATUS);
>       status |= sc->arge_intr_status;
>@@ -2456,6 +2482,14 @@ arge_intr(void *arg)
>               return;
>       }
> 
>+#ifdef        ARGE_DEBUG
>+      for (i = 0; i < 32; i++) {
>+              if (status & (1 << i)) {
>+                      sc->intr_stats.count[1 << i]++;
>+              }
>+      }
>+#endif
>+
>       if (status & DMA_INTR_RX_BUS_ERROR) {
>               ARGE_WRITE(sc, AR71XX_DMA_RX_STATUS, DMA_RX_STATUS_BUS_ERROR);
>               device_printf(sc->arge_dev, "RX bus error");
>
>Modified: head/sys/mips/atheros/if_argevar.h
>==============================================================================
>--- head/sys/mips/atheros/if_argevar.h Wed Oct 28 03:43:24 2015        
>(r290089)
>+++ head/sys/mips/atheros/if_argevar.h Wed Oct 28 05:11:06 2015        
>(r290090)
>@@ -214,6 +214,9 @@ struct arge_softc {
>               uint32_t        intr_stray2;
>               uint32_t        intr_ok;
>       } stats;
>+      struct {
>+              uint32_t        count[32];
>+      } intr_stats;
> };
> 
> #endif /* __IF_ARGEVAR_H__ */
>
>
>------------------------------
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to