Module Name: src
Committed By: matt
Date: Sat Jul 14 07:52:53 UTC 2012
Modified Files:
src/sys/arch/arm/pic: pic.c pic_splfuncs.c picvar.h
Log Message:
Add hooks for __HAVE_PIC_SET_PRIORITY which allows updating of a hardware
(PIC) priority based on current IPL.
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/pic/pic.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/pic/pic_splfuncs.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/pic/picvar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/arm/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.10 src/sys/arch/arm/pic/pic.c:1.11
--- src/sys/arch/arm/pic/pic.c:1.10 Sat Jul 7 08:05:48 2012
+++ src/sys/arch/arm/pic/pic.c Sat Jul 14 07:52:53 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: pic.c,v 1.10 2012/07/07 08:05:48 skrll Exp $ */
+/* $NetBSD: pic.c,v 1.11 2012/07/14 07:52:53 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -28,24 +28,21 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.10 2012/07/07 08:05:48 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.11 2012/07/14 07:52:53 matt Exp $");
#define _INTR_PRIVATE
#include <sys/param.h>
#include <sys/evcnt.h>
#include <sys/atomic.h>
-#include <sys/malloc.h>
-#include <sys/mallocvar.h>
+#include <sys/kmem.h>
#include <sys/atomic.h>
+#include <sys/cpu.h>
#include <arm/armreg.h>
-#include <arm/cpu.h>
#include <arm/cpufunc.h>
#include <arm/pic/picvar.h>
-MALLOC_DEFINE(M_INTRSOURCE, "intrsource", "interrupt source");
-
static uint32_t
pic_find_pending_irqs_by_ipl(struct pic_softc *, size_t, uint32_t, int);
static struct pic_softc *
@@ -73,7 +70,16 @@ static struct evcnt pic_deferral_ev =
EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, "deferred", "intr");
EVCNT_ATTACH_STATIC(pic_deferral_ev);
-
+#ifdef __HAVE_PIC_SET_PRIORITY
+void
+pic_set_priority(struct cpu_info *ci, int newipl)
+{
+ register_t psw = disable_interrupts(I32_bit);
+ ci->ci_cpl = newipl;
+ (pic_list[0]->pic_set_priority)(newipl);
+ restore_interrupts(psw);
+}
+#endif
int
pic_handle_intr(void *arg)
@@ -371,13 +377,13 @@ pic_do_pending_ints(register_t psw, int
if (ipl <= newipl)
break;
- ci->ci_cpl = ipl;
+ pic_set_priority(ci, newipl);
pic_list_deliver_irqs(psw, ipl, frame);
pic_list_unblock_irqs();
}
}
if (ci->ci_cpl != newipl)
- ci->ci_cpl = newipl;
+ pic_set_priority(ci, newipl);
#ifdef __HAVE_FAST_SOFTINTS
cpu_dosoftints();
#endif
@@ -449,7 +455,7 @@ pic_establish_intr(struct pic_softc *pic
return NULL;
}
- is = malloc(sizeof(*is), M_INTRSOURCE, M_NOWAIT|M_ZERO);
+ is = kmem_zalloc(sizeof(*is), KM_SLEEP);
if (is == NULL)
return NULL;
@@ -527,7 +533,7 @@ pic_disestablish_source(struct intrsourc
pic__iplsources[pic_ipl_offset[is->is_ipl] + is->is_iplidx] = NULL;
evcnt_detach(&is->is_ev);
- free(is, M_INTRSOURCE);
+ kmem_free(is, sizeof(*is));
}
void *
@@ -535,6 +541,9 @@ intr_establish(int irq, int ipl, int typ
{
int slot;
+ KASSERT(!cpu_intr_p());
+ KASSERT(!cpu_softintr_p());
+
for (slot = 0; slot < PIC_MAXPICS; slot++) {
struct pic_softc * const pic = pic_list[slot];
if (pic == NULL || pic->pic_irqbase < 0)
Index: src/sys/arch/arm/pic/pic_splfuncs.c
diff -u src/sys/arch/arm/pic/pic_splfuncs.c:1.2 src/sys/arch/arm/pic/pic_splfuncs.c:1.3
--- src/sys/arch/arm/pic/pic_splfuncs.c:1.2 Sat May 28 20:56:37 2011
+++ src/sys/arch/arm/pic/pic_splfuncs.c Sat Jul 14 07:52:53 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: pic_splfuncs.c,v 1.2 2011/05/28 20:56:37 jakllsch Exp $ */
+/* $NetBSD: pic_splfuncs.c,v 1.3 2012/07/14 07:52:53 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -28,7 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.2 2011/05/28 20:56:37 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.3 2012/07/14 07:52:53 matt Exp $");
#define _INTR_PRIVATE
#include <sys/param.h>
@@ -51,8 +51,9 @@ _splraise(int newipl)
struct cpu_info * const ci = curcpu();
const int oldipl = ci->ci_cpl;
KASSERT(newipl < NIPL);
- if (newipl > ci->ci_cpl)
- ci->ci_cpl = newipl;
+ if (newipl > ci->ci_cpl) {
+ pic_set_priority(ci, newipl);
+ }
return oldipl;
}
int
Index: src/sys/arch/arm/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.5 src/sys/arch/arm/pic/picvar.h:1.6
--- src/sys/arch/arm/pic/picvar.h:1.5 Mon Nov 15 09:25:58 2010
+++ src/sys/arch/arm/pic/picvar.h Sat Jul 14 07:52:53 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: picvar.h,v 1.5 2010/11/15 09:25:58 bsh Exp $ */
+/* $NetBSD: picvar.h,v 1.6 2012/07/14 07:52:53 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -100,8 +100,23 @@ struct pic_ops {
void (*pic_establish_irq)(struct pic_softc *, struct intrsource *);
void (*pic_source_name)(struct pic_softc *, int, char *, size_t);
+
+#ifdef __HAVE_PIC_SET_PRIORITY
+ void (*pic_set_priority)(struct pic_softc *, int);
+#endif
};
+#ifdef __HAVE_PIC_SET_PRIORITY
+/*
+ * This is used to update a hardware pic with a value corresponding
+ * to the ipl being set.
+ */
+struct cpu_info;
+void pic_set_priority(struct cpu_info *, int);
+#else
+/* Using an inline causes catch-22 problems with cpu.h */
+#define pic_set_priority(ci, newipl) ((void)((ci)->ci_cpl = (newipl)))
+#endif
void pic_add(struct pic_softc *, int);
void pic_do_pending_int(void);