Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Jan 2010 17:54:29 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r202762 - in stable/8: share/man/man9 sys/amd64/amd64 sys/amd64/include sys/i386/i386 sys/i386/include sys/kern sys/sparc64/include sys/sparc64/pci sys/sparc64/sparc64 sys/sys
Message-ID:  <201001211754.o0LHsT5g000844@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Thu Jan 21 17:54:29 2010
New Revision: 202762
URL: http://svn.freebsd.org/changeset/base/202762

Log:
  MFC 198134,198149,198170,198171,198391,200948:
  Add a facility for associating optional descriptions with active interrupt
  handlers.  This is primarily intended as a way to allow devices that use
  multiple interrupts (e.g. MSI) to meaningfully distinguish the various
  interrupt handlers.
  - Add a new BUS_DESCRIBE_INTR() method to the bus interface to associate
    a description with an active interrupt handler setup by BUS_SETUP_INTR.
    It has a default method (bus_generic_describe_intr()) which simply passes
    the request up to the parent device.
  - Add a bus_describe_intr() wrapper around BUS_DESCRIBE_INTR() that supports
    printf(9) style formatting using var args.
  - Reserve MAXCOMLEN bytes in the intr_handler structure to hold the name of
    an interrupt handler and copy the name passed to intr_event_add_handler()
    into that buffer instead of just saving the pointer to the name.
  - Add a new intr_event_describe_handler() which appends a description string
    to an interrupt handler's name.
  - Implement support for interrupt descriptions on amd64, i386, and sparc64 by
    having the nexus(4) driver supply a custom bus_describe_intr method that
    invokes a new intr_describe() MD routine which in turn looks up the
    associated interrupt event and invokes intr_event_describe_handler().

Added:
  stable/8/share/man/man9/BUS_DESCRIBE_INTR.9
     - copied, changed from r198134, head/share/man/man9/BUS_DESCRIBE_INTR.9
Modified:
  stable/8/share/man/man9/Makefile
  stable/8/sys/amd64/amd64/intr_machdep.c
  stable/8/sys/amd64/amd64/nexus.c
  stable/8/sys/amd64/include/intr_machdep.h
  stable/8/sys/i386/i386/intr_machdep.c
  stable/8/sys/i386/i386/nexus.c
  stable/8/sys/i386/include/intr_machdep.h
  stable/8/sys/kern/bus_if.m
  stable/8/sys/kern/kern_intr.c
  stable/8/sys/kern/subr_bus.c
  stable/8/sys/sparc64/include/intr_machdep.h
  stable/8/sys/sparc64/pci/psycho.c
  stable/8/sys/sparc64/pci/schizo.c
  stable/8/sys/sparc64/sparc64/intr_machdep.c
  stable/8/sys/sparc64/sparc64/nexus.c
  stable/8/sys/sys/bus.h
  stable/8/sys/sys/interrupt.h
Directory Properties:
  stable/8/share/man/man9/   (props changed)
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Copied and modified: stable/8/share/man/man9/BUS_DESCRIBE_INTR.9 (from r198134, head/share/man/man9/BUS_DESCRIBE_INTR.9)
==============================================================================
--- head/share/man/man9/BUS_DESCRIBE_INTR.9	Thu Oct 15 14:54:35 2009	(r198134, copy source)
+++ stable/8/share/man/man9/BUS_DESCRIBE_INTR.9	Thu Jan 21 17:54:29 2010	(r202762)
@@ -88,10 +88,10 @@ the interrupt handler name.
 Zero is returned on success, otherwise an appropriate error is returned.
 .Sh SEE ALSO
 .Xr BUS_SETUP_INTR 9 ,
-.Xr device 9 ,
-.Xr printf 9 ,
 .Xr systat 1 ,
-.Xr vmstat 8
+.Xr vmstat 8 ,
+.Xr device 9 ,
+.Xr printf 9
 .Sh HISTORY
 The
 .Fn BUS_DESCRIBE_INTR

Modified: stable/8/share/man/man9/Makefile
==============================================================================
--- stable/8/share/man/man9/Makefile	Thu Jan 21 17:46:14 2010	(r202761)
+++ stable/8/share/man/man9/Makefile	Thu Jan 21 17:54:29 2010	(r202762)
@@ -26,6 +26,7 @@ MAN=	accept_filter.9 \
 	BUS_BIND_INTR.9 \
 	bus_child_present.9 \
 	BUS_CONFIG_INTR.9 \
