svn commit: r295877 - head/sys/dev/hyperv/netvsc

2016-02-21 Thread Sepherosa Ziehau
Author: sephe
Date: Mon Feb 22 06:28:18 2016
New Revision: 295877
URL: https://svnweb.freebsd.org/changeset/base/295877

Log:
  hyperv/hn: Add TX method for txeof processing.
  
  Preamble to implement ifnet.if_transmit method.
  
  Reviewed by:  adrian
  Approved by:  adrian (mentor)
  MFC after:1 week
  Sponsored by: Microsoft OSTC
  Differential Revision:https://reviews.freebsd.org/D5346

Modified:
  head/sys/dev/hyperv/netvsc/hv_net_vsc.h
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h
==
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Feb 22 06:22:47 2016
(r295876)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Feb 22 06:28:18 2016
(r295877)
@@ -1026,9 +1026,10 @@ struct hn_tx_ring {
 #endif
int hn_txdesc_cnt;
int hn_txdesc_avail;
-   int hn_txeof;
+   int hn_has_txeof;
 
int hn_sched_tx;
+   void(*hn_txeof)(struct hn_tx_ring *);
struct taskqueue *hn_tx_taskq;
struct task hn_tx_task;
struct task hn_txeof_task;

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Mon Feb 22 06:22:47 
2016(r295876)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Mon Feb 22 06:28:18 
2016(r295877)
@@ -664,7 +664,7 @@ hn_tx_done(void *xpkt)
packet->compl.send.send_completion_tid;
 
txr = txd->txr;
-   txr->hn_txeof = 1;
+   txr->hn_has_txeof = 1;
hn_txdesc_put(txr, txd);
 }
 
@@ -684,11 +684,11 @@ netvsc_channel_rollup(struct hv_device *
}
 #endif
 
-   if (!txr->hn_txeof)
+   if (!txr->hn_has_txeof)
return;
 
-   txr->hn_txeof = 0;
-   hn_start_txeof(txr);
+   txr->hn_has_txeof = 0;
+   txr->hn_txeof(txr);
 }
 
 /*
@@ -976,12 +976,12 @@ again:
 * commands to run?  Ask netvsc_channel_rollup()
 * to kick start later.
 */
