From owner-p4-projects@FreeBSD.ORG Sat Jan 13 15:15:57 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6C5BB16A407; Sat, 13 Jan 2007 15:15:57 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1183016A415 for ; Sat, 13 Jan 2007 15:15:57 +0000 (UTC) (envelope-from piso@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 04DF113C442 for ; Sat, 13 Jan 2007 15:15:57 +0000 (UTC) (envelope-from piso@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id l0DFFuwK033782 for ; Sat, 13 Jan 2007 15:15:56 GMT (envelope-from piso@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id l0DFFurf033779 for perforce@freebsd.org; Sat, 13 Jan 2007 15:15:56 GMT (envelope-from piso@freebsd.org) Date: Sat, 13 Jan 2007 15:15:56 GMT Message-Id: <200701131515.l0DFFurf033779@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to piso@freebsd.org using -f From: Paolo Pisati To: Perforce Change Reviews Cc: Subject: PERFORCE change 112863 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jan 2007 15:15:57 -0000 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 (; iiv_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: