Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Jan 2007 15:15:56 GMT
From:      Paolo Pisati <piso@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 112863 for review
Message-ID:  <200701131515.l0DFFurf033779@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=112863

Change 112863 by piso@piso_newluxor on 2007/01/13 15:15:25

	Start teaching sun4v about filters: the enable/eoi/disab calls
	are NULL for now, that's the next step.

Affected files ...

.. //depot/projects/soc2006/intr_filter/sun4v/include/intr_machdep.h#2 edit
.. //depot/projects/soc2006/intr_filter/sun4v/sun4v/hvcons.c#4 edit
.. //depot/projects/soc2006/intr_filter/sun4v/sun4v/intr_machdep.c#3 edit
.. //depot/projects/soc2006/intr_filter/sun4v/sun4v/nexus.c#3 edit
.. //depot/projects/soc2006/intr_filter/sun4v/sun4v/vnex.c#4 edit

Differences ...

==== //depot/projects/soc2006/intr_filter/sun4v/include/intr_machdep.h#2 (text+ko) ====

@@ -77,8 +77,8 @@
 
 void	intr_setup(int level, ih_func_t *ihf, int pri, iv_func_t *ivf,
 		   void *iva);
-int	inthand_add(const char *name, int vec, void (*handler)(void *),
-    void *arg, int flags, void **cookiep);
+int	inthand_add(const char *name, int vec, int (*filter)(void *),
+    void (*handler)(void *), void *arg, int flags, void **cookiep);
 int	inthand_remove(int vec, void *cookie);
 void cpu_intrq_init(void);
 

==== //depot/projects/soc2006/intr_filter/sun4v/sun4v/hvcons.c#4 (text+ko) ====

@@ -390,8 +390,8 @@
 		goto fail;
 		
 	}
-	error = bus_setup_intr(dev, hvcn_irq, INTR_TYPE_TTY, hvcn_intr, hvcn_tp, 
-			       hvcn_intrhand);
+	error = bus_setup_intr(dev, hvcn_irq, INTR_TYPE_TTY, NULL, hvcn_intr,
+	    hvcn_tp, hvcn_intrhand);
 	
 	if (error)
 		device_printf(dev, "couldn't set up irq\n");

==== //depot/projects/soc2006/intr_filter/sun4v/sun4v/intr_machdep.c#3 (text+ko) ====

@@ -142,6 +142,9 @@
 /* protect the intr_vectors table */
 static struct mtx intr_table_lock;
 
+extern struct callout stray_callout_handle;
+void intr_callout_reset(void);
+
 static void intr_execute_handlers(void *);
 static void intr_stray_level(struct trapframe *);
 static void intr_stray_vector(void *);
@@ -149,6 +152,32 @@
 static void intrcnt_updatename(int, const char *, int);
 static void cpu_intrq_alloc(void);
 
+/* Stray detection MD code */
+static struct intr_event *
+walk_intr_sun4v(void) {
+	struct intr_vector *iv;
+	static int i = 0;
+
+	for (; i<IV_MAX; ) {
+		int j = i++;
+		iv = &intr_vectors[j];
+		if (iv != NULL && iv->iv_event != NULL)
+			return (iv->iv_event);
+	}
+	i = 0;
+	return (NULL);
+}
+
+void
+intr_callout_reset(void)
+{
+
+	mtx_lock_spin(&intr_table_lock);
+	callout_reset(&stray_callout_handle, hz, 
+	    &stray_detection, &walk_intr_sun4v);
+	mtx_unlock_spin(&intr_table_lock);
+}
+
 /*
  * not MPSAFE
  */
@@ -274,7 +303,7 @@
 }
 SYSINIT(intr_init, SI_SUB_INTR, SI_ORDER_FIRST, intr_init, NULL);
 
-
+#if 0
 static void
 intr_execute_handlers(void *cookie)
 {
@@ -312,27 +341,35 @@
 			hv_intr_setstate(iv->iv_vec, HV_INTR_IDLE_STATE);
 	}
 }
+#endif
 
 static void
-ithread_wrapper(void *arg)
+intr_execute_handlers(void *cookie)
 {
-	struct ithread_vector_handler *ivh = (struct ithread_vector_handler *)arg;
-	
-	ivh->ivh_handler(ivh->ivh_arg);
-	/* re-enable interrupt */
-	hv_intr_setstate(ivh->ivh_vec, HV_INTR_IDLE_STATE);
+	struct intr_vector *iv;
+	struct intr_event *ie;
+
+	iv = cookie;
+	ie = iv->iv_event;
 
+	if (intr_event_handle(ie, NULL) != 0)
+		intr_stray_vector(iv);
+	/*
+	 * XXX - hv_intr_setstate() is used indistinctly after a
+	 * FAST/ITHREAD handler ran: right now enable/eoi/disab in
+	 * intr_event_create() is broken.
+	 * hv_intr_setstate(iv->iv_vec, HV_INTR_IDLE_STATE);
+	 */
 }
 
 int