-   txr->hn_txeof = 1;
+   txr->hn_has_txeof = 1;
if (!send_failed) {
txr->hn_send_failed++;
send_failed = 1;
/*
-* Try sending again after set hn_txeof;
+* Try sending again after set hn_has_txeof;
 * in case that we missed the last
 * netvsc_channel_rollup().
 */
@@ -2111,6 +2111,8 @@ hn_create_tx_ring(struct hn_softc *sc, i
 */
txr->hn_sched_tx = 1;
 
+   txr->hn_txeof = hn_start_txeof; /* TODO: if_transmit */
+
parent_dtag = bus_get_dma_tag(sc->hn_dev);
 
/* DMA tag for RNDIS messages. */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r295854 - head/bin/dd

2016-02-21 Thread Bruce Evans

On Sun, 21 Feb 2016, Edward Tomasz Napierala wrote:


Log:
 Make the "invalid numeric value" error message actually displayable
 (was a dead code before).

 Submitted by:  bde@ (earlier version)
 Reviewed by:   bde@


Thanks.


Modified:
 head/bin/dd/args.c

Modified: head/bin/dd/args.c
==
--- head/bin/dd/args.c  Sun Feb 21 13:54:22 2016(r295853)
+++ head/bin/dd/args.c  Sun Feb 21 14:36:50 2016(r295854)
@@ -422,11 +422,10 @@ get_num(const char *val)

errno = 0;
num = strtoumax(val, , 0);
-   if (errno != 0) /* Overflow or underflow. */
-   err(1, "%s", oper);
-
if (expr == val)/* No valid digits. */
-   errx(1, "%s: illegal numeric value", oper);
+   errx(1, "%s: invalid numeric value", oper);
+   if (errno != 0)
+   err(1, "%s", oper);

mult = postfix_to_mult(*expr);

...


This is to avoid the POSIX bug that the strto*() family "helpfully" sets
errno for cases not specified by C90, C99 or C11.  POSIX requires setting
errno to EINVAL if the base is unsupported or no conversion could be
performed.  The FreeBSD man page says that the conversion error is
unportable.  The base error is equally unportable, but the man page doesn't
mention it.  This breaks code like the above which depends on the Standard
C bhaviour of only setting errno to ERANGE.  The code happens to do a
generic check on errno first, and that prevents the more specific handling
for a conversion error from being reached.

Standard C in general allows errno to be clobbered on success, but for
functions that are documented to set errno like the strto*() family, it
intends to require only the documented settings.  The above code is an
example showing that settings to non-Standard C values are little different
from gratuitous clobbering.

Bruce
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r295876 - head/sys/dev/hyperv/netvsc

2016-02-21 Thread Sepherosa Ziehau
Author: sephe
Date: Mon Feb 22 06:22:47 2016
New Revision: 295876
URL: https://svnweb.freebsd.org/changeset/base/295876

Log:
  hyperv/hn: Staticize and rename packet TX done function
  
  It is only used in hv_netvsc_drv_freebsd.c; and rename it to hn_tx_done()
  mainly to reserve "xmit" for ifnet.if_transmit implement.
  
  While I'm here, remove unapplied comment.
  
  Reviewed by:  adrian
  Approved by:  adrian (mentor)
  MFC after:1 week
  Sponsored by: Microsoft OSTC
  Differential Revision:https://reviews.freebsd.org/D5345

Modified:
  head/sys/dev/hyperv/netvsc/hv_net_vsc.h
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h
==
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Feb 22 06:17:26 2016
(r295875)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Feb 22 06:22:47 2016
(r295876)
@@ -1086,7 +1086,6 @@ typedef struct hn_softc {
 extern int hv_promisc_mode;
 
 void netvsc_linkstatus_callback(struct hv_device *device_obj, uint32_t status);
-void netvsc_xmit_completion(void *context);
 void hv_nv_on_receive_completion(struct hv_device *device,
 uint64_t tid, uint32_t status);
 netvsc_dev *hv_nv_on_device_add(struct hv_device *device,

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Mon Feb 22 06:17:26 
2016(r295875)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Mon Feb 22 06:22:47 
2016(r295876)
@@ -653,17 +653,10 @@ hn_txdesc_hold(struct hn_txdesc *txd)
atomic_add_int(>refs, 1);
 }
 
-/*
- * Send completion processing
- *
- * Note:  It looks like offset 0 of buf is reserved to hold the softc
- * pointer.  The sc pointer is not currently needed in this function, and
- * it is not presently populated by the TX function.
- */
-void
-netvsc_xmit_completion(void *context)
+static void
+hn_tx_done(void *xpkt)
 {
-   netvsc_packet *packet = context;
+   netvsc_packet *packet = xpkt;
struct hn_txdesc *txd;
struct hn_tx_ring *txr;
 
@@ -905,7 +898,7 @@ done:
txd->m = m_head;
 
/* Set the completion routine */
-   packet->compl.send.on_send_completion = netvsc_xmit_completion;
+   packet->compl.send.on_send_completion = hn_tx_done;
packet->compl.send.send_completion_context = packet;
packet->compl.send.send_completion_tid = (uint64_t)(uintptr_t)txd;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r295875 - head/sys/dev/hyperv/netvsc

2016-02-21 Thread Sepherosa Ziehau
Author: sephe
Date: Mon Feb 22 06:17:26 2016
New Revision: 295875
URL: https://svnweb.freebsd.org/changeset/base/295875

Log:
  hyperv/hn: Rename TX related function and struct fields a bit
  
  Preamble to implement the ifnet.if_transmit method.
  
  Reviewed by:  adrian
  Approved by:  adrian (mentor)
  MFC after:1 week
  Sponsored by: Microsoft OSTC
  Differential Revision:https://reviews.freebsd.org/D5344

Modified:
  head/sys/dev/hyperv/netvsc/hv_net_vsc.h
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h
==
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Feb 22 01:15:02 2016
(r295874)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Feb 22 06:17:26 2016
(r295875)
@@ -1030,7 +1030,7 @@ struct hn_tx_ring {
 
int hn_sched_tx;
struct taskqueue *hn_tx_taskq;
-   struct task hn_start_task;
+   struct task hn_tx_task;
struct task hn_txeof_task;
 
struct mtx  hn_tx_lock;

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Mon Feb 22 01:15:02 
2016(r295874)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Mon Feb 22 06:17:26 
2016(r295875)
@@ -298,8 +298,8 @@ static int hn_create_tx_ring(struct hn_s
 static void hn_destroy_tx_ring(struct hn_tx_ring *);
 static int hn_create_tx_data(struct hn_softc *);
 static void hn_destroy_tx_data(struct hn_softc *);
-static void hn_start_taskfunc(void *xsc, int pending);
-static void hn_txeof_taskfunc(void *xsc, int pending);
+static void hn_start_taskfunc(void *, int);
+static void hn_start_txeof_taskfunc(void *, int);
 static void hn_stop_tx_tasks(struct hn_softc *);
 static int hn_encap(struct hn_tx_ring *, struct hn_txdesc *, struct mbuf **);
 static void hn_create_rx_data(struct hn_softc *sc);
@@ -1555,7 +1555,7 @@ hn_start(struct ifnet *ifp)
return;
}
 do_sched:
-   taskqueue_enqueue(txr->hn_tx_taskq, >hn_start_task);
+   taskqueue_enqueue(txr->hn_tx_taskq, >hn_tx_task);
 }
 
 static void
@@ -1577,7 +1577,7 @@ hn_start_txeof(struct hn_tx_ring *txr)
mtx_unlock(>hn_tx_lock);
if (sched) {
taskqueue_enqueue(txr->hn_tx_taskq,
-   >hn_start_task);
+   >hn_tx_task);
}
} else {
 do_sched:
@@ -2103,8 +2103,8 @@ hn_create_tx_ring(struct hn_softc *sc, i
 #endif
 
txr->hn_tx_taskq = sc->hn_tx_taskq;
-   TASK_INIT(>hn_start_task, 0, hn_start_taskfunc, txr);
-   TASK_INIT(>hn_txeof_task, 0, hn_txeof_taskfunc, txr);
+   TASK_INIT(>hn_tx_task, 0, hn_start_taskfunc, txr);
+   TASK_INIT(>hn_txeof_task, 0, hn_start_txeof_taskfunc, txr);
 
txr->hn_direct_tx_size = hn_direct_tx_size;
if (hv_vmbus_protocal_version >= HV_VMBUS_VERSION_WIN8_1)
@@ -2399,7 +2399,7 @@ hn_start_taskfunc(void *xtxr, int pendin
 }
 
 static void
-hn_txeof_taskfunc(void *xtxr, int pending __unused)
+hn_start_txeof_taskfunc(void *xtxr, int pending __unused)
 {
struct hn_tx_ring *txr = xtxr;
 
@@ -2417,7 +2417,7 @@ hn_stop_tx_tasks(struct hn_softc *sc)
for (i = 0; i < sc->hn_tx_ring_cnt; ++i) {
struct hn_tx_ring *txr = >hn_tx_ring[i];
 
-   taskqueue_drain(txr->hn_tx_taskq, >hn_start_task);
+   taskqueue_drain(txr->hn_tx_taskq, >hn_tx_task);
taskqueue_drain(txr->hn_tx_taskq, >hn_txeof_task);
}
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r295864 - head/sys/kern

2016-02-21 Thread Bruce Evans

On Sun, 21 Feb 2016, Ian Lepore wrote:


Log:
 Allow a dynamic env to override a compiled-in static env by passing in the
 override indication in the env data.

 Submitted by:  bde


Thanks.

Bruce
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r295874 - head/sys/dev/usb/wlan

2016-02-21 Thread Andriy Voskoboinyk
Author: avos
Date: Mon Feb 22 01:15:02 2016
New Revision: 295874
URL: https://svnweb.freebsd.org/changeset/base/295874

Log:
  urtwn: shutdown the device properly
  
  - R92C path: NetBSD (mostly)
  - R88E path: TP-Link driver
  
  Tested with RTL8188EU and RTL8188CUS.
  
  Reviewed by:  kevlo
  Approved by:  adrian (mentor)
  Differential Revision:https://reviews.freebsd.org/D5198

Modified:
  head/sys/dev/usb/wlan/if_urtwn.c
  head/sys/dev/usb/wlan/if_urtwnreg.h
  head/sys/dev/usb/wlan/if_urtwnvar.h

Modified: head/sys/dev/usb/wlan/if_urtwn.c
==
--- head/sys/dev/usb/wlan/if_urtwn.cMon Feb 22 00:58:04 2016
(r295873)
+++ head/sys/dev/usb/wlan/if_urtwn.cMon Feb 22 01:15:02 2016
(r295874)
@@ -308,6 +308,8 @@ static void urtwn_start(struct urtwn_so
 static voidurtwn_parent(struct ieee80211com *);
 static int urtwn_r92c_power_on(struct urtwn_softc *);
 static int urtwn_r88e_power_on(struct urtwn_softc *);
+static voidurtwn_r92c_power_off(struct urtwn_softc *);
+static voidurtwn_r88e_power_off(struct urtwn_softc *);
 static int urtwn_llt_init(struct urtwn_softc *);
 #ifndef URTWN_WITHOUT_UCODE
 static voidurtwn_fw_reset(struct urtwn_softc *);
@@ -1782,6 +1784,7 @@ urtwn_read_rom(struct urtwn_softc *sc)
 
sc->sc_rf_write = urtwn_r92c_rf_write;
sc->sc_power_on = urtwn_r92c_power_on;
+   sc->sc_power_off = urtwn_r92c_power_off;
 
return (0);
 }
@@ -1809,6 +1812,7 @@ urtwn_r88e_read_rom(struct urtwn_softc *
 
sc->sc_rf_write = urtwn_r88e_rf_write;
sc->sc_power_on = urtwn_r88e_power_on;
+   sc->sc_power_off = urtwn_r88e_power_off;
 
return (0);
 }
@@ -3235,7 +3239,7 @@ urtwn_r88e_power_on(struct urtwn_softc *
 
/* Enable LDO normal mode. */
error = urtwn_write_1(sc, R92C_LPLDO_CTRL,
-   urtwn_read_1(sc, R92C_LPLDO_CTRL) & ~0x10);
+   urtwn_read_1(sc, R92C_LPLDO_CTRL) & ~R92C_LPLDO_CTRL_SLEEP);
if (error != USB_ERR_NORMAL_COMPLETION)
return (EIO);
 
@@ -3254,6 +3258,269 @@ urtwn_r88e_power_on(struct urtwn_softc *
return (0);
 }
 
+static __inline void
+urtwn_power_off(struct urtwn_softc *sc)
+{
+
+   return sc->sc_power_off(sc);
+}
+
+static void
+urtwn_r92c_power_off(struct urtwn_softc *sc)
+{
+   uint32_t reg;
+
+   /* Block all Tx queues. */
+   urtwn_write_1(sc, R92C_TXPAUSE, R92C_TX_QUEUE_ALL);
+
+   /* Disable RF */
+   urtwn_rf_write(sc, 0, 0, 0);
+
+   urtwn_write_1(sc, R92C_APSD_CTRL, R92C_APSD_CTRL_OFF);
+
+   /* Reset BB state machine */
+   urtwn_write_1(sc, R92C_SYS_FUNC_EN,
+   R92C_SYS_FUNC_EN_USBD | R92C_SYS_FUNC_EN_USBA |
+   R92C_SYS_FUNC_EN_BB_GLB_RST);
+   urtwn_write_1(sc, R92C_SYS_FUNC_EN,
+   R92C_SYS_FUNC_EN_USBD | R92C_SYS_FUNC_EN_USBA);
+
+   /*
+* Reset digital sequence
+*/
+#ifndef URTWN_WITHOUT_UCODE
+   if (urtwn_read_1(sc, R92C_MCUFWDL) & R92C_MCUFWDL_RDY) {
+   /* Reset MCU ready status */
+   urtwn_write_1(sc, R92C_MCUFWDL, 0);
+
+   /* If firmware in ram code, do reset */
+   urtwn_fw_reset(sc);
+   }
+#endif
+
+   /* Reset MAC and Enable 8051 */
+   urtwn_write_1(sc, R92C_SYS_FUNC_EN + 1,
+   (R92C_SYS_FUNC_EN_CPUEN |
+R92C_SYS_FUNC_EN_ELDR |
+R92C_SYS_FUNC_EN_HWPDN) >> 8);
+
+   /* Reset MCU ready status */
+   urtwn_write_1(sc, R92C_MCUFWDL, 0);
+
+   /* Disable MAC clock */
+   urtwn_write_2(sc, R92C_SYS_CLKR,
+   R92C_SYS_CLKR_ANAD16V_EN |
+   R92C_SYS_CLKR_ANA8M |
+   R92C_SYS_CLKR_LOADER_EN | 
+   R92C_SYS_CLKR_80M_SSC_DIS |
+   R92C_SYS_CLKR_SYS_EN |
+   R92C_SYS_CLKR_RING_EN |
+   0x4000);
+
+   /* Disable AFE PLL */
+   urtwn_write_1(sc, R92C_AFE_PLL_CTRL, 0x80);
+
+   /* Gated AFE DIG_CLOCK */
+   urtwn_write_2(sc, R92C_AFE_XTAL_CTRL, 0x880F);
+
+   /* Isolated digital to PON */
+   urtwn_write_1(sc, R92C_SYS_ISO_CTRL,
+   R92C_SYS_ISO_CTRL_MD2PP |
+   R92C_SYS_ISO_CTRL_PA2PCIE |
+   R92C_SYS_ISO_CTRL_PD2CORE |
+   R92C_SYS_ISO_CTRL_IP2MAC |
+   R92C_SYS_ISO_CTRL_DIOP |
+   R92C_SYS_ISO_CTRL_DIOE);
+
+   /*
+* Pull GPIO PIN to balance level and LED control
+*/
+   /* 1. Disable GPIO[7:0] */
+   urtwn_write_2(sc, R92C_GPIO_IOSEL, 0x);
+
+   reg = urtwn_read_4(sc, R92C_GPIO_PIN_CTRL) & ~0xff00;
+   reg |= ((reg << 8) & 0xff00) | 0x00ff;
+   urtwn_write_4(sc, R92C_GPIO_PIN_CTRL, reg);
+
+   /* Disable GPIO[10:8] */
+   urtwn_write_1(sc, R92C_MAC_PINMUX_CFG, 0x00);
+
+   reg = urtwn_read_2(sc, R92C_GPIO_IO_SEL) & ~0x00f0;
+   reg |= (((reg & 0x000f) << 4) | 0x0780);
+   

svn commit: r295873 - in head/sys/dev: msk sk

2016-02-21 Thread Pyun YongHyeon
Author: yongari
Date: Mon Feb 22 00:58:04 2016
New Revision: 295873
URL: https://svnweb.freebsd.org/changeset/base/295873

Log:
  ifnet lock was changed to use sx(9) long time ago.
  Don't hold a driver lock for if_free(9).

Modified:
  head/sys/dev/msk/if_msk.c
  head/sys/dev/sk/if_sk.c

Modified: head/sys/dev/msk/if_msk.c
==
--- head/sys/dev/msk/if_msk.c   Mon Feb 22 00:49:35 2016(r295872)
+++ head/sys/dev/msk/if_msk.c   Mon Feb 22 00:58:04 2016(r295873)
@@ -2059,11 +2059,11 @@ msk_detach(device_t dev)
msk_txrx_dma_free(sc_if);
bus_generic_detach(dev);
 
-   if (ifp)
-   if_free(ifp);
sc = sc_if->msk_softc;
sc->msk_if[sc_if->msk_port] = NULL;
MSK_IF_UNLOCK(sc_if);
+   if (ifp)
+   if_free(ifp);
 
return (0);
 }

Modified: head/sys/dev/sk/if_sk.c
==
--- head/sys/dev/sk/if_sk.c Mon Feb 22 00:49:35 2016(r295872)
+++ head/sys/dev/sk/if_sk.c Mon Feb 22 00:58:04 2016(r295873)
@@ -1833,8 +1833,6 @@ sk_detach(dev)
ether_ifdetach(ifp);
SK_IF_LOCK(sc_if);
}
-   if (ifp)
-   if_free(ifp);
/*
 * We're generally called from skc_detach() which is using
 * device_delete_child() to get to here. It's already trashed
@@ -1848,6 +1846,8 @@ sk_detach(dev)
sk_dma_jumbo_free(sc_if);
sk_dma_free(sc_if);
SK_IF_UNLOCK(sc_if);
+   if (ifp)
+   if_free(ifp);
 
return(0);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r295871 - in head/sys: conf dev/usb/wlan modules/usb modules/usb/urtwn

2016-02-21 Thread Andriy Voskoboinyk
Author: avos
Date: Mon Feb 22 00:48:53 2016
New Revision: 295871
URL: https://svnweb.freebsd.org/changeset/base/295871

Log:
  urtwn: add an option to compile the driver without firmware specific code
  
  - Add URTWN_WITHOUT_UCODE option (will disable any firmware specific code
  when set).
  - Do not exclude the driver from build when MK_SOURCELESS_UCODE is set
  (URTWN_WITHOUT_UCODE will be enforced unconditionally).
  - Do not abort initialization when firmware cannot be loaded;
  behave like the URTWN_WITHOUT_UCODE option was set.
  - Drop some unused variables from urtwn_softc structure.
  
  Tested with RTL8188EU and RTL8188CUS in HOSTAP and STA modes.
  
  Reviewed by:  kevlo
  Approved by:  adrian (mentor)
  Differential Revision:https://reviews.freebsd.org/D4849

Modified:
  head/sys/conf/options
  head/sys/dev/usb/wlan/if_urtwn.c
  head/sys/dev/usb/wlan/if_urtwnvar.h
  head/sys/modules/usb/Makefile
  head/sys/modules/usb/urtwn/Makefile

Modified: head/sys/conf/options
==
--- head/sys/conf/options   Sun Feb 21 22:34:09 2016(r295870)
+++ head/sys/conf/options   Mon Feb 22 00:48:53 2016(r295871)
@@ -673,6 +673,9 @@ UPLCOM_INTR_INTERVALopt_uplcom.h
 UVSCOM_DEFAULT_OPKTSIZEopt_uvscom.h
 UVSCOM_INTR_INTERVAL   opt_uvscom.h
 
+# options for the Realtek RTL8188*U/RTL8192CU driver (urtwn)
+URTWN_WITHOUT_UCODEopt_urtwn.h
+
 # Embedded system options
 INIT_PATH
 

Modified: head/sys/dev/usb/wlan/if_urtwn.c
==
--- head/sys/dev/usb/wlan/if_urtwn.cSun Feb 21 22:34:09 2016
(r295870)
+++ head/sys/dev/usb/wlan/if_urtwn.cMon Feb 22 00:48:53 2016
(r295871)
@@ -26,6 +26,7 @@ __FBSDID("$FreeBSD$");
  */
 
 #include "opt_wlan.h"
+#include "opt_urtwn.h"
 
 #include 
 #include 
@@ -308,11 +309,13 @@ static void   urtwn_parent(struct ieee802
 static int urtwn_r92c_power_on(struct urtwn_softc *);
 static int urtwn_r88e_power_on(struct urtwn_softc *);
 static int urtwn_llt_init(struct urtwn_softc *);
+#ifndef URTWN_WITHOUT_UCODE
 static voidurtwn_fw_reset(struct urtwn_softc *);
 static voidurtwn_r88e_fw_reset(struct urtwn_softc *);
 static int urtwn_fw_loadpage(struct urtwn_softc *, int,
const uint8_t *, int);
 static int urtwn_load_firmware(struct urtwn_softc *);
+#endif
 static int urtwn_dma_init(struct urtwn_softc *);
 static int urtwn_mac_init(struct urtwn_softc *);
 static voidurtwn_bb_init(struct urtwn_softc *);
@@ -1376,6 +1379,13 @@ urtwn_fw_cmd(struct urtwn_softc *sc, uin
usb_error_t error;
int ntries;
 
+   if (!(sc->sc_flags & URTWN_FW_LOADED)) {
+   URTWN_DPRINTF(sc, URTWN_DEBUG_FIRMWARE, "%s: firmware "
+   "was not loaded; command (id %d) will be discarded\n",
+   __func__, id);
+   return (0);
+   }
+
/* Wait for current FW box to be empty. */
for (ntries = 0; ntries < 100; ntries++) {
if (!(urtwn_read_1(sc, R92C_HMETFR) & (1 << sc->fwcur)))
@@ -3275,6 +3285,7 @@ urtwn_llt_init(struct urtwn_softc *sc)
return (error);
 }
 
+#ifndef URTWN_WITHOUT_UCODE
 static void
 urtwn_fw_reset(struct urtwn_softc *sc)
 {
@@ -3457,6 +3468,7 @@ fail:
firmware_put(fw, FIRMWARE_UNLOAD);
return (error);
 }
+#endif
 
 static int
 urtwn_dma_init(struct urtwn_softc *sc)
@@ -4786,10 +4798,12 @@ urtwn_init(struct urtwn_softc *sc)
urtwn_write_1(sc, R92C_BCN_MAX_ERR, 0xff);
}
 
+#ifndef URTWN_WITHOUT_UCODE
/* Load 8051 microcode. */
error = urtwn_load_firmware(sc);
-   if (error != 0)
-   goto fail;
+   if (error == 0)
+   sc->sc_flags |= URTWN_FW_LOADED;
+#endif
 
/* Initialize MAC/BB/RF blocks. */
error = urtwn_mac_init(sc);
@@ -4892,7 +4906,8 @@ urtwn_stop(struct urtwn_softc *sc)
return;
}
 
-   sc->sc_flags &= ~(URTWN_RUNNING | URTWN_TEMP_MEASURED);
+   sc->sc_flags &= ~(URTWN_RUNNING | URTWN_FW_LOADED |
+   URTWN_TEMP_MEASURED);
sc->thcal_lctemp = 0;
callout_stop(>sc_watchdog_ch);
urtwn_abort_xfers(sc);
@@ -4991,6 +5006,8 @@ static devclass_t urtwn_devclass;
 DRIVER_MODULE(urtwn, uhub, urtwn_driver, urtwn_devclass, NULL, NULL);
 MODULE_DEPEND(urtwn, usb, 1, 1, 1);
 MODULE_DEPEND(urtwn, wlan, 1, 1, 1);
+#ifndef URTWN_WITHOUT_UCODE
 MODULE_DEPEND(urtwn, firmware, 1, 1, 1);
+#endif
 MODULE_VERSION(urtwn, 1);
 USB_PNP_HOST_INFO(urtwn_devs);

Modified: head/sys/dev/usb/wlan/if_urtwnvar.h
==
--- head/sys/dev/usb/wlan/if_urtwnvar.h Sun Feb 21 22:34:09 2016
(r295870)
+++ 

Re: svn commit: r295768 - head/usr.sbin/iostat

2016-02-21 Thread Alan Somers
On Sun, Feb 21, 2016 at 3:00 PM, Andrew Turner  wrote:
> On Thu, 18 Feb 2016 20:08:01 + (UTC)
> Alan Somers  wrote:
>
>> Author: asomers
>> Date: Thu Feb 18 20:08:01 2016
>> New Revision: 295768
>> URL: https://svnweb.freebsd.org/changeset/base/295768
>>
>> Log:
>>   Fix compiler warnings in iostat
>>
>>   Raise WARNS from 1 to 6 (the default)
>
> This breaks building with gcc:
>

I'll fix it in the morning.  Thanks for reporting it.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r295768 - head/usr.sbin/iostat

2016-02-21 Thread Andrew Turner
On Thu, 18 Feb 2016 20:08:01 + (UTC)
Alan Somers  wrote:

> Author: asomers
> Date: Thu Feb 18 20:08:01 2016
> New Revision: 295768
> URL: https://svnweb.freebsd.org/changeset/base/295768
> 
> Log:
>   Fix compiler warnings in iostat
>   
>   Raise WARNS from 1 to 6 (the default)

This breaks building with gcc:

===> usr.sbin/ifmcstat (all)
===> usr.sbin/iostat (all)
cc1: warnings being treated as errors
/scratch/tmp/andrew/head-git/usr.sbin/iostat/iostat.c: In function 'devstats':
/scratch/tmp/andrew/head-git/usr.sbin/iostat/iostat.c:800: warning: declaration 
of 'devname' shadows a global declaration
/scratch/tmp/andrew/obj/powerpc.powerpc/scratch/tmp/andrew/head-git/tmp/usr/include/stdlib.h:282:
 warning: shadowed declaration is here
/scratch/tmp/andrew/head-git/usr.sbin/iostat/iostat.c: In function 'cpustats':
/scratch/tmp/andrew/head-git/usr.sbin/iostat/iostat.c:982: warning: declaration 
of 'time' shadows a global declaration
/scratch/tmp/andrew/obj/powerpc.powerpc/scratch/tmp/andrew/head-git/tmp/usr/include/time.h:154:
 warning: shadowed declaration is here
*** Error code 1

Stop.
make[4]: stopped in /scratch/tmp/andrew/head-git/usr.sbin/iostat
*** Error code 1

Stop.
make[3]: stopped in /scratch/tmp/andrew/head-git/usr.sbin
*** Error code 1

Stop.
make[2]: stopped in /scratch/tmp/andrew/head-git
*** Error code 1

Stop.
make[1]: stopped in /scratch/tmp/andrew/head-git
*** Error code 1

Stop.
make: stopped in /scratch/tmp/andrew/head-git

-Wshadow is added to the warning flags with WARNS >= 4.

Andrew
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r295869 - in head/sys/boot/efi: include libefi

2016-02-21 Thread Andrew Turner
Author: andrew
Date: Sun Feb 21 21:20:23 2016
New Revision: 295869
URL: https://svnweb.freebsd.org/changeset/base/295869

Log:
  Make efi_time and EFI_GetTimeOfDay static, neither are used by other parts
  of the efi code.
  
  Sponsored by: ABT Systems Ltd

Modified:
  head/sys/boot/efi/include/efilib.h
  head/sys/boot/efi/libefi/time.c

Modified: head/sys/boot/efi/include/efilib.h
==
--- head/sys/boot/efi/include/efilib.h  Sun Feb 21 20:58:24 2016
(r295868)
+++ head/sys/boot/efi/include/efilib.h  Sun Feb 21 21:20:23 2016
(r295869)
@@ -46,7 +46,6 @@ int efi_handle_lookup(EFI_HANDLE, struct
 int efi_handle_update_dev(EFI_HANDLE, struct devsw *, int, uint64_t);
 
 int efi_status_to_errno(EFI_STATUS);
-time_t efi_time(EFI_TIME *);
 
 EFI_STATUS main(int argc, CHAR16 *argv[]);
 void exit(EFI_STATUS status);

Modified: head/sys/boot/efi/libefi/time.c
==
--- head/sys/boot/efi/libefi/time.c Sun Feb 21 20:58:24 2016
(r295868)
+++ head/sys/boot/efi/libefi/time.c Sun Feb 21 21:20:23 2016
(r295869)
@@ -58,7 +58,7 @@ __FBSDID("$FreeBSD$");
 #define SECSPERHOUR ( 60*60 )
 #define SECSPERDAY (24 * SECSPERHOUR)
 
-time_t
+static time_t
 efi_time(EFI_TIME *ETime)
 {
 /*
@@ -164,7 +164,7 @@ efi_time(EFI_TIME *ETime)
 return UTime;
 }
 
-int
+static int
 EFI_GetTimeOfDay(
OUT struct timeval *tp,
OUT struct timezone *tzp
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r295868 - head/bin/sh

2016-02-21 Thread Jilles Tjoelker
Author: jilles
Date: Sun Feb 21 20:58:24 2016
New Revision: 295868
URL: https://svnweb.freebsd.org/changeset/base/295868

Log:
  sh: Don't hash alias name when there are no aliases.

Modified:
  head/bin/sh/alias.c

Modified: head/bin/sh/alias.c
==
--- head/bin/sh/alias.c Sun Feb 21 18:58:05 2016(r295867)
+++ head/bin/sh/alias.c Sun Feb 21 20:58:24 2016(r295868)
@@ -144,9 +144,11 @@ rmaliases(void)
 struct alias *
 lookupalias(const char *name, int check)
 {
-   struct alias *ap = *hashalias(name);
+   struct alias *ap;
 
-   for (; ap; ap = ap->next) {
+   if (aliases == 0)
+   return (NULL);
+   for (ap = *hashalias(name); ap; ap = ap->next) {
if (equal(name, ap->name)) {
if (check && (ap->flag & ALIASINUSE))
return (NULL);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r295867 - head/usr.sbin/config

2016-02-21 Thread Ian Lepore
Author: ian
Date: Sun Feb 21 18:58:05 2016
New Revision: 295867
URL: https://svnweb.freebsd.org/changeset/base/295867

Log:
  Document the ability to override compiled-in env and hints using variables
  in the bootloader-provided env.

Modified:
  head/usr.sbin/config/config.5

Modified: head/usr.sbin/config/config.5
==
--- head/usr.sbin/config/config.5   Sun Feb 21 18:54:17 2016
(r295866)
+++ head/usr.sbin/config/config.5   Sun Feb 21 18:58:05 2016
(r295867)
@@ -23,7 +23,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 3, 2005
+.Dd February 21, 2016
 .Dt CONFIG 5
 .Os
 .Sh NAME
@@ -118,7 +118,8 @@ The kernel normally uses an environment 
 by
 .Xr loader 8 .
 This directive makes the kernel ignore the boot environment and use
-the compiled-in environment instead.
+the compiled-in environment instead, unless the boot environment contains
+.Va static_env.disabled=1 .
 .Pp
 This directive is useful for setting kernel tunables in
 embedded environments that do not start from
@@ -141,7 +142,9 @@ time (see
 .Xr device.hints 5 ) .
 This directive configures the kernel to use the static device configuration
 listed in
-.Ar filename .
+.Ar filename ,
+unless the boot environment contains
+.Va static_hints.disabled=1 .
 The file
 .Ar filename
 must conform to the syntax specified by
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r295866 - head/bin/sh

2016-02-21 Thread Jilles Tjoelker
Author: jilles
Date: Sun Feb 21 18:54:17 2016
New Revision: 295866
URL: https://svnweb.freebsd.org/changeset/base/295866

Log:
  sh: Optimize setprompt(0).
  
  Avoid doing work to print an empty prompt (such as when reading scripts).

Modified:
  head/bin/sh/parser.c

Modified: head/bin/sh/parser.c
==
--- head/bin/sh/parser.cSun Feb 21 18:51:48 2016(r295865)
+++ head/bin/sh/parser.cSun Feb 21 18:54:17 2016(r295866)
@@ -1930,6 +1930,8 @@ static void
 setprompt(int which)
 {
whichprompt = which;
+   if (which == 0)
+   return;
 
 #ifndef NO_HISTORY
if (!el)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r295865 - head/sys/dev/rtwn

2016-02-21 Thread Andriy Voskoboinyk
Author: avos
Date: Sun Feb 21 18:51:48 2016
New Revision: 295865
URL: https://svnweb.freebsd.org/changeset/base/295865

Log:
  rtwn: import r290048.
  
  - Fix scanning from AUTH state.
  
  Tested by: Simone Mario Lombardo 
  
  PR:   203105
  Reviewed by:  kevlo
  Approved by:  adrian (mentor)
  Differential Revision:https://reviews.freebsd.org/D4820

Modified:
  head/sys/dev/rtwn/if_rtwn.c

Modified: head/sys/dev/rtwn/if_rtwn.c
==
--- head/sys/dev/rtwn/if_rtwn.c Sun Feb 21 18:35:01 2016(r295864)
+++ head/sys/dev/rtwn/if_rtwn.c Sun Feb 21 18:51:48 2016(r295865)
@@ -168,6 +168,8 @@ static void rtwn_get_txpower(struct rtwn
uint16_t[]);
 static voidrtwn_set_txpower(struct rtwn_softc *,
struct ieee80211_channel *, struct ieee80211_channel *);
+static voidrtwn_set_rx_bssid_all(struct rtwn_softc *, int);
+static voidrtwn_set_gain(struct rtwn_softc *, uint8_t);
 static voidrtwn_scan_start(struct ieee80211com *);
 static voidrtwn_scan_end(struct ieee80211com *);
 static voidrtwn_set_channel(struct ieee80211com *);
@@ -1237,22 +1239,6 @@ rtwn_newstate(struct ieee80211vap *vap, 
rtwn_set_led(sc, RTWN_LED_LINK, 0);
break;
case IEEE80211_S_SCAN:
-   if (vap->iv_state != IEEE80211_S_SCAN) {
-   /* Allow Rx from any BSSID. */
-   rtwn_write_4(sc, R92C_RCR,
-   rtwn_read_4(sc, R92C_RCR) &
-   ~(R92C_RCR_CBSSID_DATA | R92C_RCR_CBSSID_BCN));
-
-   /* Set gain for scanning. */
-   reg = rtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(0));
-   reg = RW(reg, R92C_OFDM0_AGCCORE1_GAIN, 0x20);
-   rtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(0), reg);
-
-   reg = rtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(1));
-   reg = RW(reg, R92C_OFDM0_AGCCORE1_GAIN, 0x20);
-   rtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(1), reg);
-   }
-
/* Make link LED blink during scan. */
rtwn_set_led(sc, RTWN_LED_LINK, !sc->ledlink);
 
@@ -1261,14 +1247,6 @@ rtwn_newstate(struct ieee80211vap *vap, 
rtwn_read_1(sc, R92C_TXPAUSE) | 0x0f);
break;
case IEEE80211_S_AUTH:
-   /* Set initial gain under link. */
-   reg = rtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(0));
-   reg = RW(reg, R92C_OFDM0_AGCCORE1_GAIN, 0x32);
-   rtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(0), reg);
-
-   reg = rtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(1));
-   reg = RW(reg, R92C_OFDM0_AGCCORE1_GAIN, 0x32);
-   rtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(1), reg);
rtwn_set_chan(sc, ic->ic_curchan, NULL);
break;
case IEEE80211_S_RUN:
@@ -2684,17 +2662,56 @@ rtwn_set_txpower(struct rtwn_softc *sc, 
 }
 
 static void
