From owner-p4-projects@FreeBSD.ORG Mon Jun 12 03:38: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 4CC0E16A46F; Mon, 12 Jun 2006 03:38: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 2897D16A41A for ; Mon, 12 Jun 2006 03:38:52 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id A6EA243D48 for ; Mon, 12 Jun 2006 03:38:51 +0000 (GMT) (envelope-from imp@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 k5C3acHM098572 for ; Mon, 12 Jun 2006 03:36:38 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k5C3acVj098569 for perforce@freebsd.org; Mon, 12 Jun 2006 03:36:38 GMT (envelope-from imp@freebsd.org) Date: Mon, 12 Jun 2006 03:36:38 GMT Message-Id: <200606120336.k5C3acVj098569@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 99030 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: Mon, 12 Jun 2006 03:38:52 -0000 http://perforce.freebsd.org/chv.cgi?CH=99030 Change 99030 by imp@imp_harmony on 2006/06/12 03:36:28 IFC @99029 Affected files ... .. //depot/projects/arm/src/sys/arm/arm/pmap.c#19 integrate .. //depot/projects/arm/src/sys/dev/acpica/acpi.c#10 integrate .. //depot/projects/arm/src/sys/dev/cardbus/cardbus.c#8 integrate .. //depot/projects/arm/src/sys/dev/cardbus/cardbus_cis.c#6 integrate .. //depot/projects/arm/src/sys/dev/cm/if_cm_isa.c#3 integrate .. //depot/projects/arm/src/sys/dev/cm/smc90cx6.c#3 integrate .. //depot/projects/arm/src/sys/dev/cm/smc90cx6reg.h#2 integrate .. //depot/projects/arm/src/sys/dev/cm/smc90cx6var.h#3 integrate .. //depot/projects/arm/src/sys/gnu/fs/xfs/FreeBSD/support/spin.h#3 integrate .. //depot/projects/arm/src/sys/gnu/fs/xfs/FreeBSD/xfs_vnops.c#4 integrate .. //depot/projects/arm/src/sys/gnu/fs/xfs/xfs_trans.c#4 integrate .. //depot/projects/arm/src/sys/net/if.c#10 integrate Differences ... ==== //depot/projects/arm/src/sys/arm/arm/pmap.c#19 (text+ko) ==== @@ -147,7 +147,7 @@ #include "opt_vm.h" #include -__FBSDID("$FreeBSD: src/sys/arm/arm/pmap.c,v 1.61 2006/06/10 05:20:18 alc Exp $"); +__FBSDID("$FreeBSD: src/sys/arm/arm/pmap.c,v 1.63 2006/06/11 04:53:06 alc Exp $"); #include #include #include @@ -413,7 +413,6 @@ static vm_paddr_t pmap_kernel_l2ptp_phys; static struct vm_object pvzone_obj; static int pv_entry_count=0, pv_entry_max=0, pv_entry_high_water=0; -int pmap_pagedaemon_waken = 0; /* * This list exists for the benefit of pmap_map_chunk(). It keeps track @@ -2262,7 +2261,6 @@ { pmap_t pm; struct pcb *pcb; - int s; pm = vmspace_pmap(td->td_proc->p_vmspace); pcb = td->td_pcb; @@ -2306,8 +2304,6 @@ cpu_domains(pcb->pcb_dacr); cpu_setttb(pcb->pcb_pagedir); - - splx(s); } critical_exit(); } @@ -2738,7 +2734,6 @@ pmap_growkernel(vm_offset_t addr) { pmap_t kpm = pmap_kernel(); - int s; if (addr <= pmap_curmaxkvaddr) return; /* we are OK */ @@ -2747,8 +2742,6 @@ * whoops! we need to add kernel PTPs */ - s = splhigh(); /* to be safe */ - /* Map 1MB at a time */ for (; pmap_curmaxkvaddr < addr; pmap_curmaxkvaddr += L1_S_SIZE) pmap_grow_l2_bucket(kpm, pmap_curmaxkvaddr); @@ -3826,11 +3819,8 @@ pv_entry_t ret_value; pv_entry_count++; - if ((pv_entry_count > pv_entry_high_water) && - (pmap_pagedaemon_waken == 0)) { - pmap_pagedaemon_waken = 1; - wakeup (&vm_pages_needed); - } + if (pv_entry_count > pv_entry_high_water) + pagedaemon_wakeup(); ret_value = uma_zalloc(pvzone, M_NOWAIT); return ret_value; } @@ -4396,13 +4386,10 @@ { pv_entry_t pv; int loops = 0; - int s; if (m->flags & PG_FICTITIOUS) return (FALSE); - s = splvm(); - /* * Not found, check current mappings returning immediately */ @@ -4410,14 +4397,12 @@ pv; pv = TAILQ_NEXT(pv, pv_list)) { if (pv->pv_pmap == pmap) { - splx(s); return (TRUE); } loops++; if (loops >= 16) break; } - splx(s); return (FALSE); } ==== //depot/projects/arm/src/sys/dev/acpica/acpi.c#10 (text+ko) ==== @@ -28,7 +28,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi.c,v 1.225 2006/06/10 08:04:38 njl Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi.c,v 1.226 2006/06/11 20:31:41 njl Exp $"); #include "opt_acpi.h" #include @@ -522,6 +522,9 @@ OID_AUTO, "s4bios", CTLFLAG_RW, &sc->acpi_s4bios, 0, "S4BIOS mode"); SYSCTL_ADD_INT(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), OID_AUTO, "verbose", CTLFLAG_RW, &sc->acpi_verbose, 0, "verbose mode"); + SYSCTL_ADD_INT(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), + OID_AUTO, "disable_on_reboot", CTLFLAG_RW, + &sc->acpi_do_disable, 0, "Disable ACPI when rebooting/halting system"); /* * Default to 1 second before sleeping to give some machines time to @@ -1630,13 +1633,15 @@ static void acpi_shutdown_final(void *arg, int howto) { - ACPI_STATUS status; + struct acpi_softc *sc; + ACPI_STATUS status; /* * XXX Shutdown code should only run on the BSP (cpuid 0). * Some chipsets do not power off the system correctly if called from * an AP. */ + sc = arg; if ((howto & RB_POWEROFF) != 0) { status = AcpiEnterSleepStatePrep(ACPI_STATE_S5); if (ACPI_FAILURE(status)) { @@ -1653,7 +1658,8 @@ DELAY(1000000); printf("ACPI power-off failed - timeout\n"); } - } else if ((howto & RB_AUTOBOOT) != 0 && AcpiGbl_FADT->ResetRegSup) { + } else if ((howto & RB_HALT) == 0 && AcpiGbl_FADT->ResetRegSup) { + /* Reboot using the reset register. */ status = AcpiHwLowLevelWrite( AcpiGbl_FADT->ResetRegister.RegisterBitWidth, AcpiGbl_FADT->ResetValue, &AcpiGbl_FADT->ResetRegister); @@ -1663,7 +1669,11 @@ DELAY(1000000); printf("ACPI reset failed - timeout\n"); } - } else if (panicstr == NULL) { + } else if (sc->acpi_do_disable && panicstr == NULL) { + /* + * Only disable ACPI if the user requested. On some systems, writing + * the disable value to SMI_CMD hangs the system. + */ printf("Shutting down ACPI\n"); AcpiTerminate(); } ==== //depot/projects/arm/src/sys/dev/cardbus/cardbus.c#8 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/cardbus/cardbus.c,v 1.61 2006/01/20 22:00:50 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/cardbus/cardbus.c,v 1.62 2006/06/12 03:17:24 imp Exp $"); #include #include @@ -192,11 +192,8 @@ dinfo->pci.cfg.dev = child; resource_list_init(&dinfo->pci.resources); device_set_ivars(child, dinfo); - if (cardbus_do_cis(cbdev, child) != 0) { - DEVPRINTF((cbdev, "Can't parse cis\n")); - pci_freecfg((struct pci_devinfo *)dinfo); - continue; - } + if (cardbus_do_cis(cbdev, child) != 0) + DEVPRINTF((cbdev, "Warning: Bogus CIS ignored\n")); pci_cfg_save(dinfo->pci.cfg.dev, &dinfo->pci, 0); pci_cfg_restore(dinfo->pci.cfg.dev, &dinfo->pci); pci_add_resources(cbdev, child, 1, dinfo->mprefetchable); ==== //depot/projects/arm/src/sys/dev/cardbus/cardbus_cis.c#6 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/cardbus/cardbus_cis.c,v 1.58 2006/01/03 03:36:17 imp Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/cardbus/cardbus_cis.c,v 1.60 2006/06/12 03:28:42 imp Exp $"); /* * CIS Handling for the Cardbus Bus @@ -597,7 +597,9 @@ bzero(tupledata, MAXTUPLESIZE); expect_linktarget = TRUE; if ((start = pci_read_config(child, PCIR_CIS, 4)) == 0) { - device_printf(cbdev, "CIS pointer is 0!\n"); + if (cardbus_cis_debug) + device_printf(cbdev, + "Warning: CIS pointer 0 (no CIS present)\n"); return (ENXIO); } if (cardbus_cis_debug) @@ -639,7 +641,6 @@ int cardbus_do_cis(device_t cbdev, device_t child) { - int ret; struct tuple_callbacks init_callbacks[] = { MAKETUPLE(LONGLINK_CB, unhandled), MAKETUPLE(INDIRECT, unhandled), @@ -656,8 +657,5 @@ MAKETUPLE(GENERIC, generic), }; - ret = cardbus_parse_cis(cbdev, child, init_callbacks, NULL); - if (ret < 0) - return (ret); - return 0; + return (cardbus_parse_cis(cbdev, child, init_callbacks, NULL)); } ==== //depot/projects/arm/src/sys/dev/cm/if_cm_isa.c#3 (text+ko) ==== @@ -1,7 +1,7 @@ /* $NetBSD: if_bah_zbus.c,v 1.6 2000/01/23 21:06:12 aymeric Exp $ */ #include -__FBSDID("$FreeBSD: src/sys/dev/cm/if_cm_isa.c,v 1.8 2005/09/19 03:10:15 imp Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/cm/if_cm_isa.c,v 1.9 2006/06/11 22:25:01 fjoe Exp $"); /*- * Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc. @@ -48,10 +48,13 @@ #include #include +#include +#include #include #include +#include #include static int cm_isa_probe (device_t); @@ -62,20 +65,35 @@ device_t dev; { struct cm_softc *sc = device_get_softc(dev); - int error; + int rid; + + rid = 0; + sc->port_res = bus_alloc_resource( + dev, SYS_RES_IOPORT, &rid, 0ul, ~0ul, CM_IO_PORTS, RF_ACTIVE); + if (sc->port_res == NULL) + return (ENOENT); - bzero(sc, sizeof(struct cm_softc)); + if (GETREG(CMSTAT) == 0xff) { + cm_release_resources(dev); + return (ENXIO); + } - error = cm_probe(dev); - if (error == 0) - goto end; + rid = 0; + sc->mem_res = bus_alloc_resource( + dev, SYS_RES_MEMORY, &rid, 0ul, ~0ul, CM_MEM_SIZE, RF_ACTIVE); + if (sc->mem_res == NULL) { + cm_release_resources(dev); + return (ENOENT); + } -end: - if (error == 0) - error = cm_alloc_irq(dev, 0); + rid = 0; + sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); + if (sc->irq_res == NULL) { + cm_release_resources(dev); + return (ENOENT); + } - cm_release_resources(dev); - return (error); + return (0); } static int @@ -85,18 +103,25 @@ struct cm_softc *sc = device_get_softc(dev); int error; - cm_alloc_port(dev, sc->port_rid, sc->port_used); - cm_alloc_memory(dev, sc->mem_rid, sc->mem_used); - cm_alloc_irq(dev, sc->irq_rid); + /* init mtx and setup interrupt */ + mtx_init(&sc->sc_mtx, device_get_nameunit(dev), + MTX_NETWORK_LOCK, MTX_DEF); + error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET | INTR_MPSAFE, + cmintr, sc, &sc->irq_handle); + if (error) + goto err; + + /* attach */ + error = cm_attach(dev); + if (error) + goto err; - error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, - cmintr, sc, &sc->irq_handle); - if (error) { - cm_release_resources(dev); - return (error); - } + return 0; - return cm_attach(dev); +err: + mtx_destroy(&sc->sc_mtx); + cm_release_resources(dev); + return (error); } static int @@ -104,19 +129,23 @@ { struct cm_softc *sc = device_get_softc(dev); struct ifnet *ifp = sc->sc_ifp; - int s; - cm_stop(sc); + /* stop and detach */ + CM_LOCK(sc); + cm_stop_locked(sc); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + CM_UNLOCK(sc); - s = splimp(); + callout_drain(&sc->sc_recon_ch); arc_ifdetach(ifp); - splx(s); + /* teardown interrupt, destroy mtx and release resources */ bus_teardown_intr(dev, sc->irq_res, sc->irq_handle); + mtx_destroy(&sc->sc_mtx); if_free(ifp); cm_release_resources(dev); + bus_generic_detach(dev); return (0); } ==== //depot/projects/arm/src/sys/dev/cm/smc90cx6.c#3 (text+ko) ==== @@ -1,7 +1,7 @@ /* $NetBSD: smc90cx6.c,v 1.38 2001/07/07 15:57:53 thorpej Exp $ */ #include -__FBSDID("$FreeBSD: src/sys/dev/cm/smc90cx6.c,v 1.16 2005/08/09 10:19:44 rwatson Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/cm/smc90cx6.c,v 1.17 2006/06/11 22:25:01 fjoe Exp $"); /*- * Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc. @@ -62,10 +62,6 @@ #include #include -#if __FreeBSD_version < 500000 -#include -#endif - #include #include #include @@ -87,25 +83,6 @@ /* for watchdog timer. This should be more than enough. */ #define ARCTIMEOUT (5*IFNET_SLOWHZ) -/* short notation */ - -#define GETREG(off) \ - bus_space_read_1(rman_get_bustag((sc)->port_res), \ - rman_get_bushandle((sc)->port_res), \ - (off)) -#define PUTREG(off, value) \ - bus_space_write_1(rman_get_bustag((sc)->port_res), \ - rman_get_bushandle((sc)->port_res), \ - (off), (value)) -#define GETMEM(off) \ - bus_space_read_1(rman_get_bustag((sc)->mem_res), \ - rman_get_bushandle((sc)->mem_res), \ - (off)) -#define PUTMEM(off, value) \ - bus_space_write_1(rman_get_bustag((sc)->mem_res), \ - rman_get_bushandle((sc)->mem_res), \ - (off), (value)) - devclass_t cm_devclass; /* @@ -134,7 +111,7 @@ * case 2: set IFF_DRV_OACTIVE to stop arc_output from filling us. * case 1: start tx * - * tint clears IFF_OCATIVE, decrements and checks tx_fillcount + * tint clears IFF_OACTIVE, decrements and checks tx_fillcount * case 1: start tx on tx_act ^ 1, softcall cm_start * case 0: softcall cm_start * @@ -142,105 +119,17 @@ */ void cm_init(void *); -void cm_reset(struct cm_softc *); +static void cm_init_locked(struct cm_softc *); +static void cm_reset_locked(struct cm_softc *); void cm_start(struct ifnet *); +void cm_start_locked(struct ifnet *); int cm_ioctl(struct ifnet *, unsigned long, caddr_t); void cm_watchdog(struct ifnet *); -void cm_srint(void *vsc); -static void cm_tint(struct cm_softc *, int); -void cm_reconwatch(void *); +void cm_srint_locked(void *vsc); +static void cm_tint_locked(struct cm_softc *, int); +void cm_reconwatch_locked(void *); -int -cm_probe(dev) - device_t dev; -{ - int error; - struct cm_softc *sc = device_get_softc(dev); - - error = cm_alloc_port(dev, 0, CM_IO_PORTS); - if (error) - return error; - - if (GETREG(CMSTAT) == 0xff) - return ENXIO; - - error = cm_alloc_memory(dev, 0, 0x800); - if (error) - return error; - - return 0; -} - /* - * Allocate a port resource with the given resource id. - */ -int -cm_alloc_port(dev, rid, size) - device_t dev; - int rid; - int size; -{ - struct cm_softc *sc = device_get_softc(dev); - struct resource *res; - - res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, - 0ul, ~0ul, size, RF_ACTIVE); - if (res) { - sc->port_rid = rid; - sc->port_res = res; - sc->port_used = size; - return (0); - } else { - return (ENOENT); - } -} - -/* - * Allocate a memory resource with the given resource id. - */ -int -cm_alloc_memory(dev, rid, size) - device_t dev; - int rid; - int size; -{ - struct cm_softc *sc = device_get_softc(dev); - struct resource *res; - - res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, - 0ul, ~0ul, size, RF_ACTIVE); - if (res) { - sc->mem_rid = rid; - sc->mem_res = res; - sc->mem_used = size; - return (0); - } else { - return (ENOENT); - } -} - -/* - * Allocate an irq resource with the given resource id. - */ -int -cm_alloc_irq(dev, rid) - device_t dev; - int rid; -{ - struct cm_softc *sc = device_get_softc(dev); - struct resource *res; - - res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); - if (res) { - sc->irq_rid = rid; - sc->irq_res = res; - return (0); - } else { - return (ENOENT); - } -} - -/* * Release all resources */ void @@ -249,26 +138,26 @@ { struct cm_softc *sc = device_get_softc(dev); - if (sc->port_res) { + if (sc->port_res != NULL) { bus_deactivate_resource(dev, SYS_RES_IOPORT, - sc->port_rid, sc->port_res); + 0, sc->port_res); bus_release_resource(dev, SYS_RES_IOPORT, - sc->port_rid, sc->port_res); - sc->port_res = 0; + 0, sc->port_res); + sc->port_res = NULL; } - if (sc->mem_res) { + if (sc->mem_res != NULL) { bus_deactivate_resource(dev, SYS_RES_MEMORY, - sc->mem_rid, sc->mem_res); + 0, sc->mem_res); bus_release_resource(dev, SYS_RES_MEMORY, - sc->mem_rid, sc->mem_res); - sc->mem_res = 0; + 0, sc->mem_res); + sc->mem_res = NULL; } - if (sc->irq_res) { + if (sc->irq_res != NULL) { bus_deactivate_resource(dev, SYS_RES_IRQ, - sc->irq_rid, sc->irq_res); + 0, sc->irq_res); bus_release_resource(dev, SYS_RES_IRQ, - sc->irq_rid, sc->irq_res); - sc->irq_res = 0; + 0, sc->irq_res); + sc->irq_res = NULL; } } @@ -278,29 +167,22 @@ { struct cm_softc *sc = device_get_softc(dev); struct ifnet *ifp; - int s; u_int8_t linkaddress; ifp = sc->sc_ifp = if_alloc(IFT_ARCNET); - if (ifp == NULL) { + if (ifp == NULL) return (ENOSPC); - } - s = splhigh(); - /* * read the arcnet address from the board */ - GETREG(CMRESET); do { DELAY(200); } while (!(GETREG(CMSTAT) & CM_POR)); - linkaddress = GETMEM(CMMACOFF); /* clear the int mask... */ - sc->sc_intmask = 0; PUTREG(CMSTAT, 0); @@ -308,13 +190,10 @@ PUTREG(CMCMD, CM_CLR(CLR_POR|CLR_RECONFIG)); sc->sc_recontime = sc->sc_reconcount = 0; - /* and reenable kernel int level */ - splx(s); - /* * set interface to stopped condition (reset) */ - cm_stop(sc); + cm_stop_locked(sc); ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); @@ -326,7 +205,7 @@ /* XXX IFQ_SET_READY(&ifp->if_snd); */ ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; ifp->if_timer = 0; - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NEEDSGIANT; + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX; arc_ifattach(ifp, linkaddress); @@ -336,11 +215,7 @@ (void (*)(void *))cm_start, ifp); #endif -#if __FreeBSD_version < 500000 - callout_init(&sc->sc_recon_ch); -#else - callout_init(&sc->sc_recon_ch, 0); -#endif + callout_init_mtx(&sc->sc_recon_ch, &sc->sc_mtx, 0); if_printf(ifp, "link addr 0x%02x (%d)\n", linkaddress, linkaddress); return 0; @@ -355,28 +230,30 @@ void *xsc; { struct cm_softc *sc = (struct cm_softc *)xsc; - struct ifnet *ifp; - int s; + + CM_LOCK(sc); + cm_init_locked(sc); + CM_UNLOCK(sc); +} - ifp = sc->sc_ifp; +static void +cm_init_locked(struct cm_softc *sc) +{ + struct ifnet *ifp = sc->sc_ifp; if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { - s = splimp(); ifp->if_drv_flags |= IFF_DRV_RUNNING; - cm_reset(sc); - cm_start(ifp); - splx(s); + cm_reset_locked(sc); } } /* * Reset the interface... * - * this assumes that it is called inside a critical section... - * + * Assumes that it is called with sc_mtx held */ void -cm_reset(sc) +cm_reset_locked(sc) struct cm_softc *sc; { struct ifnet *ifp; @@ -444,14 +321,14 @@ ifp->if_drv_flags |= IFF_DRV_RUNNING; ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - cm_start(ifp); + cm_start_locked(ifp); } /* * Take interface offline */ void -cm_stop(sc) +cm_stop_locked(sc) struct cm_softc *sc; { /* Stop the interrupts */ @@ -464,24 +341,32 @@ sc->sc_ifp->if_timer = 0; } +void +cm_start(struct ifnet *ifp) +{ + struct cm_softc *sc = ifp->if_softc; + + CM_LOCK(sc); + cm_start_locked(ifp); + CM_UNLOCK(sc); +} + /* * Start output on interface. Get another datagram to send * off the interface queue, and copy it to the * interface becore starting the output * - * this assumes that it is called inside a critical section... - * XXX hm... does it still? - * + * Assumes that sc_mtx is held */ void -cm_start(ifp) +cm_start_locked(ifp) struct ifnet *ifp; { struct cm_softc *sc = ifp->if_softc; - struct mbuf *m,*mp; + struct mbuf *m, *mp; int cm_ram_ptr; - int len, tlen, offset, s, buffer; + int len, tlen, offset, buffer; #ifdef CMTIMINGS u_long copystart, lencopy, perbyte; #endif @@ -493,18 +378,12 @@ if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) return; - s = splimp(); - - if (sc->sc_tx_fillcount >= 2) { - splx(s); + if (sc->sc_tx_fillcount >= 2) return; - } m = arc_frag_next(ifp); buffer = sc->sc_tx_act ^ 1; - splx(s); - if (m == 0) return; @@ -569,9 +448,6 @@ sc->sc_broadcast[buffer] = (m->m_flags & M_BCAST) != 0; sc->sc_retransmits[buffer] = (m->m_flags & M_BCAST) ? 1 : 5; - /* actually transmit the packet */ - s = splimp(); - if (++sc->sc_tx_fillcount > 1) { /* * We are filled up to the rim. No more bufs for the moment, @@ -596,7 +472,6 @@ ifp->if_timer = ARCTIMEOUT; } - splx(s); m_freem(m); /* @@ -605,20 +480,30 @@ * the hardware retries till shutdown. * This is integrated now in the code above. */ +} + +#ifdef CMSOFTCOPY +void +cm_srint(void *vsc) +{ + struct cm_softc *sc = (struct cm_softc *)vsc; - return; + CM_LOCK(sc); + cm_srint_locked(vsc); + CM_UNLOCK(sc); } +#endif /* * Arcnet interface receiver soft interrupt: * get the stuff out of any filled buffer we find. */ void -cm_srint(vsc) +cm_srint_locked(vsc) void *vsc; { struct cm_softc *sc = (struct cm_softc *)vsc; - int buffer, len, offset, s, type; + int buffer, len, offset, type; int cm_ram_ptr; struct mbuf *m; struct arc_header *ah; @@ -626,9 +511,7 @@ ifp = sc->sc_ifp; - s = splimp(); buffer = sc->sc_rx_act ^ 1; - splx(s); /* Allocate header mbuf */ MGETHDR(m, M_DONTWAIT, MT_DATA); @@ -695,7 +578,9 @@ rman_get_bustag(sc->mem_res), rman_get_bushandle(sc->mem_res), cm_ram_ptr + offset, mtod(m, u_char *) + 2, len); + CM_UNLOCK(sc); arc_input(ifp, m); + CM_LOCK(sc); m = NULL; ifp->if_ipackets++; @@ -707,8 +592,6 @@ /* mark buffer as invalid by source id 0 */ PUTMEM(buffer << 9, 0); - s = splimp(); - if (--sc->sc_rx_fillcount == 2 - 1) { /* was off, restart it on buffer just emptied */ @@ -723,11 +606,10 @@ if_printf(ifp, "srint: restarted rx on buf %d\n", buffer); #endif } - splx(s); } __inline static void -cm_tint(sc, isr) +cm_tint_locked(sc, isr) struct cm_softc *sc; int isr; { @@ -807,7 +689,7 @@ softintr_schedule(sc->sc_txcookie); #else /* call it directly */ - cm_start(ifp); + cm_start_locked(ifp); #endif } @@ -825,10 +707,15 @@ int buffer; u_long newsec; + CM_LOCK(sc); + isr = GETREG(CMSTAT); maskedisr = isr & sc->sc_intmask; - if (!maskedisr) + if (!maskedisr || (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { + CM_UNLOCK(sc); return; + } + do { #if defined(CM_DEBUG) && (CM_DEBUG > 1) @@ -881,7 +768,7 @@ } sc->sc_recontime = newsec; callout_reset(&sc->sc_recon_ch, 15 * hz, - cm_reconwatch, (void *)sc); + cm_reconwatch_locked, (void *)sc); } if (maskedisr & CM_RI) { @@ -936,12 +823,12 @@ softintr_schedule(sc->sc_rxcookie); #else /* this one does the copy here */ - cm_srint(sc); + cm_srint_locked(sc); #endif } } if (maskedisr & CM_TA) { - cm_tint(sc, isr); + cm_tint_locked(sc, isr); } isr = GETREG(CMSTAT); maskedisr = isr & sc->sc_intmask; @@ -950,10 +837,11 @@ if_printf(ifp, "intr (exit): status 0x%02x, intmask 0x%02x\n", isr, sc->sc_intmask); #endif + CM_UNLOCK(sc); } void -cm_reconwatch(arg) +cm_reconwatch_locked(arg) void *arg; { struct cm_softc *sc = arg; @@ -981,13 +869,12 @@ struct cm_softc *sc; struct ifaddr *ifa; struct ifreq *ifr; - int s, error; + int error; error = 0; sc = ifp->if_softc; ifa = (struct ifaddr *)data; ifr = (struct ifreq *)data; - s = splimp(); #if defined(CM_DEBUG) && (CM_DEBUG > 2) if_printf(ifp, "ioctl() called, cmd = 0x%lx\n", command); @@ -1003,13 +890,14 @@ break; case SIOCSIFFLAGS: + CM_LOCK(sc); if ((ifp->if_flags & IFF_UP) == 0 && (ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { /* * If interface is marked down and it is running, * then stop it. */ - cm_stop(sc); + cm_stop_locked(sc); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; } else if ((ifp->if_flags & IFF_UP) != 0 && (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { @@ -1017,8 +905,9 @@ * If interface is marked up and it is stopped, then * start it. */ - cm_init(sc); + cm_init_locked(sc); } + CM_UNLOCK(sc); break; default: @@ -1026,7 +915,6 @@ break; } - splx(s); return (error); } @@ -1040,16 +928,14 @@ * Only thing we do is disable transmitter. We'll get a transmit timeout, * and the int handler will have to decide not to retransmit (in case * retransmission is implemented). - * - * This one assumes being called inside splimp() */ - void cm_watchdog(ifp) struct ifnet *ifp; { struct cm_softc *sc = ifp->if_softc; + CM_LOCK(sc); PUTREG(CMCMD, CM_TXDIS); - return; >>> TRUNCATED FOR MAIL (1000 lines) <<<