-inthand_add(const char *name, int vec, void (*handler)(void *), void *arg,
-    int flags, void **cookiep)
+inthand_add(const char *name, int vec, driver_filter_t *filter,
+    void (*handler)(void *), void *arg, int flags, void **cookiep)    
 {
 	struct intr_vector *iv;
 	struct intr_event *ie;		/* descriptor for the IRQ */
 	struct intr_event *orphan;
-	struct ithread_vector_handler *ivh;
-	int errcode, pil;
+	int errcode;
 
 	/*
 	 * Work around a race where more than one CPU may be registering
@@ -343,8 +380,9 @@
 	ie = iv->iv_event;
 	mtx_unlock_spin(&intr_table_lock);
 	if (ie == NULL) {
-		errcode = intr_event_create(&ie, (void *)(intptr_t)vec, 0, NULL,
-		    "vec%d:", vec);
+		errcode = intr_event_create(&ie, (void *)(intptr_t)vec, 0,
+		    NULL, NULL, NULL, NULL, "vec%d:",
+		    vec);
 		if (errcode)
 			return (errcode);
 		mtx_lock_spin(&intr_table_lock);
@@ -359,29 +397,13 @@
 		}
 	}
 
-	if (!(flags & INTR_FAST)) {
-		ivh = (struct ithread_vector_handler *)
-			malloc(sizeof(struct ithread_vector_handler), M_DEVBUF, M_WAITOK);
-		ivh->ivh_handler = handler;
-		ivh->ivh_arg = arg;
-		ivh->ivh_vec = vec;
-		errcode = intr_event_add_handler(ie, name, ithread_wrapper, ivh,
-						 intr_priority(flags), flags, cookiep);
-	} else {
-		ivh = NULL;
-		errcode = intr_event_add_handler(ie, name, handler, arg,
-						 intr_priority(flags), flags, 
-						 cookiep);
-	}
-
-	if (errcode) {
-		if (ivh)
-			free(ivh, M_DEVBUF);
+	errcode = intr_event_add_handler(ie, name, filter, handler, arg,
+	    intr_priority(flags), flags, cookiep);
+	if (errcode)
 		return (errcode);
-	}
-	pil = (flags & INTR_FAST) ? PIL_FAST : PIL_ITHREAD;
 
-	intr_setup(pil, intr_fast, vec, intr_execute_handlers, iv);
+	intr_setup((handler == NULL) ? PIL_FAST : PIL_ITHREAD, intr_fast, vec, 
+	    intr_execute_handlers, iv);
 
 	intr_stray_count[vec] = 0;
 

==== //depot/projects/soc2006/intr_filter/sun4v/sun4v/nexus.c#3 (text+ko) ====

@@ -306,7 +306,7 @@
 
 static int
 nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags,
-    driver_intr_t *intr, void *arg, void **cookiep)
+    driver_filter_t *filter, driver_intr_t *intr, void *arg, void **cookiep)
 {
 	struct nexus_devinfo *ndi;
 	device_t ichild;
@@ -345,8 +345,8 @@
 	if ((error = rman_activate_resource(res)))
 		goto fail;
 
-	error = inthand_add(device_get_nameunit(child), ihdl,
-			   intr, arg, flags, cookiep);
+	error = inthand_add(device_get_nameunit(child), ihdl, filter,
+	    intr, arg, flags, cookiep);
 
 	cpuid = 0;
 	if (hv_intr_settarget(ihdl, cpuid) != H_EOK) {

==== //depot/projects/soc2006/intr_filter/sun4v/sun4v/vnex.c#4 (text+ko) ====

@@ -249,7 +249,7 @@
 
 static int
 vnex_setup_intr(device_t dev, device_t child, struct resource *res, int flags,
-    driver_intr_t *intr, void *arg, void **cookiep)
+    driver_filter_t *filter, driver_intr_t *intr, void *arg, void **cookiep)
 {
 
 	uint64_t reg, nreg;
@@ -297,8 +297,8 @@
 	if ((error = rman_activate_resource(res)))
 		goto fail;
 
-	error = inthand_add(device_get_nameunit(child), ihdl,
-			    intr, arg, flags, cookiep);
+	error = inthand_add(device_get_nameunit(child), ihdl, filter,
+	    intr, arg, flags, cookiep);
 
 	printf("inthandler added\n");
 fail:



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