From owner-svn-src-head@freebsd.org Sun Oct 18 00:59:29 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C7AB1A17D82; Sun, 18 Oct 2015 00:59:29 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 773E8C64; Sun, 18 Oct 2015 00:59:29 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9I0xSaM053945; Sun, 18 Oct 2015 00:59:28 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9I0xSrJ053943; Sun, 18 Oct 2015 00:59:28 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201510180059.t9I0xSrJ053943@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Sun, 18 Oct 2015 00:59:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289476 - head/sys/mips/atheros X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 00:59:30 -0000 Author: adrian Date: Sun Oct 18 00:59:28 2015 New Revision: 289476 URL: https://svnweb.freebsd.org/changeset/base/289476 Log: if_arge: fix up TX workaround; add TX/RX requirements for busdma; add stats The early ethernet MACs (I think AR71xx and AR913x) require that both TX and RX require 4-byte alignment for all packets. The later MACs have started relaxing the requirements. For now, the 1-byte TX and 1-byte RX alignment requirements are only for the QCA955x SoCs. I'll add in the relaxed requirements as I review the datasheets and do testing. * Add a hardware flags field and 1-byte / 4-byte TX/RX alignment. * .. defaulting to 4-byte TX and 4-byte RX alignment. * Only enforce the TX alignment fixup if the hardware requires a 4-byte TX alignment. This avoids a call to m_defrag(). * Add counters for various situations for further debugging. * Set the 1-byte and 4-byte busdma alignment requirement when the tag is created. This improves the straight bridging performance from 130mbit/sec to 180mbit/sec, purely by removing the need for TX path bounce buffers. The main performance issue is the RX alignment requirement and any RX bounce buffering that's occuring. (In a local test, removing the RX fixup path and just aligning buffers raises the performance to above 400mbit/sec. In theory it's a no-op for SoCs before the QCA955x. Tested: * QCA9558 SoC in AP135 board, using software bridging between arge0/arge1. Modified: head/sys/mips/atheros/if_arge.c head/sys/mips/atheros/if_argevar.h Modified: head/sys/mips/atheros/if_arge.c ============================================================================== --- head/sys/mips/atheros/if_arge.c Sat Oct 17 22:41:30 2015 (r289475) +++ head/sys/mips/atheros/if_arge.c Sun Oct 18 00:59:28 2015 (r289476) @@ -298,6 +298,29 @@ arge_attach_sysctl(device_t dev) "tx_pkts_unaligned", CTLFLAG_RW, &sc->stats.tx_pkts_unaligned, 0, "number of TX unaligned packets"); + SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "tx_pkts_unaligned_start", CTLFLAG_RW, &sc->stats.tx_pkts_unaligned_start, + 0, "number of TX unaligned packets (start)"); + + SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "tx_pkts_unaligned_len", CTLFLAG_RW, &sc->stats.tx_pkts_unaligned_len, + 0, "number of TX unaligned packets (len)"); + + SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "tx_pkts_nosegs", CTLFLAG_RW, &sc->stats.tx_pkts_nosegs, + 0, "number of TX packets fail with no ring slots avail"); + + SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "intr_stray_filter", CTLFLAG_RW, &sc->stats.intr_stray, + 0, "number of stray interrupts (filter)"); + + SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "intr_stray_intr", CTLFLAG_RW, &sc->stats.intr_stray2, + 0, "number of stray interrupts (intr)"); + + SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "intr_ok", CTLFLAG_RW, &sc->stats.intr_ok, + 0, "number of OK interrupts"); #ifdef ARGE_DEBUG SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "tx_prod", CTLFLAG_RW, &sc->arge_cdata.arge_tx_prod, 0, ""); @@ -627,6 +650,22 @@ arge_attach(device_t dev) } /* + * Hardware workarounds. + */ + switch (ar71xx_soc) { + case AR71XX_SOC_QCA9556: + case AR71XX_SOC_QCA9558: + /* Arbitrary alignment */ + sc->arge_hw_flags |= ARGE_HW_FLG_TX_DESC_ALIGN_1BYTE; + sc->arge_hw_flags |= ARGE_HW_FLG_RX_DESC_ALIGN_1BYTE; + break; + default: + sc->arge_hw_flags |= ARGE_HW_FLG_TX_DESC_ALIGN_4BYTE; + sc->arge_hw_flags |= ARGE_HW_FLG_RX_DESC_ALIGN_4BYTE; + break; + } + + /* * Some units (eg the TP-Link WR-1043ND) do not have a convenient * EEPROM location to read the ethernet MAC address from. * OpenWRT simply snaffles it from a fixed location. @@ -825,6 +864,9 @@ arge_attach(device_t dev) ARGE_WRITE(sc, AR71XX_MAC_FIFO_CFG0, FIFO_CFG0_ALL << FIFO_CFG0_ENABLE_SHIFT); + /* + * SoC specific bits. + */ switch (ar71xx_soc) { case AR71XX_SOC_AR7240: case AR71XX_SOC_AR7241: @@ -1351,24 +1393,35 @@ arge_init_locked(struct arge_softc *sc) * Return whether the mbuf chain is correctly aligned * for the arge TX engine. * - * The TX engine requires each fragment to be aligned to a - * 4 byte boundary and the size of each fragment except - * the last to be a multiple of 4 bytes. + * All the MACs have a length requirement: any non-final + * fragment (ie, descriptor with MORE bit set) needs to have + * a length divisible by 4. * - * XXX TODO: I believe this is only a bug on the AR71xx and - * AR913x MACs. The later MACs (AR724x and later) does not - * need this workaround. + * The AR71xx, AR913x require the start address also be + * DWORD aligned. The later MACs don't. */ static int -arge_mbuf_chain_is_tx_aligned(struct mbuf *m0) +arge_mbuf_chain_is_tx_aligned(struct arge_softc *sc, struct mbuf *m0) { struct mbuf *m; for (m = m0; m != NULL; m = m->m_next) { - if((mtod(m, intptr_t) & 3) != 0) + /* + * Only do this for chips that require it. + */ + if ((sc->arge_hw_flags & ARGE_HW_FLG_TX_DESC_ALIGN_4BYTE) && + (mtod(m, intptr_t) & 3) != 0) { + sc->stats.tx_pkts_unaligned_start++; return 0; - if ((m->m_next != NULL) && ((m->m_len & 0x03) != 0)) + } + + /* + * All chips have this requirement for length. + */ + if ((m->m_next != NULL) && ((m->m_len & 0x03) != 0)) { + sc->stats.tx_pkts_unaligned_len++; return 0; + } } return 1; } @@ -1389,15 +1442,10 @@ arge_encap(struct arge_softc *sc, struct ARGE_LOCK_ASSERT(sc); /* - * Fix mbuf chain, all fragments should be 4 bytes aligned and - * even 4 bytes - * - * XXX TODO: I believe this is only a bug on the AR71xx and - * AR913x MACs. The later MACs (AR724x and later) does not - * need this workaround. + * Fix mbuf chain based on hardware alignment constraints. */ m = *m_head; - if (! arge_mbuf_chain_is_tx_aligned(m)) { + if (! arge_mbuf_chain_is_tx_aligned(sc, m)) { sc->stats.tx_pkts_unaligned++; m = m_defrag(*m_head, M_NOWAIT); if (m == NULL) { @@ -1427,6 +1475,7 @@ arge_encap(struct arge_softc *sc, struct /* Check number of available descriptors. */ if (sc->arge_cdata.arge_tx_cnt + nsegs >= (ARGE_TX_RING_COUNT - 1)) { bus_dmamap_unload(sc->arge_cdata.arge_tx_tag, txd->tx_dmamap); + sc->stats.tx_pkts_nosegs++; return (ENOBUFS); } @@ -1444,7 +1493,9 @@ arge_encap(struct arge_softc *sc, struct desc = &sc->arge_rdata.arge_tx_ring[prod]; desc->packet_ctrl = ARGE_DMASIZE(txsegs[i].ds_len); - if (txsegs[i].ds_addr & 3) + /* XXX Note: only relevant for older MACs; but check length! */ + if ((sc->arge_hw_flags & ARGE_HW_FLG_TX_DESC_ALIGN_4BYTE) && + (txsegs[i].ds_addr & 3)) panic("TX packet address unaligned\n"); desc->packet_addr = txsegs[i].ds_addr; @@ -1715,6 +1766,16 @@ arge_dma_alloc(struct arge_softc *sc) struct arge_txdesc *txd; struct arge_rxdesc *rxd; int error, i; + int arge_tx_align, arge_rx_align; + + /* Assume 4 byte alignment by default */ + arge_tx_align = 4; + arge_rx_align = 4; + + if (sc->arge_hw_flags & ARGE_HW_FLG_TX_DESC_ALIGN_1BYTE) + arge_tx_align = 1; + if (sc->arge_hw_flags & ARGE_HW_FLG_RX_DESC_ALIGN_1BYTE) + arge_rx_align = 1; /* Create parent DMA tag. */ error = bus_dma_tag_create( @@ -1775,7 +1836,7 @@ arge_dma_alloc(struct arge_softc *sc) /* Create tag for Tx buffers. */ error = bus_dma_tag_create( sc->arge_cdata.arge_parent_tag, /* parent */ - sizeof(uint32_t), 0, /* alignment, boundary */ + arge_tx_align, 0, /* alignment, boundary */ BUS_SPACE_MAXADDR, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ @@ -1793,7 +1854,7 @@ arge_dma_alloc(struct arge_softc *sc) /* Create tag for Rx buffers. */ error = bus_dma_tag_create( sc->arge_cdata.arge_parent_tag, /* parent */ - ARGE_RX_ALIGN, 0, /* alignment, boundary */ + arge_rx_align, 0, /* alignment, boundary */ BUS_SPACE_MAXADDR, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ @@ -2108,6 +2169,11 @@ arge_newbuf(struct arge_softc *sc, int i if (m == NULL) return (ENOBUFS); m->m_len = m->m_pkthdr.len = MCLBYTES; + + /* + * Add extra space to "adjust" (copy) the packet back to be aligned + * for purposes of IPv4/IPv6 header contents. + */ m_adj(m, sizeof(uint64_t)); if (bus_dmamap_load_mbuf_sg(sc->arge_cdata.arge_rx_tag, @@ -2126,7 +2192,8 @@ arge_newbuf(struct arge_softc *sc, int i sc->arge_cdata.arge_rx_sparemap = map; rxd->rx_m = m; desc = rxd->desc; - if (segs[0].ds_addr & 3) + if ((sc->arge_hw_flags & ARGE_HW_FLG_RX_DESC_ALIGN_4BYTE) && + segs[0].ds_addr & 3) panic("RX packet address unaligned"); desc->packet_addr = segs[0].ds_addr; desc->packet_ctrl = ARGE_DESC_EMPTY | ARGE_DMASIZE(segs[0].ds_len); @@ -2331,10 +2398,12 @@ arge_intr_filter(void *arg) if (status & DMA_INTR_ALL) { sc->arge_intr_status |= status; ARGE_WRITE(sc, AR71XX_DMA_INTR, 0); + sc->stats.intr_ok++; return (FILTER_SCHEDULE_THREAD); } sc->arge_intr_status = 0; + sc->stats.intr_stray++; return (FILTER_STRAY); } @@ -2355,8 +2424,10 @@ arge_intr(void *arg) /* * Is it our interrupt at all? */ - if (status == 0) + if (status == 0) { + sc->stats.intr_stray2++; return; + } if (status & DMA_INTR_RX_BUS_ERROR) { ARGE_WRITE(sc, AR71XX_DMA_RX_STATUS, DMA_RX_STATUS_BUS_ERROR); Modified: head/sys/mips/atheros/if_argevar.h ============================================================================== --- head/sys/mips/atheros/if_argevar.h Sat Oct 17 22:41:30 2015 (r289475) +++ head/sys/mips/atheros/if_argevar.h Sun Oct 18 00:59:28 2015 (r289476) @@ -37,7 +37,10 @@ #define ARGE_TX_DMA_SIZE ARGE_TX_RING_COUNT * sizeof(struct arge_desc) #define ARGE_MAXFRAGS 8 #define ARGE_RING_ALIGN sizeof(struct arge_desc) -#define ARGE_RX_ALIGN sizeof(uint32_t) +#define ARGE_RX_ALIGN_4BYTE sizeof(uint32_t) +#define ARGE_RX_ALIGN_1BYTE sizeof(char) +#define ARGE_TX_ALIGN_4BYTE sizeof(uint32_t) +#define ARGE_TX_ALIGN_1BYTE sizeof(char) #define ARGE_MAXFRAGS 8 #define ARGE_TX_RING_ADDR(sc, i) \ ((sc)->arge_rdata.arge_tx_ring_paddr + sizeof(struct arge_desc) * (i)) @@ -149,6 +152,22 @@ struct arge_pll_data { uint32_t pll_1000; }; +/* + * Hardware specific behaviours. + */ + +/* + * Older chips support 4 byte only transmit and receive + * addresses. + * + * Later chips support arbitrary TX and later later, + * arbitrary RX addresses. + */ +#define ARGE_HW_FLG_TX_DESC_ALIGN_4BYTE 0x00000001 +#define ARGE_HW_FLG_RX_DESC_ALIGN_4BYTE 0x00000002 +#define ARGE_HW_FLG_TX_DESC_ALIGN_1BYTE 0x00000004 +#define ARGE_HW_FLG_RX_DESC_ALIGN_1BYTE 0x00000008 + struct arge_softc { struct ifnet *arge_ifp; /* interface info */ device_t arge_dev; @@ -180,13 +199,20 @@ struct arge_softc { uint32_t arge_intr_status; int arge_mac_unit; int arge_if_flags; + uint32_t arge_hw_flags; uint32_t arge_debug; uint32_t arge_mdiofreq; struct { uint32_t tx_pkts_unaligned; + uint32_t tx_pkts_unaligned_start; + uint32_t tx_pkts_unaligned_len; + uint32_t tx_pkts_nosegs; uint32_t tx_pkts_aligned; uint32_t rx_overflow; uint32_t tx_underflow; + uint32_t intr_stray; + uint32_t intr_stray2; + uint32_t intr_ok; } stats; }; From owner-svn-src-head@freebsd.org Sun Oct 18 01:03:45 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 13688A17EE7; Sun, 18 Oct 2015 01:03:45 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CB496FD0; Sun, 18 Oct 2015 01:03:44 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9I13hSd056672; Sun, 18 Oct 2015 01:03:43 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9I13h0w056671; Sun, 18 Oct 2015 01:03:43 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201510180103.t9I13h0w056671@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 18 Oct 2015 01:03:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289477 - head/sys/arm/mv X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 01:03:45 -0000 Author: ian Date: Sun Oct 18 01:03:43 2015 New Revision: 289477 URL: https://svnweb.freebsd.org/changeset/base/289477 Log: Fix a strange macro re-definition compile error. If the VM_MAXUSER_ADDRESS value is defined as a config option the definition is emitted into opt_global.h which is force-included into everything. In addition, the symbol is emitted by the genassym mechanism, but that by its nature reduces the value to a 0xnnnnnnnn number. When compiling a .S file you end up with two different definitions of the macro (they evaluate to the same number, but the text is different, upsetting the compiler). Nothing has changed about this code for a while but the compile error is new, so this must be fallout from the clang 3.7 update or something. Modified: head/sys/arm/mv/std-pj4b.mv Modified: head/sys/arm/mv/std-pj4b.mv ============================================================================== --- head/sys/arm/mv/std-pj4b.mv Sun Oct 18 00:59:28 2015 (r289476) +++ head/sys/arm/mv/std-pj4b.mv Sun Oct 18 01:03:43 2015 (r289477) @@ -5,4 +5,8 @@ cpu CPU_MV_PJ4B machine arm armv6 makeoptions CONF_CFLAGS="-march=armv7a" -options VM_MAXUSER_ADDRESS="(KERNBASE-(1024*1024*1024))" +# This was originally defined as "(KERNBASE-(1024*1024*1024))" but that +# (in opt_global.h) clashed with the value emitted by genassym which +# reduces the original macro text to its numeric value. The only way +# to avoid that is to define it here as the numeric value genassym emits. +options VM_MAXUSER_ADDRESS="0x80000000" From owner-svn-src-head@freebsd.org Sun Oct 18 02:00:25 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9ED17A109FC; Sun, 18 Oct 2015 02:00:25 +0000 (UTC) (envelope-from cy.schubert@komquats.com) Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.9]) by mx1.freebsd.org (Postfix) with ESMTP id 4C5CB664; Sun, 18 Oct 2015 02:00:24 +0000 (UTC) (envelope-from cy.schubert@komquats.com) Received: from spqr.komquats.com ([96.50.22.10]) by shaw.ca with SMTP id ndGoZFeumT2vondGpZcPpt; Sat, 17 Oct 2015 20:00:24 -0600 X-Authority-Analysis: v=2.1 cv=NrEbCZpJ c=1 sm=1 tr=0 a=jvE2nwUzI0ECrNeyr98KWA==:117 a=jvE2nwUzI0ECrNeyr98KWA==:17 a=BWvPGDcYAAAA:8 a=VxmjJ2MpAAAA:8 a=kj9zAlcOel0A:10 a=5lJygRwiOn0A:10 a=YxBL1-UpAAAA:8 a=6I5d2MoRAAAA:8 a=7Qk2ozbKAAAA:8 a=PYnjg3YJAAAA:8 a=qyDxTJV7AAAA:8 a=85N1-lAfAAAA:8 a=zNd2u4x_AAAA:8 a=j4nzMFrpAAAA:8 a=LXAkBHwNKlrvpHAmy1AA:9 a=p1sdcP6kqR4I5I3S:21 a=MWrKzmkL3O-0r47v:21 a=jxAiteTpt7Uo66uM:21 a=CjuIK1q_8ugA:10 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTP id 4EAD99FDD; Sat, 17 Oct 2015 19:00:22 -0700 (PDT) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id t9I20KLI062531; Sat, 17 Oct 2015 19:00:20 -0700 (PDT) (envelope-from Cy.Schubert@komquats.com) Message-Id: <201510180200.t9I20KLI062531@slippy.cwsent.com> X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.6 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.komquats.com/ To: Warner Losh cc: Cy Schubert , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, David Malone , Ollivier Robert , Xin Li Subject: Re: svn commit: r289421 - in head/etc: . mtree ntp In-Reply-To: Message from Warner Losh of "Sat, 17 Oct 2015 13:19:44 -0600." <8154492E-C29E-41B1-A13B-34E33586DEC6@bsdimp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 17 Oct 2015 19:00:20 -0700 X-CMAE-Envelope: MS4wfJj8dMMkX+NzFAMaWo5f3YmOCMnUBcgYD35YiqnMnOPRGZGlKpimKgpdteyz5kIQHpypT7OLalUdy46fA01JChtCne0CjNbkFiowdx5cAUifzOUQfT0KqTOyFmE1iXlL7I7/f+9PXnry67sutXv5mrko/Muk7zGxyKfqnD8AJUV8iJnBr4k7PeUYR4hB5ezNGsoIVqxgKEA6FZNRqEYtazKdlDq8+VaVD9UNlat8adS2KRmFTEgjojA7gw1YhBbvDvc4YzQFNwHam4CsrzexO+ZX0pHjzUQqii0lcLkxE+8B7qx/koKTYDXtumu6SUcxg7tpBx25ftdetUNWfPNP0BhZDMkhnBUpGFnSKGmVHL//V1pDO0zz6ratcEA1x6t4FieASMbxM2GgvugmIRESOXxsixky9ZHk9kCjdMYA7WYu X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 02:00:25 -0000 Agreed, this would be best. There was a suggestion a GSoC person could do it (though I'm willing to roll up my sleeves if necessary). -- Cheers, Cy Schubert or FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few. In message <8154492E-C29E-41B1-A13B-34E33586DEC6@bsdimp.com>, Warner Losh write s: > > > --Apple-Mail=_60572A67-97E7-4200-AEF6-88DC6354712B > Content-Transfer-Encoding: quoted-printable > Content-Type: text/plain; > charset=utf-8 > > Until the next leap second=E2=80=A6. It would be better to just > always try to grab the latest one=E2=80=A6 Can we put something > in periodic to do that so users that have releases > that are older than 6 months aren=E2=80=99t screwed? > > Warner > > > On Oct 16, 2015, at 8:04 AM, Cy Schubert wrote: > >=20 > > Author: cy > > Date: Fri Oct 16 14:04:16 2015 > > New Revision: 289421 > > URL: https://svnweb.freebsd.org/changeset/base/289421 > >=20 > > Log: > > Add default leap-seconds file. This should help ntp networks get the > > leap second date correct > >=20 > > Updates to the file can be obtained from ftp://time.nist.gov/pub/ or > > ftp://tycho.usno.navy.mil/pub/ntp/. > >=20 > > Suggested by: dwmalone > > Reviewed by: roberto, dwmalone, delphij > > Approved by: roberto > > MFC after: 1 week > >=20 > > Added: > > head/etc/ntp/ > > head/etc/ntp/Makefile (contents, props changed) > > head/etc/ntp/leap-seconds (contents, props changed) > > Modified: > > head/etc/Makefile > > head/etc/mtree/BSD.var.dist > > head/etc/ntp.conf > >=20 > > Modified: head/etc/Makefile > > = > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D > > --- head/etc/Makefile Fri Oct 16 12:53:22 2015 (r289420) > > +++ head/etc/Makefile Fri Oct 16 14:04:16 2015 (r289421) > > @@ -240,6 +240,9 @@ distribution: > > ${_+_}cd ${.CURDIR}/defaults; ${MAKE} install > > ${_+_}cd ${.CURDIR}/devd; ${MAKE} install > > ${_+_}cd ${.CURDIR}/gss; ${MAKE} install > > +.if ${MK_NTP} !=3D "no" > > + ${_+_}cd ${.CURDIR}/ntp; ${MAKE} install > > +.endif > > ${_+_}cd ${.CURDIR}/periodic; ${MAKE} install > > .if ${MK_PKGBOOTSTRAP} !=3D "no" > > ${_+_}cd ${.CURDIR}/pkg; ${MAKE} install > >=20 > > Modified: head/etc/mtree/BSD.var.dist > > = > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D > > --- head/etc/mtree/BSD.var.dist Fri Oct 16 12:53:22 2015 = > (r289420) > > +++ head/etc/mtree/BSD.var.dist Fri Oct 16 14:04:16 2015 = > (r289421) > > @@ -46,6 +46,8 @@ > > .. > > ipf mode=3D0700 > > .. > > + ntp mode=3D0700 > > + .. > > pkg > > .. > > ports > >=20 > > Modified: head/etc/ntp.conf > > = > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D > > --- head/etc/ntp.conf Fri Oct 16 12:53:22 2015 (r289420) > > +++ head/etc/ntp.conf Fri Oct 16 14:04:16 2015 (r289421) > > @@ -77,3 +77,8 @@ restrict 127.127.1.0 > > # > > #server 127.127.1.0 > > #fudge 127.127.1.0 stratum 10 > > + > > +# See = > http://support.ntp.org/bin/view/Support/ConfiguringNTP#Section_6.14. > > +# for documentation regarding leapfile. Updates to the file can be = > obtained > > +# from ftp://time.nist.gov/pub/ or = > ftp://tycho.usno.navy.mil/pub/ntp/. > > +leapfile "/etc/ntp/leap-seconds" > >=20 > > Added: head/etc/ntp/Makefile > > = > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D > > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > > +++ head/etc/ntp/Makefile Fri Oct 16 14:04:16 2015 = > (r289421) > > @@ -0,0 +1,10 @@ > > +# $FreeBSD$ > > + > > +NO_OBJ=3D > > + > > +FILES=3D leap-seconds > > + > > +FILESDIR=3D /etc/ntp > > +FILESMODE=3D 644 > > + > > +.include > >=20 > > Added: head/etc/ntp/leap-seconds > > = > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D > > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > > +++ head/etc/ntp/leap-seconds Fri Oct 16 14:04:16 2015 = > (r289421) > > @@ -0,0 +1,119 @@ > > +# > > +# $FreeBSD$ > > +# > > +# ATOMIC TIME. > > +# The Coordinated Universal Time (UTC) is the reference time scale = > derived > > +# from The "Temps Atomique International" (TAI) calculated by the = > Bureau > > +# International des Poids et Mesures (BIPM) using a worldwide = > network of atomic > > +# clocks. UTC differs from TAI by an integer number of seconds; it = > is the basis > > +# of all activities in the world. > > +# > > +# > > +# ASTRONOMICAL TIME (UT1) is the time scale based on the rate of = > rotation of the earth. > > +# It is now mainly derived from Very Long Baseline Interferometry = > (VLBI). The various > > +# irregular fluctuations progressively detected in the rotation = > rate of the Earth lead > > +# in 1972 to the replacement of UT1 by UTC as the reference time = > scale. > > +# > > +# > > +# LEAP SECOND > > +# Atomic clocks are more stable than the rate of the earth = > rotatiob since the later > > +# undergoes a full range of geophysical perturbations at various = > time scales (lunisolar > > +# and core-mantle torques,atmospheric and oceanic effetcs, ...) > > +# Leap seconds are needed to keep the two time scales in = > agreement, i.e. UT1-UTC smaller > > +# than 0.9 second. So, when necessary a "leap second" is = > introduced in UTC. > > +# Since the adoption of this system in 1972 it has been necessary = > to add 26 seconds to UTC, > > +# firstly due to the initial choice of the value of the second = > (1/86400 mean solar day of > > +# the year 1820) and secondly to the general slowing down of the = > Earth's rotation. It is > > +# theorically possible to have a negative leap second (a second = > removed from UTC), but so far, > > +# all leap seconds have been positive (a second has been added to = > UTC). Based on what we know about the earth's rotation, > > +# it is unlikely that we will ever have a negative leap second. > > +# > > +# > > +# HISTORY > > +# The first leap second was added on June 30, 1972. Until 2000, it = > was necessary in average to add a leap second at a rate > > +# of 1 to 2 years. Since 2000, due to the fact that the earth rate = > of rotation is accelerating, leap seconds are introduced > > +# with an average frequency of 3 to 4 years. > > +# > > +# > > +# RESPONSABILITY OF THE DECISION TO INTRODUCE A LEAP SECOND IN UTC > > +# The decision to introduce a leap second in UTC is the = > responsibility of the Earth Orientation Center of > > +# the International Earth Rotation and reference System Service = > (IERS). This center is located at Paris > > +# Observatory. According to international agreements, leap second = > date have to occur at fixed date : > > +# first preference is given to the end of December and June, and = > second preference at the end of March > > +# and September. Since the system was introduced in 1972, only = > dates in June and December were used. > > +# > > +# Questions or comments to: > > +# Daniel Gambis, daniel.gambis@obspm.fr > > +# Christian Bizouard: christian.bizouard@obspm.fr > > +# Earth orientation Center of the IERS > > +# Paris Observatory, France > > +# > > +# > > +# > > +# VALIDITY OF THE FILE > > +# It is important to express the validity of the file. These next = > two dates are > > +# given in units of seconds since 1900.0. > > +# > > +# 1) Last update of the file. > > +# > > +# Updated through IERS Bulletin C = > (ftp://hpiers.obspm.fr/iers/bul/bulc/bulletinc.dat) > > +# > > +# The following line shows the last update of this file in NTP = > timestamp: > > +# > > +#$ 3645216000 > > +# > > +# 2) Expiration date of the file given on a semi-annual basis: = > last June or last December > > +# > > +# File expires on 28 December 2015 > > +# > > +# Expire date in NTP timestamp: > > +# > > +#@ 3660249600 > > +# > > +# > > +# LIST OF LEAP SECONDS > > +# NTP timestamp (X parameter) is the number of seconds since = > 1900.0 > > +# > > +# MJD: The Modified Julian Day number. MJD =3D X/86400 + 15020 > > +# > > +# DTAI: The difference DTAI=3D TAI-UTC in units of seconds > > +# It is the quantity to add to UTC to get the time in TAI > > +# > > +# Day Month Year : epoch in clear > > +# > > +#NTP Time DTAI Day Month Year > > +# > > +2272060800 10 # 1 Jan 1972 > > +2287785600 11 # 1 Jul 1972 > > +2303683200 12 # 1 Jan 1973 > > +2335219200 13 # 1 Jan 1974 > > +2366755200 14 # 1 Jan 1975 > > +2398291200 15 # 1 Jan 1976 > > +2429913600 16 # 1 Jan 1977 > > +2461449600 17 # 1 Jan 1978 > > +2492985600 18 # 1 Jan 1979 > > +2524521600 19 # 1 Jan 1980 > > +2571782400 20 # 1 Jul 1981 > > +2603318400 21 # 1 Jul 1982 > > +2634854400 22 # 1 Jul 1983 > > +2698012800 23 # 1 Jul 1985 > > +2776982400 24 # 1 Jan 1988 > > +2840140800 25 # 1 Jan 1990 > > +2871676800 26 # 1 Jan 1991 > > +2918937600 27 # 1 Jul 1992 > > +2950473600 28 # 1 Jul 1993 > > +2982009600 29 # 1 Jul 1994 > > +3029443200 30 # 1 Jan 1996 > > +3076704000 31 # 1 Jul 1997 > > +3124137600 32 # 1 Jan 1999 > > +3345062400 33 # 1 Jan 2006 > > +3439756800 34 # 1 Jan 2009 > > +3550089600 35 # 1 Jul 2012 > > +3644697600 36 # 1 Jul 2015 > > +# > > +# In order to verify the integrity of this file, a hash code > > +# has been generated. For more information how to use > > +# this hash code, please consult the README file under the > > +# 'sha' repertory. > > +# > > +#h 620ba8af 37900668 95ac09ba d77640f9 6fd75493 > >=20 > > > --Apple-Mail=_60572A67-97E7-4200-AEF6-88DC6354712B > Content-Transfer-Encoding: 7bit > Content-Disposition: attachment; > filename=signature.asc > Content-Type: application/pgp-signature; > name=signature.asc > Content-Description: Message signed with OpenPGP using GPGMail > > -----BEGIN PGP SIGNATURE----- > Comment: GPGTools - https://gpgtools.org > > iQIcBAEBCgAGBQJWIp9QAAoJEGwc0Sh9sBEA8GMP/RxMSBQvI0BKgbMfYZh7+x2w > gGPNOl5FrDjv6R1QxM2alDe3sEZmhNsZ5o0Ekso4kA/uzz5hF9eElp2EA0wn2DMa > 1IWJKbLUwLsKvN5bC2cMVmzlklqknm9R7EVyRwPB1Q9jgN8cQV4q01tN96XzbCmQ > 1M2Tg8CccnpI9hpdOLjpZQB72kr+rTUm9YrIuiP+nq62NjP4u4UyquKOeUfyyZP1 > WnpDNHNknvzlhCnXiexFHUtueL0bAjnSs0F9C7k661xtdt43q/zp0VWkTUeib8/y > o64PLOmq3dRK+PLDwRLY94OSpe5QqDivyR4H0BAbKbV97GjC/9byhJenR2J+5GUC > 2w54ddlW6rr7rE5kZYd8E5DSoMlmunpm1rMbEwHLHtRXxorZxDUMvj779VS4rj2b > MDxVngI/H0/o3inpSZjsqyLqNut8h204r64m2W5MWTMUJ5z1Evb/Uj6Gewfu3rk2 > kALtxq32we0Edt8VjYUAOOG/ZjTUWdBY0DPsDBeqjeYqkTNP7Ebgj0z0P69UYRsu > XBuMd7ONzSDSAGYXHbyBa2eLhPxDpInBPZ/R4agybBQIJ1qKv6PtV0VH8VGYzADm > DhrVGOsSc/yyou+YX7EzTT4F0S1gjPEgO4wopmZdOUFaNBzE8n8UVxTmT4jMlrTH > SchUp801COK+osnNyG4c > =3+ya > -----END PGP SIGNATURE----- > > --Apple-Mail=_60572A67-97E7-4200-AEF6-88DC6354712B-- > From owner-svn-src-head@freebsd.org Sun Oct 18 02:00:25 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A61C2A109FD; Sun, 18 Oct 2015 02:00:25 +0000 (UTC) (envelope-from cy.schubert@komquats.com) Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.9]) by mx1.freebsd.org (Postfix) with ESMTP id 4C68D666; Sun, 18 Oct 2015 02:00:24 +0000 (UTC) (envelope-from cy.schubert@komquats.com) Received: from spqr.komquats.com ([96.50.22.10]) by shaw.ca with SMTP id ndGiZFetKT2vondGjZcPgL; Sat, 17 Oct 2015 20:00:18 -0600 X-Authority-Analysis: v=2.1 cv=NrEbCZpJ c=1 sm=1 tr=0 a=jvE2nwUzI0ECrNeyr98KWA==:117 a=jvE2nwUzI0ECrNeyr98KWA==:17 a=BWvPGDcYAAAA:8 a=VxmjJ2MpAAAA:8 a=kj9zAlcOel0A:10 a=5lJygRwiOn0A:10 a=7Qk2ozbKAAAA:8 a=YxBL1-UpAAAA:8 a=6I5d2MoRAAAA:8 a=_9h_t3xh06Rghkjd1bkA:9 a=CjuIK1q_8ugA:10 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTP id AF862A06E; Sat, 17 Oct 2015 19:00:16 -0700 (PDT) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id t9I20G3g061874; Sat, 17 Oct 2015 19:00:16 -0700 (PDT) (envelope-from Cy.Schubert@komquats.com) Message-Id: <201510180200.t9I20G3g061874@slippy.cwsent.com> X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.6 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.komquats.com/ To: Warner Losh cc: David Malone , Ian Lepore , Cy Schubert , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r289421 - in head/etc: . mtree ntp In-Reply-To: Message from Warner Losh of "Sat, 17 Oct 2015 17:44:35 -0600." <00150EF2-0020-42E5-A1E5-324A23975577@bsdimp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 17 Oct 2015 19:00:16 -0700 X-CMAE-Envelope: MS4wfF1/ro5ZvBdOsWGHUyXv4Ooa3aip5ab3fnvcAlguPBvMWWrj4Q13pFsN01eA1KKZsJyTSh1/+6MmXNGe0HzX3rwuaOdTz2VsyfHR5Qt8enF6Y33hrP0cRqfMHYaQT+L2jpGS8dF9R1XkKUk6rIyqNf0E/u3kEQhEliwByROY2v4sxcYHDQ8bvtsz1cpFjDZYp98Bnc9toRyU0+S/FtKYBDcjPgyfbIHCbyJsepv2yBRbT8Tl8hPrySEO2pMT3ql/hV4lDfUJAQlGZhDRMhmma26hJt8qSWV1tV6AiFHNHUVCEZbQMy4ZRu7BiW9+lj7KI9b/iETQ2hl0EqshiPxYgJQBq/ce1GLSFNni01fPOLwe X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 02:00:25 -0000 In message <00150EF2-0020-42E5-A1E5-324A23975577@bsdimp.com>, Warner Losh writes: > > On Oct 17, 2015, at 3:20 PM, David Malone = > wrote: > >=20 > > On Sat, Oct 17, 2015 at 12:25:50PM -0600, Ian Lepore wrote: > >> If the leapseconds file is present, the leap bits for reference > >> clocks and downstratum servers are ignored. > >>=20 > >> I can't determine from casual code examination (and I don't have time > >> to experiment now) whether that is true even if the file is expired. > >=20 > > The way the code seems to work is: > >=20 > > 1) Take a vote from your peers on if there is an upcoming > > leap second. Refclocks can outvote other peers. (This is > > in ntp_proto.c:clock_update() - search for leap_vote_ins). > > Assuming no bugs, yes. And assuming your peers are sending > the correct information. History with ntpd and ntp serves well > illustrates that these assumptions are violated often. > > > 2) If one seems to be pending, try to insert it into an > > in-memory table for the end of the month. > > NTP only recognizes June and December as valid leap insertion > points. This is likely safe for the foreseeable future though, even > though the official standard allows leap seconds to be the end of > any month. Too many things assume you only have leap seconds > at these times for IERS to issue one that isn=E2=80=99t at the end of = > December > or June until earth rotation forces their hand sometime around the > end of this century (give or take a few decades). > > > 3) If you find that you loaded a table and the leapsecond > > you are trying to insert is within the valid range of the > > table, return an error. (This is in ntp_leapsec.c:leapsec_add()) > >=20 > > So, I think the change should be safe, if the comments match the code. > > That=E2=80=99s a big if. Both Ian and I have witnessed the carnage of = > incorrect > leap seconds first hand and so are somewhat touchy on the subject. It > is a place where getting the canonical information is 1000x better than > relying on code to implement things that can=E2=80=99t go wrong. Because = > they > often do. Way way too often. When you have leap second info, always > always always try extra hard to make sure it is as up to date as you > can get it. Any =E2=80=9Cshort cut=E2=80=9D here is asking for trouble, = > even if you think > you can prove that no such trouble is possible. Would an rc.conf option to use an alternate ntp.conf be of help? Having said that (and shooting down my own idea), it does seem a bit messy and rather inelegant though. -- Cheers, Cy Schubert or FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few. From owner-svn-src-head@freebsd.org Sun Oct 18 02:00:25 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B1AEAA109FE; Sun, 18 Oct 2015 02:00:25 +0000 (UTC) (envelope-from cy.schubert@komquats.com) Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.9]) by mx1.freebsd.org (Postfix) with ESMTP id 4C63D665; Sun, 18 Oct 2015 02:00:24 +0000 (UTC) (envelope-from cy.schubert@komquats.com) Received: from spqr.komquats.com ([96.50.22.10]) by shaw.ca with SMTP id ndGhZFeszT2vondGiZcPdQ; Sat, 17 Oct 2015 20:00:18 -0600 X-Authority-Analysis: v=2.1 cv=NrEbCZpJ c=1 sm=1 tr=0 a=jvE2nwUzI0ECrNeyr98KWA==:117 a=jvE2nwUzI0ECrNeyr98KWA==:17 a=BWvPGDcYAAAA:8 a=VxmjJ2MpAAAA:8 a=8nJEP1OIZ-IA:10 a=5lJygRwiOn0A:10 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=PYnjg3YJAAAA:8 a=qyDxTJV7AAAA:8 a=85N1-lAfAAAA:8 a=zNd2u4x_AAAA:8 a=5s6zO-qXuAxs_aenfAQA:9 a=VMSVR0KU_jCSt9j8:21 a=GIVkr1912MZHXu0C:21 a=hXHcXI2ZBuaQ5wAm:21 a=wPNLvfGTeEIA:10 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTP id 053C39FDD; Sat, 17 Oct 2015 19:00:14 -0700 (PDT) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id t9I20EOP061734; Sat, 17 Oct 2015 19:00:14 -0700 (PDT) (envelope-from Cy.Schubert@komquats.com) Message-Id: <201510180200.t9I20EOP061734@slippy.cwsent.com> X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.6 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.komquats.com/ To: Ian Lepore cc: Warner Losh , Cy Schubert , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r289421 - in head/etc: . mtree ntp In-Reply-To: Message from Ian Lepore of "Sat, 17 Oct 2015 13:25:56 -0600." <1445109956.71631.44.camel@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Date: Sat, 17 Oct 2015 19:00:14 -0700 X-CMAE-Envelope: MS4wfF1/ro5ZvBdOsWGHUyXv4Ooa3aip5ab3fnvcAlguPBvMWWrj4Q13pFsN01eA1KKZsJyTSh1/+6MmXNGe0HzX3rwuaOdTz2VsyfHR5Qt8enF6Y33hrP0cRqfMHYaQT+L2jqzsVFyFXDYv+zMMrAw3VeJQhvzTIpDlEsjqExfYygL+pWI37AekLYDNj1wV2YBuzmnodp83sscRndP+FOVIeMnTLngX5apCX4yOYiXotP5pVuh8CgWOHecBj3pxYangc7unDnGzGGKYZwKDyLpPeypi1k2LqBZtYsUfR2zNNXp4hGbSyi1HntKx1WsWFxLRxS0RZZSFlqTn+kFMNffCEi0= X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 02:00:25 -0000 In message <1445109956.71631.44.camel@freebsd.org>, Ian Lepore writes: > On Sat, 2015-10-17 at 13:19 -0600, Warner Losh wrote: > > Until the next leap second…. It would be better to just > > always try to grab the latest one… Can we put something > > in periodic to do that so users that have releases > > that are older than 6 months aren’t screwed? > > > > Warner > > > > I think writing a leapfeatcher task for periodic daily|weekly would > make a nice junior-hacker task. It would be nice if it only hit the > network when expiration of the installed file is imminent (like within > a month), and only if both ntp and the leapfile feature are enabled and > stuff like that. It should probably have a configurable list of URLs t > o fetch from. Enablement through and rc.conf option possibly? Not that this is an elegant solution though. -- Cheers, Cy Schubert or FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few. > > -- Ian > > > > On Oct 16, 2015, at 8:04 AM, Cy Schubert wrote: > > > > > > Author: cy > > > Date: Fri Oct 16 14:04:16 2015 > > > New Revision: 289421 > > > URL: https://svnweb.freebsd.org/changeset/base/289421 > > > > > > Log: > > > Add default leap-seconds file. This should help ntp networks get > > > the > > > leap second date correct > > > > > > Updates to the file can be obtained from ftp://time.nist.gov/pub/ > > > or > > > ftp://tycho.usno.navy.mil/pub/ntp/. > > > > > > Suggested by: dwmalone > > > Reviewed by: roberto, dwmalone, delphij > > > Approved by: roberto > > > MFC after: 1 week > > > > > > Added: > > > head/etc/ntp/ > > > head/etc/ntp/Makefile (contents, props changed) > > > head/etc/ntp/leap-seconds (contents, props changed) > > > Modified: > > > head/etc/Makefile > > > head/etc/mtree/BSD.var.dist > > > head/etc/ntp.conf > > > > > > Modified: head/etc/Makefile > > > =================================================================== > > > =========== > > > --- head/etc/Makefile Fri Oct 16 12:53:22 2015 (r2894 > > > 20) > > > +++ head/etc/Makefile Fri Oct 16 14:04:16 2015 (r2894 > > > 21) > > > @@ -240,6 +240,9 @@ distribution: > > > ${_+_}cd ${.CURDIR}/defaults; ${MAKE} install > > > ${_+_}cd ${.CURDIR}/devd; ${MAKE} install > > > ${_+_}cd ${.CURDIR}/gss; ${MAKE} install > > > +.if ${MK_NTP} != "no" > > > + ${_+_}cd ${.CURDIR}/ntp; ${MAKE} install > > > +.endif > > > ${_+_}cd ${.CURDIR}/periodic; ${MAKE} install > > > .if ${MK_PKGBOOTSTRAP} != "no" > > > ${_+_}cd ${.CURDIR}/pkg; ${MAKE} install > > > > > > Modified: head/etc/mtree/BSD.var.dist > > > =================================================================== > > > =========== > > > --- head/etc/mtree/BSD.var.dist Fri Oct 16 12:53:22 2015 > > > (r289420) > > > +++ head/etc/mtree/BSD.var.dist Fri Oct 16 14:04:16 2015 > > > (r289421) > > > @@ -46,6 +46,8 @@ > > > .. > > > ipf mode=0700 > > > .. > > > + ntp mode=0700 > > > + .. > > > pkg > > > .. > > > ports > > > > > > Modified: head/etc/ntp.conf > > > =================================================================== > > > =========== > > > --- head/etc/ntp.conf Fri Oct 16 12:53:22 2015 (r2894 > > > 20) > > > +++ head/etc/ntp.conf Fri Oct 16 14:04:16 2015 (r2894 > > > 21) > > > @@ -77,3 +77,8 @@ restrict 127.127.1.0 > > > # > > > #server 127.127.1.0 > > > #fudge 127.127.1.0 stratum 10 > > > + > > > +# See > > > http://support.ntp.org/bin/view/Support/ConfiguringNTP#Section_6.14 > > > . > > > +# for documentation regarding leapfile. Updates to the file can be > > > obtained > > > +# from ftp://time.nist.gov/pub/ or > > > ftp://tycho.usno.navy.mil/pub/ntp/. > > > +leapfile "/etc/ntp/leap-seconds" > > > > > > Added: head/etc/ntp/Makefile > > > =================================================================== > > > =========== > > > --- /dev/null 00:00:00 1970 (empty, because file is > > > newly added) > > > +++ head/etc/ntp/Makefile Fri Oct 16 14:04:16 2015 (r > > > 289421) > > > @@ -0,0 +1,10 @@ > > > +# $FreeBSD$ > > > + > > > +NO_OBJ= > > > + > > > +FILES= leap-seconds > > > + > > > +FILESDIR= /etc/ntp > > > +FILESMODE= 644 > > > + > > > +.include > > > > > > Added: head/etc/ntp/leap-seconds > > > =================================================================== > > > =========== > > > --- /dev/null 00:00:00 1970 (empty, because file is > > > newly added) > > > +++ head/etc/ntp/leap-seconds Fri Oct 16 14:04:16 2015 > > > (r289421) > > > @@ -0,0 +1,119 @@ > > > +# > > > +# $FreeBSD$ > > > +# > > > +# ATOMIC TIME. > > > +# The Coordinated Universal Time (UTC) is the reference > > > time scale derived > > > +# from The "Temps Atomique International" (TAI) calculated > > > by the Bureau > > > +# International des Poids et Mesures (BIPM) using a > > > worldwide network of atomic > > > +# clocks. UTC differs from TAI by an integer number of > > > seconds; it is the basis > > > +# of all activities in the world. > > > +# > > > +# > > > +# ASTRONOMICAL TIME (UT1) is the time scale based on the > > > rate of rotation of the earth. > > > +# It is now mainly derived from Very Long Baseline > > > Interferometry (VLBI). The various > > > +# irregular fluctuations progressively detected in the > > > rotation rate of the Earth lead > > > +# in 1972 to the replacement of UT1 by UTC as the reference > > > time scale. > > > +# > > > +# > > > +# LEAP SECOND > > > +# Atomic clocks are more stable than the rate of the earth > > > rotatiob since the later > > > +# undergoes a full range of geophysical perturbations at > > > various time scales (lunisolar > > > +# and core-mantle torques,atmospheric and oceanic effetcs, > > > ...) > > > +# Leap seconds are needed to keep the two time scales in > > > agreement, i.e. UT1-UTC smaller > > > +# than 0.9 second. So, when necessary a "leap second" is > > > introduced in UTC. > > > +# Since the adoption of this system in 1972 it has been > > > necessary to add 26 seconds to UTC, > > > +# firstly due to the initial choice of the value of the > > > second (1/86400 mean solar day of > > > +# the year 1820) and secondly to the general slowing down > > > of the Earth's rotation. It is > > > +# theorically possible to have a negative leap second (a > > > second removed from UTC), but so far, > > > +# all leap seconds have been positive (a second has been > > > added to UTC). Based on what we know about the earth's rotation, > > > +# it is unlikely that we will ever have a negative leap > > > second. > > > +# > > > +# > > > +# HISTORY > > > +# The first leap second was added on June 30, 1972. Until > > > 2000, it was necessary in average to add a leap second at a rate > > > +# of 1 to 2 years. Since 2000, due to the fact that the > > > earth rate of rotation is accelerating, leap seconds are introduced > > > +# with an average frequency of 3 to 4 years. > > > +# > > > +# > > > +# RESPONSABILITY OF THE DECISION TO INTRODUCE A LEAP SECOND > > > IN UTC > > > +# The decision to introduce a leap second in UTC is the > > > responsibility of the Earth Orientation Center of > > > +# the International Earth Rotation and reference System > > > Service (IERS). This center is located at Paris > > > +# Observatory. According to international agreements, leap > > > second date have to occur at fixed date : > > > +# first preference is given to the end of December and > > > June, and second preference at the end of March > > > +# and September. Since the system was introduced in 1972, > > > only dates in June and December were used. > > > +# > > > +# Questions or comments to: > > > +# Daniel Gambis, daniel.gambis@obspm.fr > > > +# Christian Bizouard: > > > christian.bizouard@obspm.fr > > > +# Earth orientation Center of the IERS > > > +# Paris Observatory, France > > > +# > > > +# > > > +# > > > +# VALIDITY OF THE FILE > > > +# It is important to express the validity of the file. > > > These next two dates are > > > +# given in units of seconds since 1900.0. > > > +# > > > +# 1) Last update of the file. > > > +# > > > +# Updated through IERS Bulletin C ( > > > ftp://hpiers.obspm.fr/iers/bul/bulc/bulletinc.dat) > > > +# > > > +# The following line shows the last update of this file in > > > NTP timestamp: > > > +# > > > +#$ 3645216000 > > > +# > > > +# 2) Expiration date of the file given on a semi-annual > > > basis: last June or last December > > > +# > > > +# File expires on 28 December 2015 > > > +# > > > +# Expire date in NTP timestamp: > > > +# > > > +#@ 3660249600 > > > +# > > > +# > > > +# LIST OF LEAP SECONDS > > > +# NTP timestamp (X parameter) is the number of seconds > > > since 1900.0 > > > +# > > > +# MJD: The Modified Julian Day number. MJD = X/86400 + > > > 15020 > > > +# > > > +# DTAI: The difference DTAI= TAI-UTC in units of seconds > > > +# It is the quantity to add to UTC to get the time in TAI > > > +# > > > +# Day Month Year : epoch in clear > > > +# > > > +#NTP Time DTAI Day Month Year > > > +# > > > +2272060800 10 # 1 Jan 1972 > > > +2287785600 11 # 1 Jul 1972 > > > +2303683200 12 # 1 Jan 1973 > > > +2335219200 13 # 1 Jan 1974 > > > +2366755200 14 # 1 Jan 1975 > > > +2398291200 15 # 1 Jan 1976 > > > +2429913600 16 # 1 Jan 1977 > > > +2461449600 17 # 1 Jan 1978 > > > +2492985600 18 # 1 Jan 1979 > > > +2524521600 19 # 1 Jan 1980 > > > +2571782400 20 # 1 Jul 1981 > > > +2603318400 21 # 1 Jul 1982 > > > +2634854400 22 # 1 Jul 1983 > > > +2698012800 23 # 1 Jul 1985 > > > +2776982400 24 # 1 Jan 1988 > > > +2840140800 25 # 1 Jan 1990 > > > +2871676800 26 # 1 Jan 1991 > > > +2918937600 27 # 1 Jul 1992 > > > +2950473600 28 # 1 Jul 1993 > > > +2982009600 29 # 1 Jul 1994 > > > +3029443200 30 # 1 Jan 1996 > > > +3076704000 31 # 1 Jul 1997 > > > +3124137600 32 # 1 Jan 1999 > > > +3345062400 33 # 1 Jan 2006 > > > +3439756800 34 # 1 Jan 2009 > > > +3550089600 35 # 1 Jul 2012 > > > +3644697600 36 # 1 Jul 2015 > > > +# > > > +# In order to verify the integrity of this file, a hash > > > code > > > +# has been generated. For more information how to use > > > +# this hash code, please consult the README file under the > > > +# 'sha' repertory. > > > +# > > > +#h 620ba8af 37900668 95ac09ba d77640f9 6fd75493 > > > > > > From owner-svn-src-head@freebsd.org Sun Oct 18 03:09:04 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 98ED5A108B1; Sun, 18 Oct 2015 03:09:04 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6385BBA6; Sun, 18 Oct 2015 03:09:04 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9I393LN091884; Sun, 18 Oct 2015 03:09:03 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9I393Bd091883; Sun, 18 Oct 2015 03:09:03 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201510180309.t9I393Bd091883@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sun, 18 Oct 2015 03:09:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289480 - head/sys/contrib/ipfilter/netinet X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 03:09:04 -0000 Author: cy Date: Sun Oct 18 03:09:03 2015 New Revision: 289480 URL: https://svnweb.freebsd.org/changeset/base/289480 Log: Really fix ipfilter bug 3600459. Obtained from: ipfilter cvs repo r1.48.2.25, r1.72 and NetBSD repo r1.4 MFC after: 3 days Modified: head/sys/contrib/ipfilter/netinet/ip_state.c Modified: head/sys/contrib/ipfilter/netinet/ip_state.c ============================================================================== --- head/sys/contrib/ipfilter/netinet/ip_state.c Sun Oct 18 01:30:23 2015 (r289479) +++ head/sys/contrib/ipfilter/netinet/ip_state.c Sun Oct 18 03:09:03 2015 (r289480) @@ -3650,7 +3650,6 @@ ipf_state_del(softc, is, why) if (is->is_ref > 0) { int refs; - is->is_ref--; refs = is->is_ref; MUTEX_EXIT(&is->is_lock); if (!orphan) @@ -3667,7 +3666,7 @@ ipf_state_del(softc, is, why) } } - is->is_ref = 0; + ASSERT(is->is_ref == 0); MUTEX_EXIT(&is->is_lock); if (is->is_tqehead[0] != NULL) { From owner-svn-src-head@freebsd.org Sun Oct 18 04:07:42 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3BBBBA0F6FA; Sun, 18 Oct 2015 04:07:42 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 08FE6B1F; Sun, 18 Oct 2015 04:07:41 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9I47fI6009247; Sun, 18 Oct 2015 04:07:41 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9I47f97009246; Sun, 18 Oct 2015 04:07:41 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201510180407.t9I47f97009246@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sun, 18 Oct 2015 04:07:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289481 - 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-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 04:07:42 -0000 Author: ngie Date: Sun Oct 18 04:07:40 2015 New Revision: 289481 URL: https://svnweb.freebsd.org/changeset/base/289481 Log: Only enable -fstack-protector-strong on gcc 4.9+ and default to -fstack-protector when -fstack-protector-strong is not available, like it was implicitly before r288669 As noted by antoine@, devel/gcc (which is 4.8.5) lacks -fstack-protector-strong support, whereas 4.8.4i (devel/gcc48) has the support. Until a version is available which has -fstack-protector-strong support, be conservative and only enable support with 4.9+. Reviewed by: pfg X-MFC with: r288669, r289465 Differential Revision: https://reviews.freebsd.org/D3924 Modified: head/share/mk/bsd.sys.mk Modified: head/share/mk/bsd.sys.mk ============================================================================== --- head/share/mk/bsd.sys.mk Sun Oct 18 03:09:03 2015 (r289480) +++ head/share/mk/bsd.sys.mk Sun Oct 18 04:07:40 2015 (r289481) @@ -150,11 +150,13 @@ CXXFLAGS.clang+= -Wno-c++11-extensions ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips" .if (${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30500) || \ (${COMPILER_TYPE} == "gcc" && \ - (${COMPILER_VERSION} == 40201 || ${COMPILER_VERSION} >= 40800)) + (${COMPILER_VERSION} == 40201 || ${COMPILER_VERSION} >= 40900)) # Don't use -Wstack-protector as it breaks world with -Werror. SSP_CFLAGS?= -fstack-protector-strong -CFLAGS+= ${SSP_CFLAGS} +.else +SSP_CFLAGS?= -fstack-protector .endif +CFLAGS+= ${SSP_CFLAGS} .endif # SSP && !ARM && !MIPS # Allow user-specified additional warning flags, plus compiler specific flag overrides. From owner-svn-src-head@freebsd.org Sun Oct 18 04:50:52 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 81458A0FFB2; Sun, 18 Oct 2015 04:50:52 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4722CCA9; Sun, 18 Oct 2015 04:50:52 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9I4opaa020812; Sun, 18 Oct 2015 04:50:51 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9I4opQ5020811; Sun, 18 Oct 2015 04:50:51 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201510180450.t9I4opQ5020811@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Sun, 18 Oct 2015 04:50:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289482 - head/sys/mips/conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 04:50:52 -0000 Author: sbruno Date: Sun Oct 18 04:50:51 2015 New Revision: 289482 URL: https://svnweb.freebsd.org/changeset/base/289482 Log: Correctly use the default values for location of MAC addrs of arge0, arge1, ath0. woo! Reviewed by: adrian Modified: head/sys/mips/conf/TP-MR3020.hints Modified: head/sys/mips/conf/TP-MR3020.hints ============================================================================== --- head/sys/mips/conf/TP-MR3020.hints Sun Oct 18 04:07:40 2015 (r289481) +++ head/sys/mips/conf/TP-MR3020.hints Sun Oct 18 04:50:51 2015 (r289482) @@ -26,18 +26,18 @@ hint.arswitch.0.is_gmii=1 # arge1 <-> sw # arge0 - MII, autoneg, phy(4) hint.arge.0.phymask=0x10 # PHY4 hint.arge.0.mdio=mdioproxy1 # .. off of the switch mdiobus +hint.arge.0.eeprommac=0x1fff0000 # arge1 - GMII, 1000/full hint.arge.1.phymask=0x0 # No directly mapped PHYs hint.arge.1.media=1000 hint.arge.1.fduplex=1 +hint.arge.1.eeprommac=0x1fff0006 # Where the ART is - last 64k in the flash # 0x9fff1000 ? -hint.ath.0.eepromaddr=0x1fff1000 +hint.ath.0.eepromaddr=0x1fff0000 hint.ath.0.eepromsize=16384 - -hint.ar71xx.0.eeprom_mac_addr=0x1f01fc00 # The board 4MiB flash layout in uboot env: # From owner-svn-src-head@freebsd.org Sun Oct 18 05:50:00 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 614D4A186B6; Sun, 18 Oct 2015 05:50:00 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 13506147F; Sun, 18 Oct 2015 05:50:00 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9I5nxXL038082; Sun, 18 Oct 2015 05:49:59 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9I5nw5r038077; Sun, 18 Oct 2015 05:49:58 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201510180549.t9I5nw5r038077@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sun, 18 Oct 2015 05:49:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289487 - in head: bin/dd bin/dd/tests contrib/netbsd-tests/bin/dd etc/mtree X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 05:50:00 -0000 Author: ngie Date: Sun Oct 18 05:49:58 2015 New Revision: 289487 URL: https://svnweb.freebsd.org/changeset/base/289487 Log: Integrate contrib/netbsd-tests/bin/dd into the FreeBSD test suite as bin/dd/tests Ensure fdescfs is mounted on /dev/fd/ for the length testcase as it's used in validating the characters read from /dev/zero MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Division Added: head/bin/dd/tests/ - copied from r289485, user/ngie/more-tests2/bin/dd/tests/ Modified: head/bin/dd/Makefile head/bin/dd/tests/Makefile head/contrib/netbsd-tests/bin/dd/t_dd.sh head/etc/mtree/BSD.tests.dist Directory Properties: head/ (props changed) Modified: head/bin/dd/Makefile ============================================================================== --- head/bin/dd/Makefile Sun Oct 18 05:36:05 2015 (r289486) +++ head/bin/dd/Makefile Sun Oct 18 05:49:58 2015 (r289487) @@ -1,6 +1,8 @@ # @(#)Makefile 8.1 (Berkeley) 5/31/93 # $FreeBSD$ +.include + PROG= dd SRCS= args.c conv.c conv_tab.c dd.c misc.c position.c @@ -24,4 +26,8 @@ test: ${PROG} gen .endfor @rm -f gen +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif + .include Modified: head/bin/dd/tests/Makefile ============================================================================== --- user/ngie/more-tests2/bin/dd/tests/Makefile Sun Oct 18 05:29:49 2015 (r289485) +++ head/bin/dd/tests/Makefile Sun Oct 18 05:49:58 2015 (r289487) @@ -1,6 +1,6 @@ # $FreeBSD$ -NETBSD_ATF_TESTS_SH= dd +NETBSD_ATF_TESTS_SH= dd_test .include Modified: head/contrib/netbsd-tests/bin/dd/t_dd.sh ============================================================================== --- head/contrib/netbsd-tests/bin/dd/t_dd.sh Sun Oct 18 05:36:05 2015 (r289486) +++ head/contrib/netbsd-tests/bin/dd/t_dd.sh Sun Oct 18 05:49:58 2015 (r289487) @@ -44,6 +44,12 @@ length_head() { "the one expected to fail. (NetBSD PR bin/8521)" } length_body() { + # Begin FreeBSD + if ! df /dev/fd | grep -q '^fdescfs'; then + atf_skip "fdescfs is not mounted on /dev/fd" + fi + # End FreeBSD + test_dd_length 512 \ "dd if=/dev/zero of=/dev/fd/5 count=1 5>&1 >/dev/null 2>/dev/null" test_dd_length 512 \ Modified: head/etc/mtree/BSD.tests.dist ============================================================================== --- head/etc/mtree/BSD.tests.dist Sun Oct 18 05:36:05 2015 (r289486) +++ head/etc/mtree/BSD.tests.dist Sun Oct 18 05:49:58 2015 (r289487) @@ -12,6 +12,8 @@ .. date .. + dd + .. expr .. ls From owner-svn-src-head@freebsd.org Sun Oct 18 05:51:46 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3DC7BA187B1; Sun, 18 Oct 2015 05:51:46 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 05B9918B5; Sun, 18 Oct 2015 05:51:45 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9I5pj56038797; Sun, 18 Oct 2015 05:51:45 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9I5pj8j038796; Sun, 18 Oct 2015 05:51:45 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201510180551.t9I5pj8j038796@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sun, 18 Oct 2015 05:51:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289488 - head/bin/test/tests X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 05:51:46 -0000 Author: ngie Date: Sun Oct 18 05:51:44 2015 New Revision: 289488 URL: https://svnweb.freebsd.org/changeset/base/289488 Log: Clean up trailing whitespace MFC after: 3 days Modified: head/bin/test/tests/legacy_test.sh Modified: head/bin/test/tests/legacy_test.sh ============================================================================== --- head/bin/test/tests/legacy_test.sh Sun Oct 18 05:49:58 2015 (r289487) +++ head/bin/test/tests/legacy_test.sh Sun Oct 18 05:51:44 2015 (r289488) @@ -2,7 +2,7 @@ #- # Copyright (c) June 1996 Wolfram Schneider . Berlin. -# All rights reserved. +# All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -31,7 +31,7 @@ # $FreeBSD$ # force a specified test program, e.g. `env test=/bin/test sh regress.sh' -: ${test=test} +: ${test=test} t () { @@ -54,13 +54,13 @@ t () count=0 echo "1..130" -t 0 'b = b' -t 0 'b == b' -t 1 'b != b' -t 0 '\( b = b \)' -t 0 '\( b == b \)' -t 1 '! \( b = b \)' -t 1 '! \( b == b \)' +t 0 'b = b' +t 0 'b == b' +t 1 'b != b' +t 0 '\( b = b \)' +t 0 '\( b == b \)' +t 1 '! \( b = b \)' +t 1 '! \( b == b \)' t 1 '! -f /etc/passwd' t 0 '-h = -h' From owner-svn-src-head@freebsd.org Sun Oct 18 07:19:51 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1AF46A18214; Sun, 18 Oct 2015 07:19:51 +0000 (UTC) (envelope-from dwmalone@maths.tcd.ie) Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [IPv6:2001:770:10:300::86e2:510b]) by mx1.freebsd.org (Postfix) with ESMTP id 0D8D16E9; Sun, 18 Oct 2015 07:19:49 +0000 (UTC) (envelope-from dwmalone@maths.tcd.ie) Received: from salmon.maths.tcd.ie (localhost [127.0.0.1]) by salmon.maths.tcd.ie (Postfix) with ESMTP id EEE931591E5; Sun, 18 Oct 2015 08:19:40 +0100 (IST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=maths.tcd.ie; h= user-agent:in-reply-to:content-disposition:content-type :content-type:mime-version:references:message-id:subject:subject :from:from:date:date:received:received:received; s=20150418; t= 1445152775; x=1446967176; bh=YZf6/QWxAnMmf3JWNQn3XJAjvMc5sbwCask ljYm5Vd8=; b=u+sYxrY4SQ+2ZQ4GYp6mf/SUqhGy/j5H6FEtg5HVkld9ZFyDqbh fhN6Z8CZn6uQqR+BoV7J6df5aF7w/XrJ6QfAHQJeWRyZ/YEjVC8/EJxA8yKS0ho9 Zf4fxQFihgTAMegKLFORyHuxpPSuEMCBjstrRkkLwirM848/ffSlEUFg= X-Virus-Scanned: amavisd-new at maths.tcd.ie Received: from salmon.maths.tcd.ie ([127.0.0.1]) by salmon.maths.tcd.ie (salmon.maths.tcd.ie [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YQAvwxGhuuc1; Sun, 18 Oct 2015 08:19:35 +0100 (IST) Received: from walton.maths.tcd.ie (walton.maths.tcd.ie [IPv6:2001:770:10:300::86e2:510a]) by salmon.maths.tcd.ie (Postfix) with ESMTP id 01F151591E1; Sun, 18 Oct 2015 08:19:35 +0100 (IST) Received: by walton.maths.tcd.ie (Postfix, from userid 238) id AF6CC730AA; Sun, 18 Oct 2015 08:19:34 +0100 (IST) Date: Sun, 18 Oct 2015 08:19:34 +0100 From: David Malone To: Warner Losh Cc: Ian Lepore , Cy Schubert , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r289421 - in head/etc: . mtree ntp Message-ID: <20151018071934.GA95077@walton.maths.tcd.ie> References: <201510161404.t9GE4GqM046436@repo.freebsd.org> <1445106350.71631.36.camel@freebsd.org> <20151017212033.GA43955@walton.maths.tcd.ie> <00150EF2-0020-42E5-A1E5-324A23975577@bsdimp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <00150EF2-0020-42E5-A1E5-324A23975577@bsdimp.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 07:19:51 -0000 Hi Warner, I was trying to check Ian's specific concern, that a valid source of leap seconds might be ignored if a expired leapseconds file was present. It seems that this is not the case, at lease based on my reading of the code and comments. I included the references to the code, so others could check if they wanted. I actually suggested configuring the leapseconds file by default to try and improve the vagueries of accepting advertised leap seconds that you mentioned. > NTP only recognizes June and December as valid leap insertion > points. Interestingly, this code seems to be gone from ntp_loopfilter.c and based on a quick look through the rest of the code, I can't see a similar general check. Some of the refclocks do retain this condition, but the general code path doesn't seem to. Possibly we should take this up with the NTP guys as a check worth retaining? David. From owner-svn-src-head@freebsd.org Sun Oct 18 07:26:12 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E44DEA183BC; Sun, 18 Oct 2015 07:26:12 +0000 (UTC) (envelope-from dwmalone@maths.tcd.ie) Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [IPv6:2001:770:10:300::86e2:510b]) by mx1.freebsd.org (Postfix) with ESMTP id 94C97C0D; Sun, 18 Oct 2015 07:26:12 +0000 (UTC) (envelope-from dwmalone@maths.tcd.ie) Received: from salmon.maths.tcd.ie (localhost [127.0.0.1]) by salmon.maths.tcd.ie (Postfix) with ESMTP id 9B7B31591E5; Sun, 18 Oct 2015 08:26:11 +0100 (IST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=maths.tcd.ie; h= user-agent:in-reply-to:content-transfer-encoding :content-disposition:content-type:content-type:mime-version :references:message-id:subject:subject:from:from:date:date :received:received:received; s=20150418; t=1445153165; x= 1446967566; bh=Vu1Qlda7JxP1m4kNqFd8QjFjJtN89hERSLZSgqriy4A=; b=u uZIk9PDnTvJIs5S+ZgOJ3TBCClwScotUEN8ZxbTZP5dxNCnh8x5dYfVARvKmSlh0 tYxe0nglDXe4tJFcyPOLBb4M8zIP3i+L2GucePkL1dtvKZXlkq4QaHZwG+i8IQMZ Ixzer+QZvXJW3DNA0Cwgn4Hr2FkGCSOCs/kPGfvOn8= X-Virus-Scanned: amavisd-new at maths.tcd.ie Received: from salmon.maths.tcd.ie ([127.0.0.1]) by salmon.maths.tcd.ie (salmon.maths.tcd.ie [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GoD9cSFJ1aF6; Sun, 18 Oct 2015 08:26:05 +0100 (IST) Received: from walton.maths.tcd.ie (walton.maths.tcd.ie [134.226.81.10]) by salmon.maths.tcd.ie (Postfix) with ESMTP id 95E801591E1; Sun, 18 Oct 2015 08:26:05 +0100 (IST) Received: by walton.maths.tcd.ie (Postfix, from userid 238) id 18B20730AA; Sun, 18 Oct 2015 08:26:04 +0100 (IST) Date: Sun, 18 Oct 2015 08:26:04 +0100 From: David Malone To: Warner Losh Cc: Ian Lepore , Cy Schubert , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r289421 - in head/etc: . mtree ntp Message-ID: <20151018072604.GB95077@walton.maths.tcd.ie> References: <201510161404.t9GE4GqM046436@repo.freebsd.org> <8154492E-C29E-41B1-A13B-34E33586DEC6@bsdimp.com> <1445109956.71631.44.camel@freebsd.org> <95712496-46C7-4F1F-B267-F25E4924E3B4@bsdimp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <95712496-46C7-4F1F-B267-F25E4924E3B4@bsdimp.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 07:26:13 -0000 On Sat, Oct 17, 2015 at 05:48:19PM -0600, Warner Losh wrote: > It should be very easy to try to fetch it once a day in June and December > until you succeed from each of the URLs in a list, with the default > list being the two canonical (for the US at least) sources. Shouldn’t > be more than a dozen lines in a periodic script. We probably also want to avoid trying to fetch an update at the same moment from a bunch of time synchronised machines. A random sleep might be enough, but we should be careful about setting automatic updates that fetch things from infrastructure other than our own. David. From owner-svn-src-head@freebsd.org Sun Oct 18 07:30:52 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 16C43A18497; Sun, 18 Oct 2015 07:30:52 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E4EACE0A; Sun, 18 Oct 2015 07:30:51 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9I7UpmU067070; Sun, 18 Oct 2015 07:30:51 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9I7Uoro067061; Sun, 18 Oct 2015 07:30:50 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201510180730.t9I7Uoro067061@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sun, 18 Oct 2015 07:30:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289490 - in head: bin/ps lib/libxo lib/libxo/tests lib/libxo/tests/encoder sbin/savecore share/mk usr.bin/iscsictl usr.bin/wc usr.bin/xo X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 07:30:52 -0000 Author: ngie Date: Sun Oct 18 07:30:50 2015 New Revision: 289490 URL: https://svnweb.freebsd.org/changeset/base/289490 Log: Make libxo depend on libutil because it uses humanize_number after r287111 Remove overlinking in lib/libxo/tests, sbin/savecore, and usr.bin/{iscsictl,wc,xo} PR: 203673 Sponsored by: EMC / Isilon Storage Division Modified: head/bin/ps/Makefile head/lib/libxo/Makefile head/lib/libxo/tests/Makefile head/lib/libxo/tests/encoder/Makefile head/sbin/savecore/Makefile head/share/mk/src.libnames.mk head/usr.bin/iscsictl/Makefile head/usr.bin/wc/Makefile head/usr.bin/xo/Makefile Directory Properties: head/ (props changed) head/sbin/ (props changed) head/share/ (props changed) Modified: head/bin/ps/Makefile ============================================================================== --- head/bin/ps/Makefile Sun Oct 18 06:53:31 2015 (r289489) +++ head/bin/ps/Makefile Sun Oct 18 07:30:50 2015 (r289490) @@ -11,6 +11,6 @@ SRCS= fmt.c keyword.c nlist.c print.c ps # on large systems. # CFLAGS+=-DLAZY_PS -LIBADD= m kvm jail xo util +LIBADD= m kvm jail xo .include Modified: head/lib/libxo/Makefile ============================================================================== --- head/lib/libxo/Makefile Sun Oct 18 06:53:31 2015 (r289489) +++ head/lib/libxo/Makefile Sun Oct 18 07:30:50 2015 (r289490) @@ -19,6 +19,8 @@ CFLAGS+=-DXO_ENCODERDIR=\"/usr/lib/libxo INCS= xo.h xo_encoder.h INCSDIR=${INCLUDEDIR}/libxo +LIBADD= util + WARNS?= 5 MAN+= libxo.3 Modified: head/lib/libxo/tests/Makefile ============================================================================== --- head/lib/libxo/tests/Makefile Sun Oct 18 06:53:31 2015 (r289489) +++ head/lib/libxo/tests/Makefile Sun Oct 18 07:30:50 2015 (r289490) @@ -242,8 +242,7 @@ PROGS+= test_11 CFLAGS+= -I${LIBXOSRC}/libxo -DPADD= ${LIBXO} ${LIBUTIL} -LDADD= -lxo -lutil +LIBADD= xo SUBDIR+= encoder Modified: head/lib/libxo/tests/encoder/Makefile ============================================================================== --- head/lib/libxo/tests/encoder/Makefile Sun Oct 18 06:53:31 2015 (r289489) +++ head/lib/libxo/tests/encoder/Makefile Sun Oct 18 07:30:50 2015 (r289490) @@ -14,7 +14,6 @@ SRCS= enc_test.c CFLAGS+= -I${LIBXOSRC}/libxo -DPADD+= ${LIBXO} -LDADD+= -lxo +LIBADD= xo .include Modified: head/sbin/savecore/Makefile ============================================================================== --- head/sbin/savecore/Makefile Sun Oct 18 06:53:31 2015 (r289489) +++ head/sbin/savecore/Makefile Sun Oct 18 07:30:50 2015 (r289490) @@ -1,7 +1,7 @@ # $FreeBSD$ PROG= savecore -LIBADD= z xo util +LIBADD= z xo MAN= savecore.8 .include Modified: head/share/mk/src.libnames.mk ============================================================================== --- head/share/mk/src.libnames.mk Sun Oct 18 06:53:31 2015 (r289489) +++ head/share/mk/src.libnames.mk Sun Oct 18 07:30:50 2015 (r289490) @@ -239,6 +239,7 @@ _DP_vmmapi= util _DP_ctf= z _DP_proc= rtld_db util _DP_dtrace= rtld_db pthread +_DP_xo= util # Define spacial cases LDADD_supcplusplus= -lsupc++ Modified: head/usr.bin/iscsictl/Makefile ============================================================================== --- head/usr.bin/iscsictl/Makefile Sun Oct 18 06:53:31 2015 (r289489) +++ head/usr.bin/iscsictl/Makefile Sun Oct 18 07:30:50 2015 (r289490) @@ -6,7 +6,7 @@ CFLAGS+= -I${.CURDIR} CFLAGS+= -I${.CURDIR}/../../sys/dev/iscsi MAN= iscsi.conf.5 iscsictl.8 -LIBADD= xo util +LIBADD= xo YFLAGS+= -v LFLAGS+= -i Modified: head/usr.bin/wc/Makefile ============================================================================== --- head/usr.bin/wc/Makefile Sun Oct 18 06:53:31 2015 (r289489) +++ head/usr.bin/wc/Makefile Sun Oct 18 07:30:50 2015 (r289490) @@ -2,6 +2,6 @@ # $FreeBSD$ PROG= wc -LIBADD= xo util +LIBADD= xo .include Modified: head/usr.bin/xo/Makefile ============================================================================== --- head/usr.bin/xo/Makefile Sun Oct 18 06:53:31 2015 (r289489) +++ head/usr.bin/xo/Makefile Sun Oct 18 07:30:50 2015 (r289490) @@ -12,7 +12,7 @@ MAN= xo.1 # XXX For xoversion.h CFLAGS+=-I${LIBXOSRC}/libxo -LIBADD= xo util +LIBADD= xo .if ${MK_TESTS} != "no" SUBDIR+= tests From owner-svn-src-head@freebsd.org Sun Oct 18 08:08:38 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8ED02A18C3B; Sun, 18 Oct 2015 08:08:38 +0000 (UTC) (envelope-from jmg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 52E66E92; Sun, 18 Oct 2015 08:08:38 +0000 (UTC) (envelope-from jmg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9I88bHL078514; Sun, 18 Oct 2015 08:08:37 GMT (envelope-from jmg@FreeBSD.org) Received: (from jmg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9I88b2B078513; Sun, 18 Oct 2015 08:08:37 GMT (envelope-from jmg@FreeBSD.org) Message-Id: <201510180808.t9I88b2B078513@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jmg set sender to jmg@FreeBSD.org using -f From: John-Mark Gurney Date: Sun, 18 Oct 2015 08:08:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289492 - head/sys/sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 08:08:38 -0000 Author: jmg Date: Sun Oct 18 08:08:37 2015 New Revision: 289492 URL: https://svnweb.freebsd.org/changeset/base/289492 Log: page sized is not spelled 4096 on all arches... Modified: head/sys/sys/mbuf.h Modified: head/sys/sys/mbuf.h ============================================================================== --- head/sys/sys/mbuf.h Sun Oct 18 07:33:44 2015 (r289491) +++ head/sys/sys/mbuf.h Sun Oct 18 08:08:37 2015 (r289492) @@ -344,7 +344,7 @@ struct mbuf { */ #define EXT_CLUSTER 1 /* mbuf cluster */ #define EXT_SFBUF 2 /* sendfile(2)'s sf_bufs */ -#define EXT_JUMBOP 3 /* jumbo cluster 4096 bytes */ +#define EXT_JUMBOP 3 /* jumbo cluster page sized */ #define EXT_JUMBO9 4 /* jumbo cluster 9216 bytes */ #define EXT_JUMBO16 5 /* jumbo cluster 16184 bytes */ #define EXT_PACKET 6 /* mbuf+cluster from packet zone */ From owner-svn-src-head@freebsd.org Sun Oct 18 08:13:52 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DBAFDA18D58; Sun, 18 Oct 2015 08:13:52 +0000 (UTC) (envelope-from jmg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 96D2636F; Sun, 18 Oct 2015 08:13:52 +0000 (UTC) (envelope-from jmg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9I8DpcP080509; Sun, 18 Oct 2015 08:13:51 GMT (envelope-from jmg@FreeBSD.org) Received: (from jmg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9I8DpuX080506; Sun, 18 Oct 2015 08:13:51 GMT (envelope-from jmg@FreeBSD.org) Message-Id: <201510180813.t9I8DpuX080506@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jmg set sender to jmg@FreeBSD.org using -f From: John-Mark Gurney Date: Sun, 18 Oct 2015 08:13:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289494 - head/sys/dev/pci X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 08:13:53 -0000 Author: jmg Date: Sun Oct 18 08:13:51 2015 New Revision: 289494 URL: https://svnweb.freebsd.org/changeset/base/289494 Log: drop a bunch of white space at end of lines and end of files... -x -wb apparently doesn't hide end of file white space changes.. This is to reduce the amount of diff for my PCIe HP changes.. Modified: head/sys/dev/pci/pci.c head/sys/dev/pci/pci_pci.c head/sys/dev/pci/pcib_if.m Modified: head/sys/dev/pci/pci.c ============================================================================== --- head/sys/dev/pci/pci.c Sun Oct 18 08:12:05 2015 (r289493) +++ head/sys/dev/pci/pci.c Sun Oct 18 08:13:51 2015 (r289494) @@ -535,7 +535,7 @@ pci_romsize(uint64_t testval) } return (ln2size); } - + /* return log2 of address range supported by map register */ static int @@ -1706,7 +1706,7 @@ pci_remap_msix_method(device_t dev, devi free(used, M_DEVBUF); return (EINVAL); } - + /* Make sure none of the resources are allocated. */ for (i = 0; i < msix->msix_table_len; i++) { if (msix->msix_table[i].mte_vector == 0) @@ -2003,7 +2003,7 @@ pci_remap_intr_method(device_t bus, devi struct msix_table_entry *mte; struct msix_vector *mv; uint64_t addr; - uint32_t data; + uint32_t data; int error, i, j; /* @@ -4830,7 +4830,7 @@ pci_deactivate_resource(device_t dev, de if (error) return (error); - /* Disable decoding for device ROMs. */ + /* Disable decoding for device ROMs. */ if (device_get_parent(child) == dev) { dinfo = device_get_ivars(child); if (type == SYS_RES_MEMORY && PCIR_IS_BIOS(&dinfo->cfg, rid)) Modified: head/sys/dev/pci/pci_pci.c ============================================================================== --- head/sys/dev/pci/pci_pci.c Sun Oct 18 08:12:05 2015 (r289493) +++ head/sys/dev/pci/pci_pci.c Sun Oct 18 08:13:51 2015 (r289494) @@ -57,7 +57,7 @@ static int pcib_resume(device_t dev); static int pcib_power_for_sleep(device_t pcib, device_t dev, int *pstate); static uint16_t pcib_ari_get_rid(device_t pcib, device_t dev); -static uint32_t pcib_read_config(device_t dev, u_int b, u_int s, +static uint32_t pcib_read_config(device_t dev, u_int b, u_int s, u_int f, u_int reg, int width); static void pcib_write_config(device_t dev, u_int b, u_int s, u_int f, u_int reg, uint32_t val, int width); @@ -266,7 +266,7 @@ pcib_add_window_resources(struct pcib_wi free(w->res, M_DEVBUF); w->res = newarray; w->count += count; - + for (i = 0; i < count; i++) { error = rman_manage_region(&w->rman, rman_get_start(res[i]), rman_get_end(res[i])); @@ -783,7 +783,7 @@ pcib_get_mem_decode(struct pcib_softc *s sc->pmembase = PCI_PPBMEMBASE(0, pmemlow); pmemlow = pci_read_config(dev, PCIR_PMLIMITL_1, 2); - if ((pmemlow & PCIM_BRPM_MASK) == PCIM_BRPM_64) + if ((pmemlow & PCIM_BRPM_MASK) == PCIM_BRPM_64) sc->pmemlimit = PCI_PPBMEMLIMIT( pci_read_config(dev, PCIR_PMLIMITH_1, 4), pmemlow); else @@ -1126,7 +1126,7 @@ int pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) { struct pcib_softc *sc = device_get_softc(dev); - + switch (which) { case PCIB_IVAR_DOMAIN: *result = sc->domain; @@ -1243,9 +1243,9 @@ pcib_alloc_new_window(struct pcib_softc return (0); } } - return (ENOSPC); + return (ENOSPC); } - + wmask = (1ul << w->step) - 1; if (RF_ALIGNMENT(flags) < w->step) { flags &= ~RF_ALIGNMENT_MASK; @@ -1337,7 +1337,7 @@ pcib_expand_window(struct pcib_softc *sc KASSERT(w->base == rman_get_start(res), ("existing resource mismatch")); force_64k_base = 0; - } + } error = bus_adjust_resource(sc->dev, type, res, force_64k_base ? rman_get_start(res) : base, limit); @@ -1657,7 +1657,7 @@ pcib_release_resource(device_t dev, devi * is set up to, or capable of handling them. */ struct resource * -pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, +pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags) { struct pcib_softc *sc = device_get_softc(dev); @@ -1928,7 +1928,7 @@ pcib_route_interrupt(device_t pcib, devi int parent_intpin; int intnum; - /* + /* * * The PCI standard defines a swizzle of the child-side device/intpin to * the parent-side intpin as follows. @@ -2116,4 +2116,3 @@ pcib_try_enable_ari(device_t pcib, devic return (0); } - Modified: head/sys/dev/pci/pcib_if.m ============================================================================== --- head/sys/dev/pci/pcib_if.m Sun Oct 18 08:12:05 2015 (r289493) +++ head/sys/dev/pci/pcib_if.m Sun Oct 18 08:13:51 2015 (r289494) @@ -97,7 +97,7 @@ METHOD void write_config { }; # -# Route an interrupt. Returns a value suitable for stuffing into +# Route an interrupt. Returns a value suitable for stuffing into # a device's interrupt register. # METHOD int route_interrupt { @@ -206,4 +206,3 @@ METHOD void decode_rid { int *slot; int *func; } DEFAULT pcib_decode_rid; - From owner-svn-src-head@freebsd.org Sun Oct 18 09:33:30 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1765FA16001; Sun, 18 Oct 2015 09:33:30 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B9ACA1C04; Sun, 18 Oct 2015 09:33:29 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9I9XS8Z004708; Sun, 18 Oct 2015 09:33:28 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9I9XSCX004707; Sun, 18 Oct 2015 09:33:28 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201510180933.t9I9XSCX004707@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 18 Oct 2015 09:33:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289496 - 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-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 09:33:30 -0000 Author: kib Date: Sun Oct 18 09:33:28 2015 New Revision: 289496 URL: https://svnweb.freebsd.org/changeset/base/289496 Log: Only marker is guaranteed to be present on the queue after the relock in vm_pageout_fallback_object_lock() and vm_pageout_page_lock(). The check for the m->queue == queue assumes that the page does belong to a queue. Modify the 'unchanged' calculation bu dereferencing the marker tailq pointers, which is known to belong to the queue. Since for a page m linked to the queue, m->queue must be equal to the queue index, assert this instead of checking. In collaboration with: alc Sponsored by: The FreeBSD Foundation (kib) MFC after: 2 weeks Modified: head/sys/vm/vm_pageout.c Modified: head/sys/vm/vm_pageout.c ============================================================================== --- head/sys/vm/vm_pageout.c Sun Oct 18 09:02:17 2015 (r289495) +++ head/sys/vm/vm_pageout.c Sun Oct 18 09:33:28 2015 (r289496) @@ -292,11 +292,21 @@ vm_pageout_fallback_object_lock(vm_page_ vm_page_lock(m); vm_pagequeue_lock(pq); - /* Page queue might have changed. */ + /* + * The page's object might have changed, and/or the page might + * have moved from its original position in the queue. If the + * page's object has changed, then the caller should abandon + * processing the page because the wrong object lock was + * acquired. Use the marker's plinks.q, not the page's, to + * determine if the page has been moved. The state of the + * page's plinks.q can be indeterminate; whereas, the marker's + * plinks.q must be valid. + */ *next = TAILQ_NEXT(&marker, plinks.q); - unchanged = (m->queue == queue && - m->object == object && - &marker == TAILQ_NEXT(m, plinks.q)); + unchanged = m->object == object && + m == TAILQ_PREV(&marker, pglist, plinks.q); + KASSERT(!unchanged || m->queue == queue, + ("page %p queue %d %d", m, queue, m->queue)); TAILQ_REMOVE(&pq->pq_pl, &marker, plinks.q); return (unchanged); } @@ -333,7 +343,9 @@ vm_pageout_page_lock(vm_page_t m, vm_pag /* Page queue might have changed. */ *next = TAILQ_NEXT(&marker, plinks.q); - unchanged = (m->queue == queue && &marker == TAILQ_NEXT(m, plinks.q)); + unchanged = m == TAILQ_PREV(&marker, pglist, plinks.q); + KASSERT(!unchanged || m->queue == queue, + ("page %p queue %d %d", m, queue, m->queue)); TAILQ_REMOVE(&pq->pq_pl, &marker, plinks.q); return (unchanged); } From owner-svn-src-head@freebsd.org Sun Oct 18 09:46:08 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E28D7A16330; Sun, 18 Oct 2015 09:46:08 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5CABDD2; Sun, 18 Oct 2015 09:46:08 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id t9I9k2rk089809 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sun, 18 Oct 2015 12:46:02 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua t9I9k2rk089809 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id t9I9k2Yp089802; Sun, 18 Oct 2015 12:46:02 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 18 Oct 2015 12:46:02 +0300 From: Konstantin Belousov To: Ian Lepore Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r289477 - head/sys/arm/mv Message-ID: <20151018094602.GF2257@kib.kiev.ua> References: <201510180103.t9I13h0w056671@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201510180103.t9I13h0w056671@repo.freebsd.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 09:46:09 -0000 On Sun, Oct 18, 2015 at 01:03:43AM +0000, Ian Lepore wrote: > Author: ian > Date: Sun Oct 18 01:03:43 2015 > New Revision: 289477 > URL: https://svnweb.freebsd.org/changeset/base/289477 > > Log: > Fix a strange macro re-definition compile error. If the VM_MAXUSER_ADDRESS > value is defined as a config option the definition is emitted into > opt_global.h which is force-included into everything. In addition, the > symbol is emitted by the genassym mechanism, but that by its nature reduces > the value to a 0xnnnnnnnn number. When compiling a .S file you end up > with two different definitions of the macro (they evaluate to the same > number, but the text is different, upsetting the compiler). > > Nothing has changed about this code for a while but the compile error is > new, so this must be fallout from the clang 3.7 update or something. > > Modified: > head/sys/arm/mv/std-pj4b.mv > > Modified: head/sys/arm/mv/std-pj4b.mv > ============================================================================== > --- head/sys/arm/mv/std-pj4b.mv Sun Oct 18 00:59:28 2015 (r289476) > +++ head/sys/arm/mv/std-pj4b.mv Sun Oct 18 01:03:43 2015 (r289477) > @@ -5,4 +5,8 @@ cpu CPU_MV_PJ4B > machine arm armv6 > makeoptions CONF_CFLAGS="-march=armv7a" > > -options VM_MAXUSER_ADDRESS="(KERNBASE-(1024*1024*1024))" > +# This was originally defined as "(KERNBASE-(1024*1024*1024))" but that > +# (in opt_global.h) clashed with the value emitted by genassym which > +# reduces the original macro text to its numeric value. The only way > +# to avoid that is to define it here as the numeric value genassym emits. > +options VM_MAXUSER_ADDRESS="0x80000000" Genassym started to generate VM_MAXUSER_ADDRESS after r289372. Strange that I did not saw the error. Why does marvell need this override ? From owner-svn-src-head@freebsd.org Sun Oct 18 11:21:10 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 26B1CA18AE6; Sun, 18 Oct 2015 11:21:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E2210BC6; Sun, 18 Oct 2015 11:21:09 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IBL9oF035431; Sun, 18 Oct 2015 11:21:09 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IBL8Gi035425; Sun, 18 Oct 2015 11:21:08 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201510181121.t9IBL8Gi035425@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 18 Oct 2015 11:21:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289497 - in head/cddl/contrib/opensolaris: cmd/zfs lib/libzfs/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 11:21:10 -0000 Author: mav Date: Sun Oct 18 11:21:08 2015 New Revision: 289497 URL: https://svnweb.freebsd.org/changeset/base/289497 Log: MFV r289493: 5745 zfs set allows only one dataset property to be set at a time Reviewed by: Christopher Siden Reviewed by: George Wilson Reviewed by: Matthew Ahrens Reviewed by: Bayard Bell Reviewed by: Richard PALO Reviewed by: Steven Hartland Approved by: Rich Lowe Author: Chris Williamson illumos/illumos-gate@30925561c223021e91d15899cbe75f80e54d8889 Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs.8 head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Directory Properties: head/cddl/contrib/opensolaris/ (props changed) head/cddl/contrib/opensolaris/cmd/zfs/ (props changed) head/cddl/contrib/opensolaris/lib/libzfs/ (props changed) Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs.8 ============================================================================== --- head/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Sun Oct 18 09:33:28 2015 (r289496) +++ head/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Sun Oct 18 11:21:08 2015 (r289497) @@ -18,7 +18,7 @@ .\" information: Portions Copyright [yyyy] [name of copyright owner] .\" .\" Copyright (c) 2010, Sun Microsystems, Inc. All Rights Reserved. -.\" Copyright (c) 2014 by Delphix. All rights reserved. +.\" Copyright (c) 2011, 2014 by Delphix. All rights reserved. .\" Copyright (c) 2011, Pawel Jakub Dawidek .\" Copyright (c) 2012, Glen Barber .\" Copyright (c) 2012, Bryan Drewery @@ -117,7 +117,7 @@ .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot .Nm .Cm set -.Ar property Ns = Ns Ar value +.Ar property Ns = Ns Ar value Oc ... .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot Ns ... .Nm .Cm get @@ -2121,14 +2121,14 @@ option, but sorts by property in descend .It Xo .Nm .Cm set -.Ar property Ns = Ns Ar value +.Ar property Ns = Ns Ar value Oc ... .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot .Xc .Pp -Sets the property to the given value for each dataset. Only some properties can -be edited. See the "Properties" section for more information on what properties -can be set and acceptable values. Numeric values can be specified as exact -values, or in a human-readable form with a suffix of +Sets the property or list of properties to the given value(s) for each dataset. +Only some properties can be edited. See the "Properties" section for more +information on what properties can be set and acceptable values. Numeric values +can be specified as exact values, or in a human-readable form with a suffix of .Sy B , K , M , G , T , P , E , Z (for bytes, kilobytes, megabytes, gigabytes, terabytes, petabytes, exabytes, or zettabytes, respectively). User properties can be set on snapshots. For more Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c ============================================================================== --- head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Sun Oct 18 09:33:28 2015 (r289496) +++ head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Sun Oct 18 11:21:08 2015 (r289497) @@ -283,7 +283,7 @@ get_usage(zfs_help_t idx) "\n" "\tsend [-nvPe] -t \n")); case HELP_SET: - return (gettext("\tset " + return (gettext("\tset ... " " ...\n")); case HELP_SHARE: return (gettext("\tshare <-a | filesystem>\n")); @@ -498,6 +498,10 @@ usage(boolean_t requested) exit(requested ? 0 : 2); } +/* + * Take a property=value argument string and add it to the given nvlist. + * Modifies the argument inplace. + */ static int parseprop(nvlist_t *props, char *propname) { @@ -505,7 +509,7 @@ parseprop(nvlist_t *props, char *propnam if ((propval = strchr(propname, '=')) == NULL) { (void) fprintf(stderr, gettext("missing " - "'=' for -o option\n")); + "'=' for property=value argument\n")); return (-1); } *propval = '\0'; @@ -632,7 +636,7 @@ zfs_do_clone(int argc, char **argv) while ((c = getopt(argc, argv, "o:p")) != -1) { switch (c) { case 'o': - if (parseprop(props, optarg)) + if (parseprop(props, optarg) != 0) return (1); break; case 'p': @@ -3532,21 +3536,17 @@ out: } /* - * zfs set property=value { fs | snap | vol } ... + * zfs set property=value ... { fs | snap | vol } ... * - * Sets the given property for all datasets specified on the command line. + * Sets the given properties for all datasets specified on the command line. */ -typedef struct set_cbdata { - char *cb_propname; - char *cb_value; -} set_cbdata_t; static int set_callback(zfs_handle_t *zhp, void *data) { - set_cbdata_t *cbp = data; + nvlist_t *props = data; - if (zfs_prop_set(zhp, cbp->cb_propname, cbp->cb_value) != 0) { + if (zfs_prop_set_list(zhp, props) != 0) { switch (libzfs_errno(g_zfs)) { case EZFS_MOUNTFAILED: (void) fprintf(stderr, gettext("property may be set " @@ -3565,7 +3565,8 @@ set_callback(zfs_handle_t *zhp, void *da static int zfs_do_set(int argc, char **argv) { - set_cbdata_t cb; + nvlist_t *props = NULL; + int ds_start = -1; /* argv idx of first dataset arg */ int ret = 0; /* check for options */ @@ -3577,36 +3578,51 @@ zfs_do_set(int argc, char **argv) /* check number of arguments */ if (argc < 2) { - (void) fprintf(stderr, gettext("missing property=value " - "argument\n")); + (void) fprintf(stderr, gettext("missing arguments\n")); usage(B_FALSE); } if (argc < 3) { - (void) fprintf(stderr, gettext("missing dataset name\n")); + if (strchr(argv[1], '=') == NULL) { + (void) fprintf(stderr, gettext("missing property=value " + "argument(s)\n")); + } else { + (void) fprintf(stderr, gettext("missing dataset " + "name(s)\n")); + } usage(B_FALSE); } - /* validate property=value argument */ - cb.cb_propname = argv[1]; - if (((cb.cb_value = strchr(cb.cb_propname, '=')) == NULL) || - (cb.cb_value[1] == '\0')) { - (void) fprintf(stderr, gettext("missing value in " - "property=value argument\n")); + /* validate argument order: prop=val args followed by dataset args */ + for (int i = 1; i < argc; i++) { + if (strchr(argv[i], '=') != NULL) { + if (ds_start > 0) { + /* out-of-order prop=val argument */ + (void) fprintf(stderr, gettext("invalid " + "argument order\n"), i); + usage(B_FALSE); + } + } else if (ds_start < 0) { + ds_start = i; + } + } + if (ds_start < 0) { + (void) fprintf(stderr, gettext("missing dataset name(s)\n")); usage(B_FALSE); } - *cb.cb_value = '\0'; - cb.cb_value++; - - if (*cb.cb_propname == '\0') { - (void) fprintf(stderr, - gettext("missing property in property=value argument\n")); - usage(B_FALSE); + /* Populate a list of property settings */ + if (nvlist_alloc(&props, NV_UNIQUE_NAME, 0) != 0) + nomem(); + for (int i = 1; i < ds_start; i++) { + if ((ret = parseprop(props, argv[i])) != 0) + goto error; } - ret = zfs_for_each(argc - 2, argv + 2, 0, - ZFS_TYPE_DATASET, NULL, NULL, 0, set_callback, &cb); + ret = zfs_for_each(argc - ds_start, argv + ds_start, 0, + ZFS_TYPE_DATASET, NULL, NULL, 0, set_callback, props); +error: + nvlist_free(props); return (ret); } Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h ============================================================================== --- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Sun Oct 18 09:33:28 2015 (r289496) +++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Sun Oct 18 11:21:08 2015 (r289497) @@ -23,7 +23,7 @@ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011 Pawel Jakub Dawidek . * All rights reserved. - * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright (c) 2011, 2014 by Delphix. All rights reserved. * Copyright (c) 2012, Joyent, Inc. All rights reserved. * Copyright (c) 2012 Martin Matuska . All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. @@ -430,6 +430,7 @@ extern nvlist_t *zfs_valid_proplist(libz extern const char *zfs_prop_to_name(zfs_prop_t); extern int zfs_prop_set(zfs_handle_t *, const char *, const char *); +extern int zfs_prop_set_list(zfs_handle_t *, nvlist_t *); extern int zfs_prop_get(zfs_handle_t *, zfs_prop_t, char *, size_t, zprop_source_t *, char *, size_t, boolean_t); extern int zfs_prop_get_recvd(zfs_handle_t *, const char *, char *, size_t, Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Sun Oct 18 09:33:28 2015 (r289496) +++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Sun Oct 18 11:21:08 2015 (r289497) @@ -1534,15 +1534,10 @@ zfs_setprop_error(libzfs_handle_t *hdl, int zfs_prop_set(zfs_handle_t *zhp, const char *propname, const char *propval) { - zfs_cmd_t zc = { 0 }; int ret = -1; - prop_changelist_t *cl = NULL; char errbuf[1024]; libzfs_handle_t *hdl = zhp->zfs_hdl; - nvlist_t *nvl = NULL, *realprops; - zfs_prop_t prop; - boolean_t do_prefix = B_TRUE; - int added_resv; + nvlist_t *nvl = NULL; (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, "cannot set property for '%s'"), @@ -1554,79 +1549,148 @@ zfs_prop_set(zfs_handle_t *zhp, const ch goto error; } - if ((realprops = zfs_valid_proplist(hdl, zhp->zfs_type, nvl, - zfs_prop_get_int(zhp, ZFS_PROP_ZONED), zhp, errbuf)) == NULL) - goto error; + ret = zfs_prop_set_list(zhp, nvl); +error: nvlist_free(nvl); - nvl = realprops; + return (ret); +} - prop = zfs_name_to_prop(propname); - /* We don't support those properties on FreeBSD. */ - switch (prop) { - case ZFS_PROP_DEVICES: - case ZFS_PROP_ISCSIOPTIONS: - case ZFS_PROP_XATTR: - case ZFS_PROP_VSCAN: - case ZFS_PROP_NBMAND: - case ZFS_PROP_MLSLABEL: - (void) snprintf(errbuf, sizeof (errbuf), - "property '%s' not supported on FreeBSD", propname); - ret = zfs_error(hdl, EZFS_PERM, errbuf); - goto error; - } - if (prop == ZFS_PROP_VOLSIZE) { - if ((added_resv = zfs_add_synthetic_resv(zhp, nvl)) == -1) - goto error; - } +/* + * Given an nvlist of property names and values, set the properties for the + * given dataset. + */ +int +zfs_prop_set_list(zfs_handle_t *zhp, nvlist_t *props) +{ + zfs_cmd_t zc = { 0 }; + int ret = -1; + prop_changelist_t **cls = NULL; + int cl_idx; + char errbuf[1024]; + libzfs_handle_t *hdl = zhp->zfs_hdl; + nvlist_t *nvl; + int nvl_len; + int added_resv; - if ((cl = changelist_gather(zhp, prop, 0, 0)) == NULL) - goto error; + (void) snprintf(errbuf, sizeof (errbuf), + dgettext(TEXT_DOMAIN, "cannot set property for '%s'"), + zhp->zfs_name); - if (prop == ZFS_PROP_MOUNTPOINT && changelist_haszonedchild(cl)) { - zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, - "child dataset with inherited mountpoint is used " - "in a non-global zone")); - ret = zfs_error(hdl, EZFS_ZONED, errbuf); + if ((nvl = zfs_valid_proplist(hdl, zhp->zfs_type, props, + zfs_prop_get_int(zhp, ZFS_PROP_ZONED), zhp, errbuf)) == NULL) goto error; - } /* - * We don't want to unmount & remount the dataset when changing - * its canmount property to 'on' or 'noauto'. We only use - * the changelist logic to unmount when setting canmount=off. - */ - if (prop == ZFS_PROP_CANMOUNT) { - uint64_t idx; - int err = zprop_string_to_index(prop, propval, &idx, - ZFS_TYPE_DATASET); - if (err == 0 && idx != ZFS_CANMOUNT_OFF) - do_prefix = B_FALSE; + * We have to check for any extra properties which need to be added + * before computing the length of the nvlist. + */ + for (nvpair_t *elem = nvlist_next_nvpair(nvl, NULL); + elem != NULL; + elem = nvlist_next_nvpair(nvl, elem)) { + if (zfs_name_to_prop(nvpair_name(elem)) == ZFS_PROP_VOLSIZE && + (added_resv = zfs_add_synthetic_resv(zhp, nvl)) == -1) { + goto error; + } } - - if (do_prefix && (ret = changelist_prefix(cl)) != 0) + /* + * Check how many properties we're setting and allocate an array to + * store changelist pointers for postfix(). + */ + nvl_len = 0; + for (nvpair_t *elem = nvlist_next_nvpair(nvl, NULL); + elem != NULL; + elem = nvlist_next_nvpair(nvl, elem)) + nvl_len++; + if ((cls = calloc(nvl_len, sizeof (prop_changelist_t *))) == NULL) goto error; + cl_idx = 0; + for (nvpair_t *elem = nvlist_next_nvpair(nvl, NULL); + elem != NULL; + elem = nvlist_next_nvpair(nvl, elem)) { + + zfs_prop_t prop = zfs_name_to_prop(nvpair_name(elem)); + + assert(cl_idx < nvl_len); + /* + * We don't want to unmount & remount the dataset when changing + * its canmount property to 'on' or 'noauto'. We only use + * the changelist logic to unmount when setting canmount=off. + */ + if (!(prop == ZFS_PROP_CANMOUNT && + fnvpair_value_uint64(elem) != ZFS_CANMOUNT_OFF)) { + cls[cl_idx] = changelist_gather(zhp, prop, 0, 0); + if (cls[cl_idx] == NULL) + goto error; + } + + if (prop == ZFS_PROP_MOUNTPOINT && + changelist_haszonedchild(cls[cl_idx])) { + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "child dataset with inherited mountpoint is used " + "in a non-global zone")); + ret = zfs_error(hdl, EZFS_ZONED, errbuf); + goto error; + } + + /* We don't support those properties on FreeBSD. */ + switch (prop) { + case ZFS_PROP_DEVICES: + case ZFS_PROP_ISCSIOPTIONS: + case ZFS_PROP_XATTR: + case ZFS_PROP_VSCAN: + case ZFS_PROP_NBMAND: + case ZFS_PROP_MLSLABEL: + (void) snprintf(errbuf, sizeof (errbuf), + "property '%s' not supported on FreeBSD", + nvpair_name(elem)); + ret = zfs_error(hdl, EZFS_PERM, errbuf); + goto error; + } + + if (cls[cl_idx] != NULL && + (ret = changelist_prefix(cls[cl_idx])) != 0) + goto error; + + cl_idx++; + } + assert(cl_idx == nvl_len); + /* - * Execute the corresponding ioctl() to set this property. + * Execute the corresponding ioctl() to set this list of properties. */ (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name)); - if (zcmd_write_src_nvlist(hdl, &zc, nvl) != 0) + if ((ret = zcmd_write_src_nvlist(hdl, &zc, nvl)) != 0 || + (ret = zcmd_alloc_dst_nvlist(hdl, &zc, 0)) != 0) goto error; ret = zfs_ioctl(hdl, ZFS_IOC_SET_PROP, &zc); if (ret != 0) { - zfs_setprop_error(hdl, prop, errno, errbuf); + /* Get the list of unset properties back and report them. */ + nvlist_t *errorprops = NULL; + if (zcmd_read_dst_nvlist(hdl, &zc, &errorprops) != 0) + goto error; + for (nvpair_t *elem = nvlist_next_nvpair(nvl, NULL); + elem != NULL; + elem = nvlist_next_nvpair(nvl, elem)) { + zfs_prop_t prop = zfs_name_to_prop(nvpair_name(elem)); + zfs_setprop_error(hdl, prop, errno, errbuf); + } + nvlist_free(errorprops); + if (added_resv && errno == ENOSPC) { /* clean up the volsize property we tried to set */ uint64_t old_volsize = zfs_prop_get_int(zhp, ZFS_PROP_VOLSIZE); nvlist_free(nvl); + nvl = NULL; zcmd_free_nvlists(&zc); + if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0) != 0) goto error; if (nvlist_add_uint64(nvl, @@ -1638,8 +1702,13 @@ zfs_prop_set(zfs_handle_t *zhp, const ch (void) zfs_ioctl(hdl, ZFS_IOC_SET_PROP, &zc); } } else { - if (do_prefix) - ret = changelist_postfix(cl); + for (cl_idx = 0; cl_idx < nvl_len; cl_idx++) { + if (cls[cl_idx] != NULL) { + int clp_err = changelist_postfix(cls[cl_idx]); + if (clp_err != 0) + ret = clp_err; + } + } /* * Refresh the statistics so the new property value @@ -1652,8 +1721,13 @@ zfs_prop_set(zfs_handle_t *zhp, const ch error: nvlist_free(nvl); zcmd_free_nvlists(&zc); - if (cl) - changelist_free(cl); + if (cls != NULL) { + for (cl_idx = 0; cl_idx < nvl_len; cl_idx++) { + if (cls[cl_idx] != NULL) + changelist_free(cls[cl_idx]); + } + free(cls); + } return (ret); } @@ -4203,7 +4277,7 @@ zfs_smb_acl_mgmt(libzfs_handle_t *hdl, c if (cmd == ZFS_SMB_ACL_RENAME) { if (nvlist_alloc(&nvlist, NV_UNIQUE_NAME, 0) != 0) { (void) no_memory(hdl); - return (NULL); + return (0); } } Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Sun Oct 18 09:33:28 2015 (r289496) +++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Sun Oct 18 11:21:08 2015 (r289497) @@ -22,7 +22,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved. - * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright (c) 2011, 2014 by Delphix. All rights reserved. */ /* @@ -782,8 +782,9 @@ zcmd_alloc_dst_nvlist(libzfs_handle_t *h if (len == 0) len = 16 * 1024; zc->zc_nvlist_dst_size = len; - if ((zc->zc_nvlist_dst = (uint64_t)(uintptr_t) - zfs_alloc(hdl, zc->zc_nvlist_dst_size)) == 0) + zc->zc_nvlist_dst = + (uint64_t)(uintptr_t)zfs_alloc(hdl, zc->zc_nvlist_dst_size); + if (zc->zc_nvlist_dst == 0) return (-1); return (0); @@ -798,9 +799,9 @@ int zcmd_expand_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc) { free((void *)(uintptr_t)zc->zc_nvlist_dst); - if ((zc->zc_nvlist_dst = (uint64_t)(uintptr_t) - zfs_alloc(hdl, zc->zc_nvlist_dst_size)) - == 0) + zc->zc_nvlist_dst = + (uint64_t)(uintptr_t)zfs_alloc(hdl, zc->zc_nvlist_dst_size); + if (zc->zc_nvlist_dst == 0) return (-1); return (0); @@ -815,6 +816,9 @@ zcmd_free_nvlists(zfs_cmd_t *zc) free((void *)(uintptr_t)zc->zc_nvlist_conf); free((void *)(uintptr_t)zc->zc_nvlist_src); free((void *)(uintptr_t)zc->zc_nvlist_dst); + zc->zc_nvlist_conf = NULL; + zc->zc_nvlist_src = NULL; + zc->zc_nvlist_dst = NULL; } static int From owner-svn-src-head@freebsd.org Sun Oct 18 11:36:45 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 43816A18EB4; Sun, 18 Oct 2015 11:36:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 173A9365; Sun, 18 Oct 2015 11:36:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IBai5t040499; Sun, 18 Oct 2015 11:36:44 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IBaheE040497; Sun, 18 Oct 2015 11:36:43 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201510181136.t9IBaheE040497@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 18 Oct 2015 11:36:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289499 - in head/cddl/contrib/opensolaris: cmd/zfs lib/libzfs/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 11:36:45 -0000 Author: mav Date: Sun Oct 18 11:36:43 2015 New Revision: 289499 URL: https://svnweb.freebsd.org/changeset/base/289499 Log: MFV r247180: Update vendor/illumos/dist and vendor-sys/illumos/dist to illumos-gate 13967:92bec6d87f59 Illumos ZFS issues: 3557 dumpvp_size is not updated correctly when a dump zvol's size is changed 3558 setting the volsize on a dump device does not return back ENOSPC 3559 setting a volsize larger than the space available sometimes succeeds Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Directory Properties: head/cddl/contrib/opensolaris/ (props changed) head/cddl/contrib/opensolaris/cmd/zfs/ (props changed) head/cddl/contrib/opensolaris/lib/libzfs/ (props changed) Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c ============================================================================== --- head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Sun Oct 18 11:23:58 2015 (r289498) +++ head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Sun Oct 18 11:36:43 2015 (r289499) @@ -845,10 +845,12 @@ zfs_do_create(int argc, char **argv) if (type == ZFS_TYPE_VOLUME && !noreserve) { zpool_handle_t *zpool_handle; + nvlist_t *real_props; uint64_t spa_version; char *p; zfs_prop_t resv_prop; char *strval; + char msg[1024]; if (p = strchr(argv[0], '/')) *p = '\0'; @@ -864,7 +866,15 @@ zfs_do_create(int argc, char **argv) resv_prop = ZFS_PROP_REFRESERVATION; else resv_prop = ZFS_PROP_RESERVATION; - volsize = zvol_volsize_to_reservation(volsize, props); + + (void) snprintf(msg, sizeof (msg), + gettext("cannot create '%s'"), argv[0]); + if (props && (real_props = zfs_valid_proplist(g_zfs, type, + props, 0, NULL, msg)) == NULL) + goto error; + + volsize = zvol_volsize_to_reservation(volsize, real_props); + nvlist_free(real_props); if (nvlist_lookup_string(props, zfs_prop_to_name(resv_prop), &strval) != 0) { Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Sun Oct 18 11:23:58 2015 (r289498) +++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Sun Oct 18 11:36:43 2015 (r289499) @@ -1403,6 +1403,7 @@ zfs_add_synthetic_resv(zfs_handle_t *zhp uint64_t old_reservation; uint64_t new_reservation; zfs_prop_t resv_prop; + nvlist_t *props; /* * If this is an existing volume, and someone is setting the volsize, @@ -1412,16 +1413,25 @@ zfs_add_synthetic_resv(zfs_handle_t *zhp if (zfs_which_resv_prop(zhp, &resv_prop) < 0) return (-1); old_reservation = zfs_prop_get_int(zhp, resv_prop); - if ((zvol_volsize_to_reservation(old_volsize, zhp->zfs_props) != - old_reservation) || nvlist_lookup_uint64(nvl, - zfs_prop_to_name(resv_prop), &new_reservation) != ENOENT) { + + props = fnvlist_alloc(); + fnvlist_add_uint64(props, zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), + zfs_prop_get_int(zhp, ZFS_PROP_VOLBLOCKSIZE)); + + if ((zvol_volsize_to_reservation(old_volsize, props) != + old_reservation) || nvlist_exists(nvl, + zfs_prop_to_name(resv_prop))) { + fnvlist_free(props); return (0); } if (nvlist_lookup_uint64(nvl, zfs_prop_to_name(ZFS_PROP_VOLSIZE), - &new_volsize) != 0) + &new_volsize) != 0) { + fnvlist_free(props); return (-1); - new_reservation = zvol_volsize_to_reservation(new_volsize, - zhp->zfs_props); + } + new_reservation = zvol_volsize_to_reservation(new_volsize, props); + fnvlist_free(props); + if (nvlist_add_uint64(nvl, zfs_prop_to_name(resv_prop), new_reservation) != 0) { (void) no_memory(zhp->zfs_hdl); From owner-svn-src-head@freebsd.org Sun Oct 18 11:44:33 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5076AA11154; Sun, 18 Oct 2015 11:44:33 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 286B6AF7; Sun, 18 Oct 2015 11:44:33 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IBiWbF043355; Sun, 18 Oct 2015 11:44:32 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IBiVhW043350; Sun, 18 Oct 2015 11:44:31 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201510181144.t9IBiVhW043350@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 18 Oct 2015 11:44:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289500 - in head/cddl/contrib/opensolaris: cmd/zfs lib/libzfs/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 11:44:33 -0000 Author: mav Date: Sun Oct 18 11:44:31 2015 New Revision: 289500 URL: https://svnweb.freebsd.org/changeset/base/289500 Log: MFC r289498: 6298 zfs_create_008_neg and zpool_create_023_neg need to be updated for large block support. Reviewed by: Matthew Ahrens Reviewed by: John Kennedy Approved by: Robert Mustacchi Author: Joe Stein illumos/illumos-gate@e9316f7696401f3e5e263a5939031cb8d5641a88 Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Directory Properties: head/cddl/contrib/opensolaris/ (props changed) head/cddl/contrib/opensolaris/cmd/zfs/ (props changed) head/cddl/contrib/opensolaris/lib/libzfs/ (props changed) Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c ============================================================================== --- head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Sun Oct 18 11:36:43 2015 (r289499) +++ head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Sun Oct 18 11:44:31 2015 (r289500) @@ -21,7 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011, 2014 by Delphix. All rights reserved. + * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright 2012 Milan Jurik. All rights reserved. * Copyright (c) 2012, Joyent, Inc. All rights reserved. * Copyright (c) 2011-2012 Pawel Jakub Dawidek . @@ -861,7 +861,6 @@ zfs_do_create(int argc, char **argv) goto error; spa_version = zpool_get_prop_int(zpool_handle, ZPOOL_PROP_VERSION, NULL); - zpool_close(zpool_handle); if (spa_version >= SPA_VERSION_REFRESERVATION) resv_prop = ZFS_PROP_REFRESERVATION; else @@ -870,8 +869,11 @@ zfs_do_create(int argc, char **argv) (void) snprintf(msg, sizeof (msg), gettext("cannot create '%s'"), argv[0]); if (props && (real_props = zfs_valid_proplist(g_zfs, type, - props, 0, NULL, msg)) == NULL) + props, 0, NULL, zpool_handle, msg)) == NULL) { + zpool_close(zpool_handle); goto error; + } + zpool_close(zpool_handle); volsize = zvol_volsize_to_reservation(volsize, real_props); nvlist_free(real_props); Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h ============================================================================== --- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Sun Oct 18 11:36:43 2015 (r289499) +++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Sun Oct 18 11:44:31 2015 (r289500) @@ -23,7 +23,7 @@ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011 Pawel Jakub Dawidek . * All rights reserved. - * Copyright (c) 2011, 2014 by Delphix. All rights reserved. + * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2012, Joyent, Inc. All rights reserved. * Copyright (c) 2012 Martin Matuska . All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. @@ -426,7 +426,7 @@ extern const char *zfs_prop_column_name( extern boolean_t zfs_prop_align_right(zfs_prop_t); extern nvlist_t *zfs_valid_proplist(libzfs_handle_t *, zfs_type_t, - nvlist_t *, uint64_t, zfs_handle_t *, const char *); + nvlist_t *, uint64_t, zfs_handle_t *, zpool_handle_t *, const char *); extern const char *zfs_prop_to_name(zfs_prop_t); extern int zfs_prop_set(zfs_handle_t *, const char *, const char *); Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Sun Oct 18 11:36:43 2015 (r289499) +++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Sun Oct 18 11:44:31 2015 (r289500) @@ -22,7 +22,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved. - * Copyright (c) 2011, 2014 by Delphix. All rights reserved. + * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2012 DEY Storage Systems, Inc. All rights reserved. * Copyright (c) 2011-2012 Pawel Jakub Dawidek . * All rights reserved. @@ -890,7 +890,8 @@ zfs_which_resv_prop(zfs_handle_t *zhp, z */ nvlist_t * zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl, - uint64_t zoned, zfs_handle_t *zhp, const char *errbuf) + uint64_t zoned, zfs_handle_t *zhp, zpool_handle_t *zpool_hdl, + const char *errbuf) { nvpair_t *elem; uint64_t intval; @@ -1084,8 +1085,8 @@ zfs_valid_proplist(libzfs_handle_t *hdl, case ZFS_PROP_RECORDSIZE: { int maxbs = SPA_MAXBLOCKSIZE; - if (zhp != NULL) { - maxbs = zpool_get_prop_int(zhp->zpool_hdl, + if (zpool_hdl != NULL) { + maxbs = zpool_get_prop_int(zpool_hdl, ZPOOL_PROP_MAXBLOCKSIZE, NULL); } /* @@ -1590,7 +1591,8 @@ zfs_prop_set_list(zfs_handle_t *zhp, nvl zhp->zfs_name); if ((nvl = zfs_valid_proplist(hdl, zhp->zfs_type, props, - zfs_prop_get_int(zhp, ZFS_PROP_ZONED), zhp, errbuf)) == NULL) + zfs_prop_get_int(zhp, ZFS_PROP_ZONED), zhp, zhp->zpool_hdl, + errbuf)) == NULL) goto error; /* @@ -3254,9 +3256,23 @@ zfs_create(libzfs_handle_t *hdl, const c else ost = DMU_OST_ZFS; + /* open zpool handle for prop validation */ + char pool_path[MAXNAMELEN]; + (void) strlcpy(pool_path, path, sizeof (pool_path)); + + /* truncate pool_path at first slash */ + char *p = strchr(pool_path, '/'); + if (p != NULL) + *p = '\0'; + + zpool_handle_t *zpool_handle = zpool_open(hdl, pool_path); + if (props && (props = zfs_valid_proplist(hdl, type, props, - zoned, NULL, errbuf)) == 0) + zoned, NULL, zpool_handle, errbuf)) == 0) { + zpool_close(zpool_handle); return (-1); + } + zpool_close(zpool_handle); if (type == ZFS_TYPE_VOLUME) { /* @@ -3324,13 +3340,6 @@ zfs_create(libzfs_handle_t *hdl, const c "parent '%s' is not a filesystem"), parent); return (zfs_error(hdl, EZFS_BADTYPE, errbuf)); - case EDOM: - zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, - "volume block size must be power of 2 from " - "512B to 128KB")); - - return (zfs_error(hdl, EZFS_BADPROP, errbuf)); - case ENOTSUP: zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "pool must be upgraded to set this " @@ -3525,7 +3534,7 @@ zfs_clone(zfs_handle_t *zhp, const char type = ZFS_TYPE_FILESYSTEM; } if ((props = zfs_valid_proplist(hdl, type, props, zoned, - zhp, errbuf)) == NULL) + zhp, zhp->zpool_hdl, errbuf)) == NULL) return (-1); } @@ -3669,11 +3678,23 @@ zfs_snapshot_nvl(libzfs_handle_t *hdl, n } } + /* + * get pool handle for prop validation. assumes all snaps are in the + * same pool, as does lzc_snapshot (below). + */ + char pool[MAXNAMELEN]; + elem = nvlist_next_nvpair(snaps, NULL); + (void) strlcpy(pool, nvpair_name(elem), sizeof (pool)); + pool[strcspn(pool, "/@")] = '\0'; + zpool_handle_t *zpool_hdl = zpool_open(hdl, pool); + if (props != NULL && (props = zfs_valid_proplist(hdl, ZFS_TYPE_SNAPSHOT, - props, B_FALSE, NULL, errbuf)) == NULL) { + props, B_FALSE, NULL, zpool_hdl, errbuf)) == NULL) { + zpool_close(zpool_hdl); return (-1); } + zpool_close(zpool_hdl); ret = lzc_snapshot(snaps, props, &errors); Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Sun Oct 18 11:36:43 2015 (r289499) +++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Sun Oct 18 11:44:31 2015 (r289500) @@ -1164,8 +1164,8 @@ zpool_create(libzfs_handle_t *hdl, const zfs_prop_to_name(ZFS_PROP_ZONED), &zonestr) == 0) && strcmp(zonestr, "on") == 0); - if ((zc_fsprops = zfs_valid_proplist(hdl, - ZFS_TYPE_FILESYSTEM, fsprops, zoned, NULL, msg)) == NULL) { + if ((zc_fsprops = zfs_valid_proplist(hdl, ZFS_TYPE_FILESYSTEM, + fsprops, zoned, NULL, NULL, msg)) == NULL) { goto create_failed; } if (!zc_props && @@ -1201,6 +1201,21 @@ zpool_create(libzfs_handle_t *hdl, const "one or more vdevs refer to the same device")); return (zfs_error(hdl, EZFS_BADDEV, msg)); + case ERANGE: + /* + * This happens if the record size is smaller or larger + * than the allowed size range, or not a power of 2. + * + * NOTE: although zfs_valid_proplist is called earlier, + * this case may have slipped through since the + * pool does not exist yet and it is therefore + * impossible to read properties e.g. max blocksize + * from the pool. + */ + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "record size invalid")); + return (zfs_error(hdl, EZFS_BADPROP, msg)); + case EOVERFLOW: /* * This occurs when one of the devices is below From owner-svn-src-head@freebsd.org Sun Oct 18 12:26:26 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D89B5A10287; Sun, 18 Oct 2015 12:26:26 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 861531C6F; Sun, 18 Oct 2015 12:26:26 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9ICQPtC055011; Sun, 18 Oct 2015 12:26:25 GMT (envelope-from melifaro@FreeBSD.org) Received: (from melifaro@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9ICQPC6055010; Sun, 18 Oct 2015 12:26:25 GMT (envelope-from melifaro@FreeBSD.org) Message-Id: <201510181226.t9ICQPC6055010@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: melifaro set sender to melifaro@FreeBSD.org using -f From: "Alexander V. Chernikov" Date: Sun, 18 Oct 2015 12:26:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289501 - head/sys/netinet X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 12:26:26 -0000 Author: melifaro Date: Sun Oct 18 12:26:25 2015 New Revision: 289501 URL: https://svnweb.freebsd.org/changeset/base/289501 Log: Fix deletion of ifaddr lle entries when deleting prefix from interface in down state. Regression appeared in r287789, where the "prefix has no corresponding installed route" case was forgotten. Additionally, lltable_delete_addr() was called with incorrect byte order (default is network for lltable code). While here, improve comments on given cases and byte order. PR: 203573 Submitted by: phk Modified: head/sys/netinet/in.c Modified: head/sys/netinet/in.c ============================================================================== --- head/sys/netinet/in.c Sun Oct 18 11:44:31 2015 (r289500) +++ head/sys/netinet/in.c Sun Oct 18 12:26:25 2015 (r289501) @@ -734,14 +734,10 @@ in_scrubprefixlle(struct in_ifaddr *ia, struct sockaddr *saddr, *smask; struct ifnet *ifp; - /* - * remove all L2 entries on the given prefix - */ saddr = (struct sockaddr *)&addr; bzero(&addr, sizeof(addr)); addr.sin_len = sizeof(addr); addr.sin_family = AF_INET; - addr.sin_addr.s_addr = ntohl(ia->ia_addr.sin_addr.s_addr); smask = (struct sockaddr *)&mask; bzero(&mask, sizeof(mask)); mask.sin_len = sizeof(mask); @@ -749,10 +745,21 @@ in_scrubprefixlle(struct in_ifaddr *ia, mask.sin_addr.s_addr = ia->ia_subnetmask; ifp = ia->ia_ifp; - if (all) + if (all) { + + /* + * Remove all L2 entries matching given prefix. + * Convert address to host representation to avoid + * doing this on every callback. ia_subnetmask is already + * stored in host representation. + */ + addr.sin_addr.s_addr = ntohl(ia->ia_addr.sin_addr.s_addr); lltable_prefix_free(AF_INET, saddr, smask, flags); - else + } else { + /* Remove interface address only */ + addr.sin_addr.s_addr = ia->ia_addr.sin_addr.s_addr; lltable_delete_addr(LLTABLE(ifp), LLE_IFADDR, saddr); + } } /* @@ -808,6 +815,14 @@ in_scrubprefix(struct in_ifaddr *target, fibnum = V_rt_add_addr_allfibs ? RT_ALL_FIBS : target->ia_ifp->if_fib; rt_addrmsg(RTM_DELETE, &target->ia_ifa, fibnum); + + /* + * Removing address from !IFF_UP interface or + * prefix which exists on other interface (along with route). + * No entries should exist here except target addr. + * Given that, delete this entry only. + */ + in_scrubprefixlle(target, 0, flags); return (0); } From owner-svn-src-head@freebsd.org Sun Oct 18 13:23:22 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 884A9A16077; Sun, 18 Oct 2015 13:23:22 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 564F27CC; Sun, 18 Oct 2015 13:23:22 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IDNLds072594; Sun, 18 Oct 2015 13:23:21 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IDNLCt072593; Sun, 18 Oct 2015 13:23:21 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201510181323.t9IDNLCt072593@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Sun, 18 Oct 2015 13:23:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289502 - head/sys/arm64/arm64 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 13:23:22 -0000 Author: andrew Date: Sun Oct 18 13:23:21 2015 New Revision: 289502 URL: https://svnweb.freebsd.org/changeset/base/289502 Log: Correctly align the stack. The early csu assumed we passed the aux vector in through the stack pointer, however this may have been misaligned causing some userland applications to crash. A workaround was committed in r284707 where userland would check if the aux vector was passed using the old or new ABI and adjust the stack if needed. As 4 months have passed it is time to move to the new ABI, with the expectation the compat code in csu and the runtime linker to be removed in the future. Sponsored by: ABT Systems Ltd Modified: head/sys/arm64/arm64/machdep.c Modified: head/sys/arm64/arm64/machdep.c ============================================================================== --- head/sys/arm64/arm64/machdep.c Sun Oct 18 12:26:25 2015 (r289501) +++ head/sys/arm64/arm64/machdep.c Sun Oct 18 13:23:21 2015 (r289502) @@ -251,7 +251,13 @@ exec_setregs(struct thread *td, struct i memset(tf, 0, sizeof(struct trapframe)); - tf->tf_sp = stack; + /* + * We need to set x0 for init as it doesn't call + * cpu_set_syscall_retval to copy the value. We also + * need to set td_retval for the cases where we do. + */ + tf->tf_x[0] = td->td_retval[0] = stack; + tf->tf_sp = STACKALIGN(stack); tf->tf_lr = imgp->entry_addr; tf->tf_elr = imgp->entry_addr; } From owner-svn-src-head@freebsd.org Sun Oct 18 16:19:42 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 54604A18BE5 for ; Sun, 18 Oct 2015 16:19:42 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from pmta2.delivery6.ore.mailhop.org (pmta2.delivery6.ore.mailhop.org [54.200.129.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3477D832 for ; Sun, 18 Oct 2015 16:19:41 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from ilsoft.org (unknown [73.34.117.227]) by outbound2.ore.mailhop.org (Halon Mail Gateway) with ESMTPSA; Sun, 18 Oct 2015 16:19:52 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.14.9/8.14.9) with ESMTP id t9IGJd4w008353; Sun, 18 Oct 2015 10:19:39 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: <1445185179.71631.50.camel@freebsd.org> Subject: Re: svn commit: r289477 - head/sys/arm/mv From: Ian Lepore To: Konstantin Belousov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Date: Sun, 18 Oct 2015 10:19:39 -0600 In-Reply-To: <20151018094602.GF2257@kib.kiev.ua> References: <201510180103.t9I13h0w056671@repo.freebsd.org> <20151018094602.GF2257@kib.kiev.ua> Content-Type: text/plain; charset="us-ascii" X-Mailer: Evolution 3.16.5 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 16:19:42 -0000 On Sun, 2015-10-18 at 12:46 +0300, Konstantin Belousov wrote: > On Sun, Oct 18, 2015 at 01:03:43AM +0000, Ian Lepore wrote: > > Author: ian > > Date: Sun Oct 18 01:03:43 2015 > > New Revision: 289477 > > URL: https://svnweb.freebsd.org/changeset/base/289477 > > > > Log: > > Fix a strange macro re-definition compile error. If the > > VM_MAXUSER_ADDRESS > > value is defined as a config option the definition is emitted > > into > > opt_global.h which is force-included into everything. In > > addition, the > > symbol is emitted by the genassym mechanism, but that by its > > nature reduces > > the value to a 0xnnnnnnnn number. When compiling a .S file you > > end up > > with two different definitions of the macro (they evaluate to the > > same > > number, but the text is different, upsetting the compiler). > > > > Nothing has changed about this code for a while but the compile > > error is > > new, so this must be fallout from the clang 3.7 update or > > something. > > > > Modified: > > head/sys/arm/mv/std-pj4b.mv > > > > Modified: head/sys/arm/mv/std-pj4b.mv > > =================================================================== > > =========== > > --- head/sys/arm/mv/std-pj4b.mv Sun Oct 18 00:59:28 2015 > > (r289476) > > +++ head/sys/arm/mv/std-pj4b.mv Sun Oct 18 01:03:43 2015 > > (r289477) > > @@ -5,4 +5,8 @@ cpu CPU_MV_PJ4B > > machine arm armv6 > > makeoptions CONF_CFLAGS="-march=armv7a" > > > > -options VM_MAXUSER_ADDRESS="(KERNBASE > > -(1024*1024*1024))" > > +# This was originally defined as "(KERNBASE-(1024*1024*1024))" but > > that > > +# (in opt_global.h) clashed with the value emitted by genassym > > which > > +# reduces the original macro text to its numeric value. The only > > way > > +# to avoid that is to define it here as the numeric value genassym > > emits. > > +options VM_MAXUSER_ADDRESS="0x80000000" > > Genassym started to generate VM_MAXUSER_ADDRESS after r289372. > Strange that I did not saw the error. > > Why does marvell need this override ? > That is a very good question, to which I found no answer in the svn history... this value was in the file from day one and the commit message just says it was obtained from Marvell and Semihalf. There's other strange stuff in the arm/mv hierarchy that nobody (except maybe marvell and semihalf) knows why it's different. I finally bought myself an ARMADAXP-based system (which this config is for) about six months ago, but I literally haven't had a chance to take it out of the box since it arrived. ::sigh:: -- Ian From owner-svn-src-head@freebsd.org Sun Oct 18 16:54:36 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8C547A18498; Sun, 18 Oct 2015 16:54:36 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4E115ACF; Sun, 18 Oct 2015 16:54:36 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IGsZZC034701; Sun, 18 Oct 2015 16:54:35 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IGsYqa034689; Sun, 18 Oct 2015 16:54:34 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201510181654.t9IGsYqa034689@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 18 Oct 2015 16:54:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289522 - in head/sys/arm: allwinner/a20 altera/socfpga amlogic/aml8726 annapurna/alpine arm freescale/imx include qemu rockchip samsung/exynos ti/omap4 xilinx X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 16:54:36 -0000 Author: ian Date: Sun Oct 18 16:54:34 2015 New Revision: 289522 URL: https://svnweb.freebsd.org/changeset/base/289522 Log: Rename arm_init_secondary_ic() -> arm_pic_init_secondary(). The latter is the name the function will have when the new ARM_INTRNG code is integrated, and doing this rename first will make it easier to toggle the new interrupt handling code on/off with a config option for debugging. Modified: head/sys/arm/allwinner/a20/a20_mp.c head/sys/arm/altera/socfpga/socfpga_mp.c head/sys/arm/amlogic/aml8726/aml8726_mp.c head/sys/arm/annapurna/alpine/alpine_machdep_mp.c head/sys/arm/arm/gic.c head/sys/arm/freescale/imx/imx6_mp.c head/sys/arm/include/intr.h head/sys/arm/qemu/virt_mp.c head/sys/arm/rockchip/rk30xx_mp.c head/sys/arm/samsung/exynos/exynos5_mp.c head/sys/arm/ti/omap4/omap4_mp.c head/sys/arm/xilinx/zy7_mp.c Modified: head/sys/arm/allwinner/a20/a20_mp.c ============================================================================== --- head/sys/arm/allwinner/a20/a20_mp.c Sun Oct 18 15:03:47 2015 (r289521) +++ head/sys/arm/allwinner/a20/a20_mp.c Sun Oct 18 16:54:34 2015 (r289522) @@ -61,7 +61,7 @@ void platform_mp_init_secondary(void) { - arm_init_secondary_ic(); + arm_pic_init_secondary(); } void Modified: head/sys/arm/altera/socfpga/socfpga_mp.c ============================================================================== --- head/sys/arm/altera/socfpga/socfpga_mp.c Sun Oct 18 15:03:47 2015 (r289521) +++ head/sys/arm/altera/socfpga/socfpga_mp.c Sun Oct 18 16:54:34 2015 (r289522) @@ -87,7 +87,7 @@ void platform_mp_init_secondary(void) { - arm_init_secondary_ic(); + arm_pic_init_secondary(); } void Modified: head/sys/arm/amlogic/aml8726/aml8726_mp.c ============================================================================== --- head/sys/arm/amlogic/aml8726/aml8726_mp.c Sun Oct 18 15:03:47 2015 (r289521) +++ head/sys/arm/amlogic/aml8726/aml8726_mp.c Sun Oct 18 16:54:34 2015 (r289522) @@ -351,7 +351,7 @@ platform_mp_init_secondary(void) * each AP. */ - arm_init_secondary_ic(); + arm_pic_init_secondary(); } Modified: head/sys/arm/annapurna/alpine/alpine_machdep_mp.c ============================================================================== --- head/sys/arm/annapurna/alpine/alpine_machdep_mp.c Sun Oct 18 15:03:47 2015 (r289521) +++ head/sys/arm/annapurna/alpine/alpine_machdep_mp.c Sun Oct 18 16:54:34 2015 (r289522) @@ -122,7 +122,7 @@ void platform_mp_init_secondary(void) { - arm_init_secondary_ic(); + arm_pic_init_secondary(); } void Modified: head/sys/arm/arm/gic.c ============================================================================== --- head/sys/arm/arm/gic.c Sun Oct 18 15:03:47 2015 (r289521) +++ head/sys/arm/arm/gic.c Sun Oct 18 16:54:34 2015 (r289522) @@ -492,7 +492,7 @@ arm_get_next_irq(int last_irq) } void -arm_init_secondary_ic(void) +arm_pic_init_secondary(void) { arm_gic_init_secondary(arm_gic_sc->gic_dev); Modified: head/sys/arm/freescale/imx/imx6_mp.c ============================================================================== --- head/sys/arm/freescale/imx/imx6_mp.c Sun Oct 18 15:03:47 2015 (r289521) +++ head/sys/arm/freescale/imx/imx6_mp.c Sun Oct 18 16:54:34 2015 (r289522) @@ -69,7 +69,7 @@ void platform_mp_init_secondary(void) { - arm_init_secondary_ic(); + arm_pic_init_secondary(); } void Modified: head/sys/arm/include/intr.h ============================================================================== --- head/sys/arm/include/intr.h Sun Oct 18 15:03:47 2015 (r289521) +++ head/sys/arm/include/intr.h Sun Oct 18 16:54:34 2015 (r289522) @@ -85,7 +85,7 @@ extern int (*arm_config_irq)(int irq, en void arm_irq_memory_barrier(uintptr_t); -void arm_init_secondary_ic(void); +void arm_pic_init_secondary(void); int gic_decode_fdt(uint32_t iparentnode, uint32_t *intrcells, int *interrupt, int *trig, int *pol); Modified: head/sys/arm/qemu/virt_mp.c ============================================================================== --- head/sys/arm/qemu/virt_mp.c Sun Oct 18 15:03:47 2015 (r289521) +++ head/sys/arm/qemu/virt_mp.c Sun Oct 18 16:54:34 2015 (r289522) @@ -108,7 +108,7 @@ void platform_mp_init_secondary(void) { - arm_init_secondary_ic(); + arm_pic_init_secondary(); } void Modified: head/sys/arm/rockchip/rk30xx_mp.c ============================================================================== --- head/sys/arm/rockchip/rk30xx_mp.c Sun Oct 18 15:03:47 2015 (r289521) +++ head/sys/arm/rockchip/rk30xx_mp.c Sun Oct 18 16:54:34 2015 (r289522) @@ -82,7 +82,7 @@ void platform_mp_init_secondary(void) { - arm_init_secondary_ic(); + arm_pic_init_secondary(); } void Modified: head/sys/arm/samsung/exynos/exynos5_mp.c ============================================================================== --- head/sys/arm/samsung/exynos/exynos5_mp.c Sun Oct 18 15:03:47 2015 (r289521) +++ head/sys/arm/samsung/exynos/exynos5_mp.c Sun Oct 18 16:54:34 2015 (r289522) @@ -73,7 +73,7 @@ void platform_mp_init_secondary(void) { - arm_init_secondary_ic(); + arm_pic_init_secondary(); } void Modified: head/sys/arm/ti/omap4/omap4_mp.c ============================================================================== --- head/sys/arm/ti/omap4/omap4_mp.c Sun Oct 18 15:03:47 2015 (r289521) +++ head/sys/arm/ti/omap4/omap4_mp.c Sun Oct 18 16:54:34 2015 (r289522) @@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$"); void platform_mp_init_secondary(void) { - arm_init_secondary_ic(); + arm_pic_init_secondary(); } void Modified: head/sys/arm/xilinx/zy7_mp.c ============================================================================== --- head/sys/arm/xilinx/zy7_mp.c Sun Oct 18 15:03:47 2015 (r289521) +++ head/sys/arm/xilinx/zy7_mp.c Sun Oct 18 16:54:34 2015 (r289522) @@ -49,7 +49,7 @@ void platform_mp_init_secondary(void) { - arm_init_secondary_ic(); + arm_pic_init_secondary(); } void From owner-svn-src-head@freebsd.org Sun Oct 18 17:13:43 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E0A00A18A5F; Sun, 18 Oct 2015 17:13:42 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BA5211361; Sun, 18 Oct 2015 17:13:42 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IHDfAl040461; Sun, 18 Oct 2015 17:13:41 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IHDfO7040460; Sun, 18 Oct 2015 17:13:41 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201510181713.t9IHDfO7040460@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 18 Oct 2015 17:13:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289523 - head/contrib/llvm/tools/clang/lib/Driver X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 17:13:43 -0000 Author: dim Date: Sun Oct 18 17:13:41 2015 New Revision: 289523 URL: https://svnweb.freebsd.org/changeset/base/289523 Log: Pull in r248379 from upstream clang trunk (by Jörg Sonnenberger): Refactor library decision for -fopenmp support from Darwin into a function for sharing with other platforms. Pull in r248424 from upstream clang trunk (by Jörg Sonnenberger): Push OpenMP linker flags after linker input on Darwin. Don't add any libraries if -nostdlib is specified. Test. Pull in r248426 from upstream clang trunk (by Jörg Sonnenberger): Support linking against OpenMP runtime on NetBSD. Pull in r250657 from upstream clang trunk (by Dimitry Andric): Support linking against OpenMP runtime on FreeBSD. Modified: head/contrib/llvm/tools/clang/lib/Driver/Tools.cpp Modified: head/contrib/llvm/tools/clang/lib/Driver/Tools.cpp ============================================================================== --- head/contrib/llvm/tools/clang/lib/Driver/Tools.cpp Sun Oct 18 16:54:34 2015 (r289522) +++ head/contrib/llvm/tools/clang/lib/Driver/Tools.cpp Sun Oct 18 17:13:41 2015 (r289523) @@ -2460,6 +2460,28 @@ static OpenMPRuntimeKind getOpenMPRuntim return RT; } +static void addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC, + const ArgList &Args) { + if (!Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ, + options::OPT_fno_openmp, false)) + return; + + switch (getOpenMPRuntime(TC, Args)) { + case OMPRT_OMP: + CmdArgs.push_back("-lomp"); + break; + case OMPRT_GOMP: + CmdArgs.push_back("-lgomp"); + break; + case OMPRT_IOMP5: + CmdArgs.push_back("-liomp5"); + break; + case OMPRT_Unknown: + // Already diagnosed. + break; + } +} + static void addSanitizerRuntime(const ToolChain &TC, const ArgList &Args, ArgStringList &CmdArgs, StringRef Sanitizer, bool IsShared) { @@ -6527,24 +6549,6 @@ void darwin::Linker::ConstructJob(Compil Args.AddAllArgs(CmdArgs, options::OPT_L); - if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ, - options::OPT_fno_openmp, false)) { - switch (getOpenMPRuntime(getToolChain(), Args)) { - case OMPRT_OMP: - CmdArgs.push_back("-lomp"); - break; - case OMPRT_GOMP: - CmdArgs.push_back("-lgomp"); - break; - case OMPRT_IOMP5: - CmdArgs.push_back("-liomp5"); - break; - case OMPRT_Unknown: - // Already diagnosed. - break; - } - } - AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs); // Build the input file for -filelist (list of linker input files) in case we // need it later @@ -6563,6 +6567,10 @@ void darwin::Linker::ConstructJob(Compil InputFileList.push_back(II.getFilename()); } + if (!Args.hasArg(options::OPT_nostdlib) && + !Args.hasArg(options::OPT_nodefaultlibs)) + addOpenMPRuntime(CmdArgs, getToolChain(), Args); + if (isObjCRuntimeLinked(Args) && !Args.hasArg(options::OPT_nostdlib) && !Args.hasArg(options::OPT_nodefaultlibs)) { // We use arclite library for both ARC and subscripting support. @@ -7358,6 +7366,7 @@ void freebsd::Linker::ConstructJob(Compi if (!Args.hasArg(options::OPT_nostdlib) && !Args.hasArg(options::OPT_nodefaultlibs)) { + addOpenMPRuntime(CmdArgs, ToolChain, Args); if (D.CCCIsCXX()) { ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); if (Args.hasArg(options::OPT_pg)) @@ -7673,6 +7682,7 @@ void netbsd::Linker::ConstructJob(Compil if (!Args.hasArg(options::OPT_nostdlib) && !Args.hasArg(options::OPT_nodefaultlibs)) { + addOpenMPRuntime(CmdArgs, getToolChain(), Args); if (D.CCCIsCXX()) { getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs); CmdArgs.push_back("-lm"); From owner-svn-src-head@freebsd.org Sun Oct 18 17:14:46 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7FC5EA18AA2; Sun, 18 Oct 2015 17:14:46 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 540B01516; Sun, 18 Oct 2015 17:14:46 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IHEjUk040540; Sun, 18 Oct 2015 17:14:45 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IHEjM1040539; Sun, 18 Oct 2015 17:14:45 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201510181714.t9IHEjM1040539@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 18 Oct 2015 17:14:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289524 - head/contrib/llvm/patches X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 17:14:46 -0000 Author: dim Date: Sun Oct 18 17:14:45 2015 New Revision: 289524 URL: https://svnweb.freebsd.org/changeset/base/289524 Log: Add clang patch corresponding to r289523. Added: head/contrib/llvm/patches/patch-09-clang-r250657-openmp.diff Added: head/contrib/llvm/patches/patch-09-clang-r250657-openmp.diff ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/llvm/patches/patch-09-clang-r250657-openmp.diff Sun Oct 18 17:14:45 2015 (r289524) @@ -0,0 +1,182 @@ +Pull in r248379 from upstream clang trunk (by Jörg Sonnenberger): + + Refactor library decision for -fopenmp support from Darwin into a + function for sharing with other platforms. + +Pull in r248424 from upstream clang trunk (by Jörg Sonnenberger): + + Push OpenMP linker flags after linker input on Darwin. Don't add any + libraries if -nostdlib is specified. Test. + +Pull in r248426 from upstream clang trunk (by Jörg Sonnenberger): + + Support linking against OpenMP runtime on NetBSD. + +Pull in r250657 from upstream clang trunk (by Dimitry Andric): + + Support linking against OpenMP runtime on FreeBSD. + +Introduced here: http://svnweb.freebsd.org/changeset/base/289523 + +Index: tools/clang/lib/Driver/Tools.cpp +=================================================================== +--- tools/clang/lib/Driver/Tools.cpp ++++ tools/clang/lib/Driver/Tools.cpp +@@ -2460,6 +2460,28 @@ static OpenMPRuntimeKind getOpenMPRuntime(const To + return RT; + } + ++static void addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC, ++ const ArgList &Args) { ++ if (!Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ, ++ options::OPT_fno_openmp, false)) ++ return; ++ ++ switch (getOpenMPRuntime(TC, Args)) { ++ case OMPRT_OMP: ++ CmdArgs.push_back("-lomp"); ++ break; ++ case OMPRT_GOMP: ++ CmdArgs.push_back("-lgomp"); ++ break; ++ case OMPRT_IOMP5: ++ CmdArgs.push_back("-liomp5"); ++ break; ++ case OMPRT_Unknown: ++ // Already diagnosed. ++ break; ++ } ++} ++ + static void addSanitizerRuntime(const ToolChain &TC, const ArgList &Args, + ArgStringList &CmdArgs, StringRef Sanitizer, + bool IsShared) { +@@ -6527,24 +6549,6 @@ void darwin::Linker::ConstructJob(Compilation &C, + + Args.AddAllArgs(CmdArgs, options::OPT_L); + +- if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ, +- options::OPT_fno_openmp, false)) { +- switch (getOpenMPRuntime(getToolChain(), Args)) { +- case OMPRT_OMP: +- CmdArgs.push_back("-lomp"); +- break; +- case OMPRT_GOMP: +- CmdArgs.push_back("-lgomp"); +- break; +- case OMPRT_IOMP5: +- CmdArgs.push_back("-liomp5"); +- break; +- case OMPRT_Unknown: +- // Already diagnosed. +- break; +- } +- } +- + AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs); + // Build the input file for -filelist (list of linker input files) in case we + // need it later +@@ -6563,6 +6567,10 @@ void darwin::Linker::ConstructJob(Compilation &C, + InputFileList.push_back(II.getFilename()); + } + ++ if (!Args.hasArg(options::OPT_nostdlib) && ++ !Args.hasArg(options::OPT_nodefaultlibs)) ++ addOpenMPRuntime(CmdArgs, getToolChain(), Args); ++ + if (isObjCRuntimeLinked(Args) && !Args.hasArg(options::OPT_nostdlib) && + !Args.hasArg(options::OPT_nodefaultlibs)) { + // We use arclite library for both ARC and subscripting support. +@@ -7358,6 +7366,7 @@ void freebsd::Linker::ConstructJob(Compilation &C, + + if (!Args.hasArg(options::OPT_nostdlib) && + !Args.hasArg(options::OPT_nodefaultlibs)) { ++ addOpenMPRuntime(CmdArgs, ToolChain, Args); + if (D.CCCIsCXX()) { + ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); + if (Args.hasArg(options::OPT_pg)) +@@ -7673,6 +7682,7 @@ void netbsd::Linker::ConstructJob(Compilation &C, + + if (!Args.hasArg(options::OPT_nostdlib) && + !Args.hasArg(options::OPT_nodefaultlibs)) { ++ addOpenMPRuntime(CmdArgs, getToolChain(), Args); + if (D.CCCIsCXX()) { + getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs); + CmdArgs.push_back("-lm"); +Index: tools/clang/test/Driver/fopenmp.c +=================================================================== +--- tools/clang/test/Driver/fopenmp.c ++++ tools/clang/test/Driver/fopenmp.c +@@ -1,6 +1,15 @@ + // RUN: %clang -target x86_64-linux-gnu -fopenmp=libomp -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CC1-OPENMP + // RUN: %clang -target x86_64-linux-gnu -fopenmp=libgomp -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CC1-NO-OPENMP + // RUN: %clang -target x86_64-linux-gnu -fopenmp=libiomp5 -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CC1-OPENMP ++// RUN: %clang -target x86_64-apple-darwin -fopenmp=libomp -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CC1-OPENMP ++// RUN: %clang -target x86_64-apple-darwin -fopenmp=libgomp -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CC1-NO-OPENMP ++// RUN: %clang -target x86_64-apple-darwin -fopenmp=libiomp5 -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CC1-OPENMP ++// RUN: %clang -target x86_64-freebsd -fopenmp=libomp -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CC1-OPENMP ++// RUN: %clang -target x86_64-freebsd -fopenmp=libgomp -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CC1-NO-OPENMP ++// RUN: %clang -target x86_64-freebsd -fopenmp=libiomp5 -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CC1-OPENMP ++// RUN: %clang -target x86_64-netbsd -fopenmp=libomp -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CC1-OPENMP ++// RUN: %clang -target x86_64-netbsd -fopenmp=libgomp -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CC1-NO-OPENMP ++// RUN: %clang -target x86_64-netbsd -fopenmp=libiomp5 -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CC1-OPENMP + // + // CHECK-CC1-OPENMP: "-cc1" + // CHECK-CC1-OPENMP: "-fopenmp" +@@ -12,6 +21,30 @@ + // RUN: %clang -target x86_64-linux-gnu -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP + // RUN: %clang -target x86_64-linux-gnu -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5 + // ++// RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP ++// RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP ++// RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5 ++// ++// RUN: %clang -target x86_64-darwin -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-OMP ++// RUN: %clang -target x86_64-darwin -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP ++// RUN: %clang -target x86_64-darwin -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5 ++// ++// RUN: %clang -nostdlib -target x86_64-darwin -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP ++// RUN: %clang -nostdlib -target x86_64-darwin -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP ++// RUN: %clang -nostdlib -target x86_64-darwin -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5 ++// ++// RUN: %clang -target x86_64-netbsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-OMP ++// RUN: %clang -target x86_64-netbsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP ++// RUN: %clang -target x86_64-netbsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5 ++// ++// RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP ++// RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP ++// RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5 ++// ++// RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP ++// RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP ++// RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5 ++// + // CHECK-LD-OMP: "{{.*}}ld{{(.exe)?}}" + // CHECK-LD-OMP: "-lomp" + // +@@ -21,6 +54,15 @@ + // CHECK-LD-IOMP5: "{{.*}}ld{{(.exe)?}}" + // CHECK-LD-IOMP5: "-liomp5" + // ++// CHECK-NO-OMP: "{{.*}}ld{{(.exe)?}}" ++// CHECK-NO-OMP-NOT: "-lomp" ++// ++// CHECK-NO-GOMP: "{{.*}}ld{{(.exe)?}}" ++// CHECK-NO-GOMP-NOT: "-lgomp" ++// ++// CHECK-NO-IOMP5: "{{.*}}ld{{(.exe)?}}" ++// CHECK-NO-IOMP5-NOT: "-liomp5" ++// + // We'd like to check that the default is sane, but until we have the ability + // to *always* semantically analyze OpenMP without always generating runtime + // calls (in the event of an unsupported runtime), we don't have a good way to +@@ -28,6 +70,9 @@ + // OpenMP runtime. + // + // RUN: %clang -target x86_64-linux-gnu -fopenmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-ANY ++// RUN: %clang -target x86_64-darwin -fopenmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-ANY ++// RUN: %clang -target x86_64-freebsd -fopenmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-ANY ++// RUN: %clang -target x86_64-netbsd -fopenmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-ANY + // + // CHECK-LD-ANY: "{{.*}}ld{{(.exe)?}}" + // CHECK-LD-ANY: "-l{{(omp|gomp|iomp5)}}" From owner-svn-src-head@freebsd.org Sun Oct 18 17:18:21 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6A8B8A18B39; Sun, 18 Oct 2015 17:18:21 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3045E17F6; Sun, 18 Oct 2015 17:18:21 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IHIKRh040716; Sun, 18 Oct 2015 17:18:20 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IHIK8Q040714; Sun, 18 Oct 2015 17:18:20 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201510181718.t9IHIK8Q040714@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 18 Oct 2015 17:18:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289525 - in head/lib/clang/include: clang/Config llvm/Config X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 17:18:21 -0000 Author: dim Date: Sun Oct 18 17:18:19 2015 New Revision: 289525 URL: https://svnweb.freebsd.org/changeset/base/289525 Log: Switch the default OpenMP runtime for clang to libomp (from the LLVM project), as libgomp is not supported anyway. You can use the devel/llvm-devel port to install a recent copy of the OpenMP runtime. Modified: head/lib/clang/include/clang/Config/config.h head/lib/clang/include/llvm/Config/config.h Modified: head/lib/clang/include/clang/Config/config.h ============================================================================== --- head/lib/clang/include/clang/Config/config.h Sun Oct 18 17:14:45 2015 (r289524) +++ head/lib/clang/include/clang/Config/config.h Sun Oct 18 17:18:19 2015 (r289525) @@ -11,7 +11,7 @@ #define BUG_REPORT_URL "https://bugs.freebsd.org/submit/" /* Default OpenMP runtime used by -fopenmp. */ -#define CLANG_DEFAULT_OPENMP_RUNTIME "libgomp" +#define CLANG_DEFAULT_OPENMP_RUNTIME "libomp" /* Multilib suffix for libdir. */ #define CLANG_LIBDIR_SUFFIX "" Modified: head/lib/clang/include/llvm/Config/config.h ============================================================================== --- head/lib/clang/include/llvm/Config/config.h Sun Oct 18 17:14:45 2015 (r289524) +++ head/lib/clang/include/llvm/Config/config.h Sun Oct 18 17:18:19 2015 (r289525) @@ -15,7 +15,7 @@ #define BUG_REPORT_URL "https://bugs.freebsd.org/submit/" /* Default OpenMP runtime used by -fopenmp. */ -#define CLANG_DEFAULT_OPENMP_RUNTIME "libgomp" +#define CLANG_DEFAULT_OPENMP_RUNTIME "libomp" /* Define if we have libxml2 */ /* #undef CLANG_HAVE_LIBXML */ From owner-svn-src-head@freebsd.org Sun Oct 18 18:08:35 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4F9D59D1676; Sun, 18 Oct 2015 18:08:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 05F36DDD; Sun, 18 Oct 2015 18:08:34 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9II8YJ9055123; Sun, 18 Oct 2015 18:08:34 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9II8X3G055121; Sun, 18 Oct 2015 18:08:33 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201510181808.t9II8X3G055121@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 18 Oct 2015 18:08:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289527 - in head: cddl/contrib/opensolaris/lib/libzfs/common sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 18:08:35 -0000 Author: mav Date: Sun Oct 18 18:08:33 2015 New Revision: 289527 URL: https://svnweb.freebsd.org/changeset/base/289527 Log: MFV r289526: 5561 support root pools on EFI/GPT partitioned disks 5125 update zpool/libzfs to manage bootable whole disk pools (EFI/GPT labeled disks) Reviewed by: Jean McCormack Reviewed by: Josef 'Jeff' Sipek Approved by: Dan McDonald Author: Hans Rosenfeld illumos/illumos-gate@1a902ef8628b0dffd6df5442354ab59bb8530962 This is NOP changes for FreeBSD. Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Directory Properties: head/cddl/contrib/opensolaris/ (props changed) head/cddl/contrib/opensolaris/lib/libzfs/ (props changed) head/sys/cddl/contrib/opensolaris/ (props changed) Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Sun Oct 18 17:57:42 2015 (r289526) +++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Sun Oct 18 18:08:33 2015 (r289527) @@ -402,29 +402,6 @@ bootfs_name_valid(const char *pool, char return (B_FALSE); } -/* - * Inspect the configuration to determine if any of the devices contain - * an EFI label. - */ -static boolean_t -pool_uses_efi(nvlist_t *config) -{ -#ifdef illumos - nvlist_t **child; - uint_t c, children; - - if (nvlist_lookup_nvlist_array(config, ZPOOL_CONFIG_CHILDREN, - &child, &children) != 0) - return (read_efi_label(config, NULL) >= 0); - - for (c = 0; c < children; c++) { - if (pool_uses_efi(child[c])) - return (B_TRUE); - } -#endif /* illumos */ - return (B_FALSE); -} - boolean_t zpool_is_bootable(zpool_handle_t *zhp) { @@ -453,7 +430,6 @@ zpool_valid_proplist(libzfs_handle_t *hd char *slash, *check; struct stat64 statbuf; zpool_handle_t *zhp; - nvlist_t *nvroot; if (nvlist_alloc(&retprops, NV_UNIQUE_NAME, 0) != 0) { (void) no_memory(hdl); @@ -572,23 +548,6 @@ zpool_valid_proplist(libzfs_handle_t *hd (void) zfs_error(hdl, EZFS_OPENFAILED, errbuf); goto error; } - verify(nvlist_lookup_nvlist(zpool_get_config(zhp, NULL), - ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0); - -#ifdef illumos - /* - * bootfs property cannot be set on a disk which has - * been EFI labeled. - */ - if (pool_uses_efi(nvroot)) { - zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, - "property '%s' not supported on " - "EFI labeled devices"), propname); - (void) zfs_error(hdl, EZFS_POOL_NOTSUP, errbuf); - zpool_close(zhp); - goto error; - } -#endif /* illumos */ zpool_close(zhp); break; @@ -1326,25 +1285,6 @@ zpool_add(zpool_handle_t *zhp, nvlist_t return (zfs_error(hdl, EZFS_BADVERSION, msg)); } - if (zpool_is_bootable(zhp) && nvlist_lookup_nvlist_array(nvroot, - ZPOOL_CONFIG_SPARES, &spares, &nspares) == 0) { - uint64_t s; - - for (s = 0; s < nspares; s++) { - char *path; - - if (nvlist_lookup_string(spares[s], ZPOOL_CONFIG_PATH, - &path) == 0 && pool_uses_efi(spares[s])) { - zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, - "device '%s' contains an EFI label and " - "cannot be used on root pools."), - zpool_vdev_name(hdl, NULL, spares[s], - B_FALSE)); - return (zfs_error(hdl, EZFS_POOL_NOTSUP, msg)); - } - } - } - if (zpool_get_prop_int(zhp, ZPOOL_PROP_VERSION, NULL) < SPA_VERSION_L2CACHE && nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_L2CACHE, @@ -2365,11 +2305,9 @@ zpool_get_config_physpath(nvlist_t *conf return (EZFS_INVALCONFIG); /* - * root pool can not have EFI labeled disks and can only have - * a single top-level vdev. + * root pool can only have a single top-level vdev. */ - if (strcmp(type, VDEV_TYPE_ROOT) != 0 || count != 1 || - pool_uses_efi(vdev_root)) + if (strcmp(type, VDEV_TYPE_ROOT) != 0 || count != 1) return (EZFS_POOL_INVALARG); (void) vdev_get_physpaths(child[0], physpath, phypath_size, &rsz, @@ -2673,16 +2611,6 @@ zpool_vdev_attach(zpool_handle_t *zhp, (void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN, "cannot attach %s to %s"), new_disk, old_disk); - /* - * If this is a root pool, make sure that we're not attaching an - * EFI labeled device. - */ - if (rootpool && pool_uses_efi(nvroot)) { - zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, - "EFI labeled devices are not supported on root pools.")); - return (zfs_error(hdl, EZFS_POOL_NOTSUP, msg)); - } - (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); if ((tgt = zpool_find_vdev(zhp, old_disk, &avail_spare, &l2cache, &islog)) == 0) @@ -3996,13 +3924,6 @@ zpool_label_disk(libzfs_handle_t *hdl, z if (zhp) { nvlist_t *nvroot; - if (zpool_is_bootable(zhp)) { - zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, - "EFI labeled devices are not supported on root " - "pools.")); - return (zfs_error(hdl, EZFS_POOL_NOTSUP, errbuf)); - } - verify(nvlist_lookup_nvlist(zhp->zpool_config, ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0); Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Sun Oct 18 17:57:42 2015 (r289526) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Sun Oct 18 18:08:33 2015 (r289527) @@ -3412,8 +3412,6 @@ vdev_is_bootable(vdev_t *vd) strcmp(vdev_type, VDEV_TYPE_MISSING) == 0) { return (B_FALSE); } - } else if (vd->vdev_wholedisk == 1) { - return (B_FALSE); } for (int c = 0; c < vd->vdev_children; c++) { From owner-svn-src-head@freebsd.org Sun Oct 18 18:25:02 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5E9CD9D1A8E; Sun, 18 Oct 2015 18:25:02 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 05F3A7D8; Sun, 18 Oct 2015 18:25:01 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IIP1nf060756; Sun, 18 Oct 2015 18:25:01 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IIP1bD060755; Sun, 18 Oct 2015 18:25:01 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201510181825.t9IIP1bD060755@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 18 Oct 2015 18:25:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289528 - head/cddl/contrib/opensolaris/lib/libzfs/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 18:25:02 -0000 Author: mav Date: Sun Oct 18 18:25:00 2015 New Revision: 289528 URL: https://svnweb.freebsd.org/changeset/base/289528 Log: Reduce diff from upstream. Should be no functional change. Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Sun Oct 18 18:08:33 2015 (r289527) +++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Sun Oct 18 18:25:00 2015 (r289528) @@ -3729,17 +3729,18 @@ zpool_history_unpack(char *buf, uint64_t int zpool_get_history(zpool_handle_t *zhp, nvlist_t **nvhisp) { - char *buf = NULL; - uint64_t bufsize = HIS_BUF_LEN_DEF; + char *buf; + uint64_t buflen = HIS_BUF_LEN_DEF; uint64_t off = 0; nvlist_t **records = NULL; uint_t numrecords = 0; int err, i; - if ((buf = malloc(bufsize)) == NULL) + buf = malloc(buflen); + if (buf == NULL) return (ENOMEM); do { - uint64_t bytes_read = bufsize; + uint64_t bytes_read = buflen; uint64_t leftover; if ((err = get_history(zhp, buf, &off, &bytes_read)) != 0) @@ -3753,18 +3754,16 @@ zpool_get_history(zpool_handle_t *zhp, n &leftover, &records, &numrecords)) != 0) break; off -= leftover; - - /* - * If the history block is too big, double the buffer - * size and try again. - */ if (leftover == bytes_read) { + /* + * no progress made, because buffer is not big enough + * to hold this record; resize and retry. + */ + buflen *= 2; free(buf); buf = NULL; - - bufsize <<= 1; - if ((bufsize >= HIS_BUF_LEN_MAX) || - ((buf = malloc(bufsize)) == NULL)) { + if ((buflen >= HIS_BUF_LEN_MAX) || + ((buf = malloc(buflen)) == NULL)) { err = ENOMEM; break; } @@ -3772,6 +3771,7 @@ zpool_get_history(zpool_handle_t *zhp, n /* CONSTCOND */ } while (1); + free(buf); if (!err) { From owner-svn-src-head@freebsd.org Sun Oct 18 18:26:20 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F05719D1B61; Sun, 18 Oct 2015 18:26:20 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B1EF098B; Sun, 18 Oct 2015 18:26:20 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IIQJQ1060844; Sun, 18 Oct 2015 18:26:19 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IIQJrA060841; Sun, 18 Oct 2015 18:26:19 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201510181826.t9IIQJrA060841@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 18 Oct 2015 18:26:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289529 - in head/sys: arm/arm arm/include conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 18:26:21 -0000 Author: ian Date: Sun Oct 18 18:26:19 2015 New Revision: 289529 URL: https://svnweb.freebsd.org/changeset/base/289529 Log: Import ARM_INTRNG, the "next generation" interrupt architecture for arm and armv6 architecures. The primary enhancement over the old design is support for hierarchical interrupt controllers (such as a gpio driver which can receive interrupts from a root PIC and act as a PIC itself for clients interested in handling a change of gpio pin state as an interrupt). The new code also provides an infrastructure for mapping interrupts described in metadata in the form of a "controller reference plus interrupt number" tuple into the simple "0-n" flat numeric space understood by rman and the bus resource mechanisms. Use of the new code is enabled by setting the ARM_INTRNG option, and by making a few simple changes to the platform's support code. In addition each existing PIC driver needs changes to be ready for INTRNG; this commit contains the changes for the arm/gic driver, which most armv6 SoCs use, but it does not enable the new code yet on any platform. This project has been many years in the making, starting as a GSoC project by Jakub Klama (jceel@) in 2012. That didn't get committed right away and the source base evolved out from under it to some degree. In 2014 I rebased the diffs to then -current and did some enhancements in the area of mapping interrupt numbers and storing associated fdt data, then the project went cold again for a while. Eventually Svata Kraus took that work in progress and did another big round of work on it, removing most of the remaining rough edges. Finally I took that and made one more pass through it, mostly disabling the "INTR_SOLO" feature for now, pending further design discussions on how to most efficiently dispatch a pending interrupt through more than one layer of PIC. The current code with the INTR_SOLO feature disabled uses approximate 100 extra cpu cycles for each cascaded PIC the interrupt has to be passed to, so what's left to do is about efficiency, not correct operation. Differential Revision: https://reviews.freebsd.org/D2047 Added: head/sys/arm/arm/intrng.c (contents, props changed) head/sys/arm/arm/pic_if.m (contents, props changed) Modified: head/sys/arm/arm/gic.c head/sys/arm/arm/mp_machdep.c head/sys/arm/arm/nexus.c head/sys/arm/include/fdt.h head/sys/arm/include/intr.h head/sys/arm/include/smp.h head/sys/conf/files.arm head/sys/conf/options.arm Modified: head/sys/arm/arm/gic.c ============================================================================== --- head/sys/arm/arm/gic.c Sun Oct 18 18:25:00 2015 (r289528) +++ head/sys/arm/arm/gic.c Sun Oct 18 18:26:19 2015 (r289529) @@ -34,18 +34,25 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_platform.h" + #include #include #include #include #include #include +#include #include #include #include #include #include #include +#include +#ifdef ARM_INTRNG +#include +#endif #include #include #include @@ -55,6 +62,10 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef ARM_INTRNG +#include "pic_if.h" +#endif + /* We are using GICv2 register naming */ /* Distributor Registers */ @@ -83,8 +94,8 @@ __FBSDID("$FreeBSD$"); #define GICC_ABPR 0x001C /* v1 ICCABPR */ #define GICC_IIDR 0x00FC /* v1 ICCIIDR*/ -#define GIC_FIRST_IPI 0 /* Irqs 0-15 are SGIs/IPIs. */ -#define GIC_LAST_IPI 15 +#define GIC_FIRST_SGI 0 /* Irqs 0-15 are SGIs/IPIs. */ +#define GIC_LAST_SGI 15 #define GIC_FIRST_PPI 16 /* Irqs 16-31 are private (per */ #define GIC_LAST_PPI 31 /* core) peripheral interrupts. */ #define GIC_FIRST_SPI 32 /* Irqs 32+ are shared peripherals. */ @@ -102,8 +113,18 @@ __FBSDID("$FreeBSD$"); #define GIC_DEFAULT_ICFGR_INIT 0x00000000 #endif +#ifdef ARM_INTRNG +static u_int gic_irq_cpu; +static int arm_gic_intr(void *); +static int arm_gic_bind(device_t dev, struct arm_irqsrc *isrc); +#endif + struct arm_gic_softc { device_t gic_dev; +#ifdef ARM_INTRNG + void * gic_intrhand; + struct arm_irqsrc ** gic_irqs; +#endif struct resource * gic_res[3]; bus_space_tag_t gic_c_bst; bus_space_tag_t gic_d_bst; @@ -117,10 +138,13 @@ struct arm_gic_softc { static struct resource_spec arm_gic_spec[] = { { SYS_RES_MEMORY, 0, RF_ACTIVE }, /* Distributor registers */ { SYS_RES_MEMORY, 1, RF_ACTIVE }, /* CPU Interrupt Intf. registers */ +#ifdef ARM_INTRNG + { SYS_RES_IRQ, 0, RF_ACTIVE | RF_OPTIONAL }, /* Parent interrupt */ +#endif { -1, 0 } }; -static struct arm_gic_softc *arm_gic_sc = NULL; +static struct arm_gic_softc *gic_sc = NULL; #define gic_c_read_4(_sc, _reg) \ bus_space_read_4((_sc)->gic_c_bst, (_sc)->gic_c_bsh, (_reg)) @@ -128,12 +152,16 @@ static struct arm_gic_softc *arm_gic_sc bus_space_write_4((_sc)->gic_c_bst, (_sc)->gic_c_bsh, (_reg), (_val)) #define gic_d_read_4(_sc, _reg) \ bus_space_read_4((_sc)->gic_d_bst, (_sc)->gic_d_bsh, (_reg)) +#define gic_d_write_1(_sc, _reg, _val) \ + bus_space_write_1((_sc)->gic_d_bst, (_sc)->gic_d_bsh, (_reg), (_val)) #define gic_d_write_4(_sc, _reg, _val) \ bus_space_write_4((_sc)->gic_d_bst, (_sc)->gic_d_bsh, (_reg), (_val)) +#ifndef ARM_INTRNG static int gic_config_irq(int irq, enum intr_trigger trig, enum intr_polarity pol); static void gic_post_filter(void *); +#endif static struct ofw_compat_data compat_data[] = { {"arm,gic", true}, /* Non-standard, used in FreeBSD dts. */ @@ -159,6 +187,72 @@ arm_gic_probe(device_t dev) return (BUS_PROBE_DEFAULT); } +#ifdef ARM_INTRNG +static inline void +gic_irq_unmask(struct arm_gic_softc *sc, u_int irq) +{ + + gic_d_write_4(sc, GICD_ISENABLER(irq >> 5), (1UL << (irq & 0x1F))); +} + +static inline void +gic_irq_mask(struct arm_gic_softc *sc, u_int irq) +{ + + gic_d_write_4(sc, GICD_ICENABLER(irq >> 5), (1UL << (irq & 0x1F))); +} +#endif + +#ifdef SMP +#ifdef ARM_INTRNG +static void +arm_gic_init_secondary(device_t dev) +{ + struct arm_gic_softc *sc = device_get_softc(dev); + struct arm_irqsrc *isrc; + u_int irq; + + for (irq = 0; irq < sc->nirqs; irq += 4) + gic_d_write_4(sc, GICD_IPRIORITYR(irq >> 2), 0); + + /* Set all the interrupts to be in Group 0 (secure) */ + for (irq = 0; irq < sc->nirqs; irq += 32) { + gic_d_write_4(sc, GICD_IGROUPR(irq >> 5), 0); + } + + /* Enable CPU interface */ + gic_c_write_4(sc, GICC_CTLR, 1); + + /* Set priority mask register. */ + gic_c_write_4(sc, GICC_PMR, 0xff); + + /* Enable interrupt distribution */ + gic_d_write_4(sc, GICD_CTLR, 0x01); + + /* Unmask attached SGI interrupts. */ + for (irq = GIC_FIRST_SGI; irq <= GIC_LAST_SGI; irq++) { + isrc = sc->gic_irqs[irq]; + if (isrc != NULL && isrc->isrc_handlers != 0) { + CPU_SET(PCPU_GET(cpuid), &isrc->isrc_cpu); + gic_irq_unmask(sc, irq); + } + } + + /* Unmask attached PPI interrupts. */ + for (irq = GIC_FIRST_PPI; irq <= GIC_LAST_PPI; irq++) { + isrc = sc->gic_irqs[irq]; + if (isrc == NULL || isrc->isrc_handlers == 0) + continue; + if (isrc->isrc_flags & ARM_ISRCF_BOUND) { + if (CPU_ISSET(PCPU_GET(cpuid), &isrc->isrc_cpu)) + gic_irq_unmask(sc, irq); + } else { + CPU_SET(PCPU_GET(cpuid), &isrc->isrc_cpu); + gic_irq_unmask(sc, irq); + } + } +} +#else static void arm_gic_init_secondary(device_t dev) { @@ -189,7 +283,10 @@ arm_gic_init_secondary(device_t dev) gic_d_write_4(sc, GICD_ISENABLER(29 >> 5), (1UL << (29 & 0x1F))); gic_d_write_4(sc, GICD_ISENABLER(30 >> 5), (1UL << (30 & 0x1F))); } - +#endif /* ARM_INTRNG */ +#endif /* SMP */ + +#ifndef ARM_INTRNG int gic_decode_fdt(uint32_t iparent, uint32_t *intr, int *interrupt, int *trig, int *pol) @@ -234,6 +331,19 @@ gic_decode_fdt(uint32_t iparent, uint32_ } return (0); } +#endif + +#ifdef ARM_INTRNG +static inline intptr_t +gic_xref(device_t dev) +{ +#ifdef FDT + return (OF_xref_from_node(ofw_bus_get_node(dev))); +#else + return (0); +#endif +} +#endif static int arm_gic_attach(device_t dev) @@ -241,8 +351,11 @@ arm_gic_attach(device_t dev) struct arm_gic_softc *sc; int i; uint32_t icciidr; +#ifdef ARM_INTRNG + intptr_t xref = gic_xref(dev); +#endif - if (arm_gic_sc) + if (gic_sc) return (ENXIO); sc = device_get_softc(dev); @@ -253,7 +366,7 @@ arm_gic_attach(device_t dev) } sc->gic_dev = dev; - arm_gic_sc = sc; + gic_sc = sc; /* Initialize mutex */ mtx_init(&sc->mutex, "GIC lock", "", MTX_SPIN); @@ -273,9 +386,14 @@ arm_gic_attach(device_t dev) sc->nirqs = gic_d_read_4(sc, GICD_TYPER); sc->nirqs = 32 * ((sc->nirqs & 0x1f) + 1); +#ifdef ARM_INTRNG + sc->gic_irqs = malloc(sc->nirqs * sizeof (*sc->gic_irqs), M_DEVBUF, + M_WAITOK | M_ZERO); +#else /* Set up function pointers */ arm_post_filter = gic_post_filter; arm_config_irq = gic_config_irq; +#endif icciidr = gic_c_read_4(sc, GICC_IIDR); device_printf(dev,"pn 0x%x, arch 0x%x, rev 0x%x, implementer 0x%x irqs %u\n", @@ -311,11 +429,456 @@ arm_gic_attach(device_t dev) /* Enable interrupt distribution */ gic_d_write_4(sc, GICD_CTLR, 0x01); +#ifndef ARM_INTRNG + return (0); +#else + /* + * Now, when everything is initialized, it's right time to + * register interrupt controller to interrupt framefork. + */ + if (arm_pic_register(dev, xref) != 0) { + device_printf(dev, "could not register PIC\n"); + goto cleanup; + } + + if (sc->gic_res[2] == NULL) { + if (arm_pic_claim_root(dev, xref, arm_gic_intr, sc, + GIC_LAST_SGI - GIC_FIRST_SGI + 1) != 0) { + device_printf(dev, "could not set PIC as a root\n"); + arm_pic_unregister(dev, xref); + goto cleanup; + } + } else { + if (bus_setup_intr(dev, sc->gic_res[2], INTR_TYPE_CLK, + arm_gic_intr, NULL, sc, &sc->gic_intrhand)) { + device_printf(dev, "could not setup irq handler\n"); + arm_pic_unregister(dev, xref); + goto cleanup; + } + } + + return (0); + +cleanup: + /* + * XXX - not implemented arm_gic_detach() should be called ! + */ + if (sc->gic_irqs != NULL) + free(sc->gic_irqs, M_DEVBUF); + bus_release_resources(dev, arm_gic_spec, sc->gic_res); + return(ENXIO); +#endif +} + +#ifdef ARM_INTRNG +static int +arm_gic_intr(void *arg) +{ + struct arm_gic_softc *sc = arg; + struct arm_irqsrc *isrc; + uint32_t irq_active_reg, irq; + struct trapframe *tf; + + irq_active_reg = gic_c_read_4(sc, GICC_IAR); + irq = irq_active_reg & 0x3FF; + + /* + * 1. We do EOI here because recent read value from active interrupt + * register must be used for it. Another approach is to save this + * value into associated interrupt source. + * 2. EOI must be done on same CPU where interrupt has fired. Thus + * we must ensure that interrupted thread does not migrate to + * another CPU. + * 3. EOI cannot be delayed by any preemption which could happen on + * critical_exit() used in MI intr code, when interrupt thread is + * scheduled. See next point. + * 4. IPI_RENDEZVOUS assumes that no preemption is permitted during + * an action and any use of critical_exit() could break this + * assumption. See comments within smp_rendezvous_action(). + * 5. We always return FILTER_HANDLED as this is an interrupt + * controller dispatch function. Otherwise, in cascaded interrupt + * case, the whole interrupt subtree would be masked. + */ + + if (irq >= sc->nirqs) { + device_printf(sc->gic_dev, "Spurious interrupt detected\n"); + gic_c_write_4(sc, GICC_EOIR, irq_active_reg); + return (FILTER_HANDLED); + } + + tf = curthread->td_intr_frame; +dispatch_irq: + isrc = sc->gic_irqs[irq]; + if (isrc == NULL) { + device_printf(sc->gic_dev, "Stray interrupt %u detected\n", irq); + gic_irq_mask(sc, irq); + gic_c_write_4(sc, GICC_EOIR, irq_active_reg); + goto next_irq; + } + + /* + * Note that GIC_FIRST_SGI is zero and is not used in 'if' statement + * as compiler complains that comparing u_int >= 0 is always true. + */ + if (irq <= GIC_LAST_SGI) { +#ifdef SMP + /* Call EOI for all IPI before dispatch. */ + gic_c_write_4(sc, GICC_EOIR, irq_active_reg); + arm_ipi_dispatch(isrc, tf); + goto next_irq; +#else + printf("SGI %u on UP system detected\n", irq - GIC_FIRST_SGI); + gic_c_write_4(sc, GICC_EOIR, irq_active_reg); + goto next_irq; +#endif + } + + if (isrc->isrc_trig == INTR_TRIGGER_EDGE) + gic_c_write_4(sc, GICC_EOIR, irq_active_reg); + + arm_irq_dispatch(isrc, tf); + +next_irq: +// arm_irq_memory_barrier(irq); /* XXX */ +// irq_active_reg = gic_c_read_4(sc, GICC_IAR); +// irq = irq_active_reg & 0x3FF; + if (0 && irq < sc->nirqs) + goto dispatch_irq; + + return (FILTER_HANDLED); +} + +static int +gic_attach_isrc(struct arm_gic_softc *sc, struct arm_irqsrc *isrc, u_int irq) +{ + const char *name; + + /* + * 1. The link between ISRC and controller must be set atomically. + * 2. Just do things only once in rare case when consumers + * of shared interrupt came here at the same moment. + */ + mtx_lock_spin(&sc->mutex); + if (sc->gic_irqs[irq] != NULL) { + mtx_unlock_spin(&sc->mutex); + return (sc->gic_irqs[irq] == isrc ? 0 : EEXIST); + } + sc->gic_irqs[irq] = isrc; + isrc->isrc_data = irq; + mtx_unlock_spin(&sc->mutex); + + name = device_get_nameunit(sc->gic_dev); + if (irq <= GIC_LAST_SGI) + arm_irq_set_name(isrc, "%s,i%u", name, irq - GIC_FIRST_SGI); + else if (irq <= GIC_LAST_PPI) + arm_irq_set_name(isrc, "%s,p%u", name, irq - GIC_FIRST_PPI); + else + arm_irq_set_name(isrc, "%s,s%u", name, irq - GIC_FIRST_SPI); + return (0); +} + +static int +gic_detach_isrc(struct arm_gic_softc *sc, struct arm_irqsrc *isrc, u_int irq) +{ + + mtx_lock_spin(&sc->mutex); + if (sc->gic_irqs[irq] != isrc) { + mtx_unlock_spin(&sc->mutex); + return (sc->gic_irqs[irq] == NULL ? 0 : EINVAL); + } + sc->gic_irqs[irq] = NULL; + isrc->isrc_data = 0; + mtx_unlock_spin(&sc->mutex); + + arm_irq_set_name(isrc, ""); + return (0); +} + +static void +gic_config(struct arm_gic_softc *sc, u_int irq, enum intr_trigger trig, + enum intr_polarity pol) +{ + uint32_t reg; + uint32_t mask; + + if (irq < GIC_FIRST_SPI) + return; + + mtx_lock_spin(&sc->mutex); + + reg = gic_d_read_4(sc, GICD_ICFGR(irq >> 4)); + mask = (reg >> 2*(irq % 16)) & 0x3; + + if (pol == INTR_POLARITY_LOW) { + mask &= ~GICD_ICFGR_POL_MASK; + mask |= GICD_ICFGR_POL_LOW; + } else if (pol == INTR_POLARITY_HIGH) { + mask &= ~GICD_ICFGR_POL_MASK; + mask |= GICD_ICFGR_POL_HIGH; + } + + if (trig == INTR_TRIGGER_LEVEL) { + mask &= ~GICD_ICFGR_TRIG_MASK; + mask |= GICD_ICFGR_TRIG_LVL; + } else if (trig == INTR_TRIGGER_EDGE) { + mask &= ~GICD_ICFGR_TRIG_MASK; + mask |= GICD_ICFGR_TRIG_EDGE; + } + + /* Set mask */ + reg = reg & ~(0x3 << 2*(irq % 16)); + reg = reg | (mask << 2*(irq % 16)); + gic_d_write_4(sc, GICD_ICFGR(irq >> 4), reg); + + mtx_unlock_spin(&sc->mutex); +} +static int +gic_bind(struct arm_gic_softc *sc, u_int irq, cpuset_t *cpus) +{ + uint32_t cpu, end, mask; + + end = min(mp_ncpus, 8); + for (cpu = end; cpu < MAXCPU; cpu++) + if (CPU_ISSET(cpu, cpus)) + return (EINVAL); + + for (mask = 0, cpu = 0; cpu < end; cpu++) + if (CPU_ISSET(cpu, cpus)) + mask |= 1 << cpu; + + gic_d_write_1(sc, GICD_ITARGETSR(0) + irq, mask); return (0); } static int +gic_irq_from_nspc(struct arm_gic_softc *sc, u_int type, u_int num, u_int *irqp) +{ + + switch (type) { + case ARM_IRQ_NSPC_PLAIN: + *irqp = num; + return (*irqp < sc->nirqs ? 0 : EINVAL); + + case ARM_IRQ_NSPC_IRQ: + *irqp = num + GIC_FIRST_PPI; + return (*irqp < sc->nirqs ? 0 : EINVAL); + + case ARM_IRQ_NSPC_IPI: + *irqp = num + GIC_FIRST_SGI; + return (*irqp < GIC_LAST_SGI ? 0 : EINVAL); + + default: + return (EINVAL); + } +} + +static int +gic_map_nspc(struct arm_gic_softc *sc, struct arm_irqsrc *isrc, u_int *irqp) +{ + int error; + + error = gic_irq_from_nspc(sc, isrc->isrc_nspc_type, isrc->isrc_nspc_num, + irqp); + if (error != 0) + return (error); + return (gic_attach_isrc(sc, isrc, *irqp)); +} + +#ifdef FDT +static int +gic_map_fdt(struct arm_gic_softc *sc, struct arm_irqsrc *isrc, u_int *irqp) +{ + u_int irq, tripol; + enum intr_trigger trig; + enum intr_polarity pol; + int error; + + if (isrc->isrc_ncells == 1) { + irq = isrc->isrc_cells[0]; + pol = INTR_POLARITY_CONFORM; + trig = INTR_TRIGGER_CONFORM; + } else if (isrc->isrc_ncells == 3) { + if (isrc->isrc_cells[0] == 0) + irq = isrc->isrc_cells[1] + GIC_FIRST_SPI; + else + irq = isrc->isrc_cells[1] + GIC_FIRST_PPI; + + /* + * In intr[2], bits[3:0] are trigger type and level flags. + * 1 = low-to-high edge triggered + * 2 = high-to-low edge triggered + * 4 = active high level-sensitive + * 8 = active low level-sensitive + * The hardware only supports active-high-level or rising-edge. + */ + tripol = isrc->isrc_cells[2]; + if (tripol & 0x0a) { + printf("unsupported trigger/polarity configuration " + "0x%2x\n", tripol & 0x0f); + return (ENOTSUP); + } + pol = INTR_POLARITY_CONFORM; + if (tripol & 0x01) + trig = INTR_TRIGGER_EDGE; + else + trig = INTR_TRIGGER_LEVEL; + } else + return (EINVAL); + + if (irq >= sc->nirqs) + return (EINVAL); + + error = gic_attach_isrc(sc, isrc, irq); + if (error != 0) + return (error); + + isrc->isrc_nspc_type = ARM_IRQ_NSPC_PLAIN; + isrc->isrc_nspc_num = irq; + isrc->isrc_trig = trig; + isrc->isrc_pol = pol; + + *irqp = irq; + return (0); +} +#endif + +static int +arm_gic_register(device_t dev, struct arm_irqsrc *isrc, boolean_t *is_percpu) +{ + struct arm_gic_softc *sc = device_get_softc(dev); + u_int irq; + int error; + + if (isrc->isrc_type == ARM_ISRCT_NAMESPACE) + error = gic_map_nspc(sc, isrc, &irq); +#ifdef FDT + else if (isrc->isrc_type == ARM_ISRCT_FDT) + error = gic_map_fdt(sc, isrc, &irq); +#endif + else + return (EINVAL); + + if (error == 0) + *is_percpu = irq < GIC_FIRST_SPI ? TRUE : FALSE; + return (error); +} + +static void +arm_gic_enable_intr(device_t dev, struct arm_irqsrc *isrc) +{ + struct arm_gic_softc *sc = device_get_softc(dev); + u_int irq = isrc->isrc_data; + + if (isrc->isrc_trig == INTR_TRIGGER_CONFORM) + isrc->isrc_trig = INTR_TRIGGER_LEVEL; + + /* + * XXX - In case that per CPU interrupt is going to be enabled in time + * when SMP is already started, we need some IPI call which + * enables it on others CPUs. Further, it's more complicated as + * pic_enable_source() and pic_disable_source() should act on + * per CPU basis only. Thus, it should be solved here somehow. + */ + if (isrc->isrc_flags & ARM_ISRCF_PERCPU) + CPU_SET(PCPU_GET(cpuid), &isrc->isrc_cpu); + + gic_config(sc, irq, isrc->isrc_trig, isrc->isrc_pol); + arm_gic_bind(dev, isrc); +} + +static void +arm_gic_enable_source(device_t dev, struct arm_irqsrc *isrc) +{ + struct arm_gic_softc *sc = device_get_softc(dev); + u_int irq = isrc->isrc_data; + + arm_irq_memory_barrier(irq); + gic_irq_unmask(sc, irq); +} + +static void +arm_gic_disable_source(device_t dev, struct arm_irqsrc *isrc) +{ + struct arm_gic_softc *sc = device_get_softc(dev); + u_int irq = isrc->isrc_data; + + gic_irq_mask(sc, irq); +} + +static int +arm_gic_unregister(device_t dev, struct arm_irqsrc *isrc) +{ + struct arm_gic_softc *sc = device_get_softc(dev); + u_int irq = isrc->isrc_data; + + return (gic_detach_isrc(sc, isrc, irq)); +} + +static void +arm_gic_pre_ithread(device_t dev, struct arm_irqsrc *isrc) +{ + struct arm_gic_softc *sc = device_get_softc(dev); + + arm_gic_disable_source(dev, isrc); + gic_c_write_4(sc, GICC_EOIR, isrc->isrc_data); +} + +static void +arm_gic_post_ithread(device_t dev, struct arm_irqsrc *isrc) +{ + + arm_irq_memory_barrier(0); + arm_gic_enable_source(dev, isrc); +} + +static void +arm_gic_post_filter(device_t dev, struct arm_irqsrc *isrc) +{ + struct arm_gic_softc *sc = device_get_softc(dev); + + /* EOI for edge-triggered done earlier. */ + if (isrc->isrc_trig == INTR_TRIGGER_EDGE) + return; + + arm_irq_memory_barrier(0); + gic_c_write_4(sc, GICC_EOIR, isrc->isrc_data); +} + +#ifdef SMP +static int +arm_gic_bind(device_t dev, struct arm_irqsrc *isrc) +{ + struct arm_gic_softc *sc = device_get_softc(dev); + uint32_t irq = isrc->isrc_data; + + if (irq < GIC_FIRST_SPI) + return (EINVAL); + + if (CPU_EMPTY(&isrc->isrc_cpu)) { + gic_irq_cpu = arm_irq_next_cpu(gic_irq_cpu, &all_cpus); + CPU_SETOF(gic_irq_cpu, &isrc->isrc_cpu); + } + return (gic_bind(sc, irq, &isrc->isrc_cpu)); +} + +static void +arm_gic_ipi_send(device_t dev, struct arm_irqsrc *isrc, cpuset_t cpus) +{ + struct arm_gic_softc *sc = device_get_softc(dev); + uint32_t irq, val = 0, i; + + irq = isrc->isrc_data; + + for (i = 0; i < MAXCPU; i++) + if (CPU_ISSET(i, &cpus)) + val |= 1 << (16 + i); + + gic_d_write_4(sc, GICD_SGIR(0), val | irq); +} +#endif +#else +static int arm_gic_next_irq(struct arm_gic_softc *sc, int last_irq) { uint32_t active_irq; @@ -327,7 +890,7 @@ arm_gic_next_irq(struct arm_gic_softc *s * bits (ie CPU number), not just the IRQ number, and we do not * have this information later. */ - if ((active_irq & 0x3ff) <= GIC_LAST_IPI) + if ((active_irq & 0x3ff) <= GIC_LAST_SGI) gic_c_write_4(sc, GICC_EOIR, active_irq); active_irq &= 0x3FF; @@ -400,7 +963,7 @@ arm_gic_mask(device_t dev, int irq) struct arm_gic_softc *sc = device_get_softc(dev); gic_d_write_4(sc, GICD_ICENABLER(irq >> 5), (1UL << (irq & 0x1F))); - gic_c_write_4(sc, GICC_EOIR, irq); + gic_c_write_4(sc, GICC_EOIR, irq); /* XXX - not allowed */ } static void @@ -408,7 +971,7 @@ arm_gic_unmask(device_t dev, int irq) { struct arm_gic_softc *sc = device_get_softc(dev); - if (irq > GIC_LAST_IPI) + if (irq > GIC_LAST_SGI) arm_irq_memory_barrier(irq); gic_d_write_4(sc, GICD_ISENABLER(irq >> 5), (1UL << (irq & 0x1F))); @@ -455,10 +1018,10 @@ arm_gic_ipi_clear(device_t dev, int ipi) static void gic_post_filter(void *arg) { - struct arm_gic_softc *sc = arm_gic_sc; + struct arm_gic_softc *sc = gic_sc; uintptr_t irq = (uintptr_t) arg; - if (irq > GIC_LAST_IPI) + if (irq > GIC_LAST_SGI) arm_irq_memory_barrier(irq); gic_c_write_4(sc, GICC_EOIR, irq); } @@ -467,64 +1030,81 @@ static int gic_config_irq(int irq, enum intr_trigger trig, enum intr_polarity pol) { - return (arm_gic_config(arm_gic_sc->gic_dev, irq, trig, pol)); + return (arm_gic_config(gic_sc->gic_dev, irq, trig, pol)); } void arm_mask_irq(uintptr_t nb) { - arm_gic_mask(arm_gic_sc->gic_dev, nb); + arm_gic_mask(gic_sc->gic_dev, nb); } void arm_unmask_irq(uintptr_t nb) { - arm_gic_unmask(arm_gic_sc->gic_dev, nb); + arm_gic_unmask(gic_sc->gic_dev, nb); } int arm_get_next_irq(int last_irq) { - return (arm_gic_next_irq(arm_gic_sc, last_irq)); + return (arm_gic_next_irq(gic_sc, last_irq)); } +#ifdef SMP void arm_pic_init_secondary(void) { - arm_gic_init_secondary(arm_gic_sc->gic_dev); + arm_gic_init_secondary(gic_sc->gic_dev); } -#ifdef SMP void pic_ipi_send(cpuset_t cpus, u_int ipi) { - arm_gic_ipi_send(arm_gic_sc->gic_dev, cpus, ipi); + arm_gic_ipi_send(gic_sc->gic_dev, cpus, ipi); } int pic_ipi_read(int i) { - return (arm_gic_ipi_read(arm_gic_sc->gic_dev, i)); + return (arm_gic_ipi_read(gic_sc->gic_dev, i)); } void pic_ipi_clear(int ipi) { - arm_gic_ipi_clear(arm_gic_sc->gic_dev, ipi); + arm_gic_ipi_clear(gic_sc->gic_dev, ipi); } #endif +#endif /* ARM_INTRNG */ static device_method_t arm_gic_methods[] = { /* Device interface */ DEVMETHOD(device_probe, arm_gic_probe), DEVMETHOD(device_attach, arm_gic_attach), +#ifdef ARM_INTRNG + /* Interrupt controller interface */ + DEVMETHOD(pic_disable_source, arm_gic_disable_source), + DEVMETHOD(pic_enable_intr, arm_gic_enable_intr), + DEVMETHOD(pic_enable_source, arm_gic_enable_source), + DEVMETHOD(pic_post_filter, arm_gic_post_filter), + DEVMETHOD(pic_post_ithread, arm_gic_post_ithread), + DEVMETHOD(pic_pre_ithread, arm_gic_pre_ithread), + DEVMETHOD(pic_register, arm_gic_register), + DEVMETHOD(pic_unregister, arm_gic_unregister), +#ifdef SMP + DEVMETHOD(pic_bind, arm_gic_bind), + DEVMETHOD(pic_init_secondary, arm_gic_init_secondary), + DEVMETHOD(pic_ipi_send, arm_gic_ipi_send), +#endif +#endif { 0, 0 } }; Added: head/sys/arm/arm/intrng.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm/arm/intrng.c Sun Oct 18 18:26:19 2015 (r289529) @@ -0,0 +1,1458 @@ +/*- + * Copyright (c) 2012-2014 Jakub Wojciech Klama . + * Copyright (c) 2015 Svatopluk Kraus + * Copyright (c) 2015 Michal Meloun + * 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$ + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * ARM Interrupt Framework + * + * TODO: - to support IPI (PPI) enabling on other CPUs if already started + * - to complete things for removable PICs + */ + +#include "opt_ddb.h" +#include "opt_platform.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#ifdef DDB +#include +#endif + +#include "pic_if.h" + +#define INTRNAME_LEN (2*MAXCOMLEN + 1) + +#ifdef DEBUG +#define debugf(fmt, args...) do { printf("%s(): ", __func__); \ + printf(fmt,##args); } while (0) +#else +#define debugf(fmt, args...) +#endif + +MALLOC_DECLARE(M_INTRNG); +MALLOC_DEFINE(M_INTRNG, "intrng", "ARM interrupt handling"); + +/* Main ARM interrupt handler called from assembler -> 'hidden' for C code. */ +void arm_irq_handler(struct trapframe *tf); + +/* Root interrupt controller stuff. */ +static struct arm_irqsrc *irq_root_isrc; +static device_t irq_root_dev; +static arm_irq_filter_t *irq_root_filter; +static void *irq_root_arg; +static u_int irq_root_ipicount; + +/* Interrupt controller definition. */ +struct arm_pic { + SLIST_ENTRY(arm_pic) pic_next; + intptr_t pic_xref; /* hardware identification */ + device_t pic_dev; +}; + +static struct mtx pic_list_lock; +static SLIST_HEAD(, arm_pic) pic_list; + +static struct arm_pic *pic_lookup(device_t dev, intptr_t xref); + +/* Interrupt source definition. */ +static struct mtx isrc_table_lock; +static struct arm_irqsrc *irq_sources[NIRQ]; +u_int irq_next_free; + +#define IRQ_INVALID nitems(irq_sources) + +#ifdef SMP +static boolean_t irq_assign_cpu = FALSE; + +static struct arm_irqsrc ipi_sources[ARM_IPI_COUNT]; +static u_int ipi_next_num; +#endif + +/* + * - 2 counters for each I/O interrupt. + * - MAXCPU counters for each IPI counters for SMP. + */ +#ifdef SMP +#define INTRCNT_COUNT (NIRQ * 2 + ARM_IPI_COUNT * MAXCPU) +#else +#define INTRCNT_COUNT (NIRQ * 2) +#endif + +/* Data for MI statistics reporting. */ +u_long intrcnt[INTRCNT_COUNT]; +char intrnames[INTRCNT_COUNT * INTRNAME_LEN]; +size_t sintrcnt = sizeof(intrcnt); +size_t sintrnames = sizeof(intrnames); +static u_int intrcnt_index; + +/* + * Interrupt framework initialization routine. + */ +static void +arm_irq_init(void *dummy __unused) +{ + + SLIST_INIT(&pic_list); + mtx_init(&pic_list_lock, "arm pic list", NULL, MTX_DEF); + mtx_init(&isrc_table_lock, "arm isrc table", NULL, MTX_DEF); +} +SYSINIT(arm_irq_init, SI_SUB_INTR, SI_ORDER_FIRST, arm_irq_init, NULL); + +static void +intrcnt_setname(const char *name, int index) +{ + + snprintf(intrnames + INTRNAME_LEN * index, INTRNAME_LEN, "%-*s", + INTRNAME_LEN - 1, name); +} + +/* + * Update name for interrupt source with interrupt event. + */ +static void +intrcnt_updatename(struct arm_irqsrc *isrc) +{ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Sun Oct 18 18:32:23 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8AA279D1E02; Sun, 18 Oct 2015 18:32:23 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 50DF6FF3; Sun, 18 Oct 2015 18:32:23 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IIWMVX063801; Sun, 18 Oct 2015 18:32:22 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IIWMWM063800; Sun, 18 Oct 2015 18:32:22 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201510181832.t9IIWMWM063800@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 18 Oct 2015 18:32:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289531 - head/cddl/contrib/opensolaris/lib/libzfs/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 18:32:23 -0000 Author: mav Date: Sun Oct 18 18:32:22 2015 New Revision: 289531 URL: https://svnweb.freebsd.org/changeset/base/289531 Log: MFV r289530: 5847 libzfs_diff should check zfs_prop_get() return Reviewed by: Matthew Ahrens Reviewed by: Albert Lee Approved by: Dan McDonald Author: Alexander Eremin illumos/illumos-gate@8430278980a48338e04c7dd52b495b7f1551367a Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c Directory Properties: head/cddl/contrib/opensolaris/ (props changed) head/cddl/contrib/opensolaris/lib/libzfs/ (props changed) Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c Sun Oct 18 18:30:47 2015 (r289530) +++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c Sun Oct 18 18:32:22 2015 (r289531) @@ -21,6 +21,7 @@ /* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2015 Nexenta Systems, Inc. All rights reserved. */ /* @@ -624,9 +625,12 @@ get_snapshot_names(differ_info_t *di, co zhp = zfs_open(hdl, di->ds, ZFS_TYPE_FILESYSTEM); while (zhp != NULL) { - (void) zfs_prop_get(zhp, ZFS_PROP_ORIGIN, - origin, sizeof (origin), &src, NULL, 0, B_FALSE); - + if (zfs_prop_get(zhp, ZFS_PROP_ORIGIN, origin, + sizeof (origin), &src, NULL, 0, B_FALSE) != 0) { + (void) zfs_close(zhp); + zhp = NULL; + break; + } if (strncmp(origin, fromsnap, fsnlen) == 0) break; From owner-svn-src-head@freebsd.org Sun Oct 18 18:39:18 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 78522A18026; Sun, 18 Oct 2015 18:39:18 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 42F72144B; Sun, 18 Oct 2015 18:39:18 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IIdHgu064078; Sun, 18 Oct 2015 18:39:17 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IIdHOJ064075; Sun, 18 Oct 2015 18:39:17 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201510181839.t9IIdHOJ064075@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 18 Oct 2015 18:39:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289532 - in head/sys/arm: conf ti ti/omap4 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 18:39:18 -0000 Author: ian Date: Sun Oct 18 18:39:16 2015 New Revision: 289532 URL: https://svnweb.freebsd.org/changeset/base/289532 Log: Enable ARM_INTRNG on the pandaboard platform. Differential Revision: https://reviews.freebsd.org/D2048 Modified: head/sys/arm/conf/PANDABOARD head/sys/arm/ti/omap4/std.omap4 head/sys/arm/ti/ti_common.c Modified: head/sys/arm/conf/PANDABOARD ============================================================================== --- head/sys/arm/conf/PANDABOARD Sun Oct 18 18:32:22 2015 (r289531) +++ head/sys/arm/conf/PANDABOARD Sun Oct 18 18:39:16 2015 (r289532) @@ -30,6 +30,8 @@ hints "PANDABOARD.hints" include "std.armv6" include "../ti/omap4/pandaboard/std.pandaboard" +options ARM_INTRNG # new interrupt framework + options HZ=100 options SCHED_ULE # ULE scheduler options PLATFORM Modified: head/sys/arm/ti/omap4/std.omap4 ============================================================================== --- head/sys/arm/ti/omap4/std.omap4 Sun Oct 18 18:32:22 2015 (r289531) +++ head/sys/arm/ti/omap4/std.omap4 Sun Oct 18 18:39:16 2015 (r289532) @@ -17,7 +17,3 @@ makeoptions KERNVIRTADDR=0xc0200000 options SOC_OMAP4 options ARM_L2_PIPT - -options IPI_IRQ_START=0 -options IPI_IRQ_END=15 - Modified: head/sys/arm/ti/ti_common.c ============================================================================== --- head/sys/arm/ti/ti_common.c Sun Oct 18 18:32:22 2015 (r289531) +++ head/sys/arm/ti/ti_common.c Sun Oct 18 18:39:16 2015 (r289532) @@ -70,7 +70,7 @@ fdt_aintc_decode_ic(phandle_t node, pcel #endif fdt_pic_decode_t fdt_pic_table[] = { -#ifdef SOC_OMAP4 +#if defined(SOC_OMAP4) && !defined(ARM_INTRNG) &gic_decode_fdt, #endif #ifdef SOC_TI_AM335X From owner-svn-src-head@freebsd.org Sun Oct 18 18:40:12 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7136EA1808F; Sun, 18 Oct 2015 18:40:12 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 39B5B1617; Sun, 18 Oct 2015 18:40:12 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IIeBqL064164; Sun, 18 Oct 2015 18:40:11 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IIeBkN064163; Sun, 18 Oct 2015 18:40:11 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201510181840.t9IIeBkN064163@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Sun, 18 Oct 2015 18:40:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289533 - head/sys/mips/conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 18:40:12 -0000 Author: sbruno Date: Sun Oct 18 18:40:11 2015 New Revision: 289533 URL: https://svnweb.freebsd.org/changeset/base/289533 Log: Add VM_KMEM_SIZE_SCALE=1 as these systems are going to have super small amount of RAM, e.g. 16M or 32M Reviewed by: adrian Modified: head/sys/mips/conf/AR933X_BASE Modified: head/sys/mips/conf/AR933X_BASE ============================================================================== --- head/sys/mips/conf/AR933X_BASE Sun Oct 18 18:39:16 2015 (r289532) +++ head/sys/mips/conf/AR933X_BASE Sun Oct 18 18:40:11 2015 (r289533) @@ -40,6 +40,9 @@ options SCSI_NO_OP_STRINGS # .. And no sysctl strings options NO_SYSCTL_DESCR +# For small memory footprints +options VM_KMEM_SIZE_SCALE=1 + # Limit IO size options NBUF=128 From owner-svn-src-head@freebsd.org Sun Oct 18 18:41:32 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 557C5A18132; Sun, 18 Oct 2015 18:41:32 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2091019D7; Sun, 18 Oct 2015 18:41:32 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IIfV5H066047; Sun, 18 Oct 2015 18:41:31 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IIfVoT066046; Sun, 18 Oct 2015 18:41:31 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201510181841.t9IIfVoT066046@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Sun, 18 Oct 2015 18:41:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289534 - head/sys/mips/conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 18:41:32 -0000 Author: sbruno Date: Sun Oct 18 18:41:30 2015 New Revision: 289534 URL: https://svnweb.freebsd.org/changeset/base/289534 Log: Remove geom_uncompress from TP-MR3020 config. Its now using root on USB and there's no need for it now. Modified: head/sys/mips/conf/TP-MR3020 Modified: head/sys/mips/conf/TP-MR3020 ============================================================================== --- head/sys/mips/conf/TP-MR3020 Sun Oct 18 18:40:11 2015 (r289533) +++ head/sys/mips/conf/TP-MR3020 Sun Oct 18 18:41:30 2015 (r289534) @@ -44,9 +44,6 @@ device arswitch # redboot stuff. options AR71XX_ENV_UBOOT -# uzip - to boot natively from flash -device geom_uncompress - # Used for the static uboot partition map device geom_map From owner-svn-src-head@freebsd.org Sun Oct 18 19:05:57 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BDF15A186A1; Sun, 18 Oct 2015 19:05:57 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 99CAC6A2; Sun, 18 Oct 2015 19:05:57 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IJ5ueb072466; Sun, 18 Oct 2015 19:05:56 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IJ5uEI072465; Sun, 18 Oct 2015 19:05:56 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201510181905.t9IJ5uEI072465@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 18 Oct 2015 19:05:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289536 - head/cddl/contrib/opensolaris/cmd/zpool X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 19:05:57 -0000 Author: mav Date: Sun Oct 18 19:05:56 2015 New Revision: 289536 URL: https://svnweb.freebsd.org/changeset/base/289536 Log: MFV r289535: 5767 fix several problems with zfs test suite Reviewed by: Matthew Ahrens Reviewed by: Christopher Siden Approved by: Gordon Ross Author: John Wren Kennedy illumos/illumos-gate@52244c0958bdf281ca42932b449f644b4decfdc2 In fact, only unrelated part of that commit is applicable: 8. zpool list -v doesn't print spares It also doesn't correctly identify log devices. Modified: head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Directory Properties: head/cddl/contrib/opensolaris/ (props changed) Modified: head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c ============================================================================== --- head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Sun Oct 18 18:56:48 2015 (r289535) +++ head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Sun Oct 18 19:05:56 2015 (r289536) @@ -2940,6 +2940,9 @@ print_list_stats(zpool_handle_t *zhp, co uint_t c, children; char *vname; boolean_t scripted = cb->cb_scripted; + uint64_t islog = B_FALSE; + boolean_t haslog = B_FALSE; + char *dashes = "%-*s - - - - - -\n"; verify(nvlist_lookup_uint64_array(nv, ZPOOL_CONFIG_VDEV_STATS, (uint64_t **)&vs, &c) == 0); @@ -2990,24 +2993,47 @@ print_list_stats(zpool_handle_t *zhp, co ZPOOL_CONFIG_IS_HOLE, &ishole) == 0 && ishole) continue; + if (nvlist_lookup_uint64(child[c], + ZPOOL_CONFIG_IS_LOG, &islog) == 0 && islog) { + haslog = B_TRUE; + continue; + } + vname = zpool_vdev_name(g_zfs, zhp, child[c], B_FALSE); print_list_stats(zhp, vname, child[c], cb, depth + 2); free(vname); } - /* - * Include level 2 ARC devices in iostat output - */ + if (haslog == B_TRUE) { + /* LINTED E_SEC_PRINTF_VAR_FMT */ + (void) printf(dashes, cb->cb_namewidth, "log"); + for (c = 0; c < children; c++) { + if (nvlist_lookup_uint64(child[c], ZPOOL_CONFIG_IS_LOG, + &islog) != 0 || !islog) + continue; + vname = zpool_vdev_name(g_zfs, zhp, child[c], B_FALSE); + print_list_stats(zhp, vname, child[c], cb, depth + 2); + free(vname); + } + } + if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_L2CACHE, - &child, &children) != 0) - return; + &child, &children) == 0 && children > 0) { + /* LINTED E_SEC_PRINTF_VAR_FMT */ + (void) printf(dashes, cb->cb_namewidth, "cache"); + for (c = 0; c < children; c++) { + vname = zpool_vdev_name(g_zfs, zhp, child[c], B_FALSE); + print_list_stats(zhp, vname, child[c], cb, depth + 2); + free(vname); + } + } - if (children > 0) { - (void) printf("%-*s - - - - - " - "-\n", cb->cb_namewidth, "cache"); + if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_SPARES, &child, + &children) == 0 && children > 0) { + /* LINTED E_SEC_PRINTF_VAR_FMT */ + (void) printf(dashes, cb->cb_namewidth, "spare"); for (c = 0; c < children; c++) { - vname = zpool_vdev_name(g_zfs, zhp, child[c], - B_FALSE); + vname = zpool_vdev_name(g_zfs, zhp, child[c], B_FALSE); print_list_stats(zhp, vname, child[c], cb, depth + 2); free(vname); } From owner-svn-src-head@freebsd.org Sun Oct 18 19:54:12 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 728EDA1811C; Sun, 18 Oct 2015 19:54:12 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3D7B2C2D; Sun, 18 Oct 2015 19:54:12 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IJsBI2086920; Sun, 18 Oct 2015 19:54:11 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IJsBKJ086917; Sun, 18 Oct 2015 19:54:11 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201510181954.t9IJsBKJ086917@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 18 Oct 2015 19:54:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289537 - in head/sys/arm: conf freescale/imx X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 19:54:12 -0000 Author: ian Date: Sun Oct 18 19:54:11 2015 New Revision: 289537 URL: https://svnweb.freebsd.org/changeset/base/289537 Log: Enable ARM_INTRNG on IMX6 platforms, and make the imx_gpio driver an interrupt controller. The latter is required for INTRNG, because of the hardware erratum workaround installed by the linux folks into the imx6 FDT data, which remaps an ethernet interrupt to the gpio device. In the non-INTRNG world we intercept the call to map the interrupt and map it back to the ethernet hardware (because we don't need linux's workaround), but in the INTRNG world we lose the hookpoint where that remapping was happening, but we gain the ability to work the way linux does by having the gpio driver dispatch the interrupt. Modified: head/sys/arm/conf/IMX6 head/sys/arm/freescale/imx/imx6_machdep.c head/sys/arm/freescale/imx/imx_gpio.c Modified: head/sys/arm/conf/IMX6 ============================================================================== --- head/sys/arm/conf/IMX6 Sun Oct 18 19:05:56 2015 (r289536) +++ head/sys/arm/conf/IMX6 Sun Oct 18 19:54:11 2015 (r289537) @@ -22,6 +22,8 @@ ident IMX6 include "std.armv6" include "../freescale/imx/std.imx6" +options ARM_INTRNG + options SOC_IMX6 options HZ=500 # Scheduling quantum is 2 milliseconds. Modified: head/sys/arm/freescale/imx/imx6_machdep.c ============================================================================== --- head/sys/arm/freescale/imx/imx6_machdep.c Sun Oct 18 19:05:56 2015 (r289536) +++ head/sys/arm/freescale/imx/imx6_machdep.c Sun Oct 18 19:54:11 2015 (r289537) @@ -58,6 +58,7 @@ struct fdt_fixup_entry fdt_fixup_table[] static uint32_t gpio1_node; +#ifndef ARM_INTRNG /* * Work around the linux workaround for imx6 erratum 006687, in which some * ethernet interrupts don't go to the GPC and thus won't wake the system from @@ -91,6 +92,7 @@ fdt_pic_decode_t fdt_pic_table[] = { &imx6_decode_fdt, NULL }; +#endif static vm_offset_t imx6_lastaddr(platform_t plat) Modified: head/sys/arm/freescale/imx/imx_gpio.c ============================================================================== --- head/sys/arm/freescale/imx/imx_gpio.c Sun Oct 18 19:05:56 2015 (r289536) +++ head/sys/arm/freescale/imx/imx_gpio.c Sun Oct 18 19:54:11 2015 (r289537) @@ -34,6 +34,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_platform.h" + #include #include #include @@ -44,8 +46,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include #include #include @@ -56,13 +60,9 @@ __FBSDID("$FreeBSD$"); #include "gpio_if.h" -#define GPIO_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) -#define GPIO_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) -#define GPIO_LOCK_INIT(_sc) mtx_init(&_sc->sc_mtx, \ - device_get_nameunit(_sc->sc_dev), "imx_gpio", MTX_DEF) -#define GPIO_LOCK_DESTROY(_sc) mtx_destroy(&_sc->sc_mtx); -#define GPIO_ASSERT_LOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_OWNED); -#define GPIO_ASSERT_UNLOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_NOTOWNED); +#ifdef ARM_INTRNG +#include "pic_if.h" +#endif #define WRITE4(_sc, _r, _v) \ bus_space_write_4((_sc)->sc_iot, (_sc)->sc_ioh, (_r), (_v)) @@ -95,13 +95,13 @@ struct imx51_gpio_softc { device_t dev; device_t sc_busdev; struct mtx sc_mtx; - struct resource *sc_res[11]; /* 1 x mem, 2 x IRQ, 8 x IRQ */ - void *gpio_ih[11]; /* 1 ptr is not a big waste */ - int sc_l_irq; /* Last irq resource */ + struct resource *sc_res[3]; /* 1 x mem, 2 x IRQ */ + void *gpio_ih[2]; bus_space_tag_t sc_iot; bus_space_handle_t sc_ioh; int gpio_npins; struct gpio_pin gpio_pins[NGPIO]; + struct arm_irqsrc *gpio_pic_irqsrc[NGPIO]; }; static struct ofw_compat_data compat_data[] = { @@ -118,18 +118,6 @@ static struct resource_spec imx_gpio_spe { -1, 0 } }; -static struct resource_spec imx_gpio0irq_spec[] = { - { SYS_RES_IRQ, 2, RF_ACTIVE }, - { SYS_RES_IRQ, 3, RF_ACTIVE }, - { SYS_RES_IRQ, 4, RF_ACTIVE }, - { SYS_RES_IRQ, 5, RF_ACTIVE }, - { SYS_RES_IRQ, 6, RF_ACTIVE }, - { SYS_RES_IRQ, 7, RF_ACTIVE }, - { SYS_RES_IRQ, 8, RF_ACTIVE }, - { SYS_RES_IRQ, 9, RF_ACTIVE }, - { -1, 0 } -}; - /* * Helpers */ @@ -142,7 +130,6 @@ static void imx51_gpio_pin_configure(str static int imx51_gpio_probe(device_t); static int imx51_gpio_attach(device_t); static int imx51_gpio_detach(device_t); -static int imx51_gpio_intr(void *); /* * GPIO interface @@ -157,12 +144,258 @@ static int imx51_gpio_pin_set(device_t, static int imx51_gpio_pin_get(device_t, uint32_t, unsigned int *); static int imx51_gpio_pin_toggle(device_t, uint32_t pin); +#ifdef ARM_INTRNG +/* + * this is teardown_intr + */ +static void +gpio_pic_disable_intr(device_t dev, struct arm_irqsrc *isrc) +{ + struct imx51_gpio_softc *sc; + u_int irq; + + sc = device_get_softc(dev); + irq = isrc->isrc_data; + + // XXX Not sure this is necessary + mtx_lock_spin(&sc->sc_mtx); + CLEAR4(sc, IMX_GPIO_IMR_REG, (1U << irq)); + WRITE4(sc, IMX_GPIO_ISR_REG, (1U << irq)); + mtx_unlock_spin(&sc->sc_mtx); +} + +/* + * this is mask_intr + */ +static void +gpio_pic_disable_source(device_t dev, struct arm_irqsrc *isrc) +{ + struct imx51_gpio_softc *sc; + + sc = device_get_softc(dev); + + mtx_lock_spin(&sc->sc_mtx); + CLEAR4(sc, IMX_GPIO_IMR_REG, (1U << isrc->isrc_data)); + mtx_unlock_spin(&sc->sc_mtx); +} + +/* + * this is setup_intr + */ +static void +gpio_pic_enable_intr(device_t dev, struct arm_irqsrc *isrc) +{ + struct imx51_gpio_softc *sc; + int icfg; + u_int irq, reg, shift, wrk; + + sc = device_get_softc(dev); + + if (isrc->isrc_trig == INTR_TRIGGER_LEVEL) { + if (isrc->isrc_pol == INTR_POLARITY_LOW) + icfg = GPIO_ICR_COND_LOW; + else + icfg = GPIO_ICR_COND_HIGH; + } else { + if (isrc->isrc_pol == INTR_POLARITY_HIGH) + icfg = GPIO_ICR_COND_FALL; + else + icfg = GPIO_ICR_COND_RISE; + } + + irq = isrc->isrc_data; + if (irq < 16) { + reg = IMX_GPIO_ICR1_REG; + shift = 2 * irq; + } else { + reg = IMX_GPIO_ICR2_REG; + shift = 2 * (irq - 16); + } + + mtx_lock_spin(&sc->sc_mtx); + CLEAR4(sc, IMX_GPIO_IMR_REG, (1U << irq)); + WRITE4(sc, IMX_GPIO_ISR_REG, (1U << irq)); + wrk = READ4(sc, reg); + wrk &= ~(0x03 << shift); + wrk |= icfg << shift; + WRITE4(sc, reg, wrk); + mtx_unlock_spin(&sc->sc_mtx); +} + +/* + * this is unmask_intr + */ +static void +gpio_pic_enable_source(device_t dev, struct arm_irqsrc *isrc) +{ + struct imx51_gpio_softc *sc; + + sc = device_get_softc(dev); + + mtx_lock_spin(&sc->sc_mtx); + SET4(sc, IMX_GPIO_IMR_REG, (1U << isrc->isrc_data)); + mtx_unlock_spin(&sc->sc_mtx); +} + +static void +gpio_pic_post_filter(device_t dev, struct arm_irqsrc *isrc) +{ + struct imx51_gpio_softc *sc; + + sc = device_get_softc(dev); + + arm_irq_memory_barrier(0); + /* EOI. W1C reg so no r-m-w, no locking needed. */ + WRITE4(sc, IMX_GPIO_ISR_REG, (1U << isrc->isrc_data)); +} + +static void +gpio_pic_post_ithread(device_t dev, struct arm_irqsrc *isrc) +{ + + arm_irq_memory_barrier(0); + gpio_pic_enable_source(dev, isrc); +} + +static void +gpio_pic_pre_ithread(device_t dev, struct arm_irqsrc *isrc) +{ + + gpio_pic_disable_source(dev, isrc); +} + +/* + * intrng calls this to make a new isrc known to us. + */ +static int +gpio_pic_register(device_t dev, struct arm_irqsrc *isrc, boolean_t *is_percpu) +{ + struct imx51_gpio_softc *sc; + u_int irq, tripol; + + sc = device_get_softc(dev); + + /* + * From devicetree/bindings/gpio/fsl-imx-gpio.txt: + * #interrupt-cells: 2. The first cell is the GPIO number. The second + * cell bits[3:0] is used to specify trigger type and level flags: + * 1 = low-to-high edge triggered. + * 2 = high-to-low edge triggered. + * 4 = active high level-sensitive. + * 8 = active low level-sensitive. + * We can do any single one of these modes, but nothing in combo. + */ + + if (isrc->isrc_ncells != 2) { + device_printf(sc->dev, "Invalid #interrupt-cells"); + return (EINVAL); + } + + irq = isrc->isrc_cells[0]; + tripol = isrc->isrc_cells[1]; + if (irq >= sc->gpio_npins) { + device_printf(sc->dev, "Invalid interrupt number %d", irq); + return (EINVAL); + } + switch (tripol) + { + case 1: + isrc->isrc_trig = INTR_TRIGGER_EDGE; + isrc->isrc_pol = INTR_POLARITY_HIGH; + break; + case 2: + isrc->isrc_trig = INTR_TRIGGER_EDGE; + isrc->isrc_pol = INTR_POLARITY_LOW; + break; + case 4: + isrc->isrc_trig = INTR_TRIGGER_LEVEL; + isrc->isrc_pol = INTR_POLARITY_HIGH; + break; + case 8: + isrc->isrc_trig = INTR_TRIGGER_LEVEL; + isrc->isrc_pol = INTR_POLARITY_LOW; + break; + default: + device_printf(sc->dev, "unsupported trigger/polarity 0x%2x\n", + tripol); + return (ENOTSUP); + } + isrc->isrc_nspc_type = ARM_IRQ_NSPC_PLAIN; + isrc->isrc_nspc_num = irq; + + /* + * 1. The link between ISRC and controller must be set atomically. + * 2. Just do things only once in rare case when consumers + * of shared interrupt came here at the same moment. + */ + mtx_lock_spin(&sc->sc_mtx); + if (sc->gpio_pic_irqsrc[irq] != NULL) { + mtx_unlock_spin(&sc->sc_mtx); + return (sc->gpio_pic_irqsrc[irq] == isrc ? 0 : EEXIST); + } + sc->gpio_pic_irqsrc[irq] = isrc; + isrc->isrc_data = irq; + mtx_unlock_spin(&sc->sc_mtx); + + arm_irq_set_name(isrc, "%s,%u", device_get_nameunit(sc->dev), irq); + return (0); +} + +static int +gpio_pic_unregister(device_t dev, struct arm_irqsrc *isrc) +{ + struct imx51_gpio_softc *sc; + u_int irq; + + sc = device_get_softc(dev); + + mtx_lock_spin(&sc->sc_mtx); + irq = isrc->isrc_data; + if (sc->gpio_pic_irqsrc[irq] != isrc) { + mtx_unlock_spin(&sc->sc_mtx); + return (sc->gpio_pic_irqsrc[irq] == NULL ? 0 : EINVAL); + } + sc->gpio_pic_irqsrc[irq] = NULL; + isrc->isrc_data = 0; + mtx_unlock_spin(&sc->sc_mtx); + + arm_irq_set_name(isrc, ""); + return (0); +} + +static int +gpio_pic_filter(void *arg) +{ + struct imx51_gpio_softc *sc; + uint32_t i, interrupts; + + sc = arg; + mtx_lock_spin(&sc->sc_mtx); + interrupts = READ4(sc, IMX_GPIO_ISR_REG) & READ4(sc, IMX_GPIO_IMR_REG); + mtx_unlock_spin(&sc->sc_mtx); + + for (i = 0; interrupts != 0; i++, interrupts >>= 1) { + if ((interrupts & 0x1) == 0) + continue; + if (sc->gpio_pic_irqsrc[i]) + arm_irq_dispatch(sc->gpio_pic_irqsrc[i], curthread->td_intr_frame); + else + device_printf(sc->dev, "spurious interrupt %d\n", i); + } + + return (FILTER_HANDLED); +} +#endif + +/* + * + */ static void imx51_gpio_pin_configure(struct imx51_gpio_softc *sc, struct gpio_pin *pin, unsigned int flags) { - GPIO_LOCK(sc); + mtx_lock_spin(&sc->sc_mtx); /* * Manage input/output @@ -171,15 +404,15 @@ imx51_gpio_pin_configure(struct imx51_gp pin->gp_flags &= ~(GPIO_PIN_INPUT|GPIO_PIN_OUTPUT); if (flags & GPIO_PIN_OUTPUT) { pin->gp_flags |= GPIO_PIN_OUTPUT; - SET4(sc, IMX_GPIO_OE_REG, (1 << pin->gp_pin)); + SET4(sc, IMX_GPIO_OE_REG, (1U << pin->gp_pin)); } else { pin->gp_flags |= GPIO_PIN_INPUT; - CLEAR4(sc, IMX_GPIO_OE_REG, (1 << pin->gp_pin)); + CLEAR4(sc, IMX_GPIO_OE_REG, (1U << pin->gp_pin)); } } - GPIO_UNLOCK(sc); + mtx_unlock_spin(&sc->sc_mtx); } static device_t @@ -195,8 +428,11 @@ imx51_gpio_get_bus(device_t dev) static int imx51_gpio_pin_max(device_t dev, int *maxpin) { + struct imx51_gpio_softc *sc; + + sc = device_get_softc(dev); + *maxpin = sc->gpio_npins - 1; - *maxpin = NGPIO - 1; return (0); } @@ -215,9 +451,9 @@ imx51_gpio_pin_getcaps(device_t dev, uin if (i >= sc->gpio_npins) return (EINVAL); - GPIO_LOCK(sc); + mtx_lock_spin(&sc->sc_mtx); *caps = sc->gpio_pins[i].gp_caps; - GPIO_UNLOCK(sc); + mtx_unlock_spin(&sc->sc_mtx); return (0); } @@ -237,9 +473,9 @@ imx51_gpio_pin_getflags(device_t dev, ui if (i >= sc->gpio_npins) return (EINVAL); - GPIO_LOCK(sc); + mtx_lock_spin(&sc->sc_mtx); *flags = sc->gpio_pins[i].gp_flags; - GPIO_UNLOCK(sc); + mtx_unlock_spin(&sc->sc_mtx); return (0); } @@ -259,9 +495,9 @@ imx51_gpio_pin_getname(device_t dev, uin if (i >= sc->gpio_npins) return (EINVAL); - GPIO_LOCK(sc); + mtx_lock_spin(&sc->sc_mtx); memcpy(name, sc->gpio_pins[i].gp_name, GPIOMAXNAME); - GPIO_UNLOCK(sc); + mtx_unlock_spin(&sc->sc_mtx); return (0); } @@ -301,12 +537,12 @@ imx51_gpio_pin_set(device_t dev, uint32_ if (i >= sc->gpio_npins) return (EINVAL); - GPIO_LOCK(sc); + mtx_lock_spin(&sc->sc_mtx); if (value) - SET4(sc, IMX_GPIO_DR_REG, (1 << i)); + SET4(sc, IMX_GPIO_DR_REG, (1U << i)); else - CLEAR4(sc, IMX_GPIO_DR_REG, (1 << i)); - GPIO_UNLOCK(sc); + CLEAR4(sc, IMX_GPIO_DR_REG, (1U << i)); + mtx_unlock_spin(&sc->sc_mtx); return (0); } @@ -326,9 +562,9 @@ imx51_gpio_pin_get(device_t dev, uint32_ if (i >= sc->gpio_npins) return (EINVAL); - GPIO_LOCK(sc); + mtx_lock_spin(&sc->sc_mtx); *val = (READ4(sc, IMX_GPIO_DR_REG) >> i) & 1; - GPIO_UNLOCK(sc); + mtx_unlock_spin(&sc->sc_mtx); return (0); } @@ -348,35 +584,15 @@ imx51_gpio_pin_toggle(device_t dev, uint if (i >= sc->gpio_npins) return (EINVAL); - GPIO_LOCK(sc); + mtx_lock_spin(&sc->sc_mtx); WRITE4(sc, IMX_GPIO_DR_REG, - (READ4(sc, IMX_GPIO_DR_REG) ^ (1 << i))); - GPIO_UNLOCK(sc); + (READ4(sc, IMX_GPIO_DR_REG) ^ (1U << i))); + mtx_unlock_spin(&sc->sc_mtx); return (0); } static int -imx51_gpio_intr(void *arg) -{ - struct imx51_gpio_softc *sc; - uint32_t input, value; - - sc = arg; - input = READ4(sc, IMX_GPIO_ISR_REG); - value = input & READ4(sc, IMX_GPIO_IMR_REG); - WRITE4(sc, IMX_GPIO_ISR_REG, input); - - if (!value) - goto intr_done; - - /* TODO: interrupt handling */ - -intr_done: - return (FILTER_HANDLED); -} - -static int imx51_gpio_probe(device_t dev) { @@ -395,10 +611,13 @@ static int imx51_gpio_attach(device_t dev) { struct imx51_gpio_softc *sc; - int i, irq; + int i, irq, unit; sc = device_get_softc(dev); - mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF); + sc->dev = dev; + sc->gpio_npins = NGPIO; + + mtx_init(&sc->sc_mtx, device_get_nameunit(sc->dev), NULL, MTX_SPIN); if (bus_alloc_resources(dev, imx_gpio_spec, sc->sc_res)) { device_printf(dev, "could not allocate resources\n"); @@ -407,40 +626,40 @@ imx51_gpio_attach(device_t dev) return (ENXIO); } - sc->dev = dev; - sc->gpio_npins = NGPIO; - sc->sc_l_irq = 2; sc->sc_iot = rman_get_bustag(sc->sc_res[0]); sc->sc_ioh = rman_get_bushandle(sc->sc_res[0]); - - if (bus_alloc_resources(dev, imx_gpio0irq_spec, &sc->sc_res[3]) == 0) { - /* - * First GPIO unit able to serve +8 interrupts for 8 first - * pins. - */ - sc->sc_l_irq = 10; - } - - for (irq = 1; irq <= sc->sc_l_irq; irq ++) { - if ((bus_setup_intr(dev, sc->sc_res[irq], INTR_TYPE_MISC, - imx51_gpio_intr, NULL, sc, &sc->gpio_ih[irq]))) { + /* + * Mask off all interrupts in hardware, then set up interrupt handling. + */ + WRITE4(sc, IMX_GPIO_IMR_REG, 0); + for (irq = 0; irq < 2; irq++) { +#ifdef ARM_INTRNG + if ((bus_setup_intr(dev, sc->sc_res[1 + irq], INTR_TYPE_CLK, + gpio_pic_filter, NULL, sc, &sc->gpio_ih[irq]))) { device_printf(dev, "WARNING: unable to register interrupt handler\n"); imx51_gpio_detach(dev); return (ENXIO); } +#endif } + unit = device_get_unit(dev); for (i = 0; i < sc->gpio_npins; i++) { sc->gpio_pins[i].gp_pin = i; sc->gpio_pins[i].gp_caps = DEFAULT_CAPS; sc->gpio_pins[i].gp_flags = - (READ4(sc, IMX_GPIO_OE_REG) & (1 << i)) ? GPIO_PIN_OUTPUT: + (READ4(sc, IMX_GPIO_OE_REG) & (1U << i)) ? GPIO_PIN_OUTPUT : GPIO_PIN_INPUT; snprintf(sc->gpio_pins[i].gp_name, GPIOMAXNAME, - "imx_gpio%d.%d", device_get_unit(dev), i); + "imx_gpio%d.%d", unit, i); } + +#ifdef ARM_INTRNG + arm_pic_register(dev, OF_xref_from_node(ofw_bus_get_node(dev))); +#endif sc->sc_busdev = gpiobus_attach_bus(dev); + if (sc->sc_busdev == NULL) { imx51_gpio_detach(dev); return (ENXIO); @@ -457,14 +676,11 @@ imx51_gpio_detach(device_t dev) sc = device_get_softc(dev); - KASSERT(mtx_initialized(&sc->sc_mtx), ("gpio mutex not initialized")); - gpiobus_detach_bus(dev); - for (irq = 1; irq <= sc->sc_l_irq; irq ++) { + for (irq = 1; irq <= 2; irq++) { if (sc->gpio_ih[irq]) bus_teardown_intr(dev, sc->sc_res[irq], sc->gpio_ih[irq]); } - bus_release_resources(dev, imx_gpio0irq_spec, &sc->sc_res[3]); bus_release_resources(dev, imx_gpio_spec, sc->sc_res); mtx_destroy(&sc->sc_mtx); @@ -476,6 +692,19 @@ static device_method_t imx51_gpio_method DEVMETHOD(device_attach, imx51_gpio_attach), DEVMETHOD(device_detach, imx51_gpio_detach), +#ifdef ARM_INTRNG + /* Interrupt controller interface */ + DEVMETHOD(pic_disable_intr, gpio_pic_disable_intr), + DEVMETHOD(pic_disable_source, gpio_pic_disable_source), + DEVMETHOD(pic_enable_intr, gpio_pic_enable_intr), + DEVMETHOD(pic_enable_source, gpio_pic_enable_source), + DEVMETHOD(pic_post_filter, gpio_pic_post_filter), + DEVMETHOD(pic_post_ithread, gpio_pic_post_ithread), + DEVMETHOD(pic_pre_ithread, gpio_pic_pre_ithread), + DEVMETHOD(pic_register, gpio_pic_register), + DEVMETHOD(pic_unregister, gpio_pic_unregister), +#endif + /* GPIO protocol */ DEVMETHOD(gpio_get_bus, imx51_gpio_get_bus), DEVMETHOD(gpio_pin_max, imx51_gpio_pin_max), From owner-svn-src-head@freebsd.org Sun Oct 18 20:19:46 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 490D1A184B2; Sun, 18 Oct 2015 20:19:46 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 08EC81257; Sun, 18 Oct 2015 20:19:45 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IKJjWL092729; Sun, 18 Oct 2015 20:19:45 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IKJiDU092726; Sun, 18 Oct 2015 20:19:44 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201510182019.t9IKJiDU092726@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Sun, 18 Oct 2015 20:19:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289538 - head/sys/dev/ntb/ntb_hw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 20:19:46 -0000 Author: cem Date: Sun Oct 18 20:19:44 2015 New Revision: 289538 URL: https://svnweb.freebsd.org/changeset/base/289538 Log: NTB: Rename some constants to match Linux No functional change. Obtained from: Linux (part of e26a5843) (Dual BSD/GPL driver) Sponsored by: EMC / Isilon Storage Division Modified: head/sys/dev/ntb/ntb_hw/ntb_hw.c head/sys/dev/ntb/ntb_hw/ntb_hw.h head/sys/dev/ntb/ntb_hw/ntb_regs.h Modified: head/sys/dev/ntb/ntb_hw/ntb_hw.c ============================================================================== --- head/sys/dev/ntb/ntb_hw/ntb_hw.c Sun Oct 18 19:54:11 2015 (r289537) +++ head/sys/dev/ntb/ntb_hw/ntb_hw.c Sun Oct 18 20:19:44 2015 (r289538) @@ -66,7 +66,7 @@ __FBSDID("$FreeBSD$"); #define NTB_MAX_BARS 4 #define NTB_MW_TO_BAR(mw) ((mw) + 1) -#define MAX_MSIX_INTERRUPTS MAX(XEON_MAX_DB_BITS, SOC_MAX_DB_BITS) +#define MAX_MSIX_INTERRUPTS MAX(XEON_DB_COUNT, SOC_DB_COUNT) #define NTB_HB_TIMEOUT 1 /* second */ #define SOC_LINK_RECOVERY_TIME 500 @@ -246,18 +246,18 @@ static struct ntb_hw_info pci_ids[] = { /* XXX: PS/SS IDs left out until they are supported. */ { 0x37258086, "JSF Xeon C35xx/C55xx Non-Transparent Bridge B2B", - NTB_XEON, NTB_REGS_THRU_MW | NTB_B2BDOORBELL_BIT14 }, + NTB_XEON, NTB_SDOORBELL_LOCKUP | NTB_B2BDOORBELL_BIT14 }, { 0x3C0D8086, "SNB Xeon E5/Core i7 Non-Transparent Bridge B2B", - NTB_XEON, NTB_REGS_THRU_MW | NTB_B2BDOORBELL_BIT14 }, + NTB_XEON, NTB_SDOORBELL_LOCKUP | NTB_B2BDOORBELL_BIT14 }, { 0x0E0D8086, "IVT Xeon E5 V2 Non-Transparent Bridge B2B", NTB_XEON, - NTB_REGS_THRU_MW | NTB_B2BDOORBELL_BIT14 | NTB_SB01BASE_LOCKUP - | NTB_BAR_SIZE_4K }, + NTB_SDOORBELL_LOCKUP | NTB_B2BDOORBELL_BIT14 | + NTB_SB01BASE_LOCKUP | NTB_BAR_SIZE_4K }, { 0x2F0D8086, "HSX Xeon E5 V3 Non-Transparent Bridge B2B", NTB_XEON, - NTB_REGS_THRU_MW | NTB_B2BDOORBELL_BIT14 | NTB_SB01BASE_LOCKUP - }, + NTB_SDOORBELL_LOCKUP | NTB_B2BDOORBELL_BIT14 | + NTB_SB01BASE_LOCKUP }, { 0x6F0D8086, "BDX Xeon E5 V4 Non-Transparent Bridge B2B", NTB_XEON, - NTB_REGS_THRU_MW | NTB_B2BDOORBELL_BIT14 | NTB_SB01BASE_LOCKUP - }, + NTB_SDOORBELL_LOCKUP | NTB_B2BDOORBELL_BIT14 | + NTB_SB01BASE_LOCKUP }, { 0x00000000, NULL, NTB_SOC, 0 } }; @@ -390,7 +390,7 @@ ntb_map_pci_bars(struct ntb_softc *ntb) return (rc); ntb->bar_info[NTB_B2B_BAR_2].pci_resource_id = PCIR_BAR(4); - if (HAS_FEATURE(NTB_REGS_THRU_MW) && !HAS_FEATURE(NTB_SPLIT_BAR)) + if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP) && !HAS_FEATURE(NTB_SPLIT_BAR)) rc = map_pci_bar(ntb, map_mmr_bar, &ntb->bar_info[NTB_B2B_BAR_2]); else @@ -400,7 +400,7 @@ ntb_map_pci_bars(struct ntb_softc *ntb) return (rc); ntb->bar_info[NTB_B2B_BAR_3].pci_resource_id = PCIR_BAR(5); - if (HAS_FEATURE(NTB_REGS_THRU_MW)) + if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP)) rc = map_pci_bar(ntb, map_mmr_bar, &ntb->bar_info[NTB_B2B_BAR_3]); else @@ -650,7 +650,7 @@ ntb_setup_interrupts(struct ntb_softc *n */ mask = 0; if (ntb->type == NTB_XEON) - mask = (1 << XEON_LINK_DB); + mask = (1 << XEON_DB_LINK); db_iowrite(ntb, ntb->reg_ofs.ldb_mask, ~mask); num_vectors = desired_vectors = MIN(pci_msix_count(ntb->device), @@ -852,7 +852,7 @@ handle_xeon_event_irq(void *arg) device_printf(ntb->device, "Error determining link status\n"); /* bit 15 is always the link bit */ - db_iowrite(ntb, ntb->reg_ofs.ldb, 1 << XEON_LINK_DB); + db_iowrite(ntb, ntb->reg_ofs.ldb, 1 << XEON_DB_LINK); } static void @@ -864,9 +864,9 @@ ntb_handle_legacy_interrupt(void *arg) ldb = db_ioread(ntb, ntb->reg_ofs.ldb); - if (ntb->type == NTB_XEON && (ldb & XEON_DB_HW_LINK) != 0) { + if (ntb->type == NTB_XEON && (ldb & XEON_DB_LINK_BIT) != 0) { handle_xeon_event_irq(ntb); - ldb &= ~XEON_DB_HW_LINK; + ldb &= ~XEON_DB_LINK_BIT; } while (ldb != 0) { @@ -1014,21 +1014,21 @@ ntb_setup_xeon(struct ntb_softc *ntb) case NTB_CONN_B2B: /* * reg_ofs.rdb and reg_ofs.spad_remote are effectively ignored - * with the NTB_REGS_THRU_MW errata mode enabled. (See + * with the NTB_SDOORBELL_LOCKUP errata mode enabled. (See * ntb_ring_doorbell() and ntb_read/write_remote_spad().) */ ntb->reg_ofs.rdb = XEON_B2B_DOORBELL_OFFSET; ntb->reg_ofs.spad_remote = XEON_B2B_SPAD_OFFSET; - ntb->limits.max_spads = XEON_MAX_SPADS; + ntb->limits.max_spads = XEON_SPAD_COUNT; break; case NTB_CONN_RP: /* - * Every Xeon today needs NTB_REGS_THRU_MW, so punt on RP for + * Every Xeon today needs NTB_SDOORBELL_LOCKUP, so punt on RP for * now. */ - KASSERT(HAS_FEATURE(NTB_REGS_THRU_MW), + KASSERT(HAS_FEATURE(NTB_SDOORBELL_LOCKUP), ("Xeon without MW errata unimplemented")); device_printf(ntb->device, "NTB-RP disabled to due hardware errata.\n"); @@ -1053,7 +1053,7 @@ ntb_setup_xeon(struct ntb_softc *ntb) * This should already be the case based on the driver defaults, but * write the limit registers first just in case. */ - if (HAS_FEATURE(NTB_REGS_THRU_MW)) { + if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP)) { /* * Set the Limit register to 4k, the minimum size, to prevent * an illegal access. @@ -1076,9 +1076,9 @@ ntb_setup_xeon(struct ntb_softc *ntb) ntb->reg_ofs.lnk_stat = XEON_LINK_STATUS_OFFSET; ntb->reg_ofs.spci_cmd = XEON_PCICMD_OFFSET; - ntb->limits.max_db_bits = XEON_MAX_DB_BITS; - ntb->limits.msix_cnt = XEON_MSIX_CNT; - ntb->bits_per_vector = XEON_DB_BITS_PER_VEC; + ntb->limits.max_db_bits = XEON_DB_COUNT; + ntb->limits.msix_cnt = XEON_DB_MSIX_VECTOR_COUNT; + ntb->bits_per_vector = XEON_DB_MSIX_VECTOR_SHIFT; /* * HW Errata on bit 14 of b2bdoorbell register. Writes will not be @@ -1089,9 +1089,9 @@ ntb_setup_xeon(struct ntb_softc *ntb) * anyway. Nor for non-B2B connection types. */ if (HAS_FEATURE(NTB_B2BDOORBELL_BIT14) && - !HAS_FEATURE(NTB_REGS_THRU_MW) && + !HAS_FEATURE(NTB_SDOORBELL_LOCKUP) && ntb->conn_type == NTB_CONN_B2B) - ntb->limits.max_db_bits = XEON_MAX_DB_BITS - 1; + ntb->limits.max_db_bits = XEON_DB_COUNT - 1; configure_xeon_secondary_side_bars(ntb); @@ -1128,10 +1128,10 @@ ntb_setup_soc(struct ntb_softc *ntb) ntb->reg_ofs.spad_remote = SOC_B2B_SPAD_OFFSET; ntb->reg_ofs.spci_cmd = SOC_PCICMD_OFFSET; - ntb->limits.max_spads = SOC_MAX_SPADS; - ntb->limits.max_db_bits = SOC_MAX_DB_BITS; - ntb->limits.msix_cnt = SOC_MSIX_CNT; - ntb->bits_per_vector = SOC_DB_BITS_PER_VEC; + ntb->limits.max_spads = SOC_SPAD_COUNT; + ntb->limits.max_db_bits = SOC_DB_COUNT; + ntb->limits.msix_cnt = SOC_DB_MSIX_VECTOR_COUNT; + ntb->bits_per_vector = SOC_DB_MSIX_VECTOR_SHIFT; /* * FIXME - MSI-X bug on early SOC HW, remove once internal issue is @@ -1155,15 +1155,17 @@ configure_soc_secondary_side_bars(struct { if (ntb->dev_type == NTB_DEV_USD) { - ntb_reg_write(8, SOC_PBAR2XLAT_OFFSET, MBAR23_DSD_ADDR); - ntb_reg_write(8, SOC_PBAR4XLAT_OFFSET, MBAR4_DSD_ADDR); - ntb_reg_write(8, SOC_MBAR23_OFFSET, MBAR23_USD_ADDR); - ntb_reg_write(8, SOC_MBAR45_OFFSET, MBAR4_USD_ADDR); + ntb_reg_write(8, SOC_PBAR2XLAT_OFFSET, + XEON_B2B_BAR2_DSD_ADDR); + ntb_reg_write(8, SOC_PBAR4XLAT_OFFSET, XEON_B2B_BAR4_DSD_ADDR); + ntb_reg_write(8, SOC_MBAR23_OFFSET, XEON_B2B_BAR2_USD_ADDR); + ntb_reg_write(8, SOC_MBAR45_OFFSET, XEON_B2B_BAR4_USD_ADDR); } else { - ntb_reg_write(8, SOC_PBAR2XLAT_OFFSET, MBAR23_USD_ADDR); - ntb_reg_write(8, SOC_PBAR4XLAT_OFFSET, MBAR4_USD_ADDR); - ntb_reg_write(8, SOC_MBAR23_OFFSET, MBAR23_DSD_ADDR); - ntb_reg_write(8, SOC_MBAR45_OFFSET, MBAR4_DSD_ADDR); + ntb_reg_write(8, SOC_PBAR2XLAT_OFFSET, + XEON_B2B_BAR2_USD_ADDR); + ntb_reg_write(8, SOC_PBAR4XLAT_OFFSET, XEON_B2B_BAR4_USD_ADDR); + ntb_reg_write(8, SOC_MBAR23_OFFSET, XEON_B2B_BAR2_DSD_ADDR); + ntb_reg_write(8, SOC_MBAR45_OFFSET, XEON_B2B_BAR4_DSD_ADDR); } } @@ -1172,68 +1174,77 @@ configure_xeon_secondary_side_bars(struc { if (ntb->dev_type == NTB_DEV_USD) { - ntb_reg_write(8, XEON_PBAR2XLAT_OFFSET, MBAR23_DSD_ADDR); - if (HAS_FEATURE(NTB_REGS_THRU_MW)) + ntb_reg_write(8, XEON_PBAR2XLAT_OFFSET, + XEON_B2B_BAR2_DSD_ADDR); + if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP)) ntb_reg_write(8, XEON_PBAR4XLAT_OFFSET, - MBAR01_DSD_ADDR); + XEON_B2B_BAR0_DSD_ADDR); else { if (HAS_FEATURE(NTB_SPLIT_BAR)) { ntb_reg_write(4, XEON_PBAR4XLAT_OFFSET, - MBAR4_DSD_ADDR); + XEON_B2B_BAR4_DSD_ADDR); ntb_reg_write(4, XEON_PBAR5XLAT_OFFSET, - MBAR5_DSD_ADDR); + XEON_B2B_BAR5_DSD_ADDR); } else ntb_reg_write(8, XEON_PBAR4XLAT_OFFSET, - MBAR4_DSD_ADDR); + XEON_B2B_BAR4_DSD_ADDR); /* * B2B_XLAT_OFFSET is a 64-bit register but can only be * written 32 bits at a time. */ ntb_reg_write(4, XEON_B2B_XLAT_OFFSETL, - MBAR01_DSD_ADDR & 0xffffffff); + XEON_B2B_BAR0_DSD_ADDR & 0xffffffff); ntb_reg_write(4, XEON_B2B_XLAT_OFFSETU, - MBAR01_DSD_ADDR >> 32); + XEON_B2B_BAR0_DSD_ADDR >> 32); } - ntb_reg_write(8, XEON_SBAR0BASE_OFFSET, MBAR01_USD_ADDR); - ntb_reg_write(8, XEON_SBAR2BASE_OFFSET, MBAR23_USD_ADDR); + ntb_reg_write(8, XEON_SBAR0BASE_OFFSET, + XEON_B2B_BAR0_USD_ADDR); + ntb_reg_write(8, XEON_SBAR2BASE_OFFSET, + XEON_B2B_BAR2_USD_ADDR); if (HAS_FEATURE(NTB_SPLIT_BAR)) { - ntb_reg_write(4, XEON_SBAR4BASE_OFFSET, MBAR4_USD_ADDR); - ntb_reg_write(4, XEON_SBAR5BASE_OFFSET, MBAR5_USD_ADDR); + ntb_reg_write(4, XEON_SBAR4BASE_OFFSET, + XEON_B2B_BAR4_USD_ADDR); + ntb_reg_write(4, XEON_SBAR5BASE_OFFSET, + XEON_B2B_BAR5_USD_ADDR); } else - ntb_reg_write(8, XEON_SBAR4BASE_OFFSET, MBAR4_USD_ADDR); + ntb_reg_write(8, XEON_SBAR4BASE_OFFSET, + XEON_B2B_BAR4_USD_ADDR); } else { - ntb_reg_write(8, XEON_PBAR2XLAT_OFFSET, MBAR23_USD_ADDR); - if (HAS_FEATURE(NTB_REGS_THRU_MW)) + ntb_reg_write(8, XEON_PBAR2XLAT_OFFSET, + XEON_B2B_BAR2_USD_ADDR); + if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP)) ntb_reg_write(8, XEON_PBAR4XLAT_OFFSET, - MBAR01_USD_ADDR); + XEON_B2B_BAR0_USD_ADDR); else { if (HAS_FEATURE(NTB_SPLIT_BAR)) { ntb_reg_write(4, XEON_PBAR4XLAT_OFFSET, - MBAR4_USD_ADDR); + XEON_B2B_BAR4_USD_ADDR); ntb_reg_write(4, XEON_PBAR5XLAT_OFFSET, - MBAR5_USD_ADDR); + XEON_B2B_BAR5_USD_ADDR); } else ntb_reg_write(8, XEON_PBAR4XLAT_OFFSET, - MBAR4_USD_ADDR); + XEON_B2B_BAR4_USD_ADDR); /* * B2B_XLAT_OFFSET is a 64-bit register but can only be * written 32 bits at a time. */ ntb_reg_write(4, XEON_B2B_XLAT_OFFSETL, - MBAR01_USD_ADDR & 0xffffffff); + XEON_B2B_BAR0_USD_ADDR & 0xffffffff); ntb_reg_write(4, XEON_B2B_XLAT_OFFSETU, - MBAR01_USD_ADDR >> 32); + XEON_B2B_BAR0_USD_ADDR >> 32); } - ntb_reg_write(8, XEON_SBAR0BASE_OFFSET, MBAR01_DSD_ADDR); - ntb_reg_write(8, XEON_SBAR2BASE_OFFSET, MBAR23_DSD_ADDR); + ntb_reg_write(8, XEON_SBAR0BASE_OFFSET, + XEON_B2B_BAR0_DSD_ADDR); + ntb_reg_write(8, XEON_SBAR2BASE_OFFSET, + XEON_B2B_BAR2_DSD_ADDR); if (HAS_FEATURE(NTB_SPLIT_BAR)) { ntb_reg_write(4, XEON_SBAR4BASE_OFFSET, - MBAR4_DSD_ADDR); + XEON_B2B_BAR4_DSD_ADDR); ntb_reg_write(4, XEON_SBAR5BASE_OFFSET, - MBAR5_DSD_ADDR); + XEON_B2B_BAR5_DSD_ADDR); } else ntb_reg_write(8, XEON_SBAR4BASE_OFFSET, - MBAR4_DSD_ADDR); + XEON_B2B_BAR4_DSD_ADDR); } } @@ -1718,7 +1729,7 @@ ntb_write_remote_spad(struct ntb_softc * if (idx >= ntb->limits.max_spads) return (EINVAL); - if (HAS_FEATURE(NTB_REGS_THRU_MW)) + if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP)) ntb_mw_write(4, XEON_SHADOW_SPAD_OFFSET + idx * 4, val); else ntb_reg_write(4, ntb->reg_ofs.spad_remote + idx * 4, val); @@ -1744,7 +1755,7 @@ ntb_read_remote_spad(struct ntb_softc *n if (idx >= ntb->limits.max_spads) return (EINVAL); - if (HAS_FEATURE(NTB_REGS_THRU_MW)) + if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP)) *val = ntb_mw_read(4, XEON_SHADOW_SPAD_OFFSET + idx * 4); else *val = ntb_reg_read(4, ntb->reg_ofs.spad_remote + idx * 4); @@ -1853,7 +1864,7 @@ ntb_ring_doorbell(struct ntb_softc *ntb, bit = ((1 << ntb->bits_per_vector) - 1) << (db * ntb->bits_per_vector); - if (HAS_FEATURE(NTB_REGS_THRU_MW)) { + if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP)) { ntb_mw_write(2, XEON_SHADOW_PDOORBELL_OFFSET, bit); return; } Modified: head/sys/dev/ntb/ntb_hw/ntb_hw.h ============================================================================== --- head/sys/dev/ntb/ntb_hw/ntb_hw.h Sun Oct 18 19:54:11 2015 (r289537) +++ head/sys/dev/ntb/ntb_hw/ntb_hw.h Sun Oct 18 20:19:44 2015 (r289538) @@ -80,8 +80,7 @@ device_t ntb_get_device(struct ntb_softc /* Hardware owns the low 32 bits of features. */ #define NTB_BAR_SIZE_4K (1 << 0) -/* REGS_THRU_MW is the equivalent of Linux's NTB_HWERR_SDOORBELL_LOCKUP */ -#define NTB_REGS_THRU_MW (1 << 1) +#define NTB_SDOORBELL_LOCKUP (1 << 1) #define NTB_SB01BASE_LOCKUP (1 << 2) #define NTB_B2BDOORBELL_BIT14 (1 << 3) /* Software/configuration owns the top 32 bits. */ Modified: head/sys/dev/ntb/ntb_hw/ntb_regs.h ============================================================================== --- head/sys/dev/ntb/ntb_hw/ntb_regs.h Sun Oct 18 19:54:11 2015 (r289537) +++ head/sys/dev/ntb/ntb_hw/ntb_regs.h Sun Oct 18 20:19:44 2015 (r289538) @@ -33,17 +33,15 @@ #define NTB_LINK_SPEED_MASK 0x000f #define NTB_LINK_WIDTH_MASK 0x03f0 -#define XEON_MSIX_CNT 4 #define XEON_SNB_MAX_MW 2 #define XEON_HSXSPLIT_MAX_MW 3 -#define XEON_MAX_SPADS 16 -#define XEON_MAX_COMPAT_SPADS 16 /* Reserve the uppermost bit for link interrupt */ -#define XEON_MAX_DB_BITS 15 -#define XEON_LINK_DB 15 -#define XEON_DB_BITS_PER_VEC 5 - -#define XEON_DB_HW_LINK 0x8000 +#define XEON_DB_COUNT 15 +#define XEON_DB_LINK 15 +#define XEON_DB_MSIX_VECTOR_COUNT 4 +#define XEON_DB_MSIX_VECTOR_SHIFT 5 +#define XEON_DB_LINK_BIT (1 << XEON_DB_LINK) +#define XEON_SPAD_COUNT 16 #define XEON_PCICMD_OFFSET 0x0504 #define XEON_DEVCTRL_OFFSET 0x0598 @@ -81,11 +79,11 @@ #define XEON_B2B_XLAT_OFFSETL 0x0144 #define XEON_B2B_XLAT_OFFSETU 0x0148 -#define SOC_MSIX_CNT 34 #define SOC_MAX_MW 2 -#define SOC_MAX_SPADS 16 -#define SOC_MAX_DB_BITS 34 -#define SOC_DB_BITS_PER_VEC 1 +#define SOC_DB_COUNT 34 +#define SOC_DB_MSIX_VECTOR_COUNT 34 +#define SOC_DB_MSIX_VECTOR_SHIFT 1 +#define SOC_SPAD_COUNT 16 #define SOC_PCICMD_OFFSET 0xb004 #define SOC_MBAR23_OFFSET 0xb018 @@ -152,14 +150,14 @@ #define NTB_DEV_USD 0 /* All addresses are in low 32-bit space so 32-bit BARs can function */ -#define MBAR01_USD_ADDR 0x2100000cull -#define MBAR23_USD_ADDR 0x4100000cull -#define MBAR4_USD_ADDR 0x8100000cull -#define MBAR5_USD_ADDR 0xa100000cull -#define MBAR01_DSD_ADDR 0x2000000cull -#define MBAR23_DSD_ADDR 0x4000000cull -#define MBAR4_DSD_ADDR 0x8000000cull -#define MBAR5_DSD_ADDR 0xa000000cull +#define XEON_B2B_BAR0_USD_ADDR 0x2100000cull +#define XEON_B2B_BAR2_USD_ADDR 0x4100000cull +#define XEON_B2B_BAR4_USD_ADDR 0x8100000cull +#define XEON_B2B_BAR5_USD_ADDR 0xa100000cull +#define XEON_B2B_BAR0_DSD_ADDR 0x2000000cull +#define XEON_B2B_BAR2_DSD_ADDR 0x4000000cull +#define XEON_B2B_BAR4_DSD_ADDR 0x8000000cull +#define XEON_B2B_BAR5_DSD_ADDR 0xa000000cull /* XEON Shadowed MMIO Space */ #define XEON_SHADOW_PDOORBELL_OFFSET 0x60 From owner-svn-src-head@freebsd.org Sun Oct 18 20:19:55 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4CE6BA184D3; Sun, 18 Oct 2015 20:19:55 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 13364137C; Sun, 18 Oct 2015 20:19:54 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IKJsXn092783; Sun, 18 Oct 2015 20:19:54 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IKJrVs092779; Sun, 18 Oct 2015 20:19:53 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201510182019.t9IKJrVs092779@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Sun, 18 Oct 2015 20:19:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289539 - in head/sys/dev/ntb: if_ntb ntb_hw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 20:19:55 -0000 Author: cem Date: Sun Oct 18 20:19:53 2015 New Revision: 289539 URL: https://svnweb.freebsd.org/changeset/base/289539 Log: NTB: Rename some variables/functions to match Linux No functional change. Still part of the huge e26a5843 rewrite. I'm trying to make it less of a complete rewrite in the FreeBSD version of the driver. Still, it helps if our names match Linux. Obtained from: Linux (e26a5843) (Dual BSD/GPL driver) Sponsored by: EMC / Isilon Storage Division Modified: head/sys/dev/ntb/if_ntb/if_ntb.c head/sys/dev/ntb/ntb_hw/ntb_hw.c head/sys/dev/ntb/ntb_hw/ntb_hw.h head/sys/dev/ntb/ntb_hw/ntb_regs.h Modified: head/sys/dev/ntb/if_ntb/if_ntb.c ============================================================================== --- head/sys/dev/ntb/if_ntb/if_ntb.c Sun Oct 18 20:19:44 2015 (r289538) +++ head/sys/dev/ntb/if_ntb/if_ntb.c Sun Oct 18 20:19:53 2015 (r289539) @@ -220,7 +220,7 @@ enum { IF_NTB_MAX_SPAD, }; -#define QP_TO_MW(ntb, qp) ((qp) % ntb_get_max_mw(ntb)) +#define QP_TO_MW(ntb, qp) ((qp) % ntb_mw_count(ntb)) #define NTB_QP_DEF_NUM_ENTRIES 100 #define NTB_LINK_DOWN_TIMEOUT 10 @@ -493,7 +493,7 @@ ntb_transport_init(struct ntb_softc *ntb int rc, i; if (max_num_clients == 0) - nt->max_qps = MIN(ntb_get_max_cbs(ntb), ntb_get_max_mw(ntb)); + nt->max_qps = MIN(ntb_get_max_cbs(ntb), ntb_mw_count(ntb)); else nt->max_qps = MIN(ntb_get_max_cbs(ntb), max_num_clients); @@ -562,7 +562,7 @@ ntb_transport_init_queue(struct ntb_netd unsigned int num_qps_mw, tx_size; uint8_t mw_num, mw_max; - mw_max = ntb_get_max_mw(nt->ntb); + mw_max = ntb_mw_count(nt->ntb); mw_num = QP_TO_MW(nt->ntb, qp_num); qp = &nt->qps[qp_num]; @@ -1055,7 +1055,7 @@ ntb_transport_link_work(void *arg) uint32_t val, i, num_mw; int rc; - num_mw = ntb_get_max_mw(ntb); + num_mw = ntb_mw_count(ntb); /* send the local info, in the opposite order of the way we read it */ for (i = 0; i < num_mw; i++) { @@ -1214,7 +1214,7 @@ ntb_transport_setup_qp_mw(struct ntb_net uint8_t mw_num, mw_max; unsigned int i; - mw_max = ntb_get_max_mw(nt->ntb); + mw_max = ntb_mw_count(nt->ntb); mw_num = QP_TO_MW(nt->ntb, qp_num); if (nt->max_qps % mw_max && mw_num + 1 < nt->max_qps / mw_max) Modified: head/sys/dev/ntb/ntb_hw/ntb_hw.c ============================================================================== --- head/sys/dev/ntb/ntb_hw/ntb_hw.c Sun Oct 18 20:19:44 2015 (r289538) +++ head/sys/dev/ntb/ntb_hw/ntb_hw.c Sun Oct 18 20:19:53 2015 (r289539) @@ -59,17 +59,10 @@ __FBSDID("$FreeBSD$"); * be picked up and redistributed in Linux with a dual GPL/BSD license. */ -#define NTB_CONFIG_BAR 0 -#define NTB_B2B_BAR_1 1 -#define NTB_B2B_BAR_2 2 -#define NTB_B2B_BAR_3 3 -#define NTB_MAX_BARS 4 -#define NTB_MW_TO_BAR(mw) ((mw) + 1) - #define MAX_MSIX_INTERRUPTS MAX(XEON_DB_COUNT, SOC_DB_COUNT) -#define NTB_HB_TIMEOUT 1 /* second */ -#define SOC_LINK_RECOVERY_TIME 500 +#define NTB_HB_TIMEOUT 1 /* second */ +#define SOC_LINK_RECOVERY_TIME 500 /* ms */ #define DEVICE2SOFTC(dev) ((struct ntb_softc *) device_get_softc(dev)) @@ -78,6 +71,14 @@ enum ntb_device_type { NTB_SOC }; +enum ntb_bar { + NTB_CONFIG_BAR = 0, + NTB_B2B_BAR_1, + NTB_B2B_BAR_2, + NTB_B2B_BAR_3, + NTB_MAX_BARS +}; + /* Device features and workarounds */ #define HAS_FEATURE(feature) \ ((ntb->features & (feature)) != 0) @@ -132,12 +133,6 @@ struct ntb_softc { uint8_t max_cbs; struct { - uint8_t max_mw; - uint8_t max_spads; - uint8_t max_db_bits; - uint8_t msix_cnt; - } limits; - struct { uint32_t ldb; uint32_t ldb_mask; uint32_t rdb; @@ -153,10 +148,15 @@ struct ntb_softc { uint32_t ppd; uint8_t conn_type; uint8_t dev_type; - uint8_t bits_per_vector; uint8_t link_status; uint8_t link_width; uint8_t link_speed; + + uint8_t mw_count; + uint8_t spad_count; + uint8_t db_count; + uint8_t db_vec_count; + uint8_t db_vec_shift; }; #ifdef __i386__ @@ -189,9 +189,9 @@ bus_space_write_8(bus_space_tag_t tag, b #define ntb_reg_write(SIZE, offset, val) \ ntb_bar_write(SIZE, NTB_CONFIG_BAR, offset, val) #define ntb_mw_read(SIZE, offset) \ - ntb_bar_read(SIZE, NTB_MW_TO_BAR(ntb->limits.max_mw), offset) + ntb_bar_read(SIZE, ntb_mw_to_bar(ntb, ntb->mw_count), offset) #define ntb_mw_write(SIZE, offset, val) \ - ntb_bar_write(SIZE, NTB_MW_TO_BAR(ntb->limits.max_mw), \ + ntb_bar_write(SIZE, ntb_mw_to_bar(ntb, ntb->mw_count), \ offset, val) typedef int (*bar_map_strategy)(struct ntb_softc *ntb, @@ -200,6 +200,7 @@ typedef int (*bar_map_strategy)(struct n static int ntb_probe(device_t device); static int ntb_attach(device_t device); static int ntb_detach(device_t device); +static inline enum ntb_bar ntb_mw_to_bar(struct ntb_softc *, unsigned mw); static int ntb_map_pci_bars(struct ntb_softc *ntb); static int map_pci_bar(struct ntb_softc *ntb, bar_map_strategy strategy, struct ntb_pci_bar_info *bar); @@ -218,10 +219,10 @@ static void handle_xeon_irq(void *arg); static void handle_xeon_event_irq(void *arg); static void ntb_handle_legacy_interrupt(void *arg); static void ntb_irq_work(void *arg); -static uint64_t db_ioread(struct ntb_softc *, uint32_t regoff); -static void db_iowrite(struct ntb_softc *, uint32_t regoff, uint64_t val); -static void mask_ldb_interrupt(struct ntb_softc *ntb, unsigned int idx); -static void unmask_ldb_interrupt(struct ntb_softc *ntb, unsigned int idx); +static inline uint64_t ntb_db_read(struct ntb_softc *, uint64_t regoff); +static inline void ntb_db_write(struct ntb_softc *, uint64_t regoff, uint64_t val); +static inline void mask_ldb_interrupt(struct ntb_softc *ntb, unsigned int idx); +static inline void unmask_ldb_interrupt(struct ntb_softc *ntb, unsigned int idx); static int ntb_create_callbacks(struct ntb_softc *ntb, uint32_t num_vectors); static void ntb_free_callbacks(struct ntb_softc *ntb); static struct ntb_hw_info *ntb_get_device_info(uint32_t device_id); @@ -373,6 +374,16 @@ ntb_detach(device_t device) return (0); } +static inline enum ntb_bar +ntb_mw_to_bar(struct ntb_softc *ntb, unsigned mw) +{ + + KASSERT(mw < ntb->mw_count, ("%s: mw:%u > count:%u", __func__, mw, + (unsigned)ntb->mw_count)); + + return (NTB_B2B_BAR_1 + mw); +} + static int ntb_map_pci_bars(struct ntb_softc *ntb) { @@ -651,10 +662,10 @@ ntb_setup_interrupts(struct ntb_softc *n mask = 0; if (ntb->type == NTB_XEON) mask = (1 << XEON_DB_LINK); - db_iowrite(ntb, ntb->reg_ofs.ldb_mask, ~mask); + ntb_db_write(ntb, ntb->reg_ofs.ldb_mask, ~mask); num_vectors = desired_vectors = MIN(pci_msix_count(ntb->device), - ntb->limits.max_db_bits); + ntb->db_count); if (desired_vectors >= 1) { rc = pci_alloc_msix(ntb->device, &num_vectors); @@ -675,35 +686,37 @@ ntb_setup_interrupts(struct ntb_softc *n } else num_vectors = 1; - /* - * If allocating MSI-X interrupts succeeds, limit callbacks to the - * number of MSI-X slots available. - */ - ntb_create_callbacks(ntb, num_vectors); - - if (ntb->type == NTB_XEON) - rc = ntb_setup_xeon_msix(ntb, num_vectors); - else - rc = ntb_setup_soc_msix(ntb, num_vectors); - if (rc != 0) { - device_printf(ntb->device, - "Error allocating MSI-X interrupts: %d\n", rc); - + if (ntb->type == NTB_XEON && num_vectors < ntb->db_vec_count) { /* * If allocating MSI-X interrupts failed and we're forced to * use legacy INTx anyway, the only limit on individual * callbacks is the number of doorbell bits. - * - * CEM: This seems odd to me but matches the behavior of the - * Linux driver ca. September 2013 */ + ntb->db_vec_count = 1; + ntb->db_vec_shift = ntb->db_count; + ntb_create_callbacks(ntb, ntb->db_count); + rc = ntb_setup_legacy_interrupt(ntb); + } else { + ntb_create_callbacks(ntb, num_vectors); + if (ntb->type == NTB_XEON) + rc = ntb_setup_xeon_msix(ntb, num_vectors); + else + rc = ntb_setup_soc_msix(ntb, num_vectors); + if (rc == 0 && ntb->type == NTB_XEON) { + /* + * Prevent consumers from registering callbacks on the link event irq + * slot, from which they will never be called back. + */ + ntb->db_cb[num_vectors - 1].reserved = true; + ntb->max_cbs--; + } + } + if (rc != 0) { + device_printf(ntb->device, + "Error allocating interrupts: %d\n", rc); ntb_free_callbacks(ntb); - ntb_create_callbacks(ntb, ntb->limits.max_db_bits); } - if (ntb->type == NTB_XEON && rc == ENOSPC) - rc = ntb_setup_legacy_interrupt(ntb); - return (rc); } @@ -759,8 +772,8 @@ ntb_teardown_interrupts(struct ntb_softc * Doorbell register and mask are 64-bit on SoC, 16-bit on Xeon. Abstract it * out to make code clearer. */ -static uint64_t -db_ioread(struct ntb_softc *ntb, uint32_t regoff) +static inline uint64_t +ntb_db_read(struct ntb_softc *ntb, uint64_t regoff) { if (ntb->type == NTB_SOC) @@ -771,8 +784,8 @@ db_ioread(struct ntb_softc *ntb, uint32_ return (ntb_reg_read(2, regoff)); } -static void -db_iowrite(struct ntb_softc *ntb, uint32_t regoff, uint64_t val) +static inline void +ntb_db_write(struct ntb_softc *ntb, uint64_t regoff, uint64_t val) { if (ntb->type == NTB_SOC) { @@ -789,9 +802,9 @@ mask_ldb_interrupt(struct ntb_softc *ntb { uint64_t mask; - mask = db_ioread(ntb, ntb->reg_ofs.ldb_mask); - mask |= 1 << (idx * ntb->bits_per_vector); - db_iowrite(ntb, ntb->reg_ofs.ldb_mask, mask); + mask = ntb_db_read(ntb, ntb->reg_ofs.ldb_mask); + mask |= 1 << (idx * ntb->db_vec_shift); + ntb_db_write(ntb, ntb->reg_ofs.ldb_mask, mask); } static void @@ -799,9 +812,9 @@ unmask_ldb_interrupt(struct ntb_softc *n { uint64_t mask; - mask = db_ioread(ntb, ntb->reg_ofs.ldb_mask); - mask &= ~(1 << (idx * ntb->bits_per_vector)); - db_iowrite(ntb, ntb->reg_ofs.ldb_mask, mask); + mask = ntb_db_read(ntb, ntb->reg_ofs.ldb_mask); + mask &= ~(1 << (idx * ntb->db_vec_shift)); + ntb_db_write(ntb, ntb->reg_ofs.ldb_mask, mask); } static void @@ -810,7 +823,7 @@ handle_soc_irq(void *arg) struct ntb_db_cb *db_cb = arg; struct ntb_softc *ntb = db_cb->ntb; - db_iowrite(ntb, ntb->reg_ofs.ldb, (uint64_t) 1 << db_cb->db_num); + ntb_db_write(ntb, ntb->reg_ofs.ldb, (uint64_t) 1 << db_cb->db_num); if (db_cb->callback != NULL) { mask_ldb_interrupt(ntb, db_cb->db_num); @@ -830,9 +843,9 @@ handle_xeon_irq(void *arg) * vectors, with the 4th having a single bit for link * interrupts. */ - db_iowrite(ntb, ntb->reg_ofs.ldb, - ((1 << ntb->bits_per_vector) - 1) << - (db_cb->db_num * ntb->bits_per_vector)); + ntb_db_write(ntb, ntb->reg_ofs.ldb, + ((1 << ntb->db_vec_shift) - 1) << + (db_cb->db_num * ntb->db_vec_shift)); if (db_cb->callback != NULL) { mask_ldb_interrupt(ntb, db_cb->db_num); @@ -852,7 +865,7 @@ handle_xeon_event_irq(void *arg) device_printf(ntb->device, "Error determining link status\n"); /* bit 15 is always the link bit */ - db_iowrite(ntb, ntb->reg_ofs.ldb, 1 << XEON_DB_LINK); + ntb_db_write(ntb, ntb->reg_ofs.ldb, 1 << XEON_DB_LINK); } static void @@ -862,7 +875,7 @@ ntb_handle_legacy_interrupt(void *arg) unsigned int i; uint64_t ldb; - ldb = db_ioread(ntb, ntb->reg_ofs.ldb); + ldb = ntb_db_read(ntb, ntb->reg_ofs.ldb); if (ntb->type == NTB_XEON && (ldb & XEON_DB_LINK_BIT) != 0) { handle_xeon_event_irq(ntb); @@ -900,10 +913,14 @@ ntb_free_callbacks(struct ntb_softc *ntb { uint8_t i; + if (ntb->db_cb == NULL) + return; + for (i = 0; i < ntb->max_cbs; i++) ntb_unregister_db_callback(ntb, i); free(ntb->db_cb, M_NTB); + ntb->db_cb = NULL; ntb->max_cbs = 0; } @@ -932,14 +949,14 @@ ntb_detect_max_mw(struct ntb_softc *ntb) { if (ntb->type == NTB_SOC) { - ntb->limits.max_mw = SOC_MAX_MW; + ntb->mw_count = SOC_MW_COUNT; return; } if (HAS_FEATURE(NTB_SPLIT_BAR)) - ntb->limits.max_mw = XEON_HSXSPLIT_MAX_MW; + ntb->mw_count = XEON_HSX_SPLIT_MW_COUNT; else - ntb->limits.max_mw = XEON_SNB_MAX_MW; + ntb->mw_count = XEON_SNB_MW_COUNT; } static int @@ -1020,7 +1037,7 @@ ntb_setup_xeon(struct ntb_softc *ntb) ntb->reg_ofs.rdb = XEON_B2B_DOORBELL_OFFSET; ntb->reg_ofs.spad_remote = XEON_B2B_SPAD_OFFSET; - ntb->limits.max_spads = XEON_SPAD_COUNT; + ntb->spad_count = XEON_SPAD_COUNT; break; case NTB_CONN_RP: @@ -1063,7 +1080,7 @@ ntb_setup_xeon(struct ntb_softc *ntb) ntb_reg_write(8, XEON_PBAR4LMT_OFFSET, ntb_get_mw_size(ntb, 1) + 0x1000); /* Reserve the last MW for mapping remote spad */ - ntb->limits.max_mw--; + ntb->mw_count--; } else /* * Disable the limit register, just in case it is set to @@ -1076,9 +1093,9 @@ ntb_setup_xeon(struct ntb_softc *ntb) ntb->reg_ofs.lnk_stat = XEON_LINK_STATUS_OFFSET; ntb->reg_ofs.spci_cmd = XEON_PCICMD_OFFSET; - ntb->limits.max_db_bits = XEON_DB_COUNT; - ntb->limits.msix_cnt = XEON_DB_MSIX_VECTOR_COUNT; - ntb->bits_per_vector = XEON_DB_MSIX_VECTOR_SHIFT; + ntb->db_count = XEON_DB_COUNT; + ntb->db_vec_count = XEON_DB_MSIX_VECTOR_COUNT; + ntb->db_vec_shift = XEON_DB_MSIX_VECTOR_SHIFT; /* * HW Errata on bit 14 of b2bdoorbell register. Writes will not be @@ -1091,7 +1108,7 @@ ntb_setup_xeon(struct ntb_softc *ntb) if (HAS_FEATURE(NTB_B2BDOORBELL_BIT14) && !HAS_FEATURE(NTB_SDOORBELL_LOCKUP) && ntb->conn_type == NTB_CONN_B2B) - ntb->limits.max_db_bits = XEON_DB_COUNT - 1; + ntb->db_count = XEON_DB_COUNT - 1; configure_xeon_secondary_side_bars(ntb); @@ -1128,10 +1145,10 @@ ntb_setup_soc(struct ntb_softc *ntb) ntb->reg_ofs.spad_remote = SOC_B2B_SPAD_OFFSET; ntb->reg_ofs.spci_cmd = SOC_PCICMD_OFFSET; - ntb->limits.max_spads = SOC_SPAD_COUNT; - ntb->limits.max_db_bits = SOC_DB_COUNT; - ntb->limits.msix_cnt = SOC_DB_MSIX_VECTOR_COUNT; - ntb->bits_per_vector = SOC_DB_MSIX_VECTOR_SHIFT; + ntb->spad_count = SOC_SPAD_COUNT; + ntb->db_count = SOC_DB_COUNT; + ntb->db_vec_count = SOC_DB_MSIX_VECTOR_COUNT; + ntb->db_vec_shift = SOC_DB_MSIX_VECTOR_SHIFT; /* * FIXME - MSI-X bug on early SOC HW, remove once internal issue is @@ -1648,7 +1665,7 @@ uint8_t ntb_get_max_spads(struct ntb_softc *ntb) { - return (ntb->limits.max_spads); + return (ntb->spad_count); } uint8_t @@ -1659,10 +1676,10 @@ ntb_get_max_cbs(struct ntb_softc *ntb) } uint8_t -ntb_get_max_mw(struct ntb_softc *ntb) +ntb_mw_count(struct ntb_softc *ntb) { - return (ntb->limits.max_mw); + return (ntb->mw_count); } /** @@ -1680,7 +1697,7 @@ int ntb_write_local_spad(struct ntb_softc *ntb, unsigned int idx, uint32_t val) { - if (idx >= ntb->limits.max_spads) + if (idx >= ntb->spad_count) return (EINVAL); ntb_reg_write(4, ntb->reg_ofs.spad_local + idx * 4, val); @@ -1703,7 +1720,7 @@ int ntb_read_local_spad(struct ntb_softc *ntb, unsigned int idx, uint32_t *val) { - if (idx >= ntb->limits.max_spads) + if (idx >= ntb->spad_count) return (EINVAL); *val = ntb_reg_read(4, ntb->reg_ofs.spad_local + idx * 4); @@ -1726,7 +1743,7 @@ int ntb_write_remote_spad(struct ntb_softc *ntb, unsigned int idx, uint32_t val) { - if (idx >= ntb->limits.max_spads) + if (idx >= ntb->spad_count) return (EINVAL); if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP)) @@ -1752,7 +1769,7 @@ int ntb_read_remote_spad(struct ntb_softc *ntb, unsigned int idx, uint32_t *val) { - if (idx >= ntb->limits.max_spads) + if (idx >= ntb->spad_count) return (EINVAL); if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP)) @@ -1777,20 +1794,20 @@ void * ntb_get_mw_vbase(struct ntb_softc *ntb, unsigned int mw) { - if (mw >= ntb_get_max_mw(ntb)) + if (mw >= ntb_mw_count(ntb)) return (NULL); - return (ntb->bar_info[NTB_MW_TO_BAR(mw)].vbase); + return (ntb->bar_info[ntb_mw_to_bar(ntb, mw)].vbase); } vm_paddr_t ntb_get_mw_pbase(struct ntb_softc *ntb, unsigned int mw) { - if (mw >= ntb_get_max_mw(ntb)) + if (mw >= ntb_mw_count(ntb)) return (0); - return (ntb->bar_info[NTB_MW_TO_BAR(mw)].pbase); + return (ntb->bar_info[ntb_mw_to_bar(ntb, mw)].pbase); } /** @@ -1806,10 +1823,10 @@ u_long ntb_get_mw_size(struct ntb_softc *ntb, unsigned int mw) { - if (mw >= ntb_get_max_mw(ntb)) + if (mw >= ntb_mw_count(ntb)) return (0); - return (ntb->bar_info[NTB_MW_TO_BAR(mw)].size); + return (ntb->bar_info[ntb_mw_to_bar(ntb, mw)].size); } /** @@ -1826,10 +1843,10 @@ void ntb_set_mw_addr(struct ntb_softc *ntb, unsigned int mw, uint64_t addr) { - if (mw >= ntb_get_max_mw(ntb)) + if (mw >= ntb_mw_count(ntb)) return; - switch (NTB_MW_TO_BAR(mw)) { + switch (ntb_mw_to_bar(ntb, mw)) { case NTB_B2B_BAR_1: ntb_reg_write(8, ntb->reg_ofs.bar2_xlat, addr); break; @@ -1842,6 +1859,9 @@ ntb_set_mw_addr(struct ntb_softc *ntb, u case NTB_B2B_BAR_3: ntb_reg_write(4, ntb->reg_ofs.bar5_xlat, addr); break; + default: + KASSERT(false, ("invalid BAR")); + break; } } @@ -1861,15 +1881,15 @@ ntb_ring_doorbell(struct ntb_softc *ntb, if (ntb->type == NTB_SOC) bit = 1 << db; else - bit = ((1 << ntb->bits_per_vector) - 1) << - (db * ntb->bits_per_vector); + bit = ((1 << ntb->db_vec_shift) - 1) << + (db * ntb->db_vec_shift); if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP)) { ntb_mw_write(2, XEON_SHADOW_PDOORBELL_OFFSET, bit); return; } - db_iowrite(ntb, ntb->reg_ofs.rdb, bit); + ntb_db_write(ntb, ntb->reg_ofs.rdb, bit); } /** Modified: head/sys/dev/ntb/ntb_hw/ntb_hw.h ============================================================================== --- head/sys/dev/ntb/ntb_hw/ntb_hw.h Sun Oct 18 20:19:44 2015 (r289538) +++ head/sys/dev/ntb/ntb_hw/ntb_hw.h Sun Oct 18 20:19:53 2015 (r289539) @@ -62,7 +62,7 @@ struct ntb_softc *ntb_register_transport void *transport); void ntb_unregister_transport(struct ntb_softc *ntb); uint8_t ntb_get_max_cbs(struct ntb_softc *ntb); -uint8_t ntb_get_max_mw(struct ntb_softc *ntb); +uint8_t ntb_mw_count(struct ntb_softc *ntb); uint8_t ntb_get_max_spads(struct ntb_softc *ntb); int ntb_write_local_spad(struct ntb_softc *ntb, unsigned int idx, uint32_t val); int ntb_read_local_spad(struct ntb_softc *ntb, unsigned int idx, uint32_t *val); Modified: head/sys/dev/ntb/ntb_hw/ntb_regs.h ============================================================================== --- head/sys/dev/ntb/ntb_hw/ntb_regs.h Sun Oct 18 20:19:44 2015 (r289538) +++ head/sys/dev/ntb/ntb_hw/ntb_regs.h Sun Oct 18 20:19:53 2015 (r289539) @@ -33,8 +33,8 @@ #define NTB_LINK_SPEED_MASK 0x000f #define NTB_LINK_WIDTH_MASK 0x03f0 -#define XEON_SNB_MAX_MW 2 -#define XEON_HSXSPLIT_MAX_MW 3 +#define XEON_SNB_MW_COUNT 2 +#define XEON_HSX_SPLIT_MW_COUNT 3 /* Reserve the uppermost bit for link interrupt */ #define XEON_DB_COUNT 15 #define XEON_DB_LINK 15 @@ -79,7 +79,7 @@ #define XEON_B2B_XLAT_OFFSETL 0x0144 #define XEON_B2B_XLAT_OFFSETU 0x0148 -#define SOC_MAX_MW 2 +#define SOC_MW_COUNT 2 #define SOC_DB_COUNT 34 #define SOC_DB_MSIX_VECTOR_COUNT 34 #define SOC_DB_MSIX_VECTOR_SHIFT 1 From owner-svn-src-head@freebsd.org Sun Oct 18 20:20:04 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1E71BA1850B; Sun, 18 Oct 2015 20:20:04 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D17F2151F; Sun, 18 Oct 2015 20:20:03 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IKK2XF092850; Sun, 18 Oct 2015 20:20:02 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IKK2ia092849; Sun, 18 Oct 2015 20:20:02 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201510182020.t9IKK2ia092849@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Sun, 18 Oct 2015 20:20:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289540 - head/sys/dev/ntb/ntb_hw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 20:20:04 -0000 Author: cem Date: Sun Oct 18 20:20:02 2015 New Revision: 289540 URL: https://svnweb.freebsd.org/changeset/base/289540 Log: NTB: Simplify interrupt handling by merging SoC/Xeon Some interrupt-related function names changed to match Linux. No functional change. Still part of the huge e26a5843 rewrite in Linux. Obtained from: Linux (e26a5843) (Dual BSD/GPL driver) Sponsored by: EMC / Isilon Storage Division Modified: head/sys/dev/ntb/ntb_hw/ntb_hw.c Modified: head/sys/dev/ntb/ntb_hw/ntb_hw.c ============================================================================== --- head/sys/dev/ntb/ntb_hw/ntb_hw.c Sun Oct 18 20:19:53 2015 (r289539) +++ head/sys/dev/ntb/ntb_hw/ntb_hw.c Sun Oct 18 20:20:02 2015 (r289540) @@ -209,14 +209,12 @@ static int map_memory_window_bar(struct struct ntb_pci_bar_info *bar); static void ntb_unmap_pci_bar(struct ntb_softc *ntb); static int ntb_remap_msix(device_t, uint32_t desired, uint32_t avail); -static int ntb_setup_interrupts(struct ntb_softc *ntb); +static int ntb_init_isr(struct ntb_softc *ntb); static int ntb_setup_legacy_interrupt(struct ntb_softc *ntb); -static int ntb_setup_xeon_msix(struct ntb_softc *ntb, uint32_t num_vectors); -static int ntb_setup_soc_msix(struct ntb_softc *ntb, uint32_t num_vectors); +static int ntb_setup_msix(struct ntb_softc *ntb, uint32_t num_vectors); static void ntb_teardown_interrupts(struct ntb_softc *ntb); -static void handle_soc_irq(void *arg); -static void handle_xeon_irq(void *arg); -static void handle_xeon_event_irq(void *arg); +static inline uint64_t ntb_vec_mask(struct ntb_softc *, uint64_t db_vector); +static void handle_irq(void *arg); static void ntb_handle_legacy_interrupt(void *arg); static void ntb_irq_work(void *arg); static inline uint64_t ntb_db_read(struct ntb_softc *, uint64_t regoff); @@ -340,7 +338,7 @@ ntb_attach(device_t device) error = ntb_setup_xeon(ntb); if (error) goto out; - error = ntb_setup_interrupts(ntb); + error = ntb_init_isr(ntb); if (error) goto out; @@ -526,55 +524,7 @@ ntb_unmap_pci_bar(struct ntb_softc *ntb) } static int -ntb_setup_xeon_msix(struct ntb_softc *ntb, uint32_t num_vectors) -{ - void (*interrupt_handler)(void *); - void *int_arg; - uint32_t i; - int rc; - - if (num_vectors < 4) - return (ENOSPC); - - for (i = 0; i < num_vectors; i++) { - ntb->int_info[i].rid = i + 1; - ntb->int_info[i].res = bus_alloc_resource_any(ntb->device, - SYS_RES_IRQ, &ntb->int_info[i].rid, RF_ACTIVE); - if (ntb->int_info[i].res == NULL) { - device_printf(ntb->device, - "bus_alloc_resource failed\n"); - return (ENOMEM); - } - ntb->int_info[i].tag = NULL; - ntb->allocated_interrupts++; - if (i == num_vectors - 1) { - interrupt_handler = handle_xeon_event_irq; - int_arg = ntb; - } else { - interrupt_handler = handle_xeon_irq; - int_arg = &ntb->db_cb[i]; - } - rc = bus_setup_intr(ntb->device, ntb->int_info[i].res, - INTR_MPSAFE | INTR_TYPE_MISC, NULL, interrupt_handler, - int_arg, &ntb->int_info[i].tag); - if (rc != 0) { - device_printf(ntb->device, - "bus_setup_intr failed\n"); - return (ENXIO); - } - } - - /* - * Prevent consumers from registering callbacks on the link event irq - * slot, from which they will never be called back. - */ - ntb->db_cb[num_vectors - 1].reserved = true; - ntb->max_cbs--; - return (0); -} - -static int -ntb_setup_soc_msix(struct ntb_softc *ntb, uint32_t num_vectors) +ntb_setup_msix(struct ntb_softc *ntb, uint32_t num_vectors) { uint32_t i; int rc; @@ -591,7 +541,7 @@ ntb_setup_soc_msix(struct ntb_softc *ntb ntb->int_info[i].tag = NULL; ntb->allocated_interrupts++; rc = bus_setup_intr(ntb->device, ntb->int_info[i].res, - INTR_MPSAFE | INTR_TYPE_MISC, NULL, handle_soc_irq, + INTR_MPSAFE | INTR_TYPE_MISC, NULL, handle_irq, &ntb->db_cb[i], &ntb->int_info[i].tag); if (rc != 0) { device_printf(ntb->device, "bus_setup_intr failed\n"); @@ -647,7 +597,7 @@ ntb_remap_msix(device_t dev, uint32_t de } static int -ntb_setup_interrupts(struct ntb_softc *ntb) +ntb_init_isr(struct ntb_softc *ntb) { uint32_t desired_vectors, num_vectors; uint64_t mask; @@ -698,10 +648,7 @@ ntb_setup_interrupts(struct ntb_softc *n rc = ntb_setup_legacy_interrupt(ntb); } else { ntb_create_callbacks(ntb, num_vectors); - if (ntb->type == NTB_XEON) - rc = ntb_setup_xeon_msix(ntb, num_vectors); - else - rc = ntb_setup_soc_msix(ntb, num_vectors); + rc = ntb_setup_msix(ntb, num_vectors); if (rc == 0 && ntb->type == NTB_XEON) { /* * Prevent consumers from registering callbacks on the link event irq @@ -807,7 +754,7 @@ mask_ldb_interrupt(struct ntb_softc *ntb ntb_db_write(ntb, ntb->reg_ofs.ldb_mask, mask); } -static void +static inline void unmask_ldb_interrupt(struct ntb_softc *ntb, unsigned int idx) { uint64_t mask; @@ -817,55 +764,42 @@ unmask_ldb_interrupt(struct ntb_softc *n ntb_db_write(ntb, ntb->reg_ofs.ldb_mask, mask); } -static void -handle_soc_irq(void *arg) +static inline uint64_t +ntb_vec_mask(struct ntb_softc *ntb, uint64_t db_vector) { - struct ntb_db_cb *db_cb = arg; - struct ntb_softc *ntb = db_cb->ntb; - - ntb_db_write(ntb, ntb->reg_ofs.ldb, (uint64_t) 1 << db_cb->db_num); + uint64_t shift, mask; - if (db_cb->callback != NULL) { - mask_ldb_interrupt(ntb, db_cb->db_num); - callout_reset(&db_cb->irq_work, 0, ntb_irq_work, db_cb); - } + shift = ntb->db_vec_shift; + mask = (1ull << shift) - 1; + return (mask << (shift * db_vector)); } static void -handle_xeon_irq(void *arg) +handle_irq(void *arg) { struct ntb_db_cb *db_cb = arg; struct ntb_softc *ntb = db_cb->ntb; + uint64_t vec_mask; + int rc; - /* - * On Xeon, there are 16 bits in the interrupt register - * but only 4 vectors. So, 5 bits are assigned to the first 3 - * vectors, with the 4th having a single bit for link - * interrupts. - */ - ntb_db_write(ntb, ntb->reg_ofs.ldb, - ((1 << ntb->db_vec_shift) - 1) << - (db_cb->db_num * ntb->db_vec_shift)); + vec_mask = ntb_vec_mask(ntb, db_cb->db_num); + + if (ntb->type == NTB_XEON && (vec_mask & XEON_DB_LINK_BIT) != 0) { + rc = ntb_check_link_status(ntb); + if (rc != 0) + device_printf(ntb->device, + "Error determining link status\n"); + } if (db_cb->callback != NULL) { + KASSERT(!db_cb->reserved, ("user callback on link event cb")); mask_ldb_interrupt(ntb, db_cb->db_num); - callout_reset(&db_cb->irq_work, 0, ntb_irq_work, db_cb); } -} -/* Since we do not have a HW doorbell in SOC, this is only used in JF/JT */ -static void -handle_xeon_event_irq(void *arg) -{ - struct ntb_softc *ntb = arg; - int rc; + ntb_db_write(ntb, ntb->reg_ofs.ldb, vec_mask); - rc = ntb_check_link_status(ntb); - if (rc != 0) - device_printf(ntb->device, "Error determining link status\n"); - - /* bit 15 is always the link bit */ - ntb_db_write(ntb, ntb->reg_ofs.ldb, 1 << XEON_DB_LINK); + if (db_cb->callback != NULL) + callout_reset(&db_cb->irq_work, 0, ntb_irq_work, db_cb); } static void @@ -876,19 +810,10 @@ ntb_handle_legacy_interrupt(void *arg) uint64_t ldb; ldb = ntb_db_read(ntb, ntb->reg_ofs.ldb); - - if (ntb->type == NTB_XEON && (ldb & XEON_DB_LINK_BIT) != 0) { - handle_xeon_event_irq(ntb); - ldb &= ~XEON_DB_LINK_BIT; - } - while (ldb != 0) { i = ffs(ldb); ldb &= ldb - 1; - if (ntb->type == NTB_SOC) - handle_soc_irq(&ntb->db_cb[i]); - else - handle_xeon_irq(&ntb->db_cb[i]); + handle_irq(&ntb->db_cb[i]); } } From owner-svn-src-head@freebsd.org Sun Oct 18 20:20:12 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C2480A18550; Sun, 18 Oct 2015 20:20:12 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 933C417A8; Sun, 18 Oct 2015 20:20:12 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IKKBZ6092898; Sun, 18 Oct 2015 20:20:11 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IKKBC8092897; Sun, 18 Oct 2015 20:20:11 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201510182020.t9IKKBC8092897@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Sun, 18 Oct 2015 20:20:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289541 - head/sys/dev/ntb/ntb_hw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 20:20:13 -0000 Author: cem Date: Sun Oct 18 20:20:11 2015 New Revision: 289541 URL: https://svnweb.freebsd.org/changeset/base/289541 Log: NTB: Simplify ntb_map_pci_bars Skip using a function pointer for shared error logging. Sponsored by: EMC / Isilon Storage Division Modified: head/sys/dev/ntb/ntb_hw/ntb_hw.c Modified: head/sys/dev/ntb/ntb_hw/ntb_hw.c ============================================================================== --- head/sys/dev/ntb/ntb_hw/ntb_hw.c Sun Oct 18 20:20:02 2015 (r289540) +++ head/sys/dev/ntb/ntb_hw/ntb_hw.c Sun Oct 18 20:20:11 2015 (r289541) @@ -194,16 +194,12 @@ bus_space_write_8(bus_space_tag_t tag, b ntb_bar_write(SIZE, ntb_mw_to_bar(ntb, ntb->mw_count), \ offset, val) -typedef int (*bar_map_strategy)(struct ntb_softc *ntb, - struct ntb_pci_bar_info *bar); - static int ntb_probe(device_t device); static int ntb_attach(device_t device); static int ntb_detach(device_t device); static inline enum ntb_bar ntb_mw_to_bar(struct ntb_softc *, unsigned mw); static int ntb_map_pci_bars(struct ntb_softc *ntb); -static int map_pci_bar(struct ntb_softc *ntb, bar_map_strategy strategy, - struct ntb_pci_bar_info *bar); +static void print_map_success(struct ntb_softc *, struct ntb_pci_bar_info *); static int map_mmr_bar(struct ntb_softc *ntb, struct ntb_pci_bar_info *bar); static int map_memory_window_bar(struct ntb_softc *ntb, struct ntb_pci_bar_info *bar); @@ -388,53 +384,44 @@ ntb_map_pci_bars(struct ntb_softc *ntb) int rc; ntb->bar_info[NTB_CONFIG_BAR].pci_resource_id = PCIR_BAR(0); - rc = map_pci_bar(ntb, map_mmr_bar, &ntb->bar_info[NTB_CONFIG_BAR]); + rc = map_mmr_bar(ntb, &ntb->bar_info[NTB_CONFIG_BAR]); if (rc != 0) - return (rc); + goto out; ntb->bar_info[NTB_B2B_BAR_1].pci_resource_id = PCIR_BAR(2); - rc = map_pci_bar(ntb, map_memory_window_bar, - &ntb->bar_info[NTB_B2B_BAR_1]); + rc = map_memory_window_bar(ntb, &ntb->bar_info[NTB_B2B_BAR_1]); if (rc != 0) - return (rc); + goto out; ntb->bar_info[NTB_B2B_BAR_2].pci_resource_id = PCIR_BAR(4); if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP) && !HAS_FEATURE(NTB_SPLIT_BAR)) - rc = map_pci_bar(ntb, map_mmr_bar, - &ntb->bar_info[NTB_B2B_BAR_2]); + rc = map_mmr_bar(ntb, &ntb->bar_info[NTB_B2B_BAR_2]); else - rc = map_pci_bar(ntb, map_memory_window_bar, - &ntb->bar_info[NTB_B2B_BAR_2]); + rc = map_memory_window_bar(ntb, &ntb->bar_info[NTB_B2B_BAR_2]); if (!HAS_FEATURE(NTB_SPLIT_BAR)) - return (rc); + goto out; ntb->bar_info[NTB_B2B_BAR_3].pci_resource_id = PCIR_BAR(5); if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP)) - rc = map_pci_bar(ntb, map_mmr_bar, - &ntb->bar_info[NTB_B2B_BAR_3]); + rc = map_mmr_bar(ntb, &ntb->bar_info[NTB_B2B_BAR_3]); else - rc = map_pci_bar(ntb, map_memory_window_bar, - &ntb->bar_info[NTB_B2B_BAR_3]); - return (rc); -} + rc = map_memory_window_bar(ntb, &ntb->bar_info[NTB_B2B_BAR_3]); -static int -map_pci_bar(struct ntb_softc *ntb, bar_map_strategy strategy, - struct ntb_pci_bar_info *bar) -{ - int rc; - - rc = strategy(ntb, bar); +out: if (rc != 0) device_printf(ntb->device, "unable to allocate pci resource\n"); - else - device_printf(ntb->device, - "Bar size = %lx, v %p, p %p\n", - bar->size, bar->vbase, (void *)(bar->pbase)); return (rc); } +static void +print_map_success(struct ntb_softc *ntb, struct ntb_pci_bar_info *bar) +{ + + device_printf(ntb->device, "Bar size = %lx, v %p, p %p\n", + bar->size, bar->vbase, (void *)(bar->pbase)); +} + static int map_mmr_bar(struct ntb_softc *ntb, struct ntb_pci_bar_info *bar) { @@ -445,6 +432,7 @@ map_mmr_bar(struct ntb_softc *ntb, struc return (ENXIO); save_bar_parameters(bar); + print_map_success(ntb, bar); return (0); } @@ -505,6 +493,7 @@ map_memory_window_bar(struct ntb_softc * "unable to mark bar as WRITE_COMBINING\n"); return (rc); } + print_map_success(ntb, bar); return (0); } From owner-svn-src-head@freebsd.org Sun Oct 18 20:20:22 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6BD18A1859F; Sun, 18 Oct 2015 20:20:22 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 05FEF1929; Sun, 18 Oct 2015 20:20:21 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IKKLbn092947; Sun, 18 Oct 2015 20:20:21 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IKKLdU092945; Sun, 18 Oct 2015 20:20:21 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201510182020.t9IKKLdU092945@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Sun, 18 Oct 2015 20:20:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289542 - head/sys/dev/ntb/ntb_hw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 20:20:22 -0000 Author: cem Date: Sun Oct 18 20:20:20 2015 New Revision: 289542 URL: https://svnweb.freebsd.org/changeset/base/289542 Log: NTB: "Split ntb_hw_intel and ntb_transport drivers" This Linux commit was more or less a rewrite. Unfortunately, the commit log does not give a lot of context for the rewrite. I have tried to faithfully follow the changes made upstream, including matching function names where possible, while churning the FreeBSD driver as little as possible. This is the bulk of the rewrite. There are two groups of changes to follow in separate commits: fleshing out the rest of the changes to xeon_setup_b2b_mw(), and some changes to if_ntb. Yes, this is a big patch (3 files changed, 416 insertions(+), 237 deletions(-)), but the Linux patch was 13 files changed, 2,589 additions(+) and 2,195 deletions(-). Original Linux commit log: Change ntb_hw_intel to use the new NTB hardware abstraction layer. Split ntb_transport into its own driver. Change it to use the new NTB hardware abstraction layer. Authored by: Allen Hubbe Obtained from: Linux (e26a5843) (Dual BSD/GPL driver) Sponsored by: EMC / Isilon Storage Division Modified: head/sys/dev/ntb/ntb_hw/ntb_hw.c head/sys/dev/ntb/ntb_hw/ntb_hw.h head/sys/dev/ntb/ntb_hw/ntb_regs.h Modified: head/sys/dev/ntb/ntb_hw/ntb_hw.c ============================================================================== --- head/sys/dev/ntb/ntb_hw/ntb_hw.c Sun Oct 18 20:20:11 2015 (r289541) +++ head/sys/dev/ntb/ntb_hw/ntb_hw.c Sun Oct 18 20:20:20 2015 (r289542) @@ -1,5 +1,6 @@ /*- * Copyright (C) 2013 Intel Corporation + * Copyright (C) 2015 EMC Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -115,6 +116,33 @@ struct ntb_db_cb { bool reserved; }; +struct ntb_reg { + uint32_t ntb_ctl; + uint32_t lnk_sta; + uint8_t db_size; + unsigned mw_bar[NTB_MAX_BARS]; +}; + +struct ntb_alt_reg { + uint32_t db_bell; + uint32_t db_mask; + uint32_t spad; +}; + +struct ntb_xlat_reg { + uint64_t bar0_base; + uint64_t bar2_xlat; + uint64_t bar2_limit; +}; + +struct ntb_b2b_addr { + uint64_t bar0_addr; + uint64_t bar2_addr64; + uint64_t bar4_addr64; + uint64_t bar4_addr32; + uint64_t bar5_addr32; +}; + struct ntb_softc { device_t device; enum ntb_device_type type; @@ -135,14 +163,9 @@ struct ntb_softc { struct { uint32_t ldb; uint32_t ldb_mask; - uint32_t rdb; - uint32_t bar2_xlat; uint32_t bar4_xlat; uint32_t bar5_xlat; - uint32_t spad_remote; uint32_t spad_local; - uint32_t lnk_cntl; - uint32_t lnk_stat; uint32_t spci_cmd; } reg_ofs; uint32_t ppd; @@ -152,11 +175,36 @@ struct ntb_softc { uint8_t link_width; uint8_t link_speed; + /* Offset of peer bar0 in B2B BAR */ + uint64_t b2b_off; + /* Memory window used to access peer bar0 */ + uint8_t b2b_mw_idx; + uint8_t mw_count; uint8_t spad_count; uint8_t db_count; uint8_t db_vec_count; uint8_t db_vec_shift; + + /* Protects local DB mask and (h). */ +#define HW_LOCK(sc) mtx_lock_spin(&(sc)->db_mask_lock) +#define HW_UNLOCK(sc) mtx_unlock_spin(&(sc)->db_mask_lock) +#define HW_ASSERT(sc,f) mtx_assert(&(sc)->db_mask_lock, (f)) + struct mtx db_mask_lock; + + uint32_t ntb_ctl; /* (h) - SOC only */ + uint32_t lnk_sta; /* (h) - SOC only */ + + uint64_t db_valid_mask; + uint64_t db_link_mask; + uint64_t db_mask; /* (h) */ + + int last_ts; /* ticks @ last irq */ + + const struct ntb_reg *reg; + const struct ntb_alt_reg *self_reg; + const struct ntb_alt_reg *peer_reg; + const struct ntb_xlat_reg *xlat_reg; }; #ifdef __i386__ @@ -189,9 +237,9 @@ bus_space_write_8(bus_space_tag_t tag, b #define ntb_reg_write(SIZE, offset, val) \ ntb_bar_write(SIZE, NTB_CONFIG_BAR, offset, val) #define ntb_mw_read(SIZE, offset) \ - ntb_bar_read(SIZE, ntb_mw_to_bar(ntb, ntb->mw_count), offset) + ntb_bar_read(SIZE, ntb_mw_to_bar(ntb, ntb->b2b_mw_idx), offset) #define ntb_mw_write(SIZE, offset, val) \ - ntb_bar_write(SIZE, ntb_mw_to_bar(ntb, ntb->mw_count), \ + ntb_bar_write(SIZE, ntb_mw_to_bar(ntb, ntb->b2b_mw_idx), \ offset, val) static int ntb_probe(device_t device); @@ -217,23 +265,27 @@ static inline uint64_t ntb_db_read(struc static inline void ntb_db_write(struct ntb_softc *, uint64_t regoff, uint64_t val); static inline void mask_ldb_interrupt(struct ntb_softc *ntb, unsigned int idx); static inline void unmask_ldb_interrupt(struct ntb_softc *ntb, unsigned int idx); +static inline void ntb_db_set_mask(struct ntb_softc *, uint64_t bits); +static inline void ntb_db_clear_mask(struct ntb_softc *, uint64_t bits); static int ntb_create_callbacks(struct ntb_softc *ntb, uint32_t num_vectors); static void ntb_free_callbacks(struct ntb_softc *ntb); static struct ntb_hw_info *ntb_get_device_info(uint32_t device_id); static void ntb_detect_max_mw(struct ntb_softc *ntb); static int ntb_detect_xeon(struct ntb_softc *ntb); static int ntb_detect_soc(struct ntb_softc *ntb); -static int ntb_setup_xeon(struct ntb_softc *ntb); -static int ntb_setup_soc(struct ntb_softc *ntb); +static int ntb_xeon_init_dev(struct ntb_softc *ntb); +static int ntb_soc_init_dev(struct ntb_softc *ntb); static void ntb_teardown_xeon(struct ntb_softc *ntb); static void configure_soc_secondary_side_bars(struct ntb_softc *ntb); static void configure_xeon_secondary_side_bars(struct ntb_softc *ntb); -static void ntb_handle_heartbeat(void *arg); +static int xeon_setup_b2b_mw(struct ntb_softc *, + const struct ntb_b2b_addr *addr, const struct ntb_b2b_addr *peer_addr); +static void soc_link_hb(void *arg); static void ntb_handle_link_event(struct ntb_softc *ntb, int link_state); -static void ntb_hw_link_down(struct ntb_softc *ntb); -static void ntb_hw_link_up(struct ntb_softc *ntb); +static void ntb_link_disable(struct ntb_softc *ntb); +static void ntb_link_enable(struct ntb_softc *ntb); static void recover_soc_link(void *arg); -static int ntb_check_link_status(struct ntb_softc *ntb); +static int ntb_poll_link(struct ntb_softc *ntb); static void save_bar_parameters(struct ntb_pci_bar_info *bar); static struct ntb_hw_info pci_ids[] = { @@ -257,6 +309,61 @@ static struct ntb_hw_info pci_ids[] = { { 0x00000000, NULL, NTB_SOC, 0 } }; +static const struct ntb_reg soc_reg = { + .ntb_ctl = SOC_NTBCNTL_OFFSET, + .lnk_sta = SOC_LINK_STATUS_OFFSET, + .db_size = sizeof(uint64_t), + .mw_bar = { NTB_B2B_BAR_1, NTB_B2B_BAR_2 }, +}; + +static const struct ntb_alt_reg soc_b2b_reg = { + .db_bell = SOC_B2B_DOORBELL_OFFSET, + .spad = SOC_B2B_SPAD_OFFSET, +}; + +static const struct ntb_xlat_reg soc_sec_xlat = { +#if 0 + /* "FIXME" says the Linux driver. */ + .bar0_base = SOC_SBAR0BASE_OFFSET, + .bar2_limit = SOC_SBAR2LMT_OFFSET, +#endif + .bar2_xlat = SOC_SBAR2XLAT_OFFSET, +}; + +static const struct ntb_reg xeon_reg = { + .ntb_ctl = XEON_NTBCNTL_OFFSET, + .lnk_sta = XEON_LINK_STATUS_OFFSET, + .db_size = sizeof(uint16_t), + .mw_bar = { NTB_B2B_BAR_1, NTB_B2B_BAR_2, NTB_B2B_BAR_3 }, +}; + +static const struct ntb_alt_reg xeon_b2b_reg = { + .db_bell = XEON_B2B_DOORBELL_OFFSET, + .spad = XEON_B2B_SPAD_OFFSET, +}; + +static const struct ntb_xlat_reg xeon_sec_xlat = { + .bar0_base = XEON_SBAR0BASE_OFFSET, + .bar2_limit = XEON_SBAR2LMT_OFFSET, + .bar2_xlat = XEON_SBAR2XLAT_OFFSET, +}; + +static const struct ntb_b2b_addr xeon_b2b_usd_addr = { + .bar0_addr = XEON_B2B_BAR0_USD_ADDR, + .bar2_addr64 = XEON_B2B_BAR2_USD_ADDR64, + .bar4_addr64 = XEON_B2B_BAR4_USD_ADDR64, + .bar4_addr32 = XEON_B2B_BAR4_USD_ADDR32, + .bar5_addr32 = XEON_B2B_BAR5_USD_ADDR32, +}; + +static const struct ntb_b2b_addr xeon_b2b_dsd_addr = { + .bar0_addr = XEON_B2B_BAR0_DSD_ADDR, + .bar2_addr64 = XEON_B2B_BAR2_DSD_ADDR64, + .bar4_addr64 = XEON_B2B_BAR4_DSD_ADDR64, + .bar4_addr32 = XEON_B2B_BAR4_DSD_ADDR32, + .bar5_addr32 = XEON_B2B_BAR5_DSD_ADDR32, +}; + /* * OS <-> Driver interface structures */ @@ -311,10 +418,12 @@ ntb_attach(device_t device) ntb->device = device; ntb->type = p->type; ntb->features = p->features; + ntb->b2b_mw_idx = UINT8_MAX; /* Heartbeat timer for NTB_SOC since there is no link interrupt */ callout_init(&ntb->heartbeat_timer, 1); callout_init(&ntb->lr_timer, 1); + mtx_init(&ntb->db_mask_lock, "ntb hw bits", NULL, MTX_SPIN); if (ntb->type == NTB_SOC) error = ntb_detect_soc(ntb); @@ -329,9 +438,9 @@ ntb_attach(device_t device) if (error) goto out; if (ntb->type == NTB_SOC) - error = ntb_setup_soc(ntb); + error = ntb_soc_init_dev(ntb); else - error = ntb_setup_xeon(ntb); + error = ntb_xeon_init_dev(ntb); if (error) goto out; error = ntb_init_isr(ntb); @@ -352,12 +461,16 @@ ntb_detach(device_t device) struct ntb_softc *ntb; ntb = DEVICE2SOFTC(device); + + ntb_db_set_mask(ntb, ntb->db_valid_mask); callout_drain(&ntb->heartbeat_timer); callout_drain(&ntb->lr_timer); if (ntb->type == NTB_XEON) ntb_teardown_xeon(ntb); ntb_teardown_interrupts(ntb); + mtx_destroy(&ntb->db_mask_lock); + /* * Redetect total MWs so we unmap properly -- in case we lowered the * maximum to work around Xeon errata. @@ -368,14 +481,17 @@ ntb_detach(device_t device) return (0); } +/* + * Driver internal routines + */ static inline enum ntb_bar ntb_mw_to_bar(struct ntb_softc *ntb, unsigned mw) { - KASSERT(mw < ntb->mw_count, ("%s: mw:%u > count:%u", __func__, mw, - (unsigned)ntb->mw_count)); + KASSERT(mw < ntb->mw_count || (mw != UINT8_MAX && mw == ntb->b2b_mw_idx), + ("%s: mw:%u > count:%u", __func__, mw, (unsigned)ntb->mw_count)); - return (NTB_B2B_BAR_1 + mw); + return (ntb->reg->mw_bar[mw]); } static int @@ -593,15 +709,16 @@ ntb_init_isr(struct ntb_softc *ntb) int rc; ntb->allocated_interrupts = 0; + ntb->last_ts = ticks; /* * On SOC, disable all interrupts. On XEON, disable all but Link * Interrupt. The rest will be unmasked as callbacks are registered. */ - mask = 0; + mask = ntb->db_valid_mask; if (ntb->type == NTB_XEON) - mask = (1 << XEON_DB_LINK); - ntb_db_write(ntb, ntb->reg_ofs.ldb_mask, ~mask); + mask &= ~ntb->db_link_mask; + ntb_db_set_mask(ntb, mask); num_vectors = desired_vectors = MIN(pci_msix_count(ntb->device), ntb->db_count); @@ -724,6 +841,14 @@ static inline void ntb_db_write(struct ntb_softc *ntb, uint64_t regoff, uint64_t val) { + KASSERT((val & ~ntb->db_valid_mask) == 0, + ("%s: Invalid bits 0x%jx (valid: 0x%jx)", __func__, + (uintmax_t)(val & ~ntb->db_valid_mask), + (uintmax_t)ntb->db_valid_mask)); + + if (regoff == ntb->reg_ofs.ldb_mask) + HW_ASSERT(ntb, MA_OWNED); + if (ntb->type == NTB_SOC) { ntb_reg_write(8, regoff, val); return; @@ -733,14 +858,38 @@ ntb_db_write(struct ntb_softc *ntb, uint ntb_reg_write(2, regoff, (uint16_t)val); } -static void +static inline void +ntb_db_set_mask(struct ntb_softc *ntb, uint64_t bits) +{ + + HW_LOCK(ntb); + ntb->db_mask |= bits; + ntb_db_write(ntb, ntb->reg_ofs.ldb_mask, ntb->db_mask); + HW_UNLOCK(ntb); +} + +static inline void +ntb_db_clear_mask(struct ntb_softc *ntb, uint64_t bits) +{ + + KASSERT((bits & ~ntb->db_valid_mask) == 0, + ("%s: Invalid bits 0x%jx (valid: 0x%jx)", __func__, + (uintmax_t)(bits & ~ntb->db_valid_mask), + (uintmax_t)ntb->db_valid_mask)); + + HW_LOCK(ntb); + ntb->db_mask &= ~bits; + ntb_db_write(ntb, ntb->reg_ofs.ldb_mask, ntb->db_mask); + HW_UNLOCK(ntb); +} + +static inline void mask_ldb_interrupt(struct ntb_softc *ntb, unsigned int idx) { uint64_t mask; - mask = ntb_db_read(ntb, ntb->reg_ofs.ldb_mask); - mask |= 1 << (idx * ntb->db_vec_shift); - ntb_db_write(ntb, ntb->reg_ofs.ldb_mask, mask); + mask = 1ull << (idx * ntb->db_vec_shift); + ntb_db_set_mask(ntb, mask); } static inline void @@ -748,9 +897,8 @@ unmask_ldb_interrupt(struct ntb_softc *n { uint64_t mask; - mask = ntb_db_read(ntb, ntb->reg_ofs.ldb_mask); - mask &= ~(1 << (idx * ntb->db_vec_shift)); - ntb_db_write(ntb, ntb->reg_ofs.ldb_mask, mask); + mask = 1ull << (idx * ntb->db_vec_shift); + ntb_db_clear_mask(ntb, mask); } static inline uint64_t @@ -771,10 +919,11 @@ handle_irq(void *arg) uint64_t vec_mask; int rc; + ntb->last_ts = ticks; vec_mask = ntb_vec_mask(ntb, db_cb->db_num); - if (ntb->type == NTB_XEON && (vec_mask & XEON_DB_LINK_BIT) != 0) { - rc = ntb_check_link_status(ntb); + if ((vec_mask & ntb->db_link_mask) != 0) { + rc = ntb_poll_link(ntb); if (rc != 0) device_printf(ntb->device, "Error determining link status\n"); @@ -855,7 +1004,7 @@ static void ntb_teardown_xeon(struct ntb_softc *ntb) { - ntb_hw_link_down(ntb); + ntb_link_disable(ntb); } static void @@ -889,6 +1038,10 @@ ntb_detect_xeon(struct ntb_softc *ntb) if ((ppd & XEON_PPD_SPLIT_BAR) != 0) ntb->features |= NTB_SPLIT_BAR; + /* SB01BASE_LOCKUP errata is a superset of SDOORBELL errata */ + if (HAS_FEATURE(NTB_SB01BASE_LOCKUP)) + ntb->features |= NTB_SDOORBELL_LOCKUP; + conn_type = ppd & XEON_PPD_CONN_TYPE; switch (conn_type) { case NTB_CONN_B2B: @@ -930,48 +1083,34 @@ ntb_detect_soc(struct ntb_softc *ntb) } static int -ntb_setup_xeon(struct ntb_softc *ntb) +ntb_xeon_init_dev(struct ntb_softc *ntb) { + int rc; ntb->reg_ofs.ldb = XEON_PDOORBELL_OFFSET; ntb->reg_ofs.ldb_mask = XEON_PDBMSK_OFFSET; ntb->reg_ofs.spad_local = XEON_SPAD_OFFSET; - ntb->reg_ofs.bar2_xlat = XEON_SBAR2XLAT_OFFSET; ntb->reg_ofs.bar4_xlat = XEON_SBAR4XLAT_OFFSET; if (HAS_FEATURE(NTB_SPLIT_BAR)) ntb->reg_ofs.bar5_xlat = XEON_SBAR5XLAT_OFFSET; + ntb->reg_ofs.spci_cmd = XEON_PCICMD_OFFSET; - switch (ntb->conn_type) { - case NTB_CONN_B2B: - /* - * reg_ofs.rdb and reg_ofs.spad_remote are effectively ignored - * with the NTB_SDOORBELL_LOCKUP errata mode enabled. (See - * ntb_ring_doorbell() and ntb_read/write_remote_spad().) - */ - ntb->reg_ofs.rdb = XEON_B2B_DOORBELL_OFFSET; - ntb->reg_ofs.spad_remote = XEON_B2B_SPAD_OFFSET; - - ntb->spad_count = XEON_SPAD_COUNT; - break; - - case NTB_CONN_RP: - /* - * Every Xeon today needs NTB_SDOORBELL_LOCKUP, so punt on RP for - * now. - */ - KASSERT(HAS_FEATURE(NTB_SDOORBELL_LOCKUP), - ("Xeon without MW errata unimplemented")); - device_printf(ntb->device, - "NTB-RP disabled to due hardware errata.\n"); - return (ENXIO); + ntb->spad_count = XEON_SPAD_COUNT; + ntb->db_count = XEON_DB_COUNT; + ntb->db_link_mask = XEON_DB_LINK_BIT; + ntb->db_vec_count = XEON_DB_MSIX_VECTOR_COUNT; + ntb->db_vec_shift = XEON_DB_MSIX_VECTOR_SHIFT; - case NTB_CONN_TRANSPARENT: - default: + if (ntb->conn_type != NTB_CONN_B2B) { device_printf(ntb->device, "Connection type %d not supported\n", ntb->conn_type); return (ENXIO); } + ntb->reg = &xeon_reg; + ntb->peer_reg = &xeon_b2b_reg; + ntb->xlat_reg = &xeon_sec_xlat; + /* * There is a Xeon hardware errata related to writes to SDOORBELL or * B2BDOORBELL in conjunction with inbound access to NTB MMIO space, @@ -985,17 +1124,21 @@ ntb_setup_xeon(struct ntb_softc *ntb) * write the limit registers first just in case. */ if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP)) { + /* Reserve the last MW for mapping remote spad */ + ntb->b2b_mw_idx = ntb->mw_count - 1; + ntb->mw_count--; /* * Set the Limit register to 4k, the minimum size, to prevent * an illegal access. - * - * XXX: Should this be PBAR5LMT / get_mw_size(, max_mw - 1)? */ - ntb_reg_write(8, XEON_PBAR4LMT_OFFSET, - ntb_get_mw_size(ntb, 1) + 0x1000); - /* Reserve the last MW for mapping remote spad */ - ntb->mw_count--; - } else + if (HAS_FEATURE(NTB_SPLIT_BAR)) { + ntb_reg_write(4, XEON_PBAR4LMT_OFFSET, 0); + ntb_reg_write(4, XEON_PBAR5LMT_OFFSET, + ntb_get_mw_size(ntb, ntb->b2b_mw_idx) + 0x1000); + } else + ntb_reg_write(8, XEON_PBAR4LMT_OFFSET, + ntb_get_mw_size(ntb, ntb->b2b_mw_idx) + 0x1000); + } else { /* * Disable the limit register, just in case it is set to * something silly. A 64-bit write will also clear PBAR5LMT in @@ -1003,66 +1146,61 @@ ntb_setup_xeon(struct ntb_softc *ntb) */ ntb_reg_write(8, XEON_PBAR4LMT_OFFSET, 0); - ntb->reg_ofs.lnk_cntl = XEON_NTBCNTL_OFFSET; - ntb->reg_ofs.lnk_stat = XEON_LINK_STATUS_OFFSET; - ntb->reg_ofs.spci_cmd = XEON_PCICMD_OFFSET; - - ntb->db_count = XEON_DB_COUNT; - ntb->db_vec_count = XEON_DB_MSIX_VECTOR_COUNT; - ntb->db_vec_shift = XEON_DB_MSIX_VECTOR_SHIFT; + /* + * HW Errata on bit 14 of b2bdoorbell register. Writes will not be + * mirrored to the remote system. Shrink the number of bits by one, + * since bit 14 is the last bit. + * + * On REGS_THRU_MW errata mode, we don't use the b2bdoorbell register + * anyway. Nor for non-B2B connection types. + */ + if (HAS_FEATURE(NTB_B2BDOORBELL_BIT14)) + ntb->db_count = XEON_DB_COUNT - 1; + } - /* - * HW Errata on bit 14 of b2bdoorbell register. Writes will not be - * mirrored to the remote system. Shrink the number of bits by one, - * since bit 14 is the last bit. - * - * On REGS_THRU_MW errata mode, we don't use the b2bdoorbell register - * anyway. Nor for non-B2B connection types. - */ - if (HAS_FEATURE(NTB_B2BDOORBELL_BIT14) && - !HAS_FEATURE(NTB_SDOORBELL_LOCKUP) && - ntb->conn_type == NTB_CONN_B2B) - ntb->db_count = XEON_DB_COUNT - 1; + ntb->db_valid_mask = (1ull << ntb->db_count) - 1; - configure_xeon_secondary_side_bars(ntb); + if (ntb->dev_type == NTB_DEV_USD) + rc = xeon_setup_b2b_mw(ntb, &xeon_b2b_dsd_addr, + &xeon_b2b_usd_addr); + else + rc = xeon_setup_b2b_mw(ntb, &xeon_b2b_usd_addr, + &xeon_b2b_dsd_addr); + if (rc != 0) + return (rc); /* Enable Bus Master and Memory Space on the secondary side */ - if (ntb->conn_type == NTB_CONN_B2B) - ntb_reg_write(2, ntb->reg_ofs.spci_cmd, - PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN); + ntb_reg_write(2, ntb->reg_ofs.spci_cmd, + PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN); /* Enable link training */ - ntb_hw_link_up(ntb); + ntb_link_enable(ntb); return (0); } static int -ntb_setup_soc(struct ntb_softc *ntb) +ntb_soc_init_dev(struct ntb_softc *ntb) { KASSERT(ntb->conn_type == NTB_CONN_B2B, ("Unsupported NTB configuration (%d)\n", ntb->conn_type)); - /* Initiate PCI-E link training */ - pci_write_config(ntb->device, NTB_PPD_OFFSET, - ntb->ppd | SOC_PPD_INIT_LINK, 4); - ntb->reg_ofs.ldb = SOC_PDOORBELL_OFFSET; ntb->reg_ofs.ldb_mask = SOC_PDBMSK_OFFSET; - ntb->reg_ofs.rdb = SOC_B2B_DOORBELL_OFFSET; - ntb->reg_ofs.bar2_xlat = SOC_SBAR2XLAT_OFFSET; ntb->reg_ofs.bar4_xlat = SOC_SBAR4XLAT_OFFSET; - ntb->reg_ofs.lnk_cntl = SOC_NTBCNTL_OFFSET; - ntb->reg_ofs.lnk_stat = SOC_LINK_STATUS_OFFSET; ntb->reg_ofs.spad_local = SOC_SPAD_OFFSET; - ntb->reg_ofs.spad_remote = SOC_B2B_SPAD_OFFSET; ntb->reg_ofs.spci_cmd = SOC_PCICMD_OFFSET; - ntb->spad_count = SOC_SPAD_COUNT; + ntb->spad_count = SOC_SPAD_COUNT; ntb->db_count = SOC_DB_COUNT; ntb->db_vec_count = SOC_DB_MSIX_VECTOR_COUNT; ntb->db_vec_shift = SOC_DB_MSIX_VECTOR_SHIFT; + ntb->db_valid_mask = (1ull << ntb->db_count) - 1; + + ntb->reg = &soc_reg; + ntb->peer_reg = &soc_b2b_reg; + ntb->xlat_reg = &soc_sec_xlat; /* * FIXME - MSI-X bug on early SOC HW, remove once internal issue is @@ -1076,118 +1214,95 @@ ntb_setup_soc(struct ntb_softc *ntb) ntb_reg_write(2, ntb->reg_ofs.spci_cmd, PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN); - callout_reset(&ntb->heartbeat_timer, 0, ntb_handle_heartbeat, ntb); + /* Initiate PCI-E link training */ + ntb_link_enable(ntb); + + callout_reset(&ntb->heartbeat_timer, 0, soc_link_hb, ntb); return (0); } +/* XXX: Linux driver doesn't seem to do any of this for SoC. */ static void configure_soc_secondary_side_bars(struct ntb_softc *ntb) { if (ntb->dev_type == NTB_DEV_USD) { ntb_reg_write(8, SOC_PBAR2XLAT_OFFSET, - XEON_B2B_BAR2_DSD_ADDR); - ntb_reg_write(8, SOC_PBAR4XLAT_OFFSET, XEON_B2B_BAR4_DSD_ADDR); - ntb_reg_write(8, SOC_MBAR23_OFFSET, XEON_B2B_BAR2_USD_ADDR); - ntb_reg_write(8, SOC_MBAR45_OFFSET, XEON_B2B_BAR4_USD_ADDR); + XEON_B2B_BAR2_DSD_ADDR64); + ntb_reg_write(8, SOC_PBAR4XLAT_OFFSET, + XEON_B2B_BAR4_DSD_ADDR64); + ntb_reg_write(8, SOC_MBAR23_OFFSET, XEON_B2B_BAR2_USD_ADDR64); + ntb_reg_write(8, SOC_MBAR45_OFFSET, XEON_B2B_BAR4_USD_ADDR64); } else { ntb_reg_write(8, SOC_PBAR2XLAT_OFFSET, - XEON_B2B_BAR2_USD_ADDR); - ntb_reg_write(8, SOC_PBAR4XLAT_OFFSET, XEON_B2B_BAR4_USD_ADDR); - ntb_reg_write(8, SOC_MBAR23_OFFSET, XEON_B2B_BAR2_DSD_ADDR); - ntb_reg_write(8, SOC_MBAR45_OFFSET, XEON_B2B_BAR4_DSD_ADDR); + XEON_B2B_BAR2_USD_ADDR64); + ntb_reg_write(8, SOC_PBAR4XLAT_OFFSET, + XEON_B2B_BAR4_USD_ADDR64); + ntb_reg_write(8, SOC_MBAR23_OFFSET, XEON_B2B_BAR2_DSD_ADDR64); + ntb_reg_write(8, SOC_MBAR45_OFFSET, XEON_B2B_BAR4_DSD_ADDR64); } } -static void -configure_xeon_secondary_side_bars(struct ntb_softc *ntb) +static int +xeon_setup_b2b_mw(struct ntb_softc *ntb, const struct ntb_b2b_addr *addr, + const struct ntb_b2b_addr *peer_addr) { - if (ntb->dev_type == NTB_DEV_USD) { - ntb_reg_write(8, XEON_PBAR2XLAT_OFFSET, - XEON_B2B_BAR2_DSD_ADDR); - if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP)) - ntb_reg_write(8, XEON_PBAR4XLAT_OFFSET, - XEON_B2B_BAR0_DSD_ADDR); - else { - if (HAS_FEATURE(NTB_SPLIT_BAR)) { - ntb_reg_write(4, XEON_PBAR4XLAT_OFFSET, - XEON_B2B_BAR4_DSD_ADDR); - ntb_reg_write(4, XEON_PBAR5XLAT_OFFSET, - XEON_B2B_BAR5_DSD_ADDR); - } else - ntb_reg_write(8, XEON_PBAR4XLAT_OFFSET, - XEON_B2B_BAR4_DSD_ADDR); - /* - * B2B_XLAT_OFFSET is a 64-bit register but can only be - * written 32 bits at a time. - */ - ntb_reg_write(4, XEON_B2B_XLAT_OFFSETL, - XEON_B2B_BAR0_DSD_ADDR & 0xffffffff); - ntb_reg_write(4, XEON_B2B_XLAT_OFFSETU, - XEON_B2B_BAR0_DSD_ADDR >> 32); - } - ntb_reg_write(8, XEON_SBAR0BASE_OFFSET, - XEON_B2B_BAR0_USD_ADDR); - ntb_reg_write(8, XEON_SBAR2BASE_OFFSET, - XEON_B2B_BAR2_USD_ADDR); + /* Local addresses */ + ntb_reg_write(8, XEON_PBAR2XLAT_OFFSET, addr->bar2_addr64); + if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP)) + ntb_reg_write(8, XEON_PBAR4XLAT_OFFSET, addr->bar0_addr); + else { if (HAS_FEATURE(NTB_SPLIT_BAR)) { - ntb_reg_write(4, XEON_SBAR4BASE_OFFSET, - XEON_B2B_BAR4_USD_ADDR); - ntb_reg_write(4, XEON_SBAR5BASE_OFFSET, - XEON_B2B_BAR5_USD_ADDR); + ntb_reg_write(4, XEON_PBAR4XLAT_OFFSET, + addr->bar4_addr32); + ntb_reg_write(4, XEON_PBAR5XLAT_OFFSET, + addr->bar5_addr32); } else - ntb_reg_write(8, XEON_SBAR4BASE_OFFSET, - XEON_B2B_BAR4_USD_ADDR); - } else { - ntb_reg_write(8, XEON_PBAR2XLAT_OFFSET, - XEON_B2B_BAR2_USD_ADDR); - if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP)) ntb_reg_write(8, XEON_PBAR4XLAT_OFFSET, - XEON_B2B_BAR0_USD_ADDR); - else { - if (HAS_FEATURE(NTB_SPLIT_BAR)) { - ntb_reg_write(4, XEON_PBAR4XLAT_OFFSET, - XEON_B2B_BAR4_USD_ADDR); - ntb_reg_write(4, XEON_PBAR5XLAT_OFFSET, - XEON_B2B_BAR5_USD_ADDR); - } else - ntb_reg_write(8, XEON_PBAR4XLAT_OFFSET, - XEON_B2B_BAR4_USD_ADDR); - /* - * B2B_XLAT_OFFSET is a 64-bit register but can only be - * written 32 bits at a time. - */ - ntb_reg_write(4, XEON_B2B_XLAT_OFFSETL, - XEON_B2B_BAR0_USD_ADDR & 0xffffffff); - ntb_reg_write(4, XEON_B2B_XLAT_OFFSETU, - XEON_B2B_BAR0_USD_ADDR >> 32); - } - ntb_reg_write(8, XEON_SBAR0BASE_OFFSET, - XEON_B2B_BAR0_DSD_ADDR); - ntb_reg_write(8, XEON_SBAR2BASE_OFFSET, - XEON_B2B_BAR2_DSD_ADDR); - if (HAS_FEATURE(NTB_SPLIT_BAR)) { - ntb_reg_write(4, XEON_SBAR4BASE_OFFSET, - XEON_B2B_BAR4_DSD_ADDR); - ntb_reg_write(4, XEON_SBAR5BASE_OFFSET, - XEON_B2B_BAR5_DSD_ADDR); - } else - ntb_reg_write(8, XEON_SBAR4BASE_OFFSET, - XEON_B2B_BAR4_DSD_ADDR); + addr->bar4_addr64); + /* + * B2B_XLAT_OFFSET is a 64-bit register but can only be + * written 32 bits at a time. + */ + ntb_reg_write(4, XEON_B2B_XLAT_OFFSETL, + addr->bar0_addr & 0xffffffff); + ntb_reg_write(4, XEON_B2B_XLAT_OFFSETU, addr->bar0_addr >> 32); } + + /* Peer addresses */ + ntb_reg_write(8, XEON_SBAR0BASE_OFFSET, peer_addr->bar0_addr); + ntb_reg_write(8, XEON_SBAR2BASE_OFFSET, peer_addr->bar2_addr64); + if (HAS_FEATURE(NTB_SPLIT_BAR)) { + ntb_reg_write(4, XEON_SBAR4BASE_OFFSET, + peer_addr->bar4_addr32); + ntb_reg_write(4, XEON_SBAR5BASE_OFFSET, + peer_addr->bar5_addr32); + } else + ntb_reg_write(8, XEON_SBAR4BASE_OFFSET, + peer_addr->bar4_addr64); + return (0); } /* SOC does not have link status interrupt, poll on that platform */ static void -ntb_handle_heartbeat(void *arg) +soc_link_hb(void *arg) { struct ntb_softc *ntb = arg; uint32_t status32; int rc; - rc = ntb_check_link_status(ntb); + /* + * Delay polling the link status if an interrupt was received, unless + * the cached link status says the link is down. + */ + if ((long)ticks - ((long)ntb->last_ts + NTB_HB_TIMEOUT * hz) < 0 && + (ntb->ntb_ctl & SOC_CNTL_LINK_DOWN) == 0) + goto out; + + + rc = ntb_poll_link(ntb); if (rc != 0) device_printf(ntb->device, "Error determining link status\n"); @@ -1202,8 +1317,9 @@ ntb_handle_heartbeat(void *arg) } } - callout_reset(&ntb->heartbeat_timer, NTB_HB_TIMEOUT * hz, - ntb_handle_heartbeat, ntb); +out: + callout_reset(&ntb->heartbeat_timer, NTB_HB_TIMEOUT * hz, soc_link_hb, + ntb); } static void @@ -1261,7 +1377,7 @@ ntb_handle_link_event(struct ntb_softc * if (ntb->type == NTB_SOC || ntb->conn_type == NTB_CONN_TRANSPARENT) - status = ntb_reg_read(2, ntb->reg_ofs.lnk_stat); + status = ntb_reg_read(2, ntb->reg->lnk_sta); else status = pci_read_config(ntb->device, XEON_LINK_STATUS_OFFSET, 2); @@ -1270,7 +1386,7 @@ ntb_handle_link_event(struct ntb_softc * device_printf(ntb->device, "Link Width %d, Link Speed %d\n", ntb->link_width, ntb->link_speed); callout_reset(&ntb->heartbeat_timer, NTB_HB_TIMEOUT * hz, - ntb_handle_heartbeat, ntb); + soc_link_hb, ntb); } else { device_printf(ntb->device, "Link Down\n"); ntb->link_status = NTB_LINK_DOWN; @@ -1284,26 +1400,32 @@ ntb_handle_link_event(struct ntb_softc * } static void -ntb_hw_link_up(struct ntb_softc *ntb) +ntb_link_enable(struct ntb_softc *ntb) { uint32_t cntl; + if (ntb->type == NTB_SOC) { + pci_write_config(ntb->device, NTB_PPD_OFFSET, + ntb->ppd | SOC_PPD_INIT_LINK, 4); + return; + } + if (ntb->conn_type == NTB_CONN_TRANSPARENT) { ntb_handle_link_event(ntb, NTB_LINK_UP); return; } - cntl = ntb_reg_read(4, ntb->reg_ofs.lnk_cntl); + cntl = ntb_reg_read(4, ntb->reg->ntb_ctl); cntl &= ~(NTB_CNTL_LINK_DISABLE | NTB_CNTL_CFG_LOCK); cntl |= NTB_CNTL_P2S_BAR23_SNOOP | NTB_CNTL_S2P_BAR23_SNOOP; cntl |= NTB_CNTL_P2S_BAR4_SNOOP | NTB_CNTL_S2P_BAR4_SNOOP; if (HAS_FEATURE(NTB_SPLIT_BAR)) cntl |= NTB_CNTL_P2S_BAR5_SNOOP | NTB_CNTL_S2P_BAR5_SNOOP; - ntb_reg_write(4, ntb->reg_ofs.lnk_cntl, cntl); + ntb_reg_write(4, ntb->reg->ntb_ctl, cntl); } static void -ntb_hw_link_down(struct ntb_softc *ntb) +ntb_link_disable(struct ntb_softc *ntb) { uint32_t cntl; @@ -1312,13 +1434,13 @@ ntb_hw_link_down(struct ntb_softc *ntb) return; } - cntl = ntb_reg_read(4, ntb->reg_ofs.lnk_cntl); + cntl = ntb_reg_read(4, ntb->reg->ntb_ctl); cntl &= ~(NTB_CNTL_P2S_BAR23_SNOOP | NTB_CNTL_S2P_BAR23_SNOOP); cntl &= ~(NTB_CNTL_P2S_BAR4_SNOOP | NTB_CNTL_S2P_BAR4_SNOOP); if (HAS_FEATURE(NTB_SPLIT_BAR)) cntl &= ~(NTB_CNTL_P2S_BAR5_SNOOP | NTB_CNTL_S2P_BAR5_SNOOP); cntl |= NTB_CNTL_LINK_DISABLE | NTB_CNTL_CFG_LOCK; - ntb_reg_write(4, ntb->reg_ofs.lnk_cntl, cntl); + ntb_reg_write(4, ntb->reg->ntb_ctl, cntl); } static void @@ -1327,7 +1449,6 @@ recover_soc_link(void *arg) struct ntb_softc *ntb = arg; uint8_t speed, width; uint32_t status32; - uint16_t status16; soc_perform_link_restart(ntb); @@ -1348,19 +1469,19 @@ recover_soc_link(void *arg) if ((status32 & SOC_IBIST_ERR_OFLOW) != 0) goto retry; - status32 = ntb_reg_read(4, ntb->reg_ofs.lnk_cntl); + status32 = ntb_reg_read(4, ntb->reg->ntb_ctl); if ((status32 & SOC_CNTL_LINK_DOWN) != 0) goto out; - status16 = ntb_reg_read(2, ntb->reg_ofs.lnk_stat); - width = (status16 & NTB_LINK_WIDTH_MASK) >> 4; - speed = (status16 & NTB_LINK_SPEED_MASK); + status32 = ntb_reg_read(4, ntb->reg->lnk_sta); + width = (status32 & NTB_LINK_WIDTH_MASK) >> 4; + speed = (status32 & NTB_LINK_SPEED_MASK); if (ntb->link_width != width || ntb->link_speed != speed) goto retry; out: - callout_reset(&ntb->heartbeat_timer, NTB_HB_TIMEOUT * hz, - ntb_handle_heartbeat, ntb); + callout_reset(&ntb->heartbeat_timer, NTB_HB_TIMEOUT * hz, soc_link_hb, + ntb); return; retry: @@ -1369,21 +1490,32 @@ retry: } static int -ntb_check_link_status(struct ntb_softc *ntb) +ntb_poll_link(struct ntb_softc *ntb) { int link_state; uint32_t ntb_cntl; uint16_t status; if (ntb->type == NTB_SOC) { - ntb_cntl = ntb_reg_read(4, ntb->reg_ofs.lnk_cntl); + HW_LOCK(ntb); + ntb_cntl = ntb_reg_read(4, ntb->reg->ntb_ctl); + if (ntb_cntl == ntb->ntb_ctl) { + HW_UNLOCK(ntb); + return (0); + } + ntb->ntb_ctl = ntb_cntl; + ntb->lnk_sta = ntb_reg_read(4, ntb->reg->lnk_sta); + HW_UNLOCK(ntb); + if ((ntb_cntl & SOC_CNTL_LINK_DOWN) != 0) link_state = NTB_LINK_DOWN; else link_state = NTB_LINK_UP; } else { - status = pci_read_config(ntb->device, XEON_LINK_STATUS_OFFSET, - 2); + status = pci_read_config(ntb->device, ntb->reg->lnk_sta, 2); + if (status == ntb->lnk_sta) + return (0); + ntb->lnk_sta = status; if ((status & NTB_LINK_STATUS_ACTIVE) != 0) link_state = NTB_LINK_UP; @@ -1392,10 +1524,32 @@ ntb_check_link_status(struct ntb_softc * } ntb_handle_link_event(ntb, link_state); - return (0); } +static void +ntb_irq_work(void *arg) +{ + struct ntb_db_cb *db_cb = arg; + struct ntb_softc *ntb; + int rc; + + rc = db_cb->callback(db_cb->data, db_cb->db_num); + /* Poll if forward progress was made. */ + if (rc != 0) { + callout_reset(&db_cb->irq_work, 0, ntb_irq_work, db_cb); + return; + } + + /* Unmask interrupt if no progress was made. */ + ntb = db_cb->ntb; + unmask_ldb_interrupt(ntb, db_cb->db_num); +} + +/* + * Public API to the rest of the OS + */ + /** * ntb_register_event_callback() - register event callback * @ntb: pointer to ntb_softc instance @@ -1431,25 +1585,6 @@ ntb_unregister_event_callback(struct ntb ntb->event_cb = NULL; } -static void -ntb_irq_work(void *arg) -{ - struct ntb_db_cb *db_cb = arg; - struct ntb_softc *ntb; - int rc; - - rc = db_cb->callback(db_cb->data, db_cb->db_num); - /* Poll if forward progress was made. */ - if (rc != 0) { - callout_reset(&db_cb->irq_work, 0, ntb_irq_work, db_cb); - return; - } - - /* Unmask interrupt if no progress was made. */ - ntb = db_cb->ntb; - unmask_ldb_interrupt(ntb, db_cb->db_num); -} - /** * ntb_register_db_callback() - register a callback for doorbell interrupt * @ntb: pointer to ntb_softc instance @@ -1663,7 +1798,7 @@ ntb_write_remote_spad(struct ntb_softc * if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP)) ntb_mw_write(4, XEON_SHADOW_SPAD_OFFSET + idx * 4, val); else - ntb_reg_write(4, ntb->reg_ofs.spad_remote + idx * 4, val); + ntb_reg_write(4, ntb->peer_reg->spad + idx * 4, val); return (0); } @@ -1689,7 +1824,7 @@ ntb_read_remote_spad(struct ntb_softc *n if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP)) *val = ntb_mw_read(4, XEON_SHADOW_SPAD_OFFSET + idx * 4); else - *val = ntb_reg_read(4, ntb->reg_ofs.spad_remote + idx * 4); + *val = ntb_reg_read(4, ntb->peer_reg->spad + idx * 4); return (0); } @@ -1714,7 +1849,7 @@ ntb_get_mw_vbase(struct ntb_softc *ntb, return (ntb->bar_info[ntb_mw_to_bar(ntb, mw)].vbase); } -vm_paddr_t +bus_addr_t ntb_get_mw_pbase(struct ntb_softc *ntb, unsigned int mw) { @@ -1762,7 +1897,7 @@ ntb_set_mw_addr(struct ntb_softc *ntb, u switch (ntb_mw_to_bar(ntb, mw)) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Sun Oct 18 20:20:31 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 19128A185D5; Sun, 18 Oct 2015 20:20:31 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D6B391A6F; Sun, 18 Oct 2015 20:20:30 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IKKTMu092996; Sun, 18 Oct 2015 20:20:29 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IKKTMs092994; Sun, 18 Oct 2015 20:20:29 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201510182020.t9IKKTMs092994@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Sun, 18 Oct 2015 20:20:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289543 - head/sys/dev/ntb/ntb_hw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-