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

2017-12-21 Thread Bruce Evans
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.
  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.
  
  Reviewed by:  kib

Modified:
  head/sys/kern/subr_smp.c
  head/sys/sys/smp.h
  head/sys/x86/acpica/acpi_wakeup.c
  head/sys/x86/x86/mp_x86.c

Modified: head/sys/kern/subr_smp.c
==
--- head/sys/kern/subr_smp.cThu Dec 21 04:23:00 2017(r327055)
+++ head/sys/kern/subr_smp.cThu Dec 21 09:17:48 2017(r327056)
@@ -351,13 +351,18 @@ generic_restart_cpus(cpuset_t map, u_int type)
 
 #if X86
if (type == IPI_SUSPEND)
-   cpus = &suspended_cpus;
+   cpus = &resuming_cpus;
else
 #endif
cpus = &stopped_cpus;
 
/* signal other cpus to restart */
-   CPU_COPY_STORE_REL(&map, &started_cpus);
+#if X86
+   if (type == IPI_SUSPEND)
+   CPU_COPY_STORE_REL(&map, &toresume_cpus);
+   else
+#endif
+   CPU_COPY_STORE_REL(&map, &started_cpus);
 
 #if X86
if (!nmi_is_broadcast || nmi_kdb_lock == 0) {

Modified: head/sys/sys/smp.h
==
--- head/sys/sys/smp.h  Thu Dec 21 04:23:00 2017(r327055)
+++ head/sys/sys/smp.h  Thu Dec 21 09:17:48 2017(r327056)
@@ -155,10 +155,13 @@ struct cpu_group *smp_topo_find(struct cpu_group *top,
 
 extern void (*cpustop_restartfunc)(void);
 extern int smp_cpus;
-extern volatile cpuset_t started_cpus;
-extern volatile cpuset_t stopped_cpus;
-extern volatile cpuset_t suspended_cpus;
-extern cpuset_t hlt_cpus_mask;
+/* The suspend/resume cpusets are x86 only, but minimize ifdefs. */
+extern volatile cpuset_t resuming_cpus;/* woken up cpus in suspend pen 
*/
+extern volatile cpuset_t started_cpus; /* cpus to let out of stop pen */
+extern volatile cpuset_t stopped_cpus; /* cpus in stop pen */
+extern volatile cpuset_t suspended_cpus; /* cpus [near] sleeping in susp pen */
+extern volatile cpuset_t toresume_cpus;/* cpus to let out of suspend 
pen */
+extern cpuset_t hlt_cpus_mask; /* XXX 'mask' is detail in old impl */
 extern cpuset_t logical_cpus_mask;
 #endif /* SMP */
 

Modified: head/sys/x86/acpica/acpi_wakeup.c
==
--- head/sys/x86/acpica/acpi_wakeup.c   Thu Dec 21 04:23:00 2017
(r327055)
+++ head/sys/x86/acpica/acpi_wakeup.c   Thu Dec 21 09:17:48 2017
(r327056)
@@ -310,7 +310,7 @@ acpi_wakeup_machdep(struct acpi_softc *sc, int state, 
 
 #ifdef SMP
if (!CPU_EMPTY(&suspcpus))
-   restart_cpus(suspcpus);
+   resume_cpus(suspcpus);
 #endif
mca_resume();
 #ifdef __amd64__

Modified: head/sys/x86/x86/mp_x86.c
==
--- head/sys/x86/x86/mp_x86.c   Thu Dec 21 04:23:00 2017(r327055)
+++ head/sys/x86/x86/mp_x86.c   Thu Dec 21 09:17:48 2017(r327056)
@@ -124,6 +124,9 @@ 

svn commit: r327057 - head/usr.bin/truss

2017-12-21 Thread Ed Schouten
Author: ed
Date: Thu Dec 21 09:21:40 2017
New Revision: 327057
URL: https://svnweb.freebsd.org/changeset/base/327057

Log:
  Make truss work for CloudABI executables on i386.
  
  The system call convention is different from i386 binaries running on
  FreeBSD/amd64, but this is not noticeable by executables. On
  FreeBSD/amd64, the vDSO already does padding of arguments and return
  values to 64-bit values. On i386, it does not, meaning that system call
  return values are simply stored in registers.

Added:
  head/usr.bin/truss/i386-cloudabi32.c
 - copied, changed from r327055, head/usr.bin/truss/amd64-cloudabi32.c
Modified:
  head/usr.bin/truss/Makefile

Modified: head/usr.bin/truss/Makefile
==
--- head/usr.bin/truss/Makefile Thu Dec 21 09:17:48 2017(r327056)
+++ head/usr.bin/truss/Makefile Thu Dec 21 09:21:40 2017(r327057)
@@ -18,6 +18,7 @@ ABIS+=cloudabi64
 .endif
 .if ${MACHINE_CPUARCH} == "i386"
 ABIS+= i386-linux
+ABIS+= cloudabi32
 .endif
 .if ${MACHINE_CPUARCH} == "amd64"
 ABIS+= amd64-linux

Copied and modified: head/usr.bin/truss/i386-cloudabi32.c (from r327055, 
head/usr.bin/truss/amd64-cloudabi32.c)
==
--- head/usr.bin/truss/amd64-cloudabi32.c   Thu Dec 21 04:23:00 2017
(r327055, copy source)
+++ head/usr.bin/truss/i386-cloudabi32.cThu Dec 21 09:21:40 2017
(r327057)
@@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$");
 #include "truss.h"
 
 static int
-amd64_cloudabi32_fetch_args(struct trussinfo *trussinfo, unsigned int narg)
+i386_cloudabi32_fetch_args(struct trussinfo *trussinfo, unsigned int narg)
 {
struct current_syscall *cs;
struct ptrace_io_desc iorequest;
@@ -46,7 +46,7 @@ amd64_cloudabi32_fetch_args(struct trussinfo *trussinf
lwpid_t tid;
 
if (narg > 0) {
-   /* Fetch registers, containing the address of the arguments. */
+   /* Fetch registers, containing the stack pointer. */
tid = trussinfo->curthread->tid;
if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) == -1) {
fprintf(trussinfo->outfile,
@@ -54,10 +54,10 @@ amd64_cloudabi32_fetch_args(struct trussinfo *trussinf
return (-1);
}
 
-   /* Fetch arguments. They are already padded to 64 bits. */
+   /* Fetch arguments. */
cs = &trussinfo->curthread->cs;
iorequest.piod_op = PIOD_READ_D;
-   iorequest.piod_offs = (void *)regs.r_rcx;
+   iorequest.piod_offs = (void **)regs.r_esp + 1;
iorequest.piod_addr = cs->args;
iorequest.piod_len = sizeof(cs->args[0]) * narg;
if (ptrace(PT_IO, tid, (caddr_t)&iorequest, 0) == -1 ||
@@ -68,45 +68,31 @@ amd64_cloudabi32_fetch_args(struct trussinfo *trussinf
 }
 
 static int
-amd64_cloudabi32_fetch_retval(struct trussinfo *trussinfo, long *retval,
+i386_cloudabi32_fetch_retval(struct trussinfo *trussinfo, long *retval,
 int *errorp)
 {
-   struct ptrace_io_desc iorequest;
struct reg regs;
lwpid_t tid;
 
-   /* Fetch registers, containing the address of the return values. */
tid = trussinfo->curthread->tid;
if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) == -1) {
fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n");
return (-1);
}
 
-   if (regs.r_rax == 0) {
-   /* System call succeeded. Fetch return values. */
-   iorequest.piod_op = PIOD_READ_D;
-   iorequest.piod_offs = (void *)regs.r_rcx;
-   iorequest.piod_addr = retval;
-   iorequest.piod_len = sizeof(retval[0]) * 2;
-   if (ptrace(PT_IO, tid, (caddr_t)&iorequest, 0) == -1 ||
-   iorequest.piod_len == 0)
-   return (-1);
-   *errorp = 0;
-   } else {
-   /* System call failed. Set error. */
-   retval[0] = regs.r_rax;
-   *errorp = 1;
-   }
+   retval[0] = regs.r_eax;
+   retval[1] = regs.r_edx;
+   *errorp = (regs.r_eflags & PSL_C) != 0;
return (0);
 }
 
-static struct procabi amd64_cloudabi32 = {
+static struct procabi i386_cloudabi32 = {
"CloudABI ELF32",
SYSDECODE_ABI_CLOUDABI32,
-   amd64_cloudabi32_fetch_args,
-   amd64_cloudabi32_fetch_retval,
-   STAILQ_HEAD_INITIALIZER(amd64_cloudabi32.extra_syscalls),
+   i386_cloudabi32_fetch_args,
+   i386_cloudabi32_fetch_retval,
+   STAILQ_HEAD_INITIALIZER(i386_cloudabi32.extra_syscalls),
{ NULL }
 };
 
-PROCABI(amd64_cloudabi32);
+PROCABI(i386_cloudabi32);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-

Re: svn commit: r327053 - head/sys/sparc64/include

2017-12-21 Thread Konstantin Belousov
On Thu, Dec 21, 2017 at 01:27:33AM +, Marius Strobl wrote:
> Author: marius
> Date: Thu Dec 21 01:27:32 2017
> New Revision: 327053
> URL: https://svnweb.freebsd.org/changeset/base/327053
> 
> Log:
>   Remove MD atomic_load_{32,64,int,long,ptr}(9) obsolete since the addition
>   of (conflicting) MI ones in r326971.
I am sorry. Initially I wrote the patch with only support for required
MI types int long ptr and run the tinderbox. Then I decided that there
is no reason to not provide the rest, but did not realized that tb is
needed again.

> 
> Modified:
>   head/sys/sparc64/include/atomic.h
> 
> Modified: head/sys/sparc64/include/atomic.h
> ==
> --- head/sys/sparc64/include/atomic.h Thu Dec 21 01:22:36 2017
> (r327052)
> +++ head/sys/sparc64/include/atomic.h Thu Dec 21 01:27:32 2017
> (r327053)
> @@ -258,11 +258,6 @@ atomic_fcmpset_rel_ ## name(volatile ptype p, vtype *e
>  }\
>   \
>  static __inline vtype
> \
> -atomic_load_ ## name(volatile ptype p)   
> \
> -{\
> - return ((vtype)atomic_cas((p), 0, 0, sz));  \
atomic_cas() does not have any barrier behavior, am I right ?
I.e., it does not prevent a reordering in RMO and PSO models.

> -}\
> -static __inline vtype
> \
>  atomic_load_acq_ ## name(volatile ptype p)   \
>  {\
>   return ((vtype)atomic_cas_acq((p), 0, 0, sz));  \
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r327058 - head/stand/efi/boot1

2017-12-21 Thread Michael Zhilin
Author: mizhka
Date: Thu Dec 21 12:21:35 2017
New Revision: 327058
URL: https://svnweb.freebsd.org/changeset/base/327058

Log:
  [boot/efi] scan all display modes rather than sequential try-fail way
  
  This patch allows to scan all display modes in boot1 as loader does.
  
  Before system tried to select optimal display mode by sequential scan of
  modes and if error then stop scanning. This way is not good, because
  if mode N is not present, mode N+1 may exist.
  
  In loader we use conout->Mode->MaxMode to identify maximum number of modes.
  This commit is to use same way in boot1 as in loader.
  
  Reported by:  Andrey Pustovetov 
  Reviewed by:  tsoome
  Differential Revision:https://reviews.freebsd.org/D13541

Modified:
  head/stand/efi/boot1/boot1.c

Modified: head/stand/efi/boot1/boot1.c
==
--- head/stand/efi/boot1/boot1.cThu Dec 21 09:21:40 2017
(r327057)
+++ head/stand/efi/boot1/boot1.cThu Dec 21 12:21:35 2017
(r327058)
@@ -430,10 +430,10 @@ efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab)
conout = ST->ConOut;
conout->Reset(conout, TRUE);
max_dim = best_mode = 0;
-   for (i = 0; ; i++) {
+   for (i = 0; i < conout->Mode->MaxMode; i++) {
status = conout->QueryMode(conout, i, &cols, &rows);
if (EFI_ERROR(status))
-   break;
+   continue;
if (cols * rows > max_dim) {
max_dim = cols * rows;
best_mode = i;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r327059 - stable/11/sys/fs/devfs

2017-12-21 Thread Konstantin Belousov
Author: kib
Date: Thu Dec 21 13:30:56 2017
New Revision: 327059
URL: https://svnweb.freebsd.org/changeset/base/327059

Log:
  MFC r326851:
  In devfs_lookupx() dotdot lookup case, avoid dereferencing
  dvp->v_mount after dvp is unlocked.

Modified:
  stable/11/sys/fs/devfs/devfs_vnops.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/fs/devfs/devfs_vnops.c
==
--- stable/11/sys/fs/devfs/devfs_vnops.cThu Dec 21 12:21:35 2017
(r327058)
+++ stable/11/sys/fs/devfs/devfs_vnops.cThu Dec 21 13:30:56 2017
(r327059)
@@ -880,6 +880,7 @@ devfs_lookupx(struct vop_lookup_args *ap, int *dm_unlo
struct devfs_dirent *de, *dd;
struct devfs_dirent **dde;
struct devfs_mount *dmp;
+   struct mount *mp;
struct cdev *cdev;
int error, flags, nameiop, dvplocked;
char specname[SPECNAMELEN + 1], *pname;
@@ -891,7 +892,8 @@ devfs_lookupx(struct vop_lookup_args *ap, int *dm_unlo
td = cnp->cn_thread;
flags = cnp->cn_flags;
nameiop = cnp->cn_nameiop;
-   dmp = VFSTODEVFS(dvp->v_mount);
+   mp = dvp->v_mount;
+   dmp = VFSTODEVFS(mp);
dd = dvp->v_data;
*vpp = NULLVP;
 
@@ -924,8 +926,8 @@ devfs_lookupx(struct vop_lookup_args *ap, int *dm_unlo
return (ENOENT);
dvplocked = VOP_ISLOCKED(dvp);
VOP_UNLOCK(dvp, 0);
-   error = devfs_allocv(de, dvp->v_mount,
-   cnp->cn_lkflags & LK_TYPE_MASK, vpp);
+   error = devfs_allocv(de, mp, cnp->cn_lkflags & LK_TYPE_MASK,
+   vpp);
*dm_unlock = 0;
vn_lock(dvp, dvplocked | LK_RETRY);
return (error);
@@ -1010,8 +1012,7 @@ devfs_lookupx(struct vop_lookup_args *ap, int *dm_unlo
return (0);
}
}
-   error = devfs_allocv(de, dvp->v_mount, cnp->cn_lkflags & LK_TYPE_MASK,
-   vpp);
+   error = devfs_allocv(de, mp, cnp->cn_lkflags & LK_TYPE_MASK, vpp);
*dm_unlock = 0;
return (error);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r327060 - stable/10/sys/fs/devfs

2017-12-21 Thread Konstantin Belousov
Author: kib
Date: Thu Dec 21 13:32:49 2017
New Revision: 327060
URL: https://svnweb.freebsd.org/changeset/base/327060

Log:
  MFC r326851:
  In devfs_lookupx() dotdot lookup case, avoid dereferencing
  dvp->v_mount after dvp is unlocked.

Modified:
  stable/10/sys/fs/devfs/devfs_vnops.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/fs/devfs/devfs_vnops.c
==
--- stable/10/sys/fs/devfs/devfs_vnops.cThu Dec 21 13:30:56 2017
(r327059)
+++ stable/10/sys/fs/devfs/devfs_vnops.cThu Dec 21 13:32:49 2017
(r327060)
@@ -869,6 +869,7 @@ devfs_lookupx(struct vop_lookup_args *ap, int *dm_unlo
struct devfs_dirent *de, *dd;
struct devfs_dirent **dde;
struct devfs_mount *dmp;
+   struct mount *mp;
struct cdev *cdev;
int error, flags, nameiop, dvplocked;
char specname[SPECNAMELEN + 1], *pname;
@@ -880,7 +881,8 @@ devfs_lookupx(struct vop_lookup_args *ap, int *dm_unlo
td = cnp->cn_thread;
flags = cnp->cn_flags;
nameiop = cnp->cn_nameiop;
-   dmp = VFSTODEVFS(dvp->v_mount);
+   mp = dvp->v_mount;
+   dmp = VFSTODEVFS(mp);
dd = dvp->v_data;
*vpp = NULLVP;
 
@@ -913,8 +915,8 @@ devfs_lookupx(struct vop_lookup_args *ap, int *dm_unlo
return (ENOENT);
dvplocked = VOP_ISLOCKED(dvp);
VOP_UNLOCK(dvp, 0);
-   error = devfs_allocv(de, dvp->v_mount,
-   cnp->cn_lkflags & LK_TYPE_MASK, vpp);
+   error = devfs_allocv(de, mp, cnp->cn_lkflags & LK_TYPE_MASK,
+   vpp);
*dm_unlock = 0;
vn_lock(dvp, dvplocked | LK_RETRY);
return (error);
@@ -999,8 +1001,7 @@ devfs_lookupx(struct vop_lookup_args *ap, int *dm_unlo
return (0);
}
}
-   error = devfs_allocv(de, dvp->v_mount, cnp->cn_lkflags & LK_TYPE_MASK,
-   vpp);
+   error = devfs_allocv(de, mp, cnp->cn_lkflags & LK_TYPE_MASK, vpp);
*dm_unlock = 0;
return (error);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r327061 - stable/11/sys/netinet

2017-12-21 Thread Andrey V. Elsukov
Author: ae
Date: Thu Dec 21 14:09:06 2017
New Revision: 327061
URL: https://svnweb.freebsd.org/changeset/base/327061

Log:
  MFC r326847:
Fix mbuf leak when TCPMD5_OUTPUT() method returns error.
  
PR: 223817

Modified:
  stable/11/sys/netinet/tcp_output.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netinet/tcp_output.c
==
--- stable/11/sys/netinet/tcp_output.c  Thu Dec 21 13:32:49 2017
(r327060)
+++ stable/11/sys/netinet/tcp_output.c  Thu Dec 21 14:09:06 2017
(r327061)
@@ -1275,12 +1275,13 @@ send:
 * NOTE: since TCP options buffer doesn't point into
 * mbuf's data, calculate offset and use it.
 */
-   if (!TCPMD5_ENABLED() || TCPMD5_OUTPUT(m, th,
-   (u_char *)(th + 1) + (to.to_signature - opt)) != 0) {
+   if (!TCPMD5_ENABLED() || (error = TCPMD5_OUTPUT(m, th,
+   (u_char *)(th + 1) + (to.to_signature - opt))) != 0) {
/*
 * Do not send segment if the calculation of MD5
 * digest has failed.
 */
+   m_freem(m);
goto out;
}
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r327062 - in head/sys/dev/cxgbe: . common

2017-12-21 Thread Navdeep Parhar
Author: np
Date: Thu Dec 21 15:19:43 2017
New Revision: 327062
URL: https://svnweb.freebsd.org/changeset/base/327062

Log:
  cxgbe(4):  Read the MFG diags version from the VPD and make it available
  in the sysctl MIB.
  
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/common/common.h
  head/sys/dev/cxgbe/common/t4_hw.c
  head/sys/dev/cxgbe/t4_main.c

Modified: head/sys/dev/cxgbe/common/common.h
==
--- head/sys/dev/cxgbe/common/common.h  Thu Dec 21 14:09:06 2017
(r327061)
+++ head/sys/dev/cxgbe/common/common.h  Thu Dec 21 15:19:43 2017
(r327062)
@@ -44,6 +44,7 @@ enum {
EC_LEN = 16,/* E/C length */
ID_LEN = 16,/* ID length */
PN_LEN = 16,/* Part Number length */
+   MD_LEN = 16,/* MFG diags version length */
MACADDR_LEN= 12,/* MAC Address length */
 };
 
@@ -258,6 +259,7 @@ struct vpd_params {
u8 id[ID_LEN + 1];
u8 pn[PN_LEN + 1];
u8 na[MACADDR_LEN + 1];
+   u8 md[MD_LEN + 1];
 };
 
 struct pci_params {
@@ -590,7 +592,7 @@ int t4_get_vpd_version(struct adapter *adapter, u32 *v
 int t4_get_version_info(struct adapter *adapter);
 int t4_init_hw(struct adapter *adapter, u32 fw_params);
 const struct chip_params *t4_get_chip_params(int chipid);
-int t4_prep_adapter(struct adapter *adapter, u8 *buf);
+int t4_prep_adapter(struct adapter *adapter, u32 *buf);
 int t4_shutdown_adapter(struct adapter *adapter);
 int t4_init_devlog_params(struct adapter *adapter, int fw_attach);
 int t4_init_sge_params(struct adapter *adapter);

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==
--- head/sys/dev/cxgbe/common/t4_hw.c   Thu Dec 21 14:09:06 2017
(r327061)
+++ head/sys/dev/cxgbe/common/t4_hw.c   Thu Dec 21 15:19:43 2017
(r327062)
@@ -2664,13 +2664,16 @@ void t4_get_regs(struct adapter *adap, u8 *buf, size_t
 }
 
 /*
- * Partial EEPROM Vital Product Data structure.  Includes only the ID and
- * VPD-R sections.
+ * Partial EEPROM Vital Product Data structure.  The VPD starts with one ID
+ * header followed by one or more VPD-R sections, each with its own header.
  */
 struct t4_vpd_hdr {
u8  id_tag;
u8  id_len[2];
u8  id_data[ID_LEN];
+};
+
+struct t4_vpdr_hdr {
u8  vpdr_tag;
u8  vpdr_len[2];
 };
@@ -2905,32 +2908,43 @@ int t4_seeprom_wp(struct adapter *adapter, int enable)
 
 /**
  * get_vpd_keyword_val - Locates an information field keyword in the VPD
- * @v: Pointer to buffered vpd data structure
+ * @vpd: Pointer to buffered vpd data structure
  * @kw: The keyword to search for
+ * @region: VPD region to search (starting from 0)
  *
  * Returns the value of the information field keyword or
  * -ENOENT otherwise.
  */
-static int get_vpd_keyword_val(const struct t4_vpd_hdr *v, const char *kw)
+static int get_vpd_keyword_val(const u8 *vpd, const char *kw, int region)
 {
-   int i;
-   unsigned int offset , len;
-   const u8 *buf = (const u8 *)v;
-   const u8 *vpdr_len = &v->vpdr_len[0];
+   int i, tag;
+   unsigned int offset, len;
+   const struct t4_vpdr_hdr *vpdr;
+
offset = sizeof(struct t4_vpd_hdr);
-   len =  (u16)vpdr_len[0] + ((u16)vpdr_len[1] << 8);
+   vpdr = (const void *)(vpd + offset);
+   tag = vpdr->vpdr_tag;
+   len = (u16)vpdr->vpdr_len[0] + ((u16)vpdr->vpdr_len[1] << 8);
+   while (region--) {
+   offset += sizeof(struct t4_vpdr_hdr) + len;
+   vpdr = (const void *)(vpd + offset);
+   if (++tag != vpdr->vpdr_tag)
+   return -ENOENT;
+   len = (u16)vpdr->vpdr_len[0] + ((u16)vpdr->vpdr_len[1] << 8);
+   }
+   offset += sizeof(struct t4_vpdr_hdr);
 
-   if (len + sizeof(struct t4_vpd_hdr) > VPD_LEN) {
+   if (offset + len > VPD_LEN) {
return -ENOENT;
}
 
for (i = offset; i + VPD_INFO_FLD_HDR_SIZE <= offset + len;) {
-   if(memcmp(buf + i , kw , 2) == 0){
+   if (memcmp(vpd + i , kw , 2) == 0){
i += VPD_INFO_FLD_HDR_SIZE;
return i;
}
 
-   i += VPD_INFO_FLD_HDR_SIZE + buf[i+2];
+   i += VPD_INFO_FLD_HDR_SIZE + vpd[i+2];
}
 
return -ENOENT;
@@ -2946,18 +2960,18 @@ static int get_vpd_keyword_val(const struct t4_vpd_hdr
  * Reads card parameters stored in VPD EEPROM.
  */
 static int get_vpd_params(struct adapter *adapter, struct vpd_params *p,
-u8 *vpd)
+u32 *buf)
 {
int i, ret, addr;
-   int ec, sn, pn, na;
+   int ec, sn, pn, na, md;
u8 csum;
-   const struct t4_vpd_hdr *v;
+   const u8 *vpd = (const u8 *)buf;
 
/*
 * Card information normally star

svn commit: r327063 - head/usr.bin/patch

2017-12-21 Thread Pedro F. Giffuni
Author: pfg
Date: Thu Dec 21 16:19:10 2017
New Revision: 327063
URL: https://svnweb.freebsd.org/changeset/base/327063

Log:
  patch: rejname[] is also -r option buffer, and should be PATH_MAX.
  
  Obtained from:OpenBSD (CVS 1.64)

Modified:
  head/usr.bin/patch/patch.c

Modified: head/usr.bin/patch/patch.c
==
--- head/usr.bin/patch/patch.c  Thu Dec 21 15:19:43 2017(r327062)
+++ head/usr.bin/patch/patch.c  Thu Dec 21 16:19:10 2017(r327063)
@@ -112,7 +112,7 @@ static bool reverse_flag_specified = false;
 static boolVflag = false;
 
 /* buffer holding the name of the rejected patch file. */
-static charrejname[NAME_MAX + 1];
+static charrejname[PATH_MAX];
 
 /* how many input lines have been irretractibly output */
 static LINENUM last_frozen_line = 0;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r327064 - head/usr.bin/patch

2017-12-21 Thread Pedro F. Giffuni
Author: pfg
Date: Thu Dec 21 16:25:33 2017
New Revision: 327064
URL: https://svnweb.freebsd.org/changeset/base/327064

Log:
  patch: further cleanup to git-style diffs.
  
  Fix adding and removing files with git-style a/ b/ diffs: only skip
  six letters if they actually match "--- a/" and "+++ b/" instead of
  laxer checks.
  
  Obtained from:OpenBSD (CVS 1.59)

Modified:
  head/usr.bin/patch/pch.c

Modified: head/usr.bin/patch/pch.c
==
--- head/usr.bin/patch/pch.cThu Dec 21 16:19:10 2017(r327063)
+++ head/usr.bin/patch/pch.cThu Dec 21 16:25:33 2017(r327064)
@@ -311,14 +311,16 @@ intuit_diff_type(void)
&names[OLD_FILE].exists, strippath);
else if (strnEQ(s, "--- ", 4)) {
size_t off = 4;
-   if (piece_of_git && strippath == 957)
+   if (piece_of_git && strippath == 957 &&
+   strnEQ(s, "--- a/", 6))
off = 6;
names[NEW_FILE].path = fetchname(s + off,
&names[NEW_FILE].exists, strippath);
} else if (strnEQ(s, "+++ ", 4)) {
/* pretend it is the old name */
size_t off = 4;
-   if (piece_of_git && strippath == 957)
+   if (piece_of_git && strippath == 957 &&
+   strnEQ(s, "+++ b/", 6))
off = 6;
names[OLD_FILE].path = fetchname(s + off,
&names[OLD_FILE].exists, strippath);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r326809 - head/sys/dev/cardbus

2017-12-21 Thread Eugene Grosbein
On Thu, Dec 14, 2017 at 2:36 PM, Eugene Grosbein mailto:eu...@grosbein.net>> wrote:
> 
> - zfsloader(8) failing to find any ZFS pool after zfsboot(8) successfully
> loaded and started zfsload(8) from zpool (PR pending, need to collect 
> more info)

I've discovered the source of the problem. Here is scenario:

1. Take disk prevously used for FreeBSD. Erase its first and last megabytes
with dd to start from scratch: dd if=/dev/zero bs=1m count=1 of=... etc.

2. Create MBR with gpart, add two "freebsd" slices: first one for 8GB swap,
second one for ZFS (rest of space), make second slice active.

3. Install boot-loaders: /boot/boot0 (or /boot/mbr, it does not matter)
with gpart to the MBR and zfsboot with dd to second second slice just
as zfsboot(8) manual page instructs. Note that this does NOT change contents
of *second* 512-bytes block of this slice.

4. Create zpool using whole second slice, install FreeBSD 11.1/amd64 there and 
try to boot it.

MBR loader successfully uses second slice to load and run zfsboot.
zfsboot does its job just fine running zfsloader from ZFS
and passes needed ZFS it to zfsloader.

zfsloader uses libstand(3) trying to find its pool: zfs_probe_partition()
successfully calls libstand's version of open("disk0s1:", O_RDONLY) and skips it
as there is no ZFS. Then, it tries to open("disk0s2:", O_RDONLY) and it fails
returning -1 with errno==2 (ENOENT), so zfsloader fails.

src/tools/tools/bootparttest shows that libstand looks at *second* sector of 
the slice
and sees leftover of (now non-existing) BSD label there.
And for some reason it prevents zfsloader from using such slice.

I "fixed" this by booting from USB flash drive and dd-ing second sector with 
zeroes
and now zfsloader runs just fine and starts installed FreeBSD 11 from the pool.

This seems to me as bug in libstand, isn't it?


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


svn commit: r327065 - head/sys/amd64/vmm/intel

2017-12-21 Thread Tycho Nightingale
Author: tychon
Date: Thu Dec 21 18:30:11 2017
New Revision: 327065
URL: https://svnweb.freebsd.org/changeset/base/327065

Log:
  Recognize a pending virtual interrupt while emulating the halt instruction.
  
  Reviewed by:  grehan, rgrimes
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D13573

Modified:
  head/sys/amd64/vmm/intel/vmx.c

Modified: head/sys/amd64/vmm/intel/vmx.c
==
--- head/sys/amd64/vmm/intel/vmx.c  Thu Dec 21 16:25:33 2017
(r327064)
+++ head/sys/amd64/vmm/intel/vmx.c  Thu Dec 21 18:30:11 2017
(r327065)
@@ -3174,9 +3174,29 @@ vmx_pending_intr(struct vlapic *vlapic, int *vecptr)
pir_desc = vlapic_vtx->pir_desc;
 
pending = atomic_load_acq_long(&pir_desc->pending);
-   if (!pending)
-   return (0); /* common case */
+   if (!pending) {
+   /*
+* While a virtual interrupt may have already been
+* processed the actual delivery maybe pending the
+* interruptibility of the guest.  Recognize a pending
+* interrupt by reevaluating virtual interrupts
+* following Section 29.2.1 in the Intel SDM Volume 3.
+*/
+   uint64_t val;
+   uint8_t rvi, ppr;
 
+   vmx_getreg(vlapic_vtx->vmx, vlapic->vcpuid,
+   VMCS_IDENT(VMCS_GUEST_INTR_STATUS), &val);
+   rvi = val & APIC_TPR_INT;
+   lapic = vlapic->apic_page;
+   ppr = lapic->ppr & APIC_TPR_INT;
+   if (rvi > ppr) {
+   return (1);
+   }
+
+   return (0);
+   }
+
/*
 * If there is an interrupt pending then it will be recognized only
 * if its priority is greater than the processor priority.
@@ -3185,7 +3205,7 @@ vmx_pending_intr(struct vlapic *vlapic, int *vecptr)
 * interrupt will be recognized.
 */
lapic = vlapic->apic_page;
-   ppr = lapic->ppr & 0xf0;
+   ppr = lapic->ppr & APIC_TPR_INT;
if (ppr == 0)
return (1);
 
@@ -3195,7 +3215,7 @@ vmx_pending_intr(struct vlapic *vlapic, int *vecptr)
for (i = 3; i >= 0; i--) {
pirval = pir_desc->pir[i];
if (pirval != 0) {
-   vpr = (i * 64 + flsl(pirval) - 1) & 0xf0;
+   vpr = (i * 64 + flsl(pirval) - 1) & APIC_TPR_INT;
return (vpr > ppr);
}
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r327066 - head/usr.sbin/devinfo

2017-12-21 Thread Warner Losh
Author: imp
Date: Thu Dec 21 18:51:47 2017
New Revision: 327066
URL: https://svnweb.freebsd.org/changeset/base/327066

Log:
  Implement "-p dev" to print the path to the given device back to the
  nexus. With redirection, could also be used to test if the device
  exists in the device tree.
  
  Sponsored by: Netflix

Modified:
  head/usr.sbin/devinfo/devinfo.8
  head/usr.sbin/devinfo/devinfo.c

Modified: head/usr.sbin/devinfo/devinfo.8
==
--- head/usr.sbin/devinfo/devinfo.8 Thu Dec 21 18:30:11 2017
(r327065)
+++ head/usr.sbin/devinfo/devinfo.8 Thu Dec 21 18:51:47 2017
(r327066)
@@ -38,6 +38,8 @@
 .Op Fl rv
 .Nm
 .Fl u
+.Nm
+.Fl p dev
 .Sh DESCRIPTION
 The
 .Nm
@@ -62,6 +64,8 @@ the IRQ consumers together.
 Display all devices in the driver tree, not just those that are attached or
 busy.
 Without this flag, only those devices that have attached are reported.
+.It Fl p dev
+Display the path of dev back to the root of the device tree.
 .El
 .Sh SEE ALSO
 .Xr systat 1 ,

Modified: head/usr.sbin/devinfo/devinfo.c
==
--- head/usr.sbin/devinfo/devinfo.c Thu Dec 21 18:30:11 2017
(r327065)
+++ head/usr.sbin/devinfo/devinfo.c Thu Dec 21 18:51:47 2017
(r327066)
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include "devinfo.h"
 
@@ -196,15 +197,47 @@ print_rman(struct devinfo_rman *rman, void *arg __unus
return(0);
 }
 
+static void __dead2
+usage(void)
+{
+   fprintf(stderr, "%s\n%s\n%s\n",
+   "usage: devinfo [-rv]",
+   "   devinfo -u",
+   "   devifno -p dev");
+   exit(1);
+}
+
+
+static int
+print_path(struct devinfo_dev *dev, void *xname)
+{
+   const char *name = xname;
+   int rv;
+
+   if (strcmp(dev->dd_name, name) == 0) {
+   printf("%s", dev->dd_name);
+   return (1);
+   }
+
+   rv = devinfo_foreach_device_child(dev, print_path, xname);
+   if (rv == 1)
+   printf(" %s", dev->dd_name[0] ? dev->dd_name : "unknown");
+   return (rv);
+}
+
 int
 main(int argc, char *argv[]) 
 {
struct devinfo_dev  *root;
int c, uflag;
+   char*path;
 
uflag = 0;
-   while ((c = getopt(argc, argv, "ruv")) != -1) {
+   while ((c = getopt(argc, argv, "p:ruv")) != -1) {
switch(c) {
+   case 'p':
+   path = optarg;
+   break;
case 'r':
rflag++;
break;
@@ -215,21 +248,25 @@ main(int argc, char *argv[]) 
vflag++;
break;
default:
-   fprintf(stderr, "%s\n%s\n",
-   "usage: devinfo [-rv]",
-   "   devinfo -u");
-   exit(1);
+   usage();
}
}
 
+   if (path && (rflag || uflag))
+   usage();
+
if (devinfo_init())
err(1, "devinfo_init");
 
if ((root = devinfo_handle_to_device(DEVINFO_ROOT_DEVICE)) == NULL)
errx(1, "can't find root device");
 
-   /* print resource usage? */
-   if (uflag) {
+   if (path) {
+   if (devinfo_foreach_device_child(root, print_path, (void 
*)path) == 0)
+   errx(1, "%s: Not found", path);
+   printf("\n");
+   } else if (uflag) {
+   /* print resource usage? */
devinfo_foreach_rman(print_rman, NULL);
} else {
/* print device hierarchy */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r327067 - head/usr.sbin/devinfo

2017-12-21 Thread Warner Losh
Author: imp
Date: Thu Dec 21 18:58:14 2017
New Revision: 327067
URL: https://svnweb.freebsd.org/changeset/base/327067

Log:
  Fix markup and bump .Dd.

Modified:
  head/usr.sbin/devinfo/devinfo.8

Modified: head/usr.sbin/devinfo/devinfo.8
==
--- head/usr.sbin/devinfo/devinfo.8 Thu Dec 21 18:51:47 2017
(r327066)
+++ head/usr.sbin/devinfo/devinfo.8 Thu Dec 21 18:58:14 2017
(r327067)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 28, 2005
+.Dd December 21, 2017
 .Dt DEVINFO 8
 .Os
 .Sh NAME
@@ -39,7 +39,7 @@
 .Nm
 .Fl u
 .Nm
-.Fl p dev
+.Fl p Ar dev
 .Sh DESCRIPTION
 The
 .Nm
@@ -64,8 +64,10 @@ the IRQ consumers together.
 Display all devices in the driver tree, not just those that are attached or
 busy.
 Without this flag, only those devices that have attached are reported.
-.It Fl p dev
-Display the path of dev back to the root of the device tree.
+.It Fl p Ar dev
+Display the path of
+.Ar dev
+back to the root of the device tree.
 .El
 .Sh SEE ALSO
 .Xr systat 1 ,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r327068 - head/usr.sbin/devinfo

2017-12-21 Thread Warner Losh
Author: imp
Date: Thu Dec 21 19:19:43 2017
New Revision: 327068
URL: https://svnweb.freebsd.org/changeset/base/327068

Log:
  When -v is specified with -p dev, print the same verbose output as
  when listing the whole tree. The list, however, is from the requested
  device to the root (so it backwards from the normal tree).
  
  Sponsored by: Netflix

Modified:
  head/usr.sbin/devinfo/devinfo.8
  head/usr.sbin/devinfo/devinfo.c

Modified: head/usr.sbin/devinfo/devinfo.8
==
--- head/usr.sbin/devinfo/devinfo.8 Thu Dec 21 18:58:14 2017
(r327067)
+++ head/usr.sbin/devinfo/devinfo.8 Thu Dec 21 19:19:43 2017
(r327068)
@@ -39,7 +39,7 @@
 .Nm
 .Fl u
 .Nm
-.Fl p Ar dev
+.Fl p Ar dev Op Fl v
 .Sh DESCRIPTION
 The
 .Nm
@@ -64,6 +64,7 @@ the IRQ consumers together.
 Display all devices in the driver tree, not just those that are attached or
 busy.
 Without this flag, only those devices that have attached are reported.
+This flag also displays verbose information about each device.
 .It Fl p Ar dev
 Display the path of
 .Ar dev

Modified: head/usr.sbin/devinfo/devinfo.c
==
--- head/usr.sbin/devinfo/devinfo.c Thu Dec 21 18:58:14 2017
(r327067)
+++ head/usr.sbin/devinfo/devinfo.c Thu Dec 21 19:19:43 2017
(r327068)
@@ -131,6 +131,22 @@ print_device_rman_resources(struct devinfo_rman *rman,
return(0);
 }
 
+static void
+print_dev(struct devinfo_dev *dev)
+{
+
+   printf("%s", dev->dd_name[0] ? dev->dd_name : "unknown");
+   if (vflag && *dev->dd_pnpinfo)
+   printf(" pnpinfo %s", dev->dd_pnpinfo);
+   if (vflag && *dev->dd_location)
+   printf(" at %s", dev->dd_location);
+   if (!(dev->dd_flags & DF_ENABLED))
+   printf(" (disabled)");
+   else if (dev->dd_flags & DF_SUSPENDED)
+   printf(" (suspended)");
+}
+
+
 /*
  * Print information about a device.
  */
@@ -144,15 +160,7 @@ print_device(struct devinfo_dev *dev, void *arg)
indent = (int)(intptr_t)arg;
for (i = 0; i < indent; i++)
printf(" ");
-   printf("%s", dev->dd_name[0] ? dev->dd_name : "unknown");
-   if (vflag && *dev->dd_pnpinfo)
-   printf(" pnpinfo %s", dev->dd_pnpinfo);
-   if (vflag && *dev->dd_location)
-   printf(" at %s", dev->dd_location);
-   if (!(dev->dd_flags & DF_ENABLED))
-   printf(" (disabled)");
-   else if (dev->dd_flags & DF_SUSPENDED)
-   printf(" (suspended)");
+   print_dev(dev);
printf("\n");
if (rflag) {
ia.indent = indent + 4;
@@ -197,17 +205,6 @@ print_rman(struct devinfo_rman *rman, void *arg __unus
return(0);
 }
 
-static void __dead2
-usage(void)
-{
-   fprintf(stderr, "%s\n%s\n%s\n",
-   "usage: devinfo [-rv]",
-   "   devinfo -u",
-   "   devifno -p dev");
-   exit(1);
-}
-
-
 static int
 print_path(struct devinfo_dev *dev, void *xname)
 {
@@ -215,22 +212,38 @@ print_path(struct devinfo_dev *dev, void *xname)
int rv;
 
if (strcmp(dev->dd_name, name) == 0) {
-   printf("%s", dev->dd_name);
+   print_dev(dev);
+   if (vflag)
+   printf("\n");
return (1);
}
 
rv = devinfo_foreach_device_child(dev, print_path, xname);
-   if (rv == 1)
-   printf(" %s", dev->dd_name[0] ? dev->dd_name : "unknown");
+   if (rv == 1) {
+   printf(" ");
+   print_dev(dev);
+   if (vflag)
+   printf("\n");
+   }
return (rv);
 }
 
+static void __dead2
+usage(void)
+{
+   fprintf(stderr, "%s\n%s\n%s\n",
+   "usage: devinfo [-rv]",
+   "   devinfo -u",
+   "   devifno -p dev [-v]");
+   exit(1);
+}
+
 int
 main(int argc, char *argv[]) 
 {
struct devinfo_dev  *root;
int c, uflag;
-   char*path;
+   char*path = NULL;
 
uflag = 0;
while ((c = getopt(argc, argv, "p:ruv")) != -1) {
@@ -264,7 +277,8 @@ main(int argc, char *argv[]) 
if (path) {
if (devinfo_foreach_device_child(root, print_path, (void 
*)path) == 0)
errx(1, "%s: Not found", path);
-   printf("\n");
+   if (!vflag)
+   printf("\n");
} else if (uflag) {
/* print resource usage? */
devinfo_foreach_rman(print_rman, NULL);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubs

svn commit: r327070 - stable/11/sys/geom/mirror

2017-12-21 Thread Mark Johnston
Author: markj
Date: Thu Dec 21 22:47:04 2017
New Revision: 327070
URL: https://svnweb.freebsd.org/changeset/base/327070

Log:
  MFC r326409:
  Update gmirror metadata less frequently when synchronizing.

Modified:
  stable/11/sys/geom/mirror/g_mirror.c
  stable/11/sys/geom/mirror/g_mirror.h

Modified: stable/11/sys/geom/mirror/g_mirror.c
==
--- stable/11/sys/geom/mirror/g_mirror.cThu Dec 21 21:24:52 2017
(r327069)
+++ stable/11/sys/geom/mirror/g_mirror.cThu Dec 21 22:47:04 2017
(r327070)
@@ -69,6 +69,10 @@ SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, disconnect_on
 static u_int g_mirror_syncreqs = 2;
 SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, sync_requests, CTLFLAG_RDTUN,
 &g_mirror_syncreqs, 0, "Parallel synchronization I/O requests.");
+static u_int g_mirror_sync_period = 5;
+SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, sync_update_period, CTLFLAG_RWTUN,
+&g_mirror_sync_period, 0,
+"Metadata update period during synchroniztion, in seconds");
 
 #defineMSLEEP(ident, mtx, priority, wmesg, timeout)do {
\
G_MIRROR_DEBUG(4, "%s: Sleeping %p.", __func__, (ident));   \
@@ -463,6 +467,7 @@ g_mirror_init_disk(struct g_mirror_softc *sc, struct g
disk->d_sync.ds_consumer = NULL;
disk->d_sync.ds_offset = md->md_sync_offset;
disk->d_sync.ds_offset_done = md->md_sync_offset;
+   disk->d_sync.ds_update_ts = time_uptime;
disk->d_genid = md->md_genid;
disk->d_sync.ds_syncid = md->md_syncid;
if (errorp != NULL)
@@ -1457,10 +1462,11 @@ g_mirror_sync_request(struct bio *bp)
if (bp != NULL && bp->bio_offset < offset)
offset = bp->bio_offset;
}
-   if (sync->ds_offset_done + (MAXPHYS * 100) < offset) {
-   /* Update offset_done on every 100 blocks. */
+   if (g_mirror_sync_period > 0 &&
+   time_uptime - sync->ds_update_ts > g_mirror_sync_period) {
sync->ds_offset_done = offset;
g_mirror_update_metadata(disk);
+   sync->ds_update_ts = time_uptime;
}
return;
}

Modified: stable/11/sys/geom/mirror/g_mirror.h
==
--- stable/11/sys/geom/mirror/g_mirror.hThu Dec 21 21:24:52 2017
(r327069)
+++ stable/11/sys/geom/mirror/g_mirror.hThu Dec 21 22:47:04 2017
(r327070)
@@ -108,6 +108,7 @@ struct g_mirror_disk_sync {
off_t ds_offset;/* Offset of next request to send. */
off_t ds_offset_done; /* Offset of already synchronized
   region. */
+   time_tds_update_ts; /* Time of last metadata update. */
u_int ds_syncid;/* Disk's synchronization ID. */
u_int ds_inflight;  /* Number of in-flight sync requests. */
struct bio  **ds_bios;  /* BIOs for synchronization I/O. */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r327071 - stable/11/sbin/geom/class/mirror

2017-12-21 Thread Mark Johnston
Author: markj
Date: Thu Dec 21 22:48:02 2017
New Revision: 327071
URL: https://svnweb.freebsd.org/changeset/base/327071

Log:
  MFC r326410:
  Document gmirror sysctls.

Modified:
  stable/11/sbin/geom/class/mirror/gmirror.8
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/geom/class/mirror/gmirror.8
==
--- stable/11/sbin/geom/class/mirror/gmirror.8  Thu Dec 21 22:47:04 2017
(r327070)
+++ stable/11/sbin/geom/class/mirror/gmirror.8  Thu Dec 21 22:48:02 2017
(r327071)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 27, 2016
+.Dd November 30, 2017
 .Dt GMIRROR 8
 .Os
 .Sh NAME
@@ -179,7 +179,7 @@ Defaults to 4096 bytes.
 Clear metadata on the given providers.
 .It Cm create
 Similar to
-.Cm label,
+.Cm label ,
 but creates mirror without storing on-disk metadata in last sector.
 This special "manual" operation mode assumes some external control to manage
 mirror detection after reboot, device hot-plug and other external events.
@@ -337,6 +337,45 @@ gmirror deactivate data da1
 dd if=/dev/da1 of=/backup/data.img bs=1m
 gmirror activate data da1
 .Ed
+.Sh SYSCTL VARIABLES
+The following
+.Xr sysctl 8
+variables can be used to configure behavior for all mirrors.
+.Bl -tag -width indent
+.It Va kern.geom.mirror.debug
+Control the verbosity of kernel logging related to mirrors.
+A value larger than 0 will enable debug logging.
+.It Va kern.geom.mirror.timeout
+The amount of time, in seconds, to wait for all copies of a mirror to
+appear before starting the mirror.
+Disks that appear after the mirror has been started are not automatically
+added to the mirror.
+.It Va kern.geom.mirror.idletime
+The amount of time, in seconds, which must elapse after the last write to
+a mirror before that mirror is marked clean.
+Clean mirrors do not need to be synchronized after a power failure or
+system crash.
+A small value may result in frequent overwrites of the disks' metadata
+sectors, and thus may reduce the longevity of the disks.
+.It Va kern.geom.mirror.disconnect_on_failure
+Determine whether a disk is automatically removed from its mirror when an
+I/O request to that disk fails.
+.It Va kern.geom.mirror.sync_requests
+The number of parallel I/O requests used while synchronizing a mirror.
+This parameter may only be configured as a
+.Xr loader.conf 5
+tunable.
+.It Va kern.geom.mirror.sync_update_period
+The period, in seconds, at which a synchronizing mirror's metadata is
+updated.
+Periodic updates are used to record a synchronization's progress so that
+an interrupted synchronization may be resumed starting at the recorded
+offset, rather than at the beginning.
+A smaller value results in more accurate progress tracking, but also
+increases the number of non-sequential writes to the disk being synchronized.
+If the sysctl value is 0, no updates are performed until the synchronization
+is complete.
+.El
 .Sh NOTES
 Doing kernel dumps to
 .Nm
@@ -382,6 +421,7 @@ there.
 .Xr mount 8 ,
 .Xr newfs 8 ,
 .Xr savecore 8 ,
+.Xr sysctl 8 ,
 .Xr umount 8
 .Sh HISTORY
 The
@@ -394,7 +434,3 @@ utility appeared in
 There should be a way to change a component's priority inside a running mirror.
 .Pp
 There should be a section with an implementation description.
-.Pp
-Documentation for sysctls
-.Va kern.geom.mirror.*
-is missing.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r327072 - head/sys/net

2017-12-21 Thread Konstantin Belousov
Author: kib
Date: Thu Dec 21 23:05:13 2017
New Revision: 327072
URL: https://svnweb.freebsd.org/changeset/base/327072

Log:
  Fix build for kernels with SCHED_4BSD.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cThu Dec 21 22:48:02 2017(r327071)
+++ head/sys/net/iflib.cThu Dec 21 23:05:13 2017(r327072)
@@ -5127,7 +5127,7 @@ find_thread(int cpu, int thread_num)
 static int
 find_thread(int cpu, int thread_num __unused)
 {
-   return cpu_id;
+   return cpu;
 }
 #endif
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r327073 - head/sys/fs/nfsclient

2017-12-21 Thread Konstantin Belousov
Author: kib
Date: Thu Dec 21 23:08:10 2017
New Revision: 327073
URL: https://svnweb.freebsd.org/changeset/base/327073

Log:
  Fix build for LP64 arches with gcc.
  
  gcc complaints that the comparision is always false due to the value
  range, and the cast does not prevent the analysis.  Split the LP64
  vs. ILP32 clamping as a workaround.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/fs/nfsclient/nfs_clvnops.c

Modified: head/sys/fs/nfsclient/nfs_clvnops.c
==
--- head/sys/fs/nfsclient/nfs_clvnops.c Thu Dec 21 23:05:13 2017
(r327072)
+++ head/sys/fs/nfsclient/nfs_clvnops.c Thu Dec 21 23:08:10 2017
(r327073)
@@ -3461,7 +3461,11 @@ nfs_pathconf(struct vop_pathconf_args *ap)
}
switch (ap->a_name) {
case _PC_LINK_MAX:
+#ifdef _LP64
+   *ap->a_retval = pc.pc_linkmax;
+#else
*ap->a_retval = MIN(LONG_MAX, pc.pc_linkmax);
+#endif
break;
case _PC_NAME_MAX:
*ap->a_retval = pc.pc_namemax;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r327074 - in head/sys/mips: include mips

2017-12-21 Thread Konstantin Belousov
Author: kib
Date: Thu Dec 21 23:39:00 2017
New Revision: 327074
URL: https://svnweb.freebsd.org/changeset/base/327074

Log:
  Fix mips build after introduction of MD definitions of atomic_load_64
  and atomic_store_64.
  
  The MD definitions are provided for LP64 only, while mips also uses
  them for 32bit and n32.  Only define mips variants for 32bit and n32
  and change the syntax to match common definitions.
  
  Note that this commit does not fix 32bit asm implementation to follow
  new KBI, this will be fixed later.  The functions are only used for 8
  byte ddb accesses so the known bug does not prevent normal kernel
  operations.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/mips/include/atomic.h
  head/sys/mips/mips/db_interface.c

Modified: head/sys/mips/include/atomic.h
==
--- head/sys/mips/include/atomic.h  Thu Dec 21 23:08:10 2017
(r327073)
+++ head/sys/mips/include/atomic.h  Thu Dec 21 23:39:00 2017
(r327074)
@@ -342,20 +342,21 @@ atomic_store_rel_##WIDTH(__volatile uint##WIDTH##_t *p
 ATOMIC_STORE_LOAD(32)
 ATOMIC_STORE_LOAD(64)
 #if !defined(__mips_n64) && !defined(__mips_n32)
-void atomic_store_64(__volatile uint64_t *, uint64_t *);
-void atomic_load_64(__volatile uint64_t *, uint64_t *);
-#else
+void atomic_store_64(__volatile uint64_t *, uint64_t);
+uint64_t atomic_load_64(__volatile uint64_t *);
+#elif defined (__mips_n32)
 static __inline void
-atomic_store_64(__volatile uint64_t *p, uint64_t *v)
+atomic_store_64(__volatile uint64_t *p, uint64_t v)
 {
-   *p = *v;
+   *p = v;
 }
 
-static __inline void
-atomic_load_64(__volatile uint64_t *p, uint64_t *v)
+static __inline uint64_t
+atomic_load_64(__volatile uint64_t *p)
 {
-   *v = *p;
+   return (*p);
 }
+/* #else atomic_common.h definitions of atomic_load/store_64 are used */
 #endif
 
 #undef ATOMIC_STORE_LOAD

Modified: head/sys/mips/mips/db_interface.c
==
--- head/sys/mips/mips/db_interface.c   Thu Dec 21 23:08:10 2017
(r327073)
+++ head/sys/mips/mips/db_interface.c   Thu Dec 21 23:39:00 2017
(r327074)
@@ -164,9 +164,9 @@ db_read_bytes(vm_offset_t addr, size_t size, char *dat
*(uint32_t *)data = *(uint32_t *)addr;
break;
case 8:
-   atomic_load_64((volatile u_int64_t *)addr,
-   (u_int64_t *)data);
-   break;
+   *(uint64_t *)data = atomic_load_64(
+   (void *)addr);
+   break;
}
} else {
char *src;
@@ -207,9 +207,9 @@ db_write_bytes(vm_offset_t addr, size_t size, char *da
*(uint32_t *)addr = *(uint32_t *)data;
break;
case 8:
-   atomic_store_64((volatile u_int64_t *)addr,
-   (u_int64_t *)data);
-   break;
+   atomic_store_64((uint64_t *)addr,
+   *(uint64_t *)data);
+   break;
}
} else {
char *dst;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r327075 - head/etc/rc.d

2017-12-21 Thread Kevin Lo
Author: kevlo
Date: Fri Dec 22 01:46:25 2017
New Revision: 327075
URL: https://svnweb.freebsd.org/changeset/base/327075

Log:
  Add soft float abi caching form armv7,  it would allow people with old
  binaries to run them.
  
  Reviewed by:  imp

Modified:
  head/etc/rc.d/ldconfig

Modified: head/etc/rc.d/ldconfig
==
--- head/etc/rc.d/ldconfig  Thu Dec 21 23:39:00 2017(r327074)
+++ head/etc/rc.d/ldconfig  Fri Dec 22 01:46:25 2017(r327075)
@@ -63,7 +63,7 @@ ldconfig_start()
esac
 
case `sysctl -n hw.machine_arch` in
-   armv6)
+   armv[67])
for i in ${ldconfig_localsoft_dirs}; do
if [ -d "${i}" ]; then
_files=`find ${i} -type f`
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"