Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/pic Add hooks for __HAVE_PIC_SET_PRIORITY which...
details: https://anonhg.NetBSD.org/src/rev/31df0ad0f4af
branches: trunk
changeset: 780173:31df0ad0f4af
user: matt <matt%NetBSD.org@localhost>
date: Sat Jul 14 07:52:53 2012 +0000
description:
Add hooks for __HAVE_PIC_SET_PRIORITY which allows updating of a hardware
(PIC) priority based on current IPL.
diffstat:
sys/arch/arm/pic/pic.c | 33 +++++++++++++++++++++------------
sys/arch/arm/pic/pic_splfuncs.c | 9 +++++----
sys/arch/arm/pic/picvar.h | 17 ++++++++++++++++-
3 files changed, 42 insertions(+), 17 deletions(-)
diffs (162 lines):
diff -r b16c02e19449 -r 31df0ad0f4af sys/arch/arm/pic/pic.c
--- a/sys/arch/arm/pic/pic.c Sat Jul 14 07:43:15 2012 +0000
+++ b/sys/arch/arm/pic/pic.c Sat Jul 14 07:52:53 2012 +0000
@@ -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 @@
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 @@
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 @@
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__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 @@
{
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)
diff -r b16c02e19449 -r 31df0ad0f4af sys/arch/arm/pic/pic_splfuncs.c
--- a/sys/arch/arm/pic/pic_splfuncs.c Sat Jul 14 07:43:15 2012 +0000
+++ b/sys/arch/arm/pic/pic_splfuncs.c Sat Jul 14 07:52:53 2012 +0000
@@ -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 @@
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
diff -r b16c02e19449 -r 31df0ad0f4af sys/arch/arm/pic/picvar.h
--- a/sys/arch/arm/pic/picvar.h Sat Jul 14 07:43:15 2012 +0000
+++ b/sys/arch/arm/pic/picvar.h Sat Jul 14 07:52:53 2012 +0000
@@ -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 @@
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);
Home |
Main Index |
Thread Index |
Old Index