Module Name:    src
Committed By:   pooka
Date:           Sat Sep 19 14:18:01 UTC 2009

Modified Files:
        src/sys/rump/librump/rumpkern: intr.c

Log Message:
arrr, implement softint_disestablish().  this code be needin' an enema, matey.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/rump/librump/rumpkern/intr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/rump/librump/rumpkern/intr.c
diff -u src/sys/rump/librump/rumpkern/intr.c:1.17 src/sys/rump/librump/rumpkern/intr.c:1.18
--- src/sys/rump/librump/rumpkern/intr.c:1.17	Sun Apr 26 20:44:50 2009
+++ src/sys/rump/librump/rumpkern/intr.c	Sat Sep 19 14:18:01 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.17 2009/04/26 20:44:50 pooka Exp $	*/
+/*	$NetBSD: intr.c,v 1.18 2009/09/19 14:18:01 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.17 2009/04/26 20:44:50 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.18 2009/09/19 14:18:01 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -44,11 +44,13 @@
 
 time_t time_uptime = 0;
 
+#define SI_MPSAFE 0x01
+#define SI_ONLIST 0x02
+#define SI_KILLME 0x04
 struct softint {
 	void (*si_func)(void *);
 	void *si_arg;
-	bool si_onlist;
-	bool si_mpsafe;
+	int si_flags;
 
 	LIST_ENTRY(softint) si_entries;
 };
@@ -174,10 +176,12 @@
 			si = LIST_FIRST(&si_pending);
 			func = si->si_func;
 			funarg = si->si_arg;
-			mpsafe = si->si_mpsafe;
+			mpsafe = si->si_flags & SI_MPSAFE;
 
-			si->si_onlist = false;
+			si->si_flags &= ~SI_ONLIST;
 			LIST_REMOVE(si, si_entries);
+			if (si->si_flags & SI_KILLME)
+				softint_disestablish(si);
 		} else {
 			cv_wait(&si_cv, &si_mtx);
 			continue;
@@ -246,8 +250,7 @@
 	si = kmem_alloc(sizeof(*si), KM_SLEEP);
 	si->si_func = func;
 	si->si_arg = arg;
-	si->si_onlist = false;
-	si->si_mpsafe = flags & SOFTINT_MPSAFE;
+	si->si_flags = flags & SOFTINT_MPSAFE ? SI_MPSAFE : 0;
 
 	return si;
 }
@@ -261,15 +264,28 @@
 		si->si_func(si->si_arg);
 	} else {
 		mutex_enter(&si_mtx);
-		if (!si->si_onlist) {
+		if (!(si->si_flags & SI_ONLIST)) {
 			LIST_INSERT_HEAD(&si_pending, si, si_entries);
-			si->si_onlist = true;
+			si->si_flags |= SI_ONLIST;
 		}
 		cv_signal(&si_cv);
 		mutex_exit(&si_mtx);
 	}
 }
 
+/* flimsy disestablish: should wait for softints to finish */
+void
+softint_disestablish(void *cook)
+{
+	struct softint *si = cook;
+
+	if (si->si_flags & SI_ONLIST) {
+		si->si_flags |= SI_KILLME;
+		return;
+	}
+	kmem_free(si, sizeof(*si));
+}
+
 bool
 cpu_intr_p(void)
 {

Reply via email to