Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 May 2009 17:14:23 +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-7@freebsd.org
Subject:   svn commit: r192311 - in stable/7/sys: . amd64/amd64 arm/arm contrib/pf dev/ath/ath_hal dev/cxgb i386/i386 ia64/ia64 kern powerpc/powerpc sparc64/sparc64 sys
Message-ID:  <200905181714.n4IHEN1o068422@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Mon May 18 17:14:23 2009
New Revision: 192311
URL: http://svn.freebsd.org/changeset/base/192311

Log:
  MFC: Simplify the interrupt code a bit by always including the ie_disable
  and ie_eoi methods and collapsing down to a single intr_event_create()
  routine.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/amd64/amd64/intr_machdep.c
  stable/7/sys/arm/arm/intr.c
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/i386/i386/intr_machdep.c
  stable/7/sys/ia64/ia64/interrupt.c
  stable/7/sys/kern/kern_intr.c
  stable/7/sys/powerpc/powerpc/intr_machdep.c
  stable/7/sys/sparc64/sparc64/intr_machdep.c
  stable/7/sys/sys/interrupt.h

Modified: stable/7/sys/amd64/amd64/intr_machdep.c
==============================================================================
--- stable/7/sys/amd64/amd64/intr_machdep.c	Mon May 18 17:10:26 2009	(r192310)
+++ stable/7/sys/amd64/amd64/intr_machdep.c	Mon May 18 17:14:23 2009	(r192311)
@@ -77,12 +77,6 @@ static struct sx intr_table_lock;
 static struct mtx intrcnt_lock;
 static STAILQ_HEAD(, pic) pics;
 
-#ifdef INTR_FILTER
-static void intr_eoi_src(void *arg);
-static void intr_disab_eoi_src(void *arg);
-static void intr_event_stray(void *cookie);
-#endif
-
 #ifdef SMP
 static int assign_cpu;
 
@@ -90,6 +84,10 @@ static void	intr_assign_next_cpu(struct 
 #endif
 
 static int	intr_assign_cpu(void *arg, u_char cpu);
+static void	intr_disable_src(void *arg);
+#ifdef INTR_FILTER
+static void	intr_event_stray(void *cookie);
+#endif
 static void	intr_init(void *__dummy);
 static int	intr_pic_registered(struct pic *pic);
 static void	intrcnt_setname(const char *name, int index);
@@ -144,16 +142,10 @@ intr_register_source(struct intsrc *isrc
 	vector = isrc->is_pic->pic_vector(isrc);
 	if (interrupt_sources[vector] != NULL)
 		return (EEXIST);
-#ifdef INTR_FILTER
-	error = intr_event_create(&isrc->is_event, isrc, 0,
-	    (mask_fn)isrc->is_pic->pic_enable_source,
-	    intr_eoi_src, intr_disab_eoi_src, intr_assign_cpu, "irq%d:",
-	    vector);
-#else
 	error = intr_event_create(&isrc->is_event, isrc, 0,
-	    (mask_fn)isrc->is_pic->pic_enable_source, intr_assign_cpu, "irq%d:",
+	    intr_disable_src, (mask_fn)isrc->is_pic->pic_enable_source,
+	    (mask_fn)isrc->is_pic->pic_eoi_source, intr_assign_cpu, "irq%d:",
 	    vector);
-#endif
 	if (error)
 		return (error);
 	sx_xlock(&intr_table_lock);
@@ -237,6 +229,15 @@ intr_config_intr(int vector, enum intr_t
 	return (isrc->is_pic->pic_config_intr(isrc, trig, pol));
 }
 
+static void
+intr_disable_src(void *arg)
+{
+	struct intsrc *isrc;
+
+	isrc = arg;
+	isrc->is_pic->pic_disable_source(isrc, PIC_EOI);
+}
+
 #ifdef INTR_FILTER
 void
 intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame)
@@ -289,24 +290,6 @@ intr_event_stray(void *cookie)
 		    "too many stray irq %d's: not logging anymore\n",
 		    isrc->is_pic->pic_vector(isrc));
 }
