svn commit: r339406 - in stable/11/stand: common pc98/btx/lib pc98/libpc98

2018-10-16 Thread Warner Losh
Author: imp
Date: Wed Oct 17 04:10:23 2018
New Revision: 339406
URL: https://svnweb.freebsd.org/changeset/base/339406

Log:
  Direct commit since these files have gone away in head
  
  Move pc98's biosdisk.c to the new style disk access. This is missing
  support in common/part.c, however, for pc98 partitions, so it's
  unlikely to actually work. Lack of a pc98 machine that's in sevice
  limits my ability to test, but this allows pc98 to compile again.

Modified:
  stable/11/stand/common/part.c
  stable/11/stand/pc98/btx/lib/btxv86.h
  stable/11/stand/pc98/libpc98/biosdisk.c

Modified: stable/11/stand/common/part.c
==
--- stable/11/stand/common/part.c   Wed Oct 17 02:45:15 2018
(r339405)
+++ stable/11/stand/common/part.c   Wed Oct 17 04:10:23 2018
(r339406)
@@ -898,6 +898,38 @@ ptable_getbestpart(const struct ptable *table, struct 
pref = PREF_NONE;
}
 #endif /* LOADER_GPT_SUPPORT */
+#ifdef LOADER_PC98_SUPPORT
+   if (table->type == PTABLE_PC98) {
+   switch(entry->part.type & PC98_MID_MASK) {
+   case PC98_MID_386BSD:   /* FreeBSD */
+   if ((entry->part.type & PC98_MID_BOOTABLE) &&
+   (preflevel > PREF_FBSD_ACT)) {
+   pref = i;
+   preflevel = PREF_FBSD_ACT;
+   } else if (preflevel > PREF_FBSD) {
+   pref = i;
+   preflevel = PREF_FBSD;
+   }
+   break;
+
+   case 0x11:  /* DOS/Windows */
+   case 0x20:
+   case 0x21:
+   case 0x22:
+   case 0x23:
+   case 0x63:
+   if ((entry->part.type & PC98_MID_BOOTABLE) &&
+   (preflevel > PREF_DOS_ACT)) {
+   pref = i;
+   preflevel = PREF_DOS_ACT;
+   } else if (preflevel > PREF_DOS) {
+   pref = i;
+   preflevel = PREF_DOS;
+   }
+   break;
+   }
+   }
+#endif /* LOADER_PC98_SUPPORT */
if (pref < preflevel) {
preflevel = pref;
best = entry;
@@ -943,3 +975,162 @@ ptable_iterate(const struct ptable *table, void *arg, 
}
return (ret);
 }
+#ifdef LOADER_PC98_SUPPORT
+static int
+bd_open_pc98(struct open_disk *od, struct i386_devdesc *dev)
+{
+struct pc98_partition  *dptr;
+struct disklabel   *lp;
+intsector, slice, i;
+char   buf[BUFSIZE];
+
+/*
+ * Following calculations attempt to determine the correct value
+ * for d->od_boff by looking for the slice and partition specified,
+ * or searching for reasonable defaults.
+ */
+
+/*
+ * Find the slice in the DOS slice table.
+ */
+od->od_nslices = 0;
+if (od->od_flags & BD_FLOPPY) {
+   sector = 0;
+   goto unsliced;
+}
+if (bd_read(od, 0, 1, buf)) {
+   DEBUG("error reading MBR");
+   return (EIO);
+}
+
+/* 
+ * Check the slice table magic.
+ */
+if (((u_char)buf[0x1fe] != 0x55) || ((u_char)buf[0x1ff] != 0xaa)) {
+   /* If a slice number was explicitly supplied, this is an error */
+   if (dev->d_kind.biosdisk.slice > 0) {
+   DEBUG("no slice table/MBR (no magic)");
+   return (ENOENT);
+   }
+   sector = 0;
+   goto unsliced;  /* may be a floppy */
+}
+if (bd_read(od, 1, 1, buf)) {
+   DEBUG("error reading MBR");
+   return (EIO);
+}
+
+/*
+ * copy the partition table, then pick up any extended partitions.
+ */
+bcopy(buf + PC98_PARTOFF, >od_slicetab,
+  sizeof(struct pc98_partition) * PC98_NPARTS);
+od->od_nslices = PC98_NPARTS;  /* extended slices start here */
+od->od_flags |= BD_PARTTABOK;
+dptr = >od_slicetab[0];
+
+/* Is this a request for the whole disk? */
+if (dev->d_kind.biosdisk.slice == -1) {
+   sector = 0;
+   goto unsliced;
+}
+
+/*
+ * if a slice number was supplied but not found, this is an error.
+ */
+if (dev->d_kind.biosdisk.slice > 0) {
+slice = dev->d_kind.biosdisk.slice - 1;
+if (slice >= od->od_nslices) {
+DEBUG("slice %d not found", slice);
+   return (ENOENT);
+}
+}
+
+/* Try to auto-detect the best slice; this should always 

svn commit: r339405 - stable/11/stand/pc98/loader

2018-10-16 Thread Warner Losh
Author: imp
Date: Wed Oct 17 02:45:15 2018
New Revision: 339405
URL: https://svnweb.freebsd.org/changeset/base/339405

Log:
  Direct commit to stable, file not present in current
  
  Catch up to r332154: Fix d_dev removal of d_type.

Modified:
  stable/11/stand/pc98/loader/main.c

Modified: stable/11/stand/pc98/loader/main.c
==
--- stable/11/stand/pc98/loader/main.c  Wed Oct 17 02:25:15 2018
(r339404)
+++ stable/11/stand/pc98/loader/main.c  Wed Oct 17 02:45:15 2018
(r339405)
@@ -253,13 +253,12 @@ extract_currdev(void)
biosdev = (major << 3) + 0x80 + B_UNIT(initial_bootdev);
}
 }
-new_currdev.dd.d_type = new_currdev.dd.d_dev->dv_type;
 
 /*
  * If we are booting off of a BIOS disk and we didn't succeed in 
determining
  * which one we booted off of, just use disk0: as a reasonable default.
  */
-if ((new_currdev.dd.d_type == biosdisk.dv_type) &&
+if ((new_currdev.dd.d_dev->dv_type == biosdisk.dv_type) &&
((new_currdev.dd.d_unit = bd_bios2unit(biosdev)) == -1)) {
printf("Can't work out which disk we are booting from.\n"
   "Guessed BIOS device 0x%x not found by probes, defaulting to 
disk0:\n", biosdev);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339404 - stable/11/sys/dev/cxgbe

2018-10-16 Thread Navdeep Parhar
Author: np
Date: Wed Oct 17 02:25:15 2018
New Revision: 339404
URL: https://svnweb.freebsd.org/changeset/base/339404

Log:
  MFC r336159:
  
  cxgbe(4): Add a sysctl to report the chip's microprocessor's load
  averages.  This works with debug or custom firmwares only.
  
  sysctl dev...loadavg
  sysctl dev.t6nex.0.loadavg

Modified:
  stable/11/sys/dev/cxgbe/t4_main.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/cxgbe/t4_main.c
==
--- stable/11/sys/dev/cxgbe/t4_main.c   Wed Oct 17 02:05:31 2018
(r339403)
+++ stable/11/sys/dev/cxgbe/t4_main.c   Wed Oct 17 02:25:15 2018
(r339404)
@@ -563,6 +563,7 @@ static int sysctl_autoneg(SYSCTL_HANDLER_ARGS);
 static int sysctl_handle_t4_reg64(SYSCTL_HANDLER_ARGS);
 static int sysctl_temperature(SYSCTL_HANDLER_ARGS);
 #ifdef SBUF_DRAIN
+static int sysctl_loadavg(SYSCTL_HANDLER_ARGS);
 static int sysctl_cctrl(SYSCTL_HANDLER_ARGS);
 static int sysctl_cim_ibq_obq(SYSCTL_HANDLER_ARGS);
 static int sysctl_cim_la(SYSCTL_HANDLER_ARGS);
@@ -5460,6 +5461,10 @@ t4_sysctls(struct adapter *sc)
CTLFLAG_RD, sc, 0, sysctl_temperature, "I",
"chip temperature (in Celsius)");
 
+   SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "loadavg", CTLTYPE_STRING |
+   CTLFLAG_RD, sc, 0, sysctl_loadavg, "A",
+   "microprocessor load averages (debug firmwares only)");
+
SYSCTL_ADD_INT(ctx, children, OID_AUTO, "core_vdd", CTLFLAG_RD,
>params.core_vdd, 0, "core Vdd (in mV)");
 
@@ -6516,6 +6521,45 @@ sysctl_temperature(SYSCTL_HANDLER_ARGS)
 }
 
 #ifdef SBUF_DRAIN
+static int
+sysctl_loadavg(SYSCTL_HANDLER_ARGS)
+{
+   struct adapter *sc = arg1;
+   struct sbuf *sb;
+   int rc;
+   uint32_t param, val;
+
+   rc = begin_synchronized_op(sc, NULL, SLEEP_OK | INTR_OK, "t4lavg");
+   if (rc)
+   return (rc);
+   param = V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) |
+   V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_LOAD);
+   rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, , );
+   end_synchronized_op(sc, 0);
+   if (rc)
+   return (rc);
+
+   rc = sysctl_wire_old_buffer(req, 0);
+   if (rc != 0)
+   return (rc);
+
+   sb = sbuf_new_for_sysctl(NULL, NULL, 4096, req);
+   if (sb == NULL)
+   return (ENOMEM);
+
+   if (val == 0x) {
+   /* Only debug and custom firmwares report load averages. */
+   sbuf_printf(sb, "not available");
+   } else {
+   sbuf_printf(sb, "%d %d %d", val & 0xff, (val >> 8) & 0xff,
+   (val >> 16) & 0xff);
+   }
+   rc = sbuf_finish(sb);
+   sbuf_delete(sb);
+
+   return (rc);
+}
+
 static int
 sysctl_cctrl(SYSCTL_HANDLER_ARGS)
 {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339403 - stable/11/sys/dev/cxgbe/common

2018-10-16 Thread Navdeep Parhar
Author: np
Date: Wed Oct 17 02:05:31 2018
New Revision: 339403
URL: https://svnweb.freebsd.org/changeset/base/339403

Log:
  MFC r335352:
  
  cxgbe(4): Some mailbox commands require access to the Tx pipeline and
  can time out if it's backed up due to a non-stop deluge of PAUSE frames
  from a misbehaving peer.  Detect this situation and toggle MPS TxEn
  to allow forward progress.

Modified:
  stable/11/sys/dev/cxgbe/common/t4_hw.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/cxgbe/common/t4_hw.c
==
--- stable/11/sys/dev/cxgbe/common/t4_hw.c  Wed Oct 17 01:59:45 2018
(r339402)
+++ stable/11/sys/dev/cxgbe/common/t4_hw.c  Wed Oct 17 02:05:31 2018
(r339403)
@@ -237,6 +237,63 @@ static void fw_asrt(struct adapter *adap, struct fw_de
  be32_to_cpu(asrt->u.assert.y));
 }
 
+struct port_tx_state {
+   uint64_t rx_pause;
+   uint64_t tx_frames;
+};
+
+static void
+read_tx_state_one(struct adapter *sc, int i, struct port_tx_state *tx_state)
+{
+   uint32_t rx_pause_reg, tx_frames_reg;
+
+   if (is_t4(sc)) {
+   tx_frames_reg = PORT_REG(i, A_MPS_PORT_STAT_TX_PORT_FRAMES_L);
+   rx_pause_reg = PORT_REG(i, A_MPS_PORT_STAT_RX_PORT_PAUSE_L);
+   } else {
+   tx_frames_reg = T5_PORT_REG(i, 
A_MPS_PORT_STAT_TX_PORT_FRAMES_L);
+   rx_pause_reg = T5_PORT_REG(i, A_MPS_PORT_STAT_RX_PORT_PAUSE_L);
+   }
+
+   tx_state->rx_pause = t4_read_reg64(sc, rx_pause_reg);
+   tx_state->tx_frames = t4_read_reg64(sc, tx_frames_reg);
+}
+
+static void
+read_tx_state(struct adapter *sc, struct port_tx_state *tx_state)
+{
+   int i;
+
+   for_each_port(sc, i)
+   read_tx_state_one(sc, i, _state[i]);
+}
+
+static void
+check_tx_state(struct adapter *sc, struct port_tx_state *tx_state)
+{
+   uint32_t port_ctl_reg;
+   uint64_t tx_frames, rx_pause;
+   int i;
+
+   for_each_port(sc, i) {
+   rx_pause = tx_state[i].rx_pause;
+   tx_frames = tx_state[i].tx_frames;
+   read_tx_state_one(sc, i, _state[i]); /* update */
+
+   if (is_t4(sc))
+   port_ctl_reg = PORT_REG(i, A_MPS_PORT_CTL);
+   else
+   port_ctl_reg = T5_PORT_REG(i, A_MPS_PORT_CTL);
+   if (t4_read_reg(sc, port_ctl_reg) & F_PORTTXEN &&
+   rx_pause != tx_state[i].rx_pause &&
+   tx_frames == tx_state[i].tx_frames) {
+   t4_set_reg_field(sc, port_ctl_reg, F_PORTTXEN, 0);
+   mdelay(1);
+   t4_set_reg_field(sc, port_ctl_reg, F_PORTTXEN, 
F_PORTTXEN);
+   }
+   }
+}
+
 #define X_CIM_PF_NOACCESS 0x
 /**
  * t4_wr_mbox_meat_timeout - send a command to FW through the given mailbox
@@ -278,13 +335,14 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int 
};
u32 v;
u64 res;
-   int i, ms, delay_idx, ret;
+   int i, ms, delay_idx, ret, next_tx_check;
const __be64 *p = cmd;
u32 data_reg = PF_REG(mbox, A_CIM_PF_MAILBOX_DATA);
u32 ctl_reg = PF_REG(mbox, A_CIM_PF_MAILBOX_CTRL);
u32 ctl;
__be64 cmd_rpl[MBOX_LEN/8];
u32 pcie_fw;
+   struct port_tx_state tx_state[MAX_NPORTS];
 
if (adap->flags & CHK_MBOX_ACCESS)
ASSERT_SYNCHRONIZED_OP(adap);
@@ -373,8 +431,8 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int 
CH_DUMP_MBOX(adap, mbox, data_reg);
 
t4_write_reg(adap, ctl_reg, F_MBMSGVALID | V_MBOWNER(X_MBOWNER_FW));
-   t4_read_reg(adap, ctl_reg); /* flush write */
-
+   read_tx_state(adap, _state[0]);  /* also flushes the write_reg */
+   next_tx_check = 1000;
delay_idx = 0;
ms = delay[0];
 
