From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 00:03:14 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 51724D17; Sun, 24 Mar 2013 00:03:14 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 426EF1B6; Sun, 24 Mar 2013 00:03:14 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2O03EKo038178; Sun, 24 Mar 2013 00:03:14 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2O03CE9038168; Sun, 24 Mar 2013 00:03:12 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201303240003.r2O03CE9038168@svn.freebsd.org> From: Adrian Chadd Date: Sun, 24 Mar 2013 00:03:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248671 - head/sys/dev/ath X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 00:03:14 -0000 Author: adrian Date: Sun Mar 24 00:03:12 2013 New Revision: 248671 URL: http://svnweb.freebsd.org/changeset/base/248671 Log: Overhaul the TXQ locking (again!) as part of some beacon/cabq timing related issues. Moving the TX locking under one lock made things easier to progress on but it had one important side-effect - it increased the latency when handling CABQ setup when sending beacons. This commit introduces a bunch of new changes and a few unrelated changs that are just easier to lump in here. The aim is to have the CABQ locking separate from other locking. The CABQ transmit path in the beacon process thus doesn't have to grab the general TX lock, reducing lock contention/latency and making it more likely that we'll make the beacon TX timing. The second half of this commit is the CABQ related setup changes needed for sane looking EDMA CABQ support. Right now the EDMA TX code naively assumes that only one frame (MPDU or A-MPDU) is being pushed into each FIFO slot. For the CABQ this isn't true - a whole list of frames is being pushed in - and thus CABQ handling breaks very quickly. The aim here is to setup the CABQ list and then push _that list_ to the hardware for transmission. I can then extend the EDMA TX code to stamp that list as being "one" FIFO entry (likely by tagging the last buffer in that list as "FIFO END") so the EDMA TX completion code correctly tracks things. Major: * Migrate the per-TXQ add/removal locking back to per-TXQ, rather than a single lock. * Leave the software queue side of things under the ATH_TX_LOCK lock, (continuing) to serialise things as they are. * Add a new function which is called whenever there's a beacon miss, to print out some debugging. This is primarily designed to help me figure out if the beacon miss events are due to a noisy environment, issues with the PHY/MAC, or other. * Move the CABQ setup/enable to occur _after_ all the VAPs have been looked at. This means that for multiple VAPS in bursted mode, the CABQ gets primed once all VAPs are checked, rather than being primed on the first VAP and then having frames appended after this. Minor: * Add a (disabled) twiddle to let me enable/disable cabq traffic. It's primarily there to let me easily debug what's going on with beacon and CABQ setup/traffic; there's some DMA engine hangs which I'm finally trying to trace down. * Clear bf_next when flushing frames; it should quieten some warnings that show up when a node goes away. Tested: * AR9280, STA/hostap, up to 4 vaps (staggered) * AR5416, STA/hostap, up to 4 vaps (staggered) TODO: * (Lots) more AR9380 and later testing, as I may have missed something here. * Leverage this to fix CABQ hanling for AR9380 and later chips. * Force bursted beaconing on the chips that default to staggered beacons and ensure the CABQ stuff is all sane (eg, the MORE bits that aren't being correctly set when chaining descriptors.) Modified: head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_ath_beacon.c head/sys/dev/ath/if_ath_beacon.h head/sys/dev/ath/if_ath_misc.h head/sys/dev/ath/if_ath_sysctl.c head/sys/dev/ath/if_ath_tdma.c head/sys/dev/ath/if_ath_tx.c head/sys/dev/ath/if_ath_tx_edma.c head/sys/dev/ath/if_athvar.h Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Sat Mar 23 23:51:11 2013 (r248670) +++ head/sys/dev/ath/if_ath.c Sun Mar 24 00:03:12 2013 (r248671) @@ -694,6 +694,9 @@ ath_attach(u_int16_t devid, struct ath_s */ sc->sc_txq_mcastq_maxdepth = ath_txbuf; + /* Enable CABQ by default */ + sc->sc_cabq_enable = 1; + /* * Allow the TX and RX chainmasks to be overridden by * environment variables and/or device.hints. @@ -1899,7 +1902,7 @@ ath_bmiss_vap(struct ieee80211vap *vap) ATH_VAP(vap)->av_bmiss(vap); } -static int +int ath_hal_gethangstate(struct ath_hal *ah, uint32_t mask, uint32_t *hangs) { uint32_t rsize; @@ -2364,14 +2367,17 @@ ath_reset(struct ifnet *ifp, ATH_RESET_T /* Restart TX completion and pending TX */ if (reset_type == ATH_RESET_NOLOSS) { - ATH_TX_LOCK(sc); for (i = 0; i < HAL_NUM_TX_QUEUES; i++) { if (ATH_TXQ_SETUP(sc, i)) { + ATH_TXQ_LOCK(&sc->sc_txq[i]); ath_txq_restart_dma(sc, &sc->sc_txq[i]); + ATH_TXQ_UNLOCK(&sc->sc_txq[i]); + + ATH_TX_LOCK(sc); ath_txq_sched(sc, &sc->sc_txq[i]); + ATH_TX_UNLOCK(sc); } } - ATH_TX_UNLOCK(sc); } /* @@ -2922,6 +2928,9 @@ void ath_txqmove(struct ath_txq *dst, struct ath_txq *src) { + ATH_TXQ_LOCK_ASSERT(src); + ATH_TXQ_LOCK_ASSERT(dst); + TAILQ_CONCAT(&dst->axq_q, &src->axq_q, bf_list); dst->axq_link = src->axq_link; src->axq_link = NULL; @@ -3401,6 +3410,7 @@ ath_txq_init(struct ath_softc *sc, struc txq->axq_softc = sc; TAILQ_INIT(&txq->axq_q); TAILQ_INIT(&txq->axq_tidq); + ATH_TXQ_LOCK_INIT(sc, txq); } /* @@ -3585,6 +3595,7 @@ ath_tx_cleanupq(struct ath_softc *sc, st ath_hal_releasetxqueue(sc->sc_ah, txq->axq_qnum); sc->sc_txqsetup &= ~(1<axq_qnum); + ATH_TXQ_LOCK_DESTROY(txq); } /* @@ -3837,11 +3848,11 @@ ath_tx_processq(struct ath_softc *sc, st nacked = 0; for (;;) { - ATH_TX_LOCK(sc); + ATH_TXQ_LOCK(txq); txq->axq_intrcnt = 0; /* reset periodic desc intr count */ bf = TAILQ_FIRST(&txq->axq_q); if (bf == NULL) { - ATH_TX_UNLOCK(sc); + ATH_TXQ_UNLOCK(txq); break; } ds = bf->bf_lastds; /* XXX must be setup correctly! */ @@ -3869,7 +3880,7 @@ ath_tx_processq(struct ath_softc *sc, st ATH_KTR(sc, ATH_KTR_TXCOMP, 3, "ath_tx_processq: txq=%u, bf=%p ds=%p, HAL_EINPROGRESS", txq->axq_qnum, bf, ds); - ATH_TX_UNLOCK(sc); + ATH_TXQ_UNLOCK(txq); break; } ATH_TXQ_REMOVE(txq, bf, bf_list); @@ -3906,7 +3917,7 @@ ath_tx_processq(struct ath_softc *sc, st ATH_RSSI_LPF(sc->sc_halstats.ns_avgtxrssi, ts->ts_rssi); } - ATH_TX_UNLOCK(sc); + ATH_TXQ_UNLOCK(txq); /* * Update statistics and call completion @@ -4286,7 +4297,7 @@ ath_tx_draintxq(struct ath_softc *sc, st * we do not need to block ath_tx_proc */ for (ix = 0;; ix++) { - ATH_TX_LOCK(sc); + ATH_TXQ_LOCK(txq); bf = TAILQ_FIRST(&txq->axq_q); if (bf == NULL) { txq->axq_link = NULL; @@ -4301,7 +4312,7 @@ ath_tx_draintxq(struct ath_softc *sc, st * very fruity very quickly. */ txq->axq_fifo_depth = 0; - ATH_TX_UNLOCK(sc); + ATH_TXQ_UNLOCK(txq); break; } ATH_TXQ_REMOVE(txq, bf, bf_list); @@ -4337,7 +4348,7 @@ ath_tx_draintxq(struct ath_softc *sc, st * Clear ATH_BUF_BUSY; the completion handler * will free the buffer. */ - ATH_TX_UNLOCK(sc); + ATH_TXQ_UNLOCK(txq); bf->bf_flags &= ~ATH_BUF_BUSY; if (bf->bf_comp) bf->bf_comp(sc, bf, 1); Modified: head/sys/dev/ath/if_ath_beacon.c ============================================================================== --- head/sys/dev/ath/if_ath_beacon.c Sat Mar 23 23:51:11 2013 (r248670) +++ head/sys/dev/ath/if_ath_beacon.c Sun Mar 24 00:03:12 2013 (r248671) @@ -379,6 +379,39 @@ ath_beacon_update(struct ieee80211vap *v } /* + * Handle a beacon miss. + */ +static void +ath_beacon_miss(struct ath_softc *sc) +{ + HAL_SURVEY_SAMPLE hs; + HAL_BOOL ret; + uint32_t hangs; + + bzero(&hs, sizeof(hs)); + + ret = ath_hal_get_mib_cycle_counts(sc->sc_ah, &hs); + + if (ath_hal_gethangstate(sc->sc_ah, 0xffff, &hangs) && hangs != 0) { + DPRINTF(sc, ATH_DEBUG_BEACON, + "%s: hang=0x%08x\n", + __func__, + hangs); + } + + DPRINTF(sc, ATH_DEBUG_BEACON, + "%s: valid=%d, txbusy=%u, rxbusy=%u, chanbusy=%u, " + "extchanbusy=%u, cyclecount=%u\n", + __func__, + ret, + hs.tx_busy, + hs.rx_busy, + hs.chan_busy, + hs.ext_chan_busy, + hs.cycle_count); +} + +/* * Transmit a beacon frame at SWBA. Dynamic updates to the * frame contents are done as needed and the slot time is * also adjusted based on current state. @@ -405,6 +438,7 @@ ath_beacon_proc(void *arg, int pending) if (ath_hal_numtxpending(ah, sc->sc_bhalq) != 0) { sc->sc_bmisscount++; sc->sc_stats.ast_be_missed++; + ath_beacon_miss(sc); DPRINTF(sc, ATH_DEBUG_BEACON, "%s: missed %u consecutive beacons\n", __func__, sc->sc_bmisscount); @@ -478,6 +512,12 @@ ath_beacon_proc(void *arg, int pending) sc->sc_ant_tx[1] = sc->sc_ant_tx[2] = 0; } + /* Program the CABQ with the contents of the CABQ txq and start it */ + ATH_TXQ_LOCK(sc->sc_cabq); + ath_beacon_cabq_start(sc); + ATH_TXQ_UNLOCK(sc->sc_cabq); + + /* Program the new beacon frame if we have one for this interval */ if (bfaddr != 0) { /* * Stop any current dma and put the new frame on the queue. @@ -500,6 +540,33 @@ ath_beacon_proc(void *arg, int pending) } } +/* + * Start CABQ transmission - this assumes that all frames are prepped + * and ready in the CABQ. + * + * XXX TODO: methodize this; for the EDMA case it should only push + * into the hardware if the FIFO isn't full _AND_ then it should + * tag the final buffer in the queue as ATH_BUF_FIFOEND so the FIFO + * depth is correctly accounted for. + */ +void +ath_beacon_cabq_start(struct ath_softc *sc) +{ + struct ath_buf *bf; + struct ath_txq *cabq = sc->sc_cabq; + + ATH_TXQ_LOCK_ASSERT(cabq); + if (TAILQ_EMPTY(&cabq->axq_q)) + return; + bf = TAILQ_FIRST(&cabq->axq_q); + + /* Push the first entry into the hardware */ + ath_hal_puttxbuf(sc->sc_ah, cabq->axq_qnum, bf->bf_daddr); + + /* NB: gated by beacon so safe to start here */ + ath_hal_txstart(sc->sc_ah, cabq->axq_qnum); +} + struct ath_buf * ath_beacon_generate(struct ath_softc *sc, struct ieee80211vap *vap) { @@ -561,38 +628,43 @@ ath_beacon_generate(struct ath_softc *sc * insure cab frames are triggered by this beacon. */ if (avp->av_boff.bo_tim[4] & 1) { - struct ath_hal *ah = sc->sc_ah; /* NB: only at DTIM */ - ATH_TX_LOCK(sc); + ATH_TXQ_LOCK(&avp->av_mcastq); if (nmcastq) { struct ath_buf *bfm; /* * Move frames from the s/w mcast q to the h/w cab q. - * XXX TODO: walk the list, update MORE_DATA bit - * XXX TODO: or maybe, set the MORE data bit in the - * TX descriptor(s) here? * - * XXX TODO: we're still pushing a CABQ frame list to - * AR9380 hosts; but we don't (yet) populate - * the ATH_BUF_BUSY flag in the EDMA - * completion task (for CABQ, though!) + * XXX TODO: This should be methodized - the EDMA + * CABQ setup code may look different! + * + * XXX TODO: if we chain together multiple VAPs + * worth of CABQ traffic, should we keep the + * MORE data bit set on the last frame of each + * intermediary VAP (ie, only clear the MORE + * bit of the last frame on the last vap?) + * + * XXX TODO: once we append this, what happens + * to cabq->axq_link? It'll point at the avp + * mcastq link pointer, so things should be OK. + * Just double-check this is what actually happens. */ bfm = TAILQ_FIRST(&avp->av_mcastq.axq_q); - if (cabq->axq_link != NULL) { + ATH_TXQ_LOCK(cabq); + if (cabq->axq_link != NULL) *cabq->axq_link = bfm->bf_daddr; - } else - ath_hal_puttxbuf(ah, cabq->axq_qnum, - bfm->bf_daddr); ath_txqmove(cabq, &avp->av_mcastq); - + ATH_TXQ_UNLOCK(cabq); + /* + * XXX not entirely accurate, in case a mcast + * queue frame arrived before we grabbed the TX + * lock. + */ sc->sc_stats.ast_cabq_xmit += nmcastq; } - /* NB: gated by beacon so safe to start here */ - if (! TAILQ_EMPTY(&(cabq->axq_q))) - ath_hal_txstart(ah, cabq->axq_qnum); - ATH_TX_UNLOCK(sc); + ATH_TXQ_UNLOCK(&avp->av_mcastq); } return bf; } Modified: head/sys/dev/ath/if_ath_beacon.h ============================================================================== --- head/sys/dev/ath/if_ath_beacon.h Sat Mar 23 23:51:11 2013 (r248670) +++ head/sys/dev/ath/if_ath_beacon.h Sun Mar 24 00:03:12 2013 (r248671) @@ -39,6 +39,7 @@ extern void ath_beacon_config(struct ath struct ieee80211vap *vap); extern struct ath_buf * ath_beacon_generate(struct ath_softc *sc, struct ieee80211vap *vap); +extern void ath_beacon_cabq_start(struct ath_softc *sc); extern int ath_wme_update(struct ieee80211com *ic); extern void ath_beacon_update(struct ieee80211vap *vap, int item); extern void ath_beacon_start_adhoc(struct ath_softc *sc, Modified: head/sys/dev/ath/if_ath_misc.h ============================================================================== --- head/sys/dev/ath/if_ath_misc.h Sat Mar 23 23:51:11 2013 (r248670) +++ head/sys/dev/ath/if_ath_misc.h Sun Mar 24 00:03:12 2013 (r248671) @@ -72,6 +72,9 @@ extern void ath_tx_update_ratectrl(struc struct ieee80211_node *ni, struct ath_rc_series *rc, struct ath_tx_status *ts, int frmlen, int nframes, int nbad); +extern int ath_hal_gethangstate(struct ath_hal *ah, uint32_t mask, + uint32_t *hangs); + extern void ath_tx_freebuf(struct ath_softc *sc, struct ath_buf *bf, int status); Modified: head/sys/dev/ath/if_ath_sysctl.c ============================================================================== --- head/sys/dev/ath/if_ath_sysctl.c Sat Mar 23 23:51:11 2013 (r248670) +++ head/sys/dev/ath/if_ath_sysctl.c Sun Mar 24 00:03:12 2013 (r248671) @@ -754,6 +754,13 @@ ath_sysctlattach(struct ath_softc *sc) &sc->sc_txq_mcastq_maxdepth, 0, "Maximum buffer depth for multicast/broadcast frames"); +#if 0 + SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "cabq_enable", CTLFLAG_RW, + &sc->sc_cabq_enable, 0, + "Whether to transmit on the CABQ or not"); +#endif + #ifdef IEEE80211_SUPPORT_TDMA if (ath_hal_macversion(ah) > 0x78) { sc->sc_tdmadbaprep = 2; Modified: head/sys/dev/ath/if_ath_tdma.c ============================================================================== --- head/sys/dev/ath/if_ath_tdma.c Sat Mar 23 23:51:11 2013 (r248670) +++ head/sys/dev/ath/if_ath_tdma.c Sun Mar 24 00:03:12 2013 (r248671) @@ -612,13 +612,19 @@ ath_tdma_beacon_send(struct ath_softc *s } bf = ath_beacon_generate(sc, vap); + /* XXX We don't do cabq traffic, but just for completeness .. */ + ATH_TXQ_LOCK(sc->sc_cabq); + ath_beacon_cabq_start(sc); + ATH_TXQ_UNLOCK(sc->sc_cabq); + if (bf != NULL) { /* * Stop any current dma and put the new frame on the queue. * This should never fail since we check above that no frames * are still pending on the queue. */ - if (!ath_hal_stoptxdma(ah, sc->sc_bhalq)) { + if ((! sc->sc_isedma) && + (! ath_hal_stoptxdma(ah, sc->sc_bhalq))) { DPRINTF(sc, ATH_DEBUG_ANY, "%s: beacon queue %u did not stop?\n", __func__, sc->sc_bhalq); Modified: head/sys/dev/ath/if_ath_tx.c ============================================================================== --- head/sys/dev/ath/if_ath_tx.c Sat Mar 23 23:51:11 2013 (r248670) +++ head/sys/dev/ath/if_ath_tx.c Sun Mar 24 00:03:12 2013 (r248671) @@ -715,8 +715,10 @@ ath_tx_handoff_mcast(struct ath_softc *s /* link descriptor */ *txq->axq_link = bf->bf_daddr; } + ATH_TXQ_LOCK(txq); ATH_TXQ_INSERT_TAIL(txq, bf, bf_list); ath_hal_gettxdesclinkptr(sc->sc_ah, bf->bf_lastds, &txq->axq_link); + ATH_TXQ_UNLOCK(txq); } /* @@ -774,6 +776,7 @@ ath_tx_handoff_hw(struct ath_softc *sc, /* For now, so not to generate whitespace diffs */ if (1) { + ATH_TXQ_LOCK(txq); #ifdef IEEE80211_SUPPORT_TDMA int qbusy; @@ -899,6 +902,7 @@ ath_tx_handoff_hw(struct ath_softc *sc, txq->axq_aggr_depth++; ath_hal_gettxdesclinkptr(ah, bf->bf_lastds, &txq->axq_link); ath_hal_txstart(ah, txq->axq_qnum); + ATH_TXQ_UNLOCK(txq); ATH_KTR(sc, ATH_KTR_TX, 1, "ath_tx_handoff: txq=%u, txstart", txq->axq_qnum); } @@ -915,8 +919,7 @@ ath_legacy_tx_dma_restart(struct ath_sof struct ath_hal *ah = sc->sc_ah; struct ath_buf *bf, *bf_last; - ATH_TX_LOCK_ASSERT(sc); - + ATH_TXQ_LOCK_ASSERT(txq); /* This is always going to be cleared, empty or not */ txq->axq_flags &= ~ATH_TXQ_PUTPENDING; @@ -1834,6 +1837,7 @@ ath_tx_start(struct ath_softc *sc, struc bf->bf_state.bfs_tx_queue = txq->axq_qnum; bf->bf_state.bfs_pri = pri; +#if 1 /* * When servicing one or more stations in power-save mode * (or) if there is some mcast data waiting on the mcast @@ -1842,7 +1846,7 @@ ath_tx_start(struct ath_softc *sc, struc * * TODO: we should lock the mcastq before we check the length. */ - if (ismcast && (vap->iv_ps_sta || avp->av_mcastq.axq_depth)) { + if (sc->sc_cabq_enable && ismcast && (vap->iv_ps_sta || avp->av_mcastq.axq_depth)) { txq = &avp->av_mcastq; /* * Mark the frame as eventually belonging on the CAB @@ -1851,6 +1855,7 @@ ath_tx_start(struct ath_softc *sc, struc */ bf->bf_state.bfs_tx_queue = sc->sc_cabq->axq_qnum; } +#endif /* Do the generic frame setup */ /* XXX should just bzero the bf_state? */ @@ -3380,6 +3385,11 @@ ath_tx_tid_drain_pkt(struct ath_softc *s __func__, SEQNO(bf->bf_state.bfs_seqno)); #endif } + + /* Strip it out of an aggregate list if it was in one */ + bf->bf_next = NULL; + + /* Insert on the free queue to be freed by the caller */ TAILQ_INSERT_TAIL(bf_cq, bf, bf_list); } Modified: head/sys/dev/ath/if_ath_tx_edma.c ============================================================================== --- head/sys/dev/ath/if_ath_tx_edma.c Sat Mar 23 23:51:11 2013 (r248670) +++ head/sys/dev/ath/if_ath_tx_edma.c Sun Mar 24 00:03:12 2013 (r248671) @@ -142,7 +142,7 @@ ath_edma_tx_fifo_fill(struct ath_softc * struct ath_buf *bf; int i = 0; - ATH_TX_LOCK_ASSERT(sc); + ATH_TXQ_LOCK_ASSERT(txq); DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: called\n", __func__); @@ -181,9 +181,8 @@ ath_edma_dma_restart(struct ath_softc *s txq, txq->axq_qnum); - ATH_TX_LOCK_ASSERT(sc); + ATH_TXQ_LOCK_ASSERT(txq); ath_edma_tx_fifo_fill(sc, txq); - } /* @@ -204,7 +203,7 @@ ath_edma_xmit_handoff_hw(struct ath_soft { struct ath_hal *ah = sc->sc_ah; - ATH_TX_LOCK_ASSERT(sc); + ATH_TXQ_LOCK_ASSERT(txq); KASSERT((bf->bf_flags & ATH_BUF_BUSY) == 0, ("%s: busy status 0x%x", __func__, bf->bf_flags)); @@ -249,7 +248,7 @@ ath_edma_xmit_handoff_mcast(struct ath_s struct ath_buf *bf) { - ATH_TX_LOCK_ASSERT(sc); + ATH_TXQ_LOCK_ASSERT(txq); KASSERT((bf->bf_flags & ATH_BUF_BUSY) == 0, ("%s: busy status 0x%x", __func__, bf->bf_flags)); @@ -303,8 +302,6 @@ ath_edma_xmit_handoff(struct ath_softc * struct ath_buf *bf) { - ATH_TX_LOCK_ASSERT(sc); - DPRINTF(sc, ATH_DEBUG_XMIT_DESC, "%s: called; bf=%p, txq=%p, qnum=%d\n", __func__, @@ -526,7 +523,7 @@ ath_edma_tx_processq(struct ath_softc *s txq = &sc->sc_txq[ts.ts_queue_id]; - ATH_TX_LOCK(sc); + ATH_TXQ_LOCK(txq); bf = TAILQ_FIRST(&txq->axq_q); DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: qcuid=%d, bf=%p\n", @@ -554,7 +551,7 @@ ath_edma_tx_processq(struct ath_softc *s txq->axq_aggr_depth--; txq->axq_fifo_depth --; /* XXX assert FIFO depth >= 0 */ - ATH_TX_UNLOCK(sc); + ATH_TXQ_UNLOCK(txq); /* * First we need to make sure ts_rate is valid. @@ -636,11 +633,11 @@ ath_edma_tx_processq(struct ath_softc *s * to begin validating that things are somewhat * working. */ - ATH_TX_LOCK(sc); + ATH_TXQ_LOCK(txq); if (dosched && txq->axq_fifo_depth == 0) { ath_edma_tx_fifo_fill(sc, txq); } - ATH_TX_UNLOCK(sc); + ATH_TXQ_UNLOCK(txq); } sc->sc_wd_timer = 0; Modified: head/sys/dev/ath/if_athvar.h ============================================================================== --- head/sys/dev/ath/if_athvar.h Sat Mar 23 23:51:11 2013 (r248670) +++ head/sys/dev/ath/if_athvar.h Sun Mar 24 00:03:12 2013 (r248671) @@ -329,9 +329,11 @@ struct ath_txq { u_int axq_intrcnt; /* interrupt count */ u_int32_t *axq_link; /* link ptr in last TX desc */ TAILQ_HEAD(axq_q_s, ath_buf) axq_q; /* transmit queue */ + struct mtx axq_lock; /* lock on q and link */ + /* * XXX the holdingbf field is protected by the TXBUF lock - * for now, NOT the TX lock. + * for now, NOT the TXQ lock. * * Architecturally, it would likely be better to move * the holdingbf field to a separate array in ath_softc @@ -342,9 +344,24 @@ struct ath_txq { char axq_name[12]; /* e.g. "ath0_txq4" */ /* Per-TID traffic queue for software -> hardware TX */ + /* + * This is protected by the general TX path lock, not (for now) + * by the TXQ lock. + */ TAILQ_HEAD(axq_t_s,ath_tid) axq_tidq; }; +#define ATH_TXQ_LOCK_INIT(_sc, _tq) do { \ + snprintf((_tq)->axq_name, sizeof((_tq)->axq_name), "%s_txq%u", \ + device_get_nameunit((_sc)->sc_dev), (_tq)->axq_qnum); \ + mtx_init(&(_tq)->axq_lock, (_tq)->axq_name, NULL, MTX_DEF); \ + } while (0) +#define ATH_TXQ_LOCK_DESTROY(_tq) mtx_destroy(&(_tq)->axq_lock) +#define ATH_TXQ_LOCK(_tq) mtx_lock(&(_tq)->axq_lock) +#define ATH_TXQ_UNLOCK(_tq) mtx_unlock(&(_tq)->axq_lock) +#define ATH_TXQ_LOCK_ASSERT(_tq) mtx_assert(&(_tq)->axq_lock, MA_OWNED) + + #define ATH_NODE_LOCK(_an) mtx_lock(&(_an)->an_mtx) #define ATH_NODE_UNLOCK(_an) mtx_unlock(&(_an)->an_mtx) #define ATH_NODE_LOCK_ASSERT(_an) mtx_assert(&(_an)->an_mtx, MA_OWNED) @@ -584,6 +601,9 @@ struct ath_softc { sc_rx_stbc : 1, sc_tx_stbc : 1; + + int sc_cabq_enable; /* Enable cabq transmission */ + /* * Enterprise mode configuration for AR9380 and later chipsets. */ From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 01:35:38 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id F24B5C36; Sun, 24 Mar 2013 01:35:37 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E3A925F3; Sun, 24 Mar 2013 01:35:37 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2O1Zbxw065965; Sun, 24 Mar 2013 01:35:37 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2O1Zb95065964; Sun, 24 Mar 2013 01:35:37 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201303240135.r2O1Zb95065964@svn.freebsd.org> From: Dimitry Andric Date: Sun, 24 Mar 2013 01:35:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248672 - head/lib/libc/stdtime X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 01:35:38 -0000 Author: dim Date: Sun Mar 24 01:35:37 2013 New Revision: 248672 URL: http://svnweb.freebsd.org/changeset/base/248672 Log: Compile contrib/tzcode/stdtime/localtime.c with -fwrapv, since it relies on signed integer overflow wrapping. Otherwise mktime(3) and timegm(3) can hang, in case the timestamp passed in struct tm is not representable in a time_t. Specifically, any timestamp after 2038-01-19 03:14:07, in combination with a 32-bit time_t. Note that it would be better to change the code to not rely on undefined behaviour, but it is contributed code, and it is not entirely trivial to fix the issue properly. MFC after: 3 days Modified: head/lib/libc/stdtime/Makefile.inc Modified: head/lib/libc/stdtime/Makefile.inc ============================================================================== --- head/lib/libc/stdtime/Makefile.inc Sun Mar 24 00:03:12 2013 (r248671) +++ head/lib/libc/stdtime/Makefile.inc Sun Mar 24 01:35:37 2013 (r248672) @@ -11,6 +11,9 @@ SYM_MAPS+= ${.CURDIR}/stdtime/Symbol.map CFLAGS+= -I${.CURDIR}/../../contrib/tzcode/stdtime -I${.CURDIR}/stdtime +CFLAGS.localtime.c= -fwrapv +CFLAGS+= ${CFLAGS.${.IMPSRC:T}} + MAN+= ctime.3 strftime.3 strptime.3 time2posix.3 MAN+= tzfile.5 From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 02:04:19 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id AC6BC140; Sun, 24 Mar 2013 02:04:19 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 9DD0069B; Sun, 24 Mar 2013 02:04:19 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2O24Jxv074750; Sun, 24 Mar 2013 02:04:19 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2O24JVS074749; Sun, 24 Mar 2013 02:04:19 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201303240204.r2O24JVS074749@svn.freebsd.org> From: Sean Bruno Date: Sun, 24 Mar 2013 02:04:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248673 - head/sbin/fsck_ffs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 02:04:19 -0000 Author: sbruno Date: Sun Mar 24 02:04:19 2013 New Revision: 248673 URL: http://svnweb.freebsd.org/changeset/base/248673 Log: Minor formatting fix for printf() to fix clang builds. Submitted by: db Reviewed by: gjb Modified: head/sbin/fsck_ffs/fsutil.c Modified: head/sbin/fsck_ffs/fsutil.c ============================================================================== --- head/sbin/fsck_ffs/fsutil.c Sun Mar 24 01:35:37 2013 (r248672) +++ head/sbin/fsck_ffs/fsutil.c Sun Mar 24 02:04:19 2013 (r248673) @@ -507,7 +507,7 @@ static void printIOstats(void) clock_gettime(CLOCK_REALTIME_PRECISE, &finishpass); timespecsub(&finishpass, &startpass); - printf("Running time: %d.%03ld msec\n", + printf("Running time: %ld.%03ld msec\n", finishpass.tv_sec, finishpass.tv_nsec / 1000000); printf("buffer reads by type:\n"); for (totalmsec = 0, i = 0; i < BT_NUMBUFTYPES; i++) @@ -519,7 +519,7 @@ static void printIOstats(void) if (readcnt[i] == 0) continue; msec = readtime[i].tv_sec * 1000 + readtime[i].tv_nsec / 1000000; - printf("%21s:%8ld %2ld.%ld%% %4d.%03ld sec %2jd.%jd%%\n", + printf("%21s:%8ld %2ld.%ld%% %4ld.%03ld sec %2lld.%lld%%\n", buftype[i], readcnt[i], readcnt[i] * 100 / diskreads, (readcnt[i] * 1000 / diskreads) % 10, readtime[i].tv_sec, readtime[i].tv_nsec / 1000000, From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 02:40:50 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 5ED495D9; Sun, 24 Mar 2013 02:40:50 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [IPv6:2001:7b8:3a7:1:2d0:b7ff:fea0:8c26]) by mx1.freebsd.org (Postfix) with ESMTP id 26295783; Sun, 24 Mar 2013 02:40:50 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7::6d96:13f4:4bd2:7ac6] (unknown [IPv6:2001:7b8:3a7:0:6d96:13f4:4bd2:7ac6]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 74F075C5B; Sun, 24 Mar 2013 03:40:45 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) Subject: Re: svn commit: r248672 - head/lib/libc/stdtime From: Dimitry Andric In-Reply-To: <201303240135.r2O1Zb95065964@svn.freebsd.org> Date: Sun, 24 Mar 2013 03:40:33 +0100 Content-Transfer-Encoding: 7bit Message-Id: <40FB115A-AE6E-4BB4-AE47-50C1491F3CE2@FreeBSD.org> References: <201303240135.r2O1Zb95065964@svn.freebsd.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-Mailer: Apple Mail (2.1503) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 02:40:50 -0000 On Mar 24, 2013, at 02:35, Dimitry Andric wrote: > Author: dim > Date: Sun Mar 24 01:35:37 2013 > New Revision: 248672 > URL: http://svnweb.freebsd.org/changeset/base/248672 > > Log: > Compile contrib/tzcode/stdtime/localtime.c with -fwrapv, since it relies > on signed integer overflow wrapping. Otherwise mktime(3) and timegm(3) > can hang, in case the timestamp passed in struct tm is not representable > in a time_t. Specifically, any timestamp after 2038-01-19 03:14:07, in > combination with a 32-bit time_t. I first noticed this when Squid on a i386 machine started to hang every now and then, and started consuming 100% CPU in such cases. After rebuilding Squid with debug info, I found it hung in timegm(3), because some web servers apparently like to pass Last-Modified dates of "Fri, 31 Dec 9999 23:59:59 GMT", most likely to prevent caching. Note this is not an issue on amd64, since time_t is 64-bit there, so even a struct tm with tm_year=INT_MAX would work with mktime(3) and timegm(). From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 03:15:21 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 035A0FB9; Sun, 24 Mar 2013 03:15:21 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E8E56961; Sun, 24 Mar 2013 03:15:20 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2O3FKof097587; Sun, 24 Mar 2013 03:15:20 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2O3FK5A097584; Sun, 24 Mar 2013 03:15:20 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201303240315.r2O3FK5A097584@svn.freebsd.org> From: Alexander Motin Date: Sun, 24 Mar 2013 03:15:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248674 - head/sys/geom X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 03:15:21 -0000 Author: mav Date: Sun Mar 24 03:15:20 2013 New Revision: 248674 URL: http://svnweb.freebsd.org/changeset/base/248674 Log: Make g_wither_washer() to not loop by itself, but only when there was some more topology change done that may require its attention. Add few missing g_do_wither() calls in respective places to signal it. This fixes potential infinite loop here when some provider is withered, but still opened or connected for some reason and so can not be destroyed. For example, see r227009 and r227510. Modified: head/sys/geom/geom_event.c head/sys/geom/geom_int.h head/sys/geom/geom_subr.c Modified: head/sys/geom/geom_event.c ============================================================================== --- head/sys/geom/geom_event.c Sun Mar 24 02:04:19 2013 (r248673) +++ head/sys/geom/geom_event.c Sun Mar 24 03:15:20 2013 (r248674) @@ -273,21 +273,16 @@ one_event(void) void g_run_events() { - int i; for (;;) { g_topology_lock(); while (one_event()) ; mtx_assert(&g_eventlock, MA_OWNED); - i = g_wither_work; - if (i) { + if (g_wither_work) { + g_wither_work = 0; mtx_unlock(&g_eventlock); - while (i) { - i = g_wither_washer(); - g_wither_work = i & 1; - i &= 2; - } + g_wither_washer(); g_topology_unlock(); } else { g_topology_unlock(); Modified: head/sys/geom/geom_int.h ============================================================================== --- head/sys/geom/geom_int.h Sun Mar 24 02:04:19 2013 (r248673) +++ head/sys/geom/geom_int.h Sun Mar 24 03:15:20 2013 (r248674) @@ -65,7 +65,7 @@ void g_do_wither(void); /* geom_subr.c */ extern struct class_list_head g_classes; extern char *g_wait_event, *g_wait_sim, *g_wait_up, *g_wait_down; -int g_wither_washer(void); +void g_wither_washer(void); /* geom_io.c */ void g_io_init(void); Modified: head/sys/geom/geom_subr.c ============================================================================== --- head/sys/geom/geom_subr.c Sun Mar 24 02:04:19 2013 (r248673) +++ head/sys/geom/geom_subr.c Sun Mar 24 03:15:20 2013 (r248674) @@ -437,20 +437,16 @@ g_wither_geom_close(struct g_geom *gp, i /* * This function is called (repeatedly) until we cant wash away more - * withered bits at present. Return value contains two bits. Bit 0 - * set means "withering stuff we can't wash now", bit 1 means "call - * me again, there may be stuff I didn't get the first time around. + * withered bits at present. */ -int +void g_wither_washer() { struct g_class *mp; struct g_geom *gp, *gp2; struct g_provider *pp, *pp2; struct g_consumer *cp, *cp2; - int result; - result = 0; g_topology_assert(); LIST_FOREACH(mp, &g_classes, class) { LIST_FOREACH_SAFE(gp, &mp->geom, geom, gp2) { @@ -459,35 +455,25 @@ g_wither_washer() continue; if (LIST_EMPTY(&pp->consumers)) g_destroy_provider(pp); - else - result |= 1; } if (!(gp->flags & G_GEOM_WITHER)) continue; LIST_FOREACH_SAFE(pp, &gp->provider, provider, pp2) { if (LIST_EMPTY(&pp->consumers)) g_destroy_provider(pp); - else - result |= 1; } LIST_FOREACH_SAFE(cp, &gp->consumer, consumer, cp2) { - if (cp->acr || cp->acw || cp->ace) { - result |= 1; + if (cp->acr || cp->acw || cp->ace) continue; - } if (cp->provider != NULL) g_detach(cp); g_destroy_consumer(cp); - result |= 2; } if (LIST_EMPTY(&gp->provider) && LIST_EMPTY(&gp->consumer)) g_destroy_geom(gp); - else - result |= 1; } } - return (result); } struct g_consumer * @@ -847,9 +833,9 @@ g_detach(struct g_consumer *cp) pp = cp->provider; LIST_REMOVE(cp, consumers); cp->provider = NULL; - if (pp->geom->flags & G_GEOM_WITHER) - g_do_wither(); - else if (pp->flags & G_PF_WITHER) + if ((cp->geom->flags & G_GEOM_WITHER) || + (pp->geom->flags & G_GEOM_WITHER) || + (pp->flags & G_PF_WITHER)) g_do_wither(); redo_rank(cp->geom); } @@ -948,6 +934,9 @@ g_access(struct g_consumer *cp, int dcr, if (pp->acr != 0 || pp->acw != 0 || pp->ace != 0) KASSERT(pp->sectorsize > 0, ("Provider %s lacks sectorsize", pp->name)); + if ((cp->geom->flags & G_GEOM_WITHER) && + cp->acr == 0 && cp->acw == 0 && cp->ace == 0) + g_do_wither(); } return (error); } From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 04:09:30 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 657F4AAF; Sun, 24 Mar 2013 04:09:30 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 590B9AEC; Sun, 24 Mar 2013 04:09:30 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2O49U7F013009; Sun, 24 Mar 2013 04:09:30 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2O49TCO013008; Sun, 24 Mar 2013 04:09:29 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201303240409.r2O49TCO013008@svn.freebsd.org> From: Adrian Chadd Date: Sun, 24 Mar 2013 04:09:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248675 - head/sys/dev/ath X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 04:09:30 -0000 Author: adrian Date: Sun Mar 24 04:09:29 2013 New Revision: 248675 URL: http://svnweb.freebsd.org/changeset/base/248675 Log: Fix the locking changes due to the TXQ change drive-by. Tested: * AR9580, STA mode Modified: head/sys/dev/ath/if_ath_tx_edma.c Modified: head/sys/dev/ath/if_ath_tx_edma.c ============================================================================== --- head/sys/dev/ath/if_ath_tx_edma.c Sun Mar 24 03:15:20 2013 (r248674) +++ head/sys/dev/ath/if_ath_tx_edma.c Sun Mar 24 04:09:29 2013 (r248675) @@ -203,7 +203,7 @@ ath_edma_xmit_handoff_hw(struct ath_soft { struct ath_hal *ah = sc->sc_ah; - ATH_TXQ_LOCK_ASSERT(txq); + ATH_TXQ_LOCK(txq); KASSERT((bf->bf_flags & ATH_BUF_BUSY) == 0, ("%s: busy status 0x%x", __func__, bf->bf_flags)); @@ -234,6 +234,7 @@ ath_edma_xmit_handoff_hw(struct ath_soft txq->axq_fifo_depth++; ath_hal_txstart(ah, txq->axq_qnum); } + ATH_TXQ_UNLOCK(txq); } /* @@ -252,6 +253,7 @@ ath_edma_xmit_handoff_mcast(struct ath_s KASSERT((bf->bf_flags & ATH_BUF_BUSY) == 0, ("%s: busy status 0x%x", __func__, bf->bf_flags)); + ATH_TXQ_LOCK(txq); /* * XXX this is mostly duplicated in ath_tx_handoff_mcast(). */ @@ -278,6 +280,7 @@ ath_edma_xmit_handoff_mcast(struct ath_s ATH_TXQ_INSERT_TAIL(txq, bf, bf_list); ath_hal_gettxdesclinkptr(sc->sc_ah, bf->bf_lastds, &txq->axq_link); + ATH_TXQ_UNLOCK(txq); } /* From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 04:09:54 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E6508C21; Sun, 24 Mar 2013 04:09:54 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id DA45AAF6; Sun, 24 Mar 2013 04:09:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2O49seN013115; Sun, 24 Mar 2013 04:09:54 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2O49sRg013114; Sun, 24 Mar 2013 04:09:54 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201303240409.r2O49sRg013114@svn.freebsd.org> From: Adrian Chadd Date: Sun, 24 Mar 2013 04:09:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248676 - head/sys/dev/ath X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 04:09:55 -0000 Author: adrian Date: Sun Mar 24 04:09:54 2013 New Revision: 248676 URL: http://svnweb.freebsd.org/changeset/base/248676 Log: Move the TXQ lock earlier in this routine - so to correctly protect the link pointer check. Modified: head/sys/dev/ath/if_ath_tx.c Modified: head/sys/dev/ath/if_ath_tx.c ============================================================================== --- head/sys/dev/ath/if_ath_tx.c Sun Mar 24 04:09:29 2013 (r248675) +++ head/sys/dev/ath/if_ath_tx.c Sun Mar 24 04:09:54 2013 (r248676) @@ -702,6 +702,8 @@ ath_tx_handoff_mcast(struct ath_softc *s KASSERT((bf->bf_flags & ATH_BUF_BUSY) == 0, ("%s: busy status 0x%x", __func__, bf->bf_flags)); + + ATH_TXQ_LOCK(txq); if (txq->axq_link != NULL) { struct ath_buf *last = ATH_TXQ_LAST(txq, axq_q_s); struct ieee80211_frame *wh; @@ -715,7 +717,6 @@ ath_tx_handoff_mcast(struct ath_softc *s /* link descriptor */ *txq->axq_link = bf->bf_daddr; } - ATH_TXQ_LOCK(txq); ATH_TXQ_INSERT_TAIL(txq, bf, bf_list); ath_hal_gettxdesclinkptr(sc->sc_ah, bf->bf_lastds, &txq->axq_link); ATH_TXQ_UNLOCK(txq); From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 04:42:57 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 4C89A555; Sun, 24 Mar 2013 04:42:57 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 263BAC37; Sun, 24 Mar 2013 04:42:57 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2O4gv3F024498; Sun, 24 Mar 2013 04:42:57 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2O4guej024496; Sun, 24 Mar 2013 04:42:56 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201303240442.r2O4guej024496@svn.freebsd.org> From: Adrian Chadd Date: Sun, 24 Mar 2013 04:42:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248677 - head/sys/dev/ath/ath_hal/ah_regdomain X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 04:42:57 -0000 Author: adrian Date: Sun Mar 24 04:42:56 2013 New Revision: 248677 URL: http://svnweb.freebsd.org/changeset/base/248677 Log: Add new regulatory domain. Obtained from: Qualcomm Atheros Modified: head/sys/dev/ath/ath_hal/ah_regdomain/ah_rd_domains.h head/sys/dev/ath/ath_hal/ah_regdomain/ah_rd_regmap.h Modified: head/sys/dev/ath/ath_hal/ah_regdomain/ah_rd_domains.h ============================================================================== --- head/sys/dev/ath/ath_hal/ah_regdomain/ah_rd_domains.h Sun Mar 24 04:09:54 2013 (r248676) +++ head/sys/dev/ath/ath_hal/ah_regdomain/ah_rd_domains.h Sun Mar 24 04:42:56 2013 (r248677) @@ -741,6 +741,31 @@ static REG_DOMAIN regDomains[] = { WG1_2467_2467), .chan11g_turbo = BM1(T3_2437_2437)}, + {.regDmnEnum = WORC_WORLD, + .conformanceTestLimit = NO_CTL, + .dfsMask = DFS_FCC3 | DFS_ETSI, + .pscan = PSCAN_WWR, + .flags = ADHOC_PER_11D, + .chan11a = BM4(W1_5260_5320, + W1_5180_5240, + W1_5745_5825, + W1_5500_5700), + .chan11b = BM7(W1_2412_2412, + W1_2437_2442, + W1_2462_2462, + W1_2472_2472, + W1_2417_2432, + W1_2447_2457, + W1_2467_2467), + .chan11g = BM7(WG1_2412_2412, + WG1_2437_2442, + WG1_2462_2462, + WG1_2472_2472, + WG1_2417_2432, + WG1_2447_2457, + WG1_2467_2467), + .chan11g_turbo = BM1(T3_2437_2437)}, + {.regDmnEnum = NULL1, .conformanceTestLimit = NO_CTL, } Modified: head/sys/dev/ath/ath_hal/ah_regdomain/ah_rd_regmap.h ============================================================================== --- head/sys/dev/ath/ath_hal/ah_regdomain/ah_rd_regmap.h Sun Mar 24 04:09:54 2013 (r248676) +++ head/sys/dev/ath/ath_hal/ah_regdomain/ah_rd_regmap.h Sun Mar 24 04:42:56 2013 (r248677) @@ -129,6 +129,7 @@ static REG_DMN_PAIR_MAPPING regDomainPai {WOR9_WORLD, WOR9_WORLD, WOR9_WORLD, DISALLOW_ADHOC_11A | DISALLOW_ADHOC_11A_TURB, NO_REQ, PSCAN_DEFER, CTRY_DEFAULT }, {WORA_WORLD, WORA_WORLD, WORA_WORLD, DISALLOW_ADHOC_11A | DISALLOW_ADHOC_11A_TURB, NO_REQ, PSCAN_DEFER, CTRY_DEFAULT }, {WORB_WORLD, WORB_WORLD, WORB_WORLD, DISALLOW_ADHOC_11A | DISALLOW_ADHOC_11A_TURB, NO_REQ, PSCAN_DEFER, CTRY_DEFAULT }, + {WORC_WORLD, WORC_WORLD, WORC_WORLD, NO_REQ, NO_REQ, PSCAN_DEFER, CTRY_DEFAULT }, }; #endif From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 07:41:37 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C231346F; Sun, 24 Mar 2013 07:41:37 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id B4C54F00; Sun, 24 Mar 2013 07:41:37 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2O7fbbs079082; Sun, 24 Mar 2013 07:41:37 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2O7fanl079080; Sun, 24 Mar 2013 07:41:36 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201303240741.r2O7fanl079080@svn.freebsd.org> From: Konstantin Belousov Date: Sun, 24 Mar 2013 07:41:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248678 - in stable/9/sys: fs/tmpfs ufs/ufs X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 07:41:37 -0000 Author: kib Date: Sun Mar 24 07:41:36 2013 New Revision: 248678 URL: http://svnweb.freebsd.org/changeset/base/248678 Log: MFC r248422: Remove negative name cache entry pointing to the target name, which could be instantiated while tdvp was unlocked. Modified: stable/9/sys/fs/tmpfs/tmpfs_vnops.c stable/9/sys/ufs/ufs/ufs_vnops.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/fs/ (props changed) Modified: stable/9/sys/fs/tmpfs/tmpfs_vnops.c ============================================================================== --- stable/9/sys/fs/tmpfs/tmpfs_vnops.c Sun Mar 24 04:42:56 2013 (r248677) +++ stable/9/sys/fs/tmpfs/tmpfs_vnops.c Sun Mar 24 07:41:36 2013 (r248678) @@ -1306,6 +1306,7 @@ tmpfs_rename(struct vop_rename_args *v) cache_purge(fvp); if (tvp != NULL) cache_purge(tvp); + cache_purge_negative(tdvp); error = 0; Modified: stable/9/sys/ufs/ufs/ufs_vnops.c ============================================================================== --- stable/9/sys/ufs/ufs/ufs_vnops.c Sun Mar 24 04:42:56 2013 (r248677) +++ stable/9/sys/ufs/ufs/ufs_vnops.c Sun Mar 24 07:41:36 2013 (r248678) @@ -1562,6 +1562,7 @@ relock: cache_purge(fvp); if (tvp) cache_purge(tvp); + cache_purge_negative(tdvp); unlockout: vput(fdvp); From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 10:14:26 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id DF1C226A3; Sun, 24 Mar 2013 10:14:25 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id C26F91B9; Sun, 24 Mar 2013 10:14:25 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2OAEPeH024823; Sun, 24 Mar 2013 10:14:25 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2OAEPqF024822; Sun, 24 Mar 2013 10:14:25 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201303241014.r2OAEPqF024822@svn.freebsd.org> From: Alexander Motin Date: Sun, 24 Mar 2013 10:14:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248679 - head/sys/geom X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 10:14:26 -0000 Author: mav Date: Sun Mar 24 10:14:25 2013 New Revision: 248679 URL: http://svnweb.freebsd.org/changeset/base/248679 Log: Fix long known deadlock between geom dev destruction and d_close() call. Use destroy_dev_sched_cb() to not wait for device destruction while holding GEOM topology lock (that actually caused deadlock). Use request counting protected by mutex to properly wait for outstanding requests completion in cases of device closing and geom destruction. Unlike r227009, this code does not block taskqueue thread for indefinite time, waiting for completion. Modified: head/sys/geom/geom_dev.c Modified: head/sys/geom/geom_dev.c ============================================================================== --- head/sys/geom/geom_dev.c Sun Mar 24 07:41:36 2013 (r248678) +++ head/sys/geom/geom_dev.c Sun Mar 24 10:14:25 2013 (r248679) @@ -56,10 +56,13 @@ __FBSDID("$FreeBSD$"); #include #include -/* - * Use the consumer private field to reference a physdev alias (if any). - */ -#define cp_alias_dev private +struct g_dev_softc { + struct mtx sc_mtx; + struct cdev *sc_dev; + struct cdev *sc_alias; + int sc_open; + int sc_active; +}; static d_open_t g_dev_open; static d_close_t g_dev_close; @@ -90,6 +93,27 @@ static struct g_class g_dev_class = { .attrchanged = g_dev_attrchanged }; +static void +g_dev_destroy(void *arg, int flags __unused) +{ + struct g_consumer *cp; + struct g_geom *gp; + struct g_dev_softc *sc; + + g_topology_assert(); + cp = arg; + gp = cp->geom; + sc = cp->private; + g_trace(G_T_TOPOLOGY, "g_dev_destroy(%p(%s))", cp, gp->name); + if (cp->acr > 0 || cp->acw > 0 || cp->ace > 0) + g_access(cp, -cp->acr, -cp->acw, -cp->ace); + g_detach(cp); + g_destroy_consumer(cp); + g_destroy_geom(gp); + mtx_destroy(&sc->sc_mtx); + g_free(sc); +} + void g_dev_print(void) { @@ -106,14 +130,16 @@ g_dev_print(void) static void g_dev_attrchanged(struct g_consumer *cp, const char *attr) { + struct g_dev_softc *sc; struct cdev *dev; char buf[SPECNAMELEN + 6]; + sc = cp->private; if (strcmp(attr, "GEOM::media") == 0) { - dev = cp->geom->softc; + dev = sc->sc_dev; snprintf(buf, sizeof(buf), "cdev=%s", dev->si_name); devctl_notify_f("DEVFS", "CDEV", "MEDIACHANGE", buf, M_WAITOK); - dev = cp->cp_alias_dev; + dev = sc->sc_alias; if (dev != NULL) { snprintf(buf, sizeof(buf), "cdev=%s", dev->si_name); devctl_notify_f("DEVFS", "CDEV", "MEDIACHANGE", buf, @@ -138,14 +164,14 @@ g_dev_attrchanged(struct g_consumer *cp, struct cdev *old_alias_dev; struct cdev **alias_devp; - dev = cp->geom->softc; - old_alias_dev = cp->cp_alias_dev; - alias_devp = (struct cdev **)&cp->cp_alias_dev; + dev = sc->sc_dev; + old_alias_dev = sc->sc_alias; + alias_devp = (struct cdev **)&sc->sc_alias; make_dev_physpath_alias(MAKEDEV_WAITOK, alias_devp, dev, old_alias_dev, physpath); - } else if (cp->cp_alias_dev) { - destroy_dev((struct cdev *)cp->cp_alias_dev); - cp->cp_alias_dev = NULL; + } else if (sc->sc_alias) { + destroy_dev((struct cdev *)sc->sc_alias); + sc->sc_alias = NULL; } g_free(physpath); } @@ -170,6 +196,7 @@ g_dev_taste(struct g_class *mp, struct g { struct g_geom *gp; struct g_consumer *cp; + struct g_dev_softc *sc; int error, len; struct cdev *dev, *adev; char buf[64], *val; @@ -177,7 +204,10 @@ g_dev_taste(struct g_class *mp, struct g g_trace(G_T_TOPOLOGY, "dev_taste(%s,%s)", mp->name, pp->name); g_topology_assert(); gp = g_new_geomf(mp, "%s", pp->name); + sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO); + mtx_init(&sc->sc_mtx, "g_dev", NULL, MTX_DEF); cp = g_new_consumer(gp); + cp->private = sc; error = g_attach(cp, pp); KASSERT(error == 0, ("g_dev_taste(%s) failed to g_attach, err=%d", pp->name, error)); @@ -189,8 +219,11 @@ g_dev_taste(struct g_class *mp, struct g g_detach(cp); g_destroy_consumer(cp); g_destroy_geom(gp); + mtx_destroy(&sc->sc_mtx); + g_free(sc); return (NULL); } + sc->sc_dev = dev; /* Search for device alias name and create it if found. */ adev = NULL; @@ -209,12 +242,9 @@ g_dev_taste(struct g_class *mp, struct g } dev->si_iosize_max = MAXPHYS; - gp->softc = dev; - dev->si_drv1 = gp; dev->si_drv2 = cp; if (adev != NULL) { adev->si_iosize_max = MAXPHYS; - adev->si_drv1 = gp; adev->si_drv2 = cp; } @@ -226,17 +256,15 @@ g_dev_taste(struct g_class *mp, struct g static int g_dev_open(struct cdev *dev, int flags, int fmt, struct thread *td) { - struct g_geom *gp; struct g_consumer *cp; + struct g_dev_softc *sc; int error, r, w, e; - gp = dev->si_drv1; cp = dev->si_drv2; - if (gp == NULL || cp == NULL || gp->softc != dev) + if (cp == NULL) return(ENXIO); /* g_dev_taste() not done yet */ - g_trace(G_T_ACCESS, "g_dev_open(%s, %d, %d, %p)", - gp->name, flags, fmt, td); + cp->geom->name, flags, fmt, td); r = flags & FREAD ? 1 : 0; w = flags & FWRITE ? 1 : 0; @@ -255,27 +283,32 @@ g_dev_open(struct cdev *dev, int flags, return (error); } g_topology_lock(); - if (dev->si_devsw == NULL) - error = ENXIO; /* We were orphaned */ - else - error = g_access(cp, r, w, e); + error = g_access(cp, r, w, e); g_topology_unlock(); + if (error == 0) { + sc = cp->private; + mtx_lock(&sc->sc_mtx); + if (sc->sc_open == 0 && sc->sc_active != 0) + wakeup(&sc->sc_active); + sc->sc_open += r + w + e; + mtx_unlock(&sc->sc_mtx); + } return(error); } static int g_dev_close(struct cdev *dev, int flags, int fmt, struct thread *td) { - struct g_geom *gp; struct g_consumer *cp; - int error, r, w, e, i; + struct g_dev_softc *sc; + int error, r, w, e; - gp = dev->si_drv1; cp = dev->si_drv2; - if (gp == NULL || cp == NULL) + if (cp == NULL) return(ENXIO); g_trace(G_T_ACCESS, "g_dev_close(%s, %d, %d, %p)", - gp->name, flags, fmt, td); + cp->geom->name, flags, fmt, td); + r = flags & FREAD ? -1 : 0; w = flags & FWRITE ? -1 : 0; #ifdef notyet @@ -283,25 +316,14 @@ g_dev_close(struct cdev *dev, int flags, #else e = 0; #endif + sc = cp->private; + mtx_lock(&sc->sc_mtx); + sc->sc_open += r + w + e; + while (sc->sc_open == 0 && sc->sc_active != 0) + msleep(&sc->sc_active, &sc->sc_mtx, 0, "PRIBIO", 0); + mtx_unlock(&sc->sc_mtx); g_topology_lock(); - if (dev->si_devsw == NULL) - error = ENXIO; /* We were orphaned */ - else - error = g_access(cp, r, w, e); - for (i = 0; i < 10 * hz;) { - if (cp->acr != 0 || cp->acw != 0) - break; - if (cp->nstart == cp->nend) - break; - pause("gdevwclose", hz / 10); - i += hz / 10; - } - if (cp->acr == 0 && cp->acw == 0 && cp->nstart != cp->nend) { - printf("WARNING: Final close of geom_dev(%s) %s %s\n", - gp->name, - "still has outstanding I/O after 10 seconds.", - "Completing close anyway, panic may happen later."); - } + error = g_access(cp, r, w, e); g_topology_unlock(); return (error); } @@ -315,7 +337,6 @@ g_dev_close(struct cdev *dev, int flags, static int g_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread *td) { - struct g_geom *gp; struct g_consumer *cp; struct g_provider *pp; struct g_kerneldump kd; @@ -323,7 +344,6 @@ g_dev_ioctl(struct cdev *dev, u_long cmd int i, error; u_int u; - gp = dev->si_drv1; cp = dev->si_drv2; pp = cp->provider; @@ -437,8 +457,13 @@ g_dev_ioctl(struct cdev *dev, u_long cmd static void g_dev_done(struct bio *bp2) { + struct g_consumer *cp; + struct g_dev_softc *sc; struct bio *bp; + int destroy; + cp = bp2->bio_from; + sc = cp->private; bp = bp2->bio_parent; bp->bio_error = bp2->bio_error; if (bp->bio_error != 0) { @@ -452,6 +477,17 @@ g_dev_done(struct bio *bp2) bp->bio_resid = bp->bio_length - bp2->bio_completed; bp->bio_completed = bp2->bio_completed; g_destroy_bio(bp2); + destroy = 0; + mtx_lock(&sc->sc_mtx); + if ((--sc->sc_active) == 0) { + if (sc->sc_open == 0) + wakeup(&sc->sc_active); + if (sc->sc_dev == NULL) + destroy = 1; + } + mtx_unlock(&sc->sc_mtx); + if (destroy) + g_post_event(g_dev_destroy, cp, M_WAITOK, NULL); biodone(bp); } @@ -461,6 +497,7 @@ g_dev_strategy(struct bio *bp) struct g_consumer *cp; struct bio *bp2; struct cdev *dev; + struct g_dev_softc *sc; KASSERT(bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE || @@ -468,6 +505,7 @@ g_dev_strategy(struct bio *bp) ("Wrong bio_cmd bio=%p cmd=%d", bp, bp->bio_cmd)); dev = bp->bio_dev; cp = dev->si_drv2; + sc = cp->private; KASSERT(cp->acr || cp->acw, ("Consumer with zero access count in g_dev_strategy")); #ifdef INVARIANTS @@ -478,6 +516,11 @@ g_dev_strategy(struct bio *bp) return; } #endif + mtx_lock(&sc->sc_mtx); + KASSERT(sc->sc_open > 0, ("Closed device in g_dev_strategy")); + sc->sc_active++; + mtx_unlock(&sc->sc_mtx); + for (;;) { /* * XXX: This is not an ideal solution, but I belive it to @@ -501,46 +544,61 @@ g_dev_strategy(struct bio *bp) } /* + * g_dev_callback() + * + * Called by devfs when asynchronous device destruction is completed. + * - Mark that we have no attached device any more. + * - If there are no outstanding requests, schedule geom destruction. + * Otherwise destruction will be scheduled later by g_dev_done(). + */ + +static void +g_dev_callback(void *arg) +{ + struct g_consumer *cp; + struct g_dev_softc *sc; + int destroy; + + cp = arg; + sc = cp->private; + g_trace(G_T_TOPOLOGY, "g_dev_callback(%p(%s))", cp, cp->geom->name); + + mtx_lock(&sc->sc_mtx); + sc->sc_dev = NULL; + sc->sc_alias = NULL; + destroy = (sc->sc_active == 0); + mtx_unlock(&sc->sc_mtx); + if (destroy) + g_post_event(g_dev_destroy, cp, M_WAITOK, NULL); +} + +/* * g_dev_orphan() * * Called from below when the provider orphaned us. * - Clear any dump settings. - * - Destroy the struct cdev to prevent any more request from coming in. The - * provider is already marked with an error, so anything which comes in - * in the interrim will be returned immediately. - * - Wait for any outstanding I/O to finish. - * - Set our access counts to zero, whatever they were. - * - Detach and self-destruct. + * - Request asynchronous device destruction to prevent any more requests + * from coming in. The provider is already marked with an error, so + * anything which comes in in the interrim will be returned immediately. */ static void g_dev_orphan(struct g_consumer *cp) { - struct g_geom *gp; struct cdev *dev; + struct g_dev_softc *sc; g_topology_assert(); - gp = cp->geom; - dev = gp->softc; - g_trace(G_T_TOPOLOGY, "g_dev_orphan(%p(%s))", cp, gp->name); + sc = cp->private; + dev = sc->sc_dev; + g_trace(G_T_TOPOLOGY, "g_dev_orphan(%p(%s))", cp, cp->geom->name); /* Reset any dump-area set on this device */ if (dev->si_flags & SI_DUMPDEV) set_dumper(NULL, NULL); /* Destroy the struct cdev *so we get no more requests */ - destroy_dev(dev); - - /* Wait for the cows to come home */ - while (cp->nstart != cp->nend) - pause("gdevorphan", hz / 10); - - if (cp->acr > 0 || cp->acw > 0 || cp->ace > 0) - g_access(cp, -cp->acr, -cp->acw, -cp->ace); - - g_detach(cp); - g_destroy_consumer(cp); - g_destroy_geom(gp); + destroy_dev_sched_cb(dev, g_dev_callback, cp); } DECLARE_GEOM_CLASS(g_dev_class, g_dev); From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 10:41:30 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 0A0CF2CDF; Sun, 24 Mar 2013 10:41:30 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id EF565250; Sun, 24 Mar 2013 10:41:29 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2OAfTJ5033110; Sun, 24 Mar 2013 10:41:29 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2OAfTr1033109; Sun, 24 Mar 2013 10:41:29 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201303241041.r2OAfTr1033109@svn.freebsd.org> From: Sean Bruno Date: Sun, 24 Mar 2013 10:41:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248680 - head/sbin/fsck_ffs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 10:41:30 -0000 Author: sbruno Date: Sun Mar 24 10:41:29 2013 New Revision: 248680 URL: http://svnweb.freebsd.org/changeset/base/248680 Log: Resolve clang compile errors on amd64/i386 for certain by casting. compile tested with clang on i386, amd64 compile tested with gcc on i386, amd64, sparc64 Submitted by: delphij Modified: head/sbin/fsck_ffs/fsutil.c Modified: head/sbin/fsck_ffs/fsutil.c ============================================================================== --- head/sbin/fsck_ffs/fsutil.c Sun Mar 24 10:14:25 2013 (r248679) +++ head/sbin/fsck_ffs/fsutil.c Sun Mar 24 10:41:29 2013 (r248680) @@ -507,8 +507,8 @@ static void printIOstats(void) clock_gettime(CLOCK_REALTIME_PRECISE, &finishpass); timespecsub(&finishpass, &startpass); - printf("Running time: %ld.%03ld msec\n", - finishpass.tv_sec, finishpass.tv_nsec / 1000000); + printf("Running time: %jd.%03ld msec\n", + (intmax_t)finishpass.tv_sec, finishpass.tv_nsec / 1000000); printf("buffer reads by type:\n"); for (totalmsec = 0, i = 0; i < BT_NUMBUFTYPES; i++) totalmsec += readtime[i].tv_sec * 1000 + @@ -519,10 +519,10 @@ static void printIOstats(void) if (readcnt[i] == 0) continue; msec = readtime[i].tv_sec * 1000 + readtime[i].tv_nsec / 1000000; - printf("%21s:%8ld %2ld.%ld%% %4ld.%03ld sec %2lld.%lld%%\n", + printf("%21s:%8ld %2ld.%ld%% %4jd.%03ld sec %2lld.%lld%%\n", buftype[i], readcnt[i], readcnt[i] * 100 / diskreads, (readcnt[i] * 1000 / diskreads) % 10, - readtime[i].tv_sec, readtime[i].tv_nsec / 1000000, + (intmax_t)readtime[i].tv_sec, readtime[i].tv_nsec / 1000000, msec * 100 / totalmsec, (msec * 1000 / totalmsec) % 10); } printf("\n"); From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 12:35:13 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 3A0E8438; Sun, 24 Mar 2013 12:35:13 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 1E23B92E; Sun, 24 Mar 2013 12:35:13 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2OCZDoW066930; Sun, 24 Mar 2013 12:35:13 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2OCZChN066927; Sun, 24 Mar 2013 12:35:12 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201303241235.r2OCZChN066927@svn.freebsd.org> From: Jilles Tjoelker Date: Sun, 24 Mar 2013 12:35:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248681 - stable/9/usr.bin/find X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 12:35:13 -0000 Author: jilles Date: Sun Mar 24 12:35:12 2013 New Revision: 248681 URL: http://svnweb.freebsd.org/changeset/base/248681 Log: MFC r248446: find: Include nanoseconds when comparing timestamps of files. When comparing to the timestamp of a given file using -newer, -Xnewer and -newerXY (where X and Y are one of m, c, a, B), include nanoseconds in the comparison. The primaries that compare a timestamp of a file to a given value (-Xmin, -Xtime, -newerXt) continue to compare times in whole seconds. Note that the default value 0 of vfs.timestamp_precision almost always causes the nanoseconds part to be 0. However, touch -d can set a timestamp to the microsecond regardless of that sysctl. Modified: stable/9/usr.bin/find/find.h stable/9/usr.bin/find/function.c Directory Properties: stable/9/usr.bin/find/ (props changed) Modified: stable/9/usr.bin/find/find.h ============================================================================== --- stable/9/usr.bin/find/find.h Sun Mar 24 10:41:29 2013 (r248680) +++ stable/9/usr.bin/find/find.h Sun Mar 24 12:35:12 2013 (r248681) @@ -88,7 +88,7 @@ typedef struct _plandata { nlink_t _l_data; /* link count */ short _d_data; /* level depth (-1 to N) */ off_t _o_data; /* file size */ - time_t _t_data; /* time value */ + struct timespec _t_data; /* time value */ uid_t _u_data; /* uid */ short _mt_data; /* mount flags */ struct _plandata *_p_data[2]; /* PLAN trees */ Modified: stable/9/usr.bin/find/function.c ============================================================================== --- stable/9/usr.bin/find/function.c Sun Mar 24 10:41:29 2013 (r248680) +++ stable/9/usr.bin/find/function.c Sun Mar 24 12:35:12 2013 (r248681) @@ -238,7 +238,7 @@ nextarg(OPTION *option, char ***argvp) */ #define TIME_CORRECT(p) \ if (((p)->flags & F_ELG_MASK) == F_LESSTHAN) \ - ++((p)->t_data); + ++((p)->t_data.tv_sec); /* * -[acm]min n functions -- @@ -255,16 +255,16 @@ f_Xmin(PLAN *plan, FTSENT *entry) { if (plan->flags & F_TIME_C) { COMPARE((now - entry->fts_statp->st_ctime + - 60 - 1) / 60, plan->t_data); + 60 - 1) / 60, plan->t_data.tv_sec); } else if (plan->flags & F_TIME_A) { COMPARE((now - entry->fts_statp->st_atime + - 60 - 1) / 60, plan->t_data); + 60 - 1) / 60, plan->t_data.tv_sec); } else if (plan->flags & F_TIME_B) { COMPARE((now - entry->fts_statp->st_birthtime + - 60 - 1) / 60, plan->t_data); + 60 - 1) / 60, plan->t_data.tv_sec); } else { COMPARE((now - entry->fts_statp->st_mtime + - 60 - 1) / 60, plan->t_data); + 60 - 1) / 60, plan->t_data.tv_sec); } } @@ -278,7 +278,8 @@ c_Xmin(OPTION *option, char ***argvp) ftsoptions &= ~FTS_NOSTAT; new = palloc(option); - new->t_data = find_parsenum(new, option->name, nmins, NULL); + new->t_data.tv_sec = find_parsenum(new, option->name, nmins, NULL); + new->t_data.tv_nsec = 0; TIME_CORRECT(new); return new; } @@ -309,9 +310,9 @@ f_Xtime(PLAN *plan, FTSENT *entry) xtime = entry->fts_statp->st_mtime; if (plan->flags & F_EXACTTIME) - COMPARE(now - xtime, plan->t_data); + COMPARE(now - xtime, plan->t_data.tv_sec); else - COMPARE((now - xtime + 86400 - 1) / 86400, plan->t_data); + COMPARE((now - xtime + 86400 - 1) / 86400, plan->t_data.tv_sec); } PLAN * @@ -324,7 +325,8 @@ c_Xtime(OPTION *option, char ***argvp) ftsoptions &= ~FTS_NOSTAT; new = palloc(option); - new->t_data = find_parsetime(new, option->name, value); + new->t_data.tv_sec = find_parsetime(new, option->name, value); + new->t_data.tv_nsec = 0; if (!(new->flags & F_EXACTTIME)) TIME_CORRECT(new); return new; @@ -1113,14 +1115,19 @@ c_name(OPTION *option, char ***argvp) int f_newer(PLAN *plan, FTSENT *entry) { + struct timespec ft; + if (plan->flags & F_TIME_C) - return entry->fts_statp->st_ctime > plan->t_data; + ft = entry->fts_statp->st_ctim; else if (plan->flags & F_TIME_A) - return entry->fts_statp->st_atime > plan->t_data; + ft = entry->fts_statp->st_atim; else if (plan->flags & F_TIME_B) - return entry->fts_statp->st_birthtime > plan->t_data; + ft = entry->fts_statp->st_birthtim; else - return entry->fts_statp->st_mtime > plan->t_data; + ft = entry->fts_statp->st_mtim; + return (ft.tv_sec > plan->t_data.tv_sec || + (ft.tv_sec == plan->t_data.tv_sec && + ft.tv_nsec > plan->t_data.tv_nsec)); } PLAN * @@ -1136,20 +1143,22 @@ c_newer(OPTION *option, char ***argvp) new = palloc(option); /* compare against what */ if (option->flags & F_TIME2_T) { - new->t_data = get_date(fn_or_tspec); - if (new->t_data == (time_t) -1) + new->t_data.tv_sec = get_date(fn_or_tspec); + if (new->t_data.tv_sec == (time_t) -1) errx(1, "Can't parse date/time: %s", fn_or_tspec); + /* Use the seconds only in the comparison. */ + new->t_data.tv_nsec = 999999999; } else { if (stat(fn_or_tspec, &sb)) err(1, "%s", fn_or_tspec); if (option->flags & F_TIME2_C) - new->t_data = sb.st_ctime; + new->t_data = sb.st_ctim; else if (option->flags & F_TIME2_A) - new->t_data = sb.st_atime; + new->t_data = sb.st_atim; else if (option->flags & F_TIME2_B) - new->t_data = sb.st_birthtime; + new->t_data = sb.st_birthtim; else - new->t_data = sb.st_mtime; + new->t_data = sb.st_mtim; } return new; } From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 12:39:26 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id CDF2C758; Sun, 24 Mar 2013 12:39:26 +0000 (UTC) (envelope-from antoine@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id C07CA958; Sun, 24 Mar 2013 12:39:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2OCdQwO067504; Sun, 24 Mar 2013 12:39:26 GMT (envelope-from antoine@svn.freebsd.org) Received: (from antoine@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2OCdQLY067503; Sun, 24 Mar 2013 12:39:26 GMT (envelope-from antoine@svn.freebsd.org) Message-Id: <201303241239.r2OCdQLY067503@svn.freebsd.org> From: Antoine Brodin Date: Sun, 24 Mar 2013 12:39:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248682 - head X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 12:39:26 -0000 Author: antoine Date: Sun Mar 24 12:39:26 2013 New Revision: 248682 URL: http://svnweb.freebsd.org/changeset/base/248682 Log: Add 2 more obsolete files and a missing date. Modified: head/ObsoleteFiles.inc Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Sun Mar 24 12:35:12 2013 (r248681) +++ head/ObsoleteFiles.inc Sun Mar 24 12:39:26 2013 (r248682) @@ -38,7 +38,11 @@ # xargs -n1 | sort | uniq -d; # done +# 20130316: vinum.4 removed OLD_FILES+=usr/share/man/man4/vinum.4.gz +# 20130312: fortunes-o removed +OLD_FILES+=usr/share/games/fortune/fortunes-o +OLD_FILES+=usr/share/games/fortune/fortunes-o.dat # 20130311: Ports are no more available via cvsup OLD_FILES+=usr/share/examples/cvsup/ports-supfile OLD_FILES+=usr/share/examples/cvsup/refuse From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 12:56:03 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D3A05FC8; Sun, 24 Mar 2013 12:56:03 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from fallbackmx07.syd.optusnet.com.au (fallbackmx07.syd.optusnet.com.au [211.29.132.9]) by mx1.freebsd.org (Postfix) with ESMTP id 700BA9D3; Sun, 24 Mar 2013 12:56:02 +0000 (UTC) Received: from mail36.syd.optusnet.com.au (mail36.syd.optusnet.com.au [211.29.133.76]) by fallbackmx07.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id r2OCtrHP020144; Sun, 24 Mar 2013 23:55:53 +1100 Received: from c211-30-173-106.carlnfd1.nsw.optusnet.com.au (c211-30-173-106.carlnfd1.nsw.optusnet.com.au [211.30.173.106]) by mail36.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id r2OCtikn017904 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 24 Mar 2013 23:55:45 +1100 Date: Sun, 24 Mar 2013 23:55:44 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Sean Bruno Subject: Re: svn commit: r248680 - head/sbin/fsck_ffs In-Reply-To: <201303241041.r2OAfTr1033109@svn.freebsd.org> Message-ID: <20130324232715.L959@besplex.bde.org> References: <201303241041.r2OAfTr1033109@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.0 cv=D5QfsYtj c=1 sm=1 a=jO6rb6iV1_cA:10 a=kj9zAlcOel0A:10 a=PO7r1zJSAAAA:8 a=JzwRw_2MAAAA:8 a=0pm9H42DGT4A:10 a=wn9u6872aJiteysuqiwA:9 a=CjuIK1q_8ugA:10 a=TEtd8y5WR3g2ypngnwZWYw==:117 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 12:56:03 -0000 On Sun, 24 Mar 2013, Sean Bruno wrote: > Log: > Resolve clang compile errors on amd64/i386 for certain by casting. > > compile tested with clang on i386, amd64 > compile tested with gcc on i386, amd64, sparc64 > > Submitted by: delphij > > Modified: > head/sbin/fsck_ffs/fsutil.c > > Modified: head/sbin/fsck_ffs/fsutil.c > ============================================================================== > --- head/sbin/fsck_ffs/fsutil.c Sun Mar 24 10:14:25 2013 (r248679) > +++ head/sbin/fsck_ffs/fsutil.c Sun Mar 24 10:41:29 2013 (r248680) > @@ -507,8 +507,8 @@ static void printIOstats(void) > > clock_gettime(CLOCK_REALTIME_PRECISE, &finishpass); > timespecsub(&finishpass, &startpass); > - printf("Running time: %ld.%03ld msec\n", > - finishpass.tv_sec, finishpass.tv_nsec / 1000000); > + printf("Running time: %jd.%03ld msec\n", > + (intmax_t)finishpass.tv_sec, finishpass.tv_nsec / 1000000); > printf("buffer reads by type:\n"); > for (totalmsec = 0, i = 0; i < BT_NUMBUFTYPES; i++) > totalmsec += readtime[i].tv_sec * 1000 + Casting to intmax_t is excessive. It gives at least 64 bits, but 16 bits suffice for runtimes of up to 9.1 hours. 32 bits suffice for tuntimes of up to a measly 68 years. The following bugs remain in the changed statement: - the description claims that the runtime is in msec. It is actually in seconds with a precision of milliseconds. - non-KNF indentation in continued line. > @@ -519,10 +519,10 @@ static void printIOstats(void) > if (readcnt[i] == 0) > continue; > msec = readtime[i].tv_sec * 1000 + readtime[i].tv_nsec / 1000000; Line too long. > - printf("%21s:%8ld %2ld.%ld%% %4ld.%03ld sec %2lld.%lld%%\n", > + printf("%21s:%8ld %2ld.%ld%% %4jd.%03ld sec %2lld.%lld%%\n", > buftype[i], readcnt[i], readcnt[i] * 100 / diskreads, > (readcnt[i] * 1000 / diskreads) % 10, > - readtime[i].tv_sec, readtime[i].tv_nsec / 1000000, > + (intmax_t)readtime[i].tv_sec, readtime[i].tv_nsec / 1000000, > msec * 100 / totalmsec, (msec * 1000 / totalmsec) % 10); Simimlarly for the new cast. Now the units are correct. Now the indentation is normal. Now the long long abomination is used for the some of the times. This matches the long long abomination being used for the type of msec and totalmsec. The use of long long is inconsistent with the use of intmax_t, and almost as excessive. Now 16 bit ints are too small (they only work for 32 seconds), and 32-bit ints are only enough for 24 days, but that is more than enough. Except when calculating the average, the multiplication by 1000 would overflow after 35 minutes with 32-bit ints. Division by 0 seems to occur for runtimes of < 1 msec. Since the clock id is CLOCK_REALTIME_*, this can occur even for long actual runtimes, if the clock is stepped backwards. I don't like the poor man's floating point calculations. Everything is easier using floating point. > } > printf("\n"); > Bruce From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 13:57:26 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C2F6098; Sun, 24 Mar 2013 13:57:26 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail36.syd.optusnet.com.au (mail36.syd.optusnet.com.au [211.29.133.76]) by mx1.freebsd.org (Postfix) with ESMTP id 62860BD7; Sun, 24 Mar 2013 13:57:26 +0000 (UTC) Received: from c211-30-173-106.carlnfd1.nsw.optusnet.com.au (c211-30-173-106.carlnfd1.nsw.optusnet.com.au [211.30.173.106]) by mail36.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id r2ODvLH1022917 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 25 Mar 2013 00:57:22 +1100 Date: Mon, 25 Mar 2013 00:57:20 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Bruce Evans Subject: Re: svn commit: r248680 - head/sbin/fsck_ffs In-Reply-To: <20130324232715.L959@besplex.bde.org> Message-ID: <20130325003122.N1398@besplex.bde.org> References: <201303241041.r2OAfTr1033109@svn.freebsd.org> <20130324232715.L959@besplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.0 cv=D5QfsYtj c=1 sm=1 a=jO6rb6iV1_cA:10 a=kj9zAlcOel0A:10 a=PO7r1zJSAAAA:8 a=JzwRw_2MAAAA:8 a=0pm9H42DGT4A:10 a=AS4WCpWeJh8pi0vQyyIA:9 a=CjuIK1q_8ugA:10 a=TEtd8y5WR3g2ypngnwZWYw==:117 Cc: svn-src-head@freebsd.org, Sean Bruno , src-committers@freebsd.org, svn-src-all@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 13:57:26 -0000 On Sun, 24 Mar 2013, Bruce Evans wrote: > ... >> - printf("%21s:%8ld %2ld.%ld%% %4ld.%03ld sec %2lld.%lld%%\n", >> + printf("%21s:%8ld %2ld.%ld%% %4jd.%03ld sec %2lld.%lld%%\n", >> buftype[i], readcnt[i], readcnt[i] * 100 / diskreads, >> (readcnt[i] * 1000 / diskreads) % 10, >> - readtime[i].tv_sec, readtime[i].tv_nsec / 1000000, >> + (intmax_t)readtime[i].tv_sec, readtime[i].tv_nsec / >> 1000000, >> msec * 100 / totalmsec, (msec * 1000 / totalmsec) % 10); > ... > I don't like the poor man's floating point calculations. Everything is > easier using floating point. Don't say that this would use too many resources on embedded systems :-). In FreeBSD-2, fsck_ffs has always used floating point for printing the percentages in its primary statistics (the % fragmentation lines that are printed for every file system checked by fsck_ffs). This wasn't in 4.4BSD (poor man's floating point calculations are used there too), but it was one of the first things changed in FreeBSD-2 in 1994. The FreeBSD version used a remnant of the poor man's floating point calculations at first (a decimal multiplication by 100) at first, but I changed it in 1997 to do a floating point multiplication. The decimal multiplication could have overflowed with today's sized disk on ffs1 (this takes 21+ million frags). Bruce From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 16:43:08 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 9B5A79AA; Sun, 24 Mar 2013 16:43:08 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 74AE8614; Sun, 24 Mar 2013 16:43:08 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2OGh8To044197; Sun, 24 Mar 2013 16:43:08 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2OGh86O044196; Sun, 24 Mar 2013 16:43:08 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201303241643.r2OGh86O044196@svn.freebsd.org> From: Alan Cox Date: Sun, 24 Mar 2013 16:43:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248684 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 16:43:08 -0000 Author: alc Date: Sun Mar 24 16:43:07 2013 New Revision: 248684 URL: http://svnweb.freebsd.org/changeset/base/248684 Log: Micro-optimize the control flow in a few places. Eliminate a panic call that could never be reached in vm_radix_insert(). (If the pointer being checked by the panic call were ever NULL, the immmediately preceding loop would have already crashed on a NULL pointer dereference.) Reviewed by: attilio (an earlier version) Sponsored by: EMC / Isilon Storage Division Modified: head/sys/vm/vm_radix.c Modified: head/sys/vm/vm_radix.c ============================================================================== --- head/sys/vm/vm_radix.c Sun Mar 24 16:41:23 2013 (r248683) +++ head/sys/vm/vm_radix.c Sun Mar 24 16:43:07 2013 (r248684) @@ -310,7 +310,9 @@ vm_radix_reclaim_allnodes_int(struct vm_ { int slot; - for (slot = 0; slot < VM_RADIX_COUNT && rnode->rn_count != 0; slot++) { + KASSERT(rnode->rn_count <= VM_RADIX_COUNT, + ("vm_radix_reclaim_allnodes_int: bad count in rnode %p", rnode)); + for (slot = 0; rnode->rn_count != 0; slot++) { if (rnode->rn_child[slot] == NULL) continue; if (vm_radix_node_page(rnode->rn_child[slot]) == NULL) @@ -414,9 +416,7 @@ vm_radix_insert(struct vm_radix *rtree, vm_radix_addpage(rnode, index, 0, page); return; } - while (rnode != NULL) { - if (vm_radix_keybarr(rnode, index)) - break; + do { slot = vm_radix_slot(index, rnode->rn_clev); m = vm_radix_node_page(rnode->rn_child[slot]); if (m != NULL) { @@ -437,9 +437,7 @@ vm_radix_insert(struct vm_radix *rtree, return; } rnode = rnode->rn_child[slot]; - } - if (rnode == NULL) - panic("%s: path traversal ended unexpectedly", __func__); + } while (!vm_radix_keybarr(rnode, index)); /* * Scan the trie from the top and find the parent to insert @@ -748,8 +746,8 @@ vm_radix_reclaim_allnodes(struct vm_radi root = vm_radix_getroot(rtree); if (root == NULL) return; - vm_radix_reclaim_allnodes_int(root); vm_radix_setroot(rtree, NULL); + vm_radix_reclaim_allnodes_int(root); } #ifdef DDB From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 16:51:21 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D21DFDB; Sun, 24 Mar 2013 16:51:21 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id C3F9768D; Sun, 24 Mar 2013 16:51:21 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2OGpLU0047066; Sun, 24 Mar 2013 16:51:21 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2OGpLmS047065; Sun, 24 Mar 2013 16:51:21 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201303241651.r2OGpLmS047065@svn.freebsd.org> From: Alexander Motin Date: Sun, 24 Mar 2013 16:51:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248687 - head/sys/dev/ahci X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 16:51:21 -0000 Author: mav Date: Sun Mar 24 16:51:21 2013 New Revision: 248687 URL: http://svnweb.freebsd.org/changeset/base/248687 Log: No need to erase all 64 bytes of CFIS area if we never use more then 16. Modified: head/sys/dev/ahci/ahci.c Modified: head/sys/dev/ahci/ahci.c ============================================================================== --- head/sys/dev/ahci/ahci.c Sun Mar 24 16:48:40 2013 (r248686) +++ head/sys/dev/ahci/ahci.c Sun Mar 24 16:51:21 2013 (r248687) @@ -1208,8 +1208,8 @@ ahci_dmainit(device_t dev) NULL, NULL, AHCI_WORK_SIZE, 1, AHCI_WORK_SIZE, 0, NULL, NULL, &ch->dma.work_tag)) goto error; - if (bus_dmamem_alloc(ch->dma.work_tag, (void **)&ch->dma.work, 0, - &ch->dma.work_map)) + if (bus_dmamem_alloc(ch->dma.work_tag, (void **)&ch->dma.work, + BUS_DMA_ZERO, &ch->dma.work_map)) goto error; if (bus_dmamap_load(ch->dma.work_tag, ch->dma.work_map, ch->dma.work, AHCI_WORK_SIZE, ahci_dmasetupc_cb, &dcba, 0) || dcba.error) { @@ -2602,7 +2602,7 @@ ahci_setup_fis(device_t dev, struct ahci struct ahci_channel *ch = device_get_softc(dev); u_int8_t *fis = &ctp->cfis[0]; - bzero(ctp->cfis, 64); + bzero(ctp->cfis, 16); fis[0] = 0x27; /* host to device */ fis[1] = (ccb->ccb_h.target_id & 0x0f); if (ccb->ccb_h.func_code == XPT_SCSI_IO) { @@ -2617,10 +2617,10 @@ ahci_setup_fis(device_t dev, struct ahci } fis[7] = ATA_D_LBA; fis[15] = ATA_A_4BIT; - bzero(ctp->acmd, 32); bcopy((ccb->ccb_h.flags & CAM_CDB_POINTER) ? ccb->csio.cdb_io.cdb_ptr : ccb->csio.cdb_io.cdb_bytes, ctp->acmd, ccb->csio.cdb_len); + bzero(ctp->acmd + ccb->csio.cdb_len, 32 - ccb->csio.cdb_len); } else if ((ccb->ataio.cmd.flags & CAM_ATAIO_CONTROL) == 0) { fis[1] |= 0x80; fis[2] = ccb->ataio.cmd.command; From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 17:23:11 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 5EB18A4B; Sun, 24 Mar 2013 17:23:11 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 50ED67E1; Sun, 24 Mar 2013 17:23:11 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2OHNBGH056839; Sun, 24 Mar 2013 17:23:11 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2OHNAY2056837; Sun, 24 Mar 2013 17:23:10 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201303241723.r2OHNAY2056837@svn.freebsd.org> From: Ian Lepore Date: Sun, 24 Mar 2013 17:23:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248689 - head/sys/dev/mmc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 17:23:11 -0000 Author: ian Date: Sun Mar 24 17:23:10 2013 New Revision: 248689 URL: http://svnweb.freebsd.org/changeset/base/248689 Log: Set the backlink in mmc commands to the mmc request that contains them. Modified: head/sys/dev/mmc/mmc.c head/sys/dev/mmc/mmcsd.c Modified: head/sys/dev/mmc/mmc.c ============================================================================== --- head/sys/dev/mmc/mmc.c Sun Mar 24 16:53:08 2013 (r248688) +++ head/sys/dev/mmc/mmc.c Sun Mar 24 17:23:10 2013 (r248689) @@ -412,6 +412,7 @@ mmc_wait_for_cmd(struct mmc_softc *sc, s memset(&mreq, 0, sizeof(mreq)); memset(cmd->resp, 0, sizeof(cmd->resp)); cmd->retries = retries; + cmd->mrq = &mreq; mreq.cmd = cmd; mmc_wait_for_req(sc, &mreq); return (cmd->error); Modified: head/sys/dev/mmc/mmcsd.c ============================================================================== --- head/sys/dev/mmc/mmcsd.c Sun Mar 24 16:53:08 2013 (r248688) +++ head/sys/dev/mmc/mmcsd.c Sun Mar 24 17:23:10 2013 (r248689) @@ -322,6 +322,7 @@ mmcsd_rw(struct mmcsd_softc *sc, struct memset(&req, 0, sizeof(req)); memset(&cmd, 0, sizeof(cmd)); memset(&stop, 0, sizeof(stop)); + cmd.mrq = &req; req.cmd = &cmd; cmd.data = &data; if (bp->bio_cmd == BIO_READ) { @@ -351,6 +352,7 @@ mmcsd_rw(struct mmcsd_softc *sc, struct stop.opcode = MMC_STOP_TRANSMISSION; stop.arg = 0; stop.flags = MMC_RSP_R1B | MMC_CMD_AC; + stop.mrq = &req; req.stop = &stop; } MMCBUS_WAIT_FOR_REQUEST(device_get_parent(dev), dev, @@ -398,6 +400,7 @@ mmcsd_delete(struct mmcsd_softc *sc, str /* Set erase start position. */ memset(&req, 0, sizeof(req)); memset(&cmd, 0, sizeof(cmd)); + cmd.mrq = &req; req.cmd = &cmd; if (mmc_get_card_type(dev) == mode_sd) cmd.opcode = SD_ERASE_WR_BLK_START; From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 17:35:20 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id B154A2E4 for ; Sun, 24 Mar 2013 17:35:20 +0000 (UTC) (envelope-from will@firepipe.net) Received: from mail-ia0-x22c.google.com (mail-ia0-x22c.google.com [IPv6:2607:f8b0:4001:c02::22c]) by mx1.freebsd.org (Postfix) with ESMTP id 82D86876 for ; Sun, 24 Mar 2013 17:35:20 +0000 (UTC) Received: by mail-ia0-f172.google.com with SMTP id l29so4840692iag.17 for ; Sun, 24 Mar 2013 10:35:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:x-gm-message-state; bh=cR2eJdUpItpMzpOw4PT/Sp56ZOb73hJ07SZ6lEmdCYg=; b=Yt7mCuwNzKwzk0AMmniLg4MQ7RMCd/A+PhfP7WWN+XCD1p9o4g9BPIhG2YkT216AZS LaCv63Bku0kgcbYDJ67iVR9ChADvo0qmWs0QtevHtwkfrgxymzpITP/4REN5hD50QbCo HKtwyYSRAr9uhR5XBBRuQmsecJwfepG8y8CrP19rQVDqdRZlhQzjJGpqe1tlqnRBA8N9 2wbMf82DH2j7ipVRUR4AGOmk/SByo0LmEwUkdhJcND4pn9lHoayLx2qb1aPevNwXGAsb TGGvEDzasp+aelVTbBrJyKTF1qFR7+yunhF9B7fXN7vL1Y3WBkdLRrGX8vcDqG9ftsLz yk3g== MIME-Version: 1.0 X-Received: by 10.50.119.102 with SMTP id kt6mr6004314igb.12.1364146520123; Sun, 24 Mar 2013 10:35:20 -0700 (PDT) Received: by 10.231.247.74 with HTTP; Sun, 24 Mar 2013 10:35:20 -0700 (PDT) In-Reply-To: References: <201303231511.r2NFBrrr074289@svn.freebsd.org> Date: Sun, 24 Mar 2013 11:35:20 -0600 Message-ID: Subject: Re: svn commit: r248649 - in head: share/man/man9 sys/kern sys/sys From: Will Andrews To: Matthew Fleming X-Gm-Message-State: ALoCoQnD+EhPuY7uwLf6sA6VPQNfvzVVSJENPY2qKYQfQjq0hsXNFNj2Nq9JkN1zm6JKMjpP2LcW Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Will Andrews X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 17:35:20 -0000 BTW, the TQ_ prefix is only used in subr_taskqueue.c; it is not used in taskqueue.h. It could appear unrelated when viewed in taskqueue(9) consumers. There are also other very long names in taskqueue.h, so I'm not sure it's really worth renaming the callback types. Thanks, --Will. On Sat, Mar 23, 2013 at 12:36 PM, wrote: > On Sat, Mar 23, 2013 at 9:45 AM, Will Andrews wrote: > > I agree about the name length, it is a bit obnoxious. However, it is > also > > descriptive. TQCB strikes me as perhaps a bit too far in the other > > direction. How about TQ_CALLBACK_? Is there an existing (pseudo) > > convention for callback names? > > I'm not sure FreeBSD has anything standard, but at $WORK we use CB or > cb frequently as an abbreviation for callback. TASKQUEUE -> TQ still > removes 7 letters, which is a start. :-) > > Thanks, > matthew > > > > On Sat, Mar 23, 2013 at 10:20 AM, wrote: > >> > >> On Sat, Mar 23, 2013 at 8:11 AM, Will Andrews wrote: > >> > Author: will > >> > Date: Sat Mar 23 15:11:53 2013 > >> > New Revision: 248649 > >> > URL: http://svnweb.freebsd.org/changeset/base/248649 > >> > > >> > Log: > >> > Extend taskqueue(9) to enable per-taskqueue callbacks. > >> > > >> > The scope of these callbacks is primarily to support actions that > >> > affect the > >> > taskqueue's thread environments. They are entirely optional, and > >> > consequently are introduced as a new API: taskqueue_set_callback(). > >> > > >> > This interface allows the caller to specify that a taskqueue > requires > >> > a > >> > callback and optional context pointer for a given callback type. > >> > > >> > The callback types included in this commit can be used to register a > >> > constructor and destructor for thread-local storage using osd(9). > >> > This > >> > allows a particular taskqueue to define that its threads require a > >> > specific > >> > type of TLS, without the need for a specially-orchestrated > task-based > >> > mechanism for startup and shutdown in order to accomplish it. > >> > > >> > Two callback types are supported at this point: > >> > > >> > - TASKQUEUE_CALLBACK_TYPE_INIT, called by every thread when it > starts, > >> > prior > >> > to processing any tasks. > >> > - TASKQUEUE_CALLBACK_TYPE_SHUTDOWN, called by every thread when it > >> > exits, > >> > after it has processed its last task but before the taskqueue is > >> > reclaimed. > >> > > >> > While I'm here: > >> > > >> > - Add two new macros, TQ_ASSERT_LOCKED and TQ_ASSERT_UNLOCKED, and > use > >> > them > >> > in appropriate locations. > >> > - Fix taskqueue.9 to mention taskqueue_start_threads(), which is a > >> > required > >> > interface for all consumers of taskqueue(9). > >> > > >> > Reviewed by: kib (all), eadler (taskqueue.9), brd (taskqueue.9) > >> > Approved by: ken (mentor) > >> > Sponsored by: Spectra Logic > >> > MFC after: 1 month > >> > > >> > Modified: > >> > head/share/man/man9/taskqueue.9 > >> > head/sys/kern/subr_taskqueue.c > >> > head/sys/sys/taskqueue.h > >> > > >> > Modified: head/share/man/man9/taskqueue.9 > >> > > >> > > ============================================================================== > >> > --- head/share/man/man9/taskqueue.9 Sat Mar 23 14:52:31 2013 > >> > (r248648) > >> > +++ head/share/man/man9/taskqueue.9 Sat Mar 23 15:11:53 2013 > >> > (r248649) > >> > @@ -53,12 +53,23 @@ struct task { > >> > void *ta_context; /* argument for > handler > >> > */ > >> > }; > >> > > >> > +enum taskqueue_callback_type { > >> > + TASKQUEUE_CALLBACK_TYPE_INIT, > >> > + TASKQUEUE_CALLBACK_TYPE_SHUTDOWN, > >> > +}; > >> > + > >> > +typedef void (*taskqueue_callback_fn)(void *context); > >> > + > >> > struct timeout_task; > >> > .Ed > >> > .Ft struct taskqueue * > >> > .Fn taskqueue_create "const char *name" "int mflags" > >> > "taskqueue_enqueue_fn enqueue" "void *context" > >> > .Ft struct taskqueue * > >> > .Fn taskqueue_create_fast "const char *name" "int mflags" > >> > "taskqueue_enqueue_fn enqueue" "void *context" > >> > +.Ft int > >> > +.Fn taskqueue_start_threads "struct taskqueue **tqp" "int count" "int > >> > pri" "const char *name" "..." > >> > +.Ft void > >> > +.Fn taskqueue_set_callback "struct taskqueue *queue" "enum > >> > taskqueue_callback_type cb_type" "taskqueue_callback_fn callback" > "void > >> > *context" > >> > .Ft void > >> > .Fn taskqueue_free "struct taskqueue *queue" > >> > .Ft int > >> > @@ -127,6 +138,23 @@ should be used to free the memory used b > >> > Any tasks that are on the queue will be executed at this time after > >> > which the thread servicing the queue will be signaled that it should > >> > exit. > >> > .Pp > >> > +Once a taskqueue has been created, its threads should be started > using > >> > +.Fn taskqueue_start_threads . > >> > +Callbacks may optionally be registered using > >> > +.Fn taskqueue_set_callback . > >> > +Currently, callbacks may be registered for the following purposes: > >> > +.Bl -tag -width TASKQUEUE_CALLBACK_TYPE_SHUTDOWN > >> > +.It Dv TASKQUEUE_CALLBACK_TYPE_INIT > >> > +This callback is called by every thread in the taskqueue, before it > >> > executes > >> > +any tasks. > >> > +This callback must be set before the taskqueue's threads are started. > >> > +.It Dv TASKQUEUE_CALLBACK_TYPE_SHUTDOWN > >> > +This callback is called by every thread in the taskqueue, after it > >> > executes > >> > +its last task. > >> > +This callback will always be called before the taskqueue structure is > >> > +reclaimed. > >> > +.El > >> > +.Pp > >> > To add a task to the list of tasks queued on a taskqueue, call > >> > .Fn taskqueue_enqueue > >> > with pointers to the queue and task. > >> > > >> > Modified: head/sys/kern/subr_taskqueue.c > >> > > >> > > ============================================================================== > >> > --- head/sys/kern/subr_taskqueue.c Sat Mar 23 14:52:31 2013 > >> > (r248648) > >> > +++ head/sys/kern/subr_taskqueue.c Sat Mar 23 15:11:53 2013 > >> > (r248649) > >> > @@ -63,6 +63,8 @@ struct taskqueue { > >> > int tq_spin; > >> > int tq_flags; > >> > int tq_callouts; > >> > + taskqueue_callback_fn tq_callbacks[TASKQUEUE_NUM_CALLBACKS]; > >> > + void > >> > *tq_cb_contexts[TASKQUEUE_NUM_CALLBACKS]; > >> > }; > >> > > >> > #define TQ_FLAGS_ACTIVE (1 << 0) > >> > @@ -78,6 +80,7 @@ struct taskqueue { > >> > else > >> > \ > >> > mtx_lock(&(tq)->tq_mutex); > >> > \ > >> > } while (0) > >> > +#define TQ_ASSERT_LOCKED(tq) mtx_assert(&(tq)->tq_mutex, > >> > MA_OWNED) > >> > > >> > #define TQ_UNLOCK(tq) > >> > \ > >> > do { > >> > \ > >> > @@ -86,6 +89,7 @@ struct taskqueue { > >> > else > >> > \ > >> > mtx_unlock(&(tq)->tq_mutex); > >> > \ > >> > } while (0) > >> > +#define TQ_ASSERT_UNLOCKED(tq) mtx_assert(&(tq)->tq_mutex, > >> > MA_NOTOWNED) > >> > > >> > void > >> > _timeout_task_init(struct taskqueue *queue, struct timeout_task > >> > *timeout_task, > >> > @@ -137,6 +141,23 @@ taskqueue_create(const char *name, int m > >> > MTX_DEF, "taskqueue"); > >> > } > >> > > >> > +void > >> > +taskqueue_set_callback(struct taskqueue *queue, > >> > + enum taskqueue_callback_type cb_type, taskqueue_callback_fn > >> > callback, > >> > + void *context) > >> > +{ > >> > + > >> > + KASSERT(((cb_type >= TASKQUEUE_CALLBACK_TYPE_MIN) && > >> > + (cb_type <= TASKQUEUE_CALLBACK_TYPE_MAX)), > >> > + ("Callback type %d not valid, must be %d-%d", cb_type, > >> > + TASKQUEUE_CALLBACK_TYPE_MIN, > TASKQUEUE_CALLBACK_TYPE_MAX)); > >> > + KASSERT((queue->tq_callbacks[cb_type] == NULL), > >> > + ("Re-initialization of taskqueue callback?")); > >> > + > >> > + queue->tq_callbacks[cb_type] = callback; > >> > + queue->tq_cb_contexts[cb_type] = context; > >> > +} > >> > + > >> > /* > >> > * Signal a taskqueue thread to terminate. > >> > */ > >> > @@ -293,7 +314,7 @@ taskqueue_run_locked(struct taskqueue *q > >> > struct task *task; > >> > int pending; > >> > > >> > - mtx_assert(&queue->tq_mutex, MA_OWNED); > >> > + TQ_ASSERT_LOCKED(queue); > >> > tb.tb_running = NULL; > >> > TAILQ_INSERT_TAIL(&queue->tq_active, &tb, tb_link); > >> > > >> > @@ -332,7 +353,7 @@ task_is_running(struct taskqueue *queue, > >> > { > >> > struct taskqueue_busy *tb; > >> > > >> > - mtx_assert(&queue->tq_mutex, MA_OWNED); > >> > + TQ_ASSERT_LOCKED(queue); > >> > TAILQ_FOREACH(tb, &queue->tq_active, tb_link) { > >> > if (tb->tb_running == task) > >> > return (1); > >> > @@ -489,6 +510,18 @@ taskqueue_start_threads(struct taskqueue > >> > return (0); > >> > } > >> > > >> > +static inline void > >> > +taskqueue_run_callback(struct taskqueue *tq, > >> > + enum taskqueue_callback_type cb_type) > >> > +{ > >> > + taskqueue_callback_fn tq_callback; > >> > + > >> > + TQ_ASSERT_UNLOCKED(tq); > >> > + tq_callback = tq->tq_callbacks[cb_type]; > >> > + if (tq_callback != NULL) > >> > + tq_callback(tq->tq_cb_contexts[cb_type]); > >> > +} > >> > + > >> > void > >> > taskqueue_thread_loop(void *arg) > >> > { > >> > @@ -496,6 +529,7 @@ taskqueue_thread_loop(void *arg) > >> > > >> > tqp = arg; > >> > tq = *tqp; > >> > + taskqueue_run_callback(tq, TASKQUEUE_CALLBACK_TYPE_INIT); > >> > TQ_LOCK(tq); > >> > while ((tq->tq_flags & TQ_FLAGS_ACTIVE) != 0) { > >> > taskqueue_run_locked(tq); > >> > @@ -510,6 +544,15 @@ taskqueue_thread_loop(void *arg) > >> > } > >> > taskqueue_run_locked(tq); > >> > > >> > + /* > >> > + * This thread is on its way out, so just drop the lock > >> > temporarily > >> > + * in order to call the shutdown callback. This allows the > >> > callback > >> > + * to look at the taskqueue, even just before it dies. > >> > + */ > >> > + TQ_UNLOCK(tq); > >> > + taskqueue_run_callback(tq, TASKQUEUE_CALLBACK_TYPE_SHUTDOWN); > >> > + TQ_LOCK(tq); > >> > + > >> > /* rendezvous with thread that asked us to terminate */ > >> > tq->tq_tcount--; > >> > wakeup_one(tq->tq_threads); > >> > @@ -525,7 +568,7 @@ taskqueue_thread_enqueue(void *context) > >> > tqp = context; > >> > tq = *tqp; > >> > > >> > - mtx_assert(&tq->tq_mutex, MA_OWNED); > >> > + TQ_ASSERT_LOCKED(tq); > >> > wakeup_one(tq); > >> > } > >> > > >> > > >> > Modified: head/sys/sys/taskqueue.h > >> > > >> > > ============================================================================== > >> > --- head/sys/sys/taskqueue.h Sat Mar 23 14:52:31 2013 > >> > (r248648) > >> > +++ head/sys/sys/taskqueue.h Sat Mar 23 15:11:53 2013 > >> > (r248649) > >> > @@ -47,6 +47,16 @@ struct timeout_task { > >> > int f; > >> > }; > >> > > >> > +enum taskqueue_callback_type { > >> > + TASKQUEUE_CALLBACK_TYPE_INIT, > >> > + TASKQUEUE_CALLBACK_TYPE_SHUTDOWN, > >> > +}; > >> > +#define TASKQUEUE_CALLBACK_TYPE_MIN > >> > TASKQUEUE_CALLBACK_TYPE_INIT > >> > +#define TASKQUEUE_CALLBACK_TYPE_MAX > >> > TASKQUEUE_CALLBACK_TYPE_SHUTDOWN > >> > +#define TASKQUEUE_NUM_CALLBACKS > >> > TASKQUEUE_CALLBACK_TYPE_MAX + 1 > >> > >> This need parentheses to defensively guard against unexpected > >> precedence of operators. > >> > >> While here, TASKQUEUE_CALLBACK_ is a very long prefix (19 characters!) > >> Can this be named TQCB_ instead so it's not so verbose? > >> > >> Thanks, > >> matthew > > > > > From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 18:48:02 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id AEF05C41; Sun, 24 Mar 2013 18:48:02 +0000 (UTC) (envelope-from gleb.kurtsou@gmail.com) Received: from mail-pd0-f181.google.com (mail-pd0-f181.google.com [209.85.192.181]) by mx1.freebsd.org (Postfix) with ESMTP id 7BD57E89; Sun, 24 Mar 2013 18:48:02 +0000 (UTC) Received: by mail-pd0-f181.google.com with SMTP id q10so2204410pdj.40 for ; Sun, 24 Mar 2013 11:47:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=017UlZHTF4ncXz8OGbpHl9WkSL2+sWuYuXTT8icuNY0=; b=gLUNzRE3h6ru4EeGTtZTBiVr1n3wdLRmthHB23ZHPdZlfmb6eB/enQV6o9PbYVWCw/ za/ObFOH/qs0x3DO+aEq753eYjr2EwaRi5OF+TrRaAyQchi1QumHFY2lozXqF1xU5zdQ Hh/19UxYGqs8SKoo8k1vGb534ebHZdI3fNs3gTcuvacYEjvzLb7sitfpNWcB/bV5myKo dHs4uTQWi547zoBU0K6QDIbCyAtxsC17KZzfRXQiLJGGh2S5ZD9MOhBSbYSES8J5jMjM gi5J9/se3hW05P7tTYv9cie7R47cnyQsrgeUzwfDrvNDqRk7XZESGx0OswoPuHI+gZ+G vT+Q== X-Received: by 10.66.164.6 with SMTP id ym6mr3973215pab.92.1364150876165; Sun, 24 Mar 2013 11:47:56 -0700 (PDT) Received: from localhost (c-67-160-248-74.hsd1.ca.comcast.net. [67.160.248.74]) by mx.google.com with ESMTPS id rl3sm10385986pbb.28.2013.03.24.11.47.54 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 24 Mar 2013 11:47:55 -0700 (PDT) Sender: Gleb Kurtsou Date: Sun, 24 Mar 2013 11:47:57 -0700 From: Gleb Kurtsou To: Mark Johnston Subject: Re: svn commit: r244915 - head/share/mk Message-ID: <20130324184756.GA3874@reks> References: <201212312154.qBVLsh4v014794@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <201212312154.qBVLsh4v014794@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 18:48:02 -0000 On (31/12/2012 21:54), Mark Johnston wrote: > Author: markj > Date: Mon Dec 31 21:54:43 2012 > New Revision: 244915 > URL: http://svnweb.freebsd.org/changeset/base/244915 > > Log: > Explicitly specify that the beforelinking target depends on the > generated object files, ensuring that the beforelinking recipe won't be > executed until compilation has finished. > > Also define SHLIB_NAME_FULL to denote ${SHLIB_NAME}.debug if > DEBUG_FILES is set and ${SHLIB_NAME} otherwise, which helps avoid > obfuscating the compilation and linking rules. Shouldn't ${SHLIB_NAME}.debug and ${SHLIB_NAME}.symbols be added to CLEANFILES? Thanks, Gleb. > > Reviewed by: emaste > Approved by: emaste (co-mentor) > > Modified: > head/share/mk/bsd.lib.mk > head/share/mk/bsd.prog.mk > > Modified: head/share/mk/bsd.lib.mk > ============================================================================== > --- head/share/mk/bsd.lib.mk Mon Dec 31 21:19:44 2012 (r244914) > +++ head/share/mk/bsd.lib.mk Mon Dec 31 21:54:43 2012 (r244915) > @@ -165,19 +165,22 @@ SOBJS+= ${OBJS:.o=.So} > .if defined(SHLIB_NAME) > _LIBS+= ${SHLIB_NAME} > > +.if defined(DEBUG_FLAGS) > +SHLIB_NAME_FULL=${SHLIB_NAME}.debug > +.else > +SHLIB_NAME_FULL=${SHLIB_NAME} > +.endif > + > SOLINKOPTS= -shared -Wl,-x > .if !defined(ALLOW_SHARED_TEXTREL) > SOLINKOPTS+= -Wl,--fatal-warnings -Wl,--warn-shared-textrel > .endif > > .if target(beforelinking) > -${SHLIB_NAME}: beforelinking > -.endif > -.if defined(DEBUG_FLAGS) > -${SHLIB_NAME}.debug: ${SOBJS} > -.else > -${SHLIB_NAME}: ${SOBJS} > +beforelinking: ${SOBJS} > +${SHLIB_NAME_FULL}: beforelinking > .endif > +${SHLIB_NAME_FULL}: ${SOBJS} > @${ECHO} building shared library ${SHLIB_NAME} > @rm -f ${SHLIB_NAME} ${SHLIB_LINK} > .if defined(SHLIB_LINK) > @@ -197,12 +200,12 @@ ${SHLIB_NAME}: ${SOBJS} > .endif > > .if defined(DEBUG_FLAGS) > -${SHLIB_NAME}: ${SHLIB_NAME}.debug ${SHLIB_NAME}.symbols > +${SHLIB_NAME}: ${SHLIB_NAME_FULL} ${SHLIB_NAME}.symbols > ${OBJCOPY} --strip-debug --add-gnu-debuglink=${SHLIB_NAME}.symbols \ > - ${SHLIB_NAME}.debug ${.TARGET} > + ${SHLIB_NAME_FULL} ${.TARGET} > > -${SHLIB_NAME}.symbols: ${SHLIB_NAME}.debug > - ${OBJCOPY} --only-keep-debug ${SHLIB_NAME}.debug ${.TARGET} > +${SHLIB_NAME}.symbols: ${SHLIB_NAME_FULL} > + ${OBJCOPY} --only-keep-debug ${SHLIB_NAME_FULL} ${.TARGET} > .endif > .endif > > > Modified: head/share/mk/bsd.prog.mk > ============================================================================== > --- head/share/mk/bsd.prog.mk Mon Dec 31 21:19:44 2012 (r244914) > +++ head/share/mk/bsd.prog.mk Mon Dec 31 21:54:43 2012 (r244915) > @@ -46,6 +46,7 @@ PROG= ${PROG_CXX} > OBJS+= ${SRCS:N*.h:R:S/$/.o/g} > > .if target(beforelinking) > +beforelinking: ${OBJS} > ${PROG}: beforelinking > .endif > ${PROG}: ${OBJS} > @@ -75,6 +76,7 @@ SRCS= ${PROG}.c > OBJS= ${PROG}.o > > .if target(beforelinking) > +beforelinking: ${OBJS} > ${PROG}: beforelinking > .endif > ${PROG}: ${OBJS} From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 19:12:09 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 8A78C2A0; Sun, 24 Mar 2013 19:12:09 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 79ED7F74; Sun, 24 Mar 2013 19:12:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2OJC99T090245; Sun, 24 Mar 2013 19:12:09 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2OJC8fM090238; Sun, 24 Mar 2013 19:12:08 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201303241912.r2OJC8fM090238@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Sun, 24 Mar 2013 19:12:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248690 - in head: cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/tracemem cddl/contrib/opensolaris/lib/libdtrace/common sys/cddl/contrib/opensolaris/uts/common/dtrace sys/cddl/con... X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 19:12:09 -0000 Author: pfg Date: Sun Mar 24 19:12:08 2013 New Revision: 248690 URL: http://svnweb.freebsd.org/changeset/base/248690 Log: Dtrace: add optional size argument to tracemem(). Merge change from illumos: 1455 DTrace tracemem() should take an optional size argument Our local enhancements to dt_print_bytes were equivalent to those in illumos but we made it match the illumos version to ease further code merges. For now leave out tst.smallsize.d and tst.smallsize.d.out since those don't seem to work cleanly on FreeBSD. This change bumps the DT_VERS_* number to 1.7.1 in accordance to what is done in illumos. Illumos Revision: 13457:571b0355c2e3 Reference: https://www.illumos.org/issues/1455 Tested by: Fabian Keil Obtained from: Illumos MFC after: 1 month Added: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_ARGS.d - copied unchanged from r248673, vendor/illumos/dist/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_ARGS.d head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_DYNSIZE.d - copied unchanged from r248673, vendor/illumos/dist/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_DYNSIZE.d head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/tracemem/tst.dynsize.d - copied unchanged from r248673, vendor/illumos/dist/cmd/dtrace/test/tst/common/tracemem/tst.dynsize.d head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/tracemem/tst.dynsize.d.out - copied unchanged from r248673, vendor/illumos/dist/cmd/dtrace/test/tst/common/tracemem/tst.dynsize.d.out Deleted: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/tracemem/err.D_PROTO_LEN.toomany.d Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_errtags.h head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h Copied: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_ARGS.d (from r248673, vendor/illumos/dist/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_ARGS.d) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_ARGS.d Sun Mar 24 19:12:08 2013 (r248690, copy of r248673, vendor/illumos/dist/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_ARGS.d) @@ -0,0 +1,29 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +BEGIN +{ + tracemem(`dtrace_zero, 256, 0, "fishpong"); +} Copied: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_DYNSIZE.d (from r248673, vendor/illumos/dist/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_DYNSIZE.d) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_DYNSIZE.d Sun Mar 24 19:12:08 2013 (r248690, copy of r248673, vendor/illumos/dist/cmd/dtrace/test/tst/common/tracemem/err.D_TRACEMEM_DYNSIZE.d) @@ -0,0 +1,30 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +BEGIN +{ + tracemem(`dtrace_zero, 256, "fishpong"); + exit(0); +} Copied: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/tracemem/tst.dynsize.d (from r248673, vendor/illumos/dist/cmd/dtrace/test/tst/common/tracemem/tst.dynsize.d) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/tracemem/tst.dynsize.d Sun Mar 24 19:12:08 2013 (r248690, copy of r248673, vendor/illumos/dist/cmd/dtrace/test/tst/common/tracemem/tst.dynsize.d) @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +#pragma D option quiet + +BEGIN +{ + i = -10; +} + +tick-10ms +/i++ < 150/ +{ + printf("%d:", i); + tracemem(`dtrace_zero, 128, i); + printf("\n"); +} + +tick-10ms +/i >= 150/ +{ + exit(0); +} Copied: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/tracemem/tst.dynsize.d.out (from r248673, vendor/illumos/dist/cmd/dtrace/test/tst/common/tracemem/tst.dynsize.d.out) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/tracemem/tst.dynsize.d.out Sun Mar 24 19:12:08 2013 (r248690, copy of r248673, vendor/illumos/dist/cmd/dtrace/test/tst/common/tracemem/tst.dynsize.d.out) @@ -0,0 +1,1313 @@ +-9: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + +-8: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + +-7: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + +-6: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + +-5: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + +-4: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + +-3: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + +-2: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + +-1: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + +0: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + +1: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 . + +2: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 .. + +3: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 ... + +4: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 .... + +5: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 ..... + +6: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 ...... + +7: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 ....... + +8: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 ........ + +9: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 ......... + +10: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 .......... + +11: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 ........... + +12: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 ............ + +13: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 ............. + +14: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .............. + +15: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ............... + +16: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + +17: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 . + +18: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 .. + +19: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 ... + +20: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 .... + +21: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 ..... + +22: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 ...... + +23: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 ....... + +24: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 ........ + +25: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 ......... + +26: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 .......... + +27: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 ........... + +28: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 ............ + +29: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 ............. + +30: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .............. + +31: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ............... + +32: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + +33: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 . + +34: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 .. + +35: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 ... + +36: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 .... + +37: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 ..... + +38: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 ...... + +39: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 ....... + +40: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 ........ + +41: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 ......... + +42: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 .......... + +43: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 ........... + +44: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 ............ + +45: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 ............. + +46: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .............. + +47: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ............... + +48: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + +49: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 . + +50: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 .. + +51: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 ... + +52: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 .... + +53: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 ..... + +54: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 ...... + +55: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 ....... + +56: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 ........ + +57: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 ......... + +58: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 .......... + +59: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 ........... + +60: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 ............ + +61: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 ............. + +62: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .............. + +63: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ............... + +64: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + +65: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 . + +66: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 .. + +67: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 ... + +68: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 .... + +69: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 ..... + +70: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 ...... + +71: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 ....... + +72: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 ........ + +73: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 ......... + +74: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 .......... + +75: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 ........... + +76: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 ............ + +77: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 ............. + +78: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .............. + +79: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ............... + +80: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + +81: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 . + +82: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 .. + +83: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 ... + +84: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 .... + +85: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 ..... + +86: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 ...... + +87: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 ....... + +88: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 ........ + +89: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 ......... + +90: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 .......... + +91: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 ........... + +92: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 ............ + +93: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 ............. + +94: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .............. + +95: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ............... + +96: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + +97: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 . + +98: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 .. + +99: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 ... + +100: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 .... + +101: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 ..... + +102: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 00 ...... + +103: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 00 00 ....... + +104: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 00 00 00 ........ + +105: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 00 00 00 00 ......... + +106: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 00 00 00 00 00 .......... + +107: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 00 00 00 00 00 00 ........... + +108: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 00 00 00 00 00 00 00 ............ + +109: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 00 00 00 00 00 00 00 00 ............. + +110: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .............. + +111: + 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef + 0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ............... + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 20:18:42 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 6F337536; Sun, 24 Mar 2013 20:18:42 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-ia0-x22b.google.com (mail-ia0-x22b.google.com [IPv6:2607:f8b0:4001:c02::22b]) by mx1.freebsd.org (Postfix) with ESMTP id 27265283; Sun, 24 Mar 2013 20:18:42 +0000 (UTC) Received: by mail-ia0-f171.google.com with SMTP id z13so4976883iaz.2 for ; Sun, 24 Mar 2013 13:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=d+Dm0x3yj4pV2Eur/IXn3+mKqk/D39kg1Z3iM/Nfmms=; b=AOIQpWBIvhB+atQQfNchg7RJtZoqydi75THi4oJbdQn9vWKV0Ww/FelrcY71G3a5w6 UxUywFnx59bMFQ1c/xxJeEoOCAd3y2IiZe9zQLl0uv61aKm1WRfn+4+eyWPLKABZ66Ff KBcknIQzJiardx7cIt5x6m0lzwGqtedkK+ZfZiA84J7tJU+yHrphTILe5abInFbv9bcQ G0muB78Guqumj14P35Fl2WvUopq3TN0a/x0JrmemeR+lb87rMCOyhi7gVeWccJg4BMVc rCGLXmawuzZOKyflSEURd8a8p+sda/cAqNaT7xaehIrzRY/987qlukHiKYgX++bccTo2 VSgQ== X-Received: by 10.50.153.198 with SMTP id vi6mr9752745igb.112.1364156321863; Sun, 24 Mar 2013 13:18:41 -0700 (PDT) Received: from oddish ([66.11.160.25]) by mx.google.com with ESMTPS id xc3sm16910397igb.10.2013.03.24.13.18.39 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 24 Mar 2013 13:18:41 -0700 (PDT) Sender: Mark Johnston Date: Sun, 24 Mar 2013 16:18:30 -0400 From: Mark Johnston To: Gleb Kurtsou Subject: Re: svn commit: r244915 - head/share/mk Message-ID: <20130324201830.GA1682@oddish> References: <201212312154.qBVLsh4v014794@svn.freebsd.org> <20130324184756.GA3874@reks> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130324184756.GA3874@reks> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 20:18:42 -0000 On Sun, Mar 24, 2013 at 11:47:57AM -0700, Gleb Kurtsou wrote: > On (31/12/2012 21:54), Mark Johnston wrote: > > Author: markj > > Date: Mon Dec 31 21:54:43 2012 > > New Revision: 244915 > > URL: http://svnweb.freebsd.org/changeset/base/244915 > > > > Log: > > Explicitly specify that the beforelinking target depends on the > > generated object files, ensuring that the beforelinking recipe won't be > > executed until compilation has finished. > > > > Also define SHLIB_NAME_FULL to denote ${SHLIB_NAME}.debug if > > DEBUG_FILES is set and ${SHLIB_NAME} otherwise, which helps avoid > > obfuscating the compilation and linking rules. > > Shouldn't ${SHLIB_NAME}.debug and ${SHLIB_NAME}.symbols be added to > CLEANFILES? > > Thanks, > Gleb. Yes, I think you're right. Most of the time it doesn't matter since bsd.lib.mk runs "rm -rf lib${LIB}.so.*" when running make clean. But if a library makefile overrides SHLIB_NAME and sets it to something that doesn't have "lib${LIB}.so." as a prefix, make clean won't remove the .debug and .symbols files. I see one example of this in the tree - sys/boot/userboot/userboot. Is that how you noticed this? I'm still testing the patch below, but I think it should fix the problem. Thanks, -Mark diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index 3664210..38c8de3 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -202,6 +202,7 @@ ${SHLIB_NAME_FULL}: ${SOBJS} .endif .if defined(DEBUG_FLAGS) +CLEANFILES+= ${SHLIB_NAME_FULL} ${SHLIB_NAME}.symbols ${SHLIB_NAME}: ${SHLIB_NAME_FULL} ${SHLIB_NAME}.symbols ${OBJCOPY} --strip-debug --add-gnu-debuglink=${SHLIB_NAME}.symbols \ ${SHLIB_NAME_FULL} ${.TARGET} @@ -209,7 +210,7 @@ ${SHLIB_NAME}: ${SHLIB_NAME_FULL} ${SHLIB_NAME}.symbols ${SHLIB_NAME}.symbols: ${SHLIB_NAME_FULL} ${OBJCOPY} --only-keep-debug ${SHLIB_NAME_FULL} ${.TARGET} .endif -.endif +.endif #defined(SHLIB_NAME) .if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no" _LIBS+= lib${LIB}_pic.a @@ -398,10 +399,7 @@ clean: .endif rm -f ${SHLIB_LINK} .endif -.if defined(LIB) && !empty(LIB) - rm -f lib${LIB}.so.* lib${LIB}.so -.endif -.endif +.endif # defined(SHLIB_NAME) .if defined(WANT_LINT) && defined(LIB) && !empty(LIB) rm -f ${LINTOBJS} .endif From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 22:37:10 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id A2F09C3A; Sun, 24 Mar 2013 22:37:10 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 94DDA964; Sun, 24 Mar 2013 22:37:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2OMbAlW053203; Sun, 24 Mar 2013 22:37:10 GMT (envelope-from mckusick@svn.freebsd.org) Received: (from mckusick@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2OMbAAH053202; Sun, 24 Mar 2013 22:37:10 GMT (envelope-from mckusick@svn.freebsd.org) Message-Id: <201303242237.r2OMbAAH053202@svn.freebsd.org> From: Kirk McKusick Date: Sun, 24 Mar 2013 22:37:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248691 - head/sbin/fsck_ffs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 22:37:10 -0000 Author: mckusick Date: Sun Mar 24 22:37:10 2013 New Revision: 248691 URL: http://svnweb.freebsd.org/changeset/base/248691 Log: Note that output is in seconds, not msec. KNF indentation. No functional change. No change to printf strings. No change to casting of printf arguments. Reported by: Bruce Evans Modified: head/sbin/fsck_ffs/fsutil.c Modified: head/sbin/fsck_ffs/fsutil.c ============================================================================== --- head/sbin/fsck_ffs/fsutil.c Sun Mar 24 19:12:08 2013 (r248690) +++ head/sbin/fsck_ffs/fsutil.c Sun Mar 24 22:37:10 2013 (r248691) @@ -507,7 +507,7 @@ static void printIOstats(void) clock_gettime(CLOCK_REALTIME_PRECISE, &finishpass); timespecsub(&finishpass, &startpass); - printf("Running time: %jd.%03ld msec\n", + printf("Running time: %jd.%03ld sec\n", (intmax_t)finishpass.tv_sec, finishpass.tv_nsec / 1000000); printf("buffer reads by type:\n"); for (totalmsec = 0, i = 0; i < BT_NUMBUFTYPES; i++) @@ -518,7 +518,8 @@ static void printIOstats(void) for (i = 0; i < BT_NUMBUFTYPES; i++) { if (readcnt[i] == 0) continue; - msec = readtime[i].tv_sec * 1000 + readtime[i].tv_nsec / 1000000; + msec = + readtime[i].tv_sec * 1000 + readtime[i].tv_nsec / 1000000; printf("%21s:%8ld %2ld.%ld%% %4jd.%03ld sec %2lld.%lld%%\n", buftype[i], readcnt[i], readcnt[i] * 100 / diskreads, (readcnt[i] * 1000 / diskreads) % 10, From owner-svn-src-all@FreeBSD.ORG Sun Mar 24 22:48:45 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id C2D33377; Sun, 24 Mar 2013 22:48:45 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id B526B9F2; Sun, 24 Mar 2013 22:48:45 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2OMmjgr056631; Sun, 24 Mar 2013 22:48:45 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2OMmjBG056630; Sun, 24 Mar 2013 22:48:45 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201303242248.r2OMmjBG056630@svn.freebsd.org> From: Jilles Tjoelker Date: Sun, 24 Mar 2013 22:48:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248692 - head/bin/sh X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 22:48:45 -0000 Author: jilles Date: Sun Mar 24 22:48:45 2013 New Revision: 248692 URL: http://svnweb.freebsd.org/changeset/base/248692 Log: sh(1): Mention possible ambiguities with $(( and ((. In some other shells, things like $((a);(b)) are command substitutions. Also, there are shells that have an extension ((ARITH)) that evaluates an arithmetic expression and returns status 1 if the result is zero, 0 otherwise. This extension may lead to ambiguity with two subshells starting in sequence. Modified: head/bin/sh/sh.1 Modified: head/bin/sh/sh.1 ============================================================================== --- head/bin/sh/sh.1 Sun Mar 24 22:37:10 2013 (r248691) +++ head/bin/sh/sh.1 Sun Mar 24 22:48:45 2013 (r248692) @@ -32,7 +32,7 @@ .\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" $FreeBSD$ .\" -.Dd January 22, 2013 +.Dd March 24, 2013 .Dt SH 1 .Os .Sh NAME @@ -1061,6 +1061,9 @@ A subshell environment may be implemente If job control is enabled in an interactive shell, commands grouped in parentheses can be suspended and continued as a unit. .Pp +For compatibility with other shells, +two open parentheses in sequence should be separated by whitespace. +.Pp The second form never forks another shell, so it is slightly more efficient. Grouping commands together this way allows the user to @@ -1618,6 +1621,16 @@ and .Ic times returns information about the same process if they are the only command in a command substitution. +.Pp +If a command substitution of the +.Li $( +form begins with a subshell, +the +.Li $( +and +.Li ( +must be separated by whitespace +to avoid ambiguity with arithmetic expansion. .Ss Arithmetic Expansion Arithmetic expansion provides a mechanism for evaluating an arithmetic expression and substituting its value. From owner-svn-src-all@FreeBSD.ORG Mon Mar 25 00:31:15 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 548C9C6D; Mon, 25 Mar 2013 00:31:15 +0000 (UTC) (envelope-from gleb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 43C04DEC; Mon, 25 Mar 2013 00:31:15 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2P0VFgj089899; Mon, 25 Mar 2013 00:31:15 GMT (envelope-from gleb@svn.freebsd.org) Received: (from gleb@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2P0VEf8089892; Mon, 25 Mar 2013 00:31:14 GMT (envelope-from gleb@svn.freebsd.org) Message-Id: <201303250031.r2P0VEf8089892@svn.freebsd.org> From: Gleb Kurtsou Date: Mon, 25 Mar 2013 00:31:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248693 - in head/tools/tools/shlib-compat: . test test/libtest1 test/libtest2 test/libtest3 test/libtestsys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Mar 2013 00:31:15 -0000 Author: gleb Date: Mon Mar 25 00:31:14 2013 New Revision: 248693 URL: http://svnweb.freebsd.org/changeset/base/248693 Log: Add shlib-compat under tools. shlib-compat is ABI compatibility checker for shared libraries with symbol versioning. Added: head/tools/tools/shlib-compat/ head/tools/tools/shlib-compat/Makefile.sysfake (contents, props changed) head/tools/tools/shlib-compat/README (contents, props changed) head/tools/tools/shlib-compat/makesyscalls-fake.sh (contents, props changed) head/tools/tools/shlib-compat/shlib-compat-dirs.sh (contents, props changed) head/tools/tools/shlib-compat/shlib-compat.py (contents, props changed) head/tools/tools/shlib-compat/test/ head/tools/tools/shlib-compat/test/Makefile (contents, props changed) head/tools/tools/shlib-compat/test/Makefile.inc (contents, props changed) head/tools/tools/shlib-compat/test/Versions.def (contents, props changed) head/tools/tools/shlib-compat/test/libtest1/ head/tools/tools/shlib-compat/test/libtest1/Makefile (contents, props changed) head/tools/tools/shlib-compat/test/libtest1/Symbol.map (contents, props changed) head/tools/tools/shlib-compat/test/libtest1/test.c (contents, props changed) head/tools/tools/shlib-compat/test/libtest2/ head/tools/tools/shlib-compat/test/libtest2/Makefile (contents, props changed) head/tools/tools/shlib-compat/test/libtest2/Symbol.map (contents, props changed) head/tools/tools/shlib-compat/test/libtest2/test.c (contents, props changed) head/tools/tools/shlib-compat/test/libtest3/ head/tools/tools/shlib-compat/test/libtest3/Makefile (contents, props changed) head/tools/tools/shlib-compat/test/libtest3/Symbol.map (contents, props changed) head/tools/tools/shlib-compat/test/libtest3/test.c (contents, props changed) head/tools/tools/shlib-compat/test/libtestsys/ head/tools/tools/shlib-compat/test/libtestsys/Makefile (contents, props changed) head/tools/tools/shlib-compat/test/libtestsys/Symbol.map (contents, props changed) head/tools/tools/shlib-compat/test/regress.1-1.out (contents, props changed) head/tools/tools/shlib-compat/test/regress.1-2.out (contents, props changed) head/tools/tools/shlib-compat/test/regress.1-3.out (contents, props changed) head/tools/tools/shlib-compat/test/regress.2-1.out (contents, props changed) head/tools/tools/shlib-compat/test/regress.2-2.out (contents, props changed) head/tools/tools/shlib-compat/test/regress.2-3.out (contents, props changed) head/tools/tools/shlib-compat/test/regress.3-1.out (contents, props changed) head/tools/tools/shlib-compat/test/regress.3-2.out (contents, props changed) head/tools/tools/shlib-compat/test/regress.3-3.out (contents, props changed) head/tools/tools/shlib-compat/test/regress.m4 (contents, props changed) head/tools/tools/shlib-compat/test/regress.sh (contents, props changed) head/tools/tools/shlib-compat/test/regress.t (contents, props changed) Added: head/tools/tools/shlib-compat/Makefile.sysfake ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/tools/shlib-compat/Makefile.sysfake Mon Mar 25 00:31:14 2013 (r248693) @@ -0,0 +1,9 @@ +# $FreeBSD$ + +SRCS+= sysfake.c +CLEANFILES+= sysfake.c + +sysfake.c: ${.CURDIR}/../../sys/kern/syscalls.master + sh ${.CURDIR}/../../tools/tools/shlib-compat/makesyscalls-fake.sh \ + ${.CURDIR}/../../sys/kern/syscalls.master > ${.TARGET} + Added: head/tools/tools/shlib-compat/README ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/tools/shlib-compat/README Mon Mar 25 00:31:14 2013 (r248693) @@ -0,0 +1,22 @@ +ABI compatibility checker for shared libraries with symbol versioning. + +shlib-compat uses dwarf debugging symbols to recreate definitions of +exported symbols, including function arguments and structural types. + +The shlib-compat.py script requires devel/dwarfdump port to be +installed. + + +Syscalls in libc are implemented as assembly stubs and thus have no +debugging symbols attached. To enable sysfake stubs rebuild libc +adding the following to /etc/make.conf: + +.if ${.CURDIR:M/usr/src/lib/libc} +.include "../../tools/tools/shlib-compat/Makefile.sysfake" +.endif + +To compare libc.so versions compiled with sysfake stubs: +./shlib-compat.py -v --alias-prefix __sysfake_ \ + --alias-prefix __sysfake_freebsd8_ \ + --exclude-ver FBSDprivate \ + --out-orig out-orig.c --out-new out-new.c libc.so.7.orig libc.so.7.new Added: head/tools/tools/shlib-compat/makesyscalls-fake.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/tools/shlib-compat/makesyscalls-fake.sh Mon Mar 25 00:31:14 2013 (r248693) @@ -0,0 +1,130 @@ +#! /bin/sh - +# +# $FreeBSD$ + +set -e + +case $# in + 0) echo "usage: $0 input-file " 1>&2 + exit 1 + ;; +esac + +if [ -n "$2" -a -f "$2" ]; then + . $2 +fi + +sed -e ' +s/\$//g +:join + /\\$/{a\ + + N + s/\\\n// + b join + } +2,${ + /^#/!s/\([{}()*,]\)/ \1 /g +} +' < $1 | awk ' + BEGIN { + printf "#include \n" + printf "#include \n" + printf "\n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "#include \n" + printf "\n" + printf "#ifndef _ACL_PRIVATE\n" + printf "#define _ACL_PRIVATE\n" + printf "#endif\n" + printf "#include \n" + printf "\n" + printf "#ifndef EBUSY\n" + printf "#define errno 0\n" + printf "#define EBUSY 0\n" + printf "#endif\n" + printf "#include \n" + printf "\n" + # existing compat shims + printf "struct ostat;\n" + printf "struct nstat;\n" + printf "struct ostatfs;\n" + printf "struct osigaction;\n" + printf "struct osigcontext;\n" + printf "struct oaiocb;\n" + printf "union semun_old;\n" + printf "typedef unsigned int osigset_t;\n" + printf "struct msqid_ds_old;\n" + printf "struct shmid_ds_old;\n" + # TODO + printf "struct ucontext4;\n" + printf "struct sctp_sndrcvinfo;\n" + printf "\n" + } + NF < 4 || $1 !~ /^[0-9]+$/ { + next + } + $3 ~ "UNIMPL" || $3 ~ "OBSOL" || $3 ~ "NODEF" || $3 ~ "NOPROTO" || + $3 ~ "NOSTD"{ + next + } + $4 == "{" { + if ($3 ~ /COMPAT[0-9]*/) { + n = split($3, flags, /\|/) + for (i = 1; i <= n; i++) { + if (flags[i] == "COMPAT") { + $6 = "o" $6 + } else if (flags[i] ~ /COMPAT[0-9]+/) { + sub(/COMPAT/, "freebsd", flags[i]) + $6 = flags[i] "_" $6 + } + } + } + $6 = "__sysfake_" $6 + r = "" + if ($5 != "void") + r = "0" + def = "" + impl = "" + for ( i = 5; i <= NF; i++) { + if ($i == ";") + break; + if ($i == "," || $i == ")") + impl = impl " __unused" + impl = impl " " $i + def = def " " $i + } + printf "%s;\n", def + printf "%s\n{ return %s; }\n", impl, r + next + } + { + printf "invalid line: " + print + } +' Added: head/tools/tools/shlib-compat/shlib-compat-dirs.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/tools/shlib-compat/shlib-compat-dirs.sh Mon Mar 25 00:31:14 2013 (r248693) @@ -0,0 +1,48 @@ +#!/bin/sh -e +# +# $FreeBSD$ + +SHLIB_COMPAT=$(dirname $0)/shlib-compat.py + +if [ $# -lt 3 ]; then + echo "Usage: $0 orig-dir new-dir output-dir" + exit 1 +fi + +orig=$1 +new=$2 +out=$3 +shift 3 + +remove_empty() { + local i + for i in $*; do + [ -s $i ] || rm -f $i + done +} + +test_file() { + local i + for i in $*; do + if [ \! -f $1 ]; then + echo "file not found: $1" + return 1 + fi + done +} + +rorig=`realpath $orig` +rnew=`realpath $new` +list=`(cd $rorig; ls; cd $rnew; ls) | sort -u` +for i in $list; do + echo $i + test_file $orig/$i $new/$i || continue + $SHLIB_COMPAT --out-orig $out/$i.orig.c --out-new $out/$i.new.c -v "$@" \ + $orig/$i $new/$i > $out/$i.cmp 2> $out/$i.err || true + remove_empty $out/$i.orig.c $out/$i.new.c $out/$i.cmp $out/$i.err + if [ -f $out/$i.orig.c -a -f $out/$i.new.c ]; then + astyle --quiet --style=bsd -k3 $out/$i.orig.c $out/$i.new.c + rm -f $out/$i.orig.c.orig $out/$i.new.c.orig + diff -u $out/$i.orig.c $out/$i.new.c > $out/$i.diff || true + fi +done Added: head/tools/tools/shlib-compat/shlib-compat.py ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/tools/shlib-compat/shlib-compat.py Mon Mar 25 00:31:14 2013 (r248693) @@ -0,0 +1,1097 @@ +#!/usr/bin/env python +#- +# Copyright (c) 2010 Gleb Kurtsou +# 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$ + +import os +import sys +import re +import optparse + +class Config(object): + version = '0.1' + # controlled by user + verbose = 0 + dump = False + no_dump = False + version_filter = None + symbol_filter = None + alias_prefixes = [] + # misc opts + objdump = 'objdump' + dwarfdump = 'dwarfdump' + # debug + cmpcache_enabled = True + dwarfcache_enabled = True + w_alias = True + w_cached = False + w_symbol = True + + class FileConfig(object): + filename = None + out = sys.stdout + def init(self, outname): + if outname and outname != '-': + self.out = open(outname, "w") + + origfile = FileConfig() + newfile = FileConfig() + + @classmethod + def init(cls): + cls.version_filter = StrFilter() + cls.symbol_filter = StrFilter() + +class App(object): + result_code = 0 + +def warn(cond, msg): + if cond: + print >> sys.stderr, "WARN: " + msg + +# {{{ misc + +class StrFilter(object): + def __init__(self): + self.exclude = [] + self.include = [] + + def compile(self): + self.re_exclude = [ re.compile(x) for x in self.exclude ] + self.re_include = [ re.compile(x) for x in self.include ] + + def match(self, s): + if len(self.re_include): + matched = False + for r in self.re_include: + if r.match(s): + matched = True + break + if not matched: + return False + for r in self.re_exclude: + if r.match(s): + return False + return True + +class Cache(object): + + class CacheStats(object): + def __init__(self): + self.hit = 0 + self.miss = 0 + + def show(self, name): + total = self.hit + self.miss + if total == 0: + ratio = '(undef)' + else: + ratio = '%f' % (self.hit/float(total)) + return '%s cache stats: hit: %d; miss: %d; ratio: %s' % \ + (name, self.hit, self.miss, ratio) + + def __init__(self, enabled=True, stats=None): + self.enabled = enabled + self.items = {} + if stats == None: + self.stats = Cache.CacheStats() + else: + self.stats = stats + + def get(self, id): + if self.enabled and self.items.has_key(id): + self.stats.hit += 1 + return self.items[id] + else: + self.stats.miss += 1 + return None + + def put(self, id, obj): + if self.enabled: + if self.items.has_key(id) and obj is not self.items[id]: + #raise ValueError("Item is already cached: %d (%s, %s)" % + # (id, self.items[id], obj)) + warn(Config.w_cached, "Item is already cached: %d (%s, %s)" % \ + (id, self.items[id], obj)) + self.items[id] = obj + + def replace(self, id, obj): + if self.enabled: + assert self.items.has_key(id) + self.items[id] = obj + +class ListDiff(object): + def __init__(self, orig, new): + self.orig = set(orig) + self.new = set(new) + self.common = self.orig & self.new + self.added = self.new - self.common + self.removed = self.orig - self.common + +class PrettyPrinter(object): + def __init__(self): + self.stack = [] + + def run_nested(self, obj): + ex = obj._pp_ex(self) + self.stack.append(ex) + + def run(self, obj): + self._result = obj._pp(self) + return self._result + + def nested(self): + return sorted(set(self.stack)) + + def result(self): + return self._result; + +# }}} + +#{{{ symbols and version maps + +class Symbol(object): + def __init__(self, name, offset, version, lib): + self.name = name + self.offset = offset + self.version = version + self.lib = lib + self.definition = None + + @property + def name_ver(self): + return self.name + '@' + self.version + + def __repr__(self): + return "Symbol(%s, 0x%x, %s)" % (self.name, self.offset, self.version) + +class CommonSymbol(object): + def __init__(self, origsym, newsym): + if origsym.name != newsym.name or origsym.version != newsym.version: + raise RuntimeError("Symbols have different names: %s", + [origsym, newsym]) + self.origsym = origsym + self.newsym = newsym + self.name = newsym.name + self.version = newsym.version + + def __repr__(self): + return "CommonSymbol(%s, %s)" % (self.name, self.version) + +class SymbolAlias(object): + def __init__(self, alias, prefix, offset): + assert alias.startswith(prefix) + self.alias = alias + self.name = alias[len(prefix):] + self.offset = offset + + def __repr__(self): + return "SymbolAlias(%s, 0x%x)" % (self.alias, self.offset) + + +class VersionMap(object): + def __init__(self, name): + self.name = name + self.symbols = {} + + def append(self, symbol): + if (self.symbols.has_key(symbol.name)): + raise ValueError("Symbol is already defined %s@%s" % + (symbol.name, self.name)) + self.symbols[symbol.name] = symbol + + def names(self): + return self.symbols.keys() + + def __repr__(self): + return repr(self.symbols.values()) + +# }}} + +# {{{ types and definitions + +class Def(object): + _is_alias = False + + def __init__(self, id, name, **kwargs): + self.id = id + self.name = name + self.attrs = kwargs + + def __getattr__(self, attr): + if not self.attrs.has_key(attr): + raise AttributeError('%s in %s' % (attr, str(self))) + return self.attrs[attr] + + def _name_opt(self, default=''): + if not self.name: + return default + return self.name + + def _alias(self): + if self._is_alias: + return self.type._alias() + return self + + def __cmp__(self, other): + # TODO assert 'self' and 'other' belong to different libraries + #print 'cmp defs: %s, %s' % (self, other) + a = self._alias() + try: + b = other._alias() + except AttributeError: + return 1 + r = cmp(a.__class__, b.__class__) + if r == 0: + if a.id != 0 and b.id != 0: + ind = (long(a.id) << 32) + b.id + r = Dwarf.cmpcache.get(ind) + if r != None: + return r + else: + ind = 0 + r = cmp(a.attrs, b.attrs) + if ind != 0: + Dwarf.cmpcache.put(ind, r) + else: + r = 0 + #raise RuntimeError('Comparing different classes: %s, %s' % + # (a.__class__.__name__, b.__class__.__name__)) + return r + + def __repr__(self): + p = [] + if hasattr(self, 'name'): + p.append("name=%s" % self.name) + for (k, v) in self.attrs.items(): + if isinstance(v, Def): + v = v.__class__.__name__ + '(...)' + p.append("%s=%s" % (k, v)) + return self.__class__.__name__ + '(' + ', '.join(p) + ')' + + def _mapval(self, param, vals): + if param not in vals.keys(): + raise NotImplementedError("Invalid value '%s': %s" % + (param, str(self))) + return vals[param] + + def _pp_ex(self, pp): + raise NotImplementedError('Extended pretty print not implemeted: %s' % + str(self)) + + def _pp(self, pp): + raise NotImplementedError('Pretty print not implemeted: %s' % str(self)) + +class AnonymousDef(Def): + def __init__(self, id, **kwargs): + Def.__init__(self, id, None, **kwargs) + +class Void(AnonymousDef): + _instance = None + + def __new__(cls, *args, **kwargs): + if not cls._instance: + cls._instance = super(Void, cls).__new__( + cls, *args, **kwargs) + return cls._instance + + def __init__(self): + AnonymousDef.__init__(self, 0) + + def _pp(self, pp): + return "void" + +class VarArgs(AnonymousDef): + def _pp(self, pp): + return "..." + +class PointerDef(AnonymousDef): + def _pp(self, pp): + t = pp.run(self.type) + return "%s*" % (t,) + +class BaseTypeDef(Def): + inttypes = ['DW_ATE_signed', 'DW_ATE_unsigned', 'DW_ATE_unsigned_char'] + def _pp(self, pp): + if self.encoding in self.inttypes: + sign = '' if self.encoding == 'DW_ATE_signed' else 'u' + bits = int(self.byte_size) * 8 + return '%sint%s_t' % (sign, bits) + elif self.encoding == 'DW_ATE_signed_char' and int(self.byte_size) == 1: + return 'char'; + elif self.encoding == 'DW_ATE_float': + return self._mapval(self.byte_size, { + '16': 'long double', + '8': 'double', + '4': 'float', + }) + raise NotImplementedError('Invalid encoding: %s' % self) + +class TypeAliasDef(Def): + _is_alias = True + def _pp(self, pp): + alias = self._alias() + # push typedef name + if self.name and not alias.name: + alias.name = 'T(%s)' % self.name + # return type with modifiers + return self.type._pp(pp) + +class EnumerationTypeDef(Def): + def _pp(self, pp): + return 'enum ' + self._name_opt('UNKNOWN') + +class ConstTypeDef(AnonymousDef): + _is_alias = True + def _pp(self, pp): + return 'const ' + self.type._pp(pp) + +class VolatileTypeDef(AnonymousDef): + _is_alias = True + def _pp(self, pp): + return 'volatile ' + self.type._pp(pp) + +class ArrayDef(AnonymousDef): + def _pp(self, pp): + t = pp.run(self.type) + assert len(self.subranges) == 1 + try: + sz = int(self.subranges[0].upper_bound) + 1 + except ValueError: + s = re.sub(r'\(.+\)', '', self.subranges[0].upper_bound) + sz = int(s) + 1 + return '%s[%s]' % (t, sz) + +class ArraySubrangeDef(AnonymousDef): + pass + +class FunctionDef(Def): + def _pp(self, pp): + result = pp.run(self.result) + if not self.params: + params = "void" + else: + params = ', '.join([ pp.run(x) for x in self.params ]) + return "%s %s(%s);" % (result, self.name, params) + +class FunctionTypeDef(Def): + def _pp(self, pp): + result = pp.run(self.result) + if not self.params: + params = "void" + else: + params = ', '.join([ pp.run(x) for x in self.params ]) + return "F(%s, %s, (%s))" % (self._name_opt(), result, params) + +class ParameterDef(Def): + def _pp(self, pp): + t = pp.run(self.type) + return "%s %s" % (t, self._name_opt()) + +# TODO +class StructForwardDef(Def): + pass + +class IncompleteDef(Def): + def update(self, complete, cache=None): + self.complete = complete + complete.incomplete = self + if cache != None: + cached = cache.get(self.id) + if cached != None and isinstance(cached, IncompleteDef): + cache.replace(self.id, complete) + +class StructIncompleteDef(IncompleteDef): + def _pp(self, pp): + return "struct %s" % (self.name,) + +class UnionIncompleteDef(IncompleteDef): + def _pp(self, pp): + return "union %s" % (self.name,) + +class StructDef(Def): + def _pp_ex(self, pp, suffix=';'): + members = [ pp.run(x) for x in self.members ] + return "struct %s { %s }%s" % \ + (self._name_opt(), ' '.join(members), suffix) + def _pp(self, pp): + if self.name: + pp.run_nested(self) + return "struct %s" % (self.name,) + else: + return self._pp_ex(pp, suffix='') + +class UnionDef(Def): + def _pp_ex(self, pp, suffix=';'): + members = [ pp.run(x) for x in self.members ] + return "union %s { %s }%s" % \ + (self._name_opt(), ' '.join(members), suffix) + def _pp(self, pp): + if self.name: + pp.run_nested(self) + return "union %s" % (self.name,) + else: + return self._pp_ex(pp, suffix='') + +class MemberDef(Def): + def _pp(self, pp): + t = pp.run(self.type) + if self.bit_size: + bits = ":%s" % self.bit_size + else: + bits = "" + return "%s %s%s;" % (t, self._name_opt(), bits) + +class Dwarf(object): + + cmpcache = Cache(enabled=Config.cmpcache_enabled) + + def __init__(self, dump): + self.dump = dump + + def _build_optarg_type(self, praw): + type = praw.optarg('type', Void()) + if type != Void(): + type = self.buildref(praw.unit, type) + return type + + def build_subprogram(self, raw): + if raw.optname == None: + raw.setname('SUBPROGRAM_NONAME_' + raw.arg('low_pc')); + params = [ self.build(x) for x in raw.nested ] + result = self._build_optarg_type(raw) + return FunctionDef(raw.id, raw.name, params=params, result=result) + + def build_subroutine_type(self, raw): + params = [ self.build(x) for x in raw.nested ] + result = self._build_optarg_type(raw) + return FunctionTypeDef(raw.id, raw.optname, params=params, result=result) + + def build_formal_parameter(self, raw): + type = self._build_optarg_type(raw) + return ParameterDef(raw.id, raw.optname, type=type) + + def build_pointer_type(self, raw): + type = self._build_optarg_type(raw) + return PointerDef(raw.id, type=type) + + def build_member(self, raw): + type = self.buildref(raw.unit, raw.arg('type')) + return MemberDef(raw.id, raw.name, type=type, + bit_size=raw.optarg('bit_size', None)) + + def build_structure_type(self, raw): + incomplete = raw.unit.incomplete.get(raw.id) + if incomplete == None: + incomplete = StructIncompleteDef(raw.id, raw.optname) + raw.unit.incomplete.put(raw.id, incomplete) + else: + return incomplete + members = [ self.build(x) for x in raw.nested ] + byte_size = raw.optarg('byte_size', None) + if byte_size == None: + obj = StructForwardDef(raw.id, raw.name, members=members, + forcename=raw.name) + obj = StructDef(raw.id, raw.optname, members=members, + byte_size=byte_size) + incomplete.update(obj, cache=raw.unit.cache) + return obj + + def build_union_type(self, raw): + incomplete = raw.unit.incomplete.get(raw.id) + if incomplete == None: + incomplete = UnionIncompleteDef(raw.id, raw.optname) + raw.unit.incomplete.put(raw.id, incomplete) + else: + return incomplete + members = [ self.build(x) for x in raw.nested ] + byte_size = raw.optarg('byte_size', None) + obj = UnionDef(raw.id, raw.optname, members=members, + byte_size=byte_size) + obj.incomplete = incomplete + incomplete.complete = obj + return obj + + def build_typedef(self, raw): + type = self._build_optarg_type(raw) + return TypeAliasDef(raw.id, raw.name, type=type) + + def build_const_type(self, raw): + type = self._build_optarg_type(raw) + return ConstTypeDef(raw.id, type=type) + + def build_volatile_type(self, raw): + type = self._build_optarg_type(raw) + return VolatileTypeDef(raw.id, type=type) + + def build_enumeration_type(self, raw): + # TODO handle DW_TAG_enumerator ??? + return EnumerationTypeDef(raw.id, name=raw.optname, + byte_size=raw.arg('byte_size')) + + def build_base_type(self, raw): + return BaseTypeDef(raw.id, raw.optname, + byte_size=raw.arg('byte_size'), encoding=raw.arg('encoding')) + + def build_array_type(self, raw): + type = self.buildref(raw.unit, raw.arg('type')) + subranges = [ self.build(x) for x in raw.nested ] + return ArrayDef(raw.id, type=type, subranges=subranges) + + def build_subrange_type(self, raw): + type = self.buildref(raw.unit, raw.arg('type')) + return ArraySubrangeDef(raw.id, type=type, + upper_bound=raw.optarg('upper_bound', 0)) + + def build_unspecified_parameters(self, raw): + return VarArgs(raw.id) + + def _get_id(self, id): + try: + return int(id) + except ValueError: + if (id.startswith('<') and id.endswith('>')): + return int(id[1:-1]) + else: + raise ValueError("Invalid dwarf id: %s" % id) + + def build(self, raw): + obj = raw.unit.cache.get(raw.id) + if obj != None: + return obj + builder_name = raw.tag.replace('DW_TAG_', 'build_') + try: + builder = getattr(self, builder_name) + except AttributeError: + raise AttributeError("Unknown dwarf tag: %s" % raw) + obj = builder(raw) + raw.unit.cache.put(obj.id, obj) + return obj + + def buildref(self, unit, id): + id = self._get_id(id) + raw = unit.tags[id] + obj = self.build(raw) + return obj + +# }}} + +class Shlib(object): + def __init__(self, libfile): + self.libfile = libfile + self.versions = {} + self.alias_syms = {} + + def parse_objdump(self): + objdump = ObjdumpParser(self.libfile) + objdump.run() + for p in objdump.dynamic_symbols: + vername = p['ver'] + if vername.startswith('(') and vername.endswith(')'): + vername = vername[1:-1] + if not Config.version_filter.match(vername): + continue + if not Config.symbol_filter.match(p['symbol']): + continue + sym = Symbol(p['symbol'], p['offset'], vername, self) + if not self.versions.has_key(vername): + self.versions[vername] = VersionMap(vername) + self.versions[vername].append(sym) + if Config.alias_prefixes: + self.local_offsetmap = objdump.local_offsetmap + for p in objdump.local_symbols: + for prefix in Config.alias_prefixes: + if not p['symbol'].startswith(prefix): + continue + alias = SymbolAlias(p['symbol'], prefix, p['offset']) + if self.alias_syms.has_key(alias.name): + prevalias = self.alias_syms[alias.name] + if alias.name != prevalias.name or \ + alias.offset != prevalias.offset: + warn(Config.w_alias, "Symbol alias is " \ + "already defined: %s: %s at %08x -- %s at %08x" % \ + (alias.alias, alias.name, alias.offset, + prevalias.name, prevalias.offset)) + self.alias_syms[alias.name] = alias + + def parse_dwarfdump(self): + dwarfdump = DwarfdumpParser(self.libfile) + def lookup(sym): + raw = None + try: + raw = dwarfdump.offsetmap[sym.offset] + except: + try: + localnames = self.local_offsetmap[sym.offset] + localnames.sort(key=lambda x: -len(x)) + for localname in localnames: + if not self.alias_syms.has_key(localname): + continue + alias = self.alias_syms[localname] + raw = dwarfdump.offsetmap[alias.offset] + break + except: + pass + return raw + dwarfdump.run() + dwarf = Dwarf(dwarfdump) + for ver in self.versions.values(): + for sym in ver.symbols.values(): + raw = lookup(sym); + if not raw: + warn(Config.w_symbol, "Symbol %s (%s) not found at offset 0x%x" % \ + (sym.name_ver, self.libfile, sym.offset)) + continue + if Config.verbose >= 3: + print "Parsing symbol %s (%s)" % (sym.name_ver, self.libfile) + sym.definition = dwarf.build(raw) + + def parse(self): + if not os.path.isfile(self.libfile): + print >> sys.stderr, ("No such file: %s" % self.libfile) + sys.exit(1) + self.parse_objdump() + self.parse_dwarfdump() + +# {{{ parsers + +class Parser(object): + def __init__(self, proc): + self.proc = proc + self.parser = self.parse_begin + + def run(self): + fd = os.popen(self.proc, 'r') + while True: + line = fd.readline() + if (not line): + break + line = line.strip() + if (line): + self.parser(line) + err = fd.close() + if err: + print >> sys.stderr, ("Execution failed: %s" % self.proc) + sys.exit(2) + + def parse_begin(self, line): + print(line) + +class ObjdumpParser(Parser): + + re_header = re.compile('(?P\w*)\s*SYMBOL TABLE:') + + re_local_symbol = re.compile('(?P[0-9a-fA-F]+)\s+(?P\w+)\s+(?P\w+)\s+(?P
[^\s]+)\s+(?P[0-9a-fA-F]+)\s*(?P[^\s]*)') + re_lame_symbol = re.compile('(?P[0-9a-fA-F]+)\s+(?P\w+)\s+\*[A-Z]+\*') + + re_dynamic_symbol = re.compile('(?P[0-9a-fA-F]+)\s+(?P\w+)\s+(?P\w+)\s+(?P
[^\s]+)\s+(?P[0-9a-fA-F]+)\s*(?P[^\s]*)\s*(?P[^\s]*)') + + def __init__(self, libfile): + Parser.__init__(self, "%s -wtT %s" % (Config.objdump, libfile)) + self.dynamic_symbols = [] + self.local_symbols = [] + self.local_offsetmap = {} + + def parse_begin(self, line): + self.parse_header(line) + + def add_symbol(self, table, symbol, offsetmap = None): + offset = int(symbol['offset'], 16); + symbol['offset'] = offset + if (offset == 0): + return + table.append(symbol) + if offsetmap != None: + if not offsetmap.has_key(offset): + offsetmap[offset] = [symbol['symbol']] + else: + offsetmap[offset].append(symbol['symbol']) + + def parse_header(self, line): + m = self.re_header.match(line) + if (m): + table = m.group('table') + if (table == "DYNAMIC"): + self.parser = self.parse_dynamic + elif table == '': + self.parser = self.parse_local + else: + raise ValueError("Invalid symbol table: %s" % table) + return True + return False + + def parse_local(self, line): + if (self.parse_header(line)): + return + if (self.re_lame_symbol.match(line)): + return + m = self.re_local_symbol.match(line) + if (not m): + return + #raise ValueError("Invalid symbol definition: %s" % line) + p = m.groupdict() + if (p['symbol'] and p['symbol'].find('@') == -1): + self.add_symbol(self.local_symbols, p, self.local_offsetmap); + + def parse_dynamic(self, line): + if (self.parse_header(line)): + return + if (self.re_lame_symbol.match(line)): + return + m = self.re_dynamic_symbol.match(line) + if (not m): + raise ValueError("Invalid symbol definition: %s" % line) + p = m.groupdict() + if (p['symbol'] and p['ver']): + self.add_symbol(self.dynamic_symbols, p); + +class DwarfdumpParser(Parser): + + tagcache_stats = Cache.CacheStats() + + class Unit(object): + def __init__(self): *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Mon Mar 25 05:45:25 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 06E304A3; Mon, 25 Mar 2013 05:45:25 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id DDAF2B37; Mon, 25 Mar 2013 05:45:24 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2P5jOD3085193; Mon, 25 Mar 2013 05:45:24 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2P5jOAL085192; Mon, 25 Mar 2013 05:45:24 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201303250545.r2P5jOAL085192@svn.freebsd.org> From: Alexander Motin Date: Mon, 25 Mar 2013 05:45:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248694 - head/sys/geom X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Mar 2013 05:45:25 -0000 Author: mav Date: Mon Mar 25 05:45:24 2013 New Revision: 248694 URL: http://svnweb.freebsd.org/changeset/base/248694 Log: In GEOM DISK: - Replace single done mutex with per-disk ones. On system with several disks on several HBAs that removes small, but measurable lock congestion. - Modify disk destruction process to not destroy the mutex prematurely. - Remove some extra pointer derefences. Modified: head/sys/geom/geom_disk.c Modified: head/sys/geom/geom_disk.c ============================================================================== --- head/sys/geom/geom_disk.c Mon Mar 25 00:31:14 2013 (r248693) +++ head/sys/geom/geom_disk.c Mon Mar 25 05:45:24 2013 (r248694) @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include struct g_disk_softc { + struct mtx done_mtx; struct disk *dp; struct sysctl_ctx_list sysctl_ctx; struct sysctl_oid *sysctl_tree; @@ -67,11 +68,7 @@ struct g_disk_softc { uint32_t state; }; -static struct mtx g_disk_done_mtx; - static g_access_t g_disk_access; -static g_init_t g_disk_init; -static g_fini_t g_disk_fini; static g_start_t g_disk_start; static g_ioctl_t g_disk_ioctl; static g_dumpconf_t g_disk_dumpconf; @@ -80,8 +77,6 @@ static g_provgone_t g_disk_providergone; static struct g_class g_disk_class = { .name = "DISK", .version = G_VERSION, - .init = g_disk_init, - .fini = g_disk_fini, .start = g_disk_start, .access = g_disk_access, .ioctl = g_disk_ioctl, @@ -93,20 +88,6 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, disk, CTLFLAG_RW, 0, "GEOM_DISK stuff"); -static void -g_disk_init(struct g_class *mp __unused) -{ - - mtx_init(&g_disk_done_mtx, "g_disk_done", NULL, MTX_DEF); -} - -static void -g_disk_fini(struct g_class *mp __unused) -{ - - mtx_destroy(&g_disk_done_mtx); -} - DECLARE_GEOM_CLASS(g_disk_class, g_disk); static void __inline @@ -135,7 +116,7 @@ g_disk_access(struct g_provider *pp, int g_trace(G_T_ACCESS, "g_disk_access(%s, %d, %d, %d)", pp->name, r, w, e); g_topology_assert(); - sc = pp->geom->softc; + sc = pp->private; if (sc == NULL || (dp = sc->dp) == NULL || dp->d_destroyed) { /* * Allow decreasing access count even if disk is not @@ -240,42 +221,36 @@ static void g_disk_done(struct bio *bp) { struct bio *bp2; - struct disk *dp; struct g_disk_softc *sc; /* See "notes" for why we need a mutex here */ /* XXX: will witness accept a mix of Giant/unGiant drivers here ? */ - mtx_lock(&g_disk_done_mtx); - bp->bio_completed = bp->bio_length - bp->bio_resid; - bp2 = bp->bio_parent; + sc = bp2->bio_to->private; + bp->bio_completed = bp->bio_length - bp->bio_resid; + mtx_lock(&sc->done_mtx); if (bp2->bio_error == 0) bp2->bio_error = bp->bio_error; bp2->bio_completed += bp->bio_completed; - if ((bp->bio_cmd & (BIO_READ|BIO_WRITE|BIO_DELETE)) != 0 && - (sc = bp2->bio_to->geom->softc) != NULL && - (dp = sc->dp) != NULL) { - devstat_end_transaction_bio(dp->d_devstat, bp); - } + if ((bp->bio_cmd & (BIO_READ|BIO_WRITE|BIO_DELETE)) != 0) + devstat_end_transaction_bio(sc->dp->d_devstat, bp); g_destroy_bio(bp); bp2->bio_inbed++; if (bp2->bio_children == bp2->bio_inbed) { bp2->bio_resid = bp2->bio_bcount - bp2->bio_completed; g_io_deliver(bp2, bp2->bio_error); } - mtx_unlock(&g_disk_done_mtx); + mtx_unlock(&sc->done_mtx); } static int g_disk_ioctl(struct g_provider *pp, u_long cmd, void * data, int fflag, struct thread *td) { - struct g_geom *gp; struct disk *dp; struct g_disk_softc *sc; int error; - gp = pp->geom; - sc = gp->softc; + sc = pp->private; dp = sc->dp; if (dp->d_ioctl == NULL) @@ -295,7 +270,7 @@ g_disk_start(struct bio *bp) int error; off_t off; - sc = bp->bio_to->geom->softc; + sc = bp->bio_to->private; if (sc == NULL || (dp = sc->dp) == NULL || dp->d_destroyed) { g_io_deliver(bp, ENXIO); return; @@ -496,6 +471,7 @@ g_disk_create(void *arg, int flag) g_topology_assert(); dp = arg; sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO); + mtx_init(&sc->done_mtx, "g_disk_done", NULL, MTX_DEF); sc->dp = dp; gp = g_new_geomf(&g_disk_class, "%s%d", dp->d_name, dp->d_unit); gp->softc = sc; @@ -539,19 +515,22 @@ g_disk_providergone(struct g_provider *p struct disk *dp; struct g_disk_softc *sc; - sc = (struct g_disk_softc *)pp->geom->softc; - - /* - * If the softc is already NULL, then we've probably been through - * g_disk_destroy already; there is nothing for us to do anyway. - */ - if (sc == NULL) - return; - + sc = (struct g_disk_softc *)pp->private; dp = sc->dp; - - if (dp->d_gone != NULL) + if (dp != NULL && dp->d_gone != NULL) dp->d_gone(dp); + if (sc->sysctl_tree != NULL) { + sysctl_ctx_free(&sc->sysctl_ctx); + sc->sysctl_tree = NULL; + } + if (sc->led[0] != 0) { + led_set(sc->led, "0"); + sc->led[0] = 0; + } + pp->private = NULL; + pp->geom->softc = NULL; + mtx_destroy(&sc->done_mtx); + g_free(sc); } static void @@ -566,16 +545,9 @@ g_disk_destroy(void *ptr, int flag) gp = dp->d_geom; if (gp != NULL) { sc = gp->softc; - if (sc->sysctl_tree != NULL) { - sysctl_ctx_free(&sc->sysctl_ctx); - sc->sysctl_tree = NULL; - } - if (sc->led[0] != 0) { - led_set(sc->led, "0"); - sc->led[0] = 0; - } - g_free(sc); - gp->softc = NULL; + if (sc != NULL) + sc->dp = NULL; + dp->d_geom = NULL; g_wither_geom(gp, ENXIO); } g_free(dp); From owner-svn-src-all@FreeBSD.ORG Mon Mar 25 06:31:17 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 97D09EB6; Mon, 25 Mar 2013 06:31:17 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 8ADA8DF8; Mon, 25 Mar 2013 06:31:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2P6VHPF000179; Mon, 25 Mar 2013 06:31:17 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2P6VHX6000178; Mon, 25 Mar 2013 06:31:17 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201303250631.r2P6VHX6000178@svn.freebsd.org> From: Alexander Motin Date: Mon, 25 Mar 2013 06:31:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248695 - head/sys/cam/ata X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Mar 2013 06:31:17 -0000 Author: mav Date: Mon Mar 25 06:31:17 2013 New Revision: 248695 URL: http://svnweb.freebsd.org/changeset/base/248695 Log: Remove two bzero()s that are erasing only few more bytes then set later. Modified: head/sys/cam/ata/ata_all.c Modified: head/sys/cam/ata/ata_all.c ============================================================================== --- head/sys/cam/ata/ata_all.c Mon Mar 25 05:45:24 2013 (r248694) +++ head/sys/cam/ata/ata_all.c Mon Mar 25 06:31:17 2013 (r248695) @@ -367,7 +367,7 @@ void ata_48bit_cmd(struct ccb_ataio *ataio, uint8_t cmd, uint16_t features, uint64_t lba, uint16_t sector_count) { - bzero(&ataio->cmd, sizeof(ataio->cmd)); + ataio->cmd.flags = CAM_ATAIO_48BIT; if (cmd == ATA_READ_DMA48 || cmd == ATA_READ_DMA_QUEUED48 || @@ -391,13 +391,14 @@ ata_48bit_cmd(struct ccb_ataio *ataio, u ataio->cmd.features_exp = features >> 8; ataio->cmd.sector_count = sector_count; ataio->cmd.sector_count_exp = sector_count >> 8; + ataio->cmd.control = 0; } void ata_ncq_cmd(struct ccb_ataio *ataio, uint8_t cmd, uint64_t lba, uint16_t sector_count) { - bzero(&ataio->cmd, sizeof(ataio->cmd)); + ataio->cmd.flags = CAM_ATAIO_48BIT | CAM_ATAIO_FPDMA; ataio->cmd.command = cmd; ataio->cmd.features = sector_count; @@ -409,6 +410,9 @@ ata_ncq_cmd(struct ccb_ataio *ataio, uin ataio->cmd.lba_mid_exp = lba >> 32; ataio->cmd.lba_high_exp = lba >> 40; ataio->cmd.features_exp = sector_count >> 8; + ataio->cmd.sector_count = 0; + ataio->cmd.sector_count_exp = 0; + ataio->cmd.control = 0; } void From owner-svn-src-all@FreeBSD.ORG Mon Mar 25 07:24:58 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id BE068CE1; Mon, 25 Mar 2013 07:24:58 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id AF3EBEA; Mon, 25 Mar 2013 07:24:58 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2P7Ow1K015815; Mon, 25 Mar 2013 07:24:58 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2P7OwOR015814; Mon, 25 Mar 2013 07:24:58 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201303250724.r2P7OwOR015814@svn.freebsd.org> From: Alexander Motin Date: Mon, 25 Mar 2013 07:24:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248696 - head/sys/geom/multipath X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Mar 2013 07:24:58 -0000 Author: mav Date: Mon Mar 25 07:24:58 2013 New Revision: 248696 URL: http://svnweb.freebsd.org/changeset/base/248696 Log: Make GEOM MULTIPATH to report unmapped bio support if underling path report it. GEOM MULTIPATH itself never touches the data and so transparent. Modified: head/sys/geom/multipath/g_multipath.c Modified: head/sys/geom/multipath/g_multipath.c ============================================================================== --- head/sys/geom/multipath/g_multipath.c Mon Mar 25 06:31:17 2013 (r248695) +++ head/sys/geom/multipath/g_multipath.c Mon Mar 25 07:24:58 2013 (r248696) @@ -522,6 +522,8 @@ g_multipath_add_disk(struct g_geom *gp, sc->sc_pp->stripesize = pp->stripesize; sc->sc_pp->stripeoffset = pp->stripeoffset; } + if (sc->sc_pp != NULL) + sc->sc_pp->flags |= pp->flags & G_PF_ACCEPT_UNMAPPED; mtx_lock(&sc->sc_mtx); cp->index = 0; sc->sc_ndisks++; From owner-svn-src-all@FreeBSD.ORG Mon Mar 25 07:43:47 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id B84842CC; Mon, 25 Mar 2013 07:43:47 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id AAE3820A; Mon, 25 Mar 2013 07:43:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2P7hlt9021420; Mon, 25 Mar 2013 07:43:47 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2P7hlbJ021419; Mon, 25 Mar 2013 07:43:47 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201303250743.r2P7hlbJ021419@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Mon, 25 Mar 2013 07:43:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248697 - head/sys/netpfil/ipfw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Mar 2013 07:43:47 -0000 Author: ae Date: Mon Mar 25 07:43:46 2013 New Revision: 248697 URL: http://svnweb.freebsd.org/changeset/base/248697 Log: When we are removing a specific set, call ipfw_expire_dyn_rules only once. Obtained from: Yandex LLC MFC after: 1 week Modified: head/sys/netpfil/ipfw/ip_fw_sockopt.c Modified: head/sys/netpfil/ipfw/ip_fw_sockopt.c ============================================================================== --- head/sys/netpfil/ipfw/ip_fw_sockopt.c Mon Mar 25 07:24:58 2013 (r248696) +++ head/sys/netpfil/ipfw/ip_fw_sockopt.c Mon Mar 25 07:43:46 2013 (r248697) @@ -373,14 +373,15 @@ del_entry(struct ip_fw_chain *chain, uin /* 4. swap the maps (under BH_LOCK) */ map = swap_map(chain, map, chain->n_rules - n); /* 5. now remove the rules deleted from the old map */ + if (cmd == 1) + ipfw_expire_dyn_rules(chain, NULL, new_set); for (i = start; i < end; i++) { - int l; rule = map[i]; if (keep_rule(rule, cmd, new_set, num)) continue; - l = RULESIZE(rule); - chain->static_len -= l; - ipfw_expire_dyn_rules(chain, rule, RESVD_SET); + chain->static_len -= RULESIZE(rule); + if (cmd != 1) + ipfw_expire_dyn_rules(chain, rule, RESVD_SET); rule->x_next = chain->reap; chain->reap = rule; } From owner-svn-src-all@FreeBSD.ORG Mon Mar 25 08:50:52 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 2D9526B0; Mon, 25 Mar 2013 08:50:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 07FD480F; Mon, 25 Mar 2013 08:50:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2P8optv042219; Mon, 25 Mar 2013 08:50:51 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2P8opAS042218; Mon, 25 Mar 2013 08:50:51 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201303250850.r2P8opAS042218@svn.freebsd.org> From: Alexander Motin Date: Mon, 25 Mar 2013 08:50:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248698 - head/sys/dev/ahci X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Mar 2013 08:50:52 -0000 Author: mav Date: Mon Mar 25 08:50:51 2013 New Revision: 248698 URL: http://svnweb.freebsd.org/changeset/base/248698 Log: Depending on combination of running commands (NCQ/non-NCQ) try to avoid extra read from PxCI/PxSACT registers. If only NCQ commands are running, we don't really need PxCI. If only non-NCQ commands are running we don't need PxSACT. Mixed set may happen only on controllers with FIS-based switching when port multiplier is attached, and then we have to read both registers. MFC after: 1 month Modified: head/sys/dev/ahci/ahci.c Modified: head/sys/dev/ahci/ahci.c ============================================================================== --- head/sys/dev/ahci/ahci.c Mon Mar 25 07:43:46 2013 (r248697) +++ head/sys/dev/ahci/ahci.c Mon Mar 25 08:50:51 2013 (r248698) @@ -1449,7 +1449,7 @@ ahci_ch_intr(void *data) { device_t dev = (device_t)data; struct ahci_channel *ch = device_get_softc(dev); - uint32_t istatus, sstatus, cstatus, serr = 0, sntf = 0, ok, err; + uint32_t istatus, cstatus, serr = 0, sntf = 0, ok, err; enum ahci_err_type et; int i, ccs, port, reset = 0; @@ -1459,8 +1459,13 @@ ahci_ch_intr(void *data) return; ATA_OUTL(ch->r_mem, AHCI_P_IS, istatus); /* Read command statuses. */ - sstatus = ATA_INL(ch->r_mem, AHCI_P_SACT); - cstatus = ATA_INL(ch->r_mem, AHCI_P_CI); + if (ch->numtslots != 0) + cstatus = ATA_INL(ch->r_mem, AHCI_P_SACT); + else + cstatus = 0; + if (ch->numrslots != ch->numtslots) + cstatus |= ATA_INL(ch->r_mem, AHCI_P_CI); + /* Read SNTF in one of possible ways. */ if (istatus & AHCI_P_IX_SDB) { if (ch->caps & AHCI_CAP_SSNTF) sntf = ATA_INL(ch->r_mem, AHCI_P_SNTF); @@ -1520,14 +1525,14 @@ ahci_ch_intr(void *data) } } } - err = ch->rslots & (cstatus | sstatus); + err = ch->rslots & cstatus; } else { ccs = 0; err = 0; port = -1; } /* Complete all successfull commands. */ - ok = ch->rslots & ~(cstatus | sstatus); + ok = ch->rslots & ~cstatus; for (i = 0; i < ch->numslots; i++) { if ((ok >> i) & 1) ahci_end_transaction(&ch->slot[i], AHCI_ERR_NONE); From owner-svn-src-all@FreeBSD.ORG Mon Mar 25 09:43:51 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 28C1C609; Mon, 25 Mar 2013 09:43:51 +0000 (UTC) (envelope-from davide@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 0CC37A87; Mon, 25 Mar 2013 09:43:51 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2P9holb058221; Mon, 25 Mar 2013 09:43:50 GMT (envelope-from davide@svn.freebsd.org) Received: (from davide@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2P9hoQo058220; Mon, 25 Mar 2013 09:43:50 GMT (envelope-from davide@svn.freebsd.org) Message-Id: <201303250943.r2P9hoQo058220@svn.freebsd.org> From: Davide Italiano Date: Mon, 25 Mar 2013 09:43:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248699 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Mar 2013 09:43:51 -0000 Author: davide Date: Mon Mar 25 09:43:50 2013 New Revision: 248699 URL: http://svnweb.freebsd.org/changeset/base/248699 Log: Cache the callout precision argument as part of the informations required for migrating callouts to new CPU. This value is passed to callout_cc_add() in order to update properly precision field in case of rescheduling/migration. Reviewed by: mav Modified: head/sys/kern/kern_timeout.c Modified: head/sys/kern/kern_timeout.c ============================================================================== --- head/sys/kern/kern_timeout.c Mon Mar 25 08:50:51 2013 (r248698) +++ head/sys/kern/kern_timeout.c Mon Mar 25 09:43:50 2013 (r248699) @@ -131,6 +131,7 @@ struct cc_exec { void *ce_migration_arg; int ce_migration_cpu; sbintime_t ce_migration_time; + sbintime_t ce_migration_prec; #endif bool cc_cancel; bool cc_waiting; @@ -167,10 +168,12 @@ struct callout_cpu { #define cc_migration_arg cc_exec_entity[0].ce_migration_arg #define cc_migration_cpu cc_exec_entity[0].ce_migration_cpu #define cc_migration_time cc_exec_entity[0].ce_migration_time +#define cc_migration_prec cc_exec_entity[0].ce_migration_prec #define cc_migration_func_dir cc_exec_entity[1].ce_migration_func #define cc_migration_arg_dir cc_exec_entity[1].ce_migration_arg #define cc_migration_cpu_dir cc_exec_entity[1].ce_migration_cpu #define cc_migration_time_dir cc_exec_entity[1].ce_migration_time +#define cc_migration_prec_dir cc_exec_entity[1].ce_migration_prec struct callout_cpu cc_cpu[MAXCPU]; #define CPUBLOCK MAXCPU @@ -227,6 +230,7 @@ cc_cce_cleanup(struct callout_cpu *cc, i #ifdef SMP cc->cc_exec_entity[direct].ce_migration_cpu = CPUBLOCK; cc->cc_exec_entity[direct].ce_migration_time = 0; + cc->cc_exec_entity[direct].ce_migration_prec = 0; cc->cc_exec_entity[direct].ce_migration_func = NULL; cc->cc_exec_entity[direct].ce_migration_arg = NULL; #endif @@ -605,7 +609,7 @@ softclock_call_cc(struct callout *c, str void (*new_func)(void *); void *new_arg; int flags, new_cpu; - sbintime_t new_time; + sbintime_t new_prec, new_time; #endif #if defined(DIAGNOSTIC) || defined(CALLOUT_PROFILING) sbintime_t sbt1, sbt2; @@ -721,6 +725,7 @@ skip: */ new_cpu = cc->cc_exec_entity[direct].ce_migration_cpu; new_time = cc->cc_exec_entity[direct].ce_migration_time; + new_prec = cc->cc_exec_entity[direct].ce_migration_prec; new_func = cc->cc_exec_entity[direct].ce_migration_func; new_arg = cc->cc_exec_entity[direct].ce_migration_arg; cc_cce_cleanup(cc, direct); @@ -742,7 +747,7 @@ skip: new_cc = callout_cpu_switch(c, cc, new_cpu); flags = (direct) ? C_DIRECT_EXEC : 0; - callout_cc_add(c, new_cc, new_time, c->c_precision, new_func, + callout_cc_add(c, new_cc, new_time, new_prec, new_func, new_arg, new_cpu, flags); CC_UNLOCK(new_cc); CC_LOCK(cc); @@ -996,6 +1001,8 @@ callout_reset_sbt_on(struct callout *c, cc->cc_exec_entity[direct].ce_migration_cpu = cpu; cc->cc_exec_entity[direct].ce_migration_time = to_sbt; + cc->cc_exec_entity[direct].ce_migration_prec + = precision; cc->cc_exec_entity[direct].ce_migration_func = ftn; cc->cc_exec_entity[direct].ce_migration_arg = arg; c->c_flags |= CALLOUT_DFRMIGRATION; From owner-svn-src-all@FreeBSD.ORG Mon Mar 25 11:41:16 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id C298C746; Mon, 25 Mar 2013 11:41:16 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.69.10]) by mx1.freebsd.org (Postfix) with ESMTP id 4BCE06DD; Mon, 25 Mar 2013 11:41:16 +0000 (UTC) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.6/8.14.6) with ESMTP id r2PBfFWA025652; Mon, 25 Mar 2013 15:41:15 +0400 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.6/8.14.6/Submit) id r2PBfFGc025651; Mon, 25 Mar 2013 15:41:15 +0400 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Mon, 25 Mar 2013 15:41:15 +0400 From: Gleb Smirnoff To: Andre Oppermann Subject: Re: svn commit: r248417 - head/sys/sys Message-ID: <20130325114115.GU76816@FreeBSD.org> References: <201303170739.r2H7djP1098888@svn.freebsd.org> <51458691.4090107@freebsd.org> <20130317093339.GT48089@FreeBSD.org> <51459ED3.4040304@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <51459ED3.4040304@freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Mar 2013 11:41:16 -0000 Andre, sorry for delay. On Sun, Mar 17, 2013 at 11:45:39AM +0100, Andre Oppermann wrote: A> On 17.03.2013 10:33, Gleb Smirnoff wrote: A> > On Sun, Mar 17, 2013 at 10:02:09AM +0100, Andre Oppermann wrote: A> > A> On 17.03.2013 08:39, Gleb Smirnoff wrote: A> > A> > Author: glebius A> > A> > Date: Sun Mar 17 07:39:45 2013 A> > A> > New Revision: 248417 A> > A> > URL: http://svnweb.freebsd.org/changeset/base/248417 A> > A> > A> > A> > Log: A> > A> > Add MEXT_ALIGN() macro, similar to M_ALIGN() and MH_ALIGN(), but for A> > A> > mbufs with external buffer. A> > A> A> > A> While you are cleaning up the mbuf usage wouldn't it make sense to remove A> > A> these macros, instead of adding new ones, and use m_align() which handles A> > A> all these cases internally? A> > A> > I'm thinking about this. Maybe it is worth to request tail alignment as A> > a flag to the allocating function itself? A> A> IMHO that would overload the allocation function(s). The explicit step of A> doing m_align() for those who need it is fine and alerts the reader of what A> is going on. I'm all for simplification and unification, on the other hand A> it shouldn't be taken too far creating new complexity on the other side. That would be one less function call and one less branching, that was my point. Actually we can extend that later w/o API breakage. -- Totus tuus, Glebius. From owner-svn-src-all@FreeBSD.ORG Mon Mar 25 12:38:46 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 7E043A4C; Mon, 25 Mar 2013 12:38:46 +0000 (UTC) (envelope-from maxim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 707F7A44; Mon, 25 Mar 2013 12:38:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2PCckN9011110; Mon, 25 Mar 2013 12:38:46 GMT (envelope-from maxim@svn.freebsd.org) Received: (from maxim@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2PCckEv011109; Mon, 25 Mar 2013 12:38:46 GMT (envelope-from maxim@svn.freebsd.org) Message-Id: <201303251238.r2PCckEv011109@svn.freebsd.org> From: Maxim Konovalov Date: Mon, 25 Mar 2013 12:38:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248700 - head/sbin/geom/class/eli X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Mar 2013 12:38:46 -0000 Author: maxim Date: Mon Mar 25 12:38:45 2013 New Revision: 248700 URL: http://svnweb.freebsd.org/changeset/base/248700 Log: o Typo: IEE -> IEEE. PR: docs/173069 Submitted by: Bjorn Heidotting MFC after: 1 week Modified: head/sbin/geom/class/eli/geli.8 Modified: head/sbin/geom/class/eli/geli.8 ============================================================================== --- head/sbin/geom/class/eli/geli.8 Mon Mar 25 09:43:50 2013 (r248699) +++ head/sbin/geom/class/eli/geli.8 Mon Mar 25 12:38:45 2013 (r248700) @@ -970,7 +970,7 @@ Enter passphrase: supports two encryption modes: .Nm XTS , which was standardized as -.Nm IEE P1619 +.Nm IEEE P1619 and .Nm CBC with unpredictable IV. From owner-svn-src-all@FreeBSD.ORG Mon Mar 25 13:58:18 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 7BBC24D7; Mon, 25 Mar 2013 13:58:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 6E837FBA; Mon, 25 Mar 2013 13:58:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2PDwIW4035433; Mon, 25 Mar 2013 13:58:18 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2PDwI23035432; Mon, 25 Mar 2013 13:58:18 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201303251358.r2PDwI23035432@svn.freebsd.org> From: Alexander Motin Date: Mon, 25 Mar 2013 13:58:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248704 - head/sys/dev/ahci X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Mar 2013 13:58:18 -0000 Author: mav Date: Mon Mar 25 13:58:17 2013 New Revision: 248704 URL: http://svnweb.freebsd.org/changeset/base/248704 Log: Read Asynchronous Notification statuses only if Port Multiplier or ATAPI device are connected. ATA disks are not using ANs, while the extra register read operation is quite expensive. Modified: head/sys/dev/ahci/ahci.c Modified: head/sys/dev/ahci/ahci.c ============================================================================== --- head/sys/dev/ahci/ahci.c Mon Mar 25 13:33:06 2013 (r248703) +++ head/sys/dev/ahci/ahci.c Mon Mar 25 13:58:17 2013 (r248704) @@ -1466,7 +1466,8 @@ ahci_ch_intr(void *data) if (ch->numrslots != ch->numtslots) cstatus |= ATA_INL(ch->r_mem, AHCI_P_CI); /* Read SNTF in one of possible ways. */ - if (istatus & AHCI_P_IX_SDB) { + if ((istatus & AHCI_P_IX_SDB) && + (ch->pm_present || ch->curr[0].atapi != 0)) { if (ch->caps & AHCI_CAP_SSNTF) sntf = ATA_INL(ch->r_mem, AHCI_P_SNTF); else if (ch->fbs_enabled) { From owner-svn-src-all@FreeBSD.ORG Mon Mar 25 14:30:35 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id BA9BD7CF; Mon, 25 Mar 2013 14:30:35 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id ACEBF2DD; Mon, 25 Mar 2013 14:30:35 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2PEUZGG045866; Mon, 25 Mar 2013 14:30:35 GMT (envelope-from melifaro@svn.freebsd.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2PEUYcx045864; Mon, 25 Mar 2013 14:30:34 GMT (envelope-from melifaro@svn.freebsd.org) Message-Id: <201303251430.r2PEUYcx045864@svn.freebsd.org> From: "Alexander V. Chernikov" Date: Mon, 25 Mar 2013 14:30:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248705 - head/sys/dev/ipmi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Mar 2013 14:30:35 -0000 Author: melifaro Date: Mon Mar 25 14:30:34 2013 New Revision: 248705 URL: http://svnweb.freebsd.org/changeset/base/248705 Log: Unlock IPMI sc while performing requests via KCS and SMIC interfaces. It is already done in SSIF interface code. This reduces contention/spinning reported by many users. PR: kern/172166 Submitted by: Eric van Gyzen MFC after: 2 weeks Modified: head/sys/dev/ipmi/ipmi_kcs.c head/sys/dev/ipmi/ipmi_smic.c Modified: head/sys/dev/ipmi/ipmi_kcs.c ============================================================================== --- head/sys/dev/ipmi/ipmi_kcs.c Mon Mar 25 13:58:17 2013 (r248704) +++ head/sys/dev/ipmi/ipmi_kcs.c Mon Mar 25 14:30:34 2013 (r248705) @@ -456,6 +456,7 @@ kcs_loop(void *arg) IPMI_LOCK(sc); while ((req = ipmi_dequeue_request(sc)) != NULL) { + IPMI_UNLOCK(sc); ok = 0; for (i = 0; i < 3 && !ok; i++) ok = kcs_polled_request(sc, req); @@ -463,6 +464,7 @@ kcs_loop(void *arg) req->ir_error = 0; else req->ir_error = EIO; + IPMI_LOCK(sc); ipmi_complete_request(sc, req); } IPMI_UNLOCK(sc); Modified: head/sys/dev/ipmi/ipmi_smic.c ============================================================================== --- head/sys/dev/ipmi/ipmi_smic.c Mon Mar 25 13:58:17 2013 (r248704) +++ head/sys/dev/ipmi/ipmi_smic.c Mon Mar 25 14:30:34 2013 (r248705) @@ -362,6 +362,7 @@ smic_loop(void *arg) IPMI_LOCK(sc); while ((req = ipmi_dequeue_request(sc)) != NULL) { + IPMI_UNLOCK(sc); ok = 0; for (i = 0; i < 3 && !ok; i++) ok = smic_polled_request(sc, req); @@ -369,6 +370,7 @@ smic_loop(void *arg) req->ir_error = 0; else req->ir_error = EIO; + IPMI_LOCK(sc); ipmi_complete_request(sc, req); } IPMI_UNLOCK(sc); From owner-svn-src-all@FreeBSD.ORG Mon Mar 25 15:41:00 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D8532FB7; Mon, 25 Mar 2013 15:41:00 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id C7FE9AD4; Mon, 25 Mar 2013 15:41:00 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2PFf0rT068935; Mon, 25 Mar 2013 15:41:00 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2PFew1V068910; Mon, 25 Mar 2013 15:40:58 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201303251540.r2PFew1V068910@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Mon, 25 Mar 2013 15:40:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248706 - in head: cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs cddl/contrib/opensolaris/lib/libdtrace/common sys/cddl/contrib/opensolaris/uts/common/dtrace sys/cddl/contri... X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Mar 2013 15:41:00 -0000 Author: pfg Date: Mon Mar 25 15:40:57 2013 New Revision: 248706 URL: http://svnweb.freebsd.org/changeset/base/248706 Log: Dtrace: add toupper()/tolower() and enhancements to lltostr(). Merge changes from illumos: 1451 DTrace needs toupper()/tolower() subroutines 1457 lltostr() D subroutine should take an optional base This change bumps the DT_VERS_* number to 1.8.1 in accordance to what is done in illumos. The test suite we currently include is outdated and doesnt support some updates in tst.subr.d which had to be left out for now. Illumos Revisions: r13458 5e394d8db762 r13459 c3454574dd1a Reference: https://www.illumos.org/issues/1451 https://www.illumos.org/issues/1457 Tested by: Fabian Keil Obtained from: Illumos MFC after: 1 month Added: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.tolower.d - copied unchanged from r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.tolower.d head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.toupper.d - copied unchanged from r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.toupper.d head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.tolower.d - copied unchanged from r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.tolower.d head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.tolowertoomany.d - copied unchanged from r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.tolowertoomany.d head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.toupper.d - copied unchanged from r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.toupper.d head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.touppertoomany.d - copied unchanged from r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.touppertoomany.d head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.lltostrbase.d - copied unchanged from r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/tst.lltostrbase.d head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.lltostrbase.d.out - copied unchanged from r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/tst.lltostrbase.d.out head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.tolower.d - copied unchanged from r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/tst.tolower.d head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.toupper.d - copied unchanged from r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/tst.toupper.d Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h Copied: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.tolower.d (from r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.tolower.d) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.tolower.d Mon Mar 25 15:40:57 2013 (r248706, copy of r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.tolower.d) @@ -0,0 +1,30 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +BEGIN +{ + trace(tolower(2152006)); + exit(1); +} Copied: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.toupper.d (from r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.toupper.d) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.toupper.d Mon Mar 25 15:40:57 2013 (r248706, copy of r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.toupper.d) @@ -0,0 +1,30 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +BEGIN +{ + trace(toupper(timestamp)); + exit(1); +} Copied: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.tolower.d (from r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.tolower.d) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.tolower.d Mon Mar 25 15:40:57 2013 (r248706, copy of r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.tolower.d) @@ -0,0 +1,30 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +BEGIN +{ + trace(tolower()); + exit(1); +} Copied: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.tolowertoomany.d (from r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.tolowertoomany.d) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.tolowertoomany.d Mon Mar 25 15:40:57 2013 (r248706, copy of r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.tolowertoomany.d) @@ -0,0 +1,30 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +BEGIN +{ + trace(tolower("dory", "eel", "roughy")); + exit(1); +} Copied: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.toupper.d (from r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.toupper.d) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.toupper.d Mon Mar 25 15:40:57 2013 (r248706, copy of r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.toupper.d) @@ -0,0 +1,30 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +BEGIN +{ + trace(toupper()); + exit(1); +} Copied: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.touppertoomany.d (from r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.touppertoomany.d) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.touppertoomany.d Mon Mar 25 15:40:57 2013 (r248706, copy of r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.touppertoomany.d) @@ -0,0 +1,30 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +BEGIN +{ + trace(tolower("haino", "tylo")); + exit(1); +} Copied: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.lltostrbase.d (from r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/tst.lltostrbase.d) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.lltostrbase.d Mon Mar 25 15:40:57 2013 (r248706, copy of r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/tst.lltostrbase.d) @@ -0,0 +1,80 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +#pragma D option quiet + +int64_t val[int]; + +BEGIN +{ + base = -2; + i = 0; + val[i++] = -10; + val[i++] = -1; + val[i++] = 0; + val[i++] = 10; + val[i++] = 100; + val[i++] = 1000; + val[i++] = (1LL << 62); + maxval = i; + i = 0; +} + +tick-1ms +/i < maxval/ +{ + printf("base %2d of %20d: ", base, val[i]); +} + +tick-1ms +/i < maxval/ +{ + printf(" %s\n", lltostr(val[i], base)); +} + +ERROR +{ + printf(" \n"); +} + +tick-1ms +/i < maxval/ +{ + i++; +} + +tick-1ms +/i == maxval/ +{ + i = 0; + base++; +} + +tick-1ms +/base > 40/ +{ + exit(0); +} + Copied: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.lltostrbase.d.out (from r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/tst.lltostrbase.d.out) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.lltostrbase.d.out Mon Mar 25 15:40:57 2013 (r248706, copy of r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/tst.lltostrbase.d.out) @@ -0,0 +1,302 @@ +base -2 of -10: +base -2 of -1: +base -2 of 0: +base -2 of 10: +base -2 of 100: +base -2 of 1000: +base -2 of 4611686018427387904: +base -1 of -10: +base -1 of -1: +base -1 of 0: +base -1 of 10: +base -1 of 100: +base -1 of 1000: +base -1 of 4611686018427387904: +base 0 of -10: +base 0 of -1: +base 0 of 0: +base 0 of 10: +base 0 of 100: +base 0 of 1000: +base 0 of 4611686018427387904: +base 1 of -10: +base 1 of -1: +base 1 of 0: +base 1 of 10: +base 1 of 100: +base 1 of 1000: +base 1 of 4611686018427387904: +base 2 of -10: 1111111111111111111111111111111111111111111111111111111111110110 +base 2 of -1: 1111111111111111111111111111111111111111111111111111111111111111 +base 2 of 0: 0 +base 2 of 10: 1010 +base 2 of 100: 1100100 +base 2 of 1000: 1111101000 +base 2 of 4611686018427387904: 100000000000000000000000000000000000000000000000000000000000000 +base 3 of -10: 11112220022122120101211020120210210211120 +base 3 of -1: 11112220022122120101211020120210210211220 +base 3 of 0: 0 +base 3 of 10: 101 +base 3 of 100: 10201 +base 3 of 1000: 1101001 +base 3 of 4611686018427387904: 1010201120122220002201001122110012110111 +base 4 of -10: 33333333333333333333333333333312 +base 4 of -1: 33333333333333333333333333333333 +base 4 of 0: 0 +base 4 of 10: 22 +base 4 of 100: 1210 +base 4 of 1000: 33220 +base 4 of 4611686018427387904: 10000000000000000000000000000000 +base 5 of -10: 2214220303114400424121122411 +base 5 of -1: 2214220303114400424121122430 +base 5 of 0: 0 +base 5 of 10: 20 +base 5 of 100: 400 +base 5 of 1000: 13000 +base 5 of 4611686018427387904: 302141200402211214402403104 +base 6 of -10: 3520522010102100444244410 +base 6 of -1: 3520522010102100444244423 +base 6 of 0: 0 +base 6 of 10: 14 +base 6 of 100: 244 +base 6 of 1000: 4344 +base 6 of 4611686018427387904: 550120301313313111041104 +base 7 of -10: 45012021522523134134556 +base 7 of -1: 45012021522523134134601 +base 7 of 0: 0 +base 7 of 10: 13 +base 7 of 100: 202 +base 7 of 1000: 2626 +base 7 of 4611686018427387904: 11154003640456024361134 +base 8 of -10: 01777777777777777777766 +base 8 of -1: 01777777777777777777777 +base 8 of 0: 0 +base 8 of 10: 012 +base 8 of 100: 0144 +base 8 of 1000: 01750 +base 8 of 4611686018427387904: 0400000000000000000000 +base 9 of -10: 145808576354216723746 +base 9 of -1: 145808576354216723756 +base 9 of 0: 0 +base 9 of 10: 11 +base 9 of 100: 121 +base 9 of 1000: 1331 +base 9 of 4611686018427387904: 33646586081048405414 +base 10 of -10: -10 +base 10 of -1: -1 +base 10 of 0: 0 +base 10 of 10: 10 +base 10 of 100: 100 +base 10 of 1000: 1000 +base 10 of 4611686018427387904: 4611686018427387904 +base 11 of -10: 335500516a429071276 +base 11 of -1: 335500516a429071284 +base 11 of 0: 0 +base 11 of 10: a +base 11 of 100: 91 +base 11 of 1000: 82a +base 11 of 4611686018427387904: 9140013181078458a4 +base 12 of -10: 839365134a2a240706 +base 12 of -1: 839365134a2a240713 +base 12 of 0: 0 +base 12 of 10: a +base 12 of 100: 84 +base 12 of 1000: 6b4 +base 12 of 4611686018427387904: 20b3a733a268670194 +base 13 of -10: 219505a9511a867b66 +base 13 of -1: 219505a9511a867b72 +base 13 of 0: 0 +base 13 of 10: a +base 13 of 100: 79 +base 13 of 1000: 5bc +base 13 of 4611686018427387904: 6c1349246a2881c84 +base 14 of -10: 8681049adb03db166 +base 14 of -1: 8681049adb03db171 +base 14 of 0: 0 +base 14 of 10: a +base 14 of 100: 72 +base 14 of 1000: 516 +base 14 of 4611686018427387904: 219038263637dd3c4 +base 15 of -10: 2c1d56b648c6cd106 +base 15 of -1: 2c1d56b648c6cd110 +base 15 of 0: 0 +base 15 of 10: a +base 15 of 100: 6a +base 15 of 1000: 46a +base 15 of 4611686018427387904: a7e8ce189a933404 +base 16 of -10: 0xfffffffffffffff6 +base 16 of -1: 0xffffffffffffffff +base 16 of 0: 0x0 +base 16 of 10: 0xa +base 16 of 100: 0x64 +base 16 of 1000: 0x3e8 +base 16 of 4611686018427387904: 0x4000000000000000 +base 17 of -10: 67979g60f5428008 +base 17 of -1: 67979g60f5428010 +base 17 of 0: 0 +base 17 of 10: a +base 17 of 100: 5f +base 17 of 1000: 37e +base 17 of 4611686018427387904: 1a6a6ca03e10a88d +base 18 of -10: 2d3fgb0b9cg4bd26 +base 18 of -1: 2d3fgb0b9cg4bd2f +base 18 of 0: 0 +base 18 of 10: a +base 18 of 100: 5a +base 18 of 1000: 31a +base 18 of 4611686018427387904: c588bdbfgd12ge4 +base 19 of -10: 141c8786h1ccaag7 +base 19 of -1: 141c8786h1ccaagg +base 19 of 0: 0 +base 19 of 10: a +base 19 of 100: 55 +base 19 of 1000: 2ec +base 19 of 4611686018427387904: 5ecbb6fi9h7ggi9 +base 20 of -10: b53bjh07be4dj06 +base 20 of -1: b53bjh07be4dj0f +base 20 of 0: 0 +base 20 of 10: a +base 20 of 100: 50 +base 20 of 1000: 2a0 +base 20 of 4611686018427387904: 2g5hjj51hib39f4 +base 21 of -10: 5e8g4ggg7g56di6 +base 21 of -1: 5e8g4ggg7g56dif +base 21 of 0: 0 +base 21 of 10: a +base 21 of 100: 4g +base 21 of 1000: 25d +base 21 of 4611686018427387904: 18hjgjjjhebh8f4 +base 22 of -10: 2l4lf104353j8k6 +base 22 of -1: 2l4lf104353j8kf +base 22 of 0: 0 +base 22 of 10: a +base 22 of 100: 4c +base 22 of 1000: 21a +base 22 of 4611686018427387904: g6g95gc0hha7g4 +base 23 of -10: 1ddh88h2782i50j +base 23 of -1: 1ddh88h2782i515 +base 23 of 0: 0 +base 23 of 10: a +base 23 of 100: 48 +base 23 of 1000: 1kb +base 23 of 4611686018427387904: 93a22467dc4chd +base 24 of -10: l12ee5fn0ji1i6 +base 24 of -1: l12ee5fn0ji1if +base 24 of 0: 0 +base 24 of 10: a +base 24 of 100: 44 +base 24 of 1000: 1hg +base 24 of 4611686018427387904: 566ffd9ni4mcag +base 25 of -10: c9c336o0mlb7e6 +base 25 of -1: c9c336o0mlb7ef +base 25 of 0: 0 +base 25 of 10: a +base 25 of 100: 40 +base 25 of 1000: 1f0 +base 25 of 4611686018427387904: 32970kc6bo2kg4 +base 26 of -10: 7b7n2pcniokcg6 +base 26 of -1: 7b7n2pcniokcgf +base 26 of 0: 0 +base 26 of 10: a +base 26 of 100: 3m +base 26 of 1000: 1cc +base 26 of 4611686018427387904: 1m8c769io65344 +base 27 of -10: 4eo8hfam6fllmf +base 27 of -1: 4eo8hfam6fllmo +base 27 of 0: 0 +base 27 of 10: a +base 27 of 100: 3j +base 27 of 1000: 1a1 +base 27 of 4611686018427387904: 13jfho2j1hc5cd +base 28 of -10: 2nc6j26l66rho6 +base 28 of -1: 2nc6j26l66rhof +base 28 of 0: 0 +base 28 of 10: a +base 28 of 100: 3g +base 28 of 1000: 17k +base 28 of 4611686018427387904: jo1ilfj8fkpd4 +base 29 of -10: 1n3rsh11f098re +base 29 of -1: 1n3rsh11f098rn +base 29 of 0: 0 +base 29 of 10: a +base 29 of 100: 3d +base 29 of 1000: 15e +base 29 of 4611686018427387904: d0slim0b029e6 +base 30 of -10: 14l9lkmo30o406 +base 30 of -1: 14l9lkmo30o40f +base 30 of 0: 0 +base 30 of 10: a +base 30 of 100: 3a +base 30 of 1000: 13a +base 30 of 4611686018427387904: 8k9rrkl0ml104 +base 31 of -10: nd075ib45k866 +base 31 of -1: nd075ib45k86f +base 31 of 0: 0 +base 31 of 10: a +base 31 of 100: 37 +base 31 of 1000: 118 +base 31 of 4611686018427387904: 5qfh94i8okhh4 +base 32 of -10: fvvvvvvvvvvvm +base 32 of -1: fvvvvvvvvvvvv +base 32 of 0: 0 +base 32 of 10: a +base 32 of 100: 34 +base 32 of 1000: v8 +base 32 of 4611686018427387904: 4000000000000 +base 33 of -10: b1w8p7j5q9r66 +base 33 of -1: b1w8p7j5q9r6f +base 33 of 0: 0 +base 33 of 10: a +base 33 of 100: 31 +base 33 of 1000: ua +base 33 of 4611686018427387904: 2p826a4q6ivi4 +base 34 of -10: 7orp63sh4dph8 +base 34 of -1: 7orp63sh4dphh +base 34 of 0: 0 +base 34 of 10: a +base 34 of 100: 2w +base 34 of 1000: te +base 34 of 4611686018427387904: 1vnvr0wl9ketu +base 35 of -10: 5g24a25twkwf6 +base 35 of -1: 5g24a25twkwff +base 35 of 0: 0 +base 35 of 10: a +base 35 of 100: 2u +base 35 of 1000: sk +base 35 of 4611686018427387904: 1cqrb9a7gvgu4 +base 36 of -10: 3w5e11264sgs6 +base 36 of -1: 3w5e11264sgsf +base 36 of 0: 0 +base 36 of 10: a +base 36 of 100: 2s +base 36 of 1000: rs +base 36 of 4611686018427387904: z1ci99jj7474 +base 37 of -10: +base 37 of -1: +base 37 of 0: +base 37 of 10: +base 37 of 100: +base 37 of 1000: +base 37 of 4611686018427387904: +base 38 of -10: +base 38 of -1: +base 38 of 0: +base 38 of 10: +base 38 of 100: +base 38 of 1000: +base 38 of 4611686018427387904: +base 39 of -10: +base 39 of -1: +base 39 of 0: +base 39 of 10: +base 39 of 100: +base 39 of 1000: +base 39 of 4611686018427387904: +base 40 of -10: +base 40 of -1: +base 40 of 0: +base 40 of 10: +base 40 of 100: +base 40 of 1000: +base 40 of 4611686018427387904: + Copied: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.tolower.d (from r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/tst.tolower.d) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.tolower.d Mon Mar 25 15:40:57 2013 (r248706, copy of r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/tst.tolower.d) @@ -0,0 +1,66 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; + + input[i] = "ahi"; + expected[i++] = "ahi"; + + input[i] = "MaHi!"; + expected[i++] = "mahi!"; + + input[i] = " Nase-5"; + expected[i++] = " nase-5"; + + input[i] = "!@#$%"; + expected[i++] = "!@#$%"; + + i = 0; +} + +tick-1ms +/input[i] != NULL && (this->out = tolower(input[i])) != expected[i]/ +{ + printf("expected tolower(\"%s\") to be \"%s\"; found \"%s\"\n", + input[i], expected[i], this->out); + exit(1); +} + +tick-1ms +/input[i] != NULL/ +{ + printf("tolower(\"%s\") is \"%s\", as expected\n", + input[i], expected[i]); +} + +tick-1ms +/input[i++] == NULL/ +{ + exit(0); +} Copied: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.toupper.d (from r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/tst.toupper.d) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.toupper.d Mon Mar 25 15:40:57 2013 (r248706, copy of r248705, vendor/illumos/dist/cmd/dtrace/test/tst/common/funcs/tst.toupper.d) @@ -0,0 +1,66 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; + + input[i] = "ahi"; + expected[i++] = "AHI"; + + input[i] = "MaHi!"; + expected[i++] = "MAHI!"; + + input[i] = " dace-9"; + expected[i++] = " DACE-9"; + + input[i] = "!@#$%"; + expected[i++] = "!@#$%"; + + i = 0; +} + +tick-1ms +/input[i] != NULL && (this->out = toupper(input[i])) != expected[i]/ +{ + printf("expected toupper(\"%s\") to be \"%s\"; found \"%s\"\n", + input[i], expected[i], this->out); + exit(1); +} + +tick-1ms +/input[i] != NULL/ +{ + printf("toupper(\"%s\") is \"%s\", as expected\n", + input[i], expected[i]); +} + +tick-1ms +/input[i++] == NULL/ +{ + exit(0); +} Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c Mon Mar 25 14:30:34 2013 (r248705) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c Mon Mar 25 15:40:57 2013 (r248706) @@ -117,8 +117,10 @@ #define DT_VERS_1_6_3 DT_VERSION_NUMBER(1, 6, 3) #define DT_VERS_1_7 DT_VERSION_NUMBER(1, 7, 0) #define DT_VERS_1_7_1 DT_VERSION_NUMBER(1, 7, 1) -#define DT_VERS_LATEST DT_VERS_1_7_1 -#define DT_VERS_STRING "Sun D 1.7.1" +#define DT_VERS_1_8 DT_VERSION_NUMBER(1, 8, 0) +#define DT_VERS_1_8_1 DT_VERSION_NUMBER(1, 8, 1) +#define DT_VERS_LATEST DT_VERS_1_8_1 +#define DT_VERS_STRING "Sun D 1.8.1" const dt_version_t _dtrace_versions[] = { DT_VERS_1_0, /* D API 1.0.0 (PSARC 2001/466) Solaris 10 FCS */ @@ -136,6 +138,8 @@ const dt_version_t _dtrace_versions[] = DT_VERS_1_6_3, /* D API 1.6.3 */ DT_VERS_1_7, /* D API 1.7 */ DT_VERS_1_7_1, /* D API 1.7.1 */ + DT_VERS_1_8, /* D API 1.8 */ + DT_VERS_1_8_1, /* D API 1.8.1 */ 0 }; @@ -291,7 +295,7 @@ static const dt_ident_t _dtrace_globals[ { "jstack", DT_IDENT_ACTFUNC, 0, DT_ACT_JSTACK, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_func, "stack(...)" }, { "lltostr", DT_IDENT_FUNC, 0, DIF_SUBR_LLTOSTR, DT_ATTR_STABCMN, DT_VERS_1_0, - &dt_idops_func, "string(int64_t)" }, + &dt_idops_func, "string(int64_t, [int])" }, { "llquantize", DT_IDENT_AGGFUNC, 0, DTRACEAGG_LLQUANTIZE, DT_ATTR_STABCMN, DT_VERS_1_7, &dt_idops_func, "void(@, int32_t, int32_t, int32_t, int32_t, ...)" }, @@ -459,6 +463,10 @@ static const dt_ident_t _dtrace_globals[ { "timestamp", DT_IDENT_SCALAR, 0, DIF_VAR_TIMESTAMP, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "uint64_t" }, +{ "tolower", DT_IDENT_FUNC, 0, DIF_SUBR_TOLOWER, DT_ATTR_STABCMN, DT_VERS_1_8, + &dt_idops_func, "string(const char *)" }, +{ "toupper", DT_IDENT_FUNC, 0, DIF_SUBR_TOUPPER, DT_ATTR_STABCMN, DT_VERS_1_8, + &dt_idops_func, "string(const char *)" }, { "trace", DT_IDENT_ACTFUNC, 0, DT_ACT_TRACE, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_func, "void(@)" }, { "tracemem", DT_IDENT_ACTFUNC, 0, DT_ACT_TRACEMEM, Modified: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Mon Mar 25 14:30:34 2013 (r248705) +++ head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Mon Mar 25 15:40:57 2013 (r248706) @@ -4019,6 +4019,53 @@ dtrace_dif_subr(uint_t subr, uint_t rd, break; } + case DIF_SUBR_TOUPPER: + case DIF_SUBR_TOLOWER: { + uintptr_t s = tupregs[0].dttk_value; + uint64_t size = state->dts_options[DTRACEOPT_STRSIZE]; + char *dest = (char *)mstate->dtms_scratch_ptr, c; + size_t len = dtrace_strlen((char *)s, size); + char lower, upper, convert; + int64_t i; + + if (subr == DIF_SUBR_TOUPPER) { + lower = 'a'; + upper = 'z'; + convert = 'A'; + } else { + lower = 'A'; + upper = 'Z'; + convert = 'a'; + } + + if (!dtrace_canload(s, len + 1, mstate, vstate)) { + regs[rd] = 0; + break; + } + + if (!DTRACE_INSCRATCH(mstate, size)) { + DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH); + regs[rd] = 0; + break; + } + + for (i = 0; i < size - 1; i++) { + if ((c = dtrace_load8(s + i)) == '\0') + break; + + if (c >= lower && c <= upper) + c = convert + (c - lower); + + dest[i] = c; + } + + ASSERT(i < size); + dest[i] = '\0'; + regs[rd] = (uintptr_t)dest; + mstate->dtms_scratch_ptr += size; + break; + } + #if defined(sun) case DIF_SUBR_GETMAJOR: #ifdef _LP64 @@ -4283,9 +4330,20 @@ dtrace_dif_subr(uint_t subr, uint_t rd, case DIF_SUBR_LLTOSTR: { int64_t i = (int64_t)tupregs[0].dttk_value; - int64_t val = i < 0 ? i * -1 : i; - uint64_t size = 22; /* enough room for 2^64 in decimal */ + uint64_t val, digit; + uint64_t size = 65; /* enough room for 2^64 in binary */ char *end = (char *)mstate->dtms_scratch_ptr + size - 1; + int base = 10; + + if (nargs > 1) { + if ((base = tupregs[1].dttk_value) <= 1 || + base > ('z' - 'a' + 1) + ('9' - '0' + 1)) { + *flags |= CPU_DTRACE_ILLOP; + break; + } + } + + val = (base == 10 && i < 0) ? i * -1 : i; if (!DTRACE_INSCRATCH(mstate, size)) { DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH); @@ -4293,13 +4351,24 @@ dtrace_dif_subr(uint_t subr, uint_t rd, break; } - for (*end-- = '\0'; val; val /= 10) - *end-- = '0' + (val % 10); + for (*end-- = '\0'; val; val /= base) { + if ((digit = val % base) <= '9' - '0') { + *end-- = '0' + digit; + } else { + *end-- = 'a' + (digit - ('9' - '0') - 1); + } + } + + if (i == 0 && base == 16) + *end-- = '0'; + + if (base == 16) + *end-- = 'x'; - if (i == 0) + if (i == 0 || base == 8 || base == 16) *end-- = '0'; - if (i < 0) + if (i < 0 && base == 10) *end-- = '-'; regs[rd] = (uintptr_t)end + 1; Modified: head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h Mon Mar 25 14:30:34 2013 (r248705) +++ head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h Mon Mar 25 15:40:57 2013 (r248706) @@ -303,13 +303,15 @@ typedef enum dtrace_probespec { #define DIF_SUBR_INET_NTOP 41 #define DIF_SUBR_INET_NTOA 42 #define DIF_SUBR_INET_NTOA6 43 -#define DIF_SUBR_MEMREF 44 -#define DIF_SUBR_TYPEREF 45 -#define DIF_SUBR_SX_SHARED_HELD 46 -#define DIF_SUBR_SX_EXCLUSIVE_HELD 47 -#define DIF_SUBR_SX_ISEXCLUSIVE 48 +#define DIF_SUBR_TOUPPER 44 +#define DIF_SUBR_TOLOWER 45 +#define DIF_SUBR_MEMREF 46 +#define DIF_SUBR_TYPEREF 47 +#define DIF_SUBR_SX_SHARED_HELD 48 +#define DIF_SUBR_SX_EXCLUSIVE_HELD 49 +#define DIF_SUBR_SX_ISEXCLUSIVE 50 -#define DIF_SUBR_MAX 48 /* max subroutine value */ +#define DIF_SUBR_MAX 50 /* max subroutine value */ typedef uint32_t dif_instr_t; From owner-svn-src-all@FreeBSD.ORG Mon Mar 25 19:12:37 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 52842AF1; Mon, 25 Mar 2013 19:12:37 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 2BB54B0D; Mon, 25 Mar 2013 19:12:37 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2PJCbiC033396; Mon, 25 Mar 2013 19:12:37 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2PJCbNt033395; Mon, 25 Mar 2013 19:12:37 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201303251912.r2PJCbNt033395@svn.freebsd.org> From: Mikolaj Golub Date: Mon, 25 Mar 2013 19:12:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248707 - head/usr.sbin/bsnmpd/modules/snmp_hostres X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Mar 2013 19:12:37 -0000 Author: trociny Date: Mon Mar 25 19:12:36 2013 New Revision: 248707 URL: http://svnweb.freebsd.org/changeset/base/248707 Log: hrStorageSize and hrStorageUsed are 32 bit integers, reporting a fs size and usage in hrStorageAllocationUnits. If the file system has more than 2^31 allocations it can not be shown correctly and the meters are useless. In such cases follow net-snmp behaviour and increase hrStorageAllocationUnits so the values fit under INT_MAX. PR: bin/177183 Submitted by: Eugene Grosbein egrosbein rdtc.ru MFC after: 2 weeks Modified: head/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c Modified: head/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c ============================================================================== --- head/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c Mon Mar 25 15:40:57 2013 (r248706) +++ head/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c Mon Mar 25 19:12:36 2013 (r248707) @@ -442,10 +442,9 @@ static void storage_OS_get_fs(void) { struct storage_entry *entry; - uint64_t used_blocks_count = 0; + uint64_t size, used; + int i, mounted_fs_count, units; char fs_string[SE_DESC_MLEN]; - int mounted_fs_count; - int i = 0; if ((mounted_fs_count = getfsstat(NULL, 0, MNT_NOWAIT)) < 0) { syslog(LOG_ERR, "hrStorageTable: getfsstat() failed: %m"); @@ -488,22 +487,17 @@ storage_OS_get_fs(void) entry->flags |= HR_STORAGE_FOUND; entry->type = fs_get_type(&fs_buf[i]); /*XXX - This is wrong*/ - if (fs_buf[i].f_bsize > INT_MAX) - entry->allocationUnits = INT_MAX; - else - entry->allocationUnits = fs_buf[i].f_bsize; - - if (fs_buf[i].f_blocks > INT_MAX) - entry->size = INT_MAX; - else - entry->size = fs_buf[i].f_blocks; - - used_blocks_count = fs_buf[i].f_blocks - fs_buf[i].f_bfree; - - if (used_blocks_count > INT_MAX) - entry->used = INT_MAX; - else - entry->used = used_blocks_count; + units = fs_buf[i].f_bsize; + size = fs_buf[i].f_blocks; + used = fs_buf[i].f_blocks - fs_buf[i].f_bfree; + while (size > INT_MAX) { + units <<= 1; + size >>= 1; + used >>= 1; + } + entry->allocationUnits = units; + entry->size = size; + entry->used = used; entry->allocationFailures = 0; From owner-svn-src-all@FreeBSD.ORG Mon Mar 25 20:38:11 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 011D4B63; Mon, 25 Mar 2013 20:38:10 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E5B7FF19; Mon, 25 Mar 2013 20:38:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2PKcAFm058899; Mon, 25 Mar 2013 20:38:10 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2PKc9CF058888; Mon, 25 Mar 2013 20:38:09 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201303252038.r2PKc9CF058888@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Mon, 25 Mar 2013 20:38:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248708 - in head: cddl/contrib/opensolaris/lib/libdtrace/common cddl/lib/libdtrace sys/cddl/contrib/opensolaris/uts/common/dtrace X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Mar 2013 20:38:11 -0000 Author: pfg Date: Mon Mar 25 20:38:09 2013 New Revision: 248708 URL: http://svnweb.freebsd.org/changeset/base/248708 Log: Dtrace: Add SUN MDB-like type-aware print() action. Merge change from illumos: 1694 Add type-aware print() action This is a very nice feature implemented in upstream Dtrace. A complete description is available here: http://dtrace.org/blogs/eschrock/2011/10/26/your-mdb-fell-into-my-dtrace/ This change bumps the DT_VERS_* number to 1.9.0 in accordance to what is done in illumos. While here also include some minor cleanups to ease further merging and appease clang with a fix by Fabian Keil. Illumos Revisions: 13501:c3a7090dbc16 13483:f413e6c5d297 Reference: https://www.illumos.org/issues/1560 https://www.illumos.org/issues/1694 Tested by: Fabian Keil Obtained from: Illumos MFC after: 1 month Added: - copied from r248707, vendor/illumos/20120614/cmd/dtrace/test/tst/common/print/ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c - copied unchanged from r248707, vendor/illumos/dist/lib/libdtrace/common/dt_print.c Directory Properties: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print/ (props changed) Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_errtags.h head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_map.c head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_program.c head/cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h head/cddl/lib/libdtrace/Makefile head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c Mon Mar 25 19:12:36 2013 (r248707) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c Mon Mar 25 20:38:09 2013 (r248708) @@ -22,6 +22,7 @@ /* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, Joyent Inc. All rights reserved. + * Copyright (c) 2011 by Delphix. All rights reserved. */ /* @@ -679,6 +680,51 @@ dt_action_trace(dtrace_hdl_t *dtp, dt_no ap->dtad_kind = DTRACEACT_DIFEXPR; } +/* + * The print() action behaves identically to trace(), except that it stores the + * CTF type of the argument (if present) within the DOF for the DIFEXPR action. + * To do this, we set the 'dtsd_strdata' to point to the fully-qualified CTF + * type ID for the result of the DIF action. We use the ID instead of the name + * to handles complex types like arrays and function pointers that can't be + * resolved by ctf_type_lookup(). This is later processed by + * dtrace_dof_create() and turned into a reference into the string table so + * that we can get the type information when we process the data after the + * fact. + */ +static void +dt_action_print(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp) +{ + dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp); + dt_node_t *dret; + size_t len; + dt_module_t *dmp; + + if (dt_node_is_void(dnp->dn_args)) { + dnerror(dnp->dn_args, D_PRINT_VOID, + "print( ) may not be applied to a void expression\n"); + } + + if (dt_node_is_dynamic(dnp->dn_args)) { + dnerror(dnp->dn_args, D_PRINT_DYN, + "print( ) may not be applied to a dynamic expression\n"); + } + + dt_cg(yypcb, dnp->dn_args); + + dret = yypcb->pcb_dret; + dmp = dt_module_lookup_by_ctf(dtp, dret->dn_ctfp); + + len = snprintf(NULL, 0, "%s`%ld", dmp->dm_name, dret->dn_type) + 1; + sdp->dtsd_strdata = dt_alloc(dtp, len); + if (sdp->dtsd_strdata == NULL) + longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM); + (void) snprintf(sdp->dtsd_strdata, len, "%s`%ld", dmp->dm_name, + dret->dn_type); + + ap->dtad_difo = dt_as(yypcb); + ap->dtad_kind = DTRACEACT_DIFEXPR; +} + static void dt_action_tracemem(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp) { @@ -1135,6 +1181,9 @@ dt_compile_fun(dtrace_hdl_t *dtp, dt_nod case DT_ACT_TRACE: dt_action_trace(dtp, dnp->dn_expr, sdp); break; + case DT_ACT_PRINT: + dt_action_print(dtp, dnp->dn_expr, sdp); + break; case DT_ACT_TRACEMEM: dt_action_tracemem(dtp, dnp->dn_expr, sdp); break; Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c Mon Mar 25 19:12:36 2013 (r248707) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c Mon Mar 25 20:38:09 2013 (r248708) @@ -25,6 +25,7 @@ /* * Copyright (c) 2011, Joyent, Inc. All rights reserved. + * Copyright (c) 2011 by Delphix. All rights reserved. */ #include @@ -2193,6 +2194,7 @@ again: if (act == DTRACEACT_TRACEMEM_DYNSIZE && rec->dtrd_size == sizeof (uint64_t)) { + /* LINTED - alignment */ tracememsize = *((unsigned long long *)addr); continue; } @@ -2300,6 +2302,35 @@ again: goto nextrec; } + /* + * If this is a DIF expression, and the record has a + * format set, this indicates we have a CTF type name + * associated with the data and we should try to print + * it out by type. + */ + if (act == DTRACEACT_DIFEXPR) { + const char *strdata = dt_strdata_lookup(dtp, + rec->dtrd_format); + if (strdata != NULL) { + n = dtrace_print(dtp, fp, strdata, + addr, rec->dtrd_size); + + /* + * dtrace_print() will return -1 on + * error, or return the number of bytes + * consumed. It will return 0 if the + * type couldn't be determined, and we + * should fall through to the normal + * trace method. + */ + if (n < 0) + return (-1); + + if (n > 0) + goto nextrec; + } + } + nofmt: if (act == DTRACEACT_PRINTA) { dt_print_aggdata_t pd; Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c Mon Mar 25 19:12:36 2013 (r248707) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c Mon Mar 25 20:38:09 2013 (r248708) @@ -21,6 +21,7 @@ /* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011 by Delphix. All rights reserved. */ #include @@ -758,16 +759,23 @@ dtrace_dof_create(dtrace_hdl_t *dtp, dtr dofa[i].dofa_difo = DOF_SECIDX_NONE; /* - * If the first action in a statement has format data, - * add the format string to the global string table. + * If the first action in a statement has string data, + * add the string to the global string table. This can + * be due either to a printf() format string + * (dtsd_fmtdata) or a print() type string + * (dtsd_strdata). */ if (sdp != NULL && ap == sdp->dtsd_action) { if (sdp->dtsd_fmtdata != NULL) { (void) dtrace_printf_format(dtp, sdp->dtsd_fmtdata, fmt, maxfmt + 1); strndx = dof_add_string(ddo, fmt); - } else + } else if (sdp->dtsd_strdata != NULL) { + strndx = dof_add_string(ddo, + sdp->dtsd_strdata); + } else { strndx = 0; /* use dtad_arg instead */ + } if ((next = dt_list_next(next)) != NULL) sdp = next->ds_desc; Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_errtags.h ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_errtags.h Mon Mar 25 19:12:36 2013 (r248707) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_errtags.h Mon Mar 25 20:38:09 2013 (r248708) @@ -24,11 +24,14 @@ * Use is subject to license terms. */ + /* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + * Copyright (c) 2011 by Delphix. All rights reserved. + */ + #ifndef _DT_ERRTAGS_H #define _DT_ERRTAGS_H -#pragma ident "%Z%%M% %I% %E% SMI" - #ifdef __cplusplus extern "C" { #endif @@ -187,6 +190,8 @@ typedef enum { D_PRINTA_AGGPROTO, /* printa() aggregation mismatch */ D_TRACE_VOID, /* trace() argument has void type */ D_TRACE_DYN, /* trace() argument has dynamic type */ + D_PRINT_VOID, /* print() argument has void type */ + D_PRINT_DYN, /* print() argument has dynamic type */ D_TRACEMEM_ADDR, /* tracemem() address bad type */ D_TRACEMEM_SIZE, /* tracemem() size bad type */ D_TRACEMEM_ARGS, /* tracemem() illegal number of args */ Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h Mon Mar 25 19:12:36 2013 (r248707) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h Mon Mar 25 20:38:09 2013 (r248708) @@ -26,6 +26,7 @@ /* * Copyright (c) 2011, Joyent, Inc. All rights reserved. + * Copyright (c) 2011 by Delphix. All rights reserved. */ #ifndef _DT_IMPL_H @@ -253,6 +254,8 @@ struct dtrace_hdl { dtrace_aggdesc_t **dt_aggdesc; /* aggregation descriptions */ int dt_maxformat; /* max format ID */ void **dt_formats; /* pointer to format array */ + int dt_maxstrdata; /* max strdata ID */ + char **dt_strdata; /* pointer to strdata array */ dt_aggregate_t dt_aggregate; /* aggregate */ dtrace_bufdesc_t dt_buf; /* staging buffer */ struct dt_pfdict *dt_pfdict; /* dictionary of printf conversions */ @@ -438,8 +441,9 @@ struct dtrace_hdl { #define DT_ACT_UMOD DT_ACT(26) /* umod() action */ #define DT_ACT_UADDR DT_ACT(27) /* uaddr() action */ #define DT_ACT_SETOPT DT_ACT(28) /* setopt() action */ -#define DT_ACT_PRINTM DT_ACT(29) /* printm() action */ -#define DT_ACT_PRINTT DT_ACT(30) /* printt() action */ +#define DT_ACT_PRINT DT_ACT(29) /* print() action */ +#define DT_ACT_PRINTM DT_ACT(30) /* printm() action */ +#define DT_ACT_PRINTT DT_ACT(31) /* printt() action */ /* * Sentinel to tell freopen() to restore the saved stdout. This must not @@ -641,6 +645,9 @@ extern void dt_aggid_destroy(dtrace_hdl_ extern void *dt_format_lookup(dtrace_hdl_t *, int); extern void dt_format_destroy(dtrace_hdl_t *); +extern const char *dt_strdata_lookup(dtrace_hdl_t *, int); +extern void dt_strdata_destroy(dtrace_hdl_t *); + extern int dt_print_quantize(dtrace_hdl_t *, FILE *, const void *, size_t, uint64_t); extern int dt_print_lquantize(dtrace_hdl_t *, FILE *, Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_map.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_map.c Mon Mar 25 19:12:36 2013 (r248707) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_map.c Mon Mar 25 20:38:09 2013 (r248708) @@ -23,7 +23,9 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" +/* + * Copyright (c) 2011 by Delphix. All rights reserved. + */ #include #include @@ -35,10 +37,81 @@ #include static int +dt_strdata_add(dtrace_hdl_t *dtp, dtrace_recdesc_t *rec, void ***data, int *max) +{ + int maxformat; + dtrace_fmtdesc_t fmt; + void *result; + + if (rec->dtrd_format == 0) + return (0); + + if (rec->dtrd_format <= *max && + (*data)[rec->dtrd_format - 1] != NULL) { + return (0); + } + + bzero(&fmt, sizeof (fmt)); + fmt.dtfd_format = rec->dtrd_format; + fmt.dtfd_string = NULL; + fmt.dtfd_length = 0; + + if (dt_ioctl(dtp, DTRACEIOC_FORMAT, &fmt) == -1) + return (dt_set_errno(dtp, errno)); + + if ((fmt.dtfd_string = dt_alloc(dtp, fmt.dtfd_length)) == NULL) + return (dt_set_errno(dtp, EDT_NOMEM)); + + if (dt_ioctl(dtp, DTRACEIOC_FORMAT, &fmt) == -1) { + free(fmt.dtfd_string); + return (dt_set_errno(dtp, errno)); + } + + while (rec->dtrd_format > (maxformat = *max)) { + int new_max = maxformat ? (maxformat << 1) : 1; + size_t nsize = new_max * sizeof (void *); + size_t osize = maxformat * sizeof (void *); + void **new_data = dt_zalloc(dtp, nsize); + + if (new_data == NULL) { + dt_free(dtp, fmt.dtfd_string); + return (dt_set_errno(dtp, EDT_NOMEM)); + } + + bcopy(*data, new_data, osize); + free(*data); + + *data = new_data; + *max = new_max; + } + + switch (rec->dtrd_action) { + case DTRACEACT_DIFEXPR: + result = fmt.dtfd_string; + break; + case DTRACEACT_PRINTA: + result = dtrace_printa_create(dtp, fmt.dtfd_string); + dt_free(dtp, fmt.dtfd_string); + break; + default: + result = dtrace_printf_create(dtp, fmt.dtfd_string); + dt_free(dtp, fmt.dtfd_string); + break; + } + + if (result == NULL) + return (-1); + + (*data)[rec->dtrd_format - 1] = result; + + return (0); +} + +static int dt_epid_add(dtrace_hdl_t *dtp, dtrace_epid_t id) { dtrace_id_t max; - int rval, i, maxformat; + int rval, i; dtrace_eprobedesc_t *enabled, *nenabled; dtrace_probedesc_t *probe; @@ -132,71 +205,23 @@ dt_epid_add(dtrace_hdl_t *dtp, dtrace_ep } for (i = 0; i < enabled->dtepd_nrecs; i++) { - dtrace_fmtdesc_t fmt; dtrace_recdesc_t *rec = &enabled->dtepd_rec[i]; - if (!DTRACEACT_ISPRINTFLIKE(rec->dtrd_action)) - continue; - - if (rec->dtrd_format == 0) - continue; - - if (rec->dtrd_format <= dtp->dt_maxformat && - dtp->dt_formats[rec->dtrd_format - 1] != NULL) - continue; - - bzero(&fmt, sizeof (fmt)); - fmt.dtfd_format = rec->dtrd_format; - fmt.dtfd_string = NULL; - fmt.dtfd_length = 0; - - if (dt_ioctl(dtp, DTRACEIOC_FORMAT, &fmt) == -1) { - rval = dt_set_errno(dtp, errno); - goto err; - } - - if ((fmt.dtfd_string = malloc(fmt.dtfd_length)) == NULL) { - rval = dt_set_errno(dtp, EDT_NOMEM); - goto err; - } - - if (dt_ioctl(dtp, DTRACEIOC_FORMAT, &fmt) == -1) { - rval = dt_set_errno(dtp, errno); - free(fmt.dtfd_string); - goto err; - } - - while (rec->dtrd_format > (maxformat = dtp->dt_maxformat)) { - int new_max = maxformat ? (maxformat << 1) : 1; - size_t nsize = new_max * sizeof (void *); - size_t osize = maxformat * sizeof (void *); - void **new_formats = malloc(nsize); - - if (new_formats == NULL) { - rval = dt_set_errno(dtp, EDT_NOMEM); - free(fmt.dtfd_string); + if (DTRACEACT_ISPRINTFLIKE(rec->dtrd_action)) { + if (dt_strdata_add(dtp, rec, &dtp->dt_formats, + &dtp->dt_maxformat) != 0) { + rval = -1; + goto err; + } + } else if (rec->dtrd_action == DTRACEACT_DIFEXPR) { + if (dt_strdata_add(dtp, rec, + (void ***)&dtp->dt_strdata, + &dtp->dt_maxstrdata) != 0) { + rval = -1; goto err; } - - bzero(new_formats, nsize); - bcopy(dtp->dt_formats, new_formats, osize); - free(dtp->dt_formats); - - dtp->dt_formats = new_formats; - dtp->dt_maxformat = new_max; } - dtp->dt_formats[rec->dtrd_format - 1] = - rec->dtrd_action == DTRACEACT_PRINTA ? - dtrace_printa_create(dtp, fmt.dtfd_string) : - dtrace_printf_create(dtp, fmt.dtfd_string); - - free(fmt.dtfd_string); - - if (dtp->dt_formats[rec->dtrd_format - 1] == NULL) { - rval = -1; /* dt_errno is set for us */ - goto err; - } } dtp->dt_pdesc[id] = probe; @@ -440,3 +465,28 @@ dt_aggid_destroy(dtrace_hdl_t *dtp) dtp->dt_aggdesc = NULL; dtp->dt_maxagg = 0; } + +const char * +dt_strdata_lookup(dtrace_hdl_t *dtp, int idx) +{ + if (idx == 0 || idx > dtp->dt_maxstrdata) + return (NULL); + + if (dtp->dt_strdata == NULL) + return (NULL); + + return (dtp->dt_strdata[idx - 1]); +} + +void +dt_strdata_destroy(dtrace_hdl_t *dtp) +{ + int i; + + for (i = 0; i < dtp->dt_maxstrdata; i++) { + free(dtp->dt_strdata[i]); + } + + free(dtp->dt_strdata); + dtp->dt_strdata = NULL; +} Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c Mon Mar 25 19:12:36 2013 (r248707) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c Mon Mar 25 20:38:09 2013 (r248708) @@ -22,6 +22,7 @@ /* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, Joyent, Inc. All rights reserved. + * Copyright (c) 2011 by Delphix. All rights reserved. */ #include @@ -119,8 +120,9 @@ #define DT_VERS_1_7_1 DT_VERSION_NUMBER(1, 7, 1) #define DT_VERS_1_8 DT_VERSION_NUMBER(1, 8, 0) #define DT_VERS_1_8_1 DT_VERSION_NUMBER(1, 8, 1) -#define DT_VERS_LATEST DT_VERS_1_8_1 -#define DT_VERS_STRING "Sun D 1.8.1" +#define DT_VERS_1_9 DT_VERSION_NUMBER(1, 9, 0) +#define DT_VERS_LATEST DT_VERS_1_9 +#define DT_VERS_STRING "Sun D 1.9" const dt_version_t _dtrace_versions[] = { DT_VERS_1_0, /* D API 1.0.0 (PSARC 2001/466) Solaris 10 FCS */ @@ -140,6 +142,7 @@ const dt_version_t _dtrace_versions[] = DT_VERS_1_7_1, /* D API 1.7.1 */ DT_VERS_1_8, /* D API 1.8 */ DT_VERS_1_8_1, /* D API 1.8.1 */ + DT_VERS_1_9, /* D API 1.9 */ 0 }; @@ -357,6 +360,8 @@ static const dt_ident_t _dtrace_globals[ &dt_idops_type, "pid_t" }, { "ppid", DT_IDENT_SCALAR, 0, DIF_VAR_PPID, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "pid_t" }, +{ "print", DT_IDENT_ACTFUNC, 0, DT_ACT_PRINT, DT_ATTR_STABCMN, DT_VERS_1_9, + &dt_idops_func, "void(@)" }, { "printa", DT_IDENT_ACTFUNC, 0, DT_ACT_PRINTA, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_func, "void(@, ...)" }, { "printf", DT_IDENT_ACTFUNC, 0, DT_ACT_PRINTF, DT_ATTR_STABCMN, DT_VERS_1_0, @@ -1622,6 +1627,7 @@ dtrace_close(dtrace_hdl_t *dtp) dt_epid_destroy(dtp); dt_aggid_destroy(dtp); dt_format_destroy(dtp); + dt_strdata_destroy(dtp); dt_buffered_destroy(dtp); dt_aggregate_destroy(dtp); free(dtp->dt_buf.dtbd_data); Copied: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c (from r248707, vendor/illumos/dist/lib/libdtrace/common/dt_print.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c Mon Mar 25 20:38:09 2013 (r248708, copy of r248707, vendor/illumos/dist/lib/libdtrace/common/dt_print.c) @@ -0,0 +1,648 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +/* + * Copyright (c) 2011 by Delphix. All rights reserved. + */ + +/* + * DTrace print() action + * + * This file contains the post-processing logic for the print() action. The + * print action behaves identically to trace() in that it generates a + * DTRACEACT_DIFEXPR action, but the action argument field refers to a CTF type + * string stored in the DOF string table (similar to printf formats). We + * take the result of the trace action and post-process it in the fashion of + * MDB's ::print dcmd. + * + * This implementation differs from MDB's in the following ways: + * + * - We do not expose any options or flags. The behavior of print() is + * equivalent to "::print -tn". + * + * - MDB will display "holes" in structures (unused padding between + * members). + * + * - When printing arrays of structures, MDB will leave a trailing ',' + * after the last element. + * + * - MDB will print time_t types as date and time. + * + * - MDB will detect when an enum is actually the OR of several flags, + * and print it out with the constituent flags separated. + * + * - For large arrays, MDB will print the first few members and then + * print a "..." continuation line. + * + * - MDB will break and wrap arrays at 80 columns. + * + * - MDB prints out floats and doubles by hand, as it must run in kmdb + * context. We're able to leverage the printf() format strings, + * but the result is a slightly different format. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +/* determines whether the given integer CTF encoding is a character */ +#define CTF_IS_CHAR(e) \ + (((e).cte_format & (CTF_INT_CHAR | CTF_INT_SIGNED)) == \ + (CTF_INT_CHAR | CTF_INT_SIGNED) && (e).cte_bits == NBBY) +/* determines whether the given CTF kind is a struct or union */ +#define CTF_IS_STRUCTLIKE(k) \ + ((k) == CTF_K_STRUCT || (k) == CTF_K_UNION) + +/* + * Print structure passed down recursively through printing algorithm. + */ +typedef struct dt_printarg { + caddr_t pa_addr; /* base address of trace data */ + ctf_file_t *pa_ctfp; /* CTF container */ + int pa_depth; /* member depth */ + int pa_nest; /* nested array depth */ + FILE *pa_file; /* output file */ +} dt_printarg_t; + +static int dt_print_member(const char *, ctf_id_t, ulong_t, int, void *); + +/* + * Safe version of ctf_type_name() that will fall back to just "" if it + * can't resolve the type. + */ +static void +dt_print_type_name(ctf_file_t *ctfp, ctf_id_t id, char *buf, size_t buflen) +{ + if (ctf_type_name(ctfp, id, buf, buflen) == NULL) + (void) snprintf(buf, buflen, "<%ld>", id); +} + +/* + * Print any necessary trailing braces for structures or unions. We don't get + * invoked when a struct or union ends, so we infer the need to print braces + * based on the depth the last time we printed something and the new depth. + */ +static void +dt_print_trailing_braces(dt_printarg_t *pap, int depth) +{ + int d; + + for (d = pap->pa_depth; d > depth; d--) { + (void) fprintf(pap->pa_file, "%*s}%s", + (d + pap->pa_nest - 1) * 4, "", + d == depth + 1 ? "" : "\n"); + } +} + +/* + * Print the appropriate amount of indentation given the current depth and + * array nesting. + */ +static void +dt_print_indent(dt_printarg_t *pap) +{ + (void) fprintf(pap->pa_file, "%*s", + (pap->pa_depth + pap->pa_nest) * 4, ""); +} + +/* + * Print a bitfield. It's worth noting that the D compiler support for + * bitfields is currently broken; printing "D`user_desc_t" (pulled in by the + * various D provider files) will produce incorrect results compared to + * "genunix`user_desc_t". + */ +static void +print_bitfield(dt_printarg_t *pap, ulong_t off, ctf_encoding_t *ep) +{ + FILE *fp = pap->pa_file; + caddr_t addr = pap->pa_addr + off / NBBY; + uint64_t mask = (1ULL << ep->cte_bits) - 1; + uint64_t value = 0; + size_t size = (ep->cte_bits + (NBBY - 1)) / NBBY; + uint8_t *buf = (uint8_t *)&value; + uint8_t shift; + + /* + * On big-endian machines, we need to adjust the buf pointer to refer + * to the lowest 'size' bytes in 'value', and we need to shift based on + * the offset from the end of the data, not the offset of the start. + */ +#ifdef _BIG_ENDIAN + buf += sizeof (value) - size; + off += ep->cte_bits; +#endif + bcopy(addr, buf, size); + shift = off % NBBY; + + /* + * Offsets are counted from opposite ends on little- and + * big-endian machines. + */ +#ifdef _BIG_ENDIAN + shift = NBBY - shift; +#endif + + /* + * If the bits we want do not begin on a byte boundary, shift the data + * right so that the value is in the lowest 'cte_bits' of 'value'. + */ + if (off % NBBY != 0) + value >>= shift; + value &= mask; + + (void) fprintf(fp, "%#llx", (u_longlong_t)value); +} + +/* + * Dump the contents of memory as a fixed-size integer in hex. + */ +static void +dt_print_hex(FILE *fp, caddr_t addr, size_t size) +{ + switch (size) { + case sizeof (uint8_t): + (void) fprintf(fp, "%#x", *(uint8_t *)addr); + break; + case sizeof (uint16_t): + /* LINTED - alignment */ + (void) fprintf(fp, "%#x", *(uint16_t *)addr); + break; + case sizeof (uint32_t): + /* LINTED - alignment */ + (void) fprintf(fp, "%#x", *(uint32_t *)addr); + break; + case sizeof (uint64_t): + (void) fprintf(fp, "%#llx", + /* LINTED - alignment */ + (unsigned long long)*(uint64_t *)addr); + break; + default: + (void) fprintf(fp, "", (uint_t)size); + } +} + +/* + * Print an integer type. Before dumping the contents via dt_print_hex(), we + * first check the encoding to see if it's part of a bitfield or a character. + */ +static void +dt_print_int(ctf_id_t base, ulong_t off, dt_printarg_t *pap) +{ + FILE *fp = pap->pa_file; + ctf_file_t *ctfp = pap->pa_ctfp; + ctf_encoding_t e; + size_t size; + caddr_t addr = pap->pa_addr + off / NBBY; + + if (ctf_type_encoding(ctfp, base, &e) == CTF_ERR) { + (void) fprintf(fp, ""); + return; + } + + /* + * This comes from MDB - it's not clear under what circumstances this + * would be found. + */ + if (e.cte_format & CTF_INT_VARARGS) { + (void) fprintf(fp, "..."); + return; + } + + /* + * We print this as a bitfield if the bit encoding indicates it's not + * an even power of two byte size, or is larger than 8 bytes. + */ + size = e.cte_bits / NBBY; + if (size > 8 || (e.cte_bits % NBBY) != 0 || (size & (size - 1)) != 0) { + print_bitfield(pap, off, &e); + return; + } + + /* + * If this is a character, print it out as such. + */ + if (CTF_IS_CHAR(e)) { + char c = *(char *)addr; + if (isprint(c)) + (void) fprintf(fp, "'%c'", c); + else if (c == 0) + (void) fprintf(fp, "'\\0'"); + else + (void) fprintf(fp, "'\\%03o'", c); + return; + } + + dt_print_hex(fp, addr, size); +} + +/* + * Print a floating point (float, double, long double) value. + */ +/* ARGSUSED */ +static void +dt_print_float(ctf_id_t base, ulong_t off, dt_printarg_t *pap) +{ + FILE *fp = pap->pa_file; + ctf_file_t *ctfp = pap->pa_ctfp; + ctf_encoding_t e; + caddr_t addr = pap->pa_addr + off / NBBY; + + if (ctf_type_encoding(ctfp, base, &e) == 0) { + if (e.cte_format == CTF_FP_SINGLE && + e.cte_bits == sizeof (float) * NBBY) { + /* LINTED - alignment */ + (void) fprintf(fp, "%+.7e", *((float *)addr)); + } else if (e.cte_format == CTF_FP_DOUBLE && + e.cte_bits == sizeof (double) * NBBY) { + /* LINTED - alignment */ + (void) fprintf(fp, "%+.7e", *((double *)addr)); + } else if (e.cte_format == CTF_FP_LDOUBLE && + e.cte_bits == sizeof (long double) * NBBY) { + /* LINTED - alignment */ + (void) fprintf(fp, "%+.16LE", *((long double *)addr)); + } else { + (void) fprintf(fp, ""); + } + } +} + +/* + * A pointer is printed as a fixed-size integer. This is used both for + * pointers and functions. + */ +static void +dt_print_ptr(ctf_id_t base, ulong_t off, dt_printarg_t *pap) +{ + FILE *fp = pap->pa_file; + ctf_file_t *ctfp = pap->pa_ctfp; + caddr_t addr = pap->pa_addr + off / NBBY; + size_t size = ctf_type_size(ctfp, base); + + dt_print_hex(fp, addr, size); +} + +/* + * Print out an array. This is somewhat complex, as we must manually visit + * each member, and recursively invoke ctf_type_visit() for each member. If + * the members are non-structs, then we print them out directly: + * + * [ 0x14, 0x2e, 0 ] + * + * If they are structs, then we print out the necessary leading and trailing + * braces, to end up with: + * + * [ + * type { + * ... + * }, + * type { + * ... + * } + * ] + * + * We also use a heuristic to detect whether the array looks like a character + * array. If the encoding indicates it's a character, and we have all + * printable characters followed by a null byte, then we display it as a + * string: + * + * [ "string" ] + */ +static void +dt_print_array(ctf_id_t base, ulong_t off, dt_printarg_t *pap) +{ + FILE *fp = pap->pa_file; + ctf_file_t *ctfp = pap->pa_ctfp; + caddr_t addr = pap->pa_addr + off / NBBY; + ctf_arinfo_t car; + ssize_t eltsize; + ctf_encoding_t e; + int i; + boolean_t isstring; + int kind; + ctf_id_t rtype; + + if (ctf_array_info(ctfp, base, &car) == CTF_ERR) { + (void) fprintf(fp, "0x%p", (void *)addr); + return; + } + + if ((eltsize = ctf_type_size(ctfp, car.ctr_contents)) < 0 || + (rtype = ctf_type_resolve(ctfp, car.ctr_contents)) == CTF_ERR || + (kind = ctf_type_kind(ctfp, rtype)) == CTF_ERR) { + (void) fprintf(fp, "", car.ctr_contents); + return; + } + + /* see if this looks like a string */ + isstring = B_FALSE; + if (kind == CTF_K_INTEGER && + ctf_type_encoding(ctfp, rtype, &e) != CTF_ERR && CTF_IS_CHAR(e)) { + char c; + for (i = 0; i < car.ctr_nelems; i++) { + c = *((char *)addr + eltsize * i); + if (!isprint(c) || c == '\0') + break; + } + + if (i != car.ctr_nelems && c == '\0') + isstring = B_TRUE; + } + + /* + * As a slight aesthetic optimization, if we are a top-level type, then + * don't bother printing out the brackets. This lets print("foo") look + * like: + * + * string "foo" + * + * As D will internally represent this as a char[256] array. + */ + if (!isstring || pap->pa_depth != 0) + (void) fprintf(fp, "[ "); + + if (isstring) + (void) fprintf(fp, "\""); + + for (i = 0; i < car.ctr_nelems; i++) { + if (isstring) { + char c = *((char *)addr + eltsize * i); + if (c == '\0') + break; + (void) fprintf(fp, "%c", c); + } else { + /* + * Recursively invoke ctf_type_visit() on each member. + * We setup a new printarg struct with 'pa_nest' set to + * indicate that we are within a nested array. + */ + dt_printarg_t pa = *pap; + pa.pa_nest += pap->pa_depth + 1; + pa.pa_depth = 0; + pa.pa_addr = addr + eltsize * i; + (void) ctf_type_visit(ctfp, car.ctr_contents, + dt_print_member, &pa); + + dt_print_trailing_braces(&pa, 0); + if (i != car.ctr_nelems - 1) + (void) fprintf(fp, ", "); + else if (CTF_IS_STRUCTLIKE(kind)) + (void) fprintf(fp, "\n"); + } + } + + if (isstring) + (void) fprintf(fp, "\""); + + if (!isstring || pap->pa_depth != 0) { + if (CTF_IS_STRUCTLIKE(kind)) + dt_print_indent(pap); + else + (void) fprintf(fp, " "); + (void) fprintf(fp, "]"); + } +} + +/* + * This isued by both structs and unions to print the leading brace. + */ +/* ARGSUSED */ +static void +dt_print_structlike(ctf_id_t id, ulong_t off, dt_printarg_t *pap) +{ + (void) fprintf(pap->pa_file, "{"); +} + +/* + * For enums, we try to print the enum name, and fall back to the value if it + * can't be determined. We do not do any fancy flag processing like mdb. + */ +/* ARGSUSED */ +static void +dt_print_enum(ctf_id_t base, ulong_t off, dt_printarg_t *pap) +{ + FILE *fp = pap->pa_file; + ctf_file_t *ctfp = pap->pa_ctfp; + const char *ename; + int value = 0; + + if ((ename = ctf_enum_name(ctfp, base, value)) != NULL) + (void) fprintf(fp, "%s", ename); + else + (void) fprintf(fp, "%d", value); +} + +/* + * Forward declaration. There's not much to do here without the complete + * type information, so just print out this fact and drive on. + */ +/* ARGSUSED */ +static void +dt_print_tag(ctf_id_t base, ulong_t off, dt_printarg_t *pap) +{ + (void) fprintf(pap->pa_file, ""); +} + +typedef void dt_printarg_f(ctf_id_t, ulong_t, dt_printarg_t *); + +static dt_printarg_f *const dt_printfuncs[] = { + dt_print_int, /* CTF_K_INTEGER */ + dt_print_float, /* CTF_K_FLOAT */ + dt_print_ptr, /* CTF_K_POINTER */ + dt_print_array, /* CTF_K_ARRAY */ + dt_print_ptr, /* CTF_K_FUNCTION */ + dt_print_structlike, /* CTF_K_STRUCT */ + dt_print_structlike, /* CTF_K_UNION */ + dt_print_enum, /* CTF_K_ENUM */ + dt_print_tag /* CTF_K_FORWARD */ +}; + +/* + * Print one member of a structure. This callback is invoked from + * ctf_type_visit() recursively. + */ +static int +dt_print_member(const char *name, ctf_id_t id, ulong_t off, int depth, + void *data) +{ + char type[DT_TYPE_NAMELEN]; + int kind; + dt_printarg_t *pap = data; + FILE *fp = pap->pa_file; + ctf_file_t *ctfp = pap->pa_ctfp; + boolean_t arraymember; + boolean_t brief; + ctf_encoding_t e; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 01:17:07 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id B8A8A5D1; Tue, 26 Mar 2013 01:17:07 +0000 (UTC) (envelope-from kan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 91DF4E0E; Tue, 26 Mar 2013 01:17:07 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2Q1H7bE044116; Tue, 26 Mar 2013 01:17:07 GMT (envelope-from kan@svn.freebsd.org) Received: (from kan@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2Q1H7cF044113; Tue, 26 Mar 2013 01:17:07 GMT (envelope-from kan@svn.freebsd.org) Message-Id: <201303260117.r2Q1H7cF044113@svn.freebsd.org> From: Alexander Kabaev Date: Tue, 26 Mar 2013 01:17:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248712 - in head/sys: geom kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 01:17:07 -0000 Author: kan Date: Tue Mar 26 01:17:06 2013 New Revision: 248712 URL: http://svnweb.freebsd.org/changeset/base/248712 Log: Do not pass unmapped buffers to drivers that cannot handle them In physio, check if device can handle unmapped IO and pass an appropriately mapped buffer to the driver strategy routine. The only driver in the tree that can handle unmapped buffers is one exposed by GEOM, so mark it as such with the new flag in the driver cdevsw structure. This fixes insta-panics on hosts, running dconschat, as /dev/fwmem is an example of the driver that makes use of physio routine, but bypasses the g_down thread, where the buffer gets mapped normally. Discussed with: kib (earlier version) Modified: head/sys/geom/geom_dev.c head/sys/kern/kern_physio.c head/sys/sys/conf.h Modified: head/sys/geom/geom_dev.c ============================================================================== --- head/sys/geom/geom_dev.c Mon Mar 25 23:38:01 2013 (r248711) +++ head/sys/geom/geom_dev.c Tue Mar 26 01:17:06 2013 (r248712) @@ -78,7 +78,7 @@ static struct cdevsw g_dev_cdevsw = { .d_ioctl = g_dev_ioctl, .d_strategy = g_dev_strategy, .d_name = "g_dev", - .d_flags = D_DISK | D_TRACKCLOSE, + .d_flags = D_DISK | D_TRACKCLOSE | D_UNMAPPED_IO, }; static g_taste_t g_dev_taste; Modified: head/sys/kern/kern_physio.c ============================================================================== --- head/sys/kern/kern_physio.c Mon Mar 25 23:38:01 2013 (r248711) +++ head/sys/kern/kern_physio.c Tue Mar 26 01:17:06 2013 (r248712) @@ -91,11 +91,21 @@ physio(struct cdev *dev, struct uio *uio bp->b_blkno = btodb(bp->b_offset); - if (uio->uio_segflg == UIO_USERSPACE) - if (vmapbuf(bp, 0) < 0) { + if (uio->uio_segflg == UIO_USERSPACE) { + struct cdevsw *csw; + int mapped; + + csw = dev->si_devsw; + if (csw != NULL && + (csw->d_flags & D_UNMAPPED_IO) != 0) + mapped = 0; + else + mapped = 1; + if (vmapbuf(bp, mapped) < 0) { error = EFAULT; goto doerror; } + } dev_strategy(dev, bp); if (uio->uio_rw == UIO_READ) Modified: head/sys/sys/conf.h ============================================================================== --- head/sys/sys/conf.h Mon Mar 25 23:38:01 2013 (r248711) +++ head/sys/sys/conf.h Tue Mar 26 01:17:06 2013 (r248712) @@ -167,6 +167,7 @@ typedef int dumper_t( #define D_MMAP_ANON 0x00100000 /* special treatment in vm_mmap.c */ #define D_NEEDGIANT 0x00400000 /* driver want Giant */ #define D_NEEDMINOR 0x00800000 /* driver uses clone_create() */ +#define D_UNMAPPED_IO 0x01000000 /* d_strategy can accept unmapped IO */ /* * Version numbers. From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 04:47:41 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 0A2249A7; Tue, 26 Mar 2013 04:47:41 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id F10C9921; Tue, 26 Mar 2013 04:47:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2Q4le0k008370; Tue, 26 Mar 2013 04:47:40 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2Q4leTX008369; Tue, 26 Mar 2013 04:47:40 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201303260447.r2Q4leTX008369@svn.freebsd.org> From: Adrian Chadd Date: Tue, 26 Mar 2013 04:47:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248713 - head/sys/dev/ath X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 04:47:41 -0000 Author: adrian Date: Tue Mar 26 04:47:40 2013 New Revision: 248713 URL: http://svnweb.freebsd.org/changeset/base/248713 Log: Migrate the multicast queue assembly code to not use the axq_link pointer and instead use the HAL method to set the link pointer. Tested: * AR9280, hostap mode, CABQ frames being queued and transmitted Modified: head/sys/dev/ath/if_ath_tx.c Modified: head/sys/dev/ath/if_ath_tx.c ============================================================================== --- head/sys/dev/ath/if_ath_tx.c Tue Mar 26 01:17:06 2013 (r248712) +++ head/sys/dev/ath/if_ath_tx.c Tue Mar 26 04:47:40 2013 (r248713) @@ -704,18 +704,20 @@ ath_tx_handoff_mcast(struct ath_softc *s ("%s: busy status 0x%x", __func__, bf->bf_flags)); ATH_TXQ_LOCK(txq); - if (txq->axq_link != NULL) { - struct ath_buf *last = ATH_TXQ_LAST(txq, axq_q_s); + if (ATH_TXQ_LAST(txq, axq_q_s) != NULL) { + struct ath_buf *bf_last = ATH_TXQ_LAST(txq, axq_q_s); struct ieee80211_frame *wh; /* mark previous frame */ - wh = mtod(last->bf_m, struct ieee80211_frame *); + wh = mtod(bf_last->bf_m, struct ieee80211_frame *); wh->i_fc[1] |= IEEE80211_FC1_MORE_DATA; - bus_dmamap_sync(sc->sc_dmat, last->bf_dmamap, + bus_dmamap_sync(sc->sc_dmat, bf_last->bf_dmamap, BUS_DMASYNC_PREWRITE); /* link descriptor */ - *txq->axq_link = bf->bf_daddr; + ath_hal_settxdesclink(sc->sc_ah, + bf_last->bf_lastds, + bf->bf_daddr); } ATH_TXQ_INSERT_TAIL(txq, bf, bf_list); ath_hal_gettxdesclinkptr(sc->sc_ah, bf->bf_lastds, &txq->axq_link); From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 04:48:58 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id BFFEBB2D; Tue, 26 Mar 2013 04:48:58 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id B33AC932; Tue, 26 Mar 2013 04:48:58 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2Q4mwGf008573; Tue, 26 Mar 2013 04:48:58 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2Q4mwRp008572; Tue, 26 Mar 2013 04:48:58 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201303260448.r2Q4mwRp008572@svn.freebsd.org> From: Adrian Chadd Date: Tue, 26 Mar 2013 04:48:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248714 - head/sys/dev/ath X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 04:48:58 -0000 Author: adrian Date: Tue Mar 26 04:48:58 2013 New Revision: 248714 URL: http://svnweb.freebsd.org/changeset/base/248714 Log: Convert the EDMA multicast queue code over to use the HAL method to set the descriptor link pointer, rather than directly. This is needed on AR9380 and later (ie, EDMA) NICs so the multicast queue has a chance in hell of being put together right. Tested: * AR9380, AR9580 in hostap mode, CABQ traffic (but with other patches..) Modified: head/sys/dev/ath/if_ath_tx_edma.c Modified: head/sys/dev/ath/if_ath_tx_edma.c ============================================================================== --- head/sys/dev/ath/if_ath_tx_edma.c Tue Mar 26 04:47:40 2013 (r248713) +++ head/sys/dev/ath/if_ath_tx_edma.c Tue Mar 26 04:48:58 2013 (r248714) @@ -249,7 +249,7 @@ ath_edma_xmit_handoff_mcast(struct ath_s struct ath_buf *bf) { - ATH_TXQ_LOCK_ASSERT(txq); + ATH_TX_LOCK_ASSERT(sc); KASSERT((bf->bf_flags & ATH_BUF_BUSY) == 0, ("%s: busy status 0x%x", __func__, bf->bf_flags)); @@ -257,7 +257,7 @@ ath_edma_xmit_handoff_mcast(struct ath_s /* * XXX this is mostly duplicated in ath_tx_handoff_mcast(). */ - if (ATH_TXQ_FIRST(txq) != NULL) { + if (ATH_TXQ_LAST(txq, axq_q_s) != NULL) { struct ath_buf *bf_last = ATH_TXQ_LAST(txq, axq_q_s); struct ieee80211_frame *wh; @@ -270,7 +270,9 @@ ath_edma_xmit_handoff_mcast(struct ath_s BUS_DMASYNC_PREWRITE); /* link descriptor */ - *txq->axq_link = bf->bf_daddr; + ath_hal_settxdesclink(sc->sc_ah, + bf_last->bf_lastds, + bf->bf_daddr); } #ifdef ATH_DEBUG_ALQ From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 04:52:17 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 64F4FCD1; Tue, 26 Mar 2013 04:52:17 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 3F68C950; Tue, 26 Mar 2013 04:52:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2Q4qHXE010619; Tue, 26 Mar 2013 04:52:17 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2Q4qH9H010618; Tue, 26 Mar 2013 04:52:17 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201303260452.r2Q4qH9H010618@svn.freebsd.org> From: Adrian Chadd Date: Tue, 26 Mar 2013 04:52:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248715 - head/sys/dev/ath X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 04:52:17 -0000 Author: adrian Date: Tue Mar 26 04:52:16 2013 New Revision: 248715 URL: http://svnweb.freebsd.org/changeset/base/248715 Log: Convert the CABQ queue code over to use the HAL link pointer method instead of axq_link. This (among a bunch of uncommitted work) is required for EDMA chips to correctly transmit frames on the CABQ. Tested: * AR9280, hostap mode * AR9380/AR9580, hostap mode (staggered beacons) TODO: * This code only really gets called when burst beacons are used; it glues multiple CABQ queues together when sending to the hardware. * More thorough bursted beacon testing! (first requires some work with the beacon queue code for bursted beacons, as that currently uses the link pointer and will fail on EDMA chips.) Modified: head/sys/dev/ath/if_ath_beacon.c Modified: head/sys/dev/ath/if_ath_beacon.c ============================================================================== --- head/sys/dev/ath/if_ath_beacon.c Tue Mar 26 04:48:58 2013 (r248714) +++ head/sys/dev/ath/if_ath_beacon.c Tue Mar 26 04:52:16 2013 (r248715) @@ -632,7 +632,7 @@ ath_beacon_generate(struct ath_softc *sc /* NB: only at DTIM */ ATH_TXQ_LOCK(&avp->av_mcastq); if (nmcastq) { - struct ath_buf *bfm; + struct ath_buf *bfm, *bfc_last; /* * Move frames from the s/w mcast q to the h/w cab q. @@ -645,16 +645,23 @@ ath_beacon_generate(struct ath_softc *sc * MORE data bit set on the last frame of each * intermediary VAP (ie, only clear the MORE * bit of the last frame on the last vap?) - * - * XXX TODO: once we append this, what happens - * to cabq->axq_link? It'll point at the avp - * mcastq link pointer, so things should be OK. - * Just double-check this is what actually happens. */ bfm = TAILQ_FIRST(&avp->av_mcastq.axq_q); ATH_TXQ_LOCK(cabq); - if (cabq->axq_link != NULL) - *cabq->axq_link = bfm->bf_daddr; + + /* + * If there's already a frame on the CABQ, we + * need to link to the end of the last frame. + * We can't use axq_link here because + * EDMA descriptors require some recalculation + * (checksum) to occur. + */ + bfc_last = ATH_TXQ_LAST(cabq, axq_q_s); + if (bfc_last != NULL) { + ath_hal_settxdesclink(sc->sc_ah, + bfc_last->bf_lastds, + bfm->bf_daddr); + } ath_txqmove(cabq, &avp->av_mcastq); ATH_TXQ_UNLOCK(cabq); /* From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 04:53:41 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 57CA7E57; Tue, 26 Mar 2013 04:53:41 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 4913B962; Tue, 26 Mar 2013 04:53:41 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2Q4rfBi010825; Tue, 26 Mar 2013 04:53:41 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2Q4rfnH010824; Tue, 26 Mar 2013 04:53:41 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201303260453.r2Q4rfnH010824@svn.freebsd.org> From: Adrian Chadd Date: Tue, 26 Mar 2013 04:53:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248716 - head/sys/dev/ath X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 04:53:41 -0000 Author: adrian Date: Tue Mar 26 04:53:40 2013 New Revision: 248716 URL: http://svnweb.freebsd.org/changeset/base/248716 Log: Remove this dead code - it's no longer relevant (as yes, we do actually support TX on EDMA chips.) Modified: head/sys/dev/ath/if_ath_tx_edma.c Modified: head/sys/dev/ath/if_ath_tx_edma.c ============================================================================== --- head/sys/dev/ath/if_ath_tx_edma.c Tue Mar 26 04:52:16 2013 (r248715) +++ head/sys/dev/ath/if_ath_tx_edma.c Tue Mar 26 04:53:40 2013 (r248716) @@ -318,14 +318,6 @@ ath_edma_xmit_handoff(struct ath_softc * ath_edma_xmit_handoff_mcast(sc, txq, bf); else ath_edma_xmit_handoff_hw(sc, txq, bf); - -#if 0 - /* - * XXX For now this is a placeholder; free the buffer - * and inform the stack that the TX failed. - */ - ath_tx_default_comp(sc, bf, 1); -#endif } static int From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 04:56:55 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 42E52FF3; Tue, 26 Mar 2013 04:56:55 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 363A697D; Tue, 26 Mar 2013 04:56:55 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2Q4utbi011315; Tue, 26 Mar 2013 04:56:55 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2Q4usg9011313; Tue, 26 Mar 2013 04:56:54 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201303260456.r2Q4usg9011313@svn.freebsd.org> From: Adrian Chadd Date: Tue, 26 Mar 2013 04:56:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248717 - head/sys/dev/ath X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 04:56:55 -0000 Author: adrian Date: Tue Mar 26 04:56:54 2013 New Revision: 248717 URL: http://svnweb.freebsd.org/changeset/base/248717 Log: Remove the mcast path calls to ath_hal_gettxdesclinkptr() for axq_link - they're no longer needed for the legacy path and they're not wanted for the EDMA path. Tested: * AR9280, hostap + CABQ * AR9380/AR9580, hostap + CABQ Modified: head/sys/dev/ath/if_ath_tx.c head/sys/dev/ath/if_ath_tx_edma.c Modified: head/sys/dev/ath/if_ath_tx.c ============================================================================== --- head/sys/dev/ath/if_ath_tx.c Tue Mar 26 04:53:40 2013 (r248716) +++ head/sys/dev/ath/if_ath_tx.c Tue Mar 26 04:56:54 2013 (r248717) @@ -720,7 +720,6 @@ ath_tx_handoff_mcast(struct ath_softc *s bf->bf_daddr); } ATH_TXQ_INSERT_TAIL(txq, bf, bf_list); - ath_hal_gettxdesclinkptr(sc->sc_ah, bf->bf_lastds, &txq->axq_link); ATH_TXQ_UNLOCK(txq); } Modified: head/sys/dev/ath/if_ath_tx_edma.c ============================================================================== --- head/sys/dev/ath/if_ath_tx_edma.c Tue Mar 26 04:53:40 2013 (r248716) +++ head/sys/dev/ath/if_ath_tx_edma.c Tue Mar 26 04:56:54 2013 (r248717) @@ -279,9 +279,7 @@ ath_edma_xmit_handoff_mcast(struct ath_s if (if_ath_alq_checkdebug(&sc->sc_alq, ATH_ALQ_EDMA_TXDESC)) ath_tx_alq_post(sc, bf); #endif /* ATH_DEBUG_ALQ */ - ATH_TXQ_INSERT_TAIL(txq, bf, bf_list); - ath_hal_gettxdesclinkptr(sc->sc_ah, bf->bf_lastds, &txq->axq_link); ATH_TXQ_UNLOCK(txq); } From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 05:42:13 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D2D02B09; Tue, 26 Mar 2013 05:42:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id C5DBCBDB; Tue, 26 Mar 2013 05:42:13 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2Q5gDYD025978; Tue, 26 Mar 2013 05:42:13 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2Q5gDgd025975; Tue, 26 Mar 2013 05:42:13 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201303260542.r2Q5gDgd025975@svn.freebsd.org> From: Alexander Motin Date: Tue, 26 Mar 2013 05:42:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248720 - in head/sys/geom: gate nop raid X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 05:42:13 -0000 Author: mav Date: Tue Mar 26 05:42:12 2013 New Revision: 248720 URL: http://svnweb.freebsd.org/changeset/base/248720 Log: Remove extra bio_data and bio_length copying to child request after calling g_clone_bio(), that already copied them. Modified: head/sys/geom/gate/g_gate.c head/sys/geom/nop/g_nop.c head/sys/geom/raid/tr_raid1e.c Modified: head/sys/geom/gate/g_gate.c ============================================================================== --- head/sys/geom/gate/g_gate.c Tue Mar 26 05:31:08 2013 (r248719) +++ head/sys/geom/gate/g_gate.c Tue Mar 26 05:42:12 2013 (r248720) @@ -245,8 +245,6 @@ g_gate_start(struct bio *pbp) } cbp->bio_done = g_gate_done; cbp->bio_offset = pbp->bio_offset + sc->sc_readoffset; - cbp->bio_data = pbp->bio_data; - cbp->bio_length = pbp->bio_length; cbp->bio_to = sc->sc_readcons->provider; g_io_request(cbp, sc->sc_readcons); return; Modified: head/sys/geom/nop/g_nop.c ============================================================================== --- head/sys/geom/nop/g_nop.c Tue Mar 26 05:31:08 2013 (r248719) +++ head/sys/geom/nop/g_nop.c Tue Mar 26 05:42:12 2013 (r248720) @@ -136,8 +136,6 @@ g_nop_start(struct bio *bp) } cbp->bio_done = g_std_done; cbp->bio_offset = bp->bio_offset + sc->sc_offset; - cbp->bio_data = bp->bio_data; - cbp->bio_length = bp->bio_length; pp = LIST_FIRST(&gp->provider); KASSERT(pp != NULL, ("NULL pp")); cbp->bio_to = pp; Modified: head/sys/geom/raid/tr_raid1e.c ============================================================================== --- head/sys/geom/raid/tr_raid1e.c Tue Mar 26 05:31:08 2013 (r248719) +++ head/sys/geom/raid/tr_raid1e.c Tue Mar 26 05:42:12 2013 (r248720) @@ -1076,8 +1076,6 @@ rebuild_round_done: offset += vol->v_strip_size; } cbp->bio_offset = offset + start; - cbp->bio_length = bp->bio_length; - cbp->bio_data = bp->bio_data; cbp->bio_cmd = BIO_WRITE; cbp->bio_cflags = G_RAID_BIO_FLAG_REMAP; cbp->bio_caller2 = (void *)mask; From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 05:58:50 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 59DDCE6D; Tue, 26 Mar 2013 05:58:50 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 4CE92D0D; Tue, 26 Mar 2013 05:58:50 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2Q5wolU029754; Tue, 26 Mar 2013 05:58:50 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2Q5wob0029753; Tue, 26 Mar 2013 05:58:50 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201303260558.r2Q5wob0029753@svn.freebsd.org> From: Alexander Motin Date: Tue, 26 Mar 2013 05:58:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248721 - head/sys/geom/nop X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 05:58:50 -0000 Author: mav Date: Tue Mar 26 05:58:49 2013 New Revision: 248721 URL: http://svnweb.freebsd.org/changeset/base/248721 Log: GEOM NOP does not touch the data, so pass G_PF_ACCEPT_UNMAPPED flag through. Modified: head/sys/geom/nop/g_nop.c Modified: head/sys/geom/nop/g_nop.c ============================================================================== --- head/sys/geom/nop/g_nop.c Tue Mar 26 05:42:12 2013 (r248720) +++ head/sys/geom/nop/g_nop.c Tue Mar 26 05:58:49 2013 (r248721) @@ -242,6 +242,7 @@ g_nop_create(struct gctl_req *req, struc goto fail; } + newpp->flags |= pp->flags & G_PF_ACCEPT_UNMAPPED; g_error_provider(newpp, 0); G_NOP_DEBUG(0, "Device %s created.", gp->name); return (0); From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 07:55:25 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 95E1BBBC; Tue, 26 Mar 2013 07:55:25 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 88414615; Tue, 26 Mar 2013 07:55:25 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2Q7tPYQ065830; Tue, 26 Mar 2013 07:55:25 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2Q7tPv6065829; Tue, 26 Mar 2013 07:55:25 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201303260755.r2Q7tPv6065829@svn.freebsd.org> From: Alexander Motin Date: Tue, 26 Mar 2013 07:55:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248722 - head/sys/geom X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 07:55:25 -0000 Author: mav Date: Tue Mar 26 07:55:24 2013 New Revision: 248722 URL: http://svnweb.freebsd.org/changeset/base/248722 Log: geom_slice.c and its consumers like GEOM_LABEL are not touching the data unless hotspots are used. Pass G_PF_ACCEPT_UNMAPPED flag through except such rare cases (obsolete GEOM_SUNLABEL and GEOM_BSD). Modified: head/sys/geom/geom_slice.c Modified: head/sys/geom/geom_slice.c ============================================================================== --- head/sys/geom/geom_slice.c Tue Mar 26 05:58:49 2013 (r248721) +++ head/sys/geom/geom_slice.c Tue Mar 26 07:55:24 2013 (r248722) @@ -396,6 +396,8 @@ g_slice_config(struct g_geom *gp, u_int pp->stripeoffset = pp2->stripeoffset + offset; if (pp->stripesize > 0) pp->stripeoffset %= pp->stripesize; + if (gsp->nhotspot == 0) + pp->flags |= pp2->flags & G_PF_ACCEPT_UNMAPPED; if (0 && bootverbose) printf("GEOM: Configure %s, start %jd length %jd end %jd\n", pp->name, (intmax_t)offset, (intmax_t)length, @@ -428,11 +430,17 @@ g_slice_conf_hot(struct g_geom *gp, u_in { struct g_slicer *gsp; struct g_slice_hot *gsl, *gsl2; + struct g_provider *pp; g_trace(G_T_TOPOLOGY, "g_slice_conf_hot(%s, idx: %d, off: %jd, len: %jd)", gp->name, idx, (intmax_t)offset, (intmax_t)length); g_topology_assert(); gsp = gp->softc; + /* Deny unmapped I/O if hotspots are used. */ + if (gsp->nhotspot == 0) { + LIST_FOREACH(pp, &gp->provider, provider) + pp->flags &= ~G_PF_ACCEPT_UNMAPPED; + } gsl = gsp->hotspot; if(idx >= gsp->nhotspot) { gsl2 = g_malloc((idx + 1) * sizeof *gsl2, M_WAITOK | M_ZERO); From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 14:05:38 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id B58D2AA9; Tue, 26 Mar 2013 14:05:38 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A7546EF3; Tue, 26 Mar 2013 14:05:38 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QE5c1W079309; Tue, 26 Mar 2013 14:05:38 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QE5c8M079307; Tue, 26 Mar 2013 14:05:38 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201303261405.r2QE5c8M079307@svn.freebsd.org> From: Gleb Smirnoff Date: Tue, 26 Mar 2013 14:05:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248724 - head/sys/netgraph/netflow X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 14:05:38 -0000 Author: glebius Date: Tue Mar 26 14:05:37 2013 New Revision: 248724 URL: http://svnweb.freebsd.org/changeset/base/248724 Log: Cleanup: wrap long lines, cleanup comments, etc. Modified: head/sys/netgraph/netflow/netflow.c head/sys/netgraph/netflow/ng_netflow.c Modified: head/sys/netgraph/netflow/netflow.c ============================================================================== --- head/sys/netgraph/netflow/netflow.c Tue Mar 26 10:08:54 2013 (r248723) +++ head/sys/netgraph/netflow/netflow.c Tue Mar 26 14:05:37 2013 (r248724) @@ -91,19 +91,19 @@ static const char rcs_id[] = */ #define SMALL(fle) (fle->f.packets <= 4) - -MALLOC_DECLARE(M_NETFLOW_HASH); MALLOC_DEFINE(M_NETFLOW_HASH, "netflow_hash", "NetFlow hash"); static int export_add(item_p, struct flow_entry *); static int export_send(priv_p, fib_export_p, item_p, int); -static int hash_insert(priv_p, struct flow_hash_entry *, struct flow_rec *, int, uint8_t, uint8_t); +static int hash_insert(priv_p, struct flow_hash_entry *, struct flow_rec *, + int, uint8_t, uint8_t); #ifdef INET6 -static int hash6_insert(priv_p, struct flow_hash_entry *, struct flow6_rec *, int, uint8_t, uint8_t); +static int hash6_insert(priv_p, struct flow_hash_entry *, struct flow6_rec *, + int, uint8_t, uint8_t); #endif -static __inline void expire_flow(priv_p, fib_export_p, struct flow_entry *, int); +static void expire_flow(priv_p, fib_export_p, struct flow_entry *, int); /* * Generate hash for a given flow record. @@ -115,9 +115,10 @@ static __inline void expire_flow(priv_p, * all globally unique (it's not fully true, there is FC00::/7 for example, * but chances of address overlap are MUCH smaller) */ -static __inline uint32_t +static inline uint32_t ip_hash(struct flow_rec *r) { + switch (r->r_ip_p) { case IPPROTO_TCP: case IPPROTO_UDP: @@ -130,9 +131,10 @@ ip_hash(struct flow_rec *r) #ifdef INET6 /* Generate hash for a given flow6 record. Use lower 4 octets from v6 addresses */ -static __inline uint32_t +static inline uint32_t ip6_hash(struct flow6_rec *r) { + switch (r->r_ip_p) { case IPPROTO_TCP: case IPPROTO_UDP: @@ -224,7 +226,6 @@ get_export_dgram(priv_p priv, fib_export dgram->header.count = 0; dgram->header.version = htons(NETFLOW_V5); dgram->header.pad = 0; - } return (item); @@ -236,6 +237,7 @@ get_export_dgram(priv_p priv, fib_export static void return_export_dgram(priv_p priv, fib_export_p fe, item_p item, int flags) { + /* * It may happen on SMP, that some thread has already * put its item there, in this case we bail out and @@ -255,7 +257,7 @@ return_export_dgram(priv_p priv, fib_exp * The flow is over. Call export_add() and free it. If datagram is * full, then call export_send(). */ -static __inline void +static void expire_flow(priv_p priv, fib_export_p fe, struct flow_entry *fle, int flags) { struct netflow_export_item exp; @@ -267,7 +269,7 @@ expire_flow(priv_p priv, fib_export_p fe atomic_add_32(&priv->info.nfinfo_export_failed, 1); if (priv->export9 != NULL) atomic_add_32(&priv->info.nfinfo_export9_failed, 1); - /* fle definitely contains IPv4 flow */ + /* fle definitely contains IPv4 flow. */ uma_zfree_arg(priv->zone, fle, priv); return; } @@ -289,14 +291,16 @@ expire_flow(priv_p priv, fib_export_p fe uma_zfree_arg(priv->zone6, fle, priv); #endif else - panic("ng_netflow: Unknown IP proto: %d", version); + panic("ng_netflow: Unknown IP proto: %d", + version); return; } if (export9_add(exp.item9, exp.item9_opt, fle) > 0) export9_send(priv, fe, exp.item9, exp.item9_opt, flags); else - return_export9_dgram(priv, fe, exp.item9, exp.item9_opt, NG_QUEUE); + return_export9_dgram(priv, fe, exp.item9, + exp.item9_opt, NG_QUEUE); } if (version == IPVERSION) @@ -311,6 +315,7 @@ expire_flow(priv_p priv, fib_export_p fe void ng_netflow_copyinfo(priv_p priv, struct ng_netflow_info *i) { + /* XXX: atomic */ memcpy((void *)i, (void *)&priv->info, sizeof(priv->info)); } @@ -345,7 +350,6 @@ hash_insert(priv_p priv, struct flow_has * Now fle is totally ours. It is detached from all lists, * we can safely edit it. */ - fle->f.version = IPVERSION; bcopy(r, &fle->f.r, sizeof(struct flow_rec)); fle->f.bytes = plen; @@ -373,8 +377,8 @@ hash_insert(priv_p priv, struct flow_has ((struct sockaddr_in *)(rt->rt_gateway))->sin_addr; if (rt_mask(rt)) - fle->f.dst_mask = bitcount32(((struct sockaddr_in *) - rt_mask(rt))->sin_addr.s_addr); + fle->f.dst_mask = + bitcount32(((struct sockaddr_in *)rt_mask(rt))->sin_addr.s_addr); else if (rt->rt_flags & RTF_HOST) /* Give up. We can't determine mask :( */ fle->f.dst_mask = 32; @@ -392,8 +396,8 @@ hash_insert(priv_p priv, struct flow_has rt = rtalloc1_fib((struct sockaddr *)&sin, 0, 0, r->fib); if (rt != NULL) { if (rt_mask(rt)) - fle->f.src_mask = bitcount32(((struct sockaddr_in *) - rt_mask(rt))->sin_addr.s_addr); + fle->f.src_mask = + bitcount32(((struct sockaddr_in *)rt_mask(rt))->sin_addr.s_addr); else if (rt->rt_flags & RTF_HOST) /* Give up. We can't determine mask :( */ fle->f.src_mask = 32; @@ -449,8 +453,7 @@ hash6_insert(priv_p priv, struct flow_ha * First we do route table lookup on destination address. So we can * fill in out_ifx, dst_mask, nexthop, and dst_as in future releases. */ - if ((flags & NG_NETFLOW_CONF_NODSTLOOKUP) == 0) - { + if ((flags & NG_NETFLOW_CONF_NODSTLOOKUP) == 0) { bzero(&rin6, sizeof(struct route_in6)); dst = (struct sockaddr_in6 *)&rin6.ro_dst; dst->sin6_len = sizeof(struct sockaddr_in6); @@ -477,8 +480,7 @@ hash6_insert(priv_p priv, struct flow_ha } } - if ((flags & NG_NETFLOW_CONF_NODSTLOOKUP) == 0) - { + if ((flags & NG_NETFLOW_CONF_NODSTLOOKUP) == 0) { /* Do route lookup on source address, to fill in src_mask. */ bzero(&rin6, sizeof(struct route_in6)); src = (struct sockaddr_in6 *)&rin6.ro_dst; @@ -522,12 +524,14 @@ ng_netflow_cache_init(priv_p priv) int i; /* Initialize cache UMA zone. */ - priv->zone = uma_zcreate("NetFlow IPv4 cache", sizeof(struct flow_entry), - uma_ctor_flow, uma_dtor_flow, NULL, NULL, UMA_ALIGN_CACHE, 0); + priv->zone = uma_zcreate("NetFlow IPv4 cache", + sizeof(struct flow_entry), uma_ctor_flow, uma_dtor_flow, NULL, + NULL, UMA_ALIGN_CACHE, 0); uma_zone_set_max(priv->zone, CACHESIZE); #ifdef INET6 - priv->zone6 = uma_zcreate("NetFlow IPv6 cache", sizeof(struct flow6_entry), - uma_ctor_flow6, uma_dtor_flow6, NULL, NULL, UMA_ALIGN_CACHE, 0); + priv->zone6 = uma_zcreate("NetFlow IPv6 cache", + sizeof(struct flow6_entry), uma_ctor_flow6, uma_dtor_flow6, NULL, + NULL, UMA_ALIGN_CACHE, 0); uma_zone_set_max(priv->zone6, CACHESIZE); #endif @@ -568,7 +572,8 @@ ng_netflow_fib_init(priv_p priv, int fib if (fe != NULL) return (0); - if ((fe = malloc(sizeof(struct fib_export), M_NETGRAPH, M_NOWAIT | M_ZERO)) == NULL) + if ((fe = malloc(sizeof(struct fib_export), M_NETGRAPH, + M_NOWAIT | M_ZERO)) == NULL) return (1); mtx_init(&fe->export_mtx, "export dgram lock", NULL, MTX_DEF); @@ -576,15 +581,18 @@ ng_netflow_fib_init(priv_p priv, int fib fe->fib = fib; fe->domain_id = fib; - if (atomic_cmpset_ptr((volatile uintptr_t *)&priv->fib_data[fib], (uintptr_t)NULL, (uintptr_t)fe) == 0) { + if (atomic_cmpset_ptr((volatile uintptr_t *)&priv->fib_data[fib], + (uintptr_t)NULL, (uintptr_t)fe) == 0) { /* FIB already set up by other ISR */ - CTR3(KTR_NET, "ng_netflow(): fib init: %d setup %p but got %p", fib, fe, priv_to_fib(priv, fib)); + CTR3(KTR_NET, "ng_netflow(): fib init: %d setup %p but got %p", + fib, fe, priv_to_fib(priv, fib)); mtx_destroy(&fe->export_mtx); mtx_destroy(&fe->export9_mtx); free(fe, M_NETGRAPH); } else { /* Increase counter for statistics */ - CTR3(KTR_NET, "ng_netflow(): fib %d setup to %p (%p)", fib, fe, priv_to_fib(priv, fib)); + CTR3(KTR_NET, "ng_netflow(): fib %d setup to %p (%p)", + fib, fe, priv_to_fib(priv, fib)); atomic_fetchadd_32(&priv->info.nfinfo_alloc_fibs, 1); } @@ -650,7 +658,8 @@ ng_netflow_cache_flush(priv_p priv) export_send(priv, fe, fe->exp.item, NG_QUEUE); if (fe->exp.item9 != NULL) - export9_send(priv, fe, fe->exp.item9, fe->exp.item9_opt, NG_QUEUE); + export9_send(priv, fe, fe->exp.item9, + fe->exp.item9_opt, NG_QUEUE); mtx_destroy(&fe->export_mtx); mtx_destroy(&fe->export9_mtx); @@ -662,26 +671,24 @@ ng_netflow_cache_flush(priv_p priv) /* Insert packet from into flow cache. */ int -ng_netflow_flow_add(priv_p priv, fib_export_p fe, struct ip *ip, caddr_t upper_ptr, uint8_t upper_proto, - uint8_t flags, unsigned int src_if_index) +ng_netflow_flow_add(priv_p priv, fib_export_p fe, struct ip *ip, + caddr_t upper_ptr, uint8_t upper_proto, uint8_t flags, + unsigned int src_if_index) { - register struct flow_entry *fle, *fle1; + struct flow_entry *fle, *fle1; struct flow_hash_entry *hsh; struct flow_rec r; int hlen, plen; int error = 0; - uint8_t tcp_flags = 0; uint16_t eproto; + uint8_t tcp_flags = 0; - /* Try to fill flow_rec r */ bzero(&r, sizeof(r)); - /* check version */ + if (ip->ip_v != IPVERSION) return (EINVAL); - /* verify min header length */ hlen = ip->ip_hl << 2; - if (hlen < sizeof(struct ip)) return (EINVAL); @@ -693,7 +700,6 @@ ng_netflow_flow_add(priv_p priv, fib_exp r.r_dst = ip->ip_dst; r.fib = fe->fib; - /* save packet length */ plen = ntohs(ip->ip_len); r.r_ip_p = ip->ip_p; @@ -713,16 +719,16 @@ ng_netflow_flow_add(priv_p priv, fib_exp if ((ip->ip_off & htons(IP_OFFMASK)) == 0) switch(r.r_ip_p) { case IPPROTO_TCP: - { - register struct tcphdr *tcp; + { + struct tcphdr *tcp; tcp = (struct tcphdr *)((caddr_t )ip + hlen); r.r_sport = tcp->th_sport; r.r_dport = tcp->th_dport; tcp_flags = tcp->th_flags; break; - } - case IPPROTO_UDP: + } + case IPPROTO_UDP: r.r_ports = *(uint32_t *)((caddr_t )ip + hlen); break; } @@ -747,7 +753,8 @@ ng_netflow_flow_add(priv_p priv, fib_exp break; if ((INACTIVE(fle) && SMALL(fle)) || AGED(fle)) { TAILQ_REMOVE(&hsh->head, fle, fle_hash); - expire_flow(priv, priv_to_fib(priv, fle->f.r.fib), fle, NG_QUEUE); + expire_flow(priv, priv_to_fib(priv, fle->f.r.fib), + fle, NG_QUEUE); atomic_add_32(&priv->info.nfinfo_act_exp, 1); } } @@ -768,7 +775,8 @@ ng_netflow_flow_add(priv_p priv, fib_exp if (tcp_flags & TH_FIN || tcp_flags & TH_RST || AGED(fle) || (fle->f.bytes >= (CNTR_MAX - IF_MAXMTU)) ) { TAILQ_REMOVE(&hsh->head, fle, fle_hash); - expire_flow(priv, priv_to_fib(priv, fle->f.r.fib), fle, NG_QUEUE); + expire_flow(priv, priv_to_fib(priv, fle->f.r.fib), + fle, NG_QUEUE); atomic_add_32(&priv->info.nfinfo_act_exp, 1); } else { /* @@ -792,13 +800,14 @@ ng_netflow_flow_add(priv_p priv, fib_exp #ifdef INET6 /* Insert IPv6 packet from into flow cache. */ int -ng_netflow_flow6_add(priv_p priv, fib_export_p fe, struct ip6_hdr *ip6, caddr_t upper_ptr, uint8_t upper_proto, - uint8_t flags, unsigned int src_if_index) +ng_netflow_flow6_add(priv_p priv, fib_export_p fe, struct ip6_hdr *ip6, + caddr_t upper_ptr, uint8_t upper_proto, uint8_t flags, + unsigned int src_if_index) { - register struct flow_entry *fle = NULL, *fle1; - register struct flow6_entry *fle6; - struct flow_hash_entry *hsh; - struct flow6_rec r; + struct flow_entry *fle = NULL, *fle1; + struct flow6_entry *fle6; + struct flow_hash_entry *hsh; + struct flow6_rec r; int plen; int error = 0; uint8_t tcp_flags = 0; @@ -816,32 +825,28 @@ ng_netflow_flow6_add(priv_p priv, fib_ex /* Assume L4 template by default */ r.flow_type = NETFLOW_V9_FLOW_V6_L4; - /* save packet length */ plen = ntohs(ip6->ip6_plen) + sizeof(struct ip6_hdr); - /* XXX: set DSCP/CoS value */ #if 0 + /* XXX: set DSCP/CoS value */ r.r_tos = ip->ip_tos; #endif if ((flags & NG_NETFLOW_IS_FRAG) == 0) { switch(upper_proto) { case IPPROTO_TCP: - { - register struct tcphdr *tcp; + { + struct tcphdr *tcp; tcp = (struct tcphdr *)upper_ptr; r.r_ports = *(uint32_t *)upper_ptr; tcp_flags = tcp->th_flags; break; - } + } case IPPROTO_UDP: case IPPROTO_SCTP: - { r.r_ports = *(uint32_t *)upper_ptr; break; } - - } } r.r_ip_p = upper_proto; @@ -1145,7 +1150,8 @@ ng_netflow_expire(void *arg) if ((INACTIVE(fle) && (SMALL(fle) || (used > (NBUCKETS*2)))) || AGED(fle)) { TAILQ_REMOVE(&hsh->head, fle, fle_hash); - expire_flow(priv, priv_to_fib(priv, fle->f.r.fib), fle, NG_NOFLAGS); + expire_flow(priv, priv_to_fib(priv, + fle->f.r.fib), fle, NG_NOFLAGS); used--; atomic_add_32(&priv->info.nfinfo_inact_exp, 1); } Modified: head/sys/netgraph/netflow/ng_netflow.c ============================================================================== --- head/sys/netgraph/netflow/ng_netflow.c Tue Mar 26 10:08:54 2013 (r248723) +++ head/sys/netgraph/netflow/ng_netflow.c Tue Mar 26 14:05:37 2013 (r248724) @@ -379,7 +379,7 @@ ng_netflow_rcvmsg (node_p node, item_p i case NGM_NETFLOW_COOKIE: switch (msg->header.cmd) { case NGM_NETFLOW_INFO: - { + { struct ng_netflow_info *i; NG_MKRESPONSE(resp, msg, sizeof(struct ng_netflow_info), @@ -388,9 +388,9 @@ ng_netflow_rcvmsg (node_p node, item_p i ng_netflow_copyinfo(priv, i); break; - } + } case NGM_NETFLOW_IFINFO: - { + { struct ng_netflow_ifinfo *i; const uint16_t *index; @@ -412,13 +412,14 @@ ng_netflow_rcvmsg (node_p node, item_p i sizeof(priv->ifaces[*index].info)); break; - } + } case NGM_NETFLOW_SETDLT: - { + { struct ng_netflow_setdlt *set; struct ng_netflow_iface *iface; - if (msg->header.arglen != sizeof(struct ng_netflow_setdlt)) + if (msg->header.arglen != + sizeof(struct ng_netflow_setdlt)) ERROUT(EINVAL); set = (struct ng_netflow_setdlt *)msg->data; @@ -441,13 +442,14 @@ ng_netflow_rcvmsg (node_p node, item_p i ERROUT(EINVAL); } break; - } + } case NGM_NETFLOW_SETIFINDEX: - { + { struct ng_netflow_setifindex *set; struct ng_netflow_iface *iface; - if (msg->header.arglen != sizeof(struct ng_netflow_setifindex)) + if (msg->header.arglen != + sizeof(struct ng_netflow_setifindex)) ERROUT(EINVAL); set = (struct ng_netflow_setifindex *)msg->data; @@ -462,12 +464,13 @@ ng_netflow_rcvmsg (node_p node, item_p i iface->info.ifinfo_index = set->index; break; - } + } case NGM_NETFLOW_SETTIMEOUTS: - { + { struct ng_netflow_settimeouts *set; - if (msg->header.arglen != sizeof(struct ng_netflow_settimeouts)) + if (msg->header.arglen != + sizeof(struct ng_netflow_settimeouts)) ERROUT(EINVAL); set = (struct ng_netflow_settimeouts *)msg->data; @@ -476,12 +479,13 @@ ng_netflow_rcvmsg (node_p node, item_p i priv->info.nfinfo_act_t = set->active_timeout; break; - } + } case NGM_NETFLOW_SETCONFIG: - { + { struct ng_netflow_setconfig *set; - if (msg->header.arglen != sizeof(struct ng_netflow_setconfig)) + if (msg->header.arglen != + sizeof(struct ng_netflow_setconfig)) ERROUT(EINVAL); set = (struct ng_netflow_setconfig *)msg->data; @@ -492,12 +496,13 @@ ng_netflow_rcvmsg (node_p node, item_p i priv->ifaces[set->iface].info.conf = set->conf; break; - } + } case NGM_NETFLOW_SETTEMPLATE: - { + { struct ng_netflow_settemplate *set; - if (msg->header.arglen != sizeof(struct ng_netflow_settemplate)) + if (msg->header.arglen != + sizeof(struct ng_netflow_settemplate)) ERROUT(EINVAL); set = (struct ng_netflow_settemplate *)msg->data; @@ -506,12 +511,13 @@ ng_netflow_rcvmsg (node_p node, item_p i priv->templ_time = set->time; break; - } + } case NGM_NETFLOW_SETMTU: - { + { struct ng_netflow_setmtu *set; - if (msg->header.arglen != sizeof(struct ng_netflow_setmtu)) + if (msg->header.arglen != + sizeof(struct ng_netflow_setmtu)) ERROUT(EINVAL); set = (struct ng_netflow_setmtu *)msg->data; @@ -521,10 +527,10 @@ ng_netflow_rcvmsg (node_p node, item_p i priv->mtu = set->mtu; break; - } + } case NGM_NETFLOW_SHOW: - { - if (msg->header.arglen != sizeof(struct ngnf_show_header)) + if (msg->header.arglen != + sizeof(struct ngnf_show_header)) ERROUT(EINVAL); NG_MKRESPONSE(resp, msg, NGRESP_SIZE, M_NOWAIT); @@ -540,18 +546,17 @@ ng_netflow_rcvmsg (node_p node, item_p i NG_FREE_MSG(resp); break; - } case NGM_NETFLOW_V9INFO: - { + { struct ng_netflow_v9info *i; - NG_MKRESPONSE(resp, msg, sizeof(struct ng_netflow_v9info), - M_NOWAIT); + NG_MKRESPONSE(resp, msg, + sizeof(struct ng_netflow_v9info), M_NOWAIT); i = (struct ng_netflow_v9info *)resp->data; ng_netflow_copyv9info(priv, i); break; - } + } default: ERROUT(EINVAL); /* unknown command */ break; @@ -613,8 +618,8 @@ ng_netflow_rcvdata (hook_p hook, item_p } else ERROUT(EINVAL); - if ((!bypass) && - (iface->info.conf & (NG_NETFLOW_CONF_ONCE | NG_NETFLOW_CONF_THISONCE))) { + if ((!bypass) && (iface->info.conf & + (NG_NETFLOW_CONF_ONCE | NG_NETFLOW_CONF_THISONCE))) { mtag = m_tag_locate(NGI_M(item), MTAG_NETFLOW, MTAG_NETFLOW_CALLED, NULL); while (mtag != NULL) { @@ -636,7 +641,8 @@ ng_netflow_rcvdata (hook_p hook, item_p return (error); } - if (iface->info.conf & (NG_NETFLOW_CONF_ONCE | NG_NETFLOW_CONF_THISONCE)) { + if (iface->info.conf & + (NG_NETFLOW_CONF_ONCE | NG_NETFLOW_CONF_THISONCE)) { mtag = m_tag_alloc(MTAG_NETFLOW, MTAG_NETFLOW_CALLED, sizeof(ng_ID_t), M_NOWAIT); if (mtag) { @@ -701,7 +707,8 @@ ng_netflow_rcvdata (hook_p hook, item_p case ETHERTYPE_IPV6: /* * m_pullup() called by M_CHECK() pullups - * kern.ipc.max_protohdr (default 60 bytes) which is enough + * kern.ipc.max_protohdr (default 60 bytes) + * which is enough. */ M_CHECK(sizeof(struct ip6_hdr)); eh = mtod(m, struct ether_header *); @@ -741,9 +748,11 @@ ng_netflow_rcvdata (hook_p hook, item_p ip = mtod(m, struct ip *); /* l3_off is already zero */ #ifdef INET6 - /* If INET6 is not defined IPv6 packets will be discarded in ng_netflow_flow_add() */ + /* + * If INET6 is not defined IPv6 packets + * will be discarded in ng_netflow_flow_add(). + */ if (ip->ip_v == IP6VERSION) { - /* IPv6 packet */ ip = NULL; M_CHECK(sizeof(struct ip6_hdr) - sizeof(struct ip)); ip6 = mtod(m, struct ip6_hdr *); @@ -772,8 +781,8 @@ ng_netflow_rcvdata (hook_p hook, item_p upper_proto = ip->ip_p; /* - * XXX: in case of wrong upper layer header we will forward this packet - * but skip this record in netflow + * XXX: in case of wrong upper layer header we will + * forward this packet but skip this record in netflow. */ switch (ip->ip_p) { case IPPROTO_TCP: @@ -787,7 +796,10 @@ ng_netflow_rcvdata (hook_p hook, item_p break; } } else if (ip != NULL) { - /* Nothing to save except upper layer proto, since this is packet fragment */ + /* + * Nothing to save except upper layer proto, + * since this is a packet fragment. + */ flags |= NG_NETFLOW_IS_FRAG; upper_proto = ip->ip_p; if ((ip->ip_v != IPVERSION) || @@ -795,26 +807,29 @@ ng_netflow_rcvdata (hook_p hook, item_p goto bypass; #ifdef INET6 } else if (ip6 != NULL) { - /* Check if we can export */ - if (priv->export9 == NULL) - goto bypass; - - /* Loop thru IPv6 extended headers to get upper layer header / frag */ int cur = ip6->ip6_nxt, hdr_off = 0; struct ip6_ext *ip6e; struct ip6_frag *ip6f; - /* Save upper layer info */ + if (priv->export9 == NULL) + goto bypass; + + /* Save upper layer info. */ off = pullup_len; upper_proto = cur; if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) goto bypass; - while (42) { + /* + * Loop thru IPv6 extended headers to get upper + * layer header / frag. + */ + for (;;) { switch (cur) { /* - * Same as in IPv4, we can forward 'bad' packet without accounting + * Same as in IPv4, we can forward a 'bad' + * packet without accounting. */ case IPPROTO_TCP: M_CHECK(sizeof(struct tcphdr)); @@ -831,7 +846,8 @@ ng_netflow_rcvdata (hook_p hook, item_p case IPPROTO_ROUTING: case IPPROTO_DSTOPTS: M_CHECK(sizeof(struct ip6_ext)); - ip6e = (struct ip6_ext *)(mtod(m, caddr_t) + off); + ip6e = (struct ip6_ext *)(mtod(m, caddr_t) + + off); upper_proto = ip6e->ip6e_nxt; hdr_off = (ip6e->ip6e_len + 1) << 3; break; @@ -839,14 +855,16 @@ ng_netflow_rcvdata (hook_p hook, item_p /* RFC4302, can be before DSTOPTS */ case IPPROTO_AH: M_CHECK(sizeof(struct ip6_ext)); - ip6e = (struct ip6_ext *)(mtod(m, caddr_t) + off); + ip6e = (struct ip6_ext *)(mtod(m, caddr_t) + + off); upper_proto = ip6e->ip6e_nxt; hdr_off = (ip6e->ip6e_len + 2) << 2; break; case IPPROTO_FRAGMENT: M_CHECK(sizeof(struct ip6_frag)); - ip6f = (struct ip6_frag *)(mtod(m, caddr_t) + off); + ip6f = (struct ip6_frag *)(mtod(m, caddr_t) + + off); upper_proto = ip6f->ip6f_nxt; hdr_off = sizeof(struct ip6_frag); off += hdr_off; @@ -915,10 +933,12 @@ loopend: } if (ip != NULL) - error = ng_netflow_flow_add(priv, fe, ip, upper_ptr, upper_proto, flags, src_if_index); + error = ng_netflow_flow_add(priv, fe, ip, upper_ptr, + upper_proto, flags, src_if_index); #ifdef INET6 else if (ip6 != NULL) - error = ng_netflow_flow6_add(priv, fe, ip6, upper_ptr, upper_proto, flags, src_if_index); + error = ng_netflow_flow6_add(priv, fe, ip6, upper_ptr, + upper_proto, flags, src_if_index); #endif else goto bypass; @@ -929,10 +949,12 @@ bypass: if (acct == 0) { /* Accounting failure */ if (ip != NULL) { - atomic_fetchadd_32(&priv->info.nfinfo_spackets, 1); + atomic_fetchadd_32(&priv->info.nfinfo_spackets, + 1); priv->info.nfinfo_sbytes += m_length(m, NULL); } else if (ip6 != NULL) { - atomic_fetchadd_32(&priv->info.nfinfo_spackets6, 1); + atomic_fetchadd_32(&priv->info.nfinfo_spackets6, + 1); priv->info.nfinfo_sbytes6 += m_length(m, NULL); } } From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 14:08:15 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id F3831D2B; Tue, 26 Mar 2013 14:08:14 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E5C35F16; Tue, 26 Mar 2013 14:08:14 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QE8ESg079865; Tue, 26 Mar 2013 14:08:14 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QE8EFC079864; Tue, 26 Mar 2013 14:08:14 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201303261408.r2QE8EFC079864@svn.freebsd.org> From: Gleb Smirnoff Date: Tue, 26 Mar 2013 14:08:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248725 - head/sys/netgraph/netflow X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 14:08:15 -0000 Author: glebius Date: Tue Mar 26 14:08:14 2013 New Revision: 248725 URL: http://svnweb.freebsd.org/changeset/base/248725 Log: Return ENOMEM if malloc() fails. Modified: head/sys/netgraph/netflow/netflow.c Modified: head/sys/netgraph/netflow/netflow.c ============================================================================== --- head/sys/netgraph/netflow/netflow.c Tue Mar 26 14:05:37 2013 (r248724) +++ head/sys/netgraph/netflow/netflow.c Tue Mar 26 14:08:14 2013 (r248725) @@ -574,7 +574,7 @@ ng_netflow_fib_init(priv_p priv, int fib if ((fe = malloc(sizeof(struct fib_export), M_NETGRAPH, M_NOWAIT | M_ZERO)) == NULL) - return (1); + return (ENOMEM); mtx_init(&fe->export_mtx, "export dgram lock", NULL, MTX_DEF); mtx_init(&fe->export9_mtx, "export9 dgram lock", NULL, MTX_DEF); From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 17:30:40 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E5596BA2; Tue, 26 Mar 2013 17:30:40 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id D88A6D71; Tue, 26 Mar 2013 17:30:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QHUepr044809; Tue, 26 Mar 2013 17:30:40 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QHUeTw044808; Tue, 26 Mar 2013 17:30:40 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201303261730.r2QHUeTw044808@svn.freebsd.org> From: Alan Cox Date: Tue, 26 Mar 2013 17:30:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248728 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 17:30:41 -0000 Author: alc Date: Tue Mar 26 17:30:40 2013 New Revision: 248728 URL: http://svnweb.freebsd.org/changeset/base/248728 Log: Introduce vm_radix_isleaf() and use it in a couple places. As compared to using vm_radix_node_page() == NULL, the compiler is able to generate one less conditional branch when vm_radix_isleaf() is used. More use cases involving the inner loops of vm_radix_insert(), vm_radix_lookup{,_ge,_le}(), and vm_radix_remove() will follow. Reviewed by: attilio Sponsored by: EMC / Isilon Storage Division Modified: head/sys/vm/vm_radix.c Modified: head/sys/vm/vm_radix.c ============================================================================== --- head/sys/vm/vm_radix.c Tue Mar 26 16:38:03 2013 (r248727) +++ head/sys/vm/vm_radix.c Tue Mar 26 17:30:40 2013 (r248728) @@ -189,6 +189,16 @@ vm_radix_setroot(struct vm_radix *rtree, } /* + * Returns TRUE if the specified radix node is a leaf and FALSE otherwise. + */ +static __inline boolean_t +vm_radix_isleaf(struct vm_radix_node *rnode) +{ + + return (((uintptr_t)rnode & VM_RADIX_ISLEAF) != 0); +} + +/* * Returns the associated page extracted from rnode if available, * and NULL otherwise. */ @@ -315,7 +325,7 @@ vm_radix_reclaim_allnodes_int(struct vm_ for (slot = 0; rnode->rn_count != 0; slot++) { if (rnode->rn_child[slot] == NULL) continue; - if (vm_radix_node_page(rnode->rn_child[slot]) == NULL) + if (!vm_radix_isleaf(rnode->rn_child[slot])) vm_radix_reclaim_allnodes_int(rnode->rn_child[slot]); rnode->rn_child[slot] = NULL; rnode->rn_count--; @@ -454,7 +464,7 @@ vm_radix_insert(struct vm_radix *rtree, __func__, clev, rnode->rn_clev)); slot = vm_radix_slot(index, rnode->rn_clev); tmp = rnode->rn_child[slot]; - KASSERT(tmp != NULL && vm_radix_node_page(tmp) == NULL, + KASSERT(tmp != NULL && !vm_radix_isleaf(tmp), ("%s: unexpected lookup interruption", __func__)); if (tmp->rn_clev > clev) break; From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 18:01:25 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 03A2D521; Tue, 26 Mar 2013 18:01:25 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id EA8E8113; Tue, 26 Mar 2013 18:01:24 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QI1OO9053843; Tue, 26 Mar 2013 18:01:24 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QI1O7m053842; Tue, 26 Mar 2013 18:01:24 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303261801.r2QI1O7m053842@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 18:01:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248729 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 18:01:25 -0000 Author: jimharris Date: Tue Mar 26 18:01:24 2013 New Revision: 248729 URL: http://svnweb.freebsd.org/changeset/base/248729 Log: Do not look at the namespace's thin provisioning field to determine if DSM command is supported. The two are not related. Sponsored by: Intel Modified: head/sys/dev/nvme/nvme_ns.c Modified: head/sys/dev/nvme/nvme_ns.c ============================================================================== --- head/sys/dev/nvme/nvme_ns.c Tue Mar 26 17:30:40 2013 (r248728) +++ head/sys/dev/nvme/nvme_ns.c Tue Mar 26 18:01:24 2013 (r248729) @@ -339,7 +339,7 @@ nvme_ns_construct(struct nvme_namespace } #endif - if (ctrlr->cdata.oncs.dsm && ns->data.nsfeat.thin_prov) + if (ctrlr->cdata.oncs.dsm) ns->flags |= NVME_NS_DEALLOCATE_SUPPORTED; if (ctrlr->cdata.vwc.present) From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 18:16:31 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 340CBB4E; Tue, 26 Mar 2013 18:16:31 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 26D572C1; Tue, 26 Mar 2013 18:16:31 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QIGVKZ058037; Tue, 26 Mar 2013 18:16:31 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QIGV68058036; Tue, 26 Mar 2013 18:16:31 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303261816.r2QIGV68058036@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 18:16:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248730 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 18:16:31 -0000 Author: jimharris Date: Tue Mar 26 18:16:30 2013 New Revision: 248730 URL: http://svnweb.freebsd.org/changeset/base/248730 Log: Make the DSM range count 0-based. Previously we were deallocating one more LBA than we should have been. Sponsored by: Intel Modified: head/sys/dev/nvme/nvme_ns_cmd.c Modified: head/sys/dev/nvme/nvme_ns_cmd.c ============================================================================== --- head/sys/dev/nvme/nvme_ns_cmd.c Tue Mar 26 18:01:24 2013 (r248729) +++ head/sys/dev/nvme/nvme_ns_cmd.c Tue Mar 26 18:16:30 2013 (r248730) @@ -96,7 +96,7 @@ nvme_ns_cmd_deallocate(struct nvme_names cmd->nsid = ns->id; /* TODO: create a delete command data structure */ - cmd->cdw10 = num_ranges; + cmd->cdw10 = num_ranges - 1; cmd->cdw11 = NVME_DSM_ATTR_DEALLOCATE; nvme_ctrlr_submit_io_request(ns->ctrlr, req); From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 18:20:11 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C8C6EED8; Tue, 26 Mar 2013 18:20:11 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A35D32FF; Tue, 26 Mar 2013 18:20:11 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QIKB3T058785; Tue, 26 Mar 2013 18:20:11 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QIKBvx058784; Tue, 26 Mar 2013 18:20:11 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303261820.r2QIKBvx058784@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 18:20:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248731 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 18:20:11 -0000 Author: jimharris Date: Tue Mar 26 18:20:11 2013 New Revision: 248731 URL: http://svnweb.freebsd.org/changeset/base/248731 Log: Add an internal _nvme_qpair_submit_request function, which performs the submit action assuming the qpair lock has already been acquired. Also change nvme_qpair_submit_request to just lock/unlock the mutex around a call to this new function. This fixes a recursive mutex acquisition in the retry path. Sponsored by: Intel Modified: head/sys/dev/nvme/nvme_qpair.c Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 18:16:30 2013 (r248730) +++ head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 18:20:11 2013 (r248731) @@ -34,6 +34,9 @@ __FBSDID("$FreeBSD$"); #include "nvme_private.h" +static void _nvme_qpair_submit_request(struct nvme_qpair *qpair, + struct nvme_request *req); + static boolean_t nvme_completion_check_retry(const struct nvme_completion *cpl) { @@ -149,7 +152,7 @@ nvme_qpair_process_completions(struct nv if (!STAILQ_EMPTY(&qpair->queued_req)) { req = STAILQ_FIRST(&qpair->queued_req); STAILQ_REMOVE_HEAD(&qpair->queued_req, stailq); - nvme_qpair_submit_request(qpair, req); + _nvme_qpair_submit_request(qpair, req); } } @@ -410,13 +413,13 @@ nvme_qpair_submit_cmd(struct nvme_qpair qpair->num_cmds++; } -void -nvme_qpair_submit_request(struct nvme_qpair *qpair, struct nvme_request *req) +static void +_nvme_qpair_submit_request(struct nvme_qpair *qpair, struct nvme_request *req) { struct nvme_tracker *tr; int err; - mtx_lock(&qpair->lock); + mtx_assert(&qpair->lock, MA_OWNED); tr = SLIST_FIRST(&qpair->free_tr); @@ -427,7 +430,7 @@ nvme_qpair_submit_request(struct nvme_qp * via a command completion. */ STAILQ_INSERT_TAIL(&qpair->queued_req, req, stailq); - goto ret; + return; } SLIST_REMOVE_HEAD(&qpair->free_tr, slist); @@ -450,7 +453,13 @@ nvme_qpair_submit_request(struct nvme_qp if (err != 0) panic("bus_dmamap_load returned non-zero!\n"); } +} -ret: +void +nvme_qpair_submit_request(struct nvme_qpair *qpair, struct nvme_request *req) +{ + + mtx_lock(&qpair->lock); + _nvme_qpair_submit_request(qpair, req); mtx_unlock(&qpair->lock); } From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 18:23:36 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 61F071E5; Tue, 26 Mar 2013 18:23:36 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 4545533D; Tue, 26 Mar 2013 18:23:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QINa9Z060698; Tue, 26 Mar 2013 18:23:36 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QINZ0B060695; Tue, 26 Mar 2013 18:23:35 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303261823.r2QINZ0B060695@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 18:23:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248732 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 18:23:36 -0000 Author: jimharris Date: Tue Mar 26 18:23:35 2013 New Revision: 248732 URL: http://svnweb.freebsd.org/changeset/base/248732 Log: Add support for ABORT commands, including issuing these commands when an I/O times out. Also ensure that we retry commands that are aborted due to a timeout. Sponsored by: Intel Modified: head/sys/dev/nvme/nvme_ctrlr_cmd.c head/sys/dev/nvme/nvme_private.h head/sys/dev/nvme/nvme_qpair.c Modified: head/sys/dev/nvme/nvme_ctrlr_cmd.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr_cmd.c Tue Mar 26 18:20:11 2013 (r248731) +++ head/sys/dev/nvme/nvme_ctrlr_cmd.c Tue Mar 26 18:23:35 2013 (r248732) @@ -281,3 +281,19 @@ nvme_ctrlr_cmd_get_health_information_pa nvme_ctrlr_submit_admin_request(ctrlr, req); } + +void +nvme_ctrlr_cmd_abort(struct nvme_controller *ctrlr, uint16_t cid, + uint16_t sqid, nvme_cb_fn_t cb_fn, void *cb_arg) +{ + struct nvme_request *req; + struct nvme_command *cmd; + + req = nvme_allocate_request(NULL, 0, cb_fn, cb_arg); + + cmd = &req->cmd; + cmd->opc = NVME_OPC_ABORT; + cmd->cdw10 = (cid << 16) | sqid; + + nvme_ctrlr_submit_admin_request(ctrlr, req); +} Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 18:20:11 2013 (r248731) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 18:23:35 2013 (r248732) @@ -348,6 +348,8 @@ void nvme_ctrlr_cmd_set_asynchronous_eve void nvme_ctrlr_cmd_asynchronous_event_request(struct nvme_controller *ctrlr, nvme_cb_fn_t cb_fn, void *cb_arg); +void nvme_ctrlr_cmd_abort(struct nvme_controller *ctrlr, uint16_t cid, + uint16_t sqid, nvme_cb_fn_t cb_fn, void *cb_arg); void nvme_payload_map(void *arg, bus_dma_segment_t *seg, int nseg, int error); Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 18:20:11 2013 (r248731) +++ head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 18:23:35 2013 (r248732) @@ -49,6 +49,8 @@ nvme_completion_check_retry(const struct switch (cpl->sf_sct) { case NVME_SCT_GENERIC: switch (cpl->sf_sc) { + case NVME_SC_ABORTED_BY_REQUEST: + return (1); case NVME_SC_NAMESPACE_NOT_READY: if (cpl->sf_dnr) return (0); @@ -60,7 +62,6 @@ nvme_completion_check_retry(const struct case NVME_SC_DATA_TRANSFER_ERROR: case NVME_SC_ABORTED_POWER_LOSS: case NVME_SC_INTERNAL_DEVICE_ERROR: - case NVME_SC_ABORTED_BY_REQUEST: case NVME_SC_ABORTED_SQ_DELETION: case NVME_SC_ABORTED_FAILED_FUSED: case NVME_SC_ABORTED_MISSING_FUSED: @@ -378,10 +379,10 @@ nvme_io_qpair_destroy(struct nvme_qpair static void nvme_timeout(void *arg) { - /* - * TODO: Add explicit abort operation here, once nvme(4) supports - * abort commands. - */ + struct nvme_tracker *tr = arg; + + nvme_ctrlr_cmd_abort(tr->qpair->ctrlr, tr->cid, tr->qpair->id, + NULL, NULL); } void From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 18:27:23 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 900163F3; Tue, 26 Mar 2013 18:27:23 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 82A2636E; Tue, 26 Mar 2013 18:27:23 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QIRN3j061223; Tue, 26 Mar 2013 18:27:23 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QIRNoP061222; Tue, 26 Mar 2013 18:27:23 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303261827.r2QIRNoP061222@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 18:27:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248733 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 18:27:23 -0000 Author: jimharris Date: Tue Mar 26 18:27:22 2013 New Revision: 248733 URL: http://svnweb.freebsd.org/changeset/base/248733 Log: Break out the code for completing an nvme_tracker object into a separate function. This allows for completions outside the normal completion path, for example when an ABORT command fails due to the controller reporting the targeted command does not exist. This is mainly for protection against a faulty controller, but we need to clean up our internal request nonetheless. Sponsored by: Intel Modified: head/sys/dev/nvme/nvme_qpair.c Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 18:23:35 2013 (r248732) +++ head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 18:27:22 2013 (r248733) @@ -38,7 +38,14 @@ static void _nvme_qpair_submit_request(s struct nvme_request *req); static boolean_t -nvme_completion_check_retry(const struct nvme_completion *cpl) +nvme_completion_is_error(struct nvme_completion *cpl) +{ + + return (cpl->sf_sc != 0 || cpl->sf_sct != 0); +} + +static boolean_t +nvme_completion_is_retry(const struct nvme_completion *cpl) { /* * TODO: spec is not clear how commands that are aborted due @@ -96,69 +103,78 @@ nvme_qpair_construct_tracker(struct nvme tr->qpair = qpair; } -void -nvme_qpair_process_completions(struct nvme_qpair *qpair) +static void +nvme_qpair_complete_tracker(struct nvme_qpair *qpair, struct nvme_tracker *tr, + struct nvme_completion *cpl, boolean_t print_on_error) { - struct nvme_tracker *tr; struct nvme_request *req; - struct nvme_completion *cpl; boolean_t retry, error; - qpair->num_intr_handler_calls++; + req = tr->req; + error = nvme_completion_is_error(cpl); + retry = error && nvme_completion_is_retry(cpl); - while (1) { - cpl = &qpair->cpl[qpair->cq_head]; + if (error && print_on_error) { + nvme_dump_completion(cpl); + nvme_dump_command(&req->cmd); + } - if (cpl->p != qpair->phase) - break; + qpair->act_tr[cpl->cid] = NULL; - tr = qpair->act_tr[cpl->cid]; - req = tr->req; + KASSERT(cpl->cid == req->cmd.cid, ("cpl cid does not match cmd cid\n")); - KASSERT(tr, - ("completion queue has entries but no active trackers\n")); + if (req->cb_fn && !retry) + req->cb_fn(req->cb_arg, cpl); - error = cpl->sf_sc || cpl->sf_sct; - retry = error && nvme_completion_check_retry(cpl); + mtx_lock(&qpair->lock); + callout_stop(&tr->timer); - if (error) { - nvme_dump_completion(cpl); - nvme_dump_command(&tr->req->cmd); - } + if (retry) + nvme_qpair_submit_cmd(qpair, tr); + else { + if (req->payload_size > 0 || req->uio != NULL) + bus_dmamap_unload(qpair->dma_tag, + tr->payload_dma_map); + + nvme_free_request(req); - qpair->act_tr[cpl->cid] = NULL; + SLIST_INSERT_HEAD(&qpair->free_tr, tr, slist); - KASSERT(cpl->cid == req->cmd.cid, - ("cpl cid does not match cmd cid\n")); + if (!STAILQ_EMPTY(&qpair->queued_req)) { + req = STAILQ_FIRST(&qpair->queued_req); + STAILQ_REMOVE_HEAD(&qpair->queued_req, stailq); + _nvme_qpair_submit_request(qpair, req); + } + } - if (req->cb_fn && !retry) - req->cb_fn(req->cb_arg, cpl); + mtx_unlock(&qpair->lock); +} - qpair->sq_head = cpl->sqhd; +void +nvme_qpair_process_completions(struct nvme_qpair *qpair) +{ + struct nvme_tracker *tr; + struct nvme_completion *cpl; - mtx_lock(&qpair->lock); - callout_stop(&tr->timer); + qpair->num_intr_handler_calls++; - if (retry) - nvme_qpair_submit_cmd(qpair, tr); - else { - if (req->payload_size > 0 || req->uio != NULL) - bus_dmamap_unload(qpair->dma_tag, - tr->payload_dma_map); + while (1) { + cpl = &qpair->cpl[qpair->cq_head]; - nvme_free_request(req); + if (cpl->p != qpair->phase) + break; - SLIST_INSERT_HEAD(&qpair->free_tr, tr, slist); + tr = qpair->act_tr[cpl->cid]; - if (!STAILQ_EMPTY(&qpair->queued_req)) { - req = STAILQ_FIRST(&qpair->queued_req); - STAILQ_REMOVE_HEAD(&qpair->queued_req, stailq); - _nvme_qpair_submit_request(qpair, req); - } + if (tr != NULL) { + nvme_qpair_complete_tracker(qpair, tr, cpl, TRUE); + qpair->sq_head = cpl->sqhd; + } else { + printf("cpl does not map to outstanding cmd\n"); + nvme_dump_completion(cpl); + KASSERT(0, ("received completion for unknown cmd\n")); } - mtx_unlock(&qpair->lock); - if (++qpair->cq_head == qpair->num_entries) { qpair->cq_head = 0; qpair->phase = !qpair->phase; From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 18:29:05 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 99BC6599; Tue, 26 Mar 2013 18:29:05 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 8C8BA383; Tue, 26 Mar 2013 18:29:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QIT5hs061481; Tue, 26 Mar 2013 18:29:05 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QIT5Ko061480; Tue, 26 Mar 2013 18:29:05 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303261829.r2QIT5Ko061480@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 18:29:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248734 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 18:29:05 -0000 Author: jimharris Date: Tue Mar 26 18:29:04 2013 New Revision: 248734 URL: http://svnweb.freebsd.org/changeset/base/248734 Log: Explicitly abort a timed out command, if the ABORT command sent to the controller indicates the command was not found. Sponsored by: Intel Modified: head/sys/dev/nvme/nvme_qpair.c Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 18:27:22 2013 (r248733) +++ head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 18:29:04 2013 (r248734) @@ -393,12 +393,40 @@ nvme_io_qpair_destroy(struct nvme_qpair } static void +nvme_abort_complete(void *arg, const struct nvme_completion *status) +{ + struct nvme_completion cpl; + struct nvme_tracker *tr = arg; + + /* + * If cdw0 == 1, the controller was not able to abort the command + * we requested. We still need to check the active tracker array, + * to cover race where I/O timed out at same time controller was + * completing the I/O. + */ + if (status->cdw0 == 1 && tr->qpair->act_tr[tr->cid] != NULL) { + /* + * An I/O has timed out, and the controller was unable to + * abort it for some reason. Construct a fake completion + * status, and then complete the I/O's tracker manually. + */ + printf("abort command failed, aborting command manually\n"); + memset(&cpl, 0, sizeof(cpl)); + cpl.sqid = tr->qpair->id; + cpl.cid = tr->cid; + cpl.sf_sct = NVME_SCT_GENERIC; + cpl.sf_sc = NVME_SC_ABORTED_BY_REQUEST; + nvme_qpair_complete_tracker(tr->qpair, tr, &cpl, TRUE); + } +} + +static void nvme_timeout(void *arg) { struct nvme_tracker *tr = arg; nvme_ctrlr_cmd_abort(tr->qpair->ctrlr, tr->cid, tr->qpair->id, - NULL, NULL); + nvme_abort_complete, tr); } void From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 18:31:48 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 832718C5; Tue, 26 Mar 2013 18:31:47 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 71CD73DC; Tue, 26 Mar 2013 18:31:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QIVlli063560; Tue, 26 Mar 2013 18:31:47 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QIVkL1063556; Tue, 26 Mar 2013 18:31:46 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303261831.r2QIVkL1063556@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 18:31:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248735 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 18:31:48 -0000 Author: jimharris Date: Tue Mar 26 18:31:46 2013 New Revision: 248735 URL: http://svnweb.freebsd.org/changeset/base/248735 Log: Specify command timeout interval on a per-command type basis. This is primarily driven by the need to disable timeouts for asynchronous event requests, which by nature should not be timed out. Sponsored by: Intel Modified: head/sys/dev/nvme/nvme_ctrlr_cmd.c head/sys/dev/nvme/nvme_private.h head/sys/dev/nvme/nvme_qpair.c Modified: head/sys/dev/nvme/nvme_ctrlr_cmd.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr_cmd.c Tue Mar 26 18:29:04 2013 (r248734) +++ head/sys/dev/nvme/nvme_ctrlr_cmd.c Tue Mar 26 18:31:46 2013 (r248735) @@ -257,6 +257,12 @@ nvme_ctrlr_cmd_asynchronous_event_reques req = nvme_allocate_request(NULL, 0, cb_fn, cb_arg); + /* + * Override default timeout value here, since asynchronous event + * requests should by nature never be timed out. + */ + req->timeout = 0; + cmd = &req->cmd; cmd->opc = NVME_OPC_ASYNC_EVENT_REQUEST; Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 18:29:04 2013 (r248734) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 18:31:46 2013 (r248735) @@ -112,6 +112,7 @@ struct nvme_request { struct nvme_command cmd; void *payload; uint32_t payload_size; + uint32_t timeout; struct uio *uio; nvme_cb_fn_t cb_fn; void *cb_arg; @@ -411,6 +412,7 @@ nvme_allocate_request(void *payload, uin req->payload_size = payload_size; req->cb_fn = cb_fn; req->cb_arg = cb_arg; + req->timeout = NVME_TIMEOUT_IN_SEC; return (req); } @@ -427,6 +429,7 @@ nvme_allocate_request_uio(struct uio *ui req->uio = uio; req->cb_fn = cb_fn; req->cb_arg = cb_arg; + req->timeout = NVME_TIMEOUT_IN_SEC; return (req); } Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 18:29:04 2013 (r248734) +++ head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 18:31:46 2013 (r248735) @@ -438,11 +438,12 @@ nvme_qpair_submit_cmd(struct nvme_qpair req->cmd.cid = tr->cid; qpair->act_tr[tr->cid] = tr; + if (req->timeout > 0) #if __FreeBSD_version >= 800030 - callout_reset_curcpu(&tr->timer, NVME_TIMEOUT_IN_SEC * hz, - nvme_timeout, tr); + callout_reset_curcpu(&tr->timer, req->timeout * hz, + nvme_timeout, tr); #else - callout_reset(&tr->timer, NVME_TIMEOUT_IN_SEC * hz, nvme_timeout, tr); + callout_reset(&tr->timer, req->timeout * hz, nvme_timeout, tr); #endif /* Copy the command from the tracker to the submission queue. */ From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 18:34:20 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id DC1ECB93; Tue, 26 Mar 2013 18:34:20 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id CE341401; Tue, 26 Mar 2013 18:34:20 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QIYKML064078; Tue, 26 Mar 2013 18:34:20 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QIYK5V064075; Tue, 26 Mar 2013 18:34:20 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303261834.r2QIYK5V064075@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 18:34:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248736 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 18:34:20 -0000 Author: jimharris Date: Tue Mar 26 18:34:19 2013 New Revision: 248736 URL: http://svnweb.freebsd.org/changeset/base/248736 Log: Move controller destruction code from nvme_detach() to new nvme_ctrlr_destruct() function. Sponsored by: Intel Modified: head/sys/dev/nvme/nvme.c head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_private.h Modified: head/sys/dev/nvme/nvme.c ============================================================================== --- head/sys/dev/nvme/nvme.c Tue Mar 26 18:31:46 2013 (r248735) +++ head/sys/dev/nvme/nvme.c Tue Mar 26 18:34:19 2013 (r248736) @@ -286,53 +286,8 @@ static int nvme_detach (device_t dev) { struct nvme_controller *ctrlr = DEVICE2SOFTC(dev); - struct nvme_namespace *ns; - int i; - - for (i = 0; i < NVME_MAX_NAMESPACES; i++) { - ns = &ctrlr->ns[i]; - if (ns->cdev) - destroy_dev(ns->cdev); - } - - if (ctrlr->cdev) - destroy_dev(ctrlr->cdev); - - for (i = 0; i < ctrlr->num_io_queues; i++) { - nvme_io_qpair_destroy(&ctrlr->ioq[i]); - } - - free(ctrlr->ioq, M_NVME); - - nvme_admin_qpair_destroy(&ctrlr->adminq); - - if (ctrlr->resource != NULL) { - bus_release_resource(dev, SYS_RES_MEMORY, - ctrlr->resource_id, ctrlr->resource); - } - - if (ctrlr->bar4_resource != NULL) { - bus_release_resource(dev, SYS_RES_MEMORY, - ctrlr->bar4_resource_id, ctrlr->bar4_resource); - } - -#ifdef CHATHAM2 - if (ctrlr->chatham_resource != NULL) { - bus_release_resource(dev, SYS_RES_MEMORY, - ctrlr->chatham_resource_id, ctrlr->chatham_resource); - } -#endif - - if (ctrlr->tag) - bus_teardown_intr(ctrlr->dev, ctrlr->res, ctrlr->tag); - - if (ctrlr->res) - bus_release_resource(ctrlr->dev, SYS_RES_IRQ, - rman_get_rid(ctrlr->res), ctrlr->res); - - if (ctrlr->msix_enabled) - pci_release_msi(dev); + nvme_ctrlr_destruct(ctrlr, dev); return (0); } Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 18:31:46 2013 (r248735) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 18:34:19 2013 (r248736) @@ -808,6 +808,57 @@ intx: } void +nvme_ctrlr_destruct(struct nvme_controller *ctrlr, device_t dev) +{ + struct nvme_namespace *ns; + int i; + + for (i = 0; i < NVME_MAX_NAMESPACES; i++) { + ns = &ctrlr->ns[i]; + if (ns->cdev) + destroy_dev(ns->cdev); + } + + if (ctrlr->cdev) + destroy_dev(ctrlr->cdev); + + for (i = 0; i < ctrlr->num_io_queues; i++) { + nvme_io_qpair_destroy(&ctrlr->ioq[i]); + } + + free(ctrlr->ioq, M_NVME); + + nvme_admin_qpair_destroy(&ctrlr->adminq); + + if (ctrlr->resource != NULL) { + bus_release_resource(dev, SYS_RES_MEMORY, + ctrlr->resource_id, ctrlr->resource); + } + + if (ctrlr->bar4_resource != NULL) { + bus_release_resource(dev, SYS_RES_MEMORY, + ctrlr->bar4_resource_id, ctrlr->bar4_resource); + } + +#ifdef CHATHAM2 + if (ctrlr->chatham_resource != NULL) { + bus_release_resource(dev, SYS_RES_MEMORY, + ctrlr->chatham_resource_id, ctrlr->chatham_resource); + } +#endif + + if (ctrlr->tag) + bus_teardown_intr(ctrlr->dev, ctrlr->res, ctrlr->tag); + + if (ctrlr->res) + bus_release_resource(ctrlr->dev, SYS_RES_IRQ, + rman_get_rid(ctrlr->res), ctrlr->res); + + if (ctrlr->msix_enabled) + pci_release_msi(dev); +} + +void nvme_ctrlr_submit_admin_request(struct nvme_controller *ctrlr, struct nvme_request *req) { Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 18:31:46 2013 (r248735) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 18:34:19 2013 (r248736) @@ -358,6 +358,7 @@ void nvme_payload_map_uio(void *arg, bus bus_size_t mapsize, int error); int nvme_ctrlr_construct(struct nvme_controller *ctrlr, device_t dev); +void nvme_ctrlr_destruct(struct nvme_controller *ctrlr, device_t dev); int nvme_ctrlr_reset(struct nvme_controller *ctrlr); /* ctrlr defined as void * to allow use with config_intrhook. */ void nvme_ctrlr_start(void *ctrlr_arg); From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 18:37:37 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 60319D9E; Tue, 26 Mar 2013 18:37:37 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 521D95FD; Tue, 26 Mar 2013 18:37:37 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QIbbPi064542; Tue, 26 Mar 2013 18:37:37 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QIbaoJ064537; Tue, 26 Mar 2013 18:37:36 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303261837.r2QIbaoJ064537@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 18:37:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248737 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 18:37:37 -0000 Author: jimharris Date: Tue Mar 26 18:37:36 2013 New Revision: 248737 URL: http://svnweb.freebsd.org/changeset/base/248737 Log: Enable asynchronous event requests on non-Chatham devices. Also add logic to clean up all outstanding asynchronous event requests when resetting or shutting down the controller, since these requests will not be explicitly completed by the controller itself. Sponsored by: Intel Modified: head/sys/dev/nvme/nvme.h head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_ctrlr_cmd.c head/sys/dev/nvme/nvme_private.h head/sys/dev/nvme/nvme_qpair.c Modified: head/sys/dev/nvme/nvme.h ============================================================================== --- head/sys/dev/nvme/nvme.h Tue Mar 26 18:34:19 2013 (r248736) +++ head/sys/dev/nvme/nvme.h Tue Mar 26 18:37:36 2013 (r248737) @@ -360,7 +360,7 @@ enum nvme_feature { NVME_FEAT_INTERRUPT_COALESCING = 0x08, NVME_FEAT_INTERRUPT_VECTOR_CONFIGURATION = 0x09, NVME_FEAT_WRITE_ATOMICITY = 0x0A, - NVME_FEAT_ASYNCHRONOUS_EVENT_CONFIGURATION = 0x0B, + NVME_FEAT_ASYNC_EVENT_CONFIGURATION = 0x0B, /* 0x0C-0x7F - reserved */ NVME_FEAT_SOFTWARE_PROGRESS_MARKER = 0x80, /* 0x81-0xBF - command set specific (reserved) */ Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 18:34:19 2013 (r248736) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 18:37:36 2013 (r248737) @@ -38,6 +38,9 @@ __FBSDID("$FreeBSD$"); #include "nvme_private.h" +static void nvme_ctrlr_construct_and_submit_aer(struct nvme_controller *ctrlr, + struct nvme_async_event_request *aer); + static void nvme_ctrlr_cb(void *arg, const struct nvme_completion *status) { @@ -409,30 +412,6 @@ nvme_ctrlr_reset(struct nvme_controller return (nvme_ctrlr_enable(ctrlr)); } -/* - * Disable this code for now, since Chatham doesn't support - * AERs so I have no good way to test them. - */ -#if 0 -static void -nvme_async_event_cb(void *arg, const struct nvme_completion *status) -{ - struct nvme_controller *ctrlr = arg; - - printf("Asynchronous event occurred.\n"); - - /* TODO: decode async event type based on status */ - /* TODO: check status for any error bits */ - - /* - * Repost an asynchronous event request so that it can be - * used again by the controller. - */ - nvme_ctrlr_cmd_asynchronous_event_request(ctrlr, nvme_async_event_cb, - ctrlr); -} -#endif - static int nvme_ctrlr_identify(struct nvme_controller *ctrlr) { @@ -558,27 +537,71 @@ nvme_ctrlr_construct_namespaces(struct n } static void +nvme_ctrlr_async_event_cb(void *arg, const struct nvme_completion *cpl) +{ + struct nvme_async_event_request *aer = arg; + + if (cpl->sf_sc == NVME_SC_ABORTED_SQ_DELETION) { + /* + * This is simulated when controller is being shut down, to + * effectively abort outstanding asynchronous event requests + * and make sure all memory is freed. Do not repost the + * request in this case. + */ + return; + } + + /* TODO: decode async event type based on status */ + + /* + * Repost another asynchronous event request to replace the one that + * just completed. + */ + printf("Asynchronous event occurred.\n"); + nvme_ctrlr_construct_and_submit_aer(aer->ctrlr, aer); +} + +static void +nvme_ctrlr_construct_and_submit_aer(struct nvme_controller *ctrlr, + struct nvme_async_event_request *aer) +{ + struct nvme_request *req; + + aer->ctrlr = ctrlr; + req = nvme_allocate_request(NULL, 0, nvme_ctrlr_async_event_cb, aer); + aer->req = req; + + /* + * Override default timeout value here, since asynchronous event + * requests should by nature never be timed out. + */ + req->timeout = 0; + req->cmd.opc = NVME_OPC_ASYNC_EVENT_REQUEST; + nvme_ctrlr_submit_admin_request(ctrlr, req); +} + +static void nvme_ctrlr_configure_aer(struct nvme_controller *ctrlr) { union nvme_critical_warning_state state; - uint8_t num_async_events; + struct nvme_async_event_request *aer; + uint32_t i; state.raw = 0xFF; state.bits.reserved = 0; - nvme_ctrlr_cmd_set_asynchronous_event_config(ctrlr, state, NULL, NULL); + nvme_ctrlr_cmd_set_async_event_config(ctrlr, state, NULL, NULL); /* aerl is a zero-based value, so we need to add 1 here. */ - num_async_events = min(NVME_MAX_ASYNC_EVENTS, (ctrlr->cdata.aerl+1)); + ctrlr->num_aers = min(NVME_MAX_ASYNC_EVENTS, (ctrlr->cdata.aerl+1)); - /* - * Disable this code for now, since Chatham doesn't support - * AERs so I have no good way to test them. - */ -#if 0 - for (int i = 0; i < num_async_events; i++) - nvme_ctrlr_cmd_asynchronous_event_request(ctrlr, - nvme_async_event_cb, ctrlr); -#endif + /* Chatham doesn't support AERs. */ + if (pci_get_devid(ctrlr->dev) == CHATHAM_PCI_ID) + ctrlr->num_aers = 0; + + for (i = 0; i < ctrlr->num_aers; i++) { + aer = &ctrlr->aer[i]; + nvme_ctrlr_construct_and_submit_aer(ctrlr, aer); + } } static void @@ -810,8 +833,8 @@ intx: void nvme_ctrlr_destruct(struct nvme_controller *ctrlr, device_t dev) { - struct nvme_namespace *ns; - int i; + struct nvme_namespace *ns; + int i; for (i = 0; i < NVME_MAX_NAMESPACES; i++) { ns = &ctrlr->ns[i]; @@ -828,6 +851,13 @@ nvme_ctrlr_destruct(struct nvme_controll free(ctrlr->ioq, M_NVME); + /* Manually abort outstanding async event requests. */ + for (i = 0; i < ctrlr->num_aers; i++) { + nvme_qpair_manual_abort_request(&ctrlr->adminq, + ctrlr->aer[i].req, NVME_SCT_GENERIC, + NVME_SC_ABORTED_SQ_DELETION, FALSE); + } + nvme_admin_qpair_destroy(&ctrlr->adminq); if (ctrlr->resource != NULL) { Modified: head/sys/dev/nvme/nvme_ctrlr_cmd.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr_cmd.c Tue Mar 26 18:34:19 2013 (r248736) +++ head/sys/dev/nvme/nvme_ctrlr_cmd.c Tue Mar 26 18:37:36 2013 (r248737) @@ -211,7 +211,7 @@ nvme_ctrlr_cmd_set_num_queues(struct nvm } void -nvme_ctrlr_cmd_set_asynchronous_event_config(struct nvme_controller *ctrlr, +nvme_ctrlr_cmd_set_async_event_config(struct nvme_controller *ctrlr, union nvme_critical_warning_state state, nvme_cb_fn_t cb_fn, void *cb_arg) { @@ -219,7 +219,7 @@ nvme_ctrlr_cmd_set_asynchronous_event_co cdw11 = state.raw; nvme_ctrlr_cmd_set_feature(ctrlr, - NVME_FEAT_ASYNCHRONOUS_EVENT_CONFIGURATION, cdw11, NULL, 0, cb_fn, + NVME_FEAT_ASYNC_EVENT_CONFIGURATION, cdw11, NULL, 0, cb_fn, cb_arg); } @@ -249,27 +249,6 @@ nvme_ctrlr_cmd_set_interrupt_coalescing( } void -nvme_ctrlr_cmd_asynchronous_event_request(struct nvme_controller *ctrlr, - nvme_cb_fn_t cb_fn, void *cb_arg) -{ - struct nvme_request *req; - struct nvme_command *cmd; - - req = nvme_allocate_request(NULL, 0, cb_fn, cb_arg); - - /* - * Override default timeout value here, since asynchronous event - * requests should by nature never be timed out. - */ - req->timeout = 0; - - cmd = &req->cmd; - cmd->opc = NVME_OPC_ASYNC_EVENT_REQUEST; - - nvme_ctrlr_submit_admin_request(ctrlr, req); -} - -void nvme_ctrlr_cmd_get_health_information_page(struct nvme_controller *ctrlr, uint32_t nsid, struct nvme_health_information_page *payload, nvme_cb_fn_t cb_fn, void *cb_arg) Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 18:34:19 2013 (r248736) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 18:37:36 2013 (r248737) @@ -97,7 +97,7 @@ MALLOC_DECLARE(M_NVME); #define NVME_MAX_NAMESPACES (16) #define NVME_MAX_CONSUMERS (2) -#define NVME_MAX_ASYNC_EVENTS (4) +#define NVME_MAX_ASYNC_EVENTS (8) #define NVME_TIMEOUT_IN_SEC (30) @@ -119,6 +119,12 @@ struct nvme_request { STAILQ_ENTRY(nvme_request) stailq; }; +struct nvme_async_event_request { + + struct nvme_controller *ctrlr; + struct nvme_request *req; +}; + struct nvme_tracker { SLIST_ENTRY(nvme_tracker) slist; @@ -255,6 +261,9 @@ struct nvme_controller { boolean_t is_started; + uint32_t num_aers; + struct nvme_async_event_request aer[NVME_MAX_ASYNC_EVENTS]; + #ifdef CHATHAM2 uint64_t chatham_size; uint64_t chatham_lbas; @@ -343,12 +352,9 @@ void nvme_ctrlr_cmd_delete_io_sq(struct void nvme_ctrlr_cmd_set_num_queues(struct nvme_controller *ctrlr, uint32_t num_queues, nvme_cb_fn_t cb_fn, void *cb_arg); -void nvme_ctrlr_cmd_set_asynchronous_event_config(struct nvme_controller *ctrlr, - union nvme_critical_warning_state state, - nvme_cb_fn_t cb_fn, void *cb_arg); -void nvme_ctrlr_cmd_asynchronous_event_request(struct nvme_controller *ctrlr, - nvme_cb_fn_t cb_fn, - void *cb_arg); +void nvme_ctrlr_cmd_set_async_event_config(struct nvme_controller *ctrlr, + union nvme_critical_warning_state state, + nvme_cb_fn_t cb_fn, void *cb_arg); void nvme_ctrlr_cmd_abort(struct nvme_controller *ctrlr, uint16_t cid, uint16_t sqid, nvme_cb_fn_t cb_fn, void *cb_arg); @@ -376,6 +382,9 @@ void nvme_qpair_submit_cmd(struct nvme_q void nvme_qpair_process_completions(struct nvme_qpair *qpair); void nvme_qpair_submit_request(struct nvme_qpair *qpair, struct nvme_request *req); +void nvme_qpair_manual_abort_request(struct nvme_qpair *qpair, + struct nvme_request *req, uint32_t sct, + uint32_t sc, boolean_t print_on_error); void nvme_admin_qpair_destroy(struct nvme_qpair *qpair); Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 18:34:19 2013 (r248736) +++ head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 18:37:36 2013 (r248737) @@ -87,6 +87,23 @@ nvme_completion_is_retry(const struct nv } } +static struct nvme_tracker * +nvme_qpair_find_tracker(struct nvme_qpair *qpair, struct nvme_request *req) +{ + struct nvme_tracker *tr; + uint32_t i; + + KASSERT(req != NULL, ("%s: called with NULL req\n", __func__)); + + for (i = 0; i < qpair->num_entries; ++i) { + tr = qpair->act_tr[i]; + if (tr != NULL && tr->req == req) + return (tr); + } + + return (NULL); +} + static void nvme_qpair_construct_tracker(struct nvme_qpair *qpair, struct nvme_tracker *tr, uint16_t cid) @@ -137,6 +154,7 @@ nvme_qpair_complete_tracker(struct nvme_ tr->payload_dma_map); nvme_free_request(req); + tr->req = NULL; SLIST_INSERT_HEAD(&qpair->free_tr, tr, slist); @@ -297,7 +315,7 @@ nvme_qpair_construct(struct nvme_qpair * static void nvme_qpair_destroy(struct nvme_qpair *qpair) { - struct nvme_tracker *tr; + struct nvme_tracker *tr; if (qpair->tag) bus_teardown_intr(qpair->ctrlr->dev, qpair->res, qpair->tag); @@ -393,9 +411,41 @@ nvme_io_qpair_destroy(struct nvme_qpair } static void -nvme_abort_complete(void *arg, const struct nvme_completion *status) +nvme_qpair_manual_abort_tracker(struct nvme_qpair *qpair, + struct nvme_tracker *tr, uint32_t sct, uint32_t sc, + boolean_t print_on_error) { struct nvme_completion cpl; + + memset(&cpl, 0, sizeof(cpl)); + cpl.sqid = qpair->id; + cpl.cid = tr->cid; + cpl.sf_sct = sct; + cpl.sf_sc = sc; + nvme_qpair_complete_tracker(qpair, tr, &cpl, print_on_error); +} + +void +nvme_qpair_manual_abort_request(struct nvme_qpair *qpair, + struct nvme_request *req, uint32_t sct, uint32_t sc, + boolean_t print_on_error) +{ + struct nvme_tracker *tr; + + tr = nvme_qpair_find_tracker(qpair, req); + + if (tr == NULL) { + printf("%s: request not found\n", __func__); + nvme_dump_command(&req->cmd); + return; + } + + nvme_qpair_manual_abort_tracker(qpair, tr, sct, sc, print_on_error); +} + +static void +nvme_abort_complete(void *arg, const struct nvme_completion *status) +{ struct nvme_tracker *tr = arg; /* @@ -411,12 +461,8 @@ nvme_abort_complete(void *arg, const str * status, and then complete the I/O's tracker manually. */ printf("abort command failed, aborting command manually\n"); - memset(&cpl, 0, sizeof(cpl)); - cpl.sqid = tr->qpair->id; - cpl.cid = tr->cid; - cpl.sf_sct = NVME_SCT_GENERIC; - cpl.sf_sc = NVME_SC_ABORTED_BY_REQUEST; - nvme_qpair_complete_tracker(tr->qpair, tr, &cpl, TRUE); + nvme_qpair_manual_abort_tracker(tr->qpair, tr, + NVME_SCT_GENERIC, NVME_SC_ABORTED_BY_REQUEST, TRUE); } } From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 18:39:56 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 694AB26F; Tue, 26 Mar 2013 18:39:56 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 4CEC165D; Tue, 26 Mar 2013 18:39:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QIduT5064953; Tue, 26 Mar 2013 18:39:56 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QIdt9H064948; Tue, 26 Mar 2013 18:39:55 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303261839.r2QIdt9H064948@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 18:39:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248738 - in head/sys/dev: nvd nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 18:39:56 -0000 Author: jimharris Date: Tue Mar 26 18:39:54 2013 New Revision: 248738 URL: http://svnweb.freebsd.org/changeset/base/248738 Log: Add an interface for nvme shim drivers (i.e. nvd) to register for notifications when new nvme controllers are added to the system. Sponsored by: Intel Modified: head/sys/dev/nvd/nvd.c head/sys/dev/nvme/nvme.c head/sys/dev/nvme/nvme.h head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_private.h Modified: head/sys/dev/nvd/nvd.c ============================================================================== --- head/sys/dev/nvd/nvd.c Tue Mar 26 18:37:36 2013 (r248737) +++ head/sys/dev/nvd/nvd.c Tue Mar 26 18:39:54 2013 (r248738) @@ -45,7 +45,7 @@ struct nvd_disk; static disk_ioctl_t nvd_ioctl; static disk_strategy_t nvd_strategy; -static void create_geom_disk(void *, struct nvme_namespace *ns); +static void *create_geom_disk(struct nvme_namespace *ns, void *ctrlr); static void destroy_geom_disk(struct nvd_disk *ndisk); static int nvd_load(void); @@ -105,7 +105,7 @@ nvd_load() { TAILQ_INIT(&nvd_head); - consumer_handle = nvme_register_consumer(create_geom_disk, NULL); + consumer_handle = nvme_register_consumer(create_geom_disk, NULL, NULL); return (consumer_handle != NULL ? 0 : -1); } @@ -233,8 +233,8 @@ nvd_bioq_process(void *arg, int pending) } } -static void -create_geom_disk(void *arg, struct nvme_namespace *ns) +static void * +create_geom_disk(struct nvme_namespace *ns, void *ctrlr) { struct nvd_disk *ndisk; struct disk *disk; @@ -287,6 +287,8 @@ create_geom_disk(void *arg, struct nvme_ taskqueue_start_threads(&ndisk->tq, 1, PI_DISK, "nvd taskq"); TAILQ_INSERT_HEAD(&nvd_head, ndisk, tailq); + + return (NULL); } static void Modified: head/sys/dev/nvme/nvme.c ============================================================================== --- head/sys/dev/nvme/nvme.c Tue Mar 26 18:37:36 2013 (r248737) +++ head/sys/dev/nvme/nvme.c Tue Mar 26 18:39:54 2013 (r248738) @@ -40,11 +40,14 @@ __FBSDID("$FreeBSD$"); #include "nvme_private.h" struct nvme_consumer { - nvme_consumer_cb_fn_t cb_fn; - void *cb_arg; + uint32_t id; + nvme_cons_ns_fn_t ns_fn; + nvme_cons_ctrlr_fn_t ctrlr_fn; + nvme_cons_async_fn_t async_fn; }; struct nvme_consumer nvme_consumer[NVME_MAX_CONSUMERS]; +#define INVALID_CONSUMER_ID 0xFFFF uma_zone_t nvme_request_zone; @@ -118,8 +121,13 @@ nvme_probe (device_t device) static void nvme_init(void) { + uint32_t i; + nvme_request_zone = uma_zcreate("nvme_request", sizeof(struct nvme_request), NULL, NULL, NULL, NULL, 0, 0); + + for (i = 0; i < NVME_MAX_CONSUMERS; i++) + nvme_consumer[i].id = INVALID_CONSUMER_ID; } SYSINIT(nvme_register, SI_SUB_DRIVERS, SI_ORDER_SECOND, nvme_init, NULL); @@ -292,26 +300,52 @@ nvme_detach (device_t dev) } static void -nvme_notify_consumer(struct nvme_consumer *consumer) +nvme_notify_consumer(struct nvme_consumer *cons) { device_t *devlist; struct nvme_controller *ctrlr; - int dev, ns, devcount; + struct nvme_namespace *ns; + void *ctrlr_cookie; + int dev_idx, ns_idx, devcount; if (devclass_get_devices(nvme_devclass, &devlist, &devcount)) return; - for (dev = 0; dev < devcount; dev++) { - ctrlr = DEVICE2SOFTC(devlist[dev]); - for (ns = 0; ns < ctrlr->cdata.nn; ns++) - (*consumer->cb_fn)(consumer->cb_arg, &ctrlr->ns[ns]); + for (dev_idx = 0; dev_idx < devcount; dev_idx++) { + ctrlr = DEVICE2SOFTC(devlist[dev_idx]); + if (cons->ctrlr_fn != NULL) + ctrlr_cookie = (*cons->ctrlr_fn)(ctrlr); + else + ctrlr_cookie = NULL; + ctrlr->cons_cookie[cons->id] = ctrlr_cookie; + for (ns_idx = 0; ns_idx < ctrlr->cdata.nn; ns_idx++) { + ns = &ctrlr->ns[ns_idx]; + if (cons->ns_fn != NULL) + ns->cons_cookie[cons->id] = + (*cons->ns_fn)(ns, ctrlr_cookie); + } } free(devlist, M_TEMP); } +void +nvme_notify_async_consumers(struct nvme_controller *ctrlr, + const struct nvme_completion *async_cpl) +{ + struct nvme_consumer *cons; + uint32_t i; + + for (i = 0; i < NVME_MAX_CONSUMERS; i++) { + cons = &nvme_consumer[i]; + if (cons->id != INVALID_CONSUMER_ID && cons->async_fn != NULL) + (*cons->async_fn)(ctrlr->cons_cookie[i], async_cpl); + } +} + struct nvme_consumer * -nvme_register_consumer(nvme_consumer_cb_fn_t cb_fn, void *cb_arg) +nvme_register_consumer(nvme_cons_ns_fn_t ns_fn, nvme_cons_ctrlr_fn_t ctrlr_fn, + nvme_cons_async_fn_t async_fn) { int i; @@ -320,9 +354,11 @@ nvme_register_consumer(nvme_consumer_cb_ * right now since we only have one nvme consumer - nvd(4). */ for (i = 0; i < NVME_MAX_CONSUMERS; i++) - if (nvme_consumer[i].cb_fn == NULL) { - nvme_consumer[i].cb_fn = cb_fn; - nvme_consumer[i].cb_arg = cb_arg; + if (nvme_consumer[i].id == INVALID_CONSUMER_ID) { + nvme_consumer[i].id = i; + nvme_consumer[i].ns_fn = ns_fn; + nvme_consumer[i].ctrlr_fn = ctrlr_fn; + nvme_consumer[i].async_fn = async_fn; nvme_notify_consumer(&nvme_consumer[i]); return (&nvme_consumer[i]); @@ -336,7 +372,6 @@ void nvme_unregister_consumer(struct nvme_consumer *consumer) { - consumer->cb_fn = NULL; - consumer->cb_arg = NULL; + consumer->id = INVALID_CONSUMER_ID; } Modified: head/sys/dev/nvme/nvme.h ============================================================================== --- head/sys/dev/nvme/nvme.h Tue Mar 26 18:37:36 2013 (r248737) +++ head/sys/dev/nvme/nvme.h Tue Mar 26 18:39:54 2013 (r248738) @@ -690,10 +690,14 @@ enum nvme_io_test_flags { struct bio; struct nvme_namespace; +struct nvme_controller; struct nvme_consumer; typedef void (*nvme_cb_fn_t)(void *, const struct nvme_completion *); -typedef void (*nvme_consumer_cb_fn_t)(void *, struct nvme_namespace *); + +typedef void *(*nvme_cons_ns_fn_t)(struct nvme_namespace *, void *); +typedef void *(*nvme_cons_ctrlr_fn_t)(struct nvme_controller *); +typedef void (*nvme_cons_async_fn_t)(void *, const struct nvme_completion *); enum nvme_namespace_flags { NVME_NS_DEALLOCATE_SUPPORTED = 0x1, @@ -714,10 +718,14 @@ int nvme_ns_cmd_flush(struct nvme_namesp void *cb_arg); /* Registration functions */ -struct nvme_consumer * nvme_register_consumer(nvme_consumer_cb_fn_t cb_fn, - void *cb_arg); +struct nvme_consumer * nvme_register_consumer(nvme_cons_ns_fn_t ns_fn, + nvme_cons_ctrlr_fn_t ctrlr_fn, + nvme_cons_async_fn_t async_fn); void nvme_unregister_consumer(struct nvme_consumer *consumer); +/* Controller helper functions */ +device_t nvme_ctrlr_get_device(struct nvme_controller *ctrlr); + /* Namespace helper functions */ uint32_t nvme_ns_get_max_io_xfer_size(struct nvme_namespace *ns); uint32_t nvme_ns_get_sector_size(struct nvme_namespace *ns); Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 18:37:36 2013 (r248737) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 18:39:54 2013 (r248738) @@ -551,6 +551,8 @@ nvme_ctrlr_async_event_cb(void *arg, con return; } + nvme_notify_async_consumers(aer->ctrlr, cpl); + /* TODO: decode async event type based on status */ /* @@ -909,3 +911,10 @@ nvme_ctrlr_submit_io_request(struct nvme nvme_qpair_submit_request(qpair, req); } + +device_t +nvme_ctrlr_get_device(struct nvme_controller *ctrlr) +{ + + return (ctrlr->dev); +} Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 18:37:36 2013 (r248737) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 18:39:54 2013 (r248738) @@ -190,6 +190,7 @@ struct nvme_namespace { uint16_t id; uint16_t flags; struct cdev *cdev; + void *cons_cookie[NVME_MAX_CONSUMERS]; }; /* @@ -264,6 +265,8 @@ struct nvme_controller { uint32_t num_aers; struct nvme_async_event_request aer[NVME_MAX_ASYNC_EVENTS]; + void *cons_cookie[NVME_MAX_CONSUMERS]; + #ifdef CHATHAM2 uint64_t chatham_size; uint64_t chatham_lbas; @@ -446,4 +449,7 @@ nvme_allocate_request_uio(struct uio *ui #define nvme_free_request(req) uma_zfree(nvme_request_zone, req) +void nvme_notify_async_consumers(struct nvme_controller *ctrlr, + const struct nvme_completion *async_cpl); + #endif /* __NVME_PRIVATE_H__ */ From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 18:42:06 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id F2D6943F; Tue, 26 Mar 2013 18:42:05 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id CD63168A; Tue, 26 Mar 2013 18:42:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QIg5w0066867; Tue, 26 Mar 2013 18:42:05 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QIg5ka066865; Tue, 26 Mar 2013 18:42:05 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303261842.r2QIg5ka066865@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 18:42:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248739 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 18:42:06 -0000 Author: jimharris Date: Tue Mar 26 18:42:05 2013 New Revision: 248739 URL: http://svnweb.freebsd.org/changeset/base/248739 Log: Expose the get/set features API to nvme consumers. Sponsored by: Intel Modified: head/sys/dev/nvme/nvme.h head/sys/dev/nvme/nvme_private.h Modified: head/sys/dev/nvme/nvme.h ============================================================================== --- head/sys/dev/nvme/nvme.h Tue Mar 26 18:39:54 2013 (r248738) +++ head/sys/dev/nvme/nvme.h Tue Mar 26 18:42:05 2013 (r248739) @@ -704,6 +704,16 @@ enum nvme_namespace_flags { NVME_NS_FLUSH_SUPPORTED = 0x2, }; +/* Admin functions */ +void nvme_ctrlr_cmd_set_feature(struct nvme_controller *ctrlr, + uint8_t feature, uint32_t cdw11, + void *payload, uint32_t payload_size, + nvme_cb_fn_t cb_fn, void *cb_arg); +void nvme_ctrlr_cmd_get_feature(struct nvme_controller *ctrlr, + uint8_t feature, uint32_t cdw11, + void *payload, uint32_t payload_size, + nvme_cb_fn_t cb_fn, void *cb_arg); + /* NVM I/O functions */ int nvme_ns_cmd_write(struct nvme_namespace *ns, void *payload, uint64_t lba, uint32_t lba_count, nvme_cb_fn_t cb_fn, Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 18:39:54 2013 (r248738) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 18:42:05 2013 (r248739) @@ -316,14 +316,6 @@ struct nvme_controller { void nvme_ns_test(struct nvme_namespace *ns, u_long cmd, caddr_t arg); -void nvme_ctrlr_cmd_set_feature(struct nvme_controller *ctrlr, - uint8_t feature, uint32_t cdw11, - void *payload, uint32_t payload_size, - nvme_cb_fn_t cb_fn, void *cb_arg); -void nvme_ctrlr_cmd_get_feature(struct nvme_controller *ctrlr, - uint8_t feature, uint32_t cdw11, - void *payload, uint32_t payload_size, - nvme_cb_fn_t cb_fn, void *cb_arg); void nvme_ctrlr_cmd_identify_controller(struct nvme_controller *ctrlr, void *payload, nvme_cb_fn_t cb_fn, void *cb_arg); From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 18:43:54 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 19C565C7; Tue, 26 Mar 2013 18:43:54 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E841669B; Tue, 26 Mar 2013 18:43:53 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QIhrIF067124; Tue, 26 Mar 2013 18:43:53 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QIhrkS067122; Tue, 26 Mar 2013 18:43:53 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303261843.r2QIhrkS067122@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 18:43:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248740 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 18:43:54 -0000 Author: jimharris Date: Tue Mar 26 18:43:53 2013 New Revision: 248740 URL: http://svnweb.freebsd.org/changeset/base/248740 Log: Create a generic nvme_ctrlr_cmd_get_log_page function, and change the health information log page function to use it. Sponsored by: Intel Modified: head/sys/dev/nvme/nvme.h head/sys/dev/nvme/nvme_ctrlr_cmd.c Modified: head/sys/dev/nvme/nvme.h ============================================================================== --- head/sys/dev/nvme/nvme.h Tue Mar 26 18:42:05 2013 (r248739) +++ head/sys/dev/nvme/nvme.h Tue Mar 26 18:43:53 2013 (r248740) @@ -713,6 +713,10 @@ void nvme_ctrlr_cmd_get_feature(struct n uint8_t feature, uint32_t cdw11, void *payload, uint32_t payload_size, nvme_cb_fn_t cb_fn, void *cb_arg); +void nvme_ctrlr_cmd_get_log_page(struct nvme_controller *ctrlr, + uint8_t log_page, uint32_t nsid, + void *payload, uint32_t payload_size, + nvme_cb_fn_t cb_fn, void *cb_arg); /* NVM I/O functions */ int nvme_ns_cmd_write(struct nvme_namespace *ns, void *payload, Modified: head/sys/dev/nvme/nvme_ctrlr_cmd.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr_cmd.c Tue Mar 26 18:42:05 2013 (r248739) +++ head/sys/dev/nvme/nvme_ctrlr_cmd.c Tue Mar 26 18:43:53 2013 (r248740) @@ -249,24 +249,35 @@ nvme_ctrlr_cmd_set_interrupt_coalescing( } void -nvme_ctrlr_cmd_get_health_information_page(struct nvme_controller *ctrlr, - uint32_t nsid, struct nvme_health_information_page *payload, - nvme_cb_fn_t cb_fn, void *cb_arg) +nvme_ctrlr_cmd_get_log_page(struct nvme_controller *ctrlr, uint8_t log_page, + uint32_t nsid, void *payload, uint32_t payload_size, nvme_cb_fn_t cb_fn, + void *cb_arg) { struct nvme_request *req; struct nvme_command *cmd; - req = nvme_allocate_request(payload, sizeof(*payload), cb_fn, cb_arg); + req = nvme_allocate_request(payload, payload_size, cb_fn, cb_arg); cmd = &req->cmd; cmd->opc = NVME_OPC_GET_LOG_PAGE; cmd->nsid = nsid; - cmd->cdw10 = ((sizeof(*payload)/sizeof(uint32_t)) - 1) << 16; - cmd->cdw10 |= NVME_LOG_HEALTH_INFORMATION; + cmd->cdw10 = ((payload_size/sizeof(uint32_t)) - 1) << 16; + cmd->cdw10 |= log_page; nvme_ctrlr_submit_admin_request(ctrlr, req); } + +void +nvme_ctrlr_cmd_get_health_information_page(struct nvme_controller *ctrlr, + uint32_t nsid, struct nvme_health_information_page *payload, + nvme_cb_fn_t cb_fn, void *cb_arg) +{ + + nvme_ctrlr_cmd_get_log_page(ctrlr, NVME_LOG_HEALTH_INFORMATION, + nsid, payload, sizeof(*payload), cb_fn, cb_arg); +} + void nvme_ctrlr_cmd_abort(struct nvme_controller *ctrlr, uint16_t cid, uint16_t sqid, nvme_cb_fn_t cb_fn, void *cb_arg) From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 18:45:17 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 55E33758; Tue, 26 Mar 2013 18:45:17 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 48CAA6B2; Tue, 26 Mar 2013 18:45:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QIjH6P067408; Tue, 26 Mar 2013 18:45:17 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QIjG6N067406; Tue, 26 Mar 2013 18:45:16 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303261845.r2QIjG6N067406@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 18:45:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248741 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 18:45:17 -0000 Author: jimharris Date: Tue Mar 26 18:45:16 2013 New Revision: 248741 URL: http://svnweb.freebsd.org/changeset/base/248741 Log: Keep a doubly-linked list of outstanding trackers. This enables in-order re-submission of I/O after a controller reset. Sponsored by: Intel Modified: head/sys/dev/nvme/nvme_private.h head/sys/dev/nvme/nvme_qpair.c Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 18:43:53 2013 (r248740) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 18:45:16 2013 (r248741) @@ -127,7 +127,7 @@ struct nvme_async_event_request { struct nvme_tracker { - SLIST_ENTRY(nvme_tracker) slist; + TAILQ_ENTRY(nvme_tracker) tailq; struct nvme_request *req; struct nvme_qpair *qpair; struct callout timer; @@ -174,7 +174,8 @@ struct nvme_qpair { bus_dmamap_t cpl_dma_map; uint64_t cpl_bus_addr; - SLIST_HEAD(, nvme_tracker) free_tr; + TAILQ_HEAD(, nvme_tracker) free_tr; + TAILQ_HEAD(, nvme_tracker) outstanding_tr; STAILQ_HEAD(, nvme_request) queued_req; struct nvme_tracker **act_tr; Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 18:43:53 2013 (r248740) +++ head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 18:45:16 2013 (r248741) @@ -156,7 +156,8 @@ nvme_qpair_complete_tracker(struct nvme_ nvme_free_request(req); tr->req = NULL; - SLIST_INSERT_HEAD(&qpair->free_tr, tr, slist); + TAILQ_REMOVE(&qpair->outstanding_tr, tr, tailq); + TAILQ_INSERT_HEAD(&qpair->free_tr, tr, tailq); if (!STAILQ_EMPTY(&qpair->queued_req)) { req = STAILQ_FIRST(&qpair->queued_req); @@ -293,7 +294,8 @@ nvme_qpair_construct(struct nvme_qpair * qpair->sq_tdbl_off = nvme_mmio_offsetof(doorbell[id].sq_tdbl); qpair->cq_hdbl_off = nvme_mmio_offsetof(doorbell[id].cq_hdbl); - SLIST_INIT(&qpair->free_tr); + TAILQ_INIT(&qpair->free_tr); + TAILQ_INIT(&qpair->outstanding_tr); STAILQ_INIT(&qpair->queued_req); for (i = 0; i < qpair->num_trackers; i++) { @@ -305,7 +307,7 @@ nvme_qpair_construct(struct nvme_qpair * } nvme_qpair_construct_tracker(qpair, tr, i); - SLIST_INSERT_HEAD(&qpair->free_tr, tr, slist); + TAILQ_INSERT_HEAD(&qpair->free_tr, tr, tailq); } qpair->act_tr = malloc(sizeof(struct nvme_tracker *) * qpair->num_entries, @@ -330,9 +332,9 @@ nvme_qpair_destroy(struct nvme_qpair *qp if (qpair->act_tr) free(qpair->act_tr, M_NVME); - while (!SLIST_EMPTY(&qpair->free_tr)) { - tr = SLIST_FIRST(&qpair->free_tr); - SLIST_REMOVE_HEAD(&qpair->free_tr, slist); + while (!TAILQ_EMPTY(&qpair->free_tr)) { + tr = TAILQ_FIRST(&qpair->free_tr); + TAILQ_REMOVE(&qpair->free_tr, tr, tailq); bus_dmamap_destroy(qpair->dma_tag, tr->payload_dma_map); bus_dmamap_destroy(qpair->dma_tag, tr->prp_dma_map); free(tr, M_NVME); @@ -513,7 +515,7 @@ _nvme_qpair_submit_request(struct nvme_q mtx_assert(&qpair->lock, MA_OWNED); - tr = SLIST_FIRST(&qpair->free_tr); + tr = TAILQ_FIRST(&qpair->free_tr); if (tr == NULL) { /* @@ -525,7 +527,8 @@ _nvme_qpair_submit_request(struct nvme_q return; } - SLIST_REMOVE_HEAD(&qpair->free_tr, slist); + TAILQ_REMOVE(&qpair->free_tr, tr, tailq); + TAILQ_INSERT_TAIL(&qpair->outstanding_tr, tr, tailq); tr->req = req; if (req->uio == NULL) { From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 18:46:40 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D2DA78F3; Tue, 26 Mar 2013 18:46:40 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id C5BBA6CC; Tue, 26 Mar 2013 18:46:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QIkevk067619; Tue, 26 Mar 2013 18:46:40 GMT (envelope-from markj@svn.freebsd.org) Received: (from markj@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QIkegP067618; Tue, 26 Mar 2013 18:46:40 GMT (envelope-from markj@svn.freebsd.org) Message-Id: <201303261846.r2QIkegP067618@svn.freebsd.org> From: Mark Johnston Date: Tue, 26 Mar 2013 18:46:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248742 - head/share/mk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 18:46:40 -0000 Author: markj Date: Tue Mar 26 18:46:40 2013 New Revision: 248742 URL: http://svnweb.freebsd.org/changeset/base/248742 Log: Make sure to set OBJS consistently in the cases where SRCS is and isn't already defined. Setting it with "+=" makes it possible for other make scripts (e.g. bsd.dtrace.mk) to include additional object files in the linker arguments. Approved by: emaste (co-mentor) Modified: head/share/mk/bsd.prog.mk Modified: head/share/mk/bsd.prog.mk ============================================================================== --- head/share/mk/bsd.prog.mk Tue Mar 26 18:45:16 2013 (r248741) +++ head/share/mk/bsd.prog.mk Tue Mar 26 18:46:40 2013 (r248742) @@ -73,7 +73,7 @@ SRCS= ${PROG}.c # - the name of the object gets put into the executable symbol table instead of # the name of a variable temporary object. # - it's useful to keep objects around for crunching. -OBJS= ${PROG}.o +OBJS+= ${PROG}.o .if target(beforelinking) beforelinking: ${OBJS} From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 18:57:26 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 240DAB8D; Tue, 26 Mar 2013 18:57:26 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 15B57732; Tue, 26 Mar 2013 18:57:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QIvPle070641; Tue, 26 Mar 2013 18:57:25 GMT (envelope-from melifaro@svn.freebsd.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QIvPHt070640; Tue, 26 Mar 2013 18:57:25 GMT (envelope-from melifaro@svn.freebsd.org) Message-Id: <201303261857.r2QIvPHt070640@svn.freebsd.org> From: "Alexander V. Chernikov" Date: Tue, 26 Mar 2013 18:57:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248743 - stable/9/sys/net X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 18:57:26 -0000 Author: melifaro Date: Tue Mar 26 18:57:25 2013 New Revision: 248743 URL: http://svnweb.freebsd.org/changeset/base/248743 Log: Permit changing MTU in 6to4 relay. This behavior is recommended by RFC 4213 clause 3.2. Sometimes fragmentation is the least evil. For example, some Linux IPVS kernels forwards ICMPv6 checksums to real servers incorrectly. Modified: stable/9/sys/net/if_stf.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/net/ (props changed) Modified: stable/9/sys/net/if_stf.c ============================================================================== --- stable/9/sys/net/if_stf.c Tue Mar 26 18:46:40 2013 (r248742) +++ stable/9/sys/net/if_stf.c Tue Mar 26 18:57:25 2013 (r248743) @@ -799,7 +799,7 @@ stf_rtrequest(cmd, rt, info) struct rt_addrinfo *info; { RT_LOCK_ASSERT(rt); - rt->rt_rmx.rmx_mtu = IPV6_MMTU; + rt->rt_rmx.rmx_mtu = rt->rt_ifp->if_mtu; } static int @@ -812,7 +812,7 @@ stf_ioctl(ifp, cmd, data) struct ifreq *ifr; struct sockaddr_in6 *sin6; struct in_addr addr; - int error; + int error, mtu; error = 0; switch (cmd) { @@ -846,6 +846,18 @@ stf_ioctl(ifp, cmd, data) error = EAFNOSUPPORT; break; + case SIOCGIFMTU: + break; + + case SIOCSIFMTU: + ifr = (struct ifreq *)data; + mtu = ifr->ifr_mtu; + /* RFC 4213 3.2 ideal world MTU */ + if (mtu < IPV6_MINMTU || mtu > IF_MAXMTU - 20) + return (EINVAL); + ifp->if_mtu = mtu; + break; + default: error = EINVAL; break; From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 19:04:26 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 5D69DDC7; Tue, 26 Mar 2013 19:04:26 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from mail.ipfw.ru (unknown [IPv6:2a01:4f8:120:6141::2]) by mx1.freebsd.org (Postfix) with ESMTP id 2286C788; Tue, 26 Mar 2013 19:04:26 +0000 (UTC) Received: from [2a02:6b8:0:401:222:4dff:fe50:cd2f] (helo=dhcp170-36-red.yandex.net) by mail.ipfw.ru with esmtpsa (TLSv1:CAMELLIA256-SHA:256) (Exim 4.76 (FreeBSD)) (envelope-from ) id 1UKZDt-0006FY-Rx; Tue, 26 Mar 2013 23:07:53 +0400 Message-ID: <5151F12B.8070101@FreeBSD.org> Date: Tue, 26 Mar 2013 23:04:11 +0400 From: "Alexander V. Chernikov" User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: Re: svn commit: r248743 - stable/9/sys/net References: <201303261857.r2QIvPHt070640@svn.freebsd.org> In-Reply-To: <201303261857.r2QIvPHt070640@svn.freebsd.org> X-Enigmail-Version: 1.4.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 19:04:26 -0000 On 26.03.2013 22:57, Alexander V. Chernikov wrote: > Author: melifaro > Date: Tue Mar 26 18:57:25 2013 > New Revision: 248743 > URL: http://svnweb.freebsd.org/changeset/base/248743 > > Log: Merge r238492. > Permit changing MTU in 6to4 relay. > > This behavior is recommended by RFC 4213 clause 3.2. > > Sometimes fragmentation is the least evil. > For example, some Linux IPVS kernels forwards > ICMPv6 checksums to real servers incorrectly. > > Modified: > stable/9/sys/net/if_stf.c > Directory Properties: > stable/9/sys/ (props changed) > stable/9/sys/net/ (props changed) > > Modified: stable/9/sys/net/if_stf.c > ============================================================================== > --- stable/9/sys/net/if_stf.c Tue Mar 26 18:46:40 2013 (r248742) > +++ stable/9/sys/net/if_stf.c Tue Mar 26 18:57:25 2013 (r248743) > @@ -799,7 +799,7 @@ stf_rtrequest(cmd, rt, info) > struct rt_addrinfo *info; > { > RT_LOCK_ASSERT(rt); > - rt->rt_rmx.rmx_mtu = IPV6_MMTU; > + rt->rt_rmx.rmx_mtu = rt->rt_ifp->if_mtu; > } > > static int > @@ -812,7 +812,7 @@ stf_ioctl(ifp, cmd, data) > struct ifreq *ifr; > struct sockaddr_in6 *sin6; > struct in_addr addr; > - int error; > + int error, mtu; > > error = 0; > switch (cmd) { > @@ -846,6 +846,18 @@ stf_ioctl(ifp, cmd, data) > error = EAFNOSUPPORT; > break; > > + case SIOCGIFMTU: > + break; > + > + case SIOCSIFMTU: > + ifr = (struct ifreq *)data; > + mtu = ifr->ifr_mtu; > + /* RFC 4213 3.2 ideal world MTU */ > + if (mtu < IPV6_MINMTU || mtu > IF_MAXMTU - 20) > + return (EINVAL); > + ifp->if_mtu = mtu; > + break; > + > default: > error = EINVAL; > break; > -- WBR, Alexander From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 19:43:19 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 9B388638; Tue, 26 Mar 2013 19:43:19 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 8D3B29B1; Tue, 26 Mar 2013 19:43:19 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QJhJ6C085343; Tue, 26 Mar 2013 19:43:19 GMT (envelope-from markj@svn.freebsd.org) Received: (from markj@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QJhJKt085341; Tue, 26 Mar 2013 19:43:19 GMT (envelope-from markj@svn.freebsd.org) Message-Id: <201303261943.r2QJhJKt085341@svn.freebsd.org> From: Mark Johnston Date: Tue, 26 Mar 2013 19:43:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248744 - head/usr.sbin/watchdogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 19:43:19 -0000 Author: markj Date: Tue Mar 26 19:43:18 2013 New Revision: 248744 URL: http://svnweb.freebsd.org/changeset/base/248744 Log: Invert the meaning of -S (added in r247405) and document its meaning. Also, don't carp about the watchdog command taking too long until after the watchdog has been patted, and don't carp via warnx(3) unless -S is set since syslog(3) already logs to standard error otherwise. Discussed with: alfred Reviewed by: alfred Approved by: emaste (co-mentor) Modified: head/usr.sbin/watchdogd/watchdogd.8 head/usr.sbin/watchdogd/watchdogd.c Modified: head/usr.sbin/watchdogd/watchdogd.8 ============================================================================== --- head/usr.sbin/watchdogd/watchdogd.8 Tue Mar 26 18:57:25 2013 (r248743) +++ head/usr.sbin/watchdogd/watchdogd.8 Tue Mar 26 19:43:18 2013 (r248744) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 2, 2013 +.Dd March 5, 2013 .Dt WATCHDOGD 8 .Os .Sh NAME @@ -35,7 +35,7 @@ .Nd watchdog daemon .Sh SYNOPSIS .Nm -.Op Fl dnw +.Op Fl dnSw .Op Fl -debug .Op Fl -softtimeout .Op Fl -softtimeout-action Ar action @@ -126,6 +126,12 @@ When this option is specified, .Nm will not fork into the background at startup. .Pp +.It Fl S +Do not send a message to the system logger when the watchdog command takes +longer than expected to execute. +The default behaviour is to log a warning via the system logger with the +LOG_DAEMON facility, and to output a warning to standard error. +.Pp .It Fl w Complain when the watchdog script takes too long. This flag will cause watchdogd to complain when the amount of time to Modified: head/usr.sbin/watchdogd/watchdogd.c ============================================================================== --- head/usr.sbin/watchdogd/watchdogd.c Tue Mar 26 18:57:25 2013 (r248743) +++ head/usr.sbin/watchdogd/watchdogd.c Tue Mar 26 19:43:18 2013 (r248744) @@ -77,7 +77,7 @@ static int is_dry_run = 0; /* do not ar report on timing of the watch program */ static int do_timedog = 0; -static int do_syslog = 0; +static int do_syslog = 1; static int fd = -1; static int nap = 1; static int carp_thresh_seconds = -1; @@ -125,12 +125,10 @@ main(int argc, char *argv[]) parseargs(argc, argv); - if (do_syslog) { + if (do_syslog) openlog("watchdogd", LOG_CONS|LOG_NDELAY|LOG_PERROR, LOG_DAEMON); - } - rtp.type = RTP_PRIO_REALTIME; rtp.prio = 0; if (rtprio(RTP_SET, 0, &rtp) == -1) @@ -234,8 +232,9 @@ static long watchdog_check_dogfunction_time(struct timespec *tp_start, struct timespec *tp_end) { - struct timeval tv_start, tv_end, tv; + struct timeval tv_start, tv_end, tv_now, tv; const char *cmd_prefix, *cmd; + struct timespec tp_now; int sec; if (!do_timedog) @@ -257,16 +256,28 @@ watchdog_check_dogfunction_time(struct t } if (do_syslog) syslog(LOG_CRIT, "%s: '%s' took too long: " - "%d.%06ld seconds >= %d seconds threshhold", + "%d.%06ld seconds >= %d seconds threshold", cmd_prefix, cmd, sec, (long)tv.tv_usec, carp_thresh_seconds); - warnx("%s: '%s' took too long: " - "%d.%06ld seconds >= %d seconds threshhold", - cmd_prefix, cmd, sec, (long)tv.tv_usec, carp_thresh_seconds); + else + warnx("%s: '%s' took too long: " + "%d.%06ld seconds >= %d seconds threshold", + cmd_prefix, cmd, sec, (long)tv.tv_usec, + carp_thresh_seconds); + + /* + * Adjust the sleep interval again in case syslog(3) took a non-trivial + * amount of time to run. + */ + if (watchdog_getuptime(&tp_now)) + return (sec); + TIMESPEC_TO_TIMEVAL(&tv_now, &tp_now); + timersub(&tv_now, &tv_start, &tv); + sec = tv.tv_sec; + return (sec); } - /* * Main program loop which is iterated every second. */ @@ -298,10 +309,10 @@ watchdog_loop(void) goto try_end; } - waited = watchdog_check_dogfunction_time(&ts_start, &ts_end); - if (failed == 0) watchdog_patpat(timeout|WD_ACTIVE); + + waited = watchdog_check_dogfunction_time(&ts_start, &ts_end); if (nap - waited > 0) sleep(nap - waited); @@ -404,7 +415,7 @@ usage(void) { if (is_daemon) fprintf(stderr, "usage:\n" -" watchdogd [-dnw] [-e cmd] [-I file] [-s sleep] [-t timeout]\n" +" watchdogd [-dnSw] [-e cmd] [-I file] [-s sleep] [-t timeout]\n" " [-T script_timeout]\n" " [--debug]\n" " [--pretimeout seconds] [-pretimeout-action action]\n" @@ -551,7 +562,7 @@ parseargs(int argc, char *argv[]) nap = fetchtimeout(c, NULL, optarg); break; case 'S': - do_syslog = 1; + do_syslog = 0; break; case 't': p = NULL; From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 19:46:52 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 2F19582D; Tue, 26 Mar 2013 19:46:52 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 210399EA; Tue, 26 Mar 2013 19:46:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QJkqYi085880; Tue, 26 Mar 2013 19:46:52 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QJkpSI085877; Tue, 26 Mar 2013 19:46:51 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201303261946.r2QJkpSI085877@svn.freebsd.org> From: Adrian Chadd Date: Tue, 26 Mar 2013 19:46:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248745 - head/sys/dev/ath X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 19:46:52 -0000 Author: adrian Date: Tue Mar 26 19:46:51 2013 New Revision: 248745 URL: http://svnweb.freebsd.org/changeset/base/248745 Log: Add per-TXQ EDMA FIFO staging queue support. Each set of frames pushed into a FIFO is represented by a list of ath_bufs - the first ath_buf in the FIFO list is marked with ATH_BUF_FIFOPTR; the last ath_buf in the FIFO list is marked with ATH_BUF_FIFOEND. Multiple lists of frames are just glued together in the TAILQ as per normal - except that at the end of a FIFO list, the descriptor link pointer will be NULL and it'll be tagged with ATH_BUF_FIFOEND. For non-EDMA chipsets this is a no-op - the ath_txq frame list (axq_q) stays the same and is treated the same. For EDMA chipsets the frames are pushed into axq_q and then when the FIFO is to be (re) filled, frames will be moved onto the FIFO queue and then pushed into the FIFO. So: * Add a new queue in each hardware TXQ (ath_txq) for staging FIFO frame lists. It's a TAILQ (like the normal hardware frame queue) rather than the ath9k list-of-lists to represent FIFO entries. * Add new ath_buf flags - ATH_TX_FIFOPTR and ATH_TX_FIFOEND. * When allocating ath_buf entries, clear out the flag value before returning it or it'll end up having stale flags. * When cloning ath_buf entries, only clone ATH_BUF_MGMT. Don't clone the FIFO related flags. * Extend ath_tx_draintxq() to first drain the FIFO staging queue, _then_ drain the normal hardware queue. Tested: * AR9280, hostap * AR9280, STA * AR9380/AR9580 - hostap TODO: * Test on other chipsets, just to be thorough. Modified: head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_ath_misc.h head/sys/dev/ath/if_athvar.h Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Tue Mar 26 19:43:18 2013 (r248744) +++ head/sys/dev/ath/if_ath.c Tue Mar 26 19:46:51 2013 (r248745) @@ -2474,6 +2474,7 @@ _ath_getbuf_locked(struct ath_softc *sc, /* XXX TODO: should do this at buffer list initialisation */ /* XXX (then, ensure the buffer has the right flag set) */ + bf->bf_flags = 0; if (btype == ATH_BUFTYPE_MGMT) bf->bf_flags |= ATH_BUF_MGMT; else @@ -2530,7 +2531,7 @@ ath_buf_clone(struct ath_softc *sc, cons /* Copy basics */ tbf->bf_next = NULL; tbf->bf_nseg = bf->bf_nseg; - tbf->bf_flags = bf->bf_flags & ~ATH_BUF_BUSY; + tbf->bf_flags = bf->bf_flags & ATH_BUF_FLAGS_CLONE; tbf->bf_status = bf->bf_status; tbf->bf_m = bf->bf_m; /* @@ -3410,6 +3411,7 @@ ath_txq_init(struct ath_softc *sc, struc txq->axq_softc = sc; TAILQ_INIT(&txq->axq_q); TAILQ_INIT(&txq->axq_tidq); + TAILQ_INIT(&txq->fifo.axq_q); ATH_TXQ_LOCK_INIT(sc, txq); } @@ -4169,7 +4171,7 @@ ath_returnbuf_head(struct ath_softc *sc, /* * Free the holding buffer if it exists */ -static void +void ath_txq_freeholdingbuf(struct ath_softc *sc, struct ath_txq *txq) { ATH_TXBUF_LOCK_ASSERT(sc); @@ -4283,6 +4285,61 @@ ath_tx_freebuf(struct ath_softc *sc, str */ } +static struct ath_buf * +ath_tx_draintxq_get_one(struct ath_softc *sc, struct ath_txq *txq) +{ + struct ath_buf *bf; + + ATH_TXQ_LOCK_ASSERT(txq); + + /* + * Drain the FIFO queue first, then if it's + * empty, move to the normal frame queue. + */ + bf = TAILQ_FIRST(&txq->fifo.axq_q); + if (bf != NULL) { + /* + * Is it the last buffer in this set? + * Decrement the FIFO counter. + */ + if (bf->bf_flags & ATH_BUF_FIFOEND) { + if (txq->axq_fifo_depth == 0) { + device_printf(sc->sc_dev, + "%s: Q%d: fifo_depth=0, fifo.axq_depth=%d?\n", + __func__, + txq->axq_qnum, + txq->fifo.axq_depth); + } else + txq->axq_fifo_depth--; + } + ATH_TXQ_REMOVE(&txq->fifo, bf, bf_list); + return (bf); + } + + /* + * Debugging! + */ + if (txq->axq_fifo_depth != 0 || txq->fifo.axq_depth != 0) { + device_printf(sc->sc_dev, + "%s: Q%d: fifo_depth=%d, fifo.axq_depth=%d\n", + __func__, + txq->axq_qnum, + txq->axq_fifo_depth, + txq->fifo.axq_depth); + } + + /* + * Now drain the pending queue. + */ + bf = TAILQ_FIRST(&txq->axq_q); + if (bf == NULL) { + txq->axq_link = NULL; + return (NULL); + } + ATH_TXQ_REMOVE(txq, bf, bf_list); + return (bf); +} + void ath_tx_draintxq(struct ath_softc *sc, struct ath_txq *txq) { @@ -4298,24 +4355,11 @@ ath_tx_draintxq(struct ath_softc *sc, st */ for (ix = 0;; ix++) { ATH_TXQ_LOCK(txq); - bf = TAILQ_FIRST(&txq->axq_q); + bf = ath_tx_draintxq_get_one(sc, txq); if (bf == NULL) { - txq->axq_link = NULL; - /* - * There's currently no flag that indicates - * a buffer is on the FIFO. So until that - * occurs, just clear the FIFO counter here. - * - * Yes, this means that if something in parallel - * is pushing things onto this TXQ and pushing - * _that_ into the hardware, things will get - * very fruity very quickly. - */ - txq->axq_fifo_depth = 0; ATH_TXQ_UNLOCK(txq); break; } - ATH_TXQ_REMOVE(txq, bf, bf_list); if (bf->bf_state.bfs_aggr) txq->axq_aggr_depth--; #ifdef ATH_DEBUG Modified: head/sys/dev/ath/if_ath_misc.h ============================================================================== --- head/sys/dev/ath/if_ath_misc.h Tue Mar 26 19:43:18 2013 (r248744) +++ head/sys/dev/ath/if_ath_misc.h Tue Mar 26 19:46:51 2013 (r248745) @@ -77,6 +77,8 @@ extern int ath_hal_gethangstate(struct a extern void ath_tx_freebuf(struct ath_softc *sc, struct ath_buf *bf, int status); +extern void ath_txq_freeholdingbuf(struct ath_softc *sc, + struct ath_txq *txq); extern void ath_txqmove(struct ath_txq *dst, struct ath_txq *src); Modified: head/sys/dev/ath/if_athvar.h ============================================================================== --- head/sys/dev/ath/if_athvar.h Tue Mar 26 19:43:18 2013 (r248744) +++ head/sys/dev/ath/if_athvar.h Tue Mar 26 19:46:51 2013 (r248745) @@ -291,6 +291,10 @@ typedef TAILQ_HEAD(ath_bufhead_s, ath_bu #define ATH_BUF_MGMT 0x00000001 /* (tx) desc is a mgmt desc */ #define ATH_BUF_BUSY 0x00000002 /* (tx) desc owned by h/w */ +#define ATH_BUF_FIFOEND 0x00000004 +#define ATH_BUF_FIFOPTR 0x00000008 + +#define ATH_BUF_FLAGS_CLONE (ATH_BUF_MGMT) /* * DMA state for tx/rx descriptors. @@ -325,13 +329,30 @@ struct ath_txq { #define ATH_TXQ_PUTPENDING 0x0001 /* ath_hal_puttxbuf pending */ u_int axq_depth; /* queue depth (stat only) */ u_int axq_aggr_depth; /* how many aggregates are queued */ - u_int axq_fifo_depth; /* depth of FIFO frames */ u_int axq_intrcnt; /* interrupt count */ u_int32_t *axq_link; /* link ptr in last TX desc */ TAILQ_HEAD(axq_q_s, ath_buf) axq_q; /* transmit queue */ struct mtx axq_lock; /* lock on q and link */ /* + * This is the FIFO staging buffer when doing EDMA. + * + * For legacy chips, we just push the head pointer to + * the hardware and we ignore this list. + * + * For EDMA, the staging buffer is treated as normal; + * when it's time to push a list of frames to the hardware + * we move that list here and we stamp buffers with + * flags to identify the beginning/end of that particular + * FIFO entry. + */ + struct { + TAILQ_HEAD(axq_q_f_s, ath_buf) axq_q; + u_int axq_depth; + } fifo; + u_int axq_fifo_depth; /* depth of FIFO frames */ + + /* * XXX the holdingbf field is protected by the TXBUF lock * for now, NOT the TXQ lock. * From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 19:50:48 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 9E4729F5; Tue, 26 Mar 2013 19:50:48 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 823B7A13; Tue, 26 Mar 2013 19:50:48 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QJomii086594; Tue, 26 Mar 2013 19:50:48 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QJol0s086585; Tue, 26 Mar 2013 19:50:47 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303261950.r2QJol0s086585@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 19:50:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248746 - in head: sbin/nvmecontrol sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 19:50:48 -0000 Author: jimharris Date: Tue Mar 26 19:50:46 2013 New Revision: 248746 URL: http://svnweb.freebsd.org/changeset/base/248746 Log: Add controller reset capability to nvme(4) and ability to explicitly invoke it from nvmecontrol(8). Controller reset will be performed in cases where I/O are repeatedly timing out, the controller reports an unrecoverable condition, or when explicitly requested via IOCTL or an nvme consumer. Since the controller may be in such a state where it cannot even process queue deletion requests, we will perform a controller reset without trying to clean up anything on the controller first. Sponsored by: Intel Reviewed by: carl Modified: head/sbin/nvmecontrol/nvmecontrol.8 head/sbin/nvmecontrol/nvmecontrol.c head/sys/dev/nvme/nvme.c head/sys/dev/nvme/nvme.h head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_ns.c head/sys/dev/nvme/nvme_private.h head/sys/dev/nvme/nvme_qpair.c Modified: head/sbin/nvmecontrol/nvmecontrol.8 ============================================================================== --- head/sbin/nvmecontrol/nvmecontrol.8 Tue Mar 26 19:46:51 2013 (r248745) +++ head/sbin/nvmecontrol/nvmecontrol.8 Tue Mar 26 19:50:46 2013 (r248746) @@ -33,7 +33,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 17, 2012 +.Dd March 26, 2013 .Dt NVMECONTROL 8 .Os .Sh NAME @@ -54,7 +54,10 @@ .Op Fl p .Aq Fl s Ar size_in_bytes .Aq Fl t Ar time_in_sec -.Aq device id +.Aq namespace id +.Nm +.Ic reset +.Aq controller id .Sh DESCRIPTION NVM Express (NVMe) is a storage protocol standard, for SSDs and other high-speed storage devices over PCI Express. @@ -62,6 +65,7 @@ high-speed storage devices over PCI Expr .Dl nvmecontrol devlist .Pp Display a list of NVMe controllers and namespaces along with their device nodes. +.Pp .Dl nvmecontrol identify nvme0 .Pp Display a human-readable summary of the nvme0 IDENTIFY_CONTROLLER data. @@ -76,6 +80,10 @@ Display a hexadecimal dump of the nvme0 Run a performance test on nvme0ns1 using 32 kernel threads for 30 seconds. Each thread will issue a single 512 byte read command. Results are printed to stdout when 30 seconds expires. +.Pp +.Dl nvmecontrol reset nvme0 +.Pp +Perform a controller-level reset of the nvme0 controller. .Sh AUTHORS .An -nosplit .Nm Modified: head/sbin/nvmecontrol/nvmecontrol.c ============================================================================== --- head/sbin/nvmecontrol/nvmecontrol.c Tue Mar 26 19:46:51 2013 (r248745) +++ head/sbin/nvmecontrol/nvmecontrol.c Tue Mar 26 19:50:46 2013 (r248746) @@ -56,6 +56,9 @@ __FBSDID("$FreeBSD$"); " <-i intr|wait> [-f refthread] [-p]\n" \ " \n" +#define RESET_USAGE \ +" nvmecontrol reset \n" + static void perftest_usage(void); static void @@ -64,6 +67,7 @@ usage(void) fprintf(stderr, "usage:\n"); fprintf(stderr, DEVLIST_USAGE); fprintf(stderr, IDENTIFY_USAGE); + fprintf(stderr, RESET_USAGE); fprintf(stderr, PERFTEST_USAGE); exit(EX_USAGE); } @@ -580,6 +584,41 @@ perftest(int argc, char *argv[]) exit(EX_OK); } +static void +reset_ctrlr(int argc, char *argv[]) +{ + struct stat devstat; + char path[64]; + int ch, fd; + + while ((ch = getopt(argc, argv, "")) != -1) { + switch ((char)ch) { + default: + usage(); + } + } + + sprintf(path, "/dev/%s", argv[optind]); + + if (stat(path, &devstat) != 0) { + printf("Invalid device node '%s'.\n", path); + exit(EX_IOERR); + } + + fd = open(path, O_RDWR); + if (fd < 0) { + printf("Could not open %s.\n", path); + exit(EX_NOPERM); + } + + if (ioctl(fd, NVME_RESET_CONTROLLER) == -1) { + printf("ioctl to %s failed.\n", path); + exit(EX_IOERR); + } + + exit(EX_OK); +} + int main(int argc, char *argv[]) { @@ -593,6 +632,8 @@ main(int argc, char *argv[]) identify(argc-1, &argv[1]); else if (strcmp(argv[1], "perftest") == 0) perftest(argc-1, &argv[1]); + else if (strcmp(argv[1], "reset") == 0) + reset_ctrlr(argc-1, &argv[1]); usage(); Modified: head/sys/dev/nvme/nvme.c ============================================================================== --- head/sys/dev/nvme/nvme.c Tue Mar 26 19:46:51 2013 (r248745) +++ head/sys/dev/nvme/nvme.c Tue Mar 26 19:50:46 2013 (r248746) @@ -255,7 +255,7 @@ nvme_payload_map(void *arg, bus_dma_segm } } - nvme_qpair_submit_cmd(tr->qpair, tr); + nvme_qpair_submit_tracker(tr->qpair, tr); } static int @@ -274,11 +274,11 @@ nvme_attach(device_t dev) * to cc.en==0. This is because we don't really know what status * the controller was left in when boot handed off to OS. */ - status = nvme_ctrlr_reset(ctrlr); + status = nvme_ctrlr_hw_reset(ctrlr); if (status != 0) return (status); - status = nvme_ctrlr_reset(ctrlr); + status = nvme_ctrlr_hw_reset(ctrlr); if (status != 0) return (status); Modified: head/sys/dev/nvme/nvme.h ============================================================================== --- head/sys/dev/nvme/nvme.h Tue Mar 26 19:46:51 2013 (r248745) +++ head/sys/dev/nvme/nvme.h Tue Mar 26 19:50:46 2013 (r248746) @@ -37,6 +37,7 @@ #define NVME_IDENTIFY_NAMESPACE _IOR('n', 1, struct nvme_namespace_data) #define NVME_IO_TEST _IOWR('n', 2, struct nvme_io_test) #define NVME_BIO_TEST _IOWR('n', 4, struct nvme_io_test) +#define NVME_RESET_CONTROLLER _IO('n', 5) /* * Use to mark a command to apply to all namespaces, or to retrieve global Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 19:46:51 2013 (r248745) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 19:50:46 2013 (r248746) @@ -405,13 +405,31 @@ nvme_ctrlr_enable(struct nvme_controller } int -nvme_ctrlr_reset(struct nvme_controller *ctrlr) +nvme_ctrlr_hw_reset(struct nvme_controller *ctrlr) { + int i; + + nvme_admin_qpair_disable(&ctrlr->adminq); + for (i = 0; i < ctrlr->num_io_queues; i++) + nvme_io_qpair_disable(&ctrlr->ioq[i]); + + DELAY(100*1000); nvme_ctrlr_disable(ctrlr); return (nvme_ctrlr_enable(ctrlr)); } +void +nvme_ctrlr_reset(struct nvme_controller *ctrlr) +{ + int status; + + status = nvme_ctrlr_hw_reset(ctrlr); + DELAY(100*1000); + if (status == 0) + nvme_ctrlr_start(ctrlr); +} + static int nvme_ctrlr_identify(struct nvme_controller *ctrlr) { @@ -626,6 +644,9 @@ void nvme_ctrlr_start(void *ctrlr_arg) { struct nvme_controller *ctrlr = ctrlr_arg; + int i; + + nvme_admin_qpair_enable(&ctrlr->adminq); if (nvme_ctrlr_identify(ctrlr) != 0) goto err; @@ -642,16 +663,26 @@ nvme_ctrlr_start(void *ctrlr_arg) nvme_ctrlr_configure_aer(ctrlr); nvme_ctrlr_configure_int_coalescing(ctrlr); + for (i = 0; i < ctrlr->num_io_queues; i++) + nvme_io_qpair_enable(&ctrlr->ioq[i]); + ctrlr->is_started = TRUE; err: - /* - * Initialize sysctls, even if controller failed to start, to - * assist with debugging admin queue pair. - */ - nvme_sysctl_initialize_ctrlr(ctrlr); - config_intrhook_disestablish(&ctrlr->config_hook); + if (ctrlr->num_start_attempts == 0) { + /* + * Initialize sysctls, even if controller failed to start, to + * assist with debugging admin queue pair. Only run this + * code on the initial start attempt though, and not + * subsequent start attempts due to controller-level resets. + * + */ + nvme_sysctl_initialize_ctrlr(ctrlr); + config_intrhook_disestablish(&ctrlr->config_hook); + } + + ctrlr->num_start_attempts++; } static void @@ -730,6 +761,9 @@ nvme_ctrlr_ioctl(struct cdev *cdev, u_lo return (ENXIO); memcpy(arg, &ctrlr->cdata, sizeof(ctrlr->cdata)); break; + case NVME_RESET_CONTROLLER: + nvme_ctrlr_reset(ctrlr); + break; default: return (ENOTTY); } @@ -752,6 +786,7 @@ nvme_ctrlr_construct(struct nvme_control ctrlr->dev = dev; ctrlr->is_started = FALSE; + ctrlr->num_start_attempts = 0; status = nvme_ctrlr_allocate_bar(ctrlr); @@ -835,14 +870,10 @@ intx: void nvme_ctrlr_destruct(struct nvme_controller *ctrlr, device_t dev) { - struct nvme_namespace *ns; int i; - for (i = 0; i < NVME_MAX_NAMESPACES; i++) { - ns = &ctrlr->ns[i]; - if (ns->cdev) - destroy_dev(ns->cdev); - } + for (i = 0; i < NVME_MAX_NAMESPACES; i++) + nvme_ns_destruct(&ctrlr->ns[i]); if (ctrlr->cdev) destroy_dev(ctrlr->cdev); @@ -853,13 +884,6 @@ nvme_ctrlr_destruct(struct nvme_controll free(ctrlr->ioq, M_NVME); - /* Manually abort outstanding async event requests. */ - for (i = 0; i < ctrlr->num_aers; i++) { - nvme_qpair_manual_abort_request(&ctrlr->adminq, - ctrlr->aer[i].req, NVME_SCT_GENERIC, - NVME_SC_ABORTED_SQ_DELETION, FALSE); - } - nvme_admin_qpair_destroy(&ctrlr->adminq); if (ctrlr->resource != NULL) { Modified: head/sys/dev/nvme/nvme_ns.c ============================================================================== --- head/sys/dev/nvme/nvme_ns.c Tue Mar 26 19:46:51 2013 (r248745) +++ head/sys/dev/nvme/nvme_ns.c Tue Mar 26 19:50:46 2013 (r248746) @@ -345,6 +345,13 @@ nvme_ns_construct(struct nvme_namespace if (ctrlr->cdata.vwc.present) ns->flags |= NVME_NS_FLUSH_SUPPORTED; + /* + * cdev may have already been created, if we are reconstructing the + * namespace after a controller-level reset. + */ + if (ns->cdev != NULL) + return (0); + /* * MAKEDEV_ETERNAL was added in r210923, for cdevs that will never * be destroyed. This avoids refcounting on the cdev object. @@ -361,9 +368,15 @@ nvme_ns_construct(struct nvme_namespace device_get_unit(ctrlr->dev), ns->id); #endif - if (ns->cdev) { + if (ns->cdev != NULL) ns->cdev->si_drv1 = ns; - } return (0); } + +void nvme_ns_destruct(struct nvme_namespace *ns) +{ + + if (ns->cdev != NULL) + destroy_dev(ns->cdev); +} Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 19:46:51 2013 (r248745) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 19:50:46 2013 (r248746) @@ -180,6 +180,8 @@ struct nvme_qpair { struct nvme_tracker **act_tr; + boolean_t is_enabled; + struct mtx lock __aligned(CACHE_LINE_SIZE); } __aligned(CACHE_LINE_SIZE); @@ -233,6 +235,7 @@ struct nvme_controller { struct intr_config_hook config_hook; uint32_t ns_identified; uint32_t queues_created; + uint32_t num_start_attempts; /* For shared legacy interrupt. */ int rid; @@ -361,7 +364,8 @@ void nvme_payload_map_uio(void *arg, bus int nvme_ctrlr_construct(struct nvme_controller *ctrlr, device_t dev); void nvme_ctrlr_destruct(struct nvme_controller *ctrlr, device_t dev); -int nvme_ctrlr_reset(struct nvme_controller *ctrlr); +int nvme_ctrlr_hw_reset(struct nvme_controller *ctrlr); +void nvme_ctrlr_reset(struct nvme_controller *ctrlr); /* ctrlr defined as void * to allow use with config_intrhook. */ void nvme_ctrlr_start(void *ctrlr_arg); void nvme_ctrlr_submit_admin_request(struct nvme_controller *ctrlr, @@ -373,21 +377,23 @@ void nvme_qpair_construct(struct nvme_qp uint16_t vector, uint32_t num_entries, uint32_t num_trackers, uint32_t max_xfer_size, struct nvme_controller *ctrlr); -void nvme_qpair_submit_cmd(struct nvme_qpair *qpair, - struct nvme_tracker *tr); +void nvme_qpair_submit_tracker(struct nvme_qpair *qpair, + struct nvme_tracker *tr); void nvme_qpair_process_completions(struct nvme_qpair *qpair); void nvme_qpair_submit_request(struct nvme_qpair *qpair, struct nvme_request *req); -void nvme_qpair_manual_abort_request(struct nvme_qpair *qpair, - struct nvme_request *req, uint32_t sct, - uint32_t sc, boolean_t print_on_error); +void nvme_admin_qpair_enable(struct nvme_qpair *qpair); +void nvme_admin_qpair_disable(struct nvme_qpair *qpair); void nvme_admin_qpair_destroy(struct nvme_qpair *qpair); +void nvme_io_qpair_enable(struct nvme_qpair *qpair); +void nvme_io_qpair_disable(struct nvme_qpair *qpair); void nvme_io_qpair_destroy(struct nvme_qpair *qpair); int nvme_ns_construct(struct nvme_namespace *ns, uint16_t id, struct nvme_controller *ctrlr); +void nvme_ns_destruct(struct nvme_namespace *ns); int nvme_ns_physio(struct cdev *dev, struct uio *uio, int ioflag); Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 19:46:51 2013 (r248745) +++ head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 19:50:46 2013 (r248746) @@ -87,23 +87,6 @@ nvme_completion_is_retry(const struct nv } } -static struct nvme_tracker * -nvme_qpair_find_tracker(struct nvme_qpair *qpair, struct nvme_request *req) -{ - struct nvme_tracker *tr; - uint32_t i; - - KASSERT(req != NULL, ("%s: called with NULL req\n", __func__)); - - for (i = 0; i < qpair->num_entries; ++i) { - tr = qpair->act_tr[i]; - if (tr != NULL && tr->req == req) - return (tr); - } - - return (NULL); -} - static void nvme_qpair_construct_tracker(struct nvme_qpair *qpair, struct nvme_tracker *tr, uint16_t cid) @@ -147,7 +130,7 @@ nvme_qpair_complete_tracker(struct nvme_ callout_stop(&tr->timer); if (retry) - nvme_qpair_submit_cmd(qpair, tr); + nvme_qpair_submit_tracker(qpair, tr); else { if (req->payload_size > 0 || req->uio != NULL) bus_dmamap_unload(qpair->dma_tag, @@ -169,6 +152,21 @@ nvme_qpair_complete_tracker(struct nvme_ mtx_unlock(&qpair->lock); } +static void +nvme_qpair_manual_complete_tracker(struct nvme_qpair *qpair, + struct nvme_tracker *tr, uint32_t sct, uint32_t sc, + boolean_t print_on_error) +{ + struct nvme_completion cpl; + + memset(&cpl, 0, sizeof(cpl)); + cpl.sqid = qpair->id; + cpl.cid = tr->cid; + cpl.sf_sct = sct; + cpl.sf_sc = sc; + nvme_qpair_complete_tracker(qpair, tr, &cpl, print_on_error); +} + void nvme_qpair_process_completions(struct nvme_qpair *qpair) { @@ -177,6 +175,15 @@ nvme_qpair_process_completions(struct nv qpair->num_intr_handler_calls++; + if (!qpair->is_enabled) + /* + * qpair is not enabled, likely because a controller reset is + * is in progress. Ignore the interrupt - any I/O that was + * associated with this interrupt will get retried when the + * reset is complete. + */ + return; + while (1) { cpl = &qpair->cpl[qpair->cq_head]; @@ -236,15 +243,6 @@ nvme_qpair_construct(struct nvme_qpair * qpair->max_xfer_size = max_xfer_size; qpair->ctrlr = ctrlr; - /* - * First time through the completion queue, HW will set phase - * bit on completions to 1. So set this to 1 here, indicating - * we're looking for a 1 to know which entries have completed. - * we'll toggle the bit each time when the completion queue - * rolls over. - */ - qpair->phase = 1; - if (ctrlr->msix_enabled) { /* @@ -271,7 +269,6 @@ nvme_qpair_construct(struct nvme_qpair * qpair->num_cmds = 0; qpair->num_intr_handler_calls = 0; - qpair->sq_head = qpair->sq_tail = qpair->cq_head = 0; /* TODO: error checking on contigmalloc, bus_dmamap_load calls */ qpair->cmd = contigmalloc(qpair->num_entries * @@ -341,10 +338,30 @@ nvme_qpair_destroy(struct nvme_qpair *qp } } +static void +nvme_admin_qpair_abort_aers(struct nvme_qpair *qpair) +{ + struct nvme_tracker *tr; + + tr = TAILQ_FIRST(&qpair->outstanding_tr); + while (tr != NULL) { + if (tr->req->cmd.opc == NVME_OPC_ASYNC_EVENT_REQUEST) { + nvme_qpair_manual_complete_tracker(qpair, tr, + NVME_SCT_GENERIC, NVME_SC_ABORTED_SQ_DELETION, + FALSE); + tr = TAILQ_FIRST(&qpair->outstanding_tr); + } else { + tr = TAILQ_NEXT(tr, tailq); + } + } +} + void nvme_admin_qpair_destroy(struct nvme_qpair *qpair) { + nvme_admin_qpair_abort_aers(qpair); + /* * For NVMe, you don't send delete queue commands for the admin * queue, so we just need to unload and free the cmd and cpl memory. @@ -413,39 +430,6 @@ nvme_io_qpair_destroy(struct nvme_qpair } static void -nvme_qpair_manual_abort_tracker(struct nvme_qpair *qpair, - struct nvme_tracker *tr, uint32_t sct, uint32_t sc, - boolean_t print_on_error) -{ - struct nvme_completion cpl; - - memset(&cpl, 0, sizeof(cpl)); - cpl.sqid = qpair->id; - cpl.cid = tr->cid; - cpl.sf_sct = sct; - cpl.sf_sc = sc; - nvme_qpair_complete_tracker(qpair, tr, &cpl, print_on_error); -} - -void -nvme_qpair_manual_abort_request(struct nvme_qpair *qpair, - struct nvme_request *req, uint32_t sct, uint32_t sc, - boolean_t print_on_error) -{ - struct nvme_tracker *tr; - - tr = nvme_qpair_find_tracker(qpair, req); - - if (tr == NULL) { - printf("%s: request not found\n", __func__); - nvme_dump_command(&req->cmd); - return; - } - - nvme_qpair_manual_abort_tracker(qpair, tr, sct, sc, print_on_error); -} - -static void nvme_abort_complete(void *arg, const struct nvme_completion *status) { struct nvme_tracker *tr = arg; @@ -463,7 +447,7 @@ nvme_abort_complete(void *arg, const str * status, and then complete the I/O's tracker manually. */ printf("abort command failed, aborting command manually\n"); - nvme_qpair_manual_abort_tracker(tr->qpair, tr, + nvme_qpair_manual_complete_tracker(tr->qpair, tr, NVME_SCT_GENERIC, NVME_SC_ABORTED_BY_REQUEST, TRUE); } } @@ -478,10 +462,12 @@ nvme_timeout(void *arg) } void -nvme_qpair_submit_cmd(struct nvme_qpair *qpair, struct nvme_tracker *tr) +nvme_qpair_submit_tracker(struct nvme_qpair *qpair, struct nvme_tracker *tr) { struct nvme_request *req; + mtx_assert(&qpair->lock, MA_OWNED); + req = tr->req; req->cmd.cid = tr->cid; qpair->act_tr[tr->cid] = tr; @@ -517,11 +503,14 @@ _nvme_qpair_submit_request(struct nvme_q tr = TAILQ_FIRST(&qpair->free_tr); - if (tr == NULL) { + if (tr == NULL || !qpair->is_enabled) { /* - * No tracker is available. Put the request on the qpair's - * request queue to be processed when a tracker frees up - * via a command completion. + * No tracker is available, or the qpair is disabled due to + * an in-progress controller-level reset. + * + * Put the request on the qpair's request queue to be processed + * when a tracker frees up via a command completion or when + * the controller reset is completed. */ STAILQ_INSERT_TAIL(&qpair->queued_req, req, stailq); return; @@ -540,7 +529,7 @@ _nvme_qpair_submit_request(struct nvme_q if (err != 0) panic("bus_dmamap_load returned non-zero!\n"); } else - nvme_qpair_submit_cmd(tr->qpair, tr); + nvme_qpair_submit_tracker(tr->qpair, tr); } else { err = bus_dmamap_load_uio(tr->qpair->dma_tag, tr->payload_dma_map, req->uio, @@ -558,3 +547,85 @@ nvme_qpair_submit_request(struct nvme_qp _nvme_qpair_submit_request(qpair, req); mtx_unlock(&qpair->lock); } + +static void +nvme_qpair_enable(struct nvme_qpair *qpair) +{ + + qpair->is_enabled = TRUE; + qpair->sq_head = qpair->sq_tail = qpair->cq_head = 0; + + /* + * First time through the completion queue, HW will set phase + * bit on completions to 1. So set this to 1 here, indicating + * we're looking for a 1 to know which entries have completed. + * we'll toggle the bit each time when the completion queue + * rolls over. + */ + qpair->phase = 1; + + memset(qpair->cmd, 0, + qpair->num_entries * sizeof(struct nvme_command)); + memset(qpair->cpl, 0, + qpair->num_entries * sizeof(struct nvme_completion)); +} + +void +nvme_admin_qpair_enable(struct nvme_qpair *qpair) +{ + + nvme_qpair_enable(qpair); +} + +void +nvme_io_qpair_enable(struct nvme_qpair *qpair) +{ + STAILQ_HEAD(, nvme_request) temp; + struct nvme_tracker *tr; + struct nvme_request *req; + + mtx_lock(&qpair->lock); + + nvme_qpair_enable(qpair); + + TAILQ_FOREACH(tr, &qpair->outstanding_tr, tailq) + nvme_qpair_submit_tracker(qpair, tr); + + STAILQ_INIT(&temp); + STAILQ_SWAP(&qpair->queued_req, &temp, nvme_request); + + while (!STAILQ_EMPTY(&temp)) { + req = STAILQ_FIRST(&temp); + STAILQ_REMOVE_HEAD(&temp, stailq); + _nvme_qpair_submit_request(qpair, req); + } + + mtx_unlock(&qpair->lock); +} + +static void +nvme_qpair_disable(struct nvme_qpair *qpair) +{ + struct nvme_tracker *tr; + + qpair->is_enabled = FALSE; + mtx_lock(&qpair->lock); + TAILQ_FOREACH(tr, &qpair->outstanding_tr, tailq) + callout_stop(&tr->timer); + mtx_unlock(&qpair->lock); +} + +void +nvme_admin_qpair_disable(struct nvme_qpair *qpair) +{ + + nvme_qpair_disable(qpair); + nvme_admin_qpair_abort_aers(qpair); +} + +void +nvme_io_qpair_disable(struct nvme_qpair *qpair) +{ + + nvme_qpair_disable(qpair); +} From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 19:52:58 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D4F70B83; Tue, 26 Mar 2013 19:52:58 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id AF115A27; Tue, 26 Mar 2013 19:52:58 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QJqw7x088328; Tue, 26 Mar 2013 19:52:58 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QJqw3Q088323; Tue, 26 Mar 2013 19:52:58 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303261952.r2QJqw3Q088323@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 19:52:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248747 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 19:52:58 -0000 Author: jimharris Date: Tue Mar 26 19:52:57 2013 New Revision: 248747 URL: http://svnweb.freebsd.org/changeset/base/248747 Log: Add API for nvme consumers to access controller and namespace identify data. Sponsored by: Intel Reviewed by: carl Modified: head/sys/dev/nvme/nvme.h head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_ns.c Modified: head/sys/dev/nvme/nvme.h ============================================================================== --- head/sys/dev/nvme/nvme.h Tue Mar 26 19:50:46 2013 (r248746) +++ head/sys/dev/nvme/nvme.h Tue Mar 26 19:52:57 2013 (r248747) @@ -740,6 +740,8 @@ void nvme_unregister_consumer(struct nv /* Controller helper functions */ device_t nvme_ctrlr_get_device(struct nvme_controller *ctrlr); +const struct nvme_controller_data * + nvme_ctrlr_get_data(struct nvme_controller *ctrlr); /* Namespace helper functions */ uint32_t nvme_ns_get_max_io_xfer_size(struct nvme_namespace *ns); @@ -749,6 +751,8 @@ uint64_t nvme_ns_get_size(struct nvme_na uint32_t nvme_ns_get_flags(struct nvme_namespace *ns); const char * nvme_ns_get_serial_number(struct nvme_namespace *ns); const char * nvme_ns_get_model_number(struct nvme_namespace *ns); +const struct nvme_namespace_data * + nvme_ns_get_data(struct nvme_namespace *ns); int nvme_ns_bio_process(struct nvme_namespace *ns, struct bio *bp, nvme_cb_fn_t cb_fn); Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 19:50:46 2013 (r248746) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 19:52:57 2013 (r248747) @@ -942,3 +942,10 @@ nvme_ctrlr_get_device(struct nvme_contro return (ctrlr->dev); } + +const struct nvme_controller_data * +nvme_ctrlr_get_data(struct nvme_controller *ctrlr) +{ + + return (&ctrlr->cdata); +} Modified: head/sys/dev/nvme/nvme_ns.c ============================================================================== --- head/sys/dev/nvme/nvme_ns.c Tue Mar 26 19:50:46 2013 (r248746) +++ head/sys/dev/nvme/nvme_ns.c Tue Mar 26 19:52:57 2013 (r248747) @@ -221,6 +221,13 @@ nvme_ns_get_model_number(struct nvme_nam return ((const char *)ns->ctrlr->cdata.mn); } +const struct nvme_namespace_data * +nvme_ns_get_data(struct nvme_namespace *ns) +{ + + return (&ns->data); +} + static void nvme_ns_bio_done(void *arg, const struct nvme_completion *status) { From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 19:58:18 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 98FCDE87; Tue, 26 Mar 2013 19:58:18 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 8B84BA7F; Tue, 26 Mar 2013 19:58:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QJwIY9089079; Tue, 26 Mar 2013 19:58:18 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QJwIJW089076; Tue, 26 Mar 2013 19:58:18 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303261958.r2QJwIJW089076@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 19:58:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248748 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 19:58:18 -0000 Author: jimharris Date: Tue Mar 26 19:58:17 2013 New Revision: 248748 URL: http://svnweb.freebsd.org/changeset/base/248748 Log: Add handling for controller fatal status (csts.cfs). On any I/O timeout, check for csts.cfs==1. If set, the controller is reporting fatal status and we reset the controller immediately, rather than trying to abort the timed out command. This changeset also includes deferring the controller start portion of the reset to a separate task. This ensures we are always performing a controller start operation from a consistent context. Sponsored by: Intel Reviewed by: carl Modified: head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_private.h head/sys/dev/nvme/nvme_qpair.c Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 19:52:57 2013 (r248747) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 19:58:17 2013 (r248748) @@ -427,7 +427,7 @@ nvme_ctrlr_reset(struct nvme_controller status = nvme_ctrlr_hw_reset(ctrlr); DELAY(100*1000); if (status == 0) - nvme_ctrlr_start(ctrlr); + taskqueue_enqueue(ctrlr->taskqueue, &ctrlr->restart_task); } static int @@ -686,6 +686,14 @@ err: } static void +nvme_ctrlr_restart_task(void *arg, int pending) +{ + struct nvme_controller *ctrlr = arg; + + nvme_ctrlr_start(ctrlr); +} + +static void nvme_ctrlr_intx_handler(void *arg) { struct nvme_controller *ctrlr = arg; @@ -864,6 +872,11 @@ intx: ctrlr->cdev->si_drv1 = (void *)ctrlr; + TASK_INIT(&ctrlr->restart_task, 0, nvme_ctrlr_restart_task, ctrlr); + ctrlr->taskqueue = taskqueue_create("nvme_taskq", M_WAITOK, + taskqueue_thread_enqueue, &ctrlr->taskqueue); + taskqueue_start_threads(&ctrlr->taskqueue, 1, PI_DISK, "nvme taskq"); + return (0); } @@ -872,6 +885,8 @@ nvme_ctrlr_destruct(struct nvme_controll { int i; + taskqueue_free(ctrlr->taskqueue); + for (i = 0; i < NVME_MAX_NAMESPACES; i++) nvme_ns_destruct(&ctrlr->ns[i]); Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 19:52:57 2013 (r248747) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 19:58:17 2013 (r248748) @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -236,6 +237,8 @@ struct nvme_controller { uint32_t ns_identified; uint32_t queues_created; uint32_t num_start_attempts; + struct task restart_task; + struct taskqueue *taskqueue; /* For shared legacy interrupt. */ int rid; Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 19:52:57 2013 (r248747) +++ head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 19:58:17 2013 (r248748) @@ -98,7 +98,7 @@ nvme_qpair_construct_tracker(struct nvme bus_dmamap_load(qpair->dma_tag, tr->prp_dma_map, tr->prp, sizeof(tr->prp), nvme_single_map, &tr->prp_bus_addr, 0); - callout_init_mtx(&tr->timer, &qpair->lock, 0); + callout_init(&tr->timer, 1); tr->cid = cid; tr->qpair = qpair; } @@ -456,8 +456,24 @@ static void nvme_timeout(void *arg) { struct nvme_tracker *tr = arg; + struct nvme_qpair *qpair = tr->qpair; + struct nvme_controller *ctrlr = qpair->ctrlr; + union csts_register csts; - nvme_ctrlr_cmd_abort(tr->qpair->ctrlr, tr->cid, tr->qpair->id, + csts.raw = nvme_mmio_read_4(ctrlr, csts); + if (csts.bits.cfs == 1) { + /* + * The controller is reporting fatal status. Don't bother + * trying to abort the timed out command - proceed + * immediately to a controller-level reset. + */ + device_printf(ctrlr->dev, + "controller reports fatal status, resetting...\n"); + nvme_ctrlr_reset(ctrlr); + return; + } + + nvme_ctrlr_cmd_abort(ctrlr, tr->cid, qpair->id, nvme_abort_complete, tr); } From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 20:02:37 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 14669124; Tue, 26 Mar 2013 20:02:37 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id EC897AB7; Tue, 26 Mar 2013 20:02:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QK2aTY091510; Tue, 26 Mar 2013 20:02:36 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QK2aRU091502; Tue, 26 Mar 2013 20:02:36 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262002.r2QK2aRU091502@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 20:02:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248749 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 20:02:37 -0000 Author: jimharris Date: Tue Mar 26 20:02:35 2013 New Revision: 248749 URL: http://svnweb.freebsd.org/changeset/base/248749 Log: Add a tunable for the I/O timeout interval. Default is still 30 seconds, but can be adjusted between a min/max of 5 and 120 seconds. Sponsored by: Intel Reviewed by: carl Modified: head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_private.h head/sys/dev/nvme/nvme_qpair.c head/sys/dev/nvme/nvme_sysctl.c Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 19:58:17 2013 (r248748) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 20:02:35 2013 (r248749) @@ -592,10 +592,10 @@ nvme_ctrlr_construct_and_submit_aer(stru aer->req = req; /* - * Override default timeout value here, since asynchronous event - * requests should by nature never be timed out. + * Disable timeout here, since asynchronous event requests should by + * nature never be timed out. */ - req->timeout = 0; + req->timeout = FALSE; req->cmd.opc = NVME_OPC_ASYNC_EVENT_REQUEST; nvme_ctrlr_submit_admin_request(ctrlr, req); } @@ -791,6 +791,7 @@ nvme_ctrlr_construct(struct nvme_control union cap_lo_register cap_lo; union cap_hi_register cap_hi; int num_vectors, per_cpu_io_queues, status = 0; + int timeout_period; ctrlr->dev = dev; ctrlr->is_started = FALSE; @@ -822,6 +823,12 @@ nvme_ctrlr_construct(struct nvme_control cap_lo.raw = nvme_mmio_read_4(ctrlr, cap_lo); ctrlr->ready_timeout_in_ms = cap_lo.bits.to * 500; + timeout_period = NVME_DEFAULT_TIMEOUT_PERIOD; + TUNABLE_INT_FETCH("hw.nvme.timeout_period", &timeout_period); + timeout_period = min(timeout_period, NVME_MAX_TIMEOUT_PERIOD); + timeout_period = max(timeout_period, NVME_MIN_TIMEOUT_PERIOD); + ctrlr->timeout_period = timeout_period; + per_cpu_io_queues = 1; TUNABLE_INT_FETCH("hw.nvme.per_cpu_io_queues", &per_cpu_io_queues); ctrlr->per_cpu_io_queues = per_cpu_io_queues ? TRUE : FALSE; Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 19:58:17 2013 (r248748) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 20:02:35 2013 (r248749) @@ -100,7 +100,9 @@ MALLOC_DECLARE(M_NVME); #define NVME_MAX_CONSUMERS (2) #define NVME_MAX_ASYNC_EVENTS (8) -#define NVME_TIMEOUT_IN_SEC (30) +#define NVME_DEFAULT_TIMEOUT_PERIOD (30) /* in seconds */ +#define NVME_MIN_TIMEOUT_PERIOD (5) +#define NVME_MAX_TIMEOUT_PERIOD (120) #ifndef CACHE_LINE_SIZE #define CACHE_LINE_SIZE (64) @@ -113,7 +115,7 @@ struct nvme_request { struct nvme_command cmd; void *payload; uint32_t payload_size; - uint32_t timeout; + boolean_t timeout; struct uio *uio; nvme_cb_fn_t cb_fn; void *cb_arg; @@ -257,6 +259,9 @@ struct nvme_controller { /** interrupt coalescing threshold */ uint32_t int_coal_threshold; + /** timeout period in seconds */ + uint32_t timeout_period; + struct nvme_qpair adminq; struct nvme_qpair *ioq; @@ -427,7 +432,7 @@ nvme_allocate_request(void *payload, uin req->payload_size = payload_size; req->cb_fn = cb_fn; req->cb_arg = cb_arg; - req->timeout = NVME_TIMEOUT_IN_SEC; + req->timeout = TRUE; return (req); } @@ -444,7 +449,7 @@ nvme_allocate_request_uio(struct uio *ui req->uio = uio; req->cb_fn = cb_fn; req->cb_arg = cb_arg; - req->timeout = NVME_TIMEOUT_IN_SEC; + req->timeout = TRUE; return (req); } Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 19:58:17 2013 (r248748) +++ head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 20:02:35 2013 (r248749) @@ -480,20 +480,23 @@ nvme_timeout(void *arg) void nvme_qpair_submit_tracker(struct nvme_qpair *qpair, struct nvme_tracker *tr) { - struct nvme_request *req; + struct nvme_request *req; + struct nvme_controller *ctrlr; mtx_assert(&qpair->lock, MA_OWNED); req = tr->req; req->cmd.cid = tr->cid; qpair->act_tr[tr->cid] = tr; + ctrlr = qpair->ctrlr; - if (req->timeout > 0) + if (req->timeout) #if __FreeBSD_version >= 800030 - callout_reset_curcpu(&tr->timer, req->timeout * hz, + callout_reset_curcpu(&tr->timer, ctrlr->timeout_period * hz, nvme_timeout, tr); #else - callout_reset(&tr->timer, req->timeout * hz, nvme_timeout, tr); + callout_reset(&tr->timer, ctrlr->timeout_period * hz, + nvme_timeout, tr); #endif /* Copy the command from the tracker to the submission queue. */ Modified: head/sys/dev/nvme/nvme_sysctl.c ============================================================================== --- head/sys/dev/nvme/nvme_sysctl.c Tue Mar 26 19:58:17 2013 (r248748) +++ head/sys/dev/nvme/nvme_sysctl.c Tue Mar 26 20:02:35 2013 (r248749) @@ -123,6 +123,25 @@ nvme_sysctl_int_coal_threshold(SYSCTL_HA return (0); } +static int +nvme_sysctl_timeout_period(SYSCTL_HANDLER_ARGS) +{ + struct nvme_controller *ctrlr = arg1; + uint32_t oldval = ctrlr->timeout_period; + int error = sysctl_handle_int(oidp, &ctrlr->timeout_period, 0, req); + + if (error) + return (error); + + if (ctrlr->timeout_period > NVME_MAX_TIMEOUT_PERIOD || + ctrlr->timeout_period < NVME_MIN_TIMEOUT_PERIOD) { + ctrlr->timeout_period = oldval; + return (EINVAL); + } + + return (0); +} + static void nvme_qpair_reset_stats(struct nvme_qpair *qpair) { @@ -244,6 +263,11 @@ nvme_sysctl_initialize_ctrlr(struct nvme "Interrupt coalescing threshold"); SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, + "timeout_period", CTLTYPE_UINT | CTLFLAG_RW, ctrlr, 0, + nvme_sysctl_timeout_period, "IU", + "Timeout period (in seconds)"); + + SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, "num_cmds", CTLTYPE_S64 | CTLFLAG_RD, ctrlr, 0, nvme_sysctl_num_cmds, "IU", "Number of commands submitted"); From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 20:04:46 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id AF0A92FC; Tue, 26 Mar 2013 20:04:46 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A09C1ADC; Tue, 26 Mar 2013 20:04:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QK4kxH091930; Tue, 26 Mar 2013 20:04:46 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QK4kcU091927; Tue, 26 Mar 2013 20:04:46 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201303262004.r2QK4kcU091927@svn.freebsd.org> From: Adrian Chadd Date: Tue, 26 Mar 2013 20:04:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248750 - head/sys/dev/ath X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 20:04:46 -0000 Author: adrian Date: Tue Mar 26 20:04:45 2013 New Revision: 248750 URL: http://svnweb.freebsd.org/changeset/base/248750 Log: Implement the replacement EDMA FIFO code. (Yes, the previous code temporarily broke EDMA TX. I'm sorry; I should've actually setup ATH_BUF_FIFOEND on frames so txq->axq_fifo_depth was cleared!) This code implements a whole bunch of sorely needed EDMA TX improvements along with CABQ TX support. The specifics: * When filling/refilling the FIFO, use the new TXQ staging queue for FIFO frames * Tag frames with ATH_BUF_FIFOPTR and ATH_BUF_FIFOEND correctly. For now the non-CABQ transmit path pushes one frame into the TXQ staging queue without setting up the intermediary link pointers to chain them together, so draining frames from the txq staging queue to the FIFO queue occurs AMPDU / MPDU at a time. * In the CABQ case, manually tag the list with ATH_BUF_FIFOPTR and ATH_BUF_FIFOEND so a chain of frames is pushed into the FIFO at once. * Now that frames are in a FIFO pending queue, we can top up the FIFO after completing a single frame. This means we can keep it filled rather than waiting for it drain and _then_ adding more frames. * The EDMA restart routine now walks the FIFO queue in the TXQ rather than the pending queue and re-initialises the FIFO with that. * When restarting EDMA, we may have partially completed sending a list. So stamp the first frame that we see in a list with ATH_BUF_FIFOPTR and push _that_ into the hardware. * When completing frames, only check those on the FIFO queue. We should never ever queue frames from the pending queue direct to the hardware, so there's no point in checking. * Until I figure out what's going on, make sure if the TXSTATUS for an empty queue pops up, complain loudly and continue. This will stop the panics that people are seeing. I'll add some code later which will assist in ensuring I'm populating each descriptor with the correct queue ID. * When considering whether to queue frames to the hardware queue directly or software queue frames, make sure the depth of the FIFO is taken into account now. * When completing frames, tag them with ATH_BUF_BUSY if they're not the final frame in a FIFO list. The same holding descriptor behaviour is required when handling descriptors linked together with a link pointer as the hardware will re-read the previous descriptor to refresh the link pointer before contiuning. * .. and if we complete the FIFO list (ie, the buffer has ATH_BUF_FIFOEND set), then we don't need the holding buffer any longer. Thus, free it. Tested: * AR9380/AR9580, STA and hostap * AR9280, STA/hostap TODO: * I don't yet trust that the EDMA restart routine is totally correct in all circumstances. I'll continue to thrash this out under heavy multiple-TXQ traffic load and fix whatever pops up. Modified: head/sys/dev/ath/if_ath_beacon.c head/sys/dev/ath/if_ath_tx.c head/sys/dev/ath/if_ath_tx_edma.c Modified: head/sys/dev/ath/if_ath_beacon.c ============================================================================== --- head/sys/dev/ath/if_ath_beacon.c Tue Mar 26 20:02:35 2013 (r248749) +++ head/sys/dev/ath/if_ath_beacon.c Tue Mar 26 20:04:45 2013 (r248750) @@ -474,6 +474,10 @@ ath_beacon_proc(void *arg, int pending) vap = sc->sc_bslot[slot]; if (vap != NULL && vap->iv_state >= IEEE80211_S_RUN) { bf = ath_beacon_generate(sc, vap); + /* + * XXX TODO: this should use settxdesclinkptr() + * otherwise it won't work for EDMA chipsets! + */ if (bf != NULL) { /* XXX should do this using the ds */ *bflink = bf->bf_daddr; @@ -482,6 +486,10 @@ ath_beacon_proc(void *arg, int pending) } } } + /* + * XXX TODO: this should use settxdesclinkptr() + * otherwise it won't work for EDMA chipsets! + */ *bflink = 0; /* terminate list */ } @@ -540,17 +548,99 @@ ath_beacon_proc(void *arg, int pending) } } -/* - * Start CABQ transmission - this assumes that all frames are prepped - * and ready in the CABQ. - * - * XXX TODO: methodize this; for the EDMA case it should only push - * into the hardware if the FIFO isn't full _AND_ then it should - * tag the final buffer in the queue as ATH_BUF_FIFOEND so the FIFO - * depth is correctly accounted for. - */ -void -ath_beacon_cabq_start(struct ath_softc *sc) +static void +ath_beacon_cabq_start_edma(struct ath_softc *sc) +{ + struct ath_buf *bf, *bf_last; + struct ath_txq *cabq = sc->sc_cabq; +#if 0 + struct ath_buf *bfi; + int i = 0; +#endif + + ATH_TXQ_LOCK_ASSERT(cabq); + + if (TAILQ_EMPTY(&cabq->axq_q)) + return; + bf = TAILQ_FIRST(&cabq->axq_q); + bf_last = TAILQ_LAST(&cabq->axq_q, axq_q_s); + + /* + * This is a dirty, dirty hack to push the contents of + * the cabq staging queue into the FIFO. + * + * This ideally should live in the EDMA code file + * and only push things into the CABQ if there's a FIFO + * slot. + * + * We can't treat this like a normal TX queue because + * in the case of multi-VAP traffic, we may have to flush + * the CABQ each new (staggered) beacon that goes out. + * But for non-staggered beacons, we could in theory + * handle multicast traffic for all VAPs in one FIFO + * push. Just keep all of this in mind if you're wondering + * how to correctly/better handle multi-VAP CABQ traffic + * with EDMA. + */ + + /* + * Is the CABQ FIFO free? If not, complain loudly and + * don't queue anything. Maybe we'll flush the CABQ + * traffic, maybe we won't. But that'll happen next + * beacon interval. + */ + if (cabq->axq_fifo_depth >= HAL_TXFIFO_DEPTH) { + device_printf(sc->sc_dev, + "%s: Q%d: CAB FIFO queue=%d?\n", + __func__, + cabq->axq_qnum, + cabq->axq_fifo_depth); + return; + } + + /* + * Ok, so here's the gymnastics reqiured to make this + * all sensible. + */ + + /* + * Tag the first/last buffer appropriately. + */ + bf->bf_flags |= ATH_BUF_FIFOPTR; + bf_last->bf_flags |= ATH_BUF_FIFOEND; + +#if 0 + i = 0; + TAILQ_FOREACH(bfi, &cabq->axq_q, bf_list) { + ath_printtxbuf(sc, bf, cabq->axq_qnum, i, 0); + i++; + } +#endif + + /* + * We now need to push this set of frames onto the tail + * of the FIFO queue. We don't adjust the aggregate + * count, only the queue depth counter(s). + * We also need to blank the link pointer now. + */ + TAILQ_CONCAT(&cabq->fifo.axq_q, &cabq->axq_q, bf_list); + cabq->axq_link = NULL; + cabq->fifo.axq_depth += cabq->axq_depth; + cabq->axq_depth = 0; + + /* Bump FIFO queue */ + cabq->axq_fifo_depth++; + + /* Push the first entry into the hardware */ + ath_hal_puttxbuf(sc->sc_ah, cabq->axq_qnum, bf->bf_daddr); + + /* NB: gated by beacon so safe to start here */ + ath_hal_txstart(sc->sc_ah, cabq->axq_qnum); + +} + +static void +ath_beacon_cabq_start_legacy(struct ath_softc *sc) { struct ath_buf *bf; struct ath_txq *cabq = sc->sc_cabq; @@ -567,6 +657,26 @@ ath_beacon_cabq_start(struct ath_softc * ath_hal_txstart(sc->sc_ah, cabq->axq_qnum); } +/* + * Start CABQ transmission - this assumes that all frames are prepped + * and ready in the CABQ. + */ +void +ath_beacon_cabq_start(struct ath_softc *sc) +{ + struct ath_txq *cabq = sc->sc_cabq; + + ATH_TXQ_LOCK_ASSERT(cabq); + + if (TAILQ_EMPTY(&cabq->axq_q)) + return; + + if (sc->sc_isedma) + ath_beacon_cabq_start_edma(sc); + else + ath_beacon_cabq_start_legacy(sc); +} + struct ath_buf * ath_beacon_generate(struct ath_softc *sc, struct ieee80211vap *vap) { @@ -637,9 +747,6 @@ ath_beacon_generate(struct ath_softc *sc /* * Move frames from the s/w mcast q to the h/w cab q. * - * XXX TODO: This should be methodized - the EDMA - * CABQ setup code may look different! - * * XXX TODO: if we chain together multiple VAPs * worth of CABQ traffic, should we keep the * MORE data bit set on the last frame of each Modified: head/sys/dev/ath/if_ath_tx.c ============================================================================== --- head/sys/dev/ath/if_ath_tx.c Tue Mar 26 20:02:35 2013 (r248749) +++ head/sys/dev/ath/if_ath_tx.c Tue Mar 26 20:04:45 2013 (r248750) @@ -1816,7 +1816,8 @@ ath_tx_start(struct ath_softc *sc, struc * XXX duplicated in ath_raw_xmit(). */ if (IEEE80211_IS_MULTICAST(wh->i_addr1)) { - if (sc->sc_cabq->axq_depth > sc->sc_txq_mcastq_maxdepth) { + if (sc->sc_cabq->axq_depth + sc->sc_cabq->fifo.axq_depth + > sc->sc_txq_mcastq_maxdepth) { sc->sc_stats.ast_tx_mcastq_overflow++; r = ENOBUFS; } @@ -2219,7 +2220,8 @@ ath_raw_xmit(struct ieee80211_node *ni, * XXX duplicated in ath_tx_start(). */ if (IEEE80211_IS_MULTICAST(wh->i_addr1)) { - if (sc->sc_cabq->axq_depth > sc->sc_txq_mcastq_maxdepth) { + if (sc->sc_cabq->axq_depth + sc->sc_cabq->fifo.axq_depth + > sc->sc_txq_mcastq_maxdepth) { sc->sc_stats.ast_tx_mcastq_overflow++; error = ENOBUFS; } @@ -2845,7 +2847,7 @@ ath_tx_swq(struct ath_softc *sc, struct * * Otherwise, schedule the TID. */ - if (txq->axq_depth < sc->sc_hwq_limit) { + if (txq->axq_depth + txq->fifo.axq_depth < sc->sc_hwq_limit) { bf = ATH_TID_FIRST(atid); ATH_TID_REMOVE(atid, bf, bf_list); @@ -2869,7 +2871,7 @@ ath_tx_swq(struct ath_softc *sc, struct ath_tx_tid_sched(sc, atid); } - } else if (txq->axq_depth < sc->sc_hwq_limit) { + } else if (txq->axq_depth + txq->fifo.axq_depth < sc->sc_hwq_limit) { /* AMPDU not running, attempt direct dispatch */ DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: xmit_normal\n", __func__); /* See if clrdmask needs to be set */ Modified: head/sys/dev/ath/if_ath_tx_edma.c ============================================================================== --- head/sys/dev/ath/if_ath_tx_edma.c Tue Mar 26 20:02:35 2013 (r248749) +++ head/sys/dev/ath/if_ath_tx_edma.c Tue Mar 26 20:04:45 2013 (r248750) @@ -136,19 +136,65 @@ MALLOC_DECLARE(M_ATHDEV); static void ath_edma_tx_processq(struct ath_softc *sc, int dosched); +/* + * Push some frames into the TX FIFO if we have space. + */ static void ath_edma_tx_fifo_fill(struct ath_softc *sc, struct ath_txq *txq) { - struct ath_buf *bf; + struct ath_buf *bf, *bf_last; int i = 0; ATH_TXQ_LOCK_ASSERT(txq); - DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: called\n", __func__); + DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: Q%d: called\n", + __func__, + txq->axq_qnum); TAILQ_FOREACH(bf, &txq->axq_q, bf_list) { if (txq->axq_fifo_depth >= HAL_TXFIFO_DEPTH) break; + + /* + * We have space in the FIFO - so let's push a frame + * into it. + */ + + /* + * Remove it from the normal list + */ + ATH_TXQ_REMOVE(txq, bf, bf_list); + + /* + * XXX for now, we only dequeue a frame at a time, so + * that's only one buffer. Later on when we just + * push this staging _list_ into the queue, we'll + * set bf_last to the end pointer in the list. + */ + bf_last = bf; + DPRINTF(sc, ATH_DEBUG_TX_PROC, + "%s: Q%d: depth=%d; pushing %p->%p\n", + __func__, + txq->axq_qnum, + txq->axq_fifo_depth, + bf, + bf_last); + + /* + * Append it to the FIFO staging list + */ + ATH_TXQ_INSERT_TAIL(&txq->fifo, bf, bf_list); + + /* + * Set fifo start / fifo end flags appropriately + * + */ + bf->bf_flags |= ATH_BUF_FIFOPTR; + bf_last->bf_flags |= ATH_BUF_FIFOEND; + + /* + * Push _into_ the FIFO. + */ ath_hal_puttxbuf(sc->sc_ah, txq->axq_qnum, bf->bf_daddr); #ifdef ATH_DEBUG if (sc->sc_debug & ATH_DEBUG_XMIT_DESC) @@ -175,14 +221,115 @@ ath_edma_tx_fifo_fill(struct ath_softc * static void ath_edma_dma_restart(struct ath_softc *sc, struct ath_txq *txq) { + struct ath_buf *bf; + int i = 0; + int fifostart = 1; + int old_fifo_depth; - DPRINTF(sc, ATH_DEBUG_RESET, "%s: called: txq=%p, qnum=%d\n", + DPRINTF(sc, ATH_DEBUG_RESET, "%s: Q%d: called\n", __func__, - txq, txq->axq_qnum); ATH_TXQ_LOCK_ASSERT(txq); - ath_edma_tx_fifo_fill(sc, txq); + + /* + * Let's log if the tracked FIFO depth doesn't match + * what we actually push in. + */ + old_fifo_depth = txq->axq_fifo_depth; + txq->axq_fifo_depth = 0; + + /* + * Walk the FIFO staging list, looking for "head" entries. + * Since we may have a partially completed list of frames, + * we push the first frame we see into the FIFO and re-mark + * it as the head entry. We then skip entries until we see + * FIFO end, at which point we get ready to push another + * entry into the FIFO. + */ + TAILQ_FOREACH(bf, &txq->fifo.axq_q, bf_list) { + /* + * If we're looking for FIFOEND and we haven't found + * it, skip. + * + * If we're looking for FIFOEND and we've found it, + * reset for another descriptor. + */ +#ifdef ATH_DEBUG + if (sc->sc_debug & ATH_DEBUG_XMIT_DESC) + ath_printtxbuf(sc, bf, txq->axq_qnum, i, 0); +#endif/* ATH_DEBUG */ +#ifdef ATH_DEBUG_ALQ + if (if_ath_alq_checkdebug(&sc->sc_alq, ATH_ALQ_EDMA_TXDESC)) + ath_tx_alq_post(sc, bf); +#endif /* ATH_DEBUG_ALQ */ + + if (fifostart == 0) { + if (bf->bf_flags & ATH_BUF_FIFOEND) + fifostart = 1; + continue; + } + + /* Make sure we're not overflowing the FIFO! */ + if (txq->axq_fifo_depth >= HAL_TXFIFO_DEPTH) { + device_printf(sc->sc_dev, + "%s: Q%d: more frames in the queue; FIFO depth=%d?!\n", + __func__, + txq->axq_qnum, + txq->axq_fifo_depth); + } + +#if 0 + DPRINTF(sc, ATH_DEBUG_RESET, + "%s: Q%d: depth=%d: pushing bf=%p; start=%d, end=%d\n", + __func__, + txq->axq_qnum, + txq->axq_fifo_depth, + bf, + !! (bf->bf_flags & ATH_BUF_FIFOPTR), + !! (bf->bf_flags & ATH_BUF_FIFOEND)); +#endif + + /* + * Set this to be the first buffer in the FIFO + * list - even if it's also the last buffer in + * a FIFO list! + */ + bf->bf_flags |= ATH_BUF_FIFOPTR; + + /* Push it into the FIFO and bump the FIFO count */ + ath_hal_puttxbuf(sc->sc_ah, txq->axq_qnum, bf->bf_daddr); + txq->axq_fifo_depth++; + + /* + * If this isn't the last entry either, let's + * clear fifostart so we continue looking for + * said last entry. + */ + if (! (bf->bf_flags & ATH_BUF_FIFOEND)) + fifostart = 0; + i++; + } + + /* Only bother starting the queue if there's something in it */ + if (i > 0) + ath_hal_txstart(sc->sc_ah, txq->axq_qnum); + + DPRINTF(sc, ATH_DEBUG_RESET, "%s: Q%d: FIFO depth was %d, is %d\n", + __func__, + txq->axq_qnum, + old_fifo_depth, + txq->axq_fifo_depth); + + /* And now, let's check! */ + if (txq->axq_fifo_depth != old_fifo_depth) { + device_printf(sc->sc_dev, + "%s: Q%d: FIFO depth should be %d, is %d\n", + __func__, + txq->axq_qnum, + old_fifo_depth, + txq->axq_fifo_depth); + } } /* @@ -201,7 +348,6 @@ static void ath_edma_xmit_handoff_hw(struct ath_softc *sc, struct ath_txq *txq, struct ath_buf *bf) { - struct ath_hal *ah = sc->sc_ah; ATH_TXQ_LOCK(txq); @@ -220,20 +366,18 @@ ath_edma_xmit_handoff_hw(struct ath_soft /* Push and update frame stats */ ATH_TXQ_INSERT_TAIL(txq, bf, bf_list); - /* Only schedule to the FIFO if there's space */ - if (txq->axq_fifo_depth < HAL_TXFIFO_DEPTH) { -#ifdef ATH_DEBUG - if (sc->sc_debug & ATH_DEBUG_XMIT_DESC) - ath_printtxbuf(sc, bf, txq->axq_qnum, 0, 0); -#endif /* ATH_DEBUG */ -#ifdef ATH_DEBUG_ALQ - if (if_ath_alq_checkdebug(&sc->sc_alq, ATH_ALQ_EDMA_TXDESC)) - ath_tx_alq_post(sc, bf); -#endif /* ATH_DEBUG_ALQ */ - ath_hal_puttxbuf(ah, txq->axq_qnum, bf->bf_daddr); - txq->axq_fifo_depth++; - ath_hal_txstart(ah, txq->axq_qnum); - } + /* For now, set the link pointer in the last descriptor + * to be NULL. + * + * Later on, when it comes time to handling multiple descriptors + * in one FIFO push, we can link descriptors together this way. + */ + + /* + * Finally, call the FIFO schedule routine to schedule some + * frames to the FIFO. + */ + ath_edma_tx_fifo_fill(sc, txq); ATH_TXQ_UNLOCK(txq); } @@ -274,7 +418,6 @@ ath_edma_xmit_handoff_mcast(struct ath_s bf_last->bf_lastds, bf->bf_daddr); } - #ifdef ATH_DEBUG_ALQ if (if_ath_alq_checkdebug(&sc->sc_alq, ATH_ALQ_EDMA_TXDESC)) ath_tx_alq_post(sc, bf); @@ -434,8 +577,10 @@ ath_edma_tx_proc(void *arg, int npending { struct ath_softc *sc = (struct ath_softc *) arg; +#if 0 DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: called, npending=%d\n", __func__, npending); +#endif ath_edma_tx_processq(sc, 1); } @@ -469,15 +614,16 @@ ath_edma_tx_processq(struct ath_softc *s status = ath_hal_txprocdesc(ah, NULL, (void *) &ts); ATH_TXSTATUS_UNLOCK(sc); + if (status == HAL_EINPROGRESS) + break; + #ifdef ATH_DEBUG if (sc->sc_debug & ATH_DEBUG_TX_PROC) + if (ts.ts_queue_id != sc->sc_bhalq) ath_printtxstatbuf(sc, NULL, txstatus, ts.ts_queue_id, idx, (status == HAL_OK)); #endif - if (status == HAL_EINPROGRESS) - break; - /* * If there is an error with this descriptor, continue * processing. @@ -519,11 +665,25 @@ ath_edma_tx_processq(struct ath_softc *s txq = &sc->sc_txq[ts.ts_queue_id]; ATH_TXQ_LOCK(txq); - bf = TAILQ_FIRST(&txq->axq_q); + bf = ATH_TXQ_FIRST(&txq->fifo); - DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: qcuid=%d, bf=%p\n", + /* + * Work around the situation where I'm seeing notifications + * for Q1 when no frames are available. That needs to be + * debugged but not by crashing _here_. + */ + if (bf == NULL) { + device_printf(sc->sc_dev, "%s: Q%d: empty?\n", + __func__, + ts.ts_queue_id); + continue; + } + + DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: Q%d, bf=%p, start=%d, end=%d\n", __func__, - ts.ts_queue_id, bf); + ts.ts_queue_id, bf, + !! (bf->bf_flags & ATH_BUF_FIFOPTR), + !! (bf->bf_flags & ATH_BUF_FIFOEND)); /* XXX TODO: actually output debugging info about this */ @@ -541,14 +701,44 @@ ath_edma_tx_processq(struct ath_softc *s #endif /* This removes the buffer and decrements the queue depth */ - ATH_TXQ_REMOVE(txq, bf, bf_list); + ATH_TXQ_REMOVE(&txq->fifo, bf, bf_list); if (bf->bf_state.bfs_aggr) txq->axq_aggr_depth--; - txq->axq_fifo_depth --; + + /* + * If this was the end of a FIFO set, decrement FIFO depth + */ + if (bf->bf_flags & ATH_BUF_FIFOEND) + txq->axq_fifo_depth--; + + /* + * If this isn't the final buffer in a FIFO set, mark + * the buffer as busy so it goes onto the holding queue. + */ + if (! (bf->bf_flags & ATH_BUF_FIFOEND)) + bf->bf_flags |= ATH_BUF_BUSY; + + DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: Q%d: FIFO depth is now %d (%d)\n", + __func__, + txq->axq_qnum, + txq->axq_fifo_depth, + txq->fifo.axq_depth); + /* XXX assert FIFO depth >= 0 */ ATH_TXQ_UNLOCK(txq); /* + * Outside of the TX lock - if the buffer is end + * end buffer in this FIFO, we don't need a holding + * buffer any longer. + */ + if (bf->bf_flags & ATH_BUF_FIFOEND) { + ATH_TXBUF_LOCK(sc); + ath_txq_freeholdingbuf(sc, txq); + ATH_TXBUF_UNLOCK(sc); + } + + /* * First we need to make sure ts_rate is valid. * * Pre-EDMA chips pass the whole TX descriptor to @@ -617,21 +807,10 @@ ath_edma_tx_processq(struct ath_softc *s /* * Now that there's space in the FIFO, let's push some * more frames into it. - * - * Unfortunately for now, the txq has FIFO and non-FIFO - * frames in the same linked list, so there's no way - * to quickly/easily populate frames without walking - * the queue and skipping 'axq_fifo_depth' frames. - * - * So for now, let's only repopulate the FIFO once it - * is empty. It's sucky for performance but it's enough - * to begin validating that things are somewhat - * working. */ ATH_TXQ_LOCK(txq); - if (dosched && txq->axq_fifo_depth == 0) { + if (dosched) ath_edma_tx_fifo_fill(sc, txq); - } ATH_TXQ_UNLOCK(txq); } From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 20:11:10 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 762ED693; Tue, 26 Mar 2013 20:11:10 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 68004B5B; Tue, 26 Mar 2013 20:11:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QKBAt4094761; Tue, 26 Mar 2013 20:11:10 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QKBAjm094760; Tue, 26 Mar 2013 20:11:10 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201303262011.r2QKBAjm094760@svn.freebsd.org> From: Ed Maste Date: Tue, 26 Mar 2013 20:11:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248751 - head/share/mk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 20:11:10 -0000 Author: emaste Date: Tue Mar 26 20:11:09 2013 New Revision: 248751 URL: http://svnweb.freebsd.org/changeset/base/248751 Log: Unconditionally include ${SRCCONF} if overridden This avoids silently failing to include ${SRCCONF} specified by a make(1) invocation. Modified: head/share/mk/bsd.own.mk Modified: head/share/mk/bsd.own.mk ============================================================================== --- head/share/mk/bsd.own.mk Tue Mar 26 20:04:45 2013 (r248750) +++ head/share/mk/bsd.own.mk Tue Mar 26 20:11:09 2013 (r248751) @@ -117,7 +117,7 @@ ____: .if !defined(_WITHOUT_SRCCONF) SRCCONF?= /etc/src.conf -.if exists(${SRCCONF}) +.if exists(${SRCCONF}) || ${SRCCONF} != "/etc/src.conf" .include "${SRCCONF}" .endif .endif From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 20:17:09 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 0CF9A999; Tue, 26 Mar 2013 20:17:09 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E4977C20; Tue, 26 Mar 2013 20:17:08 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QKH8qB095593; Tue, 26 Mar 2013 20:17:08 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QKH8tl095591; Tue, 26 Mar 2013 20:17:08 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201303262017.r2QKH8tl095591@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Tue, 26 Mar 2013 20:17:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248752 - in head: cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pointers sys/cddl/contrib/opensolaris/uts/common/dtrace X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 20:17:09 -0000 Author: pfg Date: Tue Mar 26 20:17:08 2013 New Revision: 248752 URL: http://svnweb.freebsd.org/changeset/base/248752 Log: Dtrace: dtrace.c erroneously checks for memory alignment on amd64. Merge change from illumos: 3511 dtrace.c erroneously checks for memory alignment on amd64 Illumos Revision: c93cc65 Reference: https://www.illumos.org/issues/3511 Obtained from: Illumos MFC after: 3 weeks Modified: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress5.d head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Modified: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress5.d ============================================================================== --- head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress5.d Tue Mar 26 20:11:09 2013 (r248751) +++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pointers/err.InvalidAddress5.d Tue Mar 26 20:17:08 2013 (r248752) @@ -24,7 +24,9 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" +/* + * Copyright (c) 2012 by Delphix. All rights reserved. + */ /* * ASSERTION: @@ -32,44 +34,51 @@ * a runtime error. * * SECTION: Pointers and Arrays/Generic Pointers - * - * NOTES: - * This test doesn't apply to x86; for the time being, we're working - * around this with the preprocessor. */ #pragma D option quiet -int array[3]; -uintptr_t uptr; +#if defined(__i386) || defined(__amd64) +#define __x86 1 +#endif + +int array[2]; +char *ptr; int *p; int *q; int *r; BEGIN { -#ifdef __i386 + array[0] = 0x12345678; + array[1] = 0xabcdefff; + + ptr = (char *) &array[0]; + + p = (int *) (ptr); + q = (int *) (ptr + 2); + r = (int *) (ptr + 3); + + printf("*p: 0x%x\n", *p); + printf("*q: 0x%x\n", *q); + printf("*r: 0x%x\n", *r); + + /* + * On x86, the above unaligned memory accesses are allowed and should + * not result in the ERROR probe firing. + */ +#ifdef __x86 exit(1); #else - array[0] = 20; - array[1] = 40; - array[2] = 80; - - uptr = (uintptr_t) &array[0]; - - p = (int *) (uptr); - q = (int *) (uptr + 2); - r = (int *) (uptr + 3); - - printf("array[0]: %d\t*p: %d\n", array[0], *p); - printf("array[1]: %d\t*q: %d\n", array[1], *q); - printf("array[2]: %d\t*r: %d\n", array[2], *r); - exit(0); #endif } ERROR { +#ifdef __x86 + exit(0); +#else exit(1); +#endif } Modified: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Tue Mar 26 20:11:09 2013 (r248751) +++ head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Tue Mar 26 20:17:08 2013 (r248752) @@ -443,7 +443,7 @@ static kmutex_t dtrace_errlock; #define DTRACE_STORE(type, tomax, offset, what) \ *((type *)((uintptr_t)(tomax) + (uintptr_t)offset)) = (type)(what); -#ifndef __i386 +#ifndef __x86 #define DTRACE_ALIGNCHECK(addr, size, flags) \ if (addr & (size - 1)) { \ *flags |= CPU_DTRACE_BADALIGN; \ From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 20:32:46 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E9F56EA; Tue, 26 Mar 2013 20:32:46 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id DD0ACD95; Tue, 26 Mar 2013 20:32:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QKWkNB001255; Tue, 26 Mar 2013 20:32:46 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QKWkuT001254; Tue, 26 Mar 2013 20:32:46 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201303262032.r2QKWkuT001254@svn.freebsd.org> From: Ed Maste Date: Tue, 26 Mar 2013 20:32:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248753 - head/share/mk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 20:32:47 -0000 Author: emaste Date: Tue Mar 26 20:32:46 2013 New Revision: 248753 URL: http://svnweb.freebsd.org/changeset/base/248753 Log: Always define and use PROGNAME This avoids having separate cases in the install rule for PROGNAME set and not set. This is a minor cleanup in advance of further support for standalone debug files. Modified: head/share/mk/bsd.prog.mk Modified: head/share/mk/bsd.prog.mk ============================================================================== --- head/share/mk/bsd.prog.mk Tue Mar 26 20:17:08 2013 (r248752) +++ head/share/mk/bsd.prog.mk Tue Mar 26 20:32:46 2013 (r248753) @@ -41,6 +41,7 @@ PROG= ${PROG_CXX} .endif .if defined(PROG) +PROGNAME?= ${PROG} .if defined(SRCS) OBJS+= ${SRCS:N*.h:R:S/$/.o/g} @@ -153,13 +154,8 @@ realinstall: _proginstall .ORDER: beforeinstall _proginstall _proginstall: .if defined(PROG) -.if defined(PROGNAME) ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME} -.else - ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} -.endif .endif .endif # !target(realinstall) From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 20:32:58 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 65ECD24D; Tue, 26 Mar 2013 20:32:58 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 583ACD97; Tue, 26 Mar 2013 20:32:58 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QKWwrO001316; Tue, 26 Mar 2013 20:32:58 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QKWvfP001314; Tue, 26 Mar 2013 20:32:57 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262032.r2QKWvfP001314@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 20:32:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248754 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 20:32:58 -0000 Author: jimharris Date: Tue Mar 26 20:32:57 2013 New Revision: 248754 URL: http://svnweb.freebsd.org/changeset/base/248754 Log: By default, always escalate to controller reset when an I/O times out. While aborts are typically cleaner than a full controller reset, many times an I/O timeout indicates other controller-level issues where aborts may not work. NVMe drivers for other operating systems are also defaulting to controller reset rather than aborts for timed out I/O. Sponsored by: Intel Reviewed by: carl Modified: head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_private.h head/sys/dev/nvme/nvme_qpair.c Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 20:32:46 2013 (r248753) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 20:32:57 2013 (r248754) @@ -422,12 +422,8 @@ nvme_ctrlr_hw_reset(struct nvme_controll void nvme_ctrlr_reset(struct nvme_controller *ctrlr) { - int status; - status = nvme_ctrlr_hw_reset(ctrlr); - DELAY(100*1000); - if (status == 0) - taskqueue_enqueue(ctrlr->taskqueue, &ctrlr->restart_task); + taskqueue_enqueue(ctrlr->taskqueue, &ctrlr->reset_task); } static int @@ -686,11 +682,24 @@ err: } static void -nvme_ctrlr_restart_task(void *arg, int pending) +nvme_ctrlr_reset_task(void *arg, int pending) { - struct nvme_controller *ctrlr = arg; + struct nvme_controller *ctrlr = arg; + int status; - nvme_ctrlr_start(ctrlr); + device_printf(ctrlr->dev, "resetting controller"); + status = nvme_ctrlr_hw_reset(ctrlr); + /* + * Use pause instead of DELAY, so that we yield to any nvme interrupt + * handlers on this CPU that were blocked on a qpair lock. We want + * all nvme interrupts completed before proceeding with restarting the + * controller. + * + * XXX - any way to guarantee the interrupt handlers have quiesced? + */ + pause("nvmereset", hz / 10); + if (status == 0) + nvme_ctrlr_start(ctrlr); } static void @@ -841,6 +850,9 @@ nvme_ctrlr_construct(struct nvme_control ctrlr->force_intx = 0; TUNABLE_INT_FETCH("hw.nvme.force_intx", &ctrlr->force_intx); + ctrlr->enable_aborts = 0; + TUNABLE_INT_FETCH("hw.nvme.enable_aborts", &ctrlr->enable_aborts); + ctrlr->msix_enabled = 1; if (ctrlr->force_intx) { @@ -879,7 +891,7 @@ intx: ctrlr->cdev->si_drv1 = (void *)ctrlr; - TASK_INIT(&ctrlr->restart_task, 0, nvme_ctrlr_restart_task, ctrlr); + TASK_INIT(&ctrlr->reset_task, 0, nvme_ctrlr_reset_task, ctrlr); ctrlr->taskqueue = taskqueue_create("nvme_taskq", M_WAITOK, taskqueue_thread_enqueue, &ctrlr->taskqueue); taskqueue_start_threads(&ctrlr->taskqueue, 1, PI_DISK, "nvme taskq"); Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 20:32:46 2013 (r248753) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 20:32:57 2013 (r248754) @@ -230,6 +230,7 @@ struct nvme_controller { uint32_t msix_enabled; uint32_t force_intx; + uint32_t enable_aborts; uint32_t num_io_queues; boolean_t per_cpu_io_queues; @@ -239,7 +240,7 @@ struct nvme_controller { uint32_t ns_identified; uint32_t queues_created; uint32_t num_start_attempts; - struct task restart_task; + struct task reset_task; struct taskqueue *taskqueue; /* For shared legacy interrupt. */ Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 20:32:46 2013 (r248753) +++ head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 20:32:57 2013 (r248754) @@ -460,21 +460,20 @@ nvme_timeout(void *arg) struct nvme_controller *ctrlr = qpair->ctrlr; union csts_register csts; + /* Read csts to get value of cfs - controller fatal status. */ csts.raw = nvme_mmio_read_4(ctrlr, csts); - if (csts.bits.cfs == 1) { + device_printf(ctrlr->dev, "i/o timeout, csts.cfs=%d\n", csts.bits.cfs); + nvme_dump_command(&tr->req->cmd); + + if (ctrlr->enable_aborts && csts.bits.cfs == 0) { /* - * The controller is reporting fatal status. Don't bother - * trying to abort the timed out command - proceed - * immediately to a controller-level reset. + * If aborts are enabled, only use them if the controller is + * not reporting fatal status. */ - device_printf(ctrlr->dev, - "controller reports fatal status, resetting...\n"); + nvme_ctrlr_cmd_abort(ctrlr, tr->cid, qpair->id, + nvme_abort_complete, tr); + } else nvme_ctrlr_reset(ctrlr); - return; - } - - nvme_ctrlr_cmd_abort(ctrlr, tr->cid, qpair->id, - nvme_abort_complete, tr); } void From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 20:56:59 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 8117EA9A; Tue, 26 Mar 2013 20:56:59 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 73428ECD; Tue, 26 Mar 2013 20:56:59 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QKuxkb008125; Tue, 26 Mar 2013 20:56:59 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QKuwmw008120; Tue, 26 Mar 2013 20:56:58 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262056.r2QKuwmw008120@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 20:56:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248755 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 20:56:59 -0000 Author: jimharris Date: Tue Mar 26 20:56:58 2013 New Revision: 248755 URL: http://svnweb.freebsd.org/changeset/base/248755 Log: Make nvme_ctrlr_reset a nop if a reset is already in progress. This protects against cases where a controller crashes with multiple I/O outstanding, each timing out and requesting controller resets simultaneously. While here, remove a debugging printf from a previous commit, and add more logging around I/O that need to be resubmitted after a controller reset. Sponsored by: Intel Reviewed by: carl Modified: head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_private.h head/sys/dev/nvme/nvme_qpair.c Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 20:32:57 2013 (r248754) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 20:56:58 2013 (r248755) @@ -422,6 +422,13 @@ nvme_ctrlr_hw_reset(struct nvme_controll void nvme_ctrlr_reset(struct nvme_controller *ctrlr) { + int cmpset; + + cmpset = atomic_cmpset_32(&ctrlr->is_resetting, 0, 1); + + if (cmpset == 0) + /* Controller is already resetting. */ + return; taskqueue_enqueue(ctrlr->taskqueue, &ctrlr->reset_task); } @@ -700,6 +707,8 @@ nvme_ctrlr_reset_task(void *arg, int pen pause("nvmereset", hz / 10); if (status == 0) nvme_ctrlr_start(ctrlr); + + atomic_cmpset_32(&ctrlr->is_resetting, 1, 0); } static void @@ -896,6 +905,8 @@ intx: taskqueue_thread_enqueue, &ctrlr->taskqueue); taskqueue_start_threads(&ctrlr->taskqueue, 1, PI_DISK, "nvme taskq"); + ctrlr->is_resetting = 0; + return (0); } Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 20:32:57 2013 (r248754) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 20:56:58 2013 (r248755) @@ -100,7 +100,7 @@ MALLOC_DECLARE(M_NVME); #define NVME_MAX_CONSUMERS (2) #define NVME_MAX_ASYNC_EVENTS (8) -#define NVME_DEFAULT_TIMEOUT_PERIOD (30) /* in seconds */ +#define NVME_DEFAULT_TIMEOUT_PERIOD (30) /* in seconds */ #define NVME_MIN_TIMEOUT_PERIOD (5) #define NVME_MAX_TIMEOUT_PERIOD (120) @@ -280,6 +280,8 @@ struct nvme_controller { void *cons_cookie[NVME_MAX_CONSUMERS]; + uint32_t is_resetting; + #ifdef CHATHAM2 uint64_t chatham_size; uint64_t chatham_lbas; Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 20:32:57 2013 (r248754) +++ head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 20:56:58 2013 (r248755) @@ -142,7 +142,13 @@ nvme_qpair_complete_tracker(struct nvme_ TAILQ_REMOVE(&qpair->outstanding_tr, tr, tailq); TAILQ_INSERT_HEAD(&qpair->free_tr, tr, tailq); - if (!STAILQ_EMPTY(&qpair->queued_req)) { + /* + * If the controller is in the middle of resetting, don't + * try to submit queued requests here - let the reset logic + * handle that instead. + */ + if (!STAILQ_EMPTY(&qpair->queued_req) && + !qpair->ctrlr->is_resetting) { req = STAILQ_FIRST(&qpair->queued_req); STAILQ_REMOVE_HEAD(&qpair->queued_req, stailq); _nvme_qpair_submit_request(qpair, req); @@ -462,8 +468,6 @@ nvme_timeout(void *arg) /* Read csts to get value of cfs - controller fatal status. */ csts.raw = nvme_mmio_read_4(ctrlr, csts); - device_printf(ctrlr->dev, "i/o timeout, csts.cfs=%d\n", csts.bits.cfs); - nvme_dump_command(&tr->req->cmd); if (ctrlr->enable_aborts && csts.bits.cfs == 0) { /* @@ -606,8 +610,12 @@ nvme_io_qpair_enable(struct nvme_qpair * nvme_qpair_enable(qpair); - TAILQ_FOREACH(tr, &qpair->outstanding_tr, tailq) + TAILQ_FOREACH(tr, &qpair->outstanding_tr, tailq) { + device_printf(qpair->ctrlr->dev, + "resubmitting outstanding i/o\n"); + nvme_dump_command(&tr->req->cmd); nvme_qpair_submit_tracker(qpair, tr); + } STAILQ_INIT(&temp); STAILQ_SWAP(&qpair->queued_req, &temp, nvme_request); @@ -615,6 +623,9 @@ nvme_io_qpair_enable(struct nvme_qpair * while (!STAILQ_EMPTY(&temp)) { req = STAILQ_FIRST(&temp); STAILQ_REMOVE_HEAD(&temp, stailq); + device_printf(qpair->ctrlr->dev, + "resubmitting queued i/o\n"); + nvme_dump_command(&req->cmd); _nvme_qpair_submit_request(qpair, req); } From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 21:00:20 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 5C0F6DA1; Tue, 26 Mar 2013 21:00:20 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 3FD63F15; Tue, 26 Mar 2013 21:00:20 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QL0Kg1008991; Tue, 26 Mar 2013 21:00:20 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QL0It2008957; Tue, 26 Mar 2013 21:00:18 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262100.r2QL0It2008957@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 21:00:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248756 - in head/sys/dev: nvd nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 21:00:20 -0000 Author: jimharris Date: Tue Mar 26 21:00:18 2013 New Revision: 248756 URL: http://svnweb.freebsd.org/changeset/base/248756 Log: Create struct nvme_status. NVMe error log entries include status, so breaking this out into its own data structure allows it to be included in both the nvme_completion data structure as well as error log entry data structures. While here, expose nvme_completion_is_error(), and change all of the places that were explicitly looking at sc/sct bits to use this macro instead. Sponsored by: Intel Reviewed by: carl Modified: head/sys/dev/nvd/nvd.c head/sys/dev/nvme/nvme.c head/sys/dev/nvme/nvme.h head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_ns.c head/sys/dev/nvme/nvme_qpair.c head/sys/dev/nvme/nvme_test.c head/sys/dev/nvme/nvme_uio.c Modified: head/sys/dev/nvd/nvd.c ============================================================================== --- head/sys/dev/nvd/nvd.c Tue Mar 26 20:56:58 2013 (r248755) +++ head/sys/dev/nvd/nvd.c Tue Mar 26 21:00:18 2013 (r248756) @@ -153,7 +153,7 @@ nvd_ioctl(struct disk *ndisk, u_long cmd } static void -nvd_done(void *arg, const struct nvme_completion *status) +nvd_done(void *arg, const struct nvme_completion *cpl) { struct bio *bp; struct nvd_disk *ndisk; @@ -168,7 +168,7 @@ nvd_done(void *arg, const struct nvme_co * TODO: add more extensive translation of NVMe status codes * to different bio error codes (i.e. EIO, EINVAL, etc.) */ - if (status->sf_sc || status->sf_sct) { + if (nvme_completion_is_error(cpl)) { bp->bio_error = EIO; bp->bio_flags |= BIO_ERROR; bp->bio_resid = bp->bio_bcount; Modified: head/sys/dev/nvme/nvme.c ============================================================================== --- head/sys/dev/nvme/nvme.c Tue Mar 26 20:56:58 2013 (r248755) +++ head/sys/dev/nvme/nvme.c Tue Mar 26 21:00:18 2013 (r248756) @@ -223,8 +223,8 @@ nvme_dump_completion(struct nvme_complet printf("cdw0:%08x sqhd:%04x sqid:%04x " "cid:%04x p:%x sc:%02x sct:%x m:%x dnr:%x\n", cpl->cdw0, cpl->sqhd, cpl->sqid, - cpl->cid, cpl->p, cpl->sf_sc, cpl->sf_sct, cpl->sf_m, - cpl->sf_dnr); + cpl->cid, cpl->status.p, cpl->status.sc, cpl->status.sct, + cpl->status.m, cpl->status.dnr); } void Modified: head/sys/dev/nvme/nvme.h ============================================================================== --- head/sys/dev/nvme/nvme.h Tue Mar 26 20:56:58 2013 (r248755) +++ head/sys/dev/nvme/nvme.h Tue Mar 26 21:00:18 2013 (r248756) @@ -223,26 +223,31 @@ struct nvme_command uint32_t cdw15; /* command-specific */ } __packed; +struct nvme_status { + + uint16_t p : 1; /* phase tag */ + uint16_t sc : 8; /* status code */ + uint16_t sct : 3; /* status code type */ + uint16_t rsvd2 : 2; + uint16_t m : 1; /* more */ + uint16_t dnr : 1; /* do not retry */ +} __packed; + struct nvme_completion { /* dword 0 */ - uint32_t cdw0; /* command-specific */ + uint32_t cdw0; /* command-specific */ /* dword 1 */ - uint32_t rsvd1; + uint32_t rsvd1; /* dword 2 */ - uint16_t sqhd; /* submission queue head pointer */ - uint16_t sqid; /* submission queue identifier */ + uint16_t sqhd; /* submission queue head pointer */ + uint16_t sqid; /* submission queue identifier */ /* dword 3 */ - uint16_t cid; /* command identifier */ - uint16_t p : 1; /* phase tag */ - uint16_t sf_sc : 8; /* status field - status code */ - uint16_t sf_sct : 3; /* status field - status code type */ - uint16_t rsvd2 : 2; - uint16_t sf_m : 1; /* status field - more */ - uint16_t sf_dnr : 1; /* status field - do not retry */ + uint16_t cid; /* command identifier */ + struct nvme_status status; } __packed; struct nvme_dsm_range { @@ -686,6 +691,9 @@ enum nvme_io_test_flags { NVME_TEST_FLAG_REFTHREAD = 0x1, }; +#define nvme_completion_is_error(cpl) \ + ((cpl)->status.sc != 0 || (cpl)->status.sct != 0) + #ifdef _KERNEL struct bio; Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 20:56:58 2013 (r248755) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 21:00:18 2013 (r248756) @@ -447,7 +447,7 @@ nvme_ctrlr_identify(struct nvme_controll nvme_ctrlr_cb, &cpl); status = msleep(&cpl, mtx, PRIBIO, "nvme_start", hz*5); mtx_unlock(mtx); - if ((status != 0) || cpl.sf_sc || cpl.sf_sct) { + if ((status != 0) || nvme_completion_is_error(&cpl)) { printf("nvme_identify_controller failed!\n"); return (ENXIO); } @@ -474,7 +474,7 @@ nvme_ctrlr_set_num_qpairs(struct nvme_co nvme_ctrlr_cb, &cpl); status = msleep(&cpl, mtx, PRIBIO, "nvme_start", hz*5); mtx_unlock(mtx); - if ((status != 0) || cpl.sf_sc || cpl.sf_sct) { + if ((status != 0) || nvme_completion_is_error(&cpl)) { printf("nvme_set_num_queues failed!\n"); return (ENXIO); } @@ -522,7 +522,7 @@ nvme_ctrlr_create_qpairs(struct nvme_con nvme_ctrlr_cb, &cpl); status = msleep(&cpl, mtx, PRIBIO, "nvme_start", hz*5); mtx_unlock(mtx); - if ((status != 0) || cpl.sf_sc || cpl.sf_sct) { + if ((status != 0) || nvme_completion_is_error(&cpl)) { printf("nvme_create_io_cq failed!\n"); return (ENXIO); } @@ -532,7 +532,7 @@ nvme_ctrlr_create_qpairs(struct nvme_con nvme_ctrlr_cb, &cpl); status = msleep(&cpl, mtx, PRIBIO, "nvme_start", hz*5); mtx_unlock(mtx); - if ((status != 0) || cpl.sf_sc || cpl.sf_sct) { + if ((status != 0) || nvme_completion_is_error(&cpl)) { printf("nvme_create_io_sq failed!\n"); return (ENXIO); } @@ -562,7 +562,7 @@ nvme_ctrlr_async_event_cb(void *arg, con { struct nvme_async_event_request *aer = arg; - if (cpl->sf_sc == NVME_SC_ABORTED_SQ_DELETION) { + if (cpl->status.sc == NVME_SC_ABORTED_SQ_DELETION) { /* * This is simulated when controller is being shut down, to * effectively abort outstanding asynchronous event requests @@ -783,7 +783,7 @@ nvme_ctrlr_ioctl(struct cdev *cdev, u_lo nvme_ctrlr_cb, &cpl); msleep(&cpl, mtx, PRIBIO, "nvme_ioctl", 0); mtx_unlock(mtx); - if (cpl.sf_sc || cpl.sf_sct) + if (nvme_completion_is_error(&cpl)) return (ENXIO); memcpy(arg, &ctrlr->cdata, sizeof(ctrlr->cdata)); break; Modified: head/sys/dev/nvme/nvme_ns.c ============================================================================== --- head/sys/dev/nvme/nvme_ns.c Tue Mar 26 20:56:58 2013 (r248755) +++ head/sys/dev/nvme/nvme_ns.c Tue Mar 26 21:00:18 2013 (r248756) @@ -90,7 +90,7 @@ nvme_ns_ioctl(struct cdev *cdev, u_long nvme_ns_cb, &cpl); msleep(&cpl, mtx, PRIBIO, "nvme_ioctl", 0); mtx_unlock(mtx); - if (cpl.sf_sc || cpl.sf_sct) + if (nvme_completion_is_error(&cpl)) return (ENXIO); memcpy(arg, &ns->data, sizeof(ns->data)); break; @@ -132,7 +132,7 @@ nvme_ns_close(struct cdev *dev __unused, } static void -nvme_ns_strategy_done(void *arg, const struct nvme_completion *status) +nvme_ns_strategy_done(void *arg, const struct nvme_completion *cpl) { struct bio *bp = arg; @@ -140,7 +140,7 @@ nvme_ns_strategy_done(void *arg, const s * TODO: add more extensive translation of NVMe status codes * to different bio error codes (i.e. EIO, EINVAL, etc.) */ - if (status->sf_sc || status->sf_sct) { + if (nvme_completion_is_error(cpl)) { bp->bio_error = EIO; bp->bio_flags |= BIO_ERROR; bp->bio_resid = bp->bio_bcount; @@ -338,7 +338,7 @@ nvme_ns_construct(struct nvme_namespace nvme_ns_cb, &cpl); status = msleep(&cpl, mtx, PRIBIO, "nvme_start", hz*5); mtx_unlock(mtx); - if ((status != 0) || cpl.sf_sc || cpl.sf_sct) { + if ((status != 0) || nvme_completion_is_error(&cpl)) { printf("nvme_identify_namespace failed!\n"); return (ENXIO); } Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 20:56:58 2013 (r248755) +++ head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 21:00:18 2013 (r248756) @@ -38,13 +38,6 @@ static void _nvme_qpair_submit_request(s struct nvme_request *req); static boolean_t -nvme_completion_is_error(struct nvme_completion *cpl) -{ - - return (cpl->sf_sc != 0 || cpl->sf_sct != 0); -} - -static boolean_t nvme_completion_is_retry(const struct nvme_completion *cpl) { /* @@ -53,13 +46,13 @@ nvme_completion_is_retry(const struct nv * NAMESPACE_NOT_READY is the only case where we should * look at the DNR bit. */ - switch (cpl->sf_sct) { + switch (cpl->status.sct) { case NVME_SCT_GENERIC: - switch (cpl->sf_sc) { + switch (cpl->status.sc) { case NVME_SC_ABORTED_BY_REQUEST: return (1); case NVME_SC_NAMESPACE_NOT_READY: - if (cpl->sf_dnr) + if (cpl->status.dnr) return (0); else return (1); @@ -168,8 +161,8 @@ nvme_qpair_manual_complete_tracker(struc memset(&cpl, 0, sizeof(cpl)); cpl.sqid = qpair->id; cpl.cid = tr->cid; - cpl.sf_sct = sct; - cpl.sf_sc = sc; + cpl.status.sct = sct; + cpl.status.sc = sc; nvme_qpair_complete_tracker(qpair, tr, &cpl, print_on_error); } @@ -193,7 +186,7 @@ nvme_qpair_process_completions(struct nv while (1) { cpl = &qpair->cpl[qpair->cq_head]; - if (cpl->p != qpair->phase) + if (cpl->status.p != qpair->phase) break; tr = qpair->act_tr[cpl->cid]; Modified: head/sys/dev/nvme/nvme_test.c ============================================================================== --- head/sys/dev/nvme/nvme_test.c Tue Mar 26 20:56:58 2013 (r248755) +++ head/sys/dev/nvme/nvme_test.c Tue Mar 26 21:00:18 2013 (r248756) @@ -172,14 +172,14 @@ nvme_ns_bio_test(void *arg) } static void -nvme_ns_io_test_cb(void *arg, const struct nvme_completion *status) +nvme_ns_io_test_cb(void *arg, const struct nvme_completion *cpl) { struct nvme_io_test_thread *tth = arg; struct timeval t; tth->io_completed++; - if (status->sf_sc || status->sf_sct) { + if (nvme_completion_is_error(cpl)) { printf("%s: error occurred\n", __func__); wakeup_one(tth); return; Modified: head/sys/dev/nvme/nvme_uio.c ============================================================================== --- head/sys/dev/nvme/nvme_uio.c Tue Mar 26 20:56:58 2013 (r248755) +++ head/sys/dev/nvme/nvme_uio.c Tue Mar 26 21:00:18 2013 (r248756) @@ -35,12 +35,12 @@ __FBSDID("$FreeBSD$"); #include "nvme_private.h" static void -nvme_uio_done(void *arg, const struct nvme_completion *status) +nvme_uio_done(void *arg, const struct nvme_completion *cpl) { struct mtx *mtx; struct uio *uio = arg; - if (status->sf_sc == 0 && status->sf_sct == 0) + if (!nvme_completion_is_error(cpl)) uio->uio_resid = 0; mtx = mtx_pool_find(mtxpool_sleep, arg); From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 21:01:54 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 7CAD8FAE; Tue, 26 Mar 2013 21:01:54 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 567B1F39; Tue, 26 Mar 2013 21:01:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QL1s1b010718; Tue, 26 Mar 2013 21:01:54 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QL1ruE010715; Tue, 26 Mar 2013 21:01:53 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262101.r2QL1ruE010715@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 21:01:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248757 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 21:01:54 -0000 Author: jimharris Date: Tue Mar 26 21:01:53 2013 New Revision: 248757 URL: http://svnweb.freebsd.org/changeset/base/248757 Log: Add structure definitions and a controller command function for error log pages. Sponsored by: Intel Reviewed by: carl Modified: head/sys/dev/nvme/nvme.h head/sys/dev/nvme/nvme_ctrlr_cmd.c head/sys/dev/nvme/nvme_private.h Modified: head/sys/dev/nvme/nvme.h ============================================================================== --- head/sys/dev/nvme/nvme.h Tue Mar 26 21:00:18 2013 (r248756) +++ head/sys/dev/nvme/nvme.h Tue Mar 26 21:01:53 2013 (r248757) @@ -622,6 +622,19 @@ enum nvme_log_page { /* 0xC0-0xFF - vendor specific */ }; +struct nvme_error_information_entry { + + uint64_t error_count; + uint16_t sqid; + uint16_t cid; + struct nvme_status status; + uint16_t error_location; + uint64_t lba; + uint32_t nsid; + uint8_t vendor_specific; + uint8_t reserved[35]; +} __packed __aligned(4); + union nvme_critical_warning_state { uint8_t raw; Modified: head/sys/dev/nvme/nvme_ctrlr_cmd.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr_cmd.c Tue Mar 26 21:00:18 2013 (r248756) +++ head/sys/dev/nvme/nvme_ctrlr_cmd.c Tue Mar 26 21:01:53 2013 (r248757) @@ -267,6 +267,25 @@ nvme_ctrlr_cmd_get_log_page(struct nvme_ nvme_ctrlr_submit_admin_request(ctrlr, req); } +void +nvme_ctrlr_cmd_get_error_page(struct nvme_controller *ctrlr, + struct nvme_error_information_entry *payload, uint32_t num_entries, + nvme_cb_fn_t cb_fn, void *cb_arg) +{ + + KASSERT(num_entries > 0, ("%s called with num_entries==0\n", __func__)); + + /* Controller's error log page entries is 0-based. */ + if (num_entries > (ctrlr->cdata.elpe + 1)) { + printf("%s num_entries=%d cdata.elpe=%d\n", + __func__, num_entries, ctrlr->cdata.elpe); + num_entries = ctrlr->cdata.elpe + 1; + } + + nvme_ctrlr_cmd_get_log_page(ctrlr, NVME_LOG_ERROR, + NVME_GLOBAL_NAMESPACE_TAG, payload, sizeof(*payload) * num_entries, + cb_fn, cb_arg); +} void nvme_ctrlr_cmd_get_health_information_page(struct nvme_controller *ctrlr, Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 21:00:18 2013 (r248756) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 21:01:53 2013 (r248757) @@ -342,6 +342,11 @@ void nvme_ctrlr_cmd_set_interrupt_coales uint32_t threshold, nvme_cb_fn_t cb_fn, void *cb_arg); +void nvme_ctrlr_cmd_get_error_page(struct nvme_controller *ctrlr, + struct nvme_error_information_entry *payload, + uint32_t num_entries, /* 0 = max */ + nvme_cb_fn_t cb_fn, + void *cb_arg); void nvme_ctrlr_cmd_get_health_information_page(struct nvme_controller *ctrlr, uint32_t nsid, struct nvme_health_information_page *payload, From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 21:03:04 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 86B8A1D3; Tue, 26 Mar 2013 21:03:04 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 60A08F4B; Tue, 26 Mar 2013 21:03:04 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QL34E4010965; Tue, 26 Mar 2013 21:03:04 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QL330p010962; Tue, 26 Mar 2013 21:03:03 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262103.r2QL330p010962@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 21:03:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248758 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 21:03:04 -0000 Author: jimharris Date: Tue Mar 26 21:03:03 2013 New Revision: 248758 URL: http://svnweb.freebsd.org/changeset/base/248758 Log: Add structure definitions and controller command function for firmware log pages. Sponsored by: Intel Reviewed by: carl Modified: head/sys/dev/nvme/nvme.h head/sys/dev/nvme/nvme_ctrlr_cmd.c head/sys/dev/nvme/nvme_private.h Modified: head/sys/dev/nvme/nvme.h ============================================================================== --- head/sys/dev/nvme/nvme.h Tue Mar 26 21:01:53 2013 (r248757) +++ head/sys/dev/nvme/nvme.h Tue Mar 26 21:03:03 2013 (r248758) @@ -682,6 +682,18 @@ struct nvme_health_information_page { uint8_t reserved2[320]; } __packed __aligned(4); +struct nvme_firmware_page { + + struct { + uint8_t slot : 3; /* slot for current FW */ + uint8_t reserved : 5; + } __packed afi; + + uint8_t reserved[7]; + uint64_t revision[7]; /* revisions for 7 slots */ + uint8_t reserved2[448]; +} __packed __aligned(4); + #define NVME_TEST_MAX_THREADS 128 struct nvme_io_test { Modified: head/sys/dev/nvme/nvme_ctrlr_cmd.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr_cmd.c Tue Mar 26 21:01:53 2013 (r248757) +++ head/sys/dev/nvme/nvme_ctrlr_cmd.c Tue Mar 26 21:03:03 2013 (r248758) @@ -298,6 +298,16 @@ nvme_ctrlr_cmd_get_health_information_pa } void +nvme_ctrlr_cmd_get_firmware_page(struct nvme_controller *ctrlr, + struct nvme_firmware_page *payload, nvme_cb_fn_t cb_fn, void *cb_arg) +{ + + nvme_ctrlr_cmd_get_log_page(ctrlr, NVME_LOG_FIRMWARE_SLOT, + NVME_GLOBAL_NAMESPACE_TAG, payload, sizeof(*payload), cb_fn, + cb_arg); +} + +void nvme_ctrlr_cmd_abort(struct nvme_controller *ctrlr, uint16_t cid, uint16_t sqid, nvme_cb_fn_t cb_fn, void *cb_arg) { Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 21:01:53 2013 (r248757) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 21:03:03 2013 (r248758) @@ -352,6 +352,10 @@ void nvme_ctrlr_cmd_get_health_informati struct nvme_health_information_page *payload, nvme_cb_fn_t cb_fn, void *cb_arg); +void nvme_ctrlr_cmd_get_firmware_page(struct nvme_controller *ctrlr, + struct nvme_firmware_page *payload, + nvme_cb_fn_t cb_fn, + void *cb_arg); void nvme_ctrlr_cmd_create_io_cq(struct nvme_controller *ctrlr, struct nvme_qpair *io_que, uint16_t vector, nvme_cb_fn_t cb_fn, void *cb_arg); From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 21:05:16 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 6722C387; Tue, 26 Mar 2013 21:05:16 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 59541F78; Tue, 26 Mar 2013 21:05:16 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QL5GNu011380; Tue, 26 Mar 2013 21:05:16 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QL5GNS011377; Tue, 26 Mar 2013 21:05:16 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262105.r2QL5GNS011377@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 21:05:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248759 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 21:05:16 -0000 Author: jimharris Date: Tue Mar 26 21:05:15 2013 New Revision: 248759 URL: http://svnweb.freebsd.org/changeset/base/248759 Log: When an asynchronous event request is completed, automatically fetch the specified log page. This satisfies the spec condition that future async events of the same type will not be sent until the associated log page is fetched. Sponsored by: Intel Reviewed by: carl Modified: head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_private.h Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 21:03:03 2013 (r248758) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 21:05:15 2013 (r248759) @@ -557,10 +557,65 @@ nvme_ctrlr_construct_namespaces(struct n return (0); } +static boolean_t +is_log_page_id_valid(uint8_t page_id) +{ + + switch (page_id) { + case NVME_LOG_ERROR: + case NVME_LOG_HEALTH_INFORMATION: + case NVME_LOG_FIRMWARE_SLOT: + return (TRUE); + } + + return (FALSE); +} + +static uint32_t +nvme_ctrlr_get_log_page_size(struct nvme_controller *ctrlr, uint8_t page_id) +{ + uint32_t log_page_size; + + switch (page_id) { + case NVME_LOG_ERROR: + log_page_size = min( + sizeof(struct nvme_error_information_entry) * + ctrlr->cdata.elpe, + NVME_MAX_AER_LOG_SIZE); + break; + case NVME_LOG_HEALTH_INFORMATION: + log_page_size = sizeof(struct nvme_health_information_page); + break; + case NVME_LOG_FIRMWARE_SLOT: + log_page_size = sizeof(struct nvme_firmware_page); + break; + default: + log_page_size = 0; + break; + } + + return (log_page_size); +} + +static void +nvme_ctrlr_async_event_log_page_cb(void *arg, const struct nvme_completion *cpl) +{ + struct nvme_async_event_request *aer = arg; + + nvme_notify_async_consumers(aer->ctrlr, &aer->cpl); + + /* + * Repost another asynchronous event request to replace the one + * that just completed. + */ + nvme_ctrlr_construct_and_submit_aer(aer->ctrlr, aer); +} + static void nvme_ctrlr_async_event_cb(void *arg, const struct nvme_completion *cpl) { - struct nvme_async_event_request *aer = arg; + struct nvme_async_event_request *aer = arg; + uint8_t log_page_id; if (cpl->status.sc == NVME_SC_ABORTED_SQ_DELETION) { /* @@ -572,16 +627,29 @@ nvme_ctrlr_async_event_cb(void *arg, con return; } - nvme_notify_async_consumers(aer->ctrlr, cpl); + printf("Asynchronous event occurred.\n"); - /* TODO: decode async event type based on status */ + /* Associated log page is in bits 23:16 of completion entry dw0. */ + log_page_id = (cpl->cdw0 & 0xFF0000) >> 16; - /* - * Repost another asynchronous event request to replace the one that - * just completed. - */ - printf("Asynchronous event occurred.\n"); - nvme_ctrlr_construct_and_submit_aer(aer->ctrlr, aer); + if (is_log_page_id_valid(log_page_id)) { + aer->log_page_size = nvme_ctrlr_get_log_page_size(aer->ctrlr, + log_page_id); + memcpy(&aer->cpl, cpl, sizeof(*cpl)); + nvme_ctrlr_cmd_get_log_page(aer->ctrlr, log_page_id, + NVME_GLOBAL_NAMESPACE_TAG, aer->log_page_buffer, + aer->log_page_size, nvme_ctrlr_async_event_log_page_cb, + aer); + /* Wait to notify consumers until after log page is fetched. */ + } else { + nvme_notify_async_consumers(aer->ctrlr, cpl); + + /* + * Repost another asynchronous event request to replace the one + * that just completed. + */ + nvme_ctrlr_construct_and_submit_aer(aer->ctrlr, aer); + } } static void Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 21:03:03 2013 (r248758) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 21:05:15 2013 (r248759) @@ -104,6 +104,9 @@ MALLOC_DECLARE(M_NVME); #define NVME_MIN_TIMEOUT_PERIOD (5) #define NVME_MAX_TIMEOUT_PERIOD (120) +/* Maximum log page size to fetch for AERs. */ +#define NVME_MAX_AER_LOG_SIZE (4096) + #ifndef CACHE_LINE_SIZE #define CACHE_LINE_SIZE (64) #endif @@ -126,6 +129,9 @@ struct nvme_async_event_request { struct nvme_controller *ctrlr; struct nvme_request *req; + struct nvme_completion cpl; + uint32_t log_page_size; + uint8_t log_page_buffer[NVME_MAX_AER_LOG_SIZE]; }; struct nvme_tracker { From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 21:08:33 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 56DB654E; Tue, 26 Mar 2013 21:08:33 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 3A673FB0; Tue, 26 Mar 2013 21:08:33 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QL8Xxb011956; Tue, 26 Mar 2013 21:08:33 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QL8W5j011951; Tue, 26 Mar 2013 21:08:32 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262108.r2QL8W5j011951@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 21:08:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248760 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 21:08:33 -0000 Author: jimharris Date: Tue Mar 26 21:08:32 2013 New Revision: 248760 URL: http://svnweb.freebsd.org/changeset/base/248760 Log: Pass associated log page data to async event consumers, if requested. Sponsored by: Intel Reviewed by: carl Modified: head/sys/dev/nvme/nvme.c head/sys/dev/nvme/nvme.h head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_private.h Modified: head/sys/dev/nvme/nvme.c ============================================================================== --- head/sys/dev/nvme/nvme.c Tue Mar 26 21:05:15 2013 (r248759) +++ head/sys/dev/nvme/nvme.c Tue Mar 26 21:08:32 2013 (r248760) @@ -331,7 +331,9 @@ nvme_notify_consumer(struct nvme_consume void nvme_notify_async_consumers(struct nvme_controller *ctrlr, - const struct nvme_completion *async_cpl) + const struct nvme_completion *async_cpl, + uint32_t log_page_id, void *log_page_buffer, + uint32_t log_page_size) { struct nvme_consumer *cons; uint32_t i; @@ -339,7 +341,8 @@ nvme_notify_async_consumers(struct nvme_ for (i = 0; i < NVME_MAX_CONSUMERS; i++) { cons = &nvme_consumer[i]; if (cons->id != INVALID_CONSUMER_ID && cons->async_fn != NULL) - (*cons->async_fn)(ctrlr->cons_cookie[i], async_cpl); + (*cons->async_fn)(ctrlr->cons_cookie[i], async_cpl, + log_page_id, log_page_buffer, log_page_size); } } Modified: head/sys/dev/nvme/nvme.h ============================================================================== --- head/sys/dev/nvme/nvme.h Tue Mar 26 21:05:15 2013 (r248759) +++ head/sys/dev/nvme/nvme.h Tue Mar 26 21:08:32 2013 (r248760) @@ -731,7 +731,8 @@ typedef void (*nvme_cb_fn_t)(void *, con typedef void *(*nvme_cons_ns_fn_t)(struct nvme_namespace *, void *); typedef void *(*nvme_cons_ctrlr_fn_t)(struct nvme_controller *); -typedef void (*nvme_cons_async_fn_t)(void *, const struct nvme_completion *); +typedef void (*nvme_cons_async_fn_t)(void *, const struct nvme_completion *, + uint32_t, void *, uint32_t); enum nvme_namespace_flags { NVME_NS_DEALLOCATE_SUPPORTED = 0x1, Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 21:05:15 2013 (r248759) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 21:08:32 2013 (r248760) @@ -602,7 +602,21 @@ nvme_ctrlr_async_event_log_page_cb(void { struct nvme_async_event_request *aer = arg; - nvme_notify_async_consumers(aer->ctrlr, &aer->cpl); + /* + * If the log page fetch for some reason completed with an error, + * don't pass log page data to the consumers. In practice, this case + * should never happen. + */ + if (nvme_completion_is_error(cpl)) + nvme_notify_async_consumers(aer->ctrlr, &aer->cpl, + aer->log_page_id, NULL, 0); + else + /* + * Pass the cpl data from the original async event completion, + * not the log page fetch. + */ + nvme_notify_async_consumers(aer->ctrlr, &aer->cpl, + aer->log_page_id, aer->log_page_buffer, aer->log_page_size); /* * Repost another asynchronous event request to replace the one @@ -615,7 +629,6 @@ static void nvme_ctrlr_async_event_cb(void *arg, const struct nvme_completion *cpl) { struct nvme_async_event_request *aer = arg; - uint8_t log_page_id; if (cpl->status.sc == NVME_SC_ABORTED_SQ_DELETION) { /* @@ -630,19 +643,20 @@ nvme_ctrlr_async_event_cb(void *arg, con printf("Asynchronous event occurred.\n"); /* Associated log page is in bits 23:16 of completion entry dw0. */ - log_page_id = (cpl->cdw0 & 0xFF0000) >> 16; + aer->log_page_id = (cpl->cdw0 & 0xFF0000) >> 16; - if (is_log_page_id_valid(log_page_id)) { + if (is_log_page_id_valid(aer->log_page_id)) { aer->log_page_size = nvme_ctrlr_get_log_page_size(aer->ctrlr, - log_page_id); + aer->log_page_id); memcpy(&aer->cpl, cpl, sizeof(*cpl)); - nvme_ctrlr_cmd_get_log_page(aer->ctrlr, log_page_id, + nvme_ctrlr_cmd_get_log_page(aer->ctrlr, aer->log_page_id, NVME_GLOBAL_NAMESPACE_TAG, aer->log_page_buffer, aer->log_page_size, nvme_ctrlr_async_event_log_page_cb, aer); /* Wait to notify consumers until after log page is fetched. */ } else { - nvme_notify_async_consumers(aer->ctrlr, cpl); + nvme_notify_async_consumers(aer->ctrlr, cpl, aer->log_page_id, + NULL, 0); /* * Repost another asynchronous event request to replace the one Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 21:05:15 2013 (r248759) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 21:08:32 2013 (r248760) @@ -130,6 +130,7 @@ struct nvme_async_event_request { struct nvme_controller *ctrlr; struct nvme_request *req; struct nvme_completion cpl; + uint32_t log_page_id; uint32_t log_page_size; uint8_t log_page_buffer[NVME_MAX_AER_LOG_SIZE]; }; @@ -475,6 +476,8 @@ nvme_allocate_request_uio(struct uio *ui #define nvme_free_request(req) uma_zfree(nvme_request_zone, req) void nvme_notify_async_consumers(struct nvme_controller *ctrlr, - const struct nvme_completion *async_cpl); + const struct nvme_completion *async_cpl, + uint32_t log_page_id, void *log_page_buffer, + uint32_t log_page_size); #endif /* __NVME_PRIVATE_H__ */ From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 21:14:52 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C7C967CC; Tue, 26 Mar 2013 21:14:52 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id AAF7682; Tue, 26 Mar 2013 21:14:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QLEqIB014664; Tue, 26 Mar 2013 21:14:52 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QLEpLD014658; Tue, 26 Mar 2013 21:14:51 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262114.r2QLEpLD014658@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 21:14:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248761 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 21:14:52 -0000 Author: jimharris Date: Tue Mar 26 21:14:51 2013 New Revision: 248761 URL: http://svnweb.freebsd.org/changeset/base/248761 Log: Cap the number of retry attempts to a configurable number. This ensures that if a specific I/O repeatedly times out, we don't retry it indefinitely. The default number of retries will be 4, but is adjusted using hw.nvme.retry_count. Sponsored by: Intel Reviewed by: carl Modified: head/sys/dev/nvme/nvme.c head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_private.h head/sys/dev/nvme/nvme_qpair.c Modified: head/sys/dev/nvme/nvme.c ============================================================================== --- head/sys/dev/nvme/nvme.c Tue Mar 26 21:08:32 2013 (r248760) +++ head/sys/dev/nvme/nvme.c Tue Mar 26 21:14:51 2013 (r248761) @@ -49,7 +49,8 @@ struct nvme_consumer { struct nvme_consumer nvme_consumer[NVME_MAX_CONSUMERS]; #define INVALID_CONSUMER_ID 0xFFFF -uma_zone_t nvme_request_zone; +uma_zone_t nvme_request_zone; +int32_t nvme_retry_count; MALLOC_DEFINE(M_NVME, "nvme", "nvme(4) memory allocations"); Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 21:08:32 2013 (r248760) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 21:14:51 2013 (r248761) @@ -731,6 +731,10 @@ nvme_ctrlr_start(void *ctrlr_arg) struct nvme_controller *ctrlr = ctrlr_arg; int i; + nvme_qpair_reset(&ctrlr->adminq); + for (i = 0; i < ctrlr->num_io_queues; i++) + nvme_qpair_reset(&ctrlr->ioq[i]); + nvme_admin_qpair_enable(&ctrlr->adminq); if (nvme_ctrlr_identify(ctrlr) != 0) @@ -929,6 +933,9 @@ nvme_ctrlr_construct(struct nvme_control timeout_period = max(timeout_period, NVME_MIN_TIMEOUT_PERIOD); ctrlr->timeout_period = timeout_period; + nvme_retry_count = NVME_DEFAULT_RETRY_COUNT; + TUNABLE_INT_FETCH("hw.nvme.retry_count", &nvme_retry_count); + per_cpu_io_queues = 1; TUNABLE_INT_FETCH("hw.nvme.per_cpu_io_queues", &per_cpu_io_queues); ctrlr->per_cpu_io_queues = per_cpu_io_queues ? TRUE : FALSE; Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 21:08:32 2013 (r248760) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 21:14:51 2013 (r248761) @@ -104,6 +104,8 @@ MALLOC_DECLARE(M_NVME); #define NVME_MIN_TIMEOUT_PERIOD (5) #define NVME_MAX_TIMEOUT_PERIOD (120) +#define NVME_DEFAULT_RETRY_COUNT (4) + /* Maximum log page size to fetch for AERs. */ #define NVME_MAX_AER_LOG_SIZE (4096) @@ -111,7 +113,8 @@ MALLOC_DECLARE(M_NVME); #define CACHE_LINE_SIZE (64) #endif -extern uma_zone_t nvme_request_zone; +extern uma_zone_t nvme_request_zone; +extern int32_t nvme_retry_count; struct nvme_request { @@ -122,6 +125,7 @@ struct nvme_request { struct uio *uio; nvme_cb_fn_t cb_fn; void *cb_arg; + int32_t retries; STAILQ_ENTRY(nvme_request) stailq; }; @@ -409,6 +413,7 @@ void nvme_qpair_submit_tracker(struct nv void nvme_qpair_process_completions(struct nvme_qpair *qpair); void nvme_qpair_submit_request(struct nvme_qpair *qpair, struct nvme_request *req); +void nvme_qpair_reset(struct nvme_qpair *qpair); void nvme_admin_qpair_enable(struct nvme_qpair *qpair); void nvme_admin_qpair_disable(struct nvme_qpair *qpair); Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 21:08:32 2013 (r248760) +++ head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 21:14:51 2013 (r248761) @@ -105,7 +105,8 @@ nvme_qpair_complete_tracker(struct nvme_ req = tr->req; error = nvme_completion_is_error(cpl); - retry = error && nvme_completion_is_retry(cpl); + retry = error && nvme_completion_is_retry(cpl) && + req->retries < nvme_retry_count; if (error && print_on_error) { nvme_dump_completion(cpl); @@ -122,9 +123,10 @@ nvme_qpair_complete_tracker(struct nvme_ mtx_lock(&qpair->lock); callout_stop(&tr->timer); - if (retry) + if (retry) { + req->retries++; nvme_qpair_submit_tracker(qpair, tr); - else { + } else { if (req->payload_size > 0 || req->uio != NULL) bus_dmamap_unload(qpair->dma_tag, tr->payload_dma_map); @@ -568,6 +570,12 @@ nvme_qpair_enable(struct nvme_qpair *qpa { qpair->is_enabled = TRUE; +} + +void +nvme_qpair_reset(struct nvme_qpair *qpair) +{ + qpair->sq_head = qpair->sq_tail = qpair->cq_head = 0; /* @@ -597,19 +605,25 @@ nvme_io_qpair_enable(struct nvme_qpair * { STAILQ_HEAD(, nvme_request) temp; struct nvme_tracker *tr; + struct nvme_tracker *tr_temp; struct nvme_request *req; + /* + * Manually abort each outstanding I/O. This normally results in a + * retry, unless the retry count on the associated request has + * reached its limit. + */ + TAILQ_FOREACH_SAFE(tr, &qpair->outstanding_tr, tailq, tr_temp) { + device_printf(qpair->ctrlr->dev, + "aborting outstanding i/o\n"); + nvme_qpair_manual_complete_tracker(qpair, tr, NVME_SCT_GENERIC, + NVME_SC_ABORTED_BY_REQUEST, TRUE); + } + mtx_lock(&qpair->lock); nvme_qpair_enable(qpair); - TAILQ_FOREACH(tr, &qpair->outstanding_tr, tailq) { - device_printf(qpair->ctrlr->dev, - "resubmitting outstanding i/o\n"); - nvme_dump_command(&tr->req->cmd); - nvme_qpair_submit_tracker(qpair, tr); - } - STAILQ_INIT(&temp); STAILQ_SWAP(&qpair->queued_req, &temp, nvme_request); From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 21:16:54 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id AF8C59A9; Tue, 26 Mar 2013 21:16:54 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 8900ADA; Tue, 26 Mar 2013 21:16:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QLGsUL014992; Tue, 26 Mar 2013 21:16:54 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QLGssV014990; Tue, 26 Mar 2013 21:16:54 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262116.r2QLGssV014990@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 21:16:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248762 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 21:16:54 -0000 Author: jimharris Date: Tue Mar 26 21:16:53 2013 New Revision: 248762 URL: http://svnweb.freebsd.org/changeset/base/248762 Log: Ensure the controller's MDTS is accounted for in max_xfer_size. The controller's IDENTIFY data contains MDTS (Max Data Transfer Size) to allow the controller to specify the maximum I/O data transfer size. nvme(4) already provides a default maximum, but make sure it does not exceed what MDTS reports. Sponsored by: Intel Reviewed by: carl Modified: head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_private.h Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 21:14:51 2013 (r248761) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 21:16:53 2013 (r248762) @@ -457,6 +457,14 @@ nvme_ctrlr_identify(struct nvme_controll nvme_chatham_populate_cdata(ctrlr); #endif + /* + * Use MDTS to ensure our default max_xfer_size doesn't exceed what the + * controller supports. + */ + if (ctrlr->cdata.mdts > 0) + ctrlr->max_xfer_size = min(ctrlr->max_xfer_size, + ctrlr->min_page_size * (1 << (ctrlr->cdata.mdts))); + return (0); } @@ -923,6 +931,8 @@ nvme_ctrlr_construct(struct nvme_control if (cap_hi.bits.dstrd != 0) return (ENXIO); + ctrlr->min_page_size = 1 << (12 + cap_hi.bits.mpsmin); + /* Get ready timeout value from controller, in units of 500ms. */ cap_lo.raw = nvme_mmio_read_4(ctrlr, cap_lo); ctrlr->ready_timeout_in_ms = cap_lo.bits.to * 500; Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 21:14:51 2013 (r248761) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 21:16:53 2013 (r248762) @@ -265,6 +265,9 @@ struct nvme_controller { /** maximum i/o size in bytes */ uint32_t max_xfer_size; + /** minimum page size supported by this controller in bytes */ + uint32_t min_page_size; + /** interrupt coalescing time period (in microseconds) */ uint32_t int_coal_time; From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 21:19:27 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 8C8FBC77; Tue, 26 Mar 2013 21:19:27 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 7E5AE118; Tue, 26 Mar 2013 21:19:27 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QLJR5p015550; Tue, 26 Mar 2013 21:19:27 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QLJQ8W015545; Tue, 26 Mar 2013 21:19:26 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262119.r2QLJQ8W015545@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 21:19:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248763 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 21:19:27 -0000 Author: jimharris Date: Tue Mar 26 21:19:26 2013 New Revision: 248763 URL: http://svnweb.freebsd.org/changeset/base/248763 Log: Remove the is_started flag from struct nvme_controller. This flag was originally added to communicate to the sysctl code which oids should be built, but there are easier ways to do this. This needs to be cleaned up prior to adding new controller states - for example, controller failure. Sponsored by: Intel Reviewed by: carl Modified: head/sys/dev/nvme/nvme.c head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_private.h head/sys/dev/nvme/nvme_sysctl.c Modified: head/sys/dev/nvme/nvme.c ============================================================================== --- head/sys/dev/nvme/nvme.c Tue Mar 26 21:16:53 2013 (r248762) +++ head/sys/dev/nvme/nvme.c Tue Mar 26 21:19:26 2013 (r248763) @@ -283,7 +283,9 @@ nvme_attach(device_t dev) if (status != 0) return (status); - ctrlr->config_hook.ich_func = nvme_ctrlr_start; + nvme_sysctl_initialize_ctrlr(ctrlr); + + ctrlr->config_hook.ich_func = nvme_ctrlr_start_config_hook; ctrlr->config_hook.ich_arg = ctrlr; config_intrhook_establish(&ctrlr->config_hook); Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 21:16:53 2013 (r248762) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 21:19:26 2013 (r248763) @@ -733,7 +733,7 @@ nvme_ctrlr_configure_int_coalescing(stru ctrlr->int_coal_threshold, NULL, NULL); } -void +static void nvme_ctrlr_start(void *ctrlr_arg) { struct nvme_controller *ctrlr = ctrlr_arg; @@ -746,40 +746,31 @@ nvme_ctrlr_start(void *ctrlr_arg) nvme_admin_qpair_enable(&ctrlr->adminq); if (nvme_ctrlr_identify(ctrlr) != 0) - goto err; + return; if (nvme_ctrlr_set_num_qpairs(ctrlr) != 0) - goto err; + return; if (nvme_ctrlr_create_qpairs(ctrlr) != 0) - goto err; + return; if (nvme_ctrlr_construct_namespaces(ctrlr) != 0) - goto err; + return; nvme_ctrlr_configure_aer(ctrlr); nvme_ctrlr_configure_int_coalescing(ctrlr); for (i = 0; i < ctrlr->num_io_queues; i++) nvme_io_qpair_enable(&ctrlr->ioq[i]); +} - ctrlr->is_started = TRUE; - -err: - - if (ctrlr->num_start_attempts == 0) { - /* - * Initialize sysctls, even if controller failed to start, to - * assist with debugging admin queue pair. Only run this - * code on the initial start attempt though, and not - * subsequent start attempts due to controller-level resets. - * - */ - nvme_sysctl_initialize_ctrlr(ctrlr); - config_intrhook_disestablish(&ctrlr->config_hook); - } +void +nvme_ctrlr_start_config_hook(void *arg) +{ + struct nvme_controller *ctrlr = arg; - ctrlr->num_start_attempts++; + nvme_ctrlr_start(ctrlr); + config_intrhook_disestablish(&ctrlr->config_hook); } static void @@ -906,8 +897,6 @@ nvme_ctrlr_construct(struct nvme_control int timeout_period; ctrlr->dev = dev; - ctrlr->is_started = FALSE; - ctrlr->num_start_attempts = 0; status = nvme_ctrlr_allocate_bar(ctrlr); Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 21:16:53 2013 (r248762) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 21:19:26 2013 (r248763) @@ -250,7 +250,6 @@ struct nvme_controller { struct intr_config_hook config_hook; uint32_t ns_identified; uint32_t queues_created; - uint32_t num_start_attempts; struct task reset_task; struct taskqueue *taskqueue; @@ -287,8 +286,6 @@ struct nvme_controller { struct cdev *cdev; - boolean_t is_started; - uint32_t num_aers; struct nvme_async_event_request aer[NVME_MAX_ASYNC_EVENTS]; @@ -401,7 +398,7 @@ void nvme_ctrlr_destruct(struct nvme_con int nvme_ctrlr_hw_reset(struct nvme_controller *ctrlr); void nvme_ctrlr_reset(struct nvme_controller *ctrlr); /* ctrlr defined as void * to allow use with config_intrhook. */ -void nvme_ctrlr_start(void *ctrlr_arg); +void nvme_ctrlr_start_config_hook(void *ctrlr_arg); void nvme_ctrlr_submit_admin_request(struct nvme_controller *ctrlr, struct nvme_request *req); void nvme_ctrlr_submit_io_request(struct nvme_controller *ctrlr, Modified: head/sys/dev/nvme/nvme_sysctl.c ============================================================================== --- head/sys/dev/nvme/nvme_sysctl.c Tue Mar 26 21:16:53 2013 (r248762) +++ head/sys/dev/nvme/nvme_sysctl.c Tue Mar 26 21:19:26 2013 (r248763) @@ -251,38 +251,36 @@ nvme_sysctl_initialize_ctrlr(struct nvme ctrlr_tree = device_get_sysctl_tree(ctrlr->dev); ctrlr_list = SYSCTL_CHILDREN(ctrlr_tree); - if (ctrlr->is_started) { - SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, - "int_coal_time", CTLTYPE_UINT | CTLFLAG_RW, ctrlr, 0, - nvme_sysctl_int_coal_time, "IU", - "Interrupt coalescing timeout (in microseconds)"); - - SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, - "int_coal_threshold", CTLTYPE_UINT | CTLFLAG_RW, ctrlr, 0, - nvme_sysctl_int_coal_threshold, "IU", - "Interrupt coalescing threshold"); - - SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, - "timeout_period", CTLTYPE_UINT | CTLFLAG_RW, ctrlr, 0, - nvme_sysctl_timeout_period, "IU", - "Timeout period (in seconds)"); - - SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, - "num_cmds", CTLTYPE_S64 | CTLFLAG_RD, - ctrlr, 0, nvme_sysctl_num_cmds, "IU", - "Number of commands submitted"); - - SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, - "num_intr_handler_calls", CTLTYPE_S64 | CTLFLAG_RD, - ctrlr, 0, nvme_sysctl_num_intr_handler_calls, "IU", - "Number of times interrupt handler was invoked (will " - "typically be less than number of actual interrupts " - "generated due to coalescing)"); - - SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, - "reset_stats", CTLTYPE_UINT | CTLFLAG_RW, ctrlr, 0, - nvme_sysctl_reset_stats, "IU", "Reset statistics to zero"); - } + SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, + "int_coal_time", CTLTYPE_UINT | CTLFLAG_RW, ctrlr, 0, + nvme_sysctl_int_coal_time, "IU", + "Interrupt coalescing timeout (in microseconds)"); + + SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, + "int_coal_threshold", CTLTYPE_UINT | CTLFLAG_RW, ctrlr, 0, + nvme_sysctl_int_coal_threshold, "IU", + "Interrupt coalescing threshold"); + + SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, + "timeout_period", CTLTYPE_UINT | CTLFLAG_RW, ctrlr, 0, + nvme_sysctl_timeout_period, "IU", + "Timeout period (in seconds)"); + + SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, + "num_cmds", CTLTYPE_S64 | CTLFLAG_RD, + ctrlr, 0, nvme_sysctl_num_cmds, "IU", + "Number of commands submitted"); + + SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, + "num_intr_handler_calls", CTLTYPE_S64 | CTLFLAG_RD, + ctrlr, 0, nvme_sysctl_num_intr_handler_calls, "IU", + "Number of times interrupt handler was invoked (will " + "typically be less than number of actual interrupts " + "generated due to coalescing)"); + + SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, + "reset_stats", CTLTYPE_UINT | CTLFLAG_RW, ctrlr, 0, + nvme_sysctl_reset_stats, "IU", "Reset statistics to zero"); que_tree = SYSCTL_ADD_NODE(ctrlr_ctx, ctrlr_list, OID_AUTO, "adminq", CTLFLAG_RD, NULL, "Admin Queue"); From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 21:42:54 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 24DBE6AC; Tue, 26 Mar 2013 21:42:54 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 14824242; Tue, 26 Mar 2013 21:42:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QLgrps024121; Tue, 26 Mar 2013 21:42:53 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QLgr0J024120; Tue, 26 Mar 2013 21:42:53 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262142.r2QLgr0J024120@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 21:42:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248764 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 21:42:54 -0000 Author: jimharris Date: Tue Mar 26 21:42:53 2013 New Revision: 248764 URL: http://svnweb.freebsd.org/changeset/base/248764 Log: Set Pre-boot Software Load Count to 0 at the end of the controller start process. The spec indicates the OS driver should use Set Features (Software Progress Marker) to set the pre-boot software load count to 0 after the OS driver has successfully been initialized. This allows pre-boot software to determine if there have been any issues with the OS loading. Sponsored by: Intel Reviewed by: carl Modified: head/sys/dev/nvme/nvme_ctrlr.c Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 21:19:26 2013 (r248763) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 21:42:53 2013 (r248764) @@ -762,6 +762,16 @@ nvme_ctrlr_start(void *ctrlr_arg) for (i = 0; i < ctrlr->num_io_queues; i++) nvme_io_qpair_enable(&ctrlr->ioq[i]); + + /* + * Clear software progress marker to 0, to indicate to pre-boot + * software that OS driver load was successful. + * + * Chatham does not support this feature. + */ + if (pci_get_devid(ctrlr->dev) != CHATHAM_PCI_ID) + nvme_ctrlr_cmd_set_feature(ctrlr, + NVME_FEAT_SOFTWARE_PROGRESS_MARKER, 0, NULL, 0, NULL, NULL); } void From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 21:45:38 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 7896487A; Tue, 26 Mar 2013 21:45:38 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 6976626A; Tue, 26 Mar 2013 21:45:38 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QLjcFY024569; Tue, 26 Mar 2013 21:45:38 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QLjcS9024568; Tue, 26 Mar 2013 21:45:38 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262145.r2QLjcS9024568@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 21:45:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248765 - head/sys/dev/nvd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 21:45:38 -0000 Author: jimharris Date: Tue Mar 26 21:45:37 2013 New Revision: 248765 URL: http://svnweb.freebsd.org/changeset/base/248765 Log: Have nvd(4) register for controller notifications. Also have nvd maintain controller/namespace relationships internally. Sponsored by: Intel Reviewed by: carl Modified: head/sys/dev/nvd/nvd.c Modified: head/sys/dev/nvd/nvd.c ============================================================================== --- head/sys/dev/nvd/nvd.c Tue Mar 26 21:42:53 2013 (r248764) +++ head/sys/dev/nvd/nvd.c Tue Mar 26 21:45:37 2013 (r248765) @@ -45,9 +45,11 @@ struct nvd_disk; static disk_ioctl_t nvd_ioctl; static disk_strategy_t nvd_strategy; -static void *create_geom_disk(struct nvme_namespace *ns, void *ctrlr); +static void *nvd_new_disk(struct nvme_namespace *ns, void *ctrlr); static void destroy_geom_disk(struct nvd_disk *ndisk); +static void *nvd_new_controller(struct nvme_controller *ctrlr); + static int nvd_load(void); static void nvd_unload(void); @@ -67,10 +69,18 @@ struct nvd_disk { uint32_t cur_depth; - TAILQ_ENTRY(nvd_disk) tailq; + TAILQ_ENTRY(nvd_disk) global_tailq; + TAILQ_ENTRY(nvd_disk) ctrlr_tailq; +}; + +struct nvd_controller { + + TAILQ_ENTRY(nvd_controller) tailq; + TAILQ_HEAD(, nvd_disk) disk_head; }; -TAILQ_HEAD(, nvd_disk) nvd_head; +static TAILQ_HEAD(, nvd_controller) ctrlr_head; +static TAILQ_HEAD(disk_list, nvd_disk) disk_head; static int nvd_modevent(module_t mod, int type, void *arg) { @@ -104,8 +114,11 @@ static int nvd_load() { - TAILQ_INIT(&nvd_head); - consumer_handle = nvme_register_consumer(create_geom_disk, NULL, NULL); + TAILQ_INIT(&ctrlr_head); + TAILQ_INIT(&disk_head); + + consumer_handle = nvme_register_consumer(nvd_new_disk, + nvd_new_controller, NULL); return (consumer_handle != NULL ? 0 : -1); } @@ -113,13 +126,20 @@ nvd_load() static void nvd_unload() { - struct nvd_disk *nvd; + struct nvd_controller *ctrlr; + struct nvd_disk *disk; + + while (!TAILQ_EMPTY(&ctrlr_head)) { + ctrlr = TAILQ_FIRST(&ctrlr_head); + TAILQ_REMOVE(&ctrlr_head, ctrlr, tailq); + free(ctrlr, M_NVD); + } - while (!TAILQ_EMPTY(&nvd_head)) { - nvd = TAILQ_FIRST(&nvd_head); - TAILQ_REMOVE(&nvd_head, nvd, tailq); - destroy_geom_disk(nvd); - free(nvd, M_NVD); + while (!TAILQ_EMPTY(&disk_head)) { + disk = TAILQ_FIRST(&disk_head); + TAILQ_REMOVE(&disk_head, disk, global_tailq); + destroy_geom_disk(disk); + free(disk, M_NVD); } nvme_unregister_consumer(consumer_handle); @@ -234,10 +254,25 @@ nvd_bioq_process(void *arg, int pending) } static void * -create_geom_disk(struct nvme_namespace *ns, void *ctrlr) +nvd_new_controller(struct nvme_controller *ctrlr) { - struct nvd_disk *ndisk; - struct disk *disk; + struct nvd_controller *nvd_ctrlr; + + nvd_ctrlr = malloc(sizeof(struct nvd_controller), M_NVD, + M_ZERO | M_NOWAIT); + + TAILQ_INIT(&nvd_ctrlr->disk_head); + TAILQ_INSERT_TAIL(&ctrlr_head, nvd_ctrlr, tailq); + + return (nvd_ctrlr); +} + +static void * +nvd_new_disk(struct nvme_namespace *ns, void *ctrlr_arg) +{ + struct nvd_disk *ndisk; + struct disk *disk; + struct nvd_controller *ctrlr = ctrlr_arg; ndisk = malloc(sizeof(struct nvd_disk), M_NVD, M_ZERO | M_NOWAIT); @@ -251,10 +286,11 @@ create_geom_disk(struct nvme_namespace * disk->d_sectorsize = nvme_ns_get_sector_size(ns); disk->d_mediasize = (off_t)nvme_ns_get_size(ns); - if (TAILQ_EMPTY(&nvd_head)) + if (TAILQ_EMPTY(&disk_head)) disk->d_unit = 0; else - disk->d_unit = TAILQ_FIRST(&nvd_head)->disk->d_unit + 1; + disk->d_unit = + TAILQ_LAST(&disk_head, disk_list)->disk->d_unit + 1; disk->d_flags = 0; @@ -286,7 +322,8 @@ create_geom_disk(struct nvme_namespace * taskqueue_thread_enqueue, &ndisk->tq); taskqueue_start_threads(&ndisk->tq, 1, PI_DISK, "nvd taskq"); - TAILQ_INSERT_HEAD(&nvd_head, ndisk, tailq); + TAILQ_INSERT_TAIL(&disk_head, ndisk, global_tailq); + TAILQ_INSERT_TAIL(&ctrlr->disk_head, ndisk, ctrlr_tailq); return (NULL); } From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 21:48:42 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 19154A7A; Tue, 26 Mar 2013 21:48:42 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 0B7D52AF; Tue, 26 Mar 2013 21:48:42 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QLmf4n024998; Tue, 26 Mar 2013 21:48:41 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QLmf1N024996; Tue, 26 Mar 2013 21:48:41 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262148.r2QLmf1N024996@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 21:48:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248766 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 21:48:42 -0000 Author: jimharris Date: Tue Mar 26 21:48:41 2013 New Revision: 248766 URL: http://svnweb.freebsd.org/changeset/base/248766 Log: Just disable the controller instead of deleting IO queues during detach. This is just as effective, and removes the need for a bunch of admin commands to a controller that's going to be disabled shortly anyways. Sponsored by: Intel Reviewed by: carl Modified: head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_qpair.c Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 21:45:37 2013 (r248765) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 21:48:41 2013 (r248766) @@ -1013,6 +1013,7 @@ nvme_ctrlr_destruct(struct nvme_controll { int i; + nvme_ctrlr_disable(ctrlr); taskqueue_free(ctrlr->taskqueue); for (i = 0; i < NVME_MAX_NAMESPACES; i++) Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 21:45:37 2013 (r248765) +++ head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 21:48:41 2013 (r248766) @@ -324,6 +324,21 @@ nvme_qpair_destroy(struct nvme_qpair *qp bus_release_resource(qpair->ctrlr->dev, SYS_RES_IRQ, rman_get_rid(qpair->res), qpair->res); + if (qpair->cmd) { + bus_dmamap_unload(qpair->dma_tag, qpair->cmd_dma_map); + bus_dmamap_destroy(qpair->dma_tag, qpair->cmd_dma_map); + contigfree(qpair->cmd, + qpair->num_entries * sizeof(struct nvme_command), M_NVME); + } + + if (qpair->cpl) { + bus_dmamap_unload(qpair->dma_tag, qpair->cpl_dma_map); + bus_dmamap_destroy(qpair->dma_tag, qpair->cpl_dma_map); + contigfree(qpair->cpl, + qpair->num_entries * sizeof(struct nvme_completion), + M_NVME); + } + if (qpair->dma_tag) bus_dma_tag_destroy(qpair->dma_tag); @@ -362,72 +377,14 @@ nvme_admin_qpair_destroy(struct nvme_qpa { nvme_admin_qpair_abort_aers(qpair); - - /* - * For NVMe, you don't send delete queue commands for the admin - * queue, so we just need to unload and free the cmd and cpl memory. - */ - bus_dmamap_unload(qpair->dma_tag, qpair->cmd_dma_map); - bus_dmamap_destroy(qpair->dma_tag, qpair->cmd_dma_map); - - contigfree(qpair->cmd, - qpair->num_entries * sizeof(struct nvme_command), M_NVME); - - bus_dmamap_unload(qpair->dma_tag, qpair->cpl_dma_map); - bus_dmamap_destroy(qpair->dma_tag, qpair->cpl_dma_map); - contigfree(qpair->cpl, - qpair->num_entries * sizeof(struct nvme_completion), M_NVME); - nvme_qpair_destroy(qpair); } -static void -nvme_free_cmd_ring(void *arg, const struct nvme_completion *status) -{ - struct nvme_qpair *qpair; - - qpair = (struct nvme_qpair *)arg; - bus_dmamap_unload(qpair->dma_tag, qpair->cmd_dma_map); - bus_dmamap_destroy(qpair->dma_tag, qpair->cmd_dma_map); - contigfree(qpair->cmd, - qpair->num_entries * sizeof(struct nvme_command), M_NVME); - qpair->cmd = NULL; -} - -static void -nvme_free_cpl_ring(void *arg, const struct nvme_completion *status) -{ - struct nvme_qpair *qpair; - - qpair = (struct nvme_qpair *)arg; - bus_dmamap_unload(qpair->dma_tag, qpair->cpl_dma_map); - bus_dmamap_destroy(qpair->dma_tag, qpair->cpl_dma_map); - contigfree(qpair->cpl, - qpair->num_entries * sizeof(struct nvme_completion), M_NVME); - qpair->cpl = NULL; -} - void nvme_io_qpair_destroy(struct nvme_qpair *qpair) { - struct nvme_controller *ctrlr = qpair->ctrlr; - - if (qpair->num_entries > 0) { - nvme_ctrlr_cmd_delete_io_sq(ctrlr, qpair, nvme_free_cmd_ring, - qpair); - /* Spin until free_cmd_ring sets qpair->cmd to NULL. */ - while (qpair->cmd) - DELAY(5); - - nvme_ctrlr_cmd_delete_io_cq(ctrlr, qpair, nvme_free_cpl_ring, - qpair); - /* Spin until free_cpl_ring sets qpair->cmd to NULL. */ - while (qpair->cpl) - DELAY(5); - - nvme_qpair_destroy(qpair); - } + nvme_qpair_destroy(qpair); } static void From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 21:58:40 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E4D7CE92; Tue, 26 Mar 2013 21:58:40 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id C7EB83E8; Tue, 26 Mar 2013 21:58:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QLweTw027885; Tue, 26 Mar 2013 21:58:40 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QLwdPx027878; Tue, 26 Mar 2013 21:58:39 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262158.r2QLwdPx027878@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 21:58:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248767 - in head/sys/dev: nvd nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 21:58:41 -0000 Author: jimharris Date: Tue Mar 26 21:58:38 2013 New Revision: 248767 URL: http://svnweb.freebsd.org/changeset/base/248767 Log: Add the ability to internally mark a controller as failed, if it is unable to start or reset. Also add a notifier for NVMe consumers for controller fail conditions and plumb this notifier for nvd(4) to destroy the associated GEOM disks when a failure occurs. This requires a bit of work to cover the races when a consumer is sending I/O requests to a controller that is transitioning to the failed state. To help cover this condition, add a task to defer completion of I/Os submitted to a failed controller, so that the consumer will still always receive its completions in a different context than the submission. Sponsored by: Intel Reviewed by: carl Modified: head/sys/dev/nvd/nvd.c head/sys/dev/nvme/nvme.c head/sys/dev/nvme/nvme.h head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_private.h head/sys/dev/nvme/nvme_qpair.c Modified: head/sys/dev/nvd/nvd.c ============================================================================== --- head/sys/dev/nvd/nvd.c Tue Mar 26 21:48:41 2013 (r248766) +++ head/sys/dev/nvd/nvd.c Tue Mar 26 21:58:38 2013 (r248767) @@ -49,6 +49,7 @@ static void *nvd_new_disk(struct nvme_na static void destroy_geom_disk(struct nvd_disk *ndisk); static void *nvd_new_controller(struct nvme_controller *ctrlr); +static void nvd_controller_fail(void *ctrlr); static int nvd_load(void); static void nvd_unload(void); @@ -118,7 +119,7 @@ nvd_load() TAILQ_INIT(&disk_head); consumer_handle = nvme_register_consumer(nvd_new_disk, - nvd_new_controller, NULL); + nvd_new_controller, NULL, nvd_controller_fail); return (consumer_handle != NULL ? 0 : -1); } @@ -351,3 +352,22 @@ destroy_geom_disk(struct nvd_disk *ndisk mtx_destroy(&ndisk->bioqlock); } + +static void +nvd_controller_fail(void *ctrlr_arg) +{ + struct nvd_controller *ctrlr = ctrlr_arg; + struct nvd_disk *disk; + + while (!TAILQ_EMPTY(&ctrlr->disk_head)) { + disk = TAILQ_FIRST(&ctrlr->disk_head); + TAILQ_REMOVE(&disk_head, disk, global_tailq); + TAILQ_REMOVE(&ctrlr->disk_head, disk, ctrlr_tailq); + destroy_geom_disk(disk); + free(disk, M_NVD); + } + + TAILQ_REMOVE(&ctrlr_head, ctrlr, tailq); + free(ctrlr, M_NVD); +} + Modified: head/sys/dev/nvme/nvme.c ============================================================================== --- head/sys/dev/nvme/nvme.c Tue Mar 26 21:48:41 2013 (r248766) +++ head/sys/dev/nvme/nvme.c Tue Mar 26 21:58:38 2013 (r248767) @@ -44,6 +44,7 @@ struct nvme_consumer { nvme_cons_ns_fn_t ns_fn; nvme_cons_ctrlr_fn_t ctrlr_fn; nvme_cons_async_fn_t async_fn; + nvme_cons_fail_fn_t fail_fn; }; struct nvme_consumer nvme_consumer[NVME_MAX_CONSUMERS]; @@ -349,9 +350,23 @@ nvme_notify_async_consumers(struct nvme_ } } +void +nvme_notify_fail_consumers(struct nvme_controller *ctrlr) +{ + struct nvme_consumer *cons; + uint32_t i; + + for (i = 0; i < NVME_MAX_CONSUMERS; i++) { + cons = &nvme_consumer[i]; + if (cons->id != INVALID_CONSUMER_ID && cons->fail_fn != NULL) + cons->fail_fn(ctrlr->cons_cookie[i]); + } +} + struct nvme_consumer * nvme_register_consumer(nvme_cons_ns_fn_t ns_fn, nvme_cons_ctrlr_fn_t ctrlr_fn, - nvme_cons_async_fn_t async_fn) + nvme_cons_async_fn_t async_fn, + nvme_cons_fail_fn_t fail_fn) { int i; @@ -365,6 +380,7 @@ nvme_register_consumer(nvme_cons_ns_fn_t nvme_consumer[i].ns_fn = ns_fn; nvme_consumer[i].ctrlr_fn = ctrlr_fn; nvme_consumer[i].async_fn = async_fn; + nvme_consumer[i].fail_fn = fail_fn; nvme_notify_consumer(&nvme_consumer[i]); return (&nvme_consumer[i]); Modified: head/sys/dev/nvme/nvme.h ============================================================================== --- head/sys/dev/nvme/nvme.h Tue Mar 26 21:48:41 2013 (r248766) +++ head/sys/dev/nvme/nvme.h Tue Mar 26 21:58:38 2013 (r248767) @@ -733,6 +733,7 @@ typedef void *(*nvme_cons_ns_fn_t)(struc typedef void *(*nvme_cons_ctrlr_fn_t)(struct nvme_controller *); typedef void (*nvme_cons_async_fn_t)(void *, const struct nvme_completion *, uint32_t, void *, uint32_t); +typedef void (*nvme_cons_fail_fn_t)(void *); enum nvme_namespace_flags { NVME_NS_DEALLOCATE_SUPPORTED = 0x1, @@ -769,7 +770,8 @@ int nvme_ns_cmd_flush(struct nvme_namesp /* Registration functions */ struct nvme_consumer * nvme_register_consumer(nvme_cons_ns_fn_t ns_fn, nvme_cons_ctrlr_fn_t ctrlr_fn, - nvme_cons_async_fn_t async_fn); + nvme_cons_async_fn_t async_fn, + nvme_cons_fail_fn_t fail_fn); void nvme_unregister_consumer(struct nvme_consumer *consumer); /* Controller helper functions */ Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 21:48:41 2013 (r248766) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 21:58:38 2013 (r248767) @@ -311,6 +311,45 @@ nvme_ctrlr_construct_io_qpairs(struct nv return (0); } +static void +nvme_ctrlr_fail(struct nvme_controller *ctrlr) +{ + int i; + + ctrlr->is_failed = TRUE; + nvme_qpair_fail(&ctrlr->adminq); + for (i = 0; i < ctrlr->num_io_queues; i++) + nvme_qpair_fail(&ctrlr->ioq[i]); + nvme_notify_fail_consumers(ctrlr); +} + +void +nvme_ctrlr_post_failed_request(struct nvme_controller *ctrlr, + struct nvme_request *req) +{ + + mtx_lock(&ctrlr->fail_req_lock); + STAILQ_INSERT_TAIL(&ctrlr->fail_req, req, stailq); + mtx_unlock(&ctrlr->fail_req_lock); + taskqueue_enqueue(ctrlr->taskqueue, &ctrlr->fail_req_task); +} + +static void +nvme_ctrlr_fail_req_task(void *arg, int pending) +{ + struct nvme_controller *ctrlr = arg; + struct nvme_request *req; + + mtx_lock(&ctrlr->fail_req_lock); + while (!STAILQ_EMPTY(&ctrlr->fail_req)) { + req = STAILQ_FIRST(&ctrlr->fail_req); + STAILQ_REMOVE_HEAD(&ctrlr->fail_req, stailq); + nvme_qpair_manual_complete_request(req->qpair, req, + NVME_SCT_GENERIC, NVME_SC_ABORTED_BY_REQUEST, TRUE); + } + mtx_unlock(&ctrlr->fail_req_lock); +} + static int nvme_ctrlr_wait_for_ready(struct nvme_controller *ctrlr) { @@ -426,8 +465,12 @@ nvme_ctrlr_reset(struct nvme_controller cmpset = atomic_cmpset_32(&ctrlr->is_resetting, 0, 1); - if (cmpset == 0) - /* Controller is already resetting. */ + if (cmpset == 0 || ctrlr->is_failed) + /* + * Controller is already resetting or has failed. Return + * immediately since there is no need to kick off another + * reset in these cases. + */ return; taskqueue_enqueue(ctrlr->taskqueue, &ctrlr->reset_task); @@ -745,17 +788,25 @@ nvme_ctrlr_start(void *ctrlr_arg) nvme_admin_qpair_enable(&ctrlr->adminq); - if (nvme_ctrlr_identify(ctrlr) != 0) + if (nvme_ctrlr_identify(ctrlr) != 0) { + nvme_ctrlr_fail(ctrlr); return; + } - if (nvme_ctrlr_set_num_qpairs(ctrlr) != 0) + if (nvme_ctrlr_set_num_qpairs(ctrlr) != 0) { + nvme_ctrlr_fail(ctrlr); return; + } - if (nvme_ctrlr_create_qpairs(ctrlr) != 0) + if (nvme_ctrlr_create_qpairs(ctrlr) != 0) { + nvme_ctrlr_fail(ctrlr); return; + } - if (nvme_ctrlr_construct_namespaces(ctrlr) != 0) + if (nvme_ctrlr_construct_namespaces(ctrlr) != 0) { + nvme_ctrlr_fail(ctrlr); return; + } nvme_ctrlr_configure_aer(ctrlr); nvme_ctrlr_configure_int_coalescing(ctrlr); @@ -802,6 +853,8 @@ nvme_ctrlr_reset_task(void *arg, int pen pause("nvmereset", hz / 10); if (status == 0) nvme_ctrlr_start(ctrlr); + else + nvme_ctrlr_fail(ctrlr); atomic_cmpset_32(&ctrlr->is_resetting, 1, 0); } @@ -998,12 +1051,18 @@ intx: ctrlr->cdev->si_drv1 = (void *)ctrlr; - TASK_INIT(&ctrlr->reset_task, 0, nvme_ctrlr_reset_task, ctrlr); ctrlr->taskqueue = taskqueue_create("nvme_taskq", M_WAITOK, taskqueue_thread_enqueue, &ctrlr->taskqueue); taskqueue_start_threads(&ctrlr->taskqueue, 1, PI_DISK, "nvme taskq"); ctrlr->is_resetting = 0; + TASK_INIT(&ctrlr->reset_task, 0, nvme_ctrlr_reset_task, ctrlr); + + TASK_INIT(&ctrlr->fail_req_task, 0, nvme_ctrlr_fail_req_task, ctrlr); + mtx_init(&ctrlr->fail_req_lock, "nvme ctrlr fail req lock", NULL, + MTX_DEF); + STAILQ_INIT(&ctrlr->fail_req); + ctrlr->is_failed = FALSE; return (0); } Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 21:48:41 2013 (r248766) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 21:58:38 2013 (r248767) @@ -85,7 +85,7 @@ MALLOC_DECLARE(M_NVME); */ #define NVME_IO_ENTRIES (256) #define NVME_IO_TRACKERS (128) -#define NVME_MIN_IO_TRACKERS (16) +#define NVME_MIN_IO_TRACKERS (4) #define NVME_MAX_IO_TRACKERS (1024) /* @@ -119,6 +119,7 @@ extern int32_t nvme_retry_count; struct nvme_request { struct nvme_command cmd; + struct nvme_qpair *qpair; void *payload; uint32_t payload_size; boolean_t timeout; @@ -250,7 +251,9 @@ struct nvme_controller { struct intr_config_hook config_hook; uint32_t ns_identified; uint32_t queues_created; + struct task reset_task; + struct task fail_req_task; struct taskqueue *taskqueue; /* For shared legacy interrupt. */ @@ -293,6 +296,10 @@ struct nvme_controller { uint32_t is_resetting; + struct mtx fail_req_lock; + boolean_t is_failed; + STAILQ_HEAD(, nvme_request) fail_req; + #ifdef CHATHAM2 uint64_t chatham_size; uint64_t chatham_lbas; @@ -403,6 +410,8 @@ void nvme_ctrlr_submit_admin_request(str struct nvme_request *req); void nvme_ctrlr_submit_io_request(struct nvme_controller *ctrlr, struct nvme_request *req); +void nvme_ctrlr_post_failed_request(struct nvme_controller *ctrlr, + struct nvme_request *req); void nvme_qpair_construct(struct nvme_qpair *qpair, uint32_t id, uint16_t vector, uint32_t num_entries, @@ -414,6 +423,11 @@ void nvme_qpair_process_completions(stru void nvme_qpair_submit_request(struct nvme_qpair *qpair, struct nvme_request *req); void nvme_qpair_reset(struct nvme_qpair *qpair); +void nvme_qpair_fail(struct nvme_qpair *qpair); +void nvme_qpair_manual_complete_request(struct nvme_qpair *qpair, + struct nvme_request *req, + uint32_t sct, uint32_t sc, + boolean_t print_on_error); void nvme_admin_qpair_enable(struct nvme_qpair *qpair); void nvme_admin_qpair_disable(struct nvme_qpair *qpair); @@ -484,5 +498,6 @@ void nvme_notify_async_consumers(struct const struct nvme_completion *async_cpl, uint32_t log_page_id, void *log_page_buffer, uint32_t log_page_size); +void nvme_notify_fail_consumers(struct nvme_controller *ctrlr); #endif /* __NVME_PRIVATE_H__ */ Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 21:48:41 2013 (r248766) +++ head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 21:58:38 2013 (r248767) @@ -50,7 +50,6 @@ nvme_completion_is_retry(const struct nv case NVME_SCT_GENERIC: switch (cpl->status.sc) { case NVME_SC_ABORTED_BY_REQUEST: - return (1); case NVME_SC_NAMESPACE_NOT_READY: if (cpl->status.dnr) return (0); @@ -155,7 +154,7 @@ nvme_qpair_complete_tracker(struct nvme_ static void nvme_qpair_manual_complete_tracker(struct nvme_qpair *qpair, - struct nvme_tracker *tr, uint32_t sct, uint32_t sc, + struct nvme_tracker *tr, uint32_t sct, uint32_t sc, uint32_t dnr, boolean_t print_on_error) { struct nvme_completion cpl; @@ -165,10 +164,37 @@ nvme_qpair_manual_complete_tracker(struc cpl.cid = tr->cid; cpl.status.sct = sct; cpl.status.sc = sc; + cpl.status.dnr = dnr; nvme_qpair_complete_tracker(qpair, tr, &cpl, print_on_error); } void +nvme_qpair_manual_complete_request(struct nvme_qpair *qpair, + struct nvme_request *req, uint32_t sct, uint32_t sc, + boolean_t print_on_error) +{ + struct nvme_completion cpl; + boolean_t error; + + memset(&cpl, 0, sizeof(cpl)); + cpl.sqid = qpair->id; + cpl.status.sct = sct; + cpl.status.sc = sc; + + error = nvme_completion_is_error(&cpl); + + if (error && print_on_error) { + nvme_dump_completion(&cpl); + nvme_dump_command(&req->cmd); + } + + if (req->cb_fn) + req->cb_fn(req->cb_arg, &cpl); + + nvme_free_request(req); +} + +void nvme_qpair_process_completions(struct nvme_qpair *qpair) { struct nvme_tracker *tr; @@ -363,7 +389,7 @@ nvme_admin_qpair_abort_aers(struct nvme_ while (tr != NULL) { if (tr->req->cmd.opc == NVME_OPC_ASYNC_EVENT_REQUEST) { nvme_qpair_manual_complete_tracker(qpair, tr, - NVME_SCT_GENERIC, NVME_SC_ABORTED_SQ_DELETION, + NVME_SCT_GENERIC, NVME_SC_ABORTED_SQ_DELETION, 0, FALSE); tr = TAILQ_FIRST(&qpair->outstanding_tr); } else { @@ -406,7 +432,7 @@ nvme_abort_complete(void *arg, const str */ printf("abort command failed, aborting command manually\n"); nvme_qpair_manual_complete_tracker(tr->qpair, tr, - NVME_SCT_GENERIC, NVME_SC_ABORTED_BY_REQUEST, TRUE); + NVME_SCT_GENERIC, NVME_SC_ABORTED_BY_REQUEST, 0, TRUE); } } @@ -476,17 +502,32 @@ _nvme_qpair_submit_request(struct nvme_q mtx_assert(&qpair->lock, MA_OWNED); tr = TAILQ_FIRST(&qpair->free_tr); + req->qpair = qpair; if (tr == NULL || !qpair->is_enabled) { /* * No tracker is available, or the qpair is disabled due to - * an in-progress controller-level reset. - * - * Put the request on the qpair's request queue to be processed - * when a tracker frees up via a command completion or when - * the controller reset is completed. + * an in-progress controller-level reset or controller + * failure. */ - STAILQ_INSERT_TAIL(&qpair->queued_req, req, stailq); + + if (qpair->ctrlr->is_failed) { + /* + * The controller has failed. Post the request to a + * task where it will be aborted, so that we do not + * invoke the request's callback in the context + * of the submission. + */ + nvme_ctrlr_post_failed_request(qpair->ctrlr, req); + } else { + /* + * Put the request on the qpair's request queue to be + * processed when a tracker frees up via a command + * completion or when the controller reset is + * completed. + */ + STAILQ_INSERT_TAIL(&qpair->queued_req, req, stailq); + } return; } @@ -574,7 +615,7 @@ nvme_io_qpair_enable(struct nvme_qpair * device_printf(qpair->ctrlr->dev, "aborting outstanding i/o\n"); nvme_qpair_manual_complete_tracker(qpair, tr, NVME_SCT_GENERIC, - NVME_SC_ABORTED_BY_REQUEST, TRUE); + NVME_SC_ABORTED_BY_REQUEST, 0, TRUE); } mtx_lock(&qpair->lock); @@ -622,3 +663,41 @@ nvme_io_qpair_disable(struct nvme_qpair nvme_qpair_disable(qpair); } + +void +nvme_qpair_fail(struct nvme_qpair *qpair) +{ + struct nvme_tracker *tr; + struct nvme_request *req; + + mtx_lock(&qpair->lock); + + while (!STAILQ_EMPTY(&qpair->queued_req)) { + req = STAILQ_FIRST(&qpair->queued_req); + STAILQ_REMOVE_HEAD(&qpair->queued_req, stailq); + device_printf(qpair->ctrlr->dev, + "failing queued i/o\n"); + mtx_unlock(&qpair->lock); + nvme_qpair_manual_complete_request(qpair, req, NVME_SCT_GENERIC, + NVME_SC_ABORTED_BY_REQUEST, TRUE); + mtx_lock(&qpair->lock); + } + + /* Manually abort each outstanding I/O. */ + while (!TAILQ_EMPTY(&qpair->outstanding_tr)) { + tr = TAILQ_FIRST(&qpair->outstanding_tr); + /* + * Do not remove the tracker. The abort_tracker path will + * do that for us. + */ + device_printf(qpair->ctrlr->dev, + "failing outstanding i/o\n"); + mtx_unlock(&qpair->lock); + nvme_qpair_manual_complete_tracker(qpair, tr, NVME_SCT_GENERIC, + NVME_SC_ABORTED_BY_REQUEST, 1 /* do not retry */, TRUE); + mtx_lock(&qpair->lock); + } + + mtx_unlock(&qpair->lock); +} + From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 22:06:06 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 2B50D275; Tue, 26 Mar 2013 22:06:06 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 1DBF564A; Tue, 26 Mar 2013 22:06:06 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QM661A030806; Tue, 26 Mar 2013 22:06:06 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QM65Qq030805; Tue, 26 Mar 2013 22:06:05 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262206.r2QM65Qq030805@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 22:06:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248768 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 22:06:06 -0000 Author: jimharris Date: Tue Mar 26 22:06:05 2013 New Revision: 248768 URL: http://svnweb.freebsd.org/changeset/base/248768 Log: Abort and do not retry any outstanding admin commands left over after a controller reset. Sponsored by: Intel Reviewed by: carl Modified: head/sys/dev/nvme/nvme_qpair.c Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 21:58:38 2013 (r248767) +++ head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 22:06:05 2013 (r248768) @@ -594,6 +594,21 @@ nvme_qpair_reset(struct nvme_qpair *qpai void nvme_admin_qpair_enable(struct nvme_qpair *qpair) { + struct nvme_tracker *tr; + struct nvme_tracker *tr_temp; + + /* + * Manually abort each outstanding admin command. Do not retry + * admin commands found here, since they will be left over from + * a controller reset and its likely the context in which the + * command was issued no longer applies. + */ + TAILQ_FOREACH_SAFE(tr, &qpair->outstanding_tr, tailq, tr_temp) { + device_printf(qpair->ctrlr->dev, + "aborting outstanding admin command\n"); + nvme_qpair_manual_complete_tracker(qpair, tr, NVME_SCT_GENERIC, + NVME_SC_ABORTED_BY_REQUEST, 1 /* do not retry */, TRUE); + } nvme_qpair_enable(qpair); } From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 22:09:52 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 6D0925A2; Tue, 26 Mar 2013 22:09:52 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 50A626AE; Tue, 26 Mar 2013 22:09:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QM9qbc031482; Tue, 26 Mar 2013 22:09:52 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QM9pN6031479; Tue, 26 Mar 2013 22:09:51 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262209.r2QM9pN6031479@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 22:09:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248769 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 22:09:52 -0000 Author: jimharris Date: Tue Mar 26 22:09:51 2013 New Revision: 248769 URL: http://svnweb.freebsd.org/changeset/base/248769 Log: Replace usages of mtx_pool_find used for admin commands with a polling mechanism. Now that all requests are timed, we are guaranteed to get a completion notification, even if it is an abort status due to a timed out admin command. This has the effect of simplifying the controller and namespace setup code, so that it reads straight through rather than broken up into a bunch of different callback functions. Sponsored by: Intel Reviewed by: carl Modified: head/sys/dev/nvme/nvme.c head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_ns.c head/sys/dev/nvme/nvme_private.h Modified: head/sys/dev/nvme/nvme.c ============================================================================== --- head/sys/dev/nvme/nvme.c Tue Mar 26 22:06:05 2013 (r248768) +++ head/sys/dev/nvme/nvme.c Tue Mar 26 22:09:51 2013 (r248769) @@ -397,3 +397,18 @@ nvme_unregister_consumer(struct nvme_con consumer->id = INVALID_CONSUMER_ID; } +void +nvme_completion_poll_cb(void *arg, const struct nvme_completion *cpl) +{ + struct nvme_completion_poll_status *status = arg; + + /* + * Copy status into the argument passed by the caller, so that + * the caller can check the status to determine if the + * the request passed or failed. + */ + memcpy(&status->cpl, cpl, sizeof(*cpl)); + wmb(); + status->done = TRUE; +} + Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 22:06:05 2013 (r248768) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 22:09:51 2013 (r248769) @@ -41,24 +41,6 @@ __FBSDID("$FreeBSD$"); static void nvme_ctrlr_construct_and_submit_aer(struct nvme_controller *ctrlr, struct nvme_async_event_request *aer); -static void -nvme_ctrlr_cb(void *arg, const struct nvme_completion *status) -{ - struct nvme_completion *cpl = arg; - struct mtx *mtx; - - /* - * Copy status into the argument passed by the caller, so that - * the caller can check the status to determine if the - * the request passed or failed. - */ - memcpy(cpl, status, sizeof(*cpl)); - mtx = mtx_pool_find(mtxpool_sleep, cpl); - mtx_lock(mtx); - wakeup(cpl); - mtx_unlock(mtx); -} - static int nvme_ctrlr_allocate_bar(struct nvme_controller *ctrlr) { @@ -479,18 +461,14 @@ nvme_ctrlr_reset(struct nvme_controller static int nvme_ctrlr_identify(struct nvme_controller *ctrlr) { - struct mtx *mtx; - struct nvme_completion cpl; - int status; - - mtx = mtx_pool_find(mtxpool_sleep, &cpl); + struct nvme_completion_poll_status status; - mtx_lock(mtx); + status.done = FALSE; nvme_ctrlr_cmd_identify_controller(ctrlr, &ctrlr->cdata, - nvme_ctrlr_cb, &cpl); - status = msleep(&cpl, mtx, PRIBIO, "nvme_start", hz*5); - mtx_unlock(mtx); - if ((status != 0) || nvme_completion_is_error(&cpl)) { + nvme_completion_poll_cb, &status); + while (status.done == FALSE) + DELAY(5); + if (nvme_completion_is_error(&status.cpl)) { printf("nvme_identify_controller failed!\n"); return (ENXIO); } @@ -514,18 +492,15 @@ nvme_ctrlr_identify(struct nvme_controll static int nvme_ctrlr_set_num_qpairs(struct nvme_controller *ctrlr) { - struct mtx *mtx; - struct nvme_completion cpl; - int cq_allocated, sq_allocated, status; - - mtx = mtx_pool_find(mtxpool_sleep, &cpl); + struct nvme_completion_poll_status status; + int cq_allocated, sq_allocated; - mtx_lock(mtx); + status.done = FALSE; nvme_ctrlr_cmd_set_num_queues(ctrlr, ctrlr->num_io_queues, - nvme_ctrlr_cb, &cpl); - status = msleep(&cpl, mtx, PRIBIO, "nvme_start", hz*5); - mtx_unlock(mtx); - if ((status != 0) || nvme_completion_is_error(&cpl)) { + nvme_completion_poll_cb, &status); + while (status.done == FALSE) + DELAY(5); + if (nvme_completion_is_error(&status.cpl)) { printf("nvme_set_num_queues failed!\n"); return (ENXIO); } @@ -535,8 +510,8 @@ nvme_ctrlr_set_num_qpairs(struct nvme_co * Lower 16-bits indicate number of submission queues allocated. * Upper 16-bits indicate number of completion queues allocated. */ - sq_allocated = (cpl.cdw0 & 0xFFFF) + 1; - cq_allocated = (cpl.cdw0 >> 16) + 1; + sq_allocated = (status.cpl.cdw0 & 0xFFFF) + 1; + cq_allocated = (status.cpl.cdw0 >> 16) + 1; /* * Check that the controller was able to allocate the number of @@ -558,32 +533,29 @@ nvme_ctrlr_set_num_qpairs(struct nvme_co static int nvme_ctrlr_create_qpairs(struct nvme_controller *ctrlr) { - struct mtx *mtx; - struct nvme_qpair *qpair; - struct nvme_completion cpl; - int i, status; - - mtx = mtx_pool_find(mtxpool_sleep, &cpl); + struct nvme_completion_poll_status status; + struct nvme_qpair *qpair; + int i; for (i = 0; i < ctrlr->num_io_queues; i++) { qpair = &ctrlr->ioq[i]; - mtx_lock(mtx); + status.done = FALSE; nvme_ctrlr_cmd_create_io_cq(ctrlr, qpair, qpair->vector, - nvme_ctrlr_cb, &cpl); - status = msleep(&cpl, mtx, PRIBIO, "nvme_start", hz*5); - mtx_unlock(mtx); - if ((status != 0) || nvme_completion_is_error(&cpl)) { + nvme_completion_poll_cb, &status); + while (status.done == FALSE) + DELAY(5); + if (nvme_completion_is_error(&status.cpl)) { printf("nvme_create_io_cq failed!\n"); return (ENXIO); } - mtx_lock(mtx); + status.done = FALSE; nvme_ctrlr_cmd_create_io_sq(qpair->ctrlr, qpair, - nvme_ctrlr_cb, &cpl); - status = msleep(&cpl, mtx, PRIBIO, "nvme_start", hz*5); - mtx_unlock(mtx); - if ((status != 0) || nvme_completion_is_error(&cpl)) { + nvme_completion_poll_cb, &status); + while (status.done == FALSE) + DELAY(5); + if (nvme_completion_is_error(&status.cpl)) { printf("nvme_create_io_sq failed!\n"); return (ENXIO); } @@ -906,9 +878,8 @@ static int nvme_ctrlr_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int flag, struct thread *td) { - struct nvme_controller *ctrlr; - struct nvme_completion cpl; - struct mtx *mtx; + struct nvme_completion_poll_status status; + struct nvme_controller *ctrlr; ctrlr = cdev->si_drv1; @@ -925,13 +896,12 @@ nvme_ctrlr_ioctl(struct cdev *cdev, u_lo } #endif /* Refresh data before returning to user. */ - mtx = mtx_pool_find(mtxpool_sleep, &cpl); - mtx_lock(mtx); + status.done = FALSE; nvme_ctrlr_cmd_identify_controller(ctrlr, &ctrlr->cdata, - nvme_ctrlr_cb, &cpl); - msleep(&cpl, mtx, PRIBIO, "nvme_ioctl", 0); - mtx_unlock(mtx); - if (nvme_completion_is_error(&cpl)) + nvme_completion_poll_cb, &status); + while (status.done == FALSE) + DELAY(5); + if (nvme_completion_is_error(&status.cpl)) return (ENXIO); memcpy(arg, &ctrlr->cdata, sizeof(ctrlr->cdata)); break; Modified: head/sys/dev/nvme/nvme_ns.c ============================================================================== --- head/sys/dev/nvme/nvme_ns.c Tue Mar 26 22:06:05 2013 (r248768) +++ head/sys/dev/nvme/nvme_ns.c Tue Mar 26 22:09:51 2013 (r248769) @@ -41,32 +41,13 @@ __FBSDID("$FreeBSD$"); #include "nvme_private.h" -static void -nvme_ns_cb(void *arg, const struct nvme_completion *status) -{ - struct nvme_completion *cpl = arg; - struct mtx *mtx; - - /* - * Copy status into the argument passed by the caller, so that - * the caller can check the status to determine if the - * the request passed or failed. - */ - memcpy(cpl, status, sizeof(*cpl)); - mtx = mtx_pool_find(mtxpool_sleep, cpl); - mtx_lock(mtx); - wakeup(cpl); - mtx_unlock(mtx); -} - static int nvme_ns_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int flag, struct thread *td) { - struct nvme_namespace *ns; - struct nvme_controller *ctrlr; - struct nvme_completion cpl; - struct mtx *mtx; + struct nvme_completion_poll_status status; + struct nvme_namespace *ns; + struct nvme_controller *ctrlr; ns = cdev->si_drv1; ctrlr = ns->ctrlr; @@ -84,13 +65,12 @@ nvme_ns_ioctl(struct cdev *cdev, u_long } #endif /* Refresh data before returning to user. */ - mtx = mtx_pool_find(mtxpool_sleep, &cpl); - mtx_lock(mtx); + status.done = FALSE; nvme_ctrlr_cmd_identify_namespace(ctrlr, ns->id, &ns->data, - nvme_ns_cb, &cpl); - msleep(&cpl, mtx, PRIBIO, "nvme_ioctl", 0); - mtx_unlock(mtx); - if (nvme_completion_is_error(&cpl)) + nvme_completion_poll_cb, &status); + while (status.done == FALSE) + DELAY(5); + if (nvme_completion_is_error(&status.cpl)) return (ENXIO); memcpy(arg, &ns->data, sizeof(ns->data)); break; @@ -319,9 +299,7 @@ int nvme_ns_construct(struct nvme_namespace *ns, uint16_t id, struct nvme_controller *ctrlr) { - struct nvme_completion cpl; - struct mtx *mtx; - int status; + struct nvme_completion_poll_status status; ns->ctrlr = ctrlr; ns->id = id; @@ -331,14 +309,12 @@ nvme_ns_construct(struct nvme_namespace nvme_ns_populate_chatham_data(ns); else { #endif - mtx = mtx_pool_find(mtxpool_sleep, &cpl); - - mtx_lock(mtx); + status.done = FALSE; nvme_ctrlr_cmd_identify_namespace(ctrlr, id, &ns->data, - nvme_ns_cb, &cpl); - status = msleep(&cpl, mtx, PRIBIO, "nvme_start", hz*5); - mtx_unlock(mtx); - if ((status != 0) || nvme_completion_is_error(&cpl)) { + nvme_completion_poll_cb, &status); + while (status.done == FALSE) + DELAY(5); + if (nvme_completion_is_error(&status.cpl)) { printf("nvme_identify_namespace failed!\n"); return (ENXIO); } Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 22:06:05 2013 (r248768) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 22:09:51 2013 (r248769) @@ -116,6 +116,12 @@ MALLOC_DECLARE(M_NVME); extern uma_zone_t nvme_request_zone; extern int32_t nvme_retry_count; +struct nvme_completion_poll_status { + + struct nvme_completion cpl; + boolean_t done; +}; + struct nvme_request { struct nvme_command cmd; @@ -399,6 +405,7 @@ void nvme_payload_map(void *arg, bus_dma int error); void nvme_payload_map_uio(void *arg, bus_dma_segment_t *seg, int nseg, bus_size_t mapsize, int error); +void nvme_completion_poll_cb(void *arg, const struct nvme_completion *cpl); int nvme_ctrlr_construct(struct nvme_controller *ctrlr, device_t dev); void nvme_ctrlr_destruct(struct nvme_controller *ctrlr, device_t dev); From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 22:11:35 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 9D9FB766; Tue, 26 Mar 2013 22:11:35 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 81A076D1; Tue, 26 Mar 2013 22:11:35 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QMBZWB033460; Tue, 26 Mar 2013 22:11:35 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QMBYdH033454; Tue, 26 Mar 2013 22:11:34 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262211.r2QMBYdH033454@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 22:11:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248770 - in head/sys/dev: nvd nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 22:11:35 -0000 Author: jimharris Date: Tue Mar 26 22:11:34 2013 New Revision: 248770 URL: http://svnweb.freebsd.org/changeset/base/248770 Log: Change a number of malloc(9) calls to use M_WAITOK instead of M_NOWAIT. Sponsored by: Intel Suggested by: carl Reviewed by: carl Modified: head/sys/dev/nvd/nvd.c head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_ns.c head/sys/dev/nvme/nvme_qpair.c head/sys/dev/nvme/nvme_test.c Modified: head/sys/dev/nvd/nvd.c ============================================================================== --- head/sys/dev/nvd/nvd.c Tue Mar 26 22:09:51 2013 (r248769) +++ head/sys/dev/nvd/nvd.c Tue Mar 26 22:11:34 2013 (r248770) @@ -260,7 +260,7 @@ nvd_new_controller(struct nvme_controlle struct nvd_controller *nvd_ctrlr; nvd_ctrlr = malloc(sizeof(struct nvd_controller), M_NVD, - M_ZERO | M_NOWAIT); + M_ZERO | M_WAITOK); TAILQ_INIT(&nvd_ctrlr->disk_head); TAILQ_INSERT_TAIL(&ctrlr_head, nvd_ctrlr, tailq); @@ -275,7 +275,7 @@ nvd_new_disk(struct nvme_namespace *ns, struct disk *disk; struct nvd_controller *ctrlr = ctrlr_arg; - ndisk = malloc(sizeof(struct nvd_disk), M_NVD, M_ZERO | M_NOWAIT); + ndisk = malloc(sizeof(struct nvd_disk), M_NVD, M_ZERO | M_WAITOK); disk = disk_alloc(); disk->d_strategy = nvd_strategy; Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 22:09:51 2013 (r248769) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 22:11:34 2013 (r248770) @@ -263,10 +263,7 @@ nvme_ctrlr_construct_io_qpairs(struct nv ctrlr->max_xfer_size = NVME_MAX_XFER_SIZE; ctrlr->ioq = malloc(ctrlr->num_io_queues * sizeof(struct nvme_qpair), - M_NVME, M_ZERO | M_NOWAIT); - - if (ctrlr->ioq == NULL) - return (ENOMEM); + M_NVME, M_ZERO | M_WAITOK); for (i = 0; i < ctrlr->num_io_queues; i++) { qpair = &ctrlr->ioq[i]; Modified: head/sys/dev/nvme/nvme_ns.c ============================================================================== --- head/sys/dev/nvme/nvme_ns.c Tue Mar 26 22:09:51 2013 (r248769) +++ head/sys/dev/nvme/nvme_ns.c Tue Mar 26 22:11:34 2013 (r248770) @@ -254,7 +254,7 @@ nvme_ns_bio_process(struct nvme_namespac */ dsm_range = malloc(sizeof(struct nvme_dsm_range), M_NVME, - M_ZERO | M_NOWAIT); + M_ZERO | M_WAITOK); dsm_range->length = bp->bio_bcount/nvme_ns_get_sector_size(ns); dsm_range->starting_lba = Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 22:09:51 2013 (r248769) +++ head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 22:11:34 2013 (r248770) @@ -297,12 +297,11 @@ nvme_qpair_construct(struct nvme_qpair * qpair->num_cmds = 0; qpair->num_intr_handler_calls = 0; - /* TODO: error checking on contigmalloc, bus_dmamap_load calls */ qpair->cmd = contigmalloc(qpair->num_entries * - sizeof(struct nvme_command), M_NVME, M_ZERO | M_NOWAIT, + sizeof(struct nvme_command), M_NVME, M_ZERO, 0, BUS_SPACE_MAXADDR, PAGE_SIZE, 0); qpair->cpl = contigmalloc(qpair->num_entries * - sizeof(struct nvme_completion), M_NVME, M_ZERO | M_NOWAIT, + sizeof(struct nvme_completion), M_NVME, M_ZERO, 0, BUS_SPACE_MAXADDR, PAGE_SIZE, 0); bus_dmamap_create(qpair->dma_tag, 0, &qpair->cmd_dma_map); @@ -323,19 +322,13 @@ nvme_qpair_construct(struct nvme_qpair * STAILQ_INIT(&qpair->queued_req); for (i = 0; i < qpair->num_trackers; i++) { - tr = malloc(sizeof(*tr), M_NVME, M_ZERO | M_NOWAIT); - - if (tr == NULL) { - printf("warning: nvme tracker malloc failed\n"); - break; - } - + tr = malloc(sizeof(*tr), M_NVME, M_ZERO | M_WAITOK); nvme_qpair_construct_tracker(qpair, tr, i); TAILQ_INSERT_HEAD(&qpair->free_tr, tr, tailq); } qpair->act_tr = malloc(sizeof(struct nvme_tracker *) * qpair->num_entries, - M_NVME, M_ZERO | M_NOWAIT); + M_NVME, M_ZERO | M_WAITOK); } static void Modified: head/sys/dev/nvme/nvme_test.c ============================================================================== --- head/sys/dev/nvme/nvme_test.c Tue Mar 26 22:09:51 2013 (r248769) +++ head/sys/dev/nvme/nvme_test.c Tue Mar 26 22:11:34 2013 (r248770) @@ -96,7 +96,7 @@ nvme_ns_bio_test(void *arg) int ref; #endif - buf = malloc(io_test->size, M_NVME, M_NOWAIT); + buf = malloc(io_test->size, M_NVME, M_WAITOK); idx = atomic_fetchadd_int(&io_test->td_idx, 1); dev = io_test->ns->cdev; @@ -217,11 +217,11 @@ nvme_ns_io_test(void *arg) struct nvme_completion cpl; int error; - tth = malloc(sizeof(*tth), M_NVME, M_NOWAIT | M_ZERO); + tth = malloc(sizeof(*tth), M_NVME, M_WAITOK | M_ZERO); tth->ns = io_test->ns; tth->opc = io_test->opc; memcpy(&tth->start, &io_test->start, sizeof(tth->start)); - tth->buf = malloc(io_test->size, M_NVME, M_NOWAIT); + tth->buf = malloc(io_test->size, M_NVME, M_WAITOK); tth->size = io_test->size; tth->time = io_test->time; tth->idx = atomic_fetchadd_int(&io_test->td_idx, 1); @@ -269,7 +269,7 @@ nvme_ns_test(struct nvme_namespace *ns, return; io_test_internal = malloc(sizeof(*io_test_internal), M_NVME, - M_NOWAIT | M_ZERO); + M_WAITOK | M_ZERO); io_test_internal->opc = io_test->opc; io_test_internal->ns = ns; io_test_internal->td_active = io_test->num_threads; From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 22:13:07 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id DBB7E910; Tue, 26 Mar 2013 22:13:07 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id CE4996EF; Tue, 26 Mar 2013 22:13:07 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QMD7OM033759; Tue, 26 Mar 2013 22:13:07 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QMD7td033758; Tue, 26 Mar 2013 22:13:07 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262213.r2QMD7td033758@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 22:13:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248771 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 22:13:07 -0000 Author: jimharris Date: Tue Mar 26 22:13:07 2013 New Revision: 248771 URL: http://svnweb.freebsd.org/changeset/base/248771 Log: Move common code from the different nvme_allocate_request functions into a separate function. Sponsored by: Intel Suggested by: carl Reviewed by: carl Modified: head/sys/dev/nvme/nvme_private.h Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 22:11:34 2013 (r248770) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 22:13:07 2013 (r248771) @@ -464,21 +464,30 @@ nvme_single_map(void *arg, bus_dma_segme } static __inline struct nvme_request * -nvme_allocate_request(void *payload, uint32_t payload_size, nvme_cb_fn_t cb_fn, - void *cb_arg) +_nvme_allocate_request(nvme_cb_fn_t cb_fn, void *cb_arg) { struct nvme_request *req; req = uma_zalloc(nvme_request_zone, M_NOWAIT | M_ZERO); - if (req == NULL) - return (NULL); + if (req != NULL) { + req->cb_fn = cb_fn; + req->cb_arg = cb_arg; + req->timeout = TRUE; + } + return (req); +} - req->payload = payload; - req->payload_size = payload_size; - req->cb_fn = cb_fn; - req->cb_arg = cb_arg; - req->timeout = TRUE; +static __inline struct nvme_request * +nvme_allocate_request(void *payload, uint32_t payload_size, nvme_cb_fn_t cb_fn, + void *cb_arg) +{ + struct nvme_request *req; + req = _nvme_allocate_request(cb_fn, cb_arg); + if (req != NULL) { + req->payload = payload; + req->payload_size = payload_size; + } return (req); } @@ -487,15 +496,9 @@ nvme_allocate_request_uio(struct uio *ui { struct nvme_request *req; - req = uma_zalloc(nvme_request_zone, M_NOWAIT | M_ZERO); - if (req == NULL) - return (NULL); - - req->uio = uio; - req->cb_fn = cb_fn; - req->cb_arg = cb_arg; - req->timeout = TRUE; - + req = _nvme_allocate_request(cb_fn, cb_arg); + if (req != NULL) + req->uio = uio; return (req); } From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 22:14:48 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 9A962AD2; Tue, 26 Mar 2013 22:14:48 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 7DF9D717; Tue, 26 Mar 2013 22:14:48 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QMEmGs034072; Tue, 26 Mar 2013 22:14:48 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QMEmHH034071; Tue, 26 Mar 2013 22:14:48 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262214.r2QMEmHH034071@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 22:14:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248772 - head/sbin/nvmecontrol X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 22:14:48 -0000 Author: jimharris Date: Tue Mar 26 22:14:47 2013 New Revision: 248772 URL: http://svnweb.freebsd.org/changeset/base/248772 Log: Use errno and strerror to print more descriptive messages when operations fail in nvmecontrol(8). While here, use consistent checks of return values from stat, open and ioctl. Sponsored by: Intel Suggested by: carl Reviewed by: carl Modified: head/sbin/nvmecontrol/nvmecontrol.c Modified: head/sbin/nvmecontrol/nvmecontrol.c ============================================================================== --- head/sbin/nvmecontrol/nvmecontrol.c Tue Mar 26 22:13:07 2013 (r248771) +++ head/sbin/nvmecontrol/nvmecontrol.c Tue Mar 26 22:14:47 2013 (r248772) @@ -245,13 +245,15 @@ devlist(int argc, char *argv[]) fd = open(path, O_RDWR); if (fd < 0) { - printf("Could not open %s.\n", path); + printf("Could not open %s. errno=%d (%s)\n", path, + errno, strerror(errno)); exit_code = EX_NOPERM; continue; } - if (ioctl(fd, NVME_IDENTIFY_CONTROLLER, &cdata) == -1) { - printf("ioctl to %s failed.\n", path); + if (ioctl(fd, NVME_IDENTIFY_CONTROLLER, &cdata) < 0) { + printf("Identify request to %s failed. errno=%d (%s)\n", + path, errno, strerror(errno)); exit_code = EX_IOERR; continue; } @@ -264,12 +266,15 @@ devlist(int argc, char *argv[]) fd = open(path, O_RDWR); if (fd < 0) { - printf("Could not open %s.\n", path); + printf("Could not open %s. errno=%d (%s)\n", + path, errno, strerror(errno)); exit_code = EX_NOPERM; continue; } - if (ioctl(fd, NVME_IDENTIFY_NAMESPACE, &nsdata) == -1) { - printf("ioctl to %s failed.\n", path); + if (ioctl(fd, NVME_IDENTIFY_NAMESPACE, &nsdata) < 0) { + printf("Identify request to %s failed. " + "errno=%d (%s)\n", path, errno, + strerror(errno)); exit_code = EX_IOERR; continue; } @@ -311,19 +316,22 @@ identify_ctrlr(int argc, char *argv[]) sprintf(path, "/dev/%s", argv[optind]); - if (stat(path, &devstat) != 0) { - printf("Invalid device node '%s'.\n", path); + if (stat(path, &devstat) < 0) { + printf("Invalid device node %s. errno=%d (%s)\n", path, errno, + strerror(errno)); exit(EX_IOERR); } fd = open(path, O_RDWR); if (fd < 0) { - printf("Could not open %s.\n", path); + printf("Could not open %s. errno=%d (%s)\n", path, errno, + strerror(errno)); exit(EX_NOPERM); } - if (ioctl(fd, NVME_IDENTIFY_CONTROLLER, &cdata) == -1) { - printf("ioctl to %s failed.\n", path); + if (ioctl(fd, NVME_IDENTIFY_CONTROLLER, &cdata) < 0) { + printf("Identify request to %s failed. errno=%d (%s)\n", path, + errno, strerror(errno)); exit(EX_IOERR); } @@ -370,19 +378,22 @@ identify_ns(int argc, char *argv[]) sprintf(path, "/dev/%s", argv[optind]); - if (stat(path, &devstat) != 0) { - printf("Invalid device node '%s'.\n", path); + if (stat(path, &devstat) < 0) { + printf("Invalid device node %s. errno=%d (%s)\n", path, errno, + strerror(errno)); exit(EX_IOERR); } fd = open(path, O_RDWR); if (fd < 0) { - printf("Could not open %s.\n", path); + printf("Could not open %s. errno=%d (%s)\n", path, errno, + strerror(errno)); exit(EX_NOPERM); } - if (ioctl(fd, NVME_IDENTIFY_NAMESPACE, &nsdata) == -1) { - printf("ioctl to %s failed.\n", path); + if (ioctl(fd, NVME_IDENTIFY_NAMESPACE, &nsdata) < 0) { + printf("Identify request to %s failed. errno=%d (%s)\n", path, + errno, strerror(errno)); exit(EX_IOERR); } @@ -479,7 +490,7 @@ perftest(int argc, char *argv[]) char path[64]; u_long ioctl_cmd = NVME_IO_TEST; bool nflag, oflag, sflag, tflag; - int err, perthread = 0; + int perthread = 0; nflag = oflag = sflag = tflag = false; name = NULL; @@ -569,14 +580,14 @@ perftest(int argc, char *argv[]) fd = open(path, O_RDWR); if (fd < 0) { - fprintf(stderr, "%s not valid device.\n", path); + fprintf(stderr, "%s not valid device. errno=%d (%s)\n", path, + errno, strerror(errno)); perftest_usage(); } - err = ioctl(fd, ioctl_cmd, &io_test); - - if (err) { - fprintf(stderr, "NVME_IO_TEST returned %d\n", errno); + if (ioctl(fd, ioctl_cmd, &io_test) < 0) { + fprintf(stderr, "NVME_IO_TEST failed. errno=%d (%s)\n", errno, + strerror(errno)); exit(EX_IOERR); } @@ -600,19 +611,22 @@ reset_ctrlr(int argc, char *argv[]) sprintf(path, "/dev/%s", argv[optind]); - if (stat(path, &devstat) != 0) { - printf("Invalid device node '%s'.\n", path); + if (stat(path, &devstat) < 0) { + printf("Invalid device node %s. errno=%d (%s)\n", path, errno, + strerror(errno)); exit(EX_IOERR); } fd = open(path, O_RDWR); if (fd < 0) { - printf("Could not open %s.\n", path); + printf("Could not open %s. errno=%d (%s)\n", path, errno, + strerror(errno)); exit(EX_NOPERM); } - if (ioctl(fd, NVME_RESET_CONTROLLER) == -1) { - printf("ioctl to %s failed.\n", path); + if (ioctl(fd, NVME_RESET_CONTROLLER) < 0) { + printf("Reset request to %s failed. errno=%d (%s)\n", path, + errno, strerror(errno)); exit(EX_IOERR); } From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 22:17:12 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 05C70D8E; Tue, 26 Mar 2013 22:17:12 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id DE2D1757; Tue, 26 Mar 2013 22:17:11 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QMHBat034638; Tue, 26 Mar 2013 22:17:11 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QMHBvn034633; Tue, 26 Mar 2013 22:17:11 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262217.r2QMHBvn034633@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 22:17:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248773 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 22:17:12 -0000 Author: jimharris Date: Tue Mar 26 22:17:10 2013 New Revision: 248773 URL: http://svnweb.freebsd.org/changeset/base/248773 Log: Clean up debug prints. 1) Consistently use device_printf. 2) Make dump_completion and dump_command into something more human-readable. Sponsored by: Intel Reviewed by: carl Modified: head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_ctrlr_cmd.c head/sys/dev/nvme/nvme_ns.c head/sys/dev/nvme/nvme_private.h head/sys/dev/nvme/nvme_qpair.c Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 22:14:47 2013 (r248772) +++ head/sys/dev/nvme/nvme_ctrlr.c Tue Mar 26 22:17:10 2013 (r248773) @@ -55,7 +55,7 @@ nvme_ctrlr_allocate_bar(struct nvme_cont &ctrlr->resource_id, 0, ~0, 1, RF_ACTIVE); if(ctrlr->resource == NULL) { - device_printf(ctrlr->dev, "unable to allocate pci resource\n"); + nvme_printf(ctrlr, "unable to allocate pci resource\n"); return (ENOMEM); } @@ -88,7 +88,7 @@ nvme_ctrlr_allocate_chatham_bar(struct n RF_ACTIVE); if(ctrlr->chatham_resource == NULL) { - device_printf(ctrlr->dev, "unable to alloc pci resource\n"); + nvme_printf(ctrlr, "unable to alloc pci resource\n"); return (ENOMEM); } @@ -204,8 +204,8 @@ nvme_ctrlr_construct_admin_qpair(struct */ if (num_entries < NVME_MIN_ADMIN_ENTRIES || num_entries > NVME_MAX_ADMIN_ENTRIES) { - printf("nvme: invalid hw.nvme.admin_entries=%d specified\n", - num_entries); + nvme_printf(ctrlr, "invalid hw.nvme.admin_entries=%d " + "specified\n", num_entries); num_entries = NVME_ADMIN_ENTRIES; } @@ -340,8 +340,7 @@ nvme_ctrlr_wait_for_ready(struct nvme_co csts.raw = nvme_mmio_read_4(ctrlr, csts); if (!cc.bits.en) { - device_printf(ctrlr->dev, "%s called with cc.en = 0\n", - __func__); + nvme_printf(ctrlr, "%s called with cc.en = 0\n", __func__); return (ENXIO); } @@ -350,8 +349,8 @@ nvme_ctrlr_wait_for_ready(struct nvme_co while (!csts.bits.rdy) { DELAY(1000); if (ms_waited++ > ctrlr->ready_timeout_in_ms) { - device_printf(ctrlr->dev, "controller did not become " - "ready within %d ms\n", ctrlr->ready_timeout_in_ms); + nvme_printf(ctrlr, "controller did not become ready " + "within %d ms\n", ctrlr->ready_timeout_in_ms); return (ENXIO); } csts.raw = nvme_mmio_read_4(ctrlr, csts); @@ -466,7 +465,7 @@ nvme_ctrlr_identify(struct nvme_controll while (status.done == FALSE) DELAY(5); if (nvme_completion_is_error(&status.cpl)) { - printf("nvme_identify_controller failed!\n"); + nvme_printf(ctrlr, "nvme_identify_controller failed!\n"); return (ENXIO); } @@ -498,7 +497,7 @@ nvme_ctrlr_set_num_qpairs(struct nvme_co while (status.done == FALSE) DELAY(5); if (nvme_completion_is_error(&status.cpl)) { - printf("nvme_set_num_queues failed!\n"); + nvme_printf(ctrlr, "nvme_set_num_queues failed!\n"); return (ENXIO); } @@ -543,7 +542,7 @@ nvme_ctrlr_create_qpairs(struct nvme_con while (status.done == FALSE) DELAY(5); if (nvme_completion_is_error(&status.cpl)) { - printf("nvme_create_io_cq failed!\n"); + nvme_printf(ctrlr, "nvme_create_io_cq failed!\n"); return (ENXIO); } @@ -553,7 +552,7 @@ nvme_ctrlr_create_qpairs(struct nvme_con while (status.done == FALSE) DELAY(5); if (nvme_completion_is_error(&status.cpl)) { - printf("nvme_create_io_sq failed!\n"); + nvme_printf(ctrlr, "nvme_create_io_sq failed!\n"); return (ENXIO); } } @@ -660,11 +659,12 @@ nvme_ctrlr_async_event_cb(void *arg, con return; } - printf("Asynchronous event occurred.\n"); - /* Associated log page is in bits 23:16 of completion entry dw0. */ aer->log_page_id = (cpl->cdw0 & 0xFF0000) >> 16; + nvme_printf(aer->ctrlr, "async event occurred (log page id=0x%x)\n", + aer->log_page_id); + if (is_log_page_id_valid(aer->log_page_id)) { aer->log_page_size = nvme_ctrlr_get_log_page_size(aer->ctrlr, aer->log_page_id); @@ -809,7 +809,7 @@ nvme_ctrlr_reset_task(void *arg, int pen struct nvme_controller *ctrlr = arg; int status; - device_printf(ctrlr->dev, "resetting controller"); + nvme_printf(ctrlr, "resetting controller\n"); status = nvme_ctrlr_hw_reset(ctrlr); /* * Use pause instead of DELAY, so that we yield to any nvme interrupt @@ -854,7 +854,7 @@ nvme_ctrlr_configure_intx(struct nvme_co &ctrlr->rid, RF_SHAREABLE | RF_ACTIVE); if (ctrlr->res == NULL) { - device_printf(ctrlr->dev, "unable to allocate shared IRQ\n"); + nvme_printf(ctrlr, "unable to allocate shared IRQ\n"); return (ENOMEM); } @@ -863,8 +863,7 @@ nvme_ctrlr_configure_intx(struct nvme_co ctrlr, &ctrlr->tag); if (ctrlr->tag == NULL) { - device_printf(ctrlr->dev, - "unable to setup legacy interrupt handler\n"); + nvme_printf(ctrlr, "unable to setup intx handler\n"); return (ENOMEM); } Modified: head/sys/dev/nvme/nvme_ctrlr_cmd.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr_cmd.c Tue Mar 26 22:14:47 2013 (r248772) +++ head/sys/dev/nvme/nvme_ctrlr_cmd.c Tue Mar 26 22:17:10 2013 (r248773) @@ -230,15 +230,15 @@ nvme_ctrlr_cmd_set_interrupt_coalescing( uint32_t cdw11; if ((microseconds/100) >= 0x100) { - KASSERT(FALSE, ("intr coal time > 255*100 microseconds\n")); - printf("invalid coal time %d, disabling\n", microseconds); + nvme_printf(ctrlr, "invalid coal time %d, disabling\n", + microseconds); microseconds = 0; threshold = 0; } if (threshold >= 0x100) { - KASSERT(FALSE, ("intr threshold > 255\n")); - printf("invalid threshold %d, disabling\n", threshold); + nvme_printf(ctrlr, "invalid threshold %d, disabling\n", + threshold); threshold = 0; microseconds = 0; } @@ -276,11 +276,12 @@ nvme_ctrlr_cmd_get_error_page(struct nvm KASSERT(num_entries > 0, ("%s called with num_entries==0\n", __func__)); /* Controller's error log page entries is 0-based. */ - if (num_entries > (ctrlr->cdata.elpe + 1)) { - printf("%s num_entries=%d cdata.elpe=%d\n", - __func__, num_entries, ctrlr->cdata.elpe); + KASSERT(num_entries <= (ctrlr->cdata.elpe + 1), + ("%s called with num_entries=%d but (elpe+1)=%d\n", __func__, + num_entries, ctrlr->cdata.elpe + 1)); + + if (num_entries > (ctrlr->cdata.elpe + 1)) num_entries = ctrlr->cdata.elpe + 1; - } nvme_ctrlr_cmd_get_log_page(ctrlr, NVME_LOG_ERROR, NVME_GLOBAL_NAMESPACE_TAG, payload, sizeof(*payload) * num_entries, Modified: head/sys/dev/nvme/nvme_ns.c ============================================================================== --- head/sys/dev/nvme/nvme_ns.c Tue Mar 26 22:14:47 2013 (r248772) +++ head/sys/dev/nvme/nvme_ns.c Tue Mar 26 22:17:10 2013 (r248773) @@ -315,7 +315,7 @@ nvme_ns_construct(struct nvme_namespace while (status.done == FALSE) DELAY(5); if (nvme_completion_is_error(&status.cpl)) { - printf("nvme_identify_namespace failed!\n"); + nvme_printf(ctrlr, "nvme_identify_namespace failed\n"); return (ENXIO); } #ifdef CHATHAM2 Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Tue Mar 26 22:14:47 2013 (r248772) +++ head/sys/dev/nvme/nvme_private.h Tue Mar 26 22:17:10 2013 (r248773) @@ -30,6 +30,7 @@ #define __NVME_PRIVATE_H__ #include +#include #include #include #include @@ -353,6 +354,9 @@ struct nvme_controller { #define mb() __asm volatile("mfence" ::: "memory") #endif +#define nvme_printf(ctrlr, fmt, args...) \ + device_printf(ctrlr->dev, fmt, ##args) + void nvme_ns_test(struct nvme_namespace *ns, u_long cmd, caddr_t arg); void nvme_ctrlr_cmd_identify_controller(struct nvme_controller *ctrlr, Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 22:14:47 2013 (r248772) +++ head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 22:17:10 2013 (r248773) @@ -37,6 +37,215 @@ __FBSDID("$FreeBSD$"); static void _nvme_qpair_submit_request(struct nvme_qpair *qpair, struct nvme_request *req); +struct nvme_opcode_string { + + uint16_t opc; + const char * str; +}; + +static struct nvme_opcode_string admin_opcode[] = { + { NVME_OPC_DELETE_IO_SQ, "DELETE IO SQ" }, + { NVME_OPC_CREATE_IO_SQ, "CREATE IO SQ" }, + { NVME_OPC_GET_LOG_PAGE, "GET LOG PAGE" }, + { NVME_OPC_DELETE_IO_CQ, "DELETE IO CQ" }, + { NVME_OPC_CREATE_IO_CQ, "CREATE IO CQ" }, + { NVME_OPC_IDENTIFY, "IDENTIFY" }, + { NVME_OPC_ABORT, "ABORT" }, + { NVME_OPC_SET_FEATURES, "SET FEATURES" }, + { NVME_OPC_GET_FEATURES, "GET FEATURES" }, + { NVME_OPC_ASYNC_EVENT_REQUEST, "ASYNC EVENT REQUEST" }, + { NVME_OPC_FIRMWARE_ACTIVATE, "FIRMWARE ACTIVATE" }, + { NVME_OPC_FIRMWARE_IMAGE_DOWNLOAD, "FIRMWARE IMAGE DOWNLOAD" }, + { NVME_OPC_FORMAT_NVM, "FORMAT NVM" }, + { NVME_OPC_SECURITY_SEND, "SECURITY SEND" }, + { NVME_OPC_SECURITY_RECEIVE, "SECURITY RECEIVE" }, + { 0xFFFF, "ADMIN COMMAND" } +}; + +static struct nvme_opcode_string io_opcode[] = { + { NVME_OPC_FLUSH, "FLUSH" }, + { NVME_OPC_WRITE, "WRITE" }, + { NVME_OPC_READ, "READ" }, + { NVME_OPC_WRITE_UNCORRECTABLE, "WRITE UNCORRECTABLE" }, + { NVME_OPC_COMPARE, "COMPARE" }, + { NVME_OPC_DATASET_MANAGEMENT, "DATASET MANAGEMENT" }, + { 0xFFFF, "IO COMMAND" } +}; + +static const char * +get_admin_opcode_string(uint16_t opc) +{ + struct nvme_opcode_string *entry; + + entry = admin_opcode; + + while (entry->opc != 0xFFFF) { + if (entry->opc == opc) + return (entry->str); + entry++; + } + return (entry->str); +} + +static const char * +get_io_opcode_string(uint16_t opc) +{ + struct nvme_opcode_string *entry; + + entry = io_opcode; + + while (entry->opc != 0xFFFF) { + if (entry->opc == opc) + return (entry->str); + entry++; + } + return (entry->str); +} + + +static void +nvme_admin_qpair_print_command(struct nvme_qpair *qpair, + struct nvme_command *cmd) +{ + + nvme_printf(qpair->ctrlr, "%s (%02x) sqid:%d cid:%d nsid:%x " + "cdw10:%08x cdw11:%08x\n", + get_admin_opcode_string(cmd->opc), cmd->opc, qpair->id, cmd->cid, + cmd->nsid, cmd->cdw10, cmd->cdw11); +} + +static void +nvme_io_qpair_print_command(struct nvme_qpair *qpair, + struct nvme_command *cmd) +{ + + switch (cmd->opc) { + case NVME_OPC_WRITE: + case NVME_OPC_READ: + case NVME_OPC_WRITE_UNCORRECTABLE: + case NVME_OPC_COMPARE: + nvme_printf(qpair->ctrlr, "%s sqid:%d cid:%d nsid:%d " + "lba:%lu len:%d\n", + get_io_opcode_string(cmd->opc), qpair->id, cmd->cid, + cmd->nsid, ((uint64_t)cmd->cdw11 << 32) | cmd->cdw10, + (cmd->cdw12 & 0xFFFF) + 1); + break; + case NVME_OPC_FLUSH: + case NVME_OPC_DATASET_MANAGEMENT: + nvme_printf(qpair->ctrlr, "%s sqid:%d cid:%d nsid:%d\n", + get_io_opcode_string(cmd->opc), qpair->id, cmd->cid, + cmd->nsid); + break; + default: + nvme_printf(qpair->ctrlr, "%s (%02x) sqid:%d cid:%d nsid:%d\n", + get_io_opcode_string(cmd->opc), cmd->opc, qpair->id, + cmd->cid, cmd->nsid); + break; + } +} + +static void +nvme_qpair_print_command(struct nvme_qpair *qpair, struct nvme_command *cmd) +{ + if (qpair->id == 0) + nvme_admin_qpair_print_command(qpair, cmd); + else + nvme_io_qpair_print_command(qpair, cmd); +} + +struct nvme_status_string { + + uint16_t sc; + const char * str; +}; + +static struct nvme_status_string generic_status[] = { + { NVME_SC_SUCCESS, "SUCCESS" }, + { NVME_SC_INVALID_OPCODE, "INVALID OPCODE" }, + { NVME_SC_INVALID_FIELD, "INVALID_FIELD" }, + { NVME_SC_COMMAND_ID_CONFLICT, "COMMAND ID CONFLICT" }, + { NVME_SC_DATA_TRANSFER_ERROR, "DATA TRANSFER ERROR" }, + { NVME_SC_ABORTED_POWER_LOSS, "ABORTED - POWER LOSS" }, + { NVME_SC_INTERNAL_DEVICE_ERROR, "INTERNAL DEVICE ERROR" }, + { NVME_SC_ABORTED_BY_REQUEST, "ABORTED - BY REQUEST" }, + { NVME_SC_ABORTED_SQ_DELETION, "ABORTED - SQ DELETION" }, + { NVME_SC_ABORTED_FAILED_FUSED, "ABORTED - FAILED FUSED" }, + { NVME_SC_ABORTED_MISSING_FUSED, "ABORTED - MISSING FUSED" }, + { NVME_SC_INVALID_NAMESPACE_OR_FORMAT, "INVALID NAMESPACE OR FORMAT" }, + { NVME_SC_COMMAND_SEQUENCE_ERROR, "COMMAND SEQUENCE ERROR" }, + { NVME_SC_LBA_OUT_OF_RANGE, "LBA OUT OF RANGE" }, + { NVME_SC_CAPACITY_EXCEEDED, "CAPACITY EXCEEDED" }, + { NVME_SC_NAMESPACE_NOT_READY, "NAMESPACE NOT READY" }, + { 0xFFFF, "GENERIC" } +}; + +static struct nvme_status_string command_specific_status[] = { + { NVME_SC_COMPLETION_QUEUE_INVALID, "INVALID COMPLETION QUEUE" }, + { NVME_SC_INVALID_QUEUE_IDENTIFIER, "INVALID QUEUE IDENTIFIER" }, + { NVME_SC_MAXIMUM_QUEUE_SIZE_EXCEEDED, "MAX QUEUE SIZE EXCEEDED" }, + { NVME_SC_ABORT_COMMAND_LIMIT_EXCEEDED, "ABORT CMD LIMIT EXCEEDED" }, + { NVME_SC_ASYNC_EVENT_REQUEST_LIMIT_EXCEEDED, "ASYNC LIMIT EXCEEDED" }, + { NVME_SC_INVALID_FIRMWARE_SLOT, "INVALID FIRMWARE SLOT" }, + { NVME_SC_INVALID_FIRMWARE_IMAGE, "INVALID FIRMWARE IMAGE" }, + { NVME_SC_INVALID_INTERRUPT_VECTOR, "INVALID INTERRUPT VECTOR" }, + { NVME_SC_INVALID_LOG_PAGE, "INVALID LOG PAGE" }, + { NVME_SC_INVALID_FORMAT, "INVALID FORMAT" }, + { NVME_SC_FIRMWARE_REQUIRES_RESET, "FIRMWARE REQUIRES RESET" }, + { NVME_SC_CONFLICTING_ATTRIBUTES, "CONFLICTING ATTRIBUTES" }, + { NVME_SC_INVALID_PROTECTION_INFO, "INVALID PROTECTION INFO" }, + { NVME_SC_ATTEMPTED_WRITE_TO_RO_PAGE, "WRITE TO RO PAGE" }, + { 0xFFFF, "COMMAND SPECIFIC" } +}; + +static struct nvme_status_string media_error_status[] = { + { NVME_SC_WRITE_FAULTS, "WRITE FAULTS" }, + { NVME_SC_UNRECOVERED_READ_ERROR, "UNRECOVERED READ ERROR" }, + { NVME_SC_GUARD_CHECK_ERROR, "GUARD CHECK ERROR" }, + { NVME_SC_APPLICATION_TAG_CHECK_ERROR, "APPLICATION TAG CHECK ERROR" }, + { NVME_SC_REFERENCE_TAG_CHECK_ERROR, "REFERENCE TAG CHECK ERROR" }, + { NVME_SC_COMPARE_FAILURE, "COMPARE FAILURE" }, + { NVME_SC_ACCESS_DENIED, "ACCESS DENIED" }, + { 0xFFFF, "MEDIA ERROR" } +}; + +static const char * +get_status_string(uint16_t sct, uint16_t sc) +{ + struct nvme_status_string *entry; + + switch (sct) { + case NVME_SCT_GENERIC: + entry = generic_status; + break; + case NVME_SCT_COMMAND_SPECIFIC: + entry = command_specific_status; + break; + case NVME_SCT_MEDIA_ERROR: + entry = media_error_status; + break; + case NVME_SCT_VENDOR_SPECIFIC: + return ("VENDOR SPECIFIC"); + default: + return ("RESERVED"); + } + + while (entry->sc != 0xFFFF) { + if (entry->sc == sc) + return (entry->str); + entry++; + } + return (entry->str); +} + +static void +nvme_qpair_print_completion(struct nvme_qpair *qpair, + struct nvme_completion *cpl) +{ + nvme_printf(qpair->ctrlr, "%s (%02x/%02x) sqid:%d cid:%d cdw0:%x\n", + get_status_string(cpl->status.sct, cpl->status.sc), + cpl->status.sct, cpl->status.sc, cpl->sqid, cpl->cid, cpl->cdw0); +} + static boolean_t nvme_completion_is_retry(const struct nvme_completion *cpl) { @@ -108,8 +317,8 @@ nvme_qpair_complete_tracker(struct nvme_ req->retries < nvme_retry_count; if (error && print_on_error) { - nvme_dump_completion(cpl); - nvme_dump_command(&req->cmd); + nvme_qpair_print_command(qpair, &req->cmd); + nvme_qpair_print_completion(qpair, cpl); } qpair->act_tr[cpl->cid] = NULL; @@ -184,8 +393,8 @@ nvme_qpair_manual_complete_request(struc error = nvme_completion_is_error(&cpl); if (error && print_on_error) { - nvme_dump_completion(&cpl); - nvme_dump_command(&req->cmd); + nvme_qpair_print_command(qpair, &req->cmd); + nvme_qpair_print_completion(qpair, &cpl); } if (req->cb_fn) @@ -223,7 +432,8 @@ nvme_qpair_process_completions(struct nv nvme_qpair_complete_tracker(qpair, tr, cpl, TRUE); qpair->sq_head = cpl->sqhd; } else { - printf("cpl does not map to outstanding cmd\n"); + nvme_printf(qpair->ctrlr, + "cpl does not map to outstanding cmd\n"); nvme_dump_completion(cpl); KASSERT(0, ("received completion for unknown cmd\n")); } @@ -423,7 +633,8 @@ nvme_abort_complete(void *arg, const str * abort it for some reason. Construct a fake completion * status, and then complete the I/O's tracker manually. */ - printf("abort command failed, aborting command manually\n"); + nvme_printf(tr->qpair->ctrlr, + "abort command failed, aborting command manually\n"); nvme_qpair_manual_complete_tracker(tr->qpair, tr, NVME_SCT_GENERIC, NVME_SC_ABORTED_BY_REQUEST, 0, TRUE); } @@ -597,7 +808,7 @@ nvme_admin_qpair_enable(struct nvme_qpai * command was issued no longer applies. */ TAILQ_FOREACH_SAFE(tr, &qpair->outstanding_tr, tailq, tr_temp) { - device_printf(qpair->ctrlr->dev, + nvme_printf(qpair->ctrlr, "aborting outstanding admin command\n"); nvme_qpair_manual_complete_tracker(qpair, tr, NVME_SCT_GENERIC, NVME_SC_ABORTED_BY_REQUEST, 1 /* do not retry */, TRUE); @@ -620,8 +831,7 @@ nvme_io_qpair_enable(struct nvme_qpair * * reached its limit. */ TAILQ_FOREACH_SAFE(tr, &qpair->outstanding_tr, tailq, tr_temp) { - device_printf(qpair->ctrlr->dev, - "aborting outstanding i/o\n"); + nvme_printf(qpair->ctrlr, "aborting outstanding i/o\n"); nvme_qpair_manual_complete_tracker(qpair, tr, NVME_SCT_GENERIC, NVME_SC_ABORTED_BY_REQUEST, 0, TRUE); } @@ -636,9 +846,8 @@ nvme_io_qpair_enable(struct nvme_qpair * while (!STAILQ_EMPTY(&temp)) { req = STAILQ_FIRST(&temp); STAILQ_REMOVE_HEAD(&temp, stailq); - device_printf(qpair->ctrlr->dev, - "resubmitting queued i/o\n"); - nvme_dump_command(&req->cmd); + nvme_printf(qpair->ctrlr, "resubmitting queued i/o\n"); + nvme_qpair_print_command(qpair, &req->cmd); _nvme_qpair_submit_request(qpair, req); } @@ -683,8 +892,7 @@ nvme_qpair_fail(struct nvme_qpair *qpair while (!STAILQ_EMPTY(&qpair->queued_req)) { req = STAILQ_FIRST(&qpair->queued_req); STAILQ_REMOVE_HEAD(&qpair->queued_req, stailq); - device_printf(qpair->ctrlr->dev, - "failing queued i/o\n"); + nvme_printf(qpair->ctrlr, "failing queued i/o\n"); mtx_unlock(&qpair->lock); nvme_qpair_manual_complete_request(qpair, req, NVME_SCT_GENERIC, NVME_SC_ABORTED_BY_REQUEST, TRUE); @@ -698,8 +906,7 @@ nvme_qpair_fail(struct nvme_qpair *qpair * Do not remove the tracker. The abort_tracker path will * do that for us. */ - device_printf(qpair->ctrlr->dev, - "failing outstanding i/o\n"); + nvme_printf(qpair->ctrlr, "failing outstanding i/o\n"); mtx_unlock(&qpair->lock); nvme_qpair_manual_complete_tracker(qpair, tr, NVME_SCT_GENERIC, NVME_SC_ABORTED_BY_REQUEST, 1 /* do not retry */, TRUE); From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 22:46:56 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id A1496948; Tue, 26 Mar 2013 22:46:56 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 938249C0; Tue, 26 Mar 2013 22:46:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QMkuWx043437; Tue, 26 Mar 2013 22:46:56 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QMkuca043435; Tue, 26 Mar 2013 22:46:56 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201303262246.r2QMkuca043435@svn.freebsd.org> From: Jilles Tjoelker Date: Tue, 26 Mar 2013 22:46:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248774 - head/lib/libc/sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 22:46:56 -0000 Author: jilles Date: Tue Mar 26 22:46:56 2013 New Revision: 248774 URL: http://svnweb.freebsd.org/changeset/base/248774 Log: accept(2): Mention inheritance of O_ASYNC and signal destination. While almost nobody uses O_ASYNC, and rightly so, the inheritance of the related properties across accept() is a portability issue like the inheritance of O_NONBLOCK. Modified: head/lib/libc/sys/accept.2 Modified: head/lib/libc/sys/accept.2 ============================================================================== --- head/lib/libc/sys/accept.2 Tue Mar 26 22:17:10 2013 (r248773) +++ head/lib/libc/sys/accept.2 Tue Mar 26 22:46:56 2013 (r248774) @@ -28,7 +28,7 @@ .\" @(#)accept.2 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd December 11, 1993 +.Dd March 26, 2013 .Dt ACCEPT 2 .Os .Sh NAME @@ -57,7 +57,13 @@ queue of pending connections, creates a and allocates a new file descriptor for the socket which inherits the state of the .Dv O_NONBLOCK -property from the original socket +and +.Dv O_ASYNC +properties and the destination of +.Dv SIGIO +and +.Dv SIGURG +signals from the original socket .Fa s . .Pp If no pending connections are @@ -129,7 +135,11 @@ to pre-process incoming connections. .Pp Portable programs should not rely on the .Dv O_NONBLOCK -property being inherited. +and +.Dv O_ASYNC +properties and the signal destination being inherited, +but should set them explicitly using +.Xr fcntl 2 . .Sh RETURN VALUES The call returns \-1 on error. If it succeeds, it returns a non-negative From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 23:04:07 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 033AFE58; Tue, 26 Mar 2013 23:04:07 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id EA20CB15; Tue, 26 Mar 2013 23:04:06 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QN46XM049103; Tue, 26 Mar 2013 23:04:06 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QN467c049101; Tue, 26 Mar 2013 23:04:06 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303262304.r2QN467c049101@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 23:04:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248775 - head/sys/dev/isci X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 23:04:07 -0000 Author: jimharris Date: Tue Mar 26 23:04:06 2013 New Revision: 248775 URL: http://svnweb.freebsd.org/changeset/base/248775 Log: Report support for unmapped I/O by adding PIM_UNMAPPED flag. Submitted by: jhb, scottl Modified: head/sys/dev/isci/isci_controller.c head/sys/dev/isci/isci_io_request.c Modified: head/sys/dev/isci/isci_controller.c ============================================================================== --- head/sys/dev/isci/isci_controller.c Tue Mar 26 22:46:56 2013 (r248774) +++ head/sys/dev/isci/isci_controller.c Tue Mar 26 23:04:06 2013 (r248775) @@ -673,7 +673,8 @@ void isci_action(struct cam_sim *sim, un cpi->version_num = 1; cpi->hba_inquiry = PI_TAG_ABLE; cpi->target_sprt = 0; - cpi->hba_misc = PIM_NOBUSRESET | PIM_SEQSCAN; + cpi->hba_misc = PIM_NOBUSRESET | PIM_SEQSCAN | + PIM_UNMAPPED; cpi->hba_eng_cnt = 0; cpi->max_target = SCI_MAX_REMOTE_DEVICES - 1; cpi->max_lun = ISCI_MAX_LUN; Modified: head/sys/dev/isci/isci_io_request.c ============================================================================== --- head/sys/dev/isci/isci_io_request.c Tue Mar 26 22:46:56 2013 (r248774) +++ head/sys/dev/isci/isci_io_request.c Tue Mar 26 23:04:06 2013 (r248775) @@ -747,10 +747,6 @@ isci_io_request_execute_scsi_io(union cc io_request->current_sge_index = 0; io_request->parent.remote_device_handle = device->sci_object; - if ((ccb->ccb_h.flags & CAM_DATA_MASK) != CAM_DATA_VADDR) - panic("Unexpected cam data format! flags = 0x%x\n", - ccb->ccb_h.flags); - error = bus_dmamap_load_ccb(io_request->parent.dma_tag, io_request->parent.dma_map, ccb, isci_io_request_construct, io_request, 0x0); From owner-svn-src-all@FreeBSD.ORG Tue Mar 26 23:11:31 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 8594E244; Tue, 26 Mar 2013 23:11:31 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 691D3C2F; Tue, 26 Mar 2013 23:11:31 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QNBVcF051999; Tue, 26 Mar 2013 23:11:31 GMT (envelope-from markj@svn.freebsd.org) Received: (from markj@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QNBVHo051998; Tue, 26 Mar 2013 23:11:31 GMT (envelope-from markj@svn.freebsd.org) Message-Id: <201303262311.r2QNBVHo051998@svn.freebsd.org> From: Mark Johnston Date: Tue, 26 Mar 2013 23:11:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248776 - head/usr.sbin/newsyslog X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 23:11:31 -0000 Author: markj Date: Tue Mar 26 23:11:30 2013 New Revision: 248776 URL: http://svnweb.freebsd.org/changeset/base/248776 Log: Fix interval-based rotations when the -t flag is used. In this case, find the most-recently archived logfile and use its mtime to determine whether or not to rotate, as in the non-timestamped case. Previously we would just try to use the mtime of .0, which always results in a rotation since it generally doesn't exist in the -t case. PR: bin/166448 Approved by: emaste (co-mentor) Tested by: Marco Steinbach MFC after: 2 weeks Modified: head/usr.sbin/newsyslog/newsyslog.c Modified: head/usr.sbin/newsyslog/newsyslog.c ============================================================================== --- head/usr.sbin/newsyslog/newsyslog.c Tue Mar 26 23:04:06 2013 (r248775) +++ head/usr.sbin/newsyslog/newsyslog.c Tue Mar 26 23:11:30 2013 (r248776) @@ -276,7 +276,7 @@ static void parse_args(int argc, char ** static int parse_doption(const char *doption); static void usage(void); static int log_trim(const char *logname, const struct conf_entry *log_ent); -static int age_old_log(char *file); +static int age_old_log(const char *file); static void savelog(char *from, char *to); static void createdir(const struct conf_entry *ent, char *dirpart); static void createlog(const struct conf_entry *ent); @@ -1447,20 +1447,78 @@ oldlog_entry_compare(const void *a, cons } /* + * Check whether the file corresponding to dp is an archive of the logfile + * logfname, based on the timefnamefmt format string. Return true and fill out + * tm if this is the case; otherwise return false. + */ +static int +validate_old_timelog(const struct dirent *dp, const char *logfname, struct tm *tm) +{ + size_t logfname_len; + char *s; + int c; + + logfname_len = strlen(logfname); + + if (dp->d_type != DT_REG) + return (0); + /* Ignore everything but files with our logfile prefix. */ + if (strncmp(dp->d_name, logfname, logfname_len) != 0) + return (0); + /* Ignore the actual non-rotated logfile. */ + if (dp->d_namlen == logfname_len) + return (0); + + /* + * Make sure we created have found a logfile, so the + * postfix is valid, IE format is: '.