-
-static void
-intr_eoi_src(void *arg)
-{
-	struct intsrc *isrc;
-
-	isrc = arg;
-	isrc->is_pic->pic_eoi_source(isrc);
-}
-
-static void
-intr_disab_eoi_src(void *arg)
-{
-	struct intsrc *isrc;
-
-	isrc = arg;
-	isrc->is_pic->pic_disable_source(isrc, PIC_EOI);
-}
 #else
 void
 intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame)

Modified: stable/7/sys/arm/arm/intr.c
==============================================================================
--- stable/7/sys/arm/arm/intr.c	Mon May 18 17:10:26 2009	(r192310)
+++ stable/7/sys/arm/arm/intr.c	Mon May 18 17:14:23 2009	(r192311)
@@ -50,6 +50,8 @@ __FBSDID("$FreeBSD$");
 #include <machine/intr.h>
 #include <machine/cpu.h>
 
+typedef void (*mask_fn)(void *);
+
 static struct intr_event *intr_events[NIRQ];
 static int intrcnt_tab[NIRQ];
 static int intrcnt_index = 0;
@@ -57,27 +59,6 @@ static int last_printed = 0;
 
 void	arm_handler_execute(struct trapframe *, int);
 
-#ifdef INTR_FILTER
-static void
-intr_disab_eoi_src(void *arg)
-{
-	uintptr_t nb;
-
-	nb = (uintptr_t)arg;
-	arm_mask_irq(nb);
-}
-
-static void
-intr_eoi_src(void *arg)
-{
-	uintptr_t nb;
-
-	nb = (uintptr_t)arg;
-	arm_unmask_irq(nb);
-}
-
-#endif
-
 void
 arm_setup_irqhandler(const char *name, driver_filter_t *filt, 
     void (*hand)(void*), void *arg, int irq, int flags, void **cookiep)
@@ -89,14 +70,9 @@ arm_setup_irqhandler(const char *name, d
 		return;
 	event = intr_events[irq];
 	if (event == NULL) {
-#ifdef INTR_FILTER
-		error = intr_event_create(&event, (void *)irq, 0,
-		    (void (*)(void *))arm_unmask_irq, intr_eoi_src,
-		    intr_disab_eoi_src, NULL, "intr%d:", irq);
-#else
 		error = intr_event_create(&event, (void *)irq, 0,
-		    (void (*)(void *))arm_unmask_irq, NULL, "intr%d:", irq);
-#endif
+		    (mask_fn)arm_mask_irq, (mask_fn)arm_unmask_irq,
+		    (mask_fn)arm_unmask_irq, NULL, "intr%d:", irq);
 		if (error)
 			return;
 		intr_events[irq] = event;

Modified: stable/7/sys/i386/i386/intr_machdep.c
==============================================================================
--- stable/7/sys/i386/i386/intr_machdep.c	Mon May 18 17:10:26 2009	(r192310)
+++ stable/7/sys/i386/i386/intr_machdep.c	Mon May 18 17:14:23 2009	(r192311)
@@ -68,12 +68,6 @@ static struct sx intr_table_lock;
 static struct mtx intrcnt_lock;
 static STAILQ_HEAD(, pic) pics;
 
-#ifdef INTR_FILTER
-static void intr_eoi_src(void *arg);
-static void intr_disab_eoi_src(void *arg);
-static void intr_event_stray(void *cookie);
-#endif
-
 #ifdef SMP
 static int assign_cpu;
 
@@ -81,6 +75,10 @@ static void	intr_assign_next_cpu(struct 
 #endif
 
 static int	intr_assign_cpu(void *arg, u_char cpu);
+static void	intr_disable_src(void *arg);
+#ifdef INTR_FILTER
+static void	intr_event_stray(void *cookie);
+#endif
 static void	intr_init(void *__dummy);
 static int	intr_pic_registered(struct pic *pic);
 static void	intrcnt_setname(const char *name, int index);
@@ -135,16 +133,10 @@ intr_register_source(struct intsrc *isrc
 	vector = isrc->is_pic->pic_vector(isrc);
 	if (interrupt_sources[vector] != NULL)
 		return (EEXIST);
-#ifdef INTR_FILTER
-	error = intr_event_create(&isrc->is_event, isrc, 0,
-	    (mask_fn)isrc->is_pic->pic_enable_source,
-	    intr_eoi_src, intr_disab_eoi_src, intr_assign_cpu, "irq%d:",
-	    vector);
-#else
 	error = intr_event_create(&isrc->is_event, isrc, 0,
-	    (mask_fn)isrc->is_pic->pic_enable_source, intr_assign_cpu, "irq%d:",
+	    intr_disable_src, (mask_fn)isrc->is_pic->pic_enable_source,
+	    (mask_fn)isrc->is_pic->pic_eoi_source, intr_assign_cpu, "irq%d:",
 	    vector);
-#endif
 	if (error)
 		return (error);
 	sx_xlock(&intr_table_lock);
@@ -228,6 +220,15 @@ intr_config_intr(int vector, enum intr_t
 	return (isrc->is_pic->pic_config_intr(isrc, trig, pol));
 }
 
+static void
+intr_disable_src(void *arg)
+{
+	struct intsrc *isrc;
+
+	isrc = arg;
+	isrc->is_pic->pic_disable_source(isrc, PIC_EOI);
+}
+
 #ifdef INTR_FILTER
 void
 intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame)
@@ -280,24 +281,6 @@ intr_event_stray(void *cookie)
 		    "too many stray irq %d's: not logging anymore\n",
 		    isrc->is_pic->pic_vector(isrc));
 }