+rtwn_set_rx_bssid_all(struct rtwn_softc *sc, int enable)
+{
+   uint32_t reg;
+
+   reg = rtwn_read_4(sc, R92C_RCR);
+   if (enable)
+   reg &= ~R92C_RCR_CBSSID_BCN;
+   else
+   reg |= R92C_RCR_CBSSID_BCN;
+   rtwn_write_4(sc, R92C_RCR, reg);
+}
+
+static void
+rtwn_set_gain(struct rtwn_softc *sc, uint8_t gain)
+{
+   uint32_t reg;
+
+   reg = rtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(0));
+   reg = RW(reg, R92C_OFDM0_AGCCORE1_GAIN, gain);
+   rtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(0), reg);
+
+   reg = rtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(1));
+   reg = RW(reg, R92C_OFDM0_AGCCORE1_GAIN, gain);
+   rtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(1), reg);
+}
+
+static void
 rtwn_scan_start(struct ieee80211com *ic)
 {
+   struct rtwn_softc *sc = ic->ic_softc;
 
-   /* XXX do nothing?  */
+   RTWN_LOCK(sc);
+   /* Receive beacons / probe responses from any BSSID. */
+   rtwn_set_rx_bssid_all(sc, 1);
+   /* Set gain for scanning. */
+   rtwn_set_gain(sc, 0x20);
+   RTWN_UNLOCK(sc);
 }
 
 static void
 rtwn_scan_end(struct ieee80211com *ic)
 {
+   struct rtwn_softc *sc = ic->ic_softc;
 
-   /* XXX do nothing?  */
+   RTWN_LOCK(sc);
+   /* Restore limitations. */
+   rtwn_set_rx_bssid_all(sc, 0);
+   /* Set gain under link. */
+   rtwn_set_gain(sc, 0x32);
+   RTWN_UNLOCK(sc);
 }
 
 static void
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r295864 - head/sys/kern

