From owner-svn-src-stable@FreeBSD.ORG Sun Sep 20 00:15:53 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7CC5E106566C; Sun, 20 Sep 2009 00:15:53 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 69FB88FC13; Sun, 20 Sep 2009 00:15:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8K0FroN038905; Sun, 20 Sep 2009 00:15:53 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8K0Fr7o038903; Sun, 20 Sep 2009 00:15:53 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909200015.n8K0Fr7o038903@svn.freebsd.org> From: Marius Strobl Date: Sun, 20 Sep 2009 00:15:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197335 - in stable/7/sys: . contrib/pf sparc64/sparc64 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2009 00:15:53 -0000 Author: marius Date: Sun Sep 20 00:15:52 2009 New Revision: 197335 URL: http://svn.freebsd.org/changeset/base/197335 Log: MFC: r191980 - Fix style. - Use __FBSDID. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/sparc64/sparc64/vm_machdep.c Modified: stable/7/sys/sparc64/sparc64/vm_machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/vm_machdep.c Sat Sep 19 21:46:12 2009 (r197334) +++ stable/7/sys/sparc64/sparc64/vm_machdep.c Sun Sep 20 00:15:52 2009 (r197335) @@ -39,23 +39,26 @@ * * from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91 * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$ - * from: FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.167 2001/07/12 - * $FreeBSD$ + * from: FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.167 2001/07/12 */ +#include +__FBSDID("$FreeBSD$"); + #include "opt_pmap.h" #include #include -#include -#include #include #include #include #include +#include #include #include +#include #include +#include #include #include #include @@ -73,12 +76,12 @@ #include #include -#include #include +#include #include #include -#include #include +#include #include #include #include @@ -94,7 +97,7 @@ static void sf_buf_init(void *arg); SYSINIT(sock_sf, SI_SUB_MBUF, SI_ORDER_ANY, sf_buf_init, NULL); /* - * Expanded sf_freelist head. Really an SLIST_HEAD() in disguise, with the + * Expanded sf_freelist head. Really an SLIST_HEAD() in disguise, with the * sf_freelist head with the sf_lock mutex. */ static struct { @@ -124,11 +127,13 @@ cpu_exit(struct thread *td) void cpu_thread_exit(struct thread *td) { + } void cpu_thread_clean(struct thread *td) { + } void @@ -146,16 +151,19 @@ cpu_thread_alloc(struct thread *td) void cpu_thread_free(struct thread *td) { + } - + void cpu_thread_swapin(struct thread *td) { + } void cpu_thread_swapout(struct thread *td) { + } void @@ -328,6 +336,7 @@ cpu_reset(void) 0, (cell_t)bspec }; + if ((chosen = OF_finddevice("/chosen")) != 0) { if (OF_getprop(chosen, "bootpath", bspec, sizeof(bspec)) == -1) bspec[0] = '\0'; @@ -392,7 +401,7 @@ sf_buf_init(void *arg) } /* - * Get an sf_buf from the freelist. Will block if none are available. + * Get an sf_buf from the freelist. Will block if none are available. */ struct sf_buf * sf_buf_alloc(struct vm_page *m, int flags) @@ -411,7 +420,7 @@ sf_buf_alloc(struct vm_page *m, int flag sf_buf_alloc_want--; /* - * If we got a signal, don't risk going back to sleep. + * If we got a signal, don't risk going back to sleep. */ if (error) break; From owner-svn-src-stable@FreeBSD.ORG Sun Sep 20 00:51:49 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2341D1065670; Sun, 20 Sep 2009 00:51:49 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 10E868FC15; Sun, 20 Sep 2009 00:51:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8K0pmvM039594; Sun, 20 Sep 2009 00:51:48 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8K0pmG6039592; Sun, 20 Sep 2009 00:51:48 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909200051.n8K0pmG6039592@svn.freebsd.org> From: Marius Strobl Date: Sun, 20 Sep 2009 00:51:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197336 - in stable/7/sys: . contrib/pf sparc64/sparc64 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2009 00:51:49 -0000 Author: marius Date: Sun Sep 20 00:51:48 2009 New Revision: 197336 URL: http://svn.freebsd.org/changeset/base/197336 Log: MFC: r191981 Just like in cpu_halt(), use cpu_shutdown() rather than ofw_exit() directly in cpu_reset() in order to idle the APs before exiting the kernel and letting the BSP enter the firmware so that processes like init(8) which still might be running on an AP at that point don't cause a panic there when it crashes due to the fact it no longer can be supported by the kernel. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/sparc64/sparc64/vm_machdep.c Modified: stable/7/sys/sparc64/sparc64/vm_machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/vm_machdep.c Sun Sep 20 00:15:52 2009 (r197335) +++ stable/7/sys/sparc64/sparc64/vm_machdep.c Sun Sep 20 00:51:48 2009 (r197336) @@ -343,7 +343,7 @@ cpu_reset(void) bspec[sizeof(bspec) - 1] = '\0'; } - openfirmware_exit(&args); + cpu_shutdown(&args); } /* From owner-svn-src-stable@FreeBSD.ORG Sun Sep 20 00:54:52 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B6151065672; Sun, 20 Sep 2009 00:54:52 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 489058FC14; Sun, 20 Sep 2009 00:54:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8K0spno039704; Sun, 20 Sep 2009 00:54:51 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8K0spCi039701; Sun, 20 Sep 2009 00:54:51 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909200054.n8K0spCi039701@svn.freebsd.org> From: Marius Strobl Date: Sun, 20 Sep 2009 00:54:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197337 - in stable/7/sys: . contrib/pf dev/mii X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2009 00:54:52 -0000 Author: marius Date: Sun Sep 20 00:54:51 2009 New Revision: 197337 URL: http://svn.freebsd.org/changeset/base/197337 Log: MFC: r194134 - Also probe DP83865, which is an is an ultra low power version of the DP83861 and DP83891. - Reset the PHY during attach so it's in a known state. - Add a comment describing why we hardwire 10baseT support in the BMSR. - Always explicitly set IFM_HDX for half-duplex. [1] Obtained from: OpenBSD [1] Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/mii/miidevs stable/7/sys/dev/mii/nsgphy.c Modified: stable/7/sys/dev/mii/miidevs ============================================================================== --- stable/7/sys/dev/mii/miidevs Sun Sep 20 00:51:48 2009 (r197336) +++ stable/7/sys/dev/mii/miidevs Sun Sep 20 00:54:51 2009 (r197337) @@ -197,6 +197,7 @@ model NATSEMI DP83815 0x0002 DP83815 10 model NATSEMI DP83847 0x0003 DP83847 10/100 media interface model NATSEMI DP83891 0x0005 DP83891 10/100/1000 media interface model NATSEMI DP83861 0x0006 DP83861 10/100/1000 media interface +model NATSEMI DP83865 0x0007 DP83865 10/100/1000 media interface /* Quality Semiconductor PHYs */ model QUALSEMI QS6612 0x0000 QS6612 10/100 media interface Modified: stable/7/sys/dev/mii/nsgphy.c ============================================================================== --- stable/7/sys/dev/mii/nsgphy.c Sun Sep 20 00:51:48 2009 (r197336) +++ stable/7/sys/dev/mii/nsgphy.c Sun Sep 20 00:54:51 2009 (r197337) @@ -41,17 +41,19 @@ __FBSDID("$FreeBSD$"); /* - * Driver for the National Semiconductor DP83891 and DP83861 + * Driver for the National Semiconductor DP83861, DP83865 and DP83891 * 10/100/1000 PHYs. * Datasheet available at: http://www.national.com/ds/DP/DP83861.pdf + * and at: http://www.national.com/ds/DP/DP83865.pdf * - * The DP83891 is the older NatSemi gigE PHY which isn't being sold - * anymore. The DP83861 is its replacement, which is an 'enhanced' - * firmware driven component. The major difference between the - * two is that the 83891 can't generate interrupts, while the - * 83861 can. (I think it wasn't originally designed to do this, but - * it can now thanks to firmware updates.) The 83861 also allows - * access to its internal RAM via indirect register access. + * The DP83891 is the older NS GigE PHY which isn't being sold + * anymore. The DP83861 is its replacement, which is an 'enhanced' + * firmware driven component. The major difference between the + * two is that the DP83891 can't generate interrupts, while the + * 83861 can (probably it wasn't originally designed to do this, but + * it can now thanks to firmware updates). The DP83861 also allows + * access to its internal RAM via indirect register access. The + * DP83865 is an ultra low power version of the DP83861 and DP83891. */ #include @@ -99,6 +101,7 @@ static void nsgphy_status(struct mii_sof static const struct mii_phydesc nsgphys[] = { MII_PHY_DESC(NATSEMI, DP83861), + MII_PHY_DESC(NATSEMI, DP83865), MII_PHY_DESC(NATSEMI, DP83891), MII_PHY_END }; @@ -133,8 +136,14 @@ nsgphy_attach(device_t dev) mii->mii_instance++; + mii_phy_reset(sc); + + /* + * NB: the PHY has the 10baseT BMSR bits hard-wired to 0, + * even though it supports 10baseT. + */ sc->mii_capabilities = (PHY_READ(sc, MII_BMSR) | - (BMSR_10TFDX|BMSR_10THDX)) & ma->mii_capmask; + (BMSR_10TFDX | BMSR_10THDX)) & ma->mii_capmask; if (sc->mii_capabilities & BMSR_EXTSTAT) sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR); @@ -238,7 +247,7 @@ nsgphy_status(struct mii_softc *sc) return; } - switch (physup & (PHY_SUP_SPEED1|PHY_SUP_SPEED0)) { + switch (physup & (PHY_SUP_SPEED1 | PHY_SUP_SPEED0)) { case PHY_SUP_SPEED1: mii->mii_media_active |= IFM_1000_T; gtsr = PHY_READ(sc, MII_100T2SR); @@ -257,9 +266,13 @@ nsgphy_status(struct mii_softc *sc) default: mii->mii_media_active |= IFM_NONE; mii->mii_media_status = 0; + return; } + if (physup & PHY_SUP_DUPLEX) mii->mii_media_active |= IFM_FDX; + else + mii->mii_media_active |= IFM_HDX; } else mii->mii_media_active = ife->ifm_media; } From owner-svn-src-stable@FreeBSD.ORG Sun Sep 20 12:08:30 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5DE2B106566C; Sun, 20 Sep 2009 12:08:30 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 49D8A8FC23; Sun, 20 Sep 2009 12:08:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8KC8UrT055806; Sun, 20 Sep 2009 12:08:30 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8KC8U0i055798; Sun, 20 Sep 2009 12:08:30 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909201208.n8KC8U0i055798@svn.freebsd.org> From: Marius Strobl Date: Sun, 20 Sep 2009 12:08:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197343 - in stable/7/sys: . boot/forth conf contrib/pf dev/cas modules modules/cas sparc64/conf X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2009 12:08:30 -0000 Author: marius Date: Sun Sep 20 12:08:29 2009 New Revision: 197343 URL: http://svn.freebsd.org/changeset/base/197343 Log: MFC: 194246, 194904, 194973 Add cas(4), a driver for Sun Cassini/Cassini+ and National Semiconductor DP83065 Saturn Gigabit Ethernet controllers. These are the successors of the Sun GEM controllers and still have a similar but extended transmit logic. As such this driver is based on gem(4). Thanks to marcel@ for providing a Sun Quad GigaSwift Ethernet UTP (QGE) card which was vital for getting this driver to work on architectures not using Open Firmware. Added: stable/7/sys/dev/cas/ - copied from r194246, head/sys/dev/cas/ stable/7/sys/modules/cas/ - copied from r194246, head/sys/modules/cas/ Modified: stable/7/sys/ (props changed) stable/7/sys/boot/forth/loader.conf stable/7/sys/conf/NOTES stable/7/sys/conf/files stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cas/if_cas.c stable/7/sys/dev/cas/if_casvar.h stable/7/sys/modules/Makefile stable/7/sys/sparc64/conf/GENERIC Modified: stable/7/sys/boot/forth/loader.conf ============================================================================== --- stable/7/sys/boot/forth/loader.conf Sun Sep 20 11:33:39 2009 (r197342) +++ stable/7/sys/boot/forth/loader.conf Sun Sep 20 12:08:29 2009 (r197343) @@ -220,6 +220,7 @@ if_axe_load="NO" # ASIX Electronics AX8 if_bce_load="NO" # Broadcom NetXtreme II Gigabit Ethernet if_bfe_load="NO" # Broadcom BCM4401 if_bge_load="NO" # Broadcom BCM570x PCI Gigabit Ethernet +if_cas_load="NO" # Sun Cassini/Cassini+ and NS DP83065 Saturn if_cm_load="NO" # SMC (90c26, 90c56, 90c66) if_cs_load="NO" # Crystal Semiconductor CS8920 if_cue_load="NO" # CATC USB-EL1210A USB Ethernet Modified: stable/7/sys/conf/NOTES ============================================================================== --- stable/7/sys/conf/NOTES Sun Sep 20 11:33:39 2009 (r197342) +++ stable/7/sys/conf/NOTES Sun Sep 20 12:08:29 2009 (r197343) @@ -1733,6 +1733,7 @@ device miibus # BCM570x family of controllers, including the 3Com 3c996-T, # the Netgear GA302T, the SysKonnect SK-9D21 and SK-9D41, and # the embedded gigE NICs on Dell PowerEdge 2550 servers. +# cas: Sun Cassini/Cassini+ and National Semiconductor DP83065 Saturn # cm: Arcnet SMC COM90c26 / SMC COM90c56 # (and SMC COM90c66 in '56 compatibility mode) adapters. # cnw: Xircom CNW/Netware Airsurfer PC Card adapter @@ -1875,6 +1876,7 @@ device ale # Atheros AR8121/AR8113/AR8 device bce # Broadcom BCM5706/BCM5708 Gigabit Ethernet device bfe # Broadcom BCM440x 10/100 Ethernet device bge # Broadcom BCM570xx Gigabit Ethernet +device cas # Sun Cassini/Cassini+ and NS DP83065 Saturn device cxgb # Chelsio T3 10 Gigabit Ethernet device dc # DEC/Intel 21143 and various workalikes device et # Agere ET1310 10/100/Gigabit Ethernet Modified: stable/7/sys/conf/files ============================================================================== --- stable/7/sys/conf/files Sun Sep 20 11:33:39 2009 (r197342) +++ stable/7/sys/conf/files Sun Sep 20 12:08:29 2009 (r197343) @@ -671,6 +671,7 @@ dev/buslogic/bt_pci.c optional bt pci dev/cardbus/cardbus.c optional cardbus dev/cardbus/cardbus_cis.c optional cardbus dev/cardbus/cardbus_device.c optional cardbus +dev/cas/if_cas.c optional cas dev/ciss/ciss.c optional ciss dev/cm/smc90cx6.c optional cm dev/cmx/cmx.c optional cmx Modified: stable/7/sys/dev/cas/if_cas.c ============================================================================== --- head/sys/dev/cas/if_cas.c Mon Jun 15 18:22:41 2009 (r194246) +++ stable/7/sys/dev/cas/if_cas.c Sun Sep 20 12:08:29 2009 (r197343) @@ -57,7 +57,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include @@ -135,7 +135,8 @@ static void cas_free(void *arg1, void* a static void cas_init(void *xsc); static void cas_init_locked(struct cas_softc *sc); static void cas_init_regs(struct cas_softc *sc); -static void cas_intr(void *v); +static int cas_intr(void *v); +static void cas_intr_task(void *arg, int pending __unused); static int cas_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data); static int cas_load_txmbuf(struct cas_softc *sc, struct mbuf **m_head); static int cas_mediachange(struct ifnet *ifp); @@ -159,13 +160,13 @@ static void cas_rxdma_callback(void *xsc int nsegs, int error); static void cas_setladrf(struct cas_softc *sc); static void cas_start(struct ifnet *ifp); -static void cas_start_locked(struct ifnet *ifp); static void cas_stop(struct ifnet *ifp); static void cas_suspend(struct cas_softc *sc); static void cas_tick(void *arg); static void cas_tint(struct cas_softc *sc); +static void cas_tx_task(void *arg, int pending __unused); static inline void cas_txkick(struct cas_softc *sc); -static int cas_watchdog(struct cas_softc *sc); +static void cas_watchdog(struct cas_softc *sc); static devclass_t cas_devclass; @@ -201,7 +202,19 @@ cas_attach(struct cas_softc *sc) IFQ_SET_READY(&ifp->if_snd); callout_init_mtx(&sc->sc_tick_ch, &sc->sc_mtx, 0); - callout_init_mtx(&sc->sc_rx_ch, &sc->sc_mtx, 0); + callout_init(&sc->sc_rx_ch, 1); + /* Create local taskq. */ + TASK_INIT(&sc->sc_intr_task, 0, cas_intr_task, sc); + TASK_INIT(&sc->sc_tx_task, 1, cas_tx_task, ifp); + sc->sc_tq = taskqueue_create_fast("cas_taskq", M_WAITOK, + taskqueue_thread_enqueue, &sc->sc_tq); + if (sc->sc_tq == NULL) { + device_printf(sc->sc_dev, "could not create taskqueue\n"); + error = ENXIO; + goto fail_ifnet; + } + taskqueue_start_threads(&sc->sc_tq, 1, PI_NET, "%s taskq", + device_get_nameunit(sc->sc_dev)); /* Make sure the chip is stopped. */ cas_reset(sc); @@ -211,7 +224,7 @@ cas_attach(struct cas_softc *sc) BUS_SPACE_MAXSIZE, 0, BUS_SPACE_MAXSIZE, 0, NULL, NULL, &sc->sc_pdmatag); if (error != 0) - goto fail_ifnet; + goto fail_taskq; error = bus_dma_tag_create(sc->sc_pdmatag, 1, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, @@ -422,6 +435,8 @@ cas_attach(struct cas_softc *sc) bus_dma_tag_destroy(sc->sc_rdmatag); fail_ptag: bus_dma_tag_destroy(sc->sc_pdmatag); + fail_taskq: + taskqueue_free(sc->sc_tq); fail_ifnet: if_free(ifp); return (error); @@ -433,13 +448,16 @@ cas_detach(struct cas_softc *sc) struct ifnet *ifp = sc->sc_ifp; int i; + ether_ifdetach(ifp); CAS_LOCK(sc); cas_stop(ifp); CAS_UNLOCK(sc); callout_drain(&sc->sc_tick_ch); callout_drain(&sc->sc_rx_ch); - ether_ifdetach(ifp); + taskqueue_drain(sc->sc_tq, &sc->sc_intr_task); + taskqueue_drain(sc->sc_tq, &sc->sc_tx_task); if_free(ifp); + taskqueue_free(sc->sc_tq); device_delete_child(sc->sc_dev, sc->sc_miibus); for (i = 0; i < CAS_NRXDESC; i++) @@ -586,12 +604,11 @@ static void cas_tick(void *arg) { struct cas_softc *sc = arg; - struct ifnet *ifp; + struct ifnet *ifp = sc->sc_ifp; uint32_t v; CAS_LOCK_ASSERT(sc, MA_OWNED); - ifp = sc->sc_ifp; /* * Unload collision and error counters. */ @@ -622,8 +639,10 @@ cas_tick(void *arg) mii_tick(sc->sc_mii); - if (cas_watchdog(sc) == EJUSTRETURN) - return; + if (sc->sc_txfree != CAS_MAXTXFREE) + cas_tint(sc); + + cas_watchdog(sc); callout_reset(&sc->sc_tick_ch, hz, cas_tick, sc); } @@ -915,6 +934,9 @@ cas_init_locked(struct cas_softc *sc) CAS_LOCK_ASSERT(sc, MA_OWNED); + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + return; + #ifdef CAS_DEBUG CTR2(KTR_CAS, "%s: %s: calling stop", device_get_name(sc->sc_dev), __func__); @@ -994,7 +1016,7 @@ cas_init_locked(struct cas_softc *sc) /* Set up interrupts. */ CAS_WRITE_4(sc, CAS_INTMASK, - ~(CAS_INTR_TX_INT_ME | CAS_INTR_TX_ALL | CAS_INTR_TX_TAG_ERR | + ~(CAS_INTR_TX_INT_ME | CAS_INTR_TX_TAG_ERR | CAS_INTR_RX_DONE | CAS_INTR_RX_BUF_NA | CAS_INTR_RX_TAG_ERR | CAS_INTR_RX_COMP_FULL | CAS_INTR_RX_BUF_AEMPTY | CAS_INTR_RX_COMP_AFULL | CAS_INTR_RX_LEN_MMATCH | @@ -1003,6 +1025,8 @@ cas_init_locked(struct cas_softc *sc) | CAS_INTR_PCS_INT | CAS_INTR_MIF #endif )); + /* Don't clear top level interrupts when CAS_STATUS_ALIAS is read. */ + CAS_WRITE_4(sc, CAS_CLEAR_ALIAS, 0); CAS_WRITE_4(sc, CAS_MAC_RX_MASK, ~CAS_MAC_RX_OVERFLOW); CAS_WRITE_4(sc, CAS_MAC_TX_MASK, ~(CAS_MAC_TX_UNDERRUN | CAS_MAC_TX_MAX_PKT_ERR)); @@ -1240,7 +1264,7 @@ cas_load_txmbuf(struct cas_softc *sc, st CTR3(KTR_CAS, "%s: start of frame at segment %d, TX %d", __func__, seg, nexttx); #endif - if (sc->sc_txwin += nsegs > CAS_NTXSEGS * 2 / 3) { + if (sc->sc_txwin += nsegs > CAS_MAXTXFREE * 2 / 3) { sc->sc_txwin = 0; sc->sc_txdescs[txs->txs_firstdesc].cd_flags |= htole64(cflags | CAS_TD_START_OF_FRAME | CAS_TD_INT_ME); @@ -1351,13 +1375,12 @@ cas_init_regs(struct cas_softc *sc) } static void -cas_start(struct ifnet *ifp) +cas_tx_task(void *arg, int pending __unused) { - struct cas_softc *sc = ifp->if_softc; + struct ifnet *ifp; - CAS_LOCK(sc); - cas_start_locked(ifp); - CAS_UNLOCK(sc); + ifp = (struct ifnet *)arg; + cas_start(ifp); } static inline void @@ -1379,17 +1402,22 @@ cas_txkick(struct cas_softc *sc) } static void -cas_start_locked(struct ifnet *ifp) +cas_start(struct ifnet *ifp) { struct cas_softc *sc = ifp->if_softc; struct mbuf *m; int kicked, ntx; - CAS_LOCK_ASSERT(sc, MA_OWNED); + CAS_LOCK(sc); if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != - IFF_DRV_RUNNING || (sc->sc_flags & CAS_LINK) == 0) + IFF_DRV_RUNNING || (sc->sc_flags & CAS_LINK) == 0) { + CAS_UNLOCK(sc); return; + } + + if (sc->sc_txfree < CAS_MAXTXFREE / 4) + cas_tint(sc); #ifdef CAS_DEBUG CTR4(KTR_CAS, "%s: %s: txfree %d, txnext %d", @@ -1434,6 +1462,8 @@ cas_start_locked(struct ifnet *ifp) sc->sc_wdog_timer); #endif } + + CAS_UNLOCK(sc); } static void @@ -1530,17 +1560,10 @@ cas_tint(struct cas_softc *sc) #endif if (progress) { - if (sc->sc_txfree == CAS_NTXDESC - 1) - sc->sc_txwin = 0; - - /* - * We freed some descriptors, so reset IFF_DRV_OACTIVE - * and restart. - */ + /* We freed some descriptors, so reset IFF_DRV_OACTIVE. */ ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; if (STAILQ_EMPTY(&sc->sc_txdirtyq)) sc->sc_wdog_timer = 0; - cas_start_locked(ifp); } #ifdef CAS_DEBUG @@ -1554,7 +1577,7 @@ cas_rint_timeout(void *arg) { struct cas_softc *sc = arg; - CAS_LOCK_ASSERT(sc, MA_OWNED); + CAS_LOCK_ASSERT(sc, MA_NOTOWNED); cas_rint(sc); } @@ -1569,7 +1592,7 @@ cas_rint(struct cas_softc *sc) uint32_t rxhead; u_int idx, idx2, len, off, skip; - CAS_LOCK_ASSERT(sc, MA_OWNED); + CAS_LOCK_ASSERT(sc, MA_NOTOWNED); callout_stop(&sc->sc_rx_ch); @@ -1674,14 +1697,16 @@ cas_rint(struct cas_softc *sc) refcount_acquire(&rxds->rxds_refcount); bus_dmamap_sync(sc->sc_rdmatag, rxds->rxds_dmamap, BUS_DMASYNC_POSTREAD); +#if __FreeBSD_version < 800016 MEXTADD(m, (caddr_t)rxds->rxds_buf + off * 256 + ETHER_ALIGN, len, cas_free, -#if __FreeBSD_version < 800016 - rxds, + rxds, M_RDONLY, EXT_NET_DRV); #else + MEXTADD(m, (caddr_t)rxds->rxds_buf + + off * 256 + ETHER_ALIGN, len, cas_free, sc, (void *)(uintptr_t)idx, -#endif M_RDONLY, EXT_NET_DRV); +#endif if ((m->m_flags & M_EXT) == 0) { m_freem(m); m = NULL; @@ -1695,9 +1720,7 @@ cas_rint(struct cas_softc *sc) cas_rxcksum(m, CAS_GET(word4, CAS_RC4_TCP_CSUM)); /* Pass it on. */ - CAS_UNLOCK(sc); (*ifp->if_input)(ifp, m); - CAS_LOCK(sc); } else ifp->if_ierrors++; @@ -1719,14 +1742,16 @@ cas_rint(struct cas_softc *sc) m->m_len = min(CAS_PAGE_SIZE - off, len); bus_dmamap_sync(sc->sc_rdmatag, rxds->rxds_dmamap, BUS_DMASYNC_POSTREAD); - MEXTADD(m, (caddr_t)rxds->rxds_buf + off, - m->m_len, cas_free, #if __FreeBSD_version < 800016 - rxds, + MEXTADD(m, (caddr_t)rxds->rxds_buf + off, + m->m_len, cas_free, rxds, M_RDONLY, + EXT_NET_DRV); #else - sc, (void *)(uintptr_t)idx, + MEXTADD(m, (caddr_t)rxds->rxds_buf + off, + m->m_len, cas_free, sc, + (void *)(uintptr_t)idx, M_RDONLY, + EXT_NET_DRV); #endif - M_RDONLY, EXT_NET_DRV); if ((m->m_flags & M_EXT) == 0) { m_freem(m); m = NULL; @@ -1753,14 +1778,16 @@ cas_rint(struct cas_softc *sc) bus_dmamap_sync(sc->sc_rdmatag, rxds2->rxds_dmamap, BUS_DMASYNC_POSTREAD); - MEXTADD(m2, (caddr_t)rxds2->rxds_buf, - m2->m_len, cas_free, #if __FreeBSD_version < 800016 - rxds2, + MEXTADD(m2, (caddr_t)rxds2->rxds_buf, + m2->m_len, cas_free, rxds2, + M_RDONLY, EXT_NET_DRV); #else + MEXTADD(m2, (caddr_t)rxds2->rxds_buf, + m2->m_len, cas_free, sc, (void *)(uintptr_t)idx2, -#endif M_RDONLY, EXT_NET_DRV); +#endif if ((m2->m_flags & M_EXT) == 0) { m_freem(m2); m2 = NULL; @@ -1781,9 +1808,7 @@ cas_rint(struct cas_softc *sc) cas_rxcksum(m, CAS_GET(word4, CAS_RC4_TCP_CSUM)); /* Pass it on. */ - CAS_UNLOCK(sc); (*ifp->if_input)(ifp, m); - CAS_LOCK(sc); } else ifp->if_ierrors++; @@ -1799,6 +1824,8 @@ cas_rint(struct cas_softc *sc) skip: cas_rxcompinit(&sc->sc_rxcomps[sc->sc_rxcptr]); + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + break; } CAS_CDSYNC(sc, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); CAS_WRITE_4(sc, CAS_RX_COMP_TAIL, sc->sc_rxcptr); @@ -1819,7 +1846,7 @@ cas_free(void *arg1, void *arg2) { struct cas_rxdsoft *rxds; struct cas_softc *sc; - u_int idx, locked; + u_int idx; #if __FreeBSD_version < 800016 rxds = arg2; @@ -1837,18 +1864,17 @@ cas_free(void *arg1, void *arg2) * NB: this function can be called via m_freem(9) within * this driver! */ - if ((locked = CAS_LOCK_OWNED(sc)) == 0) - CAS_LOCK(sc); + cas_add_rxdesc(sc, idx); - if (locked == 0) - CAS_UNLOCK(sc); } static inline void cas_add_rxdesc(struct cas_softc *sc, u_int idx) { + u_int locked; - CAS_LOCK_ASSERT(sc, MA_OWNED); + if ((locked = CAS_LOCK_OWNED(sc)) == 0) + CAS_LOCK(sc); bus_dmamap_sync(sc->sc_rdmatag, sc->sc_rxdsoft[idx].rxds_dmamap, BUS_DMASYNC_PREREAD); @@ -1866,13 +1892,19 @@ cas_add_rxdesc(struct cas_softc *sc, u_i CAS_WRITE_4(sc, CAS_RX_KICK, (sc->sc_rxdptr + CAS_NRXDESC - 4) & CAS_NRXDESC_MASK); } + + if (locked == 0) + CAS_UNLOCK(sc); } static void cas_eint(struct cas_softc *sc, u_int status) { + struct ifnet *ifp = sc->sc_ifp; + + CAS_LOCK_ASSERT(sc, MA_NOTOWNED); - sc->sc_ifp->if_ierrors++; + ifp->if_ierrors++; device_printf(sc->sc_dev, "%s: status 0x%x", __func__, status); if ((status & CAS_INTR_PCI_ERROR_INT) != 0) { @@ -1886,21 +1918,43 @@ cas_eint(struct cas_softc *sc, u_int sta } printf("\n"); - cas_init_locked(sc); - cas_start_locked(sc->sc_ifp); + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + cas_init(sc); + if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + taskqueue_enqueue(sc->sc_tq, &sc->sc_tx_task); } -static void +static int cas_intr(void *v) { struct cas_softc *sc = v; + + if (__predict_false((CAS_READ_4(sc, CAS_STATUS_ALIAS) & + CAS_INTR_SUMMARY) == 0)) + return (FILTER_STRAY); + + /* Disable interrupts. */ + CAS_WRITE_4(sc, CAS_INTMASK, 0xffffffff); + taskqueue_enqueue(sc->sc_tq, &sc->sc_intr_task); + + return (FILTER_HANDLED); +} + +static void +cas_intr_task(void *arg, int pending __unused) +{ + struct cas_softc *sc = arg; + struct ifnet *ifp = sc->sc_ifp; uint32_t status, status2; - status = CAS_READ_4(sc, CAS_STATUS); - if (__predict_false((status & CAS_INTR_SUMMARY) == 0)) + CAS_LOCK_ASSERT(sc, MA_NOTOWNED); + + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) return; - CAS_LOCK(sc); + status = CAS_READ_4(sc, CAS_STATUS); + if (__predict_false((status & CAS_INTR_SUMMARY) == 0)) + goto done; #ifdef CAS_DEBUG CTR4(KTR_CAS, "%s: %s: cplt %x, status %x", @@ -1941,7 +1995,6 @@ cas_intr(void *v) (CAS_INTR_TX_TAG_ERR | CAS_INTR_RX_TAG_ERR | CAS_INTR_RX_LEN_MMATCH | CAS_INTR_PCI_ERROR_INT)) != 0)) { cas_eint(sc, status); - CAS_UNLOCK(sc); return; } @@ -1968,21 +2021,48 @@ cas_intr(void *v) (CAS_INTR_RX_DONE | CAS_INTR_RX_BUF_NA | CAS_INTR_RX_COMP_FULL | CAS_INTR_RX_BUF_AEMPTY | CAS_INTR_RX_COMP_AFULL)) != 0) { cas_rint(sc); +#ifdef CAS_DEBUG if (__predict_false((status & (CAS_INTR_RX_BUF_NA | CAS_INTR_RX_COMP_FULL | CAS_INTR_RX_BUF_AEMPTY | CAS_INTR_RX_COMP_AFULL)) != 0)) device_printf(sc->sc_dev, "RX fault, status %x\n", status); +#endif } if ((status & - (CAS_INTR_TX_INT_ME | CAS_INTR_TX_ALL | CAS_INTR_TX_DONE)) != 0) + (CAS_INTR_TX_INT_ME | CAS_INTR_TX_ALL | CAS_INTR_TX_DONE)) != 0) { + CAS_LOCK(sc); cas_tint(sc); + CAS_UNLOCK(sc); + } - CAS_UNLOCK(sc); + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + return; + else if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + taskqueue_enqueue(sc->sc_tq, &sc->sc_tx_task); + + status = CAS_READ_4(sc, CAS_STATUS_ALIAS); + if (__predict_false((status & CAS_INTR_SUMMARY) != 0)) { + taskqueue_enqueue(sc->sc_tq, &sc->sc_intr_task); + return; + } + + done: + /* Re-enable interrupts. */ + CAS_WRITE_4(sc, CAS_INTMASK, + ~(CAS_INTR_TX_INT_ME | CAS_INTR_TX_TAG_ERR | + CAS_INTR_RX_DONE | CAS_INTR_RX_BUF_NA | CAS_INTR_RX_TAG_ERR | + CAS_INTR_RX_COMP_FULL | CAS_INTR_RX_BUF_AEMPTY | + CAS_INTR_RX_COMP_AFULL | CAS_INTR_RX_LEN_MMATCH | + CAS_INTR_PCI_ERROR_INT +#ifdef CAS_DEBUG + | CAS_INTR_PCS_INT | CAS_INTR_MIF +#endif + )); } -static int +static void cas_watchdog(struct cas_softc *sc) { struct ifnet *ifp = sc->sc_ifp; @@ -2003,7 +2083,7 @@ cas_watchdog(struct cas_softc *sc) #endif if (sc->sc_wdog_timer == 0 || --sc->sc_wdog_timer != 0) - return (0); + return; if ((sc->sc_flags & CAS_LINK) != 0) device_printf(sc->sc_dev, "device timeout\n"); @@ -2012,9 +2092,10 @@ cas_watchdog(struct cas_softc *sc) ++ifp->if_oerrors; /* Try to get more packets going. */ + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; cas_init_locked(sc); - cas_start_locked(ifp); - return (EJUSTRETURN); + if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + taskqueue_enqueue(sc->sc_tq, &sc->sc_tx_task); } static void @@ -2378,7 +2459,8 @@ cas_ioctl(struct ifnet *ifp, u_long cmd, case SIOCADDMULTI: case SIOCDELMULTI: CAS_LOCK(sc); - cas_setladrf(sc); + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + cas_setladrf(sc); CAS_UNLOCK(sc); break; case SIOCSIFMTU: @@ -2729,7 +2811,7 @@ cas_pci_attach(device_t dev) } if (bus_setup_intr(dev, sc->sc_res[CAS_RES_INTR], INTR_TYPE_NET | - INTR_MPSAFE, NULL, cas_intr, sc, &sc->sc_ih) != 0) { + INTR_MPSAFE, cas_intr, NULL, sc, &sc->sc_ih) != 0) { device_printf(dev, "failed to set up interrupt\n"); cas_detach(sc); goto fail; Modified: stable/7/sys/dev/cas/if_casvar.h ============================================================================== --- head/sys/dev/cas/if_casvar.h Mon Jun 15 18:22:41 2009 (r194246) +++ stable/7/sys/dev/cas/if_casvar.h Sun Sep 20 12:08:29 2009 (r197343) @@ -138,6 +138,9 @@ struct cas_softc { u_char sc_enaddr[ETHER_ADDR_LEN]; struct callout sc_tick_ch; /* tick callout */ struct callout sc_rx_ch; /* delayed RX callout */ + struct task sc_intr_task; + struct task sc_tx_task; + struct taskqueue *sc_tq; u_int sc_wdog_timer; /* watchdog timer */ void *sc_ih; Modified: stable/7/sys/modules/Makefile ============================================================================== --- stable/7/sys/modules/Makefile Sun Sep 20 11:33:39 2009 (r197342) +++ stable/7/sys/modules/Makefile Sun Sep 20 12:08:29 2009 (r197343) @@ -46,6 +46,7 @@ SUBDIR= ${_3dfx} \ ${_canbepm} \ ${_canbus} \ ${_cardbus} \ + cas \ ${_cbb} \ cd9660 \ cd9660_iconv \ Modified: stable/7/sys/sparc64/conf/GENERIC ============================================================================== --- stable/7/sys/sparc64/conf/GENERIC Sun Sep 20 11:33:39 2009 (r197342) +++ stable/7/sys/sparc64/conf/GENERIC Sun Sep 20 12:08:29 2009 (r197343) @@ -164,6 +164,7 @@ device txp # 3Com 3cR990 (``Typhoon'') device miibus # MII bus support #device bfe # Broadcom BCM440x 10/100 Ethernet device bge # Broadcom BCM570xx Gigabit Ethernet +device cas # Sun Cassini/Cassini+ and NS DP83065 Saturn device dc # DEC/Intel 21143 and various workalikes device fxp # Intel EtherExpress PRO/100B (82557, 82558) device gem # Sun GEM/Sun ERI/Apple GMAC From owner-svn-src-stable@FreeBSD.ORG Sun Sep 20 12:12:36 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AAB641065676; Sun, 20 Sep 2009 12:12:36 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 988328FC17; Sun, 20 Sep 2009 12:12:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8KCCabO055935; Sun, 20 Sep 2009 12:12:36 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8KCCauu055933; Sun, 20 Sep 2009 12:12:36 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909201212.n8KCCauu055933@svn.freebsd.org> From: Marius Strobl Date: Sun, 20 Sep 2009 12:12:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197344 - in stable/7/sys: . contrib/pf dev/mpt X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2009 12:12:36 -0000 Author: marius Date: Sun Sep 20 12:12:36 2009 New Revision: 197344 URL: http://svn.freebsd.org/changeset/base/197344 Log: - Remove unused variables. [1] - Remove redundant zeroing of tmf_req which Coverity Prevent(tm) complains about. [2] Submitted by: Christoph Mallon [1] Found with: Coverity Prevent(tm) [2] CID: 2496 [2] Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/mpt/mpt_cam.c Modified: stable/7/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/7/sys/dev/mpt/mpt_cam.c Sun Sep 20 12:08:29 2009 (r197343) +++ stable/7/sys/dev/mpt/mpt_cam.c Sun Sep 20 12:12:36 2009 (r197344) @@ -884,11 +884,6 @@ mpt_sata_pass_reply_handler(struct mpt_s if (req != NULL) { if (reply_frame != NULL) { - MSG_SATA_PASSTHROUGH_REQUEST *pass; - MSG_SATA_PASSTHROUGH_REPLY *reply; - - pass = (MSG_SATA_PASSTHROUGH_REQUEST *)req->req_vbuf; - reply = (MSG_SATA_PASSTHROUGH_REPLY *)reply_frame; req->IOCStatus = le16toh(reply_frame->IOCStatus); } req->state &= ~REQ_STATE_QUEUED; @@ -1063,7 +1058,7 @@ mpt_read_config_info_spi(struct mpt_soft static int mpt_set_initial_config_spi(struct mpt_softc *mpt) { - int i, j, pp1val = ((1 << mpt->mpt_ini_id) << 16) | mpt->mpt_ini_id; + int i, pp1val = ((1 << mpt->mpt_ini_id) << 16) | mpt->mpt_ini_id; int error; mpt->mpt_disc_enable = 0xff; @@ -1101,15 +1096,11 @@ mpt_set_initial_config_spi(struct mpt_so * all targets back to async/narrow. * * We skip this step if the BIOS has already negotiated - * speeds with the targets and does not require us to - * do Domain Validation. + * speeds with the targets. */ i = mpt->mpt_port_page2.PortSettings & MPI_SCSIPORTPAGE2_PORT_MASK_NEGO_MASTER_SETTINGS; - j = mpt->mpt_port_page2.PortFlags & - MPI_SCSIPORTPAGE2_PORT_FLAGS_DV_MASK; - if (i == MPI_SCSIPORTPAGE2_PORT_ALL_MASTER_SETTINGS /* && - j == MPI_SCSIPORTPAGE2_PORT_FLAGS_OFF_DV */) { + if (i == MPI_SCSIPORTPAGE2_PORT_ALL_MASTER_SETTINGS) { mpt_lprt(mpt, MPT_PRT_NEGOTIATION, "honoring BIOS transfer negotiations\n"); } else { @@ -2602,7 +2593,6 @@ mpt_scsi_reply_handler(struct mpt_softc { MSG_SCSI_IO_REQUEST *scsi_req; union ccb *ccb; - target_id_t tgt; if (req->state == REQ_STATE_FREE) { mpt_prt(mpt, "mpt_scsi_reply_handler: req already free\n"); @@ -2617,7 +2607,6 @@ mpt_scsi_reply_handler(struct mpt_softc return (TRUE); } - tgt = scsi_req->TargetID; mpt_req_untimeout(req, mpt_timeout, ccb); ccb->ccb_h.status &= ~CAM_SIM_QUEUED; @@ -2971,13 +2960,9 @@ mpt_fc_els_reply_handler(struct mpt_soft } if (tgt_req) { mpt_tgt_state_t *tgt = MPT_TGT_STATE(mpt, tgt_req); - uint8_t *vbuf; union ccb *ccb = tgt->ccb; uint32_t ct_id; - vbuf = tgt_req->req_vbuf; - vbuf += MPT_RQSL(mpt); - /* * Check to make sure we have the correct command * The reply descriptor in the target state should @@ -3079,7 +3064,6 @@ mpt_scsi_reply_frame_handler(struct mpt_ MSG_SCSI_IO_REPLY *scsi_io_reply; u_int ioc_status; u_int sstate; - u_int loginfo; MPT_DUMP_REPLY_FRAME(mpt, reply_frame); KASSERT(reply_frame->Function == MPI_FUNCTION_SCSI_IO_REQUEST @@ -3090,7 +3074,6 @@ mpt_scsi_reply_frame_handler(struct mpt_ scsi_io_reply = (MSG_SCSI_IO_REPLY *)reply_frame; ioc_status = le16toh(scsi_io_reply->IOCStatus); - loginfo = ioc_status & MPI_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE; ioc_status &= MPI_IOCSTATUS_MASK; sstate = scsi_io_reply->SCSIState; @@ -4040,16 +4023,11 @@ mpt_scsi_send_tmf(struct mpt_softc *mpt, memset(tmf_req, 0, sizeof(*tmf_req)); tmf_req->TargetID = target; tmf_req->Bus = channel; - tmf_req->ChainOffset = 0; tmf_req->Function = MPI_FUNCTION_SCSI_TASK_MGMT; - tmf_req->Reserved = 0; tmf_req->TaskType = type; - tmf_req->Reserved1 = 0; tmf_req->MsgFlags = flags; tmf_req->MsgContext = htole32(mpt->tmf_req->index | scsi_tmf_handler_id); - memset(&tmf_req->LUN, 0, - sizeof(tmf_req->LUN) + sizeof(tmf_req->Reserved2)); if (lun > 256) { tmf_req->LUN[0] = 0x40 | ((lun >> 8) & 0x3f); tmf_req->LUN[1] = lun & 0xff; From owner-svn-src-stable@FreeBSD.ORG Sun Sep 20 12:14:43 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 36CFD1065670; Sun, 20 Sep 2009 12:14:43 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 23B678FC1A; Sun, 20 Sep 2009 12:14:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8KCEg5o056026; Sun, 20 Sep 2009 12:14:42 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8KCEg7E056020; Sun, 20 Sep 2009 12:14:42 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909201214.n8KCEg7E056020@svn.freebsd.org> From: Marius Strobl Date: Sun, 20 Sep 2009 12:14:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197345 - stable/7/share/man/man4 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2009 12:14:43 -0000 Author: marius Date: Sun Sep 20 12:14:42 2009 New Revision: 197345 URL: http://svn.freebsd.org/changeset/base/197345 Log: MFC: r194247 Add a man page for cas(4) and reference it as appropriate. Added: stable/7/share/man/man4/cas.4 - copied unchanged from r194247, head/share/man/man4/cas.4 Modified: stable/7/share/man/man4/ (props changed) stable/7/share/man/man4/Makefile stable/7/share/man/man4/altq.4 stable/7/share/man/man4/miibus.4 stable/7/share/man/man4/vlan.4 Modified: stable/7/share/man/man4/Makefile ============================================================================== --- stable/7/share/man/man4/Makefile Sun Sep 20 12:12:36 2009 (r197344) +++ stable/7/share/man/man4/Makefile Sun Sep 20 12:14:42 2009 (r197345) @@ -46,6 +46,7 @@ MAN= aac.4 \ bt.4 \ cardbus.4 \ carp.4 \ + cas.4 \ ccd.4 \ cd.4 \ cdce.4 \ @@ -448,6 +449,7 @@ MLINKS+=bfe.4 if_bfe.4 MLINKS+=bge.4 if_bge.4 MLINKS+=bktr.4 brooktree.4 MLINKS+=cnw.4 if_cnw.4 +MLINKS+=cas.4 if_cas.4 MLINKS+=crypto.4 cryptodev.4 MLINKS+=cue.4 if_cue.4 MLINKS+=dc.4 if_dc.4 Modified: stable/7/share/man/man4/altq.4 ============================================================================== --- stable/7/share/man/man4/altq.4 Sun Sep 20 12:12:36 2009 (r197344) +++ stable/7/share/man/man4/altq.4 Sun Sep 20 12:14:42 2009 (r197345) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 10, 2009 +.Dd June 14, 2009 .Dt ALTQ 4 .Os .Sh NAME @@ -126,6 +126,7 @@ They have been applied to the following .Xr bce 4 , .Xr bfe 4 , .Xr bge 4 , +.Xr cas 4 , .Xr dc 4 , .Xr de 4 , .Xr ed 4 , Copied: stable/7/share/man/man4/cas.4 (from r194247, head/share/man/man4/cas.4) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/share/man/man4/cas.4 Sun Sep 20 12:14:42 2009 (r197345, copy of r194247, head/share/man/man4/cas.4) @@ -0,0 +1,154 @@ +.\" +.\" Copyright (c) 2009 Marius Strobl +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (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$ +.\" +.Dd June 15, 2009 +.Dt CAS 4 +.Os +.Sh NAME +.Nm cas +.Nd Sun Cassini/Cassini+ and National Semiconductor DP83065 Saturn Gigabit Ethernet driver +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device miibus" +.Cd "device cas" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +if_cas="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver provides support for the Sun Cassini/Cassini+ and National +Semiconductor DP83065 Saturn Gigabit Ethernet controllers found +on-board in Sun UltraSPARC machines and as add-on cards. +.Pp +All controllers supported by the +.Nm +driver have TCP/UDP checksum offload capability for both receive and +transmit, support for the reception and transmission of extended frames +for +.Xr vlan 4 +and an interrupt coalescing/moderation mechanism as well as a 512-bit +multicast hash filter. +.Pp +The +.Nm +driver also supports Jumbo Frames (up to 9022 bytes), which can be +configured via the interface MTU setting. +Selecting an MTU larger than 1500 bytes with the +.Xr ifconfig 8 +utility configures the adapter to receive and transmit Jumbo Frames. +.Sh HARDWARE +.Pp +The chips supported by the +.Nm +driver are: +.Pp +.Bl -bullet -compact +.It +National Semiconductor DP83065 Saturn Gigabit Ethernet +.It +Sun Cassini Gigabit Ethernet +.It +Sun Cassini+ Gigabit Ethernet +.El +.Pp +The +following add-on cards are known to work with the +.Nm +driver at this time: +.Pp +.Bl -bullet -compact +.It +Sun GigaSwift Ethernet 1.0 UTP (Cassini) +(part no.\& 501-5902) +.It +Sun GigaSwift Ethernet UTP (GCS) +(part no.\& 501-6719) +.It +Sun Quad GigaSwift Ethernet UTP (QGE) +(part no.\& 501-6522) +.El +.Sh NOTES +On sparc64 the +.Nm +driver respects the +.Va local-mac-address? +system configuration variable which can be set in the Open Firmware boot +monitor using the +.Ic setenv +command or by +.Xr eeprom 8 . +If set to +.Dq Li false +(the default), the +.Nm +driver will use the system's default MAC address for all of its devices. +If set to +.Dq Li true , +the unique MAC address of each interface is used if present rather than +the system's default MAC address. +.Pp +Supported interfaces having their own MAC address include on-board +versions on boards equipped with more than one Ethernet interface and +all add-on cards. +.Sh SEE ALSO +.Xr altq 4 , +.Xr miibus 4 , +.Xr netintro 4 , +.Xr vlan 4 , +.Xr eeprom 8 , +.Xr ifconfig 8 +.Sh HISTORY +The +.Nm +device driver appeared in +.Fx 8.0 +and +.Fx 7.3 . +It is named after the +.Nm +driver which first appeared in +.Ox 4.1 +and supports the same set of controllers but is otherwise unrelated. +.Sh AUTHORS +.An -nosplit +The +.Nm +driver was written by +.An Marius Strobl +.Aq marius@FreeBSD.org +based on the +.Xr gem 4 +driver. Modified: stable/7/share/man/man4/miibus.4 ============================================================================== --- stable/7/share/man/man4/miibus.4 Sun Sep 20 12:12:36 2009 (r197344) +++ stable/7/share/man/man4/miibus.4 Sun Sep 20 12:14:42 2009 (r197345) @@ -8,7 +8,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 10, 2009 +.Dd June 14, 2009 .Dt MIIBUS 4 .Os .Sh NAME @@ -61,6 +61,8 @@ Broadcom NetXtreme II Gigabit Ethernet Broadcom BCM4401 Ethernet .It Xr bge 4 Broadcom BCM570xx Gigabit Ethernet +.It Xr cas 4 +Sun Cassini/Cassini+ and National Semiconductor DP83065 Saturn .It Xr dc 4 DEC/Intel 21143 and various workalikes .It Xr ed 4 @@ -137,6 +139,7 @@ but as a result are not well behaved new .Xr bce 4 , .Xr bfe 4 , .Xr bge 4 , +.Xr cas 4 , .Xr dc 4 , .Xr ed 4 , .Xr et 4 , Modified: stable/7/share/man/man4/vlan.4 ============================================================================== --- stable/7/share/man/man4/vlan.4 Sun Sep 20 12:12:36 2009 (r197344) +++ stable/7/share/man/man4/vlan.4 Sun Sep 20 12:14:42 2009 (r197345) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 10, 2009 +.Dd June 14, 2009 .Dt VLAN 4 .Os .Sh NAME @@ -161,6 +161,7 @@ The following interfaces support long fr .Nm natively: .Xr bfe 4 , +.Xr cas 4 , .Xr dc 4 , .Xr fwe 4 , .Xr fxp 4 , From owner-svn-src-stable@FreeBSD.ORG Sun Sep 20 12:19:22 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3EF3F106566B; Sun, 20 Sep 2009 12:19:22 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2C9C88FC14; Sun, 20 Sep 2009 12:19:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8KCJMhQ056158; Sun, 20 Sep 2009 12:19:22 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8KCJMwO056156; Sun, 20 Sep 2009 12:19:22 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909201219.n8KCJMwO056156@svn.freebsd.org> From: Marius Strobl Date: Sun, 20 Sep 2009 12:19:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197346 - stable/7/release/doc/en_US.ISO8859-1/hardware X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2009 12:19:22 -0000 Author: marius Date: Sun Sep 20 12:19:21 2009 New Revision: 197346 URL: http://svn.freebsd.org/changeset/base/197346 Log: MFC: r194248 Add cas(4). Modified: stable/7/release/doc/en_US.ISO8859-1/hardware/article.sgml (contents, props changed) Modified: stable/7/release/doc/en_US.ISO8859-1/hardware/article.sgml ============================================================================== --- stable/7/release/doc/en_US.ISO8859-1/hardware/article.sgml Sun Sep 20 12:14:42 2009 (r197345) +++ stable/7/release/doc/en_US.ISO8859-1/hardware/article.sgml Sun Sep 20 12:19:21 2009 (r197346) @@ -699,6 +699,8 @@ &hwlist.bge; + &hwlist.cas; + &hwlist.cdce; [&arch.amd64;, &arch.i386;] Crystal Semiconductor CS89x0-based NICs From owner-svn-src-stable@FreeBSD.ORG Sun Sep 20 12:24:55 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 590E5106568B; Sun, 20 Sep 2009 12:24:55 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 46F378FC08; Sun, 20 Sep 2009 12:24:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8KCOtNU056311; Sun, 20 Sep 2009 12:24:55 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8KCOt9K056309; Sun, 20 Sep 2009 12:24:55 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909201224.n8KCOt9K056309@svn.freebsd.org> From: Marius Strobl Date: Sun, 20 Sep 2009 12:24:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197347 - stable/7/usr.sbin/sysinstall X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2009 12:24:55 -0000 Author: marius Date: Sun Sep 20 12:24:55 2009 New Revision: 197347 URL: http://svn.freebsd.org/changeset/base/197347 Log: MFC: r194249 Add cas(4). Modified: stable/7/usr.sbin/sysinstall/ (props changed) stable/7/usr.sbin/sysinstall/devices.c Modified: stable/7/usr.sbin/sysinstall/devices.c ============================================================================== --- stable/7/usr.sbin/sysinstall/devices.c Sun Sep 20 12:19:21 2009 (r197346) +++ stable/7/usr.sbin/sysinstall/devices.c Sun Sep 20 12:24:55 2009 (r197347) @@ -104,6 +104,7 @@ static struct _devname { NETWORK("bce", "Broadcom NetXtreme II Gigabit Ethernet card"), NETWORK("bfe", "Broadcom BCM440x PCI Ethernet card"), NETWORK("bge", "Broadcom BCM570x PCI Gigabit Ethernet card"), + NETWORK("cas", "Sun Cassini/Cassini+ or NS DP83065 Saturn Ethernet"), NETWORK("cue", "CATC USB Ethernet adapter"), NETWORK("cxgb", "Chelsio T3 10Gb Ethernet card"), NETWORK("fpa", "DEC DEFPA PCI FDDI card"), From owner-svn-src-stable@FreeBSD.ORG Sun Sep 20 12:56:51 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2A3B71065693; Sun, 20 Sep 2009 12:56:51 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 161F78FC13; Sun, 20 Sep 2009 12:56:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8KCupqk057071; Sun, 20 Sep 2009 12:56:51 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8KCuofu057064; Sun, 20 Sep 2009 12:56:50 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909201256.n8KCuofu057064@svn.freebsd.org> From: Marius Strobl Date: Sun, 20 Sep 2009 12:56:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197349 - in stable/7/sys: . conf contrib/pf dev/gem modules/gem X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2009 12:56:51 -0000 Author: marius Date: Sun Sep 20 12:56:50 2009 New Revision: 197349 URL: http://svn.freebsd.org/changeset/base/197349 Log: MFC: r194763, r194886 - Initialize the ifnet structure, especially if_dname, before probing the PHYs as some PHY drivers use it (but probably shouldn't). How gem(4) has worked with brgphy(4) on powerpc without this so far is unclear to me. - Call ether_ifdetach(9) before stopping the controller and the callouts. The consensus is that the latter is now safe to do and should also solve the problem of active BPF listeners clearing promiscuous mode can result in the tick callout being restarted which in turn will trigger a panic once it's actually gone. - Introduce a dying flag which is set during detach and checked in gem_ioctl() in order to prevent active BPF listeners to clear promiscuous mode which may lead to the tick callout being restarted which will trigger a panic once it's actually gone. - In gem_stop() reset rather than just disable the transmitter and receiver in order to ensure we're not unloading DMA maps still in use by the hardware. [1] - The blanking time is specified in PCI clocks so we should use twice the value when operating at 66MHz. - Spell some 2 as ETHER_ALIGN and a 19 as GEM_STATUS_TX_COMPLETION_SHFT to make the actual intentions clear. - As we don't unload the peak attempts counter ignore its overflow interrupts. - Remove a stale setting of a variable to GEM_TD_INTERRUPT_ME which isn't used afterwards. - For optimum performance increment the TX kick register in multiples of 4 if possible as suggested by the documentation. - Partially revert r164931; drivers should only clear the watchdog timer if all outstanding TX descriptors are done. - Fix some debugging strings. - Add a missing BUS_DMASYNC_POSTWRITE in gem_rint(). - As the error paths in the interrupt handler are generally unlikely predict them as false. - Add support for the SBus version of the GEM controller. [2] - Add some lock assertions. - Improve some comments. - Fix some more or less cosmetic issues in the code of the PCI front-end. - Change some softc members to be unsigned where more appropriate and remove unused ones. Obtained from: NetBSD (partially) [2], OpenBSD [1] Added: stable/7/sys/dev/gem/if_gem_sbus.c - copied unchanged from r194763, head/sys/dev/gem/if_gem_sbus.c Modified: stable/7/sys/ (props changed) stable/7/sys/conf/files stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/gem/if_gem.c stable/7/sys/dev/gem/if_gem_pci.c stable/7/sys/dev/gem/if_gemreg.h stable/7/sys/dev/gem/if_gemvar.h stable/7/sys/modules/gem/Makefile Modified: stable/7/sys/conf/files ============================================================================== --- stable/7/sys/conf/files Sun Sep 20 12:40:56 2009 (r197348) +++ stable/7/sys/conf/files Sun Sep 20 12:56:50 2009 (r197349) @@ -841,6 +841,7 @@ dev/flash/at45d.c optional at45d dev/fxp/if_fxp.c optional fxp dev/gem/if_gem.c optional gem dev/gem/if_gem_pci.c optional gem pci +dev/gem/if_gem_sbus.c optional gem sbus dev/hatm/if_hatm.c optional hatm pci dev/hatm/if_hatm_intr.c optional hatm pci dev/hatm/if_hatm_ioctl.c optional hatm pci Modified: stable/7/sys/dev/gem/if_gem.c ============================================================================== --- stable/7/sys/dev/gem/if_gem.c Sun Sep 20 12:40:56 2009 (r197348) +++ stable/7/sys/dev/gem/if_gem.c Sun Sep 20 12:56:50 2009 (r197349) @@ -84,7 +84,7 @@ __FBSDID("$FreeBSD$"); CTASSERT(powerof2(GEM_NRXDESC) && GEM_NRXDESC >= 32 && GEM_NRXDESC <= 8192); CTASSERT(powerof2(GEM_NTXDESC) && GEM_NTXDESC >= 32 && GEM_NTXDESC <= 8192); -#define TRIES 10000 +#define GEM_TRIES 10000 /* * The hardware supports basic TCP/UDP checksum offloading. However, @@ -119,7 +119,7 @@ static void gem_rint(struct gem_softc *s #ifdef GEM_RINT_TIMEOUT static void gem_rint_timeout(void *arg); #endif -static __inline void gem_rxcksum(struct mbuf *m, uint64_t flags); +static inline void gem_rxcksum(struct mbuf *m, uint64_t flags); static void gem_rxdrain(struct gem_softc *sc); static void gem_setladrf(struct gem_softc *sc); static void gem_start(struct ifnet *ifp); @@ -127,6 +127,7 @@ static void gem_start_locked(struct ifne static void gem_stop(struct ifnet *ifp, int disable); static void gem_tick(void *arg); static void gem_tint(struct gem_softc *sc); +static inline void gem_txkick(struct gem_softc *sc); static int gem_watchdog(struct gem_softc *sc); devclass_t gem_devclass; @@ -151,9 +152,24 @@ gem_attach(struct gem_softc *sc) int error, i; uint32_t v; + if (bootverbose) + device_printf(sc->sc_dev, "flags=0x%x\n", sc->sc_flags); + + /* Set up ifnet structure. */ ifp = sc->sc_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) return (ENOSPC); + sc->sc_csum_features = GEM_CSUM_FEATURES; + ifp->if_softc = sc; + if_initname(ifp, device_get_name(sc->sc_dev), + device_get_unit(sc->sc_dev)); + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; + ifp->if_start = gem_start; + ifp->if_ioctl = gem_ioctl; + ifp->if_init = gem_init; + IFQ_SET_MAXLEN(&ifp->if_snd, GEM_TXQUEUELEN); + ifp->if_snd.ifq_drv_maxlen = GEM_TXQUEUELEN; + IFQ_SET_READY(&ifp->if_snd); callout_init_mtx(&sc->sc_tick_ch, &sc->sc_mtx, 0); #ifdef GEM_RINT_TIMEOUT @@ -161,27 +177,26 @@ gem_attach(struct gem_softc *sc) #endif /* Make sure the chip is stopped. */ - ifp->if_softc = sc; gem_reset(sc); error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, 0, BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL, &sc->sc_pdmatag); - if (error) + if (error != 0) goto fail_ifnet; error = bus_dma_tag_create(sc->sc_pdmatag, 1, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, 1, MCLBYTES, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->sc_rdmatag); - if (error) + if (error != 0) goto fail_ptag; error = bus_dma_tag_create(sc->sc_pdmatag, 1, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES * GEM_NTXSEGS, GEM_NTXSEGS, MCLBYTES, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->sc_tdmatag); - if (error) + if (error != 0) goto fail_rtag; error = bus_dma_tag_create(sc->sc_pdmatag, PAGE_SIZE, 0, @@ -189,7 +204,7 @@ gem_attach(struct gem_softc *sc) sizeof(struct gem_control_data), 1, sizeof(struct gem_control_data), 0, NULL, NULL, &sc->sc_cdmatag); - if (error) + if (error != 0) goto fail_ttag; /* @@ -199,7 +214,7 @@ gem_attach(struct gem_softc *sc) if ((error = bus_dmamem_alloc(sc->sc_cdmatag, (void **)&sc->sc_control_data, BUS_DMA_WAITOK | BUS_DMA_COHERENT | BUS_DMA_ZERO, - &sc->sc_cddmamap))) { + &sc->sc_cddmamap)) != 0) { device_printf(sc->sc_dev, "unable to allocate control data, error = %d\n", error); goto fail_ctag; @@ -338,19 +353,6 @@ gem_attach(struct gem_softc *sc) device_printf(sc->sc_dev, "%ukB RX FIFO, %ukB TX FIFO\n", sc->sc_rxfifosize / 1024, v / 16); - sc->sc_csum_features = GEM_CSUM_FEATURES; - /* Initialize ifnet structure. */ - ifp->if_softc = sc; - if_initname(ifp, device_get_name(sc->sc_dev), - device_get_unit(sc->sc_dev)); - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - ifp->if_start = gem_start; - ifp->if_ioctl = gem_ioctl; - ifp->if_init = gem_init; - IFQ_SET_MAXLEN(&ifp->if_snd, GEM_TXQUEUELEN); - ifp->if_snd.ifq_drv_maxlen = GEM_TXQUEUELEN; - IFQ_SET_READY(&ifp->if_snd); - /* Attach the interface. */ ether_ifattach(ifp, sc->sc_enaddr); @@ -401,6 +403,7 @@ gem_detach(struct gem_softc *sc) struct ifnet *ifp = sc->sc_ifp; int i; + ether_ifdetach(ifp); GEM_LOCK(sc); gem_stop(ifp, 1); GEM_UNLOCK(sc); @@ -408,7 +411,6 @@ gem_detach(struct gem_softc *sc) #ifdef GEM_RINT_TIMEOUT callout_drain(&sc->sc_rx_ch); #endif - ether_ifdetach(ifp); if_free(ifp); device_delete_child(sc->sc_dev, sc->sc_miibus); @@ -456,7 +458,7 @@ gem_resume(struct gem_softc *sc) GEM_UNLOCK(sc); } -static __inline void +static inline void gem_rxcksum(struct mbuf *m, uint64_t flags) { struct ether_header *eh; @@ -535,12 +537,11 @@ static void gem_tick(void *arg) { struct gem_softc *sc = arg; - struct ifnet *ifp; + struct ifnet *ifp = sc->sc_ifp; uint32_t v; GEM_LOCK_ASSERT(sc, MA_OWNED); - ifp = sc->sc_ifp; /* * Unload collision and error counters. */ @@ -584,7 +585,7 @@ gem_bitwait(struct gem_softc *sc, u_int int i; uint32_t reg; - for (i = TRIES; i--; DELAY(100)) { + for (i = GEM_TRIES; i--; DELAY(100)) { reg = GEM_BANKN_READ_M(bank, 4, sc, r); if ((reg & clr) == 0 && (reg & set) == set) return (1); @@ -593,8 +594,7 @@ gem_bitwait(struct gem_softc *sc, u_int } static void -gem_reset(sc) - struct gem_softc *sc; +gem_reset(struct gem_softc *sc) { #ifdef GEM_DEBUG @@ -644,9 +644,8 @@ gem_stop(struct ifnet *ifp, int disable) callout_stop(&sc->sc_rx_ch); #endif - /* XXX should we reset these instead? */ - gem_disable_tx(sc); - gem_disable_rx(sc); + gem_reset_tx(sc); + gem_reset_rx(sc); /* * Release any queued transmit buffers. @@ -721,7 +720,7 @@ gem_reset_rxdma(struct gem_softc *sc) if (sc->sc_rxsoft[i].rxs_mbuf != NULL) GEM_UPDATE_RXDESC(sc, i); sc->sc_rxptr = 0; - GEM_CDSYNC(sc, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); + GEM_CDSYNC(sc, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); /* NOTE: we use only 32-bit DMA addresses here. */ GEM_BANK1_WRITE_4(sc, GEM_RX_RING_PTR_HI, 0); @@ -732,9 +731,11 @@ gem_reset_rxdma(struct gem_softc *sc) ((ETHER_HDR_LEN + sizeof(struct ip)) << GEM_RX_CONFIG_CXM_START_SHFT) | (GEM_THRSH_1024 << GEM_RX_CONFIG_FIFO_THRS_SHIFT) | - (2 << GEM_RX_CONFIG_FBOFF_SHFT)); + (ETHER_ALIGN << GEM_RX_CONFIG_FBOFF_SHFT)); + /* Adjust for the SBus clock probably isn't worth the fuzz. */ GEM_BANK1_WRITE_4(sc, GEM_RX_BLANKING, - (6 << GEM_RX_BLANKING_TIME_SHIFT) | 6); + ((6 * (sc->sc_flags & GEM_PCI66) != 0 ? 2 : 1) << + GEM_RX_BLANKING_TIME_SHIFT) | 6); GEM_BANK1_WRITE_4(sc, GEM_RX_PAUSE_THRESH, (3 * sc->sc_rxfifosize / 256) | ((sc->sc_rxfifosize / 256) << 12)); @@ -798,12 +799,13 @@ gem_disable_tx(struct gem_softc *sc) } static int -gem_meminit(sc) - struct gem_softc *sc; +gem_meminit(struct gem_softc *sc) { struct gem_rxsoft *rxs; int error, i; + GEM_LOCK_ASSERT(sc, MA_OWNED); + /* * Initialize the transmit descriptor ring. */ @@ -837,7 +839,8 @@ gem_meminit(sc) GEM_INIT_RXDESC(sc, i); } sc->sc_rxptr = 0; - GEM_CDSYNC(sc, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); + + GEM_CDSYNC(sc, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); return (0); } @@ -938,6 +941,20 @@ gem_init_locked(struct gem_softc *sc) #endif /* step 8. Global Configuration & Interrupt Mask */ + + /* + * Set the internal arbitration to "infinite" bursts of the + * maximum length of 31 * 64 bytes so DMA transfers aren't + * split up in cache line size chunks. This greatly improves + * RX performance. + * Enable silicon bug workarounds for the Apple variants. + */ + GEM_BANK1_WRITE_4(sc, GEM_CONFIG, + GEM_CONFIG_TXDMA_LIMIT | GEM_CONFIG_RXDMA_LIMIT | + ((sc->sc_flags & GEM_PCI) != 0 ? GEM_CONFIG_BURST_INF : + GEM_CONFIG_BURST_64) | (GEM_IS_APPLE(sc) ? + GEM_CONFIG_RONPAULBIT | GEM_CONFIG_BUG2FIX : 0)); + GEM_BANK1_WRITE_4(sc, GEM_INTMASK, ~(GEM_INTR_TX_INTME | GEM_INTR_TX_EMPTY | GEM_INTR_RX_DONE | GEM_INTR_RX_NOBUF | GEM_INTR_RX_TAG_ERR | GEM_INTR_PERR | @@ -949,7 +966,8 @@ gem_init_locked(struct gem_softc *sc) GEM_BANK1_WRITE_4(sc, GEM_MAC_RX_MASK, GEM_MAC_RX_DONE | GEM_MAC_RX_FRAME_CNT); GEM_BANK1_WRITE_4(sc, GEM_MAC_TX_MASK, - GEM_MAC_TX_XMIT_DONE | GEM_MAC_TX_DEFER_EXP); + GEM_MAC_TX_XMIT_DONE | GEM_MAC_TX_DEFER_EXP | + GEM_MAC_TX_PEAK_EXP); #ifdef GEM_DEBUG GEM_BANK1_WRITE_4(sc, GEM_MAC_CONTROL_MASK, ~(GEM_MAC_PAUSED | GEM_MAC_PAUSE | GEM_MAC_RESUME)); @@ -961,7 +979,8 @@ gem_init_locked(struct gem_softc *sc) /* step 9. ETX Configuration: use mostly default values. */ /* Enable DMA. */ - v = gem_ringsize(GEM_NTXDESC /* XXX */); + v = gem_ringsize(GEM_NTXDESC); + /* Set TX FIFO threshold and enable DMA. */ v |= ((sc->sc_variant == GEM_SUN_ERI ? 0x100 : 0x4ff) << 10) & GEM_TX_CONFIG_TXFIFO_TH; GEM_BANK1_WRITE_4(sc, GEM_TX_CONFIG, v | GEM_TX_CONFIG_TXDMA_EN); @@ -973,14 +992,16 @@ gem_init_locked(struct gem_softc *sc) /* RX TCP/UDP checksum offset */ v |= ((ETHER_HDR_LEN + sizeof(struct ip)) << GEM_RX_CONFIG_CXM_START_SHFT); - - /* Enable DMA. */ + /* Set RX FIFO threshold, set first byte offset and enable DMA. */ GEM_BANK1_WRITE_4(sc, GEM_RX_CONFIG, v | (GEM_THRSH_1024 << GEM_RX_CONFIG_FIFO_THRS_SHIFT) | - (2 << GEM_RX_CONFIG_FBOFF_SHFT) | GEM_RX_CONFIG_RXDMA_EN); + (ETHER_ALIGN << GEM_RX_CONFIG_FBOFF_SHFT) | + GEM_RX_CONFIG_RXDMA_EN); + /* Adjust for the SBus clock probably isn't worth the fuzz. */ GEM_BANK1_WRITE_4(sc, GEM_RX_BLANKING, - (6 << GEM_RX_BLANKING_TIME_SHIFT) | 6); + ((6 * (sc->sc_flags & GEM_PCI66) != 0 ? 2 : 1) << + GEM_RX_BLANKING_TIME_SHIFT) | 6); /* * The following value is for an OFF Threshold of about 3/4 full @@ -1002,7 +1023,7 @@ gem_init_locked(struct gem_softc *sc) device_printf(sc->sc_dev, "cannot configure RX MAC\n"); GEM_BANK1_WRITE_4(sc, GEM_MAC_RX_CONFIG, v); - /* step 13. TX_MAC Configuration Register */ + /* step 13. TX_MAC Configuration Register */ v = GEM_BANK1_READ_4(sc, GEM_MAC_TX_CONFIG); v |= GEM_MAC_TX_ENABLE; GEM_BANK1_WRITE_4(sc, GEM_MAC_TX_CONFIG, 0); @@ -1037,6 +1058,8 @@ gem_load_txmbuf(struct gem_softc *sc, st uint64_t cflags, flags; int error, nexttx, nsegs, offset, seg; + GEM_LOCK_ASSERT(sc, MA_OWNED); + /* Get a work queue entry. */ if ((txs = STAILQ_FIRST(&sc->sc_txfreeq)) == NULL) { /* Ran out of descriptors. */ @@ -1143,7 +1166,6 @@ gem_load_txmbuf(struct gem_softc *sc, st #endif if (++sc->sc_txwin > GEM_NTXSEGS * 2 / 3) { sc->sc_txwin = 0; - flags |= GEM_TD_INTERRUPT_ME; sc->sc_txdescs[txs->txs_firstdesc].gd_flags |= GEM_DMA_WRITE(sc, GEM_TD_INTERRUPT_ME | GEM_TD_START_OF_PACKET); @@ -1175,6 +1197,8 @@ gem_init_regs(struct gem_softc *sc) { const u_char *laddr = IF_LLADDR(sc->sc_ifp); + GEM_LOCK_ASSERT(sc, MA_OWNED); + /* These registers are not cleared on reset. */ if ((sc->sc_flags & GEM_INITED) == 0) { /* magic values */ @@ -1182,16 +1206,19 @@ gem_init_regs(struct gem_softc *sc) GEM_BANK1_WRITE_4(sc, GEM_MAC_IPG1, 8); GEM_BANK1_WRITE_4(sc, GEM_MAC_IPG2, 4); + /* min frame length */ GEM_BANK1_WRITE_4(sc, GEM_MAC_MAC_MIN_FRAME, ETHER_MIN_LEN); - /* max frame and max burst size */ + /* max frame length and max burst size */ GEM_BANK1_WRITE_4(sc, GEM_MAC_MAC_MAX_FRAME, (ETHER_MAX_LEN + ETHER_VLAN_ENCAP_LEN) | (0x2000 << 16)); + /* more magic values */ GEM_BANK1_WRITE_4(sc, GEM_MAC_PREAMBLE_LEN, 0x7); GEM_BANK1_WRITE_4(sc, GEM_MAC_JAM_SIZE, 0x4); GEM_BANK1_WRITE_4(sc, GEM_MAC_ATTEMPT_LIMIT, 0x10); - /* dunno... */ GEM_BANK1_WRITE_4(sc, GEM_MAC_CONTROL_TYPE, 0x8088); + + /* random number seed */ GEM_BANK1_WRITE_4(sc, GEM_MAC_RANDOM_SEED, ((laddr[5] << 8) | laddr[4]) & 0x3ff); @@ -1209,7 +1236,6 @@ gem_init_regs(struct gem_softc *sc) GEM_BANK1_WRITE_4(sc, GEM_MAC_ADDR_FILTER0, 0); GEM_BANK1_WRITE_4(sc, GEM_MAC_ADDR_FILTER1, 0); GEM_BANK1_WRITE_4(sc, GEM_MAC_ADDR_FILTER2, 0); - GEM_BANK1_WRITE_4(sc, GEM_MAC_ADR_FLT_MASK1_2, 0); GEM_BANK1_WRITE_4(sc, GEM_MAC_ADR_FLT_MASK0, 0); @@ -1232,18 +1258,6 @@ gem_init_regs(struct gem_softc *sc) /* Set XOFF PAUSE time. */ GEM_BANK1_WRITE_4(sc, GEM_MAC_SEND_PAUSE_CMD, 0x1BF0); - /* - * Set the internal arbitration to "infinite" bursts of the - * maximum length of 31 * 64 bytes so DMA transfers aren't - * split up in cache line size chunks. This greatly improves - * especially RX performance. - * Enable silicon bug workarounds for the Apple variants. - */ - GEM_BANK1_WRITE_4(sc, GEM_CONFIG, - GEM_CONFIG_TXDMA_LIMIT | GEM_CONFIG_RXDMA_LIMIT | - GEM_CONFIG_BURST_INF | (GEM_IS_APPLE(sc) ? - GEM_CONFIG_RONPAULBIT | GEM_CONFIG_BUG2FIX : 0)); - /* Set the station address. */ GEM_BANK1_WRITE_4(sc, GEM_MAC_ADDR0, (laddr[4] << 8) | laddr[5]); GEM_BANK1_WRITE_4(sc, GEM_MAC_ADDR1, (laddr[2] << 8) | laddr[3]); @@ -1263,12 +1277,32 @@ gem_start(struct ifnet *ifp) GEM_UNLOCK(sc); } +static inline void +gem_txkick(struct gem_softc *sc) +{ + + /* + * Update the TX kick register. This register has to point to the + * descriptor after the last valid one and for optimum performance + * should be incremented in multiples of 4 (the DMA engine fetches/ + * updates descriptors in batches of 4). + */ +#ifdef GEM_DEBUG + CTR3(KTR_GEM, "%s: %s: kicking TX %d", + device_get_name(sc->sc_dev), __func__, sc->sc_txnext); +#endif + GEM_CDSYNC(sc, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + GEM_BANK1_WRITE_4(sc, GEM_TX_KICK, sc->sc_txnext); +} + static void gem_start_locked(struct ifnet *ifp) { struct gem_softc *sc = ifp->if_softc; struct mbuf *m; - int ntx; + int kicked, ntx; + + GEM_LOCK_ASSERT(sc, MA_OWNED); if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING || (sc->sc_flags & GEM_LINK) == 0) @@ -1280,6 +1314,7 @@ gem_start_locked(struct ifnet *ifp) sc->sc_txnext); #endif ntx = 0; + kicked = 0; for (; !IFQ_DRV_IS_EMPTY(&ifp->if_snd) && sc->sc_txfree > 1;) { IFQ_DRV_DEQUEUE(&ifp->if_snd, m); if (m == NULL) @@ -1291,19 +1326,18 @@ gem_start_locked(struct ifnet *ifp) IFQ_DRV_PREPEND(&ifp->if_snd, m); break; } + if ((sc->sc_txnext % 4) == 0) { + gem_txkick(sc); + kicked = 1; + } else + kicked = 0; ntx++; - /* Kick the transmitter. */ -#ifdef GEM_DEBUG - CTR3(KTR_GEM, "%s: %s: kicking TX %d", - device_get_name(sc->sc_dev), __func__, sc->sc_txnext); -#endif - GEM_CDSYNC(sc, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); - GEM_BANK1_WRITE_4(sc, GEM_TX_KICK, sc->sc_txnext); - BPF_MTAP(ifp, m); } if (ntx > 0) { + if (kicked == 0) + gem_txkick(sc); #ifdef GEM_DEBUG CTR2(KTR_GEM, "%s: packets enqueued, OWN on %d", device_get_name(sc->sc_dev), sc->sc_txnext); @@ -1324,10 +1358,13 @@ gem_tint(struct gem_softc *sc) { struct ifnet *ifp = sc->sc_ifp; struct gem_txsoft *txs; - int txlast, progress; + int progress; + uint32_t txlast; #ifdef GEM_DEBUG int i; + GEM_LOCK_ASSERT(sc, MA_OWNED); + CTR2(KTR_GEM, "%s: %s", device_get_name(sc->sc_dev), __func__); #endif @@ -1338,7 +1375,6 @@ gem_tint(struct gem_softc *sc) progress = 0; GEM_CDSYNC(sc, BUS_DMASYNC_POSTREAD); while ((txs = STAILQ_FIRST(&sc->sc_txdirtyq)) != NULL) { - #ifdef GEM_DEBUG if ((ifp->if_flags & IFF_DEBUG) != 0) { printf(" txsoft %p transmit chain:\n", txs); @@ -1419,8 +1455,8 @@ gem_tint(struct gem_softc *sc) * and restart. */ ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - sc->sc_wdog_timer = STAILQ_EMPTY(&sc->sc_txdirtyq) ? 0 : 5; - + if (STAILQ_EMPTY(&sc->sc_txdirtyq)) + sc->sc_wdog_timer = 0; gem_start_locked(ifp); } @@ -1437,6 +1473,7 @@ gem_rint_timeout(void *arg) struct gem_softc *sc = arg; GEM_LOCK_ASSERT(sc, MA_OWNED); + gem_rint(sc); } #endif @@ -1449,6 +1486,8 @@ gem_rint(struct gem_softc *sc) uint64_t rxstat; uint32_t rxcomp; + GEM_LOCK_ASSERT(sc, MA_OWNED); + #ifdef GEM_RINT_TIMEOUT callout_stop(&sc->sc_rx_ch); #endif @@ -1461,12 +1500,11 @@ gem_rint(struct gem_softc *sc) * how long the following loop can execute. */ rxcomp = GEM_BANK1_READ_4(sc, GEM_RX_COMPLETION); - #ifdef GEM_DEBUG - CTR3(KTR_GEM, "%s: sc->rxptr %d, complete %d", + CTR3(KTR_GEM, "%s: sc->sc_rxptr %d, complete %d", __func__, sc->sc_rxptr, rxcomp); #endif - GEM_CDSYNC(sc, BUS_DMASYNC_POSTREAD); + GEM_CDSYNC(sc, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); for (; sc->sc_rxptr != rxcomp;) { m = sc->sc_rxsoft[sc->sc_rxptr].rxs_mbuf; rxstat = GEM_DMA_READ(sc, @@ -1525,9 +1563,9 @@ gem_rint(struct gem_softc *sc) /* * Update the RX kick register. This register has to point * to the descriptor after the last valid one (before the - * current batch) and must be incremented in multiples of - * 4 (because the DMA engine fetches/updates descriptors - * in batches of 4). + * current batch) and for optimum performance should be + * incremented in multiples of 4 (the DMA engine fetches/ + * updates descriptors in batches of 4). */ sc->sc_rxptr = GEM_NEXTRX(sc->sc_rxptr); if ((sc->sc_rxptr % 4) == 0) { @@ -1545,7 +1583,7 @@ gem_rint(struct gem_softc *sc) } ifp->if_ipackets++; - m->m_data += 2; /* We're already off by two */ + m->m_data += ETHER_ALIGN; /* first byte offset */ m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = GEM_RD_BUFLEN(rxstat); @@ -1559,7 +1597,7 @@ gem_rint(struct gem_softc *sc) } #ifdef GEM_DEBUG - CTR3(KTR_GEM, "%s: done sc->rxptr %d, complete %d", __func__, + CTR3(KTR_GEM, "%s: done sc->sc_rxptr %d, complete %d", __func__, sc->sc_rxptr, GEM_BANK1_READ_4(sc, GEM_RX_COMPLETION)); #endif } @@ -1572,6 +1610,8 @@ gem_add_rxbuf(struct gem_softc *sc, int bus_dma_segment_t segs[1]; int error, nsegs; + GEM_LOCK_ASSERT(sc, MA_OWNED); + m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); if (m == NULL) return (ENOBUFS); @@ -1620,7 +1660,15 @@ gem_eint(struct gem_softc *sc, u_int sta return; } - device_printf(sc->sc_dev, "%s: status=%x\n", __func__, status); + device_printf(sc->sc_dev, "%s: status 0x%x", __func__, status); + if ((status & GEM_INTR_BERR) != 0) { + if ((sc->sc_flags & GEM_PCI) != 0) + printf(", PCI bus error 0x%x\n", + GEM_BANK1_READ_4(sc, GEM_PCI_ERROR_STATUS)); + else + printf(", SBus error 0x%x\n", + GEM_BANK1_READ_4(sc, GEM_SBUS_STATUS)); + } } void @@ -1634,8 +1682,8 @@ gem_intr(void *v) #ifdef GEM_DEBUG CTR4(KTR_GEM, "%s: %s: cplt %x, status %x", - device_get_name(sc->sc_dev), __func__, (status >> 19), - (u_int)status); + device_get_name(sc->sc_dev), __func__, + (status >> GEM_STATUS_TX_COMPLETION_SHFT), (u_int)status); /* * PCS interrupts must be cleared, otherwise no traffic is passed! @@ -1665,7 +1713,7 @@ gem_intr(void *v) device_printf(sc->sc_dev, "%s: MIF interrupt\n", __func__); #endif - if ((status & + if (__predict_false(status & (GEM_INTR_RX_TAG_ERR | GEM_INTR_PERR | GEM_INTR_BERR)) != 0) gem_eint(sc, status); @@ -1675,17 +1723,20 @@ gem_intr(void *v) if ((status & (GEM_INTR_TX_EMPTY | GEM_INTR_TX_INTME)) != 0) gem_tint(sc); - if (status & GEM_INTR_TX_MAC) { + if (__predict_false((status & GEM_INTR_TX_MAC) != 0)) { status2 = GEM_BANK1_READ_4(sc, GEM_MAC_TX_STATUS); if ((status2 & - ~(GEM_MAC_TX_XMIT_DONE | GEM_MAC_TX_DEFER_EXP)) != 0) + ~(GEM_MAC_TX_XMIT_DONE | GEM_MAC_TX_DEFER_EXP | + GEM_MAC_TX_PEAK_EXP)) != 0) device_printf(sc->sc_dev, "MAC TX fault, status %x\n", status2); if ((status2 & - (GEM_MAC_TX_UNDERRUN | GEM_MAC_TX_PKT_TOO_LONG)) != 0) + (GEM_MAC_TX_UNDERRUN | GEM_MAC_TX_PKT_TOO_LONG)) != 0) { + sc->sc_ifp->if_oerrors++; gem_init_locked(sc); + } } - if (status & GEM_INTR_RX_MAC) { + if (__predict_false((status & GEM_INTR_RX_MAC) != 0)) { status2 = GEM_BANK1_READ_4(sc, GEM_MAC_RX_STATUS); /* * At least with GEM_SUN_GEM and some GEM_SUN_ERI @@ -1906,6 +1957,8 @@ gem_mii_statchg(device_t dev) sc = device_get_softc(dev); + GEM_LOCK_ASSERT(sc, MA_OWNED); + #ifdef GEM_DEBUG if ((sc->sc_ifp->if_flags & IFF_DEBUG) != 0) device_printf(sc->sc_dev, "%s: status change: PHY = %d\n", @@ -1985,7 +2038,7 @@ gem_mii_statchg(device_t dev) if ((GEM_BANK1_READ_4(sc, GEM_MIF_CONFIG) & GEM_MIF_CONFIG_PHY_SEL) != 0) { /* External MII needs echo disable if half duplex. */ - if ((IFM_OPTIONS(sc->sc_mii->mii_media_active) & + if ((IFM_OPTIONS(sc->sc_mii->mii_media_active) & IFM_FDX) == 0) v |= GEM_MAC_XIF_ECHO_DISABL; } else Modified: stable/7/sys/dev/gem/if_gem_pci.c ============================================================================== --- stable/7/sys/dev/gem/if_gem_pci.c Sun Sep 20 12:40:56 2009 (r197348) +++ stable/7/sys/dev/gem/if_gem_pci.c Sun Sep 20 12:56:50 2009 (r197349) @@ -90,7 +90,7 @@ static device_method_t gem_pci_methods[] DEVMETHOD(miibus_writereg, gem_mii_writereg), DEVMETHOD(miibus_statchg, gem_mii_statchg), - { 0, 0 } + KOBJMETHOD_END }; static driver_t gem_pci_driver = { @@ -107,7 +107,7 @@ static const struct gem_pci_dev { uint32_t gpd_devid; int gpd_variant; const char *gpd_desc; -} gem_pci_devlist[] = { +} const gem_pci_devlist[] = { { 0x1101108e, GEM_SUN_ERI, "Sun ERI 10/100 Ethernet" }, { 0x2bad108e, GEM_SUN_GEM, "Sun GEM Gigabit Ethernet" }, { 0x0021106b, GEM_APPLE_GMAC, "Apple UniNorth GMAC Ethernet" }, @@ -200,13 +200,18 @@ gem_pci_attach(device_t dev) GEM_PCI_BANK2_OFFSET, GEM_PCI_BANK2_SIZE, &sc->sc_res[GEM_RES_BANK2]->r_bushandle); + /* Determine whether we're running at 66MHz. */ + if ((GEM_BANK2_READ_4(sc, GEM_PCI_BIF_CONFIG) & + GEM_PCI_BIF_CNF_M66EN) != 0) + sc->sc_flags |= GEM_PCI66; + #if defined(__powerpc__) || defined(__sparc64__) OF_getetheraddr(dev, sc->sc_enaddr); #else /* * Dig out VPD (vital product data) and read NA (network address). - * The VPD of GEM resides in the PCI Expansion ROM (PCI FCode) and - * can't be accessed via the PCI capability pointer. + * The VPD resides in the PCI Expansion ROM (PCI FCode) and can't + * be accessed via the PCI capability pointer. * ``Writing FCode 3.x Programs'' (newer ones, dated 1997 and later) * chapter 2 describes the data structure. */ @@ -225,22 +230,21 @@ gem_pci_attach(device_t dev) #define PCI_VPDRES_BYTE0 0x00 #define PCI_VPDRES_ISLARGE(x) ((x) & 0x80) #define PCI_VPDRES_LARGE_NAME(x) ((x) & 0x7f) -#define PCI_VPDRES_TYPE_VPD 0x10 /* large */ #define PCI_VPDRES_LARGE_LEN_LSB 0x01 #define PCI_VPDRES_LARGE_LEN_MSB 0x02 -#define PCI_VPDRES_LARGE_DATA 0x03 -#define PCI_VPD_SIZE 0x03 +#define PCI_VPDRES_LARGE_SIZE 0x03 +#define PCI_VPDRES_TYPE_VPD 0x10 /* large */ #define PCI_VPD_KEY0 0x00 #define PCI_VPD_KEY1 0x01 #define PCI_VPD_LEN 0x02 -#define PCI_VPD_DATA 0x03 +#define PCI_VPD_SIZE 0x03 #define GEM_ROM_READ_1(sc, offs) \ - GEM_BANK1_READ_1((sc), GEM_PCI_ROM_OFFSET + (offs)) + GEM_BANK1_READ_1((sc), GEM_PCI_ROM_OFFSET + (offs)) #define GEM_ROM_READ_2(sc, offs) \ - GEM_BANK1_READ_2((sc), GEM_PCI_ROM_OFFSET + (offs)) + GEM_BANK1_READ_2((sc), GEM_PCI_ROM_OFFSET + (offs)) #define GEM_ROM_READ_4(sc, offs) \ - GEM_BANK1_READ_4((sc), GEM_PCI_ROM_OFFSET + (offs)) + GEM_BANK1_READ_4((sc), GEM_PCI_ROM_OFFSET + (offs)) /* Read PCI Expansion ROM header. */ if (GEM_ROM_READ_2(sc, PCI_ROMHDR_SIG) != PCI_ROMHDR_SIG_MAGIC || @@ -273,22 +277,22 @@ gem_pci_attach(device_t dev) j + PCI_VPDRES_BYTE0)) == 0 || PCI_VPDRES_LARGE_NAME(GEM_ROM_READ_1(sc, j + PCI_VPDRES_BYTE0)) != PCI_VPDRES_TYPE_VPD || - (GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_LEN_LSB) << 8 | + ((GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_LEN_LSB) << 8) | GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_LEN_MSB)) != PCI_VPD_SIZE + ETHER_ADDR_LEN || - GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_DATA + PCI_VPD_KEY0) != + GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_SIZE + PCI_VPD_KEY0) != 0x4e /* N */ || - GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_DATA + PCI_VPD_KEY1) != + GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_SIZE + PCI_VPD_KEY1) != 0x41 /* A */ || - GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_DATA + PCI_VPD_LEN) != + GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_SIZE + PCI_VPD_LEN) != ETHER_ADDR_LEN || - GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_DATA + PCI_VPD_DATA + + GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_SIZE + PCI_VPD_SIZE + ETHER_ADDR_LEN) != 0x79) { device_printf(dev, "unexpected PCI VPD\n"); goto fail; } bus_read_region_1(sc->sc_res[GEM_RES_BANK1], - GEM_PCI_ROM_OFFSET + j + PCI_VPDRES_LARGE_DATA + PCI_VPD_DATA, + GEM_PCI_ROM_OFFSET + j + PCI_VPDRES_LARGE_SIZE + PCI_VPD_SIZE, sc->sc_enaddr, ETHER_ADDR_LEN); #endif @@ -330,19 +334,15 @@ gem_pci_detach(device_t dev) static int gem_pci_suspend(device_t dev) { - struct gem_softc *sc; - sc = device_get_softc(dev); - gem_suspend(sc); + gem_suspend(device_get_softc(dev)); return (0); } static int gem_pci_resume(device_t dev) { - struct gem_softc *sc; - sc = device_get_softc(dev); - gem_resume(sc); + gem_resume(device_get_softc(dev)); return (0); } Copied: stable/7/sys/dev/gem/if_gem_sbus.c (from r194763, head/sys/dev/gem/if_gem_sbus.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/sys/dev/gem/if_gem_sbus.c Sun Sep 20 12:56:50 2009 (r197349, copy of r194763, head/sys/dev/gem/if_gem_sbus.c) @@ -0,0 +1,210 @@ +/*- + * Copyright (C) 2001 Eduardo Horvath. + * Copyright (c) 2007 Marius Strobl + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: NetBSD: if_gem_pci.c,v 1.7 2001/10/18 15:09:15 thorpej Exp + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * SBus bindings for Sun GEM Ethernet controllers + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include + +#include + +#include +#include + +#include "miibus_if.h" + +static device_probe_t gem_sbus_probe; +static device_attach_t gem_sbus_attach; +static device_detach_t gem_sbus_detach; +static device_suspend_t gem_sbus_suspend; +static device_resume_t gem_sbus_resume; + +static device_method_t gem_sbus_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, gem_sbus_probe), + DEVMETHOD(device_attach, gem_sbus_attach), + DEVMETHOD(device_detach, gem_sbus_detach), + DEVMETHOD(device_suspend, gem_sbus_suspend), + DEVMETHOD(device_resume, gem_sbus_resume), + /* Use the suspend handler here, it is all that is required. */ + DEVMETHOD(device_shutdown, gem_sbus_suspend), + + /* bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + + /* MII interface */ + DEVMETHOD(miibus_readreg, gem_mii_readreg), + DEVMETHOD(miibus_writereg, gem_mii_writereg), + DEVMETHOD(miibus_statchg, gem_mii_statchg), + + KOBJMETHOD_END +}; + +static driver_t gem_sbus_driver = { + "gem", + gem_sbus_methods, + sizeof(struct gem_softc) +}; + +DRIVER_MODULE(gem, sbus, gem_sbus_driver, gem_devclass, 0, 0); +MODULE_DEPEND(gem, sbus, 1, 1, 1); +MODULE_DEPEND(gem, ether, 1, 1, 1); + +static int +gem_sbus_probe(device_t dev) +{ + + if (strcmp(ofw_bus_get_name(dev), "network") == 0 && + ofw_bus_get_compat(dev) != NULL && + strcmp(ofw_bus_get_compat(dev), "SUNW,sbus-gem") == 0) { + device_set_desc(dev, "Sun GEM Gigabit Ethernet"); + return (0); + } + + return (ENXIO); +} + +static struct resource_spec gem_sbus_res_spec[] = { + { SYS_RES_IRQ, 0, RF_SHAREABLE | RF_ACTIVE }, /* GEM_RES_INTR */ + { SYS_RES_MEMORY, 1, RF_ACTIVE }, /* GEM_RES_BANK1 */ + { SYS_RES_MEMORY, 0, RF_ACTIVE }, /* GEM_RES_BANK2 */ + { -1, 0 } +}; + +static int +gem_sbus_attach(device_t dev) +{ + struct gem_softc *sc; + int burst; + uint32_t val; + + sc = device_get_softc(dev); + sc->sc_variant = GEM_SUN_GEM; + sc->sc_dev = dev; + + if (bus_alloc_resources(dev, gem_sbus_res_spec, sc->sc_res)) { + device_printf(dev, "failed to allocate resources\n"); + bus_release_resources(dev, gem_sbus_res_spec, sc->sc_res); + return (ENXIO); + } + + GEM_LOCK_INIT(sc, device_get_nameunit(dev)); + + OF_getetheraddr(dev, sc->sc_enaddr); + + burst = sbus_get_burstsz(dev); + val = GEM_SBUS_CFG_PARITY; + if ((burst & SBUS_BURST64_MASK) != 0) { + val |= GEM_SBUS_CFG_64BIT; + burst >>= SBUS_BURST64_SHIFT; + } + if ((burst & SBUS_BURST_64) != 0) + val |= GEM_SBUS_CFG_BURST_64; + else if ((burst & SBUS_BURST_32) != 0) + val |= GEM_SBUS_CFG_BURST_32; + else { + device_printf(dev, "unsupported burst size\n"); + goto fail; + } + /* Reset the SBus interface only. */ + (void)GEM_BANK2_READ_4(sc, GEM_SBUS_BIF_RESET); + DELAY(100); + GEM_BANK2_WRITE_4(sc, GEM_SBUS_CONFIG, val); + + if (gem_attach(sc) != 0) { + device_printf(dev, "could not be attached\n"); + goto fail; + } + + if (bus_setup_intr(dev, sc->sc_res[GEM_RES_INTR], INTR_TYPE_NET | + INTR_MPSAFE, NULL, gem_intr, sc, &sc->sc_ih) != 0) { + device_printf(dev, "failed to set up interrupt\n"); + gem_detach(sc); + goto fail; + } + return (0); + + fail: + GEM_LOCK_DESTROY(sc); + bus_release_resources(dev, gem_sbus_res_spec, sc->sc_res); + return (ENXIO); +} + +static int +gem_sbus_detach(device_t dev) +{ + struct gem_softc *sc; + + sc = device_get_softc(dev); + bus_teardown_intr(dev, sc->sc_res[GEM_RES_INTR], sc->sc_ih); + gem_detach(sc); + GEM_LOCK_DESTROY(sc); + bus_release_resources(dev, gem_sbus_res_spec, sc->sc_res); + return (0); +} + +static int +gem_sbus_suspend(device_t dev) +{ + + gem_suspend(device_get_softc(dev)); + return (0); +} + +static int +gem_sbus_resume(device_t dev) +{ + + gem_resume(device_get_softc(dev)); + return (0); +} Modified: stable/7/sys/dev/gem/if_gemreg.h ============================================================================== --- stable/7/sys/dev/gem/if_gemreg.h Sun Sep 20 12:40:56 2009 (r197348) +++ stable/7/sys/dev/gem/if_gemreg.h Sun Sep 20 12:56:50 2009 (r197349) @@ -32,7 +32,7 @@ #ifndef _IF_GEMREG_H #define _IF_GEMREG_H -/* Register definitions for Sun GEM gigabit ethernet */ +/* register definitions for Apple GMAC, Sun ERI and Sun GEM */ /* * First bank: this registers live at the start of the PCI @@ -47,97 +47,110 @@ #define GEM_INTACK 0x0014 /* Interrupt acknowledge, W/O */ #define GEM_STATUS_ALIAS 0x001c *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@FreeBSD.ORG Sun Sep 20 13:47:56 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 31E22106566B; Sun, 20 Sep 2009 13:47:56 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0610C8FC0C; Sun, 20 Sep 2009 13:47:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8KDltto058379; Sun, 20 Sep 2009 13:47:55 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8KDltC5058378; Sun, 20 Sep 2009 13:47:55 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909201347.n8KDltC5058378@svn.freebsd.org> From: Marius Strobl Date: Sun, 20 Sep 2009 13:47:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197353 - stable/7/release/doc/en_US.ISO8859-1/hardware X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2009 13:47:56 -0000 Author: marius Date: Sun Sep 20 13:47:55 2009 New Revision: 197353 URL: http://svn.freebsd.org/changeset/base/197353 Log: Move mergeinfo for r194248 from article.sgml up to its directory. Modified: stable/7/release/doc/en_US.ISO8859-1/hardware/ (props changed) From owner-svn-src-stable@FreeBSD.ORG Sun Sep 20 13:49:10 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 957BA1065670; Sun, 20 Sep 2009 13:49:10 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4DE6D8FC1F; Sun, 20 Sep 2009 13:49:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8KDnA1l058440; Sun, 20 Sep 2009 13:49:10 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8KDnAVo058437; Sun, 20 Sep 2009 13:49:10 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909201349.n8KDnAVo058437@svn.freebsd.org> From: Marius Strobl Date: Sun, 20 Sep 2009 13:49:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197354 - in stable/6/sys: . conf contrib/pf dev/cxgb sparc64/sbus X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2009 13:49:10 -0000 Author: marius Date: Sun Sep 20 13:49:10 2009 New Revision: 197354 URL: http://svn.freebsd.org/changeset/base/197354 Log: MFC: r190112 (partial) - As suggested by OpenSolaris use up-burst-sizes for determining the supported burst sizes. - Add support for 64-bit burst sizes (required for SBus GEM). - Take advantage of KOBJMETHOD_END. - Add missing const. Modified: stable/6/sys/ (props changed) stable/6/sys/conf/ (props changed) stable/6/sys/contrib/pf/ (props changed) stable/6/sys/dev/cxgb/ (props changed) stable/6/sys/sparc64/sbus/sbus.c stable/6/sys/sparc64/sbus/sbusvar.h Modified: stable/6/sys/sparc64/sbus/sbus.c ============================================================================== --- stable/6/sys/sparc64/sbus/sbus.c Sun Sep 20 13:47:55 2009 (r197353) +++ stable/6/sys/sparc64/sbus/sbus.c Sun Sep 20 13:49:10 2009 (r197354) @@ -212,7 +212,7 @@ static ofw_bus_get_name_t sbus_get_name; static ofw_bus_get_node_t sbus_get_node; static ofw_bus_get_type_t sbus_get_type; -static int sbus_inlist(const char *, const char **); +static int sbus_inlist(const char *, const char *const *); static struct sbus_devinfo * sbus_setup_dinfo(struct sbus_softc *sc, phandle_t node, char *name); static void sbus_destroy_dinfo(struct sbus_devinfo *dinfo); @@ -233,14 +233,14 @@ static device_method_t sbus_methods[] = DEVMETHOD(bus_print_child, sbus_print_child), DEVMETHOD(bus_probe_nomatch, sbus_probe_nomatch), DEVMETHOD(bus_read_ivar, sbus_read_ivar), - DEVMETHOD(bus_setup_intr, sbus_setup_intr), - DEVMETHOD(bus_teardown_intr, sbus_teardown_intr), DEVMETHOD(bus_alloc_resource, sbus_alloc_resource), DEVMETHOD(bus_activate_resource, sbus_activate_resource), DEVMETHOD(bus_deactivate_resource, sbus_deactivate_resource), DEVMETHOD(bus_release_resource, sbus_release_resource), - DEVMETHOD(bus_get_resource_list, sbus_get_resource_list), + DEVMETHOD(bus_setup_intr, sbus_setup_intr), + DEVMETHOD(bus_teardown_intr, sbus_teardown_intr), DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + DEVMETHOD(bus_get_resource_list, sbus_get_resource_list), /* ofw_bus interface */ DEVMETHOD(ofw_bus_get_compat, sbus_get_compat), @@ -249,7 +249,7 @@ static device_method_t sbus_methods[] = DEVMETHOD(ofw_bus_get_node, sbus_get_node), DEVMETHOD(ofw_bus_get_type, sbus_get_type), - { 0, 0 } + KOBJMETHOD_END }; static driver_t sbus_driver = { @@ -266,14 +266,14 @@ MODULE_VERSION(sbus, 1); #define OFW_SBUS_TYPE "sbus" #define OFW_SBUS_NAME "sbus" -static const char *sbus_order_first[] = { +static const char *const sbus_order_first[] = { "auxio", "dma", NULL }; static int -sbus_inlist(const char *name, const char **list) +sbus_inlist(const char *name, const char *const *list) { int i; @@ -388,11 +388,12 @@ sbus_attach(device_t dev) /* * Get the SBus burst transfer size if burst transfers are supported. - * XXX: is the default correct? */ - if (OF_getprop(node, "burst-sizes", &sc->sc_burst, + if (OF_getprop(node, "up-burst-sizes", &sc->sc_burst, sizeof(sc->sc_burst)) == -1 || sc->sc_burst == 0) - sc->sc_burst = SBUS_BURST_DEF; + sc->sc_burst = + (SBUS_BURST64_DEF << SBUS_BURST64_SHIFT) | SBUS_BURST_DEF; + /* initalise the IOMMU */ @@ -849,8 +850,8 @@ sbus_activate_resource(device_t bus, dev } if (type == SYS_RES_MEMORY) { /* - * Need to memory-map the device space, as some drivers depend - * on the virtual address being set and useable. + * Need to memory-map the device space, as some drivers + * depend on the virtual address being set and usable. */ error = sparc64_bus_mem_map(rman_get_bustag(r), rman_get_bushandle(r), rman_get_size(r), 0, 0, &p); Modified: stable/6/sys/sparc64/sbus/sbusvar.h ============================================================================== --- stable/6/sys/sparc64/sbus/sbusvar.h Sun Sep 20 13:47:55 2009 (r197353) +++ stable/6/sys/sparc64/sbus/sbusvar.h Sun Sep 20 13:49:10 2009 (r197354) @@ -77,7 +77,7 @@ */ #ifndef _SPARC64_SBUS_SBUSVAR_H_ -#define _SPARC64_SBUS_SBUSVAR_H_ +#define _SPARC64_SBUS_SBUSVAR_H_ /* * Macros for probe order @@ -88,18 +88,24 @@ /* * PROM-reported DMA burst sizes for the SBus */ -#define SBUS_BURST_1 0x1 -#define SBUS_BURST_2 0x2 -#define SBUS_BURST_4 0x4 -#define SBUS_BURST_8 0x8 -#define SBUS_BURST_16 0x10 -#define SBUS_BURST_32 0x20 -#define SBUS_BURST_64 0x40 +#define SBUS_BURST_1 (1 << 0) +#define SBUS_BURST_2 (1 << 1) +#define SBUS_BURST_4 (1 << 2) +#define SBUS_BURST_8 (1 << 3) +#define SBUS_BURST_16 (1 << 4) +#define SBUS_BURST_32 (1 << 5) +#define SBUS_BURST_64 (1 << 6) +#define SBUS_BURST_MASK ((1 << SBUS_BURST_SIZE) - 1) +#define SBUS_BURST_SIZE 16 +#define SBUS_BURST64_MASK (SBUS_BURST_MASK << SBUS_BURST64_SHIFT) +#define SBUS_BURST64_SHIFT 16 /* Used if no burst sizes are specified for the bus. */ #define SBUS_BURST_DEF \ (SBUS_BURST_1 | SBUS_BURST_2 | SBUS_BURST_4 | SBUS_BURST_8 | \ - SBUS_BURST_16) + SBUS_BURST_16 | SBUS_BURST_32 | SBUS_BURST_64) +#define SBUS_BURST64_DEF \ + (SBUS_BURST_8 | SBUS_BURST_16 | SBUS_BURST_32 | SBUS_BURST_64) enum sbus_device_ivars { SBUS_IVAR_BURSTSZ, @@ -111,7 +117,7 @@ enum sbus_device_ivars { /* * Simplified accessors for sbus devices */ -#define SBUS_ACCESSOR(var, ivar, type) \ +#define SBUS_ACCESSOR(var, ivar, type) \ __BUS_ACCESSOR(sbus, var, SBUS, ivar, type) SBUS_ACCESSOR(burstsz, BURSTSZ, int) From owner-svn-src-stable@FreeBSD.ORG Sun Sep 20 13:54:27 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BA6C91065672; Sun, 20 Sep 2009 13:54:27 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A66BF8FC12; Sun, 20 Sep 2009 13:54:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8KDsROi058586; Sun, 20 Sep 2009 13:54:27 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8KDsRsT058579; Sun, 20 Sep 2009 13:54:27 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909201354.n8KDsRsT058579@svn.freebsd.org> From: Marius Strobl Date: Sun, 20 Sep 2009 13:54:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197355 - in stable/6/sys: . conf contrib/pf dev/cxgb dev/gem modules/gem X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2009 13:54:27 -0000 Author: marius Date: Sun Sep 20 13:54:27 2009 New Revision: 197355 URL: http://svn.freebsd.org/changeset/base/197355 Log: MFC: r194763, r194886 - Initialize the ifnet structure, especially if_dname, before probing the PHYs as some PHY drivers use it (but probably shouldn't). How gem(4) has worked with brgphy(4) on powerpc without this so far is unclear to me. - Call ether_ifdetach(9) before stopping the controller and the callouts. The consensus is that the latter is now safe to do and should also solve the problem of active BPF listeners clearing promiscuous mode can result in the tick callout being restarted which in turn will trigger a panic once it's actually gone. - Introduce a dying flag which is set during detach and checked in gem_ioctl() in order to prevent active BPF listeners to clear promiscuous mode which may lead to the tick callout being restarted which will trigger a panic once it's actually gone. - In gem_stop() reset rather than just disable the transmitter and receiver in order to ensure we're not unloading DMA maps still in use by the hardware. [1] - The blanking time is specified in PCI clocks so we should use twice the value when operating at 66MHz. - Spell some 2 as ETHER_ALIGN and a 19 as GEM_STATUS_TX_COMPLETION_SHFT to make the actual intentions clear. - As we don't unload the peak attempts counter ignore its overflow interrupts. - Remove a stale setting of a variable to GEM_TD_INTERRUPT_ME which isn't used afterwards. - For optimum performance increment the TX kick register in multiples of 4 if possible as suggested by the documentation. - Partially revert r164931; drivers should only clear the watchdog timer if all outstanding TX descriptors are done. - Fix some debugging strings. - Add a missing BUS_DMASYNC_POSTWRITE in gem_rint(). - As the error paths in the interrupt handler are generally unlikely predict them as false. - Add support for the SBus version of the GEM controller. [2] - Add some lock assertions. - Improve some comments. - Fix some more or less cosmetic issues in the code of the PCI front-end. - Change some softc members to be unsigned where more appropriate and remove unused ones. Obtained from: NetBSD (partially) [2], OpenBSD [1] Added: stable/6/sys/dev/gem/if_gem_sbus.c - copied unchanged from r194763, head/sys/dev/gem/if_gem_sbus.c Modified: stable/6/sys/ (props changed) stable/6/sys/conf/ (props changed) stable/6/sys/conf/files stable/6/sys/contrib/pf/ (props changed) stable/6/sys/dev/cxgb/ (props changed) stable/6/sys/dev/gem/if_gem.c stable/6/sys/dev/gem/if_gem_pci.c stable/6/sys/dev/gem/if_gemreg.h stable/6/sys/dev/gem/if_gemvar.h stable/6/sys/modules/gem/Makefile Modified: stable/6/sys/conf/files ============================================================================== --- stable/6/sys/conf/files Sun Sep 20 13:49:10 2009 (r197354) +++ stable/6/sys/conf/files Sun Sep 20 13:54:27 2009 (r197355) @@ -629,6 +629,7 @@ dev/firewire/sbp_targ.c optional sbp_ta dev/fxp/if_fxp.c optional fxp dev/gem/if_gem.c optional gem dev/gem/if_gem_pci.c optional gem pci +dev/gem/if_gem_sbus.c optional gem sbus dev/harp/if_harp.c optional harp pci dev/hatm/if_hatm.c optional hatm pci dev/hatm/if_hatm_intr.c optional hatm pci @@ -2042,4 +2043,4 @@ xdr/xdr_array.c optional nfslockd xdr/xdr_mbuf.c optional nfslockd xdr/xdr_mem.c optional nfslockd xdr/xdr_reference.c optional nfslockd -xdr/xdr_sizeof.c optional nfslockd \ No newline at end of file +xdr/xdr_sizeof.c optional nfslockd Modified: stable/6/sys/dev/gem/if_gem.c ============================================================================== --- stable/6/sys/dev/gem/if_gem.c Sun Sep 20 13:49:10 2009 (r197354) +++ stable/6/sys/dev/gem/if_gem.c Sun Sep 20 13:54:27 2009 (r197355) @@ -84,7 +84,7 @@ __FBSDID("$FreeBSD$"); CTASSERT(powerof2(GEM_NRXDESC) && GEM_NRXDESC >= 32 && GEM_NRXDESC <= 8192); CTASSERT(powerof2(GEM_NTXDESC) && GEM_NTXDESC >= 32 && GEM_NTXDESC <= 8192); -#define TRIES 10000 +#define GEM_TRIES 10000 /* * The hardware supports basic TCP/UDP checksum offloading. However, @@ -120,7 +120,7 @@ static void gem_rint(struct gem_softc *s #ifdef GEM_RINT_TIMEOUT static void gem_rint_timeout(void *arg); #endif -static __inline void gem_rxcksum(struct mbuf *m, uint64_t flags); +static inline void gem_rxcksum(struct mbuf *m, uint64_t flags); static void gem_rxdrain(struct gem_softc *sc); static void gem_setladrf(struct gem_softc *sc); static void gem_start(struct ifnet *ifp); @@ -128,6 +128,7 @@ static void gem_start_locked(struct ifne static void gem_stop(struct ifnet *ifp, int disable); static void gem_tick(void *arg); static void gem_tint(struct gem_softc *sc); +static inline void gem_txkick(struct gem_softc *sc); static int gem_watchdog(struct gem_softc *sc); devclass_t gem_devclass; @@ -152,9 +153,24 @@ gem_attach(struct gem_softc *sc) int error, i; uint32_t v; + if (bootverbose) + device_printf(sc->sc_dev, "flags=0x%x\n", sc->sc_flags); + + /* Set up ifnet structure. */ ifp = sc->sc_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) return (ENOSPC); + sc->sc_csum_features = GEM_CSUM_FEATURES; + ifp->if_softc = sc; + if_initname(ifp, device_get_name(sc->sc_dev), + device_get_unit(sc->sc_dev)); + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; + ifp->if_start = gem_start; + ifp->if_ioctl = gem_ioctl; + ifp->if_init = gem_init; + IFQ_SET_MAXLEN(&ifp->if_snd, GEM_TXQUEUELEN); + ifp->if_snd.ifq_drv_maxlen = GEM_TXQUEUELEN; + IFQ_SET_READY(&ifp->if_snd); callout_init_mtx(&sc->sc_tick_ch, &sc->sc_mtx, 0); #ifdef GEM_RINT_TIMEOUT @@ -162,27 +178,26 @@ gem_attach(struct gem_softc *sc) #endif /* Make sure the chip is stopped. */ - ifp->if_softc = sc; gem_reset(sc); error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, 0, BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL, &sc->sc_pdmatag); - if (error) + if (error != 0) goto fail_ifnet; error = bus_dma_tag_create(sc->sc_pdmatag, 1, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, 1, MCLBYTES, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->sc_rdmatag); - if (error) + if (error != 0) goto fail_ptag; error = bus_dma_tag_create(sc->sc_pdmatag, 1, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES * GEM_NTXSEGS, GEM_NTXSEGS, MCLBYTES, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->sc_tdmatag); - if (error) + if (error != 0) goto fail_rtag; error = bus_dma_tag_create(sc->sc_pdmatag, PAGE_SIZE, 0, @@ -190,7 +205,7 @@ gem_attach(struct gem_softc *sc) sizeof(struct gem_control_data), 1, sizeof(struct gem_control_data), 0, NULL, NULL, &sc->sc_cdmatag); - if (error) + if (error != 0) goto fail_ttag; /* @@ -200,7 +215,7 @@ gem_attach(struct gem_softc *sc) if ((error = bus_dmamem_alloc(sc->sc_cdmatag, (void **)&sc->sc_control_data, BUS_DMA_WAITOK | BUS_DMA_COHERENT | BUS_DMA_ZERO, - &sc->sc_cddmamap))) { + &sc->sc_cddmamap)) != 0) { device_printf(sc->sc_dev, "unable to allocate control data, error = %d\n", error); goto fail_ctag; @@ -339,19 +354,6 @@ gem_attach(struct gem_softc *sc) device_printf(sc->sc_dev, "%ukB RX FIFO, %ukB TX FIFO\n", sc->sc_rxfifosize / 1024, v / 16); - sc->sc_csum_features = GEM_CSUM_FEATURES; - /* Initialize ifnet structure. */ - ifp->if_softc = sc; - if_initname(ifp, device_get_name(sc->sc_dev), - device_get_unit(sc->sc_dev)); - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - ifp->if_start = gem_start; - ifp->if_ioctl = gem_ioctl; - ifp->if_init = gem_init; - IFQ_SET_MAXLEN(&ifp->if_snd, GEM_TXQUEUELEN); - ifp->if_snd.ifq_drv_maxlen = GEM_TXQUEUELEN; - IFQ_SET_READY(&ifp->if_snd); - /* Attach the interface. */ ether_ifattach(ifp, sc->sc_enaddr); @@ -402,6 +404,7 @@ gem_detach(struct gem_softc *sc) struct ifnet *ifp = sc->sc_ifp; int i; + ether_ifdetach(ifp); GEM_LOCK(sc); gem_stop(ifp, 1); GEM_UNLOCK(sc); @@ -409,7 +412,6 @@ gem_detach(struct gem_softc *sc) #ifdef GEM_RINT_TIMEOUT callout_drain(&sc->sc_rx_ch); #endif - ether_ifdetach(ifp); if_free(ifp); device_delete_child(sc->sc_dev, sc->sc_miibus); @@ -457,7 +459,7 @@ gem_resume(struct gem_softc *sc) GEM_UNLOCK(sc); } -static __inline void +static inline void gem_rxcksum(struct mbuf *m, uint64_t flags) { struct ether_header *eh; @@ -536,12 +538,11 @@ static void gem_tick(void *arg) { struct gem_softc *sc = arg; - struct ifnet *ifp; + struct ifnet *ifp = sc->sc_ifp; uint32_t v; GEM_LOCK_ASSERT(sc, MA_OWNED); - ifp = sc->sc_ifp; /* * Unload collision and error counters. */ @@ -585,7 +586,7 @@ gem_bitwait(struct gem_softc *sc, u_int int i; uint32_t reg; - for (i = TRIES; i--; DELAY(100)) { + for (i = GEM_TRIES; i--; DELAY(100)) { reg = GEM_BANKN_READ_M(bank, 4, sc, r); if ((reg & clr) == 0 && (reg & set) == set) return (1); @@ -594,8 +595,7 @@ gem_bitwait(struct gem_softc *sc, u_int } static void -gem_reset(sc) - struct gem_softc *sc; +gem_reset(struct gem_softc *sc) { #ifdef GEM_DEBUG @@ -645,9 +645,8 @@ gem_stop(struct ifnet *ifp, int disable) callout_stop(&sc->sc_rx_ch); #endif - /* XXX should we reset these instead? */ - gem_disable_tx(sc); - gem_disable_rx(sc); + gem_reset_tx(sc); + gem_reset_rx(sc); /* * Release any queued transmit buffers. @@ -722,7 +721,7 @@ gem_reset_rxdma(struct gem_softc *sc) if (sc->sc_rxsoft[i].rxs_mbuf != NULL) GEM_UPDATE_RXDESC(sc, i); sc->sc_rxptr = 0; - GEM_CDSYNC(sc, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); + GEM_CDSYNC(sc, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); /* NOTE: we use only 32-bit DMA addresses here. */ GEM_BANK1_WRITE_4(sc, GEM_RX_RING_PTR_HI, 0); @@ -733,9 +732,11 @@ gem_reset_rxdma(struct gem_softc *sc) ((ETHER_HDR_LEN + sizeof(struct ip)) << GEM_RX_CONFIG_CXM_START_SHFT) | (GEM_THRSH_1024 << GEM_RX_CONFIG_FIFO_THRS_SHIFT) | - (2 << GEM_RX_CONFIG_FBOFF_SHFT)); + (ETHER_ALIGN << GEM_RX_CONFIG_FBOFF_SHFT)); + /* Adjust for the SBus clock probably isn't worth the fuzz. */ GEM_BANK1_WRITE_4(sc, GEM_RX_BLANKING, - (6 << GEM_RX_BLANKING_TIME_SHIFT) | 6); + ((6 * (sc->sc_flags & GEM_PCI66) != 0 ? 2 : 1) << + GEM_RX_BLANKING_TIME_SHIFT) | 6); GEM_BANK1_WRITE_4(sc, GEM_RX_PAUSE_THRESH, (3 * sc->sc_rxfifosize / 256) | ((sc->sc_rxfifosize / 256) << 12)); @@ -799,12 +800,13 @@ gem_disable_tx(struct gem_softc *sc) } static int -gem_meminit(sc) - struct gem_softc *sc; +gem_meminit(struct gem_softc *sc) { struct gem_rxsoft *rxs; int error, i; + GEM_LOCK_ASSERT(sc, MA_OWNED); + /* * Initialize the transmit descriptor ring. */ @@ -838,7 +840,8 @@ gem_meminit(sc) GEM_INIT_RXDESC(sc, i); } sc->sc_rxptr = 0; - GEM_CDSYNC(sc, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); + + GEM_CDSYNC(sc, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); return (0); } @@ -939,6 +942,20 @@ gem_init_locked(struct gem_softc *sc) #endif /* step 8. Global Configuration & Interrupt Mask */ + + /* + * Set the internal arbitration to "infinite" bursts of the + * maximum length of 31 * 64 bytes so DMA transfers aren't + * split up in cache line size chunks. This greatly improves + * RX performance. + * Enable silicon bug workarounds for the Apple variants. + */ + GEM_BANK1_WRITE_4(sc, GEM_CONFIG, + GEM_CONFIG_TXDMA_LIMIT | GEM_CONFIG_RXDMA_LIMIT | + ((sc->sc_flags & GEM_PCI) != 0 ? GEM_CONFIG_BURST_INF : + GEM_CONFIG_BURST_64) | (GEM_IS_APPLE(sc) ? + GEM_CONFIG_RONPAULBIT | GEM_CONFIG_BUG2FIX : 0)); + GEM_BANK1_WRITE_4(sc, GEM_INTMASK, ~(GEM_INTR_TX_INTME | GEM_INTR_TX_EMPTY | GEM_INTR_RX_DONE | GEM_INTR_RX_NOBUF | GEM_INTR_RX_TAG_ERR | GEM_INTR_PERR | @@ -950,7 +967,8 @@ gem_init_locked(struct gem_softc *sc) GEM_BANK1_WRITE_4(sc, GEM_MAC_RX_MASK, GEM_MAC_RX_DONE | GEM_MAC_RX_FRAME_CNT); GEM_BANK1_WRITE_4(sc, GEM_MAC_TX_MASK, - GEM_MAC_TX_XMIT_DONE | GEM_MAC_TX_DEFER_EXP); + GEM_MAC_TX_XMIT_DONE | GEM_MAC_TX_DEFER_EXP | + GEM_MAC_TX_PEAK_EXP); #ifdef GEM_DEBUG GEM_BANK1_WRITE_4(sc, GEM_MAC_CONTROL_MASK, ~(GEM_MAC_PAUSED | GEM_MAC_PAUSE | GEM_MAC_RESUME)); @@ -962,7 +980,8 @@ gem_init_locked(struct gem_softc *sc) /* step 9. ETX Configuration: use mostly default values. */ /* Enable DMA. */ - v = gem_ringsize(GEM_NTXDESC /* XXX */); + v = gem_ringsize(GEM_NTXDESC); + /* Set TX FIFO threshold and enable DMA. */ v |= ((sc->sc_variant == GEM_SUN_ERI ? 0x100 : 0x4ff) << 10) & GEM_TX_CONFIG_TXFIFO_TH; GEM_BANK1_WRITE_4(sc, GEM_TX_CONFIG, v | GEM_TX_CONFIG_TXDMA_EN); @@ -974,14 +993,16 @@ gem_init_locked(struct gem_softc *sc) /* RX TCP/UDP checksum offset */ v |= ((ETHER_HDR_LEN + sizeof(struct ip)) << GEM_RX_CONFIG_CXM_START_SHFT); - - /* Enable DMA. */ + /* Set RX FIFO threshold, set first byte offset and enable DMA. */ GEM_BANK1_WRITE_4(sc, GEM_RX_CONFIG, v | (GEM_THRSH_1024 << GEM_RX_CONFIG_FIFO_THRS_SHIFT) | - (2 << GEM_RX_CONFIG_FBOFF_SHFT) | GEM_RX_CONFIG_RXDMA_EN); + (ETHER_ALIGN << GEM_RX_CONFIG_FBOFF_SHFT) | + GEM_RX_CONFIG_RXDMA_EN); + /* Adjust for the SBus clock probably isn't worth the fuzz. */ GEM_BANK1_WRITE_4(sc, GEM_RX_BLANKING, - (6 << GEM_RX_BLANKING_TIME_SHIFT) | 6); + ((6 * (sc->sc_flags & GEM_PCI66) != 0 ? 2 : 1) << + GEM_RX_BLANKING_TIME_SHIFT) | 6); /* * The following value is for an OFF Threshold of about 3/4 full @@ -1003,7 +1024,7 @@ gem_init_locked(struct gem_softc *sc) device_printf(sc->sc_dev, "cannot configure RX MAC\n"); GEM_BANK1_WRITE_4(sc, GEM_MAC_RX_CONFIG, v); - /* step 13. TX_MAC Configuration Register */ + /* step 13. TX_MAC Configuration Register */ v = GEM_BANK1_READ_4(sc, GEM_MAC_TX_CONFIG); v |= GEM_MAC_TX_ENABLE; GEM_BANK1_WRITE_4(sc, GEM_MAC_TX_CONFIG, 0); @@ -1124,6 +1145,8 @@ gem_load_txmbuf(struct gem_softc *sc, st uint64_t cflags, flags; int error, nexttx, nsegs, offset, seg; + GEM_LOCK_ASSERT(sc, MA_OWNED); + /* Get a work queue entry. */ if ((txs = STAILQ_FIRST(&sc->sc_txfreeq)) == NULL) { /* Ran out of descriptors. */ @@ -1230,7 +1253,6 @@ gem_load_txmbuf(struct gem_softc *sc, st #endif if (++sc->sc_txwin > GEM_NTXSEGS * 2 / 3) { sc->sc_txwin = 0; - flags |= GEM_TD_INTERRUPT_ME; sc->sc_txdescs[txs->txs_firstdesc].gd_flags |= GEM_DMA_WRITE(sc, GEM_TD_INTERRUPT_ME | GEM_TD_START_OF_PACKET); @@ -1262,6 +1284,8 @@ gem_init_regs(struct gem_softc *sc) { const u_char *laddr = IFP2ENADDR(sc->sc_ifp); + GEM_LOCK_ASSERT(sc, MA_OWNED); + /* These registers are not cleared on reset. */ if ((sc->sc_flags & GEM_INITED) == 0) { /* magic values */ @@ -1269,16 +1293,19 @@ gem_init_regs(struct gem_softc *sc) GEM_BANK1_WRITE_4(sc, GEM_MAC_IPG1, 8); GEM_BANK1_WRITE_4(sc, GEM_MAC_IPG2, 4); + /* min frame length */ GEM_BANK1_WRITE_4(sc, GEM_MAC_MAC_MIN_FRAME, ETHER_MIN_LEN); - /* max frame and max burst size */ + /* max frame length and max burst size */ GEM_BANK1_WRITE_4(sc, GEM_MAC_MAC_MAX_FRAME, (ETHER_MAX_LEN + ETHER_VLAN_ENCAP_LEN) | (0x2000 << 16)); + /* more magic values */ GEM_BANK1_WRITE_4(sc, GEM_MAC_PREAMBLE_LEN, 0x7); GEM_BANK1_WRITE_4(sc, GEM_MAC_JAM_SIZE, 0x4); GEM_BANK1_WRITE_4(sc, GEM_MAC_ATTEMPT_LIMIT, 0x10); - /* dunno... */ GEM_BANK1_WRITE_4(sc, GEM_MAC_CONTROL_TYPE, 0x8088); + + /* random number seed */ GEM_BANK1_WRITE_4(sc, GEM_MAC_RANDOM_SEED, ((laddr[5] << 8) | laddr[4]) & 0x3ff); @@ -1296,7 +1323,6 @@ gem_init_regs(struct gem_softc *sc) GEM_BANK1_WRITE_4(sc, GEM_MAC_ADDR_FILTER0, 0); GEM_BANK1_WRITE_4(sc, GEM_MAC_ADDR_FILTER1, 0); GEM_BANK1_WRITE_4(sc, GEM_MAC_ADDR_FILTER2, 0); - GEM_BANK1_WRITE_4(sc, GEM_MAC_ADR_FLT_MASK1_2, 0); GEM_BANK1_WRITE_4(sc, GEM_MAC_ADR_FLT_MASK0, 0); @@ -1319,18 +1345,6 @@ gem_init_regs(struct gem_softc *sc) /* Set XOFF PAUSE time. */ GEM_BANK1_WRITE_4(sc, GEM_MAC_SEND_PAUSE_CMD, 0x1BF0); - /* - * Set the internal arbitration to "infinite" bursts of the - * maximum length of 31 * 64 bytes so DMA transfers aren't - * split up in cache line size chunks. This greatly improves - * especially RX performance. - * Enable silicon bug workarounds for the Apple variants. - */ - GEM_BANK1_WRITE_4(sc, GEM_CONFIG, - GEM_CONFIG_TXDMA_LIMIT | GEM_CONFIG_RXDMA_LIMIT | - GEM_CONFIG_BURST_INF | (GEM_IS_APPLE(sc) ? - GEM_CONFIG_RONPAULBIT | GEM_CONFIG_BUG2FIX : 0)); - /* Set the station address. */ GEM_BANK1_WRITE_4(sc, GEM_MAC_ADDR0, (laddr[4] << 8) | laddr[5]); GEM_BANK1_WRITE_4(sc, GEM_MAC_ADDR1, (laddr[2] << 8) | laddr[3]); @@ -1350,12 +1364,32 @@ gem_start(struct ifnet *ifp) GEM_UNLOCK(sc); } +static inline void +gem_txkick(struct gem_softc *sc) +{ + + /* + * Update the TX kick register. This register has to point to the + * descriptor after the last valid one and for optimum performance + * should be incremented in multiples of 4 (the DMA engine fetches/ + * updates descriptors in batches of 4). + */ +#ifdef GEM_DEBUG + CTR3(KTR_GEM, "%s: %s: kicking TX %d", + device_get_name(sc->sc_dev), __func__, sc->sc_txnext); +#endif + GEM_CDSYNC(sc, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + GEM_BANK1_WRITE_4(sc, GEM_TX_KICK, sc->sc_txnext); +} + static void gem_start_locked(struct ifnet *ifp) { struct gem_softc *sc = ifp->if_softc; struct mbuf *m; - int ntx; + int kicked, ntx; + + GEM_LOCK_ASSERT(sc, MA_OWNED); if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING || (sc->sc_flags & GEM_LINK) == 0) @@ -1367,6 +1401,7 @@ gem_start_locked(struct ifnet *ifp) sc->sc_txnext); #endif ntx = 0; + kicked = 0; for (; !IFQ_DRV_IS_EMPTY(&ifp->if_snd) && sc->sc_txfree > 1;) { IFQ_DRV_DEQUEUE(&ifp->if_snd, m); if (m == NULL) @@ -1378,19 +1413,18 @@ gem_start_locked(struct ifnet *ifp) IFQ_DRV_PREPEND(&ifp->if_snd, m); break; } + if ((sc->sc_txnext % 4) == 0) { + gem_txkick(sc); + kicked = 1; + } else + kicked = 0; ntx++; - /* Kick the transmitter. */ -#ifdef GEM_DEBUG - CTR3(KTR_GEM, "%s: %s: kicking TX %d", - device_get_name(sc->sc_dev), __func__, sc->sc_txnext); -#endif - GEM_CDSYNC(sc, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); - GEM_BANK1_WRITE_4(sc, GEM_TX_KICK, sc->sc_txnext); - BPF_MTAP(ifp, m); } if (ntx > 0) { + if (kicked == 0) + gem_txkick(sc); #ifdef GEM_DEBUG CTR2(KTR_GEM, "%s: packets enqueued, OWN on %d", device_get_name(sc->sc_dev), sc->sc_txnext); @@ -1411,10 +1445,13 @@ gem_tint(struct gem_softc *sc) { struct ifnet *ifp = sc->sc_ifp; struct gem_txsoft *txs; - int txlast, progress; + int progress; + uint32_t txlast; #ifdef GEM_DEBUG int i; + GEM_LOCK_ASSERT(sc, MA_OWNED); + CTR2(KTR_GEM, "%s: %s", device_get_name(sc->sc_dev), __func__); #endif @@ -1425,7 +1462,6 @@ gem_tint(struct gem_softc *sc) progress = 0; GEM_CDSYNC(sc, BUS_DMASYNC_POSTREAD); while ((txs = STAILQ_FIRST(&sc->sc_txdirtyq)) != NULL) { - #ifdef GEM_DEBUG if ((ifp->if_flags & IFF_DEBUG) != 0) { printf(" txsoft %p transmit chain:\n", txs); @@ -1506,8 +1542,8 @@ gem_tint(struct gem_softc *sc) * and restart. */ ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - sc->sc_wdog_timer = STAILQ_EMPTY(&sc->sc_txdirtyq) ? 0 : 5; - + if (STAILQ_EMPTY(&sc->sc_txdirtyq)) + sc->sc_wdog_timer = 0; gem_start_locked(ifp); } @@ -1524,6 +1560,7 @@ gem_rint_timeout(void *arg) struct gem_softc *sc = arg; GEM_LOCK_ASSERT(sc, MA_OWNED); + gem_rint(sc); } #endif @@ -1536,6 +1573,8 @@ gem_rint(struct gem_softc *sc) uint64_t rxstat; uint32_t rxcomp; + GEM_LOCK_ASSERT(sc, MA_OWNED); + #ifdef GEM_RINT_TIMEOUT callout_stop(&sc->sc_rx_ch); #endif @@ -1548,12 +1587,11 @@ gem_rint(struct gem_softc *sc) * how long the following loop can execute. */ rxcomp = GEM_BANK1_READ_4(sc, GEM_RX_COMPLETION); - #ifdef GEM_DEBUG - CTR3(KTR_GEM, "%s: sc->rxptr %d, complete %d", + CTR3(KTR_GEM, "%s: sc->sc_rxptr %d, complete %d", __func__, sc->sc_rxptr, rxcomp); #endif - GEM_CDSYNC(sc, BUS_DMASYNC_POSTREAD); + GEM_CDSYNC(sc, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); for (; sc->sc_rxptr != rxcomp;) { m = sc->sc_rxsoft[sc->sc_rxptr].rxs_mbuf; rxstat = GEM_DMA_READ(sc, @@ -1612,9 +1650,9 @@ gem_rint(struct gem_softc *sc) /* * Update the RX kick register. This register has to point * to the descriptor after the last valid one (before the - * current batch) and must be incremented in multiples of - * 4 (because the DMA engine fetches/updates descriptors - * in batches of 4). + * current batch) and for optimum performance should be + * incremented in multiples of 4 (the DMA engine fetches/ + * updates descriptors in batches of 4). */ sc->sc_rxptr = GEM_NEXTRX(sc->sc_rxptr); if ((sc->sc_rxptr % 4) == 0) { @@ -1632,7 +1670,7 @@ gem_rint(struct gem_softc *sc) } ifp->if_ipackets++; - m->m_data += 2; /* We're already off by two */ + m->m_data += ETHER_ALIGN; /* first byte offset */ m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = GEM_RD_BUFLEN(rxstat); @@ -1646,7 +1684,7 @@ gem_rint(struct gem_softc *sc) } #ifdef GEM_DEBUG - CTR3(KTR_GEM, "%s: done sc->rxptr %d, complete %d", __func__, + CTR3(KTR_GEM, "%s: done sc->sc_rxptr %d, complete %d", __func__, sc->sc_rxptr, GEM_BANK1_READ_4(sc, GEM_RX_COMPLETION)); #endif } @@ -1659,6 +1697,8 @@ gem_add_rxbuf(struct gem_softc *sc, int bus_dma_segment_t segs[1]; int error, nsegs; + GEM_LOCK_ASSERT(sc, MA_OWNED); + m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); if (m == NULL) return (ENOBUFS); @@ -1707,7 +1747,15 @@ gem_eint(struct gem_softc *sc, u_int sta return; } - device_printf(sc->sc_dev, "%s: status=%x\n", __func__, status); + device_printf(sc->sc_dev, "%s: status 0x%x", __func__, status); + if ((status & GEM_INTR_BERR) != 0) { + if ((sc->sc_flags & GEM_PCI) != 0) + printf(", PCI bus error 0x%x\n", + GEM_BANK1_READ_4(sc, GEM_PCI_ERROR_STATUS)); + else + printf(", SBus error 0x%x\n", + GEM_BANK1_READ_4(sc, GEM_SBUS_STATUS)); + } } void @@ -1721,8 +1769,8 @@ gem_intr(void *v) #ifdef GEM_DEBUG CTR4(KTR_GEM, "%s: %s: cplt %x, status %x", - device_get_name(sc->sc_dev), __func__, (status >> 19), - (u_int)status); + device_get_name(sc->sc_dev), __func__, + (status >> GEM_STATUS_TX_COMPLETION_SHFT), (u_int)status); /* * PCS interrupts must be cleared, otherwise no traffic is passed! @@ -1752,7 +1800,7 @@ gem_intr(void *v) device_printf(sc->sc_dev, "%s: MIF interrupt\n", __func__); #endif - if ((status & + if (__predict_false(status & (GEM_INTR_RX_TAG_ERR | GEM_INTR_PERR | GEM_INTR_BERR)) != 0) gem_eint(sc, status); @@ -1762,17 +1810,20 @@ gem_intr(void *v) if ((status & (GEM_INTR_TX_EMPTY | GEM_INTR_TX_INTME)) != 0) gem_tint(sc); - if (status & GEM_INTR_TX_MAC) { + if (__predict_false((status & GEM_INTR_TX_MAC) != 0)) { status2 = GEM_BANK1_READ_4(sc, GEM_MAC_TX_STATUS); if ((status2 & - ~(GEM_MAC_TX_XMIT_DONE | GEM_MAC_TX_DEFER_EXP)) != 0) + ~(GEM_MAC_TX_XMIT_DONE | GEM_MAC_TX_DEFER_EXP | + GEM_MAC_TX_PEAK_EXP)) != 0) device_printf(sc->sc_dev, "MAC TX fault, status %x\n", status2); if ((status2 & - (GEM_MAC_TX_UNDERRUN | GEM_MAC_TX_PKT_TOO_LONG)) != 0) + (GEM_MAC_TX_UNDERRUN | GEM_MAC_TX_PKT_TOO_LONG)) != 0) { + sc->sc_ifp->if_oerrors++; gem_init_locked(sc); + } } - if (status & GEM_INTR_RX_MAC) { + if (__predict_false((status & GEM_INTR_RX_MAC) != 0)) { status2 = GEM_BANK1_READ_4(sc, GEM_MAC_RX_STATUS); /* * At least with GEM_SUN_GEM and some GEM_SUN_ERI @@ -1993,6 +2044,8 @@ gem_mii_statchg(device_t dev) sc = device_get_softc(dev); + GEM_LOCK_ASSERT(sc, MA_OWNED); + #ifdef GEM_DEBUG if ((sc->sc_ifp->if_flags & IFF_DEBUG) != 0) device_printf(sc->sc_dev, "%s: status change: PHY = %d\n", @@ -2072,7 +2125,7 @@ gem_mii_statchg(device_t dev) if ((GEM_BANK1_READ_4(sc, GEM_MIF_CONFIG) & GEM_MIF_CONFIG_PHY_SEL) != 0) { /* External MII needs echo disable if half duplex. */ - if ((IFM_OPTIONS(sc->sc_mii->mii_media_active) & + if ((IFM_OPTIONS(sc->sc_mii->mii_media_active) & IFM_FDX) == 0) v |= GEM_MAC_XIF_ECHO_DISABL; } else Modified: stable/6/sys/dev/gem/if_gem_pci.c ============================================================================== --- stable/6/sys/dev/gem/if_gem_pci.c Sun Sep 20 13:49:10 2009 (r197354) +++ stable/6/sys/dev/gem/if_gem_pci.c Sun Sep 20 13:54:27 2009 (r197355) @@ -89,7 +89,7 @@ static device_method_t gem_pci_methods[] DEVMETHOD(miibus_writereg, gem_mii_writereg), DEVMETHOD(miibus_statchg, gem_mii_statchg), - { 0, 0 } + KOBJMETHOD_END }; static driver_t gem_pci_driver = { @@ -106,7 +106,7 @@ static const struct gem_pci_dev { uint32_t gpd_devid; int gpd_variant; const char *gpd_desc; -} gem_pci_devlist[] = { +} const gem_pci_devlist[] = { { 0x1101108e, GEM_SUN_ERI, "Sun ERI 10/100 Ethernet" }, { 0x2bad108e, GEM_SUN_GEM, "Sun GEM Gigabit Ethernet" }, { 0x0021106b, GEM_APPLE_GMAC, "Apple UniNorth GMAC Ethernet" }, @@ -194,13 +194,18 @@ gem_pci_attach(device_t dev) GEM_PCI_BANK2_OFFSET, GEM_PCI_BANK2_SIZE, &sc->sc_bh[GEM_BS_BANK2]); + /* Determine whether we're running at 66MHz. */ + if ((GEM_BANK2_READ_4(sc, GEM_PCI_BIF_CONFIG) & + GEM_PCI_BIF_CNF_M66EN) != 0) + sc->sc_flags |= GEM_PCI66; + #if defined(__powerpc__) || defined(__sparc64__) OF_getetheraddr(dev, sc->sc_enaddr); #else /* * Dig out VPD (vital product data) and read NA (network address). - * The VPD of GEM resides in the PCI Expansion ROM (PCI FCode) and - * can't be accessed via the PCI capability pointer. + * The VPD resides in the PCI Expansion ROM (PCI FCode) and can't + * be accessed via the PCI capability pointer. * ``Writing FCode 3.x Programs'' (newer ones, dated 1997 and later) * chapter 2 describes the data structure. */ @@ -219,22 +224,21 @@ gem_pci_attach(device_t dev) #define PCI_VPDRES_BYTE0 0x00 #define PCI_VPDRES_ISLARGE(x) ((x) & 0x80) #define PCI_VPDRES_LARGE_NAME(x) ((x) & 0x7f) -#define PCI_VPDRES_TYPE_VPD 0x10 /* large */ #define PCI_VPDRES_LARGE_LEN_LSB 0x01 #define PCI_VPDRES_LARGE_LEN_MSB 0x02 -#define PCI_VPDRES_LARGE_DATA 0x03 -#define PCI_VPD_SIZE 0x03 +#define PCI_VPDRES_LARGE_SIZE 0x03 +#define PCI_VPDRES_TYPE_VPD 0x10 /* large */ #define PCI_VPD_KEY0 0x00 #define PCI_VPD_KEY1 0x01 #define PCI_VPD_LEN 0x02 -#define PCI_VPD_DATA 0x03 +#define PCI_VPD_SIZE 0x03 #define GEM_ROM_READ_1(sc, offs) \ - GEM_BANK1_READ_1((sc), GEM_PCI_ROM_OFFSET + (offs)) + GEM_BANK1_READ_1((sc), GEM_PCI_ROM_OFFSET + (offs)) #define GEM_ROM_READ_2(sc, offs) \ - GEM_BANK1_READ_2((sc), GEM_PCI_ROM_OFFSET + (offs)) + GEM_BANK1_READ_2((sc), GEM_PCI_ROM_OFFSET + (offs)) #define GEM_ROM_READ_4(sc, offs) \ - GEM_BANK1_READ_4((sc), GEM_PCI_ROM_OFFSET + (offs)) + GEM_BANK1_READ_4((sc), GEM_PCI_ROM_OFFSET + (offs)) /* Read PCI Expansion ROM header. */ if (GEM_ROM_READ_2(sc, PCI_ROMHDR_SIG) != PCI_ROMHDR_SIG_MAGIC || @@ -267,23 +271,23 @@ gem_pci_attach(device_t dev) j + PCI_VPDRES_BYTE0)) == 0 || PCI_VPDRES_LARGE_NAME(GEM_ROM_READ_1(sc, j + PCI_VPDRES_BYTE0)) != PCI_VPDRES_TYPE_VPD || - (GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_LEN_LSB) << 8 | + ((GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_LEN_LSB) << 8) | GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_LEN_MSB)) != PCI_VPD_SIZE + ETHER_ADDR_LEN || - GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_DATA + PCI_VPD_KEY0) != + GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_SIZE + PCI_VPD_KEY0) != 0x4e /* N */ || - GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_DATA + PCI_VPD_KEY1) != + GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_SIZE + PCI_VPD_KEY1) != 0x41 /* A */ || - GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_DATA + PCI_VPD_LEN) != + GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_SIZE + PCI_VPD_LEN) != ETHER_ADDR_LEN || - GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_DATA + PCI_VPD_DATA + + GEM_ROM_READ_1(sc, j + PCI_VPDRES_LARGE_SIZE + PCI_VPD_SIZE + ETHER_ADDR_LEN) != 0x79) { device_printf(dev, "unexpected PCI VPD\n"); goto fail; } bus_space_read_region_1(sc->sc_bt[GEM_BS_BANK1], sc->sc_bh[GEM_BS_BANK1], - GEM_PCI_ROM_OFFSET + j + PCI_VPDRES_LARGE_DATA + PCI_VPD_DATA, + GEM_PCI_ROM_OFFSET + j + PCI_VPDRES_LARGE_SIZE + PCI_VPD_SIZE, sc->sc_enaddr, ETHER_ADDR_LEN); #endif @@ -322,19 +326,15 @@ gem_pci_detach(device_t dev) static int gem_pci_suspend(device_t dev) { - struct gem_softc *sc; - sc = device_get_softc(dev); - gem_suspend(sc); + gem_suspend(device_get_softc(dev)); return (0); } static int gem_pci_resume(device_t dev) { - struct gem_softc *sc; - sc = device_get_softc(dev); - gem_resume(sc); + gem_resume(device_get_softc(dev)); return (0); } Copied: stable/6/sys/dev/gem/if_gem_sbus.c (from r194763, head/sys/dev/gem/if_gem_sbus.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/6/sys/dev/gem/if_gem_sbus.c Sun Sep 20 13:54:27 2009 (r197355, copy of r194763, head/sys/dev/gem/if_gem_sbus.c) @@ -0,0 +1,210 @@ +/*- + * Copyright (C) 2001 Eduardo Horvath. + * Copyright (c) 2007 Marius Strobl + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: NetBSD: if_gem_pci.c,v 1.7 2001/10/18 15:09:15 thorpej Exp + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * SBus bindings for Sun GEM Ethernet controllers + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include + +#include + +#include +#include + +#include "miibus_if.h" + +static device_probe_t gem_sbus_probe; +static device_attach_t gem_sbus_attach; +static device_detach_t gem_sbus_detach; +static device_suspend_t gem_sbus_suspend; +static device_resume_t gem_sbus_resume; + +static device_method_t gem_sbus_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, gem_sbus_probe), + DEVMETHOD(device_attach, gem_sbus_attach), + DEVMETHOD(device_detach, gem_sbus_detach), + DEVMETHOD(device_suspend, gem_sbus_suspend), + DEVMETHOD(device_resume, gem_sbus_resume), + /* Use the suspend handler here, it is all that is required. */ + DEVMETHOD(device_shutdown, gem_sbus_suspend), + + /* bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + + /* MII interface */ + DEVMETHOD(miibus_readreg, gem_mii_readreg), + DEVMETHOD(miibus_writereg, gem_mii_writereg), + DEVMETHOD(miibus_statchg, gem_mii_statchg), + + KOBJMETHOD_END +}; + +static driver_t gem_sbus_driver = { + "gem", + gem_sbus_methods, + sizeof(struct gem_softc) +}; + +DRIVER_MODULE(gem, sbus, gem_sbus_driver, gem_devclass, 0, 0); +MODULE_DEPEND(gem, sbus, 1, 1, 1); +MODULE_DEPEND(gem, ether, 1, 1, 1); + +static int +gem_sbus_probe(device_t dev) +{ + + if (strcmp(ofw_bus_get_name(dev), "network") == 0 && + ofw_bus_get_compat(dev) != NULL && + strcmp(ofw_bus_get_compat(dev), "SUNW,sbus-gem") == 0) { + device_set_desc(dev, "Sun GEM Gigabit Ethernet"); + return (0); + } + + return (ENXIO); +} + +static struct resource_spec gem_sbus_res_spec[] = { + { SYS_RES_IRQ, 0, RF_SHAREABLE | RF_ACTIVE }, /* GEM_RES_INTR */ + { SYS_RES_MEMORY, 1, RF_ACTIVE }, /* GEM_RES_BANK1 */ + { SYS_RES_MEMORY, 0, RF_ACTIVE }, /* GEM_RES_BANK2 */ + { -1, 0 } +}; + +static int +gem_sbus_attach(device_t dev) +{ + struct gem_softc *sc; + int burst; + uint32_t val; + + sc = device_get_softc(dev); + sc->sc_variant = GEM_SUN_GEM; + sc->sc_dev = dev; + + if (bus_alloc_resources(dev, gem_sbus_res_spec, sc->sc_res)) { + device_printf(dev, "failed to allocate resources\n"); + bus_release_resources(dev, gem_sbus_res_spec, sc->sc_res); + return (ENXIO); + } + + GEM_LOCK_INIT(sc, device_get_nameunit(dev)); + + OF_getetheraddr(dev, sc->sc_enaddr); + + burst = sbus_get_burstsz(dev); + val = GEM_SBUS_CFG_PARITY; + if ((burst & SBUS_BURST64_MASK) != 0) { + val |= GEM_SBUS_CFG_64BIT; + burst >>= SBUS_BURST64_SHIFT; + } + if ((burst & SBUS_BURST_64) != 0) + val |= GEM_SBUS_CFG_BURST_64; + else if ((burst & SBUS_BURST_32) != 0) + val |= GEM_SBUS_CFG_BURST_32; + else { + device_printf(dev, "unsupported burst size\n"); + goto fail; + } + /* Reset the SBus interface only. */ + (void)GEM_BANK2_READ_4(sc, GEM_SBUS_BIF_RESET); + DELAY(100); + GEM_BANK2_WRITE_4(sc, GEM_SBUS_CONFIG, val); + + if (gem_attach(sc) != 0) { + device_printf(dev, "could not be attached\n"); + goto fail; + } + + if (bus_setup_intr(dev, sc->sc_res[GEM_RES_INTR], INTR_TYPE_NET | + INTR_MPSAFE, NULL, gem_intr, sc, &sc->sc_ih) != 0) { + device_printf(dev, "failed to set up interrupt\n"); + gem_detach(sc); + goto fail; + } + return (0); + + fail: + GEM_LOCK_DESTROY(sc); + bus_release_resources(dev, gem_sbus_res_spec, sc->sc_res); + return (ENXIO); +} + +static int +gem_sbus_detach(device_t dev) +{ + struct gem_softc *sc; + + sc = device_get_softc(dev); + bus_teardown_intr(dev, sc->sc_res[GEM_RES_INTR], sc->sc_ih); + gem_detach(sc); + GEM_LOCK_DESTROY(sc); + bus_release_resources(dev, gem_sbus_res_spec, sc->sc_res); + return (0); +} + +static int +gem_sbus_suspend(device_t dev) +{ + + gem_suspend(device_get_softc(dev)); + return (0); +} + +static int +gem_sbus_resume(device_t dev) +{ + + gem_resume(device_get_softc(dev)); + return (0); +} Modified: stable/6/sys/dev/gem/if_gemreg.h ============================================================================== --- stable/6/sys/dev/gem/if_gemreg.h Sun Sep 20 13:49:10 2009 (r197354) +++ stable/6/sys/dev/gem/if_gemreg.h Sun Sep 20 13:54:27 2009 (r197355) @@ -32,7 +32,7 @@ #ifndef _IF_GEMREG_H #define _IF_GEMREG_H *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@FreeBSD.ORG Sun Sep 20 14:26:18 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 128001065670; Sun, 20 Sep 2009 14:26:18 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DB4298FC16; Sun, 20 Sep 2009 14:26:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8KEQHAl059280; Sun, 20 Sep 2009 14:26:17 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8KEQHUC059278; Sun, 20 Sep 2009 14:26:17 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909201426.n8KEQHUC059278@svn.freebsd.org> From: Marius Strobl Date: Sun, 20 Sep 2009 14:26:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197358 - stable/7/share/man/man4 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2009 14:26:18 -0000 Author: marius Date: Sun Sep 20 14:26:17 2009 New Revision: 197358 URL: http://svn.freebsd.org/changeset/base/197358 Log: MFC: r194764 - Update regarding the support for SBus GEM added in r194763 (MFC'ed in r197349). - Improve the description a bit and add a reference to vlan(4). Modified: stable/7/share/man/man4/ (props changed) stable/7/share/man/man4/gem.4 Modified: stable/7/share/man/man4/gem.4 ============================================================================== --- stable/7/share/man/man4/gem.4 Sun Sep 20 14:20:00 2009 (r197357) +++ stable/7/share/man/man4/gem.4 Sun Sep 20 14:26:17 2009 (r197358) @@ -33,7 +33,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 15, 2009 +.Dd June 14, 2009 .Dt GEM 4 .Os .Sh NAME @@ -57,9 +57,16 @@ if_gem_load="YES" .Sh DESCRIPTION The .Nm -driver provides support for the GMac Ethernet hardware found mostly in +driver provides support for the GMAC Ethernet hardware found mostly in the last Apple PowerBooks G3s and most G4-based Apple hardware, as -well as many Sun UltraSPARCs. +well as Sun UltraSPARC machines. +.Pp +All controllers supported by the +.Nm +driver have TCP checksum offload capability for both receive and transmit, +support for the reception and transmission of extended frames for +.Xr vlan 4 +and a 512-bit multicast hash filter. .Sh HARDWARE .Pp Chips supported by the @@ -84,6 +91,9 @@ driver at this time: .It Sun Gigabit Ethernet PCI 2.0/3.0 (GBE/P) (part no.\& 501-4373) +.It +Sun Gigabit Ethernet SBus 2.0/3.0 (GBE/S) +(part no.\& 501-4375) .El .Sh NOTES On sparc64 the @@ -108,15 +118,11 @@ the system's default MAC address. Supported interfaces having their own MAC address include the on-board Sun ERI 10/100 Mbps on boards equipped with more than one Ethernet interface and the Sun Gigabit Ethernet 2.0/3.0 GBE add-on cards. -.Sh CAVEATS -Currently the -.Nm -driver fails to attach to Sun Gigabit Ethernet SBus 2.0/3.0 (GBE/S) cards, -as no SBus front-end has been written so far. .Sh SEE ALSO .Xr altq 4 , .Xr miibus 4 , .Xr netintro 4 , +.Xr vlan 4 , .Xr eeprom 8 , .Xr ifconfig 8 .Sh HISTORY @@ -132,9 +138,19 @@ version to include it was .An -nosplit The .Nm -driver was written by +driver was written for +.Nx +by .An Eduardo Horvath .Aq eeh@NetBSD.org . +It was ported to +.Fx +by +.An Thomas Moestl +.Aq tmm@FreeBSD.org +and later on improved by +.An Marius Strobl +.Aq marus@FreeBSD.org . The man page was written by .An Thomas Klausner .Aq wiz@NetBSD.org . From owner-svn-src-stable@FreeBSD.ORG Sun Sep 20 14:26:27 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 279AE10656A4; Sun, 20 Sep 2009 14:26:27 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7F1FA8FC08; Sun, 20 Sep 2009 14:26:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8KEQQtK059319; Sun, 20 Sep 2009 14:26:26 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8KEQQNm059317; Sun, 20 Sep 2009 14:26:26 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909201426.n8KEQQNm059317@svn.freebsd.org> From: Marius Strobl Date: Sun, 20 Sep 2009 14:26:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197359 - stable/6/share/man/man4 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2009 14:26:27 -0000 Author: marius Date: Sun Sep 20 14:26:26 2009 New Revision: 197359 URL: http://svn.freebsd.org/changeset/base/197359 Log: MFC: r194764 - Update regarding the support for SBus GEM added in r194763 (MFC'ed in r197355). - Improve the description a bit and add a reference to vlan(4). Modified: stable/6/share/man/man4/ (props changed) stable/6/share/man/man4/gem.4 Modified: stable/6/share/man/man4/gem.4 ============================================================================== --- stable/6/share/man/man4/gem.4 Sun Sep 20 14:26:17 2009 (r197358) +++ stable/6/share/man/man4/gem.4 Sun Sep 20 14:26:26 2009 (r197359) @@ -33,7 +33,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 15, 2009 +.Dd June 14, 2009 .Dt GEM 4 .Os .Sh NAME @@ -57,9 +57,16 @@ if_gem_load="YES" .Sh DESCRIPTION The .Nm -driver provides support for the GMac Ethernet hardware found mostly in +driver provides support for the GMAC Ethernet hardware found mostly in the last Apple PowerBooks G3s and most G4-based Apple hardware, as -well as many Sun UltraSPARCs. +well as Sun UltraSPARC machines. +.Pp +All controllers supported by the +.Nm +driver have TCP checksum offload capability for both receive and transmit, +support for the reception and transmission of extended frames for +.Xr vlan 4 +and a 512-bit multicast hash filter. .Sh HARDWARE .Pp Chips supported by the @@ -84,6 +91,9 @@ driver at this time: .It Sun Gigabit Ethernet PCI 2.0/3.0 (GBE/P) (part no.\& 501-4373) +.It +Sun Gigabit Ethernet SBus 2.0/3.0 (GBE/S) +(part no.\& 501-4375) .El .Sh NOTES On sparc64 the @@ -108,15 +118,11 @@ the system's default MAC address. Supported interfaces having their own MAC address include the on-board Sun ERI 10/100 Mbps on boards equipped with more than one Ethernet interface and the Sun Gigabit Ethernet 2.0/3.0 GBE add-on cards. -.Sh CAVEATS -Currently the -.Nm -driver fails to attach to Sun Gigabit Ethernet SBus 2.0/3.0 (GBE/S) cards, -as no SBus front-end has been written so far. .Sh SEE ALSO .Xr altq 4 , .Xr miibus 4 , .Xr netintro 4 , +.Xr vlan 4 , .Xr eeprom 8 , .Xr ifconfig 8 .Sh HISTORY @@ -132,9 +138,19 @@ version to include it was .An -nosplit The .Nm -driver was written by +driver was written for +.Nx +by .An Eduardo Horvath .Aq eeh@NetBSD.org . +It was ported to +.Fx +by +.An Thomas Moestl +.Aq tmm@FreeBSD.org +and later on improved by +.An Marius Strobl +.Aq marus@FreeBSD.org . The man page was written by .An Thomas Klausner .Aq wiz@NetBSD.org . From owner-svn-src-stable@FreeBSD.ORG Sun Sep 20 17:46:57 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 17018106566B; Sun, 20 Sep 2009 17:46:57 +0000 (UTC) (envelope-from qingli@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 04BE38FC26; Sun, 20 Sep 2009 17:46:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8KHkuqR063700; Sun, 20 Sep 2009 17:46:56 GMT (envelope-from qingli@svn.freebsd.org) Received: (from qingli@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8KHkuJM063698; Sun, 20 Sep 2009 17:46:56 GMT (envelope-from qingli@svn.freebsd.org) Message-Id: <200909201746.n8KHkuJM063698@svn.freebsd.org> From: Qing Li Date: Sun, 20 Sep 2009 17:46:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197365 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2009 17:46:57 -0000 Author: qingli Date: Sun Sep 20 17:46:56 2009 New Revision: 197365 URL: http://svn.freebsd.org/changeset/base/197365 Log: MFC r197364 A wrong variable is used when setting up the interface address route, which broke source address selection in some code paths. Submitted by: noted by bz Reviewed by: hrs Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/if.c Modified: stable/8/sys/net/if.c ============================================================================== --- stable/8/sys/net/if.c Sun Sep 20 17:22:19 2009 (r197364) +++ stable/8/sys/net/if.c Sun Sep 20 17:46:56 2009 (r197365) @@ -1432,9 +1432,9 @@ ifa_add_loopback_route(struct ifaddr *if if (error == 0 && rt != NULL) { RT_LOCK(rt); ((struct sockaddr_dl *)rt->rt_gateway)->sdl_type = - rt->rt_ifp->if_type; + ifa->ifa_ifp->if_type; ((struct sockaddr_dl *)rt->rt_gateway)->sdl_index = - rt->rt_ifp->if_index; + ifa->ifa_ifp->if_index; RT_REMREF(rt); RT_UNLOCK(rt); } else if (error != 0) From owner-svn-src-stable@FreeBSD.ORG Sun Sep 20 18:53:41 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 43096106566B; Sun, 20 Sep 2009 18:53:41 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 308178FC0C; Sun, 20 Sep 2009 18:53:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8KIrejW064999; Sun, 20 Sep 2009 18:53:40 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8KIreu6064995; Sun, 20 Sep 2009 18:53:40 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909201853.n8KIreu6064995@svn.freebsd.org> From: Marius Strobl Date: Sun, 20 Sep 2009 18:53:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197366 - in stable/7/sys: . contrib/pf sparc64/include sparc64/sparc64 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2009 18:53:41 -0000 Author: marius Date: Sun Sep 20 18:53:40 2009 New Revision: 197366 URL: http://svn.freebsd.org/changeset/base/197366 Log: MFC: r195149 (partial) - Work around the broken loader behavior of not demapping no longer used kernel TLB slots when unloading the kernel or modules, which results in havoc when loading a kernel and modules which take up less TLB slots afterwards as the unused but locked ones aren't accounted for in virtual_avail. Eventually this should be fixed in the loader which isn't straight forward though and the kernel should be robust against this anyway. [1] - Remove the no longer used global msgbuf_phys. - Remove the redundant ekva parameter of pmap_bootstrap_alloc(). - Correct some outdated function names in ktr(9) invocations. Requested by: jhb [1] Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/sparc64/include/pmap.h stable/7/sys/sparc64/sparc64/machdep.c stable/7/sys/sparc64/sparc64/pmap.c Modified: stable/7/sys/sparc64/include/pmap.h ============================================================================== --- stable/7/sys/sparc64/include/pmap.h Sun Sep 20 17:46:56 2009 (r197365) +++ stable/7/sys/sparc64/include/pmap.h Sun Sep 20 18:53:40 2009 (r197366) @@ -80,7 +80,7 @@ struct pmap { #define pmap_page_get_memattr(m) VM_MEMATTR_DEFAULT #define pmap_page_set_memattr(m, ma) (void)0 -void pmap_bootstrap(vm_offset_t ekva); +void pmap_bootstrap(void); vm_paddr_t pmap_kextract(vm_offset_t va); void pmap_kenter(vm_offset_t va, vm_page_t m); void pmap_kremove(vm_offset_t); @@ -106,8 +106,6 @@ extern vm_paddr_t phys_avail[]; extern vm_offset_t virtual_avail; extern vm_offset_t virtual_end; -extern vm_paddr_t msgbuf_phys; - #ifdef PMAP_STATS SYSCTL_DECL(_debug_pmap_stats); Modified: stable/7/sys/sparc64/sparc64/machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/machdep.c Sun Sep 20 17:46:56 2009 (r197365) +++ stable/7/sys/sparc64/sparc64/machdep.c Sun Sep 20 18:53:40 2009 (r197366) @@ -242,6 +242,7 @@ sparc64_init(caddr_t mdp, u_long o1, u_l char *env; struct pcpu *pc; vm_offset_t end; + vm_offset_t va; caddr_t kmdp; phandle_t child; phandle_t root; @@ -360,19 +361,28 @@ sparc64_init(caddr_t mdp, u_long o1, u_l * Panic if there is no metadata. Most likely the kernel was booted * directly, instead of through loader(8). */ - if (mdp == NULL || kmdp == NULL) { - printf("sparc64_init: no loader metadata.\n" + if (mdp == NULL || kmdp == NULL || end == 0 || + kernel_tlb_slots == 0 || kernel_tlbs == NULL) { + printf("sparc64_init: missing loader metadata.\n" "This probably means you are not using loader(8).\n"); panic("sparc64_init"); } /* - * Sanity check the kernel end, which is important. - */ - if (end == 0) { - printf("sparc64_init: warning, kernel end not specified.\n" - "Attempting to continue anyway.\n"); - end = (vm_offset_t)_end; + * Work around the broken loader behavior of not demapping no + * longer used kernel TLB slots when unloading the kernel or + * modules. + */ + for (va = KERNBASE + (kernel_tlb_slots - 1) * PAGE_SIZE_4M; + va >= roundup2(end, PAGE_SIZE_4M); va -= PAGE_SIZE_4M) { + printf("demapping unused kernel TLB slot (va %#lx - %#lx)\n", + va, va + PAGE_SIZE_4M - 1); + stxa(TLB_DEMAP_VA(va) | TLB_DEMAP_PRIMARY | TLB_DEMAP_PAGE, + ASI_DMMU_DEMAP, 0); + stxa(TLB_DEMAP_VA(va) | TLB_DEMAP_PRIMARY | TLB_DEMAP_PAGE, + ASI_IMMU_DEMAP, 0); + flush(KERNBASE); + kernel_tlb_slots--; } /* @@ -421,7 +431,7 @@ sparc64_init(caddr_t mdp, u_long o1, u_l /* * Initialize virtual memory and calculate physmem. */ - pmap_bootstrap(end); + pmap_bootstrap(); /* * Initialize tunables. Modified: stable/7/sys/sparc64/sparc64/pmap.c ============================================================================== --- stable/7/sys/sparc64/sparc64/pmap.c Sun Sep 20 17:46:56 2009 (r197365) +++ stable/7/sys/sparc64/sparc64/pmap.c Sun Sep 20 18:53:40 2009 (r197366) @@ -119,10 +119,9 @@ __FBSDID("$FreeBSD$"); extern struct mtx sched_lock; /* - * Virtual and physical address of message buffer + * Virtual address of message buffer */ struct msgbuf *msgbufp; -vm_paddr_t msgbuf_phys; /* * Map of physical memory reagions @@ -277,7 +276,7 @@ om_cmp(const void *a, const void *b) * Bootstrap the system enough to run with virtual memory. */ void -pmap_bootstrap(vm_offset_t ekva) +pmap_bootstrap(void) { struct pmap *pm; struct tte *tp; @@ -365,8 +364,8 @@ pmap_bootstrap(vm_offset_t ekva) /* * Allocate and map the message buffer. */ - msgbuf_phys = pmap_bootstrap_alloc(MSGBUF_SIZE); - msgbufp = (struct msgbuf *)TLB_PHYS_TO_DIRECT(msgbuf_phys); + pa = pmap_bootstrap_alloc(MSGBUF_SIZE); + msgbufp = (struct msgbuf *)TLB_PHYS_TO_DIRECT(pa); /* * Patch the virtual address and the tsb mask into the trap table. @@ -415,10 +414,11 @@ pmap_bootstrap(vm_offset_t ekva) } /* - * Set the start and end of KVA. The kernel is loaded at the first - * available 4MB super page, so round up to the end of the page. + * Set the start and end of KVA. The kernel is loaded starting + * at the first available 4MB super page, so we advance to the + * end of the last one used for it. */ - virtual_avail = roundup2(ekva, PAGE_SIZE_4M); + virtual_avail = KERNBASE + kernel_tlb_slots * PAGE_SIZE_4M; virtual_end = vm_max_kernel_address; kernel_vm_end = vm_max_kernel_address; @@ -438,8 +438,7 @@ pmap_bootstrap(vm_offset_t ekva) * coloured properly, since we're allocating from phys_avail so the * memory won't have an associated vm_page_t. */ - pa = pmap_bootstrap_alloc(roundup(KSTACK_PAGES, DCACHE_COLORS) * - PAGE_SIZE); + pa = pmap_bootstrap_alloc(KSTACK_PAGES * PAGE_SIZE); kstack0_phys = pa; virtual_avail += roundup(KSTACK_GUARD_PAGES, DCACHE_COLORS) * PAGE_SIZE; @@ -582,7 +581,7 @@ pmap_bootstrap_alloc(vm_size_t size) vm_paddr_t pa; int i; - size = round_page(size); + size = roundup(size, PAGE_SIZE * DCACHE_COLORS); for (i = 0; phys_avail[i + 1] != 0; i += 2) { if (phys_avail[i + 1] - phys_avail[i] < size) continue; @@ -942,7 +941,7 @@ pmap_kremove_flags(vm_offset_t va) struct tte *tp; tp = tsb_kvtotte(va); - CTR3(KTR_PMAP, "pmap_kremove: va=%#lx tp=%p data=%#lx", va, tp, + CTR3(KTR_PMAP, "pmap_kremove_flags: va=%#lx tp=%p data=%#lx", va, tp, tp->tte_data); TTE_ZERO(tp); } @@ -1345,7 +1344,7 @@ pmap_enter_locked(pmap_t pm, vm_offset_t } CTR6(KTR_PMAP, - "pmap_enter: ctx=%p m=%p va=%#lx pa=%#lx prot=%#x wired=%d", + "pmap_enter_locked: ctx=%p m=%p va=%#lx pa=%#lx prot=%#x wired=%d", pm->pm_context[curcpu], m, va, pa, prot, wired); /* @@ -1353,7 +1352,7 @@ pmap_enter_locked(pmap_t pm, vm_offset_t * changed, must be protection or wiring change. */ if ((tp = tsb_tte_lookup(pm, va)) != NULL && TTE_GET_PA(tp) == pa) { - CTR0(KTR_PMAP, "pmap_enter: update"); + CTR0(KTR_PMAP, "pmap_enter_locked: update"); PMAP_STATS_INC(pmap_nenter_update); /* @@ -1410,12 +1409,12 @@ pmap_enter_locked(pmap_t pm, vm_offset_t * phsyical address, delete the old mapping. */ if (tp != NULL) { - CTR0(KTR_PMAP, "pmap_enter: replace"); + CTR0(KTR_PMAP, "pmap_enter_locked: replace"); PMAP_STATS_INC(pmap_nenter_replace); pmap_remove_tte(pm, NULL, tp, va); tlb_page_demap(pm, va); } else { - CTR0(KTR_PMAP, "pmap_enter: new"); + CTR0(KTR_PMAP, "pmap_enter_locked: new"); PMAP_STATS_INC(pmap_nenter_new); } From owner-svn-src-stable@FreeBSD.ORG Sun Sep 20 18:59:30 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 788231065672; Sun, 20 Sep 2009 18:59:30 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 66C6C8FC1D; Sun, 20 Sep 2009 18:59:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8KIxUPO065158; Sun, 20 Sep 2009 18:59:30 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8KIxUq2065155; Sun, 20 Sep 2009 18:59:30 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909201859.n8KIxUq2065155@svn.freebsd.org> From: Marius Strobl Date: Sun, 20 Sep 2009 18:59:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197367 - in stable/7/sys: . contrib/pf dev/pci sparc64/include X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2009 18:59:30 -0000 Author: marius Date: Sun Sep 20 18:59:30 2009 New Revision: 197367 URL: http://svn.freebsd.org/changeset/base/197367 Log: MFC: r195808 Add a MD __PCI_BAR_ZERO_VALID which denotes that BARs containing 0 actually specify valid bases that should be treated just as normal. The PCI specifications have no indication that 0 would be a magic value indicating a disabled BAR as commonly used on at least amd64 and i386 but not sparc64. It's unclear what to do in pci_delete_resource() instead of writing 0 to a BAR though as there's no (other) way do disable individual BARs so its decoding is left enabled in case of __PCI_BAR_ZERO_VALID for now. Approved by: jhb Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/pci/pci.c stable/7/sys/sparc64/include/param.h Modified: stable/7/sys/dev/pci/pci.c ============================================================================== --- stable/7/sys/dev/pci/pci.c Sun Sep 20 18:53:40 2009 (r197366) +++ stable/7/sys/dev/pci/pci.c Sun Sep 20 18:59:30 2009 (r197367) @@ -2337,7 +2337,7 @@ pci_add_map(device_t bus, device_t dev, { pci_addr_t base, map, testval; pci_addr_t start, end, count; - int barlen, maprange, mapsize, type; + int barlen, basezero, maprange, mapsize, type; uint16_t cmd; struct resource *res; @@ -2350,6 +2350,11 @@ pci_add_map(device_t bus, device_t dev, type = SYS_RES_IOPORT; mapsize = pci_mapsize(testval); base = pci_mapbase(map); +#ifdef __PCI_BAR_ZERO_VALID + basezero = 0; +#else + basezero = base == 0; +#endif maprange = pci_maprange(map); barlen = maprange == 64 ? 2 : 1; @@ -2378,17 +2383,17 @@ pci_add_map(device_t bus, device_t dev, } /* - * If base is 0, then we have problems. It is best to ignore - * such entries for the moment. These will be allocated later if - * the driver specifically requests them. However, some - * removable busses look better when all resources are allocated, - * so allow '0' to be overriden. + * If base is 0, then we have problems if this architecture does + * not allow that. It is best to ignore such entries for the + * moment. These will be allocated later if the driver specifically + * requests them. However, some removable busses look better when + * all resources are allocated, so allow '0' to be overriden. * * Similarly treat maps whose values is the same as the test value * read back. These maps have had all f's written to them by the * BIOS in an attempt to disable the resources. */ - if (!force && (base == 0 || map == testval)) + if (!force && (basezero || map == testval)) return (barlen); if ((u_long)base != base) { device_printf(bus, @@ -2425,7 +2430,7 @@ pci_add_map(device_t bus, device_t dev, } count = 1 << mapsize; - if (base == 0 || base == pci_mapbase(testval)) { + if (basezero || base == pci_mapbase(testval)) { start = 0; /* Let the parent decide. */ end = ~0ULL; } else { @@ -3669,6 +3674,7 @@ pci_delete_resource(device_t dev, device return; } +#ifndef __PCI_BAR_ZERO_VALID /* * If this is a BAR, clear the BAR so it stops * decoding before releasing the resource. @@ -3679,6 +3685,7 @@ pci_delete_resource(device_t dev, device pci_write_bar(child, rid, 0); break; } +#endif bus_release_resource(dev, type, rid, rle->res); } resource_list_delete(rl, type, rid); Modified: stable/7/sys/sparc64/include/param.h ============================================================================== --- stable/7/sys/sparc64/include/param.h Sun Sep 20 18:53:40 2009 (r197366) +++ stable/7/sys/sparc64/include/param.h Sun Sep 20 18:59:30 2009 (r197367) @@ -48,6 +48,8 @@ #ifndef _NO_NAMESPACE_POLLUTION +#define __PCI_BAR_ZERO_VALID + #ifndef _MACHINE_PARAM_H_ #define _MACHINE_PARAM_H_ From owner-svn-src-stable@FreeBSD.ORG Sun Sep 20 19:26:04 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F23E0106566B; Sun, 20 Sep 2009 19:26:04 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E119C8FC08; Sun, 20 Sep 2009 19:26:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8KJQ47h065714; Sun, 20 Sep 2009 19:26:04 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8KJQ4Qf065712; Sun, 20 Sep 2009 19:26:04 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909201926.n8KJQ4Qf065712@svn.freebsd.org> From: Marius Strobl Date: Sun, 20 Sep 2009 19:26:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197369 - stable/6/sys/dev/gem X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2009 19:26:05 -0000 Author: marius Date: Sun Sep 20 19:26:04 2009 New Revision: 197369 URL: http://svn.freebsd.org/changeset/base/197369 Log: Re-apply adaption to stable/6 which somehow managed to escape r197355. Modified: stable/6/sys/dev/gem/if_gem_sbus.c Modified: stable/6/sys/dev/gem/if_gem_sbus.c ============================================================================== --- stable/6/sys/dev/gem/if_gem_sbus.c Sun Sep 20 19:14:34 2009 (r197368) +++ stable/6/sys/dev/gem/if_gem_sbus.c Sun Sep 20 19:26:04 2009 (r197369) @@ -167,7 +167,7 @@ gem_sbus_attach(device_t dev) } if (bus_setup_intr(dev, sc->sc_res[GEM_RES_INTR], INTR_TYPE_NET | - INTR_MPSAFE, NULL, gem_intr, sc, &sc->sc_ih) != 0) { + INTR_MPSAFE, gem_intr, sc, &sc->sc_ih) != 0) { device_printf(dev, "failed to set up interrupt\n"); gem_detach(sc); goto fail; From owner-svn-src-stable@FreeBSD.ORG Sun Sep 20 19:32:11 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3BBDE106566B; Sun, 20 Sep 2009 19:32:11 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 28BBD8FC13; Sun, 20 Sep 2009 19:32:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8KJWBre065891; Sun, 20 Sep 2009 19:32:11 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8KJWBZu065887; Sun, 20 Sep 2009 19:32:11 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909201932.n8KJWBZu065887@svn.freebsd.org> From: Marius Strobl Date: Sun, 20 Sep 2009 19:32:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197370 - in stable/6/sys: . conf contrib/pf dev/cxgb sparc64/include sparc64/sparc64 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2009 19:32:11 -0000 Author: marius Date: Sun Sep 20 19:32:10 2009 New Revision: 197370 URL: http://svn.freebsd.org/changeset/base/197370 Log: MFC: r195149 (partial) - Work around the broken loader behavior of not demapping no longer used kernel TLB slots when unloading the kernel or modules, which results in havoc when loading a kernel and modules which take up less TLB slots afterwards as the unused but locked ones aren't accounted for in virtual_avail. Eventually this should be fixed in the loader which isn't straight forward though and the kernel should be robust against this anyway. [1] - Remove the no longer used global msgbuf_phys. - Remove the redundant ekva parameter of pmap_bootstrap_alloc(). - Correct some outdated function names in ktr(9) invocations. Requested by: jhb [1] Modified: stable/6/sys/ (props changed) stable/6/sys/conf/ (props changed) stable/6/sys/contrib/pf/ (props changed) stable/6/sys/dev/cxgb/ (props changed) stable/6/sys/sparc64/include/pmap.h stable/6/sys/sparc64/sparc64/machdep.c stable/6/sys/sparc64/sparc64/pmap.c Modified: stable/6/sys/sparc64/include/pmap.h ============================================================================== --- stable/6/sys/sparc64/include/pmap.h Sun Sep 20 19:26:04 2009 (r197369) +++ stable/6/sys/sparc64/include/pmap.h Sun Sep 20 19:32:10 2009 (r197370) @@ -77,7 +77,7 @@ struct pmap { #define PMAP_TRYLOCK(pmap) mtx_trylock(&(pmap)->pm_mtx) #define PMAP_UNLOCK(pmap) mtx_unlock(&(pmap)->pm_mtx) -void pmap_bootstrap(vm_offset_t ekva); +void pmap_bootstrap(void); vm_paddr_t pmap_kextract(vm_offset_t va); void pmap_kenter(vm_offset_t va, vm_page_t m); void pmap_kremove(vm_offset_t); @@ -105,8 +105,6 @@ extern vm_paddr_t phys_avail[]; extern vm_offset_t virtual_avail; extern vm_offset_t virtual_end; -extern vm_paddr_t msgbuf_phys; - #ifdef PMAP_STATS SYSCTL_DECL(_debug_pmap_stats); Modified: stable/6/sys/sparc64/sparc64/machdep.c ============================================================================== --- stable/6/sys/sparc64/sparc64/machdep.c Sun Sep 20 19:26:04 2009 (r197369) +++ stable/6/sys/sparc64/sparc64/machdep.c Sun Sep 20 19:32:10 2009 (r197370) @@ -275,6 +275,7 @@ sparc64_init(caddr_t mdp, u_long o1, u_l char *env; struct pcpu *pc; vm_offset_t end; + vm_offset_t va; caddr_t kmdp; phandle_t child; phandle_t root; @@ -338,19 +339,28 @@ sparc64_init(caddr_t mdp, u_long o1, u_l * Panic if there is no metadata. Most likely the kernel was booted * directly, instead of through loader(8). */ - if (mdp == NULL || kmdp == NULL) { - printf("sparc64_init: no loader metadata.\n" + if (mdp == NULL || kmdp == NULL || end == 0 || + kernel_tlb_slots == 0 || kernel_tlbs == NULL) { + printf("sparc64_init: missing loader metadata.\n" "This probably means you are not using loader(8).\n"); panic("sparc64_init"); } /* - * Sanity check the kernel end, which is important. - */ - if (end == 0) { - printf("sparc64_init: warning, kernel end not specified.\n" - "Attempting to continue anyway.\n"); - end = (vm_offset_t)_end; + * Work around the broken loader behavior of not demapping no + * longer used kernel TLB slots when unloading the kernel or + * modules. + */ + for (va = KERNBASE + (kernel_tlb_slots - 1) * PAGE_SIZE_4M; + va >= roundup2(end, PAGE_SIZE_4M); va -= PAGE_SIZE_4M) { + printf("demapping unused kernel TLB slot (va %#lx - %#lx)\n", + va, va + PAGE_SIZE_4M - 1); + stxa(TLB_DEMAP_VA(va) | TLB_DEMAP_PRIMARY | TLB_DEMAP_PAGE, + ASI_DMMU_DEMAP, 0); + stxa(TLB_DEMAP_VA(va) | TLB_DEMAP_PRIMARY | TLB_DEMAP_PAGE, + ASI_IMMU_DEMAP, 0); + flush(KERNBASE); + kernel_tlb_slots--; } cache_init(child); @@ -371,7 +381,7 @@ sparc64_init(caddr_t mdp, u_long o1, u_l /* * Initialize virtual memory and calculate physmem. */ - pmap_bootstrap(end); + pmap_bootstrap(); /* * Initialize tunables. Modified: stable/6/sys/sparc64/sparc64/pmap.c ============================================================================== --- stable/6/sys/sparc64/sparc64/pmap.c Sun Sep 20 19:26:04 2009 (r197369) +++ stable/6/sys/sparc64/sparc64/pmap.c Sun Sep 20 19:32:10 2009 (r197370) @@ -111,10 +111,9 @@ __FBSDID("$FreeBSD$"); #endif /* - * Virtual and physical address of message buffer + * Virtual address of message buffer */ struct msgbuf *msgbufp; -vm_paddr_t msgbuf_phys; int pmap_pagedaemon_waken; @@ -271,7 +270,7 @@ om_cmp(const void *a, const void *b) * Bootstrap the system enough to run with virtual memory. */ void -pmap_bootstrap(vm_offset_t ekva) +pmap_bootstrap(void) { struct pmap *pm; struct tte *tp; @@ -349,8 +348,8 @@ pmap_bootstrap(vm_offset_t ekva) /* * Allocate and map the message buffer. */ - msgbuf_phys = pmap_bootstrap_alloc(MSGBUF_SIZE); - msgbufp = (struct msgbuf *)TLB_PHYS_TO_DIRECT(msgbuf_phys); + pa = pmap_bootstrap_alloc(MSGBUF_SIZE); + msgbufp = (struct msgbuf *)TLB_PHYS_TO_DIRECT(pa); /* * Patch the virtual address and the tsb mask into the trap table. @@ -399,10 +398,11 @@ pmap_bootstrap(vm_offset_t ekva) } /* - * Set the start and end of KVA. The kernel is loaded at the first - * available 4MB super page, so round up to the end of the page. + * Set the start and end of KVA. The kernel is loaded starting + * at the first available 4MB super page, so we advance to the + * end of the last one used for it. */ - virtual_avail = roundup2(ekva, PAGE_SIZE_4M); + virtual_avail = KERNBASE + kernel_tlb_slots * PAGE_SIZE_4M; virtual_end = vm_max_kernel_address; kernel_vm_end = vm_max_kernel_address; @@ -422,8 +422,7 @@ pmap_bootstrap(vm_offset_t ekva) * coloured properly, since we're allocating from phys_avail so the * memory won't have an associated vm_page_t. */ - pa = pmap_bootstrap_alloc(roundup(KSTACK_PAGES, DCACHE_COLORS) * - PAGE_SIZE); + pa = pmap_bootstrap_alloc(KSTACK_PAGES * PAGE_SIZE); kstack0_phys = pa; virtual_avail += roundup(KSTACK_GUARD_PAGES, DCACHE_COLORS) * PAGE_SIZE; @@ -560,7 +559,7 @@ pmap_bootstrap_alloc(vm_size_t size) vm_paddr_t pa; int i; - size = round_page(size); + size = roundup(size, PAGE_SIZE * DCACHE_COLORS); for (i = 0; phys_avail[i + 1] != 0; i += 2) { if (phys_avail[i + 1] - phys_avail[i] < size) continue; @@ -928,7 +927,7 @@ pmap_kremove_flags(vm_offset_t va) struct tte *tp; tp = tsb_kvtotte(va); - CTR3(KTR_PMAP, "pmap_kremove: va=%#lx tp=%p data=%#lx", va, tp, + CTR3(KTR_PMAP, "pmap_kremove_flags: va=%#lx tp=%p data=%#lx", va, tp, tp->tte_data); TTE_ZERO(tp); } @@ -1330,7 +1329,7 @@ pmap_enter_locked(pmap_t pm, vm_offset_t } CTR6(KTR_PMAP, - "pmap_enter: ctx=%p m=%p va=%#lx pa=%#lx prot=%#x wired=%d", + "pmap_enter_locked: ctx=%p m=%p va=%#lx pa=%#lx prot=%#x wired=%d", pm->pm_context[curcpu], m, va, pa, prot, wired); /* @@ -1338,7 +1337,7 @@ pmap_enter_locked(pmap_t pm, vm_offset_t * changed, must be protection or wiring change. */ if ((tp = tsb_tte_lookup(pm, va)) != NULL && TTE_GET_PA(tp) == pa) { - CTR0(KTR_PMAP, "pmap_enter: update"); + CTR0(KTR_PMAP, "pmap_enter_locked: update"); PMAP_STATS_INC(pmap_nenter_update); /* @@ -1394,12 +1393,12 @@ pmap_enter_locked(pmap_t pm, vm_offset_t * phsyical address, delete the old mapping. */ if (tp != NULL) { - CTR0(KTR_PMAP, "pmap_enter: replace"); + CTR0(KTR_PMAP, "pmap_enter_locked: replace"); PMAP_STATS_INC(pmap_nenter_replace); pmap_remove_tte(pm, NULL, tp, va); tlb_page_demap(pm, va); } else { - CTR0(KTR_PMAP, "pmap_enter: new"); + CTR0(KTR_PMAP, "pmap_enter_locked: new"); PMAP_STATS_INC(pmap_nenter_new); } From owner-svn-src-stable@FreeBSD.ORG Mon Sep 21 06:47:01 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0ADAD106566C; Mon, 21 Sep 2009 06:47:01 +0000 (UTC) (envelope-from blackend@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5AB578FC12; Mon, 21 Sep 2009 06:47:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8L6l0Af078849; Mon, 21 Sep 2009 06:47:00 GMT (envelope-from blackend@svn.freebsd.org) Received: (from blackend@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8L6l0ZW078848; Mon, 21 Sep 2009 06:47:00 GMT (envelope-from blackend@svn.freebsd.org) Message-Id: <200909210647.n8L6l0ZW078848@svn.freebsd.org> From: Marc Fonvieille Date: Mon, 21 Sep 2009 06:47:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197378 - in stable/8/release: . doc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2009 06:47:01 -0000 Author: blackend (doc committer) Date: Mon Sep 21 06:47:00 2009 New Revision: 197378 URL: http://svn.freebsd.org/changeset/base/197378 Log: Add missing mergeinfo for MFC of r196588. Pointy Hat: blackend Approved by: re (kib) Modified: stable/8/release/ (props changed) stable/8/release/doc/ (props changed) From owner-svn-src-stable@FreeBSD.ORG Tue Sep 22 20:31:33 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 51551106566B; Tue, 22 Sep 2009 20:31:33 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3E7618FC1A; Tue, 22 Sep 2009 20:31:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8MKVXYG031511; Tue, 22 Sep 2009 20:31:33 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8MKVXQU031508; Tue, 22 Sep 2009 20:31:33 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200909222031.n8MKVXQU031508@svn.freebsd.org> From: Rui Paulo Date: Tue, 22 Sep 2009 20:31:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197417 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/asmc dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2009 20:31:33 -0000 Author: rpaulo Date: Tue Sep 22 20:31:32 2009 New Revision: 197417 URL: http://svn.freebsd.org/changeset/base/197417 Log: MFC 197190: Make the sudden motion sensor work on older models and add a bit of debugging. Submitted by: Christoph Langguth Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/asmc/asmc.c stable/8/sys/dev/asmc/asmcvar.h stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/asmc/asmc.c ============================================================================== --- stable/8/sys/dev/asmc/asmc.c Tue Sep 22 20:12:10 2009 (r197416) +++ stable/8/sys/dev/asmc/asmc.c Tue Sep 22 20:31:32 2009 (r197417) @@ -86,6 +86,10 @@ static void asmc_sms_handler(void *arg) #endif static void asmc_sms_printintr(device_t dev, uint8_t); static void asmc_sms_task(void *arg, int pending); +#ifdef DEBUG +void asmc_dumpall(device_t); +static int asmc_key_dump(device_t, int); +#endif /* * Model functions. @@ -532,6 +536,17 @@ asmc_detach(device_t dev) return (0); } +#ifdef DEBUG +void asmc_dumpall(device_t dev) +{ + int i; + + /* XXX magic number */ + for (i=0; i < 0x100; i++) + asmc_key_dump(dev, i); +} +#endif + static int asmc_init(device_t dev) { @@ -584,13 +599,17 @@ asmc_init(device_t dev) asmc_key_write(dev, ASMC_KEY_SMS_FLAG, buf, 1); DELAY(100); + sc->sc_sms_intr_works = 0; + /* - * Wait up to 5 seconds for SMS initialization. + * Retry SMS initialization 1000 times + * (takes approx. 2 seconds in worst case) */ - for (i = 0; i < 10000; i++) { + for (i = 0; i < 1000; i++) { if (asmc_key_read(dev, ASMC_KEY_SMS, buf, 2) == 0 && - (buf[0] != 0x00 || buf[1] != 0x00)) { + (buf[0] == ASMC_SMS_INIT1 && buf[1] == ASMC_SMS_INIT2)) { error = 0; + sc->sc_sms_intr_works = 1; goto out; } buf[0] = ASMC_SMS_INIT1; @@ -620,6 +639,10 @@ nosms: device_printf(dev, "number of keys: %d\n", buf[3]); } +#ifdef DEBUG + asmc_dumpall(dev); +#endif + return (error); } @@ -729,6 +752,100 @@ out: return (error); } +#ifdef DEBUG +static int +asmc_key_dump(device_t dev, int number) +{ + struct asmc_softc *sc = device_get_softc(dev); + char key[5] = { 0 }; + char type[7] = { 0 }; + uint8_t index[4]; + uint8_t v[32]; + uint8_t maxlen; + int i, error = 1, try = 0; + + mtx_lock_spin(&sc->sc_mtx); + + index[0] = (number >> 24) & 0xff; + index[1] = (number >> 16) & 0xff; + index[2] = (number >> 8) & 0xff; + index[3] = (number) & 0xff; + +begin: + if (asmc_command(dev, 0x12)) + goto out; + + for (i = 0; i < 4; i++) { + ASMC_DATAPORT_WRITE(sc, index[i]); + if (asmc_wait(dev, 0x04)) + goto out; + } + + ASMC_DATAPORT_WRITE(sc, 4); + + for (i = 0; i < 4; i++) { + if (asmc_wait(dev, 0x05)) + goto out; + key[i] = ASMC_DATAPORT_READ(sc); + } + + /* get type */ + if (asmc_command(dev, 0x13)) + goto out; + + for (i = 0; i < 4; i++) { + ASMC_DATAPORT_WRITE(sc, key[i]); + if (asmc_wait(dev, 0x04)) + goto out; + } + + ASMC_DATAPORT_WRITE(sc, 6); + + for (i = 0; i < 6; i++) { + if (asmc_wait(dev, 0x05)) + goto out; + type[i] = ASMC_DATAPORT_READ(sc); + } + + error = 0; +out: + if (error) { + if (++try < 10) goto begin; + device_printf(dev,"%s for key %s failed %d times, giving up\n", + __func__, key, try); + mtx_unlock_spin(&sc->sc_mtx); + } + else { + char buf[1024]; + char buf2[8]; + mtx_unlock_spin(&sc->sc_mtx); + maxlen = type[0]; + type[0] = ' '; + type[5] = 0; + if (maxlen > sizeof(v)) { + device_printf(dev, + "WARNING: cropping maxlen from %d to %zu\n", + maxlen, sizeof(v)); + maxlen = sizeof(v); + } + for (i = 0; i < sizeof(v); i++) { + v[i] = 0; + } + asmc_key_read(dev, key, v, maxlen); + snprintf(buf, sizeof(buf), "key %d is: %s, type %s " + "(len %d), data", number, key, type, maxlen); + for (i = 0; i < maxlen; i++) { + snprintf(buf2, sizeof(buf), " %02x", v[i]); + strlcat(buf, buf2, sizeof(buf)); + } + strlcat(buf, " \n", sizeof(buf)); + device_printf(dev, buf); + } + + return (error); +} +#endif + static int asmc_key_write(device_t dev, const char *key, uint8_t *buf, uint8_t len) { @@ -945,6 +1062,8 @@ asmc_sms_intrfast(void *arg) uint8_t type; device_t dev = (device_t) arg; struct asmc_softc *sc = device_get_softc(dev); + if (!sc->sc_sms_intr_works) + return (FILTER_HANDLED); mtx_lock_spin(&sc->sc_mtx); type = ASMC_INTPORT_READ(sc); Modified: stable/8/sys/dev/asmc/asmcvar.h ============================================================================== --- stable/8/sys/dev/asmc/asmcvar.h Tue Sep 22 20:12:10 2009 (r197416) +++ stable/8/sys/dev/asmc/asmcvar.h Tue Sep 22 20:31:32 2009 (r197417) @@ -49,6 +49,7 @@ struct asmc_softc { int sc_sms_intrtype; struct taskqueue *sc_sms_tq; struct task sc_sms_task; + uint8_t sc_sms_intr_works; }; /* From owner-svn-src-stable@FreeBSD.ORG Tue Sep 22 23:11:24 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2E205106566C; Tue, 22 Sep 2009 23:11:24 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0258D8FC14; Tue, 22 Sep 2009 23:11:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8MNBN8i035354; Tue, 22 Sep 2009 23:11:23 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8MNBN5A035351; Tue, 22 Sep 2009 23:11:23 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <200909222311.n8MNBN5A035351@svn.freebsd.org> From: Ed Maste Date: Tue, 22 Sep 2009 23:11:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197422 - in stable/7/sys: . contrib/pf kern sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2009 23:11:24 -0000 Author: emaste Date: Tue Sep 22 23:11:23 2009 New Revision: 197422 URL: http://svn.freebsd.org/changeset/base/197422 Log: MFC r195134, r195135, r195191 r195134, r195134: Add a complement to FIONREAD, called FIONWRITE, which returns the number of bytes not yet properly disposed of. Implement it for all sockets. r195191: Add FIONSPACE from NetBSD. FIONSPACE is provided so that programs may easily determine how much space is left in the send queue; they do not need to know the send queue size. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/kern/sys_socket.c stable/7/sys/sys/filio.h Modified: stable/7/sys/kern/sys_socket.c ============================================================================== --- stable/7/sys/kern/sys_socket.c Tue Sep 22 22:23:52 2009 (r197421) +++ stable/7/sys/kern/sys_socket.c Tue Sep 22 23:11:23 2009 (r197422) @@ -161,6 +161,19 @@ soo_ioctl(struct file *fp, u_long cmd, v *(int *)data = so->so_rcv.sb_cc; break; + case FIONWRITE: + /* Unlocked read. */ + *(int *)data = so->so_snd.sb_cc; + break; + + case FIONSPACE: + if ((so->so_snd.sb_hiwat < so->so_snd.sb_cc) || + (so->so_snd.sb_mbmax < so->so_snd.sb_mbcnt)) + *(int *)data = 0; + else + *(int *)data = sbspace(&so->so_snd); + break; + case FIOSETOWN: error = fsetown(*(int *)data, &so->so_sigio); break; Modified: stable/7/sys/sys/filio.h ============================================================================== --- stable/7/sys/sys/filio.h Tue Sep 22 22:23:52 2009 (r197421) +++ stable/7/sys/sys/filio.h Tue Sep 22 23:11:23 2009 (r197422) @@ -55,6 +55,8 @@ struct fiodgname_arg { void *buf; }; #define FIODGNAME _IOW('f', 120, struct fiodgname_arg) /* get dev. name */ +#define FIONWRITE _IOR('f', 119, int) /* get # bytes (yet) to write */ +#define FIONSPACE _IOR('f', 118, int) /* get space in send queue */ /* Handle lseek SEEK_DATA and SEEK_HOLE for holey file knowledge. */ #define FIOSEEKDATA _IOWR('f', 97, off_t) /* SEEK_DATA */ #define FIOSEEKHOLE _IOWR('f', 98, off_t) /* SEEK_HOLE */ From owner-svn-src-stable@FreeBSD.ORG Wed Sep 23 00:31:09 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 11BEB1065679; Wed, 23 Sep 2009 00:31:09 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F3E4A8FC08; Wed, 23 Sep 2009 00:31:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8N0V8Qn036915; Wed, 23 Sep 2009 00:31:08 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8N0V8bF036913; Wed, 23 Sep 2009 00:31:08 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <200909230031.n8N0V8bF036913@svn.freebsd.org> From: Ed Maste Date: Wed, 23 Sep 2009 00:31:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197423 - stable/7/usr.bin/gcore X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2009 00:31:09 -0000 Author: emaste Date: Wed Sep 23 00:31:08 2009 New Revision: 197423 URL: http://svn.freebsd.org/changeset/base/197423 Log: MFC r180603: Use %zd for size_t. With this gcore(1) is WARNS=6 clean. Modified: stable/7/usr.bin/gcore/ (props changed) stable/7/usr.bin/gcore/elfcore.c Modified: stable/7/usr.bin/gcore/elfcore.c ============================================================================== --- stable/7/usr.bin/gcore/elfcore.c Tue Sep 22 23:11:23 2009 (r197422) +++ stable/7/usr.bin/gcore/elfcore.c Wed Sep 23 00:31:08 2009 (r197423) @@ -158,7 +158,7 @@ elf_coredump(int efd __unused, int fd, p err(1, "read from %s", memname); if ((size_t)ngot < nwant) errx(1, "short read from %s:" - " wanted %d, got %d", memname, + " wanted %zd, got %zd", memname, nwant, ngot); ngot = write(fd, buf, nwant); if (ngot == -1) @@ -414,7 +414,7 @@ readhdrinfo(pid_t pid, prstatus_t *statu if ((n = read(fd, &status->pr_reg, sizeof status->pr_reg)) == -1) err(1, "read error from %s", name); if ((size_t)n < sizeof(status->pr_reg)) - errx(1, "short read from %s: wanted %u, got %d", name, + errx(1, "short read from %s: wanted %zd, got %d", name, sizeof status->pr_reg, n); close(fd); @@ -425,7 +425,7 @@ readhdrinfo(pid_t pid, prstatus_t *statu if ((n = read(fd, fpregset, sizeof *fpregset)) == -1) err(1, "read error from %s", name); if ((size_t)n < sizeof(*fpregset)) - errx(1, "short read from %s: wanted %u, got %d", name, + errx(1, "short read from %s: wanted %zd, got %d", name, sizeof *fpregset, n); close(fd); From owner-svn-src-stable@FreeBSD.ORG Wed Sep 23 10:12:58 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C666D106566B; Wed, 23 Sep 2009 10:12:58 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B52A78FC1C; Wed, 23 Sep 2009 10:12:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8NACwp4059631; Wed, 23 Sep 2009 10:12:58 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8NACwlo059629; Wed, 23 Sep 2009 10:12:58 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909231012.n8NACwlo059629@svn.freebsd.org> From: Marius Strobl Date: Wed, 23 Sep 2009 10:12:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197427 - stable/8/release/doc/en_US.ISO8859-1/hardware X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2009 10:12:58 -0000 Author: marius Date: Wed Sep 23 10:12:58 2009 New Revision: 197427 URL: http://svn.freebsd.org/changeset/base/197427 Log: MFC: r197368 - Update the list of known-working machines based on feedback for 7.2. - Update the V440 entry regarding added support for the on-board NICs in 8.0. Approved by: re (kib), blackend Modified: stable/8/release/doc/en_US.ISO8859-1/hardware/ (props changed) stable/8/release/doc/en_US.ISO8859-1/hardware/article.sgml Modified: stable/8/release/doc/en_US.ISO8859-1/hardware/article.sgml ============================================================================== --- stable/8/release/doc/en_US.ISO8859-1/hardware/article.sgml Wed Sep 23 09:18:16 2009 (r197426) +++ stable/8/release/doc/en_US.ISO8859-1/hardware/article.sgml Wed Sep 23 10:12:58 2009 (r197427) @@ -503,6 +503,10 @@ + &sun.blade; 2500 + + + &sun.fire; 280R @@ -511,7 +515,12 @@ - &sun.fire; V440 (except for the on-board NICs) + &sun.fire; V250 + + + + &sun.fire; V440 (support for the on-board NICs first + appeared in 8.0-RELEASE) From owner-svn-src-stable@FreeBSD.ORG Wed Sep 23 13:49:43 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 08380106566B; Wed, 23 Sep 2009 13:49:43 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E897C8FC14; Wed, 23 Sep 2009 13:49:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8NDngjR065369; Wed, 23 Sep 2009 13:49:42 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8NDng9i065368; Wed, 23 Sep 2009 13:49:42 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200909231349.n8NDng9i065368@svn.freebsd.org> From: Konstantin Belousov Date: Wed, 23 Sep 2009 13:49:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197431 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci vm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2009 13:49:43 -0000 Author: kib Date: Wed Sep 23 13:49:41 2009 New Revision: 197431 URL: http://svn.freebsd.org/changeset/base/197431 Log: MFC r197348: For a.out and pre-8 ELF binaries, allow the mmap of zero length. Approved by: re (kensmith) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/vm/vm_mmap.c Modified: stable/8/sys/vm/vm_mmap.c ============================================================================== --- stable/8/sys/vm/vm_mmap.c Wed Sep 23 12:33:32 2009 (r197430) +++ stable/8/sys/vm/vm_mmap.c Wed Sep 23 13:49:41 2009 (r197431) @@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -229,7 +230,8 @@ mmap(td, uap) fp = NULL; /* make sure mapping fits into numeric range etc */ - if (uap->len == 0 || + if ((uap->len == 0 && !SV_CURPROC_FLAG(SV_AOUT) && + curproc->p_osrel >= 800104) || ((flags & MAP_ANON) && uap->fd != -1)) return (EINVAL); From owner-svn-src-stable@FreeBSD.ORG Wed Sep 23 15:56:10 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 770AE1065672; Wed, 23 Sep 2009 15:56:10 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 649AC8FC0A; Wed, 23 Sep 2009 15:56:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8NFuAbV068123; Wed, 23 Sep 2009 15:56:10 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8NFuATY068121; Wed, 23 Sep 2009 15:56:10 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200909231556.n8NFuATY068121@svn.freebsd.org> From: John Baldwin Date: Wed, 23 Sep 2009 15:56:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197440 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/acpi_support dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2009 15:56:10 -0000 Author: jhb Date: Wed Sep 23 15:56:09 2009 New Revision: 197440 URL: http://svn.freebsd.org/changeset/base/197440 Log: MFC 197350: Re-remove the IBM0057 ID used for PS/2 mouse controllers. The asl for the 61p includes the hotkey device as IBM0068 and the mouse as IBM0057 similar to other systems. Approved by: re (kensmith) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/acpi_support/acpi_ibm.c stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/acpi_support/acpi_ibm.c ============================================================================== --- stable/8/sys/dev/acpi_support/acpi_ibm.c Wed Sep 23 15:42:35 2009 (r197439) +++ stable/8/sys/dev/acpi_support/acpi_ibm.c Wed Sep 23 15:56:09 2009 (r197440) @@ -288,7 +288,7 @@ static devclass_t acpi_ibm_devclass; DRIVER_MODULE(acpi_ibm, acpi, acpi_ibm_driver, acpi_ibm_devclass, 0, 0); MODULE_DEPEND(acpi_ibm, acpi, 1, 1, 1); -static char *ibm_ids[] = {"IBM0057", "IBM0068", NULL}; +static char *ibm_ids[] = {"IBM0068", NULL}; static void ibm_led(void *softc, int onoff) From owner-svn-src-stable@FreeBSD.ORG Thu Sep 24 08:35:18 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5512A106566C; Thu, 24 Sep 2009 08:35:18 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 42E1A8FC13; Thu, 24 Sep 2009 08:35:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8O8ZI4x090124; Thu, 24 Sep 2009 08:35:18 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8O8ZIeI090122; Thu, 24 Sep 2009 08:35:18 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <200909240835.n8O8ZIeI090122@svn.freebsd.org> From: Attilio Rao Date: Thu, 24 Sep 2009 08:35:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197452 - in stable/8/lib/libthr: . thread X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2009 08:35:18 -0000 Author: attilio Date: Thu Sep 24 08:35:17 2009 New Revision: 197452 URL: http://svn.freebsd.org/changeset/base/197452 Log: MFC r197445: Let fall down in the hard path (thus handling shared waiters wakeup correctly) for the shared waiters also in the rwlock held in shared mode as well, fixing possible deadlocks. Please note that this is a special condition as we want this fix in before RC2 as we assume it is critical and so it has been handled as an instant-merge. For the STABLE_7 branch, 1 week before the MFC is assumed. Approved by: re (kib) Modified: stable/8/lib/libthr/ (props changed) stable/8/lib/libthr/thread/thr_umtx.h Modified: stable/8/lib/libthr/thread/thr_umtx.h ============================================================================== --- stable/8/lib/libthr/thread/thr_umtx.h Thu Sep 24 08:16:12 2009 (r197451) +++ stable/8/lib/libthr/thread/thr_umtx.h Thu Sep 24 08:35:17 2009 (r197452) @@ -171,8 +171,11 @@ _thr_rwlock_unlock(struct urwlock *rwloc for (;;) { if (__predict_false(URWLOCK_READER_COUNT(state) == 0)) return (EPERM); - if (!((state & URWLOCK_WRITE_WAITERS) && URWLOCK_READER_COUNT(state) == 1)) { - if (atomic_cmpset_rel_32(&rwlock->rw_state, state, state-1)) + if (!((state & (URWLOCK_WRITE_WAITERS | + URWLOCK_READ_WAITERS)) && + URWLOCK_READER_COUNT(state) == 1)) { + if (atomic_cmpset_rel_32(&rwlock->rw_state, + state, state-1)) return (0); state = rwlock->rw_state; } else { From owner-svn-src-stable@FreeBSD.ORG Thu Sep 24 09:08:23 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 523A8106566B; Thu, 24 Sep 2009 09:08:23 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 400448FC19; Thu, 24 Sep 2009 09:08:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8O98NVR091258; Thu, 24 Sep 2009 09:08:23 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8O98Ncg091256; Thu, 24 Sep 2009 09:08:23 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <200909240908.n8O98Ncg091256@svn.freebsd.org> From: Attilio Rao Date: Thu, 24 Sep 2009 09:08:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197453 - in stable/7/sys: . contrib/pf kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2009 09:08:23 -0000 Author: attilio Date: Thu Sep 24 09:08:22 2009 New Revision: 197453 URL: http://svn.freebsd.org/changeset/base/197453 Log: MFC r197223: Fix a deadlock in sched_switch_migrate given by the runqueues being not locked at once together when doing the switch. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/kern/sched_ule.c Modified: stable/7/sys/kern/sched_ule.c ============================================================================== --- stable/7/sys/kern/sched_ule.c Thu Sep 24 08:35:17 2009 (r197452) +++ stable/7/sys/kern/sched_ule.c Thu Sep 24 09:08:22 2009 (r197453) @@ -1822,18 +1822,24 @@ sched_switch_migrate(struct tdq *tdq, st */ spinlock_enter(); thread_block_switch(td); /* This releases the lock on tdq. */ - TDQ_LOCK(tdn); - tdq_add(tdn, td, flags); - tdq_notify(td->td_sched); - /* - * After we unlock tdn the new cpu still can't switch into this - * thread until we've unblocked it in cpu_switch(). The lock - * pointers may match in the case of HTT cores. Don't unlock here - * or we can deadlock when the other CPU runs the IPI handler. + + /* + * Acquire both run-queue locks before placing the thread on the new + * run-queue to avoid deadlocks created by placing a thread with a + * blocked lock on the run-queue of a remote processor. The deadlock + * occurs when a third processor attempts to lock the two queues in + * question while the target processor is spinning with its own + * run-queue lock held while waiting for the blocked lock to clear. */ - if (TDQ_LOCKPTR(tdn) != TDQ_LOCKPTR(tdq)) { - TDQ_UNLOCK(tdn); + if (TDQ_LOCKPTR(tdn) == TDQ_LOCKPTR(tdq)) { TDQ_LOCK(tdq); + tdq_add(tdn, td, flags); + tdq_notify(td->td_sched); + } else { + tdq_lock_pair(tdn, tdq); + tdq_add(tdn, td, flags); + tdq_notify(td->td_sched); + TDQ_UNLOCK(tdn); } spinlock_exit(); #endif From owner-svn-src-stable@FreeBSD.ORG Thu Sep 24 14:30:17 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7A4AA1065670; Thu, 24 Sep 2009 14:30:17 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4F4A08FC13; Thu, 24 Sep 2009 14:30:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8OEUHof099334; Thu, 24 Sep 2009 14:30:17 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8OEUHDl099333; Thu, 24 Sep 2009 14:30:17 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200909241430.n8OEUHDl099333@svn.freebsd.org> From: John Baldwin Date: Thu, 24 Sep 2009 14:30:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197456 - stable/7/release/doc/en_US.ISO8859-1/hardware X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2009 14:30:17 -0000 Author: jhb Date: Thu Sep 24 14:30:17 2009 New Revision: 197456 URL: http://svn.freebsd.org/changeset/base/197456 Log: Manually remove mergeinfo from this file. For some reason svn didn't elide this automatically as it should have during the previous revision. Modified: stable/7/release/doc/en_US.ISO8859-1/hardware/article.sgml (props changed) From owner-svn-src-stable@FreeBSD.ORG Thu Sep 24 15:34:19 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3F81510656A4; Thu, 24 Sep 2009 15:34:19 +0000 (UTC) (envelope-from nyan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2E5668FC29; Thu, 24 Sep 2009 15:34:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8OFYJp5000572; Thu, 24 Sep 2009 15:34:19 GMT (envelope-from nyan@svn.freebsd.org) Received: (from nyan@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8OFYJLN000570; Thu, 24 Sep 2009 15:34:19 GMT (envelope-from nyan@svn.freebsd.org) Message-Id: <200909241534.n8OFYJLN000570@svn.freebsd.org> From: Takahashi Yoshihiro Date: Thu, 24 Sep 2009 15:34:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197457 - stable/8/lib/libdisk X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2009 15:34:19 -0000 Author: nyan Date: Thu Sep 24 15:34:18 2009 New Revision: 197457 URL: http://svn.freebsd.org/changeset/base/197457 Log: MFC: r197322 and r197374 Revision: 197322 Log: Correct BIOS header sanitizing on pc98. Revision: 197374 Log: Disable a check on a disk size because it's too strict. This change is to avoid using incorrect geometry. It seems that this is the same problem in g_part_bsd_read()@g_part_bsd.c. Reviewed by: rink Approved by: re (kib) Modified: stable/8/lib/libdisk/ (props changed) stable/8/lib/libdisk/change.c Modified: stable/8/lib/libdisk/change.c ============================================================================== --- stable/8/lib/libdisk/change.c Thu Sep 24 14:30:17 2009 (r197456) +++ stable/8/lib/libdisk/change.c Thu Sep 24 15:34:18 2009 (r197457) @@ -36,17 +36,22 @@ Sanitize_Bios_Geom(struct disk *disk) if (disk->bios_cyl >= 65536) sane = 0; - if (disk->bios_hd > 256) - sane = 0; #ifdef PC98 + if (disk->bios_hd >= 256) + sane = 0; if (disk->bios_sect >= 256) + sane = 0; #else + if (disk->bios_hd > 256) + sane = 0; if (disk->bios_sect > 63) -#endif sane = 0; +#endif +#if 0 /* Disable a check on a disk size. It's too strict. */ if (disk->bios_cyl * disk->bios_hd * disk->bios_sect != disk->chunks->size) sane = 0; +#endif if (sane) return; From owner-svn-src-stable@FreeBSD.ORG Thu Sep 24 20:43:08 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6FE1A1065692; Thu, 24 Sep 2009 20:43:08 +0000 (UTC) (envelope-from sepotvin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5DF6D8FC26; Thu, 24 Sep 2009 20:43:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8OKh8t4007221; Thu, 24 Sep 2009 20:43:08 GMT (envelope-from sepotvin@svn.freebsd.org) Received: (from sepotvin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8OKh8Yl007218; Thu, 24 Sep 2009 20:43:08 GMT (envelope-from sepotvin@svn.freebsd.org) Message-Id: <200909242043.n8OKh8Yl007218@svn.freebsd.org> From: "Stephane E. Potvin" Date: Thu, 24 Sep 2009 20:43:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197472 - stable/8/gnu/usr.bin/patch X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2009 20:43:08 -0000 Author: sepotvin Date: Thu Sep 24 20:43:08 2009 New Revision: 197472 URL: http://svn.freebsd.org/changeset/base/197472 Log: MFC r197259 The buffer returned by fgetln is not a "C" string and might not be NUL terminated. Make sure that it is before using it. Reviewed by: marck@ Approved by: re (kib) Modified: stable/8/gnu/usr.bin/patch/ (props changed) stable/8/gnu/usr.bin/patch/common.h stable/8/gnu/usr.bin/patch/pch.c Modified: stable/8/gnu/usr.bin/patch/common.h ============================================================================== --- stable/8/gnu/usr.bin/patch/common.h Thu Sep 24 20:34:44 2009 (r197471) +++ stable/8/gnu/usr.bin/patch/common.h Thu Sep 24 20:43:08 2009 (r197472) @@ -34,6 +34,7 @@ #define Strcpy (void)strcpy #define Strcat (void)strcat #define Strlcpy (void)strlcpy +#define Strncpy (void)strncpy #define Strlcat (void)strlcat /* NeXT declares malloc and realloc incompatibly from us in some of Modified: stable/8/gnu/usr.bin/patch/pch.c ============================================================================== --- stable/8/gnu/usr.bin/patch/pch.c Thu Sep 24 20:34:44 2009 (r197471) +++ stable/8/gnu/usr.bin/patch/pch.c Thu Sep 24 20:43:08 2009 (r197472) @@ -1152,7 +1152,8 @@ pgets(bool do_indent) indent++; } } - Strlcpy(buf, line, len + 1 - skipped); + Strncpy(buf, line, len - skipped); + buf[len - skipped] = '\0'; } return len; } From owner-svn-src-stable@FreeBSD.ORG Thu Sep 24 21:32:57 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 548DC1065670; Thu, 24 Sep 2009 21:32:57 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 415398FC1C; Thu, 24 Sep 2009 21:32:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8OLWvAN008156; Thu, 24 Sep 2009 21:32:57 GMT (envelope-from brooks@svn.freebsd.org) Received: (from brooks@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8OLWvOJ008154; Thu, 24 Sep 2009 21:32:57 GMT (envelope-from brooks@svn.freebsd.org) Message-Id: <200909242132.n8OLWvOJ008154@svn.freebsd.org> From: Brooks Davis Date: Thu, 24 Sep 2009 21:32:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197473 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci ufs/ufs X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2009 21:32:57 -0000 Author: brooks Date: Thu Sep 24 21:32:56 2009 New Revision: 197473 URL: http://svn.freebsd.org/changeset/base/197473 Log: MFC r197269: Allocate space for the group array in a static credential used in the quota code. One case was correctly handled in r194498, but this one was missed. PR: kern/138657 Tested by: PR submitter MFC after: 3 days Approved by: re@ (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/ufs/ufs/ufs_vnops.c Modified: stable/8/sys/ufs/ufs/ufs_vnops.c ============================================================================== --- stable/8/sys/ufs/ufs/ufs_vnops.c Thu Sep 24 20:43:08 2009 (r197472) +++ stable/8/sys/ufs/ufs/ufs_vnops.c Thu Sep 24 21:32:56 2009 (r197473) @@ -1449,6 +1449,7 @@ ufs_mkdir(ap) { #ifdef QUOTA struct ucred ucred, *ucp; + gid_t ucred_group; ucp = cnp->cn_cred; #endif /* @@ -1476,6 +1477,7 @@ ufs_mkdir(ap) refcount_init(&ucred.cr_ref, 1); ucred.cr_uid = ip->i_uid; ucred.cr_ngroups = 1; + ucred.cr_groups = &ucred_group; ucred.cr_groups[0] = dp->i_gid; ucp = &ucred; } From owner-svn-src-stable@FreeBSD.ORG Thu Sep 24 21:35:14 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3044A106568F; Thu, 24 Sep 2009 21:35:14 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DE11D8FC14; Thu, 24 Sep 2009 21:35:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8OLZDQf008258; Thu, 24 Sep 2009 21:35:13 GMT (envelope-from brooks@svn.freebsd.org) Received: (from brooks@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8OLZDnY008256; Thu, 24 Sep 2009 21:35:13 GMT (envelope-from brooks@svn.freebsd.org) Message-Id: <200909242135.n8OLZDnY008256@svn.freebsd.org> From: Brooks Davis Date: Thu, 24 Sep 2009 21:35:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197474 - stable/8/lib/libkvm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2009 21:35:14 -0000 Author: brooks Date: Thu Sep 24 21:35:13 2009 New Revision: 197474 URL: http://svn.freebsd.org/changeset/base/197474 Log: MFC r196990: cr_groups is no longer embedded in struct ucred and is instead stored in a seperate array. As such we need to use kvm_read rather than bcopy to populate the ki_groups field. This fixes a crash when running ps -ax on a coredump. Reported by: brucec Tested by: brucec MFC after: 3 days Approved by: re@ (kib) Modified: stable/8/lib/libkvm/ (props changed) stable/8/lib/libkvm/kvm_proc.c Modified: stable/8/lib/libkvm/kvm_proc.c ============================================================================== --- stable/8/lib/libkvm/kvm_proc.c Thu Sep 24 21:32:56 2009 (r197473) +++ stable/8/lib/libkvm/kvm_proc.c Thu Sep 24 21:35:13 2009 (r197474) @@ -151,7 +151,7 @@ kvm_proclist(kd, what, arg, p, bp, maxcn kp->ki_cr_flags |= KI_CRF_GRP_OVERFLOW; } kp->ki_ngroups = ucred.cr_ngroups; - bcopy(ucred.cr_groups, kp->ki_groups, + kvm_read(kd, (u_long)ucred.cr_groups, kp->ki_groups, kp->ki_ngroups * sizeof(gid_t)); kp->ki_uid = ucred.cr_uid; if (ucred.cr_prison != NULL) { From owner-svn-src-stable@FreeBSD.ORG Fri Sep 25 07:57:29 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 697F01065749; Fri, 25 Sep 2009 07:57:29 +0000 (UTC) (envelope-from marck@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3DAAB8FC18; Fri, 25 Sep 2009 07:57:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8P7vT5Z021748; Fri, 25 Sep 2009 07:57:29 GMT (envelope-from marck@svn.freebsd.org) Received: (from marck@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8P7vTih021746; Fri, 25 Sep 2009 07:57:29 GMT (envelope-from marck@svn.freebsd.org) Message-Id: <200909250757.n8P7vTih021746@svn.freebsd.org> From: Dmitry Morozovsky Date: Fri, 25 Sep 2009 07:57:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197479 - in stable/7/sys: . cddl/contrib/opensolaris/uts/common/fs/zfs contrib/pf X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2009 07:57:29 -0000 Author: marck (doc committer) Date: Fri Sep 25 07:57:28 2009 New Revision: 197479 URL: http://svn.freebsd.org/changeset/base/197479 Log: MFC r197150: There is a bug where mze_insert() can trigger an assert() of inserting the same entry twice. This bug is not fixed yet, but leads to situation where when try to access corrupted directory the kernel will panic. Until the bug is properly fixed, try to recover from it and log that it happened. OpenSolaris bug: 6709336 Approved by: pjd Modified: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c ============================================================================== --- stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Fri Sep 25 02:19:57 2009 (r197478) +++ stable/7/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Fri Sep 25 07:57:28 2009 (r197479) @@ -181,10 +181,11 @@ mze_compare(const void *arg1, const void return (0); } -static void +static int mze_insert(zap_t *zap, int chunkid, uint64_t hash, mzap_ent_phys_t *mzep) { mzap_ent_t *mze; + avl_index_t idx; ASSERT(zap->zap_ismicro); ASSERT(RW_WRITE_HELD(&zap->zap_rwlock)); @@ -194,7 +195,12 @@ mze_insert(zap_t *zap, int chunkid, uint mze->mze_chunkid = chunkid; mze->mze_hash = hash; mze->mze_phys = *mzep; - avl_add(&zap->zap_m.zap_avl, mze); + if (avl_find(&zap->zap_m.zap_avl, mze, &idx) != NULL) { + kmem_free(mze, sizeof (mzap_ent_t)); + return (EEXIST); + } + avl_insert(&zap->zap_m.zap_avl, mze, idx); + return (0); } static mzap_ent_t * @@ -329,10 +335,15 @@ mzap_open(objset_t *os, uint64_t obj, dm if (mze->mze_name[0]) { zap_name_t *zn; - zap->zap_m.zap_num_entries++; zn = zap_name_alloc(zap, mze->mze_name, MT_EXACT); - mze_insert(zap, i, zn->zn_hash, mze); + if (mze_insert(zap, i, zn->zn_hash, mze) == 0) + zap->zap_m.zap_num_entries++; + else { + printf("ZFS WARNING: Duplicated ZAP " + "entry detected (%s).", + mze->mze_name); + } zap_name_free(zn); } } @@ -771,7 +782,7 @@ again: if (zap->zap_m.zap_alloc_next == zap->zap_m.zap_num_chunks) zap->zap_m.zap_alloc_next = 0; - mze_insert(zap, i, zn->zn_hash, mze); + VERIFY(0 == mze_insert(zap, i, zn->zn_hash, mze)); return; } } From owner-svn-src-stable@FreeBSD.ORG Fri Sep 25 14:58:01 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 313441065757; Fri, 25 Sep 2009 14:58:01 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 04A8D8FC24; Fri, 25 Sep 2009 14:58:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8PEw0RL031660; Fri, 25 Sep 2009 14:58:00 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8PEw0sn031658; Fri, 25 Sep 2009 14:58:00 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200909251458.n8PEw0sn031658@svn.freebsd.org> From: John Baldwin Date: Fri, 25 Sep 2009 14:58:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197482 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/pci dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2009 14:58:01 -0000 Author: jhb Date: Fri Sep 25 14:58:00 2009 New Revision: 197482 URL: http://svn.freebsd.org/changeset/base/197482 Log: MFC 197406: Don't reread the command register to see if enabling I/O or memory decoding "took". Other OS's that I checked do not do this and it breaks some amdpm(4) devices. Prior to 7.2 we did not honor the error returned when this failed anyway, so this in effect restores previous behavior. Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/pci/pci.c stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/pci/pci.c ============================================================================== --- stable/8/sys/dev/pci/pci.c Fri Sep 25 13:51:01 2009 (r197481) +++ stable/8/sys/dev/pci/pci.c Fri Sep 25 14:58:00 2009 (r197482) @@ -2149,62 +2149,38 @@ pci_disable_busmaster_method(device_t de int pci_enable_io_method(device_t dev, device_t child, int space) { - uint16_t command; uint16_t bit; - char *error; - - bit = 0; - error = NULL; switch(space) { case SYS_RES_IOPORT: bit = PCIM_CMD_PORTEN; - error = "port"; break; case SYS_RES_MEMORY: bit = PCIM_CMD_MEMEN; - error = "memory"; break; default: return (EINVAL); } pci_set_command_bit(dev, child, bit); - /* Some devices seem to need a brief stall here, what do to? */ - command = PCI_READ_CONFIG(dev, child, PCIR_COMMAND, 2); - if (command & bit) - return (0); - device_printf(child, "failed to enable %s mapping!\n", error); - return (ENXIO); + return (0); } int pci_disable_io_method(device_t dev, device_t child, int space) { - uint16_t command; uint16_t bit; - char *error; - - bit = 0; - error = NULL; switch(space) { case SYS_RES_IOPORT: bit = PCIM_CMD_PORTEN; - error = "port"; break; case SYS_RES_MEMORY: bit = PCIM_CMD_MEMEN; - error = "memory"; break; default: return (EINVAL); } pci_clear_command_bit(dev, child, bit); - command = PCI_READ_CONFIG(dev, child, PCIR_COMMAND, 2); - if (command & bit) { - device_printf(child, "failed to disable %s mapping!\n", error); - return (ENXIO); - } return (0); } From owner-svn-src-stable@FreeBSD.ORG Fri Sep 25 14:58:31 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 89A201065670; Fri, 25 Sep 2009 14:58:31 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E52598FC1A; Fri, 25 Sep 2009 14:58:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8PEwUtH031717; Fri, 25 Sep 2009 14:58:30 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8PEwURd031715; Fri, 25 Sep 2009 14:58:30 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200909251458.n8PEwURd031715@svn.freebsd.org> From: John Baldwin Date: Fri, 25 Sep 2009 14:58:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197483 - in stable/7/sys: . contrib/pf dev/pci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2009 14:58:31 -0000 Author: jhb Date: Fri Sep 25 14:58:30 2009 New Revision: 197483 URL: http://svn.freebsd.org/changeset/base/197483 Log: MFC 197406: Don't reread the command register to see if enabling I/O or memory decoding "took". Other OS's that I checked do not do this and it breaks some amdpm(4) devices. Prior to 7.2 we did not honor the error returned when this failed anyway, so this in effect restores previous behavior. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/pci/pci.c Modified: stable/7/sys/dev/pci/pci.c ============================================================================== --- stable/7/sys/dev/pci/pci.c Fri Sep 25 14:58:00 2009 (r197482) +++ stable/7/sys/dev/pci/pci.c Fri Sep 25 14:58:30 2009 (r197483) @@ -2134,62 +2134,38 @@ pci_disable_busmaster_method(device_t de int pci_enable_io_method(device_t dev, device_t child, int space) { - uint16_t command; uint16_t bit; - char *error; - - bit = 0; - error = NULL; switch(space) { case SYS_RES_IOPORT: bit = PCIM_CMD_PORTEN; - error = "port"; break; case SYS_RES_MEMORY: bit = PCIM_CMD_MEMEN; - error = "memory"; break; default: return (EINVAL); } pci_set_command_bit(dev, child, bit); - /* Some devices seem to need a brief stall here, what do to? */ - command = PCI_READ_CONFIG(dev, child, PCIR_COMMAND, 2); - if (command & bit) - return (0); - device_printf(child, "failed to enable %s mapping!\n", error); - return (ENXIO); + return (0); } int pci_disable_io_method(device_t dev, device_t child, int space) { - uint16_t command; uint16_t bit; - char *error; - - bit = 0; - error = NULL; switch(space) { case SYS_RES_IOPORT: bit = PCIM_CMD_PORTEN; - error = "port"; break; case SYS_RES_MEMORY: bit = PCIM_CMD_MEMEN; - error = "memory"; break; default: return (EINVAL); } pci_clear_command_bit(dev, child, bit); - command = PCI_READ_CONFIG(dev, child, PCIR_COMMAND, 2); - if (command & bit) { - device_printf(child, "failed to disable %s mapping!\n", error); - return (ENXIO); - } return (0); } From owner-svn-src-stable@FreeBSD.ORG Fri Sep 25 15:08:26 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A18381065697; Fri, 25 Sep 2009 15:08:26 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8DC4B8FC0C; Fri, 25 Sep 2009 15:08:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8PF8QGK031984; Fri, 25 Sep 2009 15:08:26 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8PF8QQP031981; Fri, 25 Sep 2009 15:08:26 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200909251508.n8PF8QQP031981@svn.freebsd.org> From: John Baldwin Date: Fri, 25 Sep 2009 15:08:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197484 - in stable/8/sys: . amd64/amd64 amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci i386/i386 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2009 15:08:26 -0000 Author: jhb Date: Fri Sep 25 15:08:26 2009 New Revision: 197484 URL: http://svn.freebsd.org/changeset/base/197484 Log: MFC 197410: - Split the logic to parse an SMAP entry out into a separate function on amd64 similar to i386. This fixes a bug on amd64 where overlapping entries would not cause the SMAP parsing to stop. - Change the SMAP parsing code to do a sorted insertion into physmap[] instead of an append to support systems with out-of-order SMAP entries. Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/amd64/machdep.c stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/i386/i386/machdep.c Modified: stable/8/sys/amd64/amd64/machdep.c ============================================================================== --- stable/8/sys/amd64/amd64/machdep.c Fri Sep 25 14:58:30 2009 (r197483) +++ stable/8/sys/amd64/amd64/machdep.c Fri Sep 25 15:08:26 2009 (r197484) @@ -1192,6 +1192,77 @@ isa_irq_pending(void) u_int basemem; +static int +add_smap_entry(struct bios_smap *smap, vm_paddr_t *physmap, int *physmap_idxp) +{ + int i, insert_idx, physmap_idx; + + physmap_idx = *physmap_idxp; + + if (boothowto & RB_VERBOSE) + printf("SMAP type=%02x base=%016lx len=%016lx\n", + smap->type, smap->base, smap->length); + + if (smap->type != SMAP_TYPE_MEMORY) + return (1); + + if (smap->length == 0) + return (0); + + /* + * Find insertion point while checking for overlap. Start off by + * assuming the new entry will be added to the end. + */ + insert_idx = physmap_idx + 2; + for (i = 0; i <= physmap_idx; i += 2) { + if (smap->base < physmap[i + 1]) { + if (smap->base + smap->length <= physmap[i]) { + insert_idx = i; + break; + } + if (boothowto & RB_VERBOSE) + printf( + "Overlapping memory regions, ignoring second region\n"); + return (1); + } + } + + /* See if we can prepend to the next entry. */ + if (insert_idx <= physmap_idx && + smap->base + smap->length == physmap[insert_idx]) { + physmap[insert_idx] = smap->base; + return (1); + } + + /* See if we can append to the previous entry. */ + if (insert_idx > 0 && smap->base == physmap[insert_idx - 1]) { + physmap[insert_idx - 1] += smap->length; + return (1); + } + + physmap_idx += 2; + *physmap_idxp = physmap_idx; + if (physmap_idx == PHYSMAP_SIZE) { + printf( + "Too many segments in the physical address map, giving up\n"); + return (0); + } + + /* + * Move the last 'N' entries down to make room for the new + * entry if needed. + */ + for (i = physmap_idx; i > insert_idx; i -= 2) { + physmap[i] = physmap[i - 2]; + physmap[i + 1] = physmap[i - 1]; + } + + /* Insert the new entry. */ + physmap[insert_idx] = smap->base; + physmap[insert_idx + 1] = smap->base + smap->length; + return (1); +} + /* * Populate the (physmap) array with base/bound pairs describing the * available physical memory in the system, then test this memory and @@ -1235,40 +1306,9 @@ getmemsize(caddr_t kmdp, u_int64_t first smapsize = *((u_int32_t *)smapbase - 1); smapend = (struct bios_smap *)((uintptr_t)smapbase + smapsize); - for (smap = smapbase; smap < smapend; smap++) { - if (boothowto & RB_VERBOSE) - printf("SMAP type=%02x base=%016lx len=%016lx\n", - smap->type, smap->base, smap->length); - - if (smap->type != SMAP_TYPE_MEMORY) - continue; - - if (smap->length == 0) - continue; - - for (i = 0; i <= physmap_idx; i += 2) { - if (smap->base < physmap[i + 1]) { - if (boothowto & RB_VERBOSE) - printf( - "Overlapping or non-monotonic memory region, ignoring second region\n"); - continue; - } - } - - if (smap->base == physmap[physmap_idx + 1]) { - physmap[physmap_idx + 1] += smap->length; - continue; - } - - physmap_idx += 2; - if (physmap_idx == PHYSMAP_SIZE) { - printf( - "Too many segments in the physical address map, giving up\n"); + for (smap = smapbase; smap < smapend; smap++) + if (!add_smap_entry(smap, physmap, &physmap_idx)) break; - } - physmap[physmap_idx] = smap->base; - physmap[physmap_idx + 1] = smap->base + smap->length; - } /* * Find the 'base memory' segment for SMP Modified: stable/8/sys/i386/i386/machdep.c ============================================================================== --- stable/8/sys/i386/i386/machdep.c Fri Sep 25 14:58:30 2009 (r197483) +++ stable/8/sys/i386/i386/machdep.c Fri Sep 25 15:08:26 2009 (r197484) @@ -1946,7 +1946,7 @@ sdtossd(sd, ssd) static int add_smap_entry(struct bios_smap *smap, vm_paddr_t *physmap, int *physmap_idxp) { - int i, physmap_idx; + int i, insert_idx, physmap_idx; physmap_idx = *physmap_idxp; @@ -1968,17 +1968,34 @@ add_smap_entry(struct bios_smap *smap, v } #endif + /* + * Find insertion point while checking for overlap. Start off by + * assuming the new entry will be added to the end. + */ + insert_idx = physmap_idx + 2; for (i = 0; i <= physmap_idx; i += 2) { if (smap->base < physmap[i + 1]) { + if (smap->base + smap->length <= physmap[i]) { + insert_idx = i; + break; + } if (boothowto & RB_VERBOSE) printf( - "Overlapping or non-monotonic memory region, ignoring second region\n"); + "Overlapping memory regions, ignoring second region\n"); return (1); } } - if (smap->base == physmap[physmap_idx + 1]) { - physmap[physmap_idx + 1] += smap->length; + /* See if we can prepend to the next entry. */ + if (insert_idx <= physmap_idx && + smap->base + smap->length == physmap[insert_idx]) { + physmap[insert_idx] = smap->base; + return (1); + } + + /* See if we can append to the previous entry. */ + if (insert_idx > 0 && smap->base == physmap[insert_idx - 1]) { + physmap[insert_idx - 1] += smap->length; return (1); } @@ -1989,8 +2006,19 @@ add_smap_entry(struct bios_smap *smap, v "Too many segments in the physical address map, giving up\n"); return (0); } - physmap[physmap_idx] = smap->base; - physmap[physmap_idx + 1] = smap->base + smap->length; + + /* + * Move the last 'N' entries down to make room for the new + * entry if needed. + */ + for (i = physmap_idx; i > insert_idx; i -= 2) { + physmap[i] = physmap[i - 2]; + physmap[i + 1] = physmap[i - 1]; + } + + /* Insert the new entry. */ + physmap[insert_idx] = smap->base; + physmap[insert_idx + 1] = smap->base + smap->length; return (1); } From owner-svn-src-stable@FreeBSD.ORG Fri Sep 25 15:08:51 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E59D31065670; Fri, 25 Sep 2009 15:08:51 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D35148FC1A; Fri, 25 Sep 2009 15:08:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8PF8pIQ032027; Fri, 25 Sep 2009 15:08:51 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8PF8p0G032024; Fri, 25 Sep 2009 15:08:51 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200909251508.n8PF8p0G032024@svn.freebsd.org> From: John Baldwin Date: Fri, 25 Sep 2009 15:08:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197485 - in stable/7/sys: . amd64/amd64 contrib/pf i386/i386 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2009 15:08:52 -0000 Author: jhb Date: Fri Sep 25 15:08:51 2009 New Revision: 197485 URL: http://svn.freebsd.org/changeset/base/197485 Log: MFC 197410: - Split the logic to parse an SMAP entry out into a separate function on amd64 similar to i386. This fixes a bug on amd64 where overlapping entries would not cause the SMAP parsing to stop. - Change the SMAP parsing code to do a sorted insertion into physmap[] instead of an append to support systems with out-of-order SMAP entries. Modified: stable/7/sys/ (props changed) stable/7/sys/amd64/amd64/machdep.c stable/7/sys/contrib/pf/ (props changed) stable/7/sys/i386/i386/machdep.c Modified: stable/7/sys/amd64/amd64/machdep.c ============================================================================== --- stable/7/sys/amd64/amd64/machdep.c Fri Sep 25 15:08:26 2009 (r197484) +++ stable/7/sys/amd64/amd64/machdep.c Fri Sep 25 15:08:51 2009 (r197485) @@ -862,6 +862,77 @@ isa_irq_pending(void) u_int basemem; +static int +add_smap_entry(struct bios_smap *smap, vm_paddr_t *physmap, int *physmap_idxp) +{ + int i, insert_idx, physmap_idx; + + physmap_idx = *physmap_idxp; + + if (boothowto & RB_VERBOSE) + printf("SMAP type=%02x base=%016lx len=%016lx\n", + smap->type, smap->base, smap->length); + + if (smap->type != SMAP_TYPE_MEMORY) + return (1); + + if (smap->length == 0) + return (0); + + /* + * Find insertion point while checking for overlap. Start off by + * assuming the new entry will be added to the end. + */ + insert_idx = physmap_idx + 2; + for (i = 0; i <= physmap_idx; i += 2) { + if (smap->base < physmap[i + 1]) { + if (smap->base + smap->length <= physmap[i]) { + insert_idx = i; + break; + } + if (boothowto & RB_VERBOSE) + printf( + "Overlapping memory regions, ignoring second region\n"); + return (1); + } + } + + /* See if we can prepend to the next entry. */ + if (insert_idx <= physmap_idx && + smap->base + smap->length == physmap[insert_idx]) { + physmap[insert_idx] = smap->base; + return (1); + } + + /* See if we can append to the previous entry. */ + if (insert_idx > 0 && smap->base == physmap[insert_idx - 1]) { + physmap[insert_idx - 1] += smap->length; + return (1); + } + + physmap_idx += 2; + *physmap_idxp = physmap_idx; + if (physmap_idx == PHYSMAP_SIZE) { + printf( + "Too many segments in the physical address map, giving up\n"); + return (0); + } + + /* + * Move the last 'N' entries down to make room for the new + * entry if needed. + */ + for (i = physmap_idx; i > insert_idx; i -= 2) { + physmap[i] = physmap[i - 2]; + physmap[i + 1] = physmap[i - 1]; + } + + /* Insert the new entry. */ + physmap[insert_idx] = smap->base; + physmap[insert_idx + 1] = smap->base + smap->length; + return (1); +} + /* * Populate the (physmap) array with base/bound pairs describing the * available physical memory in the system, then test this memory and @@ -905,40 +976,9 @@ getmemsize(caddr_t kmdp, u_int64_t first smapsize = *((u_int32_t *)smapbase - 1); smapend = (struct bios_smap *)((uintptr_t)smapbase + smapsize); - for (smap = smapbase; smap < smapend; smap++) { - if (boothowto & RB_VERBOSE) - printf("SMAP type=%02x base=%016lx len=%016lx\n", - smap->type, smap->base, smap->length); - - if (smap->type != SMAP_TYPE_MEMORY) - continue; - - if (smap->length == 0) - continue; - - for (i = 0; i <= physmap_idx; i += 2) { - if (smap->base < physmap[i + 1]) { - if (boothowto & RB_VERBOSE) - printf( - "Overlapping or non-monotonic memory region, ignoring second region\n"); - continue; - } - } - - if (smap->base == physmap[physmap_idx + 1]) { - physmap[physmap_idx + 1] += smap->length; - continue; - } - - physmap_idx += 2; - if (physmap_idx == PHYSMAP_SIZE) { - printf( - "Too many segments in the physical address map, giving up\n"); + for (smap = smapbase; smap < smapend; smap++) + if (!add_smap_entry(smap, physmap, &physmap_idx)) break; - } - physmap[physmap_idx] = smap->base; - physmap[physmap_idx + 1] = smap->base + smap->length; - } /* * Find the 'base memory' segment for SMP Modified: stable/7/sys/i386/i386/machdep.c ============================================================================== --- stable/7/sys/i386/i386/machdep.c Fri Sep 25 15:08:26 2009 (r197484) +++ stable/7/sys/i386/i386/machdep.c Fri Sep 25 15:08:51 2009 (r197485) @@ -1653,7 +1653,7 @@ sdtossd(sd, ssd) static int add_smap_entry(struct bios_smap *smap, vm_paddr_t *physmap, int *physmap_idxp) { - int i, physmap_idx; + int i, insert_idx, physmap_idx; physmap_idx = *physmap_idxp; @@ -1675,17 +1675,34 @@ add_smap_entry(struct bios_smap *smap, v } #endif + /* + * Find insertion point while checking for overlap. Start off by + * assuming the new entry will be added to the end. + */ + insert_idx = physmap_idx + 2; for (i = 0; i <= physmap_idx; i += 2) { if (smap->base < physmap[i + 1]) { + if (smap->base + smap->length <= physmap[i]) { + insert_idx = i; + break; + } if (boothowto & RB_VERBOSE) printf( - "Overlapping or non-monotonic memory region, ignoring second region\n"); + "Overlapping memory regions, ignoring second region\n"); return (1); } } - if (smap->base == physmap[physmap_idx + 1]) { - physmap[physmap_idx + 1] += smap->length; + /* See if we can prepend to the next entry. */ + if (insert_idx <= physmap_idx && + smap->base + smap->length == physmap[insert_idx]) { + physmap[insert_idx] = smap->base; + return (1); + } + + /* See if we can append to the previous entry. */ + if (insert_idx > 0 && smap->base == physmap[insert_idx - 1]) { + physmap[insert_idx - 1] += smap->length; return (1); } @@ -1696,8 +1713,19 @@ add_smap_entry(struct bios_smap *smap, v "Too many segments in the physical address map, giving up\n"); return (0); } - physmap[physmap_idx] = smap->base; - physmap[physmap_idx + 1] = smap->base + smap->length; + + /* + * Move the last 'N' entries down to make room for the new + * entry if needed. + */ + for (i = physmap_idx; i > insert_idx; i -= 2) { + physmap[i] = physmap[i - 2]; + physmap[i + 1] = physmap[i - 1]; + } + + /* Insert the new entry. */ + physmap[insert_idx] = smap->base; + physmap[insert_idx + 1] = smap->base + smap->length; return (1); } From owner-svn-src-stable@FreeBSD.ORG Fri Sep 25 15:14:12 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1DBF810656B1; Fri, 25 Sep 2009 15:14:12 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E50758FC16; Fri, 25 Sep 2009 15:14:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8PFEB4H032186; Fri, 25 Sep 2009 15:14:11 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8PFEBOv032184; Fri, 25 Sep 2009 15:14:11 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200909251514.n8PFEBOv032184@svn.freebsd.org> From: John Baldwin Date: Fri, 25 Sep 2009 15:14:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197486 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/acpi_support dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2009 15:14:12 -0000 Author: jhb Date: Fri Sep 25 15:14:11 2009 New Revision: 197486 URL: http://svn.freebsd.org/changeset/base/197486 Log: MFC 197415: The elements in the component arrays may be direct Package objects rather than references to objects. In that case, simply use the Package directly. Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/acpi_support/acpi_aiboost.c stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/acpi_support/acpi_aiboost.c ============================================================================== --- stable/8/sys/dev/acpi_support/acpi_aiboost.c Fri Sep 25 15:08:51 2009 (r197485) +++ stable/8/sys/dev/acpi_support/acpi_aiboost.c Fri Sep 25 15:14:11 2009 (r197486) @@ -46,7 +46,6 @@ ACPI_MODULE_NAME("AIBOOST") #define DESCSTRLEN 32 struct acpi_aiboost_element{ - ACPI_HANDLE h; uint32_t id; char desc[DESCSTRLEN]; }; @@ -127,22 +126,23 @@ static ACPI_STATUS acpi_aiboost_getcompo for(i = 1 ; i < o->Package.Count; i++){ elem = &o->Package.Elements[i]; - if(elem->Type != ACPI_TYPE_ANY){ - printf("NOREF\n"); - goto error; - } - c->elem[ i - 1].h = elem->Reference.Handle; - - buf2.Pointer = NULL; - buf2.Length = ACPI_ALLOCATE_BUFFER; - - status = AcpiEvaluateObject(c->elem[i - 1].h, NULL, NULL, - &buf2); - if(ACPI_FAILURE(status)){ - printf("FETCH OBJECT\n"); + if (elem->Type == ACPI_TYPE_ANY) { + buf2.Pointer = NULL; + buf2.Length = ACPI_ALLOCATE_BUFFER; + + status = AcpiEvaluateObject(elem->Reference.Handle, + NULL, NULL, &buf2); + if (ACPI_FAILURE(status)){ + printf("FETCH OBJECT\n"); + goto error; + } + subobj = buf2.Pointer; + } else if (elem->Type == ACPI_TYPE_PACKAGE) + subobj = elem; + else { + printf("NO PACKAGE\n"); goto error; } - subobj = buf2.Pointer; if(ACPI_FAILURE(acpi_PkgInt32(subobj,0, &c->elem[i -1].id))){ printf("ID FAILED\n"); goto error; @@ -151,15 +151,17 @@ static ACPI_STATUS acpi_aiboost_getcompo sizeof(c->elem[i - 1].desc)); if(ACPI_FAILURE(status)){ if(status == E2BIG){ - c->elem[i-1].desc[DESCSTRLEN-1] = 0; + c->elem[i - 1].desc[DESCSTRLEN-1] = 0; }else{ printf("DESC FAILED %d\n", i-1); goto error; } } - if(buf2.Pointer) - AcpiOsFree(buf2.Pointer); + if (buf2.Pointer) { + AcpiOsFree(buf2.Pointer); + buf2.Pointer = NULL; + } } if(buf.Pointer) From owner-svn-src-stable@FreeBSD.ORG Fri Sep 25 15:14:33 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CBE04106568D; Fri, 25 Sep 2009 15:14:33 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A12D98FC18; Fri, 25 Sep 2009 15:14:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8PFEXcK032227; Fri, 25 Sep 2009 15:14:33 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8PFEXRK032225; Fri, 25 Sep 2009 15:14:33 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200909251514.n8PFEXRK032225@svn.freebsd.org> From: John Baldwin Date: Fri, 25 Sep 2009 15:14:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197487 - in stable/7/sys: . contrib/pf dev/acpi_support X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2009 15:14:33 -0000 Author: jhb Date: Fri Sep 25 15:14:33 2009 New Revision: 197487 URL: http://svn.freebsd.org/changeset/base/197487 Log: MFC 197415: The elements in the component arrays may be direct Package objects rather than references to objects. In that case, simply use the Package directly. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/acpi_support/acpi_aiboost.c Modified: stable/7/sys/dev/acpi_support/acpi_aiboost.c ============================================================================== --- stable/7/sys/dev/acpi_support/acpi_aiboost.c Fri Sep 25 15:14:11 2009 (r197486) +++ stable/7/sys/dev/acpi_support/acpi_aiboost.c Fri Sep 25 15:14:33 2009 (r197487) @@ -44,7 +44,6 @@ ACPI_MODULE_NAME("AIBOOST") #define DESCSTRLEN 32 struct acpi_aiboost_element{ - ACPI_HANDLE h; uint32_t id; char desc[DESCSTRLEN]; }; @@ -125,22 +124,23 @@ static ACPI_STATUS acpi_aiboost_getcompo for(i = 1 ; i < o->Package.Count; i++){ elem = &o->Package.Elements[i]; - if(elem->Type != ACPI_TYPE_ANY){ - printf("NOREF\n"); - goto error; - } - c->elem[ i - 1].h = elem->Reference.Handle; - - buf2.Pointer = NULL; - buf2.Length = ACPI_ALLOCATE_BUFFER; - - status = AcpiEvaluateObject(c->elem[i - 1].h, NULL, NULL, - &buf2); - if(ACPI_FAILURE(status)){ - printf("FETCH OBJECT\n"); + if (elem->Type == ACPI_TYPE_ANY) { + buf2.Pointer = NULL; + buf2.Length = ACPI_ALLOCATE_BUFFER; + + status = AcpiEvaluateObject(elem->Reference.Handle, + NULL, NULL, &buf2); + if (ACPI_FAILURE(status)){ + printf("FETCH OBJECT\n"); + goto error; + } + subobj = buf2.Pointer; + } else if (elem->Type == ACPI_TYPE_PACKAGE) + subobj = elem; + else { + printf("NO PACKAGE\n"); goto error; } - subobj = buf2.Pointer; if(ACPI_FAILURE(acpi_PkgInt32(subobj,0, &c->elem[i -1].id))){ printf("ID FAILED\n"); goto error; @@ -149,15 +149,17 @@ static ACPI_STATUS acpi_aiboost_getcompo sizeof(c->elem[i - 1].desc)); if(ACPI_FAILURE(status)){ if(status == E2BIG){ - c->elem[i-1].desc[DESCSTRLEN-1] = 0; + c->elem[i - 1].desc[DESCSTRLEN-1] = 0; }else{ printf("DESC FAILED %d\n", i-1); goto error; } } - if(buf2.Pointer) - AcpiOsFree(buf2.Pointer); + if (buf2.Pointer) { + AcpiOsFree(buf2.Pointer); + buf2.Pointer = NULL; + } } if(buf.Pointer) From owner-svn-src-stable@FreeBSD.ORG Fri Sep 25 16:45:27 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9DAF2106566B; Fri, 25 Sep 2009 16:45:27 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8A3F48FC1E; Fri, 25 Sep 2009 16:45:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8PGjR8E034002; Fri, 25 Sep 2009 16:45:27 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8PGjR5u034000; Fri, 25 Sep 2009 16:45:27 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909251645.n8PGjR5u034000@svn.freebsd.org> From: Marius Strobl Date: Fri, 25 Sep 2009 16:45:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197488 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/ata/chipsets dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2009 16:45:27 -0000 Author: marius Date: Fri Sep 25 16:45:27 2009 New Revision: 197488 URL: http://svn.freebsd.org/changeset/base/197488 Log: - Add missing bus_dmamap_sync(9) calls for the work DMA map. Previously the work area was totally unsynchronized which means this driver only had a chance of working on x86 when no bounce buffers were involved, which isn't that likely given that support for 64-bit DMA is currently broken throughout ata(4). - Add necessary little-endian conversion of accesses to the work area, making this driver work on big-endian hosts. While at it, use the alignment-agnostic byte order encoders in order to be on the safe side. - Clear the reserved member of the SG list entries in order to be on the safe side. [1] Submitted by: yongari [1] Reviewed by: yongari Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/ata/chipsets/ata-marvell.c stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/ata/chipsets/ata-marvell.c ============================================================================== --- stable/8/sys/dev/ata/chipsets/ata-marvell.c Fri Sep 25 15:14:33 2009 (r197487) +++ stable/8/sys/dev/ata/chipsets/ata-marvell.c Fri Sep 25 16:45:27 2009 (r197488) @@ -227,6 +227,8 @@ ata_marvell_edma_ch_attach(device_t dev) work = ch->dma.work_bus; /* clear work area */ bzero(ch->dma.work, 1024+256); + bus_dmamap_sync(ch->dma.work_tag, ch->dma.work_map, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); /* set legacy ATA resources */ for (i = ATA_DATA; i <= ATA_COMMAND; i++) { @@ -310,7 +312,11 @@ ata_marvell_edma_ch_attach(device_t dev) static int ata_marvell_edma_ch_detach(device_t dev) { + struct ata_channel *ch = device_get_softc(dev); + if (ch->dma.work_tag && ch->dma.work_map) + bus_dmamap_sync(ch->dma.work_tag, ch->dma.work_map, + BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); ata_dmafini(dev); return (0); } @@ -344,8 +350,6 @@ ata_marvell_edma_begin_transaction(struc struct ata_channel *ch = device_get_softc(request->parent); u_int32_t req_in; u_int8_t *bytep; - u_int16_t *wordp; - u_int32_t *quadp; int i; int error, slot; @@ -374,13 +378,14 @@ ata_marvell_edma_begin_transaction(struc slot = (((req_in & ~0xfffffc00) >> 5) + 0) & 0x1f; bytep = (u_int8_t *)(ch->dma.work); bytep += (slot << 5); - wordp = (u_int16_t *)bytep; - quadp = (u_int32_t *)bytep; /* fill in this request */ - quadp[0] = (long)request->dma->sg_bus & 0xffffffff; - quadp[1] = (u_int64_t)request->dma->sg_bus >> 32; - wordp[4] = (request->flags & ATA_R_READ ? 0x01 : 0x00) | (request->tag<<1); + le32enc(bytep + 0 * sizeof(u_int32_t), + request->dma->sg_bus & 0xffffffff); + le32enc(bytep + 1 * sizeof(u_int32_t), + (u_int64_t)request->dma->sg_bus >> 32); + le16enc(bytep + 4 * sizeof(u_int16_t), + (request->flags & ATA_R_READ ? 0x01 : 0x00) | (request->tag << 1)); i = 10; bytep[i++] = (request->u.ata.count >> 8) & 0xff; @@ -409,6 +414,9 @@ ata_marvell_edma_begin_transaction(struc bytep[i++] = request->u.ata.command; bytep[i++] = 0x90 | ATA_COMMAND; + bus_dmamap_sync(ch->dma.work_tag, ch->dma.work_map, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + /* enable EDMA machinery if needed */ if (!(ATA_INL(ctlr->r_res1, 0x02028 + ATA_MV_EDMA_BASE(ch)) & 0x00000001)) { ATA_OUTL(ctlr->r_res1, 0x02028 + ATA_MV_EDMA_BASE(ch), 0x00000001); @@ -451,6 +459,8 @@ ata_marvell_edma_end_transaction(struct slot = (((rsp_in & ~0xffffff00) >> 3)) & 0x1f; rsp_out &= 0xffffff00; rsp_out += (slot << 3); + bus_dmamap_sync(ch->dma.work_tag, ch->dma.work_map, + BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); response = (struct ata_marvell_response *) (ch->dma.work + 1024 + (slot << 3)); @@ -525,6 +535,7 @@ ata_marvell_edma_dmasetprd(void *xsc, bu prd[i].addrlo = htole32(segs[i].ds_addr); prd[i].count = htole32(segs[i].ds_len); prd[i].addrhi = htole32((u_int64_t)segs[i].ds_addr >> 32); + prd[i].reserved = 0; } prd[i - 1].count |= htole32(ATA_DMA_EOT); KASSERT(nsegs <= ATA_DMA_ENTRIES, ("too many DMA segment entries\n")); From owner-svn-src-stable@FreeBSD.ORG Fri Sep 25 17:07:44 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 411D31065676; Fri, 25 Sep 2009 17:07:44 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2F6AA8FC12; Fri, 25 Sep 2009 17:07:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8PH7iXi034477; Fri, 25 Sep 2009 17:07:44 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8PH7iJu034475; Fri, 25 Sep 2009 17:07:44 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909251707.n8PH7iJu034475@svn.freebsd.org> From: Marius Strobl Date: Fri, 25 Sep 2009 17:07:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197489 - in stable/7/sys: . contrib/pf dev/ata X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2009 17:07:44 -0000 Author: marius Date: Fri Sep 25 17:07:43 2009 New Revision: 197489 URL: http://svn.freebsd.org/changeset/base/197489 Log: MFC: 197402 - Add missing bus_dmamap_sync(9) calls for the work DMA map. Previously the work area was totally unsynchronized which means this driver only had a chance of working on x86 when no bounce buffers were involved, which isn't that likely given that support for 64-bit DMA is currently broken throughout ata(4). - Add necessary little-endian conversion of accesses to the work area, making this driver work on big-endian hosts. While at it, use the alignment-agnostic byte order encoders in order to be on the safe side. - Clear the reserved member of the SG list entries in order to be on the safe side. [1] Submitted by: yongari [1] Reviewed by: yongari Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ata/ata-chipset.c Modified: stable/7/sys/dev/ata/ata-chipset.c ============================================================================== --- stable/7/sys/dev/ata/ata-chipset.c Fri Sep 25 16:45:27 2009 (r197488) +++ stable/7/sys/dev/ata/ata-chipset.c Fri Sep 25 17:07:43 2009 (r197489) @@ -2690,6 +2690,8 @@ ata_marvell_edma_allocate(device_t dev) /* clear work area */ bzero(ch->dma->work, 1024+256); + bus_dmamap_sync(ch->dma->work_tag, ch->dma->work_map, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); /* set legacy ATA resources */ for (i = ATA_DATA; i <= ATA_COMMAND; i++) { @@ -2799,8 +2801,6 @@ ata_marvell_edma_begin_transaction(struc struct ata_channel *ch = device_get_softc(device_get_parent(request->dev)); u_int32_t req_in; u_int8_t *bytep; - u_int16_t *wordp; - u_int32_t *quadp; int i, tag = 0x07; int dummy, error, slot; @@ -2831,13 +2831,14 @@ ata_marvell_edma_begin_transaction(struc slot = (((req_in & ~0xfffffc00) >> 5) + 0) & 0x1f; bytep = (u_int8_t *)(ch->dma->work); bytep += (slot << 5); - wordp = (u_int16_t *)bytep; - quadp = (u_int32_t *)bytep; /* fill in this request */ - quadp[0] = (long)ch->dma->sg_bus & 0xffffffff; - quadp[1] = (u_int64_t)ch->dma->sg_bus >> 32; - wordp[4] = (request->flags & ATA_R_READ ? 0x01 : 0x00) | (tag<<1); + le32enc(bytep + 0 * sizeof(u_int32_t), + ch->dma->sg_bus & 0xffffffff); + le32enc(bytep + 1 * sizeof(u_int32_t), + (u_int64_t)ch->dma->sg_bus >> 32); + le16enc(bytep + 4 * sizeof(u_int16_t), + (request->flags & ATA_R_READ ? 0x01 : 0x00) | (tag << 1)); i = 10; bytep[i++] = (request->u.ata.count >> 8) & 0xff; @@ -2866,6 +2867,9 @@ ata_marvell_edma_begin_transaction(struc bytep[i++] = request->u.ata.command; bytep[i++] = 0x90 | ATA_COMMAND; + bus_dmamap_sync(ch->dma->work_tag, ch->dma->work_map, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + /* enable EDMA machinery if needed */ if (!(ATA_INL(ctlr->r_res1, 0x02028 + ATA_MV_EDMA_BASE(ch)) & 0x00000001)) { ATA_OUTL(ctlr->r_res1, 0x02028 + ATA_MV_EDMA_BASE(ch), 0x00000001); @@ -2908,6 +2912,8 @@ ata_marvell_edma_end_transaction(struct slot = (((rsp_in & ~0xffffff00) >> 3)) & 0x1f; rsp_out &= 0xffffff00; rsp_out += (slot << 3); + bus_dmamap_sync(ch->dma->work_tag, ch->dma->work_map, + BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); response = (struct ata_marvell_response *) (ch->dma->work + 1024 + (slot << 3)); @@ -2982,6 +2988,7 @@ ata_marvell_edma_dmasetprd(void *xsc, bu prd[i].addrlo = htole32(segs[i].ds_addr); prd[i].count = htole32(segs[i].ds_len); prd[i].addrhi = htole32((u_int64_t)segs[i].ds_addr >> 32); + prd[i].reserved = 0; } prd[i - 1].count |= htole32(ATA_DMA_EOT); KASSERT(nsegs <= ATA_DMA_ENTRIES, ("too many DMA segment entries\n")); From owner-svn-src-stable@FreeBSD.ORG Fri Sep 25 17:48:30 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B06531065672; Fri, 25 Sep 2009 17:48:30 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9DA488FC0A; Fri, 25 Sep 2009 17:48:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8PHmUxi035404; Fri, 25 Sep 2009 17:48:30 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8PHmUfs035402; Fri, 25 Sep 2009 17:48:30 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <200909251748.n8PHmUfs035402@svn.freebsd.org> From: Marcel Moolenaar Date: Fri, 25 Sep 2009 17:48:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197491 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci geom/part X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2009 17:48:30 -0000 Author: marcel Date: Fri Sep 25 17:48:30 2009 New Revision: 197491 URL: http://svn.freebsd.org/changeset/base/197491 Log: MFC rev 197449: Don't create more partitions than can fit in the table by checking that the index is within bounds. Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/geom/part/g_part.c Modified: stable/8/sys/geom/part/g_part.c ============================================================================== --- stable/8/sys/geom/part/g_part.c Fri Sep 25 17:08:51 2009 (r197490) +++ stable/8/sys/geom/part/g_part.c Fri Sep 25 17:48:30 2009 (r197491) @@ -480,6 +480,10 @@ g_part_ctl_add(struct gctl_req *req, str gctl_error(req, "%d index '%d'", EEXIST, gpp->gpp_index); return (EEXIST); } + if (index > table->gpt_entries) { + gctl_error(req, "%d index '%d'", ENOSPC, index); + return (ENOSPC); + } entry = (delent == NULL) ? g_malloc(table->gpt_scheme->gps_entrysz, M_WAITOK | M_ZERO) : delent; From owner-svn-src-stable@FreeBSD.ORG Fri Sep 25 17:56:14 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3CC2C1065672; Fri, 25 Sep 2009 17:56:14 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 20FF98FC12; Fri, 25 Sep 2009 17:56:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8PHuEWx035619; Fri, 25 Sep 2009 17:56:14 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8PHuDDl035617; Fri, 25 Sep 2009 17:56:13 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909251756.n8PHuDDl035617@svn.freebsd.org> From: Marius Strobl Date: Fri, 25 Sep 2009 17:56:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197492 - in stable/6/sys: . conf contrib/pf dev/ata dev/cxgb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2009 17:56:14 -0000 Author: marius Date: Fri Sep 25 17:56:13 2009 New Revision: 197492 URL: http://svn.freebsd.org/changeset/base/197492 Log: MFC: r197402 - Add missing bus_dmamap_sync(9) calls for the work DMA map. Previously the work area was totally unsynchronized which means this driver only had a chance of working on x86 when no bounce buffers were involved, which isn't that likely given that support for 64-bit DMA is currently broken throughout ata(4). - Add necessary little-endian conversion of accesses to the work area, making this driver work on big-endian hosts. While at it, use the alignment-agnostic byte order encoders in order to be on the safe side. - Clear the reserved member of the SG list entries in order to be on the safe side. [1] Submitted by: yongari [1] Reviewed by: yongari Modified: stable/6/sys/ (props changed) stable/6/sys/conf/ (props changed) stable/6/sys/contrib/pf/ (props changed) stable/6/sys/dev/ata/ata-chipset.c stable/6/sys/dev/cxgb/ (props changed) Modified: stable/6/sys/dev/ata/ata-chipset.c ============================================================================== --- stable/6/sys/dev/ata/ata-chipset.c Fri Sep 25 17:48:30 2009 (r197491) +++ stable/6/sys/dev/ata/ata-chipset.c Fri Sep 25 17:56:13 2009 (r197492) @@ -2578,6 +2578,8 @@ ata_marvell_edma_allocate(device_t dev) /* clear work area */ bzero(ch->dma->work, 1024+256); + bus_dmamap_sync(ch->dma->work_tag, ch->dma->work_map, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); /* set legacy ATA resources */ for (i = ATA_DATA; i <= ATA_COMMAND; i++) { @@ -2687,8 +2689,6 @@ ata_marvell_edma_begin_transaction(struc struct ata_channel *ch = device_get_softc(device_get_parent(request->dev)); u_int32_t req_in; u_int8_t *bytep; - u_int16_t *wordp; - u_int32_t *quadp; int i, tag = 0x07; int dummy, error, slot; @@ -2719,13 +2719,14 @@ ata_marvell_edma_begin_transaction(struc slot = (((req_in & ~0xfffffc00) >> 5) + 0) & 0x1f; bytep = (u_int8_t *)(ch->dma->work); bytep += (slot << 5); - wordp = (u_int16_t *)bytep; - quadp = (u_int32_t *)bytep; /* fill in this request */ - quadp[0] = (long)ch->dma->sg_bus & 0xffffffff; - quadp[1] = (u_int64_t)ch->dma->sg_bus >> 32; - wordp[4] = (request->flags & ATA_R_READ ? 0x01 : 0x00) | (tag<<1); + le32enc(bytep + 0 * sizeof(u_int32_t), + ch->dma->sg_bus & 0xffffffff); + le32enc(bytep + 1 * sizeof(u_int32_t), + (u_int64_t)ch->dma->sg_bus >> 32); + le16enc(bytep + 4 * sizeof(u_int16_t), + (request->flags & ATA_R_READ ? 0x01 : 0x00) | (tag << 1)); i = 10; bytep[i++] = (request->u.ata.count >> 8) & 0xff; @@ -2754,6 +2755,9 @@ ata_marvell_edma_begin_transaction(struc bytep[i++] = request->u.ata.command; bytep[i++] = 0x90 | ATA_COMMAND; + bus_dmamap_sync(ch->dma->work_tag, ch->dma->work_map, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + /* enable EDMA machinery if needed */ if (!(ATA_INL(ctlr->r_res1, 0x02028 + ATA_MV_EDMA_BASE(ch)) & 0x00000001)) { ATA_OUTL(ctlr->r_res1, 0x02028 + ATA_MV_EDMA_BASE(ch), 0x00000001); @@ -2796,6 +2800,8 @@ ata_marvell_edma_end_transaction(struct slot = (((rsp_in & ~0xffffff00) >> 3)) & 0x1f; rsp_out &= 0xffffff00; rsp_out += (slot << 3); + bus_dmamap_sync(ch->dma->work_tag, ch->dma->work_map, + BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); response = (struct ata_marvell_response *) (ch->dma->work + 1024 + (slot << 3)); @@ -2870,6 +2876,7 @@ ata_marvell_edma_dmasetprd(void *xsc, bu prd[i].addrlo = htole32(segs[i].ds_addr); prd[i].count = htole32(segs[i].ds_len); prd[i].addrhi = htole32((u_int64_t)segs[i].ds_addr >> 32); + prd[i].reserved = 0; } prd[i - 1].count |= htole32(ATA_DMA_EOT); KASSERT(nsegs <= ATA_DMA_ENTRIES, ("too many DMA segment entries\n")); From owner-svn-src-stable@FreeBSD.ORG Fri Sep 25 18:04:56 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 413BA106566C; Fri, 25 Sep 2009 18:04:56 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2EB7B8FC21; Fri, 25 Sep 2009 18:04:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8PI4uB8035939; Fri, 25 Sep 2009 18:04:56 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8PI4unk035937; Fri, 25 Sep 2009 18:04:56 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <200909251804.n8PI4unk035937@svn.freebsd.org> From: Alexander Motin Date: Fri, 25 Sep 2009 18:04:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197494 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2009 18:04:56 -0000 Author: mav Date: Fri Sep 25 18:04:55 2009 New Revision: 197494 URL: http://svn.freebsd.org/changeset/base/197494 Log: MFC rev. 197462: Do not call BUS_DRIVER_ADDED() for detached buses (attach failed) on driver load. This fixes crash on atapicam module load on systems, where some ata channels (usually ata1) was probed, but failed to attach. Reviewed by: jhb, imp Tested by: many Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/kern/subr_bus.c Modified: stable/8/sys/kern/subr_bus.c ============================================================================== --- stable/8/sys/kern/subr_bus.c Fri Sep 25 17:56:32 2009 (r197493) +++ stable/8/sys/kern/subr_bus.c Fri Sep 25 18:04:55 2009 (r197494) @@ -1017,7 +1017,7 @@ devclass_driver_added(devclass_t dc, dri * Call BUS_DRIVER_ADDED for any existing busses in this class. */ for (i = 0; i < dc->maxunit; i++) - if (dc->devices[i]) + if (dc->devices[i] && device_is_attached(dc->devices[i])) BUS_DRIVER_ADDED(dc->devices[i], driver); /* From owner-svn-src-stable@FreeBSD.ORG Fri Sep 25 18:07:24 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6DADA106566C; Fri, 25 Sep 2009 18:07:24 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5B0868FC31; Fri, 25 Sep 2009 18:07:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8PI7O7h036059; Fri, 25 Sep 2009 18:07:24 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8PI7OTL036057; Fri, 25 Sep 2009 18:07:24 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <200909251807.n8PI7OTL036057@svn.freebsd.org> From: Alexander Motin Date: Fri, 25 Sep 2009 18:07:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197495 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/ata dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2009 18:07:24 -0000 Author: mav Date: Fri Sep 25 18:07:23 2009 New Revision: 197495 URL: http://svn.freebsd.org/changeset/base/197495 Log: Remove constraint, requiring request data to fulfill controller's alignment requirements. It is busdma task, to manage proper alignment by loading data to bounce buffers. PR: kern/127316 Reviewed by: current@ Tested by: Ryan Rogers Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/ata/ata-dma.c stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/ata/ata-dma.c ============================================================================== --- stable/8/sys/dev/ata/ata-dma.c Fri Sep 25 18:04:55 2009 (r197494) +++ stable/8/sys/dev/ata/ata-dma.c Fri Sep 25 18:07:23 2009 (r197495) @@ -272,10 +272,10 @@ ata_dmaload(struct ata_request *request, "FAILURE - zero length DMA transfer attempted\n"); return EIO; } - if (((uintptr_t)(request->data) & (ch->dma.alignment - 1)) || - (request->bytecount & (ch->dma.alignment - 1))) { + if (request->bytecount & (ch->dma.alignment - 1)) { device_printf(request->dev, - "FAILURE - non aligned DMA transfer attempted\n"); + "FAILURE - odd-sized DMA transfer attempt %d %% %d\n", + request->bytecount, ch->dma.alignment); return EIO; } if (request->bytecount > ch->dma.max_iosize) { From owner-svn-src-stable@FreeBSD.ORG Fri Sep 25 19:59:19 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E1444106566B; Fri, 25 Sep 2009 19:59:18 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CDE0B8FC1A; Fri, 25 Sep 2009 19:59:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8PJxInx038405; Fri, 25 Sep 2009 19:59:18 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8PJxInd038403; Fri, 25 Sep 2009 19:59:18 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909251959.n8PJxInd038403@svn.freebsd.org> From: Marius Strobl Date: Fri, 25 Sep 2009 19:59:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197502 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/sound/pci dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2009 19:59:19 -0000 Author: marius Date: Fri Sep 25 19:59:18 2009 New Revision: 197502 URL: http://svn.freebsd.org/changeset/base/197502 Log: MFC: r197401 - According to Linux, the ALi M5451 can do 31-bit DMA instead of just 30-bit like the reset of the controllers supported by this driver. Actually ALi M5451 can be setup up to generate 32-bit addresses by setting the 31st bit via the accompanying ISA bridge, which allows it to work in sparc64 machines whose IOMMU require at least 32-bit DMA. Even though other architectures would also benefit from 32-bit DMA, enabling this bit is limited to sparc64 as bus_dma(9) doesn't generally guarantee that a low address of BUS_SPACE_MAXADDR_32BIT results in a buffer in the 32-bit range. - According to Tatsuo YOKOGAWA's ali(4), the the DMA transfer size of ALi M5451 is fixed to 64k and in fact using the default size of 4k causes the chip to overrun the mapping, triggering uncorrectable DMA errors on sparc64. - The 4DWAVE DX and NX require the recording buffer to be 8-byte aligned so adjust the bus_dma_tag_create(9) accordingly. - Unlike the rest of the controllers supported by this driver, the ALi M5451 only has 32 hardware channels instead of 64 so limit the loop in tr_intr() accordingly. [1] Submitted by: yongari [1] Reviewed by: yongari (superset of what is committed) Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/sound/pci/t4dwave.c stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/sound/pci/t4dwave.c ============================================================================== --- stable/8/sys/dev/sound/pci/t4dwave.c Fri Sep 25 19:49:07 2009 (r197501) +++ stable/8/sys/dev/sound/pci/t4dwave.c Fri Sep 25 19:59:18 2009 (r197502) @@ -45,18 +45,22 @@ SND_DECLARE_FILE("$FreeBSD$"); #define SPA_PCI_ID 0x70181039 #define TR_DEFAULT_BUFSZ 0x1000 +/* For ALi M5451 the DMA transfer size appears to be fixed to 64k. */ +#define ALI_BUFSZ 0x10000 +#define TR_BUFALGN 0x8 #define TR_TIMEOUT_CDC 0xffff +#define TR_MAXHWCH 64 +#define ALI_MAXHWCH 32 #define TR_MAXPLAYCH 4 +#define ALI_MAXPLAYCH 1 /* - * Though, it's not clearly documented in trident datasheet, trident - * audio cards can't handle DMA addresses located above 1GB. The LBA - * (loop begin address) register which holds DMA base address is 32bits - * register. - * But the MSB 2bits are used for other purposes(I guess it is really - * bad idea). This effectivly limits the DMA address space up to 1GB. + * Though, it's not clearly documented in the 4DWAVE datasheet, the + * DX and NX chips can't handle DMA addresses located above 1GB as the + * LBA (loop begin address) register which holds the DMA base address + * is 32-bit, but the two MSBs are used for other purposes. */ -#define TR_MAXADDR ((1 << 30) - 1) - +#define TR_MAXADDR ((1U << 30) - 1) +#define ALI_MAXADDR ((1U << 31) - 1) struct tr_info; @@ -97,6 +101,7 @@ struct tr_info { struct mtx *lock; + u_int32_t hwchns; u_int32_t playchns; unsigned int bufsz; @@ -398,7 +403,10 @@ tr_wrch(struct tr_chinfo *ch) ch->ec &= 0x00000fff; ch->alpha &= 0x00000fff; ch->delta &= 0x0000ffff; - ch->lba &= 0x3fffffff; + if (tr->type == ALI_PCI_ID) + ch->lba &= ALI_MAXADDR; + else + ch->lba &= TR_MAXADDR; cr[1]=ch->lba; cr[3]=(ch->fmc<<14) | (ch->rvol<<7) | (ch->cvol); @@ -441,7 +449,10 @@ tr_rdch(struct tr_chinfo *ch) snd_mtxunlock(tr->lock); - ch->lba= (cr[1] & 0x3fffffff); + if (tr->type == ALI_PCI_ID) + ch->lba=(cr[1] & ALI_MAXADDR); + else + ch->lba=(cr[1] & TR_MAXADDR); ch->fmc= (cr[3] & 0x0000c000) >> 14; ch->rvol= (cr[3] & 0x00003f80) >> 7; ch->cvol= (cr[3] & 0x0000007f); @@ -628,7 +639,6 @@ trrchan_setformat(kobj_t obj, void *data tr_wr(tr, TR_REG_SBCTRL, i, 1); return 0; - } static u_int32_t @@ -729,7 +739,7 @@ tr_intr(void *p) intsrc = tr_rd(tr, TR_REG_MISCINT, 4); if (intsrc & TR_INT_ADDR) { chnum = 0; - while (chnum < 64) { + while (chnum < tr->hwchns) { mask = 0x00000001; active = tr_rd(tr, (chnum < 32)? TR_REG_ADDRINTA : TR_REG_ADDRINTB, 4); bufhalf = tr_rd(tr, (chnum < 32)? TR_REG_CSPF_A : TR_REG_CSPF_B, 4); @@ -815,8 +825,13 @@ tr_pci_attach(device_t dev) u_int32_t data; struct tr_info *tr; struct ac97_info *codec = 0; + bus_addr_t lowaddr; int i, dacn; char status[SND_STATUSLEN]; +#ifdef __sparc64__ + device_t *children; + int nchildren; +#endif tr = malloc(sizeof(*tr), M_DEVBUF, M_WAITOK | M_ZERO); tr->type = pci_get_devid(dev); @@ -834,7 +849,7 @@ tr_pci_attach(device_t dev) } else { switch (tr->type) { case ALI_PCI_ID: - dacn = 1; + dacn = ALI_MAXPLAYCH; break; default: dacn = TR_MAXPLAYCH; @@ -859,8 +874,6 @@ tr_pci_attach(device_t dev) goto bad; } - tr->bufsz = pcm_getbuffersize(dev, 4096, TR_DEFAULT_BUFSZ, 65536); - if (tr_init(tr) == -1) { device_printf(dev, "unable to initialize the card\n"); goto bad; @@ -879,12 +892,59 @@ tr_pci_attach(device_t dev) goto bad; } - if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2, + if (tr->type == ALI_PCI_ID) { + /* + * The M5451 generates 31 bit of DMA and in order to do + * 32-bit DMA, the 31st bit can be set via its accompanying + * ISA bridge. Note that we can't predict whether bus_dma(9) + * will actually supply us with a 32-bit buffer and even when + * using a low address of BUS_SPACE_MAXADDR_32BIT for both + * we might end up with the play buffer being in the 32-bit + * range while the record buffer isn't or vice versa. So we + * limit enabling the 31st bit to sparc64, where the IOMMU + * guarantees that we're using a 32-bit address (and in turn + * requires it). + */ + lowaddr = ALI_MAXADDR; +#ifdef __sparc64__ + if (device_get_children(device_get_parent(dev), &children, + &nchildren) == 0) { + for (i = 0; i < nchildren; i++) { + if (pci_get_devid(children[i]) == 0x153310b9) { + lowaddr = BUS_SPACE_MAXADDR_32BIT; + data = pci_read_config(children[i], + 0x7e, 1); + if (bootverbose) + device_printf(dev, + "M1533 0x7e: 0x%x -> ", + data); + data |= 0x1; + if (bootverbose) + printf("0x%x\n", data); + pci_write_config(children[i], 0x7e, + data, 1); + break; + } + } + } + free(children, M_TEMP); +#endif + tr->hwchns = ALI_MAXHWCH; + tr->bufsz = ALI_BUFSZ; + } else { + lowaddr = TR_MAXADDR; + tr->hwchns = TR_MAXHWCH; + tr->bufsz = pcm_getbuffersize(dev, 4096, TR_DEFAULT_BUFSZ, + 65536); + } + + if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), + /*alignment*/TR_BUFALGN, /*boundary*/0, - /*lowaddr*/TR_MAXADDR, + /*lowaddr*/lowaddr, /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, - /*maxsize*/tr->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff, + /*maxsize*/tr->bufsz, /*nsegments*/1, /*maxsegz*/tr->bufsz, /*flags*/0, /*lockfunc*/busdma_lock_mutex, /*lockarg*/&Giant, &tr->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); From owner-svn-src-stable@FreeBSD.ORG Fri Sep 25 19:59:48 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 98600106566B; Fri, 25 Sep 2009 19:59:48 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7D2C58FC1F; Fri, 25 Sep 2009 19:59:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8PJxmXV038449; Fri, 25 Sep 2009 19:59:48 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8PJxm4v038447; Fri, 25 Sep 2009 19:59:48 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909251959.n8PJxm4v038447@svn.freebsd.org> From: Marius Strobl Date: Fri, 25 Sep 2009 19:59:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197503 - in stable/7/sys: . contrib/pf dev/sound/pci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2009 19:59:48 -0000 Author: marius Date: Fri Sep 25 19:59:48 2009 New Revision: 197503 URL: http://svn.freebsd.org/changeset/base/197503 Log: MFC: r197401 - According to Linux, the ALi M5451 can do 31-bit DMA instead of just 30-bit like the reset of the controllers supported by this driver. Actually ALi M5451 can be setup up to generate 32-bit addresses by setting the 31st bit via the accompanying ISA bridge, which allows it to work in sparc64 machines whose IOMMU require at least 32-bit DMA. Even though other architectures would also benefit from 32-bit DMA, enabling this bit is limited to sparc64 as bus_dma(9) doesn't generally guarantee that a low address of BUS_SPACE_MAXADDR_32BIT results in a buffer in the 32-bit range. - According to Tatsuo YOKOGAWA's ali(4), the the DMA transfer size of ALi M5451 is fixed to 64k and in fact using the default size of 4k causes the chip to overrun the mapping, triggering uncorrectable DMA errors on sparc64. - The 4DWAVE DX and NX require the recording buffer to be 8-byte aligned so adjust the bus_dma_tag_create(9) accordingly. - Unlike the rest of the controllers supported by this driver, the ALi M5451 only has 32 hardware channels instead of 64 so limit the loop in tr_intr() accordingly. [1] Submitted by: yongari [1] Reviewed by: yongari (superset of what is committed) Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/sound/pci/t4dwave.c Modified: stable/7/sys/dev/sound/pci/t4dwave.c ============================================================================== --- stable/7/sys/dev/sound/pci/t4dwave.c Fri Sep 25 19:59:18 2009 (r197502) +++ stable/7/sys/dev/sound/pci/t4dwave.c Fri Sep 25 19:59:48 2009 (r197503) @@ -41,18 +41,22 @@ SND_DECLARE_FILE("$FreeBSD$"); #define SPA_PCI_ID 0x70181039 #define TR_DEFAULT_BUFSZ 0x1000 +/* For ALi M5451 the DMA transfer size appears to be fixed to 64k. */ +#define ALI_BUFSZ 0x10000 +#define TR_BUFALGN 0x8 #define TR_TIMEOUT_CDC 0xffff +#define TR_MAXHWCH 64 +#define ALI_MAXHWCH 32 #define TR_MAXPLAYCH 4 +#define ALI_MAXPLAYCH 1 /* - * Though, it's not clearly documented in trident datasheet, trident - * audio cards can't handle DMA addresses located above 1GB. The LBA - * (loop begin address) register which holds DMA base address is 32bits - * register. - * But the MSB 2bits are used for other purposes(I guess it is really - * bad idea). This effectivly limits the DMA address space up to 1GB. + * Though, it's not clearly documented in the 4DWAVE datasheet, the + * DX and NX chips can't handle DMA addresses located above 1GB as the + * LBA (loop begin address) register which holds the DMA base address + * is 32-bit, but the two MSBs are used for other purposes. */ -#define TR_MAXADDR ((1 << 30) - 1) - +#define TR_MAXADDR ((1U << 30) - 1) +#define ALI_MAXADDR ((1U << 31) - 1) struct tr_info; @@ -93,6 +97,7 @@ struct tr_info { struct mtx *lock; + u_int32_t hwchns; u_int32_t playchns; unsigned int bufsz; @@ -394,7 +399,10 @@ tr_wrch(struct tr_chinfo *ch) ch->ec &= 0x00000fff; ch->alpha &= 0x00000fff; ch->delta &= 0x0000ffff; - ch->lba &= 0x3fffffff; + if (tr->type == ALI_PCI_ID) + ch->lba &= ALI_MAXADDR; + else + ch->lba &= TR_MAXADDR; cr[1]=ch->lba; cr[3]=(ch->fmc<<14) | (ch->rvol<<7) | (ch->cvol); @@ -437,7 +445,10 @@ tr_rdch(struct tr_chinfo *ch) snd_mtxunlock(tr->lock); - ch->lba= (cr[1] & 0x3fffffff); + if (tr->type == ALI_PCI_ID) + ch->lba=(cr[1] & ALI_MAXADDR); + else + ch->lba=(cr[1] & TR_MAXADDR); ch->fmc= (cr[3] & 0x0000c000) >> 14; ch->rvol= (cr[3] & 0x00003f80) >> 7; ch->cvol= (cr[3] & 0x0000007f); @@ -624,7 +635,6 @@ trrchan_setformat(kobj_t obj, void *data tr_wr(tr, TR_REG_SBCTRL, i, 1); return 0; - } static int @@ -725,7 +735,7 @@ tr_intr(void *p) intsrc = tr_rd(tr, TR_REG_MISCINT, 4); if (intsrc & TR_INT_ADDR) { chnum = 0; - while (chnum < 64) { + while (chnum < tr->hwchns) { mask = 0x00000001; active = tr_rd(tr, (chnum < 32)? TR_REG_ADDRINTA : TR_REG_ADDRINTB, 4); bufhalf = tr_rd(tr, (chnum < 32)? TR_REG_CSPF_A : TR_REG_CSPF_B, 4); @@ -811,8 +821,13 @@ tr_pci_attach(device_t dev) u_int32_t data; struct tr_info *tr; struct ac97_info *codec = 0; + bus_addr_t lowaddr; int i, dacn; char status[SND_STATUSLEN]; +#ifdef __sparc64__ + device_t *children; + int nchildren; +#endif tr = malloc(sizeof(*tr), M_DEVBUF, M_WAITOK | M_ZERO); tr->type = pci_get_devid(dev); @@ -830,7 +845,7 @@ tr_pci_attach(device_t dev) } else { switch (tr->type) { case ALI_PCI_ID: - dacn = 1; + dacn = ALI_MAXPLAYCH; break; default: dacn = TR_MAXPLAYCH; @@ -855,8 +870,6 @@ tr_pci_attach(device_t dev) goto bad; } - tr->bufsz = pcm_getbuffersize(dev, 4096, TR_DEFAULT_BUFSZ, 65536); - if (tr_init(tr) == -1) { device_printf(dev, "unable to initialize the card\n"); goto bad; @@ -875,12 +888,59 @@ tr_pci_attach(device_t dev) goto bad; } - if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2, + if (tr->type == ALI_PCI_ID) { + /* + * The M5451 generates 31 bit of DMA and in order to do + * 32-bit DMA, the 31st bit can be set via its accompanying + * ISA bridge. Note that we can't predict whether bus_dma(9) + * will actually supply us with a 32-bit buffer and even when + * using a low address of BUS_SPACE_MAXADDR_32BIT for both + * we might end up with the play buffer being in the 32-bit + * range while the record buffer isn't or vice versa. So we + * limit enabling the 31st bit to sparc64, where the IOMMU + * guarantees that we're using a 32-bit address (and in turn + * requires it). + */ + lowaddr = ALI_MAXADDR; +#ifdef __sparc64__ + if (device_get_children(device_get_parent(dev), &children, + &nchildren) == 0) { + for (i = 0; i < nchildren; i++) { + if (pci_get_devid(children[i]) == 0x153310b9) { + lowaddr = BUS_SPACE_MAXADDR_32BIT; + data = pci_read_config(children[i], + 0x7e, 1); + if (bootverbose) + device_printf(dev, + "M1533 0x7e: 0x%x -> ", + data); + data |= 0x1; + if (bootverbose) + printf("0x%x\n", data); + pci_write_config(children[i], 0x7e, + data, 1); + break; + } + } + } + free(children, M_TEMP); +#endif + tr->hwchns = ALI_MAXHWCH; + tr->bufsz = ALI_BUFSZ; + } else { + lowaddr = TR_MAXADDR; + tr->hwchns = TR_MAXHWCH; + tr->bufsz = pcm_getbuffersize(dev, 4096, TR_DEFAULT_BUFSZ, + 65536); + } + + if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), + /*alignment*/TR_BUFALGN, /*boundary*/0, - /*lowaddr*/TR_MAXADDR, + /*lowaddr*/lowaddr, /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, - /*maxsize*/tr->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff, + /*maxsize*/tr->bufsz, /*nsegments*/1, /*maxsegz*/tr->bufsz, /*flags*/0, /*lockfunc*/busdma_lock_mutex, /*lockarg*/&Giant, &tr->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); From owner-svn-src-stable@FreeBSD.ORG Fri Sep 25 20:08:54 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 27781106566B; Fri, 25 Sep 2009 20:08:54 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 14F908FC0C; Fri, 25 Sep 2009 20:08:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8PK8rsn038790; Fri, 25 Sep 2009 20:08:53 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8PK8rwR038788; Fri, 25 Sep 2009 20:08:53 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200909252008.n8PK8rwR038788@svn.freebsd.org> From: Marius Strobl Date: Fri, 25 Sep 2009 20:08:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197505 - in stable/6/sys: . conf contrib/pf dev/cxgb dev/sound/pci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2009 20:08:54 -0000 Author: marius Date: Fri Sep 25 20:08:53 2009 New Revision: 197505 URL: http://svn.freebsd.org/changeset/base/197505 Log: MFC: r197401 - According to Linux, the ALi M5451 can do 31-bit DMA instead of just 30-bit like the reset of the controllers supported by this driver. Actually ALi M5451 can be setup up to generate 32-bit addresses by setting the 31st bit via the accompanying ISA bridge, which allows it to work in sparc64 machines whose IOMMU require at least 32-bit DMA. Even though other architectures would also benefit from 32-bit DMA, enabling this bit is limited to sparc64 as bus_dma(9) doesn't generally guarantee that a low address of BUS_SPACE_MAXADDR_32BIT results in a buffer in the 32-bit range. - According to Tatsuo YOKOGAWA's ali(4), the the DMA transfer size of ALi M5451 is fixed to 64k and in fact using the default size of 4k causes the chip to overrun the mapping, triggering uncorrectable DMA errors on sparc64. - The 4DWAVE DX and NX require the recording buffer to be 8-byte aligned so adjust the bus_dma_tag_create(9) accordingly. - Unlike the rest of the controllers supported by this driver, the ALi M5451 only has 32 hardware channels instead of 64 so limit the loop in tr_intr() accordingly. [1] Submitted by: yongari [1] Reviewed by: yongari (superset of what is committed) Modified: stable/6/sys/ (props changed) stable/6/sys/conf/ (props changed) stable/6/sys/contrib/pf/ (props changed) stable/6/sys/dev/cxgb/ (props changed) stable/6/sys/dev/sound/pci/t4dwave.c Modified: stable/6/sys/dev/sound/pci/t4dwave.c ============================================================================== --- stable/6/sys/dev/sound/pci/t4dwave.c Fri Sep 25 20:06:31 2009 (r197504) +++ stable/6/sys/dev/sound/pci/t4dwave.c Fri Sep 25 20:08:53 2009 (r197505) @@ -41,18 +41,22 @@ SND_DECLARE_FILE("$FreeBSD$"); #define SPA_PCI_ID 0x70181039 #define TR_DEFAULT_BUFSZ 0x1000 +/* For ALi M5451 the DMA transfer size appears to be fixed to 64k. */ +#define ALI_BUFSZ 0x10000 +#define TR_BUFALGN 0x8 #define TR_TIMEOUT_CDC 0xffff +#define TR_MAXHWCH 64 +#define ALI_MAXHWCH 32 #define TR_MAXPLAYCH 4 +#define ALI_MAXPLAYCH 1 /* - * Though, it's not clearly documented in trident datasheet, trident - * audio cards can't handle DMA addresses located above 1GB. The LBA - * (loop begin address) register which holds DMA base address is 32bits - * register. - * But the MSB 2bits are used for other purposes(I guess it is really - * bad idea). This effectivly limits the DMA address space up to 1GB. + * Though, it's not clearly documented in the 4DWAVE datasheet, the + * DX and NX chips can't handle DMA addresses located above 1GB as the + * LBA (loop begin address) register which holds the DMA base address + * is 32-bit, but the two MSBs are used for other purposes. */ -#define TR_MAXADDR ((1 << 30) - 1) - +#define TR_MAXADDR ((1U << 30) - 1) +#define ALI_MAXADDR ((1U << 31) - 1) struct tr_info; @@ -93,6 +97,7 @@ struct tr_info { struct mtx *lock; + u_int32_t hwchns; u_int32_t playchns; unsigned int bufsz; @@ -394,7 +399,10 @@ tr_wrch(struct tr_chinfo *ch) ch->ec &= 0x00000fff; ch->alpha &= 0x00000fff; ch->delta &= 0x0000ffff; - ch->lba &= 0x3fffffff; + if (tr->type == ALI_PCI_ID) + ch->lba &= ALI_MAXADDR; + else + ch->lba &= TR_MAXADDR; cr[1]=ch->lba; cr[3]=(ch->fmc<<14) | (ch->rvol<<7) | (ch->cvol); @@ -437,7 +445,10 @@ tr_rdch(struct tr_chinfo *ch) snd_mtxunlock(tr->lock); - ch->lba= (cr[1] & 0x3fffffff); + if (tr->type == ALI_PCI_ID) + ch->lba=(cr[1] & ALI_MAXADDR); + else + ch->lba=(cr[1] & TR_MAXADDR); ch->fmc= (cr[3] & 0x0000c000) >> 14; ch->rvol= (cr[3] & 0x00003f80) >> 7; ch->cvol= (cr[3] & 0x0000007f); @@ -624,7 +635,6 @@ trrchan_setformat(kobj_t obj, void *data tr_wr(tr, TR_REG_SBCTRL, i, 1); return 0; - } static int @@ -725,7 +735,7 @@ tr_intr(void *p) intsrc = tr_rd(tr, TR_REG_MISCINT, 4); if (intsrc & TR_INT_ADDR) { chnum = 0; - while (chnum < 64) { + while (chnum < tr->hwchns) { mask = 0x00000001; active = tr_rd(tr, (chnum < 32)? TR_REG_ADDRINTA : TR_REG_ADDRINTB, 4); bufhalf = tr_rd(tr, (chnum < 32)? TR_REG_CSPF_A : TR_REG_CSPF_B, 4); @@ -811,8 +821,13 @@ tr_pci_attach(device_t dev) u_int32_t data; struct tr_info *tr; struct ac97_info *codec = 0; + bus_addr_t lowaddr; int i, dacn; char status[SND_STATUSLEN]; +#ifdef __sparc64__ + device_t *children; + int nchildren; +#endif if ((tr = malloc(sizeof(*tr), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) { device_printf(dev, "cannot allocate softc\n"); @@ -834,7 +849,7 @@ tr_pci_attach(device_t dev) } else { switch (tr->type) { case ALI_PCI_ID: - dacn = 1; + dacn = ALI_MAXPLAYCH; break; default: dacn = TR_MAXPLAYCH; @@ -859,8 +874,6 @@ tr_pci_attach(device_t dev) goto bad; } - tr->bufsz = pcm_getbuffersize(dev, 4096, TR_DEFAULT_BUFSZ, 65536); - if (tr_init(tr) == -1) { device_printf(dev, "unable to initialize the card\n"); goto bad; @@ -879,11 +892,59 @@ tr_pci_attach(device_t dev) goto bad; } - if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0, - /*lowaddr*/TR_MAXADDR, + if (tr->type == ALI_PCI_ID) { + /* + * The M5451 generates 31 bit of DMA and in order to do + * 32-bit DMA, the 31st bit can be set via its accompanying + * ISA bridge. Note that we can't predict whether bus_dma(9) + * will actually supply us with a 32-bit buffer and even when + * using a low address of BUS_SPACE_MAXADDR_32BIT for both + * we might end up with the play buffer being in the 32-bit + * range while the record buffer isn't or vice versa. So we + * limit enabling the 31st bit to sparc64, where the IOMMU + * guarantees that we're using a 32-bit address (and in turn + * requires it). + */ + lowaddr = ALI_MAXADDR; +#ifdef __sparc64__ + if (device_get_children(device_get_parent(dev), &children, + &nchildren) == 0) { + for (i = 0; i < nchildren; i++) { + if (pci_get_devid(children[i]) == 0x153310b9) { + lowaddr = BUS_SPACE_MAXADDR_32BIT; + data = pci_read_config(children[i], + 0x7e, 1); + if (bootverbose) + device_printf(dev, + "M1533 0x7e: 0x%x -> ", + data); + data |= 0x1; + if (bootverbose) + printf("0x%x\n", data); + pci_write_config(children[i], 0x7e, + data, 1); + break; + } + } + } + free(children, M_TEMP); +#endif + tr->hwchns = ALI_MAXHWCH; + tr->bufsz = ALI_BUFSZ; + } else { + lowaddr = TR_MAXADDR; + tr->hwchns = TR_MAXHWCH; + tr->bufsz = pcm_getbuffersize(dev, 4096, TR_DEFAULT_BUFSZ, + 65536); + } + + if (bus_dma_tag_create(/*parent*/NULL, + /*alignment*/TR_BUFALGN, + /*boundary*/0, + /*lowaddr*/lowaddr, /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, - /*maxsize*/tr->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff, + /*maxsize*/tr->bufsz, /*nsegments*/1, /*maxsegz*/tr->bufsz, /*flags*/0, /*lockfunc*/busdma_lock_mutex, /*lockarg*/&Giant, &tr->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); From owner-svn-src-stable@FreeBSD.ORG Sat Sep 26 11:31:25 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D5908106566B; Sat, 26 Sep 2009 11:31:25 +0000 (UTC) (envelope-from mlaier@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AA63C8FC12; Sat, 26 Sep 2009 11:31:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8QBVPss057956; Sat, 26 Sep 2009 11:31:25 GMT (envelope-from mlaier@svn.freebsd.org) Received: (from mlaier@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8QBVPhU057955; Sat, 26 Sep 2009 11:31:25 GMT (envelope-from mlaier@svn.freebsd.org) Message-Id: <200909261131.n8QBVPhU057955@svn.freebsd.org> From: Max Laier Date: Sat, 26 Sep 2009 11:31:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197516 - in stable/7/sys: . conf contrib/pf X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Sep 2009 11:31:25 -0000 Author: mlaier Date: Sat Sep 26 11:31:25 2009 New Revision: 197516 URL: http://svn.freebsd.org/changeset/base/197516 Log: MFC r197334,r197433: Extract svn and git version info from git-svn repos. Modified: stable/7/sys/ (props changed) stable/7/sys/conf/newvers.sh stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/conf/newvers.sh ============================================================================== --- stable/7/sys/conf/newvers.sh Sat Sep 26 00:10:45 2009 (r197515) +++ stable/7/sys/conf/newvers.sh Sat Sep 26 11:31:25 2009 (r197516) @@ -89,28 +89,54 @@ i=`${MAKE:-make} -V KERN_IDENT` case "$d" in */sys/*) + SRCDIR=${d##*obj} + if [ -n "$MACHINE" ]; then + SRCDIR=${SRCDIR##/$MACHINE} + fi + SRCDIR=${SRCDIR%%/sys/*} + for dir in /bin /usr/bin /usr/local/bin; do - if [ -x "${dir}/svnversion" ]; then + if [ -d "${SRCDIR}/sys/.svn" -a -x "${dir}/svnversion" ] ; then svnversion=${dir}/svnversion - SRCDIR=${d##*obj} - if [ -n "$MACHINE" ]; then - SRCDIR=${SRCDIR##/$MACHINE} - fi - SRCDIR=${SRCDIR%%/sys/*} + break + fi + if [ -d "${SRCDIR}/.git" -a -x "${dir}/git" ] ; then + git_cmd="${dir}/git --git-dir=${SRCDIR}/.git" break fi done - if [ -n "$svnversion" -a -d "${SRCDIR}/sys/.svn" ] ; then + if [ -n "$svnversion" ] ; then svn=" r`cd ${SRCDIR}/sys && $svnversion`" fi + if [ -n "$git_cmd" ] ; then + git=`$git_cmd rev-parse --verify --short HEAD 2>/dev/null` + svn=`$git_cmd svn find-rev $git 2>/dev/null` + if [ -n "$svn" ] ; then + svn=" r${svn}" + git="=${git}" + else + svn=`$git_cmd log | fgrep 'git-svn-id:' | head -1 | \ + sed -n 's/^.*@\([0-9][0-9]*\).*$/\1/p'` + if [ -n $svn ] ; then + svn=" r${svn}" + git="+${git}" + else + git=" ${git}" + fi + fi + if $git_cmd --work-tree=${SRCDIR} diff-index \ + --name-only HEAD | read dummy; then + git="${git}-dirty" + fi + fi ;; esac cat << EOF > vers.c $COPYRIGHT -#define SCCSSTR "@(#)${VERSION} #${v}${svn}: ${t}" -#define VERSTR "${VERSION} #${v}${svn}: ${t}\\n ${u}@${h}:${d}\\n" +#define SCCSSTR "@(#)${VERSION} #${v}${svn}${git}: ${t}" +#define VERSTR "${VERSION} #${v}${svn}${git}: ${t}\\n ${u}@${h}:${d}\\n" #define RELSTR "${RELEASE}" char sccs[sizeof(SCCSSTR) > 128 ? sizeof(SCCSSTR) : 128] = SCCSSTR; From owner-svn-src-stable@FreeBSD.ORG Sat Sep 26 11:44:05 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 410B61065672; Sat, 26 Sep 2009 11:44:05 +0000 (UTC) (envelope-from mlaier@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 15E428FC0C; Sat, 26 Sep 2009 11:44:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8QBi4AP058311; Sat, 26 Sep 2009 11:44:04 GMT (envelope-from mlaier@svn.freebsd.org) Received: (from mlaier@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8QBi4Fo058309; Sat, 26 Sep 2009 11:44:04 GMT (envelope-from mlaier@svn.freebsd.org) Message-Id: <200909261144.n8QBi4Fo058309@svn.freebsd.org> From: Max Laier Date: Sat, 26 Sep 2009 11:44:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197517 - in stable/6/sys: . conf contrib/pf dev/cxgb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Sep 2009 11:44:05 -0000 Author: mlaier Date: Sat Sep 26 11:44:04 2009 New Revision: 197517 URL: http://svn.freebsd.org/changeset/base/197517 Log: MFC r197334,r197433: Extract svn and git version info from git-svn repos. Modified: stable/6/sys/ (props changed) stable/6/sys/conf/ (props changed) stable/6/sys/conf/newvers.sh stable/6/sys/contrib/pf/ (props changed) stable/6/sys/dev/cxgb/ (props changed) Modified: stable/6/sys/conf/newvers.sh ============================================================================== --- stable/6/sys/conf/newvers.sh Sat Sep 26 11:31:25 2009 (r197516) +++ stable/6/sys/conf/newvers.sh Sat Sep 26 11:44:04 2009 (r197517) @@ -89,25 +89,56 @@ i=`${MAKE:-make} -V KERN_IDENT` case "$d" in */sys/*) + SRCDIR=${d##*obj} + if [ -n "$MACHINE" ]; then + if [ -n "$MACHINE" ]; then + SRCDIR=${SRCDIR##/$MACHINE} + fi + fi + SRCDIR=${SRCDIR%%/sys/*} + for dir in /bin /usr/bin /usr/local/bin; do - if [ -x "${dir}/svnversion" ]; then + if [ -d "${SRCDIR}/sys/.svn" -a -x "${dir}/svnversion" ] ; then svnversion=${dir}/svnversion - SRCDIR=${d##*obj} - SRCDIR=${SRCDIR%%/sys/*} + break + fi + if [ -d "${SRCDIR}/.git" -a -x "${dir}/git" ] ; then + git_cmd="${dir}/git --git-dir=${SRCDIR}/.git" break fi done - if [ -n "$svnversion" -a -d "${SRCDIR}/sys/.svn" ] ; then + if [ -n "$svnversion" ] ; then svn=" r`cd ${SRCDIR}/sys && $svnversion`" fi + if [ -n "$git_cmd" ] ; then + git=`$git_cmd rev-parse --verify --short HEAD 2>/dev/null` + svn=`$git_cmd svn find-rev $git 2>/dev/null` + if [ -n "$svn" ] ; then + svn=" r${svn}" + git="=${git}" + else + svn=`$git_cmd log | fgrep 'git-svn-id:' | head -1 | \ + sed -n 's/^.*@\([0-9][0-9]*\).*$/\1/p'` + if [ -n $svn ] ; then + svn=" r${svn}" + git="+${git}" + else + git=" ${git}" + fi + fi + if $git_cmd --work-tree=${SRCDIR} diff-index \ + --name-only HEAD | read dummy; then + git="${git}-dirty" + fi + fi ;; esac cat << EOF > vers.c $COPYRIGHT -#define SCCSSTR "@(#)${VERSION} #${v}${svn}: ${t}" -#define VERSTR "${VERSION} #${v}${svn}: ${t}\\n ${u}@${h}:${d}\\n" +#define SCCSSTR "@(#)${VERSION} #${v}${svn}${git}: ${t}" +#define VERSTR "${VERSION} #${v}${svn}${git}: ${t}\\n ${u}@${h}:${d}\\n" #define RELSTR "${RELEASE}" char sccs[sizeof(SCCSSTR) > 128 ? sizeof(SCCSSTR) : 128] = SCCSSTR; From owner-svn-src-stable@FreeBSD.ORG Sat Sep 26 20:07:49 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BE3A0106566C; Sat, 26 Sep 2009 20:07:49 +0000 (UTC) (envelope-from stas@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AC6198FC29; Sat, 26 Sep 2009 20:07:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8QK7n6A069710; Sat, 26 Sep 2009 20:07:49 GMT (envelope-from stas@svn.freebsd.org) Received: (from stas@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8QK7nDa069706; Sat, 26 Sep 2009 20:07:49 GMT (envelope-from stas@svn.freebsd.org) Message-Id: <200909262007.n8QK7nDa069706@svn.freebsd.org> From: Stanislav Sedov Date: Sat, 26 Sep 2009 20:07:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197529 - in stable/7/sys: . contrib/pf netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Sep 2009 20:07:49 -0000 Author: stas Date: Sat Sep 26 20:07:48 2009 New Revision: 197529 URL: http://svn.freebsd.org/changeset/base/197529 Log: - MFC r196410 by peter@: Fix signed comparison bug when ticks goes negative after 24 days of uptime. This causes the tcp time_wait state code to fail to expire sockets in timewait state. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/netinet/tcp_timewait.c Modified: stable/7/sys/netinet/tcp_timewait.c ============================================================================== --- stable/7/sys/netinet/tcp_timewait.c Sat Sep 26 19:00:47 2009 (r197528) +++ stable/7/sys/netinet/tcp_timewait.c Sat Sep 26 20:07:48 2009 (r197529) @@ -587,7 +587,7 @@ tcp_tw_2msl_scan(int reuse) INP_INFO_WLOCK_ASSERT(&tcbinfo); for (;;) { tw = TAILQ_FIRST(&twq_2msl); - if (tw == NULL || (!reuse && tw->tw_time > ticks)) + if (tw == NULL || (!reuse && (tw->tw_time - ticks) > 0)) break; INP_WLOCK(tw->tw_inpcb); tcp_twclose(tw, reuse);