Re: svn commit: r344569 - in head/cddl/contrib/opensolaris: cmd/zfs lib/libzfs/common

2019-02-26 Thread Andriy Gapon
On 26/02/2019 22:58, Cy Schubert wrote:
> I was talking about nested datasets, i.e. tank/freebsd/git/current and 
> tank/freebsd/git/ports are four levels deep.

We usually don't call them "nested".  In fact, I don't think that we call them
anything special because having N levels deep datasets (N > 1) is just a common
thing.  We may call them subordinate or child datasets when mentioning a
relation to a parent dataset.

> In my case the ports 
> dataset was mounted while the current dataset was not, though zfs 
> believed it was. unmounting the current dataset and remounting it, zfs 
> umount .../current; zfs mount .../current worked around the issue.

Are you sure that it was not mounted?
Have you checked that by looking at mount output?
I suspect that it was mounted, just not where you expected and its mount path
was covered by another filesystem.

E.g., lets consider this hypothetical case.
I have two same level datasets tank/freebsd/src and tank/freebsd/sys where
tank/freebsd/src is mounted at /usr/src and tank/freebsd/sys is mounted at
/usr/src/sys (a child directory of /usr/src).
If tank/freebsd/src is mounted first, then everything is okay, tank/freebsd/sys
would be mounted on top of sys directory in tank/freebsd/src.
If, however, tank/freebsd/sys is mounted first (assuming that path /usr/src/sys
exists in a root filesystem), then mounting tank/freebsd/src would simply hide
tank/freebsd/sys "below" it as /usr/src/sys would be sys directory in
tank/freebsd/src.

I guess that this is a kind of problem that could be introduced with parallel
mounting.  And I guess that this is a kind of problem that you might actually
have.  But it's just a guess.

-- 
Andriy Gapon
___
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: r344361 - head/cddl/contrib/opensolaris/cmd/zpool

2019-02-20 Thread Andriy Gapon
Author: avg
Date: Wed Feb 20 13:37:27 2019
New Revision: 344361
URL: https://svnweb.freebsd.org/changeset/base/344361

Log:
  zpool.8: sort zpool status flags in the same order as in illumos manual
  
  Just in case, while I was here.
  
  MFC after:1 week

Modified:
  head/cddl/contrib/opensolaris/cmd/zpool/zpool.8

Modified: head/cddl/contrib/opensolaris/cmd/zpool/zpool.8
==
--- head/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Wed Feb 20 13:34:16 
2019(r344360)
+++ head/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Wed Feb 20 13:37:27 
2019(r344361)
@@ -1897,14 +1897,6 @@ Display a histogram of deduplication statistics, showi
 and referenced
 .Pq logically referenced in the pool
 block counts and sizes by reference count.
-.It Fl x
-Only display status for pools that are exhibiting errors or are otherwise
-unavailable.
-Warnings about pools not using the latest on-disk format, having non-native
-block size or disabled features will not be included.
-.It Fl v
-Displays verbose data error information, printing out a complete list of all
-data errors since the last complete pool scrub.
 .It Fl T Cm d Ns | Ns Cm u
 Print a timestamp.
 .Pp
@@ -1916,6 +1908,14 @@ Use modifier
 .Cm u
 for unixtime
 .Pq equals Qq Ic date +%s .
+.It Fl v
+Displays verbose data error information, printing out a complete list of all
+data errors since the last complete pool scrub.
+.It Fl x
+Only display status for pools that are exhibiting errors or are otherwise
+unavailable.
+Warnings about pools not using the latest on-disk format, having non-native
+block size or disabled features will not be included.
 .El
 .It Xo
 .Nm
___
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: r344360 - head/cddl/contrib/opensolaris/cmd/zpool

2019-02-20 Thread Andriy Gapon
Author: avg
Date: Wed Feb 20 13:34:16 2019
New Revision: 344360
URL: https://svnweb.freebsd.org/changeset/base/344360

Log:
  zpool.8: document -D flag for zpool status
  
  The description is taken from the illumos manual.
  
  Reported by:  stil...@gmail.com
  MFC after:1 week

Modified:
  head/cddl/contrib/opensolaris/cmd/zpool/zpool.8

Modified: head/cddl/contrib/opensolaris/cmd/zpool/zpool.8
==
--- head/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Wed Feb 20 13:19:08 
2019(r344359)
+++ head/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Wed Feb 20 13:34:16 
2019(r344360)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 27, 2018
+.Dd February 20, 2019
 .Dt ZPOOL 8
 .Os
 .Sh NAME
@@ -187,7 +187,7 @@
 .Op Ar device ...
 .Nm
 .Cm status
-.Op Fl vx
+.Op Fl Dvx
 .Op Fl T Cm d Ns | Ns Cm u
 .Op Ar pool
 .Ar ...
@@ -1862,7 +1862,7 @@ section, above, for more information on the available 
 .It Xo
 .Nm
 .Cm status
-.Op Fl vx
+.Op Fl Dvx
 .Op Fl T Cm d Ns | Ns Cm u
 .Op Ar pool
 .Ar ...
@@ -1891,6 +1891,12 @@ done and the estimated time to completion. Both of the
 because the amount of data in the pool and the other workloads on the system
 can change.
 .Bl -tag -width indent
+.It Fl D
+Display a histogram of deduplication statistics, showing the allocated
+.Pq physically present on disk
+and referenced
+.Pq logically referenced in the pool
+block counts and sizes by reference count.
 .It Fl x
 Only display status for pools that are exhibiting errors or are otherwise
 unavailable.
___
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: r344359 - head/cddl/contrib/opensolaris/lib/libzpool/common

2019-02-20 Thread Andriy Gapon
Author: avg
Date: Wed Feb 20 13:19:08 2019
New Revision: 344359
URL: https://svnweb.freebsd.org/changeset/base/344359

Log:
  fix userland illumos taskq code to pass relative timeout to cv_timedwait
  
  Unlike illumos, FreeBSD cv_timedwait requires a relative timeout.  That
  applies both to the kernel illumos compatibility code and to the
  userland "fake kernel" code.
  
  MFC after:2 weeks
  Sponsored by: Panzura

Modified:
  head/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c

