Date: Fri, 28 Oct 2005 19:41:47 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 85991 for review Message-ID: <200510281941.j9SJflbC047022@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=85991 Change 85991 by jhb@jhb_slimer on 2005/10/28 19:40:55 IFC @85989. Affected files ... .. //depot/projects/smpng/sys/conf/files#155 integrate .. //depot/projects/smpng/sys/conf/files.i386#88 integrate .. //depot/projects/smpng/sys/conf/files.sparc64#52 integrate .. //depot/projects/smpng/sys/dev/cardbus/cardbus.c#27 integrate .. //depot/projects/smpng/sys/dev/cardbus/cardbus_cis.c#25 integrate .. //depot/projects/smpng/sys/dev/cardbus/cardbusreg.h#6 integrate .. //depot/projects/smpng/sys/dev/cardbus/cardbusvar.h#10 integrate .. //depot/projects/smpng/sys/dev/en/midway.c#28 integrate .. //depot/projects/smpng/sys/dev/pci/pci.c#63 integrate .. //depot/projects/smpng/sys/dev/pci/pcireg.h#11 integrate .. //depot/projects/smpng/sys/dev/txp/if_txp.c#29 integrate .. //depot/projects/smpng/sys/dev/txp/if_txpreg.h#5 integrate .. //depot/projects/smpng/sys/dev/uart/uart_bus_ebus.c#8 integrate .. //depot/projects/smpng/sys/dev/uart/uart_bus_pccard.c#6 integrate .. //depot/projects/smpng/sys/dev/uart/uart_core.c#9 integrate .. //depot/projects/smpng/sys/gnu/fs/ext2fs/ext2_vnops.c#3 integrate .. //depot/projects/smpng/sys/i386/isa/pcf.c#9 delete .. //depot/projects/smpng/sys/modules/Makefile#109 integrate .. //depot/projects/smpng/sys/modules/i2c/controllers/pcf/Makefile#3 integrate .. //depot/projects/smpng/sys/netgraph/ng_bridge.h#4 integrate .. //depot/projects/smpng/sys/netgraph/ng_ksocket.h#9 integrate .. //depot/projects/smpng/sys/netgraph/ng_parse.h#8 integrate .. //depot/projects/smpng/sys/netgraph/ng_pppoe.h#11 integrate .. //depot/projects/smpng/sys/netgraph/ng_vlan.h#2 integrate .. //depot/projects/smpng/sys/pc98/conf/DEFAULTS#1 branch .. //depot/projects/smpng/sys/pc98/conf/GENERIC#58 integrate .. //depot/projects/smpng/sys/pci/if_vr.c#41 integrate .. //depot/projects/smpng/sys/pci/if_vrreg.h#10 integrate .. //depot/projects/smpng/sys/pci/if_wb.c#36 integrate .. //depot/projects/smpng/sys/pci/if_wbreg.h#6 integrate Differences ... ==== //depot/projects/smpng/sys/conf/files#155 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/files,v 1.1060 2005/10/23 00:22:02 njl Exp $ +# $FreeBSD: src/sys/conf/files,v 1.1061 2005/10/28 15:58:17 joerg Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -763,6 +763,7 @@ dev/pccbb/pccbb.c optional cbb dev/pccbb/pccbb_isa.c optional cbb isa dev/pccbb/pccbb_pci.c optional cbb pci +dev/pcf/pcf.c optional pcf dev/pci/eisa_pci.c optional pci eisa dev/pci/fixup_pci.c optional pci dev/pci/ignore_pci.c optional pci ==== //depot/projects/smpng/sys/conf/files.i386#88 (text+ko) ==== @@ -1,7 +1,7 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $FreeBSD: src/sys/conf/files.i386,v 1.541 2005/09/17 03:36:46 anholt Exp $ +# $FreeBSD: src/sys/conf/files.i386,v 1.542 2005/10/28 15:58:18 joerg Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -199,6 +199,7 @@ dev/mse/mse.c optional mse dev/mse/mse_isa.c optional mse isa dev/nve/if_nve.c optional nve pci +dev/pcf/pcf_isa.c optional pcf dev/ppc/ppc.c optional ppc dev/ppc/ppc_puc.c optional ppc puc pci dev/random/nehemiah.c optional random @@ -325,7 +326,6 @@ i386/isa/isa_dma.c optional isa i386/isa/nmi.c standard i386/isa/npx.c optional npx -i386/isa/pcf.c optional pcf i386/isa/pcvt/pcvt_drv.c optional vt i386/isa/pcvt/pcvt_ext.c optional vt i386/isa/pcvt/pcvt_kbd.c optional vt ==== //depot/projects/smpng/sys/conf/files.sparc64#52 (text+ko) ==== @@ -1,7 +1,7 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $FreeBSD: src/sys/conf/files.sparc64,v 1.73 2005/06/12 00:47:21 marcel Exp $ +# $FreeBSD: src/sys/conf/files.sparc64,v 1.74 2005/10/28 15:58:18 joerg Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -46,6 +46,8 @@ dev/ofw/openfirm.c standard dev/ofw/openfirmio.c standard dev/ofw/openpromio.c standard +dev/pcf/envctrl.c optional pcf +dev/pcf/pcf_ebus.c optional pcf ebus dev/sound/sbus/cs4231.c optional snd_audiocs ebus dev/sound/sbus/cs4231.c optional snd_audiocs sbus dev/syscons/scgfbrndr.c optional sc ==== //depot/projects/smpng/sys/dev/cardbus/cardbus.c#27 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/cardbus/cardbus.c,v 1.53 2005/09/27 13:33:46 ru Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/cardbus/cardbus.c,v 1.54 2005/10/28 06:03:53 imp Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -112,8 +112,8 @@ return; } - if (reg == CARDBUS_ROM_REG) - testval = CARDBUS_ROM_ADDRMASK; + if (reg == PCIR_BIOS) + testval = PCIM_BIOS_ADDR_MASK; else testval = ~0; @@ -435,50 +435,48 @@ device_t child; int cardattached = 0; int bus, slot, func; + int cardbusfunchigh = 0; cardbus_detach_card(cbdev); /* detach existing cards */ POWER_ENABLE_SOCKET(brdev, cbdev); bus = pcib_get_bus(cbdev); + slot = 0; /* For each function, set it up and try to attach a driver to it */ - for (slot = 0; slot <= CARDBUS_SLOTMAX; slot++) { - int cardbusfunchigh = 0; - for (func = 0; func <= cardbusfunchigh; func++) { - struct cardbus_devinfo *dinfo; + for (func = 0; func <= cardbusfunchigh; func++) { + struct cardbus_devinfo *dinfo; - dinfo = (struct cardbus_devinfo *) - pci_read_device(brdev, bus, slot, func, - sizeof(struct cardbus_devinfo)); - if (dinfo == NULL) - continue; - if (dinfo->pci.cfg.mfdev) - cardbusfunchigh = CARDBUS_FUNCMAX; + dinfo = (struct cardbus_devinfo *) + pci_read_device(brdev, bus, slot, func, + sizeof(struct cardbus_devinfo)); + if (dinfo == NULL) + continue; + if (dinfo->pci.cfg.mfdev) + cardbusfunchigh = PCI_FUNCMAX; - cardbus_device_setup_regs(brdev, bus, slot, func, - &dinfo->pci.cfg); - child = device_add_child(cbdev, NULL, -1); - if (child == NULL) { - DEVPRINTF((cbdev, "Cannot add child!\n")); - pci_freecfg((struct pci_devinfo *)dinfo); - continue; - } - 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; - } - cardbus_pickup_maps(cbdev, child); - cardbus_alloc_resources(cbdev, child); - pci_print_verbose(&dinfo->pci); - if (device_probe_and_attach(child) != 0) - cardbus_release_all_resources(cbdev, dinfo); - else - cardattached++; + cardbus_device_setup_regs(brdev, bus, slot, func, + &dinfo->pci.cfg); + child = device_add_child(cbdev, NULL, -1); + if (child == NULL) { + DEVPRINTF((cbdev, "Cannot add child!\n")); + pci_freecfg((struct pci_devinfo *)dinfo); + continue; + } + 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; } + cardbus_pickup_maps(cbdev, child); + cardbus_alloc_resources(cbdev, child); + pci_print_verbose(&dinfo->pci); + if (device_probe_and_attach(child) != 0) + cardbus_release_all_resources(cbdev, dinfo); + else + cardattached++; } - if (cardattached > 0) return (0); POWER_DISABLE_SOCKET(brdev, cbdev); ==== //depot/projects/smpng/sys/dev/cardbus/cardbus_cis.c#25 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/cardbus/cardbus_cis.c,v 1.50 2005/02/20 20:36:16 imp Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/cardbus/cardbus_cis.c,v 1.52 2005/10/28 05:55:52 imp Exp $"); /* * CIS Handling for the Cardbus Bus @@ -325,7 +325,7 @@ } /* Convert from BAR type to BAR offset */ - bar = CARDBUS_BASE0_REG + (bar - 1) * 4; + bar = PCIR_BAR(bar - 1); if (type == SYS_RES_MEMORY) { if (reg & TPL_BAR_REG_PREFETCHABLE) @@ -491,32 +491,27 @@ uint32_t testval; uint32_t size; struct resource *res; + uint32_t space; - switch (CARDBUS_CIS_SPACE(*start)) { - case CARDBUS_CIS_ASI_TUPLE: + space = *start & PCIM_CIS_ASI_MASK; + switch (space) { + case PCIM_CIS_ASI_TUPLE: /* CIS in PCI config space need no initialization */ return ((struct resource*)~0UL); - case CARDBUS_CIS_ASI_BAR0: - case CARDBUS_CIS_ASI_BAR1: - case CARDBUS_CIS_ASI_BAR2: - case CARDBUS_CIS_ASI_BAR3: - case CARDBUS_CIS_ASI_BAR4: - case CARDBUS_CIS_ASI_BAR5: - *rid = CARDBUS_BASE0_REG + (CARDBUS_CIS_SPACE(*start) - 1) * 4; + case PCIM_CIS_ASI_BAR0: + case PCIM_CIS_ASI_BAR1: + case PCIM_CIS_ASI_BAR2: + case PCIM_CIS_ASI_BAR3: + case PCIM_CIS_ASI_BAR4: + case PCIM_CIS_ASI_BAR5: + *rid = PCIR_BAR(space - PCIM_CIS_ASI_BAR0); break; - case CARDBUS_CIS_ASI_ROM: - *rid = CARDBUS_ROM_REG; -#if 0 - /* - * This mask doesn't contain the bit that actually enables - * the Option ROM. - */ - pci_write_config(child, *rid, CARDBUS_ROM_ADDRMASK, 4); -#endif + case PCIM_CIS_ASI_ROM: + *rid = PCIR_BIOS; break; default: device_printf(cbdev, "Unable to read CIS: Unknown space: %d\n", - CARDBUS_CIS_SPACE(*start)); + space); return (NULL); } @@ -528,7 +523,7 @@ * This bit has a different meaning depending if we are dealing * with a normal BAR or an Option ROM BAR. */ - if (((testval & 0x1) == 0x1) && (*rid != CARDBUS_ROM_REG)) { + if (((testval & 0x1) == 0x1) && (*rid != PCIR_BIOS)) { device_printf(cbdev, "CIS Space is IO, expecting memory.\n"); return (NULL); } @@ -546,13 +541,12 @@ return (NULL); } pci_write_config(child, *rid, - rman_get_start(res) | ((*rid == CARDBUS_ROM_REG)? - CARDBUS_ROM_ENABLE : 0), + rman_get_start(res) | ((*rid == PCIR_BIOS) ? PCIM_BIOS_ENABLE : 0), 4); PCI_ENABLE_IO(cbdev, child, SYS_RES_MEMORY); /* Flip to the right ROM image if CIS is in ROM */ - if (CARDBUS_CIS_SPACE(*start) == CARDBUS_CIS_ASI_ROM) { + if (space == PCIM_CIS_ASI_ROM) { bus_space_tag_t bt; bus_space_handle_t bh; uint32_t imagesize; @@ -565,7 +559,7 @@ bt = rman_get_bustag(res); bh = rman_get_bushandle(res); - imagenum = CARDBUS_CIS_ASI_ROM_IMAGE(*start); + imagenum = (*start & PCIM_CIS_ROM_MASK) >> 28; for (romnum = 0;; romnum++) { romsig = bus_space_read_2(bt, bh, imagebase + CARDBUS_EXROM_SIGNATURE); @@ -617,9 +611,9 @@ } imagebase += imagesize; } - *start = imagebase + CARDBUS_CIS_ADDR(*start); + *start = imagebase + (*start & PCIM_CIS_ADDR_MASK); } else { - *start = CARDBUS_CIS_ADDR(*start); + *start = *start & PCIM_CIS_ADDR_MASK; } return (res); @@ -658,7 +652,7 @@ bzero(tupledata, MAXTUPLESIZE); expect_linktarget = TRUE; - if ((start = pci_read_config(child, CARDBUS_CIS_REG, 4)) == 0) { + if ((start = pci_read_config(child, PCIR_CIS, 4)) == 0) { device_printf(cbdev, "CIS pointer is 0!\n"); return (ENXIO); } ==== //depot/projects/smpng/sys/dev/cardbus/cardbusreg.h#6 (text+ko) ==== @@ -23,40 +23,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/cardbus/cardbusreg.h,v 1.8 2005/01/13 19:12:10 imp Exp $ + * $FreeBSD: src/sys/dev/cardbus/cardbusreg.h,v 1.11 2005/10/28 06:03:53 imp Exp $ */ /* * Register definitions for the Cardbus Bus */ - -/* Cardbus bus constants */ -#define CARDBUS_SLOTMAX 0 -#define CARDBUS_FUNCMAX 7 - -/* Cardbus configuration header registers */ -#define CARDBUS_BASE0_REG 0x10 -#define CARDBUS_BASE1_REG 0x14 -#define CARDBUS_BASE2_REG 0x18 -#define CARDBUS_BASE3_REG 0x1C -#define CARDBUS_BASE4_REG 0x20 -#define CARDBUS_BASE5_REG 0x24 -#define CARDBUS_CIS_REG 0x28 -# define CARDBUS_CIS_ASIMASK 0x07 -# define CARDBUS_CIS_ADDRMASK 0x0ffffff8 -# define CARDBUS_CIS_ASI_TUPLE 0x00 -# define CARDBUS_CIS_ASI_BAR0 0x01 -# define CARDBUS_CIS_ASI_BAR1 0x02 -# define CARDBUS_CIS_ASI_BAR2 0x03 -# define CARDBUS_CIS_ASI_BAR3 0x04 -# define CARDBUS_CIS_ASI_BAR4 0x05 -# define CARDBUS_CIS_ASI_BAR5 0x06 -# define CARDBUS_CIS_ASI_ROM 0x07 -#define CARDBUS_ROM_REG 0x30 -# define CARDBUS_ROM_ENABLE 0x00000001 -# define CARDBUS_ROM_ADDRMASK 0xfffff800 - /* EXROM offsets for reading CIS */ #define CARDBUS_EXROM_SIGNATURE 0x00 #define CARDBUS_EXROM_DATA_PTR 0x18 @@ -72,16 +45,6 @@ #define CARDBUS_EXROM_DATA_CODE_TYPE 0x14 /* Code Type */ #define CARDBUS_EXROM_DATA_INDICATOR 0x15 /* Indicator */ -/* useful macros */ -#define CARDBUS_CIS_ADDR(x) \ - (CARDBUS_CIS_ADDRMASK & (x)) -#define CARDBUS_CIS_SPACE(x) \ - (CARDBUS_CIS_ASIMASK & (x)) -#define CARDBUS_CIS_ASI_BAR(x) \ - (((CARDBUS_CIS_ASIMASK & (x))-1)*4+0x10) -#define CARDBUS_CIS_ASI_ROM_IMAGE(x) \ - (((x) >> 28) & 0xf) - #define CARDBUS_MAPREG_MEM_ADDR_MASK 0x0ffffff0 #define CARDBUS_MAPREG_MEM_ADDR(mr) \ ((mr) & CARDBUS_MAPREG_MEM_ADDR_MASK) ==== //depot/projects/smpng/sys/dev/cardbus/cardbusvar.h#10 (text+ko) ==== @@ -23,18 +23,19 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/cardbus/cardbusvar.h,v 1.11 2005/02/06 21:03:13 imp Exp $ + * $FreeBSD: src/sys/dev/cardbus/cardbusvar.h,v 1.12 2005/10/28 05:29:41 imp Exp $ */ /* * Structure definitions for the Cardbus Bus driver */ -struct cardbus_devinfo { +struct cardbus_devinfo +{ struct pci_devinfo pci; uint8_t mprefetchable; /* bit mask of prefetchable BARs */ uint8_t mbelow1mb; /* bit mask of BARs which require below 1Mb */ uint8_t ibelow1mb; /* bit mask of BARs which require below 1Mb */ -#define BARBIT(RID) (1<<(((RID)-CARDBUS_BASE0_REG)/4)) +#define BARBIT(RID) (1<<(((RID)-PCIR_BARS)/4)) uint16_t mfrid; /* manufacturer id */ uint16_t prodid; /* product id */ u_int funcid; /* function id */ ==== //depot/projects/smpng/sys/dev/en/midway.c#28 (text+ko) ==== @@ -32,7 +32,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/en/midway.c,v 1.66 2005/08/09 10:19:46 rwatson Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/en/midway.c,v 1.67 2005/10/27 21:08:12 jhb Exp $"); /* * @@ -1869,7 +1869,9 @@ #ifdef ENABLE_BPF BPF_MTAP(sc->ifp, m); #endif + EN_UNLOCK(sc); atm_input(sc->ifp, &ah, m, vc->rxhand); + EN_LOCK(sc); } } ==== //depot/projects/smpng/sys/dev/pci/pci.c#63 (text+ko) ==== @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/pci/pci.c,v 1.300 2005/10/25 06:53:45 wpaul Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/pci/pci.c,v 1.301 2005/10/28 05:56:50 imp Exp $"); #include "opt_bus.h" @@ -913,8 +913,7 @@ if (progif & PCIP_STORAGE_IDE_MODEPRIM) { pci_add_map(pcib, bus, dev, b, s, f, PCIR_BAR(0), rl); pci_add_map(pcib, bus, dev, b, s, f, PCIR_BAR(1), rl); - } - else { + } else { rid = PCIR_BAR(0); resource_list_add(rl, type, rid, 0x1f0, 0x1f7, 8); resource_list_alloc(rl, bus, dev, type, &rid, 0x1f0, 0x1f7,8,0); @@ -925,8 +924,7 @@ if (progif & PCIP_STORAGE_IDE_MODESEC) { pci_add_map(pcib, bus, dev, b, s, f, PCIR_BAR(2), rl); pci_add_map(pcib, bus, dev, b, s, f, PCIR_BAR(3), rl); - } - else { + } else { rid = PCIR_BAR(2); resource_list_add(rl, type, rid, 0x170, 0x177, 8); resource_list_alloc(rl, bus, dev, type, &rid, 0x170, 0x177,8,0); ==== //depot/projects/smpng/sys/dev/pci/pcireg.h#11 (text+ko) ==== @@ -23,7 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/pci/pcireg.h,v 1.45 2005/06/05 23:08:59 imp Exp $ + * $FreeBSD: src/sys/dev/pci/pcireg.h,v 1.47 2005/10/28 06:02:51 imp Exp $ * */ @@ -111,11 +111,23 @@ #define PCIR_BARS 0x10 #define PCIR_BAR(x) (PCIR_BARS + (x) * 4) -#define PCIR_CARDBUSCIS 0x28 +#define PCIR_CIS 0x28 +#define PCIM_CIS_ASI_MASK 0x7 +#define PCIM_CIS_ASI_TUPLE 0 +#define PCIM_CIS_ASI_BAR0 1 +#define PCIM_CIS_ASI_BAR1 2 +#define PCIM_CIS_ASI_BAR2 3 +#define PCIM_CIS_ASI_BAR3 4 +#define PCIM_CIS_ASI_BAR4 5 +#define PCIM_CIS_ASI_BAR5 6 +#define PCIM_CIS_ASI_ROM 7 +#define PCIM_CIS_ADDR_MASK 0x0ffffff8 +#define PCIM_CIS_ROM_MASK 0xf0000000 #define PCIR_SUBVEND_0 0x2c #define PCIR_SUBDEV_0 0x2e #define PCIR_BIOS 0x30 #define PCIM_BIOS_ENABLE 0x01 +#define PCIM_BIOS_ADDR_MASK 0xfffff800 #define PCIR_CAP_PTR 0x34 #define PCIR_INTLINE 0x3c #define PCIR_INTPIN 0x3d ==== //depot/projects/smpng/sys/dev/txp/if_txp.c#29 (text+ko) ==== @@ -35,14 +35,14 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/txp/if_txp.c,v 1.36 2005/09/19 03:10:20 imp Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/txp/if_txp.c,v 1.37 2005/10/27 21:16:17 jhb Exp $"); /* * Driver for 3c990 (Typhoon) Ethernet ASIC */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/txp/if_txp.c,v 1.36 2005/09/19 03:10:20 imp Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/txp/if_txp.c,v 1.37 2005/10/27 21:16:17 jhb Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -92,7 +92,7 @@ #ifndef lint static const char rcsid[] = - "$FreeBSD: src/sys/dev/txp/if_txp.c,v 1.36 2005/09/19 03:10:20 imp Exp $"; + "$FreeBSD: src/sys/dev/txp/if_txp.c,v 1.37 2005/10/27 21:16:17 jhb Exp $"; #endif /* @@ -122,8 +122,10 @@ static int txp_shutdown(device_t); static int txp_ioctl(struct ifnet *, u_long, caddr_t); static void txp_start(struct ifnet *); +static void txp_start_locked(struct ifnet *); static void txp_stop(struct txp_softc *); static void txp_init(void *); +static void txp_init_locked(struct txp_softc *); static void txp_watchdog(struct ifnet *); static void txp_release_resources(struct txp_softc *); @@ -216,16 +218,17 @@ struct ifnet *ifp; u_int16_t p1; u_int32_t p2; - int unit, error = 0, rid; + int error = 0, rid; u_char eaddr[6]; sc = device_get_softc(dev); - unit = device_get_unit(dev); sc->sc_dev = dev; sc->sc_cold = 1; mtx_init(&sc->sc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, - MTX_DEF | MTX_RECURSE); + MTX_DEF); + callout_init_mtx(&sc->sc_tick, &sc->sc_mtx, 0); + /* * Map control/status registers. */ @@ -324,8 +327,7 @@ ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_mtu = ETHERMTU; - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST | - IFF_NEEDSGIANT; + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = txp_ioctl; ifp->if_start = txp_start; ifp->if_watchdog = txp_watchdog; @@ -339,9 +341,8 @@ * Attach us everywhere */ ether_ifattach(ifp, eaddr); - callout_handle_init(&sc->sc_tick); - error = bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_NET, + error = bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_NET | INTR_MPSAFE, txp_intr, sc, &sc->sc_intrhand); if (error) { @@ -369,8 +370,11 @@ sc = device_get_softc(dev); ifp = sc->sc_ifp; + TXP_LOCK(sc); txp_stop(sc); + TXP_UNLOCK(sc); txp_shutdown(dev); + callout_drain(&sc->sc_tick); ifmedia_removeall(&sc->sc_ifmedia); ether_ifdetach(ifp); @@ -657,6 +661,7 @@ u_int32_t isr; /* mask all interrupts */ + TXP_LOCK(sc); WRITE_REG(sc, TXP_IMR, TXP_INT_RESERVED | TXP_INT_SELF | TXP_INT_A2H_7 | TXP_INT_A2H_6 | TXP_INT_A2H_5 | TXP_INT_A2H_4 | TXP_INT_A2H_2 | TXP_INT_A2H_1 | TXP_INT_A2H_0 | @@ -689,7 +694,8 @@ /* unmask all interrupts */ WRITE_REG(sc, TXP_IMR, TXP_INT_A2H_3); - txp_start(sc->sc_ifp); + txp_start_locked(sc->sc_ifp); + TXP_UNLOCK(sc); return; } @@ -705,6 +711,7 @@ struct txp_swdesc *sd = NULL; u_int32_t roff, woff; + TXP_LOCK_ASSERT(sc); roff = *r->r_roff; woff = *r->r_woff; rxd = r->r_desc + (roff / sizeof(struct txp_rx_desc)); @@ -736,24 +743,13 @@ */ struct mbuf *mnew; - MGETHDR(mnew, M_DONTWAIT, MT_DATA); + mnew = m_devget(mtod(m, caddr_t), rxd->rx_len, + ETHER_ALIGN, ifp, NULL); + m_freem(m); if (mnew == NULL) { - m_freem(m); + ifp->if_ierrors++; goto next; } - if (m->m_len > (MHLEN - 2)) { - MCLGET(mnew, M_DONTWAIT); - if (!(mnew->m_flags & M_EXT)) { - m_freem(mnew); - m_freem(m); - goto next; - } - } - mnew->m_pkthdr.rcvif = ifp; - m_adj(mnew, 2); - mnew->m_pkthdr.len = mnew->m_len = m->m_len; - m_copydata(m, 0, m->m_pkthdr.len, mtod(mnew, caddr_t)); - m_freem(m); m = mnew; } #endif @@ -776,7 +772,9 @@ m, htons(rxd->rx_vlan >> 16), goto next); } + TXP_UNLOCK(sc); (*ifp->if_input)(ifp, m); + TXP_LOCK(sc); next: @@ -804,6 +802,7 @@ struct txp_swdesc *sd; u_int32_t i; + TXP_LOCK_ASSERT(sc); if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) return; @@ -815,13 +814,9 @@ if (sd->sd_mbuf != NULL) break; - MGETHDR(sd->sd_mbuf, M_DONTWAIT, MT_DATA); + sd->sd_mbuf = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); if (sd->sd_mbuf == NULL) - goto err_sd; - - MCLGET(sd->sd_mbuf, M_DONTWAIT); - if ((sd->sd_mbuf->m_flags & M_EXT) == 0) - goto err_mbuf; + return; sd->sd_mbuf->m_pkthdr.rcvif = ifp; sd->sd_mbuf->m_pkthdr.len = sd->sd_mbuf->m_len = MCLBYTES; @@ -841,11 +836,6 @@ sc->sc_rxbufprod = i; return; - -err_mbuf: - m_freem(sd->sd_mbuf); -err_sd: - free(sd, M_DEVBUF); } /* @@ -863,6 +853,7 @@ struct txp_swdesc *sd = sc->sc_txd + cons; struct mbuf *m; + TXP_LOCK_ASSERT(sc); while (cons != idx) { if (cnt == 0) break; @@ -905,6 +896,8 @@ sc = device_get_softc(dev); + TXP_LOCK(sc); + /* mask all interrupts */ WRITE_REG(sc, TXP_IMR, TXP_INT_SELF | TXP_INT_PCI_TABORT | TXP_INT_PCI_MABORT | @@ -914,6 +907,7 @@ txp_command(sc, TXP_CMD_TX_DISABLE, 0, 0, 0, NULL, NULL, NULL, 0); txp_command(sc, TXP_CMD_RX_DISABLE, 0, 0, 0, NULL, NULL, NULL, 0); txp_command(sc, TXP_CMD_HALT, 0, 0, 0, NULL, NULL, NULL, 0); + TXP_UNLOCK(sc); return(0); } @@ -1062,18 +1056,18 @@ { struct txp_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *)data; - int s, error = 0; + int error = 0; - s = splnet(); - switch(command) { case SIOCSIFFLAGS: + TXP_LOCK(sc); if (ifp->if_flags & IFF_UP) { - txp_init(sc); + txp_init_locked(sc); } else { if (ifp->if_drv_flags & IFF_DRV_RUNNING) txp_stop(sc); } + TXP_UNLOCK(sc); break; case SIOCADDMULTI: case SIOCDELMULTI: @@ -1081,7 +1075,9 @@ * Multicast list has changed; set the hardware * filter accordingly. */ + TXP_LOCK(sc); txp_set_filter(sc); + TXP_UNLOCK(sc); error = 0; break; case SIOCGIFMEDIA: @@ -1093,8 +1089,6 @@ break; } - (void)splx(s); - return(error); } @@ -1106,19 +1100,15 @@ struct ifnet *ifp; struct txp_swdesc *sd; + TXP_LOCK_ASSERT(sc); ifp = sc->sc_ifp; for (i = 0; i < RXBUF_ENTRIES; i++) { sd = sc->sc_rxbufs[i].rb_sd; - MGETHDR(sd->sd_mbuf, M_DONTWAIT, MT_DATA); + sd->sd_mbuf = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); if (sd->sd_mbuf == NULL) return(ENOBUFS); - MCLGET(sd->sd_mbuf, M_DONTWAIT); - if ((sd->sd_mbuf->m_flags & M_EXT) == 0) { - m_freem(sd->sd_mbuf); - return(ENOBUFS); - } sd->sd_mbuf->m_pkthdr.len = sd->sd_mbuf->m_len = MCLBYTES; sd->sd_mbuf->m_pkthdr.rcvif = ifp; @@ -1140,6 +1130,7 @@ int i; struct txp_swdesc *sd; + TXP_LOCK_ASSERT(sc); if (sc->sc_rxbufs == NULL) return; @@ -1163,12 +1154,22 @@ void *xsc; { struct txp_softc *sc; + + sc = xsc; + TXP_LOCK(sc); + txp_init_locked(sc); + TXP_UNLOCK(sc); +} + +static void +txp_init_locked(sc) + struct txp_softc *sc; +{ struct ifnet *ifp; u_int16_t p1; u_int32_t p2; - int s; - sc = xsc; + TXP_LOCK_ASSERT(sc); ifp = sc->sc_ifp; if (ifp->if_drv_flags & IFF_DRV_RUNNING) @@ -1176,8 +1177,6 @@ txp_stop(sc); - s = splnet(); - txp_command(sc, TXP_CMD_MAX_PKT_SIZE_WRITE, TXP_MAX_PKTLEN, 0, 0, NULL, NULL, NULL, 1); @@ -1209,9 +1208,7 @@ ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; ifp->if_timer = 0; - sc->sc_tick = timeout(txp_tick, sc, hz); - - splx(s); + callout_reset(&sc->sc_tick, hz, txp_tick, sc); } static void @@ -1222,9 +1219,8 @@ struct ifnet *ifp = sc->sc_ifp; struct txp_rsp_desc *rsp = NULL; struct txp_ext_desc *ext; - int s; - s = splnet(); + TXP_LOCK_ASSERT(sc); txp_rxbuf_reclaim(sc); if (txp_command2(sc, TXP_CMD_READ_STATISTICS, 0, 0, 0, NULL, 0, @@ -1250,8 +1246,7 @@ if (rsp != NULL) free(rsp, M_DEVBUF); - splx(s); - sc->sc_tick = timeout(txp_tick, sc, hz); + callout_reset(&sc->sc_tick, hz, txp_tick, sc); return; } @@ -1260,6 +1255,18 @@ txp_start(ifp) struct ifnet *ifp; { + struct txp_softc *sc; + + sc = ifp->if_softc; + TXP_LOCK(sc); + txp_start_locked(ifp); + TXP_UNLOCK(sc); +} + +static void +txp_start_locked(ifp) + struct ifnet *ifp; +{ struct txp_softc *sc = ifp->if_softc; struct txp_tx_ring *r = &sc->sc_txhir; struct txp_tx_desc *txd; @@ -1269,6 +1276,7 @@ u_int32_t firstprod, firstcnt, prod, cnt; struct m_tag *mtag; + TXP_LOCK_ASSERT(sc); if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING) return; @@ -1572,11 +1580,12 @@ { struct ifnet *ifp; + TXP_LOCK_ASSERT(sc); ifp = sc->sc_ifp; ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); - untimeout(txp_tick, sc, sc->sc_tick); + callout_stop(&sc->sc_tick); txp_command(sc, TXP_CMD_TX_DISABLE, 0, 0, 0, NULL, NULL, NULL, 1); txp_command(sc, TXP_CMD_RX_DISABLE, 0, 0, 0, NULL, NULL, NULL, 1); @@ -1601,8 +1610,11 @@ struct ifmedia *ifm = &sc->sc_ifmedia; u_int16_t new_xcvr; - if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER) + TXP_LOCK(sc); + if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER) { + TXP_UNLOCK(sc); return (EINVAL); + } if (IFM_SUBTYPE(ifm->ifm_media) == IFM_10_T) { if ((ifm->ifm_media & IFM_GMASK) == IFM_FDX) @@ -1616,16 +1628,21 @@ new_xcvr = TXP_XCVR_100_HDX; } else if (IFM_SUBTYPE(ifm->ifm_media) == IFM_AUTO) { new_xcvr = TXP_XCVR_AUTO; - } else + } else { + TXP_UNLOCK(sc); return (EINVAL); + } /* nothing to do */ - if (sc->sc_xcvr == new_xcvr) + if (sc->sc_xcvr == new_xcvr) { + TXP_UNLOCK(sc); return (0); + } txp_command(sc, TXP_CMD_XCVR_SELECT, new_xcvr, 0, 0, NULL, NULL, NULL, 0); sc->sc_xcvr = new_xcvr; + TXP_UNLOCK(sc); return (0); } @@ -1642,6 +1659,7 @@ ifmr->ifm_status = IFM_AVALID; ifmr->ifm_active = IFM_ETHER; + TXP_LOCK(sc); if (txp_command(sc, TXP_CMD_PHY_MGMT_READ, 0, MII_BMSR, 0, &bmsr, NULL, NULL, 1)) goto bail; @@ -1656,6 +1674,7 @@ if (txp_command(sc, TXP_CMD_PHY_MGMT_READ, 0, MII_ANLPAR, 0, &anlpar, NULL, NULL, 1)) goto bail; + TXP_UNLOCK(sc); if (bmsr & BMSR_LINK) ifmr->ifm_status |= IFM_ACTIVE; @@ -1692,6 +1711,7 @@ return; bail: + TXP_UNLOCK(sc); ifmr->ifm_active |= IFM_NONE; ifmr->ifm_status &= ~IFM_AVALID; } ==== //depot/projects/smpng/sys/dev/txp/if_txpreg.h#5 (text+ko) ==== @@ -1,5 +1,5 @@ /* $OpenBSD: if_txpreg.h,v 1.30 2001/06/23 04:18:02 jason Exp $ */ -/* $FreeBSD: src/sys/dev/txp/if_txpreg.h,v 1.5 2005/10/03 15:47:15 jhb Exp $ */ +/* $FreeBSD: src/sys/dev/txp/if_txpreg.h,v 1.6 2005/10/27 21:16:17 jhb Exp $ */ /*- * Copyright (c) 2001 Aaron Campbell <aaron@monkey.org>. @@ -606,7 +606,7 @@ struct txp_cmd_ring sc_cmdring; struct txp_rsp_ring sc_rspring; struct txp_swdesc sc_txd[TX_ENTRIES]; - struct callout_handle sc_tick; + struct callout sc_tick; struct ifmedia sc_ifmedia; struct txp_tx_ring sc_txhir, sc_txlor; struct txp_rxbuf_desc *sc_rxbufs; @@ -639,6 +639,10 @@ #define READ_REG(sc,reg) \ bus_space_read_4((sc)->sc_bt, (sc)->sc_bh, reg) +#define TXP_LOCK(sc) mtx_lock(&(sc)->sc_mtx) +#define TXP_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx) +#define TXP_LOCK_ASSERT(sc) mtx_assert(&(sc)->sc_mtx, MA_OWNED) + >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200510281941.j9SJflbC047022>