From owner-p4-projects@FreeBSD.ORG Fri Jan 25 13:12:49 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7C5CB16A4C1; Fri, 25 Jan 2008 13:12:49 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0FB4E16A41A for ; Fri, 25 Jan 2008 13:12:49 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 08B5E13C458 for ; Fri, 25 Jan 2008 13:12:49 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m0PDCmtl033874 for ; Fri, 25 Jan 2008 13:12:48 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m0PDCmiH033871 for perforce@freebsd.org; Fri, 25 Jan 2008 13:12:48 GMT (envelope-from jhb@freebsd.org) Date: Fri, 25 Jan 2008 13:12:48 GMT Message-Id: <200801251312.m0PDCmiH033871@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 134076 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: Fri, 25 Jan 2008 13:12:49 -0000 http://perforce.freebsd.org/chv.cgi?CH=134076 Change 134076 by jhb@jhb_zion on 2008/01/25 13:11:57 IFC @134073 Affected files ... .. //depot/projects/smpng/sys/Makefile#19 integrate .. //depot/projects/smpng/sys/compat/opensolaris/kern/opensolaris_kmem.c#2 integrate .. //depot/projects/smpng/sys/compat/opensolaris/sys/kmem.h#3 integrate .. //depot/projects/smpng/sys/contrib/opensolaris/uts/common/fs/zfs/arc.c#4 integrate .. //depot/projects/smpng/sys/dev/amr/amr.c#45 integrate .. //depot/projects/smpng/sys/dev/amr/amrreg.h#9 integrate .. //depot/projects/smpng/sys/dev/amr/amrvar.h#26 integrate .. //depot/projects/smpng/sys/dev/mxge/if_mxge.c#20 integrate .. //depot/projects/smpng/sys/dev/mxge/if_mxge_var.h#9 integrate .. //depot/projects/smpng/sys/dev/syscons/syscons.c#61 integrate .. //depot/projects/smpng/sys/dev/usb/ehci.c#30 integrate .. //depot/projects/smpng/sys/dev/usb/if_udav.c#20 integrate .. //depot/projects/smpng/sys/dev/usb/uftdi.c#21 integrate .. //depot/projects/smpng/sys/dev/usb/uftdireg.h#3 integrate .. //depot/projects/smpng/sys/fs/cd9660/cd9660_vfsops.c#5 integrate .. //depot/projects/smpng/sys/fs/coda/coda_vnops.c#3 integrate .. //depot/projects/smpng/sys/fs/hpfs/hpfs_subr.h#5 integrate .. //depot/projects/smpng/sys/fs/hpfs/hpfs_vfsops.c#36 integrate .. //depot/projects/smpng/sys/fs/msdosfs/msdosfs_denode.c#30 integrate .. //depot/projects/smpng/sys/fs/ntfs/ntfs_subr.c#26 integrate .. //depot/projects/smpng/sys/fs/nullfs/null_vnops.c#33 integrate .. //depot/projects/smpng/sys/fs/nwfs/nwfs_node.c#21 integrate .. //depot/projects/smpng/sys/fs/smbfs/smbfs_node.c#28 integrate .. //depot/projects/smpng/sys/fs/udf/udf_vfsops.c#37 integrate .. //depot/projects/smpng/sys/fs/unionfs/union_subr.c#32 integrate .. //depot/projects/smpng/sys/gnu/fs/ext2fs/ext2_vfsops.c#14 integrate .. //depot/projects/smpng/sys/gnu/fs/reiserfs/reiserfs_inode.c#5 integrate .. //depot/projects/smpng/sys/kern/kern_jail.c#52 integrate .. //depot/projects/smpng/sys/kern/kern_lock.c#66 integrate .. //depot/projects/smpng/sys/kern/sched_ule.c#80 integrate .. //depot/projects/smpng/sys/kern/subr_sleepqueue.c#33 integrate .. //depot/projects/smpng/sys/kern/vfs_aio.c#80 integrate .. //depot/projects/smpng/sys/kern/vfs_default.c#52 integrate .. //depot/projects/smpng/sys/kern/vfs_mount.c#76 integrate .. //depot/projects/smpng/sys/kern/vfs_subr.c#145 integrate .. //depot/projects/smpng/sys/netgraph/ng_ppp.c#25 integrate .. //depot/projects/smpng/sys/netinet/in.c#40 integrate .. //depot/projects/smpng/sys/netinet/ip_options.c#5 integrate .. //depot/projects/smpng/sys/netinet/tcp_usrreq.c#66 integrate .. //depot/projects/smpng/sys/netinet6/in6.c#42 integrate .. //depot/projects/smpng/sys/netinet6/ip6_output.c#50 integrate .. //depot/projects/smpng/sys/netinet6/ip6_var.h#21 integrate .. //depot/projects/smpng/sys/netinet6/raw_ip6.c#47 integrate .. //depot/projects/smpng/sys/netinet6/udp6_usrreq.c#46 integrate .. //depot/projects/smpng/sys/netncp/ncp_conn.c#16 integrate .. //depot/projects/smpng/sys/netsmb/smb_conn.c#18 integrate .. //depot/projects/smpng/sys/nfs4client/nfs4_idmap.c#6 integrate .. //depot/projects/smpng/sys/nfsclient/nfs_node.c#28 integrate .. //depot/projects/smpng/sys/sys/buf.h#48 integrate .. //depot/projects/smpng/sys/sys/event.h#23 integrate .. //depot/projects/smpng/sys/sys/lockmgr.h#23 integrate .. //depot/projects/smpng/sys/sys/param.h#121 integrate .. //depot/projects/smpng/sys/sys/priv.h#9 integrate .. //depot/projects/smpng/sys/ufs/ffs/ffs_snapshot.c#65 integrate .. //depot/projects/smpng/sys/ufs/ffs/ffs_vfsops.c#97 integrate .. //depot/projects/smpng/sys/ufs/ffs/ffs_vnops.c#56 integrate .. //depot/projects/smpng/sys/ufs/ufs/ufs_extattr.c#42 integrate Differences ... ==== //depot/projects/smpng/sys/Makefile#19 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/Makefile,v 1.45 2007/07/12 21:04:55 rwatson Exp $ +# $FreeBSD: src/sys/Makefile,v 1.46 2008/01/23 08:50:34 maxim Exp $ .include @@ -8,11 +8,11 @@ .endif # Directories to include in cscope name file and TAGS. -CSCOPEDIRS= bsm cam compat conf contrib crypto ddb dev fs geom gnu \ +CSCOPEDIRS= boot bsm cam compat conf contrib crypto ddb dev fs gdb geom gnu \ i4b isa kern libkern modules net net80211 netatalk netatm \ netgraph netinet netinet6 netipsec netipx netnatm netncp \ - netsmb nfs nfsclient nfs4client rpc pccard pci security sys \ - ufs vm ${ARCHDIR} + netsmb nfs nfs4client nfsclient nfsserver opencrypto pccard \ + pci rpc security sys ufs vm ${ARCHDIR} ARCHDIR ?= ${MACHINE} ==== //depot/projects/smpng/sys/compat/opensolaris/kern/opensolaris_kmem.c#2 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/compat/opensolaris/kern/opensolaris_kmem.c,v 1.2 2007/04/10 02:35:56 pjd Exp $"); +__FBSDID("$FreeBSD: src/sys/compat/opensolaris/kern/opensolaris_kmem.c,v 1.3 2008/01/24 11:21:54 pjd Exp $"); #include #include @@ -108,18 +108,18 @@ free(buf, M_SOLARIS); } -u_long +uint64_t kmem_size(void) { - return ((u_long)vm_kmem_size); + return ((uint64_t)vm_kmem_size); } -u_long +uint64_t kmem_used(void) { - return ((u_long)kmem_map->size); + return ((uint64_t)kmem_map->size); } static int ==== //depot/projects/smpng/sys/compat/opensolaris/sys/kmem.h#3 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/compat/opensolaris/sys/kmem.h,v 1.3 2007/11/28 21:48:25 jb Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/kmem.h,v 1.4 2008/01/24 11:21:54 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_KMEM_H_ @@ -56,8 +56,8 @@ void *zfs_kmem_alloc(size_t size, int kmflags); void zfs_kmem_free(void *buf, size_t size); -u_long kmem_size(void); -u_long kmem_used(void); +uint64_t kmem_size(void); +uint64_t kmem_used(void); kmem_cache_t *kmem_cache_create(char *name, size_t bufsize, size_t align, int (*constructor)(void *, void *, int), void (*destructor)(void *, void *), void (*reclaim)(void *) __unused, void *private, vmem_t *vmp, int cflags); ==== //depot/projects/smpng/sys/contrib/opensolaris/uts/common/fs/zfs/arc.c#4 (text+ko) ==== @@ -1439,7 +1439,7 @@ return (1); #endif #else - if (kmem_used() > (kmem_size() * 4) / 5) + if (kmem_used() > (kmem_size() * 3) / 4) return (1); #endif @@ -2729,7 +2729,7 @@ arc_c_max = (arc_c * 8) - (1<<30); else arc_c_max = arc_c_min; - arc_c_max = MAX(arc_c * 6, arc_c_max); + arc_c_max = MAX(arc_c * 5, arc_c_max); #ifdef _KERNEL /* * Allow the tunables to override our calculations if they are @@ -2800,11 +2800,12 @@ arc_dead = FALSE; #ifdef _KERNEL - /* Warn about ZFS memory requirements. */ + /* Warn about ZFS memory and address space requirements. */ if (((uint64_t)physmem * PAGESIZE) < (256 + 128 + 64) * (1 << 20)) { printf("ZFS WARNING: Recommended minimum RAM size is 512MB; " "expect unstable behavior.\n"); - } else if (kmem_size() < 512 * (1 << 20)) { + } + if (kmem_size() < 512 * (1 << 20)) { printf("ZFS WARNING: Recommended minimum kmem_size is 512MB; " "expect unstable behavior.\n"); printf(" Consider tuning vm.kmem_size and " ==== //depot/projects/smpng/sys/dev/amr/amr.c#45 (text+ko) ==== @@ -56,7 +56,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/amr/amr.c,v 1.84 2007/12/12 05:55:03 scottl Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/amr/amr.c,v 1.85 2008/01/24 07:26:53 scottl Exp $"); /* * Driver for the AMI MegaRaid family of controllers. @@ -139,10 +139,11 @@ static int amr_mapcmd(struct amr_command *ac); static void amr_unmapcmd(struct amr_command *ac); static int amr_start(struct amr_command *ac); -static void amr_complete(void *context, int pending); +static void amr_complete(void *context, ac_qhead_t *head); static void amr_setup_sg(void *arg, bus_dma_segment_t *segs, int nsegments, int error); static void amr_setup_data(void *arg, bus_dma_segment_t *segs, int nsegments, int error); static void amr_setup_ccb(void *arg, bus_dma_segment_t *segs, int nsegments, int error); +static void amr_abort_load(struct amr_command *ac); /* * Status monitoring @@ -207,10 +208,9 @@ /* * Initialise per-controller queues. */ - TAILQ_INIT(&sc->amr_completed); - TAILQ_INIT(&sc->amr_freecmds); + amr_init_qhead(&sc->amr_freecmds); + amr_init_qhead(&sc->amr_ready); TAILQ_INIT(&sc->amr_cmd_clusters); - TAILQ_INIT(&sc->amr_ready); bioq_init(&sc->amr_bioq); debug(2, "queue init done"); @@ -236,6 +236,11 @@ #endif /* + * Allocate initial commands. + */ + amr_alloccmd_cluster(sc); + + /* * Quiz controller for features and limits. */ if (amr_query_controller(sc)) @@ -244,6 +249,12 @@ debug(2, "controller query complete"); /* + * preallocate the remaining commands. + */ + while (sc->amr_nextslot < sc->amr_maxio) + amr_alloccmd_cluster(sc); + + /* * Setup sysctls. */ amr_init_sysctl(sc); @@ -357,6 +368,18 @@ SYSCTL_CHILDREN(device_get_sysctl_tree(sc->amr_dev)), OID_AUTO, "allow_volume_configure", CTLFLAG_RW, &sc->amr_allow_vol_config, 0, ""); + SYSCTL_ADD_INT(device_get_sysctl_ctx(sc->amr_dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(sc->amr_dev)), + OID_AUTO, "nextslot", CTLFLAG_RD, &sc->amr_nextslot, 0, + ""); + SYSCTL_ADD_INT(device_get_sysctl_ctx(sc->amr_dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(sc->amr_dev)), + OID_AUTO, "busyslots", CTLFLAG_RD, &sc->amr_busyslots, 0, + ""); + SYSCTL_ADD_INT(device_get_sysctl_ctx(sc->amr_dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(sc->amr_dev)), + OID_AUTO, "maxio", CTLFLAG_RD, &sc->amr_maxio, 0, + ""); } @@ -646,8 +669,18 @@ error = ENOIOCTL; break; } else { - if (len) - dp = malloc(len, M_AMR, M_WAITOK | M_ZERO); + /* + * Bug-for-bug compatibility with Linux! + * Some apps will send commands with inlen and outlen set to 0, + * even though they expect data to be transfered to them from the + * card. Linux accidentally allows this by allocating a 4KB + * buffer for the transfer anyways, but it then throws it away + * without copying it back to the app. + */ + if (!len) + len = 4096; + + dp = malloc(len, M_AMR, M_WAITOK | M_ZERO); if (ali.inlen) { error = copyin((void *)(uintptr_t)mb->mb_physaddr, dp, len); @@ -793,8 +826,7 @@ if (sc == NULL) return (ENOENT); - return (amr_linux_ioctl_int(sc->amr_dev_t, cmd, - addr, 0, td)); + return (amr_linux_ioctl_int(sc->amr_dev_t, cmd, addr, 0, td)); } default: debug(1, "unknown ioctl 0x%lx", cmd); @@ -956,13 +988,6 @@ int ldrv; int status; - /* - * If we haven't found the real limit yet, let us have a couple of commands in - * order to be able to probe. - */ - if (sc->amr_maxio == 0) - sc->amr_maxio = 2; - /* * Greater than 10 byte cdb support */ @@ -1278,7 +1303,7 @@ int driveno; int cmd; - *acp = NULL; + ac = NULL; error = 0; /* get a command */ @@ -1340,6 +1365,7 @@ /* we fill in the s/g related data when the command is mapped */ + *acp = ac; return(error); } @@ -1411,6 +1437,12 @@ struct amr_softc *sc = ac->ac_sc; int mb_channel; + if (err) { + device_printf(sc->amr_dev, "error %d in %s", err, __FUNCTION__); + ac->ac_status = AMR_STATUS_ABORTED; + return; + } + amr_setup_sg(arg, segs, nsegs, err); /* for AMR_CMD_CONFIG Read/Write the s/g count goes elsewhere */ @@ -1565,9 +1597,6 @@ debug_called(3); - if (error) - printf("amr_setup_sg: error %d\n", error); - /* get base address of s/g table */ sg = ac->ac_sg.sg32; sg64 = ac->ac_sg.sg64; @@ -1610,6 +1639,12 @@ struct amr_softc *sc = ac->ac_sc; int mb_channel; + if (err) { + device_printf(sc->amr_dev, "error %d in %s", err, __FUNCTION__); + amr_abort_load(ac); + return; + } + amr_setup_sg(arg, segs, nsegs, err); /* for AMR_CMD_CONFIG Read/Write the s/g count goes elsewhere */ @@ -1640,6 +1675,12 @@ struct amr_passthrough *ap = &ac->ac_ccb->ccb_pthru; struct amr_ext_passthrough *aep = &ac->ac_ccb->ccb_epthru; + if (err) { + device_printf(sc->amr_dev, "error %d in %s", err, __FUNCTION__); + amr_abort_load(ac); + return; + } + /* Set up the mailbox portion of the command to point at the ccb */ ac->ac_mailbox.mb_nsgelem = 0; ac->ac_mailbox.mb_physaddr = ac->ac_ccb_busaddr; @@ -1729,6 +1770,23 @@ } } +static void +amr_abort_load(struct amr_command *ac) +{ + ac_qhead_t head; + struct amr_softc *sc = ac->ac_sc; + + mtx_assert(&sc->amr_list_lock, MA_OWNED); + + ac->ac_status = AMR_STATUS_ABORTED; + amr_init_qhead(&head); + amr_enqueue_completed(ac, &head); + + mtx_unlock(&sc->amr_list_lock); + amr_complete(sc, &head); + mtx_lock(&sc->amr_list_lock); +} + /******************************************************************************** * Take a command and give it to the controller, returns 0 if successful, or * EBUSY if the command should be retried later. @@ -1774,6 +1832,7 @@ int amr_done(struct amr_softc *sc) { + ac_qhead_t head; struct amr_command *ac; struct amr_mailbox mbox; int i, idx, result; @@ -1782,6 +1841,7 @@ /* See if there's anything for us to do */ result = 0; + amr_init_qhead(&head); /* loop collecting completed commands */ for (;;) { @@ -1803,7 +1863,7 @@ /* save status for later use */ ac->ac_status = mbox.mb_status; - amr_enqueue_completed(ac); + amr_enqueue_completed(ac, &head); debug(3, "completed command with status %x", mbox.mb_status); } else { device_printf(sc->amr_dev, "bad slot %d completed\n", idx); @@ -1814,7 +1874,7 @@ } /* handle completion and timeouts */ - amr_complete(sc, 0); + amr_complete(sc, &head); return(result); } @@ -1824,7 +1884,7 @@ */ static void -amr_complete(void *context, int pending) +amr_complete(void *context, ac_qhead_t *head) { struct amr_softc *sc = (struct amr_softc *)context; struct amr_command *ac; @@ -1833,7 +1893,7 @@ /* pull completed commands off the queue */ for (;;) { - ac = amr_dequeue_completed(sc); + ac = amr_dequeue_completed(sc, head); if (ac == NULL) break; @@ -1894,10 +1954,6 @@ ac = amr_dequeue_free(sc); if (ac == NULL) { - amr_alloccmd_cluster(sc); - ac = amr_dequeue_free(sc); - } - if (ac == NULL) { sc->amr_state |= AMR_STATE_QUEUE_FRZN; return(NULL); } @@ -1909,6 +1965,7 @@ ac->ac_bio = NULL; ac->ac_data = NULL; ac->ac_complete = NULL; + ac->ac_retries = 0; ac->ac_tag = NULL; ac->ac_datamap = NULL; return(ac); @@ -1935,12 +1992,21 @@ struct amr_command *ac; int i, nextslot; + /* + * If we haven't found the real limit yet, let us have a couple of + * commands in order to be able to probe. + */ + if (sc->amr_maxio == 0) + sc->amr_maxio = 2; + if (sc->amr_nextslot > sc->amr_maxio) return; acc = malloc(AMR_CMD_CLUSTERSIZE, M_AMR, M_NOWAIT | M_ZERO); if (acc != NULL) { nextslot = sc->amr_nextslot; + mtx_lock(&sc->amr_list_lock); TAILQ_INSERT_TAIL(&sc->amr_cmd_clusters, acc, acc_link); + mtx_unlock(&sc->amr_list_lock); for (i = 0; i < AMR_CMD_CLUSTERCOUNT; i++) { ac = &acc->acc_command[i]; ac->ac_sc = sc; @@ -1989,6 +2055,8 @@ int i; for (i = 0; i < AMR_CMD_CLUSTERCOUNT; i++) { + if (acc->acc_command[i].ac_sc == NULL) + break; bus_dmamap_destroy(sc->amr_buffer_dmat, acc->acc_command[i].ac_dmamap); if (AMR_IS_SG64(sc)) bus_dmamap_destroy(sc->amr_buffer64_dmat, acc->acc_command[i].ac_dma64map); @@ -2009,6 +2077,8 @@ amr_quartz_submit_command(struct amr_command *ac) { struct amr_softc *sc = ac->ac_sc; + static struct timeval lastfail; + static int curfail; int i = 0; mtx_lock(&sc->amr_hw_lock); @@ -2016,6 +2086,12 @@ DELAY(1); if (sc->amr_mailbox->mb_busy) { mtx_unlock(&sc->amr_hw_lock); + if (ac->ac_retries++ > 1000) { + if (ppsratecheck(&lastfail, &curfail, 1)) + device_printf(sc->amr_dev, "Too many retries on command %p. " + "Controller is likely dead\n", ac); + ac->ac_retries = 0; + } return (EBUSY); } @@ -2040,10 +2116,18 @@ amr_std_submit_command(struct amr_command *ac) { struct amr_softc *sc = ac->ac_sc; + static struct timeval lastfail; + static int curfail; mtx_lock(&sc->amr_hw_lock); if (AMR_SGET_MBSTAT(sc) & AMR_SMBOX_BUSYFLAG) { mtx_unlock(&sc->amr_hw_lock); + if (ac->ac_retries++ > 1000) { + if (ppsratecheck(&lastfail, &curfail, 1)) + device_printf(sc->amr_dev, "Too many retries on command %p. " + "Controller is likely dead\n", ac); + ac->ac_retries = 0; + } return (EBUSY); } ==== //depot/projects/smpng/sys/dev/amr/amrreg.h#9 (text+ko) ==== @@ -53,7 +53,7 @@ * SUCH DAMAGE. * * - * $FreeBSD: src/sys/dev/amr/amrreg.h,v 1.10 2006/01/13 23:50:21 jkim Exp $ + * $FreeBSD: src/sys/dev/amr/amrreg.h,v 1.11 2008/01/24 07:26:53 scottl Exp $ */ /******************************************************************************** @@ -126,6 +126,7 @@ #define AMR_CONFIG_READ_NVRAM_CONFIG 0x04 #define AMR_CONFIG_WRITE_NVRAM_CONFIG 0x0d +#define AMR_CONFIG_ENQ3_SOLICITED_NOTIFY 0x01 #define AMR_CONFIG_PRODUCT_INFO 0x0e #define AMR_CONFIG_ENQ3 0x0f #define AMR_CONFIG_ENQ3_SOLICITED_NOTIFY 0x01 @@ -141,6 +142,14 @@ #define OP_DEL_LOGDRV 0x1C /* + * Command for random deletion of logical drives + */ +#define FC_DEL_LOGDRV 0xA4 +#define OP_SUP_DEL_LOGDRV 0x2A +#define OP_GET_LDID_MAP 0x18 +#define OP_DEL_LOGDRV 0x1C + +/* * Command results */ #define AMR_STATUS_SUCCESS 0x00 ==== //depot/projects/smpng/sys/dev/amr/amrvar.h#26 (text+ko) ==== @@ -53,7 +53,7 @@ * SUCH DAMAGE. * * - * $FreeBSD: src/sys/dev/amr/amrvar.h,v 1.34 2007/12/12 05:55:03 scottl Exp $ + * $FreeBSD: src/sys/dev/amr/amrvar.h,v 1.35 2008/01/24 07:26:53 scottl Exp $ */ #include @@ -100,6 +100,9 @@ #define AMR_CMD_CLUSTERSIZE (16 * 1024) +typedef STAILQ_HEAD(, amr_command) ac_qhead_t; +typedef STAILQ_ENTRY(amr_command) ac_link_t; + union amr_ccb { struct amr_passthrough ccb_pthru; struct amr_ext_passthrough ccb_epthru; @@ -111,7 +114,7 @@ */ struct amr_command { - TAILQ_ENTRY(amr_command) ac_link; + ac_link_t ac_link; struct amr_softc *ac_sc; u_int8_t ac_slot; @@ -134,6 +137,7 @@ #define AMR_CMD_BUSY (1<<7) #define AMR_CMD_SG64 (1<<8) #define AC_IS_SG64(ac) ((ac)->ac_flags & AMR_CMD_SG64) + u_int ac_retries; struct bio *ac_bio; void (* ac_complete)(struct amr_command *ac); @@ -219,11 +223,10 @@ /* per-controller queues */ struct bio_queue_head amr_bioq; /* pending I/O with no commands */ - TAILQ_HEAD(,amr_command) amr_ready; /* commands ready to be submitted */ + ac_qhead_t amr_ready; /* commands ready to be submitted */ struct amr_command *amr_busycmd[AMR_MAXCMD]; int amr_busyslots; - TAILQ_HEAD(,amr_command) amr_completed; - TAILQ_HEAD(,amr_command) amr_freecmds; + ac_qhead_t amr_freecmds; TAILQ_HEAD(,amr_command_cluster) amr_cmd_clusters; /* CAM attachments for passthrough */ @@ -320,17 +323,24 @@ } static __inline void +amr_init_qhead(ac_qhead_t *head) +{ + + STAILQ_INIT(head); +} + +static __inline void amr_enqueue_ready(struct amr_command *ac) { - TAILQ_INSERT_TAIL(&ac->ac_sc->amr_ready, ac, ac_link); + STAILQ_INSERT_TAIL(&ac->ac_sc->amr_ready, ac, ac_link); } static __inline void amr_requeue_ready(struct amr_command *ac) { - TAILQ_INSERT_HEAD(&ac->ac_sc->amr_ready, ac, ac_link); + STAILQ_INSERT_HEAD(&ac->ac_sc->amr_ready, ac, ac_link); } static __inline struct amr_command * @@ -338,25 +348,25 @@ { struct amr_command *ac; - if ((ac = TAILQ_FIRST(&sc->amr_ready)) != NULL) - TAILQ_REMOVE(&sc->amr_ready, ac, ac_link); + if ((ac = STAILQ_FIRST(&sc->amr_ready)) != NULL) + STAILQ_REMOVE_HEAD(&sc->amr_ready, ac_link); return(ac); } static __inline void -amr_enqueue_completed(struct amr_command *ac) +amr_enqueue_completed(struct amr_command *ac, ac_qhead_t *head) { - TAILQ_INSERT_TAIL(&ac->ac_sc->amr_completed, ac, ac_link); + STAILQ_INSERT_TAIL(head, ac, ac_link); } static __inline struct amr_command * -amr_dequeue_completed(struct amr_softc *sc) +amr_dequeue_completed(struct amr_softc *sc, ac_qhead_t *head) { struct amr_command *ac; - if ((ac = TAILQ_FIRST(&sc->amr_completed)) != NULL) - TAILQ_REMOVE(&sc->amr_completed, ac, ac_link); + if ((ac = STAILQ_FIRST(head)) != NULL) + STAILQ_REMOVE_HEAD(head, ac_link); return(ac); } @@ -364,7 +374,7 @@ amr_enqueue_free(struct amr_command *ac) { - TAILQ_INSERT_TAIL(&ac->ac_sc->amr_freecmds, ac, ac_link); + STAILQ_INSERT_HEAD(&ac->ac_sc->amr_freecmds, ac, ac_link); } static __inline struct amr_command * @@ -372,7 +382,7 @@ { struct amr_command *ac; - if ((ac = TAILQ_FIRST(&sc->amr_freecmds)) != NULL) - TAILQ_REMOVE(&sc->amr_freecmds, ac, ac_link); + if ((ac = STAILQ_FIRST(&sc->amr_freecmds)) != NULL) + STAILQ_REMOVE_HEAD(&sc->amr_freecmds, ac_link); return(ac); } ==== //depot/projects/smpng/sys/dev/mxge/if_mxge.c#20 (text+ko) ==== @@ -28,7 +28,7 @@ ***************************************************************************/ #include -__FBSDID("$FreeBSD: src/sys/dev/mxge/if_mxge.c,v 1.43 2008/01/15 20:34:48 gallatin Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/mxge/if_mxge.c,v 1.44 2008/01/22 22:04:31 gallatin Exp $"); #include #include @@ -2204,14 +2204,19 @@ goto done; } rx->info[idx].m = m; + rx->shadow[idx].addr_low = + htobe32(MXGE_LOWPART_TO_U32(seg->ds_addr)); + rx->shadow[idx].addr_high = + htobe32(MXGE_HIGHPART_TO_U32(seg->ds_addr)); - for (i = 0; i < cnt; i++) { +#if MXGE_VIRT_JUMBOS + for (i = 1; i < cnt; i++) { rx->shadow[idx + i].addr_low = htobe32(MXGE_LOWPART_TO_U32(seg[i].ds_addr)); rx->shadow[idx + i].addr_high = htobe32(MXGE_HIGHPART_TO_U32(seg[i].ds_addr)); } - +#endif done: for (i = 0; i < rx->nbufs; i++) { @@ -2911,13 +2916,22 @@ err = bus_dma_tag_create(sc->parent_dmat, /* parent */ 1, /* alignment */ +#if MXGE_VIRT_JUMBOS 4096, /* boundary */ +#else + 0, /* boundary */ +#endif BUS_SPACE_MAXADDR, /* low */ BUS_SPACE_MAXADDR, /* high */ NULL, NULL, /* filter */ 3*4096, /* maxsize */ +#if MXGE_VIRT_JUMBOS 3, /* num segs */ - 4096, /* maxsegsize */ + 4096, /* maxsegsize*/ +#else + 1, /* num segs */ + MJUM9BYTES, /* maxsegsize*/ +#endif BUS_DMA_ALLOCNOW, /* flags */ NULL, NULL, /* lock */ &ss->rx_big.dmat); /* tag */ @@ -3086,6 +3100,7 @@ *nbufs = 1; return; } +#if MXGE_VIRT_JUMBOS /* now we need to use virtually contiguous buffers */ *cl_size = MJUM9BYTES; *big_buf_size = 4096; @@ -3093,6 +3108,11 @@ /* needs to be a power of two, so round up */ if (*nbufs == 3) *nbufs = 4; +#else + *cl_size = MJUM9BYTES; + *big_buf_size = MJUM9BYTES; + *nbufs = 1; +#endif } static int ==== //depot/projects/smpng/sys/dev/mxge/if_mxge_var.h#9 (text+ko) ==== @@ -25,7 +25,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -$FreeBSD: src/sys/dev/mxge/if_mxge_var.h,v 1.17 2008/01/15 20:34:48 gallatin Exp $ +$FreeBSD: src/sys/dev/mxge/if_mxge_var.h,v 1.18 2008/01/22 22:04:31 gallatin Exp $ ***************************************************************************/ @@ -39,6 +39,12 @@ #define MXGE_EEPROM_STRINGS_SIZE 256 #define MXGE_MAX_SEND_DESC 128 +#if (__FreeBSD_version < 800005) +#define MXGE_VIRT_JUMBOS 1 +#else +#define MXGE_VIRT_JUMBOS 0 +#endif + typedef struct { void *addr; bus_addr_t bus_addr; ==== //depot/projects/smpng/sys/dev/syscons/syscons.c#61 (text+ko) ==== @@ -30,7 +30,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/syscons/syscons.c,v 1.456 2007/12/29 23:26:56 wkoszek Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/syscons/syscons.c,v 1.457 2008/01/24 15:37:48 kib Exp $"); #include "opt_compat.h" #include "opt_syscons.h" @@ -1071,6 +1071,8 @@ if (error) return error; scp = sc_get_stat(SC_DEV(sc, i)); + if (scp == NULL) + return (ENXIO); if (scp == scp->sc->cur_scp) return 0; error = tsleep(&scp->smode, PZERO | PCATCH, "waitvt", 0); ==== //depot/projects/smpng/sys/dev/usb/ehci.c#30 (text+ko) ==== @@ -59,7 +59,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/usb/ehci.c,v 1.57 2008/01/08 23:48:30 attilio Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/usb/ehci.c,v 1.58 2008/01/24 12:34:25 attilio Exp $"); #include #include @@ -1560,7 +1560,7 @@ } DPRINTFN(2,("ehci_sync_hc: enter\n")); /* get doorbell */ - lockmgr(&sc->sc_doorbell_lock, LK_EXCLUSIVE, NULL, curthread); + lockmgr(&sc->sc_doorbell_lock, LK_EXCLUSIVE, NULL); s = splhardusb(); /* ask for doorbell */ EOWRITE4(sc, EHCI_USBCMD, EOREAD4(sc, EHCI_USBCMD) | EHCI_CMD_IAAD); @@ -1571,7 +1571,7 @@ EOREAD4(sc, EHCI_USBCMD), EOREAD4(sc, EHCI_USBSTS))); splx(s); /* release doorbell */ - lockmgr(&sc->sc_doorbell_lock, LK_RELEASE, NULL, curthread); + lockmgr(&sc->sc_doorbell_lock, LK_RELEASE, NULL); #ifdef DIAGNOSTIC if (error) printf("ehci_sync_hc: tsleep() = %d\n", error); ==== //depot/projects/smpng/sys/dev/usb/if_udav.c#20 (text+ko) ==== @@ -1,6 +1,6 @@ /* $NetBSD: if_udav.c,v 1.2 2003/09/04 15:17:38 tsutsui Exp $ */ /* $nabe: if_udav.c,v 1.3 2003/08/21 16:57:19 nabe Exp $ */ -/* $FreeBSD: src/sys/dev/usb/if_udav.c,v 1.34 2008/01/08 23:48:30 attilio Exp $ */ +/* $FreeBSD: src/sys/dev/usb/if_udav.c,v 1.35 2008/01/24 12:34:25 attilio Exp $ */ /*- * Copyright (c) 2003 * Shingo WATANABE . All rights reserved. @@ -45,7 +45,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/usb/if_udav.c,v 1.34 2008/01/08 23:48:30 attilio Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/usb/if_udav.c,v 1.35 2008/01/24 12:34:25 attilio Exp $"); #include "opt_inet.h" #if defined(__NetBSD__) @@ -1777,11 +1777,7 @@ __func__)); sc->sc_refcnt++; -#if defined(__NetBSD__) lockmgr(&sc->sc_mii_lock, LK_EXCLUSIVE, NULL); -#elif defined(__FreeBSD__) - lockmgr(&sc->sc_mii_lock, LK_EXCLUSIVE, NULL, curthread); -#endif } static void @@ -1790,11 +1786,7 @@ DPRINTFN(0xff, ("%s: %s: enter\n", device_get_nameunit(sc->sc_dev), __func__)); -#if defined(__NetBSD__) lockmgr(&sc->sc_mii_lock, LK_RELEASE, NULL); -#elif defined(__FreeBSD__) - lockmgr(&sc->sc_mii_lock, LK_RELEASE, NULL, curthread); -#endif if (--sc->sc_refcnt < 0) usb_detach_wakeup(sc->sc_dev); } ==== //depot/projects/smpng/sys/dev/usb/uftdi.c#21 (text+ko) ==== @@ -37,7 +37,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/usb/uftdi.c,v 1.37 2007/06/22 05:53:05 imp Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/usb/uftdi.c,v 1.38 2008/01/25 02:41:44 emaste Exp $"); /* * FTDI FT8U100AX serial adapter driver @@ -121,6 +121,7 @@ static void uftdi_write(void *sc, int portno, u_char *to, u_char *from, u_int32_t *count); static void uftdi_break(void *sc, int portno, int onoff); +static int uftdi_8u232am_getrate(speed_t speed, int *rate); struct ucom_callback uftdi_callback = { uftdi_get_status, @@ -569,25 +570,8 @@ break; case UFTDI_TYPE_8U232AM: - switch(t->c_ospeed) { - case 300: rate = ftdi_8u232am_b300; break; - case 600: rate = ftdi_8u232am_b600; break; - case 1200: rate = ftdi_8u232am_b1200; break; - case 2400: rate = ftdi_8u232am_b2400; break; - case 4800: rate = ftdi_8u232am_b4800; break; - case 9600: rate = ftdi_8u232am_b9600; break; - case 19200: rate = ftdi_8u232am_b19200; break; - case 38400: rate = ftdi_8u232am_b38400; break; - case 57600: rate = ftdi_8u232am_b57600; break; - case 115200: rate = ftdi_8u232am_b115200; break; - case 230400: rate = ftdi_8u232am_b230400; break; - case 460800: rate = ftdi_8u232am_b460800; break; - case 921600: rate = ftdi_8u232am_b921600; break; - case 2000000: rate = ftdi_8u232am_b2000000; break; - case 3000000: rate = ftdi_8u232am_b3000000; break; - default: + if (uftdi_8u232am_getrate(t->c_ospeed, &rate) == -1) return (EINVAL); - } break; } req.bmRequestType = UT_WRITE_VENDOR_DEVICE; @@ -702,6 +686,70 @@ (void)usbd_do_request(ucom->sc_udev, &req, NULL); } +static int +uftdi_8u232am_getrate(speed_t speed, int *rate) +{ + /* Table of the nearest even powers-of-2 for values 0..15. */ + static const unsigned char roundoff[16] = { + 0, 2, 2, 4, 4, 4, 8, 8, + 8, 8, 8, 8, 16, 16, 16, 16, + }; + + unsigned int d, freq; + int result; + + if (speed <= 0) + return (-1); + + /* Special cases for 2M and 3M. */ + if (speed >= 3000000 * 100 / 103 && + speed <= 3000000 * 100 / 97) { + result = 0; + goto done; + } + if (speed >= 2000000 * 100 / 103 && + speed <= 2000000 * 100 / 97) { + result = 1; + goto done; + } + + d = (FTDI_8U232AM_FREQ << 4) / speed; + d = (d & ~15) + roundoff[d & 15]; + + if (d < FTDI_8U232AM_MIN_DIV) + d = FTDI_8U232AM_MIN_DIV; + else if (d > FTDI_8U232AM_MAX_DIV) + d = FTDI_8U232AM_MAX_DIV; + + /* + * Calculate the frequency needed for d to exactly divide down + * to our target speed, and check that the actual frequency is + * within 3% of this. + */ + freq = speed * d; >>> TRUNCATED FOR MAIL (1000 lines) <<<