+	BUS_DESCRIBE_INTR.9 \
 	bus_dma.9 \
 	bus_generic_attach.9 \
 	bus_generic_detach.9 \
@@ -404,6 +405,7 @@ MLINKS+=buf.9 bp.9
 MLINKS+=bus_activate_resource.9 bus_deactivate_resource.9
 MLINKS+=bus_alloc_resource.9 bus_alloc_resource_any.9
 MLINKS+=BUS_BIND_INTR.9 bus_bind_intr.9
+MLINKS+=BUS_DESCRIBE_INTR.9 bus_describe_intr.9
 MLINKS+=bus_dma.9 busdma.9 \
 	bus_dma.9 bus_dmamap_create.9 \
 	bus_dma.9 bus_dmamap_destroy.9 \

Modified: stable/8/sys/amd64/amd64/intr_machdep.c
==============================================================================
--- stable/8/sys/amd64/amd64/intr_machdep.c	Thu Jan 21 17:46:14 2010	(r202761)
+++ stable/8/sys/amd64/amd64/intr_machdep.c	Thu Jan 21 17:54:29 2010	(r202762)
@@ -400,6 +400,23 @@ atpic_reset(void)
 }
 #endif
 
+/* Add a description to an active interrupt handler. */
+int
+intr_describe(u_int vector, void *ih, const char *descr)
+{
+	struct intsrc *isrc;
+	int error;
+
+	isrc = intr_lookup_source(vector);
+	if (isrc == NULL)
+		return (EINVAL);
+	error = intr_event_describe_handler(isrc->is_event, ih, descr);
+	if (error)
+		return (error);
+	intrcnt_updatename(isrc);
+	return (0);
+}
+
 #ifdef DDB
 /*
  * Dump data about interrupt handlers

Modified: stable/8/sys/amd64/amd64/nexus.c
==============================================================================
--- stable/8/sys/amd64/amd64/nexus.c	Thu Jan 21 17:46:14 2010	(r202761)
+++ stable/8/sys/amd64/amd64/nexus.c	Thu Jan 21 17:54:29 2010	(r202762)
@@ -92,6 +92,9 @@ static	int nexus_bind_intr(device_t, dev
 #endif
 static	int nexus_config_intr(device_t, int, enum intr_trigger,
 			      enum intr_polarity);
+static	int nexus_describe_intr(device_t dev, device_t child,
+				struct resource *irq, void *cookie,
+				const char *descr);
 static	int nexus_activate_resource(device_t, device_t, int, int,
 				    struct resource *);
 static	int nexus_deactivate_resource(device_t, device_t, int, int,
@@ -135,6 +138,7 @@ static device_method_t nexus_methods[] =
 	DEVMETHOD(bus_bind_intr,	nexus_bind_intr),
 #endif
 	DEVMETHOD(bus_config_intr,	nexus_config_intr),
+	DEVMETHOD(bus_describe_intr,	nexus_describe_intr),
 	DEVMETHOD(bus_get_resource_list, nexus_get_reslist),
 	DEVMETHOD(bus_set_resource,	nexus_set_resource),
 	DEVMETHOD(bus_get_resource,	nexus_get_resource),
@@ -479,6 +483,14 @@ nexus_config_intr(device_t dev, int irq,
 	return (intr_config_intr(irq, trig, pol));
 }
 
+static int
+nexus_describe_intr(device_t dev, device_t child, struct resource *irq,
+    void *cookie, const char *descr)
+{
+
+	return (intr_describe(rman_get_start(irq), cookie, descr));
+}
+
 static struct resource_list *
 nexus_get_reslist(device_t dev, device_t child)
 {

Modified: stable/8/sys/amd64/include/intr_machdep.h
==============================================================================
--- stable/8/sys/amd64/include/intr_machdep.h	Thu Jan 21 17:46:14 2010	(r202761)
+++ stable/8/sys/amd64/include/intr_machdep.h	Thu Jan 21 17:54:29 2010	(r202762)
@@ -151,6 +151,7 @@ int	intr_bind(u_int vector, u_char cpu);
 #endif
 int	intr_config_intr(int vector, enum intr_trigger trig,
     enum intr_polarity pol);
+int	intr_describe(u_int vector, void *ih, const char *descr);
 void	intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame);
 u_int	intr_next_cpu(void);
 struct intsrc *intr_lookup_source(int vector);

Modified: stable/8/sys/i386/i386/intr_machdep.c
==============================================================================
--- stable/8/sys/i386/i386/intr_machdep.c	Thu Jan 21 17:46:14 2010	(r202761)
+++ stable/8/sys/i386/i386/intr_machdep.c	Thu Jan 21 17:54:29 2010	(r202762)
@@ -366,6 +366,23 @@ intr_init(void *dummy __unused)
 }
 SYSINIT(intr_init, SI_SUB_INTR, SI_ORDER_FIRST, intr_init, NULL);
 
+/* Add a description to an active interrupt handler. */
+int
+intr_describe(u_int vector, void *ih, const char *descr)
+{
+	struct intsrc *isrc;
+	int error;
+
+	isrc = intr_lookup_source(vector);
+	if (isrc == NULL)
+		return (EINVAL);
+	error = intr_event_describe_handler(isrc->is_event, ih, descr);
+	if (error)
+		return (error);
+	intrcnt_updatename(isrc);
+	return (0);
+}
+
 #ifdef DDB
 /*
  * Dump data about interrupt handlers

Modified: stable/8/sys/i386/i386/nexus.c
==============================================================================
--- stable/8/sys/i386/i386/nexus.c	Thu Jan 21 17:46:14 2010	(r202761)
+++ stable/8/sys/i386/i386/nexus.c	Thu Jan 21 17:54:29 2010	(r202762)
@@ -96,6 +96,9 @@ static	int nexus_bind_intr(device_t, dev
 #endif
 static	int nexus_config_intr(device_t, int, enum intr_trigger,
 			      enum intr_polarity);
+static	int nexus_describe_intr(device_t dev, device_t child,
+				struct resource *irq, void *cookie,
+				const char *descr);
 static	int nexus_activate_resource(device_t, device_t, int, int,
 				    struct resource *);
 static	int nexus_deactivate_resource(device_t, device_t, int, int,
@@ -141,6 +144,7 @@ static device_method_t nexus_methods[] =
 	DEVMETHOD(bus_bind_intr,	nexus_bind_intr),
 #endif
 	DEVMETHOD(bus_config_intr,	nexus_config_intr),
+	DEVMETHOD(bus_describe_intr,	nexus_describe_intr),
 	DEVMETHOD(bus_get_resource_list, nexus_get_reslist),
 	DEVMETHOD(bus_set_resource,	nexus_set_resource),
 	DEVMETHOD(bus_get_resource,	nexus_get_resource),
@@ -526,6 +530,14 @@ nexus_config_intr(device_t dev, int irq,
 	return (intr_config_intr(irq, trig, pol));
 }
 
+static int
+nexus_describe_intr(device_t dev, device_t child, struct resource *irq,
+    void *cookie, const char *descr)
+{
+
+	return (intr_describe(rman_get_start(irq), cookie, descr));
+}
+
 static struct resource_list *
 nexus_get_reslist(device_t dev, device_t child)
 {

Modified: stable/8/sys/i386/include/intr_machdep.h
==============================================================================
--- stable/8/sys/i386/include/intr_machdep.h	Thu Jan 21 17:46:14 2010	(r202761)
+++ stable/8/sys/i386/include/intr_machdep.h	Thu Jan 21 17:54:29 2010	(r202762)
@@ -138,6 +138,7 @@ int	intr_bind(u_int vector, u_char cpu);
 #endif
 int	intr_config_intr(int vector, enum intr_trigger trig,
     enum intr_polarity pol);
+int	intr_describe(u_int vector, void *ih, const char *descr);
 void	intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame);
 u_int	intr_next_cpu(void);
 struct intsrc *intr_lookup_source(int vector);

Modified: stable/8/sys/kern/bus_if.m
==============================================================================
--- stable/8/sys/kern/bus_if.m	Thu Jan 21 17:46:14 2010	(r202761)
+++ stable/8/sys/kern/bus_if.m	Thu Jan 21 17:54:29 2010	(r202762)
@@ -509,7 +509,6 @@ METHOD int bind_intr {
 	int		_cpu;
 } DEFAULT bus_generic_bind_intr;
 
-
 /**
  * @brief Allow (bus) drivers to specify the trigger mode and polarity
  * of the specified interrupt.
@@ -527,6 +526,25 @@ METHOD int config_intr {
 } DEFAULT bus_generic_config_intr;
 
 /**
+ * @brief Allow drivers to associate a description with an active
+ * interrupt handler.
+ *
+ * @param _dev		the parent device of @p _child
+ * @param _child	the device which allocated the resource
+ * @param _irq		the resource representing the interrupt
+ * @param _cookie	the cookie value returned when the interrupt
+ *			was originally registered
+ * @param _descr	the description to associate with the interrupt
+ */
+METHOD int describe_intr {
+	device_t	_dev;
+	device_t	_child;
+	struct resource *_irq;
+	void		*_cookie;
+	const char	*_descr;
+} DEFAULT bus_generic_describe_intr;
+
+/**
  * @brief Notify a (bus) driver about a child that the hints mechanism
  * believes it has discovered.
  *

Modified: stable/8/sys/kern/kern_intr.c
==============================================================================
--- stable/8/sys/kern/kern_intr.c	Thu Jan 21 17:46:14 2010	(r202761)
+++ stable/8/sys/kern/kern_intr.c	Thu Jan 21 17:54:29 2010	(r202762)
@@ -524,7 +524,7 @@ intr_event_add_handler(struct intr_event
 	ih->ih_filter = filter;
 	ih->ih_handler = handler;
 	ih->ih_argument = arg;
-	ih->ih_name = name;
+	strlcpy(ih->ih_name, name, sizeof(ih->ih_name));
 	ih->ih_event = ie;
 	ih->ih_pri = pri;
 	if (flags & INTR_EXCL)
@@ -597,7 +597,7 @@ intr_event_add_handler(struct intr_event
 	ih->ih_filter = filter;
 	ih->ih_handler = handler;
 	ih->ih_argument = arg;
-	ih->ih_name = name;
+	strlcpy(ih->ih_name, name, sizeof(ih->ih_name));
 	ih->ih_event = ie;
 	ih->ih_pri = pri;
 	if (flags & INTR_EXCL)
@@ -665,6 +665,61 @@ intr_event_add_handler(struct intr_event
 #endif
 
 /*
+ * Append a description preceded by a ':' to the name of the specified
+ * interrupt handler.
+ */
+int
+intr_event_describe_handler(struct intr_event *ie, void *cookie,
+    const char *descr)
+{
+	struct intr_handler *ih;
+	size_t space;
+	char *start;
+
+	mtx_lock(&ie->ie_lock);
+#ifdef INVARIANTS
+	TAILQ_FOREACH(ih, &ie->ie_handlers, ih_next) {
+		if (ih == cookie)
+			break;
+	}
+	if (ih == NULL) {
+		mtx_unlock(&ie->ie_lock);
+		panic("handler %p not found in interrupt event %p", cookie, ie);
+	}
+#endif
+	ih = cookie;
+
+	/*
+	 * Look for an existing description by checking for an
+	 * existing ":".  This assumes device names do not include
+	 * colons.  If one is found, prepare to insert the new
+	 * description at that point.  If one is not found, find the
+	 * end of the name to use as the insertion point.
+	 */
+	start = index(ih->ih_name, ':');
+	if (start == NULL)
+		start = index(ih->ih_name, 0);
+
+	/*
+	 * See if there is enough remaining room in the string for the
+	 * description + ":".  The "- 1" leaves room for the trailing
+	 * '\0'.  The "+ 1" accounts for the colon.
+	 */
+	space = sizeof(ih->ih_name) - (start - ih->ih_name) - 1;
+	if (strlen(descr) + 1 > space) {
+		mtx_unlock(&ie->ie_lock);
+		return (ENOSPC);
+	}
+
+	/* Append a colon followed by the description. */
+	*start = ':';
+	strcpy(start + 1, descr);
+	intr_event_update(ie);
+	mtx_unlock(&ie->ie_lock);
+	return (0);
+}
+
+/*
  * Return the ie_source field from the intr_event an intr_handler is
  * associated with.
  */

