From d850edfa785efdb665c991a974594c2bc5d70cec Mon Sep 17 00:00:00 2001 From: nwhitehorn Date: Wed, 13 Jul 2011 13:25:12 +0000 Subject: [PATCH 01/14] Run newaliases at the end of the install process. Submitted by: kevlo git-svn-id: svn+ssh://svn.freebsd.org/base/head@223980 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- usr.sbin/bsdinstall/scripts/config | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/usr.sbin/bsdinstall/scripts/config b/usr.sbin/bsdinstall/scripts/config index 5d7c3cead61..4340450b896 100755 --- a/usr.sbin/bsdinstall/scripts/config +++ b/usr.sbin/bsdinstall/scripts/config @@ -30,3 +30,7 @@ cat $BSDINSTALL_TMPETC/rc.conf.* >> $BSDINSTALL_TMPETC/rc.conf rm $BSDINSTALL_TMPETC/rc.conf.* cp $BSDINSTALL_TMPETC/* $BSDINSTALL_CHROOT/etc + +# Set up other things from installed config +chroot $BSDINSTALL_CHROOT /usr/bin/newaliases + From 3d8b70ddea834f12d090ea1254e0e46a2df0df35 Mon Sep 17 00:00:00 2001 From: marius Date: Wed, 13 Jul 2011 14:10:28 +0000 Subject: [PATCH 02/14] Remove extra empty lines. git-svn-id: svn+ssh://svn.freebsd.org/base/head@223981 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/dev/mpt/mpt_pci.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/sys/dev/mpt/mpt_pci.c b/sys/dev/mpt/mpt_pci.c index a3cb61151fe..98604d0de5b 100644 --- a/sys/dev/mpt/mpt_pci.c +++ b/sys/dev/mpt/mpt_pci.c @@ -193,8 +193,6 @@ __FBSDID("$FreeBSD$"); #define PCIM_CMD_SERRESPEN 0x0100 #endif - - static int mpt_pci_probe(device_t); static int mpt_pci_attach(device_t); static void mpt_free_bus_resources(struct mpt_softc *mpt); @@ -362,7 +360,6 @@ mpt_set_options(struct mpt_softc *mpt) mpt->cfg_role = tval; mpt->do_cfg_role = 1; } - tval = 0; mpt->msi_enable = 0; if (resource_int_value(device_get_name(mpt->dev), @@ -372,7 +369,6 @@ mpt_set_options(struct mpt_softc *mpt) } #endif - static void mpt_link_peer(struct mpt_softc *mpt) { @@ -411,7 +407,6 @@ mpt_unlink_peer(struct mpt_softc *mpt) } } - static int mpt_pci_attach(device_t dev) { @@ -687,7 +682,6 @@ mpt_free_bus_resources(struct mpt_softc *mpt) MPT_LOCK_DESTROY(mpt); } - /* * Disconnect ourselves from the system. */ @@ -712,7 +706,6 @@ mpt_pci_detach(device_t dev) return(0); } - /* * Disable the hardware */ @@ -808,8 +801,6 @@ mpt_dma_mem_alloc(struct mpt_softc *mpt) return (0); } - - /* Deallocate memory that was allocated by mpt_dma_mem_alloc */ static void @@ -832,8 +823,6 @@ mpt_dma_mem_free(struct mpt_softc *mpt) } - - /* Reads modifiable (via PCI transactions) config registers */ static void mpt_read_config_regs(struct mpt_softc *mpt) From c4577fd8fdbee6e0a2ed8f38e7afa4bc68ad04d4 Mon Sep 17 00:00:00 2001 From: marius Date: Wed, 13 Jul 2011 18:35:47 +0000 Subject: [PATCH 03/14] PCIB_ALLOC_MSIX() may already fail on the first pass, f.e. when the PCI-PCI bridge is blacklisted. In that case just return from pci_alloc_msix_method(), otherwise we continue without a single MSI-X resource, causing subsequent attempts to use the seemingly available resource to fail or when booting verbose a NULL-pointer dereference of rle->start when trying to print the IRQ in pci_alloc_msix_method(). Reviewed by: jhb MFC after: 1 week git-svn-id: svn+ssh://svn.freebsd.org/base/head@223984 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/dev/pci/pci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 004190a321b..7eb84e6e5ee 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -1353,8 +1353,11 @@ pci_alloc_msix_method(device_t dev, device_t child, int *count) for (i = 0; i < max; i++) { /* Allocate a message. */ error = PCIB_ALLOC_MSIX(device_get_parent(dev), child, &irq); - if (error) + if (error) { + if (i == 0) + return (error); break; + } resource_list_add(&dinfo->resources, SYS_RES_IRQ, i + 1, irq, irq, 1); } From 4187d830ebd46c25427937fcdb746e8a987b5d6e Mon Sep 17 00:00:00 2001 From: marius Date: Wed, 13 Jul 2011 18:48:51 +0000 Subject: [PATCH 04/14] - For SAS but neither FC nor SPI controllers default to using MSI (still allowing their use to be disabled via device hints though). This matches what the corresponding Linux driver provided by LSI does. Tested with SAS1064. - There's no need to keep track of the RIDs used. - Don't allocate MSI/MSI-X as RF_SHAREABLE. - Remove a comment which no longer applies since r209599. - Assign NULL rather than 0 to pointers. MFC after: 1 month git-svn-id: svn+ssh://svn.freebsd.org/base/head@223985 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/dev/mpt/mpt.h | 2 -- sys/dev/mpt/mpt_pci.c | 40 ++++++++++++++++++++-------------------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/sys/dev/mpt/mpt.h b/sys/dev/mpt/mpt.h index 47af5ba6e50..d12c307c803 100644 --- a/sys/dev/mpt/mpt.h +++ b/sys/dev/mpt/mpt.h @@ -721,11 +721,9 @@ struct mpt_softc { * DMA Mapping Stuff */ struct resource * pci_reg; /* Register map for chip */ - int pci_mem_rid; /* Resource ID */ bus_space_tag_t pci_st; /* Bus tag for registers */ bus_space_handle_t pci_sh; /* Bus handle for registers */ /* PIO versions of above. */ - int pci_pio_rid; struct resource * pci_pio_reg; bus_space_tag_t pci_pio_st; bus_space_handle_t pci_pio_sh; diff --git a/sys/dev/mpt/mpt_pci.c b/sys/dev/mpt/mpt_pci.c index 98604d0de5b..f7201b613e6 100644 --- a/sys/dev/mpt/mpt_pci.c +++ b/sys/dev/mpt/mpt_pci.c @@ -362,9 +362,11 @@ mpt_set_options(struct mpt_softc *mpt) } tval = 0; mpt->msi_enable = 0; - if (resource_int_value(device_get_name(mpt->dev), - device_get_unit(mpt->dev), "msi_enable", &tval) == 0 && tval == 1) { + if (mpt->is_sas) mpt->msi_enable = 1; + if (resource_int_value(device_get_name(mpt->dev), + device_get_unit(mpt->dev), "msi_enable", &tval) == 0) { + mpt->msi_enable = tval; } } #endif @@ -517,9 +519,9 @@ mpt_pci_attach(device_t dev) * certain reset operations (but must be disabled for * some cards otherwise). */ - mpt->pci_pio_rid = PCIR_BAR(mpt_io_bar); + mpt_io_bar = PCIR_BAR(mpt_io_bar); mpt->pci_pio_reg = bus_alloc_resource_any(dev, SYS_RES_IOPORT, - &mpt->pci_pio_rid, RF_ACTIVE); + &mpt_io_bar, RF_ACTIVE); if (mpt->pci_pio_reg == NULL) { device_printf(dev, "unable to map registers in PIO mode\n"); goto bad; @@ -528,9 +530,9 @@ mpt_pci_attach(device_t dev) mpt->pci_pio_sh = rman_get_bushandle(mpt->pci_pio_reg); /* Allocate kernel virtual memory for the 9x9's Mem0 region */ - mpt->pci_mem_rid = PCIR_BAR(mpt_mem_bar); + mpt_mem_bar = PCIR_BAR(mpt_mem_bar); mpt->pci_reg = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &mpt->pci_mem_rid, RF_ACTIVE); + &mpt_mem_bar, RF_ACTIVE); if (mpt->pci_reg == NULL) { device_printf(dev, "Unable to memory map registers.\n"); if (mpt->is_sas) { @@ -570,7 +572,7 @@ mpt_pci_attach(device_t dev) } } mpt->pci_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &iqd, - RF_ACTIVE | RF_SHAREABLE); + RF_ACTIVE | (mpt->pci_msi_count ? 0 : RF_SHAREABLE)); if (mpt->pci_irq == NULL) { device_printf(dev, "could not allocate interrupt\n"); goto bad; @@ -589,7 +591,6 @@ mpt_pci_attach(device_t dev) } /* Allocate dma memory */ -/* XXX JGibbs -Should really be done based on IOCFacts. */ if (mpt_dma_mem_alloc(mpt)) { mpt_prt(mpt, "Could not allocate DMA memory\n"); goto bad; @@ -655,13 +656,13 @@ mpt_free_bus_resources(struct mpt_softc *mpt) { if (mpt->ih) { bus_teardown_intr(mpt->dev, mpt->pci_irq, mpt->ih); - mpt->ih = 0; + mpt->ih = NULL; } if (mpt->pci_irq) { bus_release_resource(mpt->dev, SYS_RES_IRQ, - mpt->pci_msi_count ? 1 : 0, mpt->pci_irq); - mpt->pci_irq = 0; + rman_get_rid(mpt->pci_irq), mpt->pci_irq); + mpt->pci_irq = NULL; } if (mpt->pci_msi_count) { @@ -670,14 +671,14 @@ mpt_free_bus_resources(struct mpt_softc *mpt) } if (mpt->pci_pio_reg) { - bus_release_resource(mpt->dev, SYS_RES_IOPORT, mpt->pci_pio_rid, - mpt->pci_pio_reg); - mpt->pci_pio_reg = 0; + bus_release_resource(mpt->dev, SYS_RES_IOPORT, + rman_get_rid(mpt->pci_pio_reg), mpt->pci_pio_reg); + mpt->pci_pio_reg = NULL; } if (mpt->pci_reg) { - bus_release_resource(mpt->dev, SYS_RES_MEMORY, mpt->pci_mem_rid, - mpt->pci_reg); - mpt->pci_reg = 0; + bus_release_resource(mpt->dev, SYS_RES_MEMORY, + rman_get_rid(mpt->pci_reg), mpt->pci_reg); + mpt->pci_reg = NULL; } MPT_LOCK_DESTROY(mpt); } @@ -817,10 +818,9 @@ mpt_dma_mem_free(struct mpt_softc *mpt) bus_dmamem_free(mpt->reply_dmat, mpt->reply, mpt->reply_dmap); bus_dma_tag_destroy(mpt->reply_dmat); bus_dma_tag_destroy(mpt->parent_dmat); - mpt->reply_dmat = 0; + mpt->reply_dmat = NULL; free(mpt->request_pool, M_DEVBUF); - mpt->request_pool = 0; - + mpt->request_pool = NULL; } /* Reads modifiable (via PCI transactions) config registers */ From 9d390e8f64959cb1048db90ec3cef4ffc6e5281f Mon Sep 17 00:00:00 2001 From: marius Date: Wed, 13 Jul 2011 18:52:11 +0000 Subject: [PATCH 05/14] - Expand the scope of the lock in the interrupt routine to close races with checking IFF_DRV_RUNNING and simplify the code. This also involves holding the driver lock in the rx_ch callout. - Just use ifp instead of sc->sc_ifp. Submitted by: jhb (mostly) git-svn-id: svn+ssh://svn.freebsd.org/base/head@223986 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/dev/cas/if_cas.c | 47 +++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/sys/dev/cas/if_cas.c b/sys/dev/cas/if_cas.c index 5d830f85a6a..858c8bc381c 100644 --- a/sys/dev/cas/if_cas.c +++ b/sys/dev/cas/if_cas.c @@ -203,7 +203,7 @@ 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(&sc->sc_rx_ch, 1); + callout_init_mtx(&sc->sc_rx_ch, &sc->sc_mtx, 0); /* 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); @@ -1599,7 +1599,7 @@ cas_rint_timeout(void *arg) { struct cas_softc *sc = arg; - CAS_LOCK_ASSERT(sc, MA_NOTOWNED); + CAS_LOCK_ASSERT(sc, MA_OWNED); cas_rint(sc); } @@ -1614,7 +1614,7 @@ cas_rint(struct cas_softc *sc) uint32_t rxhead; u_int idx, idx2, len, off, skip; - CAS_LOCK_ASSERT(sc, MA_NOTOWNED); + CAS_LOCK_ASSERT(sc, MA_OWNED); callout_stop(&sc->sc_rx_ch); @@ -1742,7 +1742,9 @@ 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_iqdrops++; @@ -1838,7 +1840,9 @@ 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_iqdrops++; @@ -1876,7 +1880,7 @@ cas_free(void *arg1, void *arg2) { struct cas_rxdsoft *rxds; struct cas_softc *sc; - u_int idx; + u_int idx, locked; #if __FreeBSD_version < 800016 rxds = arg2; @@ -1894,17 +1898,18 @@ 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; - if ((locked = CAS_LOCK_OWNED(sc)) == 0) - CAS_LOCK(sc); + CAS_LOCK_ASSERT(sc, MA_OWNED); bus_dmamap_sync(sc->sc_rdmatag, sc->sc_rxdsoft[idx].rxds_dmamap, BUS_DMASYNC_PREREAD); @@ -1922,9 +1927,6 @@ cas_add_rxdesc(struct cas_softc *sc, u_int idx) CAS_WRITE_4(sc, CAS_RX_KICK, (sc->sc_rxdptr + CAS_NRXDESC - 4) & CAS_NRXDESC_MASK); } - - if (locked == 0) - CAS_UNLOCK(sc); } static void @@ -1932,7 +1934,7 @@ cas_eint(struct cas_softc *sc, u_int status) { struct ifnet *ifp = sc->sc_ifp; - CAS_LOCK_ASSERT(sc, MA_NOTOWNED); + CAS_LOCK_ASSERT(sc, MA_OWNED); ifp->if_ierrors++; @@ -1949,7 +1951,7 @@ cas_eint(struct cas_softc *sc, u_int status) printf("\n"); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; - cas_init(sc); + cas_init_locked(sc); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) taskqueue_enqueue(sc->sc_tq, &sc->sc_tx_task); } @@ -1986,6 +1988,7 @@ cas_intr_task(void *arg, int pending __unused) if (__predict_false((status & CAS_INTR_SUMMARY) == 0)) goto done; + CAS_LOCK(sc); #ifdef CAS_DEBUG CTR4(KTR_CAS, "%s: %s: cplt %x, status %x", device_get_name(sc->sc_dev), __func__, @@ -2025,6 +2028,7 @@ cas_intr_task(void *arg, int pending __unused) (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; } @@ -2032,7 +2036,7 @@ cas_intr_task(void *arg, int pending __unused) status2 = CAS_READ_4(sc, CAS_MAC_TX_STATUS); if ((status2 & (CAS_MAC_TX_UNDERRUN | CAS_MAC_TX_MAX_PKT_ERR)) != 0) - sc->sc_ifp->if_oerrors++; + ifp->if_oerrors++; else if ((status2 & ~CAS_MAC_TX_FRAME_XMTD) != 0) device_printf(sc->sc_dev, "MAC TX fault, status %x\n", status2); @@ -2041,7 +2045,7 @@ cas_intr_task(void *arg, int pending __unused) if (__predict_false(status & CAS_INTR_RX_MAC_INT)) { status2 = CAS_READ_4(sc, CAS_MAC_RX_STATUS); if ((status2 & CAS_MAC_RX_OVERFLOW) != 0) - sc->sc_ifp->if_ierrors++; + ifp->if_ierrors++; else if ((status2 & ~CAS_MAC_RX_FRAME_RCVD) != 0) device_printf(sc->sc_dev, "MAC RX fault, status %x\n", status2); @@ -2061,16 +2065,15 @@ cas_intr_task(void *arg, int pending __unused) } if ((status & - (CAS_INTR_TX_INT_ME | CAS_INTR_TX_ALL | CAS_INTR_TX_DONE)) != 0) { - CAS_LOCK(sc); + (CAS_INTR_TX_INT_ME | CAS_INTR_TX_ALL | CAS_INTR_TX_DONE)) != 0) cas_tint(sc); - CAS_UNLOCK(sc); - } - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { + CAS_UNLOCK(sc); return; - else if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + } else if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) taskqueue_enqueue(sc->sc_tq, &sc->sc_tx_task); + CAS_UNLOCK(sc); status = CAS_READ_4(sc, CAS_STATUS_ALIAS); if (__predict_false((status & CAS_INTR_SUMMARY) != 0)) { @@ -2403,7 +2406,7 @@ cas_mii_statchg(device_t dev) CAS_WRITE_4(sc, CAS_MAC_XIF_CONF, v); sc->sc_mac_rxcfg = rxcfg; - if ((sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING) != 0 && + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0 && (sc->sc_flags & CAS_LINK) != 0) { CAS_WRITE_4(sc, CAS_MAC_TX_CONF, txcfg | CAS_MAC_TX_CONF_EN); From e03ec52be43fbd3985357d97b9d07c70e0182191 Mon Sep 17 00:00:00 2001 From: kib Date: Wed, 13 Jul 2011 21:07:41 +0000 Subject: [PATCH 06/14] While fixing the looping of a thread while devfs vnode is reclaimed, r179247 introduced a possibility of devfs_allocv() returning spurious ENOENT. If the vnode is selected by vnlru daemon for reclamation, then devfs_allocv() can get ENOENT from vget() due to devfs_close() dropping vnode lock around the call to cdevsw d_close method. Use LK_RETRY in the vget() call, and do some part of the devfs_reclaim() work in devfs_allocv(), clearing vp->v_data and de->de_vnode. Retry the allocation of the vnode, now with de->de_vnode == NULL. The check vp->v_data == NULL at the start of devfs_close() cannot be affected by the change, since vnode lock must be held while VI_DOOMED is set, and only dropped after the check. Reported and tested by: Kohji Okuno Reviewed by: attilio MFC after: 3 weeks git-svn-id: svn+ssh://svn.freebsd.org/base/head@223988 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/fs/devfs/devfs_vnops.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index bf6dab8dbe3..955bd8b0f22 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -397,6 +397,7 @@ devfs_allocv(struct devfs_dirent *de, struct mount *mp, int lockmode, sx_xunlock(&dmp->dm_lock); return (ENOENT); } +loop: DEVFS_DE_HOLD(de); DEVFS_DMP_HOLD(dmp); mtx_lock(&devfs_de_interlock); @@ -405,16 +406,21 @@ devfs_allocv(struct devfs_dirent *de, struct mount *mp, int lockmode, VI_LOCK(vp); mtx_unlock(&devfs_de_interlock); sx_xunlock(&dmp->dm_lock); - error = vget(vp, lockmode | LK_INTERLOCK, curthread); + vget(vp, lockmode | LK_INTERLOCK | LK_RETRY, curthread); sx_xlock(&dmp->dm_lock); if (devfs_allocv_drop_refs(0, dmp, de)) { - if (error == 0) - vput(vp); + vput(vp); return (ENOENT); } - else if (error) { - sx_xunlock(&dmp->dm_lock); - return (error); + else if ((vp->v_iflag & VI_DOOMED) != 0) { + mtx_lock(&devfs_de_interlock); + if (de->de_vnode == vp) { + de->de_vnode = NULL; + vp->v_data = NULL; + } + mtx_unlock(&devfs_de_interlock); + vput(vp); + goto loop; } sx_xunlock(&dmp->dm_lock); *vpp = vp; From 2af9869ebf29271a888e9cc62ba4364de2cf3e8c Mon Sep 17 00:00:00 2001 From: hselasky Date: Wed, 13 Jul 2011 21:07:50 +0000 Subject: [PATCH 07/14] Fix for dump after shutdown with USB keyboard plugged in. It appears that the system timer is stopped during shutdown and that the pause() statement in ukbd causes infinite hang in this regard. The fix is to use mi_switch() instead of pause() to do the required task switch to ensure that the required USB processes get executed. Reported by: Mike_Karels@mcafee.com MFC after: 1 week git-svn-id: svn+ssh://svn.freebsd.org/base/head@223989 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/dev/usb/input/ukbd.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/sys/dev/usb/input/ukbd.c b/sys/dev/usb/input/ukbd.c index aa68f7eba32..1ad3bd59cb6 100644 --- a/sys/dev/usb/input/ukbd.c +++ b/sys/dev/usb/input/ukbd.c @@ -59,6 +59,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include @@ -385,6 +387,33 @@ ukbd_put_key(struct ukbd_softc *sc, uint32_t key) } } +static void +ukbd_yield(void) +{ + struct thread *td = curthread; + uint32_t old_prio; + + DROP_GIANT(); + + thread_lock(td); + + /* get current priority */ + old_prio = td->td_base_pri; + + /* set new priority */ + sched_prio(td, td->td_user_pri); + + /* cause a task switch */ + mi_switch(SW_INVOL | SWT_RELINQUISH, NULL); + + /* restore priority */ + sched_prio(td, old_prio); + + thread_unlock(td); + + PICKUP_GIANT(); +} + static void ukbd_do_poll(struct ukbd_softc *sc, uint8_t wait) { @@ -396,8 +425,9 @@ ukbd_do_poll(struct ukbd_softc *sc, uint8_t wait) if (kdb_active == 0) { while (sc->sc_inputs == 0) { - /* make sure the USB code gets a chance to run */ - pause("UKBD", 1); + + /* give USB threads a chance to run */ + ukbd_yield(); /* check if we should wait */ if (!wait) From 058e4977469dc77eb8582f580e42322b0287ef6e Mon Sep 17 00:00:00 2001 From: gjb Date: Thu, 14 Jul 2011 02:41:45 +0000 Subject: [PATCH 08/14] Improvements to the shutdown(8) manual. PR: 158807 Submitted by: arundel MFC after: 1 week git-svn-id: svn+ssh://svn.freebsd.org/base/head@223991 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sbin/shutdown/shutdown.8 | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/sbin/shutdown/shutdown.8 b/sbin/shutdown/shutdown.8 index 032c4f3ca2d..c3de61fca88 100644 --- a/sbin/shutdown/shutdown.8 +++ b/sbin/shutdown/shutdown.8 @@ -28,7 +28,7 @@ .\" @(#)shutdown.8 8.2 (Berkeley) 4/27/95 .\" $FreeBSD$ .\" -.Dd December 30, 2010 +.Dd July 13, 2011 .Dt SHUTDOWN 8 .Os .Sh NAME @@ -83,20 +83,20 @@ If one of the .Fl p or .Fl r -is specified, +options are specified, .Nm will execute .Xr halt 8 or .Xr reboot 8 -instead of sending signal to +instead of sending a signal to .Xr init 8 . .It Fl n If the .Fl o -is specified, prevent the file system cache from being flushed by passing +option is specified, prevent the file system cache from being flushed by passing .Fl n -option to +to .Xr halt 8 or .Xr reboot 8 . @@ -106,10 +106,10 @@ This option should probably not be used. is the time at which .Nm will bring the system down and -may be the word +may be the case-insensitive word .Ar now (indicating an immediate shutdown) or -specify a future time in one of two formats: +a future time in one of two formats: .Ar +number , or .Ar yymmddhhmm , @@ -148,7 +148,7 @@ exits. .Pp At shutdown time a message is written to the system log, containing the time of shutdown, the person who initiated the shutdown and the reason. -Corresponding signal is then sent to +The corresponding signal is then sent to .Xr init 8 to respectively halt, reboot or bring the system down to single-user state (depending on the above options). @@ -176,16 +176,18 @@ utility will place the system into single user mode at the .Ar time specified. .Pp -Calling utility as -.Nm poweroff -is equivalent of calling: +Calling +.Dq Nm poweroff +is equivalent to running: .Bd -literal -offset indent shutdown -p now .Ed .Sh FILES .Bl -tag -width /var/run/nologin -compact .It Pa /var/run/nologin -tells login not to let anyone log in +tells +.Xr login 1 +not to let anyone log in .El .Sh COMPATIBILITY The hours and minutes in the second time format may be separated by From 9f3210a2e44d1416ba7c56ddd38e26045c7e3962 Mon Sep 17 00:00:00 2001 From: gjb Date: Thu, 14 Jul 2011 03:08:10 +0000 Subject: [PATCH 09/14] Remove trailing whitespace in the shutdown(8) manual. MFC after: 1 week git-svn-id: svn+ssh://svn.freebsd.org/base/head@223992 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sbin/shutdown/shutdown.8 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sbin/shutdown/shutdown.8 b/sbin/shutdown/shutdown.8 index c3de61fca88..b7067e12fff 100644 --- a/sbin/shutdown/shutdown.8 +++ b/sbin/shutdown/shutdown.8 @@ -170,9 +170,9 @@ file that .Nm created will be removed automatically. .Pp -When run without options, the +When run without options, the .Nm -utility will place the system into single user mode at the +utility will place the system into single user mode at the .Ar time specified. .Pp From e9011e4168a2c565e9bedf5ef44d277396e62b0b Mon Sep 17 00:00:00 2001 From: adrian Date: Thu, 14 Jul 2011 05:19:28 +0000 Subject: [PATCH 10/14] Japan regulatory domain update #1 - sync with CRDA entries. Specifics: * add 4920MHz-4980MHz for 11a and 11n/HT20 * add 5040MHz-5080MHz for 11a and 11n/HT20 * add 5500MHz-5700MHz for 11a and 11n/HT20 (DFS needed) * add 5500MHz-5680MHz for 11n/HT40 (DFS needed) TODO: * add correct HT40 bands for 4920-4980 and 5040-5080 For the curious: There's been many revisions to the Japan regulatory rules. Apparently, the requirements require old cards certified on a previous version of the rules to obey the older rules, not the newer rules. The regdomain.xml outlines the -current- restrictions. The card driver (eg the ath_hal regulatory domain code) may include previous revisions of the Japan rules. The ath_hal regdomain code populates the initial channel list based on what the EEPROM indicates is possible. The regdomain.xml database imposes further restrictions on this. So regdomain.xml only needs to have the -current- rules. If the card was certified on an earlier set of JP rules, it may only support a subset of those channels - these are calculated at device attach and this restricted list is kicked to net80211. regdomain.xml operates on -this- list of channels. And thus, the correct regulatory behaviour for Japan is handled with only one regdomain.xml Japan database entry. (phew.) Obtained from: Linux wireless-regdb git-svn-id: svn+ssh://svn.freebsd.org/base/head@223996 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- etc/regdomain.xml | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/etc/regdomain.xml b/etc/regdomain.xml index 9b406055f5a..f47b9178140 100644 --- a/etc/regdomain.xml +++ b/etc/regdomain.xml @@ -323,6 +323,14 @@ + + + 23 + + + + 23 + 23 @@ -333,6 +341,12 @@ IEEE80211_CHAN_PASSIVE IEEE80211_CHAN_DFS + + + 23 + IEEE80211_CHAN_PASSIVE + IEEE80211_CHAN_DFS + @@ -349,6 +363,16 @@ + + + 23 + IEEE80211_CHAN_HT20 + + + + 23 + IEEE80211_CHAN_HT20 + 23 @@ -373,6 +397,20 @@ IEEE80211_CHAN_PASSIVE IEEE80211_CHAN_DFS + + + 23 + IEEE80211_CHAN_HT20 + IEEE80211_CHAN_PASSIVE + IEEE80211_CHAN_DFS + + + + 23 + IEEE80211_CHAN_HT40 + IEEE80211_CHAN_PASSIVE + IEEE80211_CHAN_DFS + @@ -1624,11 +1662,21 @@ IEEE80211_CHAN_A IEEE80211_CHAN_HALF + + 4920 4980 + 20 5 + IEEE80211_CHAN_A + 4950 4980 20 5 IEEE80211_CHAN_A + + 5040 5080 + 20 20 + IEEE80211_CHAN_A + 5120 5240 20 20 From 0bbb7d8cc40c84cd7364f437e8da9363daac3344 Mon Sep 17 00:00:00 2001 From: adrian Date: Thu, 14 Jul 2011 05:49:35 +0000 Subject: [PATCH 11/14] More Japan regulatory domain fixes: * Add HT40 entries for the two new Japan bands * Fix a channel separation bug in one of the new bands I introduced in a previous commit. git-svn-id: svn+ssh://svn.freebsd.org/base/head@223998 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- etc/regdomain.xml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/etc/regdomain.xml b/etc/regdomain.xml index f47b9178140..ff5711392c4 100644 --- a/etc/regdomain.xml +++ b/etc/regdomain.xml @@ -368,11 +368,21 @@ 23 IEEE80211_CHAN_HT20 + + + 23 + IEEE80211_CHAN_HT40 + 23 IEEE80211_CHAN_HT20 + + + 23 + IEEE80211_CHAN_HT40 + 23 @@ -1664,7 +1674,12 @@ 4920 4980 - 20 5 + 20 20 + IEEE80211_CHAN_A + + + 4920 4980 + 40 20 IEEE80211_CHAN_A @@ -1677,6 +1692,11 @@ 20 20 IEEE80211_CHAN_A + + 5040 5080 + 40 20 + IEEE80211_CHAN_A + 5120 5240 20 20 From ff03ec508fd4729eb1f3347383887261a9b805c7 Mon Sep 17 00:00:00 2001 From: delphij Date: Thu, 14 Jul 2011 07:28:49 +0000 Subject: [PATCH 12/14] Use prototype. While I'm there, add a pair of parenthesis to mark an if statment's border. MFC after: 1 month git-svn-id: svn+ssh://svn.freebsd.org/base/head@224001 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- usr.sbin/rpcbind/rpcb_stat.c | 2 +- usr.sbin/rpcbind/rpcb_svc_com.c | 2 +- usr.sbin/rpcbind/rpcbind.c | 5 +++-- usr.sbin/rpcbind/util.c | 2 +- usr.sbin/rpcbind/warmstart.c | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/usr.sbin/rpcbind/rpcb_stat.c b/usr.sbin/rpcbind/rpcb_stat.c index b10ed508b0b..30617545f7b 100644 --- a/usr.sbin/rpcbind/rpcb_stat.c +++ b/usr.sbin/rpcbind/rpcb_stat.c @@ -54,7 +54,7 @@ static rpcb_stat_byvers inf; void -rpcbs_init() +rpcbs_init(void) { } diff --git a/usr.sbin/rpcbind/rpcb_svc_com.c b/usr.sbin/rpcbind/rpcb_svc_com.c index 79cb93751f5..f90dc5964b5 100644 --- a/usr.sbin/rpcbind/rpcb_svc_com.c +++ b/usr.sbin/rpcbind/rpcb_svc_com.c @@ -1076,7 +1076,7 @@ netbuffree(struct netbuf *ap) extern bool_t __svc_clean_idle(fd_set *, int, bool_t); void -my_svc_run() +my_svc_run(void) { size_t nfds; struct pollfd pollfds[FD_SETSIZE]; diff --git a/usr.sbin/rpcbind/rpcbind.c b/usr.sbin/rpcbind/rpcbind.c index 5a76a68f1f3..dff0b08993c 100644 --- a/usr.sbin/rpcbind/rpcbind.c +++ b/usr.sbin/rpcbind/rpcbind.c @@ -178,12 +178,13 @@ main(int argc, char *argv[]) init_transport(nconf); while ((nconf = getnetconfig(nc_handle))) { - if (nconf->nc_flag & NC_VISIBLE) + if (nconf->nc_flag & NC_VISIBLE) { if (ipv6_only == 1 && strcmp(nconf->nc_protofmly, "inet") == 0) { /* DO NOTHING */ } else init_transport(nconf); + } } endnetconfig(nc_handle); @@ -766,7 +767,7 @@ terminate(int dummy __unused) } void -rpcbind_abort() +rpcbind_abort(void) { #ifdef WARMSTART write_warmstart(); /* Dump yourself */ diff --git a/usr.sbin/rpcbind/util.c b/usr.sbin/rpcbind/util.c index 6c41253d2ec..16e6f700266 100644 --- a/usr.sbin/rpcbind/util.c +++ b/usr.sbin/rpcbind/util.c @@ -283,7 +283,7 @@ addrmerge(struct netbuf *caller, char *serv_uaddr, char *clnt_uaddr, } void -network_init() +network_init(void) { #ifdef INET6 struct ifaddrs *ifap, *ifp; diff --git a/usr.sbin/rpcbind/warmstart.c b/usr.sbin/rpcbind/warmstart.c index 410f270820f..fc0956f574f 100644 --- a/usr.sbin/rpcbind/warmstart.c +++ b/usr.sbin/rpcbind/warmstart.c @@ -142,7 +142,7 @@ error: fprintf(stderr, "rpcbind: will start from scratch\n"); } void -write_warmstart() +write_warmstart(void) { (void) write_struct(RPCBFILE, (xdrproc_t)xdr_rpcblist_ptr, &list_rbl); #ifdef PORTMAP @@ -152,7 +152,7 @@ write_warmstart() } void -read_warmstart() +read_warmstart(void) { rpcblist_ptr tmp_rpcbl = NULL; #ifdef PORTMAP From 742d9e3968042a50692bc4a1dcf5915bc17a25e0 Mon Sep 17 00:00:00 2001 From: delphij Date: Thu, 14 Jul 2011 07:33:53 +0000 Subject: [PATCH 13/14] Add a new option, -N to disable the default and recommended syslogd(8) behavior, which binds to the well known UDP port. This option implies -s. MFC after: 2 months git-svn-id: svn+ssh://svn.freebsd.org/base/head@224002 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- usr.sbin/syslogd/syslogd.8 | 9 ++++++++- usr.sbin/syslogd/syslogd.c | 30 +++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/usr.sbin/syslogd/syslogd.8 b/usr.sbin/syslogd/syslogd.8 index ff0141daa08..23ba6d0542c 100644 --- a/usr.sbin/syslogd/syslogd.8 +++ b/usr.sbin/syslogd/syslogd.8 @@ -36,7 +36,7 @@ .Nd log systems messages .Sh SYNOPSIS .Nm -.Op Fl 468ACcdknosuv +.Op Fl 468ACcdkNnosuv .Op Fl a Ar allowed_peer .Op Fl b Ar bind_address .Op Fl f Ar config_file @@ -227,6 +227,13 @@ facility is reserved for messages read directly from Select the number of minutes between .Dq mark messages; the default is 20 minutes. +.It Fl N +Disable binding on UDP sockets. RFC 3164 recommends that outgoing +syslogd messages should originate from the privileged port, this +option +.Em disables +the recommended behavior. This option inherits +.Fl s . .It Fl n Disable dns query for every request. .It Fl o diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 045da5b8159..d1c9fd16e28 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -278,6 +278,7 @@ static int fklog = -1; /* /dev/klog */ static int Initialized; /* set when we have initialized ourselves */ static int MarkInterval = 20 * 60; /* interval between marks in seconds */ static int MarkSeq; /* mark sequence number */ +static int NoBind; /* don't bind() as suggested by RFC 3164 */ static int SecureMode; /* when true, receive only unix domain socks */ #ifdef INET6 static int family = PF_UNSPEC; /* protocol family (IPv4, IPv6 or both) */ @@ -358,7 +359,7 @@ main(int argc, char *argv[]) dprintf("madvise() failed: %s\n", strerror(errno)); bindhostname = NULL; - while ((ch = getopt(argc, argv, "468Aa:b:cCdf:kl:m:nop:P:sS:Tuv")) + while ((ch = getopt(argc, argv, "468Aa:b:cCdf:kl:m:nNop:P:sS:Tuv")) != -1) switch (ch) { case '4': @@ -437,6 +438,10 @@ main(int argc, char *argv[]) case 'm': /* mark interval */ MarkInterval = atoi(optarg) * 60; break; + case 'N': + NoBind = 1; + SecureMode = 1; + break; case 'n': resolve = 0; break; @@ -2685,13 +2690,24 @@ socksetup(int af, char *bindhostname) close(*s); continue; } - if (bind(*s, r->ai_addr, r->ai_addrlen) < 0) { - close(*s); - logerror("bind"); - continue; - } + /* + * RFC 3164 recommends that client side message + * should come from the privileged syslogd port. + * + * If the system administrator choose not to obey + * this, we can skip the bind() step so that the + * system will choose a port for us. + */ + if (!NoBind) { + if (bind(*s, r->ai_addr, r->ai_addrlen) < 0) { + close(*s); + logerror("bind"); + continue; + } - double_rbuf(*s); + if (!SecureMode) + double_rbuf(*s); + } (*socks)++; s++; From 45e6686de1b5e6fd61e457dfa7c4b8b0a04e84a1 Mon Sep 17 00:00:00 2001 From: delphij Date: Thu, 14 Jul 2011 07:35:28 +0000 Subject: [PATCH 14/14] Use calloc() instead of an explicit memset. MFC after: 2 weeks git-svn-id: svn+ssh://svn.freebsd.org/base/head@224003 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- usr.sbin/mountd/mountd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c index 01a27eb0d08..a1e83c35082 100644 --- a/usr.sbin/mountd/mountd.c +++ b/usr.sbin/mountd/mountd.c @@ -1789,10 +1789,9 @@ get_exp(void) { struct exportlist *ep; - ep = (struct exportlist *)malloc(sizeof (struct exportlist)); + ep = (struct exportlist *)calloc(1, sizeof (struct exportlist)); if (ep == (struct exportlist *)NULL) out_of_mem(); - memset(ep, 0, sizeof(struct exportlist)); return (ep); } @@ -1804,10 +1803,9 @@ get_grp(void) { struct grouplist *gp; - gp = (struct grouplist *)malloc(sizeof (struct grouplist)); + gp = (struct grouplist *)calloc(1, sizeof (struct grouplist)); if (gp == (struct grouplist *)NULL) out_of_mem(); - memset(gp, 0, sizeof(struct grouplist)); return (gp); }