-
-static void
-intr_eoi_src(void *arg)
-{
-	struct intsrc *isrc;
-
-	isrc = arg;
-	isrc->is_pic->pic_eoi_source(isrc);
-}
-
-static void
-intr_disab_eoi_src(void *arg)
-{
-	struct intsrc *isrc;
-
-	isrc = arg;
-	isrc->is_pic->pic_disable_source(isrc, PIC_EOI);
-}
 #else
 void
 intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame)

Modified: stable/7/sys/ia64/ia64/interrupt.c
==============================================================================
--- stable/7/sys/ia64/ia64/interrupt.c	Mon May 18 17:10:26 2009	(r192310)
+++ stable/7/sys/ia64/ia64/interrupt.c	Mon May 18 17:14:23 2009	(r192311)
@@ -340,10 +340,7 @@ ia64_setup_intr(const char *name, int ir
 			return (ENOMEM);
 
 		error = intr_event_create(&i->event, (void *)(uintptr_t)vector,
-		    0, ia64_intr_unmask,
-#ifdef INTR_FILTER
-		    ia64_intr_eoi, ia64_intr_mask,
-#endif
+		    0, ia64_intr_mask, ia64_intr_unmask, ia64_intr_eoi,
 		    NULL, "irq%u:", irq);
 		if (error) {
 			free(i, M_DEVBUF);

Modified: stable/7/sys/kern/kern_intr.c
==============================================================================
--- stable/7/sys/kern/kern_intr.c	Mon May 18 17:10:26 2009	(r192310)
+++ stable/7/sys/kern/kern_intr.c	Mon May 18 17:14:23 2009	(r192311)
@@ -238,43 +238,9 @@ intr_event_update(struct intr_event *ie)
 	CTR2(KTR_INTR, "%s: updated %s", __func__, ie->ie_fullname);
 }
 
-#ifndef INTR_FILTER
-int
-intr_event_create(struct intr_event **event, void *source, int flags,
-    void (*enable)(void *), int (*assign_cpu)(void *, u_char), const char *fmt,
-    ...)
-{
-	struct intr_event *ie;
-	va_list ap;
-
-	/* The only valid flag during creation is IE_SOFT. */
-	if ((flags & ~IE_SOFT) != 0)
-		return (EINVAL);
-	ie = malloc(sizeof(struct intr_event), M_ITHREAD, M_WAITOK | M_ZERO);
-	ie->ie_source = source;
-	ie->ie_enable = enable;
-	ie->ie_assign_cpu = assign_cpu;
-	ie->ie_flags = flags;
-	ie->ie_cpu = NOCPU;
-	TAILQ_INIT(&ie->ie_handlers);
-	mtx_init(&ie->ie_lock, "intr event", NULL, MTX_DEF);
-
-	va_start(ap, fmt);
-	vsnprintf(ie->ie_name, sizeof(ie->ie_name), fmt, ap);
-	va_end(ap);
-	strlcpy(ie->ie_fullname, ie->ie_name, sizeof(ie->ie_fullname));
-	mtx_pool_lock(mtxpool_sleep, &event_list);
-	TAILQ_INSERT_TAIL(&event_list, ie, ie_list);
-	mtx_pool_unlock(mtxpool_sleep, &event_list);
-	if (event != NULL)
-		*event = ie;
-	CTR2(KTR_INTR, "%s: created %s", __func__, ie->ie_name);
-	return (0);
-}
-#else
 int
-intr_event_create(struct intr_event **event, void *source, int flags,
-    void (*enable)(void *), void (*eoi)(void *), void (*disab)(void *), 
+intr_event_create(struct intr_event **event, void *source,int flags,
+    void (*disable)(void *), void (*enable)(void *), void (*eoi)(void *),
     int (*assign_cpu)(void *, u_char), const char *fmt, ...)
 {
 	struct intr_event *ie;
@@ -285,10 +251,10 @@ intr_event_create(struct intr_event **ev
 		return (EINVAL);
 	ie = malloc(sizeof(struct intr_event), M_ITHREAD, M_WAITOK | M_ZERO);
 	ie->ie_source = source;
+	ie->ie_disable = disable;
 	ie->ie_enable = enable;
-	ie->ie_assign_cpu = assign_cpu;
 	ie->ie_eoi = eoi;
-	ie->ie_disab = disab;
+	ie->ie_assign_cpu = assign_cpu;
 	ie->ie_flags = flags;
 	ie->ie_cpu = NOCPU;
 	TAILQ_INIT(&ie->ie_handlers);
@@ -306,7 +272,6 @@ intr_event_create(struct intr_event **ev
 	CTR2(KTR_INTR, "%s: created %s", __func__, ie->ie_name);
 	return (0);
 }
-#endif
 
 /*
  * Bind an interrupt event to the specified CPU.  Note that not all
@@ -945,13 +910,8 @@ swi_add(struct intr_event **eventp, cons
 		if (!(ie->ie_flags & IE_SOFT))
 			return (EINVAL);
 	} else {
-#ifdef INTR_FILTER
 		error = intr_event_create(&ie, NULL, IE_SOFT,
 		    NULL, NULL, NULL, NULL, "swi%d:", pri);
-#else
-		error = intr_event_create(&ie, NULL, IE_SOFT,
-		    NULL, NULL, "swi%d:", pri);
-#endif
 		if (error)
 			return (error);
 		if (eventp != NULL)
@@ -1408,8 +1368,8 @@ intr_event_handle(struct intr_event *ie,
 		if (ie->ie_eoi != NULL)
 			ie->ie_eoi(ie->ie_source);
 	} else {
-		if (ie->ie_disab != NULL)
-			ie->ie_disab(ie->ie_source);
+		if (ie->ie_disable != NULL)
+			ie->ie_disable(ie->ie_source);
 	}
 	critical_exit();
 	

Modified: stable/7/sys/powerpc/powerpc/intr_machdep.c
==============================================================================
--- stable/7/sys/powerpc/powerpc/intr_machdep.c	Mon May 18 17:10:26 2009	(r192310)
+++ stable/7/sys/powerpc/powerpc/intr_machdep.c	Mon May 18 17:14:23 2009	(r192311)
@@ -105,7 +105,6 @@ intrcnt_setname(const char *name, int in
 	    MAXCOMLEN, name);
 }
 
-#ifdef INTR_FILTER
 static void
 powerpc_intr_eoi(void *arg)
 {
@@ -121,7 +120,6 @@ powerpc_intr_mask(void *arg)
 
 	PIC_MASK(pic, irq);
 }
-#endif
 
 static void
 powerpc_intr_unmask(void *arg)
@@ -187,10 +185,7 @@ powerpc_setup_intr(const char *name, u_i
 			return (ENOMEM);
 		}
 		error = intr_event_create(&i->event, (void *)irq, 0,
-		    powerpc_intr_unmask,
-#ifdef INTR_FILTER
-		    powerpc_intr_eoi, powerpc_intr_mask,
-#endif
+		    powerpc_intr_mask, powerpc_intr_unmask, powerpc_intr_eoi,
 		    NULL, "irq%u:", irq);
 		if (error) {
 			/* XXX unlock */

Modified: stable/7/sys/sparc64/sparc64/intr_machdep.c
==============================================================================
--- stable/7/sys/sparc64/sparc64/intr_machdep.c	Mon May 18 17:10:26 2009	(r192310)
+++ stable/7/sys/sparc64/sparc64/intr_machdep.c	Mon May 18 17:14:23 2009	(r192311)
@@ -345,12 +345,8 @@ intr_controller_register(int vec, const 
 	sx_xunlock(&intr_table_lock);
 	if (ie != NULL)
 		return (EEXIST);
-	error = intr_event_create(&ie, iv, 0, ic->ic_clear,
-#ifdef INTR_FILTER
-	    ic->ic_clear, NULL, intr_assign_cpu, "vec%d:", vec);
-#else
-	    intr_assign_cpu, "vec%d:", vec);
-#endif
+	error = intr_event_create(&ie, iv, 0, NULL, ic->ic_clear,
+	    ic->ic_clear, intr_assign_cpu, "vec%d:", vec);
 	if (error != 0)
 		return (error);
 	sx_xlock(&intr_table_lock);

Modified: stable/7/sys/sys/interrupt.h
==============================================================================
--- stable/7/sys/sys/interrupt.h	Mon May 18 17:10:26 2009	(r192310)
+++ stable/7/sys/sys/interrupt.h	Mon May 18 17:14:23 2009	(r192311)
@@ -72,12 +72,10 @@ struct intr_event {
 	struct mtx	ie_lock;
 	void		*ie_source;	/* Cookie used by MD code. */
 	struct intr_thread *ie_thread;	/* Thread we are connected to. */
+	void		(*ie_disable)(void *);
 	void		(*ie_enable)(void *);
-	int		(*ie_assign_cpu)(void *, u_char);
-#ifdef INTR_FILTER
 	void		(*ie_eoi)(void *);
-	void		(*ie_disab)(void *);
-#endif
+	int		(*ie_assign_cpu)(void *, u_char);
 	int		ie_flags;
 	int		ie_count;	/* Loop counter. */
 	int		ie_warncnt;	/* Rate-check interrupt storm warns. */
@@ -130,18 +128,11 @@ int	intr_event_add_handler(struct intr_e
 	    driver_filter_t filter, driver_intr_t handler, void *arg, 
 	    u_char pri, enum intr_type flags, void **cookiep);	    
 int	intr_event_bind(struct intr_event *ie, u_char cpu);
-#ifndef INTR_FILTER
-int	intr_event_create(struct intr_event **event, void *source,
-	    int flags, void (*enable)(void *),
-	    int (*assign_cpu)(void *, u_char), const char *fmt, ...)
-	    __printflike(6, 7);
-#else
 int	intr_event_create(struct intr_event **event, void *source,
-	    int flags, void (*enable)(void *), void (*eoi)(void *), 
-	    void (*disab)(void *), int (*assign_cpu)(void *, u_char),
+	    int flags, void (*disable)(void *), void (*enable)(void *),
+	    void (*eoi)(void *), int (*assign_cpu)(void *, u_char),
 	    const char *fmt, ...)
 	    __printflike(8, 9);
-#endif
 int	intr_event_destroy(struct intr_event *ie);
 int	intr_event_remove_handler(void *cookie);
 #ifndef INTR_FILTER



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