Modified: stable/8/sys/kern/subr_bus.c
==============================================================================
--- stable/8/sys/kern/subr_bus.c	Thu Jan 21 17:46:14 2010	(r202761)
+++ stable/8/sys/kern/subr_bus.c	Thu Jan 21 17:54:29 2010	(r202762)
@@ -3530,6 +3530,24 @@ bus_generic_config_intr(device_t dev, in
 }
 
 /**
+ * @brief Helper function for implementing BUS_DESCRIBE_INTR().
+ *
+ * This simple implementation of BUS_DESCRIBE_INTR() simply calls the
+ * BUS_DESCRIBE_INTR() method of the parent of @p dev.
+ */
+int
+bus_generic_describe_intr(device_t dev, device_t child, struct resource *irq,
+    void *cookie, const char *descr)
+{
+
+	/* Propagate up the bus hierarchy until someone handles it. */
+	if (dev->parent)
+		return (BUS_DESCRIBE_INTR(dev->parent, child, irq, cookie,
+		    descr));
+	return (EINVAL);
+}
+
+/**
  * @brief Helper function for implementing BUS_GET_DMA_TAG().
  *
  * This simple implementation of BUS_GET_DMA_TAG() simply calls the
@@ -3834,6 +3852,28 @@ bus_bind_intr(device_t dev, struct resou
 }
 
 /**
+ * @brief Wrapper function for BUS_DESCRIBE_INTR().
+ *
+ * This function first formats the requested description into a
+ * temporary buffer and then calls the BUS_DESCRIBE_INTR() method of
+ * the parent of @p dev.
+ */
+int
+bus_describe_intr(device_t dev, struct resource *irq, void *cookie,
+    const char *fmt, ...)
+{
+	char descr[MAXCOMLEN];
+	va_list ap;
+
+	if (dev->parent == NULL)
+		return (EINVAL);
+	va_start(ap, fmt);
+	vsnprintf(descr, sizeof(descr), fmt, ap);
+	va_end(ap);
+	return (BUS_DESCRIBE_INTR(dev->parent, dev, irq, cookie, descr));
+}
+
+/**
  * @brief Wrapper function for BUS_SET_RESOURCE().
  *
  * This function simply calls the BUS_SET_RESOURCE() method of the

Modified: stable/8/sys/sparc64/include/intr_machdep.h
==============================================================================
--- stable/8/sys/sparc64/include/intr_machdep.h	Thu Jan 21 17:46:14 2010	(r202761)
+++ stable/8/sys/sparc64/include/intr_machdep.h	Thu Jan 21 17:54:29 2010	(r202762)
@@ -93,6 +93,7 @@ extern struct intr_vector intr_vectors[]
 void	intr_add_cpu(u_int cpu);
 #endif
 int	intr_bind(int vec, u_char cpu);
+int	intr_describe(int vec, void *ih, const char *descr);
 void	intr_setup(int level, ih_func_t *ihf, int pri, iv_func_t *ivf,
 	    void *iva);
 void	intr_init1(void);

Modified: stable/8/sys/sparc64/pci/psycho.c
==============================================================================
--- stable/8/sys/sparc64/pci/psycho.c	Thu Jan 21 17:46:14 2010	(r202761)
+++ stable/8/sys/sparc64/pci/psycho.c	Thu Jan 21 17:54:29 2010	(r202762)
@@ -115,6 +115,7 @@ static bus_alloc_resource_t psycho_alloc
 static bus_activate_resource_t psycho_activate_resource;
 static bus_deactivate_resource_t psycho_deactivate_resource;
 static bus_release_resource_t psycho_release_resource;
+static bus_describe_intr_t psycho_describe_intr;
 static bus_get_dma_tag_t psycho_get_dma_tag;
 static pcib_maxslots_t psycho_maxslots;
 static pcib_read_config_t psycho_read_config;
@@ -139,6 +140,7 @@ static device_method_t psycho_methods[] 
 	DEVMETHOD(bus_activate_resource,	psycho_activate_resource),
 	DEVMETHOD(bus_deactivate_resource,	psycho_deactivate_resource),
 	DEVMETHOD(bus_release_resource,	psycho_release_resource),
+	DEVMETHOD(bus_describe_intr,	psycho_describe_intr),
 	DEVMETHOD(bus_get_dma_tag,	psycho_get_dma_tag),
 
 	/* pcib interface */
