Date: Wed, 1 Aug 2007 16:22:35 GMT From: Rui Paulo <rpaulo@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 124476 for review Message-ID: <200708011622.l71GMZYi040730@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=124476 Change 124476 by rpaulo@rpaulo_epsilon on 2007/08/01 16:21:53 IFC Affected files ... .. //depot/projects/soc2007/rpaulo-macbook/arm/arm/trap.c#3 integrate .. //depot/projects/soc2007/rpaulo-macbook/arm/at91/at91rm92reg.h#2 integrate .. //depot/projects/soc2007/rpaulo-macbook/arm/at91/kb920x_machdep.c#3 integrate .. //depot/projects/soc2007/rpaulo-macbook/arm/at91/ohci_atmelarm.c#2 integrate .. //depot/projects/soc2007/rpaulo-macbook/arm/conf/KB920X#2 integrate .. //depot/projects/soc2007/rpaulo-macbook/conf/kern.pre.mk#6 integrate .. //depot/projects/soc2007/rpaulo-macbook/conf/options.ia64#2 integrate .. //depot/projects/soc2007/rpaulo-macbook/dev/acpica/acpi_hpet.c#5 integrate .. //depot/projects/soc2007/rpaulo-macbook/dev/acpica/acpi_timer.c#3 integrate .. //depot/projects/soc2007/rpaulo-macbook/dev/aic7xxx/aic7xxx.c#3 integrate .. //depot/projects/soc2007/rpaulo-macbook/dev/aic7xxx/aic_osm_lib.c#2 integrate .. //depot/projects/soc2007/rpaulo-macbook/dev/arcmsr/arcmsr.c#3 integrate .. //depot/projects/soc2007/rpaulo-macbook/dev/bce/if_bce.c#6 integrate .. //depot/projects/soc2007/rpaulo-macbook/dev/bce/if_bcefw.h#4 integrate .. //depot/projects/soc2007/rpaulo-macbook/dev/bce/if_bcereg.h#6 integrate .. //depot/projects/soc2007/rpaulo-macbook/dev/usb/umodem.c#6 integrate .. //depot/projects/soc2007/rpaulo-macbook/ia64/ia64/db_machdep.c#3 integrate .. //depot/projects/soc2007/rpaulo-macbook/ia64/ia64/exception.S#4 integrate .. //depot/projects/soc2007/rpaulo-macbook/ia64/ia64/interrupt.c#3 integrate .. //depot/projects/soc2007/rpaulo-macbook/ia64/ia64/machdep.c#6 integrate .. //depot/projects/soc2007/rpaulo-macbook/ia64/ia64/mp_machdep.c#3 integrate .. //depot/projects/soc2007/rpaulo-macbook/ia64/ia64/nexus.c#2 integrate .. //depot/projects/soc2007/rpaulo-macbook/ia64/ia64/pmap.c#6 integrate .. //depot/projects/soc2007/rpaulo-macbook/ia64/ia64/sapic.c#2 integrate .. //depot/projects/soc2007/rpaulo-macbook/ia64/include/atomic.h#2 integrate .. //depot/projects/soc2007/rpaulo-macbook/ia64/include/intr.h#2 integrate .. //depot/projects/soc2007/rpaulo-macbook/ia64/include/md_var.h#2 integrate .. //depot/projects/soc2007/rpaulo-macbook/ia64/include/sapicvar.h#2 integrate .. //depot/projects/soc2007/rpaulo-macbook/net/if_bridge.c#5 integrate .. //depot/projects/soc2007/rpaulo-macbook/net/if_bridgevar.h#4 integrate .. //depot/projects/soc2007/rpaulo-macbook/net/if_lagg.c#9 integrate .. //depot/projects/soc2007/rpaulo-macbook/net/if_lagg.h#7 integrate .. //depot/projects/soc2007/rpaulo-macbook/netinet/tcp_fsm.h#3 integrate .. //depot/projects/soc2007/rpaulo-macbook/netinet/tcp_input.c#12 integrate .. //depot/projects/soc2007/rpaulo-macbook/netinet/tcp_subr.c#12 integrate .. //depot/projects/soc2007/rpaulo-macbook/netinet/tcp_syncache.c#9 integrate .. //depot/projects/soc2007/rpaulo-macbook/netinet/tcp_timer.h#3 integrate .. //depot/projects/soc2007/rpaulo-macbook/netinet/tcp_usrreq.c#8 integrate .. //depot/projects/soc2007/rpaulo-macbook/netipx/spx_debug.c#3 integrate .. //depot/projects/soc2007/rpaulo-macbook/netipx/spx_debug.h#3 integrate .. //depot/projects/soc2007/rpaulo-macbook/pc98/cbus/clock.c#4 integrate .. //depot/projects/soc2007/rpaulo-macbook/powerpc/powerpc/trap.c#3 integrate Differences ... ==== //depot/projects/soc2007/rpaulo-macbook/arm/arm/trap.c#3 (text+ko) ==== @@ -82,7 +82,7 @@ #include "opt_ktrace.h" #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/arm/arm/trap.c,v 1.34 2007/06/04 21:38:45 attilio Exp $"); +__FBSDID("$FreeBSD: src/sys/arm/arm/trap.c,v 1.35 2007/07/31 17:09:05 cognet Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -943,7 +943,7 @@ case 0: #ifdef __ARMEB__ if ((insn & 0x000fffff) == SYS___syscall && - (code != SYS_lseek)) { + code != SYS_freebsd6_lseek && code != SYS_lseek) { /* * 64-bit return, 32-bit syscall. Fixup byte order */ ==== //depot/projects/soc2007/rpaulo-macbook/arm/at91/at91rm92reg.h#2 (text) ==== @@ -22,7 +22,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* $FreeBSD: src/sys/arm/at91/at91rm92reg.h,v 1.4 2006/08/28 20:05:00 cognet Exp $ */ +/* $FreeBSD: src/sys/arm/at91/at91rm92reg.h,v 1.5 2007/07/31 17:43:18 imp Exp $ */ #ifndef AT91RM92REG_H_ #define AT91RM92REG_H_ @@ -336,7 +336,8 @@ #define AT91RM92_TC1C1_BASE 0xffa4040 #define AT91RM92_TC1C2_BASE 0xffa4080 -#define AT91RM92_OHCI_BASE 0x00300000 +#define AT91RM92_OHCI_BASE 0xdfe00000 +#define AT91RM92_OHCI_PA_BASE 0x00300000 #define AT91RM92_OHCI_SIZE 0x00100000 #define AT91C_MASTER_CLOCK 60000000 ==== //depot/projects/soc2007/rpaulo-macbook/arm/at91/kb920x_machdep.c#3 (text) ==== @@ -48,7 +48,7 @@ #include "opt_at91.h" #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/arm/at91/kb920x_machdep.c,v 1.22 2007/05/23 13:20:50 cognet Exp $"); +__FBSDID("$FreeBSD: src/sys/arm/at91/kb920x_machdep.c,v 1.23 2007/07/31 17:43:18 imp Exp $"); #define _ARM32_BUS_DMA_PRIVATE #include <sys/param.h> @@ -165,14 +165,14 @@ * initialization is done. However, the AT91 resource allocation * system doesn't know how to use pmap_mapdev() yet. */ -#if 0 +#if 1 { /* * Add the ohci controller, and anything else that might be * on this chip select for a VA/PA mapping. */ AT91RM92_OHCI_BASE, - AT91RM92_OHCI_BASE, + AT91RM92_OHCI_PA_BASE, AT91RM92_OHCI_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, ==== //depot/projects/soc2007/rpaulo-macbook/arm/at91/ohci_atmelarm.c#2 (text) ==== @@ -23,12 +23,14 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/arm/at91/ohci_atmelarm.c,v 1.2 2007/03/01 09:10:55 piso Exp $"); +__FBSDID("$FreeBSD: src/sys/arm/at91/ohci_atmelarm.c,v 1.3 2007/07/31 17:43:18 imp Exp $"); #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> +#include <sys/lock.h> #include <sys/module.h> +#include <sys/mutex.h> #include <sys/bus.h> #include <sys/queue.h> #include <machine/bus.h> @@ -99,6 +101,30 @@ } device_set_ivars(sc->sc_ohci.sc_bus.bdev, &sc->sc_ohci.sc_bus); + /* Allocate a parent dma tag for DMA maps */ + err = bus_dma_tag_create(bus_get_dma_tag(dev), 1, 0, + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, + BUS_SPACE_MAXSIZE_32BIT, USB_DMA_NSEG, BUS_SPACE_MAXSIZE_32BIT, 0, + NULL, NULL, &sc->sc_ohci.sc_bus.parent_dmatag); + if (err) { + device_printf(dev, "Could not allocate parent DMA tag (%d)\n", + err); + err = ENXIO; + goto error; + } + + /* Allocate a dma tag for transfer buffers */ + err = bus_dma_tag_create(sc->sc_ohci.sc_bus.parent_dmatag, 1, 0, + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, + BUS_SPACE_MAXSIZE_32BIT, USB_DMA_NSEG, BUS_SPACE_MAXSIZE_32BIT, 0, + busdma_lock_mutex, &Giant, &sc->sc_ohci.sc_bus.buffer_dmatag); + if (err) { + device_printf(dev, "Could not allocate transfer tag (%d)\n", + err); + err = ENXIO; + goto error; + } + err = bus_setup_intr(dev, sc->sc_ohci.irq_res, INTR_TYPE_BIO, NULL, ohci_intr, sc, &sc->sc_ohci.ih); if (err) { @@ -158,6 +184,12 @@ bus_teardown_intr(dev, sc->sc_ohci.irq_res, sc->sc_ohci.ih); sc->sc_ohci.ih = NULL; } + + if (sc->sc_ohci.sc_bus.parent_dmatag != NULL) + bus_dma_tag_destroy(sc->sc_ohci.sc_bus.parent_dmatag); + if (sc->sc_ohci.sc_bus.buffer_dmatag != NULL) + bus_dma_tag_destroy(sc->sc_ohci.sc_bus.buffer_dmatag); + if (sc->sc_ohci.sc_bus.bdev) { device_delete_child(dev, sc->sc_ohci.sc_bus.bdev); sc->sc_ohci.sc_bus.bdev = NULL; ==== //depot/projects/soc2007/rpaulo-macbook/arm/conf/KB920X#2 (text) ==== @@ -16,7 +16,7 @@ # If you are in doubt as to the purpose or necessity of a line, check first # in NOTES. # -# $FreeBSD: src/sys/arm/conf/KB920X,v 1.12 2007/03/23 23:47:59 imp Exp $ +# $FreeBSD: src/sys/arm/conf/KB920X,v 1.13 2007/07/31 17:45:54 imp Exp $ machine arm ident KB920X @@ -93,3 +93,47 @@ device icee device bpf +# USB support +device ohci # OHCI localbus->USB interface +device usb # USB Bus (required) +#device udbp # USB Double Bulk Pipe devices +device ugen # Generic +device uhid # "Human Interface Devices" +device ulpt # Printer +device umass # Disks/Mass storage - Requires scbus and da +device ural # Ralink Technology RT2500USB wireless NICs +device rum # Ralink Technology RT2501USB wireless NICs +device urio # Diamond Rio 500 MP3 player +device uscanner # Scanners +# USB Ethernet, requires miibus +device miibus +device aue # ADMtek USB Ethernet +device axe # ASIX Electronics USB Ethernet +device cdce # Generic USB over Ethernet +device cue # CATC USB Ethernet +device kue # Kawasaki LSI USB Ethernet +device rue # RealTek RTL8150 USB Ethernet +device udav +# usb serial +device ucom +device uark +device ubsa +device ubser +device uftdi +device uipaq +device uplcom +device uvisor +device uvscom +# SCSI peripherals +device scbus # SCSI bus (required for SCSI) +device da # Direct Access (disks) +device cd # CD +device pass # Passthrough device (direct SCSI access) +# Wireless NIC cards +device wlan # 802.11 support +device wlan_wep # 802.11 WEP support +device wlan_ccmp # 802.11 CCMP support +device wlan_tkip # 802.11 TKIP support +device wlan_amrr # AMRR transmit rate control algorithm +device wlan_scan_ap # 802.11 AP mode scanning +device wlan_scan_sta # 802.11 STA mode scanning ==== //depot/projects/soc2007/rpaulo-macbook/conf/kern.pre.mk#6 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/kern.pre.mk,v 1.90 2007/07/12 00:01:53 jfv Exp $ +# $FreeBSD: src/sys/conf/kern.pre.mk,v 1.91 2007/07/31 03:15:32 marcel Exp $ # Part of a unified Makefile for building kernels. This part contains all # of the definitions that need to be before %BEFORE_DEPEND. @@ -88,7 +88,7 @@ CFLAGS+= --param inline-unit-growth=100 CFLAGS+= --param large-function-growth=1000 .if ${MACHINE_ARCH} == "amd64" || ${MACHINE} == "i386" || \ - ${MACHINE_ARCH} == "sparc64" + ${MACHINE_ARCH} == "ia64" || ${MACHINE_ARCH} == "sparc64" WERROR?= -Werror .endif .endif ==== //depot/projects/soc2007/rpaulo-macbook/conf/options.ia64#2 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/options.ia64,v 1.27 2006/04/24 23:31:50 marcel Exp $ +# $FreeBSD: src/sys/conf/options.ia64,v 1.28 2007/07/30 22:42:33 marcel Exp $ # Options specific to the ia64 platform kernels ITANIUM opt_global.h @@ -11,6 +11,8 @@ COMPAT_IA32 opt_compat.h +EXCEPTION_TRACING opt_xtrace.h + VGA_ALT_SEQACCESS opt_vga.h VGA_DEBUG opt_vga.h VGA_NO_FONT_LOADING opt_vga.h ==== //depot/projects/soc2007/rpaulo-macbook/dev/acpica/acpi_hpet.c#5 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_hpet.c,v 1.10 2007/07/22 20:45:27 njl Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_hpet.c,v 1.11 2007/07/30 15:21:26 njl Exp $"); #include "opt_acpi.h" #include <sys/param.h> @@ -70,7 +70,7 @@ .tc_get_timecount = hpet_get_timecount, .tc_counter_mask = ~0u, .tc_name = "HPET", - .tc_quality = 2000, + .tc_quality = 900, }; static u_int ==== //depot/projects/soc2007/rpaulo-macbook/dev/acpica/acpi_timer.c#3 (text+ko) ==== @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_timer.c,v 1.41 2007/06/04 18:25:03 dwmalone Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_timer.c,v 1.42 2007/07/30 15:21:26 njl Exp $"); #include "opt_acpi.h" #include <sys/param.h> @@ -96,7 +96,7 @@ 0, /* no default counter_mask */ 0, /* no default frequency */ "ACPI", /* name */ - 1000 /* quality */ + -1 /* quality (chosen later) */ }; static u_int @@ -185,9 +185,11 @@ if (j == 10) { acpi_timer_timecounter.tc_name = "ACPI-fast"; acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount; + acpi_timer_timecounter.tc_quality = 1000; } else { acpi_timer_timecounter.tc_name = "ACPI-safe"; acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount_safe; + acpi_timer_timecounter.tc_quality = 850; } tc_init(&acpi_timer_timecounter); ==== //depot/projects/soc2007/rpaulo-macbook/dev/aic7xxx/aic7xxx.c#3 (text+ko) ==== @@ -46,7 +46,7 @@ #include "aicasm/aicasm_insformat.h" #else #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/aic7xxx/aic7xxx.c,v 1.111 2007/04/19 18:53:52 scottl Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/aic7xxx/aic7xxx.c,v 1.112 2007/07/31 20:11:02 scottl Exp $"); #include <dev/aic7xxx/aic7xxx_osm.h> #include <dev/aic7xxx/aic7xxx_inline.h> #include <dev/aic7xxx/aicasm/aicasm_insformat.h> @@ -6932,7 +6932,6 @@ struct ahc_softc *ahc; ahc = scb->ahc_softc; - ahc_lock(ahc); if ((scb->flags & SCB_ACTIVE) != 0) { if ((scb->flags & SCB_TIMEDOUT) == 0) { LIST_INSERT_HEAD(&ahc->timedout_scbs, scb, @@ -6941,7 +6940,6 @@ } ahc_wakeup_recovery_thread(ahc); } - ahc_unlock(ahc); } /* ==== //depot/projects/soc2007/rpaulo-macbook/dev/aic7xxx/aic_osm_lib.c#2 (text+ko) ==== @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/aic7xxx/aic_osm_lib.c,v 1.5 2007/04/17 06:26:25 scottl Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/aic7xxx/aic_osm_lib.c,v 1.6 2007/07/31 20:11:03 scottl Exp $"); static void aic_recovery_thread(void *arg); @@ -120,9 +120,7 @@ if ((aic->flags & AIC_SHUTDOWN_RECOVERY) != 0) break; - aic_unlock(aic); aic_recover_commands(aic); - aic_lock(aic); } aic->platform_data->recovery_thread = NULL; wakeup(aic->platform_data); ==== //depot/projects/soc2007/rpaulo-macbook/dev/arcmsr/arcmsr.c#3 (text+ko) ==== @@ -56,7 +56,7 @@ ** and cause g_vfs_done() read write error ****************************************************************************************** -* $FreeBSD: src/sys/dev/arcmsr/arcmsr.c,v 1.23 2007/06/17 05:55:48 scottl Exp $ +* $FreeBSD: src/sys/dev/arcmsr/arcmsr.c,v 1.24 2007/07/31 20:16:50 scottl Exp $ */ #include <sys/param.h> #include <sys/systm.h> @@ -103,6 +103,7 @@ #include <dev/pci/pcivar.h> #include <dev/pci/pcireg.h> #define ARCMSR_LOCK_INIT(l, s) mtx_init(l, s, NULL, MTX_DEF|MTX_RECURSE) + #define ARCMSR_LOCK_DESTROY(l) mtx_destroy(l) #define ARCMSR_LOCK_ACQUIRE(l) mtx_lock(l) #define ARCMSR_LOCK_RELEASE(l) mtx_unlock(l) #define ARCMSR_LOCK_TRY(l) mtx_trylock(l) @@ -113,6 +114,7 @@ #include <pci/pcivar.h> #include <pci/pcireg.h> #define ARCMSR_LOCK_INIT(l, s) simple_lock_init(l) + #define ARCMSR_LOCK_DESTROY(l) #define ARCMSR_LOCK_ACQUIRE(l) simple_lock(l) #define ARCMSR_LOCK_RELEASE(l) simple_unlock(l) #define ARCMSR_LOCK_TRY(l) simple_lock_try(l) @@ -417,7 +419,6 @@ bus_dmamap_sync(acb->dm_segs_dmat, srb->dm_segs_dmamap, op); bus_dmamap_unload(acb->dm_segs_dmat, srb->dm_segs_dmamap); } - ARCMSR_LOCK_ACQUIRE(&acb->workingQ_done_lock); if(stand_flag==1) { atomic_subtract_int(&acb->srboutstandingcount, 1); if((acb->acb_flags & ACB_F_CAM_DEV_QFRZN) && ( @@ -431,7 +432,6 @@ acb->srbworkingQ[acb->workingsrb_doneindex]=srb; acb->workingsrb_doneindex++; acb->workingsrb_doneindex %= ARCMSR_MAX_FREESRB_NUM; - ARCMSR_LOCK_RELEASE(&acb->workingQ_done_lock); xpt_done(pccb); return; } @@ -671,6 +671,18 @@ ********************************************************************** ********************************************************************** */ +static void arcmsr_intr_handler(void *arg) +{ + struct AdapterControlBlock *acb=(struct AdapterControlBlock *)arg; + + ARCMSR_LOCK_ACQUIRE(&acb->qbuffer_lock); + arcmsr_interrupt(acb); + ARCMSR_LOCK_RELEASE(&acb->qbuffer_lock); +} +/* +********************************************************************** +********************************************************************** +*/ static void arcmsr_interrupt(void *arg) { struct AdapterControlBlock *acb=(struct AdapterControlBlock *)arg; @@ -1035,7 +1047,6 @@ struct CommandControlBlock *srb=NULL; u_int32_t workingsrb_startindex, workingsrb_doneindex; - ARCMSR_LOCK_ACQUIRE(&acb->workingQ_start_lock); workingsrb_doneindex=acb->workingsrb_doneindex; workingsrb_startindex=acb->workingsrb_startindex; srb=acb->srbworkingQ[workingsrb_startindex]; @@ -1046,7 +1057,6 @@ } else { srb=NULL; } - ARCMSR_LOCK_RELEASE(&acb->workingQ_start_lock); return(srb); } /* @@ -1970,7 +1980,7 @@ /*maxsegsz*/ BUS_SPACE_MAXSIZE_32BIT, /*flags*/ 0, /*lockfunc*/ busdma_lock_mutex, - /*lockarg*/ &Giant, + /*lockarg*/ &acb->qbuffer_lock, &acb->dm_segs_dmat) != 0) #else if(bus_dma_tag_create( /*parent_dmat*/ acb->parent_dmat, @@ -2114,9 +2124,10 @@ printf("arcmsr%d: cannot allocate softc\n", unit); return (ENOMEM); } - bzero(acb, sizeof(struct AdapterControlBlock)); + ARCMSR_LOCK_INIT(&acb->qbuffer_lock, "arcmsr Q buffer lock"); if(arcmsr_initialize(dev)) { printf("arcmsr%d: initialize failure!\n", unit); + ARCMSR_LOCK_DESTROY(&acb->qbuffer_lock); return ENXIO; } /* After setting up the adapter, map our interrupt */ @@ -2124,8 +2135,9 @@ irqres=bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0ul, ~0ul, 1, RF_SHAREABLE | RF_ACTIVE); if(irqres == NULL || bus_setup_intr(dev, irqres, INTR_TYPE_CAM|INTR_ENTROPY|INTR_MPSAFE - , NULL, arcmsr_interrupt, acb, &acb->ih)) { + , NULL, arcmsr_intr_handler, acb, &acb->ih)) { arcmsr_free_resource(acb); + ARCMSR_LOCK_DESTROY(&acb->qbuffer_lock); printf("arcmsr%d: unable to register interrupt handler!\n", unit); return ENXIO; } @@ -2142,23 +2154,27 @@ if(devq == NULL) { arcmsr_free_resource(acb); bus_release_resource(dev, SYS_RES_IRQ, 0, acb->irqres); + ARCMSR_LOCK_DESTROY(&acb->qbuffer_lock); printf("arcmsr%d: cam_simq_alloc failure!\n", unit); return ENXIO; } acb->psim=cam_sim_alloc(arcmsr_action, arcmsr_poll, - "arcmsr", acb, unit, &Giant, 1, + "arcmsr", acb, unit, &acb->qbuffer_lock, 1, ARCMSR_MAX_OUTSTANDING_CMD, devq); if(acb->psim == NULL) { arcmsr_free_resource(acb); bus_release_resource(dev, SYS_RES_IRQ, 0, acb->irqres); cam_simq_free(devq); + ARCMSR_LOCK_DESTROY(&acb->qbuffer_lock); printf("arcmsr%d: cam_sim_alloc failure!\n", unit); return ENXIO; } + ARCMSR_LOCK_ACQUIRE(&acb->qbuffer_lock); if(xpt_bus_register(acb->psim, dev, 0) != CAM_SUCCESS) { arcmsr_free_resource(acb); bus_release_resource(dev, SYS_RES_IRQ, 0, acb->irqres); cam_sim_free(acb->psim, /*free_devq*/TRUE); + ARCMSR_LOCK_DESTROY(&acb->qbuffer_lock); printf("arcmsr%d: xpt_bus_register failure!\n", unit); return ENXIO; } @@ -2170,12 +2186,10 @@ bus_release_resource(dev, SYS_RES_IRQ, 0, acb->irqres); xpt_bus_deregister(cam_sim_path(acb->psim)); cam_sim_free(acb->psim, /* free_simq */ TRUE); + ARCMSR_LOCK_DESTROY(&acb->qbuffer_lock); printf("arcmsr%d: xpt_create_path failure!\n", unit); return ENXIO; } - ARCMSR_LOCK_INIT(&acb->workingQ_done_lock, "arcmsr done working Q lock"); - ARCMSR_LOCK_INIT(&acb->workingQ_start_lock, "arcmsr start working Q lock"); - ARCMSR_LOCK_INIT(&acb->qbuffer_lock, "arcmsr Q buffer lock"); /* **************************************************** */ @@ -2185,6 +2199,7 @@ csa.callback=arcmsr_async; csa.callback_arg=acb->psim; xpt_action((union ccb *)&csa); + ARCMSR_LOCK_RELEASE(&acb->qbuffer_lock); /* Create the control device. */ acb->ioctl_dev=make_dev(&arcmsr_cdevsw , unit @@ -2256,6 +2271,7 @@ struct AdapterControlBlock *acb=(struct AdapterControlBlock *)device_get_softc(dev); /* stop adapter background rebuild */ + ARCMSR_LOCK_ACQUIRE(&acb->qbuffer_lock); arcmsr_stop_adapter_bgrb(acb); arcmsr_flush_adapter_cache(acb); /* disable all outbound interrupt */ @@ -2289,6 +2305,7 @@ atomic_set_int(&acb->srboutstandingcount, 0); acb->workingsrb_doneindex=0; acb->workingsrb_startindex=0; + ARCMSR_LOCK_RELEASE(&acb->qbuffer_lock); return; } /* @@ -2299,15 +2316,18 @@ { struct AdapterControlBlock *acb=(struct AdapterControlBlock *)device_get_softc(dev); + bus_teardown_intr(dev, acb->irqres, acb->ih); arcmsr_shutdown(dev); arcmsr_free_resource(acb); bus_release_resource(dev, SYS_RES_MEMORY, PCIR_BAR(0), acb->sys_res_arcmsr); - bus_teardown_intr(dev, acb->irqres, acb->ih); bus_release_resource(dev, SYS_RES_IRQ, 0, acb->irqres); + ARCMSR_LOCK_ACQUIRE(&acb->qbuffer_lock); xpt_async(AC_LOST_DEVICE, acb->ppath, NULL); xpt_free_path(acb->ppath); xpt_bus_deregister(cam_sim_path(acb->psim)); cam_sim_free(acb->psim, TRUE); + ARCMSR_LOCK_RELEASE(&acb->qbuffer_lock); + ARCMSR_LOCK_DESTROY(&acb->qbuffer_lock); return (0); } ==== //depot/projects/soc2007/rpaulo-macbook/dev/bce/if_bce.c#6 (text) ==== @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/bce/if_bce.c,v 1.33 2007/06/16 02:27:03 davidch Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/bce/if_bce.c,v 1.34 2007/07/31 00:06:04 davidch Exp $"); /* * The following controllers are supported by this driver: @@ -288,21 +288,22 @@ static int bce_get_buf (struct bce_softc *, struct mbuf *, u16 *, u16 *, u32 *); static int bce_init_tx_chain (struct bce_softc *); +static void bce_fill_rx_chain (struct bce_softc *); static int bce_init_rx_chain (struct bce_softc *); static void bce_free_rx_chain (struct bce_softc *); static void bce_free_tx_chain (struct bce_softc *); -static int bce_tx_encap (struct bce_softc *, struct mbuf **); +static int bce_tx_encap (struct bce_softc *, struct mbuf **); static void bce_start_locked (struct ifnet *); static void bce_start (struct ifnet *); static int bce_ioctl (struct ifnet *, u_long, caddr_t); static void bce_watchdog (struct bce_softc *); static int bce_ifmedia_upd (struct ifnet *); -static void bce_ifmedia_upd_locked (struct ifnet *); +static void bce_ifmedia_upd_locked (struct ifnet *); static void bce_ifmedia_sts (struct ifnet *, struct ifmediareq *); static void bce_init_locked (struct bce_softc *); static void bce_init (void *); -static void bce_mgmt_init_locked(struct bce_softc *sc); +static void bce_mgmt_init_locked (struct bce_softc *sc); static void bce_init_context (struct bce_softc *); static void bce_get_mac_addr (struct bce_softc *); @@ -629,7 +630,7 @@ if (val & BCE_PCICFG_MISC_STATUS_32BIT_DET) sc->bce_flags |= BCE_PCI_32BIT_FLAG; - /* Reset the controller and announce to bootcde that driver is present. */ + /* Reset the controller and announce to bootcode that driver is present. */ if (bce_reset(sc, BCE_DRV_MSG_CODE_RESET)) { BCE_PRINTF("%s(%d): Controller reset failed!\n", __FILE__, __LINE__); @@ -3178,7 +3179,7 @@ bce_disable_intr(sc); - /* Free the RX lists. */ + /* Free RX buffers. */ bce_free_rx_chain(sc); /* Free TX buffers. */ @@ -3498,6 +3499,9 @@ /* This routine will map an mbuf cluster into 1 or more rx_bd's as */ /* necessary. */ /* */ +/* Todo: Consider writing the hardware mailboxes here to make rx_bd's */ +/* available to the hardware as soon as possible. */ +/* */ /* Returns: */ /* 0 for success, positive value for failure. */ /****************************************************************************/ @@ -3505,10 +3509,10 @@ bce_get_buf(struct bce_softc *sc, struct mbuf *m, u16 *prod, u16 *chain_prod, u32 *prod_bseq) { - bus_dmamap_t map; - bus_dma_segment_t segs[4]; + bus_dmamap_t map; + bus_dma_segment_t segs[BCE_MAX_SEGMENTS]; struct mbuf *m_new = NULL; - struct rx_bd *rxbd; + struct rx_bd *rxbd; int i, nsegs, error, rc = 0; #ifdef BCE_DEBUG u16 debug_chain_prod = *chain_prod; @@ -3525,12 +3529,13 @@ DBPRINT(sc, BCE_VERBOSE_RECV, "%s(enter): prod = 0x%04X, chain_prod = 0x%04X, " "prod_bseq = 0x%08X\n", __FUNCTION__, *prod, *chain_prod, *prod_bseq); + /* Check whether this is a new mbuf allocation. */ if (m == NULL) { + /* Simulate an mbuf allocation failure. */ DBRUNIF(DB_RANDOMTRUE(bce_debug_mbuf_allocation_failure), - BCE_PRINTF("%s(%d): Simulating mbuf allocation failure.\n", - __FILE__, __LINE__); - sc->mbuf_alloc_failed++; + sc->mbuf_alloc_failed++; + sc->mbuf_sim_alloc_failed++; rc = ENOBUFS; goto bce_get_buf_exit); @@ -3541,13 +3546,24 @@ DBPRINT(sc, BCE_WARN, "%s(%d): RX mbuf header allocation failed!\n", __FILE__, __LINE__); - DBRUNIF(1, sc->mbuf_alloc_failed++); + sc->mbuf_alloc_failed++; rc = ENOBUFS; goto bce_get_buf_exit; } DBRUNIF(1, sc->rx_mbuf_alloc++); + + /* Simulate an mbuf cluster allocation failure. */ + DBRUNIF(DB_RANDOMTRUE(bce_debug_mbuf_allocation_failure), + m_freem(m_new); + sc->rx_mbuf_alloc--; + sc->mbuf_alloc_failed++; + sc->mbuf_sim_alloc_failed++; + rc = ENOBUFS; + goto bce_get_buf_exit); + + /* Attach a cluster to the mbuf. */ m_cljget(m_new, M_DONTWAIT, sc->mbuf_alloc_size); if (!(m_new->m_flags & M_EXT)) { @@ -3555,16 +3571,17 @@ __FILE__, __LINE__); m_freem(m_new); - DBRUNIF(1, sc->rx_mbuf_alloc--); - DBRUNIF(1, sc->mbuf_alloc_failed++); + sc->mbuf_alloc_failed++; rc = ENOBUFS; goto bce_get_buf_exit; } + /* Initialize the mbuf cluster. */ m_new->m_len = m_new->m_pkthdr.len = sc->mbuf_alloc_size; } else { + /* Reuse an existing mbuf. */ m_new = m; m_new->m_len = m_new->m_pkthdr.len = sc->mbuf_alloc_size; m_new->m_data = m_new->m_ext.ext_buf; @@ -3575,27 +3592,38 @@ error = bus_dmamap_load_mbuf_sg(sc->rx_mbuf_tag, map, m_new, segs, &nsegs, BUS_DMA_NOWAIT); + /* Handle any mapping errors. */ if (error) { BCE_PRINTF("%s(%d): Error mapping mbuf into RX chain!\n", __FILE__, __LINE__); m_freem(m_new); - DBRUNIF(1, sc->rx_mbuf_alloc--); rc = ENOBUFS; goto bce_get_buf_exit; } - /* Watch for overflow. */ - DBRUNIF((sc->free_rx_bd > USABLE_RX_BD), - BCE_PRINTF("%s(%d): Too many free rx_bd (0x%04X > 0x%04X)!\n", - __FILE__, __LINE__, sc->free_rx_bd, (u16) USABLE_RX_BD)); + /* Make sure there is room in the receive chain. */ + if (nsegs > sc->free_rx_bd) { + bus_dmamap_unload(sc->rx_mbuf_tag, map); + + m_freem(m_new); + DBRUNIF(1, sc->rx_mbuf_alloc--); + + rc = EFBIG; + goto bce_get_buf_exit; + } + +#ifdef BCE_DEBUG + /* Track the distribution of buffer segments. */ + sc->rx_mbuf_segs[nsegs]++; +#endif /* Update some debug statistic counters */ DBRUNIF((sc->free_rx_bd < sc->rx_low_watermark), sc->rx_low_watermark = sc->free_rx_bd); - DBRUNIF((sc->free_rx_bd == 0), sc->rx_empty_count++); + DBRUNIF((sc->free_rx_bd == sc->max_rx_bd), sc->rx_empty_count++); /* Setup the rx_bd for the first segment. */ rxbd = &sc->rx_bd_chain[RX_PAGE(*chain_prod)][RX_IDX(*chain_prod)]; @@ -3741,6 +3769,8 @@ for (i = 0; i < TX_PAGES; i++) bzero((char *)sc->tx_bd_chain[i], BCE_TX_CHAIN_PAGE_SZ); + sc->used_tx_bd = 0; + /* Check if we lost any mbufs in the process. */ DBRUNIF((sc->tx_mbuf_alloc), BCE_PRINTF("%s(%d): Memory leak! Lost %d mbufs " @@ -3752,6 +3782,62 @@ /****************************************************************************/ +/* Add mbufs to the RX chain until its full or an mbuf allocation error */ +/* occurs. */ +/* */ +/* Returns: */ +/* Nothing */ +/****************************************************************************/ +static void +bce_fill_rx_chain(struct bce_softc *sc) +{ + u16 prod, chain_prod; + u32 prod_bseq; +#ifdef BCE_DEBUG + int rx_mbuf_alloc_before, free_rx_bd_before; +#endif + + DBPRINT(sc, BCE_EXCESSIVE_RECV, "Entering %s()\n", __FUNCTION__); + + prod = sc->rx_prod; + prod_bseq = sc->rx_prod_bseq; + +#ifdef BCE_DEBUG + rx_mbuf_alloc_before = sc->rx_mbuf_alloc; + free_rx_bd_before = sc->free_rx_bd; +#endif + + /* Keep filling the RX chain until it's full. */ + while (sc->free_rx_bd > 0) { + chain_prod = RX_CHAIN_IDX(prod); + if (bce_get_buf(sc, NULL, &prod, &chain_prod, &prod_bseq)) { + /* Bail out if we can't add an mbuf to the chain. */ + break; + } + prod = NEXT_RX_BD(prod); + } + +#if 0 + DBRUNIF((sc->rx_mbuf_alloc - rx_mbuf_alloc_before), + BCE_PRINTF("%s(): Installed %d mbufs in %d rx_bd entries.\n", + __FUNCTION__, (sc->rx_mbuf_alloc - rx_mbuf_alloc_before), + (free_rx_bd_before - sc->free_rx_bd))); +#endif + + /* Save the RX chain producer index. */ + sc->rx_prod = prod; + sc->rx_prod_bseq = prod_bseq; + + /* Tell the chip about the waiting rx_bd's. */ + REG_WR16(sc, MB_RX_CID_ADDR + BCE_L2CTX_HOST_BDIDX, sc->rx_prod); + REG_WR(sc, MB_RX_CID_ADDR + BCE_L2CTX_HOST_BSEQ, sc->rx_prod_bseq); + + DBPRINT(sc, BCE_EXCESSIVE_RECV, "Exiting %s()\n", __FUNCTION__); + +} + + +/****************************************************************************/ /* Allocate memory and initialize the RX data structures. */ /* */ /* Returns: */ @@ -3762,8 +3848,7 @@ { struct rx_bd *rxbd; int i, rc = 0; - u16 prod, chain_prod; - u32 prod_bseq, val; + u32 val; DBPRINT(sc, BCE_VERBOSE_RESET, "Entering %s()\n", __FUNCTION__); @@ -3805,22 +3890,10 @@ val = BCE_ADDR_LO(sc->rx_bd_chain_paddr[0]); CTX_WR(sc, GET_CID_ADDR(RX_CID), BCE_L2CTX_NX_BDHADDR_LO, val); - /* Allocate mbuf clusters for the rx_bd chain. */ - prod = prod_bseq = 0; - while (prod < TOTAL_RX_BD) { - chain_prod = RX_CHAIN_IDX(prod); - if (bce_get_buf(sc, NULL, &prod, &chain_prod, &prod_bseq)) { - BCE_PRINTF("%s(%d): Error filling RX chain: rx_bd[0x%04X]!\n", - __FILE__, __LINE__, chain_prod); - rc = ENOBUFS; - break; - } - prod = NEXT_RX_BD(prod); - } + + /* Fill up the RX chain. */ + bce_fill_rx_chain(sc); - /* Save the RX chain producer index. */ - sc->rx_prod = prod; - sc->rx_prod_bseq = prod_bseq; for (i = 0; i < RX_PAGES; i++) { bus_dmamap_sync( @@ -3829,10 +3902,6 @@ BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); } - /* Tell the chip about the waiting rx_bd's. */ - REG_WR16(sc, MB_RX_CID_ADDR + BCE_L2CTX_HOST_BDIDX, sc->rx_prod); - REG_WR(sc, MB_RX_CID_ADDR + BCE_L2CTX_HOST_BSEQ, sc->rx_prod_bseq); - DBRUN(BCE_VERBOSE_RECV, bce_dump_rx_chain(sc, 0, TOTAL_RX_BD)); DBPRINT(sc, BCE_VERBOSE_RESET, "Exiting %s()\n", __FUNCTION__); @@ -3851,9 +3920,16 @@ bce_free_rx_chain(struct bce_softc *sc) { int i; +#ifdef BCE_DEBUG + int rx_mbuf_alloc_before; +#endif DBPRINT(sc, BCE_VERBOSE_RESET, "Entering %s()\n", __FUNCTION__); +#ifdef BCE_DEBUG + rx_mbuf_alloc_before = sc->rx_mbuf_alloc; +#endif + /* Free any mbufs still in the RX mbuf chain. */ for (i = 0; i < TOTAL_RX_BD; i++) { if (sc->rx_mbuf_ptr[i] != NULL) { @@ -3866,10 +3942,16 @@ } } + DBRUNIF((rx_mbuf_alloc_before - sc->rx_mbuf_alloc), + BCE_PRINTF("%s(): Released %d mbufs.\n", + __FUNCTION__, (rx_mbuf_alloc_before - sc->rx_mbuf_alloc))); + /* Clear each RX chain page. */ for (i = 0; i < RX_PAGES; i++) bzero((char *)sc->rx_bd_chain[i], BCE_RX_CHAIN_PAGE_SZ); + sc->free_rx_bd = sc->max_rx_bd; + /* Check if we lost any mbufs in the process. */ DBRUNIF((sc->rx_mbuf_alloc), BCE_PRINTF("%s(%d): Memory leak! Lost %d mbufs from rx chain!\n", @@ -4035,8 +4117,7 @@ DBPRINT(sc, BCE_INFO_RECV, "%s(enter): sw_prod = 0x%04X, " "sw_cons = 0x%04X, sw_prod_bseq = 0x%08X\n", - __FUNCTION__, sw_prod, sw_cons, - sw_prod_bseq); + __FUNCTION__, sw_prod, sw_cons, sw_prod_bseq); /* Prevent speculative reads from getting ahead of the status block. */ bus_space_barrier(sc->bce_btag, sc->bce_bhandle, 0, 0, @@ -4045,7 +4126,7 @@ /* Update some debug statistics counters */ DBRUNIF((sc->free_rx_bd < sc->rx_low_watermark), sc->rx_low_watermark = sc->free_rx_bd); - DBRUNIF((sc->free_rx_bd == 0), sc->rx_empty_count++); + DBRUNIF((sc->free_rx_bd == USABLE_RX_BD), sc->rx_empty_count++); /* Scan through the receive chain as long as there is work to do */ while (sw_cons != hw_cons) { @@ -4100,7 +4181,7 @@ bus_dmamap_unload(sc->rx_mbuf_tag, sc->rx_mbuf_map[sw_chain_cons]); - /* Remove the mbuf from the driver's chain. */ + /* Remove the mbuf from the RX chain. */ m = sc->rx_mbuf_ptr[sw_chain_cons]; sc->rx_mbuf_ptr[sw_chain_cons] = NULL; @@ -4138,44 +4219,17 @@ L2_FHDR_ERRORS_PHY_DECODE | L2_FHDR_ERRORS_ALIGNMENT | L2_FHDR_ERRORS_TOO_SHORT | L2_FHDR_ERRORS_GIANT_FRAME)) { + /* Log the error and release the mbuf. */ ifp->if_ierrors++; DBRUNIF(1, sc->l2fhdr_status_errors++); + + /* Todo: Reuse the mbuf to improve performance. */ - /* Reuse the mbuf for a new frame. */ - if (bce_get_buf(sc, m, &sw_prod, &sw_chain_prod, &sw_prod_bseq)) { - - DBRUNIF(1, bce_breakpoint(sc)); - panic("bce%d: Can't reuse RX mbuf!\n", sc->bce_unit); - - } + m_freem(m); + m = NULL; goto bce_rx_int_next_rx; } - /* - * Get a new mbuf for the rx_bd. If no new - * mbufs are available then reuse the current mbuf, - * log an ierror on the interface, and generate - * an error in the system log. - */ - if (bce_get_buf(sc, NULL, &sw_prod, &sw_chain_prod, &sw_prod_bseq)) { - - DBRUN(BCE_WARN, - BCE_PRINTF("%s(%d): Failed to allocate " - "new mbuf, incoming frame dropped!\n", - __FILE__, __LINE__)); - - ifp->if_ierrors++; - - /* Try and reuse the exisitng mbuf. */ - if (bce_get_buf(sc, m, &sw_prod, &sw_chain_prod, &sw_prod_bseq)) { - - DBRUNIF(1, bce_breakpoint(sc)); - panic("bce%d: Double mbuf allocation failure!", sc->bce_unit); - - } - goto bce_rx_int_next_rx; - } - /* Skip over the l2_fhdr when passing the data up the stack. */ >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708011622.l71GMZYi040730>