Modified: head/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c
==
--- head/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c   Wed Feb 20 
11:58:40 2019(r344358)
+++ head/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c   Wed Feb 20 
13:19:08 2019(r344359)
@@ -79,8 +79,13 @@ again:   if ((t = tq->tq_freelist) != NULL && tq->tq_nal
 * immediately retry the allocation.
 */
tq->tq_maxalloc_wait++;
+#ifdef __FreeBSD__
rv = cv_timedwait(&tq->tq_maxalloc_cv,
+   &tq->tq_lock, hz);
+#else
+   rv = cv_timedwait(&tq->tq_maxalloc_cv,
&tq->tq_lock, ddi_get_lbolt() + hz);
+#endif
tq->tq_maxalloc_wait--;
if (rv > 0)
goto again; /* signaled */
___
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: r343113 - head/contrib/libc++/include

2019-01-17 Thread Andriy Gapon
On 17/01/2019 17:35, Kirk McKusick wrote:
> -#ifdef ELAST
> +#if defined(ELAST)

I think that these are exactly the same, so not sure what the change does.

-- 
Andriy Gapon
___
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: r343026 - in head: lib/libmemstat sys/vm

2019-01-14 Thread Andriy Gapon
On 15/01/2019 02:02, Gleb Smirnoff wrote:
>   o Since new limits don't play well with multi-keg zones, remove them. The
> idea of multi-keg zones was introduced exactly 10 years ago, and never
> have had a practical usage. In discussion with Jeff we came to a wild
> agreement that if we ever want to reintroduce the idea of a smart 
> allocator
> that would be able to choose between two (or more) totally different
> backing stores, that choice should be made one level higher than UMA,
> e.g. in malloc(9) or in mget(), or whatever and choice should be 
> controlled
> by the caller.

I would make this a separate commit before the main change.
But no troubles.
Thank you for the change!

-- 
Andriy Gapon
___
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: r342541 - in head: cddl/contrib/opensolaris/cmd/zpool sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris/uts/common/sys/fs

2018-12-26 Thread Andriy Gapon
Author: avg
Date: Wed Dec 26 11:03:14 2018
New Revision: 342541
URL: https://svnweb.freebsd.org/changeset/base/342541

Log:
  MFV r342532: 5882 Temporary pool names
  
  Note that this commit brings only formatting changes that were done
  during the final review of the illumos change, because FreeBSD got the
  main changes before illumos.
  
  illumos/illumos-gate@04e56356520b98d5a93c496b10f02530bb6647e0
  
https://github.com/illumos/illumos-gate/commit/04e56356520b98d5a93c496b10f02530bb6647e0
  
  https://www.illumos.org/issues/5882
This is an import of the temporary pool names functionality from ZoL:

https://github.com/zfsonlinux/zfs/commit/e2282ef57edc79cdce2a4b9b7ec56494a807

https://github.com/zfsonlinux/zfs/commit/26b42f3f9d03f85cc7966dc2fe4dfe9216601b0e

https://github.com/zfsonlinux/zfs/commit/2f3ec9006146844af6763d1fa4e823fd9047fd54

https://github.com/zfsonlinux/zfs/commit/00d2a8c92f614f49d23dea5d73f7ea7eb489ccf1

https://github.com/zfsonlinux/zfs/commit/83e9986f6eefdf0afc387f06407087bba3ead4e9

https://github.com/zfsonlinux/zfs/commit/023bbe6f017380f4a04c5060feb24dd8cdda9fce
It is intended to assist the creation and management of virtual machines
that have their rootfs on ZFS on hosts that also have their rootfs on
ZFS. These situations cause SPA namespace collisions when the standard
name rpool is used in both cases. The solution is either to give each
guest pool a name unique to the host, which is not always desireable, or
boot a VM environment containing an ISO image to install it, which is
cumbersome.
  
  MFC after:1 week
  Sponsored by: Panzura

Modified:
  head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c
  head/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h
Directory Properties:
  head/cddl/contrib/opensolaris/   (props changed)
  head/sys/cddl/contrib/opensolaris/   (props changed)

Modified: head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
==
--- head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.cWed Dec 26 
10:48:39 2018(r342540)
+++ head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.cWed Dec 26 
11:03:14 2018(r342541)
@@ -1273,7 +1273,7 @@ badusage:
 /*
  * zpool destroy 
  *
- * -f  Forcefully unmount any datasets
+ * -f  Forcefully unmount any datasets
  *
  * Destroy the given pool.  Automatically unmounts any datasets in the pool.
  */
@@ -2165,8 +2165,8 @@ do_import(nvlist_t *config, const char *newname, const
  * zpool checkpoint 
  *   checkpoint --discard 
  *
- *   -d Discard the checkpoint from a checkpointed
- *   --discard  pool.
+ * -d  Discard the checkpoint from a checkpointed
+ * --discard  pool.
  *
  * Checkpoints the specified pool, by taking a "snapshot" of its
  * current state. A pool can only have one checkpoint at a time.
@@ -2242,45 +2242,45 @@ zpool_do_checkpoint(int argc, char **argv)
  *  [-d dir | -c cachefile] [-f] [-n] [-F] [-t]
  *   [newpool]
  *
- *  -c Read pool information from a cachefile instead of searching
+ * -c  Read pool information from a cachefile instead of searching
  * devices.
  *
- *   -dScan in a specific directory, other than /dev/dsk.  More than
+ * -d  Scan in a specific directory, other than /dev/dsk.  More than
  * one directory can be specified using multiple '-d' options.
  *
- *   -D Scan for previously destroyed pools or import all or only
- *  specified destroyed pools.
+ * -D  Scan for previously destroyed pools or import all or only
+ * specified destroyed pools.
  *
- *   -RTemporarily import the pool, with all mountpoints relative to
+ * -R  Temporarily import the pool, with all mountpoints relative to
  * the given root.  The pool will remain exported when the machine
  * is rebooted.
  *
- *   -VImport even in the presence of faulted vdevs.  This is an
- * intentionally undocumented option for testing purposes, and
- * treats the pool configuration as complete, leaving any bad
+ * -V  Import even in the presence of faulted vdevs.  This is an
+ * intentionally undocumented option for testing purposes, and
+ * treats the pool configuration as complete, leaving any bad
  * vdevs in the FAULTED state. In other words, it does verbatim
  * import.
  *
- *   -fForce import, even if it appears that the pool is active.
+ * -f  Force import, even if it appears that the pool is active.
  *
- *   -F Attempt rewind if necessary.
+ * -F  Attempt rewind if necessary.
  *
- *   -n See if rewind would work, but don't actually rewind.
+ * -n  See i

svn commit: r342525 - in head: cddl/contrib/opensolaris/lib/libzfs/common cddl/contrib/opensolaris/lib/libzfs_core/common sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2018-12-26 Thread Andriy Gapon
Author: avg
Date: Wed Dec 26 10:37:41 2018
New Revision: 342525
URL: https://svnweb.freebsd.org/changeset/base/342525

Log:
  MFV r342469: 9630 add lzc_rename and lzc_destroy to libzfs_core
  
  illumos/illumos-gate@049ba636fa37a2892809192fc671bff9158a01cd
  
https://github.com/illumos/illumos-gate/commit/049ba636fa37a2892809192fc671bff9158a01cd
  
  https://www.illumos.org/issues/9630
Rename and destroy are very useful operations that deserve to be in
libzfs_core.  And they are not hard to implement too.
  
  MFC after:2 weeks
  Relnotes: maybe

Modified:
  head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
  head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
  head/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c
  head/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
Directory Properties:
  head/cddl/contrib/opensolaris/   (props changed)
  head/cddl/contrib/opensolaris/lib/libzfs/   (props changed)
  head/sys/cddl/contrib/opensolaris/   (props changed)

Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
==
--- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.cWed Dec 
26 10:37:06 2018(r342524)
+++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.cWed Dec 
26 10:37:41 2018(r342525)
@@ -3647,32 +3647,34 @@ zfs_create(libzfs_handle_t *hdl, const char *path, zfs
 int
 zfs_destroy(zfs_handle_t *zhp, boolean_t defer)
 {
-   zfs_cmd_t zc = { 0 };
+   int error;
 
+   if (zhp->zfs_type != ZFS_TYPE_SNAPSHOT && defer)
+   return (EINVAL);
+
if (zhp->zfs_type == ZFS_TYPE_BOOKMARK) {
nvlist_t *nv = fnvlist_alloc();
fnvlist_add_boolean(nv, zhp->zfs_name);
-   int error = lzc_destroy_bookmarks(nv, NULL);
+   error = lzc_destroy_bookmarks(nv, NULL);
fnvlist_free(nv);
if (error != 0) {
-   return (zfs_standard_error_fmt(zhp->zfs_hdl, errno,
+   return (zfs_standard_error_fmt(zhp->zfs_hdl, error,
dgettext(TEXT_DOMAIN, "cannot destroy '%s'"),
zhp->zfs_name));
}
return (0);
}
 
-   (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
-
-   if (ZFS_IS_VOLUME(zhp)) {
-   zc.zc_objset_type = DMU_OST_ZVOL;
+   if (zhp->zfs_type == ZFS_TYPE_SNAPSHOT) {
+   nvlist_t *nv = fnvlist_alloc();
+   fnvlist_add_boolean(nv, zhp->zfs_name);
+   error = lzc_destroy_snaps(nv, defer, NULL);
+   fnvlist_free(nv);
} else {
-   zc.zc_objset_type = DMU_OST_ZFS;
+   error = lzc_destroy(zhp->zfs_name);
}
 
-   zc.zc_defer_destroy = defer;
-   if (zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_DESTROY, &zc) != 0 &&
-   errno != ENOENT) {
+   if (error != 0 && error != ENOENT) {
return (zfs_standard_error_fmt(zhp->zfs_hdl, errno,
dgettext(TEXT_DOMAIN, "cannot destroy '%s'"),
zhp->zfs_name));

Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
==
--- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c   Wed Dec 
26 10:37:06 2018(r342524)
+++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c   Wed Dec 
26 10:37:41 2018(r342525)
@@ -2140,7 +2140,6 @@ recv_rename(libzfs_handle_t *hdl, const char *name, co
 int baselen, char *newname, recvflags_t *flags)
 {
static int seq;
-   zfs_cmd_t zc = { 0 };
int err;
prop_changelist_t *clp;
zfs_handle_t *zhp;
@@ -2157,19 +2156,13 @@ recv_rename(libzfs_handle_t *hdl, const char *name, co
if (err)
return (err);
 
-   zc.zc_objset_type = DMU_OST_ZFS;
-   (void) strlcpy(zc.zc_name, name, sizeof (zc.zc_name));
-
if (tryname) {
(void) strcpy(newname, tryname);
-
-   (void) strlcpy(zc.zc_value, tryname, sizeof (zc.zc_value));
-
if (flags->verbose) {
(void) printf("attempting rename %s to %s\n",
-   zc.zc_name, zc.zc_value);
+   name, newname);
}
-   err = ioctl(hdl->libzfs_fd, ZFS_IOC_RENAME, &zc);
+   err = lzc_rename(name, newname);
if (err == 0)
changelist_rename(clp, name, tryname);
} else {
@@ -2181,13 +2174,11 @@ recv_rename(libzfs_handle_t *hdl, const char *name, co
 
(void) snprintf(newname, ZFS_MAX_DATASET_NAME_LEN,
"%.*srecv-%u-%u", ba

svn commit: r342204 - head/share/man/man4

2018-12-18 Thread Andriy Gapon
Author: avg
Date: Tue Dec 18 21:43:33 2018
New Revision: 342204
URL: https://svnweb.freebsd.org/changeset/base/342204

Log:
  cyapa.4, isl.4: cross-reference and document use of chromebook_platform(4)
  
  PR:   218632
  Reported by:  Denis Kozadaev 
  MFC after:1 week

Modified:
  head/share/man/man4/cyapa.4
  head/share/man/man4/isl.4

Modified: head/share/man/man4/cyapa.4
==
--- head/share/man/man4/cyapa.4 Tue Dec 18 21:01:48 2018(r342203)
+++ head/share/man/man4/cyapa.4 Tue Dec 18 21:43:33 2018(r342204)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 03, 2016
+.Dd December 18, 2018
 .Dt CYAPA 4
 .Os
 .Sh NAME
@@ -46,7 +46,13 @@ cyapa_load="YES"
 ig4_load="YES"
 .Ed
 .Pp
-In
+On many Chromebook models this driver can be automatically configured with the
+help of the
+.Xr chromebook_platform 4
+driver.
+Alternatively, the
+.Nm
+driver can be manually configured in
 .Pa /boot/device.hints :
 .Cd hint.cyapa.0.at="iicbus0"
 .Cd hint.cyapa.0.addr="0xCE"
@@ -195,6 +201,7 @@ file:
 .Dl debug.cyapa_thumbarea_percent=0
 .Dl debug.cyapa_enable_tapclick=2
 .Sh SEE ALSO
+.Xr chromebook_platform 4 ,
 .Xr ig4 4 ,
 .Xr iicbus 4 ,
 .Xr sysmouse 4 ,

Modified: head/share/man/man4/isl.4
==
--- head/share/man/man4/isl.4   Tue Dec 18 21:01:48 2018(r342203)
+++ head/share/man/man4/isl.4   Tue Dec 18 21:43:33 2018(r342204)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 03, 2016
+.Dd December 18, 2018
 .Dt ISL 4
 .Os
 .Sh NAME
@@ -46,7 +46,13 @@ isl_load="YES"
 ig4_load="YES"
 .Ed
 .Pp
-In
+On many Chromebook models this driver can be automatically configured with the
+help of the
+.Xr chromebook_platform 4
+driver.
+Alternatively, the
+.Nm
+driver can be manually configured in
 .Pa /boot/device.hints :
 .Cd hint.isl.0.at="iicbus0"
 .Cd hint.isl.0.addr="0x88"
@@ -106,6 +112,7 @@ $ pkg install intel-backlight
 $ sh /usr/local/share/examples/intel-backlight/isl_backlight.sh
 .Ed
 .Sh SEE ALSO
+.Xr chromebook_platform 4 ,
 .Xr ig4 4 ,
 .Xr iicbus 4
 .Sh AUTHORS
___
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: r342193 - head/sys/dev/ichwd

2018-12-18 Thread Andriy Gapon
Author: avg
Date: Tue Dec 18 17:17:53 2018
New Revision: 342193
URL: https://svnweb.freebsd.org/changeset/base/342193

Log:
  ichwd: add a few assertions about tco_version
  
  Those should ensure correctness of ichwd_find_ich_lpc_bridge() and
  ichwd_find_ich_lpc_bridge() as well as make it easier for both humans
  and static analyzers to see the relation between tco_version and ich and
  smb variables in ichwd_identify().
  
  Reported by:  Coverity
  CID:  1396314, 1396317
  MFC after:10 days

Modified:
  head/sys/dev/ichwd/ichwd.c

Modified: head/sys/dev/ichwd/ichwd.c
==
--- head/sys/dev/ichwd/ichwd.c  Tue Dec 18 16:47:03 2018(r342192)
+++ head/sys/dev/ichwd/ichwd.c  Tue Dec 18 17:17:53 2018(r342193)
@@ -635,6 +635,13 @@ ichwd_identify(driver_t *driver, device_t parent)
return;
}
 
+   KASSERT(id_p->tco_version >= 1,
+   ("unexpected TCO version %d", id_p->tco_version));
+   KASSERT(id_p->tco_version != 4 || smb != NULL,
+   ("could not find PCI SMBus device for TCOv4"));
+   KASSERT(id_p->tco_version >= 4 || ich != NULL,
+   ("could not find PCI LPC bridge device for TCOv1-3"));
+
/* good, add child to bus */
if ((dev = device_find_child(parent, driver->name, 0)) == NULL)
dev = BUS_ADD_CHILD(parent, 0, driver->name, 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: r342179 - head/sys/dev/ichiic

2018-12-17 Thread Andriy Gapon
Author: avg
Date: Mon Dec 17 21:33:25 2018
New Revision: 342179
URL: https://svnweb.freebsd.org/changeset/base/342179

Log:
  fix formatting and style in ig4iic_acpi_probe afetr r339754
  
  This includes removing stray whitespace, adding a line after the
  variable declaration block and removing a redundant check.
  
  MFC after:1 week
  X-MFC with:   r339754

Modified:
  head/sys/dev/ichiic/ig4_acpi.c

Modified: head/sys/dev/ichiic/ig4_acpi.c
==
--- head/sys/dev/ichiic/ig4_acpi.c  Mon Dec 17 21:13:05 2018
(r342178)
+++ head/sys/dev/ichiic/ig4_acpi.c  Mon Dec 17 21:33:25 2018
(r342179)
@@ -71,21 +71,17 @@ ig4iic_acpi_probe(device_t dev)
ig4iic_softc_t *sc;
char *hid;
int rv;
-   sc = device_get_softc(dev);
 
+   sc = device_get_softc(dev);
if (acpi_disabled("ig4iic"))
return (ENXIO);
rv = ACPI_ID_PROBE(device_get_parent(dev), dev, ig4iic_ids, &hid);
-   if (rv > 0){
+   if (rv > 0)
return (rv);
-   }   
 
 if (strcmp("AMDI0010", hid) == 0)
 sc->access_intr_mask = 1;
-
-   
-   if (rv <= 0)
-   device_set_desc(dev, "Designware I2C Controller");
+   device_set_desc(dev, "Designware I2C Controller");
return (rv);
 }
 
___
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: r342170 - in head/sys: dev/pci kern sys x86/x86

2018-12-17 Thread Andriy Gapon
Author: avg
Date: Mon Dec 17 17:11:00 2018
New Revision: 342170
URL: https://svnweb.freebsd.org/changeset/base/342170

Log:
  add support for marking interrupt handlers as suspended
  
  The goal of this change is to fix a problem with PCI shared interrupts
  during suspend and resume.
  
  I have observed a couple of variations of the following scenario.
  Devices A and B are on the same PCI bus and share the same interrupt.
  Device A's driver is suspended first and the device is powered down.
  Device B generates an interrupt. Interrupt handlers of both drivers are
  called. Device A's interrupt handler accesses registers of the powered
  down device and gets back bogus values (I assume all 0xff). That data is
  interpreted as interrupt status bits, etc. So, the interrupt handler
  gets confused and may produce some noise or enter an infinite loop, etc.
  
  This change affects only PCI devices.  The pci(4) bus driver marks a
  child's interrupt handler as suspended after the child's suspend method
  is called and before the device is powered down.  This is done only for
  traditional PCI interrupts, because only they can be shared.
  
  At the moment the change is only for x86.
  
  Notable changes in core subsystems / interfaces:
  - BUS_SUSPEND_INTR and BUS_RESUME_INTR methods are added to bus
interface along with convenience functions bus_suspend_intr and
bus_resume_intr;
  - rman_set_irq_cookie and rman_get_irq_cookie functions are added to
provide a way to associate an interrupt resource with an interrupt
cookie;
  - intr_event_suspend_handler and intr_event_resume_handler functions
are added to the MI interrupt handler interface.
  
  I added two new interrupt handler flags, IH_SUSP and IH_CHANGED, to
  implement the new intr_event functions.  IH_SUSP marks a suspended
  interrupt handler.  IH_CHANGED is used to implement a barrier that
  ensures that a change to the interrupt handler's state is visible
  to future interrupts.
  While there, I fixed some whitespace issues in comments and changed a
  couple of logically boolean variables to be bool.
  
  MFC after:1 month (maybe)
  Differential Revision: https://reviews.freebsd.org/D15755

Modified:
  head/sys/dev/pci/pci.c
  head/sys/kern/bus_if.m
  head/sys/kern/kern_intr.c
  head/sys/kern/subr_bus.c
  head/sys/kern/subr_rman.c
  head/sys/sys/bus.h
  head/sys/sys/interrupt.h
  head/sys/sys/rman.h
  head/sys/x86/x86/nexus.c

Modified: head/sys/dev/pci/pci.c
==
--- head/sys/dev/pci/pci.c  Mon Dec 17 16:01:37 2018(r342169)
+++ head/sys/dev/pci/pci.c  Mon Dec 17 17:11:00 2018(r342170)
@@ -4467,6 +4467,7 @@ int
 pci_suspend_child(device_t dev, device_t child)
 {
struct pci_devinfo *dinfo;
+   struct resource_list_entry *rle;
int error;
 
dinfo = device_get_ivars(child);
@@ -4483,8 +4484,20 @@ pci_suspend_child(device_t dev, device_t child)
if (error)
return (error);
 
-   if (pci_do_power_suspend)
+   if (pci_do_power_suspend) {
+   /*
+* Make sure this device's interrupt handler is not invoked
+* in the case the device uses a shared interrupt that can
+* be raised by some other device.
+* This is applicable only to regular (legacy) PCI interrupts
+* as MSI/MSI-X interrupts are never shared.
+*/
+   rle = resource_list_find(&dinfo->resources,
+   SYS_RES_IRQ, 0);
+   if (rle != NULL && rle->res != NULL)
+   (void)bus_suspend_intr(child, rle->res);
pci_set_power_child(dev, child, PCI_POWERSTATE_D3);
+   }
 
return (0);
 }
@@ -4493,6 +4506,7 @@ int
 pci_resume_child(device_t dev, device_t child)
 {
struct pci_devinfo *dinfo;
+   struct resource_list_entry *rle;
 
if (pci_do_power_resume)
pci_set_power_child(dev, child, PCI_POWERSTATE_D0);
@@ -4503,6 +4517,16 @@ pci_resume_child(device_t dev, device_t child)
pci_cfg_save(child, dinfo, 1);
 
bus_generic_resume_child(dev, child);
+
+   /*
+* Allow interrupts only after fully resuming the driver and hardware.
+*/
+   if (pci_do_power_suspend) {
+   /* See pci_suspend_child for details. */
+   rle = resource_list_find(&dinfo->resources, SYS_RES_IRQ, 0);
+   if (rle != NULL && rle->res != NULL)
+   (void)bus_resume_intr(child, rle->res);
+   }
 
return (0);
 }

Modified: head/sys/kern/bus_if.m
==
--- head/sys/kern/bus_if.m  Mon Dec 17 16:01:37 2018(r342169)
+++ head/sys/kern/bus_if.m  Mon Dec 17 17:11:00 2018(r342170)
@@ -472,6 +472,44 @@ METHOD int teardown_intr {
 };
 
 /**
+ * @brief S

svn commit: r342169 - head/sys/cam/scsi

2018-12-17 Thread Andriy Gapon
Author: avg
Date: Mon Dec 17 16:01:37 2018
New Revision: 342169
URL: https://svnweb.freebsd.org/changeset/base/342169

Log:
  add a knob that disables detection of write protected disks
  
  It has been reported that on some systems (with real hardware passed
  through to a virtual machine) the WP detection causes USB disk probing
  failures.
  
  While here, also fix the selection of the next state in the case
  of malloc failure in DA_STATE_PROBE_WP.  It was DA_STATE_PROBE_RC
  unconditionally even when it should have been DA_STATE_PROBE_RC16.
  
  PR:   225794
  Reported by:  David Boyd 
  MFC after:3 weeks
  Differential Revision: https://reviews.freebsd.org/D18496

Modified:
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/scsi/scsi_da.c
==
--- head/sys/cam/scsi/scsi_da.c Mon Dec 17 16:00:35 2018(r342168)
+++ head/sys/cam/scsi/scsi_da.c Mon Dec 17 16:01:37 2018(r342169)
@@ -1469,6 +1469,7 @@ static int da_retry_count = DA_DEFAULT_RETRY;
 static int da_default_timeout = DA_DEFAULT_TIMEOUT;
 static sbintime_t da_default_softtimeout = DA_DEFAULT_SOFTTIMEOUT;
 static int da_send_ordered = DA_DEFAULT_SEND_ORDERED;
+static int da_disable_wp_detection = 0;
 
 static SYSCTL_NODE(_kern_cam, OID_AUTO, da, CTLFLAG_RD, 0,
 "CAM Direct Access Disk driver");
@@ -1480,6 +1481,9 @@ SYSCTL_INT(_kern_cam_da, OID_AUTO, default_timeout, CT
&da_default_timeout, 0, "Normal I/O timeout (in seconds)");
 SYSCTL_INT(_kern_cam_da, OID_AUTO, send_ordered, CTLFLAG_RWTUN,
&da_send_ordered, 0, "Send Ordered Tags");
+SYSCTL_INT(_kern_cam_da, OID_AUTO, disable_wp_detection, CTLFLAG_RWTUN,
+   &da_disable_wp_detection, 0,
+  "Disable detection of write-protected disks");
 
 SYSCTL_PROC(_kern_cam_da, OID_AUTO, default_softtimeout,
 CTLTYPE_UINT | CTLFLAG_RW, NULL, 0, dasysctlsofttimeout, "I",
@@ -3336,12 +3340,22 @@ out:
void  *mode_buf;
intmode_buf_len;
 
+   if (da_disable_wp_detection) {
+   if ((softc->flags & DA_FLAG_CAN_RC16) != 0)
+   softc->state = DA_STATE_PROBE_RC16;
+   else
+   softc->state = DA_STATE_PROBE_RC;
+   goto skipstate;
+   }
mode_buf_len = 192;
mode_buf = malloc(mode_buf_len, M_SCSIDA, M_NOWAIT);
if (mode_buf == NULL) {
xpt_print(periph->path, "Unable to send mode sense - "
"malloc failure\n");
-   softc->state = DA_STATE_PROBE_RC;
+   if ((softc->flags & DA_FLAG_CAN_RC16) != 0)
+   softc->state = DA_STATE_PROBE_RC16;
+   else
+   softc->state = DA_STATE_PROBE_RC;
goto skipstate;
}
scsi_mode_sense_len(&start_ccb->csio,
___
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: r342073 - head/sys/dev/ichwd

2018-12-14 Thread Andriy Gapon
Author: avg
Date: Fri Dec 14 09:30:43 2018
New Revision: 342073
URL: https://svnweb.freebsd.org/changeset/base/342073

Log:
  ichwd: add Sunrise Point-LP ID
  
  Submitted by: Tetsuya Uemura 
  Tested by:Tetsuya Uemura 
  MFC after:2 weeks
  Relnotes: maybe

Modified:
  head/sys/dev/ichwd/ichwd.c
  head/sys/dev/ichwd/ichwd.h

Modified: head/sys/dev/ichwd/ichwd.c
==
--- head/sys/dev/ichwd/ichwd.c  Fri Dec 14 09:28:20 2018(r342072)
+++ head/sys/dev/ichwd/ichwd.c  Fri Dec 14 09:30:43 2018(r342073)
@@ -295,6 +295,7 @@ static struct ichwd_device ichwd_devices[] = {
 
 static struct ichwd_device ichwd_smb_devices[] = {
{ DEVICEID_LEWISBURG_SMB, "Lewisburg watchdog timer",   10, 4 },
+   { DEVICEID_SRPTLP_SMB,"Sunrise Point-LP watchdog timer",10, 4 },
{ 0, NULL, 0, 0 },
 };
 

Modified: head/sys/dev/ichwd/ichwd.h
==
--- head/sys/dev/ichwd/ichwd.h  Fri Dec 14 09:28:20 2018(r342072)
+++ head/sys/dev/ichwd/ichwd.h  Fri Dec 14 09:30:43 2018(r342073)
@@ -276,6 +276,7 @@ struct ichwd_softc {
 #defineDEVICEID_WCPT_LP7   0x9cc7
 #defineDEVICEID_WCPT_LP9   0x9cc9
 #defineDEVICEID_LEWISBURG_SMB  0xa1a3
+#defineDEVICEID_SRPTLP_SMB 0x9d23
 
 /* ICH LPC Interface Bridge Registers (ICH5 and older) */
 #defineICH_GEN_STA 0xd4
___
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: r342072 - head/sys/dev/ichwd

2018-12-14 Thread Andriy Gapon
Author: avg
Date: Fri Dec 14 09:28:20 2018
New Revision: 342072
URL: https://svnweb.freebsd.org/changeset/base/342072

Log:
  ichwd: add support for clearing No Reboot bit in TCOv4
  
  This is based on a patch developed by
  Tetsuya Uemura .
  Many thanks!
  
  Submitted by: Tetsuya Uemura  (earlier version)
  Tested by:Tetsuya Uemura 
  MFC after:2 weeks

Modified:
  head/sys/dev/ichwd/ichwd.c
  head/sys/dev/ichwd/ichwd.h

Modified: head/sys/dev/ichwd/ichwd.c
==
--- head/sys/dev/ichwd/ichwd.c  Fri Dec 14 09:24:14 2018(r342071)
+++ head/sys/dev/ichwd/ichwd.c  Fri Dec 14 09:28:20 2018(r342072)
@@ -76,6 +76,10 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
+#include 
+#include 
+#include 
+
 static struct ichwd_device ichwd_devices[] = {
{ DEVICEID_82801AA,  "Intel 82801AA watchdog timer",1, 1 },
{ DEVICEID_82801AB,  "Intel 82801AB watchdog timer",1, 1 },
@@ -309,6 +313,8 @@ static devclass_t ichwd_devclass;
 /* NB: TCO version 3 devices use the gcs_res resource for the PMC register. */
 #define ichwd_read_pmc_4(sc, off) \
bus_read_4((sc)->gcs_res, (off))
+#define ichwd_read_gc_4(sc, off) \
+   bus_read_4((sc)->gc_res, (off))
 
 #define ichwd_write_tco_1(sc, off, val) \
bus_write_1((sc)->tco_res, (off), (val))
@@ -323,6 +329,8 @@ static devclass_t ichwd_devclass;
 /* NB: TCO version 3 devices use the gcs_res resource for the PMC register. */
 #define ichwd_write_pmc_4(sc, off, val) \
bus_write_4((sc)->gcs_res, (off), (val))
+#define ichwd_write_gc_4(sc, off, val) \
+   bus_write_4((sc)->gc_res, (off), (val))
 
 #define ichwd_verbose_printf(dev, ...) \
do {\
@@ -495,9 +503,12 @@ ichwd_clear_noreboot(struct ichwd_softc *sc)
rc = EIO;
break;
case 4:
-   /*
-* TODO.  This needs access to a hidden PCI device at 31:1.
-*/
+   status = ichwd_read_gc_4(sc, 0);
+   status &= ~SMB_GC_NO_REBOOT;
+   ichwd_write_gc_4(sc, 0, status);
+   status = ichwd_read_gc_4(sc, 0);
+   if (status & SMB_GC_NO_REBOOT)
+   rc = EIO;
break;
default:
ichwd_verbose_printf(sc->device,
@@ -611,6 +622,7 @@ ichwd_identify(driver_t *driver, device_t parent)
struct ichwd_device *id_p;
device_t ich, smb;
device_t dev;
+   uint64_t base_address64;
uint32_t base_address;
uint32_t ctl;
int rc;
@@ -671,6 +683,33 @@ ichwd_identify(driver_t *driver, device_t parent)
"Can not set TCO v%d I/O resource (err = %d)\n",
id_p->tco_version, rc);
}
+
+   /*
+* Unhide Primary to Sideband Bridge (P2SB) PCI device, so that
+* we can discover the base address of Private Configuration
+* Space via the bridge's BAR.
+* Then hide back the bridge.
+*/
+   pci_cfgregwrite(0, 31, 1, 0xe1, 0, 1);
+   base_address64 = pci_cfgregread(0, 31, 1, SBREG_BAR + 4, 4);
+   base_address64 <<= 32;
+   base_address64 |= pci_cfgregread(0, 31, 1, SBREG_BAR, 4);
+   base_address64 &= ~0xfull;
+   pci_cfgregwrite(0, 31, 1, 0xe1, 1, 1);
+
+   /*
+* No Reboot bit is in General Control register, offset 0xc,
+* within the SMBus target port, ID 0xc6.
+*/
+   base_address64 += PCR_REG_OFF(SMB_PORT_ID, SMB_GC_REG);
+   rc = bus_set_resource(dev, SYS_RES_MEMORY, 1, base_address64,
+   SMB_GC_SIZE);
+   if (rc != 0) {
+   ichwd_verbose_printf(dev,
+   "Can not set TCO v%d PCR I/O resource (err = %d)\n",
+   id_p->tco_version, rc);
+   }
+
break;
default:
ichwd_verbose_printf(dev,
@@ -723,6 +762,18 @@ ichwd_smb_attach(device_t dev)
return (ENXIO);
}
 
+   /*
+* Allocate General Control I/O register in PCH
+* Private Configuration Space (PCR).
+*/
+   sc->gc_rid = 1;
+   sc->gc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->gc_rid,
+   RF_ACTIVE | RF_SHAREABLE);
+   if (sc->gc_res == NULL) {
+   device_printf(dev, "unable to reserve hidden P2SB registers\n");
+   return (ENXIO);
+   }
+
/* Get ACPI base address. */
isab = device_get_parent(device_get_parent(dev));
pmdev = pci_find_dbsf(pci_get_domain(isab), pci_get_bus(isab), 31, 2);
@@ -737,7 +788,7 @@ ichwd_smb_attach(device_t dev)
}
 
/* Allocate SMI control I/O register space. */
-

Re: svn commit: r341681 - head/sys/cam/scsi

2018-12-07 Thread Andriy Gapon
On 07/12/2018 18:33, Warner Losh wrote:
> 
> 
> On Fri, Dec 7, 2018 at 5:02 AM Andriy Gapon  <mailto:a...@freebsd.org>> wrote:
> 
> Author: avg
> Date: Fri Dec  7 12:02:31 2018
> New Revision: 341681
> URL: https://svnweb.freebsd.org/changeset/base/341681
> 
> Log:
>   daprobedone: announce if a disk is write-protected
> 
>   MFC after:    2 weeks
> 
> Modified:
>   head/sys/cam/scsi/scsi_da.c
> 
> Modified: head/sys/cam/scsi/scsi_da.c
> 
> ==
> --- head/sys/cam/scsi/scsi_da.c Fri Dec  7 11:47:42 2018        (r341680)
> +++ head/sys/cam/scsi/scsi_da.c Fri Dec  7 12:02:31 2018        (r341681)
> @@ -2472,6 +2472,11 @@ daprobedone(struct cam_periph *periph, union ccb 
> *ccb)
>                 printf("%s%d: %s\n", periph->periph_name,
>                     periph->unit_number, buf);
>         }
> +       if ((softc->disk->d_flags & DISKFLAG_WRITE_PROTECT) != 0 &&
> +           (softc->flags & DA_FLAG_ANNOUNCED) == 0) {
> +               printf("%s%d: Write Protected\n", periph->periph_name,
> +                   periph->unit_number);
> +       }
> 
> 
> This is incorrect. It needs to be added to buf so that it gets printed
> atomically with the rest of things.

My impression is that "the rest of the things" is not printed atomically,
unfortunately.  It would be great if it was.
For example, the printf that we see in the diff context above prints only
"Delete methods:" line.

-- 
Andriy Gapon
___
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: r341696 - head/sys/dev/acpica

2018-12-07 Thread Andriy Gapon
Author: avg
Date: Fri Dec  7 16:05:39 2018
New Revision: 341696
URL: https://svnweb.freebsd.org/changeset/base/341696

Log:
  acpi_MatchHid: use ACPI_MATCHHID_NOMATCH instead of FALSE
  
  Binary representation of both is the same (zero), but
  ACPI_MATCHHID_NOMATCH is better for consistency.
  
  MFC after:4 days
  X-MFC with:   r339754

Modified:
  head/sys/dev/acpica/acpi.c

Modified: head/sys/dev/acpica/acpi.c
==
--- head/sys/dev/acpica/acpi.c  Fri Dec  7 16:01:51 2018(r341695)
+++ head/sys/dev/acpica/acpi.c  Fri Dec  7 16:05:39 2018(r341696)
@@ -2290,7 +2290,7 @@ acpi_MatchHid(ACPI_HANDLE h, const char *hid) 
ACPI_FAILURE(AcpiGetObjectInfo(h, &devinfo)))
return (ACPI_MATCHHID_NOMATCH);
 
-ret = FALSE;
+ret = ACPI_MATCHHID_NOMATCH;
 if ((devinfo->Valid & ACPI_VALID_HID) != 0 &&
strcmp(hid, devinfo->HardwareId.String) == 0)
ret = ACPI_MATCHHID_HID;
___
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: r341695 - head/sys/dev/acpi_support

2018-12-07 Thread Andriy Gapon
Author: avg
Date: Fri Dec  7 16:01:51 2018
New Revision: 341695
URL: https://svnweb.freebsd.org/changeset/base/341695

Log:
  aibs: fix a typo in the probe method that was introduced in r339754
  
  Because of that typo the driver would try to attach to every device
  on acpi bus.  That disrupted acpi attachment of uart driver, at least.
  
  MFC after:4 days
  X-MFC with:   r339754

Modified:
  head/sys/dev/acpi_support/atk0110.c

Modified: head/sys/dev/acpi_support/atk0110.c
==
--- head/sys/dev/acpi_support/atk0110.c Fri Dec  7 15:56:40 2018
(r341694)
+++ head/sys/dev/acpi_support/atk0110.c Fri Dec  7 16:01:51 2018
(r341695)
@@ -129,7 +129,7 @@ aibs_probe(device_t dev)
rv = ACPI_ID_PROBE(device_get_parent(dev), dev, aibs_hids, NULL);
if (rv <= 0 )
device_set_desc(dev, "ASUSTeK AI Booster (ACPI ASOC ATK0110)");
-   return (0);
+   return (rv);
 }
 
 static int
___
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: r341681 - head/sys/cam/scsi

2018-12-07 Thread Andriy Gapon
Author: avg
Date: Fri Dec  7 12:02:31 2018
New Revision: 341681
URL: https://svnweb.freebsd.org/changeset/base/341681

Log:
  daprobedone: announce if a disk is write-protected
  
  MFC after:2 weeks

Modified:
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/scsi/scsi_da.c
==
--- head/sys/cam/scsi/scsi_da.c Fri Dec  7 11:47:42 2018(r341680)
+++ head/sys/cam/scsi/scsi_da.c Fri Dec  7 12:02:31 2018(r341681)
@@ -2472,6 +2472,11 @@ daprobedone(struct cam_periph *periph, union ccb *ccb)
printf("%s%d: %s\n", periph->periph_name,
periph->unit_number, buf);
}
+   if ((softc->disk->d_flags & DISKFLAG_WRITE_PROTECT) != 0 &&
+   (softc->flags & DA_FLAG_ANNOUNCED) == 0) {
+   printf("%s%d: Write Protected\n", periph->periph_name,
+   periph->unit_number);
+   }
 
/*
 * Since our peripheral may be invalidated by an error
___
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: r341632 - head/sys/dev/acpica

2018-12-06 Thread Andriy Gapon
Author: avg
Date: Thu Dec  6 12:34:34 2018
New Revision: 341632
URL: https://svnweb.freebsd.org/changeset/base/341632

Log:
  acpi_{Device,Battery}IsPresent: restore pre-r330957 behaviour
  
  Specifically, assume that the device is present if evaluation of _STA
  method fails.
  
  Before r330957 we ignored any _STA evaluation failure (which was
  performed by AcpiGetObjectInfo in ACPICA contrib code) for the purpose
  of acpi_DeviceIsPresent and acpi_BatteryIsPresent.  ACPICA 20180313
  removed evaluation of _STA from AcpiGetObjectInfo.  So, we added
  evaluation of _STA to acpi_DeviceIsPresent and acpi_BatteryIsPresent.
  One important difference is that the new code ignored a failure only if
  _STA did not exist (AE_NOT_FOUND).  Any other kind of failure was
  treated as a fatal failure.  Apparently, on some systems we can get
  AE_NOT_EXIST when evaluating _STA.  And that error is not an evil twin
  of AE_NOT_FOUND, despite a very similar name, but a distinct error
  related to a missing handler for an ACPI operation region.
  
  It's possible that for some people the problem was already fixed by
  changes in ACPICA and/or in acpi_ec driver (or even in BIOS) that fixed
  the AE_NOT_EXIST failure related to EC operation region.
  
  This work is based on a great analysis by cem and an earlier patch by
  Ali Abdallah .
  
  PR:   227191
  Reported by:  0mp
  MFC after:2 weeks

Modified:
  head/sys/dev/acpica/acpi.c

Modified: head/sys/dev/acpica/acpi.c
==
--- head/sys/dev/acpica/acpi.c  Thu Dec  6 11:52:07 2018(r341631)
+++ head/sys/dev/acpica/acpi.c  Thu Dec  6 12:34:34 2018(r341632)
@@ -2203,8 +2203,6 @@ acpi_DeviceIsPresent(device_t dev)
h = acpi_get_handle(dev);
if (h == NULL)
return (FALSE);
-   status = acpi_GetInteger(h, "_STA", &s);
-
/*
 * Certain Treadripper boards always returns 0 for FreeBSD because it
 * only returns non-zero for the OS string "Windows 2015". Otherwise it
@@ -2214,9 +2212,14 @@ acpi_DeviceIsPresent(device_t dev)
if (acpi_MatchHid(h, "AMDI0020") || acpi_MatchHid(h, "AMDI0010"))
return (TRUE);
 
-   /* If no _STA method, must be present */
+   status = acpi_GetInteger(h, "_STA", &s);
+
+   /*
+* If no _STA method or if it failed, then assume that
+* the device is present.
+*/
if (ACPI_FAILURE(status))
-   return (status == AE_NOT_FOUND ? TRUE : FALSE);
+   return (TRUE);
 
return (ACPI_DEVICE_PRESENT(s) ? TRUE : FALSE);
 }
@@ -2236,9 +2239,12 @@ acpi_BatteryIsPresent(device_t dev)
return (FALSE);
status = acpi_GetInteger(h, "_STA", &s);
 
-   /* If no _STA method, must be present */
+   /*
+* If no _STA method or if it failed, then assume that
+* the device is present.
+*/
if (ACPI_FAILURE(status))
-   return (status == AE_NOT_FOUND ? TRUE : FALSE);
+   return (TRUE);
 
return (ACPI_BATTERY_PRESENT(s) ? TRUE : FALSE);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r340450 - head/sys/sys

2018-11-18 Thread Andriy Gapon
On 19/11/2018 03:38, Warner Losh wrote:
> I'll talk to Allan to see if he can test that. the bare 1 should be handled
> properly because of C's promotion rules. 1ull << 32 is an unsigned long long.
> What I really wanted was "~(uint32_t)0" but that construct has bit me in the 
> past.

I think that you could just do (unsigned int)-1 or UINT_MAX.

As a side note, I wonder if those functions are ever used on negative values,
given the type of the argument, and if anyone checked their correctness in that
case.

-- 
Andriy Gapon
___
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: r340055 - in head: share/man/man9 sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/fs/ext2fs sys/fs/fuse sys/fs/nandfs sys/fs/nfs sys/fs/nfsclient sys/fs/tmpfs sys/kern sys/sys sys/u

2018-11-02 Thread Andriy Gapon
On 02/11/2018 16:42, Brooks Davis wrote:
> Author: brooks
> Date: Fri Nov  2 14:42:36 2018
> New Revision: 340055
> URL: https://svnweb.freebsd.org/changeset/base/340055
> 
> Log:
>   Make vop_symlink take a const target path.
>   
>   This will enable callers to take const paths as part of syscall
>   decleration improvements.
>   
>   Where doing so is easy and non-distruptive carry the const through
>   implementations. In UFS the value is passed to an interface that must
>   take non-const values. In ZFS, const poisoning would touch code shared
>   with upstream and it's not worth adding diffs.

zfs_vnops.c is already sufficiently different from upstream (because of quite
different VFS models), so a small difference in zfs_symlink's signature would
not be too bad.

>   Bump __FreeBSD_version for external API consumers.
>   
>   Reviewed by:kib (prior version)
>   Obtained from:  CheriBSD
>   Sponsored by:   DARPA, AFRL
>   Differential Revision:  https://reviews.freebsd.org/D17805
> 
> Modified:
>   head/share/man/man9/VOP_CREATE.9
>   head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c


-- 
Andriy Gapon
___
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: r339917 - head/sys/kern

2018-10-30 Thread Andriy Gapon
On 30/10/2018 16:54, Eric van Gyzen wrote:
> Author: vangyzen
> Date: Tue Oct 30 14:54:15 2018
> New Revision: 339917
> URL: https://svnweb.freebsd.org/changeset/base/339917
> 
> Log:
>   Always stop the scheduler when entering kdb
>   
>   Set curthread->td_stopsched when entering kdb via any vector.
>   Previously, it was only set when entering via panic, so when
>   entering kdb another way, mutexes and such were still "live",
>   and an attempt to lock an already locked mutex would panic.
>   
>   Reviewed by:kib, cem
>   Discussed with: jhb
>   Tested by:  pho
>   MFC after:  2 months
>   Sponsored by:   Dell EMC Isilon
>   Differential Revision:  https://reviews.freebsd.org/D17687

My recollection from way back then is that the previous behavior was on purpose.
The idea was that the kdb code and code hat services it should be written
specifically to avoid taking locks used by general code.
I am not sure if that approach had any practical benefits, just sharing the 
memory.

-- 
Andriy Gapon
___
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: r339595 - head/sys/fs/nfsserver

2018-10-22 Thread Andriy Gapon
Author: avg
Date: Mon Oct 22 15:33:05 2018
New Revision: 339595
URL: https://svnweb.freebsd.org/changeset/base/339595

Log:
  nfsrvd_readdirplus: for some errors, do not fail the entire request
  
  Instead, a failing entry is skipped.
  This change consist of two logical changes.
  
  A failure to vget or lookup an entry is considered to be a result of a
  concurrent removal, which is the only reasonable explanation given that
  the filesystem is busied.  So, the entry would be silently skipped.
  
  In the case of a failure to get attributes of an entry for an NFSv3
  request, the entry would be silently skipped.  There can be legitimate
  reasons for the failure, but NFSv3 does not provide any means to report
  the error, so we have two options: either fail the whole request or
  ignore the failed entry.  Traditionally, the old NFS server used the
  latter option, so the code is reverted to it.  Making the whole
  directory unreadable because of a single entry seems to be unpractical.
  
  Additionally, some bits of code are slightly re-arranged to account for
  the new control flow and to honor style(9).
  
  Reviewed by:  rmacklem
  Sponsored by: Panzura
  Differential Revision: https://reviews.freebsd.org/D15424

Modified:
  head/sys/fs/nfsserver/nfs_nfsdport.c

Modified: head/sys/fs/nfsserver/nfs_nfsdport.c
==
--- head/sys/fs/nfsserver/nfs_nfsdport.cMon Oct 22 15:18:49 2018
(r339594)
+++ head/sys/fs/nfsserver/nfs_nfsdport.cMon Oct 22 15:33:05 2018
(r339595)
@@ -2416,10 +2416,22 @@ again:
}
}
}
-   if (!r) {
-   if (refp == NULL &&
-   ((nd->nd_flag & ND_NFSV3) ||
-NFSNONZERO_ATTRBIT(&attrbits))) {
+
+   /*
+* If we failed to look up the entry, then it
+* has become invalid, most likely removed.
+*/
+   if (r != 0) {
+   if (needs_unbusy)
+   vfs_unbusy(new_mp);
+   goto invalid;
+   }
+   KASSERT(refp != NULL || nvp != NULL,
+   ("%s: undetected lookup error", __func__));
+
+   if (refp == NULL &&
+   ((nd->nd_flag & ND_NFSV3) ||
+NFSNONZERO_ATTRBIT(&attrbits))) {
r = nfsvno_getfh(nvp, &nfh, p);
if (!r)
r = nfsvno_getattr(nvp, nvap, nd, p,
@@ -2440,17 +2452,25 @@ again:
if (new_mp == mp)
new_mp = nvp->v_mount;
}
-   }
-   } else {
-   nvp = NULL;
}
-   if (r) {
+
+   /*
+* If we failed to get attributes of the entry,
+* then just skip it for NFSv3 (the traditional
+* behavior in the old NFS server).
+* For NFSv4 the behavior is controlled by
+* RDATTRERROR: we either ignore the error or
+* fail the request.
+* Note that RDATTRERROR is never set for NFSv3.
+*/
+   if (r != 0) {
if (!NFSISSET_ATTRBIT(&attrbits,
NFSATTRBIT_RDATTRERROR)) {
-   if (nvp != NULL)
-   vput(nvp);
+   vput(nvp);
if (needs_unbusy != 0)
vfs_unbusy(new_mp);
+   if ((nd->nd_flag & ND_NFSV3))
+   goto invalid;
nd->nd_repstat = r;
break;
}
@@ -2519,6 +2539,7 @@ again:
if (dirlen <= cnt)
entrycnt++;
}
+inva

svn commit: r339591 - head/sys/dev/ichwd

2018-10-22 Thread Andriy Gapon
Author: avg
Date: Mon Oct 22 14:44:44 2018
New Revision: 339591
URL: https://svnweb.freebsd.org/changeset/base/339591

Log:
  ichwd: add support for TCO watchdog timer in Lewisburg PCH (C620)
  
  The change is based on public documents listed below as well as Linux
  changes and the code developed by Kostik.
  
  The documents:
  - Intel® C620 Series Chipset Platform Controller Hub Datasheet
  - Intel® 100 Series and Intel® C230 Series Chipset Family Platform
Controller Hub (PCH) Datasheet - Volume 2 of 2
  
  Interesting Linux commits:
  - 
https://github.com/torvalds/linux/commit/9424693035a57961a8eb09e96aab315a7096535d
  - 
https://github.com/torvalds/linux/commit/2a7a0e9bf7b32e838d873226808ab8a6c00148f7
  
  The peculiarity of the new chipsets is that the watchdog resources are
  configured in PCI registers of SMBus controller and Power Management
  function as opposed to the LPC bridge.  I took a simplistic approach of
  querying the resources from the respective PCI devices.  ichwd is still
  a device on isa bus.  The PCI devices are found by their slot and
  function defined in the datasheets as siblings of the upstream LPC
  bridge.
  
  There are some shortcuts and missing features.
  
  First of all, I have not implemented the functionality required to clear
  the no-reboot bit.  That would require writing to a special PCI
  configuration register of a hidden / invisible PCI device after which
  the device would start responding to accesses to other registers.  The
  no-reboot bit was not set on my test hardware, so I decided to leave its
  handling for the later time.
  
  Also, I did not try to handle the case where the watchdog resources are
  not configured by the hardware as well as the case where ACPI defined
  operational region conflicts with the watchdog resources.  My test
  system did not have either of those problem, so, again, I decided to
  leave those cases until later.
  See this Linux commit for some details of the ACPI problem:
  
https://github.com/torvalds/linux/commit/a7ae81952cdab56a1277bd2f9ed7284c0f575120
  
  Finally, I have added only the PCI ID found on my test system.  I think
  that more IDs can be added as the change gets tested.
  
  Tested on Dell PowerEdge R740.
  
  PR:   222079
  Reviewed by:  mav, kib
  MFC after:3 weeks
  Relnotes: maybe
  Sponsored by: Panzura
  Differential Revision: https://reviews.freebsd.org/D17585

Modified:
  head/sys/dev/ichwd/ichwd.c
  head/sys/dev/ichwd/ichwd.h

Modified: head/sys/dev/ichwd/ichwd.c
==
--- head/sys/dev/ichwd/ichwd.c  Mon Oct 22 14:01:34 2018(r339590)
+++ head/sys/dev/ichwd/ichwd.c  Mon Oct 22 14:44:44 2018(r339591)
@@ -289,6 +289,11 @@ static struct ichwd_device ichwd_devices[] = {
{ 0, NULL, 0, 0 },
 };
 
+static struct ichwd_device ichwd_smb_devices[] = {
+   { DEVICEID_LEWISBURG_SMB, "Lewisburg watchdog timer",   10, 4 },
+   { 0, NULL, 0, 0 },
+};
+
 static devclass_t ichwd_devclass;
 
 #define ichwd_read_tco_1(sc, off) \
@@ -374,7 +379,8 @@ ichwd_sts_reset(struct ichwd_softc *sc)
 * be done in two separate operations.
 */
ichwd_write_tco_2(sc, TCO2_STS, TCO_SECOND_TO_STS);
-   ichwd_write_tco_2(sc, TCO2_STS, TCO_BOOT_STS);
+   if (sc->tco_version < 4)
+   ichwd_write_tco_2(sc, TCO2_STS, TCO_BOOT_STS);
 }
 
 /*
@@ -488,6 +494,11 @@ ichwd_clear_noreboot(struct ichwd_softc *sc)
if (status & ICH_PMC_NO_REBOOT)
rc = EIO;
break;
+   case 4:
+   /*
+* TODO.  This needs access to a hidden PCI device at 31:1.
+*/
+   break;
default:
ichwd_verbose_printf(sc->device,
"Unknown TCO Version: %d, can't set NO_REBOOT.\n",
@@ -560,6 +571,36 @@ ichwd_find_ich_lpc_bridge(device_t isa, struct ichwd_d
return (NULL);
 }
 
+static device_t
+ichwd_find_smb_dev(device_t isa, struct ichwd_device **id_p)
+{
+   struct ichwd_device *id;
+   device_t isab, smb;
+   uint16_t devid;
+
+   /*
+* Check if SMBus controller provides TCO configuration.
+* The controller's device and function are fixed and we expect
+* it to be on the same bus as ISA bridge.
+*/
+   isab = device_get_parent(isa);
+   smb = pci_find_dbsf(pci_get_domain(isab), pci_get_bus(isab), 31, 4);
+   if (smb == NULL)
+   return (NULL);
+   if (pci_get_vendor(smb) != VENDORID_INTEL)
+   return (NULL);
+   devid = pci_get_device(smb);
+   for (id = ichwd_smb_devices; id->desc != NULL; ++id) {
+   if (devid == id->device) {
+   if (id_p != NULL)
+   *id_p = id;
+   return (smb);
+   }
+   }
+
+   return (NULL);
+}
+
 /*
  * Look for an ICH LPC in

Re: svn commit: r338214 - in head/sys: conf kern sys

2018-08-23 Thread Andriy Gapon
On 23/08/2018 01:19, Conrad Meyer wrote:
> Author: cem
> Date: Wed Aug 22 22:19:42 2018
> New Revision: 338214
> URL: https://svnweb.freebsd.org/changeset/base/338214
> 
> Log:
>   KASSERT: Make runtime optionality optional

Thank you!

>   Add an option, KASSERT_PANIC_OPTIONAL, that allows runtime KASSERT()
>   behavior changes.  When this option is not enabled, code that allows
>   KASSERTs to become optional is not enabled, and all violated assertions
>   cause termination.
>   
>   The runtime KASSERT behavior was added in r243980.
>   
>   One important distinction here is that panic has __dead2
>   ("attribute((noreturn))"), while kassert_panic does not.  Static analyzers
>   like Coverity understand __dead2.  Without it, KASSERTs go misunderstood,
>   resulting in many false positives that result from violation of program
>   invariants.
>   
>   Reviewed by:jhb, jtl, np, vangyzen
>   Relnotes:   yes
>   Sponsored by:   Dell EMC Isilon
>   Differential Revision:  https://reviews.freebsd.org/D16835


-- 
Andriy Gapon
___
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: r338172 - in head: . sys/amd64/conf sys/dev/drm sys/dev/drm2 sys/dev/drm2/i915 sys/dev/drm2/radeon sys/dev/drm2/radeon/reg_srcs sys/dev/drm2/ttm sys/i386/conf sys/modules sys/modules/d

2018-08-22 Thread Andriy Gapon
On 22/08/2018 04:50, Matt Macy wrote:
> Author: mmacy
> Date: Wed Aug 22 01:50:12 2018
> New Revision: 338172
> URL: https://svnweb.freebsd.org/changeset/base/338172
> 
> Log:
>   Remove legacy drm and drm2 from tree
>   
>   As discussed on the MLs drm2 conflicts with the ports' version and there
>   is no upstream for most if not all of drm. Both have been merged in to
>   a single port.
...
>   Approved by: core@

I am curious if this "panic: implment me" has been addressed?
https://lists.freebsd.org/pipermail/freebsd-current/2018-May/069428.html


-- 
Andriy Gapon
___
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: r337754 - head/sys/x86/x86

2018-08-14 Thread Andriy Gapon
On 14/08/2018 17:02, Mark Johnston wrote:
>   At some point memcpy() may be an ifunc, ifunc resolution cannot be done
>   until CPU identification has been performed, and CPU identification must
>   be done after loading any microcode updates.

Wouldn't it be cool if before an ifunc is resolved (to a proper
optimized version) it pointed to a default implementation that is
sufficiently naive and robust that it can work on all CPUs?
But I don't know much about ifunc implementation, so no idea if it can
work like that.

-- 
Andriy Gapon
___
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: r337528 - in head: share/man/man4 sys/ddb

2018-08-09 Thread Andriy Gapon
Author: avg
Date: Thu Aug  9 11:21:31 2018
New Revision: 337528
URL: https://svnweb.freebsd.org/changeset/base/337528

Log:
  add an option for ddb ps command to print process arguments
  
  We use ps to collect the information of all processes in textdump. But
  it doesn't contain process arguments which however sometimes are very
  useful for debugging.  The new 'a' modifier adds that capability.
  
  While here, remove 'm' modifier from ddb.4.  It was in the manual page
  from its very first revision, but I could not find any evidence of the
  code ever supporting it.
  
  Submitted by: Terry Hu 
  Reviewed by:  kib
  MFC after:1 week
  Sponsored by: Panzura
  Differential Revision: https://reviews.freebsd.org/D16603

Modified:
  head/share/man/man4/ddb.4
  head/sys/ddb/db_ps.c

Modified: head/share/man/man4/ddb.4
==
--- head/share/man/man4/ddb.4   Thu Aug  9 09:39:32 2018(r337527)
+++ head/share/man/man4/ddb.4   Thu Aug  9 11:21:31 2018(r337528)
@@ -537,16 +537,15 @@ If the thread is not found, search the thread stack ca
 cached stack address.
 Otherwise, prints nothing.
 .Pp
-.It Ic show Cm all procs Ns Op Li / Ns Cm m
-.It Ic ps Ns Op Li / Ns Cm m
+.It Ic show Cm all procs Ns Op Li / Ns Cm a
+.It Ic ps Ns Op Li / Ns Cm a
 Display all process information.
 The process information may not be shown if it is not
 supported in the machine, or the bottom of the stack of the
 target process is not in the main memory at that time.
 The
-.Cm m
-modifier will alter the display to show VM map
-addresses for the process and not show other information.
+.Cm a
+modifier will print command line arguments for each process.
 .\"
 .Pp
 .It Ic show Cm all trace

Modified: head/sys/ddb/db_ps.c
==
--- head/sys/ddb/db_ps.cThu Aug  9 09:39:32 2018(r337527)
+++ head/sys/ddb/db_ps.cThu Aug  9 11:21:31 2018(r337528)
@@ -50,8 +50,13 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
+#define PRINT_NONE 0
+#define PRINT_ARGS 1
+
 static voiddumpthread(volatile struct proc *p, volatile struct thread *td,
int all);
+static int ps_mode;
+
 /*
  * At least one non-optional show-command must be implemented using
  * DB_SHOW_ALL_COMMAND() so that db_show_all_cmd_set gets created.
@@ -62,6 +67,24 @@ DB_SHOW_ALL_COMMAND(procs, db_procs_cmd)
db_ps(addr, have_addr, count, modif);
 }
 
+static void
+dump_args(volatile struct proc *p)
+{
+   char *args;
+   int i, len;
+
+   if (p->p_args == NULL)
+   return;
+   args = p->p_args->ar_args;
+   len = (int)p->p_args->ar_length;
+   for (i = 0; i < len; i++) {
+   if (args[i] == '\0')
+   db_printf(" ");
+   else
+   db_printf("%c", args[i]);
+   }
+}
+
 /*
  * Layout:
  * - column counts
@@ -90,6 +113,7 @@ db_ps(db_expr_t addr, bool hasaddr, db_expr_t count, c
char state[9];
int np, rflag, sflag, dflag, lflag, wflag;
 
+   ps_mode = modif[0] == 'a' ? PRINT_ARGS : PRINT_NONE;
np = nprocs;
 
if (!LIST_EMPTY(&allproc))
@@ -207,6 +231,10 @@ db_ps(db_expr_t addr, bool hasaddr, db_expr_t count, c
db_printf("%s", p->p_comm);
if (p->p_flag & P_SYSTEM)
db_printf("]");
+   if (ps_mode == PRINT_ARGS) {
+   db_printf(" ");
+   dump_args(p);
+   }
db_printf("\n");
}
FOREACH_THREAD_IN_PROC(p, td) {
@@ -299,6 +327,10 @@ dumpthread(volatile struct proc *p, volatile struct th
db_printf("%s", td->td_proc->p_comm);
if (p->p_flag & P_SYSTEM)
db_printf("]");
+   if (ps_mode == PRINT_ARGS && all == 0) {
+   db_printf(" ");
+   dump_args(p);
+   }
db_printf("\n");
 }
 
@@ -445,12 +477,7 @@ DB_SHOW_COMMAND(proc, db_show_proc)
db_printf(" ABI: %s\n", p->p_sysent->sv_name);
if (p->p_args != NULL) {
db_printf(" arguments: ");
-   for (i = 0; i < (int)p->p_args->ar_length; i++) {
-   if (p->p_args->ar_args[i] == '\0')
-   db_printf(" ");
-   else
-   db_printf("%c", p->p_args->ar_args[i]);
-   }
+   dump_args(p);
db_printf("\n");
}
db_printf(" repear: %p reapsubtree: %d\n",
___
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: r337255 - in head/sys: kern sys

2018-08-03 Thread Andriy Gapon
Author: avg
Date: Fri Aug  3 14:27:28 2018
New Revision: 337255
URL: https://svnweb.freebsd.org/changeset/base/337255

Log:
  safer wait-free iteration of shared interrupt handlers
  
  The code that iterates a list of interrupt handlers for a (shared)
  interrupt, whether in the ISR context or in the context of an interrupt
  thread, does so in a lock-free fashion.   Thus, the routines that modify
  the list need to take special steps to ensure that the iterating code
  has a consistent view of the list.  Previously, those routines tried to
  play nice only with the code running in the ithread context.  The
  iteration in the ISR context was left to a chance.
  
  After commit r336635 atomic operations and memory fences are used to
  ensure that ie_handlers list is always safe to navigate with respect to
  inserting and removal of list elements.
  
  There is still a question of when it is safe to actually free a removed
  element.
  
  The idea of this change is somewhat similar to the idea of the epoch
  based reclamation.  There are some simplifications comparing to the
  general epoch based reclamation.  All writers are serialized using a
  mutex, so we do not need to worry about concurrent modifications.  Also,
  all read accesses from the open context are serialized too.
  
  So, we can get away just two epochs / phases.  When a thread removes an
  element it switches the global phase from the current phase to the other
  and then drains the previous phase.  Only after the draining the removed
  element gets actually freed. The code that iterates the list in the ISR
  context takes a snapshot of the global phase and then increments the use
  count of that phase before iterating the list.  The use count (in the
  same phase) is decremented after the iteration.  This should ensure that
  there should be no iteration over the removed element when its gets
  freed.
  
  This commit also simplifies the coordination with the interrupt thread
  context.  Now we always schedule the interrupt thread when removing one
  of handlers for its interrupt.  This makes the code both simpler and
  safer as the interrupt thread masks the interrupt thus ensuring that
  there is no interaction with the ISR context.
  
  P.S.  This change matters only for shared interrupts and I realize that
  those are becoming a thing of the past (and quickly).  I also understand
  that the problem that I am trying to solve is extremely rare.
  
  PR:   229106
  Reviewed by:  cem
  Discussed with:   Samy Al Bahra
  MFC after:5 weeks
  Differential Revision: https://reviews.freebsd.org/D15905

Modified:
  head/sys/kern/kern_intr.c
  head/sys/sys/interrupt.h

Modified: head/sys/kern/kern_intr.c
==
--- head/sys/kern/kern_intr.c   Fri Aug  3 14:25:15 2018(r337254)
+++ head/sys/kern/kern_intr.c   Fri Aug  3 14:27:28 2018(r337255)
@@ -683,6 +683,45 @@ intr_handler_source(void *cookie)
 }
 
 /*
+ * If intr_event_handle() is running in the ISR context at the time of the 
call,
+ * then wait for it to complete.
+ */
+static void
+intr_event_barrier(struct intr_event *ie)
+{
+   int phase;
+
+   mtx_assert(&ie->ie_lock, MA_OWNED);
+   phase = ie->ie_phase;
+
+   /*
+* Switch phase to direct future interrupts to the other active counter.
+* Make sure that any preceding stores are visible before the switch.
+*/
+   KASSERT(ie->ie_active[!phase] == 0, ("idle phase has activity"));
+   atomic_store_rel_int(&ie->ie_phase, !phase);
+
+   /*
+* This code cooperates with wait-free iteration of ie_handlers
+* in intr_event_handle.
+* Make sure that the removal and the phase update are not reordered
+* with the active count check.
+* Note that no combination of acquire and release fences can provide
+* that guarantee as Store->Load sequences can always be reordered.
+*/
+   atomic_thread_fence_seq_cst();
+
+   /*
+* Now wait on the inactive phase.
+* The acquire fence is needed so that that all post-barrier accesses
+* are after the check.
+*/
+   while (ie->ie_active[phase] > 0)
+   cpu_spinwait();
+   atomic_thread_fence_acq();
+}
+
+/*
  * Sleep until an ithread finishes executing an interrupt handler.
  *
  * XXX Doesn't currently handle interrupt filters or fast interrupt
@@ -752,44 +791,30 @@ intr_event_remove_handler(void *cookie)
}
 
/*
-* If there is no ithread, then just remove the handler and return.
-* XXX: Note that an INTR_FAST handler might be running on another
-* CPU!
+* If there is no ithread, then directly remove the handler.  Note that
+* intr_event_handle() iterates ie_handlers in a lock-less fashion, so
+* care needs to be taken to keep ie_handlers consistent and to free
+* the removed handle

svn commit: r337123 - head/sys/kern

2018-08-02 Thread Andriy Gapon
Author: avg
Date: Thu Aug  2 09:41:55 2018
New Revision: 337123
URL: https://svnweb.freebsd.org/changeset/base/337123

Log:
  fix a typo resulting in a wrong variable in kern_syscall_deregister
  
  The difference is between sysent, a global, and sysents, a function
  parameter.

Modified:
  head/sys/kern/kern_syscalls.c

Modified: head/sys/kern/kern_syscalls.c
==
--- head/sys/kern/kern_syscalls.c   Thu Aug  2 09:31:50 2018
(r337122)
+++ head/sys/kern/kern_syscalls.c   Thu Aug  2 09:41:55 2018
(r337123)
@@ -148,7 +148,7 @@ kern_syscall_deregister(struct sysent *sysents, int of
if ((se->sy_thrcnt & SY_THR_STATIC) != 0)
return (EINVAL);
syscall_thread_drain(se);
-   sysent[offset] = *old_sysent;
+   sysents[offset] = *old_sysent;
return (0);
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r336641 - head/sys/security/audit

2018-07-23 Thread Andriy Gapon
Author: avg
Date: Mon Jul 23 16:56:49 2018
New Revision: 336641
URL: https://svnweb.freebsd.org/changeset/base/336641

Log:
  fix incorrect operator in the AUDITPIPE_SET_QLIMIT bounds check
  
  PR:   229983
  Submitted by: Aniket Pandey 
  Reported by:  Aniket Pandey 
  MFC after:1 week

Modified:
  head/sys/security/audit/audit_pipe.c

Modified: head/sys/security/audit/audit_pipe.c
==
--- head/sys/security/audit/audit_pipe.cMon Jul 23 16:11:03 2018
(r336640)
+++ head/sys/security/audit/audit_pipe.cMon Jul 23 16:56:49 2018
(r336641)
@@ -756,7 +756,7 @@ audit_pipe_ioctl(struct cdev *dev, u_long cmd, caddr_t
 
case AUDITPIPE_SET_QLIMIT:
/* Lockless integer write. */
-   if (*(u_int *)data >= AUDIT_PIPE_QLIMIT_MIN ||
+   if (*(u_int *)data >= AUDIT_PIPE_QLIMIT_MIN &&
*(u_int *)data <= AUDIT_PIPE_QLIMIT_MAX) {
ap->ap_qlimit = *(u_int *)data;
error = 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: r336639 - in head/sys: arm/arm arm/mv mips/atheros mips/atheros/ar531x mips/malta mips/mediatek mips/mips sparc64/sparc64

2018-07-23 Thread Andriy Gapon
Author: avg
Date: Mon Jul 23 15:36:55 2018
New Revision: 336639
URL: https://svnweb.freebsd.org/changeset/base/336639

Log:
  follow-up to r336635, update TAILQ to CK_SLIST for ie_handlers
  
  arm, mips and sparc64 were affected.

Modified:
  head/sys/arm/arm/intr.c
  head/sys/arm/mv/gpio.c
  head/sys/mips/atheros/apb.c
  head/sys/mips/atheros/ar531x/apb.c
  head/sys/mips/atheros/ar71xx_pci.c
  head/sys/mips/atheros/ar724x_pci.c
  head/sys/mips/atheros/qca955x_pci.c
  head/sys/mips/malta/gt_pci.c
  head/sys/mips/mediatek/mtk_pcie.c
  head/sys/mips/mips/intr_machdep.c
  head/sys/sparc64/sparc64/intr_machdep.c

Modified: head/sys/arm/arm/intr.c
==
--- head/sys/arm/arm/intr.c Mon Jul 23 14:58:44 2018(r336638)
+++ head/sys/arm/arm/intr.c Mon Jul 23 15:36:55 2018(r336639)
@@ -170,7 +170,7 @@ arm_remove_irqhandler(int irq, void *cookie)
 
error = intr_event_remove_handler(cookie);
 
-   if (!TAILQ_EMPTY(&event->ie_handlers))
+   if (!CK_SLIST_EMPTY(&event->ie_handlers))
arm_unmask_irq(irq);
return (error);
 }

Modified: head/sys/arm/mv/gpio.c
==
--- head/sys/arm/mv/gpio.c  Mon Jul 23 14:58:44 2018(r336638)
+++ head/sys/arm/mv/gpio.c  Mon Jul 23 15:36:55 2018(r336639)
@@ -515,7 +515,8 @@ mv_gpio_intr_handler(device_t dev, int pin)
 #endif
isrc.isrc_event = sc->gpio_events[pin];
 
-   if (isrc.isrc_event == NULL || 
TAILQ_EMPTY(&isrc.isrc_event->ie_handlers))
+   if (isrc.isrc_event == NULL ||
+   CK_SLIST_EMPTY(&isrc.isrc_event->ie_handlers))
return;
 
intr_isrc_dispatch(&isrc, NULL);

Modified: head/sys/mips/atheros/apb.c
==
--- head/sys/mips/atheros/apb.c Mon Jul 23 14:58:44 2018(r336638)
+++ head/sys/mips/atheros/apb.c Mon Jul 23 15:36:55 2018(r336639)
@@ -382,7 +382,7 @@ apb_filter(void *arg)
event = sc->sc_eventstab[irq];
/* always count interrupts; spurious or otherwise */
mips_intrcnt_inc(sc->sc_intr_counter[irq]);
-   if (!event || TAILQ_EMPTY(&event->ie_handlers)) {
+   if (!event || CK_SLIST_EMPTY(&event->ie_handlers)) {
if (irq == APB_INTR_PMC) {
td = PCPU_GET(curthread);
tf = td->td_intr_frame;

Modified: head/sys/mips/atheros/ar531x/apb.c
==
--- head/sys/mips/atheros/ar531x/apb.c  Mon Jul 23 14:58:44 2018
(r336638)
+++ head/sys/mips/atheros/ar531x/apb.c  Mon Jul 23 15:36:55 2018
(r336639)
@@ -508,7 +508,7 @@ apb_filter(void *arg)
}
 
event = sc->sc_eventstab[irq];
-   if (!event || TAILQ_EMPTY(&event->ie_handlers)) {
+   if (!event || CK_SLIST_EMPTY(&event->ie_handlers)) {
if(irq == 1 && ar531x_soc < AR531X_SOC_AR5315) {
ATH_READ_REG(AR5312_SYSREG_BASE +
AR5312_SYSREG_AHBPERR);

Modified: head/sys/mips/atheros/ar71xx_pci.c
==
--- head/sys/mips/atheros/ar71xx_pci.c  Mon Jul 23 14:58:44 2018
(r336638)
+++ head/sys/mips/atheros/ar71xx_pci.c  Mon Jul 23 15:36:55 2018
(r336639)
@@ -630,7 +630,7 @@ ar71xx_pci_intr(void *arg)
for (irq = AR71XX_PCI_IRQ_START; irq <= AR71XX_PCI_IRQ_END; irq++) {
if (reg & (1 << irq)) {
event = sc->sc_eventstab[irq];
-   if (!event || TAILQ_EMPTY(&event->ie_handlers)) {
+   if (!event || CK_SLIST_EMPTY(&event->ie_handlers)) {
/* Ignore timer interrupts */
if (irq != 0)
printf("Stray IRQ %d\n", irq);

Modified: head/sys/mips/atheros/ar724x_pci.c
==
--- head/sys/mips/atheros/ar724x_pci.c  Mon Jul 23 14:58:44 2018
(r336638)
+++ head/sys/mips/atheros/ar724x_pci.c  Mon Jul 23 15:36:55 2018
(r336639)
@@ -605,7 +605,7 @@ ar724x_pci_intr(void *arg)
 
irq = AR71XX_PCI_IRQ_START;
event = sc->sc_eventstab[irq];
-   if (!event || TAILQ_EMPTY(&event->ie_handlers)) {
+   if (!event || CK_SLIST_EMPTY(&event->ie_handlers)) {
printf("Stray IRQ %d\n", irq);
return (FILTER_STRAY);
}

Modified: head/sys/mips/atheros/qca955

Re: svn commit: r336635 - in head/sys: kern sys

2018-07-23 Thread Andriy Gapon
On 23/07/2018 15:51, Andriy Gapon wrote:
> Author: avg
> Date: Mon Jul 23 12:51:23 2018
> New Revision: 336635
> URL: https://svnweb.freebsd.org/changeset/base/336635
> 
> Log:
>   change interrupt event's list of handlers from TAILQ to CK_SLIST

This commit broke a lot of !x86 architectures that access ie_handlers
directly.  I am building testing a fix for that now.

But maybe we should think about making sys/interrupt.h interface more
expressive so that the consumers do not need to poke into what could be
considered the internals of MI interrupt handling code.

-- 
Andriy Gapon
___
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: r336635 - in head/sys: kern sys

2018-07-23 Thread Andriy Gapon
Author: avg
Date: Mon Jul 23 12:51:23 2018
New Revision: 336635
URL: https://svnweb.freebsd.org/changeset/base/336635

Log:
  change interrupt event's list of handlers from TAILQ to CK_SLIST
  
  The primary reason for this commit is to separate mechanical and nearly
  mechanical code changes from an upcoming fix for unsafe teardown of
  shared interrupt handlers that have only filters (see D15905).
  
  The technical rationale is that SLIST is sufficient.  The only operation
  that gets worse performance -- O(n) instead of O(1) is a removal of a
  handler,  but it is not a critical operation and the list is expected to
  be rather short.
  
  Additionally, it is easier to reason about SLIST when considering the
  concurrent lock-free access to the list from the interrupt context and
  the interrupt thread.
  
  CK_SLIST is used because the upcoming change depends on the memory order
  provided by CK_SLIST insert and the fact that CL_SLIST remove does not
  trash the linkage in a removed element.
  
  While here, I also fixed a couple of whitespace issues, made code under
  ifdef notyet compilable, added a lock assertion to ithread_update() and
  made intr_event_execute_handlers() static as it had no external callers.
  
  Reviewed by:  cem (earlier version)
  MFC after:4 weeks
  Differential Revision: https://reviews.freebsd.org/D16016

Modified:
  head/sys/kern/kern_intr.c
  head/sys/sys/interrupt.h

Modified: head/sys/kern/kern_intr.c
==
--- head/sys/kern/kern_intr.c   Mon Jul 23 11:21:43 2018(r336634)
+++ head/sys/kern/kern_intr.c   Mon Jul 23 12:51:23 2018(r336635)
@@ -160,12 +160,13 @@ ithread_update(struct intr_thread *ithd)
 
ie = ithd->it_event;
td = ithd->it_thread;
+   mtx_assert(&ie->ie_lock, MA_OWNED);
 
/* Determine the overall priority of this event. */
-   if (TAILQ_EMPTY(&ie->ie_handlers))
+   if (CK_SLIST_EMPTY(&ie->ie_handlers))
pri = PRI_MAX_ITHD;
else
-   pri = TAILQ_FIRST(&ie->ie_handlers)->ih_pri;
+   pri = CK_SLIST_FIRST(&ie->ie_handlers)->ih_pri;
 
/* Update name and priority. */
strlcpy(td->td_name, ie->ie_fullname, sizeof(td->td_name));
@@ -195,7 +196,7 @@ intr_event_update(struct intr_event *ie)
space = 1;
 
/* Run through all the handlers updating values. */
-   TAILQ_FOREACH(ih, &ie->ie_handlers, ih_next) {
+   CK_SLIST_FOREACH(ih, &ie->ie_handlers, ih_next) {
if (strlen(ie->ie_fullname) + strlen(ih->ih_name) + 1 <
sizeof(ie->ie_fullname)) {
strcat(ie->ie_fullname, " ");
@@ -257,7 +258,7 @@ intr_event_create(struct intr_event **event, void *sou
ie->ie_flags = flags;
ie->ie_irq = irq;
ie->ie_cpu = NOCPU;
-   TAILQ_INIT(&ie->ie_handlers);
+   CK_SLIST_INIT(&ie->ie_handlers);
mtx_init(&ie->ie_lock, "intr event", NULL, MTX_DEF);
 
va_start(ap, fmt);
@@ -378,7 +379,7 @@ intr_lookup(int irq)
TAILQ_FOREACH(ie, &event_list, ie_list)
if (ie->ie_irq == irq &&
(ie->ie_flags & IE_SOFT) == 0 &&
-   TAILQ_FIRST(&ie->ie_handlers) != NULL)
+   CK_SLIST_FIRST(&ie->ie_handlers) != NULL)
break;
mtx_unlock(&event_lock);
return (ie);
@@ -474,7 +475,7 @@ intr_event_destroy(struct intr_event *ie)
 
mtx_lock(&event_lock);
mtx_lock(&ie->ie_lock);
-   if (!TAILQ_EMPTY(&ie->ie_handlers)) {
+   if (!CK_SLIST_EMPTY(&ie->ie_handlers)) {
mtx_unlock(&ie->ie_lock);
mtx_unlock(&event_lock);
return (EBUSY);
@@ -504,7 +505,7 @@ ithread_create(const char *name)
 
error = kproc_kthread_add(ithread_loop, ithd, &intrproc,
&td, RFSTOPPED | RFHIGHPID,
-   0, "intr", "%s", name);
+   0, "intr", "%s", name);
if (error)
panic("kproc_create() failed with %d", error);
thread_lock(td);
@@ -539,6 +540,7 @@ intr_event_add_handler(struct intr_event *ie, const ch
 enum intr_type flags, void **cookiep)
 {
struct intr_handler *ih, *temp_ih;
+   struct intr_handler **prevptr;
struct intr_thread *it;
 
if (ie == NULL || name == NULL || (handler == NULL && filter == NULL))
@@ -561,9 +563,9 @@ intr_event_add_handler(struct intr_event *ie, const ch
 
/* We can only have one exclusive handler in a event. */
mtx_lock(&ie->ie_lock);
-   if (!TAILQ_EMPTY(&ie->ie_handlers)) {
+   if (!CK_SLIST_EMPTY(&ie->ie_handlers)) {
if ((flags & INTR_EXCL) ||
-   (TAILQ_FIRST(&ie->ie_handlers)->ih_flags & IH_EXCLUSIVE)) {
+   (CK_SLIST_FIRST(&ie->ie_handlers)->ih_flags & 
IH_EXCLUSIVE)) {
mtx_unlock(&ie->ie_lock);

svn commit: r336634 - in head/sys/contrib/ck/include: . gcc/x86 gcc/x86_64

2018-07-23 Thread Andriy Gapon
Author: avg
Date: Mon Jul 23 11:21:43 2018
New Revision: 336634
URL: https://svnweb.freebsd.org/changeset/base/336634

Log:
  MFV CK@r336629: Import CK as of commit 
1c1f9901c2dea7a883342cd03d3906a1bc482583
  
  This adds CK_SLIST_INSERT_PREVPTR and CK_SLIST_REMOVE_PREVPTR macros
  as well as ck_pr_dec_is_zero family of functions.
  
  MFC after:3 weeks

Modified:
  head/sys/contrib/ck/include/ck_pr.h
  head/sys/contrib/ck/include/ck_queue.h
  head/sys/contrib/ck/include/gcc/x86/ck_pr.h
  head/sys/contrib/ck/include/gcc/x86_64/ck_pr.h
Directory Properties:
  head/sys/contrib/ck/   (props changed)

Modified: head/sys/contrib/ck/include/ck_pr.h
==
--- head/sys/contrib/ck/include/ck_pr.h Mon Jul 23 09:54:28 2018
(r336633)
+++ head/sys/contrib/ck/include/ck_pr.h Mon Jul 23 11:21:43 2018
(r336634)
@@ -619,8 +619,8 @@ CK_PR_BTX_S(bts, 16, uint16_t, |,)
}
 
 #define CK_PR_UNARY_Z(K, S, M, T, P, C, Z) \
-   CK_CC_INLINE static void\
-   ck_pr_##K##_##S##_zero(M *target, bool *zero)   \
+   CK_CC_INLINE static bool\
+   ck_pr_##K##_##S##_is_zero(M *target)\
{   \
T previous; \
C punt; \
@@ -631,12 +631,21 @@ CK_PR_BTX_S(bts, 16, uint16_t, |,)
 (C)(previous P 1), \
 &previous) == false)   \
ck_pr_stall();  \
-   *zero = previous == (T)Z;   \
+   return previous == (T)Z;\
+}
+
+#define CK_PR_UNARY_Z_STUB(K, S, M)\
+   CK_CC_INLINE static void\
+   ck_pr_##K##_##S##_zero(M *target, bool *zero)   \
+   {   \
+   *zero = ck_pr_##K##_##S##_is_zero(target);  \
return; \
}
 
 #define CK_PR_UNARY_S(K, X, S, M) CK_PR_UNARY(K, X, S, M, M)
-#define CK_PR_UNARY_Z_S(K, S, M, P, Z) CK_PR_UNARY_Z(K, S, M, M, P, M, Z)
+#define CK_PR_UNARY_Z_S(K, S, M, P, Z)  \
+CK_PR_UNARY_Z(K, S, M, M, P, M, Z)  \
+CK_PR_UNARY_Z_STUB(K, S, M)
 
 #if defined(CK_F_PR_LOAD_CHAR) && defined(CK_F_PR_CAS_CHAR_VALUE)
 
@@ -648,6 +657,8 @@ CK_PR_UNARY_S(inc, add, char, char)
 #ifndef CK_F_PR_INC_CHAR_ZERO
 #define CK_F_PR_INC_CHAR_ZERO
 CK_PR_UNARY_Z_S(inc, char, char, +, -1)
+#else
+CK_PR_UNARY_Z_STUB(inc, char, char)
 #endif /* CK_F_PR_INC_CHAR_ZERO */
 
 #ifndef CK_F_PR_DEC_CHAR
@@ -658,6 +669,8 @@ CK_PR_UNARY_S(dec, sub, char, char)
 #ifndef CK_F_PR_DEC_CHAR_ZERO
 #define CK_F_PR_DEC_CHAR_ZERO
 CK_PR_UNARY_Z_S(dec, char, char, -, 1)
+#else
+CK_PR_UNARY_Z_STUB(dec, char, char)
 #endif /* CK_F_PR_DEC_CHAR_ZERO */
 
 #endif /* CK_F_PR_LOAD_CHAR && CK_F_PR_CAS_CHAR_VALUE */
@@ -672,6 +685,8 @@ CK_PR_UNARY_S(inc, add, int, int)
 #ifndef CK_F_PR_INC_INT_ZERO
 #define CK_F_PR_INC_INT_ZERO
 CK_PR_UNARY_Z_S(inc, int, int, +, -1)
+#else
+CK_PR_UNARY_Z_STUB(inc, int, int)
 #endif /* CK_F_PR_INC_INT_ZERO */
 
 #ifndef CK_F_PR_DEC_INT
@@ -682,6 +697,8 @@ CK_PR_UNARY_S(dec, sub, int, int)
 #ifndef CK_F_PR_DEC_INT_ZERO
 #define CK_F_PR_DEC_INT_ZERO
 CK_PR_UNARY_Z_S(dec, int, int, -, 1)
+#else
+CK_PR_UNARY_Z_STUB(dec, int, int)
 #endif /* CK_F_PR_DEC_INT_ZERO */
 
 #endif /* CK_F_PR_LOAD_INT && CK_F_PR_CAS_INT_VALUE */
@@ -711,6 +728,8 @@ CK_PR_UNARY_S(inc, add, uint, unsigned int)
 #ifndef CK_F_PR_INC_UINT_ZERO
 #define CK_F_PR_INC_UINT_ZERO
 CK_PR_UNARY_Z_S(inc, uint, unsigned int, +, UINT_MAX)
+#else
+CK_PR_UNARY_Z_STUB(inc, uint, unsigned int)
 #endif /* CK_F_PR_INC_UINT_ZERO */
 
 #ifndef CK_F_PR_DEC_UINT
@@ -721,6 +740,8 @@ CK_PR_UNARY_S(dec, sub, uint, unsigned int)
 #ifndef CK_F_PR_DEC_UINT_ZERO
 #define CK_F_PR_DEC_UINT_ZERO
 CK_PR_UNARY_Z_S(dec, uint, unsigned int, -, 1)
+#else
+CK_PR_UNARY_Z_STUB(dec, uint, unsigned int)
 #endif /* CK_F_PR_DEC_UINT_ZERO */
 
 #endif /* CK_F_PR_LOAD_UINT && CK_F_PR_CAS_UINT_VALUE */
@@ -735,6 +756,8 @@ CK_PR_UNARY(inc, add, ptr, void, uintptr_t)
 #ifndef CK_F_PR_INC_PTR_ZERO
 #define CK_F_PR_INC_PTR_ZERO
 CK_PR_UNARY_Z(inc, ptr, void, uintptr_t, +, void *, UINT_MAX)
+#else
+CK_PR_UNARY_Z_STUB(inc, ptr, void)
 #endif /* CK_F_PR_INC_PTR_ZERO */
 
 #ifndef CK_F_PR_DEC_PTR
@@ -745,6 +768,8 @@ CK_PR_UNARY(dec, sub, ptr, void, uintptr_t)
 #ifndef CK_F_PR_DEC_PTR_ZERO
 #define CK_F_PR_DEC_PTR_ZERO
 CK_PR_UNARY_Z(dec, ptr, void, uintptr_t, -, void *, 

Re: svn commit: r336532 - in head/stand: . common i386 i386/loader i386/zfsboot i386/zfsloader sparc64 sparc64/loader sparc64/zfsloader

2018-07-20 Thread Andriy Gapon
On 20/07/2018 08:17, Warner Losh wrote:
> Provide a symbolic link from zfsloader
>   to loader so people who have not upgraded their boot blocks are not
>   affected

I am not sure that ZFS boot blocks can handle symbolic links...
I seem to recall that not a long time ago they lacked that ability.

-- 
Andriy Gapon
___
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: r336068 - in head/sys: dev/amdsmb modules/amdsmb

2018-07-07 Thread Andriy Gapon
On 07/07/2018 18:55, Warner Losh wrote:
> Author: imp
> Date: Sat Jul  7 15:55:52 2018
> New Revision: 336068
> URL: https://svnweb.freebsd.org/changeset/base/336068
> 
> Log:
>   Update AMDSMB to use PCI_MATCH

Just curious if anyone still uses this driver for ancient hardware.
maybe de-orbit time?

>   Differential Review: https://reviews.freebsd.org/D16172

Just curious what's the point of referencing a review request that
- had no reviewers
- had no reviews
- does not even have a description

> Added:
>   head/sys/modules/amdsmb/
>   head/sys/modules/amdsmb/Makefile   (contents, props changed)
> Modified:
>   head/sys/dev/amdsmb/amdsmb.c
> 
> Modified: head/sys/dev/amdsmb/amdsmb.c
> ==
> --- head/sys/dev/amdsmb/amdsmb.c  Sat Jul  7 15:25:16 2018
> (r336067)
> +++ head/sys/dev/amdsmb/amdsmb.c  Sat Jul  7 15:55:52 2018
> (r336068)
> @@ -125,24 +125,22 @@ struct amdsmb_softc {
>  
>  static int   amdsmb_detach(device_t dev);
>  
> +struct pci_device_table amdsmb_devs[] = {
> + { PCI_DEV(AMDSMB_VENDORID_AMD, AMDSMB_DEVICEID_AMD8111_SMB2),
> +   PCI_DESCR("AMD-8111 SMBus 2.0 Controller") }
> +};
> +
>  static int
>  amdsmb_probe(device_t dev)
>  {
> - u_int16_t vid;
> - u_int16_t did;
> + const struct pci_device_table *tbl;
>  
> - vid = pci_get_vendor(dev);
> - did = pci_get_device(dev);
> + tbl = PCI_MATCH(dev, amdsmb_devs);
> + if (tbl == NULL)
> + return (ENXIO);
> + device_set_desc(dev, tbl->descr);
>  
> - if (vid == AMDSMB_VENDORID_AMD) {
> - switch(did) {
> - case AMDSMB_DEVICEID_AMD8111_SMB2:
> - device_set_desc(dev, "AMD-8111 SMBus 2.0 Controller");
> - return (BUS_PROBE_DEFAULT);
> - }
> - }
> -
> - return (ENXIO);
> + return (BUS_PROBE_DEFAULT);
>  }
>  
>  static int
> 
> Added: head/sys/modules/amdsmb/Makefile
> ==
> --- /dev/null 00:00:00 1970   (empty, because file is newly added)
> +++ head/sys/modules/amdsmb/Makefile  Sat Jul  7 15:55:52 2018    
> (r336068)
> @@ -0,0 +1,8 @@
> +# $FreeBSD$
> +
> +.PATH:   ${SRCTOP}/sys/dev/amdsmb
> +
> +KMOD=amdsmb
> +SRCS=amdsmb.c bus_if.h device_if.h pci_if.h smbus_if.h
> +
> +.include 
> 


-- 
Andriy Gapon
___
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: r335934 - in head/sys: cam cam/ata cam/nvme cam/scsi dev/acpica/Osd dev/pccbb kern

2018-07-04 Thread Andriy Gapon
Author: avg
Date: Wed Jul  4 09:07:18 2018
New Revision: 335934
URL: https://svnweb.freebsd.org/changeset/base/335934

Log:
  remove unneeded inclusion of sys/interrupt.h from several files
  
  It's likely that the header was needed in the past for swi(9).
  But now that code does not use swi(9) or any other interfaces defined
  in sys/interrupt.h.
  
  MFC after:1 week

Modified:
  head/sys/cam/ata/ata_xpt.c
  head/sys/cam/cam_xpt.c
  head/sys/cam/nvme/nvme_xpt.c
  head/sys/cam/scsi/scsi_xpt.c
  head/sys/dev/acpica/Osd/OsdSchedule.c
  head/sys/dev/pccbb/pccbb.c
  head/sys/kern/subr_bus.c

Modified: head/sys/cam/ata/ata_xpt.c
==
--- head/sys/cam/ata/ata_xpt.c  Wed Jul  4 07:37:45 2018(r335933)
+++ head/sys/cam/ata/ata_xpt.c  Wed Jul  4 09:07:18 2018(r335934)
@@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 

Modified: head/sys/cam/cam_xpt.c
==
--- head/sys/cam/cam_xpt.c  Wed Jul  4 07:37:45 2018(r335933)
+++ head/sys/cam/cam_xpt.c  Wed Jul  4 09:07:18 2018(r335934)
@@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 

Modified: head/sys/cam/nvme/nvme_xpt.c
==
--- head/sys/cam/nvme/nvme_xpt.cWed Jul  4 07:37:45 2018
(r335933)
+++ head/sys/cam/nvme/nvme_xpt.cWed Jul  4 09:07:18 2018
(r335934)
@@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 

Modified: head/sys/cam/scsi/scsi_xpt.c
==
--- head/sys/cam/scsi/scsi_xpt.cWed Jul  4 07:37:45 2018
(r335933)
+++ head/sys/cam/scsi/scsi_xpt.cWed Jul  4 09:07:18 2018
(r335934)
@@ -42,7 +42,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 

Modified: head/sys/dev/acpica/Osd/OsdSchedule.c
==
--- head/sys/dev/acpica/Osd/OsdSchedule.c   Wed Jul  4 07:37:45 2018
(r335933)
+++ head/sys/dev/acpica/Osd/OsdSchedule.c   Wed Jul  4 09:07:18 2018
(r335934)
@@ -37,7 +37,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 

Modified: head/sys/dev/pccbb/pccbb.c
==
--- head/sys/dev/pccbb/pccbb.c  Wed Jul  4 07:37:45 2018(r335933)
+++ head/sys/dev/pccbb/pccbb.c  Wed Jul  4 09:07:18 2018(r335934)
@@ -86,7 +86,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 

Modified: head/sys/kern/subr_bus.c
==
--- head/sys/kern/subr_bus.cWed Jul  4 07:37:45 2018(r335933)
+++ head/sys/kern/subr_bus.cWed Jul  4 09:07:18 2018(r335934)
@@ -59,7 +59,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
___
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: r335632 - in head/sys: dev/vt/hw/vga x86/include x86/isa x86/x86

2018-06-25 Thread Andriy Gapon
On 25/06/2018 14:01, Konstantin Belousov wrote:
> Modified: head/sys/x86/x86/cpu_machdep.c
> ==
> --- head/sys/x86/x86/cpu_machdep.cMon Jun 25 10:52:41 2018
> (r335631)
> +++ head/sys/x86/x86/cpu_machdep.cMon Jun 25 11:01:12 2018
> (r335632)

Maybe acpi_machdep.c or some other file under x86/acpica would be better...

> @@ -41,6 +41,7 @@
>  #include 
>  __FBSDID("$FreeBSD$");
>  
> +#include "opt_acpi.h"
>  #include "opt_atpic.h"
>  #include "opt_cpu.h"
>  #include "opt_ddb.h"
> @@ -98,6 +99,8 @@ __FBSDID("$FreeBSD$");
>  
>  #include 
>  
> +#include 
> +
>  #define  STATE_RUNNING   0x0
>  #define  STATE_MWAIT 0x1
>  #define  STATE_SLEEPING  0x2


-- 
Andriy Gapon
___
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: r333590 - head/share/man/man9

2018-06-25 Thread Andriy Gapon
On 25/06/2018 10:25, Ed Schouten wrote:
> Hi Andriy, Matthew,
> 
> 2018-06-24 23:36 GMT+02:00 Andriy Gapon :
>> Perhaps a little application of google can help.
>> [keywords: epoch based reclamation]
> 
> Based on the man page, it wasn't clear that this refers to a generally
> accepted construct or something that is specific to FreeBSD. Any
> objections if I were to extend the man page as follows?

Certainly not from me.
Also, given that epoch(9) is a wrapper around (or based on) the implementation
provided by Concurrency Kit, maybe we should have some kind of a gateway manual
page for the latter.  That page would provide an introduction to Concurrency Kit
and links to its resources.  Then epoch.9 could reference it.

> Index: epoch.9
> ===
> --- epoch.9 (revision 335613)
> +++ epoch.9 (working copy)
> @@ -39,7 +39,7 @@
>  .Nm epoch_wait ,
>  .Nm epoch_call ,
>  .Nm in_epoch ,
> -.Nd kernel epoch based reclamation
> +.Nd kernel Epoch Based Reclamation (EBR)
>  .Sh SYNOPSIS
>  .In sys/param.h
>  .In sys/proc.h
> @@ -191,3 +191,10 @@
>  .Xr sleep 9 ,
>  .Xr sx 9 ,
>  .Xr timeout 9
> +.Rs
> +.%A K. Fraser
> +.%T Practical lock-freedom
> +.%D February 2004
> +.%P 79-81
> +.%U https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-579.pdf
> +.Re
> 


-- 
Andriy Gapon
___
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: r333590 - head/share/man/man9

2018-06-24 Thread Andriy Gapon
On 24/06/2018 23:55, Ed Schouten wrote:
> Hi Matt,
> 
> 2018-05-17 9:06 GMT+02:00 Ed Schouten :
>> Hi Matt,
>>
>> 2018-05-14 1:16 GMT+02:00 Matt Macy :
>>> +Epochs do not have any lock ordering issues. Entering and leaving
>>
>> It looks like the man page is missing some newlines between sentences.
>>
>> Quick question: How does this work relate to RCU
>> (https://en.wikipedia.org/wiki/Read-copy-update)? If there is any
>> relation, should we mention it in the documentation?
> 
> I never got a response to this. Any thoughts?

Perhaps a little application of google can help.
[keywords: epoch based reclamation]

-- 
Andriy Gapon
___
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: r334786 - head/sys/x86/x86

2018-06-07 Thread Andriy Gapon
Author: avg
Date: Thu Jun  7 14:46:52 2018
New Revision: 334786
URL: https://svnweb.freebsd.org/changeset/base/334786

Log:
  x86: reorganize code that deals with unexpected NMI-s
  
  Expected NMI-s are those than are either generated by the software (such
  as a CPU sending NMI to other CPU) or generated by the hardware after
  the software configured it to do so (such as NMI-s on PMC events).
  
  Some unexpected NMI-s can be caused by hardware failures and it is
  possible to inquire the hardware about them (somewhat like MCA but much
  more primitive) using an EISA mechanism.  In some cases the origin of
  the NMI can remain truly unknown.
  
  This commit should not change any functionality.  It just reorganizes
  the code, so that it is easier to extend with new checks for the origin
  of the NMI.  Also, it frees the code that has nothing to do with ISA
  from DEV_ISA.
  
  MFC after:3 weeks

Modified:
  head/sys/x86/x86/cpu_machdep.c
  head/sys/x86/x86/mp_x86.c

Modified: head/sys/x86/x86/cpu_machdep.c
==
--- head/sys/x86/x86/cpu_machdep.c  Thu Jun  7 14:23:31 2018
(r334785)
+++ head/sys/x86/x86/cpu_machdep.c  Thu Jun  7 14:46:52 2018
(r334786)
@@ -735,33 +735,34 @@ SYSCTL_INT(_machdep, OID_AUTO, kdb_on_nmi, CTLFLAG_RWT
 "Go to KDB on NMI with unknown source");
 #endif
 
-#ifdef DEV_ISA
 void
 nmi_call_kdb(u_int cpu, u_int type, struct trapframe *frame)
 {
+   bool claimed = false;
 
+#ifdef DEV_ISA
/* machine/parity/power fail/"kitchen sink" faults */
-   if (isa_nmi(frame->tf_err) == 0) {
+   if (isa_nmi(frame->tf_err)) {
+   claimed = true;
+   if (panic_on_nmi)
+   panic("NMI indicates hardware failure");
+   }
+#endif /* DEV_ISA */
 #ifdef KDB
+   if (!claimed && kdb_on_nmi) {
/*
 * NMI can be hooked up to a pushbutton for debugging.
 */
-   if (kdb_on_nmi) {
-   printf("NMI/cpu%d ... going to debugger\n", cpu);
-   kdb_trap(type, 0, frame);
-   }
-#endif /* KDB */
-   } else if (panic_on_nmi) {
-   panic("NMI indicates hardware failure");
+   printf("NMI/cpu%d ... going to debugger\n", cpu);
+   kdb_trap(type, 0, frame);
}
+#endif /* KDB */
 }
-#endif
 
 void
 nmi_handle_intr(u_int type, struct trapframe *frame)
 {
 
-#ifdef DEV_ISA
 #ifdef SMP
if (nmi_is_broadcast) {
nmi_call_kdb_smp(type, frame);
@@ -769,7 +770,6 @@ nmi_handle_intr(u_int type, struct trapframe *frame)
}
 #endif
nmi_call_kdb(PCPU_GET(cpuid), type, frame);
-#endif
 }
 
 int hw_ibrs_active;

Modified: head/sys/x86/x86/mp_x86.c
==
--- head/sys/x86/x86/mp_x86.c   Thu Jun  7 14:23:31 2018(r334785)
+++ head/sys/x86/x86/mp_x86.c   Thu Jun  7 14:46:52 2018(r334786)
@@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$");
 #include "opt_apic.h"
 #endif
 #include "opt_cpu.h"
-#include "opt_isa.h"
 #include "opt_kstack_pages.h"
 #include "opt_pmap.h"
 #include "opt_sched.h"
@@ -1339,7 +1338,6 @@ ipi_nmi_handler(void)
return (0);
 }
 
-#ifdef DEV_ISA
 int nmi_kdb_lock;
 
 void
@@ -1363,7 +1361,6 @@ nmi_call_kdb_smp(u_int type, struct trapframe *frame)
if (call_post)
cpustop_handler_post(cpu);
 }
-#endif
 
 /*
  * Handle an IPI_STOP by saving our current context and spinning until we
___
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: r334785 - head/sys/x86/x86

2018-06-07 Thread Andriy Gapon
Author: avg
Date: Thu Jun  7 14:23:31 2018
New Revision: 334785
URL: https://svnweb.freebsd.org/changeset/base/334785

Log:
  expand descriptions of x86 panic_on_nmi and kdb_on_nmi sysctls
  
  The descriptions were as terse as the variable names and they did not
  explain additional conditions for knobs.
  
  MFC after:1 week

Modified:
  head/sys/x86/x86/cpu_machdep.c

Modified: head/sys/x86/x86/cpu_machdep.c
==
--- head/sys/x86/x86/cpu_machdep.c  Thu Jun  7 13:57:34 2018
(r334784)
+++ head/sys/x86/x86/cpu_machdep.c  Thu Jun  7 14:23:31 2018
(r334785)
@@ -723,7 +723,7 @@ SYSINIT(cpu_idle_tun, SI_SUB_CPU, SI_ORDER_MIDDLE, cpu
 static int panic_on_nmi = 1;
 SYSCTL_INT(_machdep, OID_AUTO, panic_on_nmi, CTLFLAG_RWTUN,
 &panic_on_nmi, 0,
-"Panic on NMI");
+"Panic on NMI raised by hardware failure");
 int nmi_is_broadcast = 1;
 SYSCTL_INT(_machdep, OID_AUTO, nmi_is_broadcast, CTLFLAG_RWTUN,
 &nmi_is_broadcast, 0,
@@ -732,7 +732,7 @@ SYSCTL_INT(_machdep, OID_AUTO, nmi_is_broadcast, CTLFL
 int kdb_on_nmi = 1;
 SYSCTL_INT(_machdep, OID_AUTO, kdb_on_nmi, CTLFLAG_RWTUN,
 &kdb_on_nmi, 0,
-"Go to KDB on NMI");
+"Go to KDB on NMI with unknown source");
 #endif
 
 #ifdef DEV_ISA
___
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: r334708 - head/sys/kern

2018-06-06 Thread Andriy Gapon
On 06/06/2018 16:02, Warner Losh wrote:
> 
> 
> On Wed, Jun 6, 2018 at 8:57 AM, Justin Hibbits  <mailto:jhibb...@freebsd.org>> wrote:
> 
> Author: jhibbits
> Date: Wed Jun  6 12:57:11 2018
> New Revision: 334708
> URL: https://svnweb.freebsd.org/changeset/base/334708
> <https://svnweb.freebsd.org/changeset/base/334708>
> 
> Log:
>   Add a memory barrier after taking a reference on the vnode holdcnt in 
> _vhold
> 
>   This is needed to avoid a race between the VNASSERT() below, and another
>   thread updating the VI_FREE flag, on weakly-ordered architectures.
> 
>   On a 72-thread POWER9, without this barrier a 'make -j72 buildworld' 
> would
>   panic on the assert regularly.
> 
>   It may be possible to use a weaker barrier, and I'll investigate that 
> once
>   all stability issues are worked out on POWER9.
> 
> Modified:
>   head/sys/kern/vfs_subr.c
> 
> Modified: head/sys/kern/vfs_subr.c
> 
> ==
> --- head/sys/kern/vfs_subr.c    Wed Jun  6 10:46:24 2018        (r334707)
> +++ head/sys/kern/vfs_subr.c    Wed Jun  6 12:57:11 2018        (r334708)
> @@ -2807,6 +2807,9 @@ _vhold(struct vnode *vp, bool locked)
>         CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
>         if (!locked) {
>                 if (refcount_acquire_if_not_zero(&vp->v_holdcnt)) {
> +#if !defined(__amd64__) && !defined(__i386__)
> +                       mb();
> +#endif
>                         VNASSERT((vp->v_iflag & VI_FREE) == 0, vp,
>                             ("_vhold: vnode with holdcnt is free"));
>                         return;
> 
> 
> So why isn't the refcount_acquire() enough?

This is the wrong "acquire", "acquire" in a sense of "get" or "increment", not
in a sense of a memory barrier.



-- 
Andriy Gapon
___
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: r334669 - head/sys/sys

2018-06-05 Thread Andriy Gapon
On 06/06/2018 00:07, Eric van Gyzen wrote:
> On 06/05/2018 15:53, Ian Lepore wrote:
>> This is a sad sad thing. Treating (bits & flagconstants) as boolean has
>> a long long history in C. Surely there are literally thousand of
>> occurrances in freebsd code already, so why did this one get flagged?
> 
> I agree, and I tend to avoid adding "!= 0" unnecessarily, but I don't
> feel very strongly about it.  

I am not sure what parts of code you work on, but turning bit operations into
logical operations within conditions is the predominant FreeBSD style.
Please accept it.


-- 
Andriy Gapon
___
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: r334543 - head/usr.bin/top

2018-06-03 Thread Andriy Gapon
On 04/06/2018 00:33, Rodney W. Grimes wrote:
> lsof is your friend here.  That is the tool of choice for finding
> cwd of processes that are in directories you can not unmount.

s/lsof/fstat -f [-m]/
:-)

-- 
Andriy Gapon
___
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: r334479 - head/sys/dev/acpica

2018-06-01 Thread Andriy Gapon
Author: avg
Date: Fri Jun  1 09:44:23 2018
New Revision: 334479
URL: https://svnweb.freebsd.org/changeset/base/334479

Log:
  call AcpiLeaveSleepStatePrep after re-enabling interrupts
  
  I want to do this change because this call (actually,
  AcpiHwLegacyWakePrep) does a memory allocation and ACPI namespace
  evaluation.  Although it is not very likely to run into any trouble, it
  is still not safe to make those calls with interrupts disabled.
  witness(4) and malloc(9) do not currently check for a context with
  interrupts disabled via intr_disable and we lack a facility for doing
  that.  So, those unsafe operations fly under the radar.  But if
  intr_disable in acpi_EnterSleepState was replaced with spinlock_enter
  (which it probably should be), then witness and malloc would immediately
  complain.
  
  Also, AcpiLeaveSleepStatePrep is documented as called when interrupts
  are enabled.  It used to require disabled interrupts, but that
  requirement was changed a long time ago when support for _BFS and _GTS
  was removed from ACPICA.
  
  The ACPI wakeup sequence is very sensitive to changes. I consider this
  change to be correct, but there can be fallouts from it.
  
  What AcpiHwLegacyWakePrep essentially does is writing a value
  corresponding to S0 into SLP_TYPx bits of PM1 Control Register(s).
  According to ACPI specifications that write should be a NOP as SLP_EN
  bit is not set.  But I see in some chipset specifications that they
  allow to ignore SLP_EN altogether and to act on a change of SLP_TYPx
  alone.
  
  Also, there are a couple of accesses to ACPI hardware before the new
  location of the call to AcpiLeaveSleepStatePrep.  One is to clear the
  power button status and the other is to enable SCI.  So, the move may
  affect the interaction between then OS and ACPI platform.
  
  I have not seen any regressions on my test system, but it's a desktop.
  
  MFC after:5 weeks

Modified:
  head/sys/dev/acpica/acpi.c

Modified: head/sys/dev/acpica/acpi.c
==
--- head/sys/dev/acpica/acpi.c  Fri Jun  1 09:41:15 2018(r334478)
+++ head/sys/dev/acpica/acpi.c  Fri Jun  1 09:44:23 2018(r334479)
@@ -2977,8 +2977,6 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state)
if (sleep_result == 1 && state != ACPI_STATE_S4)
AcpiWriteBitRegister(ACPI_BITREG_SCI_ENABLE, ACPI_ENABLE_EVENT);
 
-   AcpiLeaveSleepStatePrep(state);
-
if (sleep_result == 1 && state == ACPI_STATE_S3) {
/*
 * Prevent mis-interpretation of the wakeup by power button
@@ -3007,6 +3005,8 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state)
/* call acpi_wakeup_machdep() again with interrupt enabled */
acpi_wakeup_machdep(sc, state, sleep_result, 1);
 
+   AcpiLeaveSleepStatePrep(state);
+
if (sleep_result == -1)
goto backout;
 
@@ -3015,8 +3015,8 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state)
AcpiEnable();
 } else {
status = AcpiEnterSleepState(state);
-   AcpiLeaveSleepStatePrep(state);
intr_restore(intr);
+   AcpiLeaveSleepStatePrep(state);
if (ACPI_FAILURE(status)) {
device_printf(sc->acpi_dev, "AcpiEnterSleepState failed - %s\n",
  AcpiFormatException(status));
___
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: r334340 - in head/sys: dev/uart kern sys x86/acpica

2018-05-29 Thread Andriy Gapon
Author: avg
Date: Tue May 29 16:16:24 2018
New Revision: 334340
URL: https://svnweb.freebsd.org/changeset/base/334340

Log:
  add support for console resuming, implement it for uart, use on x86
  
  This change adds a new optional console method cn_resume and a kernel
  console interface cnresume.  Consoles that may need to re-initialize
  their hardware after suspend (e.g., because firmware does not care to do
  it) will implement cn_resume.  Note that it is called in rather early
  environment not unlike early boot, so the same restrictions apply.
  Platform specific code, for platforms that support hardware suspend,
  should call cnresume early after resume, before any console output is
  expected.
  
  This change fixes a problem with a system of mine failing to resume when
  a serial console is used.  I found that the serial port was in a strange
  configuration and an attempt to write to it likely resulted in an
  infinite loop.
  
  To avoid adding cn_resume method to every console driver, CONSOLE_DRIVER
  macro has been extended to support optional methods.
  
  Reviewed by:  imp, mav
  MFC after:3 weeks
  Differential Revision: https://reviews.freebsd.org/D15552

Modified:
  head/sys/dev/uart/uart_tty.c
  head/sys/kern/kern_cons.c
  head/sys/sys/cons.h
  head/sys/x86/acpica/acpi_wakeup.c

Modified: head/sys/dev/uart/uart_tty.c
==
--- head/sys/dev/uart/uart_tty.cTue May 29 16:04:53 2018
(r334339)
+++ head/sys/dev/uart/uart_tty.cTue May 29 16:16:24 2018
(r334340)
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
 
 static cn_probe_t uart_cnprobe;
 static cn_init_t uart_cninit;
+static cn_init_t uart_cnresume;
 static cn_term_t uart_cnterm;
 static cn_getc_t uart_cngetc;
 static cn_putc_t uart_cnputc;
@@ -69,7 +70,10 @@ static tsw_modem_t uart_tty_modem;
 static tsw_free_t uart_tty_free;
 static tsw_busy_t uart_tty_busy;
 
-CONSOLE_DRIVER(uart);
+CONSOLE_DRIVER(
+   uart,
+   .cn_resume = uart_cnresume,
+);
 
 static struct uart_devinfo uart_console;
 
@@ -112,6 +116,13 @@ uart_cninit(struct consdev *cp)
di->type = UART_DEV_CONSOLE;
uart_add_sysdev(di);
uart_init(di);
+}
+
+static void
+uart_cnresume(struct consdev *cp)
+{
+
+   uart_init(cp->cn_arg);
 }
 
 static void

Modified: head/sys/kern/kern_cons.c
==
--- head/sys/kern/kern_cons.c   Tue May 29 16:04:53 2018(r334339)
+++ head/sys/kern/kern_cons.c   Tue May 29 16:16:24 2018(r334340)
@@ -384,6 +384,19 @@ cnungrab()
}
 }
 
+void
+cnresume()
+{
+   struct cn_device *cnd;
+   struct consdev *cn;
+
+   STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) {
+   cn = cnd->cnd_cn;
+   if (cn->cn_ops->cn_resume != NULL)
+   cn->cn_ops->cn_resume(cn);
+   }
+}
+
 /*
  * Low level console routines.
  */

Modified: head/sys/sys/cons.h
==
--- head/sys/sys/cons.h Tue May 29 16:04:53 2018(r334339)
+++ head/sys/sys/cons.h Tue May 29 16:16:24 2018(r334340)
@@ -66,6 +66,8 @@ struct consdev_ops {
/* grab console for exclusive kernel use */
cn_ungrab_t *cn_ungrab;
/* ungrab console */
+   cn_init_t   *cn_resume;
+   /* set up console after sleep, optional */
 };
 
 struct consdev {
@@ -105,8 +107,9 @@ extern  struct tty *constty;/* Temporary virtual 
conso
};  \
DATA_SET(cons_set, name)
 
-#defineCONSOLE_DRIVER(name)
\
+#defineCONSOLE_DRIVER(name, ...)   
\
static const struct consdev_ops name##_consdev_ops = {  \
+   /* Mandatory methods. */\
.cn_probe = name##_cnprobe, \
.cn_init = name##_cninit,   \
.cn_term = name##_cnterm,   \
@@ -114,6 +117,8 @@ extern  struct tty *constty;/* Temporary virtual 
conso
.cn_putc = name##_cnputc,   \
.cn_grab = name##_cngrab,   \
.cn_ungrab = name##_cnungrab,   \
+   /* Optional fields. */  \
+   __VA_ARGS__ \
};  \
CONSOLE_DEVICE(name##_consdev, name##_consdev_ops, NULL)
 
@@ -126,6 +131,7 @@ voidcnremove(struct consdev *);
 void   cnselect(struct consdev *);
 void  

svn commit: r334338 - head/sys/x86/x86

2018-05-29 Thread Andriy Gapon
Author: avg
Date: Tue May 29 16:03:53 2018
New Revision: 334338
URL: https://svnweb.freebsd.org/changeset/base/334338

Log:
  fix x86 UP build broken by r334204, TSC resynchronization
  
  Reported by:  bde
  MFC after:1 week
  X-MFC with:   r334204

Modified:
  head/sys/x86/x86/tsc.c

Modified: head/sys/x86/x86/tsc.c
==
--- head/sys/x86/x86/tsc.c  Tue May 29 15:06:13 2018(r334337)
+++ head/sys/x86/x86/tsc.c  Tue May 29 16:03:53 2018(r334338)
@@ -505,19 +505,6 @@ retry:
 
 #undef N
 
-#else
-
-/*
- * The function is not called, it is provided to avoid linking failure
- * on uniprocessor kernel.
- */
-static int
-test_tsc(int adj_max_count __unused)
-{
-
-   return (0);
-}
-
 #endif /* SMP */
 
 static void
@@ -578,9 +565,12 @@ init_TSC_tc(void)
 * non-zero value.  The TSC seems unreliable in virtualized SMP
 * environments, so it is set to a negative quality in those cases.
 */
+#ifdef SMP
if (mp_ncpus > 1)
tsc_timecounter.tc_quality = test_tsc(smp_tsc_adjust);
-   else if (tsc_is_invariant)
+   else
+#endif /* SMP */
+   if (tsc_is_invariant)
tsc_timecounter.tc_quality = 1000;
max_freq >>= tsc_shift;
 
@@ -618,6 +608,7 @@ SYSINIT(tsc_tc, SI_SUB_SMP, SI_ORDER_ANY, init_TSC_tc,
 void
 resume_TSC(void)
 {
+#ifdef SMP
int quality;
 
/* If TSC was not good on boot, it is unlikely to become good now. */
@@ -637,6 +628,7 @@ resume_TSC(void)
tsc_timecounter.tc_quality, quality);
tsc_timecounter.tc_quality = quality;
}
+#endif /* SMP */
 }
 
 /*
___
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: r334204 - in head/sys: amd64/include dev/acpica i386/include x86/x86

2018-05-25 Thread Andriy Gapon
Author: avg
Date: Fri May 25 07:33:20 2018
New Revision: 334204
URL: https://svnweb.freebsd.org/changeset/base/334204

Log:
  re-synchronize TSC-s on SMP systems after resume, if necessary
  
  The TSC-s are checked and synchronized only if they were good
  originally.  That is, invariant, synchronized, etc.
  
  This is necessary on an AMD-based system where after a wakeup from STR I
  see that BSP clock differs from AP clocks by a count that roughly
  corresponds to one second.  The APs are in sync with each other.  Not
  sure if this is a hardware quirk or a firmware bug.
  
  This is what I see after a resume with this change:
  SMP: passed TSC synchronization test after adjustment
  acpi_timer0: restoring timecounter, ACPI-fast -> TSC-low
  
  Reviewed by:  kib
  MFC after:3 weeks
  Differential Revision: https://reviews.freebsd.org/D15551

Modified:
  head/sys/amd64/include/clock.h
  head/sys/dev/acpica/acpi.c
  head/sys/i386/include/clock.h
  head/sys/x86/x86/tsc.c

Modified: head/sys/amd64/include/clock.h
==
--- head/sys/amd64/include/clock.h  Fri May 25 07:29:52 2018
(r334203)
+++ head/sys/amd64/include/clock.h  Fri May 25 07:33:20 2018
(r334204)
@@ -34,6 +34,7 @@ void  clock_init(void);
 
 void   startrtclock(void);
 void   init_TSC(void);
+void   resume_TSC(void);
 
 #defineHAS_TIMER_SPKR 1
 inttimer_spkr_acquire(void);

Modified: head/sys/dev/acpica/acpi.c
==
--- head/sys/dev/acpica/acpi.c  Fri May 25 07:29:52 2018(r334203)
+++ head/sys/dev/acpica/acpi.c  Fri May 25 07:33:20 2018(r334204)
@@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #if defined(__i386__) || defined(__amd64__)
+#include 
 #include 
 #endif
 #include 
@@ -3040,6 +3041,10 @@ backout:
 if (slp_state >= ACPI_SS_SLP_PREP)
AcpiLeaveSleepState(state);
 if (slp_state >= ACPI_SS_SLEPT) {
+#if defined(__i386__) || defined(__amd64__)
+   /* NB: we are still using ACPI timecounter at this point. */
+   resume_TSC();
+#endif
acpi_resync_clock(sc);
acpi_enable_fixed_events(sc);
 }

Modified: head/sys/i386/include/clock.h
==
--- head/sys/i386/include/clock.h   Fri May 25 07:29:52 2018
(r334203)
+++ head/sys/i386/include/clock.h   Fri May 25 07:33:20 2018
(r334204)
@@ -32,6 +32,7 @@ void  clock_init(void);
 void   startrtclock(void);
 void   timer_restore(void);
 void   init_TSC(void);
+void   resume_TSC(void);
 
 #defineHAS_TIMER_SPKR 1
 inttimer_spkr_acquire(void);

Modified: head/sys/x86/x86/tsc.c
==
--- head/sys/x86/x86/tsc.c  Fri May 25 07:29:52 2018(r334203)
+++ head/sys/x86/x86/tsc.c  Fri May 25 07:33:20 2018(r334204)
@@ -451,7 +451,7 @@ adj_smp_tsc(void *arg)
 }
 
 static int
-test_tsc(void)
+test_tsc(int adj_max_count)
 {
uint64_t *data, *tsc;
u_int i, size, adj;
@@ -467,7 +467,7 @@ retry:
smp_tsc = 1;/* XXX */
smp_rendezvous(smp_no_rendezvous_barrier, comp_smp_tsc,
smp_no_rendezvous_barrier, data);
-   if (!smp_tsc && adj < smp_tsc_adjust) {
+   if (!smp_tsc && adj < adj_max_count) {
adj++;
smp_rendezvous(smp_no_rendezvous_barrier, adj_smp_tsc,
smp_no_rendezvous_barrier, data);
@@ -512,7 +512,7 @@ retry:
  * on uniprocessor kernel.
  */
 static int
-test_tsc(void)
+test_tsc(int adj_max_count __unused)
 {
 
return (0);
@@ -579,7 +579,7 @@ init_TSC_tc(void)
 * environments, so it is set to a negative quality in those cases.
 */
if (mp_ncpus > 1)
-   tsc_timecounter.tc_quality = test_tsc();
+   tsc_timecounter.tc_quality = test_tsc(smp_tsc_adjust);
else if (tsc_is_invariant)
tsc_timecounter.tc_quality = 1000;
max_freq >>= tsc_shift;
@@ -614,6 +614,30 @@ init:
}
 }
 SYSINIT(tsc_tc, SI_SUB_SMP, SI_ORDER_ANY, init_TSC_tc, NULL);
+
+void
+resume_TSC(void)
+{
+   int quality;
+
+   /* If TSC was not good on boot, it is unlikely to become good now. */
+   if (tsc_timecounter.tc_quality < 0)
+   return;
+   /* Nothing to do with UP. */
+   if (mp_ncpus < 2)
+   return;
+
+   /*
+* If TSC was good, a single synchronization should be enough,
+* but honour smp_tsc_adjust if it's set.
+*/
+   quality = test_tsc(MAX(smp_tsc_adjust, 1));
+   if (quality != tsc_timecounter.tc_quality) {
+   printf("TSC timecounter quality changed: %d -> %d\n",
+   tsc_timecounter.tc_quality, quality);
+   tsc_timecounter.tc_quality = quality;
+   }
+}
 
 /*
  * When cpufreq

svn commit: r334203 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2018-05-25 Thread Andriy Gapon
Author: avg
Date: Fri May 25 07:29:52 2018
New Revision: 334203
URL: https://svnweb.freebsd.org/changeset/base/334203

Log:
  fix zfs_getpages crash when called from sendfile, followup to r329363
  
  It turns out that sendfile_swapin() has an optimization where it may
  insert pointers to bogus_page into the page array that it passes to
  VOP_GETPAGES.  That happens to work with buffer cache, because it
  extensively uses bogus_page internally, so it has the necessary checks.
  However, ZFS did not expect bogus_page as VOP_GETPAGES(9) does not
  document such a (ab)use of bogus_page.
  
  So, this commit adds checks and handling of bogus_page.
  
  I expect that use of bogus_page with VOP_GETPAGES will get documented
  sooner rather than later.
  
  Reported by:  Andrew Reilly , delphij
  Tested by:Andrew Reilly 
  Requested by: many
  MFC after:1 week

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c   Fri May 25 
06:26:07 2018(r334202)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c   Fri May 25 
07:29:52 2018(r334203)
@@ -1732,17 +1732,21 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_
for (mi = 0, di = 0; mi < count && di < numbufs; ) {
if (pgoff == 0) {
m = ma[mi];
-   vm_page_assert_xbusied(m);
-   ASSERT(m->valid == 0);
-   ASSERT(m->dirty == 0);
-   ASSERT(!pmap_page_is_mapped(m));
-   va = zfs_map_page(m, &sf);
+   if (m != bogus_page) {
+   vm_page_assert_xbusied(m);
+   ASSERT(m->valid == 0);
+   ASSERT(m->dirty == 0);
+   ASSERT(!pmap_page_is_mapped(m));
+   va = zfs_map_page(m, &sf);
+   }
}
if (bufoff == 0)
db = dbp[di];
 
-   ASSERT3U(IDX_TO_OFF(m->pindex) + pgoff, ==,
-   db->db_offset + bufoff);
+   if (m != bogus_page) {
+   ASSERT3U(IDX_TO_OFF(m->pindex) + pgoff, ==,
+   db->db_offset + bufoff);
+   }
 
/*
 * We do not need to clamp the copy size by the file
@@ -1750,13 +1754,16 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_
 * end of file anyway.
 */
tocpy = MIN(db->db_size - bufoff, PAGESIZE - pgoff);
-   bcopy((char *)db->db_data + bufoff, va + pgoff, tocpy);
+   if (m != bogus_page)
+   bcopy((char *)db->db_data + bufoff, va + pgoff, tocpy);
 
pgoff += tocpy;
ASSERT(pgoff <= PAGESIZE);
if (pgoff == PAGESIZE) {
-   zfs_unmap_page(sf);
-   m->valid = VM_PAGE_BITS_ALL;
+   if (m != bogus_page) {
+   zfs_unmap_page(sf);
+   m->valid = VM_PAGE_BITS_ALL;
+   }
ASSERT(mi < count);
mi++;
pgoff = 0;
@@ -1801,6 +1808,7 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_
}
 #endif
if (pgoff != 0) {
+   ASSERT(m != bogus_page);
bzero(va + pgoff, PAGESIZE - pgoff);
zfs_unmap_page(sf);
m->valid = VM_PAGE_BITS_ALL;
___
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: r334197 - head/sys/kern

2018-05-24 Thread Andriy Gapon
On 25/05/2018 04:15, Mateusz Guzik wrote:
> Author: mjg
> Date: Thu May 25 23:58:57 2018
> New Revision: 334197
> URL: https://svnweb.freebsd.org/changeset/base/334197
> 
> Log:
>   Implement Mostly Exclusive locks.
> 
>   High lock contention is one of the biggest scalability bottlenecks on
>   multicore systems. Although the real fix consists of making lock
>   consumers better suited for multicore operation, locking primitive
>   performance is still a crucial factor in real-world systems.
> 
>   It turns out that a lot of the locking is overzealous - the lock is
>   held longer than it needs to be and sometimes even completely
>   unnecessarily in the first place. Even when lock is needed in
>   principle, all relevant consumers may be only *reading* the state
>   protected by the lock or modifying disjoint parts of protected data.
> 
>   As such, a lot of the locking can be elided.
> 
>   The idea boils down to trying to take the lock for a limited amount of
>   time and in case of failure pretending we got it anyway. The approach
>   along with practical analysis of performance win/new crash ratio is
>   described in "Towards reliability-oblivious low latency locking" by
>   Leland Oller.

Great change!  Looking forward to new crashes!
:-)

> Modified:
>   head/sys/kern/kern_mutex.c
> 
> Modified: head/sys/kern/kern_mutex.c
> ===
> --- sys/kern/kern_mutex.c (revision 334196)
> +++ sys/kern/kern_mutex.c (working copy)
> @@ -557,6 +557,9 @@ __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t
>   lda.spin_cnt++;
>  #endif
>  #ifdef ADAPTIVE_MUTEXES
> + if (lda.spin_cnt > 16384)
> + break;
> +
>   /*
>* If the owner is running on another CPU, spin until the
>* owner stops running or the state of the lock changes.
> @@ -1020,16 +1023,22 @@ __mtx_unlock_sleep(volatile uintptr_t *c, uintptr_
>   turnstile_chain_lock(&m->lock_object);
>   _mtx_release_lock_quick(m);
>   ts = turnstile_lookup(&m->lock_object);
> - MPASS(ts != NULL);
> - if (LOCK_LOG_TEST(&m->lock_object, opts))
> - CTR1(KTR_LOCK, "_mtx_unlock_sleep: %p contested", m);
> - turnstile_broadcast(ts, TS_EXCLUSIVE_QUEUE);
> -
>   /*
> -  * This turnstile is now no longer associated with the mutex.  We can
> -  * unlock the chain lock so a new turnstile may take it's place.
> +  * We failed to previously grab the lock. Unlock fast path brings
> +  * us here thinking there are blocked threads, but there may be
> +  * none
>*/
> - turnstile_unpend(ts, TS_EXCLUSIVE_LOCK);
> + if (ts != NULL) {
> + if (LOCK_LOG_TEST(&m->lock_object, opts))
> + CTR1(KTR_LOCK, "_mtx_unlock_sleep: %p contested", m);
> + turnstile_broadcast(ts, TS_EXCLUSIVE_QUEUE);
> +
> + /*
> +  * This turnstile is now no longer associated with the mutex.  
> We can
> +  * unlock the chain lock so a new turnstile may take it's place.
> +  */
> + turnstile_unpend(ts, TS_EXCLUSIVE_LOCK);
> + }
>   turnstile_chain_unlock(&m->lock_object);
>  }
> 

P.S.
I had to re-read the commit message twice, the actual change three times and to
check the calendar five times.

-- 
Andriy Gapon
___
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: r334000 - head/sys/dev/usb/serial

2018-05-21 Thread Andriy Gapon
Author: avg
Date: Mon May 21 21:00:13 2018
New Revision: 334000
URL: https://svnweb.freebsd.org/changeset/base/334000

Log:
  uchcom: reject parity and double stop bits as unsupported
  
  Reviewed by:  hselasky
  MFC after:2 weeks

Modified:
  head/sys/dev/usb/serial/uchcom.c

Modified: head/sys/dev/usb/serial/uchcom.c
==
--- head/sys/dev/usb/serial/uchcom.cMon May 21 20:59:15 2018
(r333999)
+++ head/sys/dev/usb/serial/uchcom.cMon May 21 21:00:13 2018
(r334000)
@@ -689,6 +689,10 @@ uchcom_pre_param(struct ucom_softc *ucom, struct termi
default:
return (EIO);
}
+   if ((t->c_cflag & CSTOPB) != 0)
+   return (EIO);
+   if ((t->c_cflag & PARENB) != 0)
+   return (EIO);
 
if (uchcom_calc_divider_settings(&dv, t->c_ospeed)) {
return (EIO);
___
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: r334002 - head/sys/dev/usb/serial

2018-05-21 Thread Andriy Gapon
Author: avg
Date: Mon May 21 21:04:31 2018
New Revision: 334002
URL: https://svnweb.freebsd.org/changeset/base/334002

Log:
  uchcom: extend hardware support to version 0x30
  
  This change adds support for a UBS<->RS232 adapter based on CH340 (or an
  analogue) that I own.  The device seems to have a newer internal version
  (0x30) and the existing code incorrectly configures line control for it
  resulting in garbled transmission.  The changes are based on what I
  learned in Linux drivers for the same hardware.
  
  Additional changes:
  - use UCHCOM_REG_LCR1 / UCHCOM_REG_LCR2 instead of explicit 0x18 and
0x25
  - use NULL instead of 0 where a pointer is expected
  
  Reviewed by:  hselasky
  MFC after:3 weeks
  Differential Revision: https://reviews.freebsd.org/D15498

Modified:
  head/sys/dev/usb/serial/uchcom.c

Modified: head/sys/dev/usb/serial/uchcom.c
==
--- head/sys/dev/usb/serial/uchcom.cMon May 21 21:02:10 2018
(r334001)
+++ head/sys/dev/usb/serial/uchcom.cMon May 21 21:04:31 2018
(r334002)
@@ -126,6 +126,7 @@ SYSCTL_INT(_hw_usb_uchcom, OID_AUTO, debug, CTLFLAG_RW
 #defineUCHCOM_REG_LCR2 0x25
 
 #defineUCHCOM_VER_20   0x20
+#defineUCHCOM_VER_30   0x30
 
 #defineUCHCOM_BASE_UNKNOWN 0
 #defineUCHCOM_BPS_MOD_BASE 2000
@@ -706,11 +707,26 @@ uchcom_cfg_param(struct ucom_softc *ucom, struct termi
 {
struct uchcom_softc *sc = ucom->sc_parent;
 
-   uchcom_get_version(sc, 0);
+   uchcom_get_version(sc, NULL);
uchcom_ctrl_write(sc, UCHCOM_REQ_RESET, 0, 0);
uchcom_set_baudrate(sc, t->c_ospeed);
-   uchcom_read_reg(sc, 0x18, 0, 0x25, 0);
-   uchcom_write_reg(sc, 0x18, 0x50, 0x25, 0x00);
+   if (sc->sc_version < UCHCOM_VER_30) {
+   uchcom_read_reg(sc, UCHCOM_REG_LCR1, NULL,
+   UCHCOM_REG_LCR2, NULL);
+   uchcom_write_reg(sc, UCHCOM_REG_LCR1, 0x50,
+   UCHCOM_REG_LCR2, 0x00);
+   } else {
+   /*
+* Set up line control:
+* - enable transmit and receive
+* - set 8n1 mode
+* To do: support other sizes, parity, stop bits.
+*/
+   uchcom_write_reg(sc,
+   UCHCOM_REG_LCR1,
+   UCHCOM_LCR1_RX | UCHCOM_LCR1_TX | UCHCOM_LCR1_CS8,
+   UCHCOM_REG_LCR2, 0x00);
+   }
uchcom_update_status(sc);
uchcom_ctrl_write(sc, UCHCOM_REQ_RESET, 0x501f, 0xd90a);
uchcom_set_baudrate(sc, t->c_ospeed);
___
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: r334001 - head/sys/dev/usb/serial

2018-05-21 Thread Andriy Gapon
Author: avg
Date: Mon May 21 21:02:10 2018
New Revision: 334001
URL: https://svnweb.freebsd.org/changeset/base/334001

Log:
  uchcom: remove UCHCOM_REG_BREAK2 alias of UCHCOM_REG_LCR1
  
  Also, add definitions for more bits of UCHCOM_REG_LCR1 as seen in the
  Linux driver.  UCHCOM_LCR1_PARENB definition was different from that in
  the Linux driver and clashed with newly added UCHCOM_LCR1_RX.  I took a
  liberty to change UCHCOM_LCR1_PARENB to the Linux definition as it was
  unused in the driver anyway.  This change should make
  uchcom_cfg_set_break() easier to understand.
  
  Approved by:  hselasky
  MFC after:2 weeks

Modified:
  head/sys/dev/usb/serial/uchcom.c

Modified: head/sys/dev/usb/serial/uchcom.c
==
--- head/sys/dev/usb/serial/uchcom.cMon May 21 21:00:13 2018
(r334000)
+++ head/sys/dev/usb/serial/uchcom.cMon May 21 21:02:10 2018
(r334001)
@@ -122,7 +122,6 @@ SYSCTL_INT(_hw_usb_uchcom, OID_AUTO, debug, CTLFLAG_RW
 #defineUCHCOM_REG_BPS_MOD  0x14
 #defineUCHCOM_REG_BPS_PAD  0x0F
 #defineUCHCOM_REG_BREAK1   0x05
-#defineUCHCOM_REG_BREAK2   0x18
 #defineUCHCOM_REG_LCR1 0x18
 #defineUCHCOM_REG_LCR2 0x25
 
@@ -135,12 +134,14 @@ SYSCTL_INT(_hw_usb_uchcom, OID_AUTO, debug, CTLFLAG_RW
 #defineUCHCOM_DTR_MASK 0x20
 #defineUCHCOM_RTS_MASK 0x40
 
-#defineUCHCOM_BRK1_MASK0x01
-#defineUCHCOM_BRK2_MASK0x40
+#defineUCHCOM_BRK_MASK 0x01
 
 #defineUCHCOM_LCR1_MASK0xAF
 #defineUCHCOM_LCR2_MASK0x07
-#defineUCHCOM_LCR1_PARENB  0x80
+#defineUCHCOM_LCR1_RX  0x80
+#defineUCHCOM_LCR1_TX  0x40
+#defineUCHCOM_LCR1_PARENB  0x08
+#defineUCHCOM_LCR1_CS8 0x03
 #defineUCHCOM_LCR2_PAREVEN 0x07
 #defineUCHCOM_LCR2_PARODD  0x06
 #defineUCHCOM_LCR2_PARMARK 0x05
@@ -556,17 +557,17 @@ uchcom_cfg_set_break(struct ucom_softc *ucom, uint8_t 
uint8_t brk1;
uint8_t brk2;
 
-   uchcom_read_reg(sc, UCHCOM_REG_BREAK1, &brk1, UCHCOM_REG_BREAK2, &brk2);
+   uchcom_read_reg(sc, UCHCOM_REG_BREAK1, &brk1, UCHCOM_REG_LCR1, &brk2);
if (onoff) {
/* on - clear bits */
-   brk1 &= ~UCHCOM_BRK1_MASK;
-   brk2 &= ~UCHCOM_BRK2_MASK;
+   brk1 &= ~UCHCOM_BRK_MASK;
+   brk2 &= ~UCHCOM_LCR1_TX;
} else {
/* off - set bits */
-   brk1 |= UCHCOM_BRK1_MASK;
-   brk2 |= UCHCOM_BRK2_MASK;
+   brk1 |= UCHCOM_BRK_MASK;
+   brk2 |= UCHCOM_LCR1_TX;
}
-   uchcom_write_reg(sc, UCHCOM_REG_BREAK1, brk1, UCHCOM_REG_BREAK2, brk2);
+   uchcom_write_reg(sc, UCHCOM_REG_BREAK1, brk1, UCHCOM_REG_LCR1, brk2);
 }
 
 static int
___
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: r333997 - head/sys/dev/usb/serial

2018-05-21 Thread Andriy Gapon
Author: avg
Date: Mon May 21 20:57:14 2018
New Revision: 333997
URL: https://svnweb.freebsd.org/changeset/base/333997

Log:
  uchcom: report detected product based on USB product ID
  
  Product IDs are specified in vendor documents.  The previously used
  device ID is not.  This is a cosmetic change.  No functionality depends
  on those IDs.
  
  Reviewed by:  hselasky
  MFC after:2 weeks

Modified:
  head/sys/dev/usb/serial/uchcom.c

Modified: head/sys/dev/usb/serial/uchcom.c
==
--- head/sys/dev/usb/serial/uchcom.cMon May 21 20:54:54 2018
(r333996)
+++ head/sys/dev/usb/serial/uchcom.cMon May 21 20:57:14 2018
(r333997)
@@ -322,12 +322,16 @@ uchcom_attach(device_t dev)
 
sc->sc_udev = uaa->device;
 
-   switch (uaa->info.bcdDevice) {
-   case UCHCOM_REV_CH340:
+   switch (uaa->info.idProduct) {
+   case USB_PRODUCT_WCH2_CH341SER:
device_printf(dev, "CH340 detected\n");
break;
-   default:
+   case USB_PRODUCT_WCH2_CH341SER_2:
device_printf(dev, "CH341 detected\n");
+   break;
+   default:
+   device_printf(dev, "New CH340/CH341 product 0x%04x detected\n",
+   uaa->info.idProduct);
break;
}
 
___
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: r333999 - head/sys/dev/usb/serial

2018-05-21 Thread Andriy Gapon
Author: avg
Date: Mon May 21 20:59:15 2018
New Revision: 333999
URL: https://svnweb.freebsd.org/changeset/base/333999

Log:
  uchcom: add a hardware configuration tweak seen in Linux code
  
  Reviewed by:  hselasky
  MFC after:2 weeks

Modified:
  head/sys/dev/usb/serial/uchcom.c

Modified: head/sys/dev/usb/serial/uchcom.c
==
--- head/sys/dev/usb/serial/uchcom.cMon May 21 20:58:06 2018
(r333998)
+++ head/sys/dev/usb/serial/uchcom.cMon May 21 20:59:15 2018
(r333999)
@@ -618,8 +618,12 @@ uchcom_set_baudrate(struct uchcom_softc *sc, uint32_t 
if (uchcom_calc_divider_settings(&dv, rate))
return;
 
+   /*
+* According to linux code we need to set bit 7 of UCHCOM_REG_BPS_PRE,
+* otherwise the chip will buffer data.
+*/
uchcom_write_reg(sc,
-   UCHCOM_REG_BPS_PRE, dv.dv_prescaler,
+   UCHCOM_REG_BPS_PRE, dv.dv_prescaler | 0x80,
UCHCOM_REG_BPS_DIV, dv.dv_div);
uchcom_write_reg(sc,
UCHCOM_REG_BPS_MOD, dv.dv_mod,
___
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: r333998 - head/sys/dev/usb/serial

2018-05-21 Thread Andriy Gapon
Author: avg
Date: Mon May 21 20:58:06 2018
New Revision: 333998
URL: https://svnweb.freebsd.org/changeset/base/333998

Log:
  uchcom: add DPRINTF-s to aid debugging of the driver
  
  Reviewed by:  hselasky
  MFC after:2 weeks

Modified:
  head/sys/dev/usb/serial/uchcom.c

Modified: head/sys/dev/usb/serial/uchcom.c
==
--- head/sys/dev/usb/serial/uchcom.cMon May 21 20:57:14 2018
(r333997)
+++ head/sys/dev/usb/serial/uchcom.cMon May 21 20:58:06 2018
(r333998)
@@ -416,6 +416,8 @@ uchcom_ctrl_write(struct uchcom_softc *sc, uint8_t req
USETW(req.wIndex, index);
USETW(req.wLength, 0);
 
+   DPRINTF("WR REQ 0x%02X VAL 0x%04X IDX 0x%04X\n",
+   reqno, value, index);
ucom_cfg_do_request(sc->sc_udev,
&sc->sc_ucom, &req, NULL, 0, 1000);
 }
@@ -432,6 +434,8 @@ uchcom_ctrl_read(struct uchcom_softc *sc, uint8_t reqn
USETW(req.wIndex, index);
USETW(req.wLength, buflen);
 
+   DPRINTF("RD REQ 0x%02X VAL 0x%04X IDX 0x%04X LEN %d\n",
+   reqno, value, index, buflen);
ucom_cfg_do_request(sc->sc_udev,
&sc->sc_ucom, &req, buf, USB_SHORT_XFER_OK, 1000);
 }
@@ -506,6 +510,7 @@ static void
 uchcom_update_version(struct uchcom_softc *sc)
 {
uchcom_get_version(sc, &sc->sc_version);
+   DPRINTF("Chip version: 0x%02x\n", sc->sc_version);
 }
 
 static void
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333994 - in head/sys: dev/acpica kern sys

2018-05-21 Thread Andriy Gapon
Author: avg
Date: Mon May 21 20:23:04 2018
New Revision: 333994
URL: https://svnweb.freebsd.org/changeset/base/333994

Log:
  stop and restart kernel event timers in the suspend / resume cycle
  
  I have a system that is very unstable after resuming from suspend-to-RAM
  but only if HPET is used as the event timer.  The theory is that SMM
  code / firmware could be enabling HPET for its own uses and unexpected
  interrupts cause a trouble for it.  Originally I wanted to solve the
  problem in hpet_suspend() method, but that was insufficient as the event
  timer could get reprogrammed again.
  
  So, it's better, for my case and in general, to stop the event timer(s)
  before entering the hardware suspend.
  
  MFC after:4 weeks
  Differential Revision: https://reviews.freebsd.org/D15413

Modified:
  head/sys/dev/acpica/acpi.c
  head/sys/kern/kern_clocksource.c
  head/sys/sys/systm.h

Modified: head/sys/dev/acpica/acpi.c
==
--- head/sys/dev/acpica/acpi.c  Mon May 21 20:20:28 2018(r333993)
+++ head/sys/dev/acpica/acpi.c  Mon May 21 20:23:04 2018(r333994)
@@ -2958,6 +2958,7 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state)
 if (sc->acpi_sleep_delay > 0)
DELAY(sc->acpi_sleep_delay * 100);
 
+suspendclock();
 intr = intr_disable();
 if (state != ACPI_STATE_S1) {
sleep_result = acpi_sleep_machdep(sc, state);
@@ -3028,6 +3029,8 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state)
  * process.  This handles both the error and success cases.
  */
 backout:
+if (slp_state >= ACPI_SS_SLP_PREP)
+   resumeclock();
 if (slp_state >= ACPI_SS_GPE_SET) {
acpi_wake_prep_walk(state);
sc->acpi_sstate = ACPI_STATE_S0;

Modified: head/sys/kern/kern_clocksource.c
==
--- head/sys/kern/kern_clocksource.cMon May 21 20:20:28 2018
(r333993)
+++ head/sys/kern/kern_clocksource.cMon May 21 20:23:04 2018
(r333994)
@@ -698,6 +698,22 @@ cpu_initclocks_ap(void)
spinlock_exit();
 }
 
+void
+suspendclock(void)
+{
+   ET_LOCK();
+   configtimer(0);
+   ET_UNLOCK();
+}
+
+void
+resumeclock(void)
+{
+   ET_LOCK();
+   configtimer(1);
+   ET_UNLOCK();
+}
+
 /*
  * Switch to profiling clock rates.
  */

Modified: head/sys/sys/systm.h
==
--- head/sys/sys/systm.hMon May 21 20:20:28 2018(r333993)
+++ head/sys/sys/systm.hMon May 21 20:23:04 2018(r333994)
@@ -333,6 +333,8 @@ voidstartprofclock(struct proc *);
 void   stopprofclock(struct proc *);
 void   cpu_startprofclock(void);
 void   cpu_stopprofclock(void);
+void   suspendclock(void);
+void   resumeclock(void);
 sbintime_t cpu_idleclock(void);
 void   cpu_activeclock(void);
 void   cpu_new_callout(int cpu, sbintime_t bt, sbintime_t bt_opt);
___
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: r333707 - head/sys/x86/x86

2018-05-17 Thread Andriy Gapon
Author: avg
Date: Thu May 17 10:16:20 2018
New Revision: 333707
URL: https://svnweb.freebsd.org/changeset/base/333707

Log:
  fix a problem with bad performance after wakeup caused by r21
  
  This change reverts a "while here" part of r21 that moved clearing
  of suspended_cpus to an earlier place.
  
  Apparently, there can be a problem when modifying (shared) memory before
  restoring proper cache attributes.  So, to be safe, move the clearing to
  the old place.
  
  Many thanks to Johannes Lundberg for bisecting the changes to that
  particular commit and then bisecting the commit to the particular
  change.
  
  Reported by:  many
  Debugged by:  Johannes Lundberg 
  MFC after:1 week
  X-MFC with:   r21

Modified:
  head/sys/x86/x86/mp_x86.c

Modified: head/sys/x86/x86/mp_x86.c
==
--- head/sys/x86/x86/mp_x86.c   Thu May 17 10:13:18 2018(r333706)
+++ head/sys/x86/x86/mp_x86.c   Thu May 17 10:16:20 2018(r333707)
@@ -1457,8 +1457,6 @@ cpususpend_handler(void)
 */
wbinvd();
} else {
-   /* Indicate that we have restarted and restored the context. */
-   CPU_CLR_ATOMIC(cpu, &suspended_cpus);
 #ifdef __amd64__
fpuresume(susppcbs[cpu]->sp_fpususpend);
 #else
@@ -1468,6 +1466,9 @@ cpususpend_handler(void)
initializecpu();
PCPU_SET(switchtime, 0);
PCPU_SET(switchticks, ticks);
+
+   /* Indicate that we have restarted and restored the context. */
+   CPU_CLR_ATOMIC(cpu, &suspended_cpus);
}
 
/* Wait for resume directive */
___
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: r333667 - in head/sys: arm/arm arm64/arm64 mips/mips

2018-05-15 Thread Andriy Gapon
Author: avg
Date: Wed May 16 06:52:08 2018
New Revision: 333667
URL: https://svnweb.freebsd.org/changeset/base/333667

Log:
  followup to r332730/r332752: set kdb_why to "trap" for fatal traps
  
  This change updates arm, arm64 and mips achitectures.  Additionally, it
  removes redundant checks for kdb_active where it already results in
  kdb_reenter() and adds kdb_reenter() calls where they were missing.
  
  Some architectures check the return value of kdb_trap(), but some don't.
  I haven't changed any of that.
  
  Some trap handling routines have a return code.  I am not sure if I
  provided correct ones for returns after kdb_reenter().  kdb_reenter
  should never return unless kdb_jmpbufp is NULL for some reason.
  
  Only compile tested for all affected architectures.  There can be bugs
  resulting from my poor understanding of architecture specific details.
  
  Reported by:  jhb
  Reviewed by:  jhb, eadler
  MFC after:4 weeks
  Differential Revision: https://reviews.freebsd.org/D15431

Modified:
  head/sys/arm/arm/trap-v4.c
  head/sys/arm/arm/trap-v6.c
  head/sys/arm64/arm64/trap.c
  head/sys/mips/mips/trap.c

Modified: head/sys/arm/arm/trap-v4.c
==
--- head/sys/arm/arm/trap-v4.c  Wed May 16 03:17:37 2018(r333666)
+++ head/sys/arm/arm/trap-v4.c  Wed May 16 06:52:08 2018(r333667)
@@ -404,7 +404,16 @@ dab_fatal(struct trapframe *tf, u_int fsr, u_int far, 
 struct ksig *ksig)
 {
const char *mode;
+#ifdef KDB
+   bool handled;
+#endif
 
+#ifdef KDB
+   if (kdb_active) {
+   kdb_reenter();
+   return (0);
+   }
+#endif
 #ifdef KDTRACE_HOOKS
if (!TRAP_USERMODE(tf)) {
if (dtrace_trap_func != NULL && (*dtrace_trap_func)(tf, far & 
FAULT_TYPE_MASK))
@@ -447,9 +456,13 @@ dab_fatal(struct trapframe *tf, u_int fsr, u_int far, 
printf(", pc =%08x\n\n", tf->tf_pc);
 
 #ifdef KDB
-   if (debugger_on_panic || kdb_active)
-   if (kdb_trap(fsr, 0, tf))
+   if (debugger_on_panic) {
+   kdb_why = KDB_WHY_TRAP;
+   handled = kdb_trap(fsr, 0, tf);
+   kdb_why = KDB_WHY_UNSET;
+   if (handled)
return (0);
+   }
 #endif
panic("Fatal abort");
/*NOTREACHED*/

Modified: head/sys/arm/arm/trap-v6.c
==
--- head/sys/arm/arm/trap-v6.c  Wed May 16 03:17:37 2018(r333666)
+++ head/sys/arm/arm/trap-v6.c  Wed May 16 06:52:08 2018(r333667)
@@ -599,8 +599,11 @@ abort_fatal(struct trapframe *tf, u_int idx, u_int fsr
printf(", pc =%08x\n\n", tf->tf_pc);
 
 #ifdef KDB
-   if (debugger_on_panic || kdb_active)
+   if (debugger_on_panic) {
+   kdb_why = KDB_WHY_TRAP;
kdb_trap(fsr, 0, tf);
+   kdb_why = KDB_WHY_UNSET;
+   }
 #endif
panic("Fatal abort");
/*NOTREACHED*/

Modified: head/sys/arm64/arm64/trap.c
==
--- head/sys/arm64/arm64/trap.c Wed May 16 03:17:37 2018(r333666)
+++ head/sys/arm64/arm64/trap.c Wed May 16 06:52:08 2018(r333667)
@@ -156,6 +156,9 @@ data_abort(struct thread *td, struct trapframe *frame,
vm_prot_t ftype;
vm_offset_t va;
int error, sig, ucode;
+#ifdef KDB
+   bool handled;
+#endif
 
/*
 * According to the ARMv8-A rev. A.g, B2.10.5 "Load-Exclusive
@@ -226,9 +229,14 @@ data_abort(struct thread *td, struct trapframe *frame,
printf(" esr: %.8lx\n", esr);
 
 #ifdef KDB
-   if (debugger_on_panic || kdb_active)
-   if (kdb_trap(ESR_ELx_EXCEPTION(esr), 0, frame))
+   if (debugger_on_panic) {
+   kdb_why = KDB_WHY_TRAP;
+   handled = kdb_trap(ESR_ELx_EXCEPTION(esr), 0,
+   frame);
+   kdb_why = KDB_WHY_UNSET;
+   if (handled)
return;
+   }
 #endif
panic("vm_fault failed: %lx", frame->tf_elr);
}

Modified: head/sys/mips/mips/trap.c
==
--- head/sys/mips/mips/trap.c   Wed May 16 03:17:37 2018(r333666)
+++ head/sys/mips/mips/trap.c   Wed May 16 06:52:08 2018(r333667)
@@ -530,7 +530,12 @@ trap(struct trapframe *trapframe)
register_t *frame_regs;
 
trapdebug_enter(trapframe, 0);
-   
+#ifdef KDB
+   if (kdb_active) {
+   kdb_reenter();
+   return (0);
+   }
+#endif
type = (trapframe->cause & MIPS_CR_EXC_CODE) >> MIPS_CR_EXC_CODE_SHIFT;
if (TRAPF_USERMODE(tra

svn commit: r333638 - head/sys/x86/x86

2018-05-15 Thread Andriy Gapon
Author: avg
Date: Tue May 15 16:56:30 2018
New Revision: 333638
URL: https://svnweb.freebsd.org/changeset/base/333638

Log:
  calibrate lapic timer in native_lapic_setup
  
  The idea is to calibrate the LAPIC timer just once and only on boot,
  given that [at present] the timer constants are global and shared
  between all processors.
  
  My primary motivation is to fix a panic that can happen when dynamically
  switching to lapic timer.  The panic is caused by a recursion on
  et_hw_mtx when printing the calibration results to console.  See the
  review for the details of the panic.
  
  Also, the code should become slightly simpler and easier to read.  The
  previous code was racy too.  Multiple processors could start calibrating
  the global constants concurrently, although that seems to have been
  benign.
  
  Reviewed by:  kib, mav, jhb
  MFC after:3 weeks
  Differential Revision: https://reviews.freebsd.org/D15422

Modified:
  head/sys/x86/x86/local_apic.c

Modified: head/sys/x86/x86/local_apic.c
==
--- head/sys/x86/x86/local_apic.c   Tue May 15 16:54:41 2018
(r333637)
+++ head/sys/x86/x86/local_apic.c   Tue May 15 16:56:30 2018
(r333638)
@@ -206,6 +206,9 @@ SYSCTL_INT(_hw_apic, OID_AUTO, eoi_suppression, CTLFLA
 SYSCTL_INT(_hw_apic, OID_AUTO, timer_tsc_deadline, CTLFLAG_RD,
 &lapic_timer_tsc_deadline, 0, "");
 
+static void lapic_calibrate_initcount(struct lapic *la);
+static void lapic_calibrate_deadline(struct lapic *la);
+
 static uint32_t
 lapic_read32(enum LAPIC_REGISTERS reg)
 {
@@ -787,6 +790,13 @@ native_lapic_setup(int boot)
intrcnt_add(buf, &la->la_timer_count);
}
 
+   /* Calibrate the timer parameters using BSP. */
+   if (boot && IS_BSP()) {
+   lapic_calibrate_initcount(la);
+   if (lapic_timer_tsc_deadline)
+   lapic_calibrate_deadline(la);
+   }
+
/* Setup the timer if configured. */
if (la->la_timer_mode != LAT_MODE_UNDEF) {
KASSERT(la->la_timer_period != 0, ("lapic%u: zero divisor",
@@ -921,7 +931,7 @@ native_lapic_disable_pmc(void)
 }
 
 static void
-lapic_calibrate_initcount(struct eventtimer *et, struct lapic *la)
+lapic_calibrate_initcount(struct lapic *la)
 {
u_long value;
 
@@ -947,7 +957,7 @@ lapic_calibrate_initcount(struct eventtimer *et, struc
 }
 
 static void
-lapic_calibrate_deadline(struct eventtimer *et, struct lapic *la __unused)
+lapic_calibrate_deadline(struct lapic *la __unused)
 {
 
if (bootverbose) {
@@ -989,11 +999,6 @@ lapic_et_start(struct eventtimer *et, sbintime_t first
struct lapic *la;
 
la = &lapics[PCPU_GET(apic_id)];
-   if (et->et_frequency == 0) {
-   lapic_calibrate_initcount(et, la);
-   if (lapic_timer_tsc_deadline)
-   lapic_calibrate_deadline(et, la);
-   }
if (period != 0) {
lapic_change_mode(et, la, LAT_MODE_PERIODIC);
la->la_timer_period = ((uint32_t)et->et_frequency * period) >>
___
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: r333630 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2018-05-15 Thread Andriy Gapon
Author: avg
Date: Tue May 15 13:27:29 2018
New Revision: 333630
URL: https://svnweb.freebsd.org/changeset/base/333630

Log:
  Fix 'zpool create -t '
  
  Creating a pool with a temporary name fails when we also specify custom
  dataset properties: this is because we mistakenly call
  zfs_set_prop_nvlist() on the "real" pool name which, as expected,
  cannot be found because the SPA is present in the namespace with the
  temporary name.
  
  Fix this by specifying the correct pool name when setting the dataset
  properties.
  
  Author: loli10K 
  Reviewed-by: Prakash Surya 
  Reviewed-by: Brian Behlendorf 
  
  Obtained from:ZFS on Linux, zfsonlinux/zfs@4ceb8dd6fdfdde
  MFC after:1 week

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Tue May 
15 13:19:00 2018(r333629)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Tue May 
15 13:27:29 2018(r333630)
@@ -1556,6 +1556,7 @@ zfs_ioc_pool_create(zfs_cmd_t *zc)
nvlist_t *config, *props = NULL;
nvlist_t *rootprops = NULL;
nvlist_t *zplprops = NULL;
+   char *spa_name = zc->zc_name;
 
if (error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size,
zc->zc_iflags, &config))
@@ -1571,6 +1572,7 @@ zfs_ioc_pool_create(zfs_cmd_t *zc)
if (props) {
nvlist_t *nvl = NULL;
uint64_t version = SPA_VERSION;
+   char *tname;
 
(void) nvlist_lookup_uint64(props,
zpool_prop_to_name(ZPOOL_PROP_VERSION), &version);
@@ -1593,6 +1595,10 @@ zfs_ioc_pool_create(zfs_cmd_t *zc)
zplprops, NULL);
if (error != 0)
goto pool_props_bad;
+
+   if (nvlist_lookup_string(props,
+   zpool_prop_to_name(ZPOOL_PROP_TNAME), &tname) == 0)
+   spa_name = tname;
}
 
error = spa_create(zc->zc_name, config, props, zplprops);
@@ -1600,9 +1606,9 @@ zfs_ioc_pool_create(zfs_cmd_t *zc)
/*
 * Set the remaining root properties
 */
-   if (!error && (error = zfs_set_prop_nvlist(zc->zc_name,
+   if (!error && (error = zfs_set_prop_nvlist(spa_name,
ZPROP_SRC_LOCAL, rootprops, NULL)) != 0)
-   (void) spa_destroy(zc->zc_name);
+   (void) spa_destroy(spa_name);
 
 pool_props_bad:
nvlist_free(rootprops);
___
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: r332730 - in head/sys: amd64/amd64 i386/i386 powerpc/powerpc

2018-05-14 Thread Andriy Gapon
On 05/05/2018 01:55, John Baldwin wrote:
> On Wednesday, April 18, 2018 03:44:54 PM Andriy Gapon wrote:
>> Author: avg
>> Date: Wed Apr 18 15:44:54 2018
>> New Revision: 332730
>> URL: https://svnweb.freebsd.org/changeset/base/332730
>>
>> Log:
>>   don't check for kdb reentry in trap_fatal(), it's impossible
>>   
>>   trap() checks for it earlier and calls kdb_reentry().
> 
> I just noticed today that there are several other kdb_trap() checks in
> other architectures that need this fix and the KDB_WHY_TRAP change.  Just
> grep for debugger_on_panic under sys.  For example:
> 
> arm/arm/trap-v4.c:  if (debugger_on_panic || kdb_active)
> arm/arm/trap-v6.c:  if (debugger_on_panic || kdb_active)
> arm64/arm64/trap.c: if (debugger_on_panic || kdb_active)
> mips/mips/trap.c:   if (debugger_on_panic || kdb_active) {

This list seems to be exhaustive.
Please see https://reviews.freebsd.org/D15431
Thanks!

-- 
Andriy Gapon
___
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: r333321 - head/sys/x86/x86

2018-05-07 Thread Andriy Gapon
Author: avg
Date: Mon May  7 12:22:25 2018
New Revision: 21
URL: https://svnweb.freebsd.org/changeset/base/21

Log:
  x86 cpususpend_handler: call wbinvd after setting suspend state bits
  
  Without a subsequent wbinvd the changes to suspended_cpus (and
  resuming_cpus) can be lost at least on AMD systems that use MOESI cache
  coherency protocol.  That can happen because one of APs ends up as an
  Owner of the corresponding cache line(s) and the changes may never reach
  the main memory before the AP is reset.
  
  While here, move clearing of suspended_cpus a little bit earlier as the
  fact of returning from savectx (with zero return value) means that the
  CPU has fully restored it execution context.
  
  Also, rework the comment that describes the need for resuming_cpus.
  
  This change fixed suspend to RAM a previously broken AMD-based system.
  
  Reviewed by:  kib
  Discussed with:   bde
  MFC after:3 weeks
  Differential Revision: https://reviews.freebsd.org/D15295

Modified:
  head/sys/x86/x86/mp_x86.c

Modified: head/sys/x86/x86/mp_x86.c
==
--- head/sys/x86/x86/mp_x86.c   Mon May  7 09:42:35 2018(r20)
+++ head/sys/x86/x86/mp_x86.c   Mon May  7 12:22:25 2018(r21)
@@ -1425,16 +1425,36 @@ cpususpend_handler(void)
 #else
npxsuspend(susppcbs[cpu]->sp_fpususpend);
 #endif
-   wbinvd();
-   CPU_SET_ATOMIC(cpu, &suspended_cpus);
/*
-* Hack for xen, which does not use resumectx() so never
-* uses the next clause: set resuming_cpus early so that
-* resume_cpus() can wait on the same bitmap for acpi and
-* xen.  resuming_cpus now means eventually_resumable_cpus.
+* suspended_cpus is cleared shortly after each AP is restarted
+* by a Startup IPI, so that the BSP can proceed to restarting
+* the next AP.
+*
+* resuming_cpus gets cleared when the AP completes
+* initialization after having been released by the BSP.
+* resuming_cpus is probably not the best name for the
+* variable, because it is actually a set of processors that
+* haven't resumed yet and haven't necessarily started resuming.
+*
+* Note that suspended_cpus is meaningful only for ACPI suspend
+* as it's not really used for Xen suspend since the APs are
+* automatically restored to the running state and the correct
+* context.  For the same reason resumectx is never called in
+* that case.
 */
+   CPU_SET_ATOMIC(cpu, &suspended_cpus);
CPU_SET_ATOMIC(cpu, &resuming_cpus);
+
+   /*
+* Invalidate the cache after setting the global status bits.
+* The last AP to set its bit may end up being an Owner of the
+* corresponding cache line in MOESI protocol.  The AP may be
+* stopped before the cache line is written to the main memory.
+*/
+   wbinvd();
} else {
+   /* Indicate that we have restarted and restored the context. */
+   CPU_CLR_ATOMIC(cpu, &suspended_cpus);
 #ifdef __amd64__
fpuresume(susppcbs[cpu]->sp_fpususpend);
 #else
@@ -1444,9 +1464,6 @@ cpususpend_handler(void)
initializecpu();
PCPU_SET(switchtime, 0);
PCPU_SET(switchticks, ticks);
-
-   /* Indicate that we are resuming */
-   CPU_CLR_ATOMIC(cpu, &suspended_cpus);
}
 
/* Wait for resume directive */
___
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: r333269 - head/sys/dev/amdsbwd

2018-05-04 Thread Andriy Gapon
Author: avg
Date: Sat May  5 05:22:11 2018
New Revision: 333269
URL: https://svnweb.freebsd.org/changeset/base/333269

Log:
  amdsbwd: fix reboot status reporting
  
  Originally, I overlooked that PMIO register 0xc0 has a dual personality.
  It can either be S5/Reset Status register or Misc. Fix register (aka
  debug status register).  The mode is controlled by bit 2 in PMIO
  register 0xc4.  Apparently there are register programming requirements
  for the second personality, so many BIOSes leave the register, after
  programming it, in that mode.  So, we need to switch the register to the
  correct mode.
  
  Additionally, AMDSB8_WD_RST_STS was defined incorrectly as bit 13 while
  it is actually bit 25 (and the register's width is 32 bits, not 16).
  
  With this change I see the following in dmesg after a reset by the
  watchdog:
  amdsbwd0: ResetStatus = 0x4200
  amdsbwd0: Previous Reset was caused by Watchdog
  
  MFC after:2 weeks

Modified:
  head/sys/dev/amdsbwd/amd_chipset.h
  head/sys/dev/amdsbwd/amdsbwd.c

Modified: head/sys/dev/amdsbwd/amd_chipset.h
==
--- head/sys/dev/amdsbwd/amd_chipset.h  Sat May  5 05:19:32 2018
(r333268)
+++ head/sys/dev/amdsbwd/amd_chipset.h  Sat May  5 05:22:11 2018
(r333269)
@@ -95,9 +95,10 @@
 #defineAMDSB8_WDT_32KHZ0x00
 #defineAMDSB8_WDT_1HZ  0x03
 #defineAMDSB8_WDT_RES_MASK 0x03
-#defineAMDSB8_PM_RESET_STATUS0 0xc0
-#defineAMDSB8_PM_RESET_STATUS1 0xc1
-#defineAMDSB8_WD_RST_STS   0x20
+#defineAMDSB8_PM_RESET_STATUS  0xc0/* 32 bit wide */
+#defineAMDSB8_WD_RST_STS   0x200
+#defineAMDSB8_PM_RESET_CTRL0xc4
+#defineAMDSB8_RST_STS_DIS  0x04
 
 /*
  * Newer FCH registers in the PMIO space.

Modified: head/sys/dev/amdsbwd/amdsbwd.c
==
--- head/sys/dev/amdsbwd/amdsbwd.c  Sat May  5 05:19:32 2018
(r333268)
+++ head/sys/dev/amdsbwd/amdsbwd.c  Sat May  5 05:22:11 2018
(r333269)
@@ -321,16 +321,23 @@ amdsbwd_probe_sb7xx(device_t dev, struct resource *pmr
 static void
 amdsbwd_probe_sb8xx(device_t dev, struct resource *pmres, uint32_t *addr)
 {
-   uint8_t val;
-   int i;
+   uint32_tval;
+   int i;
 
/* Report cause of previous reset for user's convenience. */
-   val = pmio_read(pmres, AMDSB8_PM_RESET_STATUS0);
+
+   val = pmio_read(pmres, AMDSB8_PM_RESET_CTRL);
+   if ((val & AMDSB8_RST_STS_DIS) != 0) {
+   val &= ~AMDSB8_RST_STS_DIS;
+   pmio_write(pmres, AMDSB8_PM_RESET_CTRL, val);
+   }
+   val = 0;
+   for (i = 3; i >= 0; i--) {
+   val <<= 8;
+   val |= pmio_read(pmres, AMDSB8_PM_RESET_STATUS + i);
+   }
if (val != 0)
-   amdsbwd_verbose_printf(dev, "ResetStatus0 = %#04x\n", val);
-   val = pmio_read(pmres, AMDSB8_PM_RESET_STATUS1);
-   if (val != 0)
-   amdsbwd_verbose_printf(dev, "ResetStatus1 = %#04x\n", val);
+   amdsbwd_verbose_printf(dev, "ResetStatus = 0x%08x\n", val);
if ((val & AMDSB8_WD_RST_STS) != 0)
device_printf(dev, "Previous Reset was caused by Watchdog\n");
 
___
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: r333268 - head/sys/kern

2018-05-04 Thread Andriy Gapon
Author: avg
Date: Sat May  5 05:19:32 2018
New Revision: 333268
URL: https://svnweb.freebsd.org/changeset/base/333268

Log:
  for bus suspend, detach and shutdown iterate children in reverse order
  
  For most buses all children are equal, so the order does not matter.
  Other buses, such as acpi, carefully order their child devices to
  express implicit dependencies between them.  For such buses it is safer
  to bring down devices in the reverse order.
  
  I believe that this is the reason why hpet_suspend had to be disabled.
  Some drivers depend on a working event timer until they are suspended.
  But previously we would suspend hpet very early.
  
  I tested this change by makinbg hpet_suspend actually stop HPET timers
  and tested that too.
  
  Note that this change is not a complete solution as it does not take
  into account bus passes.
  A better approach would be to track the actual attach order of the
  devices and to use the reverse of that.
  
  Reviewed by:  imp, mav
  MFC after:3 weeks
  Differential Revision: https://reviews.freebsd.org/D15291

Modified:
  head/sys/kern/subr_bus.c

Modified: head/sys/kern/subr_bus.c
==
--- head/sys/kern/subr_bus.cFri May  4 22:48:10 2018(r333267)
+++ head/sys/kern/subr_bus.cSat May  5 05:19:32 2018(r333268)
@@ -3708,7 +3708,11 @@ bus_generic_detach(device_t dev)
if (dev->state != DS_ATTACHED)
return (EBUSY);
 
-   TAILQ_FOREACH(child, &dev->children, link) {
+   /*
+* Detach children in the reverse order.
+* See bus_generic_suspend for details.
+*/
+   TAILQ_FOREACH_REVERSE(child, &dev->children, device_list, link) {
if ((error = device_detach(child)) != 0)
return (error);
}
@@ -3728,7 +3732,11 @@ bus_generic_shutdown(device_t dev)
 {
device_t child;
 
-   TAILQ_FOREACH(child, &dev->children, link) {
+   /*
+* Shut down children in the reverse order.
+* See bus_generic_suspend for details.
+*/
+   TAILQ_FOREACH_REVERSE(child, &dev->children, device_list, link) {
device_shutdown(child);
}
 
@@ -3781,15 +3789,23 @@ int
 bus_generic_suspend(device_t dev)
 {
int error;
-   device_tchild, child2;
+   device_tchild;
 
-   TAILQ_FOREACH(child, &dev->children, link) {
+   /*
+* Suspend children in the reverse order.
+* For most buses all children are equal, so the order does not matter.
+* Other buses, such as acpi, carefully order their child devices to
+* express implicit dependencies between them.  For such buses it is
+* safer to bring down devices in the reverse order.
+*/
+   TAILQ_FOREACH_REVERSE(child, &dev->children, device_list, link) {
error = BUS_SUSPEND_CHILD(dev, child);
-   if (error) {
-   for (child2 = TAILQ_FIRST(&dev->children);
-child2 && child2 != child;
-child2 = TAILQ_NEXT(child2, link))
-   BUS_RESUME_CHILD(dev, child2);
+   if (error != 0) {
+   child = TAILQ_NEXT(child, link);
+   if (child != NULL) {
+   TAILQ_FOREACH_FROM(child, &dev->children, link)
+   BUS_RESUME_CHILD(dev, child);
+   }
return (error);
}
}
___
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: r333243 - head/sys/cddl/compat/opensolaris/kern

2018-05-04 Thread Andriy Gapon
Author: avg
Date: Fri May  4 07:28:01 2018
New Revision: 333243
URL: https://svnweb.freebsd.org/changeset/base/333243

Log:
  opensolaris system_taskq does not need to run at maximum priority
  
  In fact, this taskqueue should use "boring" threads, nothing special
  about them.
  
  MFC after:2 weeks

Modified:
  head/sys/cddl/compat/opensolaris/kern/opensolaris_taskq.c

Modified: head/sys/cddl/compat/opensolaris/kern/opensolaris_taskq.c
==
--- head/sys/cddl/compat/opensolaris/kern/opensolaris_taskq.c   Fri May  4 
06:51:01 2018(r333242)
+++ head/sys/cddl/compat/opensolaris/kern/opensolaris_taskq.c   Fri May  4 
07:28:01 2018(r333243)
@@ -48,7 +48,8 @@ system_taskq_init(void *arg)
 
taskq_zone = uma_zcreate("taskq_zone", sizeof(taskq_ent_t),
NULL, NULL, NULL, NULL, 0, 0);
-   system_taskq = taskq_create("system_taskq", mp_ncpus, 0, 0, 0, 0);
+   system_taskq = taskq_create("system_taskq", mp_ncpus, minclsyspri,
+   0, 0, 0);
 }
 SYSINIT(system_taskq_init, SI_SUB_CONFIGURE, SI_ORDER_ANY, system_taskq_init, 
NULL);
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333212 - head/sys/dev/amdsbwd

2018-05-03 Thread Andriy Gapon
Author: avg
Date: Thu May  3 15:33:18 2018
New Revision: 333212
URL: https://svnweb.freebsd.org/changeset/base/333212

Log:
  amdsbwd: add suspend and resume methods
  
  Without the suspend method the watchdog may fire in S1 state.  Without
  the resume method the watchdog is not re-enabled after returning from S3
  state.  I observe this on one of my systems.
  
  Not sure if watchdog(4) should participate in the suspend actions.
  Right now everything is up to individual drivers.
  
  MFC after:2 weeks

Modified:
  head/sys/dev/amdsbwd/amdsbwd.c

Modified: head/sys/dev/amdsbwd/amdsbwd.c
==
--- head/sys/dev/amdsbwd/amdsbwd.c  Thu May  3 15:01:27 2018
(r333211)
+++ head/sys/dev/amdsbwd/amdsbwd.c  Thu May  3 15:33:18 2018
(r333212)
@@ -104,12 +104,16 @@ static void   amdsbwd_identify(driver_t *driver, 
device_
 static int amdsbwd_probe(device_t dev);
 static int amdsbwd_attach(device_t dev);
 static int amdsbwd_detach(device_t dev);
+static int amdsbwd_suspend(device_t dev);
+static int amdsbwd_resume(device_t dev);
 
 static device_method_t amdsbwd_methods[] = {
DEVMETHOD(device_identify,  amdsbwd_identify),
DEVMETHOD(device_probe, amdsbwd_probe),
DEVMETHOD(device_attach,amdsbwd_attach),
DEVMETHOD(device_detach,amdsbwd_detach),
+   DEVMETHOD(device_suspend,   amdsbwd_suspend),
+   DEVMETHOD(device_resume,amdsbwd_resume),
 #if 0
DEVMETHOD(device_shutdown,  amdsbwd_detach),
 #endif
@@ -553,3 +557,30 @@ amdsbwd_detach(device_t dev)
return (0);
 }
 
+static int
+amdsbwd_suspend(device_t dev)
+{
+   struct amdsbwd_softc *sc;
+   uint32_t val;
+
+   sc = device_get_softc(dev);
+   val = wdctrl_read(sc);
+   val &= ~AMDSB_WD_RUN;
+   wdctrl_write(sc, val);
+   return (0);
+}
+
+static int
+amdsbwd_resume(device_t dev)
+{
+   struct amdsbwd_softc *sc;
+
+   sc = device_get_softc(dev);
+   wdctrl_write(sc, AMDSB_WD_FIRED);
+   if (sc->active) {
+   amdsbwd_tmr_set(sc, sc->timeout);
+   amdsbwd_tmr_enable(sc);
+   amdsbwd_tmr_reload(sc);
+   }
+   return (0);
+}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333209 - head/sys/dev/acpica

2018-05-03 Thread Andriy Gapon
Author: avg
Date: Thu May  3 13:14:31 2018
New Revision: 333209
URL: https://svnweb.freebsd.org/changeset/base/333209

Log:
  hpet: use macros instead of magic values for the timer mode
  
  MFC after:1 week

Modified:
  head/sys/dev/acpica/acpi_hpet.c

Modified: head/sys/dev/acpica/acpi_hpet.c
==
--- head/sys/dev/acpica/acpi_hpet.c Thu May  3 10:17:37 2018
(r333208)
+++ head/sys/dev/acpica/acpi_hpet.c Thu May  3 13:14:31 2018
(r333209)
@@ -96,6 +96,9 @@ struct hpet_softc {
struct hpet_softc   *sc;
int num;
int mode;
+#defineTIMER_STOPPED   0
+#defineTIMER_PERIODIC  1
+#defineTIMER_ONESHOT   2
int intr_rid;
int irq;
int pcpu_cpu;
@@ -206,10 +209,10 @@ hpet_start(struct eventtimer *et, sbintime_t first, sb
 
t = (mt->pcpu_master < 0) ? mt : &sc->t[mt->pcpu_slaves[curcpu]];
if (period != 0) {
-   t->mode = 1;
+   t->mode = TIMER_PERIODIC;
t->div = (sc->freq * period) >> 32;
} else {
-   t->mode = 2;
+   t->mode = TIMER_ONESHOT;
t->div = 0;
}
if (first != 0)
@@ -222,7 +225,7 @@ hpet_start(struct eventtimer *et, sbintime_t first, sb
now = bus_read_4(sc->mem_res, HPET_MAIN_COUNTER);
 restart:
t->next = now + fdiv;
-   if (t->mode == 1 && (t->caps & HPET_TCAP_PER_INT)) {
+   if (t->mode == TIMER_PERIODIC && (t->caps & HPET_TCAP_PER_INT)) {
t->caps |= HPET_TCNF_TYPE;
bus_write_4(sc->mem_res, HPET_TIMER_CAP_CNF(t->num),
t->caps | HPET_TCNF_VAL_SET);
@@ -253,7 +256,7 @@ hpet_stop(struct eventtimer *et)
struct hpet_softc *sc = mt->sc;
 
t = (mt->pcpu_master < 0) ? mt : &sc->t[mt->pcpu_slaves[curcpu]];
-   t->mode = 0;
+   t->mode = TIMER_STOPPED;
t->caps &= ~(HPET_TCNF_INT_ENB | HPET_TCNF_TYPE);
bus_write_4(sc->mem_res, HPET_TIMER_CAP_CNF(t->num), t->caps);
return (0);
@@ -267,7 +270,7 @@ hpet_intr_single(void *arg)
struct hpet_softc *sc = t->sc;
uint32_t now;
 
-   if (t->mode == 0)
+   if (t->mode == TIMER_STOPPED)
return (FILTER_STRAY);
/* Check that per-CPU timer interrupt reached right CPU. */
if (t->pcpu_cpu >= 0 && t->pcpu_cpu != curcpu) {
@@ -281,8 +284,9 @@ hpet_intr_single(void *arg)
 * Reload timer, hoping that next time may be more lucky
 * (system will manage proper interrupt binding).
 */
-   if ((t->mode == 1 && (t->caps & HPET_TCAP_PER_INT) == 0) ||
-   t->mode == 2) {
+   if ((t->mode == TIMER_PERIODIC &&
+   (t->caps & HPET_TCAP_PER_INT) == 0) ||
+   t->mode == TIMER_ONESHOT) {
t->next = bus_read_4(sc->mem_res, HPET_MAIN_COUNTER) +
sc->freq / 8;
bus_write_4(sc->mem_res, HPET_TIMER_COMPARATOR(t->num),
@@ -290,7 +294,7 @@ hpet_intr_single(void *arg)
}
return (FILTER_HANDLED);
}
-   if (t->mode == 1 &&
+   if (t->mode == TIMER_PERIODIC &&
(t->caps & HPET_TCAP_PER_INT) == 0) {
t->next += t->div;
now = bus_read_4(sc->mem_res, HPET_MAIN_COUNTER);
@@ -298,8 +302,8 @@ hpet_intr_single(void *arg)
t->next = now + t->div / 2;
bus_write_4(sc->mem_res,
HPET_TIMER_COMPARATOR(t->num), t->next);
-   } else if (t->mode == 2)
-   t->mode = 0;
+   } else if (t->mode == TIMER_ONESHOT)
+   t->mode = TIMER_STOPPED;
mt = (t->pcpu_master < 0) ? t : &sc->t[t->pcpu_master];
if (mt->et.et_active)
mt->et.et_event_cb(&mt->et, mt->et.et_arg);
@@ -528,7 +532,7 @@ hpet_attach(device_t dev)
t = &sc->t[i];
t->sc = sc;
t->num = i;
-   t->mode = 0;
+   t->mode = TIMER_STOPPED;
t->intr_rid = -1;
t->irq = -1;
t->pcpu_cpu = -1;
@@ -878,10 +882,11 @@ hpet_resume(device_t dev)
}
}
 #endif
-   if (t->mode == 0)
+   if (t->mode == TIMER_STOPPED)
continue;
t->next = bus_read_4(sc->mem_res, HPET_MAIN_COUNTER);
-   if (t->mode == 1 && (t->caps & HPET_TCAP_PER_INT)) {
+   if (t->mode == TIMER_PERIODIC &&
+   (t->caps & HPET_TCAP_PER_INT) != 0) {
t->caps |= HPET_TCNF_TYPE;
t->next += t->div;
bus_

svn commit: r332918 - in head/sys: dev/acpica x86/acpica

2018-04-24 Thread Andriy Gapon
Author: avg
Date: Tue Apr 24 09:42:58 2018
New Revision: 332918
URL: https://svnweb.freebsd.org/changeset/base/332918

Log:
  add a new ACPI suspend debugging knob, debug.acpi.suspend_deep_bounce
  
  This sysctl allows a deeper dive into the sleep abyss comparing to
  debug.acpi.suspend_bounce.  When the new sysctl is set the system will
  execute the suspend sequence up to the call to AcpiEnterSleepState().
  That includes saving processor contexts and parking APs.  Then, instead
  of actually entering the sleep state, the BSP will call resumectx() to
  emulate the wakeup.  The APs should get restarted by the sequence of
  Init and Startup IPIs that BSP sends to them.
  
  MFC after:8 days

Modified:
  head/sys/dev/acpica/acpi.c
  head/sys/x86/acpica/acpi_wakeup.c

Modified: head/sys/dev/acpica/acpi.c
==
--- head/sys/dev/acpica/acpi.c  Tue Apr 24 08:48:20 2018(r332917)
+++ head/sys/dev/acpica/acpi.c  Tue Apr 24 09:42:58 2018(r332918)
@@ -291,6 +291,11 @@ static int acpi_susp_bounce;
 SYSCTL_INT(_debug_acpi, OID_AUTO, suspend_bounce, CTLFLAG_RW,
 &acpi_susp_bounce, 0, "Don't actually suspend, just test devices.");
 
+int acpi_susp_deep_bounce;
+SYSCTL_INT(_debug_acpi, OID_AUTO, suspend_deep_bounce, CTLFLAG_RW,
+&acpi_susp_deep_bounce, 0, "Don't actually suspend, "
+"bail out just before entering the sleep state.");
+
 /*
  * ACPI can only be loaded as a module by the loader; activating it after
  * system bootstrap time is not useful, and can be fatal to the system.

Modified: head/sys/x86/acpica/acpi_wakeup.c
==
--- head/sys/x86/acpica/acpi_wakeup.c   Tue Apr 24 08:48:20 2018
(r332917)
+++ head/sys/x86/acpica/acpi_wakeup.c   Tue Apr 24 09:42:58 2018
(r332918)
@@ -79,6 +79,7 @@ CTASSERT(sizeof(wakecode) < PAGE_SIZE - 1024);
 
 extern int acpi_resume_beep;
 extern int acpi_reset_video;
+extern int acpi_susp_deep_bounce;
 
 #ifdef SMP
 extern struct susppcb  **susppcbs;
@@ -263,6 +264,9 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state)
 */
PTD[KPTDI] = PTD[LOWPTDI];
 #endif
+
+   if (acpi_susp_deep_bounce)
+   resumectx(pcb);
 
/* Call ACPICA to enter the desired sleep state */
if (state == ACPI_STATE_S4 && sc->acpi_s4bios)
___
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: r332816 - head/sys/kern

2018-04-20 Thread Andriy Gapon
Author: avg
Date: Fri Apr 20 13:08:04 2018
New Revision: 332816
URL: https://svnweb.freebsd.org/changeset/base/332816

Log:
  call racct_proc_ucred_changed() under the proc lock
  
  The lock is required to ensure that the switch to the new credentials
  and the transfer of the process's accounting data from the old
  credentials to the new ones is done atomically.  Otherwise, some updates
  may be applied to the new credentials and then additionally transferred
  from the old credentials if the updates happen after proc_set_cred() and
  before racct_proc_ucred_changed().
  
  The problem is especially pronounced for RACCT_RSS because
  - there is a strict accounting for this resource (it's reclaimable)
  - it's updated asynchronously by the vm daemon
  - it's updated by setting an absolute value instead of applying a delta
  
  I had to remove a call to rctl_proc_ucred_changed() from
  racct_proc_ucred_changed() and make all callers of latter call the
  former as well.  The reason is that rctl_proc_ucred_changed, as it is
  implemented now, cannot be called while holding the proc lock, so the
  lock is dropped after calling racct_proc_ucred_changed.  Additionally,
  I've added calls to crhold / crfree around the rctl call, because
  without the proc lock there is no gurantee that the new credentials,
  owned by the process, will stay stable.  That does not eliminate a
  possibility that the credentials passed to the rctl will get stale.
  Ideally, rctl_proc_ucred_changed should be able to work under the proc
  lock.
  
  Many thanks to kib for pointing out the above problems.
  
  PR:   222027
  Discussed with:   kib
  No comment:   trasz
  MFC after:2 weeks
  Differential Revision: https://reviews.freebsd.org/D15048

Modified:
  head/sys/kern/kern_jail.c
  head/sys/kern/kern_loginclass.c
  head/sys/kern/kern_prot.c
  head/sys/kern/kern_racct.c
  head/sys/kern/kern_rctl.c

Modified: head/sys/kern/kern_jail.c
==
--- head/sys/kern/kern_jail.c   Fri Apr 20 12:40:05 2018(r332815)
+++ head/sys/kern/kern_jail.c   Fri Apr 20 13:08:04 2018(r332816)
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2401,10 +2402,15 @@ do_jail_attach(struct thread *td, struct prison *pr)
newcred->cr_prison = pr;
proc_set_cred(p, newcred);
setsugid(p);
-   PROC_UNLOCK(p);
 #ifdef RACCT
racct_proc_ucred_changed(p, oldcred, newcred);
+   crhold(newcred);
 #endif
+   PROC_UNLOCK(p);
+#ifdef RCTL
+   rctl_proc_ucred_changed(p, newcred);
+   crfree(newcred);
+#endif
prison_deref(oldcred->cr_prison, PD_DEREF | PD_DEUREF);
crfree(oldcred);
return (0);
@@ -3960,6 +3966,7 @@ prison_racct_modify(struct prison *pr)
 */
racct_move(pr->pr_prison_racct->prr_racct, oldprr->prr_racct);
 
+#ifdef RCTL
/*
 * Force rctl to reattach rules to processes.
 */
@@ -3967,9 +3974,10 @@ prison_racct_modify(struct prison *pr)
PROC_LOCK(p);
cred = crhold(p->p_ucred);
PROC_UNLOCK(p);
-   racct_proc_ucred_changed(p, cred, cred);
+   rctl_proc_ucred_changed(p, cred);
crfree(cred);
}
+#endif
 
sx_sunlock(&allproc_lock);
prison_racct_free_locked(oldprr);

Modified: head/sys/kern/kern_loginclass.c
==
--- head/sys/kern/kern_loginclass.c Fri Apr 20 12:40:05 2018
(r332815)
+++ head/sys/kern/kern_loginclass.c Fri Apr 20 13:08:04 2018
(r332816)
@@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -230,9 +231,14 @@ sys_setloginclass(struct thread *td, struct setlogincl
oldcred = crcopysafe(p, newcred);
newcred->cr_loginclass = newlc;
proc_set_cred(p, newcred);
-   PROC_UNLOCK(p);
 #ifdef RACCT
racct_proc_ucred_changed(p, oldcred, newcred);
+   crhold(newcred);
+#endif
+   PROC_UNLOCK(p);
+#ifdef RCTL
+   rctl_proc_ucred_changed(p, newcred);
+   crfree(newcred);
 #endif
loginclass_free(oldcred->cr_loginclass);
crfree(oldcred);

Modified: head/sys/kern/kern_prot.c
==
--- head/sys/kern/kern_prot.c   Fri Apr 20 12:40:05 2018(r332815)
+++ head/sys/kern/kern_prot.c   Fri Apr 20 13:08:04 2018(r332816)
@@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -575,10 +576,15 @@ sys_setuid(struct thread *td, struct setuid_args *uap)
setsugid(p);
}
proc_set_cred(p, newcred);
-   PROC_UNLOCK(p);
 #ifdef RACCT
racct_proc_ucred_changed(p, oldcred, newcred);
+ 

svn commit: r332752 - in head/sys: amd64/amd64 i386/i386 powerpc/powerpc sys

2018-04-18 Thread Andriy Gapon
Author: avg
Date: Thu Apr 19 05:06:56 2018
New Revision: 332752
URL: https://svnweb.freebsd.org/changeset/base/332752

Log:
  set kdb_why to "trap" when calling kdb_trap from trap_fatal
  
  This will allow to hook a ddb script to "kdb.enter.trap" event.
  Previously there was no specific name for this event, so it could only
  be handled by either "kdb.enter.unknown" or "kdb.enter.default" hooks.
  Both are very unspecific.
  
  Having a specific event is useful because the fatal trap condition is
  very similar to panic but it has an additional property that the current
  stack frame is the frame where the trap occurred.  So, both a register
  dump and a stack bottom dump have additional information that can help
  analyze the problem.
  
  I have added the event only on architectures that have trap_fatal()
  function defined.  I haven't looked at other architectures.  Their
  maintainers can add support for the event later.
  
  Sample script:
  kdb.enter.trap=bt; show reg; x/aS $rsp,20; x/agx $rsp,20
  
  Reviewed by:  kib, jhb, markj
  MFC after:11 days
  Sponsored by: Panzura
  Differential Revision: https://reviews.freebsd.org/D15093

Modified:
  head/sys/amd64/amd64/trap.c
  head/sys/i386/i386/trap.c
  head/sys/powerpc/powerpc/trap.c
  head/sys/sys/kdb.h

Modified: head/sys/amd64/amd64/trap.c
==
--- head/sys/amd64/amd64/trap.c Thu Apr 19 03:31:41 2018(r332751)
+++ head/sys/amd64/amd64/trap.c Thu Apr 19 05:06:56 2018(r332752)
@@ -761,6 +761,9 @@ trap_fatal(frame, eva)
u_int type;
struct soft_segment_descriptor softseg;
char *msg;
+#ifdef KDB
+   bool handled;
+#endif
 
code = frame->tf_err;
type = frame->tf_trapno;
@@ -811,9 +814,13 @@ trap_fatal(frame, eva)
curproc->p_pid, curthread->td_name);
 
 #ifdef KDB
-   if (debugger_on_panic)
-   if (kdb_trap(type, 0, frame))
+   if (debugger_on_panic) {
+   kdb_why = KDB_WHY_TRAP;
+   handled = kdb_trap(type, 0, frame);
+   kdb_why = KDB_WHY_UNSET;
+   if (handled)
return;
+   }
 #endif
printf("trap number = %d\n", type);
if (type <= MAX_TRAP_MSG)

Modified: head/sys/i386/i386/trap.c
==
--- head/sys/i386/i386/trap.c   Thu Apr 19 03:31:41 2018(r332751)
+++ head/sys/i386/i386/trap.c   Thu Apr 19 05:06:56 2018(r332752)
@@ -879,6 +879,9 @@ trap_fatal(frame, eva)
int code, ss, esp;
u_int type;
struct soft_segment_descriptor softseg;
+#ifdef KDB
+   bool handled;
+#endif
 
code = frame->tf_err;
type = frame->tf_trapno;
@@ -940,12 +943,13 @@ trap_fatal(frame, eva)
 
 #ifdef KDB
if (debugger_on_panic) {
+   kdb_why = KDB_WHY_TRAP;
frame->tf_err = eva;/* smuggle fault address to ddb */
-   if (kdb_trap(type, 0, frame)) {
-   frame->tf_err = code;   /* restore error code */
+   handled = kdb_trap(type, 0, frame);
+   frame->tf_err = code;   /* restore error code */
+   kdb_why = KDB_WHY_UNSET;
+   if (handled)
return;
-   }
-   frame->tf_err = code;   /* restore error code */
}
 #endif
printf("trap number = %d\n", type);

Modified: head/sys/powerpc/powerpc/trap.c
==
--- head/sys/powerpc/powerpc/trap.c Thu Apr 19 03:31:41 2018
(r332751)
+++ head/sys/powerpc/powerpc/trap.c Thu Apr 19 05:06:56 2018
(r332752)
@@ -449,11 +449,19 @@ trap(struct trapframe *frame)
 static void
 trap_fatal(struct trapframe *frame)
 {
+#ifdef KDB
+   bool handled;
+#endif
 
printtrap(frame->exc, frame, 1, (frame->srr1 & PSL_PR));
 #ifdef KDB
-   if (debugger_on_panic && kdb_trap(frame->exc, 0, frame))
-   return;
+   if (debugger_on_panic) {
+   kdb_why = KDB_WHY_TRAP;
+   handled = kdb_trap(frame->exc, 0, frame);
+   kdb_why = KDB_WHY_UNSET;
+   if (handled)
+   return;
+   }
 #endif
panic("%s trap", trapname(frame->exc));
 }

Modified: head/sys/sys/kdb.h
==
--- head/sys/sys/kdb.h  Thu Apr 19 03:31:41 2018(r332751)
+++ head/sys/sys/kdb.h  Thu Apr 19 05:06:56 2018(r332752)
@@ -101,6 +101,7 @@ extern const char * volatile kdb_why;
 #defineKDB_WHY_UNSET   NULL/* No reason set. */
 #defineKDB_WHY_PANIC   "panic" /* panic() was called. 
*/
 #defineKDB_WHY_KASSERT "kassert"   /* kassert failed. */
+#defineKDB_WHY_TRA

svn commit: r332730 - in head/sys: amd64/amd64 i386/i386 powerpc/powerpc

2018-04-18 Thread Andriy Gapon
Author: avg
Date: Wed Apr 18 15:44:54 2018
New Revision: 332730
URL: https://svnweb.freebsd.org/changeset/base/332730

Log:
  don't check for kdb reentry in trap_fatal(), it's impossible
  
  trap() checks for it earlier and calls kdb_reentry().
  
  Discussed with:   jhb
  MFC after:12 days
  Sponsored by: Panzura

Modified:
  head/sys/amd64/amd64/trap.c
  head/sys/i386/i386/trap.c
  head/sys/powerpc/powerpc/trap.c

Modified: head/sys/amd64/amd64/trap.c
==
--- head/sys/amd64/amd64/trap.c Wed Apr 18 15:34:18 2018(r332729)
+++ head/sys/amd64/amd64/trap.c Wed Apr 18 15:44:54 2018(r332730)
@@ -811,7 +811,7 @@ trap_fatal(frame, eva)
curproc->p_pid, curthread->td_name);
 
 #ifdef KDB
-   if (debugger_on_panic || kdb_active)
+   if (debugger_on_panic)
if (kdb_trap(type, 0, frame))
return;
 #endif

Modified: head/sys/i386/i386/trap.c
==
--- head/sys/i386/i386/trap.c   Wed Apr 18 15:34:18 2018(r332729)
+++ head/sys/i386/i386/trap.c   Wed Apr 18 15:44:54 2018(r332730)
@@ -937,7 +937,7 @@ trap_fatal(frame, eva)
curproc->p_pid, curthread->td_name);
 
 #ifdef KDB
-   if (debugger_on_panic || kdb_active) {
+   if (debugger_on_panic) {
frame->tf_err = eva;/* smuggle fault address to ddb */
if (kdb_trap(type, 0, frame)) {
frame->tf_err = code;   /* restore error code */

Modified: head/sys/powerpc/powerpc/trap.c
==
--- head/sys/powerpc/powerpc/trap.c Wed Apr 18 15:34:18 2018
(r332729)
+++ head/sys/powerpc/powerpc/trap.c Wed Apr 18 15:44:54 2018
(r332730)
@@ -452,8 +452,7 @@ trap_fatal(struct trapframe *frame)
 
printtrap(frame->exc, frame, 1, (frame->srr1 & PSL_PR));
 #ifdef KDB
-   if ((debugger_on_panic || kdb_active) &&
-   kdb_trap(frame->exc, 0, frame))
+   if (debugger_on_panic && kdb_trap(frame->exc, 0, frame))
return;
 #endif
panic("%s trap", trapname(frame->exc));
___
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: r332559 - head/usr.sbin/mountd

2018-04-16 Thread Andriy Gapon
On 16/04/2018 13:56, Konstantin Belousov wrote:
> On Mon, Apr 16, 2018 at 09:17:36AM +0000, Andriy Gapon wrote:
>> Author: avg
>> Date: Mon Apr 16 09:17:36 2018
>> New Revision: 332559
>> URL: https://svnweb.freebsd.org/changeset/base/332559
>>
>> Log:
>>   mountd: fix a crash when getgrouplist reports too many groups
>>   
>>   Previously the code only warned about the condition and then happily
>>   proceeded to use the too large value resulting in the array
>>   out-of-bounds access.
>>   
>>   Obtained from: Panzura (Chuanbo Zheng)
>>   MFC after: 10 days
>>   Sponsored by:  Panzura
>>
>> Modified:
>>   head/usr.sbin/mountd/mountd.c
>>
>> Modified: head/usr.sbin/mountd/mountd.c
>> ==
>> --- head/usr.sbin/mountd/mountd.cMon Apr 16 08:41:44 2018
>> (r332558)
>> +++ head/usr.sbin/mountd/mountd.cMon Apr 16 09:17:36 2018
>> (r332559)
>> @@ -2915,8 +2915,11 @@ parsecred(char *namelist, struct xucred *cr)
>>  }
>>  cr->cr_uid = pw->pw_uid;
>>  ngroups = XU_NGROUPS + 1;
>> -if (getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups))
>> +if (getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups)) {
>>  syslog(LOG_ERR, "too many groups");
>> +ngroups = XU_NGROUPS + 1;
> Why XU_NGROUPS and not the value of sysctl("kern.ngroups") ?

Two reasons:

1. it's what the code already used
2. the groups are placed into struct xucred and later that struct is passed to
kernel, so in my opinion it's xucred that defines the limit in this case


-- 
Andriy Gapon
___
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: r332559 - head/usr.sbin/mountd

2018-04-16 Thread Andriy Gapon
Author: avg
Date: Mon Apr 16 09:17:36 2018
New Revision: 332559
URL: https://svnweb.freebsd.org/changeset/base/332559

Log:
  mountd: fix a crash when getgrouplist reports too many groups
  
  Previously the code only warned about the condition and then happily
  proceeded to use the too large value resulting in the array
  out-of-bounds access.
  
  Obtained from:Panzura (Chuanbo Zheng)
  MFC after:10 days
  Sponsored by: Panzura

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

Modified: head/usr.sbin/mountd/mountd.c
==
--- head/usr.sbin/mountd/mountd.c   Mon Apr 16 08:41:44 2018
(r332558)
+++ head/usr.sbin/mountd/mountd.c   Mon Apr 16 09:17:36 2018
(r332559)
@@ -2915,8 +2915,11 @@ parsecred(char *namelist, struct xucred *cr)
}
cr->cr_uid = pw->pw_uid;
ngroups = XU_NGROUPS + 1;
-   if (getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups))
+   if (getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups)) {
syslog(LOG_ERR, "too many groups");
+   ngroups = XU_NGROUPS + 1;
+   }
+
/*
 * Compress out duplicate.
 */
___
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: r332426 - in head: cddl/contrib/opensolaris/cmd/zpool cddl/contrib/opensolaris/lib/libzfs/common sys/cddl/contrib/opensolaris/common/zfs sys/cddl/contrib/opensolaris/uts/common/fs/zfs s...

2018-04-12 Thread Andriy Gapon
Author: avg
Date: Thu Apr 12 10:37:26 2018
New Revision: 332426
URL: https://svnweb.freebsd.org/changeset/base/332426

Log:
  allow ZFS pool to have temporary name for duration of current import
  
  The change adds -t  option to zpool create and -t option to zpool
  import in its form with an old name and a new name.  This allows to
  import (or create) a pool under a name that's different from its real,
  permanent name without affecting that name.  This is useful when working
  with VM images or images of other physical systems if they happen to
  have a ZFS pool with the same name as the host system.
  
  The changes come from ZoL with some small tweaks.
  The porting has been done by julian.
  
  The change is being submitted to OpenZFS:
  https://github.com/openzfs/openzfs/pull/600
  
  Submitted by: julian
  Reviewed by:  smh
  MFC after:2 weeks
  Sponsored by: Panzura (porting)
  Differential Revision: https://reviews.freebsd.org/D14972

Modified:
  head/cddl/contrib/opensolaris/cmd/zpool/zpool.8
  head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
  head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
  head/sys/cddl/contrib/opensolaris/common/zfs/zpool_prop.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c
  head/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h

Modified: head/cddl/contrib/opensolaris/cmd/zpool/zpool.8
==
--- head/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Thu Apr 12 07:39:24 
2018(r332425)
+++ head/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Thu Apr 12 10:37:26 
2018(r332426)
@@ -62,6 +62,7 @@
 .Ar ...
 .Op Fl m Ar mountpoint
 .Op Fl R Ar root
+.Op Fl t Ar tempname
 .Ar pool vdev ...
 .Nm
 .Cm destroy
@@ -115,6 +116,7 @@
 .Op Fl m
 .Op Fl N
 .Op Fl R Ar root
+.Op Fl t
 .Op Fl F Op Fl n
 .Ar pool | id
 .Op Ar newpool
@@ -961,6 +963,7 @@ do not actually discard any transactions.
 .Ar ...
 .Op Fl m Ar mountpoint
 .Op Fl R Ar root
+.Op Fl t Ar tempname
 .Ar pool vdev ...
 .Xc
 .Pp
@@ -1062,6 +1065,18 @@ or
 .Qq Cm none .
 For more information on dataset mount points, see
 .Xr zfs 8 .
+.It Fl t Ar tempname
+Sets the in-core pool name to
+.Pa tempname
+while the on-disk name will be the name specified as the pool name
+.Pa pool .
+This will set the default
+.Sy cachefile
+property to
+.Sy none .
+This is intended to handle name space collisions when creating pools
+for other systems, such as virtual machines or physical machines
+whose pools live on network block devices.
 .El
 .It Xo
 .Nm
@@ -1316,6 +1331,7 @@ Searches for and imports all pools found.
 .Op Fl m
 .Op Fl N
 .Op Fl R Ar root
+.Op Fl t
 .Op Fl F Op Fl n
 .Ar pool | id
 .Op Ar newpool
@@ -1375,6 +1391,20 @@ Import the pool without mounting any file systems.
 .It Fl R Ar root
 Equivalent to
 .Qq Fl o Cm cachefile=none,altroot= Ns Pa root
+.It Fl t
+Used with
+.Ar newpool .
+Specifies that
+.Ar newpool
+is temporary.
+Temporary pool names last until export.
+Ensures that the original pool name will be used in all label updates and
+therefore is retained upon export.
+Will also set
+.Sy cachefile
+property to
+.Sy none
+when not explicitly specified.
 .It Fl F
 Recovery mode for a non-importable pool. Attempt to return the pool to an
 importable state by discarding the last few transactions. Not all damaged pools

Modified: head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
==
--- head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.cThu Apr 12 
07:39:24 2018(r332425)
+++ head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.cThu Apr 12 
10:37:26 2018(r332426)
@@ -220,8 +220,9 @@ get_usage(zpool_help_t idx)
case HELP_CREATE:
return (gettext("\tcreate [-fnd] [-B] "
"[-o property=value] ... \n"
-   "\t[-O file-system-property=value] ... \n"
-   "\t[-m mountpoint] [-R root]   ...\n"));
+   "\t[-O file-system-property=value] ...\n"
+   "\t[-m mountpoint] [-R root] [-t tempname] "
+   "  ...\n"));
case HELP_CHECKPOINT:
return (gettext("\tcheckpoint [--discard]  ...\n"));
case HELP_DESTROY:
@@ -239,7 +240,7 @@ get_usage(zpool_help_t idx)
"[-R root] [-F [-n]] -a\n"
"\timport [-o mntopts] [-o property=value] ... \n"
"\t[-d dir | -c cachefile] [-D] [-f] [-m] [-N] "
-   "[-R root] [-F [-n]]\n"
+   "[-R root] [-F [-n]] [-t]\n"
"\t[--rewind-to-checkpoint]  [newpool]\n"));
case HELP_IOSTAT:
return (gettext("\tiostat [-v] [-T d|u] [pool] ... [interval "
@@ -489,6 +490,21 @@ add_prop_list(const char *propname, char *propval, nvl
 }
 

Re: svn commit: r331701 - in head: cddl/contrib/opensolaris/cmd/zdb cddl/contrib/opensolaris/cmd/zpool cddl/contrib/opensolaris/cmd/ztest cddl/contrib/opensolaris/lib/libzfs/common cddl/contrib/openso

2018-04-05 Thread Andriy Gapon
On 29/03/2018 01:01, Alexander Motin wrote:
>   MFV r331695, 331700: 9166 zfs storage pool checkpoint
>   
>   illumos/illumos-gate@8671400134a11c848244896ca51a7db4d0f69da4
>   
>   The idea of Storage Pool Checkpoint (aka zpool checkpoint) deals with
>   exactly that.  It can be thought of as a “pool-wide snapshot” (or a
>   variation of extreme rewind that doesn’t corrupt your data).  It remembers
>   the entire state of the pool at the point that it was taken and the user
>   can revert back to it later or discard it.  Its generic use case is an
>   administrator that is about to perform a set of destructive actions to ZFS
>   as part of a critical procedure.  She takes a checkpoint of the pool before
>   performing the actions, then rewinds back to it if one of them fails or puts
>   the pool into an unexpected state.  Otherwise, she discards it.  With the
>   assumption that no one else is making modifications to ZFS, she basically
>   wraps all these actions into a “high-level transaction”.

A small nit:
> /* check options */
> -   while ((c = getopt(argc, argv, ":aCc:d:DEfFmnNo:R:T:VX")) != -1) {
> +   while ((c = getopt_long(argc, argv, ":aCc:d:DEfFmnNo:rR:T:VX",
> +   long_options, NULL)) != -1) {
> switch (c) {

It seems that on illumos zpool import has an undocumented option with no effect,
-r.  I think that we removed that option from FreeBSD.  This commit restored it.
I am actually indifferent about having it.  Just pointing out this possibly
unintended change.

-- 
Andriy Gapon
___
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: r331931 - in head/sys: amd64/amd64 i386/i386 x86/x86

2018-04-03 Thread Andriy Gapon
Author: avg
Date: Tue Apr  3 17:16:06 2018
New Revision: 331931
URL: https://svnweb.freebsd.org/changeset/base/331931

Log:
  fix i386 build with CPU_ELAN (LINT for instance) after r331878
  
  x86/cpu_machdep.c now needs to include elan_mmcr.h when CPU_ELAN is set.
  While here, also remove the now unneeded inclusion of isareg.h in i386
  and amd64 vm_machdep.c.
  
  Reported by:  lwhsu
  MFC after:14 days
  X-MFC with:   r331878

Modified:
  head/sys/amd64/amd64/vm_machdep.c
  head/sys/i386/i386/vm_machdep.c
  head/sys/x86/x86/cpu_machdep.c

Modified: head/sys/amd64/amd64/vm_machdep.c
==
--- head/sys/amd64/amd64/vm_machdep.c   Tue Apr  3 15:14:30 2018
(r331930)
+++ head/sys/amd64/amd64/vm_machdep.c   Tue Apr  3 17:16:06 2018
(r331931)
@@ -82,8 +82,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include 
-
 _Static_assert(OFFSETOF_CURTHREAD == offsetof(struct pcpu, pc_curthread),
 "OFFSETOF_CURTHREAD does not correspond with offset of pc_curthread.");
 _Static_assert(OFFSETOF_CURPCB == offsetof(struct pcpu, pc_curpcb),

Modified: head/sys/i386/i386/vm_machdep.c
==
--- head/sys/i386/i386/vm_machdep.c Tue Apr  3 15:14:30 2018
(r331930)
+++ head/sys/i386/i386/vm_machdep.c Tue Apr  3 17:16:06 2018
(r331931)
@@ -79,18 +79,12 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#ifdef CPU_ELAN
-#include 
-#endif
-
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-
-#include 
 
 #ifndef NSFBUFS
 #defineNSFBUFS (512 + maxusers * 16)

Modified: head/sys/x86/x86/cpu_machdep.c
==
--- head/sys/x86/x86/cpu_machdep.c  Tue Apr  3 15:14:30 2018
(r331930)
+++ head/sys/x86/x86/cpu_machdep.c  Tue Apr  3 17:16:06 2018
(r331931)
@@ -85,6 +85,9 @@ __FBSDID("$FreeBSD$");
 #ifdef SMP
 #include 
 #endif
+#ifdef CPU_ELAN
+#include 
+#endif
 #include 
 
 #include 
___
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: r327056 - in head/sys: kern sys x86/acpica x86/x86

2018-04-03 Thread Andriy Gapon
On 02/04/2018 18:28, Bruce Evans wrote:
> On Mon, 2 Apr 2018, Andriy Gapon wrote:
> 
>> On 21/12/2017 11:17, Bruce Evans wrote:
>>> Author: bde
>>> Date: Thu Dec 21 09:17:48 2017
>>> New Revision: 327056
>>> URL: https://svnweb.freebsd.org/changeset/base/327056
>>>
>>> Log:
>>>   Use resume_cpus() instead of restart_cpus() to resume from ACPI 
>>> suspension.
>>
>> Bruce,
>>
>> do you plan to merge this to stable/11 and maybe stable/10?
> 
> No.  I'm nit (yet?) set up to merge to stable at all, and this is not the
> first thing that I would want to merge.
> 
>> If you'd like, I can do it.  Unless you see any reason not to.
> 
> Please do it.

Done in r327056 and r327056.
All merge bugs are mine.

> It is only a small part of fixing mapping bugs for low memory which first
> showed up s incoherent page tables for vm86 (low memory was left unmapped
> all the time to handle the problem that ACPI resume needs this mapping for
> 1 instruction).  You might need the other fixes.  This one is fairly stand-
> alone but doesn't do much by itself.

I was just interested in fixing the KPI misuse (restart vs resume).
No particular "real" problems that I wanted to address.


-- 
Andriy Gapon
___
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: r331908 - head/sys/x86/x86

2018-04-02 Thread Andriy Gapon
Author: avg
Date: Tue Apr  3 06:46:26 2018
New Revision: 331908
URL: https://svnweb.freebsd.org/changeset/base/331908

Log:
  fix signatures of cpu_reset_real and cpu_reset_proxy, broken in r331878
  
  When I moved these functions from i386 and amd64 to x86 I dropped their
  prototype declarations (that were correct) and left only their definitions
  that became incorrect.
  
  Reported by:  bde
  MFC after:15 days
  X-MFC with:   r331878

Modified:
  head/sys/x86/x86/cpu_machdep.c

Modified: head/sys/x86/x86/cpu_machdep.c
==
--- head/sys/x86/x86/cpu_machdep.c  Tue Apr  3 06:06:39 2018
(r331907)
+++ head/sys/x86/x86/cpu_machdep.c  Tue Apr  3 06:46:26 2018
(r331908)
@@ -251,7 +251,7 @@ cpu_halt(void)
 }
 
 static void
-cpu_reset_real()
+cpu_reset_real(void)
 {
struct region_descriptor null_idt;
int b;
@@ -324,7 +324,7 @@ cpu_reset_real()
 
 #ifdef SMP
 static void
-cpu_reset_proxy()
+cpu_reset_proxy(void)
 {
 
cpu_reset_proxy_active = 1;
@@ -338,7 +338,7 @@ cpu_reset_proxy()
 #endif
 
 void
-cpu_reset()
+cpu_reset(void)
 {
 #ifdef SMP
cpuset_t map;
___
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: r331878 - in head/sys: amd64/amd64 i386/i386 x86/x86

2018-04-02 Thread Andriy Gapon
Author: avg
Date: Mon Apr  2 13:45:23 2018
New Revision: 331878
URL: https://svnweb.freebsd.org/changeset/base/331878

Log:
  unify amd64 and i386 cpu_reset() in x86/cpu_machdep.c
  
  Because I didn't see any reason not too.
  I've been making some changes to the code and couldn't help but notice
  that the i386 and am64 code was nearly identical.
  
  MFC after:17 days

Modified:
  head/sys/amd64/amd64/vm_machdep.c
  head/sys/i386/i386/vm_machdep.c
  head/sys/x86/x86/cpu_machdep.c

Modified: head/sys/amd64/amd64/vm_machdep.c
==
--- head/sys/amd64/amd64/vm_machdep.c   Mon Apr  2 13:36:48 2018
(r331877)
+++ head/sys/amd64/amd64/vm_machdep.c   Mon Apr  2 13:45:23 2018
(r331878)
@@ -84,13 +84,6 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
-static voidcpu_reset_real(void);
-#ifdef SMP
-static voidcpu_reset_proxy(void);
-static u_int   cpu_reset_proxyid;
-static volatile u_int  cpu_reset_proxy_active;
-#endif
-
 _Static_assert(OFFSETOF_CURTHREAD == offsetof(struct pcpu, pc_curthread),
 "OFFSETOF_CURTHREAD does not correspond with offset of pc_curthread.");
 _Static_assert(OFFSETOF_CURPCB == offsetof(struct pcpu, pc_curpcb),
@@ -563,129 +556,6 @@ cpu_set_user_tls(struct thread *td, void *tls_base)
 #endif
pcb->pcb_fsbase = (register_t)tls_base;
return (0);
-}
-
-#ifdef SMP
-static void
-cpu_reset_proxy()
-{
-
-   cpu_reset_proxy_active = 1;
-   while (cpu_reset_proxy_active == 1)
-   ia32_pause(); /* Wait for other cpu to see that we've started */
-
-   printf("cpu_reset_proxy: Stopped CPU %d\n", cpu_reset_proxyid);
-   DELAY(100);
-   cpu_reset_real();
-}
-#endif
-
-void
-cpu_reset()
-{
-#ifdef SMP
-   cpuset_t map;
-   u_int cnt;
-
-   if (smp_started) {
-   map = all_cpus;
-   CPU_CLR(PCPU_GET(cpuid), &map);
-   CPU_NAND(&map, &stopped_cpus);
-   if (!CPU_EMPTY(&map)) {
-   printf("cpu_reset: Stopping other CPUs\n");
-   stop_cpus(map);
-   }
-
-   if (PCPU_GET(cpuid) != 0) {
-   cpu_reset_proxyid = PCPU_GET(cpuid);
-   cpustop_restartfunc = cpu_reset_proxy;
-   cpu_reset_proxy_active = 0;
-   printf("cpu_reset: Restarting BSP\n");
-
-   /* Restart CPU #0. */
-   CPU_SETOF(0, &started_cpus);
-   wmb();
-
-   cnt = 0;
-   while (cpu_reset_proxy_active == 0 && cnt < 1000) {
-   ia32_pause();
-   cnt++;  /* Wait for BSP to announce restart */
-   }
-   if (cpu_reset_proxy_active == 0) {
-   printf("cpu_reset: Failed to restart BSP\n");
-   } else {
-   cpu_reset_proxy_active = 2;
-   while (1)
-   ia32_pause();
-   /* NOTREACHED */
-   }
-   }
-
-   DELAY(100);
-   }
-#endif
-   cpu_reset_real();
-   /* NOTREACHED */
-}
-
-static void
-cpu_reset_real()
-{
-   struct region_descriptor null_idt;
-   int b;
-
-   disable_intr();
-
-   /*
-* Attempt to do a CPU reset via the keyboard controller,
-* do not turn off GateA20, as any machine that fails
-* to do the reset here would then end up in no man's land.
-*/
-   outb(IO_KBD + 4, 0xFE);
-   DELAY(50);  /* wait 0.5 sec to see if that did it */
-
-   /*
-* Attempt to force a reset via the Reset Control register at
-* I/O port 0xcf9.  Bit 2 forces a system reset when it
-* transitions from 0 to 1.  Bit 1 selects the type of reset
-* to attempt: 0 selects a "soft" reset, and 1 selects a
-* "hard" reset.  We try a "hard" reset.  The first write sets
-* bit 1 to select a "hard" reset and clears bit 2.  The
-* second write forces a 0 -> 1 transition in bit 2 to trigger
-* a reset.
-*/
-   outb(0xcf9, 0x2);
-   outb(0xcf9, 0x6);
-   DELAY(50);  /* wait 0.5 sec to see if that did it */
-
-   /*
-* Attempt to force a reset via the Fast A20 and Init register
-* at I/O port 0x92.  Bit 1 serves as an alternate A20 gate.
-* Bit 0 asserts INIT# when set to 1.  We are careful to only
-* preserve bit 1 while setting bit 0.  We also must clear bit
-* 0 before setting it if it isn't already clear.
-*/
-   b = inb(0x92);
-   if (b != 0xff) {
-   if ((b & 0x1) != 0)
-   outb(0x92, b & 0xfe);
-   outb(0x92, b | 0x1);
-   DELAY(50);  /* wait 0.5 

Re: svn commit: r327056 - in head/sys: kern sys x86/acpica x86/x86

2018-04-02 Thread Andriy Gapon
On 21/12/2017 11:17, Bruce Evans wrote:
> Author: bde
> Date: Thu Dec 21 09:17:48 2017
> New Revision: 327056
> URL: https://svnweb.freebsd.org/changeset/base/327056
> 
> Log:
>   Use resume_cpus() instead of restart_cpus() to resume from ACPI suspension.

Bruce,

do you plan to merge this to stable/11 and maybe stable/10?
If you'd like, I can do it.  Unless you see any reason not to.

>   restart_cpus() worked well enough by accident.  Before this set of fixes,
>   resume_cpus() used the same cpuset (started_cpus, meaning CPUs directed to
>   restart) as restart_cpus().  resume_cpus() waited for the wrong cpuset
>   (stopped_cpus) to become empty, but since mixtures of stopped and suspended
>   CPUs are not close to working, stopped_cpus must be empty when resuming so
>   the wait is null -- restart_cpus just allows the other CPUs to restart and
>   returns without waiting.
>   
>   Fix resume_cpus() to wait on a non-wrong cpuset for the ACPI case, and
>   add further kludges to try to keep it working for the XEN case.  It
>   was only used for XEN.  It waited on suspended_cpus.  This works for
>   XEN.  However, for ACPI, resuming is a 2-step process.  ACPI has already
>   woken up the other CPUs and removed them from suspended_cpus.  This
>   fix records the move by putting them in a new cpuset resuming_cpus.
>   Waiting on suspended_cpus would give the same null wait as waiting on
>   stopped_cpus.  Wait on resuming_cpus instead.
>   
>   Add a cpuset toresume_cpus to map the CPUs being told to resume to keep
>   this separate from the cpuset started_cpus for mapping the CPUs being told
>   to restart.  Mixtures of stopped and suspended/resuming CPUs are still far
>   from working.  Describe new and some old cpusets in comments.
>   
>   Add further kludges to cpususpend_handler() to try to avoid breaking it
>   for XEN.  XEN doesn't use resumectx(), so it doesn't use the second
>   return path for savectx(), and it goes from the suspended state directly
>   to the restarted state, while ACPI resume goes through the resuming state.
>   Enter the resuming state early for all cases so that resume_cpus can test
>   for being in this state and not have to worry about the intermediate
>   !suspended state for ACPI only.


-- 
Andriy Gapon
___
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: r331875 - in head/sys: amd64/amd64 i386/i386

2018-04-02 Thread Andriy Gapon
Author: avg
Date: Mon Apr  2 08:06:18 2018
New Revision: 331875
URL: https://svnweb.freebsd.org/changeset/base/331875

Log:
  x86 cpu_reset: if failed to switch to BSP proceed to cpu_reset_real
  
  If cpu_reset() is called on an AP and if it somehow fails to wake the
  BSP, then it's better to attempt the reset on the AP than just sit there
  spinning on an unusable and undebuggable system.
  
  MFC after:16 days

Modified:
  head/sys/amd64/amd64/vm_machdep.c
  head/sys/i386/i386/vm_machdep.c

Modified: head/sys/amd64/amd64/vm_machdep.c
==
--- head/sys/amd64/amd64/vm_machdep.c   Mon Apr  2 07:45:13 2018
(r331874)
+++ head/sys/amd64/amd64/vm_machdep.c   Mon Apr  2 08:06:18 2018
(r331875)
@@ -611,13 +611,14 @@ cpu_reset()
ia32_pause();
cnt++;  /* Wait for BSP to announce restart */
}
-   if (cpu_reset_proxy_active == 0)
+   if (cpu_reset_proxy_active == 0) {
printf("cpu_reset: Failed to restart BSP\n");
-   cpu_reset_proxy_active = 2;
-
-   while (1)
-   ia32_pause();
-   /* NOTREACHED */
+   } else {
+   cpu_reset_proxy_active = 2;
+   while (1)
+   ia32_pause();
+   /* NOTREACHED */
+   }
}
 
DELAY(100);

Modified: head/sys/i386/i386/vm_machdep.c
==
--- head/sys/i386/i386/vm_machdep.c Mon Apr  2 07:45:13 2018
(r331874)
+++ head/sys/i386/i386/vm_machdep.c Mon Apr  2 08:06:18 2018
(r331875)
@@ -623,13 +623,14 @@ cpu_reset()
ia32_pause();
cnt++;  /* Wait for BSP to announce restart */
}
-   if (cpu_reset_proxy_active == 0)
+   if (cpu_reset_proxy_active == 0) {
printf("cpu_reset: Failed to restart BSP\n");
-   cpu_reset_proxy_active = 2;
-
-   while (1)
-   ia32_pause();
-   /* NOTREACHED */
+   } else {
+   cpu_reset_proxy_active = 2;
+   while (1)
+   ia32_pause();
+   /* NOTREACHED */
+   }
}
 
DELAY(100);
___
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: r331874 - in head/sys: amd64/amd64 i386/i386

2018-04-02 Thread Andriy Gapon
Author: avg
Date: Mon Apr  2 07:45:13 2018
New Revision: 331874
URL: https://svnweb.freebsd.org/changeset/base/331874

Log:
  x86 cpu_reset_proxy: no need to stop_cpus() the original processor
  
  The processor is "parked" in a spin-loop already and that's sufficient
  for the reset.  There is nothing that stop_cpus() would add here, only
  extra complexity and fragility.
  The original processor does not need to enable interrupts now, in fact,
  it must not do that.
  
  MFC after:2 weeks

Modified:
  head/sys/amd64/amd64/vm_machdep.c
  head/sys/i386/i386/vm_machdep.c

Modified: head/sys/amd64/amd64/vm_machdep.c
==
--- head/sys/amd64/amd64/vm_machdep.c   Mon Apr  2 05:15:25 2018
(r331873)
+++ head/sys/amd64/amd64/vm_machdep.c   Mon Apr  2 07:45:13 2018
(r331874)
@@ -569,14 +569,11 @@ cpu_set_user_tls(struct thread *td, void *tls_base)
 static void
 cpu_reset_proxy()
 {
-   cpuset_t tcrp;
 
cpu_reset_proxy_active = 1;
while (cpu_reset_proxy_active == 1)
ia32_pause(); /* Wait for other cpu to see that we've started */
 
-   CPU_SETOF(cpu_reset_proxyid, &tcrp);
-   stop_cpus(tcrp);
printf("cpu_reset_proxy: Stopped CPU %d\n", cpu_reset_proxyid);
DELAY(100);
cpu_reset_real();
@@ -616,7 +613,6 @@ cpu_reset()
}
if (cpu_reset_proxy_active == 0)
printf("cpu_reset: Failed to restart BSP\n");
-   enable_intr();
cpu_reset_proxy_active = 2;
 
while (1)

Modified: head/sys/i386/i386/vm_machdep.c
==
--- head/sys/i386/i386/vm_machdep.c Mon Apr  2 05:15:25 2018
(r331873)
+++ head/sys/i386/i386/vm_machdep.c Mon Apr  2 07:45:13 2018
(r331874)
@@ -581,14 +581,11 @@ kvtop(void *addr)
 static void
 cpu_reset_proxy()
 {
-   cpuset_t tcrp;
 
cpu_reset_proxy_active = 1;
while (cpu_reset_proxy_active == 1)
ia32_pause(); /* Wait for other cpu to see that we've started */
 
-   CPU_SETOF(cpu_reset_proxyid, &tcrp);
-   stop_cpus(tcrp);
printf("cpu_reset_proxy: Stopped CPU %d\n", cpu_reset_proxyid);
DELAY(100);
cpu_reset_real();
@@ -628,7 +625,6 @@ cpu_reset()
}
if (cpu_reset_proxy_active == 0)
printf("cpu_reset: Failed to restart BSP\n");
-   enable_intr();
cpu_reset_proxy_active = 2;
 
while (1)
___
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: r331761 - head/sys/i386/i386

2018-03-30 Thread Andriy Gapon
Author: avg
Date: Fri Mar 30 11:25:30 2018
New Revision: 331761
URL: https://svnweb.freebsd.org/changeset/base/331761

Log:
  align i386 cpu_reset() with amd64 version
  
  Maybe this code could be moved to x86.
  
  MFC after:1 week

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

Modified: head/sys/i386/i386/vm_machdep.c
==
--- head/sys/i386/i386/vm_machdep.c Fri Mar 30 10:55:31 2018
(r331760)
+++ head/sys/i386/i386/vm_machdep.c Fri Mar 30 11:25:30 2018
(r331761)
@@ -585,7 +585,8 @@ cpu_reset_proxy()
 
cpu_reset_proxy_active = 1;
while (cpu_reset_proxy_active == 1)
-   ;   /* Wait for other cpu to see that we've started */
+   ia32_pause(); /* Wait for other cpu to see that we've started */
+
CPU_SETOF(cpu_reset_proxyid, &tcrp);
stop_cpus(tcrp);
printf("cpu_reset_proxy: Stopped CPU %d\n", cpu_reset_proxyid);
@@ -617,19 +618,21 @@ cpu_reset()
printf("cpu_reset: Restarting BSP\n");
 
/* Restart CPU #0. */
-   /* XXX: restart_cpus(1 << 0); */
CPU_SETOF(0, &started_cpus);
wmb();
 
cnt = 0;
-   while (cpu_reset_proxy_active == 0 && cnt < 1000)
+   while (cpu_reset_proxy_active == 0 && cnt < 1000) {
+   ia32_pause();
cnt++;  /* Wait for BSP to announce restart */
+   }
if (cpu_reset_proxy_active == 0)
printf("cpu_reset: Failed to restart BSP\n");
enable_intr();
cpu_reset_proxy_active = 2;
 
-   while (1);
+   while (1)
+   ia32_pause();
/* NOTREACHED */
}
 
___
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: r331666 - in head/sys: cddl/contrib/opensolaris/uts/common/fs kern sys

2018-03-28 Thread Andriy Gapon
Author: avg
Date: Wed Mar 28 08:55:31 2018
New Revision: 331666
URL: https://svnweb.freebsd.org/changeset/base/331666

Log:
  ZFS vn_rele_async: catch up with the use of refcount(9) for the vnode use 
count
  
  It's not sufficient nor required to use the vnode interlock when
  checking if we are going to drop the last use count as the code in
  vputx() uses refcount (atomic) operations for both checking and
  decrementing the use code.  Apply the same method to vn_rele_async().
  While here, remove vn_rele_inactive(), a wrapper around vrele() that
  didn't add any value.
  
  Also, the change required making vfs_refcount_release_if_not_last()
  public.  I've made vfs_refcount_acquire_if_not_zero() public as well.
  They are in sys/refcount.h now.  While making the move I've dropped the
  vfs_ prefix.
  
  Reviewed by:  mjg
  MFC after:2 weeks
  Sponsored by: Panzura
  Differential Revision: https://reviews.freebsd.org/D14869

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/vnode.c
  head/sys/kern/vfs_subr.c
  head/sys/sys/refcount.h

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/vnode.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/vnode.c Wed Mar 28 
07:59:16 2018(r331665)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/vnode.c Wed Mar 28 
08:55:31 2018(r331666)
@@ -72,12 +72,6 @@ xva_getxoptattr(xvattr_t *xvap)
return (xoap);
 }
 
-static void
-vn_rele_inactive(vnode_t *vp)
-{
-   vrele(vp);
-}
-
 /*
  * Like vn_rele() except if we are going to call VOP_INACTIVE() then do it
  * asynchronously using a taskq. This can avoid deadlocks caused by re-entering
@@ -92,13 +86,10 @@ void
 vn_rele_async(vnode_t *vp, taskq_t *taskq)
 {
VERIFY(vp->v_count > 0);
-   VI_LOCK(vp);
-   if (vp->v_count == 1 && !(vp->v_iflag & VI_DOINGINACT)) {
-   VI_UNLOCK(vp);
-   VERIFY(taskq_dispatch((taskq_t *)taskq,
-   (task_func_t *)vn_rele_inactive, vp, TQ_SLEEP) != 0);
+   if (refcount_release_if_not_last(&vp->v_usecount)) {
+   vdrop(vp);
return;
}
-   refcount_release(&vp->v_usecount);
-   vdropl(vp);
+   VERIFY(taskq_dispatch((taskq_t *)taskq,
+   (task_func_t *)vrele, vp, TQ_SLEEP) != 0);
 }

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cWed Mar 28 07:59:16 2018(r331665)
+++ head/sys/kern/vfs_subr.cWed Mar 28 08:55:31 2018(r331666)
@@ -2455,37 +2455,6 @@ reassignbuf(struct buf *bp)
BO_UNLOCK(bo);
 }
 
-/*
- * A temporary hack until refcount_* APIs are sorted out.
- */
-static __inline int
-vfs_refcount_acquire_if_not_zero(volatile u_int *count)
-{
-   u_int old;
-
-   old = *count;
-   for (;;) {
-   if (old == 0)
-   return (0);
-   if (atomic_fcmpset_int(count, &old, old + 1))
-   return (1);
-   }
-}
-
-static __inline int
-vfs_refcount_release_if_not_last(volatile u_int *count)
-{
-   u_int old;
-
-   old = *count;
-   for (;;) {
-   if (old == 1)
-   return (0);
-   if (atomic_fcmpset_int(count, &old, old - 1))
-   return (1);
-   }
-}
-
 static void
 v_init_counters(struct vnode *vp)
 {
@@ -2524,7 +2493,7 @@ v_incr_usecount(struct vnode *vp)
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
 
if (vp->v_type != VCHR &&
-   vfs_refcount_acquire_if_not_zero(&vp->v_usecount)) {
+   refcount_acquire_if_not_zero(&vp->v_usecount)) {
VNASSERT((vp->v_iflag & VI_OWEINACT) == 0, vp,
("vnode with usecount and VI_OWEINACT set"));
} else {
@@ -2616,7 +2585,7 @@ vget(struct vnode *vp, int flags, struct thread *td)
 * Upgrade our holdcnt to a usecount.
 */
if (vp->v_type == VCHR ||
-   !vfs_refcount_acquire_if_not_zero(&vp->v_usecount)) {
+   !refcount_acquire_if_not_zero(&vp->v_usecount)) {
VI_LOCK(vp);
if ((vp->v_iflag & VI_OWEINACT) == 0) {
oweinact = 0;
@@ -2720,7 +2689,7 @@ vputx(struct vnode *vp, int func)
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
 
if (vp->v_type != VCHR &&
-   vfs_refcount_release_if_not_last(&vp->v_usecount)) {
+   refcount_release_if_not_last(&vp->v_usecount)) {
if (func == VPUTX_VPUT)
VOP_UNLOCK(vp, 0);
vdrop(vp);
@@ -2836,7 +2805,7 @@ _vhold(struct vnode *vp, bool locked)
ASSERT_VI_UNLOCKED(vp, __func__);
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
if (!locked) {
-   if (vfs_refcount_acquire_if_not_zero(&vp->v_holdcnt)) {
+   if (refcount_acquire_if_not_zero

svn commit: r331616 - in head: sbin/mount sys/kern

2018-03-27 Thread Andriy Gapon
Author: avg
Date: Tue Mar 27 14:31:42 2018
New Revision: 331616
URL: https://svnweb.freebsd.org/changeset/base/331616

Log:
  vfs_donmount: in certain cases try r/o mount if r/w mount fails
  
  If the operation is not an update, if neither r/w nor r/o mode is
  explicitly requested, if the error code hints at the possibility of the
  media being read-only, and if the fallback is allowed, then we can try
  to automatically downgrade to the readonly mode.
  
  This is especially useful for auto-mounting of removable media that
  sometimes can happen to be write-protected.
  
  The fallback to r/o is not enabled by default.  It can be requested on a
  per-mount basis with a new mount option, 'autoro'.  Or it can be
  globally allowed by setting vfs.default_autoro.
  
  Reviewed by:  cem, kib
  MFC after:3 weeks
  Relnotes: yes
  Differential Revision: https://reviews.freebsd.org/D13361

Modified:
  head/sbin/mount/mount.8
  head/sys/kern/vfs_mount.c

Modified: head/sbin/mount/mount.8
==
--- head/sbin/mount/mount.8 Tue Mar 27 13:59:57 2018(r331615)
+++ head/sbin/mount/mount.8 Tue Mar 27 14:31:42 2018(r331616)
@@ -155,6 +155,10 @@ This flag indicates that the file system was mounted b
 .Xr automountd 8 .
 Automounted file systems are automatically unmounted by
 .Xr autounmountd 8 .
+.It Cm autoro
+Mount the file system read-write.
+If that fails with an error that suggests that the media could be read-only,
+then automatically try to mount the file system read-only.
 .It Cm current
 When used with the
 .Fl u

Modified: head/sys/kern/vfs_mount.c
==
--- head/sys/kern/vfs_mount.c   Tue Mar 27 13:59:57 2018(r331615)
+++ head/sys/kern/vfs_mount.c   Tue Mar 27 14:31:42 2018(r331616)
@@ -81,6 +81,10 @@ static int   usermount = 0;
 SYSCTL_INT(_vfs, OID_AUTO, usermount, CTLFLAG_RW, &usermount, 0,
 "Unprivileged users may mount and unmount file systems");
 
+static booldefault_autoro = false;
+SYSCTL_BOOL(_vfs, OID_AUTO, default_autoro, CTLFLAG_RW, &default_autoro, 0,
+"Retry failed r/w mount as r/o if no explicit ro/rw option is specified");
+
 MALLOC_DEFINE(M_MOUNT, "mount", "vfs mount structure");
 MALLOC_DEFINE(M_STATFS, "statfs", "statfs structure");
 static uma_zone_t mount_zone;
@@ -546,6 +550,31 @@ vfs_mount_destroy(struct mount *mp)
uma_zfree(mount_zone, mp);
 }
 
+static bool
+vfs_should_downgrade_to_ro_mount(uint64_t fsflags, int error)
+{
+   /* This is an upgrade of an exisiting mount. */
+   if ((fsflags & MNT_UPDATE) != 0)
+   return (false);
+   /* This is already an R/O mount. */
+   if ((fsflags & MNT_RDONLY) != 0)
+   return (false);
+
+   switch (error) {
+   case ENODEV:/* generic, geom, ... */
+   case EACCES:/* cam/scsi, ... */
+   case EROFS: /* md, mmcsd, ... */
+   /*
+* These errors can be returned by the storage layer to signal
+* that the media is read-only.  No harm in the R/O mount
+* attempt if the error was returned for some other reason.
+*/
+   return (true);
+   default:
+   return (false);
+   }
+}
+
 int
 vfs_donmount(struct thread *td, uint64_t fsflags, struct uio *fsoptions)
 {
@@ -553,10 +582,12 @@ vfs_donmount(struct thread *td, uint64_t fsflags, stru
struct vfsopt *opt, *tmp_opt;
char *fstype, *fspath, *errmsg;
int error, fstypelen, fspathlen, errmsg_len, errmsg_pos;
+   bool autoro;
 
errmsg = fspath = NULL;
errmsg_len = fspathlen = 0;
errmsg_pos = -1;
+   autoro = default_autoro;
 
error = vfs_buildopts(fsoptions, &optlist);
if (error)
@@ -648,17 +679,28 @@ vfs_donmount(struct thread *td, uint64_t fsflags, stru
free(opt->name, M_MOUNT);
opt->name = strdup("nonosymfollow", M_MOUNT);
}
-   else if (strcmp(opt->name, "noro") == 0)
+   else if (strcmp(opt->name, "noro") == 0) {
fsflags &= ~MNT_RDONLY;
-   else if (strcmp(opt->name, "rw") == 0)
+   autoro = false;
+   }
+   else if (strcmp(opt->name, "rw") == 0) {
fsflags &= ~MNT_RDONLY;
-   else if (strcmp(opt->name, "ro") == 0)
+   autoro = false;
+   }
+   else if (strcmp(opt->name, "ro") == 0) {
fsflags |= MNT_RDONLY;
+   autoro = false;
+   }
else if (strcmp(opt->name, "rdonly") == 0) {
free(opt->name, M_MOUNT);
opt->name = strdup("ro", M_MOUNT);
fsflags |= MNT_RDONLY;
+

svn commit: r331613 - in head/tests/sys/cddl/zfs: bin include tests/cli_root/zpool_add tests/delegate tests/devices tests/hotspare tests/interop tests/largest_pool tests/slog tests/utils_test tests...

2018-03-27 Thread Andriy Gapon
Author: avg
Date: Tue Mar 27 11:49:15 2018
New Revision: 331613
URL: https://svnweb.freebsd.org/changeset/base/331613

Log:
  ZFS test suite: fix uses of illumos /dev/[r]dsk/ and /dev/zvol/[r]dsk/

Modified:
  head/tests/sys/cddl/zfs/bin/devname2devid.c
  head/tests/sys/cddl/zfs/bin/zpool_bsd.ksh
  head/tests/sys/cddl/zfs/bin/zpool_smi.ksh
  head/tests/sys/cddl/zfs/include/libtest.kshlib
  head/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add.kshlib
  head/tests/sys/cddl/zfs/tests/delegate/delegate_common.kshlib
  head/tests/sys/cddl/zfs/tests/devices/devices_common.kshlib
  head/tests/sys/cddl/zfs/tests/hotspare/hotspare_add_003_neg.ksh
  head/tests/sys/cddl/zfs/tests/hotspare/hotspare_create_001_neg.ksh
  head/tests/sys/cddl/zfs/tests/hotspare/hotspare_remove_002_neg.ksh
  head/tests/sys/cddl/zfs/tests/interop/interop.cfg
  head/tests/sys/cddl/zfs/tests/largest_pool/largest_pool.cfg
  head/tests/sys/cddl/zfs/tests/slog/slog_013_pos.ksh
  head/tests/sys/cddl/zfs/tests/utils_test/utils_test_001_pos.ksh
  head/tests/sys/cddl/zfs/tests/utils_test/utils_test_002_pos.ksh
  head/tests/sys/cddl/zfs/tests/utils_test/utils_test_005_pos.ksh
  head/tests/sys/cddl/zfs/tests/utils_test/utils_test_006_pos.ksh
  head/tests/sys/cddl/zfs/tests/utils_test/utils_test_008_pos.ksh
  head/tests/sys/cddl/zfs/tests/utils_test/utils_test_009_pos.ksh
  head/tests/sys/cddl/zfs/tests/xattr/xattr_004_pos.ksh
  head/tests/sys/cddl/zfs/tests/zones/zones_001_pos.ksh
  head/tests/sys/cddl/zfs/tests/zvol/zvol_common.kshlib
  head/tests/sys/cddl/zfs/tests/zvol/zvol_misc/zvol_misc_001_neg.ksh
  head/tests/sys/cddl/zfs/tests/zvol/zvol_misc/zvol_misc_003_neg.ksh
  head/tests/sys/cddl/zfs/tests/zvol/zvol_misc/zvol_misc_004_pos.ksh
  head/tests/sys/cddl/zfs/tests/zvol/zvol_misc/zvol_misc_005_neg.ksh
  head/tests/sys/cddl/zfs/tests/zvol/zvol_misc/zvol_misc_006_pos.ksh
  head/tests/sys/cddl/zfs/tests/zvol/zvol_swap/cleanup.ksh
  head/tests/sys/cddl/zfs/tests/zvol/zvol_swap/zvol_swap_001_pos.ksh
  head/tests/sys/cddl/zfs/tests/zvol/zvol_swap/zvol_swap_002_pos.ksh
  head/tests/sys/cddl/zfs/tests/zvol/zvol_swap/zvol_swap_003_pos.ksh
  head/tests/sys/cddl/zfs/tests/zvol/zvol_swap/zvol_swap_004_pos.ksh
  head/tests/sys/cddl/zfs/tests/zvol/zvol_swap/zvol_swap_005_pos.ksh
  head/tests/sys/cddl/zfs/tests/zvol/zvol_swap/zvol_swap_006_pos.ksh

Modified: head/tests/sys/cddl/zfs/bin/devname2devid.c
==
--- head/tests/sys/cddl/zfs/bin/devname2devid.c Tue Mar 27 11:34:34 2018
(r331612)
+++ head/tests/sys/cddl/zfs/bin/devname2devid.c Tue Mar 27 11:49:15 2018
(r331613)
@@ -39,11 +39,11 @@
  * Usage: devname2devid 
  *
  * Examples:
- * # ./devname2devid /dev/dsk/c1t4d0s0
+ * # ./devname2devid /dev/c1t4d0s0
  * devid id1,sd@SSEAGATE_ST318404LSUN18G_3BT2G0Z32146G4CR/a
- * # ./devname2devid /dev/dsk/c1t4d0
+ * # ./devname2devid /dev/c1t4d0
  * devid id1,sd@SSEAGATE_ST318404LSUN18G_3BT2G0Z32146G4CR/wd
- * # ./devname2devid /dev/dsk/c1t4d0s1
+ * # ./devname2devid /dev/c1t4d0s1
  * devid id1,sd@SSEAGATE_ST318404LSUN18G_3BT2G0Z32146G4CR/b
  * #
  *
@@ -99,7 +99,7 @@ main(int argc, char *argv[])
if (argc == 3) {
search_path = argv[2];
} else {
-   search_path = "/dev/rdsk";
+   search_path = "/dev/";
}
 
if (devid_deviceid_to_nmlist(search_path, devid, DEVID_MINOR_NAME_ALL,

Modified: head/tests/sys/cddl/zfs/bin/zpool_bsd.ksh
==
--- head/tests/sys/cddl/zfs/bin/zpool_bsd.ksh   Tue Mar 27 11:34:34 2018
(r331612)
+++ head/tests/sys/cddl/zfs/bin/zpool_bsd.ksh   Tue Mar 27 11:49:15 2018
(r331613)
@@ -16,8 +16,8 @@ typeset option
 case $cmd in
create|add|attach|detach|replace|remove|online|offline|clear)
for arg in $@; do
-   if [[ $arg == "/dev/dsk/"* ]]; then
-   arg=${arg#/dev/dsk/}
+   if [[ $arg == "/dev/"* ]]; then
+   arg=${arg#/dev/}
arg="/dev/"$arg
fi
if [[ $arg == "/dev/"* ]]; then

Modified: head/tests/sys/cddl/zfs/bin/zpool_smi.ksh
==
--- head/tests/sys/cddl/zfs/bin/zpool_smi.ksh   Tue Mar 27 11:34:34 2018
(r331612)
+++ head/tests/sys/cddl/zfs/bin/zpool_smi.ksh   Tue Mar 27 11:49:15 2018
(r331613)
@@ -42,7 +42,7 @@ label
 yes
 _EOF
 
-   labeltype=$(/usr/sbin/prtvtoc -fh /dev/rdsk/${disk}s2 | \
+   labeltype=$(/usr/sbin/prtvtoc -fh /dev/${disk}s2 | \
awk '{print $1}' | awk -F= '{print $2}' )
if [[ -z $labeltype ]]; then
print "${disk} not exist."
@@ -61,7 +61,7 @@ _EOF
print "q" >> $label_file
   

svn commit: r331420 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2018-03-23 Thread Andriy Gapon
Author: avg
Date: Fri Mar 23 09:42:47 2018
New Revision: 331420
URL: https://svnweb.freebsd.org/changeset/base/331420

Log:
  zfs: fix mismatch between format specifier and type
  
  vdev_dbgmsg_print_tree printed vdev_id of uint64_t type with %u format
  specifier.  That caused subsequent parameters to be incorrectly read
  from the stack and lead to a crash when a wrong value was interpreted as
  a string pointer.
  
  This should be upstreamed.
  
  Reported by:  pho
  MFC after:3 days

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c  Fri Mar 23 
09:40:41 2018(r331419)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c  Fri Mar 23 
09:42:47 2018(r331420)
@@ -237,7 +237,7 @@ vdev_dbgmsg_print_tree(vdev_t *vd, int indent)
}
 
zfs_dbgmsg("%*svdev %u: %s%s, guid: %llu, path: %s, %s", indent,
-   "", vd->vdev_id, vd->vdev_ops->vdev_op_type,
+   "", (int)vd->vdev_id, vd->vdev_ops->vdev_op_type,
vd->vdev_islog ? " (log)" : "",
(u_longlong_t)vd->vdev_guid,
vd->vdev_path ? vd->vdev_path : "N/A", state);
___
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: r331347 - in head: etc/mtree include sys/conf sys/dev/tcp_log sys/kern sys/netinet usr.bin/netstat

2018-03-22 Thread Andriy Gapon
On 22/03/2018 17:39, Jonathan Looney wrote:
> A tinderbox build didn't complain about atomic_fetchadd_64, so I assume it is 
> OK.
> 
> Yes, this can be made optional, if there is a need for that.
> 

FWWI, TARGET=powerpc TARGET_ARCH=powerpc build failed for me.

cc1: warnings being treated as errors
/usr/devel/svn/head/sys/netinet/tcp_log_buf.c: In function 'tcp_log_selectauto':
/usr/devel/svn/head/sys/netinet/tcp_log_buf.c:286: warning: implicit declaration
of function 'atomic_fetchadd_64'
/usr/devel/svn/head/sys/netinet/tcp_log_buf.c:286: warning: nested extern
declaration of 'atomic_fetchadd_64' [-Wnested-externs]

-- 
Andriy Gapon
___
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: r331209 - head

2018-03-19 Thread Andriy Gapon
On 19/03/2018 18:20, John Baldwin wrote:
> On Monday, March 19, 2018 03:27:53 PM Kyle Evans wrote:
>> Author: kevans
>> Date: Mon Mar 19 15:27:53 2018
>> New Revision: 331209
>> URL: https://svnweb.freebsd.org/changeset/base/331209
>>
>> Log:
>>   Add note to UPDATING about UEFI changes requiring loader(8) update
>>   
>>   These problems have only been observed with boards using U-Boot (e.g. ARM)
>>   where virtual addresses are already set in the memory map by the firmware
>>   and the firmware is expecting a call to SetVirtualAddressMap to be made.
>>   I refrain from mentioning this in the note because this could also be the
>>   case on some not-yet-tested firmware on amd64 and it's not a bad
>>   recommendation for the general case.
> 
> How does this fit with the recommended installation steps of doing
> 'make installkernel' and rebooting before doing a 'make installworld'?

Installation of /boot/loader along with likes of cat and cut has always puzzled
me very much.


-- 
Andriy Gapon
___
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: r331006 - head/share/termcap

2018-03-15 Thread Andriy Gapon
On 15/03/2018 17:13, Baptiste Daroussin wrote:
> Add termcap entries for the st terminal (https://st.sucksless.org)

Just in case anyone else got curious, the correct URL is https://st.suckless.org

-- 
Andriy Gapon
___
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: r331004 - head/tests/sys/cddl/zfs/tests/cli_root/zpool_history

2018-03-15 Thread Andriy Gapon
Author: avg
Date: Thu Mar 15 14:47:53 2018
New Revision: 331004
URL: https://svnweb.freebsd.org/changeset/base/331004

Log:
  zfs test suite: move definition of DISK to the cfg file in zpool_get
  
  The variable is used not only by the setup script but also by the
  atf test bodies.
  
  Another one that should have been in r331001.

Modified:
  head/tests/sys/cddl/zfs/tests/cli_root/zpool_history/setup.ksh
  head/tests/sys/cddl/zfs/tests/cli_root/zpool_history/zpool_history.cfg

Modified: head/tests/sys/cddl/zfs/tests/cli_root/zpool_history/setup.ksh
==
--- head/tests/sys/cddl/zfs/tests/cli_root/zpool_history/setup.ksh  Thu Mar 
15 14:41:09 2018(r331003)
+++ head/tests/sys/cddl/zfs/tests/cli_root/zpool_history/setup.ksh  Thu Mar 
15 14:47:53 2018(r331004)
@@ -31,5 +31,4 @@
 
 . $STF_SUITE/include/libtest.kshlib
 
-DISK=${DISKS%% *}
 default_container_volume_setup $DISK

Modified: head/tests/sys/cddl/zfs/tests/cli_root/zpool_history/zpool_history.cfg
==
--- head/tests/sys/cddl/zfs/tests/cli_root/zpool_history/zpool_history.cfg  
Thu Mar 15 14:41:09 2018(r331003)
+++ head/tests/sys/cddl/zfs/tests/cli_root/zpool_history/zpool_history.cfg  
Thu Mar 15 14:47:53 2018(r331004)
@@ -28,3 +28,5 @@
 #
 
 . $STF_SUITE/tests/cli_root/cli.cfg
+
+export DISK=${DISKS%% *}
___
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: r331003 - head/tests/sys/cddl/zfs/tests/cli_root/zpool_get

2018-03-15 Thread Andriy Gapon
Author: avg
Date: Thu Mar 15 14:41:09 2018
New Revision: 331003
URL: https://svnweb.freebsd.org/changeset/base/331003

Log:
  zfs test suite: add new pool properties / features to the zpool_get list

Modified:
  head/tests/sys/cddl/zfs/tests/cli_root/zpool_get/zpool_get.cfg

Modified: head/tests/sys/cddl/zfs/tests/cli_root/zpool_get/zpool_get.cfg
==
--- head/tests/sys/cddl/zfs/tests/cli_root/zpool_get/zpool_get.cfg  Thu Mar 
15 14:35:46 2018(r331002)
+++ head/tests/sys/cddl/zfs/tests/cli_root/zpool_get/zpool_get.cfg  Thu Mar 
15 14:41:09 2018(r331003)
@@ -53,6 +53,7 @@ typeset -a properties=(
 "freeing"
 "fragmentation"
 "leaked"
+"bootsize"
 "feature@async_destroy"
 "feature@empty_bpobj"
 "feature@lz4_compress"
@@ -68,6 +69,8 @@ typeset -a properties=(
 "feature@sha512"
 "feature@skein"
 # "feature@edonr" Edonr is not yet implemented on FreeBSD
+"feature@device_removal"
+"feature@obsolete_counts"
 )
 
 export DISK=${DISKS%% *}
___
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: r331002 - head/tests/sys/cddl/zfs/tests/cli_root/zpool_get

2018-03-15 Thread Andriy Gapon
Author: avg
Date: Thu Mar 15 14:35:46 2018
New Revision: 331002
URL: https://svnweb.freebsd.org/changeset/base/331002

Log:
  zfs test suite: move definition of DISK to the cfg file in zpool_get
  
  The variable is used not only by the setup script but also by the
  atf test bodies.
  
  This should have been in r331001.

Modified:
  head/tests/sys/cddl/zfs/tests/cli_root/zpool_get/setup.ksh
  head/tests/sys/cddl/zfs/tests/cli_root/zpool_get/zpool_get.cfg

Modified: head/tests/sys/cddl/zfs/tests/cli_root/zpool_get/setup.ksh
==
--- head/tests/sys/cddl/zfs/tests/cli_root/zpool_get/setup.ksh  Thu Mar 15 
14:23:31 2018(r331001)
+++ head/tests/sys/cddl/zfs/tests/cli_root/zpool_get/setup.ksh  Thu Mar 15 
14:35:46 2018(r331002)
@@ -32,6 +32,4 @@
 . ${STF_SUITE}/include/libtest.kshlib
 verify_runnable "both"
 
-DISK=${DISKS%% *}
-
 default_setup $DISK

Modified: head/tests/sys/cddl/zfs/tests/cli_root/zpool_get/zpool_get.cfg
==
--- head/tests/sys/cddl/zfs/tests/cli_root/zpool_get/zpool_get.cfg  Thu Mar 
15 14:23:31 2018(r331001)
+++ head/tests/sys/cddl/zfs/tests/cli_root/zpool_get/zpool_get.cfg  Thu Mar 
15 14:35:46 2018(r331002)
@@ -69,3 +69,5 @@ typeset -a properties=(
 "feature@skein"
 # "feature@edonr" Edonr is not yet implemented on FreeBSD
 )
+
+export DISK=${DISKS%% *}
___
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: r331001 - head/tests/sys/cddl/zfs/tests/cli_root/zpool_export

2018-03-15 Thread Andriy Gapon
Author: avg
Date: Thu Mar 15 14:23:31 2018
New Revision: 331001
URL: https://svnweb.freebsd.org/changeset/base/331001

Log:
  zfs test suite: move definition of DISK to the cfg file in zpool_export
  
  The variable is used not only by the setup script but also by the
  atf test bodies.

Modified:
  head/tests/sys/cddl/zfs/tests/cli_root/zpool_export/setup.ksh
  head/tests/sys/cddl/zfs/tests/cli_root/zpool_export/zpool_export.cfg

Modified: head/tests/sys/cddl/zfs/tests/cli_root/zpool_export/setup.ksh
==
--- head/tests/sys/cddl/zfs/tests/cli_root/zpool_export/setup.ksh   Thu Mar 
15 13:46:28 2018(r331000)
+++ head/tests/sys/cddl/zfs/tests/cli_root/zpool_export/setup.ksh   Thu Mar 
15 14:23:31 2018(r331001)
@@ -31,6 +31,4 @@
 
 . $STF_SUITE/include/libtest.kshlib
 
-DISK=${DISKS%% *}
-
 default_setup $DISK

Modified: head/tests/sys/cddl/zfs/tests/cli_root/zpool_export/zpool_export.cfg
==
--- head/tests/sys/cddl/zfs/tests/cli_root/zpool_export/zpool_export.cfg
Thu Mar 15 13:46:28 2018(r331000)
+++ head/tests/sys/cddl/zfs/tests/cli_root/zpool_export/zpool_export.cfg
Thu Mar 15 14:23:31 2018(r331001)
@@ -30,3 +30,5 @@
 #
 
 . $STF_SUITE/tests/cli_root/cli.cfg
+
+export DISK=${DISKS%% *}
___
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: r330996 - in head/tests/sys/cddl/zfs: include tests/cache tests/cli_root/zpool_add

2018-03-15 Thread Andriy Gapon
Author: avg
Date: Thu Mar 15 12:47:34 2018
New Revision: 330996
URL: https://svnweb.freebsd.org/changeset/base/330996

Log:
  zfs test suite: support device paths with intermediate directories
  
  The code assumed that disks (devices) used for testing are always named
  like /dev/foo, but there is no reason for that restriction and we can
  easily support paths like /dev/stripe/bar.

Modified:
  head/tests/sys/cddl/zfs/include/libtest.kshlib
  head/tests/sys/cddl/zfs/tests/cache/cache.kshlib
  head/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add.kshlib

Modified: head/tests/sys/cddl/zfs/include/libtest.kshlib
==
--- head/tests/sys/cddl/zfs/include/libtest.kshlib  Thu Mar 15 12:44:13 
2018(r330995)
+++ head/tests/sys/cddl/zfs/include/libtest.kshlib  Thu Mar 15 12:47:34 
2018(r330996)
@@ -640,7 +640,7 @@ function wipe_partition_table # [/dev/null 2>&1; then
+   if gpart list ${diskname#/dev/} >/dev/null 2>&1; then
wait_for 5 1 $GPART destroy -F $diskname
else
log_note "No GPT partitions detected on $diskname"

Modified: head/tests/sys/cddl/zfs/tests/cache/cache.kshlib
==
--- head/tests/sys/cddl/zfs/tests/cache/cache.kshlibThu Mar 15 12:44:13 
2018(r330995)
+++ head/tests/sys/cddl/zfs/tests/cache/cache.kshlibThu Mar 15 12:47:34 
2018(r330996)
@@ -90,9 +90,7 @@ function verify_cache_device
 
# Zpool status returns on the device name sans the /dev, so
# if the device contains /dev/ remove it.
-   if [[ $device =~ "^/dev/" ]]; then
-   device=`basename ${device}`
-   fi
+   device=${device#"/dev/"}
 
if [[ $WRAPPER == *"smi"* ]]; then
$ECHO $device | $EGREP "^c[0-F]+([td][0-F]+)+$" > /dev/null 2>&1

Modified: head/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add.kshlib
==
--- head/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add.kshlib   Thu Mar 
15 12:44:13 2018(r330995)
+++ head/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add.kshlib   Thu Mar 
15 12:47:34 2018(r330996)
@@ -55,9 +55,7 @@ function iscontained
for vdev in $@; do
 
 # remove /dev/dsk in vdev if there is
-   $ECHO $vdev | $GREP "^/dev/" >/dev/null 2>&1
-   (( $? == 0 )) && \
-   vdev=${vdev##*/}
+   vdev=${vdev#/dev/}
 
$ZPOOL status "$pool" | $AWK '$1 == vdevname {exit 1}' \
vdevname=$vdev >/dev/null 2>&1
___
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: r330995 - head/tests/sys/cddl/zfs/tests/slog

2018-03-15 Thread Andriy Gapon
Author: avg
Date: Thu Mar 15 12:44:13 2018
New Revision: 330995
URL: https://svnweb.freebsd.org/changeset/base/330995

Log:
  zfs test suite: fix a typo, TESTPOOL vs TESTPOOL2

Modified:
  head/tests/sys/cddl/zfs/tests/slog/slog.kshlib

Modified: head/tests/sys/cddl/zfs/tests/slog/slog.kshlib
==
--- head/tests/sys/cddl/zfs/tests/slog/slog.kshlib  Thu Mar 15 12:42:19 
2018(r330994)
+++ head/tests/sys/cddl/zfs/tests/slog/slog.kshlib  Thu Mar 15 12:44:13 
2018(r330995)
@@ -34,7 +34,7 @@
 function cleanup
 {
poolexists $TESTPOOL && log_must $ZPOOL status $TESTPOOL
-   poolexists $TESTPOOL && log_must $ZPOOL status $TESTPOOL2
+   poolexists $TESTPOOL2 && log_must $ZPOOL status $TESTPOOL2
destroy_pool $TESTPOOL
destroy_pool $TESTPOOL2
 }
___
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"


<    1   2   3   4   5   6   7   8   9   10   >