@@ -389,6 +447,12 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int 
if (pcie_fw & F_PCIE_FW_ERR)
break;
}
+
+   if (i >= next_tx_check) {
+   check_tx_state(adap, _state[0]);
+   next_tx_check = i + 1000;
+   }
+
if (sleep_ok) {
ms = delay[delay_idx];  /* last element may repeat */
if (delay_idx < ARRAY_SIZE(delay) - 1)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339402 - stable/11/sys/dev/cxgbe

2018-10-16 Thread Navdeep Parhar
Author: np
Date: Wed Oct 17 01:59:45 2018
New Revision: 339402
URL: https://svnweb.freebsd.org/changeset/base/339402

Log:
  MFC r334987:
  
  cxgbe(4): Remove homemade version of htobe32 from the driver.
  
  It was needed only for ia64 where it was implemented as a call to
  bswapXX, which was always a real function.  htobeXX with a constant
  argument is calculated at compile-time everywhere else.

Modified:
  stable/11/sys/dev/cxgbe/osdep.h
  stable/11/sys/dev/cxgbe/t4_main.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/cxgbe/osdep.h
==
--- stable/11/sys/dev/cxgbe/osdep.h Wed Oct 17 01:49:43 2018
(r339401)
+++ stable/11/sys/dev/cxgbe/osdep.h Wed Oct 17 01:59:45 2018
(r339402)
@@ -65,11 +65,8 @@ typedef uint64_t __be64;
 
 #if BYTE_ORDER == BIG_ENDIAN
 #define __BIG_ENDIAN_BITFIELD
-#define htobe32_const(x) (x)
 #elif BYTE_ORDER == LITTLE_ENDIAN
 #define __LITTLE_ENDIAN_BITFIELD
-#define htobe32_const(x) (((x) >> 24) | (((x) >> 8) & 0xff00) |\
-x) & 0xff) << 8) & 0xff) | x) & 0xff) << 24) & 0xff00))
 #else
 #error "Must set BYTE_ORDER"
 #endif