@@ -1261,6 +1263,18 @@ psycho_teardown_intr(device_t dev, devic
 	return (bus_generic_teardown_intr(dev, child, vec, cookie));
 }
 
+static int
+psycho_describe_intr(device_t dev, device_t child, struct resource *vec,
+    void *cookie, const char *descr)
+{
+	struct psycho_softc *sc;
+
+	sc = device_get_softc(dev);
+	if (sc->sc_mode == PSYCHO_MODE_SABRE)
+		cookie = ((struct psycho_dma_sync *)cookie)->pds_cookie;
+	return (bus_generic_describe_intr(dev, child, vec, cookie, descr));
+}
+
 static struct resource *
 psycho_alloc_resource(device_t bus, device_t child, int type, int *rid,
     u_long start, u_long end, u_long count, u_int flags)

Modified: stable/8/sys/sparc64/pci/schizo.c
==============================================================================
--- stable/8/sys/sparc64/pci/schizo.c	Thu Jan 21 17:46:14 2010	(r202761)
+++ stable/8/sys/sparc64/pci/schizo.c	Thu Jan 21 17:54:29 2010	(r202762)
@@ -113,6 +113,7 @@ static bus_alloc_resource_t schizo_alloc
 static bus_activate_resource_t schizo_activate_resource;
 static bus_deactivate_resource_t schizo_deactivate_resource;
 static bus_release_resource_t schizo_release_resource;