2016-02-21 Thread Ian Lepore
Author: ian
Date: Sun Feb 21 18:35:01 2016
New Revision: 295864
URL: https://svnweb.freebsd.org/changeset/base/295864

Log:
  Allow a dynamic env to override a compiled-in static env by passing in the
  override indication in the env data.
  
  Submitted by: bde

Modified:
  head/sys/kern/kern_environment.c

Modified: head/sys/kern/kern_environment.c
==
--- head/sys/kern/kern_environment.cSun Feb 21 18:17:09 2016
(r295863)
+++ head/sys/kern/kern_environment.cSun Feb 21 18:35:01 2016
(r295864)
@@ -217,6 +217,9 @@ done:
  * environment obtained from a boot loader, or to provide an empty buffer into
  * which MD code can store an initial environment using kern_setenv() calls.
  *
+ * When a copy of an initial environment is passed in, we start by scanning 
that
+ * env for overrides to the compiled-in envmode and hintmode variables.
+ *
  * If the global envmode is 1, the environment is initialized from the global
  * static_env[], regardless of the arguments passed.  This implements the env
  * keyword described in config(5).  In this case env_pos is set to env_len,
@@ -238,6 +241,14 @@ done:
 void
 init_static_kenv(char *buf, size_t len)
 {
+   char *cp;
+   
+   for (cp = buf; cp != NULL && cp[0] != '\0'; cp += strlen(cp) + 1) {
+   if (strcmp(cp, "static_env.disabled=1") == 0)
+   envmode = 0;
+   if (strcmp(cp, "static_hints.disabled=1") == 0)
+   hintmode = 0;
+   }
 
if (envmode == 1) {
kern_envp = static_env;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r295863 - head/sys/i386/i386

2016-02-21 Thread Ian Lepore
Author: ian
Date: Sun Feb 21 18:17:09 2016
New Revision: 295863
URL: https://svnweb.freebsd.org/changeset/base/295863

Log:
  Minor style cleanups.
  
  Submitted by: bde

Modified:
  head/sys/i386/i386/machdep.c

Modified: head/sys/i386/i386/machdep.c
==
--- head/sys/i386/i386/machdep.cSun Feb 21 16:48:37 2016
(r295862)
+++ head/sys/i386/i386/machdep.cSun Feb 21 18:17:09 2016
(r295863)
@@ -2463,8 +2463,8 @@ init386(first)
metadata_missing = 1;
}
 
-   if (bootinfo.bi_envp)
-   init_static_kenv((caddr_t)bootinfo.bi_envp + KERNBASE, 0);
+   if (bootinfo.bi_envp != 0)
+   init_static_kenv((char *)bootinfo.bi_envp + KERNBASE, 0);
else
init_static_kenv(NULL, 0);
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r295862 - head/bin/sh

2016-02-21 Thread Jilles Tjoelker
Author: jilles
Date: Sun Feb 21 16:48:37 2016
New Revision: 295862
URL: https://svnweb.freebsd.org/changeset/base/295862

Log:
  sh: Remove unnecessary flushouts while reading script.
  
  Output is flushed when a builtin is done or immediately after writing it
  (error messages, set -v output, prompts).

Modified:
  head/bin/sh/input.c

Modified: head/bin/sh/input.c
==
--- head/bin/sh/input.c Sun Feb 21 16:45:22 2016(r295861)
+++ head/bin/sh/input.c Sun Feb 21 16:48:37 2016(r295862)
@@ -212,8 +212,6 @@ preadbuffer(void)
}
if (parsenleft == EOF_NLEFT || parsefile->buf == NULL)
return PEOF;
-   flushout();
-   flushout();
 
 again:
