Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Mar 2013 18:48:14 GMT
From:      Brooks Davis <brooks@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 225861 for review
Message-ID:  <201303221848.r2MImEsD075821@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@225861?ac=10

Change 225861 by brooks@brooks_zenith on 2013/03/22 18:47:50

	Add (mips only) per-source interrupt statistics to beripic.
	Reduce verbosity a bit.

Affected files ...

.. //depot/projects/ctsrd/beribsd/src/sys/mips/beri/beri_pic.c#2 edit

Differences ...

==== //depot/projects/ctsrd/beribsd/src/sys/mips/beri/beri_pic.c#2 (text+ko) ====

@@ -58,6 +58,9 @@
 static char	*bp_strconfig(uint64_t, char *, size_t);
 static void	bp_print_config(device_t);
 static void	bp_config_source(device_t, int, int, u_long, u_long);
+#ifdef __mips__
+static void	bp_set_counter_name(device_t, device_t, int);
+#endif
 
 static int	beripic_fdt_probe(device_t);
 static int	beripic_fdt_attach(device_t);
@@ -110,6 +113,10 @@
 	int			bp_nsrcs;
 	struct rman		bp_src_rman;
 
+#ifdef __mips__
+	mips_intrcnt_t		*bp_counters;
+#endif
+
 	struct mtx		bp_cfgmtx;
 };
 
@@ -118,6 +125,9 @@
 	driver_intr_t		*intr;
 	void			*arg;
 	struct resource		*irq;
+#ifdef __mips__
+	mips_intrcnt_t		counter;
+#endif
 	/* XXX counter */
 };
 
@@ -234,7 +244,7 @@
 {
 	char configstr[64];
 	struct beripic_softc *sc;
-	uint64_t config, oconfig;
+	uint64_t config;
 
 	sc = device_get_softc(ic);
 
@@ -243,16 +253,31 @@
 	config |= tid << BP_CFG_SHIFT_TID;
 	config |= irq << BP_CFG_SHIFT_IRQ;
 
-	oconfig = bp_read_cfg(sc, src);
-	if (oconfig != 0 && config != 0)
-		device_printf(ic, "src %d previous config: %s\n",
-		    src, bp_strconfig(oconfig, configstr, sizeof(configstr)));
 	if (bootverbose)
 		device_printf(ic, "src %d: %s\n", src,
 		    bp_strconfig(config, configstr, sizeof(configstr)));
 	bp_write_cfg(sc, src, config);
 }
 
+#ifdef __mips__
+static void
+bp_set_counter_name(device_t ic, device_t child, int src)
+{
+	struct beripic_softc *sc;
+	char name[MAXCOMLEN + 1];
+
+	sc = device_get_softc(ic);
+
+	if (snprintf(name, sizeof(name), "bp%dsrc%d%s%s%s",
+	    device_get_unit(ic), src, src < sc->bp_nhard ? "" : "s",
+	    child == NULL ? "" : " ",
+	    child == NULL ? " " : device_get_nameunit(child)) >= sizeof(name))
+		name[sizeof(name) - 2] = '+';
+	
+	mips_intrcnt_setname(sc->bp_counters[src], name);
+}
+#endif
+
 static int
 beripic_fdt_probe(device_t dev)
 {
@@ -387,6 +412,15 @@
 	if (bootverbose)
 		device_printf(dev, "%d hard and %d soft sources\n",
 		    sc->bp_nhard, sc->bp_nsoft);
+
+#ifdef __mips__
+	sc->bp_counters = malloc(sizeof(*sc->bp_counters) * sc->bp_nsrcs,
+	    M_BERIPIC, M_WAITOK|M_ZERO);
+	for (i = 0; i < sc->bp_nsrcs; i++) {
+		sc->bp_counters[i] = mips_intrcnt_create("");
+		bp_set_counter_name(dev, NULL, i);
+	}
+#endif
 	
 	sc->bp_src_rman.rm_start = 0;
 	sc->bp_src_rman.rm_end = sc->bp_nsrcs - 1;
@@ -492,19 +526,24 @@
 	struct beripic_intr_arg *bpia;
 	struct beripic_cookie *bpc;
 	int error;
-	u_long hirq, tid;
+	u_long hirq, src, tid;
 
 	sc = device_get_softc(ic);
 
-	KASSERT(rman_get_start(irq) < sc->bp_nsrcs,
-	    ("source (%ul) out of range 0-%d", rman_get_start(irq),
-	     rman_get_start(irq) - 1));
+	src = rman_get_start(irq);
+
+	KASSERT(src < sc->bp_nsrcs, ("source (%ul) out of range 0-%d",
+	     src, sc->bp_nsrcs - 1));
 
 	bpia = malloc(sizeof(*bpia), M_BERIPIC, M_WAITOK|M_ZERO);
 	bpia->filter = filter;
 	bpia->intr = intr;
 	bpia->arg = arg;
 	bpia->irq = irq;
+#ifdef __mips__
+	bpia->counter = sc->bp_counters[src];
+	bp_set_counter_name(ic, child, src);
+#endif
 
 	bpc = malloc(sizeof(*bpc), M_BERIPIC, M_WAITOK|M_ZERO);
 	bpc->bpia = bpia;
@@ -514,13 +553,9 @@
 	hirq = rman_get_start(bpc->hirq);
 	tid = sc->bp_next_tid;
 
-device_printf(ic, "allocated irq %lu tid %lu to %s who requsted %lu\n",
-    hirq, tid, device_get_nameunit(child), rman_get_start(irq));
-
-	/* XXX: should add a filter that checks IP state */
 	error = BUS_SETUP_INTR(device_get_parent(ic), ic, bpc->hirq, flags,
-	    filter == NULL ? NULL : beripic_filter,
-	    intr == NULL ? NULL : beripic_intr, bpia, &(bpc->cookie));
+	    beripic_filter, intr == NULL ? NULL : beripic_intr, bpia,
+	    &(bpc->cookie));
 	if (error != 0)
 		goto err;
 
@@ -577,8 +612,14 @@
 
 	bpic = arg;
 
-	KASSERT(bpic->filter != NULL,
-	    ("%s installed, but no child filter", __func__));
+#ifdef __mips__
+	mips_intrcnt_inc(bpic->counter);
+#endif
+
+	/* XXX: Add a check that our source is high */
+
+	if (bpic->filter == NULL)
+		return (FILTER_SCHEDULE_THREAD);
 
 	return (bpic->filter(bpic->arg));
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303221848.r2MImEsD075821>