+static bus_describe_intr_t schizo_describe_intr;
 static bus_get_dma_tag_t schizo_get_dma_tag;
 static pcib_maxslots_t schizo_maxslots;
 static pcib_read_config_t schizo_read_config;
@@ -137,6 +138,7 @@ static device_method_t schizo_methods[] 
 	DEVMETHOD(bus_activate_resource,	schizo_activate_resource),
 	DEVMETHOD(bus_deactivate_resource,	schizo_deactivate_resource),
 	DEVMETHOD(bus_release_resource,	schizo_release_resource),
+	DEVMETHOD(bus_describe_intr,	schizo_describe_intr),
 	DEVMETHOD(bus_get_dma_tag,	schizo_get_dma_tag),
 
 	/* pcib interface */
@@ -1282,6 +1284,18 @@ schizo_teardown_intr(device_t dev, devic
 	return (bus_generic_teardown_intr(dev, child, vec, cookie));
 }
 
+static int
+schizo_describe_intr(device_t dev, device_t child, struct resource *vec,
+    void *cookie, const char *descr)
+{
+	struct schizo_softc *sc;
+
+	sc = device_get_softc(dev);
+	if ((sc->sc_flags & SCHIZO_FLAGS_CDMA) != 0)
+		cookie = ((struct schizo_dma_sync *)cookie)->sds_cookie;
+	return (bus_generic_describe_intr(dev, child, vec, cookie, descr));
+}
+
 static struct resource *
 schizo_alloc_resource(device_t bus, device_t child, int type, int *rid,
     u_long start, u_long end, u_long count, u_int flags)

