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

2017-01-14 Thread Jason A. Harmening
Author: jah
Date: Sat Jan 14 09:56:01 2017
New Revision: 312153
URL: https://svnweb.freebsd.org/changeset/base/312153

Log:
  For i386 temporary mappings, unpin the thread before releasing
  the cmap lock.  Releasing the lock first may result in the thread
  being immediately rescheduled and bound to the same CPU, only to
  unpin itself upon resuming execution.
  
  Noted by: skra (in review for armv6 equivalent)
  MFC after:1 week

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

Modified: head/sys/i386/i386/pmap.c
==
--- head/sys/i386/i386/pmap.c   Sat Jan 14 09:47:06 2017(r312152)
+++ head/sys/i386/i386/pmap.c   Sat Jan 14 09:56:01 2017(r312153)
@@ -4216,8 +4216,8 @@ pmap_zero_page(vm_page_t m)
invlcaddr(pc->pc_cmap_addr2);
pagezero(pc->pc_cmap_addr2);
*cmap_pte2 = 0;
-   mtx_unlock(&pc->pc_cmap_lock);
sched_unpin();
+   mtx_unlock(&pc->pc_cmap_lock);
 }
 
 /*
@@ -4244,8 +4244,8 @@ pmap_zero_page_area(vm_page_t m, int off
else
bzero(pc->pc_cmap_addr2 + off, size);
*cmap_pte2 = 0;
-   mtx_unlock(&pc->pc_cmap_lock);
sched_unpin();
+   mtx_unlock(&pc->pc_cmap_lock);
 }
 
 /*
@@ -4275,8 +4275,8 @@ pmap_copy_page(vm_page_t src, vm_page_t 
bcopy(pc->pc_cmap_addr1, pc->pc_cmap_addr2, PAGE_SIZE);
*cmap_pte1 = 0;
*cmap_pte2 = 0;
-   mtx_unlock(&pc->pc_cmap_lock);
sched_unpin();
+   mtx_unlock(&pc->pc_cmap_lock);
 }
 
 int unmapped_buf_allowed = 1;
@@ -4323,8 +4323,8 @@ pmap_copy_pages(vm_page_t ma[], vm_offse
}
*cmap_pte1 = 0;
*cmap_pte2 = 0;
-   mtx_unlock(&pc->pc_cmap_lock);
sched_unpin();
+   mtx_unlock(&pc->pc_cmap_lock);
 }
 
 /*
@@ -5310,8 +5310,8 @@ pmap_flush_page(vm_page_t m)
if (useclflushopt || cpu_vendor_id != CPU_VENDOR_INTEL)
mfence();
*cmap_pte2 = 0;
-   mtx_unlock(&pc->pc_cmap_lock);
sched_unpin();
+   mtx_unlock(&pc->pc_cmap_lock);
} else
pmap_invalidate_cache();
 }
___
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: r312162 - head/usr.sbin/inetd

2017-01-14 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 10:20:38 2017
New Revision: 312162
URL: https://svnweb.freebsd.org/changeset/base/312162

Log:
  Fix up r312105
  
  - Only #include tcpd.h when LIBWRAP is true to avoid header include errors
  - Only define whichaf when LIBWRAP is true to avoid -Wunused warning and
to avoid issues with structs being defined that should only be defined
when tcpd.h is included.
  
  MFC after:2 weeks
  X-MFC with:   r312105
  Pointyhat to: ngie
  Reported by:  gcc tinderbox
  Sponsored by: Dell EMC Isilon

Modified:
  head/usr.sbin/inetd/inetd.c

Modified: head/usr.sbin/inetd/inetd.c
==
--- head/usr.sbin/inetd/inetd.c Sat Jan 14 10:20:27 2017(r312161)
+++ head/usr.sbin/inetd/inetd.c Sat Jan 14 10:20:38 2017(r312162)
@@ -138,7 +138,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#ifdef LIBWRAP
 #include 
+#endif
 #include 
 
 #include "inetd.h"
@@ -307,6 +309,7 @@ getvalue(const char *arg, int *value, co
return 0;   /* success */
 }
 
+#ifdef LIBWRAP
 static sa_family_t
 whichaf(struct request_info *req)
 {
@@ -322,6 +325,7 @@ whichaf(struct request_info *req)
 #endif
return sa->sa_family;
 }
+#endif
 
 int
 main(int argc, char **argv)
___
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: r312164 - head/tests/sys/mac/bsdextended

2017-01-14 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 10:38:39 2017
New Revision: 312164
URL: https://svnweb.freebsd.org/changeset/base/312164

Log:
  Fix -Wformat issue
  
  Use %zu for printing out results from nitems, as it's size_t based
  
  MFC after:1 week
  X-MFC with:   r312120
  Reported by:  gcc (mips:mipsel tinderbox)
  Sponsored by: Dell EMC Isilon

Modified:
  head/tests/sys/mac/bsdextended/ugidfw_test.c

Modified: head/tests/sys/mac/bsdextended/ugidfw_test.c
==
--- head/tests/sys/mac/bsdextended/ugidfw_test.cSat Jan 14 10:23:05 
2017(r312163)
+++ head/tests/sys/mac/bsdextended/ugidfw_test.cSat Jan 14 10:38:39 
2017(r312164)
@@ -222,7 +222,7 @@ main(void)
return (0);
}
 