if (parselleft <= 0) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r295856 - head/sys/compat/linprocfs

2016-02-21 Thread Mateusz Guzik
On Sun, Feb 21, 2016 at 02:56:05PM +, Dag-Erling Smørgrav wrote:

First of all I received this patch over a month ago and then I forgot a
about it, for which I have to apologize.

Now back to business.

> Author: des
> Date: Sun Feb 21 14:56:05 2016
> New Revision: 295856
> URL: https://svnweb.freebsd.org/changeset/base/295856
> 
> Log:
>   Implement /proc/$$/limits.
>   
>   PR: 207386
>   Submitted by:   Szymon Śliwa 
>   MFC after:  3 weeks
> 
> Modified:
>   head/sys/compat/linprocfs/linprocfs.c
> 
> Modified: head/sys/compat/linprocfs/linprocfs.c
> ==
> --- head/sys/compat/linprocfs/linprocfs.c Sun Feb 21 14:50:37 2016
> (r295855)
> +++ head/sys/compat/linprocfs/linprocfs.c Sun Feb 21 14:56:05 2016
> (r295856)
> @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -1366,6 +1367,67 @@ linprocfs_dofdescfs(PFS_FILL_ARGS)
>   return (0);
>  }
>  
> +/*
> + * Filler function for proc/pid/limits
> + */
> +
> +#define RLIM_NONE -1
> +
> +static const struct limit_info {
> + const char  *desc;
> + const char  *unit;
> + unsigned long long  rlim_id;
> +} limits_info[] = {
> + { "Max cpu time",   "seconds",  RLIMIT_CPU },
> + { "Max file size",  "bytes",RLIMIT_FSIZE },
> + { "Max data size",  "bytes",RLIMIT_DATA },
> + { "Max stack size", "bytes",RLIMIT_STACK },
> + { "Max core file size", "bytes",RLIMIT_CORE },
> + { "Max resident set",   "bytes",RLIMIT_RSS },
> + { "Max processes",  "processes",RLIMIT_NPROC },
> + { "Max open files", "files",RLIMIT_NOFILE },
> + { "Max locked memory",  "bytes",RLIMIT_MEMLOCK },
> + { "Max address space",  "bytes",RLIMIT_AS },
> + { "Max file locks", "locks",RLIM_INFINITY },
> + { "Max pending signals","signals",  RLIM_INFINITY },
> + { "Max msgqueue size",  "bytes",RLIM_NONE },
> + { "Max nice priority",  "", RLIM_NONE },
> + { "Max realtime priority",  "", RLIM_NONE },
> + { "Max realtime timeout",   "us",   RLIM_INFINITY },
> + { 0, 0, 0 }
> +};
> +
> +static int
> +linprocfs_doproclimits(PFS_FILL_ARGS)
> +{
> + const struct limit_info *li;
> + struct rlimit li_rlimits;
> + struct plimit *cur_proc_lim;
> +

'cur' is a bad part for a name here. For instance 'curthread' refers to
the thread executing the code. Now 'cur' strongly implies this is a
pointer to limits from the current thread. This also is not the standard
name used for pointers to plimit.

> + cur_proc_lim = lim_alloc();

I presume this function is called with the process unlocked. If it was
locked, bound sleep property of the mtx would conflict with unbodung
sleep possibly induced by lim_alloc.

But there is no reason to allocate anything.

> + lim_copy(cur_proc_lim, p->p_limit);

If the process is unlocked, this has to be wrong. The target process may
be in the process of changing its limits leading to this code reading a
pointer to a buffer which is freed before lim_copy accesses it.

The limit structure is maintained with a reference counter. Thus the
correct thing to do is to lock the process, grab the reference, unlock
the process, do what you need to do with the structure and finally unref
it.

Interestingly the correct thing to do is implemented here:
http://fxr.watson.org/fxr/source/fs/procfs/procfs_rlimit.c#L112

I have not verified correctness of the rest of the patch.

> + sbuf_printf(sb, "%-26s%-21s%-21s%-10s\n", "Limit", "Soft Limit",
> + "Hard Limit", "Units");
> + for (li = limits_info; li->desc != NULL; ++li) {
> + if (li->rlim_id != RLIM_INFINITY && li->rlim_id != RLIM_NONE)
> + li_rlimits = cur_proc_lim->pl_rlimit[li->rlim_id];
> + else {
> + li_rlimits.rlim_cur = 0;
> + li_rlimits.rlim_max = 0;
> + }
> + if (li->rlim_id == RLIM_INFINITY ||
> + li_rlimits.rlim_cur == RLIM_INFINITY)
> + sbuf_printf(sb, "%-26s%-21s%-21s%-10s\n",
> + li->desc, "unlimited", "unlimited", li->unit);
> + else
> + sbuf_printf(sb, "%-26s%-21ld%-21ld%-10s\n",
> + li->desc, (long)li_rlimits.rlim_cur,
> + (long)li_rlimits.rlim_max, li->unit);
> + }
> + lim_free(cur_proc_lim);
> + return (0);
> +}
> +
>  
>  /*
>   * Filler function for proc/sys/kernel/random/uuid
> @@ -1504,6 +1566,8 @@ linprocfs_init(PFS_INIT_ARGS)
>   NULL, 

svn commit: r295861 - head/sys/dev/pms/freebsd/driver/ini/src

2016-02-21 Thread Pedro F. Giffuni
Author: pfg
Date: Sun Feb 21 16:45:22 2016
New Revision: 295861
URL: https://svnweb.freebsd.org/changeset/base/295861

Log:
  ostiInitiatorIOCompleted(): wrong sizeof() argument.
  
  Detected by:  PVS Static Analysis
  CID:  1331601, 1331523

Modified:
  head/sys/dev/pms/freebsd/driver/ini/src/osapi.c

Modified: head/sys/dev/pms/freebsd/driver/ini/src/osapi.c
==
--- head/sys/dev/pms/freebsd/driver/ini/src/osapi.c Sun Feb 21 16:27:55 
2016(r295860)
+++ head/sys/dev/pms/freebsd/driver/ini/src/osapi.c Sun Feb 21 16:45:22 
2016(r295861)
@@ -313,7 +313,7 @@ ostiInitiatorIOCompleted(tiRoot_t  *
   }
   sense_len = MIN( pSenseData->senseLen,
pccb->senseLen - csio->sense_resid );
-  bzero(>sense_data, sizeof(>sense_data));
+  bzero(>sense_data, sizeof(csio->sense_data));
   AGTIAPI_PRINTK("ostiInitiatorIOCompleted: check condition copying\n");
   memcpy( (void *)pccb->pSenseData,
   pSenseData->senseData,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r295857 - head/contrib/binutils/bfd

2016-02-21 Thread Ian Lepore
Author: ian
Date: Sun Feb 21 14:59:24 2016
New Revision: 295857
URL: https://svnweb.freebsd.org/changeset/base/295857

Log:
  Unconditionally set e_ident[OSABI]=ELFOSABI_FREEBSD in arm binary headers.
  
  When the armv6 support was imported from a project branch, this complex
  conditional logic and related #define'd values came along, but it's really
  not clear what the intent of it all was.  The effect, however, was that
  OSABI was always set to zero, which is "UNIX System V ABI".  Having the wrong
  value there causes pkg(8) to avoid looking inside arm elf binaries to
  determine shared-lib required/provides info for packaging.

Modified:
  head/contrib/binutils/bfd/elf32-arm.c

Modified: head/contrib/binutils/bfd/elf32-arm.c
==
--- head/contrib/binutils/bfd/elf32-arm.c   Sun Feb 21 14:56:05 2016
(r295856)
+++ head/contrib/binutils/bfd/elf32-arm.c   Sun Feb 21 14:59:24 2016
(r295857)
@@ -59,13 +59,6 @@
 #define elf_info_to_howto   0
 #define elf_info_to_howto_rel   elf32_arm_info_to_howto
 
-#define ARM_ELF_ABI_VERSION0
-#ifdef __FreeBSD__
-#define ARM_ELF_OS_ABI_VERSION ELFOSABI_FREEBSD
-#else
-#define ARM_ELF_OS_ABI_VERSION ELFOSABI_ARM
-#endif
-
 static struct elf_backend_data elf32_arm_vxworks_bed;
 
 /* Note: code such as elf32_arm_reloc_type_lookup expect to use e.g.
@@ -9377,11 +9370,8 @@ elf32_arm_post_process_headers (bfd * ab
 
   i_ehdrp = elf_elfheader (abfd);
 
-  if (EF_ARM_EABI_VERSION (i_ehdrp->e_flags) == EF_ARM_EABI_UNKNOWN)
-i_ehdrp->e_ident[EI_OSABI] = ARM_ELF_OS_ABI_VERSION;
-  else
-i_ehdrp->e_ident[EI_OSABI] = 0;
-  i_ehdrp->e_ident[EI_ABIVERSION] = ARM_ELF_ABI_VERSION;
+  i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
+  i_ehdrp->e_ident[EI_ABIVERSION] = 0;
 
   if (link_info)
 {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r295856 - head/sys/compat/linprocfs

2016-02-21 Thread Dag-Erling Smørgrav
Author: des
Date: Sun Feb 21 14:56:05 2016
New Revision: 295856
URL: https://svnweb.freebsd.org/changeset/base/295856

Log:
  Implement /proc/$$/limits.
  
  PR:   207386
  Submitted by: Szymon Śliwa 
  MFC after:3 weeks

Modified:
  head/sys/compat/linprocfs/linprocfs.c

Modified: head/sys/compat/linprocfs/linprocfs.c
==
--- head/sys/compat/linprocfs/linprocfs.c   Sun Feb 21 14:50:37 2016
(r295855)
+++ head/sys/compat/linprocfs/linprocfs.c   Sun Feb 21 14:56:05 2016
(r295856)
@@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1366,6 +1367,67 @@ linprocfs_dofdescfs(PFS_FILL_ARGS)
return (0);
 }
 
+/*
+ * Filler function for proc/pid/limits
+ */
+
+#define RLIM_NONE -1
+
+static const struct limit_info {
+   const char  *desc;
+   const char  *unit;
+   unsigned long long  rlim_id;
+} limits_info[] = {
+   { "Max cpu time",   "seconds",  RLIMIT_CPU },
+   { "Max file size",  "bytes",RLIMIT_FSIZE },
+   { "Max data size",  "bytes",RLIMIT_DATA },
+   { "Max stack size", "bytes",RLIMIT_STACK },
+   { "Max core file size", "bytes",RLIMIT_CORE },
+   { "Max resident set",   "bytes",RLIMIT_RSS },
+   { "Max processes",  "processes",RLIMIT_NPROC },
+   { "Max open files", "files",RLIMIT_NOFILE },
+   { "Max locked memory",  "bytes",RLIMIT_MEMLOCK },
+   { "Max address space",  "bytes",RLIMIT_AS },
+   { "Max file locks", "locks",RLIM_INFINITY },
+   { "Max pending signals","signals",  RLIM_INFINITY },
+   { "Max msgqueue size",  "bytes",RLIM_NONE },
+   { "Max nice priority",  "", RLIM_NONE },
+   { "Max realtime priority",  "", RLIM_NONE },
+   { "Max realtime timeout",   "us",   RLIM_INFINITY },
+   { 0, 0, 0 }
+};
+
+static int
+linprocfs_doproclimits(PFS_FILL_ARGS)
+{
+   const struct limit_info *li;
+   struct rlimit li_rlimits;
+   struct plimit *cur_proc_lim;
+
+   cur_proc_lim = lim_alloc();
+   lim_copy(cur_proc_lim, p->p_limit);
+   sbuf_printf(sb, "%-26s%-21s%-21s%-10s\n", "Limit", "Soft Limit",
+   "Hard Limit", "Units");
+   for (li = limits_info; li->desc != NULL; ++li) {
+   if (li->rlim_id != RLIM_INFINITY && li->rlim_id != RLIM_NONE)
+   li_rlimits = cur_proc_lim->pl_rlimit[li->rlim_id];
+   else {
+   li_rlimits.rlim_cur = 0;
+   li_rlimits.rlim_max = 0;
+   }
+   if (li->rlim_id == RLIM_INFINITY ||
+   li_rlimits.rlim_cur == RLIM_INFINITY)
+   sbuf_printf(sb, "%-26s%-21s%-21s%-10s\n",
+   li->desc, "unlimited", "unlimited", li->unit);
+   else
+   sbuf_printf(sb, "%-26s%-21ld%-21ld%-10s\n",
+   li->desc, (long)li_rlimits.rlim_cur,
+   (long)li_rlimits.rlim_max, li->unit);
+   }
+   lim_free(cur_proc_lim);
+   return (0);
+}
+
 
 /*
  * Filler function for proc/sys/kernel/random/uuid
@@ -1504,6 +1566,8 @@ linprocfs_init(PFS_INIT_ARGS)
NULL, NULL, NULL, 0);
pfs_create_file(dir, "auxv", _doauxv,
NULL, _candebug, NULL, PFS_RD|PFS_RAWRD);
+   pfs_create_file(dir, "limits", _doproclimits,
+   NULL, NULL, NULL, PFS_RD);
 
/* /proc/scsi/... */
dir = pfs_create_dir(root, "scsi", NULL, NULL, NULL, 0);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