Modified: stable/11/sys/dev/cxgbe/t4_main.c
==
--- stable/11/sys/dev/cxgbe/t4_main.c   Wed Oct 17 01:49:43 2018
(r339401)
+++ stable/11/sys/dev/cxgbe/t4_main.c   Wed Oct 17 01:59:45 2018
(r339402)
@@ -3064,7 +3064,7 @@ struct fw_info {
.fw_mod_name = "t4fw",
.fw_hdr = {
.chip = FW_HDR_CHIP_T4,
-   .fw_ver = htobe32_const(FW_VERSION(T4)),
+   .fw_ver = htobe32(FW_VERSION(T4)),
.intfver_nic = FW_INTFVER(T4, NIC),
.intfver_vnic = FW_INTFVER(T4, VNIC),
.intfver_ofld = FW_INTFVER(T4, OFLD),
@@ -3080,7 +3080,7 @@ struct fw_info {
.fw_mod_name = "t5fw",
.fw_hdr = {
.chip = FW_HDR_CHIP_T5,
-   .fw_ver = htobe32_const(FW_VERSION(T5)),
+   .fw_ver = htobe32(FW_VERSION(T5)),
.intfver_nic = FW_INTFVER(T5, NIC),
.intfver_vnic = FW_INTFVER(T5, VNIC),
.intfver_ofld = FW_INTFVER(T5, OFLD),
@@ -3096,7 +3096,7 @@ struct fw_info {
.fw_mod_name = "t6fw",
.fw_hdr = {
.chip = FW_HDR_CHIP_T6,
-   .fw_ver = htobe32_const(FW_VERSION(T6)),
+   .fw_ver = htobe32(FW_VERSION(T6)),
.intfver_nic = FW_INTFVER(T6, NIC),
.intfver_vnic = FW_INTFVER(T6, VNIC),
.intfver_ofld = FW_INTFVER(T6, OFLD),
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339401 - stable/11/sys/dev/cxgbe/tom

2018-10-16 Thread Navdeep Parhar
Author: np
Date: Wed Oct 17 01:49:43 2018
New Revision: 339401
URL: https://svnweb.freebsd.org/changeset/base/339401

Log:
  MFC r320426:
  
  cxgbe/t4_tom: Do not include space taken by the TCP timestamp option in
  the "effective MSS" for the connection.  The chip expects it this way.

Modified:
  stable/11/sys/dev/cxgbe/tom/t4_cpl_io.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/cxgbe/tom/t4_cpl_io.c
==
--- stable/11/sys/dev/cxgbe/tom/t4_cpl_io.c Wed Oct 17 01:30:51 2018
(r339400)
+++ stable/11/sys/dev/cxgbe/tom/t4_cpl_io.c Wed Oct 17 01:49:43 2018
(r339401)
@@ -260,6 +260,8 @@ assign_rxopt(struct tcpcb *tp, unsigned int opt)
n = sizeof(struct ip6_hdr) + sizeof(struct tcphdr);
else
n = sizeof(struct ip) + sizeof(struct tcphdr);
+   if (V_tcp_do_rfc1323)
+   n += TCPOLEN_TSTAMP_APPA;
tp->t_maxseg = sc->params.mtus[G_TCPOPT_MSS(opt)] - n;
 
CTR4(KTR_CXGBE, "%s: tid %d, mtu_idx %u (%u)", __func__, toep->tid,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339400 - stable/11/sys/dev/cxgbe

2018-10-16 Thread Navdeep Parhar
Author: np
Date: Wed Oct 17 01:30:51 2018
New Revision: 339400
URL: https://svnweb.freebsd.org/changeset/base/339400

Log:
  MFC r338254:
  
  cxgbe(4): Use fcmpset instead of cmpset when appropriate.

Modified:
  stable/11/sys/dev/cxgbe/t4_mp_ring.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/cxgbe/t4_mp_ring.c
==
--- stable/11/sys/dev/cxgbe/t4_mp_ring.cWed Oct 17 01:20:18 2018
(r339399)
+++ stable/11/sys/dev/cxgbe/t4_mp_ring.cWed Oct 17 01:30:51 2018
(r339400)
@@ -122,11 +122,12 @@ drain_ring(struct mp_ring *r, union ring_state os, uin
n = r->drain(r, cidx, pidx);
if (n == 0) {
critical_enter();
+   os.state = r->state;
do {
-   os.state = ns.state = r->state;
+   ns.state = os.state;
ns.cidx = cidx;
ns.flags = STALLED;
-   } while (atomic_cmpset_64(>state, os.state,
+   } while (atomic_fcmpset_64(>state, ,
ns.state) == 0);
critical_exit();
if (prev != STALLED)
@@ -149,11 +150,12 @@ drain_ring(struct mp_ring *r, union ring_state os, uin
if (cidx != pidx && pending < 64 && total < budget)
continue;
critical_enter();
+   os.state = r->state;
do {
-   os.state = ns.state = r->state;
+   ns.state = os.state;
ns.cidx = cidx;
ns.flags = state_to_flags(ns, total >= budget);
-   } while (atomic_cmpset_acq_64(>state, os.state, ns.state) == 
0);
+   } while (atomic_fcmpset_acq_64(>state, , ns.state) 
== 0);
critical_exit();
 
if (ns.flags == ABDICATED)
@@ -259,8 +261,8 @@ mp_ring_enqueue(struct mp_ring *r, void **items, int n
 * Reserve room for the new items.  Our reservation, if successful, is
 * from 'pidx_start' to 'pidx_stop'.
 */
+   os.state = r->state;
for (;;) {
-   os.state = r->state;
if (n >= space_available(r, os)) {
counter_u64_add(r->drops, n);
MPASS(os.flags != IDLE);
@@ -271,7 +273,7 @@ mp_ring_enqueue(struct mp_ring *r, void **items, int n
ns.state = os.state;
ns.pidx_head = increment_idx(r, os.pidx_head, n);
critical_enter();
-   if (atomic_cmpset_64(>state, os.state, ns.state))
+   if (atomic_fcmpset_64(>state, , ns.state))
break;
critical_exit();
cpu_spinwait();
@@ -301,11 +303,12 @@ mp_ring_enqueue(struct mp_ring *r, void **items, int n
 * Update the ring's pidx_tail.  The release style atomic guarantees
 * that the items are visible to any thread that sees the updated pidx.
 */
+   os.state = r->state;
do {
-   os.state = ns.state = r->state;
+   ns.state = os.state;
ns.pidx_tail = pidx_stop;
ns.flags = BUSY;
-   } while (atomic_cmpset_rel_64(>state, os.state, ns.state) == 0);
+   } while (atomic_fcmpset_rel_64(>state, , ns.state) == 0);
critical_exit();
counter_u64_add(r->enqueues, n);
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339399 - in stable/11: share/man/man4 sys/dev/cxgbe sys/dev/cxgbe/common sys/dev/cxgbe/tom

2018-10-16 Thread Navdeep Parhar
Author: np
Date: Wed Oct 17 01:20:18 2018
New Revision: 339399
URL: https://svnweb.freebsd.org/changeset/base/339399

Log:
  MFC r338924:
  
  cxgbe(4): Link related changes.
  
  - Switch to using 32b port/link capabilities in the driver.  The 32b
format is used internally by firmwares > 1.16.45.0 and the driver will
now interact with the firmware in its native format, whether it's 16b
or 32b.  Note that the 16b format doesn't have room for 50G, 200G, or
400G speeds.
  
  - Add a bit in the pause_settings knobs to allow negotiated PAUSE
settings to override manual settings.
  
  - Ensure that manual link settings persist across an administrative
down/up as well as transceiver unplug/replug.
  
  - Remove unused is_*G_port() functions.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/11/share/man/man4/cxgbe.4
  stable/11/sys/dev/cxgbe/adapter.h
  stable/11/sys/dev/cxgbe/common/common.h
  stable/11/sys/dev/cxgbe/common/t4_hw.c
  stable/11/sys/dev/cxgbe/osdep.h
  stable/11/sys/dev/cxgbe/t4_main.c
  stable/11/sys/dev/cxgbe/tom/t4_cpl_io.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/share/man/man4/cxgbe.4
==
--- stable/11/share/man/man4/cxgbe.4Wed Oct 17 01:05:52 2018
(r339398)
+++ stable/11/share/man/man4/cxgbe.4Wed Oct 17 01:20:18 2018
(r339399)
@@ -31,7 +31,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 22, 2016
+.Dd Sep 24, 2018
 .Dt CXGBE 4
 .Os
 .Sh NAME
@@ -278,19 +278,21 @@ This usually results in the port emitting PAUSE frames
 1 instructs the hardware to drop frames destined for congested queues.
 .It Va hw.cxgbe.pause_settings
 PAUSE frame settings.
-Bit 0 is rx_pause, bit 1 is tx_pause.
+Bit 0 is rx_pause, bit 1 is tx_pause, bit 2 is pause_autoneg.
 rx_pause = 1 instructs the hardware to heed incoming PAUSE frames, 0 instructs
 it to ignore them.
 tx_pause = 1 allows the hardware to emit PAUSE frames when its receive FIFO
 reaches a high threshold, 0 prohibits the hardware from emitting PAUSE frames.
-The default is 3 (both rx_pause and tx_pause = 1).
+pause_autoneg = 1 overrides the rx_pause and tx_pause bits and instructs the
+hardware to negotiate PAUSE settings with the link peer.
+The default is 7 (all three = 1).
 This tunable establishes the default PAUSE settings for all ports.
 Settings can be displayed and controlled on a per-port basis via the
 dev..X.pause_settings sysctl.
 .It Va hw.cxgbe.fec
 FEC (Forward Error Correction) settings.
 0 diables FEC.
-Bit 0 enables RS FEC, bit 1 enables BASE-R RS, bit 3 is reserved.
+Bit 0 enables RS FEC, bit 1 enables BASE-R FEC (aka Firecode FEC).
 The default is -1 which lets the driver pick a value.
 This tunable establishes the default FEC settings for all ports.
 Settings can be displayed and controlled on a per-port basis via the

Modified: stable/11/sys/dev/cxgbe/adapter.h
==
--- stable/11/sys/dev/cxgbe/adapter.h   Wed Oct 17 01:05:52 2018
(r339398)
+++ stable/11/sys/dev/cxgbe/adapter.h   Wed Oct 17 01:20:18 2018
(r339399)
@@ -289,7 +289,6 @@ struct port_info {
uint8_t  rx_e_chan_map; /* rx TP e-channel bitmap */
 
struct link_config link_cfg;
-   struct link_config old_link_cfg;
struct ifmedia media;
 
struct timeval last_refreshed;
@@ -1050,52 +1049,6 @@ t4_os_set_hw_addr(struct port_info *pi, uint8_t hw_add
 {
 
bcopy(hw_addr, pi->vi[0].hw_addr, ETHER_ADDR_LEN);
-}
-
-static inline bool
-is_10G_port(const struct port_info *pi)
-{
-
-   return ((pi->link_cfg.supported & FW_PORT_CAP_SPEED_10G) != 0);
-}
-
-static inline bool
-is_25G_port(const struct port_info *pi)
-{
-
-   return ((pi->link_cfg.supported & FW_PORT_CAP_SPEED_25G) != 0);
-}
-
-static inline bool
-is_40G_port(const struct port_info *pi)
-{
-
-   return ((pi->link_cfg.supported & FW_PORT_CAP_SPEED_40G) != 0);
-}
-
-static inline bool
-is_100G_port(const struct port_info *pi)
-{
-
-   return ((pi->link_cfg.supported & FW_PORT_CAP_SPEED_100G) != 0);
-}
-
-static inline int
-port_top_speed(const struct port_info *pi)
-{
-
-   if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_100G)
-   return (100);
-   if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_40G)
-   return (40);
-   if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_25G)
-   return (25);
-   if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_10G)
-   return (10);
-   if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_1G)
-   return (1);
-
-   return (0);
 }
 
 static inline int

Modified: stable/11/sys/dev/cxgbe/common/common.h
==
--- stable/11/sys/dev/cxgbe/common/common.h Wed Oct 17 01:05:52 2018
(r339398)
+++ stable/11/sys/dev/cxgbe/common/common.h Wed 

svn commit: r339398 - stable/11/sys/dev/cxgbe/common

2018-10-16 Thread Navdeep Parhar
Author: np
Date: Wed Oct 17 01:05:52 2018
New Revision: 339398
URL: https://svnweb.freebsd.org/changeset/base/339398

Log:
  MFC r336042:
  
  cxgbe(4): Assume that any unknown flash on the card is 4MB and has 64KB
  sectors, instead of refusing to attach to the card.
  
  Submitted by: Casey Leedom @ Chelsio
  Sponsored by: Chelsio Communications

Modified:
  stable/11/sys/dev/cxgbe/common/t4_hw.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/cxgbe/common/t4_hw.c
==
--- stable/11/sys/dev/cxgbe/common/t4_hw.c  Wed Oct 17 00:57:28 2018
(r339397)
+++ stable/11/sys/dev/cxgbe/common/t4_hw.c  Wed Oct 17 01:05:52 2018
(r339398)
@@ -7844,7 +7844,7 @@ int t4_get_flash_params(struct adapter *adapter)
int ret;
u32 flashid = 0;
unsigned int part, manufacturer;
-   unsigned int density, size;
+   unsigned int density, size = 0;
 
 
/*
@@ -7883,7 +7883,7 @@ int t4_get_flash_params(struct adapter *adapter)
 */
manufacturer = flashid & 0xff;
switch (manufacturer) {
-   case 0x20: { /* Micron/Numonix */
+   case 0x20: /* Micron/Numonix */
/*
 * This Density -> Size decoding table is taken from Micron
 * Data Sheets.
@@ -7899,17 +7899,10 @@ int t4_get_flash_params(struct adapter *adapter)
case 0x20: size = 1 << 26; break; /*  64MB */
case 0x21: size = 1 << 27; break; /* 128MB */
case 0x22: size = 1 << 28; break; /* 256MB */
-
-   default:
-   CH_ERR(adapter, "Micron Flash Part has bad size, "
-  "ID = %#x, Density code = %#x\n",
-  flashid, density);
-   return -EINVAL;
}
break;
-   }
 
-   case 0x9d: { /* ISSI -- Integrated Silicon Solution, Inc. */
+   case 0x9d: /* ISSI -- Integrated Silicon Solution, Inc. */
/*
 * This Density -> Size decoding table is taken from ISSI
 * Data Sheets.
@@ -7918,17 +7911,10 @@ int t4_get_flash_params(struct adapter *adapter)
switch (density) {
case 0x16: size = 1 << 25; break; /*  32MB */
case 0x17: size = 1 << 26; break; /*  64MB */
-
-   default:
-   CH_ERR(adapter, "ISSI Flash Part has bad size, "
-  "ID = %#x, Density code = %#x\n",
-  flashid, density);
-   return -EINVAL;
}
break;
-   }
 
-   case 0xc2: { /* Macronix */
+   case 0xc2: /* Macronix */
/*
 * This Density -> Size decoding table is taken from Macronix
 * Data Sheets.
@@ -7937,17 +7923,10 @@ int t4_get_flash_params(struct adapter *adapter)
switch (density) {
case 0x17: size = 1 << 23; break; /*   8MB */
case 0x18: size = 1 << 24; break; /*  16MB */
-
-   default:
-   CH_ERR(adapter, "Macronix Flash Part has bad size, "
-  "ID = %#x, Density code = %#x\n",
-  flashid, density);
-   return -EINVAL;
}
break;
-   }
 
-   case 0xef: { /* Winbond */
+   case 0xef: /* Winbond */
/*
 * This Density -> Size decoding table is taken from Winbond
 * Data Sheets.
@@ -7956,19 +7935,19 @@ int t4_get_flash_params(struct adapter *adapter)
switch (density) {
case 0x17: size = 1 << 23; break; /*   8MB */
case 0x18: size = 1 << 24; break; /*  16MB */
-
-   default:
-   CH_ERR(adapter, "Winbond Flash Part has bad size, "
-  "ID = %#x, Density code = %#x\n",
-  flashid, density);
-   return -EINVAL;
}
break;
}
 
-   default:
-   CH_ERR(adapter, "Unsupported Flash Part, ID = %#x\n", flashid);
-   return -EINVAL;
+   /* If we didn't recognize the FLASH part, that's no real issue: the
+* Hardware/Software contract says that Hardware will _*ALWAYS*_
+* use a FLASH part which is at least 4MB in size and has 64KB
+* sectors.  The unrecognized FLASH part is likely to be much larger
+* than 4MB, but that's all we really need.
+*/
+   if (size == 0) {
+   CH_WARN(adapter, "Unknown Flash Part, ID = %#x, assuming 
4MB\n", flashid);
+   size = 1 << 22;
}
 
/*
___
svn-src-all@freebsd.org mailing list

svn commit: r339397 - stable/11/sys/dev/cxgbe

2018-10-16 Thread Navdeep Parhar
Author: np
Date: Wed Oct 17 00:57:28 2018
New Revision: 339397
URL: https://svnweb.freebsd.org/changeset/base/339397

Log:
  MFC r333139:
  
  cxgbe(4): Destroy the cdev before disabling interrupts in driver detach.
  
  Filter work requests are submitted in the nexus cdev's ioctl which then
  blocks waiting for a reply.  If driver detach runs in this state and
  disables interrupts the ioctl will never complete and detach will hang
  in destroy_cdev.

Modified:
  stable/11/sys/dev/cxgbe/t4_main.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/cxgbe/t4_main.c
==
--- stable/11/sys/dev/cxgbe/t4_main.c   Wed Oct 17 00:45:01 2018
(r339396)
+++ stable/11/sys/dev/cxgbe/t4_main.c   Wed Oct 17 00:57:28 2018
(r339397)
@@ -1308,15 +1308,15 @@ t4_detach_common(device_t dev)
 
sc = device_get_softc(dev);
 
+   if (sc->cdev) {
+   destroy_dev(sc->cdev);
+   sc->cdev = NULL;
+   }
+
sc->flags &= ~CHK_MBOX_ACCESS;
if (sc->flags & FULL_INIT_DONE) {
if (!(sc->flags & IS_VF))
t4_intr_disable(sc);
-   }
-
-   if (sc->cdev) {
-   destroy_dev(sc->cdev);
-   sc->cdev = NULL;
}
 
if (device_is_attached(dev)) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339396 - stable/11/sys/dev/cxgbe

2018-10-16 Thread Navdeep Parhar
Author: np
Date: Wed Oct 17 00:45:01 2018
New Revision: 339396
URL: https://svnweb.freebsd.org/changeset/base/339396

Log:
  MFC r325840, r327811, and r329701.
  
  r325840:
  CXGBE: fix big-endian behaviour
  
  The setbit/clearbit pair casts the bitfield pointer
  to uint8_t* which effectively treats its contents as
  little-endian variable. The ffs() function accepts int as
  the parameter, which is big-endian. Use uint8_t here to
  avoid mismatch, as we have only 4 doorbells.
  
  Submitted by:  Wojciech Macek 
  Reviewed by:   np
  Obtained from: Semihalf
  Sponsored by:  QCM Technologies
  Differential revision: https://reviews.freebsd.org/D13084
  
  r327811:
  CXGBE: fix get_filt to be endianness-aware
  
  Unconditional 32-bit shift is not endianness-safe.
  Modify the logic to work both on LE and BE.
  
  Submitted by:  Wojciech Macek 
  Reviewed by:   np
  Obtained from: Semihalf
  Sponsored by:  IBM, QCM Technologies
  Differential revision: https://reviews.freebsd.org/D13102
  
  r329701:
  CXGBE: implement prefetch on non-Intel architectures
  
  Submitted by:  Michal Stanek 
  Obtained from: Semihalf
  Reviewed by:   np, p...@semihalf.com
  Sponsored by:  IBM, QCM Technologies
  Differential revision: https://reviews.freebsd.org/D14452

Modified:
  stable/11/sys/dev/cxgbe/adapter.h
  stable/11/sys/dev/cxgbe/t4_sge.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/cxgbe/adapter.h
==
--- stable/11/sys/dev/cxgbe/adapter.h   Wed Oct 17 00:27:21 2018
(r339395)
+++ stable/11/sys/dev/cxgbe/adapter.h   Wed Oct 17 00:45:01 2018
(r339396)
@@ -70,7 +70,7 @@ prefetch(void *x)
__asm volatile("prefetcht0 %0" :: "m" (*(unsigned long *)x));
 }
 #else
-#define prefetch(x)
+#define prefetch(x) __builtin_prefetch(x)
 #endif
 
 #ifndef SYSCTL_ADD_UQUAD
@@ -422,7 +422,7 @@ struct sge_eq {
struct mtx eq_lock;
 
struct tx_desc *desc;   /* KVA of descriptor ring */
-   uint16_t doorbells;
+   uint8_t doorbells;
volatile uint32_t *udb; /* KVA of doorbell (lies within BAR2) */
u_int udb_qid;  /* relative qid within the doorbell page */
uint16_t sidx;  /* index of the entry with the status page */
@@ -692,7 +692,7 @@ struct sge_nm_txq {
uint16_t equiqidx;  /* EQUIQ last requested at this pidx */
uint16_t equeqidx;  /* EQUEQ last requested at this pidx */
uint16_t dbidx; /* pidx of the most recent doorbell */
-   uint16_t doorbells;
+   uint8_t doorbells;
volatile uint32_t *udb;
u_int udb_qid;
u_int cntxt_id;
@@ -804,7 +804,7 @@ struct adapter {
struct l2t_data *l2t;   /* L2 table */
struct tid_info tids;
 
-   uint16_t doorbells;
+   uint8_t doorbells;
int offload_map;/* ports with IFCAP_TOE enabled */
int active_ulds;/* ULDs activated on this adapter */
int flags;

Modified: stable/11/sys/dev/cxgbe/t4_sge.c
==
--- stable/11/sys/dev/cxgbe/t4_sge.cWed Oct 17 00:27:21 2018
(r339395)
+++ stable/11/sys/dev/cxgbe/t4_sge.cWed Oct 17 00:45:01 2018
(r339396)
@@ -4731,13 +4731,13 @@ get_flit(struct sglist_seg *segs, int nsegs, int idx)
 
switch (idx % 3) {
case 0: {
-   __be64 rc;
+   uint64_t rc;
 
-   rc = htobe32(segs[i].ss_len);
+   rc = (uint64_t)segs[i].ss_len << 32;
if (i + 1 < nsegs)
-   rc |= (uint64_t)htobe32(segs[i + 1].ss_len) << 32;
+   rc |= (uint64_t)(segs[i + 1].ss_len);
 
-   return (rc);
+   return (htobe64(rc));
}
case 1:
return (htobe64(segs[i].ss_paddr));
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339395 - stable/11/sys/dev/cxgbe/iw_cxgbe

2018-10-16 Thread Navdeep Parhar
Author: np
Date: Wed Oct 17 00:27:21 2018
New Revision: 339395
URL: https://svnweb.freebsd.org/changeset/base/339395

Log:
  MFC r320419, r337679, r338366, and r338652.
  
  r320419:
  cxgbe/iw_cxgbe: Disable debug output by default.  The help text for the sysctl
  already says that the default is 0.
  
  r337679:
  Remove unused stuff from iw_cxgbe.h
  
  r338366:
  cxgbe/iw_cxgbe: Fix iWARP RDMA + VIMAGE operation by setting the VNET
  properly in a couple of places in the driver.
  
  r338652:
  cxgbe/iw_cxgbe: Fix reported build breakage when the kernel
  configuration has "device cxgbe' but no VIMAGE.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/11/sys/dev/cxgbe/iw_cxgbe/cm.c
  stable/11/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/cxgbe/iw_cxgbe/cm.c
==
--- stable/11/sys/dev/cxgbe/iw_cxgbe/cm.c   Tue Oct 16 22:13:05 2018
(r339394)
+++ stable/11/sys/dev/cxgbe/iw_cxgbe/cm.c   Wed Oct 17 00:27:21 2018
(r339395)
@@ -74,6 +74,7 @@ struct cpl_set_tcb_rpl;
 #include 
 #include 
 #include 
+#include 
 
 static spinlock_t req_lock;
 static TAILQ_HEAD(c4iw_ep_list, c4iw_ep_common) req_list;
@@ -1195,7 +1196,7 @@ static int enable_tcp_window_scaling = 1;
 SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_window_scaling, CTLFLAG_RWTUN, 
_tcp_window_scaling, 0,
"Enable tcp window scaling (default = 1)");
 
-int c4iw_debug = 1;
+int c4iw_debug = 0;
 SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, c4iw_debug, CTLFLAG_RWTUN, _debug, 0,
"Enable debug logging (default = 0)");
 
@@ -2514,6 +2515,10 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_
struct c4iw_dev *dev = to_c4iw_dev(cm_id->device);
struct c4iw_ep *ep = NULL;
struct ifnet*nh_ifp;/* Logical egress interface */
+#ifdef VIMAGE
+   struct rdma_cm_id *rdma_id = (struct rdma_cm_id*)cm_id->context;
+   struct vnet *vnet = rdma_id->route.addr.dev_addr.net;
+#endif
 
CTR2(KTR_IW_CXGBE, "%s:ccB %p", __func__, cm_id);
 
@@ -2559,7 +2564,10 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_
ref_qp(ep);
ep->com.thread = curthread;
 
+   CURVNET_SET(vnet);
err = get_ifnet_from_raddr(_id->remote_addr, _ifp);
+   CURVNET_RESTORE();
+
if (err) {
 
CTR2(KTR_IW_CXGBE, "%s:cc7 %p", __func__, ep);
@@ -2802,7 +2810,10 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt,
 
if (!ep->parent_ep)
ep->com.state = MORIBUND;
+
+   CURVNET_SET(ep->com.so->so_vnet);
sodisconnect(ep->com.so);
+   CURVNET_RESTORE();
}
 
}

Modified: stable/11/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h
==
--- stable/11/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h Tue Oct 16 22:13:05 2018
(r339394)
+++ stable/11/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h Wed Oct 17 00:27:21 2018
(r339395)
@@ -976,20 +976,4 @@ u32 c4iw_get_qpid(struct c4iw_rdev *rdev, struct c4iw_
 void c4iw_put_qpid(struct c4iw_rdev *rdev, u32 qid,
struct c4iw_dev_ucontext *uctx);
 void c4iw_ev_dispatch(struct c4iw_dev *dev, struct t4_cqe *err_cqe);
-void __iomem *c4iw_bar2_addrs(struct c4iw_rdev *rdev, unsigned int qid,
-   enum t4_bar2_qtype qtype,
-   unsigned int *pbar2_qid, u64 *pbar2_pa);
-extern struct cxgb4_client t4c_client;
-extern c4iw_handler_func c4iw_handlers[NUM_CPL_CMDS];
-
-#if defined(__i386__) || defined(__amd64__)
-#define L1_CACHE_BYTES 128
-#else
-#define L1_CACHE_BYTES 32
-#endif
-
-void your_reg_device(struct c4iw_dev *dev);
-
-#define SGE_CTRLQ_NUM  0
-
 #endif
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339394 - stable/11/usr.sbin/cxgbetool

2018-10-16 Thread Navdeep Parhar
Author: np
Date: Tue Oct 16 22:13:05 2018
New Revision: 339394
URL: https://svnweb.freebsd.org/changeset/base/339394

Log:
  MFC r332515:
  Fix typo in cxgbetool.8.

Modified:
  stable/11/usr.sbin/cxgbetool/cxgbetool.8
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/cxgbetool/cxgbetool.8
==
--- stable/11/usr.sbin/cxgbetool/cxgbetool.8Tue Oct 16 22:09:33 2018
(r339393)
+++ stable/11/usr.sbin/cxgbetool/cxgbetool.8Tue Oct 16 22:13:05 2018
(r339394)
@@ -420,7 +420,7 @@ Class Rate Limiting.
 .It Sy cl-wrr
 Class Weighted Round Robin.
 .Pp
-.It Sy cl-wrr
+.It Sy ch-rl
 Channel Rate Limiting.
 .El
 .It Sy mode Ar scheduler-mode
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339393 - stable/11/usr.sbin/cxgbetool

2018-10-16 Thread Navdeep Parhar
Author: np
Date: Tue Oct 16 22:09:33 2018
New Revision: 339393
URL: https://svnweb.freebsd.org/changeset/base/339393

Log:
  MFC r330887:
  cxgbetool(8): Add the ability to decode hardware TCBs.
  
  Sponsored by: Chelsio Communications

Added:
  stable/11/usr.sbin/cxgbetool/tcb_common.c
 - copied unchanged from r330887, head/usr.sbin/cxgbetool/tcb_common.c
  stable/11/usr.sbin/cxgbetool/tcb_common.h
 - copied unchanged from r330887, head/usr.sbin/cxgbetool/tcb_common.h
  stable/11/usr.sbin/cxgbetool/tcbinfot4.c
 - copied unchanged from r330887, head/usr.sbin/cxgbetool/tcbinfot4.c
  stable/11/usr.sbin/cxgbetool/tcbinfot5.c
 - copied unchanged from r330887, head/usr.sbin/cxgbetool/tcbinfot5.c
  stable/11/usr.sbin/cxgbetool/tcbinfot6.c
 - copied unchanged from r330887, head/usr.sbin/cxgbetool/tcbinfot6.c
  stable/11/usr.sbin/cxgbetool/tcbshowt4.c
 - copied unchanged from r330887, head/usr.sbin/cxgbetool/tcbshowt4.c
  stable/11/usr.sbin/cxgbetool/tcbshowt5.c
 - copied unchanged from r330887, head/usr.sbin/cxgbetool/tcbshowt5.c
  stable/11/usr.sbin/cxgbetool/tcbshowt6.c
 - copied unchanged from r330887, head/usr.sbin/cxgbetool/tcbshowt6.c
Modified:
  stable/11/usr.sbin/cxgbetool/Makefile
  stable/11/usr.sbin/cxgbetool/cxgbetool.c
Directory Properties:
  stable/11/   (props changed)
  stable/11/usr.sbin/cxgbetool/reg_defs_t5.c   (props changed)
  stable/11/usr.sbin/cxgbetool/reg_defs_t6.c   (props changed)

Modified: stable/11/usr.sbin/cxgbetool/Makefile
==
--- stable/11/usr.sbin/cxgbetool/Makefile   Tue Oct 16 20:53:16 2018
(r339392)
+++ stable/11/usr.sbin/cxgbetool/Makefile   Tue Oct 16 22:09:33 2018
(r339393)
@@ -2,6 +2,11 @@
 
 PROG=  cxgbetool
 MAN=   cxgbetool.8
+SRCS=  cxgbetool.c
+SRCS+= tcb_common.c
+SRCS+= tcbinfot4.c tcbshowt4.c
+SRCS+= tcbinfot5.c tcbshowt5.c
+SRCS+= tcbinfot6.c tcbshowt6.c
 CFLAGS+= -I${SRCTOP}/sys/dev/cxgbe -I${SRCTOP}/sys -I.
 WARNS?= 2
 

Modified: stable/11/usr.sbin/cxgbetool/cxgbetool.c
==
--- stable/11/usr.sbin/cxgbetool/cxgbetool.cTue Oct 16 20:53:16 2018
(r339392)
+++ stable/11/usr.sbin/cxgbetool/cxgbetool.cTue Oct 16 22:09:33 2018
(r339393)
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include "t4_ioctl.h"
+#include "tcb_common.h"
 
 #define in_range(val, lo, hi) ( val < 0 || (val <= hi && val >= lo))
 #definemax(x, y) ((x) > (y) ? (x) : (y))
@@ -2102,6 +2103,7 @@ memdump(int argc, const char *argv[])
 static void
 show_tcb(uint32_t *buf, uint32_t len)
 {
+   unsigned char *tcb = (unsigned char *)buf;
const char *s;
int i, n = 8;
 
@@ -2112,6 +2114,10 @@ show_tcb(uint32_t *buf, uint32_t len)
}
printf("\n");
}
+   set_tcb_info(TIDTYPE_TCB, chip_id);
+   set_print_style(PRNTSTYL_COMP);
+   swizzle_tcb(tcb);
+   parse_n_display_xcb(tcb);
 }
 
 #define A_TP_CMM_TCB_BASE 0x7d10

Copied: stable/11/usr.sbin/cxgbetool/tcb_common.c (from r330887, 
head/usr.sbin/cxgbetool/tcb_common.c)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/11/usr.sbin/cxgbetool/tcb_common.c   Tue Oct 16 22:09:33 2018
(r339393, copy of r330887, head/usr.sbin/cxgbetool/tcb_common.c)
@@ -0,0 +1,703 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018 Chelsio Communications, Inc.
+ * 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 

svn commit: r339392 - stable/11/usr.bin/vmstat

2018-10-16 Thread John Baldwin
Author: jhb
Date: Tue Oct 16 20:53:16 2018
New Revision: 339392
URL: https://svnweb.freebsd.org/changeset/base/339392

Log:
  MFC 326138,326436,326852: Style fixes to kdump.
  
  326138:
  Use C standard spelling uint64_t for u_int64_t.
  
  326436:
  vmstat: fix style(9) violations and bump WARNS.
  
  326852:
  Re-add spaces lost in r326436.

Modified:
  stable/11/usr.bin/vmstat/Makefile
  stable/11/usr.bin/vmstat/vmstat.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/vmstat/Makefile
==
--- stable/11/usr.bin/vmstat/Makefile   Tue Oct 16 20:12:35 2018
(r339391)
+++ stable/11/usr.bin/vmstat/Makefile   Tue Oct 16 20:53:16 2018
(r339392)
@@ -5,6 +5,6 @@ PROG=   vmstat
 MAN=   vmstat.8
 LIBADD=devstat kvm memstat xo util
 
-WARNS?=1
+WARNS?=6
 
 .include 

Modified: stable/11/usr.bin/vmstat/vmstat.c
==
--- stable/11/usr.bin/vmstat/vmstat.c   Tue Oct 16 20:12:35 2018
(r339391)
+++ stable/11/usr.bin/vmstat/vmstat.c   Tue Oct 16 20:53:16 2018
(r339392)
@@ -82,55 +82,43 @@ __FBSDID("$FreeBSD$");
 
 static char da[] = "da";
 
+enum x_stats { X_SUM, X_HZ, X_STATHZ, X_NCHSTATS, X_INTRNAMES, X_SINTRNAMES,
+X_INTRCNT, X_SINTRCNT, X_DEFICIT, X_REC, X_PGIN, X_XSTATS };
+
 static struct nlist namelist[] = {
-#define X_SUM  0
-   { "_vm_cnt" },
-#define X_HZ   1
-   { "_hz" },
-#define X_STATHZ   2
-   { "_stathz" },
-#define X_NCHSTATS 3
-   { "_nchstats" },
-#defineX_INTRNAMES 4
-   { "_intrnames" },
-#defineX_SINTRNAMES5
-   { "_sintrnames" },
-#defineX_INTRCNT   6
-   { "_intrcnt" },
-#defineX_SINTRCNT  7
-   { "_sintrcnt" },
+   [X_SUM] = { .n_name = "_vm_cnt", },
+   [X_HZ] = { .n_name = "_hz", },
+   [X_STATHZ] = { .n_name = "_stathz", },
+   [X_NCHSTATS] = { .n_name = "_nchstats", },
+   [X_INTRNAMES] = { .n_name = "_intrnames", },
+   [X_SINTRNAMES] = { .n_name = "_sintrnames", },
+   [X_INTRCNT] = { .n_name = "_intrcnt", },
+   [X_SINTRCNT] = { .n_name = "_sintrcnt", },
 #ifdef notyet
-#defineX_DEFICIT   XXX
-   { "_deficit" },
-#define X_REC  XXX
-   { "_rectime" },
-#define X_PGIN XXX
-   { "_pgintime" },
-#defineX_XSTATSXXX
-   { "_xstats" },
-#define X_END  XXX
-#else
-#define X_END  8
+   [X_DEFICIT] = { .n_name = "_deficit", },
+   [X_REC] = { .n_name = "_rectime", },
+   [X_PGIN] = { .n_name = "_pgintime", },
+   [X_XSTATS] = { .n_name = "_xstats", },
 #endif
-   { "" },
+   { .n_name = NULL, },
 };
 
-static struct statinfo cur, last;
-static int num_devices, maxshowdevs;
-static long generation;
-static struct device_selection *dev_select;
-static int num_selected;
 static struct devstat_match *matches;
-static int num_matches = 0;
-static int num_devices_specified, num_selections;
-static long select_generation;
-static char **specified_devices;
+static struct device_selection *dev_select;
+static struct statinfo cur, last;
 static devstat_select_mode select_mode;
+static size_t size_cp_times;
+static long *cur_cp_times, *last_cp_times;
+static long generation, select_generation;
+static int hz, hdrcnt, maxshowdevs;
+static int num_devices, num_devices_specified;
+static int num_matches, num_selected, num_selections;
+static char **specified_devices;
 
 static struct  vmmeter sum, osum;
 
 #defineVMSTAT_DEFAULT_LINES20  /* Default number of 
`winlines'. */
-volatile sig_atomic_t wresized;/* Tty resized, when non-zero. 
*/
+static volatile sig_atomic_t wresized; /* Tty resized when non-zero. */
 static int winlines = VMSTAT_DEFAULT_LINES; /* Current number of tty rows. */
 
 static int aflag;
@@ -138,7 +126,7 @@ static int  nflag;
 static int Pflag;
 static int hflag;
 
-static kvm_t   *kd;
+static kvm_t   *kd;
 
 #defineFORKSTAT0x01
 #defineINTRSTAT0x02
@@ -146,11 +134,11 @@ static kvm_t   *kd;
 #defineSUMSTAT 0x08
 #defineTIMESTAT0x10
 #defineVMSTAT  0x20
-#define ZMEMSTAT   0x40
+#defineZMEMSTAT0x40
 #defineOBJSTAT 0x80
 
 static voidcpustats(void);
-static voidpcpustats(int, u_long, int);
+static voidpcpustats(u_long, int);
 static voiddevstats(void);
 static voiddoforkst(void);
 static voiddointr(unsigned int, int);
@@ -161,7 +149,6 @@ static void domemstat_malloc(void);
 static voiddomemstat_zone(void);
 static voidkread(int, void *, size_t);
 static voidkreado(int, void *, size_t, size_t);
-static char*kgetstr(const char *);
 static voidneedhdr(int);
 static voidneedresize(int);
 static void

Re: svn commit: r339386 - in head/sys/amd64: amd64 include

2018-10-16 Thread Oliver Pinter
On 10/16/18, Konstantin Belousov  wrote:
> Author: kib
> Date: Tue Oct 16 17:28:10 2018
> New Revision: 339386
> URL: https://svnweb.freebsd.org/changeset/base/339386
>
> Log:
>   Provide pmap_large_map() KPI on amd64.
>
>   The KPI allows to map very large contigous physical memory regions
>   into KVA, which are not covered by DMAP.
>
>   I see both with QEMU and with some real hardware started shipping, the
>   regions for NVDIMMs might be very far apart from the normal RAM, and
>   we expect that at least initial users of NVDIMM could install very
>   large amount of such memory.  IMO it is not reasonable to extend DMAP
>   to cover that far-away regions both because it could overflow existing
>   4T window for DMAP in KVA, and because it costs in page table pages
>   allocations, for gap and for possibly unused NV RAM.
>
>   Also, KPI provides some special functionality for fast cache flushing
>   based on the knowledge of the NVRAM mapping use.
>
>   Reviewed by:alc, markj
>   Sponsored by:   The FreeBSD Foundation
>   Approved by:re (gjb)
>   MFC after:  1 week
>   Differential revision:  https://reviews.freebsd.org/D17070
>
> Modified:
>   head/sys/amd64/amd64/pmap.c
>   head/sys/amd64/include/pmap.h
>   head/sys/amd64/include/vmparam.h
>
> Modified: head/sys/amd64/amd64/pmap.c
> ==
> --- head/sys/amd64/amd64/pmap.c   Tue Oct 16 17:17:11 2018
> (r339385)
> +++ head/sys/amd64/amd64/pmap.c   Tue Oct 16 17:28:10 2018
> (r339386)
> @@ -409,6 +409,9 @@ static struct mtx qframe_mtx;
>
>  static int pmap_flags = PMAP_PDE_SUPERPAGE;  /* flags for x86 pmaps */
>
> +static vmem_t *large_vmem;
> +static u_int lm_ents;
> +
>  int pmap_pcid_enabled = 1;
>  SYSCTL_INT(_vm_pmap, OID_AUTO, pcid_enabled, CTLFLAG_RDTUN |
> CTLFLAG_NOFETCH,
>  _pcid_enabled, 0, "Is TLB Context ID enabled ?");
> @@ -655,6 +658,7 @@ static void pmap_invalidate_cache_range_all(vm_offset_
>  static void pmap_invalidate_pde_page(pmap_t pmap, vm_offset_t va,
>   pd_entry_t pde);
>  static void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, int mode);
> +static vm_page_t pmap_large_map_getptp_unlocked(void);
>  static void pmap_pde_attr(pd_entry_t *pde, int cache_bits, int mask);
>  #if VM_NRESERVLEVEL > 0
>  static void pmap_promote_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t va,
> @@ -1313,7 +1317,7 @@ void
>  pmap_init(void)
>  {
>   struct pmap_preinit_mapping *ppim;
> - vm_page_t mpte;
> + vm_page_t m, mpte;
>   vm_size_t s;
>   int error, i, pv_npg, ret, skz63;
>
> @@ -1440,6 +1444,28 @@ pmap_init(void)
>   (vmem_addr_t *));
>   if (error != 0)
>   panic("qframe allocation failed");
> +
> + lm_ents = 8;
> + TUNABLE_INT_FETCH("vm.pmap.large_map_pml4_entries", _ents);
> + if (lm_ents > LMEPML4I - LMSPML4I + 1)
> + lm_ents = LMEPML4I - LMSPML4I + 1;
> + if (bootverbose)
> + printf("pmap: large map %u PML4 slots (%lu Gb)\n",

Isn't this GB (GigaByte instead of Gigabit?)

> + lm_ents, (u_long)lm_ents * (NBPML4 / 1024 / 1024 / 1024));
> + if (lm_ents != 0) {
> + large_vmem = vmem_create("large", LARGEMAP_MIN_ADDRESS,
> + (vmem_size_t)lm_ents * NBPML4, PAGE_SIZE, 0, M_WAITOK);
> + if (large_vmem == NULL) {
> + printf("pmap: cannot create large map\n");
> + lm_ents = 0;
> + }
> + for (i = 0; i < lm_ents; i++) {
> + m = pmap_large_map_getptp_unlocked();
> + kernel_pmap->pm_pml4[LMSPML4I + i] = X86_PG_V |
> + X86_PG_RW | X86_PG_A | X86_PG_M | pg_nx |
> + VM_PAGE_TO_PHYS(m);
> + }
> + }
>  }
>
>  static SYSCTL_NODE(_vm_pmap, OID_AUTO, pde, CTLFLAG_RD, 0,
> @@ -2315,14 +2341,6 @@ pmap_force_invalidate_cache_range(vm_offset_t sva,
> vm_
>  {
>
>   sva &= ~(vm_offset_t)(cpu_clflush_line_size - 1);
> - if (eva - sva >= PMAP_CLFLUSH_THRESHOLD) {
> - /*
> -  * The supplied range is bigger than 2MB.
> -  * Globally invalidate cache.
> -  */
> - pmap_invalidate_cache();
> - return;
> - }
>
>   /*
>* XXX: Some CPUs fault, hang, or trash the local APIC
> @@ -2406,6 +2424,64 @@ pmap_invalidate_cache_pages(vm_page_t *pages, int
> coun
>   }
>  }
>
> +void
> +pmap_flush_cache_range(vm_offset_t sva, vm_offset_t eva)
> +{
> +
> + pmap_invalidate_cache_range_check_align(sva, eva);
> +
> + if ((cpu_stdext_feature & CPUID_STDEXT_CLWB) == 0) {
> + pmap_force_invalidate_cache_range(sva, eva);
> + return;
> + }
> +
> + /* See comment in pmap_force_invalidate_cache_range(). */
> + if (pmap_kextract(sva) == lapic_paddr)
> + return;
> +
> + sfence();
> + 

svn commit: r339391 - in head/sys: dev/nvdimm modules modules/nvdimm

2018-10-16 Thread Konstantin Belousov
Author: kib
Date: Tue Oct 16 20:12:35 2018
New Revision: 339391
URL: https://svnweb.freebsd.org/changeset/base/339391

Log:
  Add initial driver for ACPI NFIT-enumerated NVDIMMs.
  
  Driver enumerates NVDIMMs.  Besides, for each found System Physical
  Address (SPA) range, spaN geom provider is created, which allows
  formatting and mounting the region as the normal volume.  Also,
  /dev/nvdimm_spaN node is created, which can be read/written/mapped by
  userspace, the mapping is zero-copy.
  
  No support for block access methods implemented, labels are not
  parsed.   No management interfaces are provided.
  
  Tested by:Intel, NetApp
  Sponsored by: The FreeBSD Foundation
  Approved by:  re (gjb)
  MFC after:2 weeks

Added:
  head/sys/dev/nvdimm/
  head/sys/dev/nvdimm/nvdimm.c   (contents, props changed)
  head/sys/dev/nvdimm/nvdimm_spa.c   (contents, props changed)
  head/sys/dev/nvdimm/nvdimm_var.h   (contents, props changed)
  head/sys/modules/nvdimm/
  head/sys/modules/nvdimm/Makefile   (contents, props changed)
Modified:
  head/sys/modules/Makefile

Added: head/sys/dev/nvdimm/nvdimm.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/nvdimm/nvdimm.cTue Oct 16 20:12:35 2018
(r339391)
@@ -0,0 +1,423 @@
+/*-
+ * Copyright (c) 2017 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Konstantin Belousov 
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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 "opt_acpi.h"
+#include "opt_ddb.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define _COMPONENT ACPI_OEM
+ACPI_MODULE_NAME("NVDIMM")
+
+static devclass_t nvdimm_devclass;
+static device_t *nvdimm_devs;
+static int nvdimm_devcnt;
+MALLOC_DEFINE(M_NVDIMM, "nvdimm", "NVDIMM driver memory");
+
+struct nvdimm_dev *
+nvdimm_find_by_handle(nfit_handle_t nv_handle)
+{
+   device_t dev;
+   struct nvdimm_dev *res, *nv;
+   int i;
+
+   res = NULL;
+   for (i = 0; i < nvdimm_devcnt; i++) {
+   dev = nvdimm_devs[i];
+   if (dev == NULL)
+   continue;
+   nv = device_get_softc(dev);
+   if (nv->nv_handle == nv_handle) {
+   res = nv;
+   break;
+   }
+   }
+   return (res);
+}
+
+static int
+nvdimm_parse_flush_addr(void *nfitsubtbl, void *arg)
+{
+   ACPI_NFIT_FLUSH_ADDRESS *nfitflshaddr;
+   struct nvdimm_dev *nv;
+   int i;
+
+   nfitflshaddr = nfitsubtbl;
+   nv = arg;
+   if (nfitflshaddr->DeviceHandle != nv->nv_handle)
+   return (0);
+
+   MPASS(nv->nv_flush_addr == NULL && nv->nv_flush_addr_cnt == 0);
+   nv->nv_flush_addr = malloc(nfitflshaddr->HintCount * sizeof(uint64_t *),
+   M_NVDIMM, M_WAITOK);
+   for (i = 0; i < nfitflshaddr->HintCount; i++)
+   nv->nv_flush_addr[i] = (uint64_t *)nfitflshaddr->HintAddress[i];
+   nv->nv_flush_addr_cnt = nfitflshaddr->HintCount;
+   return (0);
+}
+
+int
+nvdimm_iterate_nfit(ACPI_TABLE_NFIT *nfitbl, enum AcpiNfitType type,
+int (*cb)(void *, void *), void *arg)
+{
+   ACPI_NFIT_HEADER *nfithdr;
+   ACPI_NFIT_SYSTEM_ADDRESS *nfitaddr;
+   ACPI_NFIT_MEMORY_MAP *nfitmap;
+   ACPI_NFIT_INTERLEAVE *nfitintrl;
+   ACPI_NFIT_SMBIOS *nfitsmbios;
+   ACPI_NFIT_CONTROL_REGION *nfitctlreg;
+   ACPI_NFIT_DATA_REGION *nfitdtreg;
+   ACPI_NFIT_FLUSH_ADDRESS 

svn commit: r339390 - in head: sys/kern tests/sys/kern

2018-10-16 Thread Mark Johnston
Author: markj
Date: Tue Oct 16 20:06:56 2018
New Revision: 339390
URL: https://svnweb.freebsd.org/changeset/base/339390

Log:
  Reparent a child of pdfork(2) to its reaper when the procdesc is closed.
  
  Unconditionally reparenting to PID 1 breaks the procctl(2) reaper
  functionality.
  
  Add a regression test for this case.
  
  Reviewed by:  kib
  Approved by:  re (gjb)
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D17589

Modified:
  head/sys/kern/sys_procdesc.c
  head/tests/sys/kern/reaper.c

Modified: head/sys/kern/sys_procdesc.c
==
--- head/sys/kern/sys_procdesc.cTue Oct 16 19:26:04 2018
(r339389)
+++ head/sys/kern/sys_procdesc.cTue Oct 16 20:06:56 2018
(r339390)
@@ -312,8 +312,8 @@ procdesc_exit(struct proc *p)
pd = p->p_procdesc;
 
PROCDESC_LOCK(pd);
-   KASSERT((pd->pd_flags & PDF_CLOSED) == 0 || p->p_pptr == initproc,
-   ("procdesc_exit: closed && parent not init"));
+   KASSERT((pd->pd_flags & PDF_CLOSED) == 0 || p->p_pptr == p->p_reaper,
+   ("procdesc_exit: closed && parent not reaper"));
 
pd->pd_flags |= PDF_EXITED;
pd->pd_xstat = KW_EXITCODE(p->p_xexit, p->p_xsig);
@@ -361,7 +361,8 @@ procdesc_reap(struct proc *p)
 /*
  * procdesc_close() - last close on a process descriptor.  If the process is
  * still running, terminate with SIGKILL (unless PDF_DAEMON is set) and let
- * init(8) clean up the mess; if not, we have to clean up the zombie ourselves.
+ * its reaper clean up the mess; if not, we have to clean up the zombie
+ * ourselves.
  */
 static int
 procdesc_close(struct file *fp, struct thread *td)
@@ -410,12 +411,12 @@ procdesc_close(struct file *fp, struct thread *td)
procdesc_free(pd);
 
/*
-* Next, reparent it to init(8) so that there's someone
-* to pick up the pieces; finally, terminate with
-* prejudice.
+* Next, reparent it to its reaper (usually init(8)) so
+* that there's someone to pick up the pieces; finally,
+* terminate with prejudice.
 */
p->p_sigparent = SIGCHLD;
-   proc_reparent(p, initproc);
+   proc_reparent(p, p->p_reaper);
if ((pd->pd_flags & PDF_DAEMON) == 0)
kern_psignal(p, SIGKILL);
PROC_UNLOCK(p);

Modified: head/tests/sys/kern/reaper.c
==
--- head/tests/sys/kern/reaper.cTue Oct 16 19:26:04 2018
(r339389)
+++ head/tests/sys/kern/reaper.cTue Oct 16 20:06:56 2018
(r339390)
@@ -28,6 +28,7 @@
 __FBSDID("$FreeBSD$");
 
 #include 
+#include 
 #include 
 
 #include 
@@ -740,6 +741,40 @@ ATF_TC_BODY(reaper_kill_subtree, tc)
ATF_REQUIRE_EQ(0, r);
 }
 
+ATF_TC_WITHOUT_HEAD(reaper_pdfork);
+ATF_TC_BODY(reaper_pdfork, tc)
+{
+   struct procctl_reaper_status st;
+   pid_t child, grandchild, parent, pid;
+   int pd, r, status;
+
+   parent = getpid();
+   r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL);
+   ATF_REQUIRE_EQ(r, 0);
+
+   child = pdfork(, 0);
+   ATF_REQUIRE(child != -1);
+   if (child == 0) {
+   grandchild = pdfork(, 0);
+   if (grandchild == -1)
+   _exit(1);
+   if (grandchild == 0)
+   pause();
+   _exit(0);
+   }
+   pid = waitpid(child, , 0);
+   ATF_REQUIRE_EQ(pid, child);
+   r = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
+   ATF_REQUIRE_EQ(r, 0);
+
+   r = procctl(P_PID, parent, PROC_REAP_STATUS, );
+   ATF_REQUIRE_EQ(r, 0);
+   ATF_CHECK((st.rs_flags & REAPER_STATUS_OWNED) != 0);
+   ATF_CHECK(st.rs_reaper == parent);
+   ATF_CHECK(st.rs_children == 1);
+   ATF_CHECK(st.rs_descendants == 1);
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 
@@ -754,5 +789,6 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, reaper_kill_empty);
ATF_TP_ADD_TC(tp, reaper_kill_normal);
ATF_TP_ADD_TC(tp, reaper_kill_subtree);
+   ATF_TP_ADD_TC(tp, reaper_pdfork);
return (atf_no_error());
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339389 - stable/11/sys/dev/cxgbe/iw_cxgbe

2018-10-16 Thread Navdeep Parhar
Author: np
Date: Tue Oct 16 19:26:04 2018
New Revision: 339389
URL: https://svnweb.freebsd.org/changeset/base/339389

Log:
  MFC r327254, r327904, and r328994.
  
  r327254:
  cxgbe/iw_cxgbe: Fix iWARP over VLANs (catch up with r326169).
  
  r327904:
  cxgbe/iw_cxgbe: Remove duplicates to fix compilation with recent gcc.
  
  r328994:
  iw_cxgbe: Remove declaration of a function that no longer exists.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/11/sys/dev/cxgbe/iw_cxgbe/cm.c
  stable/11/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/cxgbe/iw_cxgbe/cm.c
==
--- stable/11/sys/dev/cxgbe/iw_cxgbe/cm.c   Tue Oct 16 18:47:13 2018
(r339388)
+++ stable/11/sys/dev/cxgbe/iw_cxgbe/cm.c   Tue Oct 16 19:26:04 2018
(r339389)
@@ -337,24 +337,28 @@ find_real_listen_ep(struct c4iw_listen_ep *master_lep,
 {
struct adapter *adap = NULL;
struct c4iw_listen_ep *lep = NULL;
-   struct sockaddr_storage remote = { 0 };
-   struct ifnet *new_conn_ifp = NULL;
+   struct ifnet *ifp = NULL, *hw_ifp = NULL;
struct listen_port_info *port_info = NULL;
-   int err = 0, i = 0,
-   found_portinfo = 0, found_lep = 0;
+   int i = 0, found_portinfo = 0, found_lep = 0;
uint16_t port;
 
-   /* STEP 1: get 'ifnet' based on socket's remote address */
-   GET_REMOTE_ADDR(, so);
+   /*
+* STEP 1: Figure out 'ifp' of the physical interface, not pseudo
+* interfaces like vlan, lagg, etc..
+* TBD: lagg support, lagg + vlan support.
+*/
+   ifp = TOEPCB(so)->l2te->ifp;
+   if (ifp->if_type == IFT_L2VLAN) {
+   hw_ifp = VLAN_TRUNKDEV(ifp);
+   if (hw_ifp == NULL) {
+   CTR4(KTR_IW_CXGBE, "%s: Failed to get parent ifnet of "
+   "vlan ifnet %p, sock %p, master_lep %p",
+   __func__, ifp, so, master_lep);
+   return (NULL);
+   }
+   } else
+   hw_ifp = ifp;
 
-   err = get_ifnet_from_raddr(, _conn_ifp);
-   if (err) {
-   CTR4(KTR_IW_CXGBE, "%s: Failed to get ifnet, sock %p, "
-   "master_lep %p err %d",
-   __func__, so, master_lep, err);
-   return (NULL);
-   }
-
/* STEP 2: Find 'port_info' with listener local port address. */
port = (master_lep->com.local_addr.ss_family == AF_INET) ?
((struct sockaddr_in *)_lep->com.local_addr)->sin_port :
@@ -377,7 +381,7 @@ find_real_listen_ep(struct c4iw_listen_ep *master_lep,
list_for_each_entry(lep, _info->lep_list, listen_ep_list) {
adap = lep->com.dev->rdev.adap;
for_each_port(adap, i) {
-   if (new_conn_ifp == adap->port[i]->vi[0].ifp) {
+   if (hw_ifp == adap->port[i]->vi[0].ifp) {
found_lep =1;
goto out;
}

Modified: stable/11/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h
==
--- stable/11/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h Tue Oct 16 18:47:13 2018
(r339388)
+++ stable/11/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h Tue Oct 16 19:26:04 2018
(r339389)
@@ -897,8 +897,6 @@ typedef int (*c4iw_handler_func)(struct c4iw_dev *dev,
 
 int c4iw_ep_redirect(void *ctx, struct dst_entry *old, struct dst_entry *new,
 struct l2t_entry *l2t);
-void c4iw_put_qpid(struct c4iw_rdev *rdev, u32 qpid,
-  struct c4iw_dev_ucontext *uctx);
 u32 c4iw_get_resource(struct c4iw_id_table *id_table);
 void c4iw_put_resource(struct c4iw_id_table *id_table, u32 entry);
 int c4iw_init_resource(struct c4iw_rdev *rdev, u32 nr_tpt, u32 nr_pdid);
@@ -964,7 +962,6 @@ void c4iw_pblpool_free(struct c4iw_rdev *rdev, u32 add
 int c4iw_ofld_send(struct c4iw_rdev *rdev, struct mbuf *m);
 void c4iw_flush_hw_cq(struct c4iw_cq *cq);
 void c4iw_count_rcqes(struct t4_cq *cq, struct t4_wq *wq, int *count);
-void c4iw_count_scqes(struct t4_cq *cq, struct t4_wq *wq, int *count);
 int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp);
 int __c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp);
 int c4iw_flush_rq(struct t4_wq *wq, struct t4_cq *cq, int count);
@@ -984,7 +981,6 @@ void __iomem *c4iw_bar2_addrs(struct c4iw_rdev *rdev, 
unsigned int *pbar2_qid, u64 *pbar2_pa);
 extern struct cxgb4_client t4c_client;
 extern c4iw_handler_func c4iw_handlers[NUM_CPL_CMDS];
-extern int c4iw_max_read_depth;
 
 #if defined(__i386__) || defined(__amd64__)
 #define L1_CACHE_BYTES 128
___
svn-src-all@freebsd.org mailing list

svn commit: r339388 - head/sys/dev/usb/controller

2018-10-16 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Oct 16 18:47:13 2018
New Revision: 339388
URL: https://svnweb.freebsd.org/changeset/base/339388

Log:
  Fix for reception of large full speed isochronous frames via the transaction
  translator, when using the DWC OTG USB controller driver. Make sure to re-try
  getting the complete split packets until a DATA0 packet is received. Larger
  isochronous frames may be split into multiple MDATA packets terminated
  by a single DATA0 packet.
  
  PR:   230434
  MFC after:3 days
  Approved by:  re (gjb)
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/dev/usb/controller/dwc_otg.c

Modified: head/sys/dev/usb/controller/dwc_otg.c
==
--- head/sys/dev/usb/controller/dwc_otg.c   Tue Oct 16 18:17:07 2018
(r339387)
+++ head/sys/dev/usb/controller/dwc_otg.c   Tue Oct 16 18:47:13 2018
(r339388)
@@ -1458,6 +1458,8 @@ dwc_otg_host_data_rx(struct dwc_otg_softc *sc, struct 
/* check if we are complete */
if (td->tt_xactpos == HCSPLT_XACTPOS_BEGIN) {
goto complete;
+   } else if (td->hcsplt != 0) {
+   goto receive_pkt;
} else {
/* get more packets */
goto busy;
@@ -1516,8 +1518,10 @@ receive_pkt:
if (td->hcsplt != 0) {
delta = td->tt_complete_slot - sc->sc_last_frame_num - 1;
if (td->tt_scheduled == 0 || delta < DWC_OTG_TT_SLOT_MAX) {
-   td->state = DWC_CHAN_ST_WAIT_C_PKT;
-   goto busy;
+   if (td->ep_type != UE_ISOCHRONOUS) {
+   td->state = DWC_CHAN_ST_WAIT_C_PKT;
+   goto busy;
+   }
}
delta = sc->sc_last_frame_num - td->tt_start_slot;
if (delta > DWC_OTG_TT_SLOT_MAX) {
@@ -1563,12 +1567,23 @@ receive_pkt:
hcchar = td->hcchar;
hcchar |= HCCHAR_EPDIR_IN;
 
-   /* receive complete split ASAP */
-   if ((sc->sc_last_frame_num & 1) != 0 &&
-   td->ep_type == UE_ISOCHRONOUS)
-   hcchar |= HCCHAR_ODDFRM;
-   else
+   if (td->ep_type == UE_ISOCHRONOUS) {
+   if (td->hcsplt != 0) {
+   /* continously buffer */
+   if (sc->sc_last_frame_num & 1)
+   hcchar &= ~HCCHAR_ODDFRM;
+   else
+   hcchar |= HCCHAR_ODDFRM;
+   } else {
+   /* multi buffer, if any */
+   if (sc->sc_last_frame_num & 1)
+   hcchar |= HCCHAR_ODDFRM;
+   else
+   hcchar &= ~HCCHAR_ODDFRM;
+   }
+   } else {
hcchar &= ~HCCHAR_ODDFRM;
+   }
 
/* must enable channel before data can be received */
DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(channel), hcchar);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339387 - head/lib/libc/gen

2018-10-16 Thread Edward Tomasz Napierala
Author: trasz
Date: Tue Oct 16 18:17:07 2018
New Revision: 339387
URL: https://svnweb.freebsd.org/changeset/base/339387

Log:
  Get rid unneccessary useless calls to lseek(2) from getgrent(3).
  Looks like this:
  
   fstatat(AT_FDCWD,"/etc/nsswitch.conf",{ mode=-rw-r--r-- 
,inode=2167001,size=390,blksize=32768 },0x0) = 0 (0x0)
   open("/etc/group",O_RDONLY|O_CLOEXEC,0666)  = 3 (0x3)
   fstat(3,{ mode=-rw-r--r-- ,inode=2166927,size=919,blksize=32768 }) = 0 (0x0)
  -lseek(3,0x0,SEEK_CUR)   = 0 (0x0)
  -lseek(3,0x0,SEEK_SET)   = 0 (0x0)
   read(3,"# $FreeBSD: release/10.0.0/etc/g"...,32768) = 919 (0x397)
   close(3)= 0 (0x0)
  
  Reviewed by:  kib
  Approved by:  re (gjb)
  MFC after:2 weeks
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D17571

Modified:
  head/lib/libc/gen/getgrent.c

Modified: head/lib/libc/gen/getgrent.c
==
--- head/lib/libc/gen/getgrent.cTue Oct 16 17:28:10 2018
(r339386)
+++ head/lib/libc/gen/getgrent.cTue Oct 16 18:17:07 2018
(r339387)
@@ -836,8 +836,9 @@ files_group(void *retval, void *mdata, va_list ap)
char*buffer;
size_t   bufsize, linesize;
off_tpos;
-   int  rv, stayopen, *errnop;
+   int  fresh, rv, stayopen, *errnop;
 
+   fresh = 0;
name = NULL;
gid = (gid_t)-1;
how = (enum nss_lookup_type)mdata;
@@ -860,19 +861,24 @@ files_group(void *retval, void *mdata, va_list ap)
*errnop = files_getstate();
if (*errnop != 0)
return (NS_UNAVAIL);
-   if (st->fp == NULL &&
-   ((st->fp = fopen(_PATH_GROUP, "re")) == NULL)) {
-   *errnop = errno;
-   return (NS_UNAVAIL);
+   if (st->fp == NULL) {
+   st->fp = fopen(_PATH_GROUP, "re");
+   if (st->fp == NULL) {
+   *errnop = errno;
+   return (NS_UNAVAIL);
+   }
+   fresh = 1;
}
if (how == nss_lt_all)
stayopen = 1;
else {
-   rewind(st->fp);
+   if (!fresh)
+   rewind(st->fp);
stayopen = st->stayopen;
}
rv = NS_NOTFOUND;
-   pos = ftello(st->fp);
+   if (stayopen)
+   pos = ftello(st->fp);
while ((line = fgetln(st->fp, )) != NULL) {
if (line[linesize-1] == '\n')
linesize--;
@@ -894,7 +900,8 @@ files_group(void *retval, void *mdata, va_list ap)
[linesize + 1], bufsize - linesize - 1, errnop);
if (rv & NS_TERMINATE)
break;
-   pos = ftello(st->fp);
+   if (stayopen)
+   pos = ftello(st->fp);
}
if (st->fp != NULL && !stayopen) {
fclose(st->fp);
@@ -1304,7 +1311,7 @@ compat_group(void *retval, void *mdata, va_list ap)
void*discard;
size_t   bufsize, linesize;
off_tpos;
-   int  rv, stayopen, *errnop;
+   int  fresh, rv, stayopen, *errnop;
 
 #define set_lookup_type(x, y) do { \
int i;  \
@@ -1312,6 +1319,7 @@ compat_group(void *retval, void *mdata, va_list ap)
x[i].mdata = (void *)y; \
 } while (0)
 
+   fresh = 0;
name = NULL;
gid = (gid_t)-1;
how = (enum nss_lookup_type)mdata;
@@ -1334,16 +1342,20 @@ compat_group(void *retval, void *mdata, va_list ap)
*errnop = compat_getstate();
if (*errnop != 0)
return (NS_UNAVAIL);
-   if (st->fp == NULL &&
-   ((st->fp = fopen(_PATH_GROUP, "re")) == NULL)) {
-   *errnop = errno;
-   rv = NS_UNAVAIL;
-   goto fin;
+   if (st->fp == NULL) {
+   st->fp = fopen(_PATH_GROUP, "re");
+   if (st->fp == NULL) {
+   *errnop = errno;
+   rv = NS_UNAVAIL;
+   goto fin;
+   }
+   fresh = 1;
}
if (how == nss_lt_all)
stayopen = 1;
else {
-   rewind(st->fp);
+   if (!fresh)
+   rewind(st->fp);
stayopen = st->stayopen;
}
 docompat:
@@ -1406,7 +1418,8 @@ docompat:
break;
}
rv = NS_NOTFOUND;
-   pos = ftello(st->fp);
+   if (stayopen)
+   pos = ftello(st->fp);
while ((line = fgetln(st->fp, )) != NULL) {
if 

svn commit: r339386 - in head/sys/amd64: amd64 include

2018-10-16 Thread Konstantin Belousov
Author: kib
Date: Tue Oct 16 17:28:10 2018
New Revision: 339386
URL: https://svnweb.freebsd.org/changeset/base/339386

Log:
  Provide pmap_large_map() KPI on amd64.
  
  The KPI allows to map very large contigous physical memory regions
  into KVA, which are not covered by DMAP.
  
  I see both with QEMU and with some real hardware started shipping, the
  regions for NVDIMMs might be very far apart from the normal RAM, and
  we expect that at least initial users of NVDIMM could install very
  large amount of such memory.  IMO it is not reasonable to extend DMAP
  to cover that far-away regions both because it could overflow existing
  4T window for DMAP in KVA, and because it costs in page table pages
  allocations, for gap and for possibly unused NV RAM.
  
  Also, KPI provides some special functionality for fast cache flushing
  based on the knowledge of the NVRAM mapping use.
  
  Reviewed by:  alc, markj
  Sponsored by: The FreeBSD Foundation
  Approved by:  re (gjb)
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D17070

Modified:
  head/sys/amd64/amd64/pmap.c
  head/sys/amd64/include/pmap.h
  head/sys/amd64/include/vmparam.h

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Tue Oct 16 17:17:11 2018(r339385)
+++ head/sys/amd64/amd64/pmap.c Tue Oct 16 17:28:10 2018(r339386)
@@ -409,6 +409,9 @@ static struct mtx qframe_mtx;
 
 static int pmap_flags = PMAP_PDE_SUPERPAGE;/* flags for x86 pmaps */
 
+static vmem_t *large_vmem;
+static u_int lm_ents;
+
 int pmap_pcid_enabled = 1;
 SYSCTL_INT(_vm_pmap, OID_AUTO, pcid_enabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH,
 _pcid_enabled, 0, "Is TLB Context ID enabled ?");
@@ -655,6 +658,7 @@ static void pmap_invalidate_cache_range_all(vm_offset_
 static void pmap_invalidate_pde_page(pmap_t pmap, vm_offset_t va,
pd_entry_t pde);
 static void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, int mode);
+static vm_page_t pmap_large_map_getptp_unlocked(void);
 static void pmap_pde_attr(pd_entry_t *pde, int cache_bits, int mask);
 #if VM_NRESERVLEVEL > 0
 static void pmap_promote_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t va,
@@ -1313,7 +1317,7 @@ void
 pmap_init(void)
 {
struct pmap_preinit_mapping *ppim;
-   vm_page_t mpte;
+   vm_page_t m, mpte;
vm_size_t s;
int error, i, pv_npg, ret, skz63;
 
@@ -1440,6 +1444,28 @@ pmap_init(void)
(vmem_addr_t *));
if (error != 0)
panic("qframe allocation failed");
+
+   lm_ents = 8;
+   TUNABLE_INT_FETCH("vm.pmap.large_map_pml4_entries", _ents);
+   if (lm_ents > LMEPML4I - LMSPML4I + 1)
+   lm_ents = LMEPML4I - LMSPML4I + 1;
+   if (bootverbose)
+   printf("pmap: large map %u PML4 slots (%lu Gb)\n",
+   lm_ents, (u_long)lm_ents * (NBPML4 / 1024 / 1024 / 1024));
+   if (lm_ents != 0) {
+   large_vmem = vmem_create("large", LARGEMAP_MIN_ADDRESS,
+   (vmem_size_t)lm_ents * NBPML4, PAGE_SIZE, 0, M_WAITOK);
+   if (large_vmem == NULL) {
+   printf("pmap: cannot create large map\n");
+   lm_ents = 0;
+   }
+   for (i = 0; i < lm_ents; i++) {
+   m = pmap_large_map_getptp_unlocked();
+   kernel_pmap->pm_pml4[LMSPML4I + i] = X86_PG_V |
+   X86_PG_RW | X86_PG_A | X86_PG_M | pg_nx |
+   VM_PAGE_TO_PHYS(m);
+   }
+   }
 }
 
 static SYSCTL_NODE(_vm_pmap, OID_AUTO, pde, CTLFLAG_RD, 0,
@@ -2315,14 +2341,6 @@ pmap_force_invalidate_cache_range(vm_offset_t sva, vm_
 {
 
sva &= ~(vm_offset_t)(cpu_clflush_line_size - 1);
-   if (eva - sva >= PMAP_CLFLUSH_THRESHOLD) {
-   /*
-* The supplied range is bigger than 2MB.
-* Globally invalidate cache.
-*/
-   pmap_invalidate_cache();
-   return;
-   }
 
/*
 * XXX: Some CPUs fault, hang, or trash the local APIC
@@ -2406,6 +2424,64 @@ pmap_invalidate_cache_pages(vm_page_t *pages, int coun
}
 }
 
+void
+pmap_flush_cache_range(vm_offset_t sva, vm_offset_t eva)
+{
+
+   pmap_invalidate_cache_range_check_align(sva, eva);
+
+   if ((cpu_stdext_feature & CPUID_STDEXT_CLWB) == 0) {
+   pmap_force_invalidate_cache_range(sva, eva);
+   return;
+   }
+
+   /* See comment in pmap_force_invalidate_cache_range(). */
+   if (pmap_kextract(sva) == lapic_paddr)
+   return;
+
+   sfence();
+   for (; sva < eva; sva += cpu_clflush_line_size)
+   clwb(sva);
+   sfence();
+}
+
+void
+pmap_flush_cache_phys_range(vm_paddr_t spa, vm_paddr_t epa, vm_memattr_t mattr)
+{
+   pt_entry_t *pte;
+   vm_offset_t vaddr;
+   int 

svn commit: r339385 - head/contrib/mandoc

2018-10-16 Thread Yuri Pankov
Author: yuripv
Date: Tue Oct 16 17:17:11 2018
New Revision: 339385
URL: https://svnweb.freebsd.org/changeset/base/339385

Log:
  apropos/whatis: use output of manpath(1) to set defpaths if -M is not
  specified.  This fixes searching the paths specified in
  /usr/local/etc/man.d/*.conf, as currently apropos/whatis from mandoc
  suite aren't aware about them.
  
  PR:   227922
  Reviewed by:  bapt
  Approved by:  re (gjb), kib (mentor)
  Differential Revision:https://reviews.freebsd.org/D17454

Modified:
  head/contrib/mandoc/main.c

Modified: head/contrib/mandoc/main.c
==
--- head/contrib/mandoc/main.c  Tue Oct 16 17:00:42 2018(r339384)
+++ head/contrib/mandoc/main.c  Tue Oct 16 17:17:11 2018(r339385)
@@ -248,7 +248,13 @@ main(int argc, char *argv[])
outmode = OUTMODE_ALL;
break;
case 'M':
+#ifdef __FreeBSD__
+   defpaths = strdup(optarg);
+   if (defpaths == NULL)
+   err(1, "strdup");
+#else
defpaths = optarg;
+#endif
break;
case 'm':
auxpaths = optarg;
@@ -380,9 +386,34 @@ main(int argc, char *argv[])
outmode == OUTMODE_ONE)
search.firstmatch = 1;
 
+#ifdef __FreeBSD__
+   /*
+* Use manpath(1) to populate defpaths if -M is not specified.
+* Don't treat any failures as fatal.
+*/
+   if (defpaths == NULL) {
+   FILE *fp;
+   size_t linecap = 0;
+   ssize_t linelen;
+
+   if ((fp = popen("/usr/bin/manpath -q", "r")) != NULL) {
+   if ((linelen = getline(,
+   , fp)) > 0) {
+   /* Strip trailing newline */
+   defpaths[linelen - 1] = '\0';
+   }
+   pclose(fp);
+   }
+   }
+#endif
+
/* Access the mandoc database. */
 
manconf_parse(, conf_file, defpaths, auxpaths);
+#ifdef __FreeBSD__
+   free(defpaths);
+#endif
+
if ( ! mansearch(, ,
argc, argv, , ))
usage(search.argmode);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339384 - head/sys/amd64/include

2018-10-16 Thread Konstantin Belousov
Author: kib
Date: Tue Oct 16 17:00:42 2018
New Revision: 339384
URL: https://svnweb.freebsd.org/changeset/base/339384

Log:
  Add clwb().
  
  Reviewed by:  alc, markj
  Sponsored by: The FreeBSD Foundation
  Approved by:  re (gjb)
  MFC after:3 days
  Differential revision:https://reviews.freebsd.org/D17070

Modified:
  head/sys/amd64/include/cpufunc.h

Modified: head/sys/amd64/include/cpufunc.h
==
--- head/sys/amd64/include/cpufunc.hTue Oct 16 16:45:21 2018
(r339383)
+++ head/sys/amd64/include/cpufunc.hTue Oct 16 17:00:42 2018
(r339384)
@@ -116,6 +116,13 @@ clflushopt(u_long addr)
 }
 
 static __inline void
+clwb(u_long addr)
+{
+
+   __asm __volatile("clwb %0" : : "m" (*(char *)addr));
+}
+
+static __inline void
 clts(void)
 {
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339381 - head/sys/riscv/riscv

2018-10-16 Thread Ruslan Bukin
Author: br
Date: Tue Oct 16 16:03:17 2018
New Revision: 339381
URL: https://svnweb.freebsd.org/changeset/base/339381

Log:
  Invalidate TLB on a local hart.
  
  This was missed in r339367 ("Various fixes for TLB management on RISC-V.").
  
  This fixes operation on lowRISC.
  
  Reviewed by:  jhb
  Approved by:  re (gjb)
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D17583

Modified:
  head/sys/riscv/riscv/pmap.c

Modified: head/sys/riscv/riscv/pmap.c
==
--- head/sys/riscv/riscv/pmap.c Tue Oct 16 16:00:41 2018(r339380)
+++ head/sys/riscv/riscv/pmap.c Tue Oct 16 16:03:17 2018(r339381)
@@ -804,6 +804,7 @@ pmap_invalidate_all(pmap_t pmap)
 * all sfence_vma requests as global however.
 */
sbi_remote_sfence_vma(mask.__bits, 0, 0);
+   sfence_vma();
sched_unpin();
 }
 #else
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339380 - head/usr.sbin/pw

2018-10-16 Thread Yuri Pankov
Author: yuripv
Date: Tue Oct 16 16:00:41 2018
New Revision: 339380
URL: https://svnweb.freebsd.org/changeset/base/339380

Log:
  pw: (file == NULL) check is always false in read_userconfig(), remove
  it.  Drop the now unused _PATH_PW_CONF definition. [1]
  
  While here, change the last remaining hardcoded "/etc" to _PATH_PWD.
  
  Noted by: glebius [1]
  Reviewed by:  eugen
  Approved by:  re (gjb), kib (mentor)
  Differential Revision:https://reviews.freebsd.org/D17575

Modified:
  head/usr.sbin/pw/pw.c
  head/usr.sbin/pw/pw.h
  head/usr.sbin/pw/pw_conf.c

Modified: head/usr.sbin/pw/pw.c
==
--- head/usr.sbin/pw/pw.c   Tue Oct 16 15:57:16 2018(r339379)
+++ head/usr.sbin/pw/pw.c   Tue Oct 16 16:00:41 2018(r339380)
@@ -162,7 +162,8 @@ main(int argc, char *argv[])
PWF._altdir = PWF_ROOTDIR;
}
snprintf(conf.etcpath, sizeof(conf.etcpath),
-   "%s%s", optarg, arg == 'R' ? "/etc" : "");
+   "%s%s", optarg, arg == 'R' ?
+   _PATH_PWD : "");
} else
break;
}

Modified: head/usr.sbin/pw/pw.h
==
--- head/usr.sbin/pw/pw.h   Tue Oct 16 15:57:16 2018(r339379)
+++ head/usr.sbin/pw/pw.h   Tue Oct 16 16:00:41 2018(r339380)
@@ -65,7 +65,6 @@ enum _which
 
 #define_DEF_DIRMODE(S_IRWXU | S_IRWXG | S_IRWXO)
 #define_PW_CONF"pw.conf"
-#define _PATH_PW_CONF  "/etc/pw.conf"
 #define _UC_MAXLINE1024
 #define _UC_MAXSHELLS  32
 

Modified: head/usr.sbin/pw/pw_conf.c
==
--- head/usr.sbin/pw/pw_conf.c  Tue Oct 16 15:57:16 2018(r339379)
+++ head/usr.sbin/pw/pw_conf.c  Tue Oct 16 16:00:41 2018(r339380)
@@ -255,9 +255,6 @@ read_userconfig(char const * file)
buf = NULL;
linecap = 0;
 
-   if (file == NULL)
-   file = _PATH_PW_CONF;
-
if ((fp = fopen(file, "r")) == NULL)
return ();
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339379 - head/sys/kern

2018-10-16 Thread Gleb Smirnoff
Author: glebius
Date: Tue Oct 16 15:57:16 2018
New Revision: 339379
URL: https://svnweb.freebsd.org/changeset/base/339379

Log:
  Plug sendfile(2) on a listening socket with proper error code.
  
  Reported by:  ngie
  Reviewed by:  ngie
  Approved by:  re (delphij)

Modified:
  head/sys/kern/kern_sendfile.c

Modified: head/sys/kern/kern_sendfile.c
==
--- head/sys/kern/kern_sendfile.c   Tue Oct 16 14:41:09 2018
(r339378)
+++ head/sys/kern/kern_sendfile.c   Tue Oct 16 15:57:16 2018
(r339379)
@@ -526,6 +526,8 @@ sendfile_getsock(struct thread *td, int s, struct file
*so = (*sock_fp)->f_data;
if ((*so)->so_type != SOCK_STREAM)
return (EINVAL);
+   if (SOLISTENING(*so))
+   return (ENOTCONN);
return (0);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339378 - head/sys/netinet

2018-10-16 Thread Jonathan T. Looney
Author: jtl
Date: Tue Oct 16 14:41:09 2018
New Revision: 339378
URL: https://svnweb.freebsd.org/changeset/base/339378

Log:
  In r338102, the TCP reassembly code was substantially restructured. Prior
  to this change, the code sometimes used a temporary stack variable to hold
  details of a TCP segment. r338102 stopped using the variable to hold
  segments, but did not actually remove the variable.
  
  Because the variable is no longer used, we can safely remove it.
  
  Approved by:  re (gjb)

Modified:
  head/sys/netinet/tcp_reass.c

Modified: head/sys/netinet/tcp_reass.c
==
--- head/sys/netinet/tcp_reass.cTue Oct 16 14:16:39 2018
(r339377)
+++ head/sys/netinet/tcp_reass.cTue Oct 16 14:41:09 2018
(r339378)
@@ -528,7 +528,6 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, tcp_seq
struct tseg_qent *p = NULL;
struct tseg_qent *nq = NULL;
struct tseg_qent *te = NULL;
-   struct tseg_qent tqs;
struct mbuf *mlast = NULL;
struct sockbuf *sb;
struct socket *so = tp->t_inpcb->inp_socket;
@@ -1053,8 +1052,7 @@ present:
KASSERT(tp->t_segqmbuflen >= q->tqe_mbuf_cnt,
("tp:%p seg queue goes negative", tp));
tp->t_segqmbuflen -= q->tqe_mbuf_cnt;
-   if (q != ) 
-   uma_zfree(tcp_reass_zone, q);
+   uma_zfree(tcp_reass_zone, q);
tp->t_segqlen--;
q = nq;
} while (q && q->tqe_start == tp->rcv_nxt);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339377 - head/sys/conf

2018-10-16 Thread Glen Barber
Author: gjb
Date: Tue Oct 16 14:16:39 2018
New Revision: 339377
URL: https://svnweb.freebsd.org/changeset/base/339377

Log:
  Update head from ALPHA9 to ALPHA10 as part of the 12.0-RELEASE
  cycle.
  
  This is expected to be the final ALPHA build of this release
  cycle, prior to branching stable/12.
  
  Approved by:  re (implicit)
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/conf/newvers.sh

Modified: head/sys/conf/newvers.sh
==
--- head/sys/conf/newvers.shTue Oct 16 03:18:57 2018(r339376)
+++ head/sys/conf/newvers.shTue Oct 16 14:16:39 2018(r339377)
@@ -46,7 +46,7 @@
 
 TYPE="FreeBSD"
 REVISION="12.0"
-BRANCH="ALPHA9"
+BRANCH="ALPHA10"
 if [ -n "${BRANCH_OVERRIDE}" ]; then
BRANCH=${BRANCH_OVERRIDE}
 fi
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r339350 - head/contrib/elftoolchain/elfcopy

2018-10-16 Thread Baptiste Daroussin
On Tue, Oct 16, 2018 at 10:26:14AM +0300, Konstantin Belousov wrote:
> On Tue, Oct 16, 2018 at 07:39:32AM +0200, Antoine Brodin wrote:
> > On Mon, Oct 15, 2018 at 3:53 PM Ed Maste  wrote:
> > > On Mon, 15 Oct 2018 at 07:13, Ed Maste  wrote:
> > > > Hi Antoine, did you bisect to this rev or does it just look like the
> > > > most probable candidate? Can you copy a pair of differing .o files
> > > > (say, gcc/cc1plus-checksum.o) from the work dir to freefall?
> > >
> > > Antoine provided a tarball of the work dir to me, and pointed out that
> > > the *-checksum.o files are not interesting - they are warnings only
> > > and are present prior to the identified change.
> > >
> > > Comparing one of the other differing files, e.g.
> > > stage{2,3}-gcc/expmed.o, demonstrates the problem. Gcc's build
> > > machinery is reasonably obfuscated so I'm not sure of the exact set of
> > > operations, but I can infer that the stage2/stage3 comparison is
> > > running strip on the object files and then comparing the result. Gcc
> > > is encountering this part of my strip/objcopy change:
> > >
> > > > Stripping binaries with relocations
> > > > referencing removed symbols was already broken, and after this change
> > > > may still be broken in a different way.
> > >
> > > Stripping symbols and relocations from an object file is not a
> > > particularly useful operation, since the object then can't be linked
> > > or otherwise used. But it seems Gcc's stage comparison relies on this.
> > > I did try running "strip --strip-debug" on stage{2,3}-gcc/expmed.o (a
> > > reasonable operation on object files) and that produced identical
> > > output.
> > >
> > > It may well be that a further change to ELF Tool Chain's strip is
> > > warranted, but I suspect the most straightforward and reliable fix
> > > here will be to just have gcc use GNU strip.
> > 
> > The attached patch for the gcc ports fixes the failures for me.
> > 
> > Antoine
> 
> > Index: lang/gcc48/Makefile
> > ===
> > --- lang/gcc48/Makefile (revision 482165)
> > +++ lang/gcc48/Makefile (working copy)
> > @@ -33,6 +33,7 @@
> >  SUFFIX=${PORTVERSION:C/([0-9]+).([0-9]+).*/\1\2/}
> >  USES=  compiler cpe gmake iconv libtool makeinfo perl5 
> > tar:bzip2
> >  USE_BINUTILS=  yes
> > +BINARY_ALIAS=  strip=${LOCALBASE}/bin/strip
> Shouldn't USE_BINUTILS automatically prefer all binaries from there to be
> used, instead of the base system variants ?
> 

Strip is not in the list of binaries to override, probably something to fix.
Plus it expects the build system to respect the "classic" env var, which imho
should be replaced by BINARY_ALIAS when possible

Best regards,
Bapt


signature.asc
Description: PGP signature


Re: svn commit: r339350 - head/contrib/elftoolchain/elfcopy

2018-10-16 Thread Konstantin Belousov
On Tue, Oct 16, 2018 at 07:39:32AM +0200, Antoine Brodin wrote:
> On Mon, Oct 15, 2018 at 3:53 PM Ed Maste  wrote:
> > On Mon, 15 Oct 2018 at 07:13, Ed Maste  wrote:
> > > Hi Antoine, did you bisect to this rev or does it just look like the
> > > most probable candidate? Can you copy a pair of differing .o files
> > > (say, gcc/cc1plus-checksum.o) from the work dir to freefall?
> >
> > Antoine provided a tarball of the work dir to me, and pointed out that
> > the *-checksum.o files are not interesting - they are warnings only
> > and are present prior to the identified change.
> >
> > Comparing one of the other differing files, e.g.
> > stage{2,3}-gcc/expmed.o, demonstrates the problem. Gcc's build
> > machinery is reasonably obfuscated so I'm not sure of the exact set of
> > operations, but I can infer that the stage2/stage3 comparison is
> > running strip on the object files and then comparing the result. Gcc
> > is encountering this part of my strip/objcopy change:
> >
> > > Stripping binaries with relocations
> > > referencing removed symbols was already broken, and after this change
> > > may still be broken in a different way.
> >
> > Stripping symbols and relocations from an object file is not a
> > particularly useful operation, since the object then can't be linked
> > or otherwise used. But it seems Gcc's stage comparison relies on this.
> > I did try running "strip --strip-debug" on stage{2,3}-gcc/expmed.o (a
> > reasonable operation on object files) and that produced identical
> > output.
> >
> > It may well be that a further change to ELF Tool Chain's strip is
> > warranted, but I suspect the most straightforward and reliable fix
> > here will be to just have gcc use GNU strip.
> 
> The attached patch for the gcc ports fixes the failures for me.
> 
> Antoine

> Index: lang/gcc48/Makefile
> ===
> --- lang/gcc48/Makefile   (revision 482165)
> +++ lang/gcc48/Makefile   (working copy)
> @@ -33,6 +33,7 @@
>  SUFFIX=  ${PORTVERSION:C/([0-9]+).([0-9]+).*/\1\2/}
>  USES=compiler cpe gmake iconv libtool makeinfo perl5 
> tar:bzip2
>  USE_BINUTILS=yes
> +BINARY_ALIAS=strip=${LOCALBASE}/bin/strip
Shouldn't USE_BINUTILS automatically prefer all binaries from there to be
used, instead of the base system variants ?
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"