svn commit: r321678 - head/usr.sbin/prometheus_sysctl_exporter

2017-07-29 Thread Ed Schouten
Author: ed
Date: Sat Jul 29 08:35:07 2017
New Revision: 321678
URL: https://svnweb.freebsd.org/changeset/base/321678

Log:
  Be a bit more liberal about sysctl naming.
  
  On the systems on which I tested this exporter, I never ran into metrics
  that were named in such a way that they couldn't be exported to
  Prometheus metrics directly. Now it turns out that on systems with NUMA,
  the sysctl tree contains metrics named dev.${driver}.${index}.%domain.
  For these metrics, the % in the name is problematic, as Prometheus
  doesn't allow this symbol to be used.
  
  Remove the assertions that were originally put in place to prevent the
  exporter from generating malformed output and add code to deal with it
  accordingly. For metric names, convert any unsupported character to an
  underscore. For label values, perform string escaping.
  
  PR:   https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=221035
  Reported by:  lifanov@

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

Modified: head/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c
==
--- head/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c   
Sat Jul 29 08:24:51 2017(r321677)
+++ head/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c   
Sat Jul 29 08:35:07 2017(r321678)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2016 Nuxi, https://nuxi.nl/
+ * Copyright (c) 2016-2017 Nuxi, https://nuxi.nl/
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -384,11 +385,12 @@ oidname_print(const struct oidname *on, const struct o
label = on->labels;
for (i = 0; i < on->oid.len; ++i) {
if (*label == '\0') {
-   assert(name[strspn(name,
-   "abcdefghijklmnopqrstuvwxyz"
-   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-   "0123456789_")] == '\0');
-   fprintf(fp, "_%s", name);
+   fputc('_', fp);
+   while (*name != '\0') {
+   /* Map unsupported characters to underscores. */
+   fputc(isalnum(*name) ? *name : '_', fp);
+   ++name;
+   }
}
name += strlen(name) + 1;
label += strlen(label) + 1;
@@ -404,15 +406,18 @@ oidname_print(const struct oidname *on, const struct o
separator = '{';
for (i = 0; i < on->oid.len; ++i) {
if (*label != '\0') {
-   assert(name[strspn(name,
-   "abcdefghijklmnopqrstuvwxyz"
-   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-   "0123456789_-")] == '\0');
assert(label[strspn(label,
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789_")] == '\0');
-   fprintf(fp, "%c%s=\"%s\"", separator, label, name);
+   fprintf(fp, "%c%s=\"", separator, label);
+   while (*name != '\0') {
+   /* Escape backslashes and double quotes. */
+   if (*name == '\\' || *name == '"')
+   fputc('\\', fp);
+   fputc(*name++, fp);
+   }
+   fputc('"', fp);
separator = ',';
}
name += strlen(name) + 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: r321679 - head/sys/dev/virtio/network

2017-07-29 Thread Kristof Provost
Author: kp
Date: Sat Jul 29 09:22:48 2017
New Revision: 321679
URL: https://svnweb.freebsd.org/changeset/base/321679

Log:
  vtnet: Support jumbo frames without TSO/GSO
  
  Currently in Virtio driver without TSO/GSO features enabled, the max scatter
  gather segments for the TX path can be 4, which limits the support for 9K 
JUMBO
  frames. 9K JUMBO frames results in more than 4 scatter gather segments and
  virtio driver fails to send the frame down to host OS. With TSO/GSO feature
  enabled max scatter gather segments can be 64, then 9K JUMBO frames are fine,
  this is making virtio driver to support JUMBO frames only with TSO/GSO.
  
  Increasing the VTNET_MIN_TX_SEGS which is the case for non TSO/GSO to 32 to
  support upto 64K JUMBO frames to Host.
  
  Submitted by: Lohith Bellad 
  Reviewed by:  adrian
  Differential Revision:https://reviews.freebsd.org/D8803

Modified:
  head/sys/dev/virtio/network/if_vtnetvar.h

Modified: head/sys/dev/virtio/network/if_vtnetvar.h
==
--- head/sys/dev/virtio/network/if_vtnetvar.h   Sat Jul 29 08:35:07 2017
(r321678)
+++ head/sys/dev/virtio/network/if_vtnetvar.h   Sat Jul 29 09:22:48 2017
(r321679)
@@ -314,7 +314,7 @@ CTASSERT(sizeof(struct vtnet_mac_filter) <= PAGE_SIZE)
 #define VTNET_MRG_RX_SEGS  1
 #define VTNET_MIN_RX_SEGS  2
 #define VTNET_MAX_RX_SEGS  34
-#define VTNET_MIN_TX_SEGS  4
+#define VTNET_MIN_TX_SEGS  32
 #define VTNET_MAX_TX_SEGS  64
 
 /*
___
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: r321684 - head

2017-07-29 Thread Dimitry Andric
Author: dim
Date: Sat Jul 29 12:22:29 2017
New Revision: 321684
URL: https://svnweb.freebsd.org/changeset/base/321684

Log:
  Don't use libc++ when cross-building for gcc arches
  
  Since we imported clang 5.0.0, the version check in Makefile.inc1 which
  checks whether to use libc++ fires even when the compiler for the target
  architecture is gcc 4.2.1.  This is because only X_COMPILER_VERSION is
  checked.  Also check X_COMPILER_TYPE, so it will only use libc++ when an
  external gcc toolchain is used.
  
  Reviewed by:  emaste, rpokala
  MFC after:3 days
  Differential Revision: https://reviews.freebsd.org/D11776

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Sat Jul 29 11:27:54 2017(r321683)
+++ head/Makefile.inc1  Sat Jul 29 12:22:29 2017(r321684)
@@ -624,8 +624,7 @@ XCFLAGS+=   -isystem ${WORLDTMP}/usr/include -L${WORLDTM
 # combined with --sysroot.
 XCFLAGS+=  -B${WORLDTMP}/usr/lib
 # Force using libc++ for external GCC.
-# XXX: This should be checking MK_GNUCXX == no
-.if ${X_COMPILER_VERSION} >= 40800
+.if ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
 XCXXFLAGS+=-isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
-nostdinc++
 .endif
___
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: r321685 - head/sys/sys

2017-07-29 Thread Alexander Motin
Author: mav
Date: Sat Jul 29 13:54:28 2017
New Revision: 321685
URL: https://svnweb.freebsd.org/changeset/base/321685

Log:
  Fix IORDY bits definition.
  
  According to the ATA specs, IORDYDIS should be bit 10, IORDY -- bit 11.
  
  PR:   221049
  Submitted by: aaron.s...@baesystems.com
  MFC after:1 week

Modified:
  head/sys/sys/ata.h

Modified: head/sys/sys/ata.h
==
--- head/sys/sys/ata.h  Sat Jul 29 12:22:29 2017(r321684)
+++ head/sys/sys/ata.h  Sat Jul 29 13:54:28 2017(r321685)
@@ -68,8 +68,8 @@ struct ata_params {
 /*049*/ u_int16_t   capabilities1;
 #define ATA_SUPPORT_DMA 0x0100
 #define ATA_SUPPORT_LBA 0x0200
-#define ATA_SUPPORT_IORDY   0x0400
-#define ATA_SUPPORT_IORDYDIS0x0800
+#define ATA_SUPPORT_IORDYDIS0x0400
+#define ATA_SUPPORT_IORDY   0x0800
 #define ATA_SUPPORT_OVERLAP 0x4000
 
 /*050*/ u_int16_t   capabilities2;
___
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: r320802 - head/etc/rc.d

2017-07-29 Thread Harry Schmalzbauer
 Bezüglich Kristof Provost's Nachricht vom 08.07.2017 11:28 (localtime):
> Author: kp
> Date: Sat Jul  8 09:28:31 2017
> New Revision: 320802
> URL: https://svnweb.freebsd.org/changeset/base/320802
>
> Log:
>   Allow more services to run in vnet jails
>   
>   After some tests, here are the services that run into a vnet jail:
> - defaultroute
> - dhclient
> - ip6addrctl
> - natd
> - pf
> - pfsync
> - pflog (deamon runs, pflog0 interface usable, but /var/log/pflog not 
> filled)
> - rarpd
> - route6d (do nothing anyway because obsolete)
> - routed (do nothing anyway because obsolete)
> - rtsold
> - static_arp
> - static_ndp
>   
>   PR: 220530
>   Submitted by:   oliv...@freebsd.org

Do you (or somebidy else) plan to MFC this, along with r320696?
Valuable "extension" IMHO.

Thanks,

-harry

___
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: r320802 - head/etc/rc.d

2017-07-29 Thread Kristof Provost

On 29 Jul 2017, at 17:20, Harry Schmalzbauer wrote:
 Bezüglich Kristof Provost's Nachricht vom 08.07.2017 11:28 
(localtime):

Author: kp
Date: Sat Jul  8 09:28:31 2017
New Revision: 320802
URL: https://svnweb.freebsd.org/changeset/base/320802

Log:
  Allow more services to run in vnet jails


Do you (or somebidy else) plan to MFC this, along with r320696?
Valuable "extension" IMHO.


I have no plans to, no.

I’m not terribly confident that vnet is sufficiently robust in 
stable/11 to
encourage people to use it.  There are a number of vnet bugs that are 
fixed (or

being worked on) in CURRENT that still affect stable/11.

Regards,
Kristof
___
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: r320802 - head/etc/rc.d

2017-07-29 Thread Harry Schmalzbauer
 Bezüglich Harry Schmalzbauer's Nachricht vom 29.07.2017 17:20 (localtime):
>  Bezüglich Kristof Provost's Nachricht vom 08.07.2017 11:28 (localtime):
>> Author: kp
>> Date: Sat Jul  8 09:28:31 2017
>> New Revision: 320802
>> URL: https://svnweb.freebsd.org/changeset/base/320802
>>
>> Log:
>>   Allow more services to run in vnet jails
>>   
>>   After some tests, here are the services that run into a vnet jail:
>> - defaultroute
>> - dhclient
>> - ip6addrctl
>> - natd
>> - pf
>> - pfsync
>> - pflog (deamon runs, pflog0 interface usable, but /var/log/pflog not 
>> filled)
>> - rarpd
>> - route6d (do nothing anyway because obsolete)
>> - routed (do nothing anyway because obsolete)
>> - rtsold
>> - static_arp
>> - static_ndp
>>   
>>   PR:220530
>>   Submitted by:  oliv...@freebsd.org
> Do you (or somebidy else) plan to MFC this, along with r320696?
Forgot to mention r320618 also.

> Valuable "extension" IMHO.
>
> Thanks,
>
> -harry
>


___
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: r320802 - head/etc/rc.d

2017-07-29 Thread Harry Schmalzbauer
Bezüglich Kristof Provost's Nachricht vom 29.07.2017 17:22 (localtime):
> On 29 Jul 2017, at 17:20, Harry Schmalzbauer wrote:
>>  Bezüglich Kristof Provost's Nachricht vom 08.07.2017 11:28 (localtime):
>>> Author: kp
>>> Date: Sat Jul  8 09:28:31 2017
>>> New Revision: 320802
>>> URL: https://svnweb.freebsd.org/changeset/base/320802
>>>
>>> Log:
>>>   Allow more services to run in vnet jails
>>>
>> Do you (or somebidy else) plan to MFC this, along with r320696?
>> Valuable "extension" IMHO.
>>
> I have no plans to, no.
> 
> I’m not terribly confident that vnet is sufficiently robust in stable/11 to
> encourage people to use it.  There are a number of vnet bugs that are
> fixed (or
> being worked on) in CURRENT that still affect stable/11.

I see, thanks a lot for your quick response.

Haven't used vnet (in production) before stable/11, but palnning to do
so, so I'm prepared to find some of them in the near future. I'm merging
locally and can at least provide testing.

Thanks,

-harry
___
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: r321633 - in head/sys/arm: arm include

2017-07-29 Thread Ian Lepore
On Thu, 2017-07-27 at 23:14 +, Zbigniew Bodek wrote:
> Author: zbb
> Date: Thu Jul 27 23:14:17 2017
> New Revision: 321633
> URL: https://svnweb.freebsd.org/changeset/base/321633
> 
> Log:
>   Fix TEX index acquisition using L2 attributes
>   
>   The TEX index is selected using (TEX0 C B) bits
>   from the L2 descriptor. Use correct index by masking
>   and shifting those bits accordingly.
>   
>   Differential Revision:  https://reviews.freebsd.org/D11703

How did you guys discover this bug, like what were the symptoms?
 Should we consider merging this to 11-stable?

-- Ian
___
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: r321686 - in head/sys: arm/arm compat/linuxkpi/common/src dev/ow sys

2017-07-29 Thread Ian Lepore
Author: ian
Date: Sat Jul 29 17:00:23 2017
New Revision: 321686
URL: https://svnweb.freebsd.org/changeset/base/321686

Log:
  Add inline functions to convert between sbintime_t and decimal time units.
  Use them in some existing code that is vulnerable to roundoff errors.
  
  The existing constant SBT_1NS is a honeypot, luring unsuspecting folks into
  writing code such as long_timeout_ns*SBT_1NS to generate the argument for a
  sleep call.  The actual value of 1ns in sbt units is ~4.3, leading to a
  large roundoff error giving a shorter sleep than expected when multiplying
  by the trucated value of 4 in SBT_1NS.  (The evil honeypot aspect becomes
  clear after you waste a whole day figuring out why your sleeps return early.)

Modified:
  head/sys/arm/arm/mpcore_timer.c
  head/sys/compat/linuxkpi/common/src/linux_hrtimer.c
  head/sys/dev/ow/owc_gpiobus.c
  head/sys/sys/time.h

Modified: head/sys/arm/arm/mpcore_timer.c
==
--- head/sys/arm/arm/mpcore_timer.c Sat Jul 29 13:54:28 2017
(r321685)
+++ head/sys/arm/arm/mpcore_timer.c Sat Jul 29 17:00:23 2017
(r321686)
@@ -351,7 +351,7 @@ attach_et(struct arm_tmr_softc *sc)
sc->et.et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_ONESHOT | 
ET_FLAGS_PERCPU;
sc->et.et_quality = 1000;
sc->et.et_frequency = sc->clkfreq;
-   sc->et.et_min_period = 20 * SBT_1NS;
+   sc->et.et_min_period = nstosbt(20);
sc->et.et_max_period =  2 * SBT_1S;
sc->et.et_start = arm_tmr_start;
sc->et.et_stop = arm_tmr_stop;

Modified: head/sys/compat/linuxkpi/common/src/linux_hrtimer.c
==
--- head/sys/compat/linuxkpi/common/src/linux_hrtimer.c Sat Jul 29 13:54:28 
2017(r321685)
+++ head/sys/compat/linuxkpi/common/src/linux_hrtimer.c Sat Jul 29 17:00:23 
2017(r321686)
@@ -101,8 +101,8 @@ linux_hrtimer_start_range_ns(struct hrtimer *hrtimer, 
 {
 
mtx_lock(&hrtimer->mtx);
-   callout_reset_sbt(&hrtimer->callout, time.tv64 * SBT_1NS,
-   nsec * SBT_1NS, hrtimer_call_handler, hrtimer, 0);
+   callout_reset_sbt(&hrtimer->callout, nstosbt(time.tv64), nstosbt(nsec),
+   hrtimer_call_handler, hrtimer, 0);
hrtimer->flags |= HRTIMER_ACTIVE;
mtx_unlock(&hrtimer->mtx);
 }

Modified: head/sys/dev/ow/owc_gpiobus.c
==
--- head/sys/dev/ow/owc_gpiobus.c   Sat Jul 29 13:54:28 2017
(r321685)
+++ head/sys/dev/ow/owc_gpiobus.c   Sat Jul 29 17:00:23 2017
(r321686)
@@ -295,10 +295,10 @@ owc_gpiobus_read_data(device_t dev, struct ow_timing *
do {
now = sbinuptime();
GETPIN(sc, &sample);
-   } while ((now - then) / SBT_1US < t->t_rdv + 2 && sample == 0);
+   } while (sbttous(now - then) < t->t_rdv + 2 && sample == 0);
critical_exit();
 
-   if ((now - then) / SBT_1NS < t->t_rdv * 1000)
+   if (sbttons(now - then) < t->t_rdv * 1000)
*bit = 1;
else
*bit = 0;

Modified: head/sys/sys/time.h
==
--- head/sys/sys/time.h Sat Jul 29 13:54:28 2017(r321685)
+++ head/sys/sys/time.h Sat Jul 29 17:00:23 2017(r321686)
@@ -128,7 +128,7 @@ bintime_shift(struct bintime *_bt, int _exp)
 #defineSBT_1M  (SBT_1S * 60)
 #defineSBT_1MS (SBT_1S / 1000)
 #defineSBT_1US (SBT_1S / 100)
-#defineSBT_1NS (SBT_1S / 10)
+#defineSBT_1NS (SBT_1S / 10) /* beware rounding, see nstosbt() 
*/
 #defineSBT_MAX 0x7fffLL
 
 static __inline int
@@ -155,6 +155,53 @@ sbttobt(sbintime_t _sbt)
return (_bt);
 }
 
+/*
+ * Decimal<->sbt conversions.  Multiplying or dividing by SBT_1NS results in
+ * large roundoff errors which sbttons() and nstosbt() avoid.  Millisecond and
+ * microsecond functions are also provided for completeness.
+ */
+static __inline int64_t
+sbttons(sbintime_t _sbt)
+{
+
+   return ((10 * _sbt) >> 32);
+}
+
+static __inline sbintime_t
+nstosbt(int64_t _ns)
+{
+
+   return ((_ns * (((uint64_t)1 << 63) / 5) >> 32));
+}
+
+static __inline int64_t
+sbttous(sbintime_t _sbt)
+{
+
+   return ((100 * _sbt) >> 32);
+}
+
+static __inline sbintime_t
+ustosbt(int64_t _us)
+{
+
+   return ((_us * (((uint64_t)1 << 63) / 50) >> 32));
+}
+
+static __inline int64_t
+sbttoms(sbintime_t _sbt)
+{
+
+   return ((1000 * _sbt) >> 32);
+}
+
+static __inline sbintime_t
+mstosbt(int64_t _ms)
+{
+
+   return ((_ms * (((uint64_t)1 << 63) / 500) >> 32));
+}
+
 /*-
  * Background information:
  *
@@ -210,7 +257,7 @@ sbttots(sbintime_t _sbt)
struct timespec _ts;
 
_ts.tv_sec = _sbt >> 32;
-   _ts.tv_nsec = ((uint64_t)10 * (uint32_t)_sbt) >> 

svn commit: r321688 - in head/sys: fs/nfs fs/nfsclient nfs sys

2017-07-29 Thread Rick Macklem
Author: rmacklem
Date: Sat Jul 29 19:52:47 2017
New Revision: 321688
URL: https://svnweb.freebsd.org/changeset/base/321688

Log:
  Add kernel support for the NFS client forced dismount "umount -N" option.
  
  When an NFS mount is hung against an unresponsive NFS server, the "umount -f"
  option can be used to dismount the mount. Unfortunately, "umount -f" gets
  hung as well if a "umount" without "-f" has already been done. Usually,
  this is because of a vnode lock being held by the "umount" for the mounted-on
  vnode.
  This patch adds kernel code so that a new "-N" option can be added to 
"umount",
  allowing it to avoid getting hung for this case.
  It adds two flags. One indicates that a forced dismount is about to happen
  and the other is used, along with setting mnt_data == NULL, to handshake
  with the nfs_unmount() VFS call.
  It includes a slight change to the interface used between the client and
  common NFS modules, so I bumped __FreeBSD_version to ensure both modules are
  rebuilt.
  
  Tested by:pho
  Reviewed by:  kib
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D11735

Modified:
  head/sys/fs/nfs/nfscl.h
  head/sys/fs/nfsclient/nfs_clport.c
  head/sys/fs/nfsclient/nfs_clvfsops.c
  head/sys/fs/nfsclient/nfsmount.h
  head/sys/nfs/nfs_nfssvc.c
  head/sys/nfs/nfssvc.h
  head/sys/sys/param.h

Modified: head/sys/fs/nfs/nfscl.h
==
--- head/sys/fs/nfs/nfscl.h Sat Jul 29 17:30:25 2017(r321687)
+++ head/sys/fs/nfs/nfscl.h Sat Jul 29 19:52:47 2017(r321688)
@@ -60,7 +60,8 @@ struct nfsv4node {
 #defineNFSCL_LEASE(r)  ((r) * 2)
 
 /* This macro checks to see if a forced dismount is about to occur. */
-#defineNFSCL_FORCEDISM(m)  (((m)->mnt_kern_flag & MNTK_UNMOUNTF) 
!= 0)
+#defineNFSCL_FORCEDISM(m)  (((m)->mnt_kern_flag & MNTK_UNMOUNTF) 
!= 0 || \
+(VFSTONFS(m)->nm_privflag & NFSMNTP_FORCEDISM) != 0)
 
 /*
  * These flag bits are used for the argument to nfscl_fillsattr() to

Modified: head/sys/fs/nfsclient/nfs_clport.c
==
--- head/sys/fs/nfsclient/nfs_clport.c  Sat Jul 29 17:30:25 2017
(r321687)
+++ head/sys/fs/nfsclient/nfs_clport.c  Sat Jul 29 19:52:47 2017
(r321688)
@@ -1311,6 +1311,8 @@ nfssvc_nfscl(struct thread *td, struct nfssvc_args *ua
cap_rights_t rights;
char *buf;
int error;
+   struct mount *mp;
+   struct nfsmount *nmp;
 
if (uap->flag & NFSSVC_CBADDSOCK) {
error = copyin(uap->argp, (caddr_t)&nfscbdarg, 
sizeof(nfscbdarg));
@@ -1365,6 +1367,56 @@ nfssvc_nfscl(struct thread *td, struct nfssvc_args *ua
dumpmntopts.ndmnt_blen);
free(buf, M_TEMP);
}
+   } else if (uap->flag & NFSSVC_FORCEDISM) {
+   buf = malloc(MNAMELEN + 1, M_TEMP, M_WAITOK);
+   error = copyinstr(uap->argp, buf, MNAMELEN + 1, NULL);
+   if (error == 0) {
+   nmp = NULL;
+   mtx_lock(&mountlist_mtx);
+   TAILQ_FOREACH(mp, &mountlist, mnt_list) {
+   if (strcmp(mp->mnt_stat.f_mntonname, buf) ==
+   0 && strcmp(mp->mnt_stat.f_fstypename,
+   "nfs") == 0 && mp->mnt_data != NULL) {
+   nmp = VFSTONFS(mp);
+   mtx_lock(&nmp->nm_mtx);
+   if ((nmp->nm_privflag &
+   NFSMNTP_FORCEDISM) == 0) {
+   nmp->nm_privflag |= 
+  (NFSMNTP_FORCEDISM |
+   NFSMNTP_CANCELRPCS);
+   mtx_unlock(&nmp->nm_mtx);
+   } else {
+   nmp = NULL;
+   mtx_unlock(&nmp->nm_mtx);
+   }
+   break;
+   }
+   }
+   mtx_unlock(&mountlist_mtx);
+
+   if (nmp != NULL) {
+   /*
+* Call newnfs_nmcancelreqs() to cause
+* any RPCs in progress on the mount point to
+* fail.
+* This will cause any process waiting for an
+* RPC to complete while holding a vnode lock
+* on the mounted-on vnode (such as "df" or
+* a non-forced "umount") to fa

svn commit: r321689 - head/sbin/umount

2017-07-29 Thread Rick Macklem
Author: rmacklem
Date: Sat Jul 29 20:08:25 2017
New Revision: 321689
URL: https://svnweb.freebsd.org/changeset/base/321689

Log:
  Add a new "-N" option to umount(8), that does a forced dismount of an NFS 
mount
  point.
  
  The new "-N" option does a forced dismount of an NFS mount point, but avoids
  doing any checking of the mounted-on path, so that it will not get hung
  when a vnode lock is held by another hung process on the mounted-on vnode.
  The most common case of this is a "umount" with the "-f" option.
  Other than avoiding checking the mounted-on path, it performs the same
  forced dismount as a successful "umount -f" would do.
  
  This commit includes a content change to the man page.
  
  Tested by:pho
  Reviewed by:  kib
  MFC after:2 weeks
  Relnotes: yes
  Differential Revision:https://reviews.freebsd.org/D11735

Modified:
  head/sbin/umount/umount.8
  head/sbin/umount/umount.c

Modified: head/sbin/umount/umount.8
==
--- head/sbin/umount/umount.8   Sat Jul 29 19:52:47 2017(r321688)
+++ head/sbin/umount/umount.8   Sat Jul 29 20:08:25 2017(r321689)
@@ -28,7 +28,7 @@
 .\" @(#)umount.8   8.2 (Berkeley) 5/8/95
 .\" $FreeBSD$
 .\"
-.Dd September 10, 2016
+.Dd July 25, 2017
 .Dt UMOUNT 8
 .Os
 .Sh NAME
@@ -36,7 +36,7 @@
 .Nd unmount file systems
 .Sh SYNOPSIS
 .Nm
-.Op Fl fnv
+.Op Fl fNnv
 .Ar special ... | node ... | fsid ...
 .Nm
 .Fl a | A
@@ -81,6 +81,15 @@ The root file system cannot be forcibly unmounted.
 For NFS, a forced dismount can take up to 1 minute or more to
 complete against an unresponsive server and may throw away
 data not yet written to the server for this case.
+If a process, such as
+.Nm
+without the
+.Fl f
+flag is hung on an
+.Tn NFS
+mount point, use the
+.Fl N
+flag instead.
 Also, doing a forced dismount of an NFSv3 mount when
 .Xr rpc.lockd 8
 is running is unsafe and can result in a crash.
@@ -94,6 +103,24 @@ option and, unless otherwise specified with the
 option, will only unmount
 .Tn NFS
 file systems.
+.It Fl N
+Do a forced dismount of an
+.Tn NFS
+mount point without checking the mount path.
+This option can only be used with the path to the mount point
+.Ar node
+and the path must be specified exactly as it was at mount time.
+This option is useful when a process is hung waiting for an unresponsive
+.Tn NFS
+server while holding a vnode lock on the mounted-on vnode, such that
+.Nm
+with the
+.Fl f
+flag can't complete.
+Using this option can result in a loss of file updates that have not been
+flushed to the
+.Tn NFS
+server.
 .It Fl n
 Unless the
 .Fl f

Modified: head/sbin/umount/umount.c
==
--- head/sbin/umount/umount.c   Sat Jul 29 19:52:47 2017(r321688)
+++ head/sbin/umount/umount.c   Sat Jul 29 20:08:25 2017(r321689)
@@ -86,13 +86,13 @@ int  xdr_dir (XDR *, char *);
 int
 main(int argc, char *argv[])
 {
-   int all, errs, ch, mntsize, error;
+   int all, errs, ch, mntsize, error, nfsforce, ret;
char **typelist = NULL;
struct statfs *mntbuf, *sfs;
struct addrinfo hints;
 
-   all = errs = 0;
-   while ((ch = getopt(argc, argv, "AaF:fh:nt:v")) != -1)
+   nfsforce = all = errs = 0;
+   while ((ch = getopt(argc, argv, "AaF:fh:Nnt:v")) != -1)
switch (ch) {
case 'A':
all = 2;
@@ -110,6 +110,9 @@ main(int argc, char *argv[])
all = 2;
nfshost = optarg;
break;
+   case 'N':
+   nfsforce = 1;
+   break;
case 'n':
fflag |= MNT_NONBUSY;
break;
@@ -132,12 +135,15 @@ main(int argc, char *argv[])
err(1, "-f and -n are mutually exclusive");
 
/* Start disks transferring immediately. */
-   if ((fflag & (MNT_FORCE | MNT_NONBUSY)) == 0)
+   if ((fflag & (MNT_FORCE | MNT_NONBUSY)) == 0 && nfsforce == 0)
sync();
 
if ((argc == 0 && !all) || (argc != 0 && all))
usage();
 
+   if (nfsforce != 0 && (argc == 0 || nfshost != NULL || typelist != NULL))
+   usage();
+
/* -h implies "-t nfs" if no -t flag. */
if ((nfshost != NULL) && (typelist == NULL))
typelist = makevfslist("nfs");
@@ -175,7 +181,20 @@ main(int argc, char *argv[])
break;
case 0:
for (errs = 0; *argv != NULL; ++argv)
-   if (checkname(*argv, typelist) != 0)
+   if (nfsforce != 0) {
+   /*
+* First do the nfssvc() syscall to shut down
+* the mount point and then do the forced
+* dismount.
+   

Re: svn commit: r321633 - in head/sys/arm: arm include

2017-07-29 Thread Zbigniew Bodek
2017-07-29 18:06 GMT+02:00 Ian Lepore :
> On Thu, 2017-07-27 at 23:14 +, Zbigniew Bodek wrote:
>> Author: zbb
>> Date: Thu Jul 27 23:14:17 2017
>> New Revision: 321633
>> URL: https://svnweb.freebsd.org/changeset/base/321633
>>
>> Log:
>>   Fix TEX index acquisition using L2 attributes
>>
>>   The TEX index is selected using (TEX0 C B) bits
>>   from the L2 descriptor. Use correct index by masking
>>   and shifting those bits accordingly.
>>
>>   Differential Revision:  https://reviews.freebsd.org/D11703
>
> How did you guys discover this bug, like what were the symptoms?

Hello Ian,

We had bug in usage of  pmap_remap_vm_attr() and fixing it didn't help
for the issue so the second bug has been found here.

>  Should we consider merging this to 11-stable?

As far as I know nobody besides Armada38x is using this function in
HEAD and nobody uses it in 11.
You may merge it to 11 though (just for the safety of this code in the future).

>
> -- Ian
___
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: r321633 - in head/sys/arm: arm include

2017-07-29 Thread Ian Lepore
On Sat, 2017-07-29 at 22:11 +0200, Zbigniew Bodek wrote:
> 2017-07-29 18:06 GMT+02:00 Ian Lepore :
> > 
> > On Thu, 2017-07-27 at 23:14 +, Zbigniew Bodek wrote:
> > > 
> > > Author: zbb
> > > Date: Thu Jul 27 23:14:17 2017
> > > New Revision: 321633
> > > URL: https://svnweb.freebsd.org/changeset/base/321633
> > > 
> > > Log:
> > >   Fix TEX index acquisition using L2 attributes
> > > 
> > >   The TEX index is selected using (TEX0 C B) bits
> > >   from the L2 descriptor. Use correct index by masking
> > >   and shifting those bits accordingly.
> > > 
> > >   Differential Revision:  https://reviews.freebsd.org/D11703
> > How did you guys discover this bug, like what were the symptoms?
> Hello Ian,
> 
> We had bug in usage of  pmap_remap_vm_attr() and fixing it didn't
> help
> for the issue so the second bug has been found here.
> 
> > 
> >  Should we consider merging this to 11-stable?
> As far as I know nobody besides Armada38x is using this function in
> HEAD and nobody uses it in 11.
> You may merge it to 11 though (just for the safety of this code in
> the future).

Cool, thanks.  We just imported 11-stable for use at $work, so I want
to start from the most bug-free base we can.  :)

-- Ian

___
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: r321702 - head/tests/sys/geom/class/gate

2017-07-29 Thread Ngie Cooper
Author: ngie
Date: Sat Jul 29 22:01:17 2017
New Revision: 321702
URL: https://svnweb.freebsd.org/changeset/base/321702

Log:
  Load geom_gate(4) if necessary before running tests; skip if it can't be 
loaded
  
  The test code prior to r311893 loaded geom_gate at test start if necessary and
  skipped the tests if it couldn't be loaded.
  
  The ATF-ifcation of this test done in r311893 unfortunately dropped this
  functionality.
  
  This change restores the geom_gate module load and skips the test(s) if 
unavailable
  in an ATF-like way.
  
  MFC after:1 month
  PR:   220164
  Reported by:  gjb

Modified:
  head/tests/sys/geom/class/gate/ggate_test.sh

Modified: head/tests/sys/geom/class/gate/ggate_test.sh
==
--- head/tests/sys/geom/class/gate/ggate_test.shSat Jul 29 21:31:54 
2017(r321701)
+++ head/tests/sys/geom/class/gate/ggate_test.shSat Jul 29 22:01:17 
2017(r321702)
@@ -16,6 +16,8 @@ ggated_head()
 
 ggated_body()
 {
+   load_ggate
+
us=$(alloc_ggate_dev)
work=$(alloc_md)
src=$(alloc_md)
@@ -57,6 +59,8 @@ ggatel_file_head()
 
 ggatel_file_body()
 {
+   load_ggate
+
us=$(alloc_ggate_dev)
 
echo src work >> ${PLAINFILES}
@@ -91,6 +95,8 @@ ggatel_md_head()
 
 ggatel_md_body()
 {
+   load_ggate
+
us=$(alloc_ggate_dev)
work=$(alloc_md)
src=$(alloc_md)
@@ -193,6 +199,19 @@ common_cleanup()
rm md.devs
fi
true
+}
+
+load_ggate()
+{
+   local class=gate
+
+   # If the geom class isn't already loaded, try loading it.
+   if ! kldstat -q -m g_${class}; then
+   if ! geom ${class} load; then
+   atf_skip "could not load module for geom class=${class}"
+   exit 0
+   fi
+   fi
 }
 
 # Bug 204616: ggatel(8) creates /dev/ggate* asynchronously if `ggatel create`
___
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: r321703 - head/tests/sys/geom/class/gate

2017-07-29 Thread Ngie Cooper
Author: ngie
Date: Sat Jul 29 22:03:21 2017
New Revision: 321703
URL: https://svnweb.freebsd.org/changeset/base/321703

Log:
  Remove superfluous `exit 0` added in r321702
  
  atf_skip triggers equivalent functionality, which means the `exit 0`
  is unreachable code.
  
  PR:   220164
  MFC after:1 month
  MFC with: r321702

Modified:
  head/tests/sys/geom/class/gate/ggate_test.sh

Modified: head/tests/sys/geom/class/gate/ggate_test.sh
==
--- head/tests/sys/geom/class/gate/ggate_test.shSat Jul 29 22:01:17 
2017(r321702)
+++ head/tests/sys/geom/class/gate/ggate_test.shSat Jul 29 22:03:21 
2017(r321703)
@@ -209,7 +209,6 @@ load_ggate()
if ! kldstat -q -m g_${class}; then
if ! geom ${class} load; then
atf_skip "could not load module for geom class=${class}"
-   exit 0
fi
fi
 }
___
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: r321704 - head/lib/libprocstat

2017-07-29 Thread Ngie Cooper
Author: ngie
Date: Sat Jul 29 22:16:05 2017
New Revision: 321704
URL: https://svnweb.freebsd.org/changeset/base/321704

Log:
  Add sys/socket.h to SYNOPSIS for libprocstat(3)
  
  sys/socket.h is required for procstat_get_socket_info(3), added in
  r221807.
  
  MFC after:1 month
  PR:   217884
  Submitted by: tobik

Modified:
  head/lib/libprocstat/libprocstat.3

Modified: head/lib/libprocstat/libprocstat.3
==
--- head/lib/libprocstat/libprocstat.3  Sat Jul 29 22:03:21 2017
(r321703)
+++ head/lib/libprocstat/libprocstat.3  Sat Jul 29 22:16:05 2017
(r321704)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 27, 2017
+.Dd July 29, 2017
 .Dt LIBPROCSTAT 3
 .Os
 .Sh NAME
@@ -66,6 +66,7 @@
 .Sh SYNOPSIS
 .In sys/param.h
 .In sys/queue.h
+.In sys/socket.h
 .In libprocstat.h
 .Ft void
 .Fn procstat_close "struct procstat *procstat"
___
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: r321705 - head/lib/libprocstat

2017-07-29 Thread Ngie Cooper
Author: ngie
Date: Sat Jul 29 22:19:00 2017
New Revision: 321705
URL: https://svnweb.freebsd.org/changeset/base/321705

Log:
  libprocstat(3): fix reference (typo) to procstat_freeenvv in description for
  procstat_getargv(3)
  
  PR:   217884
  MFC after:1 month
  Submitted by: tobik

Modified:
  head/lib/libprocstat/libprocstat.3

Modified: head/lib/libprocstat/libprocstat.3
==
--- head/lib/libprocstat/libprocstat.3  Sat Jul 29 22:16:05 2017
(r321704)
+++ head/lib/libprocstat/libprocstat.3  Sat Jul 29 22:19:00 2017
(r321705)
@@ -379,7 +379,7 @@ function is similar to
 .Fn procstat_getargv
 but returns the vector of environment strings.
 The caller may free the allocated memory with a subsequent
-.Fn procstat_freeenv
+.Fn procstat_freeenvv
 function call.
 .Pp
 The
___
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: r321706 - head/lib/libprocstat

2017-07-29 Thread Ngie Cooper
Author: ngie
Date: Sat Jul 29 22:25:45 2017
New Revision: 321706
URL: https://svnweb.freebsd.org/changeset/base/321706

Log:
  libprocstat(3): fix arguments list for procstat_getargv(3) and 
procstat_getenvv(3)
  
  Neither libcall takes a fourth argument (`char *errbuf`).
  
  PR:   217884
  Submitted by: tobik
  MFC after:1 month

Modified:
  head/lib/libprocstat/libprocstat.3

Modified: head/lib/libprocstat/libprocstat.3
==
--- head/lib/libprocstat/libprocstat.3  Sat Jul 29 22:19:00 2017
(r321705)
+++ head/lib/libprocstat/libprocstat.3  Sat Jul 29 22:25:45 2017
(r321706)
@@ -157,7 +157,6 @@
 .Fa "struct procstat *procstat"
 .Fa "const struct kinfo_proc *kp"
 .Fa "size_t nchr"
-.Fa "char *errbuf"
 .Fc
 .Ft "Elf_Auxinfo *"
 .Fo procstat_getauxv
@@ -170,7 +169,6 @@
 .Fa "struct procstat *procstat"
 .Fa "const struct kinfo_proc *kp"
 .Fa "size_t nchr"
-.Fa "char *errbuf"
 .Fc
 .Ft "struct filestat_list *"
 .Fo procstat_getfiles
___
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: r321707 - head/sys/kern

2017-07-29 Thread Conrad Meyer
Author: cem
Date: Sat Jul 29 23:31:21 2017
New Revision: 321707
URL: https://svnweb.freebsd.org/changeset/base/321707

Log:
  kldstat: Use sizeof in place of named constants for sizing
  
  No functional change.
  
  This is handy for FreeBSD derivatives that want to modify the value of
  MAXPATHLEN, but not the kld_file_stat ABI.
  
  Submitted by: Siddhant Agarwal 
  Sponsored by: Dell EMC Isilon

Modified:
  head/sys/kern/kern_linker.c

Modified: head/sys/kern/kern_linker.c
==
--- head/sys/kern/kern_linker.c Sat Jul 29 22:25:45 2017(r321706)
+++ head/sys/kern/kern_linker.c Sat Jul 29 23:31:21 2017(r321707)
@@ -1243,8 +1243,8 @@ kern_kldstat(struct thread *td, int fileid, struct kld
 
/* Version 1 fields: */
namelen = strlen(lf->filename) + 1;
-   if (namelen > MAXPATHLEN)
-   namelen = MAXPATHLEN;
+   if (namelen > sizeof(stat->name))
+   namelen = sizeof(stat->name);
bcopy(lf->filename, &stat->name[0], namelen);
stat->refs = lf->refs;
stat->id = lf->id;
@@ -1252,8 +1252,8 @@ kern_kldstat(struct thread *td, int fileid, struct kld
stat->size = lf->size;
/* Version 2 fields: */
namelen = strlen(lf->pathname) + 1;
-   if (namelen > MAXPATHLEN)
-   namelen = MAXPATHLEN;
+   if (namelen > sizeof(stat->pathname))
+   namelen = sizeof(stat->pathname);
bcopy(lf->pathname, &stat->pathname[0], namelen);
sx_xunlock(&kld_sx);
 
___
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: r321708 - in head/sys: conf dev/iicbus

2017-07-29 Thread Ian Lepore
Author: ian
Date: Sat Jul 29 23:45:57 2017
New Revision: 321708
URL: https://svnweb.freebsd.org/changeset/base/321708

Log:
  Replace the pcf8563 i2c RTC driver with a new nxprtc driver which handles
  all the chips in the NXP PCA212x and PCA/PCF85xx series.  In addition to
  supporting more chips, this driver uses the countdown timer on the chips as
  a fractional seconds counter, giving it a resolution of about 15 milliseconds.

Added:
  head/sys/dev/iicbus/nxprtc.c   (contents, props changed)
Deleted:
  head/sys/dev/iicbus/pcf8563.c
  head/sys/dev/iicbus/pcf8563reg.h
Modified:
  head/sys/conf/files

Modified: head/sys/conf/files
==
--- head/sys/conf/files Sat Jul 29 23:31:21 2017(r321707)
+++ head/sys/conf/files Sat Jul 29 23:45:57 2017(r321708)
@@ -1737,8 +1737,8 @@ dev/iicbus/iicsmb.c   optional iicsmb 
\
dependency  "iicbus_if.h"
 dev/iicbus/iicoc.c optional iicoc
 dev/iicbus/lm75.c  optional lm75
+dev/iicbus/nxprtc.coptional nxprtc | pcf8563
 dev/iicbus/ofw_iicbus.coptional fdt iicbus
-dev/iicbus/pcf8563.c   optional pcf8563
 dev/iicbus/s35390a.c   optional s35390a
 dev/iir/iir.c  optional iir
 dev/iir/iir_ctrl.c optional iir

Added: head/sys/dev/iicbus/nxprtc.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/iicbus/nxprtc.cSat Jul 29 23:45:57 2017
(r321708)
@@ -0,0 +1,787 @@
+/*-
+ * Copyright (c) 2017 Ian Lepore 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+/*
+ * Driver for NXP real-time clock/calendar chips:
+ *  - PCF8563 = low power, countdown timer
+ *  - PCA8565 = like PCF8563, automotive temperature range
+ *  - PCF8523 = low power, countdown timer, oscillator freq tuning, 2 timers
+ *  - PCF2127 = like PCF8523, industrial, tcxo, tamper/ts, i2c & spi, 512B ram
+ *  - PCA2129 = like PCF8523, automotive, tcxo, tamper/ts, i2c & spi, no timer
+ *  - PCF2129 = like PCF8523, industrial, tcxo, tamper/ts, i2c & spi, no timer
+ *
+ *  Most chips have a countdown timer, ostensibly intended to generate periodic
+ *  interrupt signals on an output pin.  The timer is driven from the same
+ *  divider chain that clocks the time of day registers, and they start 
counting
+ *  in sync when the STOP bit is cleared after the time and timer registers are
+ *  set.  The timer register can also be read on the fly, so we use it to count
+ *  fractional seconds and get a resolution of ~15ms.
+ */
+
+#include "opt_platform.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#ifdef FDT
+#include 
+#include 
+#include 
+#endif
+
+#include "clock_if.h"
+#include "iicbus_if.h"
+
+/*
+ * I2C address 1010 001x : PCA2129 PCF2127 PCF2129 PCF8563 PCF8565
+ * I2C address 1101 000x : PCF8523
+ */
+#definePCF8563_ADDR0xa2
+#definePCF8523_ADDR0xd0
+
+/*
+ * Registers, bits within them, and masks that are common to all chip types.
+ */
+#definePCF85xx_R_CS1   0x00/* CS1 and CS2 control regs are 
in */
+#definePCF85xx_R_CS2   0x01/* the same location on all 
chips. */
+
+#definePCF85xx_B_CS1_STOP  0x20/* Stop time incrementing bit */
+#definePCF85xx_B_SECOND_OS 0x80/* Oscillator Stopped bit */
+
+#definePCF85xx_M_SECOND0x7f/* Masks for all BCD time 
regs... */
+#define

svn commit: r321709 - head/sys/dev/iicbus

2017-07-29 Thread Ian Lepore
Author: ian
Date: Sun Jul 30 00:00:30 2017
New Revision: 321709
URL: https://svnweb.freebsd.org/changeset/base/321709

Log:
  Fix building this driver on non-FDT platforms.

Modified:
  head/sys/dev/iicbus/ds1307.c

Modified: head/sys/dev/iicbus/ds1307.c
==
--- head/sys/dev/iicbus/ds1307.cSat Jul 29 23:45:57 2017
(r321708)
+++ head/sys/dev/iicbus/ds1307.cSun Jul 30 00:00:30 2017
(r321709)
@@ -299,8 +299,10 @@ ds1307_attach(device_t dev)
sc->enum_hook.ich_func = ds1307_start;
sc->enum_hook.ich_arg = dev;
 
+#ifdef FDT
if (ofw_bus_is_compatible(dev, "microchip,mcp7941x"))
sc->sc_mcp7941x = 1;
+#endif
 
/*
 * We have to wait until interrupts are enabled.  Usually I2C read
___
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: r321710 - head/sys/conf

2017-07-29 Thread Ian Lepore
Author: ian
Date: Sun Jul 30 00:01:31 2017
New Revision: 321710
URL: https://svnweb.freebsd.org/changeset/base/321710

Log:
  Add a few missing i2c devices that build fine on all arches.

Modified:
  head/sys/conf/NOTES

Modified: head/sys/conf/NOTES
==
--- head/sys/conf/NOTES Sun Jul 30 00:00:30 2017(r321709)
+++ head/sys/conf/NOTES Sun Jul 30 00:01:31 2017(r321710)
@@ -2523,14 +2523,24 @@ device  iicoc   # OpenCores I2C 
controller support
 
 # I2C peripheral devices
 #
+# ds1307   Dallas Semiconductor DS1307 RTC and compatible
 # ds133x   Dallas Semiconductor DS1337, DS1338 and DS1339 RTC
 # ds1374   Dallas Semiconductor DS1374 RTC
 # ds1672   Dallas Semiconductor DS1672 RTC
+# ds3231   Dallas Semiconductor DS3231 RTC + temperature
+# icee AT24Cxxx and compatible EEPROMs
+# lm75 LM75 compatible temperature sensor
+# nxprtc   NXP RTCs: PCA2129 PCA8565 PCF2127 PCF2129 PCF8523 PCF8563
 # s35390a  Seiko Instruments S-35390A RTC
 #
+device ds1307
 device ds133x
 device ds1374
 device ds1672
+device ds3231
+device icee
+device lm75
+device nxprtc
 device s35390a
 
 # Parallel-Port Bus
___
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: r321711 - head/sys/conf

2017-07-29 Thread Ian Lepore
Author: ian
Date: Sun Jul 30 00:24:15 2017
New Revision: 321711
URL: https://svnweb.freebsd.org/changeset/base/321711

Log:
  Move the device descriptions onto the device lines, so they cut and paste
  nicely into other config files.

Modified:
  head/sys/conf/NOTES

Modified: head/sys/conf/NOTES
==
--- head/sys/conf/NOTES Sun Jul 30 00:01:31 2017(r321710)
+++ head/sys/conf/NOTES Sun Jul 30 00:24:15 2017(r321711)
@@ -2523,25 +2523,15 @@ device  iicoc   # OpenCores I2C 
controller support
 
 # I2C peripheral devices
 #
-# ds1307   Dallas Semiconductor DS1307 RTC and compatible
-# ds133x   Dallas Semiconductor DS1337, DS1338 and DS1339 RTC
-# ds1374   Dallas Semiconductor DS1374 RTC
-# ds1672   Dallas Semiconductor DS1672 RTC
-# ds3231   Dallas Semiconductor DS3231 RTC + temperature
-# icee AT24Cxxx and compatible EEPROMs
-# lm75 LM75 compatible temperature sensor
-# nxprtc   NXP RTCs: PCA2129 PCA8565 PCF2127 PCF2129 PCF8523 PCF8563
-# s35390a  Seiko Instruments S-35390A RTC
-#
-device ds1307
-device ds133x
-device ds1374
-device ds1672
-device ds3231
-device icee
-device lm75
-device nxprtc
-device s35390a
+device ds1307  # Dallas DS1307 RTC and compatible
+device ds133x  # Dallas DS1337, DS1338 and DS1339 RTC
+device ds1374  # Dallas DS1374 RTC
+device ds1672  # Dallas DS1672 RTC
+device ds3231  # Dallas DS3231 RTC + temperature
+device icee# AT24Cxxx and compatible EEPROMs
+device lm75# LM75 compatible temperature sensor
+device nxprtc  # NXP RTCs: PCA/PFC212x PCA/PCF85xx
+device s35390a # Seiko Instruments S-35390A RTC
 
 # Parallel-Port Bus
 #
___
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: r321712 - head/sys/arm/conf

2017-07-29 Thread Ian Lepore
Author: ian
Date: Sun Jul 30 00:25:29 2017
New Revision: 321712
URL: https://svnweb.freebsd.org/changeset/base/321712

Log:
  Add the i2c RTC drivers found on various arm systems.

Modified:
  head/sys/arm/conf/GENERIC

Modified: head/sys/arm/conf/GENERIC
==
--- head/sys/arm/conf/GENERIC   Sun Jul 30 00:24:15 2017(r321711)
+++ head/sys/arm/conf/GENERIC   Sun Jul 30 00:25:29 2017(r321712)
@@ -128,15 +128,22 @@ devicep2wi# Allwinner 
Push-Pull Two Wire
 device axp209  # AXP209 Power Management Unit
 device axp81x  # AXP813/818 Power Management Unit
 device bcm2835_bsc
-device icee
+device icee# AT24Cxxx and compatible EEPROMs
 device sy8106a # SY8106A Buck Regulator
 device ti_i2c
 device am335x_pmic # AM335x Power Management IC (TPC65217)
 device am335x_rtc  # RTC support (power management only)
-#defineam335x_dmtpps   # Pulse Per Second capture driver
 device twl # TI TWLX0X0/TPS659x0 Power Management
 device twl_vreg# twl voltage regulation
 device twl_clks# twl external clocks
+
+# i2c RTCs
+device ds1307  # Dallas DS1307 RTC and compatible
+device ds133x  # Dallas DS1337, DS1338 and DS1339 RTC
+device ds1672  # Dallas DS1672 RTC
+device ds3231  # Dallas DS3231 RTC + temperature
+device nxprtc  # NXP RTCs: PCA/PFC212x PCA/PCF85xx
+device s35390a # Seiko Instruments S-35390A RTC
 
 # GPIO
 device gpio
___
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: r321713 - head/sys/sys

2017-07-29 Thread Xin LI
Author: delphij
Date: Sun Jul 30 06:27:32 2017
New Revision: 321713
URL: https://svnweb.freebsd.org/changeset/base/321713

Log:
  Bump copyright year.
  
  MFC after:3 days

Modified:
  head/sys/sys/copyright.h

Modified: head/sys/sys/copyright.h
==
--- head/sys/sys/copyright.hSun Jul 30 00:25:29 2017(r321712)
+++ head/sys/sys/copyright.hSun Jul 30 06:27:32 2017(r321713)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (C) 1992-2016 The FreeBSD Project. All rights reserved.
+ * Copyright (C) 1992-2017 The FreeBSD Project. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
___
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: r321714 - in head/sys/dev: mpr mps

2017-07-29 Thread Scott Long
Author: scottl
Date: Sun Jul 30 06:53:58 2017
New Revision: 321714
URL: https://svnweb.freebsd.org/changeset/base/321714

Log:
  Split the interrupt setup code into two parts: allocation and 
configuration.
  Do the allocation before requesting the IOCFacts message.  This triggers
  the LSI firmware to recognize the multiqueue should be enabled if 
available.
  Multiqueue isn't used by the driver yet, but this also fixes a problem 
with
  the cached IOCFacts not matching latter checks, leading to potential 
problems
  with error recovery.
  
  As a side-effect, fetch the driver tunables as early as possible.
  
  Reviewed by:  slm
  Obtained from:Netflix
  Differential Revision:D9243

Modified:
  head/sys/dev/mpr/mpr.c
  head/sys/dev/mpr/mpr_pci.c
  head/sys/dev/mpr/mprvar.h
  head/sys/dev/mps/mps.c
  head/sys/dev/mps/mps_pci.c
  head/sys/dev/mps/mpsvar.h

Modified: head/sys/dev/mpr/mpr.c
==
--- head/sys/dev/mpr/mpr.c  Sun Jul 30 06:27:32 2017(r321713)
+++ head/sys/dev/mpr/mpr.c  Sun Jul 30 06:53:58 2017(r321714)
@@ -1482,7 +1482,7 @@ mpr_init_queues(struct mpr_softc *sc)
  * Next are the global settings, if they exist.  Highest are the per-unit
  * settings, if they exist.
  */
-static void
+void
 mpr_get_tunables(struct mpr_softc *sc)
 {
char tmpstr[80];
@@ -1657,8 +1657,6 @@ int
 mpr_attach(struct mpr_softc *sc)
 {
int error;
-
-   mpr_get_tunables(sc);
 
MPR_FUNCTRACE(sc);
 

Modified: head/sys/dev/mpr/mpr_pci.c
==
--- head/sys/dev/mpr/mpr_pci.c  Sun Jul 30 06:27:32 2017(r321713)
+++ head/sys/dev/mpr/mpr_pci.c  Sun Jul 30 06:53:58 2017(r321714)
@@ -69,6 +69,7 @@ static intmpr_pci_resume(device_t);
 static voidmpr_pci_free(struct mpr_softc *);
 static int mpr_alloc_msix(struct mpr_softc *sc, int msgs);
 static int mpr_alloc_msi(struct mpr_softc *sc, int msgs);
+static int mpr_pci_alloc_interrupts(struct mpr_softc *sc);
 
 static device_method_t mpr_methods[] = {
DEVMETHOD(device_probe, mpr_pci_probe),
@@ -191,6 +192,8 @@ mpr_pci_attach(device_t dev)
m = mpr_find_ident(dev);
sc->mpr_flags = m->flags;
 
+   mpr_get_tunables(sc);
+
/* Twiddle basic PCI config bits for a sanity check */
pci_enable_busmaster(dev);
 
@@ -240,28 +243,51 @@ mpr_pci_attach(device_t dev)
return (ENOMEM);
}
 
-   if ((error = mpr_attach(sc)) != 0)
+   if (((error = mpr_pci_alloc_interrupts(sc)) != 0) ||
+   ((error = mpr_attach(sc)) != 0))
mpr_pci_free(sc);
 
return (error);
 }
 
+/*
+ * Allocate, but don't assign interrupts early.  Doing it before requesting
+ * the IOCFacts message informs the firmware that we want to do MSI-X
+ * multiqueue.  We might not use all of the available messages, but there's
+ * no reason to re-alloc if we don't.
+ */
 int
-mpr_pci_setup_interrupts(struct mpr_softc *sc)
+mpr_pci_alloc_interrupts(struct mpr_softc *sc)
 {
device_t dev;
-   int i, error, msgs;
+   int error, msgs;
 
dev = sc->mpr_dev;
-   error = ENXIO;
+   error = 0;
+
if ((sc->disable_msix == 0) &&
((msgs = pci_msix_count(dev)) >= MPR_MSI_COUNT))
error = mpr_alloc_msix(sc, MPR_MSI_COUNT);
if ((error != 0) && (sc->disable_msi == 0) &&
((msgs = pci_msi_count(dev)) >= MPR_MSI_COUNT))
error = mpr_alloc_msi(sc, MPR_MSI_COUNT);
+   else
+   msgs = 0;
 
-   if (error != 0) {
+   sc->msi_msgs = msgs;
+   return (error);
+}
+
+int
+mpr_pci_setup_interrupts(struct mpr_softc *sc)
+{
+   device_t dev;
+   int i, error;
+
+   dev = sc->mpr_dev;
+   error = ENXIO;
+
+   if (sc->msi_msgs == 0) {
sc->mpr_flags |= MPR_FLAGS_INTX;
sc->mpr_irq_rid[0] = 0;
sc->mpr_irq[0] = bus_alloc_resource_any(dev, SYS_RES_IRQ,

Modified: head/sys/dev/mpr/mprvar.h
==
--- head/sys/dev/mpr/mprvar.h   Sun Jul 30 06:27:32 2017(r321713)
+++ head/sys/dev/mpr/mprvar.h   Sun Jul 30 06:53:58 2017(r321714)
@@ -278,6 +278,7 @@ struct mpr_softc {
u_int   mpr_debug;
u_int   disable_msix;
u_int   disable_msi;
+   int msi_msgs;
u_int   atomic_desc_capable;
int tm_cmds_active;
int io_cmds_active;
@@ -702,6 +703,7 @@ mpr_unmask_intr(struct mpr_softc *sc)
 int mpr_pci_setup_interrupts(struct mpr_softc *sc);
 int mpr_pci_restore(struct mpr_softc *sc);
 
+void mpr_get_tunables(struct