svn commit: r295854 - head/bin/dd

2016-02-21 Thread Edward Tomasz Napierala
Author: trasz
Date: Sun Feb 21 14:36:50 2016
New Revision: 295854
URL: https://svnweb.freebsd.org/changeset/base/295854

Log:
  Make the "invalid numeric value" error message actually displayable
  (was a dead code before).
  
  Submitted by: bde@ (earlier version)
  Reviewed by:  bde@
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/bin/dd/args.c

Modified: head/bin/dd/args.c
==
--- head/bin/dd/args.c  Sun Feb 21 13:54:22 2016(r295853)
+++ head/bin/dd/args.c  Sun Feb 21 14:36:50 2016(r295854)
@@ -422,11 +422,10 @@ get_num(const char *val)
 
errno = 0;
num = strtoumax(val, , 0);
-   if (errno != 0) /* Overflow or underflow. */
-   err(1, "%s", oper);
-   
if (expr == val)/* No valid digits. */
-   errx(1, "%s: illegal numeric value", oper);
+   errx(1, "%s: invalid numeric value", oper);
+   if (errno != 0)
+   err(1, "%s", oper);
 
mult = postfix_to_mult(*expr);
 
@@ -472,11 +471,10 @@ get_off_t(const char *val)
 
errno = 0;
num = strtoimax(val, , 0);
-   if (errno != 0) /* Overflow or underflow. */
-   err(1, "%s", oper);
-   
if (expr == val)/* No valid digits. */
-   errx(1, "%s: illegal numeric value", oper);
+   errx(1, "%s: invalid numeric value", oper);
+   if (errno != 0)
+   err(1, "%s", oper);
 