Modified: stable/8/sys/sparc64/sparc64/intr_machdep.c
==============================================================================
--- stable/8/sys/sparc64/sparc64/intr_machdep.c	Thu Jan 21 17:46:14 2010	(r202761)
+++ stable/8/sys/sparc64/sparc64/intr_machdep.c	Thu Jan 21 17:54:29 2010	(r202762)
@@ -413,6 +413,31 @@ inthand_remove(int vec, void *cookie)
 	return (error);
 }
 
+/* Add a description to an active interrupt handler. */
+int
+intr_describe(int vec, void *ih, const char *descr)
+{
+	struct intr_vector *iv;
+	int error;
+
+	if (vec < 0 || vec >= IV_MAX)
+		return (EINVAL);
+	sx_xlock(&intr_table_lock);
+	iv = &intr_vectors[vec];
+	if (iv == NULL) {
+		sx_xunlock(&intr_table_lock);
+		return (EINVAL);
+	}
+	error = intr_event_describe_handler(iv->iv_event, ih, descr);
+	if (error) {
+		sx_xunlock(&intr_table_lock);
+		return (error);
+	}
+	intrcnt_updatename(vec, iv->iv_event->ie_fullname, 0);
+	sx_xunlock(&intr_table_lock);
+	return (error);
+}
+
 #ifdef SMP
 /*
  * Support for balancing interrupt sources across CPUs.  For now we just

Modified: stable/8/sys/sparc64/sparc64/nexus.c
==============================================================================
--- stable/8/sys/sparc64/sparc64/nexus.c	Thu Jan 21 17:46:14 2010	(r202761)
+++ stable/8/sys/sparc64/sparc64/nexus.c	Thu Jan 21 17:54:29 2010	(r202762)
@@ -90,12 +90,13 @@ static bus_activate_resource_t nexus_act
 static bus_deactivate_resource_t nexus_deactivate_resource;
 static bus_release_resource_t nexus_release_resource;
 static bus_get_resource_list_t nexus_get_resource_list;
+#ifdef SMP
+static bus_bind_intr_t nexus_bind_intr;
+#endif
+static bus_describe_intr_t nexus_describe_intr;
 static bus_get_dma_tag_t nexus_get_dma_tag;
 static ofw_bus_get_devinfo_t nexus_get_devinfo;
 
-#ifdef SMP
-static int nexus_bind_intr(device_t, device_t, struct resource *, int);
-#endif
 static int nexus_inlist(const char *, const char *const *);
 static struct nexus_devinfo * nexus_setup_dinfo(device_t, phandle_t);
 static void nexus_destroy_dinfo(struct nexus_devinfo *);
@@ -128,6 +129,7 @@ static device_method_t nexus_methods[] =
 #ifdef SMP
 	DEVMETHOD(bus_bind_intr,	nexus_bind_intr),
 #endif
+	DEVMETHOD(bus_describe_intr,	nexus_describe_intr),
 	DEVMETHOD(bus_get_dma_tag,	nexus_get_dma_tag),
 
 	/* ofw_bus interface */
