svn commit: r363411 - in head/sys/geom: cache concat eli label mirror mountver nop raid3 stripe virstor

2020-07-21 Thread Xin LI
Author: delphij
Date: Wed Jul 22 02:15:21 2020
New Revision: 363411
URL: https://svnweb.freebsd.org/changeset/base/363411

Log:
  Consistently use gctl_get_provider instead of home-grown variants.
  
  Reviewed by:  cem, imp
  MFC after:2 weeks
  Differential revision:https://reviews.freebsd.org/D25739

Modified:
  head/sys/geom/cache/g_cache.c
  head/sys/geom/concat/g_concat.c
  head/sys/geom/eli/g_eli_ctl.c
  head/sys/geom/label/g_label.c
  head/sys/geom/mirror/g_mirror_ctl.c
  head/sys/geom/mountver/g_mountver.c
  head/sys/geom/nop/g_nop.c
  head/sys/geom/raid3/g_raid3_ctl.c
  head/sys/geom/stripe/g_stripe.c
  head/sys/geom/virstor/g_virstor.c

Modified: head/sys/geom/cache/g_cache.c
==
--- head/sys/geom/cache/g_cache.c   Wed Jul 22 02:14:27 2020
(r363410)
+++ head/sys/geom/cache/g_cache.c   Wed Jul 22 02:15:21 2020
(r363411)
@@ -757,19 +757,9 @@ g_cache_ctl_create(struct gctl_req *req, struct g_clas
/* This field is not important here. */
md.md_provsize = 0;
 
-   name = gctl_get_asciiparam(req, "arg1");
-   if (name == NULL) {
-   gctl_error(req, "No 'arg1' argument");
+   pp = gctl_get_provider(req, "arg1");
+   if (pp == NULL)
return;
-   }
-   if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0)
-   name += strlen(_PATH_DEV);
-   pp = g_provider_by_name(name);
-   if (pp == NULL) {
-   G_CACHE_DEBUG(1, "Provider %s is invalid.", name);
-   gctl_error(req, "Provider %s is invalid.", name);
-   return;
-   }
gp = g_cache_create(mp, pp, , G_CACHE_TYPE_MANUAL);
if (gp == NULL) {
gctl_error(req, "Can't create %s.", md.md_name);

Modified: head/sys/geom/concat/g_concat.c
==
--- head/sys/geom/concat/g_concat.c Wed Jul 22 02:14:27 2020
(r363410)
+++ head/sys/geom/concat/g_concat.c Wed Jul 22 02:15:21 2020
(r363411)
@@ -840,19 +840,9 @@ g_concat_ctl_create(struct gctl_req *req, struct g_cla
/* Check all providers are valid */
for (no = 1; no < *nargs; no++) {
snprintf(param, sizeof(param), "arg%u", no);
-   name = gctl_get_asciiparam(req, param);
-   if (name == NULL) {
-   gctl_error(req, "No 'arg%u' argument.", no);
+   pp = gctl_get_provider(req, param);
+   if (pp == NULL)
return;
-   }
-   if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0)
-   name += strlen(_PATH_DEV);
-   pp = g_provider_by_name(name);
-   if (pp == NULL) {
-   G_CONCAT_DEBUG(1, "Disk %s is invalid.", name);
-   gctl_error(req, "Disk %s is invalid.", name);
-   return;
-   }
}
 
gp = g_concat_create(mp, , G_CONCAT_TYPE_MANUAL);
@@ -866,15 +856,13 @@ g_concat_ctl_create(struct gctl_req *req, struct g_cla
sbuf_printf(sb, "Can't attach disk(s) to %s:", gp->name);
for (attached = 0, no = 1; no < *nargs; no++) {
snprintf(param, sizeof(param), "arg%u", no);
-   name = gctl_get_asciiparam(req, param);
-   if (name == NULL) {
-   gctl_error(req, "No 'arg%d' argument.", no);
-   return;
+   pp = gctl_get_provider(req, param);
+   if (pp == NULL) {
+   name = gctl_get_asciiparam(req, param);
+   MPASS(name != NULL);
+   sbuf_printf(sb, " %s", name);
+   continue;
}
-   if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0)
-   name += strlen(_PATH_DEV);
-   pp = g_provider_by_name(name);
-   KASSERT(pp != NULL, ("Provider %s disappear?!", name));
if (g_concat_add_disk(sc, pp, no - 1) != 0) {
G_CONCAT_DEBUG(1, "Disk %u (%s) not attached to %s.",
no, pp->name, gp->name);

Modified: head/sys/geom/eli/g_eli_ctl.c
==
--- head/sys/geom/eli/g_eli_ctl.c   Wed Jul 22 02:14:27 2020
(r363410)
+++ head/sys/geom/eli/g_eli_ctl.c   Wed Jul 22 02:15:21 2020
(r363411)
@@ -58,7 +58,6 @@ g_eli_ctl_attach(struct gctl_req *req, struct g_class 
 {
struct g_eli_metadata md;
struct g_provider *pp;
-   const char *name;
u_char *key, mkey[G_ELI_DATAIVKEYLEN];
int *nargs, *detach, *readonly, *dryrunp;
int keysize, error, nkey, dryrun, dummy;
@@ -115,22 +114,13 @@ g_eli_ctl_attach(struct gctl_req *req, struct g_class 

svn commit: r363410 - head/sys/geom

2020-07-21 Thread Xin LI
Author: delphij
Date: Wed Jul 22 02:14:27 2020
New Revision: 363410
URL: https://svnweb.freebsd.org/changeset/base/363410

Log:
  gctl_get_class, gctl_get_geom and gctl_get_provider: provide feedback
  when the requested argument is missing.
  
  Reviewed by:  cem
  MFC after:2 weeks
  Differential revision:https://reviews.freebsd.org/D25738

Modified:
  head/sys/geom/geom_ctl.c

Modified: head/sys/geom/geom_ctl.c
==
--- head/sys/geom/geom_ctl.cWed Jul 22 02:09:10 2020(r363409)
+++ head/sys/geom/geom_ctl.cWed Jul 22 02:14:27 2020(r363410)
@@ -396,12 +396,15 @@ gctl_get_class(struct gctl_req *req, char const *arg)
struct g_class *cp;
 
p = gctl_get_asciiparam(req, arg);
-   if (p == NULL)
+   if (p == NULL) {
+   gctl_error(req, "Missing %s argument", arg);
return (NULL);
+   }
LIST_FOREACH(cp, _classes, class) {
if (!strcmp(p, cp->name))
return (cp);
}
+   gctl_error(req, "Class not found: \"%s\"", p);
return (NULL);
 }
 
@@ -413,8 +416,10 @@ gctl_get_geom(struct gctl_req *req, struct g_class *mp
struct g_geom *gp;
 
p = gctl_get_asciiparam(req, arg);
-   if (p == NULL)
+   if (p == NULL) {
+   gctl_error(req, "Missing %s argument", arg);
return (NULL);
+   }
LIST_FOREACH(mp, _classes, class) {
if (mpr != NULL && mpr != mp)
continue;
@@ -434,8 +439,10 @@ gctl_get_provider(struct gctl_req *req, char const *ar
struct g_provider *pp;
 
p = gctl_get_asciiparam(req, arg);
-   if (p == NULL)
+   if (p == NULL) {
+   gctl_error(req, "Missing '%s' argument", arg);
return (NULL);
+   }
pp = g_provider_by_name(p);
if (pp != NULL)
return (pp);
@@ -453,10 +460,8 @@ g_ctl_req(void *arg, int flag __unused)
g_topology_assert();
req = arg;
mp = gctl_get_class(req, "class");
-   if (mp == NULL) {
-   gctl_error(req, "Class not found");
+   if (mp == NULL)
return;
-   }
if (mp->ctlreq == NULL) {
gctl_error(req, "Class takes no requests");
return;
___
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: r363409 - head/lib/libbe

2020-07-21 Thread Kyle Evans
Author: kevans
Date: Wed Jul 22 02:09:10 2020
New Revision: 363409
URL: https://svnweb.freebsd.org/changeset/base/363409

Log:
  libbe: annotate lbh as __unused in be_is_auto_snapshot_name
  
  lbh is included for consistency with other functions and in case
  future work needs to use it, but it is currently unused. Mark it,
  and a post-OpenZFS-import world will be able to raise WARNS of
  libbe to the default (pending some minor changes to openzfs libzfs).
  
  MFC after:3 days

Modified:
  head/lib/libbe/be.c

Modified: head/lib/libbe/be.c
==
--- head/lib/libbe/be.c Wed Jul 22 00:44:47 2020(r363408)
+++ head/lib/libbe/be.c Wed Jul 22 02:09:10 2020(r363409)
@@ -563,7 +563,7 @@ be_setup_snapshot_name(libbe_handle_t *lbh, char *buf,
 }
 
 bool
-be_is_auto_snapshot_name(libbe_handle_t *lbh, const char *name)
+be_is_auto_snapshot_name(libbe_handle_t *lbh __unused, const char *name)
 {
const char *snap;
int day, hour, minute, month, second, serial, year;
___
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: r363408 - head/libexec/getty

2020-07-21 Thread Warner Losh
Author: imp
Date: Wed Jul 22 00:44:47 2020
New Revision: 363408
URL: https://svnweb.freebsd.org/changeset/base/363408

Log:
  getty appears to date from 3rd edition research unix. That's the oldest man 
page
  on TUHS and its 'unix 1972' restoration effort has assembler sources that look
  like simpler version of what's in the 5th edition.

Modified:
  head/libexec/getty/getty.8

Modified: head/libexec/getty/getty.8
==
--- head/libexec/getty/getty.8  Tue Jul 21 23:38:05 2020(r363407)
+++ head/libexec/getty/getty.8  Wed Jul 22 00:44:47 2020(r363408)
@@ -28,7 +28,7 @@
 .\" from: @(#)getty.8  8.1 (Berkeley) 6/4/93
 .\" $FreeBSD$
 .\" "
-.Dd March 2, 2018
+.Dd July 21, 2020
 .Dt GETTY 8
 .Os
 .Sh NAME
@@ -122,4 +122,4 @@ does not exist.
 A
 .Nm
 utility appeared in
-.At v6 .
+.At v3 .
___
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: r363404 - in head/sys: kern riscv/riscv

2020-07-21 Thread Mitchell Horne
Author: mhorne
Date: Tue Jul 21 22:47:02 2020
New Revision: 363404
URL: https://svnweb.freebsd.org/changeset/base/363404

Log:
  INTRNG: only shuffle for !EARLY_AP_STARTUP
  
  During device attachment, all interrupt sources will bind to the BSP,
  as it is the only processor online. This means interrupts must be
  redistributed ("shuffled") later, during SI_SUB_SMP.
  
  For the EARLY_AP_STARTUP case, this is no longer true. SI_SUB_SMP will
  execute much earlier, meaning APs will be online and available before
  devices begin attachment, and there will therefore be nothing to
  shuffle.
  
  All PIC-conforming interrupt controllers will handle this early
  distribution properly, except for RISC-V's PLIC. Make the necessary
  tweak to the PLIC driver.
  
  While here, convert irq_assign_cpu from a boolean_t to a bool.
  
  Reviewed by:  markj
  Differential Revision:https://reviews.freebsd.org/D25693

Modified:
  head/sys/kern/subr_intr.c
  head/sys/riscv/riscv/plic.c

Modified: head/sys/kern/subr_intr.c
==
--- head/sys/kern/subr_intr.c   Tue Jul 21 19:56:13 2020(r363403)
+++ head/sys/kern/subr_intr.c   Tue Jul 21 22:47:02 2020(r363404)
@@ -128,8 +128,12 @@ static struct intr_irqsrc *irq_sources[NIRQ];
 u_int irq_next_free;
 
 #ifdef SMP
-static boolean_t irq_assign_cpu = FALSE;
+#ifdef EARLY_AP_STARTUP
+static bool irq_assign_cpu = true;
+#else
+static bool irq_assign_cpu = false;
 #endif
+#endif
 
 /*
  * - 2 counters for each I/O interrupt.
@@ -1191,6 +1195,7 @@ intr_irq_next_cpu(u_int last_cpu, cpuset_t *cpumask)
return (last_cpu);
 }
 
+#ifndef EARLY_AP_STARTUP
 /*
  *  Distribute all the interrupt sources among the available
  *  CPUs once the AP's have been launched.
@@ -1205,7 +1210,7 @@ intr_irq_shuffle(void *arg __unused)
return;
 
mtx_lock(_table_lock);
-   irq_assign_cpu = TRUE;
+   irq_assign_cpu = true;
for (i = 0; i < NIRQ; i++) {
isrc = irq_sources[i];
if (isrc == NULL || isrc->isrc_handlers == 0 ||
@@ -1231,6 +1236,7 @@ intr_irq_shuffle(void *arg __unused)
mtx_unlock(_table_lock);
 }
 SYSINIT(intr_irq_shuffle, SI_SUB_SMP, SI_ORDER_SECOND, intr_irq_shuffle, NULL);
+#endif /* !EARLY_AP_STARTUP */
 
 #else
 u_int
@@ -1239,7 +1245,7 @@ intr_irq_next_cpu(u_int current_cpu, cpuset_t *cpumask
 
return (PCPU_GET(cpuid));
 }
-#endif
+#endif /* SMP */
 
 /*
  * Allocate memory for new intr_map_data structure.

Modified: head/sys/riscv/riscv/plic.c
==
--- head/sys/riscv/riscv/plic.c Tue Jul 21 19:56:13 2020(r363403)
+++ head/sys/riscv/riscv/plic.c Tue Jul 21 22:47:02 2020(r363404)
@@ -408,8 +408,7 @@ plic_setup_intr(device_t dev, struct intr_irqsrc *isrc
sc = device_get_softc(dev);
src = (struct plic_irqsrc *)isrc;
 
-   /* Bind to the boot CPU for now. */
-   CPU_SET(PCPU_GET(cpuid), >isrc_cpu);
+   CPU_ZERO(>isrc_cpu);
plic_bind_intr(dev, isrc);
 
return (0);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r363403 - in head/sys: fs/nfsclient net netinet6 nfs

2020-07-21 Thread Alexander V. Chernikov
Author: melifaro
Date: Tue Jul 21 19:56:13 2020
New Revision: 363403
URL: https://svnweb.freebsd.org/changeset/base/363403

Log:
  Transition from rtrequest1_fib() to rib_action().
  
  Remove all variations of rtrequest  and their uses and switch to
   to rib_action(). This is part of the new routing KPI.
  
  Submitted by: Neel Chauhan 
  Differential Revision: https://reviews.freebsd.org/D25546

Modified:
  head/sys/fs/nfsclient/nfs_clvfsops.c
  head/sys/net/if.c
  head/sys/net/route.c
  head/sys/net/route.h
  head/sys/netinet6/in6_rmx.c
  head/sys/netinet6/in6_var.h
  head/sys/netinet6/nd6.c
  head/sys/netinet6/nd6_rtr.c
  head/sys/nfs/bootp_subr.c

Modified: head/sys/fs/nfsclient/nfs_clvfsops.c
==
--- head/sys/fs/nfsclient/nfs_clvfsops.cTue Jul 21 19:18:29 2020
(r363402)
+++ head/sys/fs/nfsclient/nfs_clvfsops.cTue Jul 21 19:56:13 2020
(r363403)
@@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -466,6 +467,8 @@ nfs_mountroot(struct mount *mp)
nd->mygateway.sin_addr.s_addr != 0) {
struct sockaddr_in mask, sin;
struct epoch_tracker et;
+   struct rt_addrinfo info;
+   struct rib_cmd_info rc;
 
bzero((caddr_t), sizeof(mask));
sin = mask;
@@ -474,10 +477,14 @@ nfs_mountroot(struct mount *mp)
 /* XXX MRT use table 0 for this sort of thing */
NET_EPOCH_ENTER(et);
CURVNET_SET(TD_TO_VNET(td));
-   error = rtrequest_fib(RTM_ADD, (struct sockaddr *),
-   (struct sockaddr *)>mygateway,
-   (struct sockaddr *),
-   RTF_UP | RTF_GATEWAY, NULL, RT_DEFAULT_FIB);
+
+   bzero((caddr_t), sizeof(info));
+   info.rti_flags = RTF_UP | RTF_GATEWAY;
+   info.rti_info[RTAX_DST] = (struct sockaddr *)
+   info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)>mygateway;
+   info.rti_info[RTAX_NETMASK] = (struct sockaddr *)
+
+   error = rib_action(RT_DEFAULT_FIB, RTM_ADD, , );
CURVNET_RESTORE();
NET_EPOCH_EXIT(et);
if (error)

Modified: head/sys/net/if.c
==
--- head/sys/net/if.c   Tue Jul 21 19:18:29 2020(r363402)
+++ head/sys/net/if.c   Tue Jul 21 19:56:13 2020(r363403)
@@ -80,6 +80,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #if defined(INET) || defined(INET6)
@@ -1845,6 +1846,7 @@ static int
 ifa_maintain_loopback_route(int cmd, const char *otype, struct ifaddr *ifa,
 struct sockaddr *ia)
 {
+   struct rib_cmd_info rc;
struct epoch_tracker et;
int error;
struct rt_addrinfo info;
@@ -1872,7 +1874,7 @@ ifa_maintain_loopback_route(int cmd, const char *otype
info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)_sdl;
link_init_sdl(ifp, (struct sockaddr *)_sdl, ifp->if_type);
 
-   error = rtrequest1_fib(cmd, , NULL, ifp->if_fib);
+   error = rib_action(ifp->if_fib, cmd, , );
NET_EPOCH_EXIT(et);
 
if (rti_ifa != NULL)

Modified: head/sys/net/route.c
==
--- head/sys/net/route.cTue Jul 21 19:18:29 2020(r363402)
+++ head/sys/net/route.cTue Jul 21 19:56:13 2020(r363403)
@@ -470,7 +470,7 @@ int
 rib_add_redirect(u_int fibnum, struct sockaddr *dst, struct sockaddr *gateway,
 struct sockaddr *author, struct ifnet *ifp, int flags, int lifetime_sec)
 {
-   struct rtentry *rt;
+   struct rib_cmd_info rc;
int error;
struct rt_addrinfo info;
struct rt_metrics rti_rmx;
@@ -504,7 +504,7 @@ rib_add_redirect(u_int fibnum, struct sockaddr *dst, s
info.rti_mflags |= RTV_EXPIRE;
info.rti_rmx = _rmx;
 
-   error = rtrequest1_fib(RTM_ADD, , , fibnum);
+   error = rib_action(fibnum, RTM_ADD, , );
ifa_free(ifa);
 
if (error != 0) {
@@ -512,9 +512,9 @@ rib_add_redirect(u_int fibnum, struct sockaddr *dst, s
return (error);
}
 
-   RT_LOCK(rt);
-   flags = rt->rt_flags;
-   RT_UNLOCK(rt);
+   RT_LOCK(rc.rc_rt);
+   flags = rc.rc_rt->rt_flags;
+   RT_UNLOCK(rc.rc_rt);
 
RTSTAT_INC(rts_dynamic);
 
@@ -602,33 +602,7 @@ ifa_ifwithroute(int flags, const struct sockaddr *dst,
return (ifa);
 }
 
-/*
- * Do appropriate manipulations of a routing tree given
- * all the bits of info needed
- */
-int
-rtrequest_fib(int req,
-   struct sockaddr *dst,
-   struct sockaddr *gateway,
-   struct sockaddr *netmask,
-   int flags,
-   struct rtentry **ret_nrt,
-   u_int fibnum)
-{
-   struct rt_addrinfo info;
 
-   if (dst->sa_len == 0)
-

svn commit: r363402 - in head: sys/geom/eli tests/sys/geom/class/eli

2020-07-21 Thread Alan Somers
Author: asomers
Date: Tue Jul 21 19:18:29 2020
New Revision: 363402
URL: https://svnweb.freebsd.org/changeset/base/363402

Log:
  Fix geli's null cipher, and add a test case
  
  PR:   247954
  Submitted by: jhb (sys), asomers (tests)
  Reviewed by:  jhb (tests), asomers (sys)
  MFC after:2 weeks
  Sponsored by: Axcient

Modified:
  head/sys/geom/eli/g_eli_integrity.c
  head/sys/geom/eli/g_eli_privacy.c
  head/tests/sys/geom/class/eli/onetime_test.sh

Modified: head/sys/geom/eli/g_eli_integrity.c
==
--- head/sys/geom/eli/g_eli_integrity.c Tue Jul 21 17:34:05 2020
(r363401)
+++ head/sys/geom/eli/g_eli_integrity.c Tue Jul 21 19:18:29 2020
(r363402)
@@ -536,13 +536,15 @@ g_eli_auth_run(struct g_eli_worker *wr, struct bio *bp
crp->crp_digest_start = 0;
crp->crp_payload_start = sc->sc_alen;
crp->crp_payload_length = data_secsize;
-   crp->crp_flags |= CRYPTO_F_IV_SEPARATE;
if ((sc->sc_flags & G_ELI_FLAG_FIRST_KEY) == 0) {
crp->crp_cipher_key = g_eli_key_hold(sc, dstoff,
encr_secsize);
}
-   g_eli_crypto_ivgen(sc, dstoff, crp->crp_iv,
-   sizeof(crp->crp_iv));
+   if (g_eli_ivlen(sc->sc_ealgo) != 0) {
+   crp->crp_flags |= CRYPTO_F_IV_SEPARATE;
+   g_eli_crypto_ivgen(sc, dstoff, crp->crp_iv,
+   sizeof(crp->crp_iv));
+   }
 
g_eli_auth_keygen(sc, dstoff, authkey);
crp->crp_auth_key = authkey;

Modified: head/sys/geom/eli/g_eli_privacy.c
==
--- head/sys/geom/eli/g_eli_privacy.c   Tue Jul 21 17:34:05 2020
(r363401)
+++ head/sys/geom/eli/g_eli_privacy.c   Tue Jul 21 19:18:29 2020
(r363402)
@@ -281,13 +281,15 @@ g_eli_crypto_run(struct g_eli_worker *wr, struct bio *
 
crp->crp_payload_start = 0;
crp->crp_payload_length = secsize;
-   crp->crp_flags |= CRYPTO_F_IV_SEPARATE;
if ((sc->sc_flags & G_ELI_FLAG_SINGLE_KEY) == 0) {
crp->crp_cipher_key = g_eli_key_hold(sc, dstoff,
secsize);
}
-   g_eli_crypto_ivgen(sc, dstoff, crp->crp_iv,
-   sizeof(crp->crp_iv));
+   if (g_eli_ivlen(sc->sc_ealgo) != 0) {
+   crp->crp_flags |= CRYPTO_F_IV_SEPARATE;
+   g_eli_crypto_ivgen(sc, dstoff, crp->crp_iv,
+   sizeof(crp->crp_iv));
+   }
 
error = crypto_dispatch(crp);
KASSERT(error == 0, ("crypto_dispatch() failed (error=%d)",

Modified: head/tests/sys/geom/class/eli/onetime_test.sh
==
--- head/tests/sys/geom/class/eli/onetime_test.sh   Tue Jul 21 17:34:05 
2020(r363401)
+++ head/tests/sys/geom/class/eli/onetime_test.sh   Tue Jul 21 19:18:29 
2020(r363402)
@@ -130,9 +130,54 @@ onetime_d_cleanup()
geli_test_cleanup
 }
 
+atf_test_case onetime cleanup
+onetime_null_head()
+{
+   atf_set "descr" "geli onetime can use the null cipher"
+   atf_set "require.user" "root"
+}
+onetime_null_body()
+{
+   geli_test_setup
+
+   sectors=100
+
+   dd if=/dev/random of=rnd bs=${MAX_SECSIZE} count=${sectors} status=none
+
+   secsize=512
+   ealgo=${cipher%%:*}
+   keylen=${cipher##*:}
+
+   md=$(attach_md -t malloc -s 100k)
+
+   atf_check -s exit:0 -o ignore -e ignore \
+   geli onetime -e null -s ${secsize} ${md}
+
+   atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=${sectors} 
status=none
+
+   md_rnd=`dd if=rnd bs=${secsize} count=${sectors} status=none | md5`
+   atf_check_equal 0 $?
+   md_ddev=`dd if=/dev/${md}.eli bs=${secsize} count=${sectors} 
status=none | md5`
+   atf_check_equal 0 $?
+   md_edev=`dd if=/dev/${md} bs=${secsize} count=${sectors} status=none | 
md5`
+   atf_check_equal 0 $?
+
+   if [ ${md_rnd} != ${md_ddev} ]; then
+   atf_fail "geli did not return the original data"
+   fi
+   if [ ${md_rnd} != ${md_edev} ]; then
+   atf_fail "geli encrypted the data even with the null cipher"
+   fi
+}
+onetime_null_cleanup()
+{
+   geli_test_cleanup
+}
+
 atf_init_test_cases()
 {
atf_add_test_case onetime
atf_add_test_case onetime_a
atf_add_test_case onetime_d
+   atf_add_test_case onetime_null
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r363401 - in head/lib/clang/include: . llvm/Support

2020-07-21 Thread Dimitry Andric
Author: dim
Date: Tue Jul 21 17:34:05 2020
New Revision: 363401
URL: https://svnweb.freebsd.org/changeset/base/363401

Log:
  Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
  10.0.1 final (aka llvmorg-10.0.1-0-gef32c611aa2).
  
  There were no changes since rc2, except in the upstream regression
  tests, which we do not ship.
  
  Relnotes: yes
  MFC after:immediately (no material changes except tag)

Modified:
  head/lib/clang/include/VCSVersion.inc
  head/lib/clang/include/llvm/Support/VCSRevision.h
Directory Properties:
  head/contrib/llvm-project/   (props changed)

Modified: head/lib/clang/include/VCSVersion.inc
==
--- head/lib/clang/include/VCSVersion.inc   Tue Jul 21 17:20:34 2020
(r363400)
+++ head/lib/clang/include/VCSVersion.inc   Tue Jul 21 17:34:05 2020
(r363401)
@@ -1,14 +1,14 @@
 // $FreeBSD$
 
-#define LLVM_REVISION "llvmorg-10.0.1-rc2-0-g77d76b71d7d"
+#define LLVM_REVISION "llvmorg-10.0.1-0-gef32c611aa2"
 #define LLVM_REPOSITORY "g...@github.com:llvm/llvm-project.git"
 
-#define CLANG_REVISION "llvmorg-10.0.1-rc2-0-g77d76b71d7d"
+#define CLANG_REVISION "llvmorg-10.0.1-0-gef32c611aa2"
 #define CLANG_REPOSITORY "g...@github.com:llvm/llvm-project.git"
 
 // -
-#define LLD_REVISION "llvmorg-10.0.1-rc2-0-g77d76b71d7d-137"
+#define LLD_REVISION "llvmorg-10.0.1-0-gef32c611aa2-137"
 #define LLD_REPOSITORY "FreeBSD"
 
-#define LLDB_REVISION "llvmorg-10.0.1-rc2-0-g77d76b71d7d"
+#define LLDB_REVISION "llvmorg-10.0.1-0-gef32c611aa2"
 #define LLDB_REPOSITORY "g...@github.com:llvm/llvm-project.git"

Modified: head/lib/clang/include/llvm/Support/VCSRevision.h
==
--- head/lib/clang/include/llvm/Support/VCSRevision.h   Tue Jul 21 17:20:34 
2020(r363400)
+++ head/lib/clang/include/llvm/Support/VCSRevision.h   Tue Jul 21 17:34:05 
2020(r363401)
@@ -1,3 +1,3 @@
 /* $FreeBSD$ */
-#define LLVM_REVISION "llvmorg-10.0.1-rc2-0-g77d76b71d7d"
+#define LLVM_REVISION "llvmorg-10.0.1-0-gef32c611aa2"
 #define LLVM_REPOSITORY "g...@github.com:llvm/llvm-project.git"
___
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: r363399 - in head/sys: amd64/amd64 i386/i386

2020-07-21 Thread Alexander Motin
Author: mav
Date: Tue Jul 21 17:18:38 2020
New Revision: 363399
URL: https://svnweb.freebsd.org/changeset/base/363399

Log:
  Avoid code duplicaiton by using ipi_selected().
  
  MFC after:2 weeks

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

Modified: head/sys/amd64/amd64/mp_machdep.c
==
--- head/sys/amd64/amd64/mp_machdep.c   Tue Jul 21 16:46:40 2020
(r363398)
+++ head/sys/amd64/amd64/mp_machdep.c   Tue Jul 21 17:18:38 2020
(r363399)
@@ -696,13 +696,7 @@ smp_targeted_tlb_shootdown(cpuset_t mask, pmap_t pmap,
CPU_CLR(PCPU_GET(cpuid), _cpus);
} else {
other_cpus = mask;
-   while ((cpu = CPU_FFS()) != 0) {
-   cpu--;
-   CPU_CLR(cpu, );
-   CTR3(KTR_SMP, "%s: cpu: %d invl ipi op: %x", __func__,
-   cpu, op);
-   ipi_send_cpu(cpu, IPI_INVLOP);
-   }
+   ipi_selected(mask, IPI_INVLOP);
}
curcpu_cb(pmap, addr1, addr2);
while ((cpu = CPU_FFS(_cpus)) != 0) {

Modified: head/sys/i386/i386/mp_machdep.c
==
--- head/sys/i386/i386/mp_machdep.c Tue Jul 21 16:46:40 2020
(r363398)
+++ head/sys/i386/i386/mp_machdep.c Tue Jul 21 17:18:38 2020
(r363399)
@@ -536,13 +536,7 @@ smp_targeted_tlb_shootdown(cpuset_t mask, u_int vector
CPU_CLR(PCPU_GET(cpuid), _cpus);
} else {
other_cpus = mask;
-   while ((cpu = CPU_FFS()) != 0) {
-   cpu--;
-   CPU_CLR(cpu, );
-   CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__,
-   cpu, vector);
-   ipi_send_cpu(cpu, vector);
-   }
+   ipi_selected(mask, vector);
}
curcpu_cb(pmap, addr1, addr2);
while ((cpu = CPU_FFS(_cpus)) != 0) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r363398 - head/lib/libc/sys

2020-07-21 Thread Alan Somers
Author: asomers
Date: Tue Jul 21 16:46:40 2020
New Revision: 363398
URL: https://svnweb.freebsd.org/changeset/base/363398

Log:
  [skip ci] document close_range(2) as async-signal-safe
  
  Reviewed by:  bcr (manpages)
  MFC after:2 weeks
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D25513

Modified:
  head/lib/libc/sys/sigaction.2

Modified: head/lib/libc/sys/sigaction.2
==
--- head/lib/libc/sys/sigaction.2   Tue Jul 21 16:21:52 2020
(r363397)
+++ head/lib/libc/sys/sigaction.2   Tue Jul 21 16:46:40 2020
(r363398)
@@ -28,7 +28,7 @@
 .\"From: @(#)sigaction.2   8.2 (Berkeley) 4/3/94
 .\" $FreeBSD$
 .\"
-.Dd June 28, 2018
+.Dd June 29, 2020
 .Dt SIGACTION 2
 .Os
 .Sh NAME
@@ -569,6 +569,7 @@ Extension Interfaces:
 .Pp
 .Fn accept4 ,
 .Fn bindat ,
+.Fn close_range ,
 .Fn closefrom ,
 .Fn connectat ,
 .Fn eaccess ,
___
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: r363397 - head/sys/netinet/cc

2020-07-21 Thread Richard Scheffenegger
Author: rscheff
Date: Tue Jul 21 16:21:52 2020
New Revision: 363397
URL: https://svnweb.freebsd.org/changeset/base/363397

Log:
  Fix style and comment around concave/convex regions in TCP cubic.
  
  In cubic, the concave region is when snd_cwnd starts growing slower
  towards max_cwnd (cwnd at the time of the congestion event), and
  the convex region is when snd_cwnd starts to grow faster and
  eventually appearing like slow-start like growth.
  
  PR:   238478
  Reviewed by:  tuexen (mentor), rgrimes (mentor)
  Approved by:  tuexen (mentor), rgrimes (mentor)
  MFC after:2 weeks
  Sponsored by: NetApp, Inc.
  Differential Revision:https://reviews.freebsd.org/D24657

Modified:
  head/sys/netinet/cc/cc_cubic.c

Modified: head/sys/netinet/cc/cc_cubic.c
==
--- head/sys/netinet/cc/cc_cubic.c  Tue Jul 21 16:17:23 2020
(r363396)
+++ head/sys/netinet/cc/cc_cubic.c  Tue Jul 21 16:21:52 2020
(r363397)
@@ -185,12 +185,11 @@ cubic_ack_received(struct cc_var *ccv, uint16_t type)
 */
if (CCV(ccv, snd_cwnd) < w_tf)
CCV(ccv, snd_cwnd) = ulmin(w_tf, 
INT_MAX);
-   }
-
-   else if (CCV(ccv, snd_cwnd) < w_cubic_next) {
+   } else if (CCV(ccv, snd_cwnd) < w_cubic_next) {
/*
 * Concave or convex region, follow CUBIC
 * cwnd growth.
+* Only update snd_cwnd, if it doesn't shrink.
 */
if (V_tcp_do_rfc3465)
CCV(ccv, snd_cwnd) = ulmin(w_cubic_next,
___
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: r363396 - head/usr.bin/netstat

2020-07-21 Thread Fernando ApesteguĂ­a
Author: fernape (ports committer)
Date: Tue Jul 21 16:17:23 2020
New Revision: 363396
URL: https://svnweb.freebsd.org/changeset/base/363396

Log:
  netstat(1): Add EXAMPLES section
  
  * Add small EXAMPLES section
  * Fix warning reported by mandoc (./netstat.1:747:2: WARNING: skipping 
paragraph
macro: Pp before Ss)
  
  Approved by:  manpages (gbe)
  Differential Revision: https://reviews.freebsd.org/D25212

Modified:
  head/usr.bin/netstat/netstat.1

Modified: head/usr.bin/netstat/netstat.1
==
--- head/usr.bin/netstat/netstat.1  Tue Jul 21 15:03:36 2020
(r363395)
+++ head/usr.bin/netstat/netstat.1  Tue Jul 21 16:17:23 2020
(r363396)
@@ -28,7 +28,7 @@
 .\"@(#)netstat.1   8.8 (Berkeley) 4/18/94
 .\" $FreeBSD$
 .\"
-.Dd March 22, 2018
+.Dd July 21, 2020
 .Dt NETSTAT 1
 .Os
 .Sh NAME
@@ -744,7 +744,6 @@ The flags field shows available ISR handlers:
 .It Li F Ta Dv NETISR_SNP_FLAGS_M2FLOW Ta "Able to map mbuf to flow id"
 .El
 .El
-.Pp
 .Ss GENERAL OPTIONS
 Some options have the general meaning:
 .Bl -tag -width flag
@@ -798,6 +797,28 @@ Normally
 attempts to resolve addresses and ports,
 and display them symbolically.
 .El
+.Sh EXAMPLES
+Show packet traffic information (packets, bytes, errors, packet drops, etc) for
+interface re0 updated every 2 seconds and exit after 5 outputs:
+.Bd -literal -offset indent
+$ netstat -w 2 -q 5 -I re0
+.Ed
+.Pp
+Show statistics for ICMP on any interface:
+.Bd -literal -offset indent
+$ netstat -s -p icmp
+.Ed
+.Pp
+Show routing tables:
+.Bd -literal -offset indent
+$ netstat -r
+.Ed
+.Pp
+Same as above, but without resolving numeric addresses and port numbers to
+names:
+.Bd -literal -offset indent
+$ netstat -rn
+.Ed
 .Sh SEE ALSO
 .Xr fstat 1 ,
 .Xr nfsstat 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: r363395 - head/usr.sbin/traceroute6

2020-07-21 Thread Mark Johnston
Author: markj
Date: Tue Jul 21 15:03:36 2020
New Revision: 363395
URL: https://svnweb.freebsd.org/changeset/base/363395

Log:
  traceroute6: Fix most warnings at the default WARNS level.
  
  Fix some style issues as well.  Leave -Wno-cast-aligned set for now, as
  most of the warnings come casts of CMSG_DATA(), which does provide
  sufficient alignment in practice.
  
  Submitted by: Shubh Gupta 
  Sponsored by: Google (GSOC 2020)
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D25603

Modified:
  head/usr.sbin/traceroute6/Makefile
  head/usr.sbin/traceroute6/traceroute6.c

Modified: head/usr.sbin/traceroute6/Makefile
==
--- head/usr.sbin/traceroute6/Makefile  Tue Jul 21 14:42:22 2020
(r363394)
+++ head/usr.sbin/traceroute6/Makefile  Tue Jul 21 15:03:36 2020
(r363395)
@@ -26,8 +26,8 @@ BINMODE= 4555
 CFLAGS+= -DIPSEC -DHAVE_POLL
 CFLAGS+= -I${.CURDIR} -I${TRACEROUTE_DISTDIR} -I.
 
-WARNS?=3
-
 LIBADD=ipsec
 
 .include 
+
+CWARNFLAGS+= -Wno-cast-align

Modified: head/usr.sbin/traceroute6/traceroute6.c
==
--- head/usr.sbin/traceroute6/traceroute6.c Tue Jul 21 14:42:22 2020
(r363394)
+++ head/usr.sbin/traceroute6/traceroute6.c Tue Jul 21 15:03:36 2020
(r363395)
@@ -294,16 +294,14 @@ static const char rcsid[] =
 #define freehostent(x)
 #endif
 
-u_char packet[512];/* last inbound (icmp) packet */
-char   *outpacket; /* last output packet */
+static u_char  packet[512];/* last inbound (icmp) packet */
+static char*outpacket; /* last output packet */
 
 intmain(int, char *[]);
 intwait_for_reply(int, struct msghdr *);
-#ifdef IPSEC
-#ifdef IPSEC_POLICY_IPSEC
+#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
 intsetpolicy(int so, char *policy);
 #endif
-#endif
 void   send_probe(int, u_long);
 void   *get_uphdr(struct ip6_hdr *, u_char *);
 intget_hoplim(struct msghdr *);
@@ -318,40 +316,40 @@ u_int16_t tcp_chksum(struct sockaddr_in6 *, struct soc
 void *, u_int32_t);
 void   usage(void);
 
-int rcvsock;   /* receive (icmp) socket file descriptor */
-int sndsock;   /* send (raw/udp) socket file descriptor */
+static int rcvsock;/* receive (icmp) socket file 
descriptor */
+static int sndsock;/* send (raw/udp) socket file 
descriptor */
 
-struct msghdr rcvmhdr;
-struct iovec rcviov[2];
-int rcvhlim;
-struct in6_pktinfo *rcvpktinfo;
+static struct msghdr rcvmhdr;
+static struct iovec rcviov[2];
+static int rcvhlim;
+static struct in6_pktinfo *rcvpktinfo;
 
-struct sockaddr_in6 Src, Dst, Rcv;
-u_long datalen = 20;   /* How much data */
+static struct sockaddr_in6 Src, Dst, Rcv;
+static u_long datalen = 20;/* How much data */
 #defineICMP6ECHOLEN8
 /* XXX: 2064 = 127(max hops in type 0 rthdr) * sizeof(ip6_hdr) + 16(margin) */
-char rtbuf[2064];
-struct ip6_rthdr *rth;
-struct cmsghdr *cmsg;
+static char rtbuf[2064];
+static struct ip6_rthdr *rth;
+static struct cmsghdr *cmsg;
 
-char *source = NULL;
-char *hostname;
+static char *source = NULL;
+static char *hostname;
 
-u_long nprobes = 3;
-u_long first_hop = 1;
-u_long max_hops = 30;
-u_int16_t srcport;
-u_int16_t port = 32768+666;/* start udp dest port # for probe packets */
-u_int16_t ident;
-int options;   /* socket options */
-int verbose;
-int waittime = 5;  /* time to wait for response (in seconds) */
-int nflag; /* print addresses numerically */
-int useproto = IPPROTO_UDP;/* protocol to use to send packet */
-int lflag; /* print both numerical address & hostname */
-int as_path;   /* print as numbers for each hop */
-char *as_server = NULL;
-void *asn;
+static u_long nprobes = 3;
+static u_long first_hop = 1;
+static u_long max_hops = 30;
+static u_int16_t srcport;
+static u_int16_t port = 32768+666; /* start udp dest port # for probe 
packets */
+static u_int16_t ident;
+static int options;/* socket options */
+static int verbose;
+static int waittime = 5;   /* time to wait for response (in 
seconds) */
+static int nflag;  /* print addresses numerically */
+static int useproto = IPPROTO_UDP; /* protocol to use to send packet */
+static int lflag;  /* print both numerical address & 
hostname */
+static int as_path;/* print as numbers for each hop */
+static char *as_server = NULL;
+static void *asn;
 
 int
 main(int argc, char *argv[])
@@ -366,6 +364,10 @@ main(int argc, char *argv[])
size_t size, minlen;
uid_t uid;
u_char type, code;
+#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
+   char ipsec_inpolicy[] 

svn commit: r363393 - head/sys/kern

2020-07-21 Thread Mateusz Guzik
Author: mjg
Date: Tue Jul 21 14:41:25 2020
New Revision: 363393
URL: https://svnweb.freebsd.org/changeset/base/363393

Log:
  lockmgr: rewrite upgrade to stop always dropping the lock
  
  This matches rw and sx locks.

Modified:
  head/sys/kern/kern_lock.c

Modified: head/sys/kern/kern_lock.c
==
--- head/sys/kern/kern_lock.c   Tue Jul 21 14:39:20 2020(r363392)
+++ head/sys/kern/kern_lock.c   Tue Jul 21 14:41:25 2020(r363393)
@@ -878,9 +878,8 @@ static __noinline int
 lockmgr_upgrade(struct lock *lk, u_int flags, struct lock_object *ilk,
 const char *file, int line, struct lockmgr_wait *lwa)
 {
-   uintptr_t tid, x, v;
+   uintptr_t tid, v, setv;
int error = 0;
-   int wakeup_swapper = 0;
int op;
 
if (KERNEL_PANICKED())
@@ -889,48 +888,47 @@ lockmgr_upgrade(struct lock *lk, u_int flags, struct l
tid = (uintptr_t)curthread;
 
_lockmgr_assert(lk, KA_SLOCKED, file, line);
-   v = lockmgr_read_value(lk);
-   x = v & LK_ALL_WAITERS;
-   v &= LK_EXCLUSIVE_SPINNERS;
 
-   /*
-* Try to switch from one shared lock to an exclusive one.
-* We need to preserve waiters flags during the operation.
-*/
-   if (atomic_cmpset_ptr(>lk_lock, LK_SHARERS_LOCK(1) | x | v,
-   tid | x)) {
-   LOCK_LOG_LOCK("XUPGRADE", >lock_object, 0, 0, file,
-   line);
-   WITNESS_UPGRADE(>lock_object, LOP_EXCLUSIVE |
-   LK_TRYWIT(flags), file, line);
-   LOCKSTAT_RECORD0(lockmgr__upgrade, lk);
-   TD_SLOCKS_DEC(curthread);
-   goto out;
-   }
-
op = flags & LK_TYPE_MASK;
+   v = lockmgr_read_value(lk);
+   for (;;) {
+   if (LK_SHARERS_LOCK(v) > 1) {
+   if (op == LK_TRYUPGRADE) {
+   LOCK_LOG2(lk, "%s: %p failed the nowait 
upgrade",
+   __func__, lk);
+   error = EBUSY;
+   goto out;
+   }
+   if (lockmgr_sunlock_try(lk, )) {
+   lockmgr_note_shared_release(lk, file, line);
+   goto out_xlock;
+   }
+   }
+   MPASS((v & ~LK_ALL_WAITERS) == LK_SHARERS_LOCK(1));
 
-   /*
-* In LK_TRYUPGRADE mode, do not drop the lock,
-* returning EBUSY instead.
-*/
-   if (op == LK_TRYUPGRADE) {
-   LOCK_LOG2(lk, "%s: %p failed the nowait upgrade",
-   __func__, lk);
-   error = EBUSY;
-   goto out;
+   setv = tid;
+   setv |= (v & LK_ALL_WAITERS);
+
+   /*
+* Try to switch from one shared lock to an exclusive one.
+* We need to preserve waiters flags during the operation.
+*/
+   if (atomic_fcmpset_ptr(>lk_lock, , setv)) {
+   LOCK_LOG_LOCK("XUPGRADE", >lock_object, 0, 0, file,
+   line);
+   WITNESS_UPGRADE(>lock_object, LOP_EXCLUSIVE |
+   LK_TRYWIT(flags), file, line);
+   LOCKSTAT_RECORD0(lockmgr__upgrade, lk);
+   TD_SLOCKS_DEC(curthread);
+   goto out;
+   }
}
 
-   /*
-* We have been unable to succeed in upgrading, so just
-* give up the shared lock.
-*/
-   lockmgr_note_shared_release(lk, file, line);
-   wakeup_swapper |= wakeupshlk(lk, file, line);
+out_xlock:
error = lockmgr_xlock_hard(lk, flags, ilk, file, line, lwa);
flags &= ~LK_INTERLOCK;
 out:
-   lockmgr_exit(flags, ilk, wakeup_swapper);
+   lockmgr_exit(flags, ilk, 0);
return (error);
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r363392 - in head/sys: kern sys

2020-07-21 Thread Mateusz Guzik
Author: mjg
Date: Tue Jul 21 14:39:20 2020
New Revision: 363392
URL: https://svnweb.freebsd.org/changeset/base/363392

Log:
  lockmgr: add a helper for reading the lock value

Modified:
  head/sys/kern/kern_lock.c
  head/sys/sys/lockmgr.h

Modified: head/sys/kern/kern_lock.c
==
--- head/sys/kern/kern_lock.c   Tue Jul 21 14:35:50 2020(r363391)
+++ head/sys/kern/kern_lock.c   Tue Jul 21 14:39:20 2020(r363392)
@@ -140,7 +140,7 @@ LK_CAN_SHARE(uintptr_t x, int flags, bool fp)
 #definelockmgr_xlocked_v(v)
\
(((v) & ~(LK_FLAGMASK & ~LK_SHARE)) == (uintptr_t)curthread)
 
-#definelockmgr_xlocked(lk) lockmgr_xlocked_v((lk)->lk_lock)
+#definelockmgr_xlocked(lk) lockmgr_xlocked_v(lockmgr_read_value(lk))
 
 static voidassert_lockmgr(const struct lock_object *lock, int how);
 #ifdef DDB
@@ -233,7 +233,7 @@ static void
 lockmgr_note_exclusive_release(struct lock *lk, const char *file, int line)
 {
 
-   if (LK_HOLDER(lk->lk_lock) != LK_KERNPROC) {
+   if (LK_HOLDER(lockmgr_read_value(lk)) != LK_KERNPROC) {
WITNESS_UNLOCK(>lock_object, LOP_EXCLUSIVE, file, line);
TD_LOCKS_DEC(curthread);
}
@@ -246,7 +246,7 @@ lockmgr_xholder(const struct lock *lk)
 {
uintptr_t x;
 
-   x = lk->lk_lock;
+   x = lockmgr_read_value(lk);
return ((x & LK_SHARE) ? NULL : (struct thread *)LK_HOLDER(x));
 }
 
@@ -309,7 +309,7 @@ wakeupshlk(struct lock *lk, const char *file, int line
 
wakeup_swapper = 0;
for (;;) {
-   x = lk->lk_lock;
+   x = lockmgr_read_value(lk);
if (lockmgr_sunlock_try(lk, ))
break;
 
@@ -318,7 +318,7 @@ wakeupshlk(struct lock *lk, const char *file, int line
 * path in order to handle wakeups correctly.
 */
sleepq_lock(>lock_object);
-   orig_x = lk->lk_lock;
+   orig_x = lockmgr_read_value(lk);
 retry_sleepq:
x = orig_x & (LK_ALL_WAITERS | LK_EXCLUSIVE_SPINNERS);
v = LK_UNLOCKED;
@@ -515,7 +515,7 @@ lockmgr_slock_try(struct lock *lk, uintptr_t *xp, int 
 * waiters, if we fail to acquire the shared lock
 * loop back and retry.
 */
-   *xp = lk->lk_lock;
+   *xp = lockmgr_read_value(lk);
while (LK_CAN_SHARE(*xp, flags, fp)) {
if (atomic_fcmpset_acq_ptr(>lk_lock, xp,
*xp + LK_ONE_SHARER)) {
@@ -603,7 +603,7 @@ lockmgr_slock_hard(struct lock *lk, u_int flags, struc
 * probabilly will need to manipulate waiters flags.
 */
sleepq_lock(>lock_object);
-   x = lk->lk_lock;
+   x = lockmgr_read_value(lk);
 retry_sleepq:
 
/*
@@ -772,7 +772,7 @@ lockmgr_xlock_hard(struct lock *lk, u_int flags, struc
 * probabilly will need to manipulate waiters flags.
 */
sleepq_lock(>lock_object);
-   x = lk->lk_lock;
+   x = lockmgr_read_value(lk);
 retry_sleepq:
 
/*
@@ -889,7 +889,7 @@ lockmgr_upgrade(struct lock *lk, u_int flags, struct l
tid = (uintptr_t)curthread;
 
_lockmgr_assert(lk, KA_SLOCKED, file, line);
-   v = lk->lk_lock;
+   v = lockmgr_read_value(lk);
x = v & LK_ALL_WAITERS;
v &= LK_EXCLUSIVE_SPINNERS;
 
@@ -970,7 +970,7 @@ lockmgr_lock_flags(struct lock *lk, u_int flags, struc
LOP_EXCLUSIVE, file, line, flags & LK_INTERLOCK ?
ilk : NULL);
tid = (uintptr_t)curthread;
-   if (lk->lk_lock == LK_UNLOCKED &&
+   if (lockmgr_read_value(lk) == LK_UNLOCKED &&
atomic_cmpset_acq_ptr(>lk_lock, LK_UNLOCKED, tid)) {
lockmgr_note_exclusive_acquire(lk, 0, 0, file, line,
flags);
@@ -1054,7 +1054,7 @@ lockmgr_xunlock_hard(struct lock *lk, uintptr_t x, u_i
goto out;
 
sleepq_lock(>lock_object);
-   x = lk->lk_lock;
+   x = lockmgr_read_value(lk);
v = LK_UNLOCKED;
 
/*
@@ -1178,7 +1178,7 @@ lockmgr_unlock(struct lock *lk)
line = __LINE__;
 
_lockmgr_assert(lk, KA_LOCKED, file, line);
-   x = lk->lk_lock;
+   x = lockmgr_read_value(lk);
if (__predict_true(x & LK_SHARE) != 0) {
lockmgr_note_shared_release(lk, file, line);
if (lockmgr_sunlock_try(lk, )) {
@@ -1292,7 +1292,7 @@ __lockmgr_args(struct lock *lk, u_int flags, struct lo
 * In order to preserve waiters flags, just spin.
 */
for (;;) {
-   x = lk->lk_lock;
+   x = lockmgr_read_value(lk);
MPASS((x & 

svn commit: r363390 - head/sys/dev/virtio/mmio

2020-07-21 Thread Andrew Turner
Author: andrew
Date: Tue Jul 21 14:25:36 2020
New Revision: 363390
URL: https://svnweb.freebsd.org/changeset/base/363390

Log:
  Only write to VIRTIO_MMIO_GUEST_PAGE_SIZE with virtio mmio version 1
  
  This register is only defined for the legacy v1 interface so only write
  to it when interacting with a legacy device.
  
  Sponsored by: Innovate UK

Modified:
  head/sys/dev/virtio/mmio/virtio_mmio.c

Modified: head/sys/dev/virtio/mmio/virtio_mmio.c
==
--- head/sys/dev/virtio/mmio/virtio_mmio.c  Tue Jul 21 14:17:35 2020
(r363389)
+++ head/sys/dev/virtio/mmio/virtio_mmio.c  Tue Jul 21 14:25:36 2020
(r363390)
@@ -491,8 +491,10 @@ vtmmio_alloc_virtqueues(device_t dev, int flags, int n
if (sc->vtmmio_vqs == NULL)
return (ENOMEM);
 
-   vtmmio_write_config_4(sc, VIRTIO_MMIO_GUEST_PAGE_SIZE,
-   (1 << PAGE_SHIFT));
+   if (sc->vtmmio_version == 1) {
+   vtmmio_write_config_4(sc, VIRTIO_MMIO_GUEST_PAGE_SIZE,
+   (1 << PAGE_SHIFT));
+   }
 
for (idx = 0; idx < nvqs; idx++) {
vqx = >vtmmio_vqs[idx];
@@ -564,8 +566,10 @@ vtmmio_reinit(device_t dev, uint64_t features)
 
vtmmio_negotiate_features(dev, features);
 
-   vtmmio_write_config_4(sc, VIRTIO_MMIO_GUEST_PAGE_SIZE,
-   (1 << PAGE_SHIFT));
+   if (sc->vtmmio_version == 1) {
+   vtmmio_write_config_4(sc, VIRTIO_MMIO_GUEST_PAGE_SIZE,
+   (1 << PAGE_SHIFT));
+   }
 
for (idx = 0; idx < sc->vtmmio_nvqs; idx++) {
error = vtmmio_reinit_virtqueue(sc, idx);
___
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: r363388 - in head/sys: dev/iommu sys x86/iommu

2020-07-21 Thread Ruslan Bukin
Author: br
Date: Tue Jul 21 13:50:10 2020
New Revision: 363388
URL: https://svnweb.freebsd.org/changeset/base/363388

Log:
  Move sys/iommu.h to dev/iommu/ as a part of generic IOMMU busdma backend.
  
  Reviewed by:  kib
  Sponsored by: DARPA/AFRL
  Differential Revision:https://reviews.freebsd.org/D25750

Added:
  head/sys/dev/iommu/iommu.h
 - copied unchanged from r363387, head/sys/sys/iommu.h
Deleted:
  head/sys/sys/iommu.h
Modified:
  head/sys/dev/iommu/busdma_iommu.c
  head/sys/dev/iommu/busdma_iommu.h
  head/sys/x86/iommu/intel_dmar.h

Modified: head/sys/dev/iommu/busdma_iommu.c
==
--- head/sys/dev/iommu/busdma_iommu.c   Tue Jul 21 10:38:51 2020
(r363387)
+++ head/sys/dev/iommu/busdma_iommu.c   Tue Jul 21 13:50:10 2020
(r363388)
@@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -68,6 +67,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #endif
 

Modified: head/sys/dev/iommu/busdma_iommu.h
==
--- head/sys/dev/iommu/busdma_iommu.h   Tue Jul 21 10:38:51 2020
(r363387)
+++ head/sys/dev/iommu/busdma_iommu.h   Tue Jul 21 13:50:10 2020
(r363388)
@@ -34,7 +34,7 @@
 #ifndef __X86_IOMMU_BUSDMA_DMAR_H
 #define __X86_IOMMU_BUSDMA_DMAR_H
 
-#include 
+#include 
 
 struct bus_dma_tag_iommu {
struct bus_dma_tag_common common;

Copied: head/sys/dev/iommu/iommu.h (from r363387, head/sys/sys/iommu.h)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/iommu/iommu.h  Tue Jul 21 13:50:10 2020(r363388, copy 
of r363387, head/sys/sys/iommu.h)
@@ -0,0 +1,168 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Konstantin Belousov 
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _SYS_IOMMU_H_
+#define _SYS_IOMMU_H_
+
+#include 
+#include 
+#include 
+#include 
+
+/* Host or physical memory address, after translation. */
+typedef uint64_t iommu_haddr_t;
+/* Guest or bus address, before translation. */
+typedef uint64_t iommu_gaddr_t;
+
+struct bus_dma_tag_common;
+struct iommu_map_entry;
+TAILQ_HEAD(iommu_map_entries_tailq, iommu_map_entry);
+
+struct iommu_qi_genseq {
+   u_int gen;
+   uint32_t seq;
+};
+
+struct iommu_map_entry {
+   iommu_gaddr_t start;
+   iommu_gaddr_t end;
+   iommu_gaddr_t first;/* Least start in subtree */
+   iommu_gaddr_t last; /* Greatest end in subtree */
+   iommu_gaddr_t free_down;/* Max free space below the
+  current R/B tree node */
+   u_int flags;
+   TAILQ_ENTRY(iommu_map_entry) dmamap_link; /* Link for dmamap entries */
+   RB_ENTRY(iommu_map_entry) rb_entry;  /* Links for domain entries */
+   TAILQ_ENTRY(iommu_map_entry) unroll_link; /* Link for unroll after
+   dmamap_load failure */
+   struct iommu_domain *domain;
+   struct iommu_qi_genseq gseq;
+};
+
+#defineIOMMU_MAP_ENTRY_PLACE   0x0001  /* Fake entry */
+#defineIOMMU_MAP_ENTRY_RMRR0x0002  /* Permanent, not linked by
+  dmamap_link */
+#defineIOMMU_MAP_ENTRY_MAP 0x0004  /* Busdma created, linked by
+   

svn commit: r363387 - in head/sys: conf dev/iommu x86/iommu

2020-07-21 Thread Ruslan Bukin
Author: br
Date: Tue Jul 21 10:38:51 2020
New Revision: 363387
URL: https://svnweb.freebsd.org/changeset/base/363387

Log:
  Move the Intel DMAR busdma backend to a generic place so
  it can be used on other IOMMU systems.
  
  Reviewed by:  kib
  Sponsored by: DARPA/AFRL
  Differential Revision:https://reviews.freebsd.org/D25720

Added:
  head/sys/dev/iommu/
  head/sys/dev/iommu/busdma_iommu.c
 - copied, changed from r363386, head/sys/x86/iommu/busdma_dmar.c
  head/sys/dev/iommu/busdma_iommu.h
 - copied unchanged from r363386, head/sys/x86/iommu/busdma_dmar.h
Deleted:
  head/sys/x86/iommu/busdma_dmar.c
  head/sys/x86/iommu/busdma_dmar.h
Modified:
  head/sys/conf/files.x86
  head/sys/x86/iommu/intel_ctx.c
  head/sys/x86/iommu/intel_drv.c
  head/sys/x86/iommu/intel_fault.c
  head/sys/x86/iommu/intel_gas.c
  head/sys/x86/iommu/intel_idpgtbl.c
  head/sys/x86/iommu/intel_intrmap.c
  head/sys/x86/iommu/intel_qi.c
  head/sys/x86/iommu/intel_quirks.c
  head/sys/x86/iommu/intel_utils.c

Modified: head/sys/conf/files.x86
==
--- head/sys/conf/files.x86 Tue Jul 21 08:13:35 2020(r363386)
+++ head/sys/conf/files.x86 Tue Jul 21 10:38:51 2020(r363387)
@@ -165,6 +165,7 @@ dev/imcsmb/imcsmb.c optionalimcsmb
 dev/imcsmb/imcsmb_pci.coptionalimcsmb pci
 dev/intel/spi.coptionalintelspi
 dev/io/iodev.c optionalio
+dev/iommu/busdma_iommu.c   optionalacpi acpi_dmar pci
 dev/ipmi/ipmi.coptionalipmi
 dev/ipmi/ipmi_acpi.c   optionalipmi acpi
 dev/ipmi/ipmi_isa.coptionalipmi isa
@@ -300,7 +301,6 @@ x86/cpufreq/hwpstate_amd.c  optionalcpufreq
 x86/cpufreq/hwpstate_intel.c   optionalcpufreq
 x86/cpufreq/p4tcc.coptionalcpufreq
 x86/cpufreq/powernow.c optionalcpufreq
-x86/iommu/busdma_dmar.coptionalacpi acpi_dmar pci
 x86/iommu/intel_ctx.c  optionalacpi acpi_dmar pci
 x86/iommu/intel_drv.c  optionalacpi acpi_dmar pci
 x86/iommu/intel_fault.coptionalacpi acpi_dmar pci

Copied and modified: head/sys/dev/iommu/busdma_iommu.c (from r363386, 
head/sys/x86/iommu/busdma_dmar.c)
==
--- head/sys/x86/iommu/busdma_dmar.cTue Jul 21 08:13:35 2020
(r363386, copy source)
+++ head/sys/dev/iommu/busdma_iommu.c   Tue Jul 21 10:38:51 2020
(r363387)
@@ -67,13 +67,13 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #endif
 
 /*
- * busdma_dmar.c, the implementation of the busdma(9) interface using
- * DMAR units from Intel VT-d.
+ * busdma_iommu.c, the implementation of the busdma(9) interface using
+ * IOMMU units from Intel VT-d.
  */
 
 static bool

Copied: head/sys/dev/iommu/busdma_iommu.h (from r363386, 
head/sys/x86/iommu/busdma_dmar.h)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/iommu/busdma_iommu.h   Tue Jul 21 10:38:51 2020
(r363387, copy of r363386, head/sys/x86/iommu/busdma_dmar.h)
@@ -0,0 +1,66 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Konstantin Belousov 
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef 

svn commit: r363383 - in head/sys/cddl/dev: dtrace/arm fbt/arm

2020-07-21 Thread Andriy Gapon
Author: avg
Date: Tue Jul 21 07:41:36 2020
New Revision: 363383
URL: https://svnweb.freebsd.org/changeset/base/363383

Log:
  dtrace/fbt: fix return probe arguments on arm
  
  arg0 should be an offset of the return point within the function, arg1
  should be the return value.  Previously the return probe had arguments as
  if for the entry probe.
  
  Tested on armv7.
  
  andrew noted that the same problem seems to be present on arm64, mips,
  and riscv.
  I am not sure if I will get around to fixing those.  So, platform users
  or anyone looking to make a contribution please be aware of this
  opportunity.
  
  Reviewed by:  markj
  MFC after:1 week
  Differential Revision: https://reviews.freebsd.org/D25685

Modified:
  head/sys/cddl/dev/dtrace/arm/dtrace_subr.c
  head/sys/cddl/dev/fbt/arm/fbt_isa.c

Modified: head/sys/cddl/dev/dtrace/arm/dtrace_subr.c
==
--- head/sys/cddl/dev/dtrace/arm/dtrace_subr.c  Tue Jul 21 07:35:03 2020
(r363382)
+++ head/sys/cddl/dev/dtrace/arm/dtrace_subr.c  Tue Jul 21 07:41:36 2020
(r363383)
@@ -248,7 +248,7 @@ dtrace_invop_start(struct trapframe *frame)
register_t *r0, *sp;
int data, invop, reg, update_sp;
 
-   invop = dtrace_invop(frame->tf_pc, frame, frame->tf_pc);
+   invop = dtrace_invop(frame->tf_pc, frame, frame->tf_r0);
switch (invop & DTRACE_INVOP_MASK) {
case DTRACE_INVOP_PUSHM:
sp = (register_t *)frame->tf_svc_sp;

Modified: head/sys/cddl/dev/fbt/arm/fbt_isa.c
==
--- head/sys/cddl/dev/fbt/arm/fbt_isa.c Tue Jul 21 07:35:03 2020
(r363382)
+++ head/sys/cddl/dev/fbt/arm/fbt_isa.c Tue Jul 21 07:41:36 2020
(r363383)
@@ -56,9 +56,12 @@ fbt_invop(uintptr_t addr, struct trapframe *frame, uin
register_t fifthparam;
 
for (; fbt != NULL; fbt = fbt->fbtp_hashnext) {
-   if ((uintptr_t)fbt->fbtp_patchpoint == addr) {
-   cpu->cpu_dtrace_caller = addr;
+   if ((uintptr_t)fbt->fbtp_patchpoint != addr)
+   continue;
 
+   cpu->cpu_dtrace_caller = addr;
+
+   if (fbt->fbtp_roffset == 0) {
/* Get 5th parameter from stack */
DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
fifthparam = *(register_t *)frame->tf_svc_sp;
@@ -67,11 +70,13 @@ fbt_invop(uintptr_t addr, struct trapframe *frame, uin
dtrace_probe(fbt->fbtp_id, frame->tf_r0,
frame->tf_r1, frame->tf_r2,
frame->tf_r3, fifthparam);
-
-   cpu->cpu_dtrace_caller = 0;
-
-   return (fbt->fbtp_rval | (fbt->fbtp_savedval << 
DTRACE_INVOP_SHIFT));
+   } else {
+   dtrace_probe(fbt->fbtp_id, fbt->fbtp_roffset, rval,
+   0, 0, 0);
}
+
+   cpu->cpu_dtrace_caller = 0;
+   return (fbt->fbtp_rval | (fbt->fbtp_savedval << 
DTRACE_INVOP_SHIFT));
}
 
return (0);
@@ -178,6 +183,7 @@ again:
fbt->fbtp_rval = DTRACE_INVOP_B;
else
fbt->fbtp_rval = DTRACE_INVOP_POPM;
+   fbt->fbtp_roffset = (uintptr_t)instr - (uintptr_t)symval->value;
fbt->fbtp_savedval = *instr;
fbt->fbtp_patchval = FBT_BREAKPOINT;
fbt->fbtp_hashnext = fbt_probetab[FBT_ADDR2NDX(instr)];
___
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: r363382 - head/sys/dev/gpio

2020-07-21 Thread Andriy Gapon
Author: avg
Date: Tue Jul 21 07:35:03 2020
New Revision: 363382
URL: https://svnweb.freebsd.org/changeset/base/363382

Log:
  gpioiic: never drive lines active high
  
  I2C communication is done by a combination of driving a line low or
  letting it float, so that it is either pulled up or driven low by
  another party.
  
  r355276 besides the stated goal of the change -- using the new GPIO API
  -- also changed the logic, so that active state is signaled by actively
  driving a line.
  
  That worked with iicbb prior to r362042, but stopped working after that
  commit on at least some hardware.  My guess that the breakage was
  related to getting an ACK bit.  A device expected to be able to drive
  SDA actively low, but controller was actively driving it high for some
  time.
  
  Anyway, this change seems to fix the problem.
  Tested using gpioiic on Orange Pi PC Plus with HTU21 sensor.
  
  Reported by:  Nick Kostirya 
  Reviewed by:  manu
  MFC after:1 week
  Differential Revision: https://reviews.freebsd.org/D25684

Modified:
  head/sys/dev/gpio/gpioiic.c

Modified: head/sys/dev/gpio/gpioiic.c
==
--- head/sys/dev/gpio/gpioiic.c Mon Jul 20 23:57:53 2020(r363381)
+++ head/sys/dev/gpio/gpioiic.c Tue Jul 21 07:35:03 2020(r363382)
@@ -191,16 +191,14 @@ static void
 gpioiic_setsda(device_t dev, int val)
 {
struct gpioiic_softc *sc = device_get_softc(dev);
-   int err;
 
-   /*
-* Some controllers cannot set an output value while a pin is in input
-* mode; in that case we set the pin again after changing mode.
-*/
-   err = gpio_pin_set_active(sc->sdapin, val);
-   gpio_pin_setflags(sc->sdapin, GPIO_PIN_OUTPUT | GPIO_PIN_OPENDRAIN);
-   if (err != 0)
-   gpio_pin_set_active(sc->sdapin, val);
+   if (val) {
+   gpio_pin_setflags(sc->sdapin, GPIO_PIN_INPUT);
+   } else {
+   gpio_pin_setflags(sc->sdapin,
+   GPIO_PIN_OUTPUT | GPIO_PIN_OPENDRAIN);
+   gpio_pin_set_active(sc->sdapin, 0);
+   }
 }
 
 static void
@@ -208,8 +206,13 @@ gpioiic_setscl(device_t dev, int val)
 {
struct gpioiic_softc *sc = device_get_softc(dev);
 
-   gpio_pin_setflags(sc->sclpin, GPIO_PIN_OUTPUT | GPIO_PIN_OPENDRAIN);
-   gpio_pin_set_active(sc->sclpin, val);
+   if (val) {
+   gpio_pin_setflags(sc->sclpin, GPIO_PIN_INPUT);
+   } else {
+   gpio_pin_setflags(sc->sclpin,
+   GPIO_PIN_OUTPUT | GPIO_PIN_OPENDRAIN);
+   gpio_pin_set_active(sc->sclpin, 0);
+   }
 }
 
 static int
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"