Add hooks for __HAVE_PIC_SET_PRIORITY which allows updating of a hardware

(PIC) priority based on current IPL.
This commit is contained in:
matt 2012-07-14 07:52:53 +00:00
parent 9db3ad34c1
commit 1ca677e576
3 changed files with 42 additions and 17 deletions

View File

@ -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 newipl, void *frame)
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, int irq, int ipl, int type,
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 intrsource *is)
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 type, int (*func)(void *), void *arg)
{
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)

View File

@ -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

View File

@ -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);