-   printf("1..%lu\n", nitems(test_users) + nitems(test_groups) +
+   printf("1..%zu\n", nitems(test_users) + nitems(test_groups) +
3 * nitems(test_strings) + 2);
 
test_libugidfw_strings();
___
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: r311455 - head/sys/boot/fdt/dts/arm

2017-01-14 Thread Emmanuel Vadot

 Hello zbb,

On Thu, 5 Jan 2017 17:27:50 + (UTC)
Zbigniew Bodek  wrote:

> Author: zbb
> Date: Thu Jan  5 17:27:50 2017
> New Revision: 311455
> URL: https://svnweb.freebsd.org/changeset/base/311455
> 
> Log:
>   Add DTS file for Armada 385 DB-AP board
>   
>   Armada38x is already supported in the tree.
>   This commit adds support for DB-AP board.
>   File was taken from Linux v4.8 and accustomed to FreeBSD
>   in minimal possible way.
>   
>   Submitted by:   Bartosz Szczepanek 
>   Obtained from:  Semihalf
>   Sponsored by:   Stormshield
>   Differential revision: https://reviews.freebsd.org/D7327
> 
> Added:
>   head/sys/boot/fdt/dts/arm/armada-385-db-ap.dts   (contents, props changed)

 This file is already present in sys/gnu/dts (from an earlier version
of Linux, 4.7-rcX). As I said in the review I'm not sure that we want
multiple version of DTS in the tree.
 Could you use the upstream dts as base (include it in our DTS) and add
the FreeBSD needed nodes in it like we do for Allwinner and BeagleBone ?

 Thanks.

> Added: head/sys/boot/fdt/dts/arm/armada-385-db-ap.dts
> ==
> --- /dev/null 00:00:00 1970   (empty, because file is newly added)
> +++ head/sys/boot/fdt/dts/arm/armada-385-db-ap.dtsThu Jan  5 17:27:50 
> 2017(r311455)
> @@ -0,0 +1,271 @@
> +/*
> + * Device Tree file for Marvell Armada 385 Access Point Development board
> + * (DB-88F6820-AP)
> + *
> + *  Copyright (C) 2014 Marvell
> + *
> + * Nadav Haklai 
> + *
> + * This file is dual-licensed: you can use it either under the terms
> + * of the GPL or the X11 license, at your option. Note that this dual
> + * licensing only applies to this file, and not this project as a
> + * whole.
> + *
> + *  a) This file is licensed under the terms of the GNU General Public
> + * License version 2.  This program is licensed "as is" without
> + * any warranty of any kind, whether express or implied.
> + *
> + * Or, alternatively,
> + *
> + *  b) Permission is hereby granted, free of charge, to any person
> + * obtaining a copy of this software and associated documentation
> + * files (the "Software"), to deal in the Software without
> + * restriction, including without limitation the rights to use,
> + * copy, modify, merge, publish, distribute, sublicense, and/or
> + * sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following
> + * conditions:
> + *
> + * The above copyright notice and this permission notice shall be
> + * included in all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
> + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
> + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
> + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
> + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> + * OTHER DEALINGS IN THE SOFTWARE.
> + *
> + * $FreeBSD$
> + */
> +
> +/dts-v1/;
> +#include "armada-385.dtsi"
> +
> +#include 
> +
> +/ {
> + model = "Marvell Armada 385 Access Point Development Board";
> + compatible = "marvell,a385-db-ap", "marvell,armada385", 
> "marvell,armada380";
> +
> + chosen {
> + stdout-path = "serial1";
> + };
> +
> + memory {
> + device_type = "memory";
> + reg = <0x 0x8000>; /* 2GB */
> + };
> +
> + soc {
> + ranges = ;
> +
> + internal-regs {
> + i2c0: i2c@11000 {
> + pinctrl-names = "default";
> + pinctrl-0 = <&i2c0_pins>;
> + status = "okay";
> +
> + /*
> +  * This bus is wired to two EEPROM
> +  * sockets, one of which holding the
> +  * board ID used by the bootloader.
> +  * Erasing this EEPROM's content will
> +  * brick the board.
> +  * Use this bus with caution.
> +  */
> + };
> +
> + mdio@72004 {
> + pinctrl-names = "default";
> + pinctrl-0 = <&mdio_pins>;
> +
> + phy0: ethernet-phy@1 {
> + reg = <1>;
> + };
> +
> + phy1: ethernet-phy@4 {
> + reg = <4>;
> + };
> +
> + phy2: ethernet-phy@6 {
> +

svn commit: r312190 - head/usr.sbin/ctld

2017-01-14 Thread Alexander Motin
Author: mav
Date: Sat Jan 14 18:04:12 2017
New Revision: 312190
URL: https://svnweb.freebsd.org/changeset/base/312190

Log:
  Decouple iSCSI connection limits from defaults.
  
  If initiator does not negotiate some parameter, it expects one to get
  default value, not some unknown remote hardware limit.  On the side side,
  if some parameter is negotiated, its default value from RFC should not
  be used for anything.

Modified:
  head/usr.sbin/ctld/ctld.c
  head/usr.sbin/ctld/ctld.h
  head/usr.sbin/ctld/login.c

Modified: head/usr.sbin/ctld/ctld.c
==
--- head/usr.sbin/ctld/ctld.c   Sat Jan 14 16:58:49 2017(r312189)
+++ head/usr.sbin/ctld/ctld.c   Sat Jan 14 18:04:12 2017(r312190)
@@ -1582,6 +1582,7 @@ connection_new(struct portal *portal, in
 * Default values, from RFC 3720, section 12.
 */
conn->conn_max_recv_data_segment_length = 8192;
+   conn->conn_max_send_data_segment_length = 8192;
conn->conn_max_burst_length = 262144;
conn->conn_first_burst_length = 65536;
conn->conn_immediate_data = true;

Modified: head/usr.sbin/ctld/ctld.h
==
--- head/usr.sbin/ctld/ctld.h   Sat Jan 14 16:58:49 2017(r312189)
+++ head/usr.sbin/ctld/ctld.h   Sat Jan 14 18:04:12 2017(r312190)
@@ -48,8 +48,6 @@
 #defineMAX_LUNS1024
 #defineMAX_NAME_LEN223
 #defineMAX_DATA_SEGMENT_LENGTH (128 * 1024)
-#defineMAX_BURST_LENGTH16776192
-#defineFIRST_BURST_LENGTH  (128 * 1024)
 #defineSOCKBUF_SIZE1048576
 
 struct auth {
@@ -242,6 +240,10 @@ struct connection {
struct sockaddr_storage conn_initiator_sa;
uint32_tconn_cmdsn;
uint32_tconn_statsn;
+   int conn_max_recv_data_segment_limit;
+   int conn_max_send_data_segment_limit;
+   int conn_max_burst_limit;
+   int conn_first_burst_limit;
int conn_max_recv_data_segment_length;
int conn_max_send_data_segment_length;
int conn_max_burst_length;

Modified: head/usr.sbin/ctld/login.c
==
--- head/usr.sbin/ctld/login.c  Sat Jan 14 16:58:49 2017(r312189)
+++ head/usr.sbin/ctld/login.c  Sat Jan 14 18:04:12 2017(r312190)
@@ -557,13 +557,15 @@ login_negotiate_key(struct pdu *request,
 * our MaxRecvDataSegmentLength is not influenced by the
 * initiator in any way.
 */
-   if ((int)tmp > conn->conn_max_send_data_segment_length) {
-   log_debugx("capping max_send_data_segment_length "
+   if ((int)tmp > conn->conn_max_send_data_segment_limit) {
+   log_debugx("capping MaxRecvDataSegmentLength "
"from %zd to %d", tmp,
-   conn->conn_max_send_data_segment_length);
-   tmp = conn->conn_max_send_data_segment_length;
+   conn->conn_max_send_data_segment_limit);
+   tmp = conn->conn_max_send_data_segment_limit;
}
conn->conn_max_send_data_segment_length = tmp;
+   conn->conn_max_recv_data_segment_length =
+   conn->conn_max_recv_data_segment_limit;
keys_add_int(response_keys, name,
conn->conn_max_recv_data_segment_length);
} else if (strcmp(name, "MaxBurstLength") == 0) {
@@ -572,10 +574,10 @@ login_negotiate_key(struct pdu *request,
login_send_error(request, 0x02, 0x00);
log_errx(1, "received invalid MaxBurstLength");
}
-   if ((int)tmp > conn->conn_max_burst_length) {
+   if ((int)tmp > conn->conn_max_burst_limit) {
log_debugx("capping MaxBurstLength from %zd to %d",
-   tmp, conn->conn_max_burst_length);
-   tmp = conn->conn_max_burst_length;
+   tmp, conn->conn_max_burst_limit);
+   tmp = conn->conn_max_burst_limit;
}
conn->conn_max_burst_length = tmp;
keys_add_int(response_keys, name, tmp);
@@ -585,10 +587,10 @@ login_negotiate_key(struct pdu *request,
login_send_error(request, 0x02, 0x00);
log_errx(1, "received invalid FirstBurstLength");
}
-   if ((int)tmp > conn->conn_first_burst_length) {
+   if ((int)tmp > conn->conn_first_burst_limit) {

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

2017-01-14 Thread Jason A. Harmening
Author: jah
Date: Sat Jan 14 19:35:36 2017
New Revision: 312191
URL: https://svnweb.freebsd.org/changeset/base/312191

Log:
  Add comment explaining relative order of sched_unpin() and mtx_unlock().
  
  Suggested by: alc
  MFC after:1 week

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

Modified: head/sys/i386/i386/pmap.c
==
--- head/sys/i386/i386/pmap.c   Sat Jan 14 18:04:12 2017(r312190)
+++ head/sys/i386/i386/pmap.c   Sat Jan 14 19:35:36 2017(r312191)
@@ -4216,6 +4216,12 @@ pmap_zero_page(vm_page_t m)
invlcaddr(pc->pc_cmap_addr2);
pagezero(pc->pc_cmap_addr2);
*cmap_pte2 = 0;
+
+   /*
+* Unpin the thread before releasing the lock.  Otherwise the thread
+* could be rescheduled while still bound to the current CPU, only
+* to unpin itself immediately upon resuming execution.
+*/
sched_unpin();
mtx_unlock(&pc->pc_cmap_lock);
 }
___
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: r312192 - head/usr.sbin/ctld

2017-01-14 Thread Alexander Motin
Author: mav
Date: Sat Jan 14 19:58:51 2017
New Revision: 312192
URL: https://svnweb.freebsd.org/changeset/base/312192

Log:
  Fix wrong way assignment in r312190.

Modified:
  head/usr.sbin/ctld/login.c

Modified: head/usr.sbin/ctld/login.c
==
--- head/usr.sbin/ctld/login.c  Sat Jan 14 19:35:36 2017(r312191)
+++ head/usr.sbin/ctld/login.c  Sat Jan 14 19:58:51 2017(r312192)
@@ -725,8 +725,8 @@ login_negotiate(struct connection *conn,
 */
if (conn->conn_max_send_data_segment_limit <
conn->conn_max_send_data_segment_length) {
-   conn->conn_max_send_data_segment_limit =
-   conn->conn_max_send_data_segment_length;
+   conn->conn_max_send_data_segment_length =
+   conn->conn_max_send_data_segment_limit;
}
} else {
conn->conn_max_recv_data_segment_limit =
___
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: r312194 - in head/tests/sys: fs kern kqueue mac

2017-01-14 Thread Ngie Cooper
Author: ngie
Date: Sat Jan 14 20:29:26 2017
New Revision: 312194
URL: https://svnweb.freebsd.org/changeset/base/312194

Log:
  Add include Makefiles for tests/sys/{fs,kern,kqueue,mac}/...
  
  The primary goal for doing this is to leverage the work done in r312114
  for enabling WARNS to address trivial code quality issues with new tests
  
  MFC after:6 days
  Tested with:  make tinderbox
  Sponsored by: Dell EMC Isilon

Added:
  head/tests/sys/fs/Makefile.inc
 - copied unchanged from r312193, 
projects/netbsd-tests-upstream-01-2017/tests/sys/fs/Makefile.inc
  head/tests/sys/kern/Makefile.inc
 - copied unchanged from r312193, 
projects/netbsd-tests-upstream-01-2017/tests/sys/kern/Makefile.inc
  head/tests/sys/kqueue/Makefile.inc
 - copied unchanged from r312193, 
projects/netbsd-tests-upstream-01-2017/tests/sys/kqueue/Makefile.inc
  head/tests/sys/mac/Makefile.inc
 - copied unchanged from r312193, 
projects/netbsd-tests-upstream-01-2017/tests/sys/mac/Makefile.inc
Modified:
Directory Properties:
  head/   (props changed)

Copied: head/tests/sys/fs/Makefile.inc (from r312193, 
projects/netbsd-tests-upstream-01-2017/tests/sys/fs/Makefile.inc)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tests/sys/fs/Makefile.inc  Sat Jan 14 20:29:26 2017
(r312194, copy of r312193, 
projects/netbsd-tests-upstream-01-2017/tests/sys/fs/Makefile.inc)
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+.include "../Makefile.inc"

Copied: head/tests/sys/kern/Makefile.inc (from r312193, 
projects/netbsd-tests-upstream-01-2017/tests/sys/kern/Makefile.inc)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tests/sys/kern/Makefile.incSat Jan 14 20:29:26 2017
(r312194, copy of r312193, 
projects/netbsd-tests-upstream-01-2017/tests/sys/kern/Makefile.inc)
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+.include "../Makefile.inc"

Copied: head/tests/sys/kqueue/Makefile.inc (from r312193, 
projects/netbsd-tests-upstream-01-2017/tests/sys/kqueue/Makefile.inc)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tests/sys/kqueue/Makefile.inc  Sat Jan 14 20:29:26 2017
(r312194, copy of r312193, 
projects/netbsd-tests-upstream-01-2017/tests/sys/kqueue/Makefile.inc)
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+.include "../Makefile.inc"

Copied: head/tests/sys/mac/Makefile.inc (from r312193, 
projects/netbsd-tests-upstream-01-2017/tests/sys/mac/Makefile.inc)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tests/sys/mac/Makefile.inc Sat Jan 14 20:29:26 2017
(r312194, copy of r312193, 
projects/netbsd-tests-upstream-01-2017/tests/sys/mac/Makefile.inc)
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+.include "../Makefile.inc"
___
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: r312195 - head/usr.sbin/iscsid

2017-01-14 Thread Alexander Motin
Author: mav
Date: Sat Jan 14 20:41:44 2017
New Revision: 312195
URL: https://svnweb.freebsd.org/changeset/base/312195

Log:
  Alike to r312190 decouple iSCSI connection limits from defaults.
  
  Connection parameters should remain at defaults until negotiated.
  
  While there, remove sythetic limits, applied if kernel provided none.
  iscsid has no own limitations, no configuration and no any idea what
  values are good.  Assume kernel knows what it requests.

Modified:
  head/usr.sbin/iscsid/iscsid.c
  head/usr.sbin/iscsid/iscsid.h
  head/usr.sbin/iscsid/login.c

Modified: head/usr.sbin/iscsid/iscsid.c
==
--- head/usr.sbin/iscsid/iscsid.c   Sat Jan 14 20:29:26 2017
(r312194)
+++ head/usr.sbin/iscsid/iscsid.c   Sat Jan 14 20:41:44 2017
(r312195)
@@ -172,8 +172,10 @@ connection_new(int iscsi_fd, const struc
conn->conn_data_digest = CONN_DIGEST_NONE;
conn->conn_initial_r2t = true;
conn->conn_immediate_data = true;
-   conn->conn_max_burst_length = MAX_BURST_LENGTH;
-   conn->conn_first_burst_length = FIRST_BURST_LENGTH;
+   conn->conn_max_recv_data_segment_length = 8192;
+   conn->conn_max_send_data_segment_length = 8192;
+   conn->conn_max_burst_length = 262144;
+   conn->conn_first_burst_length = 65536;
conn->conn_iscsi_fd = iscsi_fd;
 
conn->conn_session_id = request->idr_session_id;
@@ -190,31 +192,28 @@ connection_new(int iscsi_fd, const struc
 */
isl = &conn->conn_limits;
memcpy(isl, &request->idr_limits, sizeof(*isl));
-   if (isl->isl_max_recv_data_segment_length == 0) {
-   conn->conn_max_recv_data_segment_length = 8192;
-   conn->conn_max_send_data_segment_length = 8192;
-   isl->isl_max_recv_data_segment_length = 8192;
-   } else {
-   conn->conn_max_recv_data_segment_length =
-   isl->isl_max_recv_data_segment_length;
-   conn->conn_max_send_data_segment_length =
-   isl->isl_max_recv_data_segment_length;
-   }
-   if (isl->isl_max_send_data_segment_length == 0) {
+   if (isl->isl_max_recv_data_segment_length == 0)
+   isl->isl_max_recv_data_segment_length = (1 << 24) - 1;
+   if (isl->isl_max_send_data_segment_length == 0)
isl->isl_max_send_data_segment_length =
isl->isl_max_recv_data_segment_length;
-   } else {
+   if (isl->isl_max_burst_length == 0)
+   isl->isl_max_burst_length = (1 << 24) - 1;
+   if (isl->isl_first_burst_length == 0)
+   isl->isl_first_burst_length = (1 << 24) - 1;
+   if (isl->isl_first_burst_length > isl->isl_max_burst_length)
+   isl->isl_first_burst_length = isl->isl_max_burst_length;
+
+   /*
+* Limit default send length in case it won't be negotiated.
+* We can't do it for other limits, since they may affect both
+* sender and receiver operation, and we must obey defaults.
+*/
+   if (conn->conn_max_send_data_segment_length >
+   isl->isl_max_send_data_segment_length) {
conn->conn_max_send_data_segment_length =
isl->isl_max_send_data_segment_length;
}
-   if (isl->isl_max_burst_length == 0)
-   isl->isl_max_burst_length = conn->conn_max_burst_length;
-   if (isl->isl_first_burst_length == 0) {
-   if (isl->isl_max_burst_length < 
(int)conn->conn_first_burst_length)
-   isl->isl_first_burst_length = isl->isl_max_burst_length;
-   else
-   isl->isl_first_burst_length = 
conn->conn_first_burst_length;
-   }
 
from_addr = conn->conn_conf.isc_initiator_addr;
to_addr = conn->conn_conf.isc_target_addr;

Modified: head/usr.sbin/iscsid/iscsid.h
==
--- head/usr.sbin/iscsid/iscsid.h   Sat Jan 14 20:29:26 2017
(r312194)
+++ head/usr.sbin/iscsid/iscsid.h   Sat Jan 14 20:41:44 2017
(r312195)
@@ -44,8 +44,6 @@
 
 #defineCONN_MUTUAL_CHALLENGE_LEN   1024
 #defineSOCKBUF_SIZE1048576
-#defineMAX_BURST_LENGTH(256 * 1024)
-#defineFIRST_BURST_LENGTH  (128 * 1024)
 
 struct connection {
int conn_iscsi_fd;

Modified: head/usr.sbin/iscsid/login.c
==
--- head/usr.sbin/iscsid/login.cSat Jan 14 20:29:26 2017
(r312194)
+++ head/usr.sbin/iscsid/login.cSat Jan 14 20:41:44 2017
(r312195)
@@ -397,6 +397,9 @@ login_negotiate_key(struct connection *c
tmp = isl->isl_max_send_data_segment_length;
}
conn->conn_max_send_data_segment_length = tmp;

Re: svn commit: r311952 - head/sys/ddb

2017-01-14 Thread Mark Johnston
On Fri, Jan 13, 2017 at 02:51:04PM +1100, Bruce Evans wrote:
> On Thu, 12 Jan 2017, Mark Johnston wrote:
> 
> > Log:
> >  Enable the use of ^C and ^S/^Q in DDB.
> >
> >  This lets one interrupt DDB's output, which is useful if paging is
> >  disabled and the output device is slow.
> 
> This is quite broken.  It removes the code that was necessary for avoiding
> loss of input.

Hi Bruce,

I've reverted this for now. I haven't thought much about how
db_check_interrupt() might losslessly poll the console driver for
ctrl-C, but I do think it's a valuable feature to have - just this
morning I absent-mindedly dumped a 128K-entry KTR ring from a DDB prompt
after having set $lines = 0, and had to wait for quite a while to get
my prompt back.

> 
> > Modified: head/sys/ddb/db_input.c
> > ==
> > --- head/sys/ddb/db_input.c Thu Jan 12 00:09:31 2017(r311951)
> > +++ head/sys/ddb/db_input.c Thu Jan 12 00:22:36 2017(r311952)
> > @@ -63,7 +63,6 @@ static intdb_lhist_nlines;
> > #define BLANK   ' '
> > #define BACKUP  '\b'
> >
> > -static int cnmaygetc(void);
> > static void db_delete(int n, int bwd);
> > static int  db_inputchar(int c);
> > static void db_putnchars(int c, int count);
> > @@ -291,12 +290,6 @@ db_inputchar(c)
> > return (0);
> > }
> >
> > -static int
> > -cnmaygetc()
> > -{
> > -   return (-1);
> > -}
> > -
> 
> BSD never had a usable console API (function) for checking for input.
> cncheckc() is the correct name for such a function.  The actual
> cncheckc() returns any input that it finds.  This is not the main
> problem here.  The input will have to be read here anyway to determine
> what it is.  The problems are that there is no console API at all for
> ungetting characters in the input stream, and this function doesn't
> even use a stub cnungetc(), but drops the input on the floor.  It does
> document this behaviour in a comment, but doesn't say that it is wrong.
> 
> > int
> > db_readline(lstart, lsize)
> > char *  lstart;
> > @@ -350,7 +343,7 @@ db_check_interrupt(void)
> > {
> > int c;
> >
> > -   c = cnmaygetc();
> > +   c = cncheckc();
> > switch (c) {
> > case -1:/* no character */
> > return;
> 
> The stub function always returns -1, so db_check_interrupt() is turned into
> a no-op.
> 
> db_check_interrupt() now eats the first byte of any input on every call.
> 
> > @@ -361,7 +354,7 @@ db_check_interrupt(void)
> >
> > case CTRL('s'):
> > do {
> > -   c = cnmaygetc();
> > +   c = cncheckc();
> > if (c == CTRL('c'))
> > db_error((char *)0);
> > } while (c != CTRL('q'));
> 
> This is now a bad implementation of xon/xoff.  It doesn't support ixany,
> but busy-waits for ^Q or ^C using cncheckc().  It should at least
> busy-wait using cngetc(), since that might be do a smarter busy wait.
> cngetc() is actually only slightly smarter -- it uses busy-waiting too,
> but with cpu_spinwait() in the loop.  This cpu_spinwait() makes little
> difference since cncheckc() tends to be a heavyweight function.  Only
> cpu_spinwait()s in the innermost loops of cncheckc(), if any, are likely
> to have much effect.
> 
> Multiple consoles complicate this a bit.
> 
> db_check_interrupt() is called after every db_putc() of a newline.  So
> the breakage is mainly for type-ahead while writing many lines.

I'll note that type-ahead interacts rather poorly with DDB's behaviour
of repeating the previous command upon reading an empty input line:
entering a carriage return at any point while "show ktr" is working will
cause it to be started again once it's finished.

> 
> Control processing belongs in the lowest level of console drivers, and
> at least the xon/xoff part is very easy to do.  This makes it work for
> contexts like boot messages -- this can only be controlled now by booting
> with -p, which gives something like an automatic ^S after every line,
> but the control characters for this mode are unusual and there is no
> way to get back to -p mode after turning it off or not starting with 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"


svn commit: r312196 - head/sys/ddb

2017-01-14 Thread Mark Johnston
Author: markj
Date: Sat Jan 14 22:06:25 2017
New Revision: 312196
URL: https://svnweb.freebsd.org/changeset/base/312196

Log:
  Revert r311952.
  
  It broke DDB type-ahead since it caused db_check_interrupt() to drop
  unrecognized characters.
  
  Reported by:  bde

Modified:
  head/sys/ddb/db_input.c

Modified: head/sys/ddb/db_input.c
==
--- head/sys/ddb/db_input.c Sat Jan 14 20:41:44 2017(r312195)
+++ head/sys/ddb/db_input.c Sat Jan 14 22:06:25 2017(r312196)
@@ -63,6 +63,7 @@ static intdb_lhist_nlines;
 #defineBLANK   ' '
 #defineBACKUP  '\b'
 
+static int cnmaygetc(void);
 static voiddb_delete(int n, int bwd);
 static int db_inputchar(int c);
 static voiddb_putnchars(int c, int count);
@@ -290,6 +291,12 @@ db_inputchar(c)
return (0);
 }
 
+static int
+cnmaygetc()
+{
+   return (-1);
+}
+
 int
 db_readline(lstart, lsize)
char *  lstart;
@@ -343,7 +350,7 @@ db_check_interrupt(void)
 {
int c;
 
-   c = cncheckc();
+   c = cnmaygetc();
switch (c) {
case -1:/* no character */
return;
@@ -354,7 +361,7 @@ db_check_interrupt(void)
 
case CTRL('s'):
do {
-   c = cncheckc();
+   c = cnmaygetc();
if (c == CTRL('c'))
db_error((char *)0);
} while (c != CTRL('q'));
___
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: r312199 - head/sys/kern

2017-01-14 Thread Mark Johnston
Author: markj
Date: Sat Jan 14 22:16:03 2017
New Revision: 312199
URL: https://svnweb.freebsd.org/changeset/base/312199

Log:
  Stop the scheduler upon panic even in non-SMP kernels.
  
  This is needed for kernel dumps to work, as the panicking thread will call
  into code that makes use of kernel locks.
  
  Reported and tested by:   Eugene Grosbein
  MFC after:1 week

Modified:
  head/sys/kern/kern_shutdown.c

Modified: head/sys/kern/kern_shutdown.c
==
--- head/sys/kern/kern_shutdown.c   Sat Jan 14 22:16:01 2017
(r312198)
+++ head/sys/kern/kern_shutdown.c   Sat Jan 14 22:16:03 2017
(r312199)
@@ -733,13 +733,13 @@ vpanic(const char *fmt, va_list ap)
CPU_CLR(PCPU_GET(cpuid), &other_cpus);
stop_cpus_hard(other_cpus);
}
+#endif
 
/*
 * Ensure that the scheduler is stopped while panicking, even if panic
 * has been entered from kdb.
 */
td->td_stopsched = 1;
-#endif
 
bootopt = RB_AUTOBOOT;
newpanic = 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: r312203 - head/sys/mips/conf

2017-01-14 Thread Michael Zhilin
Author: mizhka
Date: Sat Jan 14 22:56:20 2017
New Revision: 312203
URL: https://svnweb.freebsd.org/changeset/base/312203

Log:
  [mips/onionomega] WiFi & gpio kernel configuration bits
  
  This patch adds missing hints for ath0 (eepromaddr) and GPIO (mask & leds).
  ath0 doesn't work without eeprom hints, so this commit should make wifi
  works on Onion Omega.
  
  GPIO mask is required if you want to use gpiobus and GPIO pins on your
  board. Onion Omega has several leds connected to gpio pins (one on board,
  one color on dock).
  This commit adds mask for gpiobus and allow you to turn off/on leds via
  /dev/leds/{board,blue,green,red} (on by default).
  
  Tested on Onion Omega 1.
  
  Reviewed by:  adrian
  Approved by:  adrian (mentor)
  Differential Revision:https://reviews.freebsd.org/D9107

Modified:
  head/sys/mips/conf/ONIONOMEGA.hints

Modified: head/sys/mips/conf/ONIONOMEGA.hints
==
--- head/sys/mips/conf/ONIONOMEGA.hints Sat Jan 14 22:27:31 2017
(r312202)
+++ head/sys/mips/conf/ONIONOMEGA.hints Sat Jan 14 22:56:20 2017
(r312203)
@@ -31,6 +31,10 @@ hint.arge.1.media=1000
 hint.arge.1.fduplex=1
 hint.arge.1.eeprommac=0x1fff0006
 
+# ath0
+hint.ath.0.eepromaddr=0x1fff
+hint.ath.0.eepromsize=16384
+
 # 16MB flash layout:
 # [0.51] 5 tp-link partitions found on MTD device spi0.0
 # [0.51] Creating 5 MTD partitions on "spi0.0":
@@ -92,3 +96,30 @@ hint.map.6.start=0x00ff
 hint.map.6.end=0x0100
 hint.map.6.name="ART"
 hint.map.6.readonly=1
+
+# GPIO
+hint.gpio.0.pinmask=0x0c8ff1c3
+
+hint.gpioled.0.at="gpiobus0"
+hint.gpioled.0.pins=0x0800
+hint.gpioled.0.name="board"
+hint.gpioled.0.invert=0
+
+#Red
+hint.gpioled.1.at="gpiobus0"
+hint.gpioled.1.pins=0x0002
+hint.gpioled.1.name="red"
+hint.gpioled.1.invert=0
+
+#Green
+hint.gpioled.2.at="gpiobus0"
+hint.gpioled.2.pins=0x0001
+hint.gpioled.2.name="green"
+hint.gpioled.2.invert=0
+
+#Blue
+hint.gpioled.3.at="gpiobus0"
+hint.gpioled.3.pins=0x8000
+hint.gpioled.3.name="blue"
+hint.gpioled.3.invert=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: r312204 - head/sys/dev/etherswitch/micrel

2017-01-14 Thread Michael Zhilin
Author: mizhka
Date: Sat Jan 14 23:24:50 2017
New Revision: 312204
URL: https://svnweb.freebsd.org/changeset/base/312204

Log:
  [etherswitch] Support Micrel KSZ8995MA switch chip
  
  This is Micrel KSZ8995MA driver code. KSZ8995MA uses SPI bus to control.
  This code is written & tested on @SRCHACK's ksz8995ma board and FON2100
  with gpiospi.
  etherswitchcfg support commands: addtag, ingress, striptag, dropuntagged.
  
  Submitted by: Hiroki Mori 
  Reviewed by:  mizhka, adrian
  Approved by:  adrian (mentor)
  Differential Revision:https://reviews.freebsd.org/D8790

Added:
  head/sys/dev/etherswitch/micrel/
  head/sys/dev/etherswitch/micrel/ksz8995ma.c   (contents, props changed)

Added: head/sys/dev/etherswitch/micrel/ksz8995ma.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/etherswitch/micrel/ksz8995ma.c Sat Jan 14 23:24:50 2017
(r312204)
@@ -0,0 +1,960 @@
+/*-
+ * Copyright (c) 2016 Hiroki Mori
+ * Copyright (c) 2013 Luiz Otavio O Souza.
+ * Copyright (c) 2011-2012 Stefan Bethke.
+ * Copyright (c) 2012 Adrian Chadd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * This is Micrel KSZ8995MA driver code. KSZ8995MA use SPI bus on control.
+ * This code development on @SRCHACK's ksz8995ma board and FON2100 with
+ * gpiospi.
+ * etherswitchcfg command port option support addtag, ingress, striptag, 
+ * dropuntagged.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#include "spibus_if.h"
+#include "miibus_if.h"
+#include "etherswitch_if.h"
+
+#defineKSZ8995MA_SPI_READ  0x03
+#defineKSZ8995MA_SPI_WRITE 0x02
+
+#defineKSZ8995MA_CID0  0x00
+#defineKSZ8995MA_CID1  0x01
+
+#defineKSZ8995MA_GC0   0x02
+#defineKSZ8995MA_GC1   0x03
+#defineKSZ8995MA_GC2   0x04
+#defineKSZ8995MA_GC3   0x05
+
+#defineKSZ8995MA_PORT_SIZE 0x10
+
+#defineKSZ8995MA_PC0_BASE  0x10
+#defineKSZ8995MA_PC1_BASE  0x11
+#defineKSZ8995MA_PC2_BASE  0x12
+#defineKSZ8995MA_PC3_BASE  0x13
+#defineKSZ8995MA_PC4_BASE  0x14
+#defineKSZ8995MA_PC5_BASE  0x15
+#defineKSZ8995MA_PC6_BASE  0x16
+#defineKSZ8995MA_PC7_BASE  0x17
+#defineKSZ8995MA_PC8_BASE  0x18
+#defineKSZ8995MA_PC9_BASE  0x19
+#defineKSZ8995MA_PC10_BASE 0x1a
+#defineKSZ8995MA_PC11_BASE 0x1b
+#defineKSZ8995MA_PC12_BASE 0x1c
+#defineKSZ8995MA_PC13_BASE 0x1d
+
+#defineKSZ8995MA_PS0_BASE  0x1e
+
+#defineKSZ8995MA_PC14_BASE 0x1f
+
+#defineKSZ8995MA_IAC0  0x6e
+#defineKSZ8995MA_IAC1  0x6f
+#defineKSZ8995MA_IDR8  0x70
+#defineKSZ8995MA_IDR7  0x71
+#defineKSZ8995MA_IDR6  0x72
+#defineKSZ8995MA_IDR5  0x73
+#defineKSZ8995MA_IDR4  0x74
+#defineKSZ8995MA_IDR3  0x75
+#defineKSZ8995MA_IDR2  0x76
+#defineKSZ8995MA_IDR1  0x77

svn commit: r312205 - in head/sys: kern net

2017-01-14 Thread Sean Bruno
Author: sbruno
Date: Sun Jan 15 00:50:10 2017
New Revision: 312205
URL: https://svnweb.freebsd.org/changeset/base/312205

Log:
  Fix hangs in a uniprocessor configuration (qemu, virtualbox, real hw).
  
  sys/net/iflib.c:
Add ctx to filter_info and don't skpi interrupt early on unless we're on an
SMP system
  
  sys/kern/subr_gtaskqueue.c:
Skip smp check if we're running UP
  
  Submitted by: Matt Macy 
  Reported by:  emaste bde

Modified:
  head/sys/kern/subr_gtaskqueue.c
  head/sys/net/iflib.c

Modified: head/sys/kern/subr_gtaskqueue.c
==
--- head/sys/kern/subr_gtaskqueue.c Sat Jan 14 23:24:50 2017
(r312204)
+++ head/sys/kern/subr_gtaskqueue.c Sun Jan 15 00:50:10 2017
(r312205)
@@ -647,7 +647,7 @@ taskqgroup_attach(struct taskqgroup *qgr
qgroup->tqg_queue[qid].tgc_cnt++;
LIST_INSERT_HEAD(&qgroup->tqg_queue[qid].tgc_tasks, gtask, gt_list);
gtask->gt_taskqueue = qgroup->tqg_queue[qid].tgc_taskq;
-   if (irq != -1 && smp_started) {
+   if (irq != -1 && (smp_started || mp_ncpus == 1)) {
gtask->gt_cpu = qgroup->tqg_queue[qid].tgc_cpu;
CPU_ZERO(&mask);
CPU_SET(qgroup->tqg_queue[qid].tgc_cpu, &mask);
@@ -697,7 +697,7 @@ taskqgroup_attach_cpu(struct taskqgroup 
gtask->gt_irq = irq;
gtask->gt_cpu = cpu;
mtx_lock(&qgroup->tqg_lock);
-   if (smp_started) {
+   if (smp_started || mp_ncpus == 1) {
for (i = 0; i < qgroup->tqg_cnt; i++)
if (qgroup->tqg_queue[i].tgc_cpu == cpu) {
qid = i;
@@ -717,7 +717,7 @@ taskqgroup_attach_cpu(struct taskqgroup 
 
CPU_ZERO(&mask);
CPU_SET(cpu, &mask);
-   if (irq != -1 && smp_started)
+   if (irq != -1 && (smp_started || mp_ncpus == 1))
intr_setaffinity(irq, &mask);
return (0);
 }
@@ -731,7 +731,7 @@ taskqgroup_attach_cpu_deferred(struct ta
qid = -1;
irq = gtask->gt_irq;
cpu = gtask->gt_cpu;
-   MPASS(smp_started);
+   MPASS(smp_started || mp_ncpus == 1);
mtx_lock(&qgroup->tqg_lock);
for (i = 0; i < qgroup->tqg_cnt; i++)
if (qgroup->tqg_queue[i].tgc_cpu == cpu) {
@@ -824,7 +824,7 @@ _taskqgroup_adjust(struct taskqgroup *qg
 
mtx_assert(&qgroup->tqg_lock, MA_OWNED);
 
-   if (cnt < 1 || cnt * stride > mp_ncpus || !smp_started) {
+   if (cnt < 1 || cnt * stride > mp_ncpus || (!smp_started && (mp_ncpus != 
1))) {
printf("taskqgroup_adjust failed cnt: %d stride: %d mp_ncpus: 
%d smp_started: %d\n",
   cnt, stride, mp_ncpus, smp_started);
return (EINVAL);

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cSat Jan 14 23:24:50 2017(r312204)
+++ head/sys/net/iflib.cSun Jan 15 00:50:10 2017(r312205)
@@ -133,10 +133,13 @@ typedef struct iflib_rxq *iflib_rxq_t;
 struct iflib_fl;
 typedef struct iflib_fl *iflib_fl_t;
 
+struct iflib_ctx;
+
 typedef struct iflib_filter_info {
driver_filter_t *ifi_filter;
void *ifi_filter_arg;
struct grouptask *ifi_task;
+   struct iflib_ctx *ifi_ctx;
 } *iflib_filter_info_t;
 
 struct iflib_ctx {
@@ -300,6 +303,8 @@ typedef struct iflib_sw_tx_desc_array {
 #defineIFC_MULTISEG0x04
 #defineIFC_DMAR0x08
 #defineIFC_SC_ALLOCATED0x10
+#defineIFC_INIT_DONE   0x20
+
 
 #define CSUM_OFFLOAD   (CSUM_IP_TSO|CSUM_IP6_TSO|CSUM_IP| \
 CSUM_IP_UDP|CSUM_IP_TCP|CSUM_IP_SCTP| \
@@ -1194,7 +1199,7 @@ iflib_fast_intr(void *arg)
iflib_filter_info_t info = arg;
struct grouptask *gtask = info->ifi_task;
 
-   if (!smp_started)
+   if (!smp_started && mp_ncpus > 1)
return (FILTER_HANDLED);
 
DBG_COUNTER_INC(fast_intrs);
@@ -3753,6 +3758,7 @@ iflib_device_register(device_t dev, void
 
if_setgetcounterfn(ctx->ifc_ifp, iflib_if_get_counter);
iflib_add_device_sysctl_post(ctx);
+   ctx->ifc_flags |= IFC_INIT_DONE;
return (0);
 fail_detach:
ether_ifdetach(ctx->ifc_ifp);
@@ -4471,6 +4477,7 @@ iflib_irq_alloc_generic(if_ctx_t ctx, if
info->ifi_filter = filter;
info->ifi_filter_arg = filter_arg;
info->ifi_task = gtask;
+   info->ifi_ctx = ctx;
 
err = _iflib_irq_alloc(ctx, irq, rid, iflib_fast_intr, NULL, info,  
name);
if (err != 0) {
@@ -4567,6 +4574,7 @@ iflib_legacy_setup(if_ctx_t ctx, driver_
info->ifi_filter = filter;
info->ifi_filter_arg = filter_arg;
info->ifi_task = gtask;
+   info->ifi_ctx = ctx;
 
/* We allocate a single interrupt resource */
if ((err = _iflib_irq_alloc(ctx, irq, tqrid, i

svn commit: r312208 - head/sys/vm

2017-01-14 Thread Mark Johnston
Author: markj
Date: Sun Jan 15 03:50:08 2017
New Revision: 312208
URL: https://svnweb.freebsd.org/changeset/base/312208

Log:
  Avoid unnecessary page lookups in vm_object_madvise().
  
  vm_object_madvise() is frequently used to apply advice to a contiguous
  set of pages in an object with no backing object. Optimize this case by
  skipping non-resident subranges in constant time, and by iterating over
  resident pages using the object memq, thus avoiding radix tree lookups on
  each page index in the specified range.
  
  While here, move MADV_WILLNEED handling to vm_page_advise(), and rename the
  "advise" parameter to vm_object_madvise() to "advice."
  
  Reviewed by:  alc, kib
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D9098

Modified:
  head/sys/vm/vm_object.c
  head/sys/vm/vm_page.c

Modified: head/sys/vm/vm_object.c
==
--- head/sys/vm/vm_object.c Sun Jan 15 01:36:45 2017(r312207)
+++ head/sys/vm/vm_object.c Sun Jan 15 03:50:08 2017(r312208)
@@ -1097,7 +1097,7 @@ vm_object_sync(vm_object_t object, vm_oo
  */
 void
 vm_object_madvise(vm_object_t object, vm_pindex_t pindex, vm_pindex_t end,
-int advise)
+int advice)
 {
vm_pindex_t tpindex;
vm_object_t backing_object, tobject;
@@ -1105,11 +1105,9 @@ vm_object_madvise(vm_object_t object, vm
 
if (object == NULL)
return;
+
VM_OBJECT_WLOCK(object);
-   /*
-* Locate and adjust resident pages
-*/
-   for (; pindex < end; pindex += 1) {
+   for (m = NULL; pindex < end; pindex++) {
 relookup:
tobject = object;
tpindex = pindex;
@@ -1118,7 +1116,7 @@ shadowlookup:
 * MADV_FREE only operates on OBJT_DEFAULT or OBJT_SWAP pages
 * and those pages must be OBJ_ONEMAPPING.
 */
-   if (advise == MADV_FREE) {
+   if (advice == MADV_FREE) {
if ((tobject->type != OBJT_DEFAULT &&
 tobject->type != OBJT_SWAP) ||
(tobject->flags & OBJ_ONEMAPPING) == 0) {
@@ -1126,15 +1124,29 @@ shadowlookup:
}
} else if ((tobject->flags & OBJ_UNMANAGED) != 0)
goto unlock_tobject;
-   m = vm_page_lookup(tobject, tpindex);
-   if (m == NULL) {
-   /*
-* There may be swap even if there is no backing page
-*/
-   if (advise == MADV_FREE && tobject->type == OBJT_SWAP)
+
+   /*
+* In the common case where the object has no backing object, we
+* can avoid performing lookups at each pindex.  In either case,
+* when applying MADV_FREE we take care to release any swap
+* space used to store non-resident pages.
+*/
+   if (object->backing_object == NULL) {
+   m = (m != NULL) ? TAILQ_NEXT(m, listq) :
+   vm_page_find_least(object, pindex);
+   tpindex = (m != NULL && m->pindex < end) ?
+   m->pindex : end;
+   if (advice == MADV_FREE && object->type == OBJT_SWAP &&
+   tpindex > pindex)
+   swap_pager_freespace(object, pindex,
+   tpindex - pindex);
+   if ((pindex = tpindex) == end)
+   break;
+   } else if ((m = vm_page_lookup(tobject, tpindex)) == NULL) {
+   if (advice == MADV_FREE && tobject->type == OBJT_SWAP)
swap_pager_freespace(tobject, tpindex, 1);
/*
-* next object
+* Prepare to search the next object in the chain.
 */
backing_object = tobject->backing_object;
if (backing_object == NULL)
@@ -1145,11 +1157,13 @@ shadowlookup:
VM_OBJECT_WUNLOCK(tobject);
tobject = backing_object;
goto shadowlookup;
-   } else if (m->valid != VM_PAGE_BITS_ALL)
-   goto unlock_tobject;
+   }
+
/*
 * If the page is not in a normal state, skip it.
 */
+   if (m->valid != VM_PAGE_BITS_ALL)
+   goto unlock_tobject;
vm_page_lock(m);
if (m->hold_count != 0 || m->wire_count != 0) {
vm_page_unlock(m);
@@ -1160,7 +1174,7 @@ shadowlookup:
KASSERT((m->oflags & VPO_UNMANAGED) == 0,
("vm_object_madvise: page %p is not

svn commit: r312209 - head/sys/kern

2017-01-14 Thread Mark Johnston
Author: markj
Date: Sun Jan 15 03:53:20 2017
New Revision: 312209
URL: https://svnweb.freebsd.org/changeset/base/312209

Log:
  Suppress a warning about m_assertbuf being unused.
  
  MFC after:1 week

Modified:
  head/sys/kern/uipc_mbuf.c

Modified: head/sys/kern/uipc_mbuf.c
==
--- head/sys/kern/uipc_mbuf.c   Sun Jan 15 03:50:08 2017(r312208)
+++ head/sys/kern/uipc_mbuf.c   Sun Jan 15 03:53:20 2017(r312209)
@@ -169,7 +169,7 @@ CTASSERT(sizeof(struct m_ext) == 28);
  * plain pointer does.
  */
 #ifdef INVARIANTS
-static struct mbuf m_assertbuf;
+static struct mbuf __used m_assertbuf;
 CTASSERT(sizeof(m_assertbuf.m_slist) == sizeof(m_assertbuf.m_next));
 CTASSERT(sizeof(m_assertbuf.m_stailq) == sizeof(m_assertbuf.m_next));
 CTASSERT(sizeof(m_assertbuf.m_slistpkt) == sizeof(m_assertbuf.m_nextpkt));
___
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: r311952 - head/sys/ddb

2017-01-14 Thread Julian Elischer

On 15/01/2017 6:06 AM, Mark Johnston wrote:

On Fri, Jan 13, 2017 at 02:51:04PM +1100, Bruce Evans wrote:

On Thu, 12 Jan 2017, Mark Johnston wrote:


Log:
  Enable the use of ^C and ^S/^Q in DDB.

  This lets one interrupt DDB's output, which is useful if paging is
  disabled and the output device is slow.

This is quite broken.  It removes the code that was necessary for avoiding
loss of input.

Hi Bruce,

I've reverted this for now. I haven't thought much about how
db_check_interrupt() might losslessly poll the console driver for
ctrl-C, but I do think it's a valuable feature to have - just this
morning I absent-mindedly dumped a 128K-entry KTR ring from a DDB prompt
after having set $lines = 0, and had to wait for quite a while to get
my prompt back.


Modified: head/sys/ddb/db_input.c
==
--- head/sys/ddb/db_input.c Thu Jan 12 00:09:31 2017(r311951)
+++ head/sys/ddb/db_input.c Thu Jan 12 00:22:36 2017(r311952)
@@ -63,7 +63,6 @@ static intdb_lhist_nlines;
#define BLANK   ' '
#define BACKUP  '\b'

-static int cnmaygetc(void);
static void db_delete(int n, int bwd);
static int  db_inputchar(int c);
static void db_putnchars(int c, int count);
@@ -291,12 +290,6 @@ db_inputchar(c)
return (0);
}

-static int
-cnmaygetc()
-{
-   return (-1);
-}
-

BSD never had a usable console API (function) for checking for input.
cncheckc() is the correct name for such a function.  The actual
cncheckc() returns any input that it finds.  This is not the main
problem here.  The input will have to be read here anyway to determine
what it is.  The problems are that there is no console API at all for
ungetting characters in the input stream, and this function doesn't
even use a stub cnungetc(), but drops the input on the floor.  It does
document this behaviour in a comment, but doesn't say that it is wrong.


int
db_readline(lstart, lsize)
char *  lstart;
@@ -350,7 +343,7 @@ db_check_interrupt(void)
{
int c;

-   c = cnmaygetc();
+   c = cncheckc();
switch (c) {
case -1:/* no character */
return;

The stub function always returns -1, so db_check_interrupt() is turned into
a no-op.

db_check_interrupt() now eats the first byte of any input on every call.


@@ -361,7 +354,7 @@ db_check_interrupt(void)

case CTRL('s'):
do {
-   c = cnmaygetc();
+   c = cncheckc();
if (c == CTRL('c'))
db_error((char *)0);
} while (c != CTRL('q'));

This is now a bad implementation of xon/xoff.  It doesn't support ixany,
but busy-waits for ^Q or ^C using cncheckc().  It should at least
busy-wait using cngetc(), since that might be do a smarter busy wait.
cngetc() is actually only slightly smarter -- it uses busy-waiting too,
but with cpu_spinwait() in the loop.  This cpu_spinwait() makes little
difference since cncheckc() tends to be a heavyweight function.  Only
cpu_spinwait()s in the innermost loops of cncheckc(), if any, are likely
to have much effect.

Multiple consoles complicate this a bit.

db_check_interrupt() is called after every db_putc() of a newline.  So
the breakage is mainly for type-ahead while writing many lines.

I'll note that type-ahead interacts rather poorly with DDB's behaviour
of repeating the previous command upon reading an empty input line:
entering a carriage return at any point while "show ktr" is working will
cause it to be started again once it's finished.


the old DEC machines had (from memory) ^O  which dropped all pending 
output.
Not so useful when there is 2MB of network buffers queued up to you, 
but very useful on

and asr-33 teletype.




Control processing belongs in the lowest level of console drivers, and
at least the xon/xoff part is very easy to do.  This makes it work for
contexts like boot messages -- this can only be controlled now by booting
with -p, which gives something like an automatic ^S after every line,
but the control characters for this mode are unusual and there is no
way to get back to -p mode after turning it off or not starting with 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: r312199 - head/sys/kern

2017-01-14 Thread Bruce Evans

On Sat, 14 Jan 2017, Mark Johnston wrote:


Log:
 Stop the scheduler upon panic even in non-SMP kernels.

 This is needed for kernel dumps to work, as the panicking thread will call
 into code that makes use of kernel locks.

 Reported and tested by:Eugene Grosbein
 MFC after: 1 week

Modified:
 head/sys/kern/kern_shutdown.c

Modified: head/sys/kern/kern_shutdown.c
==
--- head/sys/kern/kern_shutdown.c   Sat Jan 14 22:16:01 2017
(r312198)
+++ head/sys/kern/kern_shutdown.c   Sat Jan 14 22:16:03 2017
(r312199)
@@ -733,13 +733,13 @@ vpanic(const char *fmt, va_list ap)
CPU_CLR(PCPU_GET(cpuid), &other_cpus);
stop_cpus_hard(other_cpus);
}
+#endif

/*
 * Ensure that the scheduler is stopped while panicking, even if panic
 * has been entered from kdb.
 */
td->td_stopsched = 1;
-#endif

bootopt = RB_AUTOBOOT;
newpanic = 0;


This variable causes various problems.  In my patches for early use of the
message buffer, I have to provide a fake td to point to it since curthread
is not initialized early and message buffer code does bogus locking.

This variable used to be a global, but was changed to per-thread because it
was claimed to cause cache contention.  I don't see how a the global can
cause significant contention (or more than other globals) provided it is
not in the same cache line as an often-written-to global.  This variable
is not even checked by inline mutex code, so this code is broken and without
INVARIANTS the variable is mainly accessed in the contended case, but the
contended case is already slow and accesses many other globals.

The accesses are well obfuscated by ifdefs.  __mtx_lock_sleep() seems to
have only the following at the beginning in the non-INVARIANTS case:
- SCHEDULER_STOPPED() accesses this variable
- then if ADAPTIVE_MUTEXES is configured, the much larger global mtx_delay
  is accessed.  Even standard compiler optimizations are likely to copy from
  static global data to initialize constants a bit like this.
These seem to be the only globals in the main, not counting per-CPU ones
like curthread.  This and other mutex functions recently gained the
dubious optimization of initializing lda early in the main path.  This is
correct if the main path is usually to do almost everything (because the
usual case is contended).

Scheduler code also checks 'cold' quite often and kdb_active sometimes.
It is not called as often as mutex code.  No care is taken to keep 'cold'
away from other globals.  On i386, it is just 'int cold = 1;' in machdep.c,
so it is placed wherever the linker decides to pack it.

WHen this variable was changed from global to thread-local, it was set for
more threads.  Now it is set for only 1 thread.  This depends on all other
CPUs being stopped so that they can't be running other threads.  If another
thread somehow runs, then the thread variable is much more broken than the
global since it doesn't stop scheduling on all threads.  Perhaps the change
to stop other threads made the global less pessimal than before (I can't
see why -- efficiency doesn't matter while the scheduler is stopped --
we just need to make the access efficient in normal operation when the
variable is 0).

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: r312211 - head/sys/mips/atheros

2017-01-14 Thread Adrian Chadd
Author: adrian
Date: Sun Jan 15 06:35:00 2017
New Revision: 312211
URL: https://svnweb.freebsd.org/changeset/base/312211

Log:
  [ar71xx] add EARLY_PRINTF support for the rest of the non-AR933x SoCs.
  
  Tested:
  
  * AR934x SoC

Modified:
  head/sys/mips/atheros/ar71xxreg.h
  head/sys/mips/atheros/uart_bus_ar71xx.c

Modified: head/sys/mips/atheros/ar71xxreg.h
==
--- head/sys/mips/atheros/ar71xxreg.h   Sun Jan 15 04:23:20 2017
(r312210)
+++ head/sys/mips/atheros/ar71xxreg.h   Sun Jan 15 06:35:00 2017
(r312211)
@@ -111,6 +111,10 @@
 #define PCI_WINDOW7_CONF_ADDR  0x0700
 
 #defineAR71XX_UART_ADDR0x1802
+#defineAR71XX_UART_THR 0x0
+#defineAR71XX_UART_LSR 0x14
+#defineAR71XX_UART_LSR_THRE(1 << 5)
+#defineAR71XX_UART_LSR_TEMT(1 << 6)
 
 #defineAR71XX_USB_CTRL_FLADJ   0x1803
 #defineUSB_CTRL_FLADJ_HOST_SHIFT   12

Modified: head/sys/mips/atheros/uart_bus_ar71xx.c
==
--- head/sys/mips/atheros/uart_bus_ar71xx.c Sun Jan 15 04:23:20 2017
(r312210)
+++ head/sys/mips/atheros/uart_bus_ar71xx.c Sun Jan 15 06:35:00 2017
(r312211)
@@ -86,4 +86,21 @@ uart_ar71xx_probe(device_t dev)
return (uart_bus_probe(dev, 2, freq, 0, 0));
 }
 
+#ifdef EARLY_PRINTF
+static void
+ar71xx_early_putc(int c)
+{
+   int i;
+
+   for (i = 0; i < 1000; i++) {
+   if (ATH_READ_REG(AR71XX_UART_ADDR + AR71XX_UART_LSR)
+   & AR71XX_UART_LSR_THRE)
+   break;
+   }
+
+   ATH_WRITE_REG(AR71XX_UART_ADDR + AR71XX_UART_THR, (c & 0xff));
+}
+early_putc_t *early_putc = ar71xx_early_putc;
+#endif
+
 DRIVER_MODULE(uart, apb, uart_ar71xx_driver, uart_devclass, 0, 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: r312119 - head/sys/kern

2017-01-14 Thread Bruce Evans

On Sat, 14 Jan 2017, Ngie Cooper wrote:


Log:
 encode_long, encode_timeval: mechanically replace `exp` with `exponent`

 This helps fix a -Wshadow issue with exp(3) with tests/sys/acct/acct_test,
 which include math.h, which in turn defines exp(3)


But kern_acct.c doesn't include math.h.

This messes up the kernel sources to simplify abusing them in tests.

The bug was only in the sed script in the makefile that translates
kern_acct.c to convert.c.  It converts 'log(' to 'syslog(', but is missing
conversion of the exp identifier to sysexp.


==
--- head/sys/kern/kern_acct.c   Sat Jan 14 05:02:53 2017(r312118)
+++ head/sys/kern/kern_acct.c   Sat Jan 14 05:06:14 2017(r312119)
@@ -469,8 +469,8 @@ static uint32_t
encode_timeval(struct timeval tv)
{
int log2_s;
-   int val, exp;   /* Unnormalized value and exponent */
-   int norm_exp;   /* Normalized exponent */
+   int val, exponent;  /* Unnormalized value and exponent */
+   int norm_exponent;  /* Normalized exponent */
int shift;

/*


Now the bug is also bad style in the kernel sources.  The regexp was too
simple and munged norm_exp too, but not the exp's in comments.  The
comments are more banal than before now that they don't even expand 'exp'
but just echo 'exponent'.


...
-   return (((FLT_MAX_EXP - 1 + exp + norm_exp) << (FLT_MANT_DIG - 1)) |
+   return (((FLT_MAX_EXP - 1 + exponent + norm_exponent) << (FLT_MANT_DIG 
- 1)) |
((shift > 0 ? val << shift : val >> -shift) & MANT_MASK));


Here the expansion also broke the formatting.

The details of the abuse in the test program are that acct_test.c includes
math.h and then includes then convert.c which is nearly a copy of the kernel
source file.  This takes clean include files and not enabling warnings
about redundant declarations to have a chance of working.

I use a similar hack to test libm, and didn't have to mess up the sources
too much to make the translation not too hard.  Files have to be copied
just to make the include paths manageable, and to compile them all with
the same CFLAGS since this is a performance test.  The most complicated
parts are to avoid library functions because they might not match the
sources or were compiled with different CFLAGS.  The sources are not well
organized well enough for my preferred method of "cc ${CLAGS} *.c" to work.

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"


Re: svn commit: r312205 - in head/sys: kern net

2017-01-14 Thread Ivan Klymenko
On Sun, 15 Jan 2017 00:50:10 + (UTC)
Sean Bruno  wrote:

> Log:
>   Fix hangs in a uniprocessor configuration (qemu, virtualbox, real
> hw).

Hello.

MFC to STABLE?
___
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"