mult = postfix_to_mult(*expr);
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r295844 - in head/cddl/contrib/opensolaris/cmd: zfs zpool

2016-02-21 Thread Dimitry Andric
Author: dim
Date: Sun Feb 21 13:03:58 2016
New Revision: 295844
URL: https://svnweb.freebsd.org/changeset/base/295844

Log:
  Fix "invalid type '(null)'" usage messages in zfs(8) and zpool(8).
  
  Currently, zfs(8) and zpool(8) print "invalid type '(null)'" or similar
  messages, if you pass in invalid types, sources or column names for "zfs
  get", "zfs list" and "zpool get".  This is because the commands use
  getsubopt(3), and in case of failure, they print 'value', which is NULL
  when sub options don't match.
  
  They should print 'suboptarg' instead, which is the documented way to
  get at the non-matching sub option value.
  
  Reviewed by:  smh
  MFC after:3 days
  Differential Revision: https://reviews.freebsd.org/D5365

Modified:
  head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
  head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c

Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
==
--- head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.cSat Feb 20 22:58:33 
2016(r295843)
+++ head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.cSun Feb 21 13:03:58 
2016(r295844)
@@ -1713,7 +1713,7 @@ zfs_do_get(int argc, char **argv)
default:
(void) fprintf(stderr,
gettext("invalid column name "
-   "'%s'\n"), value);
+   "'%s'\n"), suboptarg);
usage(B_FALSE);
}
}
@@ -1750,7 +1750,7 @@ zfs_do_get(int argc, char **argv)
default:
(void) fprintf(stderr,
gettext("invalid source "
-   "'%s'\n"), value);
+   "'%s'\n"), suboptarg);
usage(B_FALSE);
}
}
@@ -1786,7 +1786,7 @@ zfs_do_get(int argc, char **argv)
default:
(void) fprintf(stderr,
gettext("invalid type '%s'\n"),
-   value);
+   suboptarg);
usage(B_FALSE);
}
}
@@ -3156,7 +3156,7 @@ zfs_do_list(int argc, char **argv)
default:
(void) fprintf(stderr,
gettext("invalid type '%s'\n"),
-   value);
+   suboptarg);
usage(B_FALSE);
}
}

Modified: head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
==
--- head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.cSat Feb 20 
22:58:33 2016(r295843)
+++ head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.cSun Feb 21 
13:03:58 2016(r295844)
@@ -5431,7 +5431,7 @@ zpool_do_get(int argc, char **argv)
default:
(void) fprintf(stderr,
gettext("invalid column name "
-   "'%s'\n"), value);
+   "'%s'\n"), suboptarg);
usage(B_FALSE);
}
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"