Re: svn commit: r365071 - in head/sys: net net/altq net/route net80211 netgraph netgraph/atm netgraph/atm/ccatm netgraph/atm/sscfu netgraph/atm/sscop netgraph/atm/uni netgraph/bluetooth/common netgrap

2020-09-06 Thread Ed Maste
On Fri, 4 Sep 2020 at 23:11, Kevin Bowling  wrote:
>
> An arbitrary formater may leave a
> little bit of annoyance to each person's taste, but that is a tiny
> drop in the bucket compared to never having to discuss and especially
> correct (which may /seem/ helpful but is pretty offputting to
> newcomers).

As an experiment I ran clang-format over an arbitrary file
(vtfontcvt.c) and put the results in
https://reviews.freebsd.org/D26340

Relative to the original file there are a few style(9) items that have
been fixed, a few that have been broken, and some that are arguably
worse but really indifferent.

Fixed:
- *_FOREACH now has a space before (, equivalent to for (;;)
- header sorting
- space between sizeof and ( removed
- indentation of an if body
- unwrapped function call that fits on one line

Broken:
- indentation of if / for conditions that span 2 or more lines

Indifferent:
- lose lined-up struct members or comments
- space vs tab after #define
- newlines before quoted function arguments
- function argument wrapping (see write_glyph_buf)
- leading indentation and args-per-line (print_font_info)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r365071 - in head/sys: net net/altq net/route net80211 netgraph netgraph/atm netgraph/atm/ccatm netgraph/atm/sscfu netgraph/atm/sscop netgraph/atm/uni netgraph/bluetooth/common netgrap

2020-09-06 Thread Warner Losh
On Sat, Sep 5, 2020 at 1:42 PM Ed Maste  wrote:

> On Fri, 4 Sep 2020 at 23:11, Kevin Bowling 
> wrote:
> >
> > An arbitrary formater may leave a
> > little bit of annoyance to each person's taste, but that is a tiny
> > drop in the bucket compared to never having to discuss and especially
> > correct (which may /seem/ helpful but is pretty offputting to
> > newcomers).
>
> As an experiment I ran clang-format over an arbitrary file
> (vtfontcvt.c) and put the results in
> https://reviews.freebsd.org/D26340
>
> Relative to the original file there are a few style(9) items that have
> been fixed, a few that have been broken, and some that are arguably
> worse but really indifferent.
>
> Fixed:
> - *_FOREACH now has a space before (, equivalent to for (;;)
>

Except pretty much everywhere we don't have a space there...


> - header sorting
> - space between sizeof and ( removed
> - indentation of an if body
> - unwrapped function call that fits on one line
>
> Broken:
> - indentation of if / for conditions that span 2 or more lines
>
broke all alignment of variables and comments that were done.
broke all err() calls to wrap too much
broke purposely outdented code in statistics function
extra headers still included.


>
> Indifferent:
> - lose lined-up struct members or comments
>

This will cause a huge amount of churn, and is a needless change. It makes
things harder to read. Though this alignment style has been slowly waining
after being popular early on...

The comments moving is a bigger problem for the worse.


> - space vs tab after #define
> - newlines before quoted function arguments
>

Also a problem since it introduces more verticality.


> - function argument wrapping (see write_glyph_buf)
> - leading indentation and args-per-line (print_font_info)
>

An interesting experiment, but there's far more worse after than before.
The rearranging of carefully aligned elements is an especially galling
change for some people (myself included).

Warner
___
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: r365373 - in head: lib/libc/stdlib/jemalloc tools/build/options

2020-09-06 Thread Dimitry Andric
Author: dim
Date: Sun Sep  6 09:08:06 2020
New Revision: 365373
URL: https://svnweb.freebsd.org/changeset/base/365373

Log:
  Follow-up r365371 by removing sentences which indicate the state of the
  MK_MALLOC_PRODUCTION option on -CURRENT.
  
  Also, for the sake of backwards compatibility, support the old way of
  enabling 'production malloc', e.g. by adding a define in make.conf(5).
  
  MFC after:1 week
  X-MFC-With:   r365371

Modified:
  head/lib/libc/stdlib/jemalloc/Makefile.inc
  head/tools/build/options/WITHOUT_MALLOC_PRODUCTION
  head/tools/build/options/WITH_MALLOC_PRODUCTION

Modified: head/lib/libc/stdlib/jemalloc/Makefile.inc
==
--- head/lib/libc/stdlib/jemalloc/Makefile.inc  Sun Sep  6 00:36:51 2020
(r365372)
+++ head/lib/libc/stdlib/jemalloc/Makefile.inc  Sun Sep  6 09:08:06 2020
(r365373)
@@ -45,6 +45,6 @@ MLINKS+= \
jemalloc.3 nallocx.3 \
jemalloc.3 malloc.conf.5
 
-.if ${MK_MALLOC_PRODUCTION} != "no"
+.if ${MK_MALLOC_PRODUCTION} != "no" || defined(MALLOC_PRODUCTION)
 CFLAGS+=   -DMALLOC_PRODUCTION
 .endif

Modified: head/tools/build/options/WITHOUT_MALLOC_PRODUCTION
==
--- head/tools/build/options/WITHOUT_MALLOC_PRODUCTION  Sun Sep  6 00:36:51 
2020(r365372)
+++ head/tools/build/options/WITHOUT_MALLOC_PRODUCTION  Sun Sep  6 09:08:06 
2020(r365373)
@@ -2,4 +2,3 @@
 Set to enable assertions and statistics gathering in
 .Xr malloc 3 .
 It also defaults the A and J runtime options to on.
-Enabled by default on -CURRENT.

Modified: head/tools/build/options/WITH_MALLOC_PRODUCTION
==
--- head/tools/build/options/WITH_MALLOC_PRODUCTION Sun Sep  6 00:36:51 
2020(r365372)
+++ head/tools/build/options/WITH_MALLOC_PRODUCTION Sun Sep  6 09:08:06 
2020(r365373)
@@ -2,4 +2,3 @@
 Set to disable assertions and statistics gathering in
 .Xr malloc 3 .
 It also defaults the A and J runtime options to off.
-Disabled by default on -CURRENT.
___
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: r365378 - head/usr.sbin/traceroute6

2020-09-06 Thread Mariusz Zaborski
Author: oshogbo
Date: Sun Sep  6 14:04:02 2020
New Revision: 365378
URL: https://svnweb.freebsd.org/changeset/base/365378

Log:
  traceroute6: capsicumize it
  
  Submitted by: Shubh Gupta 
  Sponsored by: Google (GSOC 2020)
  Differential Revision:https://reviews.freebsd.org/D25604

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

Modified: head/usr.sbin/traceroute6/Makefile
==
--- head/usr.sbin/traceroute6/Makefile  Sun Sep  6 11:29:06 2020
(r365377)
+++ head/usr.sbin/traceroute6/Makefile  Sun Sep  6 14:04:02 2020
(r365378)
@@ -13,6 +13,10 @@
 # A PARTICULAR PURPOSE.
 # $FreeBSD$
 
+.include 
+
+.include 
+
 TRACEROUTE_DISTDIR?= ${SRCTOP}/contrib/traceroute
 .PATH: ${TRACEROUTE_DISTDIR}
 
@@ -26,7 +30,13 @@ BINMODE= 4555
 CFLAGS+= -DIPSEC -DHAVE_POLL
 CFLAGS+= -I${.CURDIR} -I${TRACEROUTE_DISTDIR} -I.
 
-LIBADD=ipsec
+.if ${MK_CASPER} != "no"
+LIBADD+=   casper
+LIBADD+=   cap_dns
+CFLAGS+=   -DWITH_CASPER
+.endif
+
+LIBADD+=   ipsec
 
 .include 
 

Modified: head/usr.sbin/traceroute6/traceroute6.c
==
--- head/usr.sbin/traceroute6/traceroute6.c Sun Sep  6 11:29:06 2020
(r365377)
+++ head/usr.sbin/traceroute6/traceroute6.c Sun Sep  6 14:04:02 2020
(r365378)
@@ -249,6 +249,7 @@ static const char rcsid[] =
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -260,6 +261,10 @@ static const char rcsid[] =
 
 #include 
 
+#include 
+#include 
+#include 
+
 #include 
 #include 
 #include 
@@ -289,11 +294,6 @@ static const char rcsid[] =
 
 #defineMAXPACKET   65535   /* max ip packet size */
 
-#ifndef HAVE_GETIPNODEBYNAME
-#define getipnodebyname(x, y, z, u)gethostbyname2((x), (y))
-#define freehostent(x)
-#endif
-
 static u_char  packet[512];/* last inbound (icmp) packet */
 static char*outpacket; /* last output packet */
 
@@ -304,6 +304,7 @@ int setpolicy(int so, char *policy);
 #endif
 void   send_probe(int, u_long);
 void   *get_uphdr(struct ip6_hdr *, u_char *);
+void   capdns_open(void);
 intget_hoplim(struct msghdr *);
 double deltaT(struct timeval *, struct timeval *);
 const char *pr_type(int);
@@ -312,6 +313,8 @@ voidprint(struct msghdr *, int);
 const char *inetname(struct sockaddr *);
 u_int32_t sctp_crc32c(void *, u_int32_t);
 u_int16_t in_cksum(u_int16_t *addr, int);
+u_int16_t udp_cksum(struct sockaddr_in6 *, struct sockaddr_in6 *,
+void *, u_int32_t);
 u_int16_t tcp_chksum(struct sockaddr_in6 *, struct sockaddr_in6 *,
 void *, u_int32_t);
 void   usage(void);
@@ -335,6 +338,8 @@ static struct cmsghdr *cmsg;
 static char *source = NULL;
 static char *hostname;
 
+static cap_channel_t *capdns;
+
 static u_long nprobes = 3;
 static u_long first_hop = 1;
 static u_long max_hops = 30;
@@ -368,7 +373,10 @@ main(int argc, char *argv[])
char ipsec_inpolicy[] = "in bypass";
char ipsec_outpolicy[] = "out bypass";
 #endif
+   cap_rights_t rights;
 
+   capdns_open();
+
/*
 * Receive ICMP
 */
@@ -429,6 +437,7 @@ main(int argc, char *argv[])
}
break;
case 'g':
+   /* XXX use after capability mode is entered */
hp = getipnodebyname(optarg, AF_INET6, 0, &h_errno);
if (hp == NULL) {
fprintf(stderr,
@@ -560,8 +569,8 @@ main(int argc, char *argv[])
sndsock = rcvsock;
break;
case IPPROTO_UDP:
-   if ((sndsock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
-   perror("socket(SOCK_DGRAM)");
+   if ((sndsock = socket(AF_INET6, SOCK_RAW, IPPROTO_UDP)) < 0) {
+   perror("socket(SOCK_RAW)");
exit(5);
}
break;
@@ -606,7 +615,9 @@ main(int argc, char *argv[])
hints.ai_socktype = SOCK_RAW;
hints.ai_protocol = IPPROTO_ICMPV6;
hints.ai_flags = AI_CANONNAME;
-   error = getaddrinfo(*argv, NULL, &hints, &res);
+
+   error = cap_getaddrinfo(capdns, *argv, NULL, &hints, &res);
+
if (error) {
fprintf(stderr,
"traceroute6: %s\n", gai_strerror(error));
@@ -624,7 +635,7 @@ main(int argc, char *argv[])
exit(1);
}
if (res->ai_next) {
-   if (getnameinfo(res->ai_addr, res->ai_addrlen, hbuf,
+   if (cap_getnameinfo(capdns, res->ai_addr, res->ai_addrlen, hbuf,
sizeof(hbuf), NULL, 0, NI_NUMERICHOST) != 0)
strlcpy(hbuf, "?", sizeof(hbuf));
fprintf(stderr, "traceroute6: Warning: %s has multiple "
@@ -803,7 +814,7 @@ main(int argc, char *argv[])
 

svn commit: r365382 - head/usr.sbin/traceroute6

2020-09-06 Thread Mariusz Zaborski
Author: oshogbo
Date: Sun Sep  6 15:44:09 2020
New Revision: 365382
URL: https://svnweb.freebsd.org/changeset/base/365382

Log:
  Remove duplicated line.
  
  Reported by:  lwhsu

Modified:
  head/usr.sbin/traceroute6/Makefile

Modified: head/usr.sbin/traceroute6/Makefile
==
--- head/usr.sbin/traceroute6/Makefile  Sun Sep  6 14:41:35 2020
(r365381)
+++ head/usr.sbin/traceroute6/Makefile  Sun Sep  6 15:44:09 2020
(r365382)
@@ -15,8 +15,6 @@
 
 .include 
 
-.include 
-
 TRACEROUTE_DISTDIR?= ${SRCTOP}/contrib/traceroute
 .PATH: ${TRACEROUTE_DISTDIR}
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r365378 - head/usr.sbin/traceroute6

2020-09-06 Thread Oliver Pinter
On Sunday, September 6, 2020, Mariusz Zaborski  wrote:

> Author: oshogbo
> Date: Sun Sep  6 14:04:02 2020
> New Revision: 365378
> URL: https://svnweb.freebsd.org/changeset/base/365378
>
> Log:
>   traceroute6: capsicumize it
>
>   Submitted by: Shubh Gupta 
>   Sponsored by: Google (GSOC 2020)
>   Differential Revision:https://reviews.freebsd.org/D25604
>
> Modified:
>   head/usr.sbin/traceroute6/Makefile
>   head/usr.sbin/traceroute6/traceroute6.c
>
> Modified: head/usr.sbin/traceroute6/Makefile
> 
> ==
> --- head/usr.sbin/traceroute6/Makefile  Sun Sep  6 11:29:06 2020
> (r365377)
> +++ head/usr.sbin/traceroute6/Makefile  Sun Sep  6 14:04:02 2020
> (r365378)
> @@ -13,6 +13,10 @@
>  # A PARTICULAR PURPOSE.
>  # $FreeBSD$
>
> +.include 
> +
> +.include 


Dup


> +
>  TRACEROUTE_DISTDIR?= ${SRCTOP}/contrib/traceroute
>  .PATH: ${TRACEROUTE_DISTDIR}
>
> @@ -26,7 +30,13 @@ BINMODE= 4555
>  CFLAGS+= -DIPSEC -DHAVE_POLL
>  CFLAGS+= -I${.CURDIR} -I${TRACEROUTE_DISTDIR} -I.
>
> -LIBADD=ipsec
> +.if ${MK_CASPER} != "no"
> +LIBADD+=   casper
> +LIBADD+=   cap_dns
> +CFLAGS+=   -DWITH_CASPER
> +.endif
> +
> +LIBADD+=   ipsec
>
>  .include 
>
>
> Modified: head/usr.sbin/traceroute6/traceroute6.c
> 
> ==
> --- head/usr.sbin/traceroute6/traceroute6.c Sun Sep  6 11:29:06 2020
>   (r365377)
> +++ head/usr.sbin/traceroute6/traceroute6.c Sun Sep  6 14:04:02 2020
>   (r365378)
> @@ -249,6 +249,7 @@ static const char rcsid[] =
>   */
>
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -260,6 +261,10 @@ static const char rcsid[] =
>
>  #include 
>
> +#include 
> +#include 
> +#include 
> +
>  #include 
>  #include 
>  #include 
> @@ -289,11 +294,6 @@ static const char rcsid[] =
>
>  #defineMAXPACKET   65535   /* max ip packet size */
>
> -#ifndef HAVE_GETIPNODEBYNAME
> -#define getipnodebyname(x, y, z, u)gethostbyname2((x), (y))
> -#define freehostent(x)
> -#endif
> -
>  static u_char  packet[512];/* last inbound (icmp) packet */
>  static char*outpacket; /* last output packet */
>
> @@ -304,6 +304,7 @@ int setpolicy(int so, char *policy);
>  #endif
>  void   send_probe(int, u_long);
>  void   *get_uphdr(struct ip6_hdr *, u_char *);
> +void   capdns_open(void);
>  intget_hoplim(struct msghdr *);
>  double deltaT(struct timeval *, struct timeval *);
>  const char *pr_type(int);
> @@ -312,6 +313,8 @@ voidprint(struct msghdr *, int);
>  const char *inetname(struct sockaddr *);
>  u_int32_t sctp_crc32c(void *, u_int32_t);
>  u_int16_t in_cksum(u_int16_t *addr, int);
> +u_int16_t udp_cksum(struct sockaddr_in6 *, struct sockaddr_in6 *,
> +void *, u_int32_t);
>  u_int16_t tcp_chksum(struct sockaddr_in6 *, struct sockaddr_in6 *,
>  void *, u_int32_t);
>  void   usage(void);
> @@ -335,6 +338,8 @@ static struct cmsghdr *cmsg;
>  static char *source = NULL;
>  static char *hostname;
>
> +static cap_channel_t *capdns;
> +
>  static u_long nprobes = 3;
>  static u_long first_hop = 1;
>  static u_long max_hops = 30;
> @@ -368,7 +373,10 @@ main(int argc, char *argv[])
> char ipsec_inpolicy[] = "in bypass";
> char ipsec_outpolicy[] = "out bypass";
>  #endif
> +   cap_rights_t rights;
>
> +   capdns_open();
> +
> /*
>  * Receive ICMP
>  */
> @@ -429,6 +437,7 @@ main(int argc, char *argv[])
> }
> break;
> case 'g':
> +   /* XXX use after capability mode is entered */
> hp = getipnodebyname(optarg, AF_INET6, 0,
> &h_errno);
> if (hp == NULL) {
> fprintf(stderr,
> @@ -560,8 +569,8 @@ main(int argc, char *argv[])
> sndsock = rcvsock;
> break;
> case IPPROTO_UDP:
> -   if ((sndsock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
> -   perror("socket(SOCK_DGRAM)");
> +   if ((sndsock = socket(AF_INET6, SOCK_RAW, IPPROTO_UDP)) <
> 0) {
> +   perror("socket(SOCK_RAW)");
> exit(5);
> }
> break;
> @@ -606,7 +615,9 @@ main(int argc, char *argv[])
> hints.ai_socktype = SOCK_RAW;
> hints.ai_protocol = IPPROTO_ICMPV6;
> hints.ai_flags = AI_CANONNAME;
> -   error = getaddrinfo(*argv, NULL, &hints, &res);
> +
> +   error = cap_getaddrinfo(capdns, *argv, NULL, &hints, &res);
> +
> if (error) {
> fprintf(stderr,
> "traceroute6: %s\n", gai_strerror(error));
> @@ -624,7 +635,7 @@ main(int argc, char *argv[])
> exit(1);
> }
> if (res->ai_next) {
> -   if (getnameinfo(res->ai_addr, res->ai_addrlen, hbuf,
> 

Re: svn commit: r365378 - head/usr.sbin/traceroute6

2020-09-06 Thread Alexey Dokuchaev
On Sun, Sep 06, 2020 at 08:32:46PM +0200, Oliver Pinter wrote:
> On Sunday, September 6, 2020, Mariusz Zaborski  wrote:
> > New Revision: 365378
> > URL: https://svnweb.freebsd.org/changeset/base/365378
> >
> > Log:
> >   traceroute6: capsicumize it
> >
> > ...
> > @@ -13,6 +13,10 @@
> >  # A PARTICULAR PURPOSE.
> >  # $FreeBSD$
> >
> > +.include 
> > +
> > +.include 
> 
> Dup

1) It's usually a good idea to read all svn-mail in your inbox before
replying to a particular commit, the problem could already be fixed;

2) Please don't overquote, i.e. do *not* include the rest of the diff
if you only wanted to comment on the first lines it.

./danfe
___
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: r365389 - head/sys/crypto/via

2020-09-06 Thread Alan Somers
Author: asomers
Date: Sun Sep  6 19:25:31 2020
New Revision: 365389
URL: https://svnweb.freebsd.org/changeset/base/365389

Log:
  padlock(4): fix instapanics with geli authentication
  
  cryptodev_process implementations are supposed to return 0
  
  PR:   247986
  Submitted by: jhb
  MFC after:1 week

Modified:
  head/sys/crypto/via/padlock.c

Modified: head/sys/crypto/via/padlock.c
==
--- head/sys/crypto/via/padlock.c   Sun Sep  6 19:03:19 2020
(r365388)
+++ head/sys/crypto/via/padlock.c   Sun Sep  6 19:25:31 2020
(r365389)
@@ -275,7 +275,7 @@ out:
 #endif
crp->crp_etype = error;
crypto_done(crp);
-   return (error);
+   return (0);
 }
 
 static device_method_t padlock_methods[] = {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r364098 - head/sys/dev/dwc

2020-09-06 Thread Oleksandr Tymoshenko
Li-Wen Hsu (lw...@freebsd.org) wrote:
> Author: lwhsu
> Date: Tue Aug 11 05:17:10 2020
> New Revision: 364098
> URL: https://svnweb.freebsd.org/changeset/base/364098
> 
> Log:
>   Fix armv{6,7} build after r364088
>   
>   Sponsored by:   The FreeBSD Foundation

I overlooked this change when it was committed. Thanks for fixing and
sorry for the breakage.

-- 
gonzo
___
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: r365391 - head/share/man/man5

2020-09-06 Thread Alan Somers
Author: asomers
Date: Sun Sep  6 20:32:13 2020
New Revision: 365391
URL: https://svnweb.freebsd.org/changeset/base/365391

Log:
  nsswitch.conf(5): recommend placing cache after files
  
  When cache precedes files, and nscd is configured to allow negative caching,
  commands like "pw groupadd" can fail. The sequence of events looks like:
  
  1. A command like pkg(8) looks up the group, and finds it absent.
  2. pkg invokes pw(8) to add the group
  3. pkg queries the group, but nscd says it doesn't exist, since it has a
 negative cache entry for that group.
  
  See also: 
https://lists.freebsd.org/pipermail/freebsd-current/2012-January/031595.html
  
  Reviewed by:  bcr (manpages)
  MFC after:1 week
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D26184

Modified:
  head/share/man/man5/nsswitch.conf.5

Modified: head/share/man/man5/nsswitch.conf.5
==
--- head/share/man/man5/nsswitch.conf.5 Sun Sep  6 20:03:13 2020
(r365390)
+++ head/share/man/man5/nsswitch.conf.5 Sun Sep  6 20:32:13 2020
(r365391)
@@ -33,7 +33,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 10, 2018
+.Dd September 6, 2020
 .Dt NSSWITCH.CONF 5
 .Os
 .Sh NAME
@@ -224,20 +224,24 @@ and continue on anything else (i.e,
 .Ss Cache
 You can enable caching for the particular database by specifying
 .Dq cache
-as the first source in the
+in the
 .Nm
 file.
+It should come after
+.Dq files ,
+but before remote sources like
+.Dq nis .
 You should also enable caching for this database in
 .Xr nscd.conf 5 .
-If for the particular query
+If for a particular query
 .Dq cache
-source returns success, no further sources are queried.
+source returns success, then no further sources are queried.
 On the other hand, if there are no previously cached data, the
 query result will be placed into the cache right after
 all other sources are processed.
-Note, that
+Note that
 .Dq cache
-requires
+requires the
 .Xr nscd 8
 daemon to be running.
 .Ss Compat mode: +/- syntax
@@ -321,15 +325,16 @@ resides in
 .Pa /etc .
 .El
 .Sh EXAMPLES
-To lookup hosts in cache, then in
+To lookup hosts in
 .Pa /etc/hosts
+, then in cache,
 and then from the DNS, and lookup user information from
 .Tn NIS
 then files, use:
 .Pp
 .Bl -tag -width passwd: -compact
 .It hosts:
-cache files dns
+files cache dns
 .It passwd:
 nis [notfound=return] files
 .It group:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r364637 - head/sys/kern

2020-09-06 Thread Alan Somers
On Mon, Aug 24, 2020 at 3:01 AM Mateusz Guzik  wrote:

> Author: mjg
> Date: Mon Aug 24 09:00:57 2020
> New Revision: 364637
> URL: https://svnweb.freebsd.org/changeset/base/364637
>
> Log:
>   cache: lockless reverse lookup
>
>   This enables fully scalable operation for getcwd and significantly
> improves
>   realpath.
>
>   For example:
>   PATH_CUSTOM=/usr/src ./getcwd_processes -t 104
>   before:  1550851
>   after: 380135380
>
>   Tested by:pho
>
> Modified:
>   head/sys/kern/vfs_cache.c
>
> Modified: head/sys/kern/vfs_cache.c
>
> ==
> --- head/sys/kern/vfs_cache.c   Mon Aug 24 09:00:07 2020(r364636)
> +++ head/sys/kern/vfs_cache.c   Mon Aug 24 09:00:57 2020(r364637)
> @@ -477,6 +485,8 @@ STATNODE_COUNTER(shrinking_skipped,
>  static void cache_zap_locked(struct namecache *ncp);
>  static int vn_fullpath_hardlink(struct nameidata *ndp, char **retbuf,
>  char **freebuf, size_t *buflen);
> +static int vn_fullpath_any_smr(struct vnode *vp, struct vnode *rdir, char
> *buf,
> +char **retbuf, size_t *buflen, bool slash_prefixed, size_t addend);
>  static int vn_fullpath_any(struct vnode *vp, struct vnode *rdir, char
> *buf,
>  char **retbuf, size_t *buflen);
>  static int vn_fullpath_dir(struct vnode *vp, struct vnode *rdir, char
> *buf,
> @@ -2476,9 +2486,17 @@ vn_getcwd(char *buf, char **retbuf, size_t *buflen)
>

What does the "smr" stand for?
-Alan
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r364637 - head/sys/kern

2020-09-06 Thread Jessica Clarke
On 6 Sep 2020, at 21:46, Alan Somers  wrote:
> 
> On Mon, Aug 24, 2020 at 3:01 AM Mateusz Guzik  wrote:
> Author: mjg
> Date: Mon Aug 24 09:00:57 2020
> New Revision: 364637
> URL: https://svnweb.freebsd.org/changeset/base/364637
> 
> Log:
>   cache: lockless reverse lookup
> 
>   This enables fully scalable operation for getcwd and significantly improves
>   realpath.
> 
>   For example:
>   PATH_CUSTOM=/usr/src ./getcwd_processes -t 104
>   before:  1550851
>   after: 380135380
> 
>   Tested by:pho
> 
> Modified:
>   head/sys/kern/vfs_cache.c
> 
> Modified: head/sys/kern/vfs_cache.c
> ==
> --- head/sys/kern/vfs_cache.c   Mon Aug 24 09:00:07 2020(r364636)
> +++ head/sys/kern/vfs_cache.c   Mon Aug 24 09:00:57 2020(r364637)
> @@ -477,6 +485,8 @@ STATNODE_COUNTER(shrinking_skipped,
>  static void cache_zap_locked(struct namecache *ncp);
>  static int vn_fullpath_hardlink(struct nameidata *ndp, char **retbuf,
>  char **freebuf, size_t *buflen);
> +static int vn_fullpath_any_smr(struct vnode *vp, struct vnode *rdir, char 
> *buf,
> +char **retbuf, size_t *buflen, bool slash_prefixed, size_t addend);
>  static int vn_fullpath_any(struct vnode *vp, struct vnode *rdir, char *buf,
>  char **retbuf, size_t *buflen);
>  static int vn_fullpath_dir(struct vnode *vp, struct vnode *rdir, char *buf,
> @@ -2476,9 +2486,17 @@ vn_getcwd(char *buf, char **retbuf, size_t *buflen)
> 
> What does the "smr" stand for?

Safe Memory Reclamation (see sys/sys/smr.h and sys/kern/subr_smr.c).

Jess

___
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: r365395 - in head/sys: arm/allwinner/clkng dev/extres/clk

2020-09-06 Thread Andriy Gapon
Author: avg
Date: Mon Sep  7 06:27:18 2020
New Revision: 365395
URL: https://svnweb.freebsd.org/changeset/base/365395

Log:
  aw_clk_nm: fix incorrect use of abs()
  
  abs() takes a (signed) int as input.
  Instead, it was used with unsigned 64-bit integers.
  
  So, add and use a new helper function to calculate a difference between
  two uint64_t-s.
  
  Reviewed by:  manu
  MFC after:2 weeks
  Differential Revision: https://reviews.freebsd.org/D26307

Modified:
  head/sys/arm/allwinner/clkng/aw_clk_nm.c
  head/sys/dev/extres/clk/clk.h

Modified: head/sys/arm/allwinner/clkng/aw_clk_nm.c
==
--- head/sys/arm/allwinner/clkng/aw_clk_nm.cMon Sep  7 06:22:30 2020
(r365394)
+++ head/sys/arm/allwinner/clkng/aw_clk_nm.cMon Sep  7 06:27:18 2020
(r365395)
@@ -153,7 +153,8 @@ aw_clk_nm_find_best(struct aw_clk_nm_sc *sc, uint64_t 
for (m = min_m; m <= max_m; ) {
for (n = min_n; n <= max_n; ) {
cur = fparent / n / m;
-   if (abs(*fout - cur) < abs(*fout - best)) {
+   if (clk_freq_diff(*fout, cur) <
+   clk_freq_diff(*fout, best)) {
best = cur;
*factor_n = n;
*factor_m = m;
@@ -196,7 +197,8 @@ aw_clk_nm_set_freq(struct clknode *clk, uint64_t fpare
clknode_get_freq(p_clk, &fparent);
 
cur = aw_clk_nm_find_best(sc, fparent, fout, &n, &m);
-   if (abs((*fout - cur)) < abs((*fout - best))) {
+   if (clk_freq_diff(*fout, cur) <
+   clk_freq_diff(*fout, best)) {
best = cur;
best_parent = p_idx;
best_n = n;

Modified: head/sys/dev/extres/clk/clk.h
==
--- head/sys/dev/extres/clk/clk.h   Mon Sep  7 06:22:30 2020
(r365394)
+++ head/sys/dev/extres/clk/clk.h   Mon Sep  7 06:27:18 2020
(r365395)
@@ -135,6 +135,12 @@ int clk_get_parent(clk_t clk, clk_t *parent);
 int clk_set_parent_by_clk(clk_t clk, clk_t parent);
 const char *clk_get_name(clk_t clk);
 
+static inline uint64_t
+clk_freq_diff(uint64_t x, uint64_t y)
+{
+   return (x >= y ? x - y : y - x);
+}
+
 #ifdef FDT
 int clk_set_assigned(device_t dev, phandle_t node);
 int clk_get_by_ofw_index(device_t dev, phandle_t node, int idx, clk_t *clk);
___
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: r365396 - head/sys/dev/iicbus/twsi

2020-09-06 Thread Andriy Gapon
Author: avg
Date: Mon Sep  7 06:29:41 2020
New Revision: 365396
URL: https://svnweb.freebsd.org/changeset/base/365396

Log:
  twsi: use tsleep instead of pause for better responsiveness
  
  wakeup() does not have any effect on pause(), so if a transfer was
  not finished by the time of the first check, then the thread
  would sleep full 30 ms.
  
  To do: protect the transfer and interrupt code with the mutex,
  switch from tsleep from msleep
  
  Reviewed by:  manu
  MFC after:3 weeks
  Differential Revision: https://reviews.freebsd.org/D26309

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

Modified: head/sys/dev/iicbus/twsi/twsi.c
==
--- head/sys/dev/iicbus/twsi/twsi.c Mon Sep  7 06:27:18 2020
(r365395)
+++ head/sys/dev/iicbus/twsi/twsi.c Mon Sep  7 06:29:41 2020
(r365396)
@@ -510,7 +510,7 @@ twsi_transfer(device_t dev, struct iic_msg *msgs, uint
sc->control_val &= ~TWSI_CONTROL_ACK;
TWSI_WRITE(sc, sc->reg_control, sc->control_val | TWSI_CONTROL_START);
while (sc->error == 0 && sc->transfer != 0) {
-   pause_sbt("twsi", SBT_1MS * 30, SBT_1MS, 0);
+   tsleep_sbt(sc, 0, "twsi", SBT_1MS * 30, SBT_1MS, 0);
}
debugf(sc->dev, "pause finish\n");
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365397 - head/sys/dev/iicbus/twsi

2020-09-06 Thread Andriy Gapon
Author: avg
Date: Mon Sep  7 06:32:03 2020
New Revision: 365397
URL: https://svnweb.freebsd.org/changeset/base/365397

Log:
  twsi: some variants clear interrupt flag by writing 0, others by writing 1
  
  Make that distinction more explicit and regular in the code.
  The difference in behavior is documented in the respective datasheets.
  
  Previously, the code handled the distinction by writing the control
  register multiple times where at least one write was zero and another
  was one.
  
  This can be considered a follow-up to r363021.
  
  Reviewed by:  manu
  MFC after:4 weeks
  Differential Revision: https://reviews.freebsd.org/D26308

Modified:
  head/sys/dev/iicbus/twsi/a10_twsi.c
  head/sys/dev/iicbus/twsi/twsi.c
  head/sys/dev/iicbus/twsi/twsi.h

Modified: head/sys/dev/iicbus/twsi/a10_twsi.c
==
--- head/sys/dev/iicbus/twsi/a10_twsi.c Mon Sep  7 06:29:41 2020
(r365396)
+++ head/sys/dev/iicbus/twsi/a10_twsi.c Mon Sep  7 06:32:03 2020
(r365397)
@@ -122,6 +122,10 @@ a10_twsi_attach(device_t dev)
sc->reg_soft_reset = TWI_SRST;
 
sc->need_ack = true;
+
+   if (ofw_bus_is_compatible(dev, "allwinner,sun6i-a31-i2c") ||
+   ofw_bus_is_compatible(dev, "allwinner,sun6i-a83t-i2c"))
+   sc->iflag_w1c = true;
return (twsi_attach(dev));
 }
 

Modified: head/sys/dev/iicbus/twsi/twsi.c
==
--- head/sys/dev/iicbus/twsi/twsi.c Mon Sep  7 06:29:41 2020
(r365396)
+++ head/sys/dev/iicbus/twsi/twsi.c Mon Sep  7 06:32:03 2020
(r365397)
@@ -147,7 +147,11 @@ twsi_clear_iflg(struct twsi_softc *sc)
 {
 
DELAY(1000);
-   twsi_control_clear(sc, TWSI_CONTROL_IFLG);
+   /* There are two ways of clearing IFLAG. */
+   if (sc->iflag_w1c)
+   twsi_control_set(sc, TWSI_CONTROL_IFLG);
+   else
+   twsi_control_clear(sc, TWSI_CONTROL_IFLG);
DELAY(1000);
 }
 
@@ -667,13 +671,11 @@ twsi_intr(void *arg)
}
debugf(sc->dev, "Refresh reg_control\n");
 
-   /* 
-* Fix silicon bug on > Allwinner A20 by doing a read and writing
-* again to the control register
+   /*
+* Newer Allwinner chips clear IFLG after writing 1 to it.
 */
-   status = TWSI_READ(sc, sc->reg_status);
-   TWSI_WRITE(sc, sc->reg_control,
- sc->control_val | TWSI_CONTROL_IFLG);
+   TWSI_WRITE(sc, sc->reg_control, sc->control_val |
+   (sc->iflag_w1c ? TWSI_CONTROL_IFLG : 0));
 
debugf(sc->dev, "Done with interrupts\n\n");
if (transfer_done == 1) {

Modified: head/sys/dev/iicbus/twsi/twsi.h
==
--- head/sys/dev/iicbus/twsi/twsi.h Mon Sep  7 06:29:41 2020
(r365396)
+++ head/sys/dev/iicbus/twsi/twsi.h Mon Sep  7 06:32:03 2020
(r365397)
@@ -66,6 +66,7 @@ struct twsi_softc {
int error;
uint32_tcontrol_val;
boolneed_ack;
+   booliflag_w1c;
 
bus_size_t  reg_data;
bus_size_t  reg_slave_addr;
___
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: r365398 - in head/sys: arm/allwinner arm64/conf conf

2020-09-06 Thread Andriy Gapon
Author: avg
Date: Mon Sep  7 06:39:00 2020
New Revision: 365398
URL: https://svnweb.freebsd.org/changeset/base/365398

Log:
  Allwinner USB DRD support (musb_otg)
  
  Allwinner USB DRD is based on the Mentor USB OTG controller, with a
  different register layout and a few missing registers.
  
  The code is by Andrew Turner (andrew).
  
  Reviewed by:  hselasky, manu
  Obtained from:andrew
  MFC after:5 weeks
  Differential Revision: https://reviews.freebsd.org/D5881

Modified:
  head/sys/arm/allwinner/aw_usbphy.c
  head/sys/arm/allwinner/files.allwinner
  head/sys/arm64/conf/GENERIC
  head/sys/conf/files.arm64

Modified: head/sys/arm/allwinner/aw_usbphy.c
==
--- head/sys/arm/allwinner/aw_usbphy.c  Mon Sep  7 06:32:03 2020
(r365397)
+++ head/sys/arm/allwinner/aw_usbphy.c  Mon Sep  7 06:39:00 2020
(r365398)
@@ -169,6 +169,18 @@ DEFINE_CLASS_1(awusbphy_phynode, awusbphy_phynode_clas
 #defineCLR4(res, o, m) WR4(res, o, RD4(res, o) & ~(m))
 #defineSET4(res, o, m) WR4(res, o, RD4(res, o) | (m))
 
+#definePHY_CSR 0x00
+#define ID_PULLUP_EN   (1 << 17)
+#define DPDM_PULLUP_EN (1 << 16)
+#define FORCE_ID   (0x3 << 14)
+#define FORCE_ID_SHIFT 14
+#define FORCE_ID_LOW   2
+#define FORCE_VBUS_VALID   (0x3 << 12)
+#define FORCE_VBUS_VALID_SHIFT 12
+#define FORCE_VBUS_VALID_HIGH  3
+#define VBUS_CHANGE_DET(1 << 6)
+#define ID_CHANGE_DET  (1 << 5)
+#define DPDM_CHANGE_DET(1 << 4)
 #defineOTG_PHY_CFG 0x20
 #define OTG_PHY_ROUTE_OTG  (1 << 0)
 #definePMU_IRQ_ENABLE  0x00
@@ -214,6 +226,7 @@ awusbphy_init(device_t dev)
struct awusbphy_softc *sc;
phandle_t node;
char pname[20];
+   uint32_t val;
int error, off, rid;
regulator_t reg;
hwreset_t rst;
@@ -288,6 +301,16 @@ awusbphy_init(device_t dev)
return (ENXIO);
}
}
+
+   /* Enable OTG PHY for host mode */
+   val = bus_read_4(sc->phy_ctrl, PHY_CSR);
+   val &= ~(VBUS_CHANGE_DET | ID_CHANGE_DET | DPDM_CHANGE_DET);
+   val |= (ID_PULLUP_EN | DPDM_PULLUP_EN);
+   val &= ~FORCE_ID;
+   val |= (FORCE_ID_LOW << FORCE_ID_SHIFT);
+   val &= ~FORCE_VBUS_VALID;
+   val |= (FORCE_VBUS_VALID_HIGH << FORCE_VBUS_VALID_SHIFT);
+   bus_write_4(sc->phy_ctrl, PHY_CSR, val);
 
return (0);
 }

Modified: head/sys/arm/allwinner/files.allwinner
==
--- head/sys/arm/allwinner/files.allwinner  Mon Sep  7 06:32:03 2020
(r365397)
+++ head/sys/arm/allwinner/files.allwinner  Mon Sep  7 06:39:00 2020
(r365398)
@@ -27,6 +27,7 @@ dev/usb/controller/generic_ohci.c optionalohci
 dev/usb/controller/generic_usb_if.moptionalohci
 dev/usb/controller/generic_ehci.c  optionalehci
 dev/usb/controller/generic_ehci_fdt.c  optionalehci
+dev/usb/controller/musb_otg_allwinner.coptionalmusb
 arm/allwinner/aw_sid.c optionalaw_sid
 arm/allwinner/aw_thermal.c optionalaw_thermal
 arm/allwinner/aw_cir.c optionalaw_cir evdev

Modified: head/sys/arm64/conf/GENERIC
==
--- head/sys/arm64/conf/GENERIC Mon Sep  7 06:32:03 2020(r365397)
+++ head/sys/arm64/conf/GENERIC Mon Sep  7 06:39:00 2020(r365398)
@@ -222,6 +222,7 @@ device  aw_usbphy   # Allwinner USB 
PHY
 device rk_usb2phy  # Rockchip USB2PHY
 device rk_typec_phy# Rockchip TypeC PHY
 device dwcotg  # DWC OTG controller
+device musb# Mentor Graphics USB OTG controller
 device ohci# OHCI USB interface
 device ehci# EHCI USB interface (USB 2.0)
 device ehci_mv # Marvell EHCI USB interface

Modified: head/sys/conf/files.arm64
==
--- head/sys/conf/files.arm64   Mon Sep  7 06:32:03 2020(r365397)
+++ head/sys/conf/files.arm64   Mon Sep  7 06:39:00 2020(r365398)
@@ -339,6 +339,7 @@ dev/usb/controller/generic_ehci_acpi.c optional ehci a
 dev/usb/controller/generic_ehci_fdt.c optional ehci fdt
 dev/usb/controller/generic_ohci.c optional ohci fdt
 dev/usb/controller/generic_usb_if.m optional   ohci fdt
+dev/usb/controller/musb_otg_allwinner.coptional musb fdt 
soc_allwinner_a64
 dev/usb/controller/usb_nop_xceiv.c optional fdt ext_resources
 dev/usb/controller/generic_xhci.c  optionalxhci
 dev/us

svn commit: r365399 - head/sys/dev/usb/controller

2020-09-06 Thread Andriy Gapon
Author: avg
Date: Mon Sep  7 06:44:24 2020
New Revision: 365399
URL: https://svnweb.freebsd.org/changeset/base/365399

Log:
  fixup r365398: add a missed file with all the new Allwinner musb_otg code
  
  Obtained from:andrew
  MFC after:5 weeks
  X-MFC with:   r365398

Added:
  head/sys/dev/usb/controller/musb_otg_allwinner.c   (contents, props changed)

Added: head/sys/dev/usb/controller/musb_otg_allwinner.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/usb/controller/musb_otg_allwinner.cMon Sep  7 06:44:24 
2020(r365399)
@@ -0,0 +1,543 @@
+/*-
+ * Copyright (c) 2016 Jared McNeill 
+ * Copyright (c) 2018 Andrew Turner 
+ * All rights reserved.
+ *
+ * This software was developed by SRI International and the University of
+ * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
+ * ("CTSRD"), as part of the DARPA CRASH research programme.
+ *
+ * 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 ``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 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$
+ */
+
+/*
+ * Allwinner USB Dual-Role Device (DRD) controller
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#ifdef __arm__
+#include 
+#include 
+#endif
+
+#defineDRD_EP_MAX  5
+
+#defineMUSB2_REG_AWIN_VEND00x0043
+#defineVEND0_PIO_MODE  0
+
+#if defined(__arm__)
+#definebs_parent_space(bs) ((bs)->bs_parent)
+typedef bus_space_tag_tawusb_bs_tag;
+#elif defined(__aarch64__)
+#definebs_parent_space(bs) (bs)
+typedef void * awusb_bs_tag;
+#endif
+
+#defineAWUSB_OKAY  0x01
+#defineAWUSB_NO_CONFDATA   0x02
+static struct ofw_compat_data compat_data[] = {
+   { "allwinner,sun4i-a10-musb",   AWUSB_OKAY },
+   { "allwinner,sun6i-a31-musb",   AWUSB_OKAY },
+   { "allwinner,sun8i-a33-musb",   AWUSB_OKAY | AWUSB_NO_CONFDATA },
+   { NULL, 0 }
+};
+
+static const struct musb_otg_ep_cfg musbotg_ep_allwinner[] = {
+   {
+   .ep_end = 5,
+   .ep_fifosz_shift = 9,
+   .ep_fifosz_reg = MUSB2_VAL_FIFOSZ_512,
+   },
+   {
+   .ep_end = -1,
+   },
+};
+
+struct awusbdrd_softc {
+   struct musbotg_softcsc;
+   struct resource *res[2];
+   clk_t   clk;
+   hwreset_t   reset;
+   struct bus_spacebs;
+   int flags;
+};
+
+static struct resource_spec awusbdrd_spec[] = {
+   { SYS_RES_MEMORY,   0,  RF_ACTIVE },
+   { SYS_RES_IRQ,  0,  RF_ACTIVE },
+   { -1, 0 }
+};
+
+#defineREMAPFLAG   0x8000
+#defineREGDECL(a, b)   [(a)] = ((b) | REMAPFLAG)
+
+/* Allwinner USB DRD register mappings */
+static const uint16_t awusbdrd_regmap[] = {
+   REGDECL(MUSB2_REG_EPFIFO(0),0x),
+   REGDECL(MUSB2_REG_EPFIFO(1),0x0004),
+   REGDECL(MUSB2_REG_EPFIFO(2),0x0008),
+   REGDECL(MUSB2_REG_EPFIFO(3),0x000c),
+   REGDECL(MUSB2_REG_EPFIFO(4),0x0010),
+   REGDECL(MUSB2_REG_EPFIFO(5),0x0014),
+   REGDECL(MUSB2_REG_POWER,0x0040),
+   REGDECL(MUSB2_REG_DEVCTL,   0x0041),
+   REGDECL(MUSB2_REG_EPINDEX,  0x0042),
+   REGDECL(MUSB2_REG_INTTX,0x0044),
+   REGDECL(MUSB2_REG_INTRX,0x0046),
+   REGDECL(MUSB2_REG_INTTXE,   0x0048),
+   REGDECL(MUSB2_REG_INTRXE,   0x004a),
+   REGDECL

svn commit: r365400 - head/sys/dev/usb/controller

2020-09-06 Thread Andriy Gapon
Author: avg
Date: Mon Sep  7 06:48:08 2020
New Revision: 365400
URL: https://svnweb.freebsd.org/changeset/base/365400

Log:
  musb/allwinner: apply register filter in awusbdrd_bs_r_2() as well
  
  Otherwise, I get this panic:
  panic: awusbdrd_reg: Invalid register 0x342
  
  It looks that musb code both writes and reads at least MUSB2_REG_TXDBDIS.
  
  MFC after:5 weeks
  X-MFC after:  r365399

Modified:
  head/sys/dev/usb/controller/musb_otg_allwinner.c

Modified: head/sys/dev/usb/controller/musb_otg_allwinner.c
==
--- head/sys/dev/usb/controller/musb_otg_allwinner.cMon Sep  7 06:44:24 
2020(r365399)
+++ head/sys/dev/usb/controller/musb_otg_allwinner.cMon Sep  7 06:48:08 
2020(r365400)
@@ -259,6 +259,8 @@ awusbdrd_bs_r_2(awusb_bs_tag t, bus_space_handle_t h, 
 {
const struct bus_space *bs = t;
 
+   if (awusbdrd_filt(o) != 0)
+   return (0);
return bus_space_read_2(bs_parent_space(bs), h, awusbdrd_reg(o));
 }
 
___
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: r365401 - head/sys/dev/usb/controller

2020-09-06 Thread Andriy Gapon
Author: avg
Date: Mon Sep  7 06:49:07 2020
New Revision: 365401
URL: https://svnweb.freebsd.org/changeset/base/365401

Log:
  musb/allwinner: add H3 support
  
  MFC after:6 weeks

Modified:
  head/sys/dev/usb/controller/musb_otg_allwinner.c

Modified: head/sys/dev/usb/controller/musb_otg_allwinner.c
==
--- head/sys/dev/usb/controller/musb_otg_allwinner.cMon Sep  7 06:48:08 
2020(r365400)
+++ head/sys/dev/usb/controller/musb_otg_allwinner.cMon Sep  7 06:49:07 
2020(r365401)
@@ -71,6 +71,7 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #defineDRD_EP_MAX  5
+#defineDRD_EP_MAX_H3   4
 
 #defineMUSB2_REG_AWIN_VEND00x0043
 #defineVEND0_PIO_MODE  0
@@ -89,12 +90,13 @@ static struct ofw_compat_data compat_data[] = {
{ "allwinner,sun4i-a10-musb",   AWUSB_OKAY },
{ "allwinner,sun6i-a31-musb",   AWUSB_OKAY },
{ "allwinner,sun8i-a33-musb",   AWUSB_OKAY | AWUSB_NO_CONFDATA },
+   { "allwinner,sun8i-h3-musb",AWUSB_OKAY | AWUSB_NO_CONFDATA },
{ NULL, 0 }
 };
 
 static const struct musb_otg_ep_cfg musbotg_ep_allwinner[] = {
{
-   .ep_end = 5,
+   .ep_end = DRD_EP_MAX,
.ep_fifosz_shift = 9,
.ep_fifosz_reg = MUSB2_VAL_FIFOSZ_512,
},
@@ -103,6 +105,17 @@ static const struct musb_otg_ep_cfg musbotg_ep_allwinn
},
 };
 
+static const struct musb_otg_ep_cfg musbotg_ep_allwinner_h3[] = {
+   {
+   .ep_end = DRD_EP_MAX_H3,
+   .ep_fifosz_shift = 9,
+   .ep_fifosz_reg = MUSB2_VAL_FIFOSZ_512,
+   },
+   {
+   .ep_end = -1,
+   },
+};
+
 struct awusbdrd_softc {
struct musbotg_softcsc;
struct resource *res[2];
@@ -445,8 +458,13 @@ awusbdrd_attach(device_t dev)
sc->sc.sc_id = 0;
sc->sc.sc_platform_data = sc;
sc->sc.sc_mode = MUSB2_HOST_MODE;   /* XXX HOST vs DEVICE mode */
-   sc->sc.sc_ep_max = DRD_EP_MAX;
-   sc->sc.sc_ep_cfg = musbotg_ep_allwinner;
+   if (ofw_bus_is_compatible(dev, "allwinner,sun8i-h3-musb")) {
+   sc->sc.sc_ep_cfg = musbotg_ep_allwinner_h3;
+   sc->sc.sc_ep_max = DRD_EP_MAX_H3;
+   } else {
+   sc->sc.sc_ep_cfg = musbotg_ep_allwinner;
+   sc->sc.sc_ep_max = DRD_EP_MAX;
+   }
 
error = bus_setup_intr(dev, sc->res[1], INTR_MPSAFE | INTR_TYPE_BIO,
NULL, awusbdrd_intr, sc, &sc->sc.sc_intr_hdl);
___
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: r365402 - head/sys/dev/usb/controller

2020-09-06 Thread Andriy Gapon
Author: avg
Date: Mon Sep  7 06:53:29 2020
New Revision: 365402
URL: https://svnweb.freebsd.org/changeset/base/365402

Log:
  musb/allwinner: add support for configuring phy as well as device mode
  
  At least on Orange Pi PC Plus even the host mode does not work without
  enabling the phy and setting it to the host mode.
  
  The driver will now parse dr_mode property and will try to configure
  itself and the phy accordingly.
  OTG mode is not supported yet, so it is treated as the device / peripheral
  mode.
  
  The phy is enabled -- powered on -- only for the host mode.
  
  The device mode requires support from a phy driver, e.g., aw_usbphy on
  Allwinner platform.
  aw_usbphy does not support the device mode, so it cannnot work yet.
  
  MFC after:6 weeks

Modified:
  head/sys/dev/usb/controller/musb_otg_allwinner.c

Modified: head/sys/dev/usb/controller/musb_otg_allwinner.c
==
--- head/sys/dev/usb/controller/musb_otg_allwinner.cMon Sep  7 06:49:07 
2020(r365401)
+++ head/sys/dev/usb/controller/musb_otg_allwinner.cMon Sep  7 06:53:29 
2020(r365402)
@@ -64,6 +64,8 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
+#include 
 
 #ifdef __arm__
 #include 
@@ -121,6 +123,7 @@ struct awusbdrd_softc {
struct resource *res[2];
clk_t   clk;
hwreset_t   reset;
+   phy_t   phy;
struct bus_spacebs;
int flags;
 };
@@ -382,7 +385,10 @@ awusbdrd_probe(device_t dev)
 static int
 awusbdrd_attach(device_t dev)
 {
+   char usb_mode[24];
struct awusbdrd_softc *sc;
+   uint8_t musb_mode;
+   int phy_mode;
int error;
 
sc = device_get_softc(dev);
@@ -392,6 +398,31 @@ awusbdrd_attach(device_t dev)
if (error != 0)
return (error);
 
+   musb_mode = MUSB2_HOST_MODE;/* default */
+   phy_mode = PHY_USB_MODE_HOST;
+   if (OF_getprop(ofw_bus_get_node(dev), "dr_mode",
+   &usb_mode, sizeof(usb_mode)) > 0) {
+   usb_mode[sizeof(usb_mode) - 1] = 0;
+   if (strcasecmp(usb_mode, "host") == 0) {
+   musb_mode = MUSB2_HOST_MODE;
+   phy_mode = PHY_USB_MODE_HOST;
+   } else if (strcasecmp(usb_mode, "peripheral") == 0) {
+   musb_mode = MUSB2_DEVICE_MODE;
+   phy_mode = PHY_USB_MODE_DEVICE;
+   } else if (strcasecmp(usb_mode, "otg") == 0) {
+   /*
+* XXX phy has PHY_USB_MODE_OTG, but MUSB does not have
+* it.  It's not clear how to propagate mode changes
+* from phy layer (that detects them) to MUSB.
+*/
+   musb_mode = MUSB2_DEVICE_MODE;
+   phy_mode = PHY_USB_MODE_DEVICE;
+   } else {
+   device_printf(dev, "Invalid FDT dr_mode: %s\n",
+   usb_mode);
+   }
+   }
+
/* AHB gate clock is required */
error = clk_get_by_ofw_index(dev, 0, 0, &sc->clk);
if (error != 0)
@@ -415,6 +446,24 @@ awusbdrd_attach(device_t dev)
}
}
 
+   /* XXX not sure if this is universally needed. */
+   (void)phy_get_by_ofw_name(dev, 0, "usb", &sc->phy);
+   if (sc->phy != NULL) {
+   device_printf(dev, "setting phy mode %d\n", phy_mode);
+   if (musb_mode == MUSB2_HOST_MODE) {
+   error = phy_enable(sc->phy);
+   if (error != 0) {
+   device_printf(dev, "Could not enable phy\n");
+   goto fail;
+   }
+   }
+   error = phy_usb_set_mode(sc->phy, phy_mode);
+   if (error != 0) {
+   device_printf(dev, "Could not set phy mode\n");
+   goto fail;
+   }
+   }
+
sc->sc.sc_bus.parent = dev;
sc->sc.sc_bus.devices = sc->sc.sc_devices;
sc->sc.sc_bus.devices_max = MUSB2_MAX_DEVICES;
@@ -457,7 +506,7 @@ awusbdrd_attach(device_t dev)
device_set_ivars(sc->sc.sc_bus.bdev, &sc->sc.sc_bus);
sc->sc.sc_id = 0;
sc->sc.sc_platform_data = sc;
-   sc->sc.sc_mode = MUSB2_HOST_MODE;   /* XXX HOST vs DEVICE mode */
+   sc->sc.sc_mode = musb_mode;
if (ofw_bus_is_compatible(dev, "allwinner,sun8i-h3-musb")) {
sc->sc.sc_ep_cfg = musbotg_ep_allwinner_h3;
sc->sc.sc_ep_max = DRD_EP_MAX_H3;
@@ -497,8 +546,15 @@ awusbdrd_attach(device_t dev)
return (0);
 
 fail:
-   if (sc->reset != NULL)
+   if (sc->phy != NULL) {
+   if (musb_mode == MUSB2_HOST_MODE)
+   (void)phy_disable(sc->phy);
+