@@ -329,6 +331,14 @@ nexus_bind_intr(device_t dev, device_t c
 }
 #endif
 
+static int
+nexus_describe_intr(device_t dev, device_t child, struct resource *r,
+    void *cookie, const char *descr)
+{
+
+	return (intr_describe(rman_get_start(r), cookie, descr));
+}
+
 static struct resource *
 nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
     u_long start, u_long end, u_long count, u_int flags)

Modified: stable/8/sys/sys/bus.h
==============================================================================
--- stable/8/sys/sys/bus.h	Thu Jan 21 17:46:14 2010	(r202761)
+++ stable/8/sys/sys/bus.h	Thu Jan 21 17:54:29 2010	(r202762)
@@ -292,6 +292,9 @@ int	bus_generic_bind_intr(device_t dev, 
 int	bus_generic_child_present(device_t dev, device_t child);
 int	bus_generic_config_intr(device_t, int, enum intr_trigger,
 				enum intr_polarity);
+int	bus_generic_describe_intr(device_t dev, device_t child,
+				  struct resource *irq, void *cookie,
+				  const char *descr);
 int	bus_generic_deactivate_resource(device_t dev, device_t child, int type,
 					int rid, struct resource *r);
 int	bus_generic_detach(device_t dev);
@@ -363,6 +366,8 @@ int	bus_setup_intr(device_t dev, struct 
 		       void *arg, void **cookiep);
 int	bus_teardown_intr(device_t dev, struct resource *r, void *cookie);
 int	bus_bind_intr(device_t dev, struct resource *r, int cpu);
+int	bus_describe_intr(device_t dev, struct resource *irq, void *cookie,
+			  const char *fmt, ...);
 int	bus_set_resource(device_t dev, int type, int rid,
 			 u_long start, u_long count);
 int	bus_get_resource(device_t dev, int type, int rid,

Modified: stable/8/sys/sys/interrupt.h
==============================================================================
--- stable/8/sys/sys/interrupt.h	Thu Jan 21 17:46:14 2010	(r202761)
+++ stable/8/sys/sys/interrupt.h	Thu Jan 21 17:54:29 2010	(r202762)
@@ -47,7 +47,7 @@ struct intr_handler {
 	driver_intr_t	*ih_handler;	/* Threaded handler function. */
 	void		*ih_argument;	/* Argument to pass to handlers. */
 	int		 ih_flags;
-	const char	*ih_name;	/* Name of handler. */
+	char		 ih_name[MAXCOMLEN]; /* Name of handler. */
 	struct intr_event *ih_event;	/* Event we are connected to. */
 	int		 ih_need;	/* Needs service. */
 	TAILQ_ENTRY(intr_handler) ih_next; /* Next handler for this event. */
@@ -168,6 +168,8 @@ int	intr_event_create(struct intr_event 
 	    void (*post_ithread)(void *), void (*post_filter)(void *),
 	    int (*assign_cpu)(void *, u_char), const char *fmt, ...)
 	    __printflike(9, 10);
+int	intr_event_describe_handler(struct intr_event *ie, void *cookie,
+	    const char *descr);
 int	intr_event_destroy(struct intr_event *ie);
 void	intr_event_execute_handlers(struct proc *p, struct intr_event *ie);
 int	intr_event_handle(struct intr_event *ie, struct trapframe *frame);



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