From owner-p4-projects@FreeBSD.ORG Sat May 20 18:51:52 2006 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 7AE1016A48B; Sat, 20 May 2006 18:51:52 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 04FBD16A480 for ; Sat, 20 May 2006 18:51:52 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id C10A343D46 for ; Sat, 20 May 2006 18:51:51 +0000 (GMT) (envelope-from kmacy@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 k4KIpHbu084522 for ; Sat, 20 May 2006 18:51:17 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k4KIpHuR084519 for perforce@freebsd.org; Sat, 20 May 2006 18:51:17 GMT (envelope-from kmacy@freebsd.org) Date: Sat, 20 May 2006 18:51:17 GMT Message-Id: <200605201851.k4KIpHuR084519@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to kmacy@freebsd.org using -f From: Kip Macy To: Perforce Change Reviews Cc: Subject: PERFORCE change 97522 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, 20 May 2006 18:51:52 -0000 http://perforce.freebsd.org/chv.cgi?CH=97522 Change 97522 by kmacy@kmacy_storage:sun4v_rwbuf on 2006/05/20 18:50:36 put debug output under -DDEBUG add interrupt wrapper for doing interrupt reset Affected files ... .. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/nexus.c#9 edit Differences ... ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/nexus.c#9 (text+ko) ==== @@ -81,6 +81,15 @@ struct rman sc_mem_rman; }; +typedef struct nexus_id { + devhandle_t dh; + uint32_t ino; + devhandle_t nid_ihdl; + driver_intr_t *nid_handler; + void *nid_arg; + +} nexus_id_t; + static device_probe_t nexus_probe; static device_attach_t nexus_attach; static bus_print_child_t nexus_print_child; @@ -246,6 +255,12 @@ ndi->ndi_obdinfo.obd_node = -1; ndi->ndi_obdinfo.obd_name = strdup(name, M_OFWPROP); resource_list_init(&ndi->ndi_rl); + ndi->ndi_intr_rman.rm_type = RMAN_ARRAY; + ndi->ndi_intr_rman.rm_descr = "Interrupts"; + if (rman_init(&ndi->ndi_intr_rman) != 0 || + rman_manage_region(&ndi->ndi_intr_rman, 0, IV_MAX - 1) != 0) + panic("%s: failed to set up rmans.", __func__); + device_set_ivars(cdev, ndi); return (cdev); @@ -295,6 +310,51 @@ #ifdef SUN4V +void nexus_intr_reset(void *arg); + +void +nexus_intr_reset(void *arg) +{ + nexus_id_t *nidp; + + nidp = (nexus_id_t *)arg; + + hvio_intr_setstate(nidp->nid_ihdl, HV_INTR_IDLE_STATE); + +} + + +static void +nexus_intr_wrapper(void *arg) +{ + nexus_id_t *nidp; + driver_intr_t *handler; + void *harg; + int state, valid; + + nidp = (nexus_id_t *)arg; +#if 1 + if (nidp->dh == 0x7c0) + printf("(%#lx, %#x)", nidp->dh, nidp->ino); +#endif + handler = nidp->nid_handler; + harg = nidp->nid_arg; + + (*handler)(harg); + + hvio_intr_setstate(nidp->nid_ihdl, HV_INTR_IDLE_STATE); + +#ifdef DEBUG + if (nidp->dh == 0x7c0) { + hvio_intr_getstate(nidp->nid_ihdl, &state); + hvio_intr_getvalid(nidp->nid_ihdl, &valid); + printf("i: %#lx, s: %d, v: %d\n", nidp->nid_ihdl, state, valid); + } +#endif +} + + + static int nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags, @@ -304,18 +364,20 @@ uint64_t ihdl; uint64_t ino; int error, cpuid; + nexus_id_t *nidp; ndi = device_get_ivars(child); if (res == NULL) panic("%s: NULL interrupt resource!", __func__); - +#ifdef DEBUG printf("dev=%s child=%s\n", ofw_bus_get_name(dev), ofw_bus_get_name(child)); - +#endif ino = rman_get_start(res); - +#ifdef DEBUG printf("child=%s reg=0x%lx ino=0x%lx\n", ofw_bus_get_name(child), ndi->ndi_devhandle, ino); +#endif if (hvio_intr_devino_to_sysino(ndi->ndi_devhandle, (uint32_t)ino, &ihdl) != H_EOK) { @@ -347,10 +409,20 @@ if ((error = rman_activate_resource(res))) goto fail; + if ((nidp = malloc(sizeof(nexus_id_t), M_DEVBUF, M_NOWAIT)) == NULL) { + printf("failed to allocate nexus_id\n"); + error = ENOMEM; + goto fail; + } + nidp->nid_ihdl = ihdl; + nidp->nid_handler = intr; + nidp->nid_arg = arg; + nidp->dh = ndi->ndi_devhandle; + nidp->ino = ino; + error = inthand_add(device_get_nameunit(child), ihdl, - intr, arg, flags, cookiep); + nexus_intr_wrapper, nidp, flags, cookiep); - printf("inthandler added\n"); fail: return (error); @@ -449,6 +521,10 @@ flags &= ~RF_ACTIVE; rv = rman_reserve_resource(rm, start, end, count, flags, child); + if (type == SYS_RES_IRQ && rv == NULL) { + printf("%s: start: %ld, end: %ld, flags: %#x\n", __func__, + start, end, flags); + } if (rv == NULL) return (NULL); if (type == SYS_RES_MEMORY) {