From 4bfa972e11dfe356bbcfbfc980440a356bdb39a9 Mon Sep 17 00:00:00 2001 From: yongari Date: Tue, 5 Feb 2013 00:37:45 +0000 Subject: [PATCH 01/27] Rework jumbo frame handling. QAC confirmed that the controller requires 8 bytes alignment on RX buffer. Given that non-jumbo frame works on any alignments I guess this DMA limitation for RX buffer could be jumbo frame specific one. Also I'm not sure whether this DMA limitation is related with 64bit DMA. Previously age(4) disabled 64bit DMA addressing due to silent data corruption. So we may need more testing on re-enabling 64bit DMA in future. While I'm here, change mbuf chaining algorithm to use fixed sized buffer and force software checksum if controller reports length error. According to QAC, RFD is not updated at all for jumbo frame so it works just like alc(4) controllers. This change also added alignment fixup for strict alignment architectures. Because I'm not aware of any non-x86 machines that use age(4) controllers it's just for completeness at this moment. Wit this change, jumbo frame should work with age(4). Tested by: Christian Gusenbauer < c47g <> gmx dot at > MFC after: 1 week --- sys/dev/age/if_age.c | 125 ++++++++++++++++++++++++++-------------- sys/dev/age/if_agevar.h | 6 ++ 2 files changed, 87 insertions(+), 44 deletions(-) diff --git a/sys/dev/age/if_age.c b/sys/dev/age/if_age.c index 829f350b08f5..7fab237d97d4 100644 --- a/sys/dev/age/if_age.c +++ b/sys/dev/age/if_age.c @@ -142,6 +142,9 @@ static int age_init_rx_ring(struct age_softc *); static void age_init_rr_ring(struct age_softc *); static void age_init_cmb_block(struct age_softc *); static void age_init_smb_block(struct age_softc *); +#ifndef __NO_STRICT_ALIGNMENT +static struct mbuf *age_fixup_rx(struct ifnet *, struct mbuf *); +#endif static int age_newbuf(struct age_softc *, struct age_rxdesc *); static void age_rxvlan(struct age_softc *); static void age_rxfilter(struct age_softc *); @@ -1133,7 +1136,7 @@ again: /* Create tag for Rx buffers. */ error = bus_dma_tag_create( sc->age_cdata.age_buffer_tag, /* parent */ - 1, 0, /* alignment, boundary */ + AGE_RX_BUF_ALIGN, 0, /* alignment, boundary */ BUS_SPACE_MAXADDR, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ @@ -2268,16 +2271,53 @@ age_txintr(struct age_softc *sc, int tpd_cons) } } +#ifndef __NO_STRICT_ALIGNMENT +static struct mbuf * +age_fixup_rx(struct ifnet *ifp, struct mbuf *m) +{ + struct mbuf *n; + int i; + uint16_t *src, *dst; + + src = mtod(m, uint16_t *); + dst = src - 3; + + if (m->m_next == NULL) { + for (i = 0; i < (m->m_len / sizeof(uint16_t) + 1); i++) + *dst++ = *src++; + m->m_data -= 6; + return (m); + } + /* + * Append a new mbuf to received mbuf chain and copy ethernet + * header from the mbuf chain. This can save lots of CPU + * cycles for jumbo frame. + */ + MGETHDR(n, M_NOWAIT, MT_DATA); + if (n == NULL) { + ifp->if_iqdrops++; + m_freem(m); + return (NULL); + } + bcopy(m->m_data, n->m_data, ETHER_HDR_LEN); + m->m_data += ETHER_HDR_LEN; + m->m_len -= ETHER_HDR_LEN; + n->m_len = ETHER_HDR_LEN; + M_MOVE_PKTHDR(n, m); + n->m_next = m; + return (n); +} +#endif + /* Receive a frame. */ static void age_rxeof(struct age_softc *sc, struct rx_rdesc *rxrd) { struct age_rxdesc *rxd; - struct rx_desc *desc; struct ifnet *ifp; struct mbuf *mp, *m; uint32_t status, index, vtag; - int count, nsegs, pktlen; + int count, nsegs; int rx_cons; AGE_LOCK_ASSERT(sc); @@ -2289,9 +2329,7 @@ age_rxeof(struct age_softc *sc, struct rx_rdesc *rxrd) nsegs = AGE_RX_NSEGS(index); sc->age_cdata.age_rxlen = AGE_RX_BYTES(le32toh(rxrd->len)); - if ((status & AGE_RRD_ERROR) != 0 && - (status & (AGE_RRD_CRC | AGE_RRD_CODE | AGE_RRD_DRIBBLE | - AGE_RRD_RUNT | AGE_RRD_OFLOW | AGE_RRD_TRUNC)) != 0) { + if ((status & (AGE_RRD_ERROR | AGE_RRD_LENGTH_NOK)) != 0) { /* * We want to pass the following frames to upper * layer regardless of error status of Rx return @@ -2301,33 +2339,31 @@ age_rxeof(struct age_softc *sc, struct rx_rdesc *rxrd) * o frame length and protocol specific length * does not match. */ - sc->age_cdata.age_rx_cons += nsegs; - sc->age_cdata.age_rx_cons %= AGE_RX_RING_CNT; - return; + status |= AGE_RRD_IPCSUM_NOK | AGE_RRD_TCP_UDPCSUM_NOK; + if ((status & (AGE_RRD_CRC | AGE_RRD_CODE | AGE_RRD_DRIBBLE | + AGE_RRD_RUNT | AGE_RRD_OFLOW | AGE_RRD_TRUNC)) != 0) + return; } - pktlen = 0; for (count = 0; count < nsegs; count++, AGE_DESC_INC(rx_cons, AGE_RX_RING_CNT)) { rxd = &sc->age_cdata.age_rxdesc[rx_cons]; mp = rxd->rx_m; - desc = rxd->rx_desc; /* Add a new receive buffer to the ring. */ if (age_newbuf(sc, rxd) != 0) { ifp->if_iqdrops++; /* Reuse Rx buffers. */ - if (sc->age_cdata.age_rxhead != NULL) { + if (sc->age_cdata.age_rxhead != NULL) m_freem(sc->age_cdata.age_rxhead); - AGE_RXCHAIN_RESET(sc); - } break; } - /* The length of the first mbuf is computed last. */ - if (count != 0) { - mp->m_len = AGE_RX_BYTES(le32toh(desc->len)); - pktlen += mp->m_len; - } + /* + * Assume we've received a full sized frame. + * Actual size is fixed when we encounter the end of + * multi-segmented frame. + */ + mp->m_len = AGE_RX_BUF_SIZE; /* Chain received mbufs. */ if (sc->age_cdata.age_rxhead == NULL) { @@ -2342,14 +2378,20 @@ age_rxeof(struct age_softc *sc, struct rx_rdesc *rxrd) } if (count == nsegs - 1) { + /* Last desc. for this frame. */ + m = sc->age_cdata.age_rxhead; + m->m_flags |= M_PKTHDR; /* * It seems that L1 controller has no way * to tell hardware to strip CRC bytes. */ - sc->age_cdata.age_rxlen -= ETHER_CRC_LEN; + m->m_pkthdr.len = sc->age_cdata.age_rxlen - + ETHER_CRC_LEN; if (nsegs > 1) { + /* Set last mbuf size. */ + mp->m_len = sc->age_cdata.age_rxlen - + ((nsegs - 1) * AGE_RX_BUF_SIZE); /* Remove the CRC bytes in chained mbufs. */ - pktlen -= ETHER_CRC_LEN; if (mp->m_len <= ETHER_CRC_LEN) { sc->age_cdata.age_rxtail = sc->age_cdata.age_rxprev_tail; @@ -2360,15 +2402,9 @@ age_rxeof(struct age_softc *sc, struct rx_rdesc *rxrd) } else { mp->m_len -= ETHER_CRC_LEN; } - } - - m = sc->age_cdata.age_rxhead; - m->m_flags |= M_PKTHDR; + } else + m->m_len = m->m_pkthdr.len; m->m_pkthdr.rcvif = ifp; - m->m_pkthdr.len = sc->age_cdata.age_rxlen; - /* Set the first mbuf length. */ - m->m_len = sc->age_cdata.age_rxlen - pktlen; - /* * Set checksum information. * It seems that L1 controller can compute partial @@ -2383,9 +2419,9 @@ age_rxeof(struct age_softc *sc, struct rx_rdesc *rxrd) */ if ((ifp->if_capenable & IFCAP_RXCSUM) != 0 && (status & AGE_RRD_IPV4) != 0) { - m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; if ((status & AGE_RRD_IPCSUM_NOK) == 0) - m->m_pkthdr.csum_flags |= CSUM_IP_VALID; + m->m_pkthdr.csum_flags |= + CSUM_IP_CHECKED | CSUM_IP_VALID; if ((status & (AGE_RRD_TCP | AGE_RRD_UDP)) && (status & AGE_RRD_TCP_UDPCSUM_NOK) == 0) { m->m_pkthdr.csum_flags |= @@ -2406,22 +2442,21 @@ age_rxeof(struct age_softc *sc, struct rx_rdesc *rxrd) m->m_pkthdr.ether_vtag = AGE_RX_VLAN_TAG(vtag); m->m_flags |= M_VLANTAG; } - +#ifndef __NO_STRICT_ALIGNMENT + m = age_fixup_rx(ifp, m); + if (m != NULL) +#endif + { /* Pass it on. */ AGE_UNLOCK(sc); (*ifp->if_input)(ifp, m); AGE_LOCK(sc); - - /* Reset mbuf chains. */ - AGE_RXCHAIN_RESET(sc); + } } } - if (count != nsegs) { - sc->age_cdata.age_rx_cons += nsegs; - sc->age_cdata.age_rx_cons %= AGE_RX_RING_CNT; - } else - sc->age_cdata.age_rx_cons = rx_cons; + /* Reset mbuf chains. */ + AGE_RXCHAIN_RESET(sc); } static int @@ -2456,16 +2491,16 @@ age_rxintr(struct age_softc *sc, int rr_prod, int count) * I'm not sure whether this check is really needed. */ pktlen = AGE_RX_BYTES(le32toh(rxrd->len)); - if (nsegs != ((pktlen + (MCLBYTES - ETHER_ALIGN - 1)) / - (MCLBYTES - ETHER_ALIGN))) + if (nsegs != (pktlen + (AGE_RX_BUF_SIZE - 1)) / AGE_RX_BUF_SIZE) break; - prog++; /* Received a frame. */ age_rxeof(sc, rxrd); /* Clear return ring. */ rxrd->index = 0; AGE_DESC_INC(rr_cons, AGE_RR_RING_CNT); + sc->age_cdata.age_rx_cons += nsegs; + sc->age_cdata.age_rx_cons %= AGE_RX_RING_CNT; } if (prog > 0) { @@ -3065,7 +3100,9 @@ age_newbuf(struct age_softc *sc, struct age_rxdesc *rxd) if (m == NULL) return (ENOBUFS); m->m_len = m->m_pkthdr.len = MCLBYTES; - m_adj(m, ETHER_ALIGN); +#ifndef __NO_STRICT_ALIGNMENT + m_adj(m, AGE_RX_BUF_ALIGN); +#endif if (bus_dmamap_load_mbuf_sg(sc->age_cdata.age_rx_tag, sc->age_cdata.age_rx_sparemap, m, segs, &nsegs, 0) != 0) { diff --git a/sys/dev/age/if_agevar.h b/sys/dev/age/if_agevar.h index db98eb15ae81..6ee5423fc8e2 100644 --- a/sys/dev/age/if_agevar.h +++ b/sys/dev/age/if_agevar.h @@ -43,6 +43,12 @@ #define AGE_TSO_MAXSEGSIZE 4096 #define AGE_TSO_MAXSIZE (65535 + sizeof(struct ether_vlan_header)) #define AGE_MAXTXSEGS 32 +#define AGE_RX_BUF_ALIGN 8 +#ifndef __NO_STRICT_ALIGNMENT +#define AGE_RX_BUF_SIZE (MCLBYTES - AGE_RX_BUF_ALIGN) +#else +#define AGE_RX_BUF_SIZE (MCLBYTES) +#endif #define AGE_ADDR_LO(x) ((uint64_t) (x) & 0xFFFFFFFF) #define AGE_ADDR_HI(x) ((uint64_t) (x) >> 32) From 5e7c84227ace667264813a5d2055b26b85057778 Mon Sep 17 00:00:00 2001 From: ganbold Date: Tue, 5 Feb 2013 02:25:13 +0000 Subject: [PATCH 02/27] Add gpio driver and update dts and kernel config accordingly. Approved by: gonzo@ --- sys/arm/allwinner/a10_gpio.c | 521 ++++++++++++++++++++++++++++++++ sys/arm/allwinner/files.a10 | 1 + sys/arm/conf/CUBIEBOARD | 2 +- sys/boot/fdt/dts/cubieboard.dts | 9 + 4 files changed, 532 insertions(+), 1 deletion(-) create mode 100644 sys/arm/allwinner/a10_gpio.c diff --git a/sys/arm/allwinner/a10_gpio.c b/sys/arm/allwinner/a10_gpio.c new file mode 100644 index 000000000000..b70d0364bd87 --- /dev/null +++ b/sys/arm/allwinner/a10_gpio.c @@ -0,0 +1,521 @@ +/*- + * Copyright (c) 2013 Ganbold Tsagaankhuu + * Copyright (c) 2012 Oleksandr Tymoshenko + * Copyright (c) 2012 Luiz Otavio O Souza. + * 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. + * + */ +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "gpio_if.h" + +/* + * A10 have 9 banks of gpio. + * 32 pins per bank: + * PA0 - PA17 | PB0 - PB23 | PC0 - PC24 + * PD0 - PD27 | PE0 - PE31 | PF0 - PF5 + * PG0 - PG9 | PH0 - PH27 | PI0 - PI12 + */ + +#define A10_GPIO_PINS 288 +#define A10_GPIO_DEFAULT_CAPS (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT | \ + GPIO_PIN_PULLUP | GPIO_PIN_PULLDOWN) + +struct a10_gpio_softc { + device_t sc_dev; + struct mtx sc_mtx; + struct resource * sc_mem_res; + struct resource * sc_irq_res; + bus_space_tag_t sc_bst; + bus_space_handle_t sc_bsh; + void * sc_intrhand; + int sc_gpio_npins; + struct gpio_pin sc_gpio_pins[A10_GPIO_PINS]; +}; + +enum a10_gpio_fsel { + A10_GPIO_INPUT, + A10_GPIO_OUTPUT, +}; + +enum a10_gpio_pud { + A10_GPIO_NONE, + A10_GPIO_PULLDOWN, + A10_GPIO_PULLUP, +}; + +#define A10_GPIO_LOCK(_sc) mtx_lock(&_sc->sc_mtx) +#define A10_GPIO_UNLOCK(_sc) mtx_unlock(&_sc->sc_mtx) +#define A10_GPIO_LOCK_ASSERT(_sc) mtx_assert(&_sc->sc_mtx, MA_OWNED) + +#define A10_GPIO_GP_CFG(_bank, _pin) 0x00 + ((_bank) * 0x24) + ((_pin)<<2) +#define A10_GPIO_GP_DAT(_bank) 0x10 + ((_bank) * 0x24) +#define A10_GPIO_GP_DRV(_bank, _pin) 0x14 + ((_bank) * 0x24) + ((_pin)<<2) +#define A10_GPIO_GP_PUL(_bank, _pin) 0x1c + ((_bank) * 0x24) + ((_pin)<<2) + +#define A10_GPIO_GP_INT_CFG0 0x200 +#define A10_GPIO_GP_INT_CFG1 0x204 +#define A10_GPIO_GP_INT_CFG2 0x208 +#define A10_GPIO_GP_INT_CFG3 0x20c + +#define A10_GPIO_GP_INT_CTL 0x210 +#define A10_GPIO_GP_INT_STA 0x214 +#define A10_GPIO_GP_INT_DEB 0x218 + +#define A10_GPIO_WRITE(_sc, _off, _val) \ + bus_space_write_4(_sc->sc_bst, _sc->sc_bsh, _off, _val) +#define A10_GPIO_READ(_sc, _off) \ + bus_space_read_4(_sc->sc_bst, _sc->sc_bsh, _off) + +static uint32_t +a10_gpio_get_function(struct a10_gpio_softc *sc, uint32_t pin) +{ + uint32_t bank, func, offset; + + bank = pin / 32; + pin = pin - 32 * bank; + func = pin >> 3; + offset = ((pin & 0x07) << 2); + + A10_GPIO_LOCK(sc); + func = (A10_GPIO_READ(sc, A10_GPIO_GP_CFG(bank, func)) >> offset) & 7; + A10_GPIO_UNLOCK(sc); + + return (func); +} + +static uint32_t +a10_gpio_func_flag(uint32_t nfunc) +{ + + switch (nfunc) { + case A10_GPIO_INPUT: + return (GPIO_PIN_INPUT); + case A10_GPIO_OUTPUT: + return (GPIO_PIN_OUTPUT); + } + return (0); +} + +static void +a10_gpio_set_function(struct a10_gpio_softc *sc, uint32_t pin, uint32_t f) +{ + uint32_t bank, func, data, offset; + + /* Must be called with lock held. */ + A10_GPIO_LOCK_ASSERT(sc); + + bank = pin / 32; + pin = pin - 32 * bank; + func = pin >> 3; + offset = ((pin & 0x07) << 2); + + data = A10_GPIO_READ(sc, A10_GPIO_GP_CFG(bank, func)); + data &= ~(7 << offset); + data |= (f << offset); + A10_GPIO_WRITE(sc, A10_GPIO_GP_CFG(bank, func), data); +} + +static void +a10_gpio_set_pud(struct a10_gpio_softc *sc, uint32_t pin, uint32_t state) +{ + uint32_t bank, offset, pull, val; + + /* Must be called with lock held. */ + A10_GPIO_LOCK_ASSERT(sc); + + bank = pin / 32; + pin = pin - 32 * bank; + pull = pin >> 4; + offset = ((pin & 0x0f) << 1); + + val = A10_GPIO_READ(sc, A10_GPIO_GP_PUL(bank, pull)); + val &= ~(0x03 << offset); + val |= (state << offset); + A10_GPIO_WRITE(sc, A10_GPIO_GP_PUL(bank, pull), val); +} + +static void +a10_gpio_pin_configure(struct a10_gpio_softc *sc, struct gpio_pin *pin, + unsigned int flags) +{ + + A10_GPIO_LOCK(sc); + + /* + * Manage input/output. + */ + if (flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) { + pin->gp_flags &= ~(GPIO_PIN_INPUT|GPIO_PIN_OUTPUT); + if (flags & GPIO_PIN_OUTPUT) { + pin->gp_flags |= GPIO_PIN_OUTPUT; + a10_gpio_set_function(sc, pin->gp_pin, + A10_GPIO_OUTPUT); + } else { + pin->gp_flags |= GPIO_PIN_INPUT; + a10_gpio_set_function(sc, pin->gp_pin, + A10_GPIO_INPUT); + } + } + + /* Manage Pull-up/pull-down. */ + pin->gp_flags &= ~(GPIO_PIN_PULLUP|GPIO_PIN_PULLDOWN); + if (flags & (GPIO_PIN_PULLUP|GPIO_PIN_PULLDOWN)) { + if (flags & GPIO_PIN_PULLUP) { + pin->gp_flags |= GPIO_PIN_PULLUP; + a10_gpio_set_pud(sc, pin->gp_pin, A10_GPIO_PULLUP); + } else { + pin->gp_flags |= GPIO_PIN_PULLDOWN; + a10_gpio_set_pud(sc, pin->gp_pin, A10_GPIO_PULLDOWN); + } + } else + a10_gpio_set_pud(sc, pin->gp_pin, A10_GPIO_NONE); + + A10_GPIO_UNLOCK(sc); +} + +static int +a10_gpio_pin_max(device_t dev, int *maxpin) +{ + + *maxpin = A10_GPIO_PINS - 1; + return (0); +} + +static int +a10_gpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps) +{ + struct a10_gpio_softc *sc = device_get_softc(dev); + int i; + + for (i = 0; i < sc->sc_gpio_npins; i++) { + if (sc->sc_gpio_pins[i].gp_pin == pin) + break; + } + + if (i >= sc->sc_gpio_npins) + return (EINVAL); + + A10_GPIO_LOCK(sc); + *caps = sc->sc_gpio_pins[i].gp_caps; + A10_GPIO_UNLOCK(sc); + + return (0); +} + +static int +a10_gpio_pin_getflags(device_t dev, uint32_t pin, uint32_t *flags) +{ + struct a10_gpio_softc *sc = device_get_softc(dev); + int i; + + for (i = 0; i < sc->sc_gpio_npins; i++) { + if (sc->sc_gpio_pins[i].gp_pin == pin) + break; + } + + if (i >= sc->sc_gpio_npins) + return (EINVAL); + + A10_GPIO_LOCK(sc); + *flags = sc->sc_gpio_pins[i].gp_flags; + A10_GPIO_UNLOCK(sc); + + return (0); +} + +static int +a10_gpio_pin_getname(device_t dev, uint32_t pin, char *name) +{ + struct a10_gpio_softc *sc = device_get_softc(dev); + int i; + + for (i = 0; i < sc->sc_gpio_npins; i++) { + if (sc->sc_gpio_pins[i].gp_pin == pin) + break; + } + + if (i >= sc->sc_gpio_npins) + return (EINVAL); + + A10_GPIO_LOCK(sc); + memcpy(name, sc->sc_gpio_pins[i].gp_name, GPIOMAXNAME); + A10_GPIO_UNLOCK(sc); + + return (0); +} + +static int +a10_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags) +{ + struct a10_gpio_softc *sc = device_get_softc(dev); + int i; + + for (i = 0; i < sc->sc_gpio_npins; i++) { + if (sc->sc_gpio_pins[i].gp_pin == pin) + break; + } + + if (i >= sc->sc_gpio_npins) + return (EINVAL); + + /* Filter out unwanted flags. */ + if ((flags &= sc->sc_gpio_pins[i].gp_caps) != flags) + return (EINVAL); + + /* Can't mix input/output together. */ + if ((flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) == + (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) + return (EINVAL); + + /* Can't mix pull-up/pull-down together. */ + if ((flags & (GPIO_PIN_PULLUP|GPIO_PIN_PULLDOWN)) == + (GPIO_PIN_PULLUP|GPIO_PIN_PULLDOWN)) + return (EINVAL); + + a10_gpio_pin_configure(sc, &sc->sc_gpio_pins[i], flags); + + return (0); +} + +static int +a10_gpio_pin_set(device_t dev, uint32_t pin, unsigned int value) +{ + struct a10_gpio_softc *sc = device_get_softc(dev); + uint32_t bank, offset, data; + int i; + + for (i = 0; i < sc->sc_gpio_npins; i++) { + if (sc->sc_gpio_pins[i].gp_pin == pin) + break; + } + + if (i >= sc->sc_gpio_npins) + return (EINVAL); + + bank = pin / 32; + pin = pin - 32 * bank; + offset = pin & 0x1f; + + A10_GPIO_LOCK(sc); + data = A10_GPIO_READ(sc, A10_GPIO_GP_DAT(bank)); + if (value) + data |= (1 << offset); + else + data &= ~(1 << offset); + A10_GPIO_WRITE(sc, A10_GPIO_GP_DAT(bank), data); + A10_GPIO_UNLOCK(sc); + + return (0); +} + +static int +a10_gpio_pin_get(device_t dev, uint32_t pin, unsigned int *val) +{ + struct a10_gpio_softc *sc = device_get_softc(dev); + uint32_t bank, offset, reg_data; + int i; + + for (i = 0; i < sc->sc_gpio_npins; i++) { + if (sc->sc_gpio_pins[i].gp_pin == pin) + break; + } + + if (i >= sc->sc_gpio_npins) + return (EINVAL); + + bank = pin / 32; + pin = pin - 32 * bank; + offset = pin & 0x1f; + + A10_GPIO_LOCK(sc); + reg_data = A10_GPIO_READ(sc, A10_GPIO_GP_DAT(bank)); + A10_GPIO_UNLOCK(sc); + *val = (reg_data & (1 << offset)) ? 1 : 0; + + return (0); +} + +static int +a10_gpio_pin_toggle(device_t dev, uint32_t pin) +{ + struct a10_gpio_softc *sc = device_get_softc(dev); + uint32_t bank, data, offset; + int i; + + for (i = 0; i < sc->sc_gpio_npins; i++) { + if (sc->sc_gpio_pins[i].gp_pin == pin) + break; + } + + if (i >= sc->sc_gpio_npins) + return (EINVAL); + + bank = pin / 32; + pin = pin - 32 * bank; + offset = pin & 0x1f; + + A10_GPIO_LOCK(sc); + data = A10_GPIO_READ(sc, A10_GPIO_GP_DAT(bank)); + if (data & (1 << offset)) + data &= ~(1 << offset); + else + data |= (1 << offset); + A10_GPIO_WRITE(sc, A10_GPIO_GP_DAT(bank), data); + A10_GPIO_UNLOCK(sc); + + return (0); +} + +static int +a10_gpio_probe(device_t dev) +{ + if (!ofw_bus_is_compatible(dev, "allwinner,sun4i-gpio")) + return (ENXIO); + + device_set_desc(dev, "Allwinner GPIO controller"); + return (BUS_PROBE_DEFAULT); +} + +static int +a10_gpio_attach(device_t dev) +{ + struct a10_gpio_softc *sc = device_get_softc(dev); + uint32_t func; + int i, rid; + phandle_t gpio; + + sc->sc_dev = dev; + + mtx_init(&sc->sc_mtx, "a10 gpio", "gpio", MTX_DEF); + + rid = 0; + sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, + RF_ACTIVE); + if (!sc->sc_mem_res) { + device_printf(dev, "cannot allocate memory window\n"); + return (ENXIO); + } + + sc->sc_bst = rman_get_bustag(sc->sc_mem_res); + sc->sc_bsh = rman_get_bushandle(sc->sc_mem_res); + + rid = 0; + sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, + RF_ACTIVE); + if (!sc->sc_irq_res) { + bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res); + device_printf(dev, "cannot allocate interrupt\n"); + return (ENXIO); + } + + /* Find our node. */ + gpio = ofw_bus_get_node(sc->sc_dev); + + if (!OF_hasprop(gpio, "gpio-controller")) + /* Node is not a GPIO controller. */ + goto fail; + + /* Initialize the software controlled pins. */ + for (i = 0; i < A10_GPIO_PINS; i++) { + snprintf(sc->sc_gpio_pins[i].gp_name, GPIOMAXNAME, + "pin %d", i); + func = a10_gpio_get_function(sc, i); + sc->sc_gpio_pins[i].gp_pin = i; + sc->sc_gpio_pins[i].gp_caps = A10_GPIO_DEFAULT_CAPS; + sc->sc_gpio_pins[i].gp_flags = a10_gpio_func_flag(func); + } + sc->sc_gpio_npins = i; + + device_add_child(dev, "gpioc", device_get_unit(dev)); + device_add_child(dev, "gpiobus", device_get_unit(dev)); + return (bus_generic_attach(dev)); + +fail: + if (sc->sc_irq_res) + bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq_res); + if (sc->sc_mem_res) + bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res); + return (ENXIO); +} + +static int +a10_gpio_detach(device_t dev) +{ + + return (EBUSY); +} + +static device_method_t a10_gpio_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, a10_gpio_probe), + DEVMETHOD(device_attach, a10_gpio_attach), + DEVMETHOD(device_detach, a10_gpio_detach), + + /* GPIO protocol */ + DEVMETHOD(gpio_pin_max, a10_gpio_pin_max), + DEVMETHOD(gpio_pin_getname, a10_gpio_pin_getname), + DEVMETHOD(gpio_pin_getflags, a10_gpio_pin_getflags), + DEVMETHOD(gpio_pin_getcaps, a10_gpio_pin_getcaps), + DEVMETHOD(gpio_pin_setflags, a10_gpio_pin_setflags), + DEVMETHOD(gpio_pin_get, a10_gpio_pin_get), + DEVMETHOD(gpio_pin_set, a10_gpio_pin_set), + DEVMETHOD(gpio_pin_toggle, a10_gpio_pin_toggle), + + DEVMETHOD_END +}; + +static devclass_t a10_gpio_devclass; + +static driver_t a10_gpio_driver = { + "gpio", + a10_gpio_methods, + sizeof(struct a10_gpio_softc), +}; + +DRIVER_MODULE(a10_gpio, simplebus, a10_gpio_driver, a10_gpio_devclass, 0, 0); diff --git a/sys/arm/allwinner/files.a10 b/sys/arm/allwinner/files.a10 index 9d056fc26ed4..5cf202385456 100644 --- a/sys/arm/allwinner/files.a10 +++ b/sys/arm/allwinner/files.a10 @@ -10,6 +10,7 @@ arm/arm/cpufunc_asm_armv7.S standard arm/arm/irq_dispatch.S standard arm/allwinner/a10_clk.c standard +arm/allwinner/a10_gpio.c optional gpio arm/allwinner/a10_ehci.c optional ehci arm/allwinner/timer.c standard arm/allwinner/aintc.c standard diff --git a/sys/arm/conf/CUBIEBOARD b/sys/arm/conf/CUBIEBOARD index 82f484b00d78..fa5bfc8751d1 100644 --- a/sys/arm/conf/CUBIEBOARD +++ b/sys/arm/conf/CUBIEBOARD @@ -99,7 +99,7 @@ device random # Entropy device #device iic # GPIO -#device gpio +device gpio device scbus # SCSI bus (required for SCSI) device da # Direct Access (disks) diff --git a/sys/boot/fdt/dts/cubieboard.dts b/sys/boot/fdt/dts/cubieboard.dts index c4dd2a824612..2d90720b51e9 100644 --- a/sys/boot/fdt/dts/cubieboard.dts +++ b/sys/boot/fdt/dts/cubieboard.dts @@ -76,6 +76,15 @@ clock-frequency = < 24000000 >; }; + GPIO: gpio@01c20800 { + #gpio-cells = <3>; + compatible = "allwinner,sun4i-gpio"; + gpio-controller; + reg =< 0x01c20800 0x400 >; + interrupts = < 28 >; + interrupt-parent = <&AINTC>; + }; + usb1: usb@01c1c000 { compatible = "allwinner,usb-ehci", "usb-ehci"; reg = <0x01c1c000 0x1000>; From f48b0cf979342ef25249b2404b5870feaa101416 Mon Sep 17 00:00:00 2001 From: pfg Date: Tue, 5 Feb 2013 02:57:59 +0000 Subject: [PATCH 03/27] crunchgen: Permit use of alternative linkers. Submitted by: Pete Chou MFC after: 1 week --- usr.sbin/crunch/crunchgen/crunchgen.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.sbin/crunch/crunchgen/crunchgen.c b/usr.sbin/crunch/crunchgen/crunchgen.c index 0fb49064e85b..e25c1accef44 100644 --- a/usr.sbin/crunch/crunchgen/crunchgen.c +++ b/usr.sbin/crunch/crunchgen/crunchgen.c @@ -979,6 +979,7 @@ top_makefile_rules(FILE *outmk) { prog_t *p; + fprintf(outmk, "LD?= ld\n"); if ( subtract_strlst(&libs, &libs_so) ) fprintf(outmk, "# NOTE: Some LIBS declarations below overridden by LIBS_SO\n"); @@ -1108,7 +1109,7 @@ prog_makefile_rules(FILE *outmk, prog_t *p) fprintf(outmk, " $(%s_LIBS)", p->ident); fprintf(outmk, "\n"); - fprintf(outmk, "\tld -dc -r -o %s.lo %s_stub.o $(%s_OBJPATHS)", + fprintf(outmk, "\t$(LD) -dc -r -o %s.lo %s_stub.o $(%s_OBJPATHS)", p->name, p->name, p->ident); if (p->libs) fprintf(outmk, " $(%s_LIBS)", p->ident); From affc90ea665a0feb83f94f917607b09e1f6e7715 Mon Sep 17 00:00:00 2001 From: pfg Date: Tue, 5 Feb 2013 03:01:04 +0000 Subject: [PATCH 04/27] ext2fs: Use EXT2_LINK_MAX instead of LINK_MAX Submitted by: Christoph Mallon MFC after: 2 weeks --- sys/fs/ext2fs/ext2_vnops.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/fs/ext2fs/ext2_vnops.c b/sys/fs/ext2fs/ext2_vnops.c index 4f8f6a90dfe4..7cfc64b0be5e 100644 --- a/sys/fs/ext2fs/ext2_vnops.c +++ b/sys/fs/ext2fs/ext2_vnops.c @@ -730,7 +730,7 @@ ext2_link(ap) goto out; } ip = VTOI(vp); - if ((nlink_t)ip->i_nlink >= LINK_MAX) { + if ((nlink_t)ip->i_nlink >= EXT2_LINK_MAX) { error = EMLINK; goto out; } @@ -841,7 +841,7 @@ abortit: goto abortit; dp = VTOI(fdvp); ip = VTOI(fvp); - if (ip->i_nlink >= LINK_MAX) { + if (ip->i_nlink >= EXT2_LINK_MAX) { VOP_UNLOCK(fvp, 0); error = EMLINK; goto abortit; @@ -939,7 +939,7 @@ abortit: * parent we don't fool with the link count. */ if (doingdirectory && newparent) { - if ((nlink_t)dp->i_nlink >= LINK_MAX) { + if ((nlink_t)dp->i_nlink >= EXT2_LINK_MAX) { error = EMLINK; goto bad; } @@ -1160,7 +1160,7 @@ ext2_mkdir(ap) panic("ext2_mkdir: no name"); #endif dp = VTOI(dvp); - if ((nlink_t)dp->i_nlink >= LINK_MAX) { + if ((nlink_t)dp->i_nlink >= EXT2_LINK_MAX) { error = EMLINK; goto out; } @@ -1524,7 +1524,7 @@ ext2_pathconf(ap) switch (ap->a_name) { case _PC_LINK_MAX: - *ap->a_retval = LINK_MAX; + *ap->a_retval = EXT2_LINK_MAX; return (0); case _PC_NAME_MAX: *ap->a_retval = NAME_MAX; From c181635a65f2aac53f06c8553fa9b67317362cf0 Mon Sep 17 00:00:00 2001 From: pfg Date: Tue, 5 Feb 2013 03:08:56 +0000 Subject: [PATCH 05/27] ext2fs: Use nitems(). Submitted by: Christoph Mallon MFC after: 2 weeks --- sys/fs/ext2fs/ext2_lookup.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sys/fs/ext2fs/ext2_lookup.c b/sys/fs/ext2fs/ext2_lookup.c index 9aadb6a47d3b..edd57049db4a 100644 --- a/sys/fs/ext2fs/ext2_lookup.c +++ b/sys/fs/ext2fs/ext2_lookup.c @@ -88,9 +88,8 @@ static u_char ext2_ft_to_dt[] = { DT_SOCK, /* EXT2_FT_SOCK */ DT_LNK, /* EXT2_FT_SYMLINK */ }; -#define FTTODT(ft) \ - ((ft) > sizeof(ext2_ft_to_dt) / sizeof(ext2_ft_to_dt[0]) ? \ - DT_UNKNOWN : ext2_ft_to_dt[(ft)]) +#define FTTODT(ft) \ + ((ft) > nitems(ext2_ft_to_dt) ? DT_UNKNOWN : ext2_ft_to_dt[(ft)]) static u_char dt_to_ext2_ft[] = { EXT2_FT_UNKNOWN, /* DT_UNKNOWN */ @@ -109,9 +108,8 @@ static u_char dt_to_ext2_ft[] = { EXT2_FT_UNKNOWN, /* unused */ EXT2_FT_UNKNOWN, /* DT_WHT */ }; -#define DTTOFT(dt) \ - ((dt) > sizeof(dt_to_ext2_ft) / sizeof(dt_to_ext2_ft[0]) ? \ - EXT2_FT_UNKNOWN : dt_to_ext2_ft[(dt)]) +#define DTTOFT(dt) \ + ((dt) > nitems(dt_to_ext2_ft) ? EXT2_FT_UNKNOWN : dt_to_ext2_ft[(dt)]) static int ext2_dirbadentry(struct vnode *dp, struct ext2fs_direct_2 *de, int entryoffsetinblock); From 28dd7f0e2d52783a84b0a2e72365a2ff34d54a41 Mon Sep 17 00:00:00 2001 From: pfg Date: Tue, 5 Feb 2013 03:13:05 +0000 Subject: [PATCH 06/27] ext2fs: Correct off-by-one errors in FFTODT() and DDTOFT(). Submitted by: Christoph Mallon MFC after: 2 weeks --- sys/fs/ext2fs/ext2_lookup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/fs/ext2fs/ext2_lookup.c b/sys/fs/ext2fs/ext2_lookup.c index edd57049db4a..441e9a611eca 100644 --- a/sys/fs/ext2fs/ext2_lookup.c +++ b/sys/fs/ext2fs/ext2_lookup.c @@ -89,7 +89,7 @@ static u_char ext2_ft_to_dt[] = { DT_LNK, /* EXT2_FT_SYMLINK */ }; #define FTTODT(ft) \ - ((ft) > nitems(ext2_ft_to_dt) ? DT_UNKNOWN : ext2_ft_to_dt[(ft)]) + ((ft) < nitems(ext2_ft_to_dt) ? ext2_ft_to_dt[(ft)] : DT_UNKNOWN) static u_char dt_to_ext2_ft[] = { EXT2_FT_UNKNOWN, /* DT_UNKNOWN */ @@ -109,7 +109,7 @@ static u_char dt_to_ext2_ft[] = { EXT2_FT_UNKNOWN, /* DT_WHT */ }; #define DTTOFT(dt) \ - ((dt) > nitems(dt_to_ext2_ft) ? EXT2_FT_UNKNOWN : dt_to_ext2_ft[(dt)]) + ((dt) < nitems(dt_to_ext2_ft) ? dt_to_ext2_ft[(dt)] : EXT2_FT_UNKNOWN) static int ext2_dirbadentry(struct vnode *dp, struct ext2fs_direct_2 *de, int entryoffsetinblock); From c6538dcc306735e3c4403502e6a57ee5f189bae0 Mon Sep 17 00:00:00 2001 From: pfg Date: Tue, 5 Feb 2013 03:17:41 +0000 Subject: [PATCH 07/27] ext2fs: Remove useless rootino local variable. Submitted by: Christoph Mallon MFC after: 2 weeks --- sys/fs/ext2fs/ext2_lookup.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/fs/ext2fs/ext2_lookup.c b/sys/fs/ext2fs/ext2_lookup.c index 441e9a611eca..57c8ece733a8 100644 --- a/sys/fs/ext2fs/ext2_lookup.c +++ b/sys/fs/ext2fs/ext2_lookup.c @@ -1086,7 +1086,7 @@ ext2_checkpath(source, target, cred) struct ucred *cred; { struct vnode *vp; - int error, rootino, namlen; + int error, namlen; struct dirtemplate dirbuf; vp = ITOV(target); @@ -1094,9 +1094,8 @@ ext2_checkpath(source, target, cred) error = EEXIST; goto out; } - rootino = EXT2_ROOTINO; error = 0; - if (target->i_number == rootino) + if (target->i_number == EXT2_ROOTINO) goto out; for (;;) { @@ -1121,7 +1120,7 @@ ext2_checkpath(source, target, cred) error = EINVAL; break; } - if (dirbuf.dotdot_ino == rootino) + if (dirbuf.dotdot_ino == EXT2_ROOTINO) break; vput(vp); if ((error = VFS_VGET(vp->v_mount, dirbuf.dotdot_ino, From 935c860d1b33195a4176499a8009549fd7a1c814 Mon Sep 17 00:00:00 2001 From: pfg Date: Tue, 5 Feb 2013 03:23:56 +0000 Subject: [PATCH 08/27] ext2fs: Remove unused em_e2fsb definition.. Submitted by: Christoph Mallon MFC after: 2 weeks --- sys/fs/ext2fs/ext2_mount.h | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/fs/ext2fs/ext2_mount.h b/sys/fs/ext2fs/ext2_mount.h index f9952673271e..7c598f690734 100644 --- a/sys/fs/ext2fs/ext2_mount.h +++ b/sys/fs/ext2fs/ext2_mount.h @@ -48,7 +48,6 @@ struct ext2mount { struct vnode *um_devvp; /* block device mounted vnode */ struct m_ext2fs *um_e2fs; /* EXT2FS */ -#define em_e2fsb um_e2fs->e2fs u_long um_nindir; /* indirect ptrs per block */ u_long um_bptrtodb; /* indir ptr to disk block */ From 5e55b2c6f7167a85ef25c5e89b3657cea1f67b36 Mon Sep 17 00:00:00 2001 From: pfg Date: Tue, 5 Feb 2013 03:26:34 +0000 Subject: [PATCH 09/27] ext2fs: move assignment where it is not dead. Submitted by: Christoph Mallon MFC after: 2 weeks --- sys/fs/ext2fs/ext2_lookup.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/fs/ext2fs/ext2_lookup.c b/sys/fs/ext2fs/ext2_lookup.c index 57c8ece733a8..8827550c0e09 100644 --- a/sys/fs/ext2fs/ext2_lookup.c +++ b/sys/fs/ext2fs/ext2_lookup.c @@ -1094,9 +1094,10 @@ ext2_checkpath(source, target, cred) error = EEXIST; goto out; } - error = 0; - if (target->i_number == EXT2_ROOTINO) + if (target->i_number == EXT2_ROOTINO) { + error = 0; goto out; + } for (;;) { if (vp->v_type != VDIR) { From cb0688f6b3e190f7e08ad7051a30e91e4e6471bd Mon Sep 17 00:00:00 2001 From: ganbold Date: Tue, 5 Feb 2013 04:13:34 +0000 Subject: [PATCH 10/27] Remove two dead assignments and make use of sc more explicit and clear Submitted by: Christoph Mallon Approved by: gonzo@ --- sys/arm/allwinner/a10_clk.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sys/arm/allwinner/a10_clk.c b/sys/arm/allwinner/a10_clk.c index 2d7699ededfd..275ec4b85c1c 100644 --- a/sys/arm/allwinner/a10_clk.c +++ b/sys/arm/allwinner/a10_clk.c @@ -62,10 +62,10 @@ struct a10_ccm_softc { static struct a10_ccm_softc *a10_ccm_sc = NULL; -#define ccm_read_4(reg) \ - bus_space_read_4(a10_ccm_sc->bst, a10_ccm_sc->bsh, reg) -#define ccm_write_4(reg, val) \ - bus_space_write_4(a10_ccm_sc->bst, a10_ccm_sc->bsh, reg, val) +#define ccm_read_4(sc, reg) \ + bus_space_read_4((sc)->bst, (sc)->bsh, (reg)) +#define ccm_write_4(sc, reg, val) \ + bus_space_write_4((sc)->bst, (sc)->bsh, (reg), (val)) static int a10_ccm_probe(device_t dev) @@ -121,24 +121,24 @@ int a10_clk_usb_activate(void) { struct a10_ccm_softc *sc = a10_ccm_sc; - uint32_t reg_value = 0; + uint32_t reg_value; if (sc == NULL) return ENXIO; /* Gating AHB clock for USB */ - reg_value = ccm_read_4(CCM_AHB_GATING0); + reg_value = ccm_read_4(sc, CCM_AHB_GATING0); reg_value |= CCM_AHB_GATING_USB0; /* AHB clock gate usb0 */ reg_value |= CCM_AHB_GATING_EHCI1; /* AHB clock gate ehci1 */ - ccm_write_4(CCM_AHB_GATING0, reg_value); + ccm_write_4(sc, CCM_AHB_GATING0, reg_value); /* Enable clock for USB */ - reg_value = ccm_read_4(CCM_USB_CLK); + reg_value = ccm_read_4(sc, CCM_USB_CLK); reg_value |= CCM_USB_PHY; /* USBPHY */ reg_value |= CCM_USB0_RESET; /* disable reset for USB0 */ reg_value |= CCM_USB1_RESET; /* disable reset for USB1 */ reg_value |= CCM_USB2_RESET; /* disable reset for USB2 */ - ccm_write_4(CCM_USB_CLK, reg_value); + ccm_write_4(sc, CCM_USB_CLK, reg_value); return (0); } @@ -147,24 +147,24 @@ int a10_clk_usb_deactivate(void) { struct a10_ccm_softc *sc = a10_ccm_sc; - uint32_t reg_value = 0; + uint32_t reg_value; if (sc == NULL) return ENXIO; /* Disable clock for USB */ - reg_value = ccm_read_4(CCM_USB_CLK); + reg_value = ccm_read_4(sc, CCM_USB_CLK); reg_value &= ~CCM_USB_PHY; /* USBPHY */ reg_value &= ~CCM_USB0_RESET; /* reset for USB0 */ reg_value &= ~CCM_USB1_RESET; /* reset for USB1 */ reg_value &= ~CCM_USB2_RESET; /* reset for USB2 */ - ccm_write_4(CCM_USB_CLK, reg_value); + ccm_write_4(sc, CCM_USB_CLK, reg_value); /* Disable gating AHB clock for USB */ - reg_value = ccm_read_4(CCM_AHB_GATING0); + reg_value = ccm_read_4(sc, CCM_AHB_GATING0); reg_value &= ~CCM_AHB_GATING_USB0; /* disable AHB clock gate usb0 */ reg_value &= ~CCM_AHB_GATING_EHCI1; /* disable AHB clock gate ehci1 */ - ccm_write_4(CCM_AHB_GATING0, reg_value); + ccm_write_4(sc, CCM_AHB_GATING0, reg_value); return (0); } From dd9a9322547ab032c9e7a3fe43e96964a0ae22b6 Mon Sep 17 00:00:00 2001 From: andrew Date: Tue, 5 Feb 2013 05:16:02 +0000 Subject: [PATCH 11/27] Build clang for little-endian arm by default. Due to size issues when built with gcc disable CLANG_FULL for now. --- share/mk/bsd.own.mk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index aea33d3eae77..d500586cccf0 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -389,9 +389,13 @@ __T=${TARGET_ARCH} .else __T=${MACHINE_ARCH} .endif -# Clang is only for x86 and powerpc right now, by default. +# Clang is only for x86, powerpc and little-endian arm right now, by default. .if ${__T} == "amd64" || ${__T} == "i386" || ${__T:Mpowerpc*} __DEFAULT_YES_OPTIONS+=CLANG CLANG_FULL +.elif ${__T} == "arm" || ${__T} == "armv6" +__DEFAULT_YES_OPTIONS+=CLANG +# GCC is unable to build the full clang on arm, disable it by default. +__DEFAULT_NO_OPTIONS+=CLANG_FULL .else __DEFAULT_NO_OPTIONS+=CLANG CLANG_FULL .endif From 2ab43ec83ecf3474d4eddf9a184cc0adea3516d5 Mon Sep 17 00:00:00 2001 From: des Date: Tue, 5 Feb 2013 12:18:39 +0000 Subject: [PATCH 12/27] Load the pfsync module if necessary. Reviewed by: glebius@ MFC after: 1 week --- etc/rc.d/pfsync | 1 + 1 file changed, 1 insertion(+) diff --git a/etc/rc.d/pfsync b/etc/rc.d/pfsync index fa89b30bc08d..3dab3a84adcd 100755 --- a/etc/rc.d/pfsync +++ b/etc/rc.d/pfsync @@ -35,6 +35,7 @@ pfsync_start() if [ -n "${pfsync_syncpeer}" ]; then _syncpeer="syncpeer ${pfsync_syncpeer}" fi + load_kld pfsync ifconfig pfsync0 $_syncpeer syncdev $pfsync_syncdev $pfsync_ifconfig up } From 7dec4a95038f38871867b747e711cea945746647 Mon Sep 17 00:00:00 2001 From: hselasky Date: Tue, 5 Feb 2013 12:37:50 +0000 Subject: [PATCH 13/27] Fix depend target. --- sys/boot/usb/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/boot/usb/Makefile b/sys/boot/usb/Makefile index b71b10df40dd..3ed12c801999 100644 --- a/sys/boot/usb/Makefile +++ b/sys/boot/usb/Makefile @@ -42,13 +42,13 @@ OBJCOPY?= objcopy SYSCC?= cc CFLAGS+= -DBOOTPROG=\"usbloader\" -CFLAGS+= -DUSB_GLOBAL_INCLUDE_FILE="\"bsd_global.h\"" +CFLAGS+= -DUSB_GLOBAL_INCLUDE_FILE=\"bsd_global.h\" CFLAGS+= -ffunction-sections -fdata-sections CFLAGS+= -ffreestanding CFLAGS+= -Wformat -Wall -CFLAGS+= -I ${S} -CFLAGS+= -I ${T} -CFLAGS+= -I ${.CURDIR} +CFLAGS+= -I${S} +CFLAGS+= -I${T} +CFLAGS+= -I${.CURDIR} CFLAGS+= -g .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" From 44b21d3825c0d4faf0e12c6e7e2e0eff88397f47 Mon Sep 17 00:00:00 2001 From: hselasky Date: Tue, 5 Feb 2013 13:30:07 +0000 Subject: [PATCH 14/27] Fix some nits. --- sys/dev/usb/usb_bus.h | 2 ++ sys/dev/usb/usb_dynamic.c | 2 +- sys/dev/usb/usb_msctest.c | 2 +- sys/dev/usb/usb_process.c | 4 ++-- sys/dev/usb/usb_request.c | 2 -- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/dev/usb/usb_bus.h b/sys/dev/usb/usb_bus.h index 07207cf6190c..95c163210948 100644 --- a/sys/dev/usb/usb_bus.h +++ b/sys/dev/usb/usb_bus.h @@ -51,7 +51,9 @@ struct usb_bus_stat { struct usb_bus { struct usb_bus_stat stats_err; struct usb_bus_stat stats_ok; +#if USB_HAVE_ROOT_MOUNT_HOLD struct root_hold_token *bus_roothold; +#endif /* * There are two callback processes. One for Giant locked * callbacks. One for non-Giant locked callbacks. This should diff --git a/sys/dev/usb/usb_dynamic.c b/sys/dev/usb/usb_dynamic.c index f8bb03fe5c66..58deb4e2cf32 100644 --- a/sys/dev/usb/usb_dynamic.c +++ b/sys/dev/usb/usb_dynamic.c @@ -68,7 +68,7 @@ usb_temp_setup_by_index_t *usb_temp_setup_by_index_p = &usb_temp_setup_by_index_ usb_temp_unsetup_t *usb_temp_unsetup_p = &usb_temp_unsetup_w; usb_test_quirk_t *usb_test_quirk_p = &usb_test_quirk_w; usb_quirk_ioctl_t *usb_quirk_ioctl_p = &usb_quirk_ioctl_w; -devclass_t usb_devclass_ptr = NULL; +devclass_t usb_devclass_ptr; static usb_error_t usb_temp_setup_by_index_w(struct usb_device *udev, uint16_t index) diff --git a/sys/dev/usb/usb_msctest.c b/sys/dev/usb/usb_msctest.c index 497e382019de..a1bc5fc006a4 100644 --- a/sys/dev/usb/usb_msctest.c +++ b/sys/dev/usb/usb_msctest.c @@ -848,7 +848,7 @@ usb_msc_eject(struct usb_device *udev, uint8_t iface_index, int method) sizeof(scsi_tct_eject), USB_MS_HZ); break; default: - printf("usb_msc_eject: unknown eject method (%d)\n", method); + DPRINTF("Unknown eject method (%d)\n", method); break; } DPRINTF("Eject CD command status: %s\n", usbd_errstr(err)); diff --git a/sys/dev/usb/usb_process.c b/sys/dev/usb/usb_process.c index 34314f458a05..7493e39c6686 100644 --- a/sys/dev/usb/usb_process.c +++ b/sys/dev/usb/usb_process.c @@ -24,8 +24,6 @@ * SUCH DAMAGE. */ -#define USB_DEBUG_VAR usb_proc_debug - #ifdef USB_GLOBAL_INCLUDE_FILE #include USB_GLOBAL_INCLUDE_FILE #else @@ -52,6 +50,8 @@ #include #include #include + +#define USB_DEBUG_VAR usb_proc_debug #include #include diff --git a/sys/dev/usb/usb_request.c b/sys/dev/usb/usb_request.c index 6a819457a369..4db5b7d9b39a 100644 --- a/sys/dev/usb/usb_request.c +++ b/sys/dev/usb/usb_request.c @@ -800,8 +800,6 @@ usbd_req_reset_port(struct usb_device *udev, struct mtx *mtx, uint8_t port) /* check for errors */ if (err) goto done; -#ifdef USB_DEBUG -#endif n = 0; while (1) { /* wait for the device to recover from reset */ From e05b8f83c12a3cb88401b017b2931c013b8d3622 Mon Sep 17 00:00:00 2001 From: zeising Date: Tue, 5 Feb 2013 14:29:37 +0000 Subject: [PATCH 15/27] Bump .Dd for the change in r246121. Approved by: joel (mentor) --- sbin/devd/devd.8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/devd/devd.8 b/sbin/devd/devd.8 index bc5092ccb7ac..8e332366dc9e 100644 --- a/sbin/devd/devd.8 +++ b/sbin/devd/devd.8 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 24, 2005 +.Dd January 30, 2013 .Dt DEVD 8 .Os .Sh NAME From 72c8e2de5282a2d1848447691f49c30e83e28950 Mon Sep 17 00:00:00 2001 From: des Date: Tue, 5 Feb 2013 14:39:37 +0000 Subject: [PATCH 16/27] Remove political propaganda --- games/fortune/datfiles/fortunes-o.real | 227 ------------------------- 1 file changed, 227 deletions(-) diff --git a/games/fortune/datfiles/fortunes-o.real b/games/fortune/datfiles/fortunes-o.real index 93fe0ef2bb15..851a439c8c7e 100644 --- a/games/fortune/datfiles/fortunes-o.real +++ b/games/fortune/datfiles/fortunes-o.real @@ -11437,233 +11437,6 @@ two new uses for sheep. Meat and wool. % Runners do it alone. % -Rush Limbaugh's 35 Undeniable Truths of Life: - -(1) The greatest threat to the human spirit is liberalism. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(10) Liberalism poisons the soul. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(11) Neither the United States, nor anyone else, "imposes" freedom on - the people of other nations. Freedom is not an imposition. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(12) Freedom is God-given. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(13) To dictatorships, peace means the absence of opposition. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(14) To free people, peace means the absence of threat. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(15) The Peace Movement in the United States was, whether by accident or - design, pro-communist. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(16) The collective knowledge and wisdom of seasoned citizens is the - most valuable, yet untapped, resource our young people have. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(17) The greatest football team in the history of civilization was the - Pittsburgh Steelers of 1975 through 1980. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(18) There is no such thing as "war atrocities." War is an atrocity. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(19) Regardless of the pain in our memories, nostalgia only reminds us - of the good times in our past. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(2) The single greatest threat to the free people of the world is posed - by the heinous idea of centralized government control. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(20) There is a God. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(21) Abortion is wrong. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(22) Morality is not defined by individual choice. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(23) Evolution cannot explain creation. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(24) Feminism was established so that unattractive women could have - easier access to the mainstream of society. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(25) Love is the only human emotion which cannot be controlled. You - either do or you don't. You can't fake it. (Except women, and - thank God they can.) - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(26) The only difference between Mikhail Gorbachev and previous Soviet - leaders is that he is alive. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(27) Soviet leaders were actually left-wing dictators. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(28) Abraham Lincoln saved this nation. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(29) The Los Angeles Raiders will never be the team they were when they - called Oakland home. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(3) Peace does not mean the elimination of nuclear weapons. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(30) The United States will again go to war. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(31) To more and more American intellectuals, a victorious United States - is a sinful United States. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(32) The fact that American intellectuals rue a victorious United States - is frightening and ominous. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(33) There will always be poor people. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(34) The fact that there will always be poor people is not the fault of - the rich. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(35) Rather than feel guilty as some do, you should thank God for making - you an American. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(4) Peace does not mean the absence of war. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(5) War is not obsolete. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(6) Ours is a world governed by the aggressive use of force. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(7) There is only one way to eliminate nuclear weapons. Use them. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(8) Peace cannot be achieved merely by developing an "understanding" - among peoples. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% -Rush Limbaugh's 35 Undeniable Truths of Life: - -(9) Americans opposing America is not always sacred nor courageous ... - it is sometimes dangerous. - - -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc. -% Said a dainty young whore named Ms. Meggs, "The men like to spread my two legs, Then slip in between, From 2e6231f8ebe6ac7a9374e9c72531a220a8aa2d9d Mon Sep 17 00:00:00 2001 From: hselasky Date: Tue, 5 Feb 2013 14:44:25 +0000 Subject: [PATCH 17/27] Add defines to more easily allow a single threaded version of the FreeBSD USB stack. This is useful for non-kernel purposes, like the loader. --- sys/boot/usb/bsd_global.h | 2 + sys/boot/usb/bsd_kernel.c | 46 +------------------- sys/boot/usb/bsd_kernel.h | 4 ++ sys/dev/usb/controller/usb_controller.c | 58 +++++++++++++------------ sys/dev/usb/controller/xhci.c | 11 +---- sys/dev/usb/controller/xhci.h | 3 +- sys/dev/usb/usb_bus.h | 8 ++++ sys/dev/usb/usb_device.c | 2 +- sys/dev/usb/usb_freebsd.h | 1 + sys/dev/usb/usb_freebsd_loader.h | 1 + sys/dev/usb/usb_hub.c | 2 +- sys/dev/usb/usb_transfer.c | 22 +++++----- 12 files changed, 64 insertions(+), 96 deletions(-) diff --git a/sys/boot/usb/bsd_global.h b/sys/boot/usb/bsd_global.h index 9fe1c8cf244e..80cbd6366a35 100644 --- a/sys/boot/usb/bsd_global.h +++ b/sys/boot/usb/bsd_global.h @@ -60,4 +60,6 @@ #include #include +extern struct usb_process usb_process[USB_PROC_MAX]; + #endif /* _BSD_GLOBAL_H_ */ diff --git a/sys/boot/usb/bsd_kernel.c b/sys/boot/usb/bsd_kernel.c index 5f24c2d79823..d3daa63f26f0 100644 --- a/sys/boot/usb/bsd_kernel.c +++ b/sys/boot/usb/bsd_kernel.c @@ -26,7 +26,8 @@ #include -static struct usb_process usb_process[USB_PROC_MAX]; +struct usb_process usb_process[USB_PROC_MAX]; + static device_t usb_pci_root; /*------------------------------------------------------------------------* @@ -977,41 +978,6 @@ repeat: return (worked); } -int -usb_proc_create(struct usb_process *up, struct mtx *p_mtx, - const char *pmesg, uint8_t prio) -{ -#define USB_PROC_OFFSET(a,b) \ - ((int)(((long)&((struct usb_bus *)0)->a) - \ - ((long)&((struct usb_bus *)0)->b))) - - /* figure out which process we are creating */ - switch ((int)((long)up - (long)p_mtx)) { - case USB_PROC_OFFSET(giant_callback_proc, bus_mtx): - up->up_ptr = (void *)(usb_process + 2); - break; - case USB_PROC_OFFSET(non_giant_callback_proc, bus_mtx): - up->up_ptr = (void *)(usb_process + 2); - break; - case USB_PROC_OFFSET(explore_proc, bus_mtx): - up->up_ptr = (void *)(usb_process + 0); - break; - case USB_PROC_OFFSET(control_xfer_proc, bus_mtx): - up->up_ptr = (void *)(usb_process + 1); - break; - default: - up->up_ptr = (void *)(usb_process + 1); - break; - } - return (0); /* success */ -} - -void -usb_proc_free(struct usb_process *up) -{ - /* NOP */ -} - void * usb_proc_msignal(struct usb_process *up, void *_pm0, void *_pm1) { @@ -1021,10 +987,6 @@ usb_proc_msignal(struct usb_process *up, void *_pm0, void *_pm1) usb_size_t d; uint8_t t; - /* find the correct parent */ - while (up->up_ptr != NULL) - up = (struct usb_process *)up->up_ptr; - t = 0; if (pm0->pm_qentry.tqe_prev) { @@ -1104,10 +1066,6 @@ usb_proc_mwait(struct usb_process *up, void *_pm0, void *_pm1) struct usb_proc_msg *pm0 = _pm0; struct usb_proc_msg *pm1 = _pm1; - /* find the correct parent */ - while (up->up_ptr != NULL) - up = (struct usb_process *)up->up_ptr; - /* Just remove the messages from the queue. */ if (pm0->pm_qentry.tqe_prev) { TAILQ_REMOVE(&up->up_qhead, pm0, pm_qentry); diff --git a/sys/boot/usb/bsd_kernel.h b/sys/boot/usb/bsd_kernel.h index 4c9472165616..e9d9602fb441 100644 --- a/sys/boot/usb/bsd_kernel.h +++ b/sys/boot/usb/bsd_kernel.h @@ -40,6 +40,10 @@ #define M_USB 0 #define M_USBDEV 0 #define USB_PROC_MAX 3 +#define USB_BUS_GIANT_PROC(bus) (usb_process + 2) +#define USB_BUS_NON_GIANT_PROC(bus) (usb_process + 2) +#define USB_BUS_EXPLORE_PROC(bus) (usb_process + 0) +#define USB_BUS_CONTROL_XFER_PROC(bus) (usb_process + 1) #define SYSCTL_DECL(...) #define SYSCTL_NODE(name,...) struct { } name __used #define SYSCTL_INT(...) diff --git a/sys/dev/usb/controller/usb_controller.c b/sys/dev/usb/controller/usb_controller.c index 204569f17b4a..cf2ae7a5569a 100644 --- a/sys/dev/usb/controller/usb_controller.c +++ b/sys/dev/usb/controller/usb_controller.c @@ -214,27 +214,29 @@ usb_detach(device_t dev) USB_BUS_LOCK(bus); /* Queue detach job */ - usb_proc_msignal(&bus->explore_proc, + usb_proc_msignal(USB_BUS_EXPLORE_PROC(bus), &bus->detach_msg[0], &bus->detach_msg[1]); /* Wait for detach to complete */ - usb_proc_mwait(&bus->explore_proc, + usb_proc_mwait(USB_BUS_EXPLORE_PROC(bus), &bus->detach_msg[0], &bus->detach_msg[1]); USB_BUS_UNLOCK(bus); +#if USB_HAVE_PER_BUS_PROCESS /* Get rid of USB callback processes */ - usb_proc_free(&bus->giant_callback_proc); - usb_proc_free(&bus->non_giant_callback_proc); + usb_proc_free(USB_BUS_GIANT_PROC(bus)); + usb_proc_free(USB_BUS_NON_GIANT_PROC(bus)); /* Get rid of USB explore process */ - usb_proc_free(&bus->explore_proc); + usb_proc_free(USB_BUS_EXPLORE_PROC(bus)); /* Get rid of control transfer process */ - usb_proc_free(&bus->control_xfer_proc); + usb_proc_free(USB_BUS_CONTROL_XFER_PROC(bus)); +#endif #if USB_HAVE_PF usbpf_detach(bus); @@ -258,11 +260,11 @@ usb_suspend(device_t dev) } USB_BUS_LOCK(bus); - usb_proc_msignal(&bus->explore_proc, + usb_proc_msignal(USB_BUS_EXPLORE_PROC(bus), &bus->suspend_msg[0], &bus->suspend_msg[1]); if (usb_no_suspend_wait == 0) { /* wait for suspend callback to be executed */ - usb_proc_mwait(&bus->explore_proc, + usb_proc_mwait(USB_BUS_EXPLORE_PROC(bus), &bus->suspend_msg[0], &bus->suspend_msg[1]); } USB_BUS_UNLOCK(bus); @@ -286,7 +288,7 @@ usb_resume(device_t dev) } USB_BUS_LOCK(bus); - usb_proc_msignal(&bus->explore_proc, + usb_proc_msignal(USB_BUS_EXPLORE_PROC(bus), &bus->resume_msg[0], &bus->resume_msg[1]); USB_BUS_UNLOCK(bus); @@ -311,11 +313,11 @@ usb_shutdown(device_t dev) device_printf(bus->bdev, "Controller shutdown\n"); USB_BUS_LOCK(bus); - usb_proc_msignal(&bus->explore_proc, + usb_proc_msignal(USB_BUS_EXPLORE_PROC(bus), &bus->shutdown_msg[0], &bus->shutdown_msg[1]); if (usb_no_shutdown_wait == 0) { /* wait for shutdown callback to be executed */ - usb_proc_mwait(&bus->explore_proc, + usb_proc_mwait(USB_BUS_EXPLORE_PROC(bus), &bus->shutdown_msg[0], &bus->shutdown_msg[1]); } USB_BUS_UNLOCK(bus); @@ -358,9 +360,9 @@ usb_bus_explore(struct usb_proc_msg *pm) * The following three lines of code are only here to * recover from DDB: */ - usb_proc_rewakeup(&bus->control_xfer_proc); - usb_proc_rewakeup(&bus->giant_callback_proc); - usb_proc_rewakeup(&bus->non_giant_callback_proc); + usb_proc_rewakeup(USB_BUS_CONTROL_XFER_PROC(bus)); + usb_proc_rewakeup(USB_BUS_GIANT_PROC(bus)); + usb_proc_rewakeup(USB_BUS_NON_GIANT_PROC(bus)); #endif USB_BUS_UNLOCK(bus); @@ -585,7 +587,7 @@ usb_power_wdog(void *arg) * The following line of code is only here to recover from * DDB: */ - usb_proc_rewakeup(&bus->explore_proc); /* recover from DDB */ + usb_proc_rewakeup(USB_BUS_EXPLORE_PROC(bus)); /* recover from DDB */ #endif #if USB_HAVE_POWERD @@ -708,8 +710,6 @@ usb_bus_attach(struct usb_proc_msg *pm) static void usb_attach_sub(device_t dev, struct usb_bus *bus) { - const char *pname = device_get_nameunit(dev); - mtx_lock(&Giant); if (usb_devclass_ptr == NULL) usb_devclass_ptr = devclass_find("usbus"); @@ -749,28 +749,31 @@ usb_attach_sub(device_t dev, struct usb_bus *bus) bus->shutdown_msg[1].hdr.pm_callback = &usb_bus_shutdown; bus->shutdown_msg[1].bus = bus; +#if USB_HAVE_PER_BUS_PROCESS /* Create USB explore and callback processes */ - if (usb_proc_create(&bus->giant_callback_proc, - &bus->bus_mtx, pname, USB_PRI_MED)) { + if (usb_proc_create(USB_BUS_GIANT_PROC(bus), + &bus->bus_mtx, device_get_nameunit(dev), USB_PRI_MED)) { device_printf(dev, "WARNING: Creation of USB Giant " "callback process failed.\n"); - } else if (usb_proc_create(&bus->non_giant_callback_proc, - &bus->bus_mtx, pname, USB_PRI_HIGH)) { + } else if (usb_proc_create(USB_BUS_NON_GIANT_PROC(bus), + &bus->bus_mtx, device_get_nameunit(dev), USB_PRI_HIGH)) { device_printf(dev, "WARNING: Creation of USB non-Giant " "callback process failed.\n"); - } else if (usb_proc_create(&bus->explore_proc, - &bus->bus_mtx, pname, USB_PRI_MED)) { + } else if (usb_proc_create(USB_BUS_EXPLORE_PROC(bus), + &bus->bus_mtx, device_get_nameunit(dev), USB_PRI_MED)) { device_printf(dev, "WARNING: Creation of USB explore " "process failed.\n"); - } else if (usb_proc_create(&bus->control_xfer_proc, - &bus->bus_mtx, pname, USB_PRI_MED)) { + } else if (usb_proc_create(USB_BUS_CONTROL_XFER_PROC(bus), + &bus->bus_mtx, device_get_nameunit(dev), USB_PRI_MED)) { device_printf(dev, "WARNING: Creation of USB control transfer " "process failed.\n"); - } else { + } else +#endif + { /* Get final attach going */ USB_BUS_LOCK(bus); - usb_proc_msignal(&bus->explore_proc, + usb_proc_msignal(USB_BUS_EXPLORE_PROC(bus), &bus->attach_msg[0], &bus->attach_msg[1]); USB_BUS_UNLOCK(bus); @@ -778,7 +781,6 @@ usb_attach_sub(device_t dev, struct usb_bus *bus) usb_needs_explore(bus, 1); } } - SYSUNINIT(usb_bus_unload, SI_SUB_KLD, SI_ORDER_ANY, usb_bus_unload, NULL); /*------------------------------------------------------------------------* diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c index 4023eccc4596..9f84b394fac3 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -547,19 +547,12 @@ xhci_init(struct xhci_softc *sc, device_t self) sc->sc_config_msg[1].hdr.pm_callback = &xhci_configure_msg; sc->sc_config_msg[1].bus = &sc->sc_bus; - if (usb_proc_create(&sc->sc_config_proc, - &sc->sc_bus.bus_mtx, device_get_nameunit(self), USB_PRI_MED)) { - printf("WARNING: Creation of XHCI configure " - "callback process failed.\n"); - } return (0); } void xhci_uninit(struct xhci_softc *sc) { - usb_proc_free(&sc->sc_config_proc); - usb_bus_mem_free_all(&sc->sc_bus, &xhci_iterate_hw_softc); cv_destroy(&sc->sc_cmd_cv); @@ -2684,7 +2677,7 @@ xhci_transfer_insert(struct usb_xfer *xfer) DPRINTFN(8, "Not running\n"); /* start configuration */ - (void)usb_proc_msignal(&sc->sc_config_proc, + (void)usb_proc_msignal(USB_BUS_CONTROL_XFER_PROC(&sc->sc_bus), &sc->sc_config_msg[0], &sc->sc_config_msg[1]); return (0); } @@ -3652,7 +3645,7 @@ xhci_start_dma_delay(struct usb_xfer *xfer) /* put transfer on interrupt queue (again) */ usbd_transfer_enqueue(&sc->sc_bus.intr_q, xfer); - (void)usb_proc_msignal(&sc->sc_config_proc, + (void)usb_proc_msignal(USB_BUS_CONTROL_XFER_PROC(&sc->sc_bus), &sc->sc_config_msg[0], &sc->sc_config_msg[1]); } diff --git a/sys/dev/usb/controller/xhci.h b/sys/dev/usb/controller/xhci.h index 01e60ee2ef4f..2a08ba720b23 100644 --- a/sys/dev/usb/controller/xhci.h +++ b/sys/dev/usb/controller/xhci.h @@ -434,8 +434,7 @@ struct xhci_softc { struct xhci_hw_softc sc_hw; /* base device */ struct usb_bus sc_bus; - /* configure process */ - struct usb_process sc_config_proc; + /* configure message */ struct usb_bus_msg sc_config_msg[2]; union xhci_hub_desc sc_hub_desc; diff --git a/sys/dev/usb/usb_bus.h b/sys/dev/usb/usb_bus.h index 95c163210948..dea15f8f71a5 100644 --- a/sys/dev/usb/usb_bus.h +++ b/sys/dev/usb/usb_bus.h @@ -54,6 +54,13 @@ struct usb_bus { #if USB_HAVE_ROOT_MOUNT_HOLD struct root_hold_token *bus_roothold; #endif + +#if USB_HAVE_PER_BUS_PROCESS +#define USB_BUS_GIANT_PROC(bus) (&(bus)->giant_callback_proc) +#define USB_BUS_NON_GIANT_PROC(bus) (&(bus)->non_giant_callback_proc) +#define USB_BUS_EXPLORE_PROC(bus) (&(bus)->explore_proc) +#define USB_BUS_CONTROL_XFER_PROC(bus) (&(bus)->control_xfer_proc) + /* * There are two callback processes. One for Giant locked * callbacks. One for non-Giant locked callbacks. This should @@ -67,6 +74,7 @@ struct usb_bus { /* Control request process */ struct usb_process control_xfer_proc; +#endif struct usb_bus_msg explore_msg[2]; struct usb_bus_msg detach_msg[2]; diff --git a/sys/dev/usb/usb_device.c b/sys/dev/usb/usb_device.c index 8d88bf53dfd1..a9aab53e8f35 100644 --- a/sys/dev/usb/usb_device.c +++ b/sys/dev/usb/usb_device.c @@ -2128,7 +2128,7 @@ usb_free_device(struct usb_device *udev, uint8_t flag) * anywhere: */ USB_BUS_LOCK(udev->bus); - usb_proc_mwait(&udev->bus->non_giant_callback_proc, + usb_proc_mwait(USB_BUS_NON_GIANT_PROC(udev->bus), &udev->cs_msg[0], &udev->cs_msg[1]); USB_BUS_UNLOCK(udev->bus); diff --git a/sys/dev/usb/usb_freebsd.h b/sys/dev/usb/usb_freebsd.h index e93bee7692b3..026baabaee2c 100644 --- a/sys/dev/usb/usb_freebsd.h +++ b/sys/dev/usb/usb_freebsd.h @@ -44,6 +44,7 @@ #define USB_HAVE_PF 1 #define USB_HAVE_ROOT_MOUNT_HOLD 1 #define USB_HAVE_ID_SECTION 1 +#define USB_HAVE_PER_BUS_PROCESS 1 #define USB_TD_GET_PROC(td) (td)->td_proc #define USB_PROC_GET_GID(td) (td)->p_pgid diff --git a/sys/dev/usb/usb_freebsd_loader.h b/sys/dev/usb/usb_freebsd_loader.h index 566f9222099b..b21c2291487d 100644 --- a/sys/dev/usb/usb_freebsd_loader.h +++ b/sys/dev/usb/usb_freebsd_loader.h @@ -44,6 +44,7 @@ #define USB_HAVE_PF 0 #define USB_HAVE_ROOT_MOUNT_HOLD 0 #define USB_HAVE_ID_SECTION 0 +#define USB_HAVE_PER_BUS_PROCESS 0 #define USB_TD_GET_PROC(td) (td)->td_proc #define USB_PROC_GET_GID(td) (td)->p_pgid diff --git a/sys/dev/usb/usb_hub.c b/sys/dev/usb/usb_hub.c index 5e372c82e974..1d87a3fae3cb 100644 --- a/sys/dev/usb/usb_hub.c +++ b/sys/dev/usb/usb_hub.c @@ -1917,7 +1917,7 @@ usb_needs_explore(struct usb_bus *bus, uint8_t do_probe) if (do_probe) { bus->do_probe = 1; } - if (usb_proc_msignal(&bus->explore_proc, + if (usb_proc_msignal(USB_BUS_EXPLORE_PROC(bus), &bus->explore_msg[0], &bus->explore_msg[1])) { /* ignore */ } diff --git a/sys/dev/usb/usb_transfer.c b/sys/dev/usb/usb_transfer.c index 397b0b7acc9b..edcc5960cea9 100644 --- a/sys/dev/usb/usb_transfer.c +++ b/sys/dev/usb/usb_transfer.c @@ -965,14 +965,14 @@ usbd_transfer_setup(struct usb_device *udev, * deadlock! */ if (setup_start == usb_control_ep_cfg) - info->done_p = - &udev->bus->control_xfer_proc; + info->done_p = + USB_BUS_CONTROL_XFER_PROC(udev->bus); else if (xfer_mtx == &Giant) - info->done_p = - &udev->bus->giant_callback_proc; + info->done_p = + USB_BUS_GIANT_PROC(udev->bus); else - info->done_p = - &udev->bus->non_giant_callback_proc; + info->done_p = + USB_BUS_NON_GIANT_PROC(udev->bus); } /* reset sizes */ @@ -2614,7 +2614,7 @@ usbd_pipe_start(struct usb_xfer_queue *pq) } else if (udev->ctrl_xfer[1]) { info = udev->ctrl_xfer[1]->xroot; usb_proc_msignal( - &info->bus->non_giant_callback_proc, + USB_BUS_NON_GIANT_PROC(info->bus), &udev->cs_msg[0], &udev->cs_msg[1]); } else { /* should not happen */ @@ -3216,10 +3216,10 @@ usbd_transfer_poll(struct usb_xfer **ppxfer, uint16_t max) } /* Make sure cv_signal() and cv_broadcast() is not called */ - udev->bus->control_xfer_proc.up_msleep = 0; - udev->bus->explore_proc.up_msleep = 0; - udev->bus->giant_callback_proc.up_msleep = 0; - udev->bus->non_giant_callback_proc.up_msleep = 0; + USB_BUS_CONTROL_XFER_PROC(udev->bus)->up_msleep = 0; + USB_BUS_EXPLORE_PROC(udev->bus)->up_msleep = 0; + USB_BUS_GIANT_PROC(udev->bus)->up_msleep = 0; + USB_BUS_NON_GIANT_PROC(udev->bus)->up_msleep = 0; /* poll USB hardware */ (udev->bus->methods->xfer_poll) (udev->bus); From b313f550e1119059ac3b02a0849b10b166b3a3fd Mon Sep 17 00:00:00 2001 From: jhb Date: Tue, 5 Feb 2013 18:55:09 +0000 Subject: [PATCH 18/27] Install and as userland headers in /usr/include. MFC after: 2 weeks --- etc/mtree/BSD.include.dist | 4 ++++ include/Makefile | 25 +++++++++++++++++++++---- usr.sbin/bhyve/Makefile | 2 -- usr.sbin/pciconf/Makefile | 2 -- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/etc/mtree/BSD.include.dist b/etc/mtree/BSD.include.dist index 4a4deee95c8a..374889d56013 100644 --- a/etc/mtree/BSD.include.dist +++ b/etc/mtree/BSD.include.dist @@ -100,6 +100,8 @@ dev acpica .. + agp + .. an .. bktr @@ -136,6 +138,8 @@ .. pbio .. + pci + .. powermac_nvram .. ppbus diff --git a/include/Makefile b/include/Makefile index 33663390900a..1cd70aab8d28 100644 --- a/include/Makefile +++ b/include/Makefile @@ -42,9 +42,10 @@ LDIRS= bsm cam geom net net80211 netatalk netgraph netinet netinet6 \ sys vm LSUBDIRS= cam/ata cam/scsi \ - dev/acpica dev/an dev/bktr dev/ciss dev/filemon dev/firewire dev/hwpmc \ + dev/acpica dev/agp dev/an dev/bktr dev/ciss dev/filemon dev/firewire \ + dev/hwpmc \ dev/ic dev/iicbus ${_dev_ieee488} dev/io dev/lmc dev/mfi dev/nvme \ - dev/ofw dev/pbio ${_dev_powermac_nvram} dev/ppbus dev/smbus \ + dev/ofw dev/pbio dev/pci ${_dev_powermac_nvram} dev/ppbus dev/smbus \ dev/speaker dev/usb dev/utopia dev/vkbd dev/wi \ fs/devfs fs/fdescfs fs/msdosfs fs/nandfs fs/nfs fs/nullfs \ fs/procfs fs/udf fs/unionfs \ @@ -154,7 +155,7 @@ copies: done .endif .endfor -.for i in ${LDIRS} ${LSUBDIRS:Ndev/acpica:Ndev/bktr:Ndev/nand} ${LSUBSUBDIRS} +.for i in ${LDIRS} ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/nand:Ndev/pci} ${LSUBSUBDIRS} cd ${.CURDIR}/../sys; \ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 $i/*.h \ ${DESTDIR}${INCLUDEDIR}/$i @@ -162,6 +163,9 @@ copies: cd ${.CURDIR}/../sys/dev/acpica; \ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 acpiio.h \ ${DESTDIR}${INCLUDEDIR}/dev/acpica + cd ${.CURDIR}/../sys/dev/agp; \ + ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 agpreg.h \ + ${DESTDIR}${INCLUDEDIR}/dev/agp cd ${.CURDIR}/../sys/dev/bktr; \ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ioctl_*.h \ ${DESTDIR}${INCLUDEDIR}/dev/bktr @@ -172,6 +176,9 @@ copies: ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 nand_dev.h \ ${DESTDIR}${INCLUDEDIR}/dev/nand .endif + cd ${.CURDIR}/../sys/dev/pci; \ + ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 pcireg.h \ + ${DESTDIR}${INCLUDEDIR}/dev/pci cd ${.CURDIR}/../sys/contrib/altq/altq; \ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \ ${DESTDIR}${INCLUDEDIR}/altq @@ -225,7 +232,7 @@ symlinks: ln -fs ../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \ done .endfor -.for i in ${LSUBDIRS:Ndev/acpica:Ndev/bktr:Ndev/nand} +.for i in ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/nand:Ndev/pci} cd ${.CURDIR}/../sys/$i; \ for h in *.h; do \ ln -fs ../../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \ @@ -236,6 +243,11 @@ symlinks: ln -fs ../../../../sys/dev/acpica/$$h \ ${DESTDIR}${INCLUDEDIR}/dev/acpica; \ done + cd ${.CURDIR}/../sys/dev/agp; \ + for h in agpreg.h; do \ + ln -fs ../../../../sys/dev/agp/$$h \ + ${DESTDIR}${INCLUDEDIR}/dev/agp; \ + done cd ${.CURDIR}/../sys/dev/bktr; \ for h in ioctl_*.h; do \ ln -fs ../../../../sys/dev/bktr/$$h \ @@ -248,6 +260,11 @@ symlinks: ${DESTDIR}${INCLUDEDIR}/dev/nand; \ done .endif + cd ${.CURDIR}/../sys/dev/pci; \ + for h in pcireg.h; do \ + ln -fs ../../../../sys/dev/pci/$$h \ + ${DESTDIR}${INCLUDEDIR}/dev/pci; \ + done .for i in ${LSUBSUBDIRS} cd ${.CURDIR}/../sys/$i; \ for h in *.h; do \ diff --git a/usr.sbin/bhyve/Makefile b/usr.sbin/bhyve/Makefile index 078ef9a885dc..ef3907972775 100644 --- a/usr.sbin/bhyve/Makefile +++ b/usr.sbin/bhyve/Makefile @@ -22,6 +22,4 @@ LDADD= -lvmmapi -lmd -lpthread WARNS?= 2 -CFLAGS+= -I${.CURDIR}/../../sys - .include diff --git a/usr.sbin/pciconf/Makefile b/usr.sbin/pciconf/Makefile index 32e984871166..a83973354523 100644 --- a/usr.sbin/pciconf/Makefile +++ b/usr.sbin/pciconf/Makefile @@ -5,8 +5,6 @@ PROG= pciconf SRCS= pciconf.c cap.c err.c MAN= pciconf.8 -CFLAGS+= -I${.CURDIR}/../../sys - WARNS?= 3 .include From 18658720df177c8047dfc7d4f19be4eb9553b0c1 Mon Sep 17 00:00:00 2001 From: andrew Date: Tue, 5 Feb 2013 20:03:58 +0000 Subject: [PATCH 19/27] * Add the integer div & mod functions and ARM EABI support functions to libstand. * Stop linking the ARM U-Boot loader against libgcc now libstand has the required symbols. --- lib/libstand/Makefile | 13 +++++++++++++ sys/boot/arm/uboot/Makefile | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/libstand/Makefile b/lib/libstand/Makefile index fd720a9e4a86..807136d116dc 100644 --- a/lib/libstand/Makefile +++ b/lib/libstand/Makefile @@ -61,7 +61,20 @@ SRCS+= bcmp.c bcopy.c bzero.c ffs.c memccpy.c memchr.c memcmp.c memcpy.c \ .endif .if ${MACHINE_CPUARCH} == "arm" .PATH: ${.CURDIR}/../libc/arm/gen + +.if ${MK_ARM_EABI} == "no" SRCS+= divsi3.S +.else +# Compiler support functions +.PATH: ${.CURDIR}/../../contrib/compiler-rt/lib/ +SRCS+= divmoddi4.c divmodsi4.c divdi3.c divsi3.c moddi3.c modsi3.c +SRCS+= udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c + +.PATH: ${.CURDIR}/../../contrib/compiler-rt/lib/arm/ +SRCS+= aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S +SRCS+= aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S +.endif + .endif .if ${MACHINE_CPUARCH} == "ia64" .PATH: ${.CURDIR}/../libc/ia64/string diff --git a/sys/boot/arm/uboot/Makefile b/sys/boot/arm/uboot/Makefile index c3c4bd8c1f6d..197421893fa7 100644 --- a/sys/boot/arm/uboot/Makefile +++ b/sys/boot/arm/uboot/Makefile @@ -112,8 +112,8 @@ CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ # clang doesn't understand %D as a specifier to printf NO_WERROR.clang= -DPADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} ${LIBSTAND} ${LIBGCC} -LDADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} -lstand -lgcc +DPADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} ${LIBSTAND} +LDADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} -lstand vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} From eb7eb10dd6630a3383acfc5c3f3043d482df57cd Mon Sep 17 00:00:00 2001 From: pluknet Date: Tue, 5 Feb 2013 20:08:33 +0000 Subject: [PATCH 20/27] Remove reference to the rlist code from comments, and fix a typo visible in the resulted change. Reviewed by: kib MFC after: 1 week --- sys/kern/subr_blist.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/sys/kern/subr_blist.c b/sys/kern/subr_blist.c index 788b5eb035d0..5c45b8197ee4 100644 --- a/sys/kern/subr_blist.c +++ b/sys/kern/subr_blist.c @@ -52,14 +52,10 @@ * radix tree should be able to operate well no matter how much * fragmentation there is and no matter how large a bitmap is used. * - * Unlike the rlist code, the blist code wires all necessary memory at - * creation time. Neither allocations nor frees require interaction with - * the memory subsystem. In contrast, the rlist code may allocate memory - * on an rlist_free() call. The non-blocking features of the blist code - * are used to great advantage in the swap code (vm/nswap_pager.c). The - * rlist code uses a little less overall memory than the blist code (but - * due to swap interleaving not all that much less), but the blist code - * scales much, much better. + * The blist code wires all necessary memory at creation time. Neither + * allocations nor frees require interaction with the memory subsystem. + * The non-blocking features of the blist code are used in the swap code + * (vm/swap_pager.c). * * LAYOUT: The radix tree is layed out recursively using a * linear array. Each meta node is immediately followed (layed out From f923241b9373157c315e6049fda6f55ede7fdaad Mon Sep 17 00:00:00 2001 From: jilles Date: Tue, 5 Feb 2013 22:54:09 +0000 Subject: [PATCH 21/27] sh: Do not test for digit_contig in mksyntax. ISO/IEC 9899:1999 (E) 5.2.1p3 guarantees that the values of the characters 0123456789 are contiguous. The generated syntax.c and syntax.h remain the same. Submitted by: Christoph Mallon --- bin/sh/mksyntax.c | 48 ++--------------------------------------------- 1 file changed, 2 insertions(+), 46 deletions(-) diff --git a/bin/sh/mksyntax.c b/bin/sh/mksyntax.c index 2b8ecdb3aa0f..6594da3a1bd7 100644 --- a/bin/sh/mksyntax.c +++ b/bin/sh/mksyntax.c @@ -107,14 +107,12 @@ static const char *syntax[513]; static int base; static int size; /* number of values which a char variable can have */ static int nbits; /* number of bits in a character */ -static int digit_contig;/* true if digits are contiguous */ static void filltable(const char *); static void init(void); static void add(const char *, const char *); static void print(const char *); static void output_type_macros(void); -static void digit_convert(void); int main(int argc __unused, char **argv __unused) @@ -125,7 +123,6 @@ main(int argc __unused, char **argv __unused) int i; char buf[80]; int pos; - static char digit[] = "0123456789"; /* Create output files */ if ((cfile = fopen("syntax.c", "w")) == NULL) { @@ -158,11 +155,6 @@ main(int argc __unused, char **argv __unused) base = 1; if (sign) base += 1 << (nbits - 1); - digit_contig = 1; - for (i = 0 ; i < 10 ; i++) { - if (digit[i] != '0' + i) - digit_contig = 0; - } fputs("#include \n", hfile); @@ -248,8 +240,6 @@ main(int argc __unused, char **argv __unused) add("_", "ISUNDER"); add("#?$!-*@", "ISSPECL"); print("is_type"); - if (! digit_contig) - digit_convert(); exit(0); } @@ -341,12 +331,13 @@ print(const char *name) */ static const char *macro[] = { - "#define is_digit(c)\t((is_type+SYNBASE)[(int)c] & ISDIGIT)", + "#define is_digit(c)\t((unsigned int)((c) - '0') <= 9)", "#define is_eof(c)\t((c) == PEOF)", "#define is_alpha(c)\t((is_type+SYNBASE)[(int)c] & (ISUPPER|ISLOWER))", "#define is_name(c)\t((is_type+SYNBASE)[(int)c] & (ISUPPER|ISLOWER|ISUNDER))", "#define is_in_name(c)\t((is_type+SYNBASE)[(int)c] & (ISUPPER|ISLOWER|ISUNDER|ISDIGIT))", "#define is_special(c)\t((is_type+SYNBASE)[(int)c] & (ISSPECL|ISDIGIT))", + "#define digit_val(c)\t((c) - '0')", NULL }; @@ -355,41 +346,6 @@ output_type_macros(void) { const char **pp; - if (digit_contig) - macro[0] = "#define is_digit(c)\t((unsigned int)((c) - '0') <= 9)"; for (pp = macro ; *pp ; pp++) fprintf(hfile, "%s\n", *pp); - if (digit_contig) - fputs("#define digit_val(c)\t((c) - '0')\n", hfile); - else - fputs("#define digit_val(c)\t(digit_value[c])\n", hfile); -} - - - -/* - * Output digit conversion table (if digits are not contiguous). - */ - -static void -digit_convert(void) -{ - int maxdigit; - static char digit[] = "0123456789"; - char *p; - int i; - - maxdigit = 0; - for (p = digit ; *p ; p++) - if (*p > maxdigit) - maxdigit = *p; - fputs("extern const char digit_value[];\n", hfile); - fputs("\n\nconst char digit_value[] = {\n", cfile); - for (i = 0 ; i <= maxdigit ; i++) { - for (p = digit ; *p && *p != i ; p++); - if (*p == '\0') - p = digit; - fprintf(cfile, " %d,\n", (int)(p - digit)); - } - fputs("};\n", cfile); } From 34f6d259a30c45a17229a6742c75eaf1a57452f6 Mon Sep 17 00:00:00 2001 From: andrew Date: Wed, 6 Feb 2013 00:01:28 +0000 Subject: [PATCH 22/27] Add the __aeabi_mem* functions to compiler-rt as clang uses them. --- lib/libcompiler_rt/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/libcompiler_rt/Makefile b/lib/libcompiler_rt/Makefile index 26ce4f7aaa3a..a9daada4742f 100644 --- a/lib/libcompiler_rt/Makefile +++ b/lib/libcompiler_rt/Makefile @@ -188,6 +188,10 @@ SRCS+= ${file}.c .if ${MACHINE_CPUARCH} == "arm" && ${MK_ARM_EABI} != "no" SRCS+= aeabi_idivmod.S \ aeabi_ldivmod.S \ + aeabi_memcmp.S \ + aeabi_memcpy.S \ + aeabi_memmove.S \ + aeabi_memset.S \ aeabi_uidivmod.S \ aeabi_uldivmod.S .endif From e1ce6ad8dd8348d781f3da2548bc66a336e4a5fc Mon Sep 17 00:00:00 2001 From: ganbold Date: Wed, 6 Feb 2013 01:03:13 +0000 Subject: [PATCH 23/27] Use and set gpio pin to high to power up usb. Approved by: gonzo@ --- sys/arm/allwinner/a10_ehci.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/sys/arm/allwinner/a10_ehci.c b/sys/arm/allwinner/a10_ehci.c index d3a90d0f5788..0d1636b7bfa9 100644 --- a/sys/arm/allwinner/a10_ehci.c +++ b/sys/arm/allwinner/a10_ehci.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -58,6 +59,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include "gpio_if.h" + #include "a10_clk.h" #define EHCI_HC_DEVSTR "Allwinner Integrated USB 2.0 controller" @@ -70,8 +73,9 @@ __FBSDID("$FreeBSD$"); #define SW_ULPI_BYPASS (1 << 0) #define SW_AHB_INCRX_ALIGN (1 << 8) -#define SW_AHB_INCR4 (1 << 9) +#define SW_AHB_INCR4 (1 << 9) #define SW_AHB_INCR8 (1 << 10) +#define GPIO_USB2_PWR 227 #define A10_READ_4(sc, reg) \ bus_space_read_4((sc)->sc_io_tag, (sc)->sc_io_hdl, reg) @@ -101,6 +105,7 @@ a10_ehci_attach(device_t self) { ehci_softc_t *sc = device_get_softc(self); bus_space_handle_t bsh; + device_t sc_gpio_dev; int err; int rid; uint32_t reg_value = 0; @@ -153,6 +158,13 @@ a10_ehci_attach(device_t self) sprintf(sc->sc_vendor, "Allwinner"); + /* Get the GPIO device, we need this to give power to USB */ + sc_gpio_dev = devclass_get_device(devclass_find("gpio"), 0); + if (sc_gpio_dev == NULL) { + device_printf(self, "Error: failed to get the GPIO device\n"); + goto error; + } + err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, NULL, (driver_intr_t *)ehci_interrupt, sc, &sc->sc_intr_hdl); if (err) { @@ -166,6 +178,10 @@ a10_ehci_attach(device_t self) /* Enable clock for USB */ a10_clk_usb_activate(); + /* Give power to USB */ + GPIO_PIN_SETFLAGS(sc_gpio_dev, GPIO_USB2_PWR, GPIO_PIN_OUTPUT); + GPIO_PIN_SET(sc_gpio_dev, GPIO_USB2_PWR, GPIO_PIN_HIGH); + /* Enable passby */ reg_value = A10_READ_4(sc, SW_USB_PMU_IRQ_ENABLE); reg_value |= SW_AHB_INCR8; /* AHB INCR8 enable */ From c25d6690790d84356e2a43d03341e6787d16d2d6 Mon Sep 17 00:00:00 2001 From: neel Date: Wed, 6 Feb 2013 04:53:00 +0000 Subject: [PATCH 24/27] Compute the number of initial kernel page table pages (NKPT) dynamically. This eliminates the need to recompile the kernel when the default value of NKPT is not big enough - for e.g. when loading large kernel modules or memory disk images from the loader. If NKPT is defined in the kernel configuration file then it overrides the dynamic calculation. Reviewed by: alc, kib --- sys/amd64/amd64/minidump_machdep.c | 4 +- sys/amd64/amd64/pmap.c | 67 +++++++++++++++++++++++++----- sys/amd64/include/pmap.h | 7 +--- 3 files changed, 59 insertions(+), 19 deletions(-) diff --git a/sys/amd64/amd64/minidump_machdep.c b/sys/amd64/amd64/minidump_machdep.c index c1b03c1f5c96..79d8bde31266 100644 --- a/sys/amd64/amd64/minidump_machdep.c +++ b/sys/amd64/amd64/minidump_machdep.c @@ -232,7 +232,7 @@ minidumpsys(struct dumperinfo *di) /* Walk page table pages, set bits in vm_page_dump */ pmapsize = 0; pdp = (uint64_t *)PHYS_TO_DMAP(KPDPphys); - for (va = VM_MIN_KERNEL_ADDRESS; va < MAX(KERNBASE + NKPT * NBPDR, + for (va = VM_MIN_KERNEL_ADDRESS; va < MAX(KERNBASE + nkpt * NBPDR, kernel_vm_end); ) { /* * We always write a page, even if it is zero. Each @@ -364,7 +364,7 @@ minidumpsys(struct dumperinfo *di) /* Dump kernel page directory pages */ bzero(fakepd, sizeof(fakepd)); pdp = (uint64_t *)PHYS_TO_DMAP(KPDPphys); - for (va = VM_MIN_KERNEL_ADDRESS; va < MAX(KERNBASE + NKPT * NBPDR, + for (va = VM_MIN_KERNEL_ADDRESS; va < MAX(KERNBASE + nkpt * NBPDR, kernel_vm_end); va += NBPDP) { i = (va >> PDPSHIFT) & ((1ul << NPDPEPGSHIFT) - 1); diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index f73e9562b7df..c2debf7117eb 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -202,6 +202,10 @@ struct pmap kernel_pmap_store; vm_offset_t virtual_avail; /* VA of first avail page (after kernel bss) */ vm_offset_t virtual_end; /* VA of last avail page (end of kernel AS) */ +int nkpt; +SYSCTL_INT(_machdep, OID_AUTO, nkpt, CTLFLAG_RD, &nkpt, 0, + "Number of kernel page table pages allocated on bootup"); + static int ndmpdp; static vm_paddr_t dmaplimit; vm_offset_t kernel_vm_end = VM_MIN_KERNEL_ADDRESS; @@ -495,17 +499,42 @@ allocpages(vm_paddr_t *firstaddr, int n) CTASSERT(powerof2(NDMPML4E)); +/* number of kernel PDP slots */ +#define NKPDPE(ptpgs) howmany((ptpgs), NPDEPG) + +static void +nkpt_init(vm_paddr_t addr) +{ + int pt_pages; + +#ifdef NKPT + pt_pages = NKPT; +#else + pt_pages = howmany(addr, 1 << PDRSHIFT); + pt_pages += NKPDPE(pt_pages); + + /* + * Add some slop beyond the bare minimum required for bootstrapping + * the kernel. + * + * This is quite important when allocating KVA for kernel modules. + * The modules are required to be linked in the negative 2GB of + * the address space. If we run out of KVA in this region then + * pmap_growkernel() will need to allocate page table pages to map + * the entire 512GB of KVA space which is an unnecessary tax on + * physical memory. + */ + pt_pages += 8; /* 16MB additional slop for kernel modules */ +#endif + nkpt = pt_pages; +} + static void create_pagetables(vm_paddr_t *firstaddr) { - int i, j, ndm1g; - - /* Allocate pages */ - KPTphys = allocpages(firstaddr, NKPT); - KPML4phys = allocpages(firstaddr, 1); - KPDPphys = allocpages(firstaddr, NKPML4E); - KPDphys = allocpages(firstaddr, NKPDPE); + int i, j, ndm1g, nkpdpe; + /* Allocate page table pages for the direct map */ ndmpdp = (ptoa(Maxmem) + NBPDP - 1) >> PDPSHIFT; if (ndmpdp < 4) /* Minimum 4GB of dirmap */ ndmpdp = 4; @@ -517,6 +546,22 @@ create_pagetables(vm_paddr_t *firstaddr) DMPDphys = allocpages(firstaddr, ndmpdp - ndm1g); dmaplimit = (vm_paddr_t)ndmpdp << PDPSHIFT; + /* Allocate pages */ + KPML4phys = allocpages(firstaddr, 1); + KPDPphys = allocpages(firstaddr, NKPML4E); + + /* + * Allocate the initial number of kernel page table pages required to + * bootstrap. We defer this until after all memory-size dependent + * allocations are done (e.g. direct map), so that we don't have to + * build in too much slop in our estimate. + */ + nkpt_init(*firstaddr); + nkpdpe = NKPDPE(nkpt); + + KPTphys = allocpages(firstaddr, nkpt); + KPDphys = allocpages(firstaddr, nkpdpe); + /* Fill in the underlying page table pages */ /* Read-only from zero to physfree */ /* XXX not fully used, underneath 2M pages */ @@ -526,7 +571,7 @@ create_pagetables(vm_paddr_t *firstaddr) } /* Now map the page tables at their location within PTmap */ - for (i = 0; i < NKPT; i++) { + for (i = 0; i < nkpt; i++) { ((pd_entry_t *)KPDphys)[i] = KPTphys + (i << PAGE_SHIFT); ((pd_entry_t *)KPDphys)[i] |= PG_RW | PG_V; } @@ -539,7 +584,7 @@ create_pagetables(vm_paddr_t *firstaddr) } /* And connect up the PD to the PDP */ - for (i = 0; i < NKPDPE; i++) { + for (i = 0; i < nkpdpe; i++) { ((pdp_entry_t *)KPDPphys)[i + KPDPI] = KPDphys + (i << PAGE_SHIFT); ((pdp_entry_t *)KPDPphys)[i + KPDPI] |= PG_RW | PG_V | PG_U; @@ -768,7 +813,7 @@ pmap_init(void) * Initialize the vm page array entries for the kernel pmap's * page table pages. */ - for (i = 0; i < NKPT; i++) { + for (i = 0; i < nkpt; i++) { mpte = PHYS_TO_VM_PAGE(KPTphys + (i << PAGE_SHIFT)); KASSERT(mpte >= vm_page_array && mpte < &vm_page_array[vm_page_array_size], @@ -1995,7 +2040,7 @@ pmap_growkernel(vm_offset_t addr) * any new kernel page table pages between "kernel_vm_end" and * "KERNBASE". */ - if (KERNBASE < addr && addr <= KERNBASE + NKPT * NBPDR) + if (KERNBASE < addr && addr <= KERNBASE + nkpt * NBPDR) return; addr = roundup2(addr, NBPDR); diff --git a/sys/amd64/include/pmap.h b/sys/amd64/include/pmap.h index 71045ae88224..334d6c68ca1d 100644 --- a/sys/amd64/include/pmap.h +++ b/sys/amd64/include/pmap.h @@ -113,13 +113,7 @@ ((unsigned long)(l2) << PDRSHIFT) | \ ((unsigned long)(l1) << PAGE_SHIFT)) -/* Initial number of kernel page tables. */ -#ifndef NKPT -#define NKPT 32 -#endif - #define NKPML4E 1 /* number of kernel PML4 slots */ -#define NKPDPE howmany(NKPT, NPDEPG)/* number of kernel PDP slots */ #define NUPML4E (NPML4EPG/2) /* number of userland PML4 pages */ #define NUPDPE (NUPML4E*NPDPEPG)/* number of userland PDP pages */ @@ -181,6 +175,7 @@ typedef u_int64_t pml4_entry_t; #define PML4map ((pd_entry_t *)(addr_PML4map)) #define PML4pml4e ((pd_entry_t *)(addr_PML4pml4e)) +extern int nkpt; /* Initial number of kernel page tables */ extern u_int64_t KPDPphys; /* physical address of kernel level 3 */ extern u_int64_t KPML4phys; /* physical address of kernel level 4 */ From 73c1717b7e07dec67ad73cdee5c43064533a7e8b Mon Sep 17 00:00:00 2001 From: np Date: Wed, 6 Feb 2013 06:44:42 +0000 Subject: [PATCH 25/27] Busy-wait when cold. Reported by: gnn, jhb MFC after: 3 days --- sys/dev/cxgbe/common/t4_hw.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/dev/cxgbe/common/t4_hw.c b/sys/dev/cxgbe/common/t4_hw.c index 902a4e85c6be..099f5a9005fb 100644 --- a/sys/dev/cxgbe/common/t4_hw.c +++ b/sys/dev/cxgbe/common/t4_hw.c @@ -35,7 +35,12 @@ __FBSDID("$FreeBSD$"); #include "firmware/t4fw_interface.h" #undef msleep -#define msleep(x) pause("t4hw", (x) * hz / 1000) +#define msleep(x) do { \ + if (cold) \ + DELAY((x) * 1000); \ + else \ + pause("t4hw", (x) * hz / 1000); \ +} while (0) /** * t4_wait_op_done_val - wait until an operation is completed From 40a2400cbed1f40f70252328eeb5d4001f0a6fbb Mon Sep 17 00:00:00 2001 From: glebius Date: Wed, 6 Feb 2013 07:27:25 +0000 Subject: [PATCH 26/27] Fixes to QUEUE_MACRO_DEBUG support: - Add const quilifiers to fields that store value of __FILE__. - Use long type for fields that store value of __LINE__. - Sort and style(9) debugging fields. - Add initializer for debugging fields into TAILQ_INITIALIZER macro. PR: 175759 Submitted by: Andrey Simonenko Reviewed by: bde --- sys/sys/queue.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sys/sys/queue.h b/sys/sys/queue.h index e65b1ce20404..368d69e2c67d 100644 --- a/sys/sys/queue.h +++ b/sys/sys/queue.h @@ -105,13 +105,14 @@ #ifdef QUEUE_MACRO_DEBUG /* Store the last 2 places the queue element or head was altered */ struct qm_trace { - char * lastfile; - int lastline; - char * prevfile; - int prevline; + unsigned long lastline; + unsigned long prevline; + const char *lastfile; + const char *prevfile; }; #define TRACEBUF struct qm_trace trace; +#define TRACEBUF_INITIALIZER { __FILE__, __LINE__, NULL, 0 } , #define TRASHIT(x) do {(x) = (void *)-1;} while (0) #define QMD_SAVELINK(name, link) void **name = (void *)&(link) @@ -134,6 +135,7 @@ struct qm_trace { #define QMD_TRACE_HEAD(head) #define QMD_SAVELINK(name, link) #define TRACEBUF +#define TRACEBUF_INITIALIZER #define TRASHIT(x) #endif /* QUEUE_MACRO_DEBUG */ @@ -461,7 +463,7 @@ struct name { \ } #define TAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).tqh_first } + { NULL, &(head).tqh_first, TRACEBUF_INITIALIZER } #define TAILQ_ENTRY(type) \ struct { \ From 7280eb0924ffd1922c50d6f2fafbd523b47c9210 Mon Sep 17 00:00:00 2001 From: hselasky Date: Wed, 6 Feb 2013 11:16:18 +0000 Subject: [PATCH 27/27] Make sure that all mouse buttons are released when clients using /dev/consolectl close. This fixes a problem where if a USB mouse is detached while a button is pressed, that button is never released. MFC after: 1 week --- sys/dev/syscons/syscons.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index beb0c67e2216..8094ea313be0 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -253,11 +253,13 @@ static struct ttydevsw sc_ttydevsw = { }; static d_ioctl_t consolectl_ioctl; +static d_close_t consolectl_close; static struct cdevsw consolectl_devsw = { .d_version = D_VERSION, - .d_flags = D_NEEDGIANT, + .d_flags = D_NEEDGIANT | D_TRACKCLOSE, .d_ioctl = consolectl_ioctl, + .d_close = consolectl_close, .d_name = "consolectl", }; @@ -1561,6 +1563,23 @@ consolectl_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, return sctty_ioctl(dev->si_drv1, cmd, data, td); } +static int +consolectl_close(struct cdev *dev, int flags, int mode, struct thread *td) +{ +#ifndef SC_NO_SYSMOUSE + mouse_info_t info; + memset(&info, 0, sizeof(info)); + info.operation = MOUSE_ACTION; + + /* + * Make sure all buttons are released when moused and other + * console daemons exit, so that no buttons are left pressed. + */ + (void) sctty_ioctl(dev->si_drv1, CONS_MOUSECTL, (caddr_t)&info, td); +#endif + return (0); +} + static void sc_cnprobe(struct consdev *cp) {