attach ahci faster
On some systems, attaching ahci(4) is one of the most noticeably slow parts of the boot process, since each port with no device attached takes a whole second to probe. I've made a few noises about fixing that over the years, and here's a new one. This rearranges the device detection phase so that we poll all the ports in parallel until either all ports have detected a device or one second has elapsed. Devices are still attached in the same order, just faster. The diff doesn't really show what's going on, since it's mostly splitting up ahci_port_portreset into a few smaller pieces. VMware's emulated ahci always has 32 ports, so this cuts about 30 seconds off boot time if you use that for some reason. Qemu's has fewer ports, so it only cuts 4s or so off in my testing. Similar improvements can be expected on desktop systems since they tend to have some extra sata ports, but laptops are unlikely to see any difference. ok? diff --git a/sys/dev/ic/ahci.c b/sys/dev/ic/ahci.c index 9057d44ff78..00a162cf340 100644 --- a/sys/dev/ic/ahci.c +++ b/sys/dev/ic/ahci.c @@ -72,6 +72,7 @@ void ahci_enable_interrupts(struct ahci_port *); intahci_init(struct ahci_softc *); intahci_port_alloc(struct ahci_softc *, u_int); +void ahci_port_detect(struct ahci_softc *, u_int); void ahci_port_free(struct ahci_softc *, u_int); intahci_port_init(struct ahci_softc *, u_int); @@ -80,6 +81,9 @@ int ahci_port_stop(struct ahci_port *, int); intahci_port_clo(struct ahci_port *); intahci_port_softreset(struct ahci_port *); intahci_port_portreset(struct ahci_port *, int); +void ahci_port_portreset_start(struct ahci_port *); +intahci_port_portreset_poll(struct ahci_port *); +intahci_port_portreset_finish(struct ahci_port *, int); intahci_port_signature(struct ahci_port *); intahci_pmp_port_softreset(struct ahci_port *, int); intahci_pmp_port_portreset(struct ahci_port *, int); @@ -173,7 +177,7 @@ ahci_attach(struct ahci_softc *sc) { struct atascsi_attach_args aaa; u_int32_t pi; - int i; + int i, j, done; if (sc->sc_port_start == NULL) sc->sc_port_start = ahci_default_port_start; @@ -268,6 +272,37 @@ noccc: if (ahci_port_alloc(sc, i) == ENOMEM) goto freeports; + + if (sc->sc_ports[i] != NULL) + ahci_port_portreset_start(sc->sc_ports[i]); + } + + /* +* Poll for device detection until all ports report a device, or one +* second has elapsed. +*/ + for (i = 0; i < 1000; i++) { + done = 1; + for (j = 0; j < AHCI_MAX_PORTS; j++) { + if (sc->sc_ports[j] == NULL) + continue; + + if (ahci_port_portreset_poll(sc->sc_ports[j])) + done = 0; + } + + if (done) + break; + + delay(1000); + } + + /* +* Finish device detection on all ports that initialized. +*/ + for (i = 0; i < AHCI_MAX_PORTS; i++) { + if (sc->sc_ports[i] != NULL) + ahci_port_detect(sc, i); } memset(, 0, sizeof(aaa)); @@ -446,7 +481,6 @@ ahci_port_alloc(struct ahci_softc *sc, u_int port) u_int32_t cmd; struct ahci_cmd_hdr *hdr; struct ahci_cmd_table *table; - const char *speed; int i, rc = ENOMEM; ap = malloc(sizeof(*ap), M_DEVBUF, M_NOWAIT | M_ZERO); @@ -594,10 +628,25 @@ nomem: /* Wait for ICC change to complete */ ahci_pwait_clr(ap, AHCI_PREG_CMD, AHCI_PREG_CMD_ICC, 1); + rc = 0; - /* Reset port */ - rc = ahci_port_portreset(ap, 1); +freeport: + if (rc != 0) + ahci_port_free(sc, port); +reterr: + return (rc); +} + +void +ahci_port_detect(struct ahci_softc *sc, u_int port) +{ + struct ahci_port*ap; + const char *speed; + int rc; + + ap = sc->sc_ports[port]; + rc = ahci_port_portreset_finish(ap, 1); switch (rc) { case ENODEV: switch (ahci_pread(ap, AHCI_PREG_SSTS) & AHCI_PREG_SSTS_DET) { @@ -667,12 +716,9 @@ nomem: ahci_write(sc, AHCI_REG_IS, 1 << port); ahci_enable_interrupts(ap); - freeport: if (rc != 0) ahci_port_free(sc, port); -reterr: - return (rc); }
Re: tetris: use monotonic clock for fall timeout
1 week bump. -- Scott Cheloha > On Aug 5, 2017, at 8:25 PM, Scott Chelohawrote: > > Hi, > > In tetris(6) we use gettimeofday(2) to determine (roughly) how > long we polled for user input. This then gets subtracted from > the time remaining until we drop the block another row. > > This should be computed with a monotonic clock instead, lest > bullshit like clock drift rob you of that crucial tenth of a > second and cost you your new high score. > > Moving to a monotonic clock implies using nanoseconds instead of > microseconds, but this actually turns out to be kind of nice > because ppoll(2) accepts a timespec structure, so then we can > delete a few things we were using to jam a timeval into poll(2). > > I've playtested a bit and it doesn't ~feel~ any different. If > anything the game *should* feel less choppy under certain > conditions, though I can't really prove that. > > Feedback? > > -- > Scott Cheloha > > Index: games/tetris/input.c > === > RCS file: /cvs/src/games/tetris/input.c,v > retrieving revision 1.18 > diff -u -p -r1.18 input.c > --- games/tetris/input.c 27 Aug 2016 02:02:44 - 1.18 > +++ games/tetris/input.c 6 Aug 2017 01:21:41 - > @@ -40,89 +40,75 @@ > */ > > #include > + > #include > #include > +#include > #include > > #include "input.h" > #include "tetris.h" > > -/* return true iff the given timeval is positive */ > -#define TV_POS(tv) \ > - ((tv)->tv_sec > 0 || ((tv)->tv_sec == 0 && (tv)->tv_usec > 0)) > - > -/* subtract timeval `sub' from `res' */ > -#define TV_SUB(res, sub) \ > - (res)->tv_sec -= (sub)->tv_sec; \ > - (res)->tv_usec -= (sub)->tv_usec; \ > - if ((res)->tv_usec < 0) { \ > - (res)->tv_usec += 100; \ > - (res)->tv_sec--; \ > - } > +/* return true iff the given timespec is positive */ > +#define TS_POS(ts) \ > + ((ts)->tv_sec > 0 || ((ts)->tv_sec == 0 && (ts)->tv_nsec > 0)) > > /* > - * Do a `read wait': poll for reading from stdin, with timeout *tvp. > - * On return, modify *tvp to reflect the amount of time spent waiting. > + * Do a `read wait': poll for reading from stdin, with timeout *limit. > + * On return, subtract the time spent waiting from *limit. > * It will be positive only if input appeared before the time ran out; > * otherwise it will be zero or perhaps negative. > * > - * If tvp is nil, wait forever, but return if poll is interrupted. > + * If limit is NULL, wait forever, but return if poll is interrupted. > * > - * Return 0 => no input, 1 => can read() from stdin > + * Return 0 => no input, 1 => can read() from stdin, -1 => interrupted > */ > int > -rwait(struct timeval *tvp) > +rwait(struct timespec *limit) > { > - int timo = INFTIM; > - struct timeval starttv, endtv; > + struct timespec start, end, elapsed; > struct pollfd pfd[1]; > > -#define NILTZ ((struct timezone *)0) > - > - if (tvp) { > - (void) gettimeofday(, NILTZ); > - endtv = *tvp; > - timo = endtv.tv_sec * 1000 + endtv.tv_usec / 1000; > - } > -again: > pfd[0].fd = STDIN_FILENO; > pfd[0].events = POLLIN; > - switch (poll(pfd, 1, timo)) { > + > + if (limit != NULL) > + clock_gettime(CLOCK_MONOTONIC, ); > +again: > + switch (ppoll(pfd, 1, limit, NULL)) { > case -1: > - if (tvp == 0) > + if (limit == NULL) > return (-1); > if (errno == EINTR) > goto again; > stop("poll failed, help"); > - > case 0: /* timed out */ > - tvp->tv_sec = 0; > - tvp->tv_usec = 0; > + timespecclear(limit); > return (0); > } > - if (tvp) { > - /* since there is input, we may not have timed out */ > - (void) gettimeofday(, NILTZ); > - TV_SUB(, ); > - TV_SUB(tvp, );/* adjust *tvp by elapsed time */ > + if (limit != NULL) { > + /* we have input, so subtract the elapsed time from *limit */ > + clock_gettime(CLOCK_MONOTONIC, ); > + timespecsub(, , ); > + timespecsub(limit, , limit); > } > return (1); > } > > /* > - * `sleep' for the current turn time (using poll). > - * Eat any input that might be available. > + * `sleep' for the current turn time and eat any > + * input that becomes available. > */ > void > tsleep(void) > { > - struct timeval tv; > + struct timespec ts; > char c; > > - tv.tv_sec = 0; > - tv.tv_usec = fallrate; > - while (TV_POS()) > - if (rwait() && read(STDIN_FILENO, , 1) != 1) > + ts.tv_sec = 0; > + ts.tv_nsec = fallrate; > + while (TS_POS()) > + if (rwait() && read(STDIN_FILENO, , 1) != 1) > break; > } > > @@ -132,7 +118,7 @@
dd: use monotonic clock for summary statistics
Hi, Another gettimeofday(2) -> clock_gettime(2) w/ CLOCK_MONOTONIC. This is a statistics printout, so you naturally don't want the timer subject to jumping. Also, you're supposed to include to use gettimeofday(2), which we were not doing in dd.c, so I guess this fixes that in a bit of a roundabout sort of way. Feedback? -- Scott Cheloha Index: bin/dd/dd.c === RCS file: /cvs/src/bin/dd/dd.c,v retrieving revision 1.23 diff -u -p -r1.23 dd.c --- bin/dd/dd.c 9 Oct 2015 01:37:06 - 1.23 +++ bin/dd/dd.c 13 Aug 2017 01:33:17 - @@ -193,7 +193,7 @@ setup(void) } /* Statistics timestamp. */ - (void)gettimeofday(, (struct timezone *)NULL); + clock_gettime(CLOCK_MONOTONIC, ); } static void Index: bin/dd/dd.h === RCS file: /cvs/src/bin/dd/dd.h,v retrieving revision 1.7 diff -u -p -r1.7 dd.h --- bin/dd/dd.h 16 Aug 2016 16:44:55 - 1.7 +++ bin/dd/dd.h 13 Aug 2017 01:33:17 - @@ -68,7 +68,7 @@ typedef struct { size_t trunc; /* # of truncated records */ size_t swab; /* # of odd-length swab blocks */ off_t bytes; /* # of bytes written */ - struct timeval startv; /* start time of dd */ + struct timespec start; /* start time of dd */ } STAT; /* Flags (in ddflags). */ Index: bin/dd/misc.c === RCS file: /cvs/src/bin/dd/misc.c,v retrieving revision 1.20 diff -u -p -r1.20 misc.c --- bin/dd/misc.c 25 Aug 2016 05:25:21 - 1.20 +++ bin/dd/misc.c 13 Aug 2017 01:33:17 - @@ -52,20 +52,20 @@ void summary(void) { - struct timeval nowtv; + struct timespec elapsed, now; char buf[4][100]; struct iovec iov[4]; - double microsecs; + double nanosecs; int i = 0; if (ddflags & C_NOINFO) return; - (void)gettimeofday(, (struct timezone *)NULL); - timersub(, , ); - microsecs = ((double)nowtv.tv_sec * 100) + nowtv.tv_usec; - if (microsecs == 0) - microsecs = 1; + clock_gettime(CLOCK_MONOTONIC, ); + timespecsub(, , ); + nanosecs = ((double)elapsed.tv_sec * 10) + elapsed.tv_nsec; + if (nanosecs == 0) + nanosecs = 1; /* Use snprintf(3) so that we don't reenter stdio(3). */ (void)snprintf(buf[0], sizeof(buf[0]), @@ -92,8 +92,8 @@ summary(void) (void)snprintf(buf[3], sizeof(buf[3]), "%lld bytes transferred in %lld.%03ld secs " "(%0.0f bytes/sec)\n", (long long)st.bytes, - (long long)nowtv.tv_sec, nowtv.tv_usec / 1000, - ((double)st.bytes * 100) / microsecs); + (long long)elapsed.tv_sec, elapsed.tv_nsec / 100, + ((double)st.bytes * 10) / nanosecs); iov[i].iov_base = buf[3]; iov[i++].iov_len = strlen(buf[3]); }
[patch] Add -z and -Z to apmd for automatic suspend/hibernate
Hello tech@ I've been stuck with fsck for way to many times now because of me forgetting to connect the AC power. This patch will add -z and -Z followed by the percentage. apmd will try to suspend or hibernate the system if the AC is not connected and the estimated battery life goes below the specified percentage. Jesper Wallin Index: usr.sbin/apmd/apmd.8 === RCS file: /cvs/src/usr.sbin/apmd/apmd.8,v retrieving revision 1.47 diff -u -p -r1.47 apmd.8 --- usr.sbin/apmd/apmd.812 Feb 2015 14:03:49 - 1.47 +++ usr.sbin/apmd/apmd.812 Aug 2017 21:18:28 - @@ -113,6 +113,16 @@ The polling rate defaults to once per 10 minutes, but may be specified using the .Fl t command-line flag. +.It Fl z Ar percent +Automatically suspend the system if no AC is connected and the +estimated battery life is equal or below +.Ar percent . +.It Fl Z Ar percent +Automatically hibernate the system if no AC is connected and the +estimated battery life is equal or below +.Ar percent . +This will supersedes +.Fl z . .El .Pp When a client requests a suspend or stand-by state, Index: usr.sbin/apmd/apmd.c === RCS file: /cvs/src/usr.sbin/apmd/apmd.c,v retrieving revision 1.79 diff -u -p -r1.79 apmd.c --- usr.sbin/apmd/apmd.c16 Nov 2015 17:35:05 - 1.79 +++ usr.sbin/apmd/apmd.c12 Aug 2017 21:18:28 - @@ -94,8 +94,8 @@ void usage(void) { fprintf(stderr, - "usage: %s [-AadHLs] [-f devname] [-S sockname] [-t seconds]\n", - __progname); + "usage: %s [-AadHLs] [-f devname] [-S sockname] [-t seconds] " + "[-z percent] [-Z percent]\n", __progname); exit(1); } @@ -348,6 +348,8 @@ main(int argc, char *argv[]) { const char *fname = apmdev; int ctl_fd, sock_fd, ch, suspends, standbys, hibernates, resumes; + int autoaction = 0; + int autolimit = 0; int statonly = 0; int powerstatus = 0, powerbak = 0, powerchange = 0; int noacsleep = 0; @@ -361,7 +363,7 @@ main(int argc, char *argv[]) int ncpu; size_t ncpu_sz = sizeof(ncpu); - while ((ch = getopt(argc, argv, "aACdHLsf:t:S:")) != -1) + while ((ch = getopt(argc, argv, "aACdHLsf:t:S:z:Z:")) != -1) switch(ch) { case 'a': noacsleep = 1; @@ -402,6 +404,14 @@ main(int argc, char *argv[]) doperf = PERF_MANUAL; setperfpolicy("high"); break; + case 'z': + autoaction = 1; + autolimit = strtoul(optarg, NULL, 0); + break; + case 'Z': + autoaction = 2; + autolimit = strtoul(optarg, NULL, 0); + break; case '?': default: usage(); @@ -479,6 +489,20 @@ main(int argc, char *argv[]) if (powerstatus != powerbak) { powerstatus = powerbak; powerchange = 1; + } + + if (!powerstatus && autoaction && + autolimit > (int)pinfo.battery_life) { + syslog(LOG_NOTICE, "estimated battery life %d%%, " + "autoaction limit set to %d%% .", + pinfo.battery_life, + autolimit + ); + + if (autoaction == 1) + suspend(ctl_fd); + else + hibernate(ctl_fd); } }
iwm: end scan in interrupt context
iwm schedules a separate task just for calling ieee80211_end_scan(). That function is safe to call in interrupt context. This wrinkle was already part of the original driver from 2015 but with a workq instead of a task. Back then, the driver had to run two separate scan commands in succession (for 2 GHz and then 5 GHz). Which is why a task was used, since sending another command requires a sleepable context. Nowadays, with our current firmware, a single scan command is sufficient so there is no code path which needs to sleep when the scan ends. This gives me one less asynchronous task to worry about in this driver. OK? Index: if_iwm.c === RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v retrieving revision 1.204 diff -u -p -r1.204 if_iwm.c --- if_iwm.c23 Jul 2017 13:51:11 - 1.204 +++ if_iwm.c12 Aug 2017 18:40:12 - @@ -442,7 +442,7 @@ voidiwm_setrates(struct iwm_node *); intiwm_media_change(struct ifnet *); void iwm_newstate_task(void *); intiwm_newstate(struct ieee80211com *, enum ieee80211_state, int); -void iwm_endscan_cb(void *); +void iwm_endscan(struct iwm_softc *); void iwm_fill_sf_command(struct iwm_softc *, struct iwm_sf_cfg_cmd *, struct ieee80211_node *); intiwm_sf_config(struct iwm_softc *, int); @@ -5952,13 +5952,11 @@ iwm_newstate(struct ieee80211com *ic, en } void -iwm_endscan_cb(void *arg) +iwm_endscan(struct iwm_softc *sc) { - struct iwm_softc *sc = arg; struct ieee80211com *ic = >sc_ic; - /* Check if device was reset while scanning. */ - if (ic->ic_state != IEEE80211_S_SCAN) + if ((sc->sc_flags & IWM_FLAG_SCANNING) == 0) return; sc->sc_flags &= ~IWM_FLAG_SCANNING; @@ -6442,7 +6440,6 @@ iwm_stop(struct ifnet *ifp, int disable) task_del(systq, >init_task); task_del(sc->sc_nswq, >newstate_task); - task_del(sc->sc_eswq, >sc_eswk); task_del(systq, >setrates_task); task_del(systq, >ba_task); task_del(systq, >htprot_task); @@ -7003,22 +7000,21 @@ iwm_notif_intr(struct iwm_softc *sc) case IWM_SCAN_ITERATION_COMPLETE: { struct iwm_lmac_scan_complete_notif *notif; SYNC_RESP_STRUCT(notif, pkt); - task_add(sc->sc_eswq, >sc_eswk); + iwm_endscan(sc); break; } case IWM_SCAN_COMPLETE_UMAC: { struct iwm_umac_scan_complete *notif; SYNC_RESP_STRUCT(notif, pkt); - task_add(sc->sc_eswq, >sc_eswk); + iwm_endscan(sc); break; } case IWM_SCAN_ITERATION_COMPLETE_UMAC: { struct iwm_umac_scan_iter_complete_notif *notif; SYNC_RESP_STRUCT(notif, pkt); - - task_add(sc->sc_eswq, >sc_eswk); + iwm_endscan(sc); break; } @@ -7330,7 +7326,6 @@ iwm_attach(struct device *parent, struct sc->sc_pcitag = pa->pa_tag; sc->sc_dmat = pa->pa_dmat; - task_set(>sc_eswk, iwm_endscan_cb, sc); rw_init(>ioctl_rwl, "iwmioctl"); err = pci_get_capability(sc->sc_pct, sc->sc_pcitag, @@ -7539,9 +7534,6 @@ iwm_attach(struct device *parent, struct goto fail4; } - sc->sc_eswq = taskq_create("iwmes", 1, IPL_NET, 0); - if (sc->sc_eswq == NULL) - goto fail4; sc->sc_nswq = taskq_create("iwmns", 1, IPL_NET, 0); if (sc->sc_nswq == NULL) goto fail4; Index: if_iwmvar.h === RCS file: /cvs/src/sys/dev/pci/if_iwmvar.h,v retrieving revision 1.31 diff -u -p -r1.31 if_iwmvar.h --- if_iwmvar.h 16 Jul 2017 22:48:26 - 1.31 +++ if_iwmvar.h 12 Aug 2017 18:39:25 - @@ -466,8 +466,7 @@ struct iwm_softc { int sc_wantresp; int sc_nic_locks; - struct taskq *sc_nswq, *sc_eswq; - struct task sc_eswk; + struct taskq *sc_nswq; struct iwm_rx_phy_info sc_last_phy_info; int sc_ampdu_ref;
rtadvd: no longer decrement lifetimes in real time
Stop supporting prefix lifetimes that decrement in real time. It complicates the code, it's off by default and RFC 4861 section 6.2.1 lists it as MAY. After this we can stop regenerating the RA packets everytime we send them. Also I'm not convinced that this has a use case. I think it comes from a fairy tale where renumbering is easy. Considering the two hour rule in RFC 4862 this might not actually work to begin with... OK? diff --git config.c config.c index 497fedbf562..62ce62c58d3 100644 --- config.c +++ config.c @@ -212,14 +212,6 @@ getconfig(char *intface) /* prefix information */ - /* -* This is an implementation specific parameter to consider -* link propagation delays and poorly synchronized clocks when -* checking consistency of advertised lifetimes. -*/ - MAYHAVE(val, "clockskew", 0); - tmp->clockskew = val; - tmp->pfxs = 0; for (i = -1; i < MAXPREFIX; i++) { struct prefix *pfx; @@ -278,14 +270,6 @@ getconfig(char *intface) pfx->validlifetime = (u_int32_t)val64; - makeentry(entbuf, sizeof(entbuf), i, "vltimedecr"); - if (agetflag(entbuf)) { - struct timeval now; - gettimeofday(, 0); - pfx->vltimeexpire = - now.tv_sec + pfx->validlifetime; - } - makeentry(entbuf, sizeof(entbuf), i, "pltime"); MAYHAVE(val64, entbuf, DEF_ADVPREFERREDLIFETIME); if (val64 < 0 || val64 > 0x) @@ -296,13 +280,6 @@ getconfig(char *intface) pfx->preflifetime = (u_int32_t)val64; - makeentry(entbuf, sizeof(entbuf), i, "pltimedecr"); - if (agetflag(entbuf)) { - struct timeval now; - gettimeofday(, 0); - pfx->pltimeexpire = - now.tv_sec + pfx->preflifetime; - } } if (tmp->pfxs == 0 && !agetflag("noifprefix")) get_prefix(tmp); @@ -748,9 +725,6 @@ make_packet(struct rainfo *rainfo) } TAILQ_FOREACH(pfx, >prefixes, entry) { - u_int32_t vltime, pltime; - struct timeval now; - ndopt_pi = (struct nd_opt_prefix_info *)buf; ndopt_pi->nd_opt_pi_type = ND_OPT_PREFIX_INFORMATION; ndopt_pi->nd_opt_pi_len = 4; @@ -762,27 +736,9 @@ make_packet(struct rainfo *rainfo) if (pfx->autoconfflg) ndopt_pi->nd_opt_pi_flags_reserved |= ND_OPT_PI_FLAG_AUTO; - if (pfx->vltimeexpire || pfx->pltimeexpire) - gettimeofday(, NULL); - if (pfx->vltimeexpire == 0) - vltime = pfx->validlifetime; - else - vltime = (u_int32_t)(pfx->vltimeexpire > now.tv_sec ? - pfx->vltimeexpire - now.tv_sec : 0); - if (pfx->pltimeexpire == 0) - pltime = pfx->preflifetime; - else - pltime = (u_int32_t)(pfx->pltimeexpire > now.tv_sec ? - pfx->pltimeexpire - now.tv_sec : 0); - if (vltime < pltime) { - /* -* this can happen if vltime is decremented but pltime -* is not. -*/ - pltime = vltime; - } - ndopt_pi->nd_opt_pi_valid_time = htonl(vltime); - ndopt_pi->nd_opt_pi_preferred_time = htonl(pltime); + + ndopt_pi->nd_opt_pi_valid_time = htonl(pfx->validlifetime); + ndopt_pi->nd_opt_pi_preferred_time = htonl(pfx->preflifetime); ndopt_pi->nd_opt_pi_reserved2 = 0; ndopt_pi->nd_opt_pi_prefix = pfx->prefix; diff --git dump.c dump.c index bccfad7a3fb..f4a7bd4b2cf 100644 --- dump.c +++ dump.c @@ -113,7 +113,6 @@ rtadvd_dump(void) int first; struct timeval now, next; char *origin, *vltime, *pltime, *flags; - char *vltimexpire, *pltimexpire; char ctimebuf[26]; gettimeofday(, NULL); @@ -164,9 +163,7 @@ rtadvd_dump(void) log_info(" ReachableTime: %d, RetransTimer: %d, " "CurHopLimit: %d", rai->reachabletime, rai->retranstimer, rai->hoplimit); - if (rai->clockskew) - log_info(" Clock skew: %ldsec", - rai->clockskew); + first = 1; TAILQ_FOREACH(pfx, >prefixes, entry) { if (first) { @@ -186,40 +183,17 @@ rtadvd_dump(void) default: origin = ""; } - if
Re: perl 5.24.2 update
On Sat, Aug 12, 2017 at 10:15:56AM -0700, Andrew Fresh wrote: > The full patch is here, but most of it is documentation and tests: > http://cvs.afresh1.com/~andrew/OpenBSD-perl-5.24.2.patch.txt I have applied this on my laptop. Let's see whether anything breaks. > Planning to do a single commit for it, unless someone really wants all > the churn of getting stock 5.24.2 in then adding our patches. Usually I prefer a vendor import so I can see, what OpenBSD is doing differently. Curently it is hard to see what patches we have relative to 5.24.1 as it was missed previously. But if that means too much work for you, I would also accept a simple commit. > OK? OK bluhm@
perl 5.24.2 update
Seems like a good idea to pick up the minor update to perl. The full patch is here, but most of it is documentation and tests: http://cvs.afresh1.com/~andrew/OpenBSD-perl-5.24.2.patch.txt I successfully built a release with this on amd64 and unfortunately broke my other architectures trying to do a remote update without having tested the serial consoles before I left home. Now building some test packages so I'll find out if frozen-bubble works soon. Also going to work on perl 5.26 for after the 6.2 unlock. Planning to do a single commit for it, unless someone really wants all the churn of getting stock 5.24.2 in then adding our patches. OK? Inline are the three actual changes, as documented in perldelta https://metacpan.org/pod/release/SHAY/perl-5.24.2/pod/perldelta.pod The amazingly poorly named "wip" commit that actually is the final version of the base.pm patch that we had mostly already applied. https://perl5.git.perl.org/perl.git/commitdiff/1afa2890005f3acdb5794bc9ec34dfd0a7e54c28 Then a fix for perl bug #129038, "Crash with s///l" https://rt.perl.org/Public/Bug/Display.html?id=129038 https://perl5.git.perl.org/perl.git/commit/93e39480947573cb85e287907a745faf061002f6 And "Fix checks for tainted dir in $ENV{PATH}" https://perl5.git.perl.org/perl.git/commit/1addf2f85380133ce4aa5f2f1d35bac377e0d90a Handily, after the previous update, the set list change is simple: Index: distrib/sets/lists/base/mi === RCS file: /cvs/src/distrib/sets/lists/base/mi,v retrieving revision 1.850 diff -u -p -r1.850 mi --- distrib/sets/lists/base/mi 11 Aug 2017 06:16:53 - 1.850 +++ distrib/sets/lists/base/mi 11 Aug 2017 22:22:42 - @@ -639,7 +642,7 @@ ./usr/lib/libpanel.so.6.0 ./usr/lib/libpanelw.so.6.0 ./usr/lib/libpcap.so.8.3 -./usr/lib/libperl.so.18.0 +./usr/lib/libperl.so.18.1 ./usr/lib/libpthread.so.23.0 ./usr/lib/libradius.so.1.0 ./usr/lib/libreadline.so.4.0 @@ -1469,8 +1472,10 @@ ./usr/libdata/perl5/pod/perl5220delta.pod ./usr/libdata/perl5/pod/perl5221delta.pod ./usr/libdata/perl5/pod/perl5222delta.pod +./usr/libdata/perl5/pod/perl5223delta.pod ./usr/libdata/perl5/pod/perl5240delta.pod ./usr/libdata/perl5/pod/perl5241delta.pod +./usr/libdata/perl5/pod/perl5242delta.pod ./usr/libdata/perl5/pod/perl561delta.pod ./usr/libdata/perl5/pod/perl56delta.pod ./usr/libdata/perl5/pod/perl581delta.pod # 1afa2890005f3acdb5794bc9ec34dfd0a7e54c28 Index: gnu/usr.bin/perl/dist/base/lib/base.pm === RCS file: /cvs/src/gnu/usr.bin/perl/dist/base/lib/base.pm,v retrieving revision 1.4 diff -u -p -r1.4 base.pm --- gnu/usr.bin/perl/dist/base/lib/base.pm 5 Feb 2017 00:33:40 - 1.4 +++ gnu/usr.bin/perl/dist/base/lib/base.pm 11 Aug 2017 22:39:16 - @@ -7,10 +7,9 @@ $VERSION = '2.23_01'; $VERSION =~ tr/_//d; # simplest way to avoid indexing of the package: no package statement -sub base::__inc_scope_guard::DESTROY { - my $noop = $_[0][0]; - ref $_ and $_ == $noop and $_ = '.' for @INC; -} +sub base::__inc::unhook { @INC = grep !(ref eq 'CODE' && $_ == $_[0]), @INC } +# instance is blessed array of coderefs to be removed from @INC at scope exit +sub base::__inc::scope_guard::DESTROY { base::__inc::unhook $_ for @{$_[0]} } # constant.pm is slow sub SUCCESS () { 1 } @@ -103,11 +102,53 @@ sub import { { local $SIG{__DIE__}; my $fn = _module_to_filename($base); -my $dotty = $INC[-1] eq '.' && ( $INC[-1] = sub {()} ); +my $dot_hidden; eval { -my $redotty = $dotty && bless [ $dotty ], 'base::__inc_scope_guard'; +my $guard; +if ($INC[-1] eq '.' && %{"$base\::"}) { +# So: the package already exists => this an optional load +# And: there is a dot at the end of @INC => we want to hide it +# However: we only want to hide it during our *own* require() +# (i.e. without affecting nested require()s). +# So we add a hook to @INC whose job is to hide the dot, but which +# first checks checks the callstack depth, because within nested +# require()s the callstack is deeper. +# Since CORE::GLOBAL::require makes it unknowable in advance what +# the exact relevant callstack depth will be, we have to record it +# inside a hook. So we put another hook just for that at the front +# of @INC, where it's guaranteed to run -- immediately. +# The dot-hiding hook does its job by sitting directly in front of +# the dot and removing itself from @INC when reached. This causes +
Re: wscons(4): set WS_KERNEL_COLATTR to WSATTR_HILIT in vt100 emulation
I see no reason to change this. The first complaint in 25 years sounds like "personal preference" or "desire to push a change". > Currently, output originating from the kernel is displayed using > WSCOL_WHITE on WSCOL_BLUE, which translates to NORMAL_WHITE on > NORMAL_BLUE. > > When booting in BIOS mode, NORMAL_WHITE is 0xaa in text mode > (which is very hard to read on a blue backgroud), and when framebuffer > attaches, NORMAL_WHITE becomes 0xc7c7c7. > > The proposed change makes text display using HILITE_WHITE, which > is 0xff in both text mode and framebuffer console. > > I've been running with this diff for a while now and find kernel > messages easier to read this way, especially in text mode. > > Comments? OK? > > Index: sys/dev/wscons/wsemul_vt100.c > === > RCS file: /cvs/src/sys/dev/wscons/wsemul_vt100.c,v > retrieving revision 1.36 > diff -u -p -r1.36 wsemul_vt100.c > --- sys/dev/wscons/wsemul_vt100.c 10 Aug 2017 09:12:32 - 1.36 > +++ sys/dev/wscons/wsemul_vt100.c 12 Aug 2017 14:42:28 - > @@ -171,7 +171,7 @@ wsemul_vt100_cnattach(const struct wsscr > #define WS_KERNEL_BG WSCOL_BLUE > #endif > #ifndef WS_KERNEL_COLATTR > -#define WS_KERNEL_COLATTR 0 > +#define WS_KERNEL_COLATTR WSATTR_HILIT > #endif > #ifndef WS_KERNEL_MONOATTR > #define WS_KERNEL_MONOATTR 0 >
Re: wscons(4): set WS_KERNEL_COLATTR to WSATTR_HILIT in vt100 emulation
> Date: Sat, 12 Aug 2017 17:06:18 +0200 > From: Frederic Cambus> > Hi tech@, > > Currently, output originating from the kernel is displayed using > WSCOL_WHITE on WSCOL_BLUE, which translates to NORMAL_WHITE on > NORMAL_BLUE. > > When booting in BIOS mode, NORMAL_WHITE is 0xaa in text mode > (which is very hard to read on a blue backgroud), and when framebuffer > attaches, NORMAL_WHITE becomes 0xc7c7c7. > > The proposed change makes text display using HILITE_WHITE, which > is 0xff in both text mode and framebuffer console. > > I've been running with this diff for a while now and find kernel > messages easier to read this way, especially in text mode. > > Comments? OK? Way too bright if you're in a dark environment IMHO. Even the 0xc7c7c7 is a bit on the bright side, and I don't really consider the 0xaa in BIOS mode to be a real problem. > Index: sys/dev/wscons/wsemul_vt100.c > === > RCS file: /cvs/src/sys/dev/wscons/wsemul_vt100.c,v > retrieving revision 1.36 > diff -u -p -r1.36 wsemul_vt100.c > --- sys/dev/wscons/wsemul_vt100.c 10 Aug 2017 09:12:32 - 1.36 > +++ sys/dev/wscons/wsemul_vt100.c 12 Aug 2017 14:42:28 - > @@ -171,7 +171,7 @@ wsemul_vt100_cnattach(const struct wsscr > #define WS_KERNEL_BG WSCOL_BLUE > #endif > #ifndef WS_KERNEL_COLATTR > -#define WS_KERNEL_COLATTR 0 > +#define WS_KERNEL_COLATTR WSATTR_HILIT > #endif > #ifndef WS_KERNEL_MONOATTR > #define WS_KERNEL_MONOATTR 0 > >
wscons(4): set WS_KERNEL_COLATTR to WSATTR_HILIT in vt100 emulation
Hi tech@, Currently, output originating from the kernel is displayed using WSCOL_WHITE on WSCOL_BLUE, which translates to NORMAL_WHITE on NORMAL_BLUE. When booting in BIOS mode, NORMAL_WHITE is 0xaa in text mode (which is very hard to read on a blue backgroud), and when framebuffer attaches, NORMAL_WHITE becomes 0xc7c7c7. The proposed change makes text display using HILITE_WHITE, which is 0xff in both text mode and framebuffer console. I've been running with this diff for a while now and find kernel messages easier to read this way, especially in text mode. Comments? OK? Index: sys/dev/wscons/wsemul_vt100.c === RCS file: /cvs/src/sys/dev/wscons/wsemul_vt100.c,v retrieving revision 1.36 diff -u -p -r1.36 wsemul_vt100.c --- sys/dev/wscons/wsemul_vt100.c 10 Aug 2017 09:12:32 - 1.36 +++ sys/dev/wscons/wsemul_vt100.c 12 Aug 2017 14:42:28 - @@ -171,7 +171,7 @@ wsemul_vt100_cnattach(const struct wsscr #define WS_KERNEL_BG WSCOL_BLUE #endif #ifndef WS_KERNEL_COLATTR -#define WS_KERNEL_COLATTR 0 +#define WS_KERNEL_COLATTR WSATTR_HILIT #endif #ifndef WS_KERNEL_MONOATTR #define WS_KERNEL_MONOATTR 0
Fix rasops rotation with RI_VCONS
There is a bit too much layering going on and the rasops_erasecols_rotated() and rasops_eraserows_rotated() functions end up calling the vcons functions creating a nice infinite loop. Simplest fix os for them to simply call rasops_putchar_rotated() directly. I don't really see a valid reason not to. The rotation code hasn't been used since we removed zaurus, but I intend to use it again to rotate the framebuffer console on a 2-in-1 amd64 laptop I have. ok? Index: dev/rasops/rasops.c === RCS file: /cvs/src/sys/dev/rasops/rasops.c,v retrieving revision 1.45 diff -u -p -r1.45 rasops.c --- dev/rasops/rasops.c 16 May 2017 02:22:51 - 1.45 +++ dev/rasops/rasops.c 12 Aug 2017 14:14:54 - @@ -1264,7 +1264,7 @@ rasops_erasecols_rotated(void *cookie, i ri = (struct rasops_info *)cookie; for (i = col; i < col + num; i++) { - rc = ri->ri_ops.putchar(cookie, row, i, ' ', attr); + rc = rasops_putchar_rotated(cookie, row, i, ' ', attr); if (rc != 0) return rc; } @@ -1323,7 +1323,7 @@ rasops_eraserows_rotated(void *cookie, i for (rn = row; rn < row + num; rn++) for (col = 0; col < ri->ri_cols; col++) { - rc = ri->ri_ops.putchar(cookie, rn, col, ' ', attr); + rc = rasops_putchar_rotated(cookie, rn, col, ' ', attr); if (rc != 0) return rc; }
iwm: manage time event better
This makes iwm keep track of the firmware "stay on channel" time event used during association. Currently, iwm tells the firmware to schedule the time event, and forgets. With this diff, iwm keeps track of the time event's scheduling and cancels the time event if a deauth frame is received while trying to associate. Leaving AUTH state will cause iwm to tear down some firmware state in iwm_deauth(). Leaving the time event scheduled while tearing down other firmware state does not seem like a good idea. Linux does something similar to this, making sure time events won't linger beyond their intended purpose. The diff doesn't seem to have a noticeable effect. But I suppose hitting a race where this maters requires some luck. OK? Index: if_iwm.c === RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v retrieving revision 1.204 diff -u -p -r1.204 if_iwm.c --- if_iwm.c23 Jul 2017 13:51:11 - 1.204 +++ if_iwm.c12 Aug 2017 13:28:16 - @@ -312,6 +312,7 @@ int iwm_send_time_event_cmd(struct iwm_s const struct iwm_time_event_cmd_v2 *); void iwm_protect_session(struct iwm_softc *, struct iwm_node *, uint32_t, uint32_t); +void iwm_unprotect_session(struct iwm_softc *, struct iwm_node *); intiwm_nvm_read_chunk(struct iwm_softc *, uint16_t, uint16_t, uint16_t, uint8_t *, uint16_t *); intiwm_nvm_read_section(struct iwm_softc *, uint16_t, uint8_t *, @@ -2200,14 +2201,47 @@ iwm_send_time_event_cmd(struct iwm_softc const struct iwm_time_event_cmd_v2 *cmd) { struct iwm_time_event_cmd_v1 cmd_v1; + struct iwm_host_cmd hcmd = { + .id = IWM_TIME_EVENT_CMD, + .flags = IWM_CMD_WANT_SKB, + }; + struct iwm_rx_packet *pkt; + struct iwm_time_event_resp *resp; + uint32_t resp_len; + int err; + + if (sc->sc_capaflags & IWM_UCODE_TLV_FLAGS_TIME_EVENT_API_V2) { + hcmd.data[0] = cmd; + hcmd.len[0] = sizeof(*cmd); + } else { + iwm_te_v2_to_v1(cmd, _v1); + hcmd.data[0] = _v1; + hcmd.len[0] = sizeof(cmd_v1); + } + err = iwm_send_cmd(sc, ); + if (err) + return err; + + pkt = hcmd.resp_pkt; + if (!pkt || (pkt->hdr.flags & IWM_CMD_FAILED_MSK)) { + err = EIO; + goto out; + } + + resp_len = iwm_rx_packet_payload_len(pkt); + if (resp_len != sizeof(*resp)) { + err = EIO; + goto out; + } - if (sc->sc_capaflags & IWM_UCODE_TLV_FLAGS_TIME_EVENT_API_V2) - return iwm_send_cmd_pdu(sc, IWM_TIME_EVENT_CMD, - 0, sizeof(*cmd), cmd); - - iwm_te_v2_to_v1(cmd, _v1); - return iwm_send_cmd_pdu(sc, IWM_TIME_EVENT_CMD, 0, - sizeof(cmd_v1), _v1); + resp = (void *)pkt->data; + if (le32toh(resp->status) == 0) + sc->sc_time_event_uid = le32toh(resp->unique_id); + else + err = EIO; +out: + iwm_free_resp(sc, ); + return err; } void @@ -2216,6 +2250,10 @@ iwm_protect_session(struct iwm_softc *sc { struct iwm_time_event_cmd_v2 time_cmd; + /* Do nothing if a time event is already scheduled. */ + if (sc->sc_flags & IWM_FLAG_TE_ACTIVE) + return; + memset(_cmd, 0, sizeof(time_cmd)); time_cmd.action = htole32(IWM_FW_CTXT_ACTION_ADD); @@ -2236,7 +2274,32 @@ iwm_protect_session(struct iwm_softc *sc IWM_TE_V2_NOTIF_HOST_EVENT_END | IWM_T2_V2_START_IMMEDIATELY); - iwm_send_time_event_cmd(sc, _cmd); + if (iwm_send_time_event_cmd(sc, _cmd) == 0) + sc->sc_flags |= IWM_FLAG_TE_ACTIVE; + + DELAY(100); +} + +void +iwm_unprotect_session(struct iwm_softc *sc, struct iwm_node *in) +{ + struct iwm_time_event_cmd_v2 time_cmd; + + /* Do nothing if the time event has already ended. */ + if ((sc->sc_flags & IWM_FLAG_TE_ACTIVE) == 0) + return; + + memset(_cmd, 0, sizeof(time_cmd)); + + time_cmd.action = htole32(IWM_FW_CTXT_ACTION_REMOVE); + time_cmd.id_and_color = + htole32(IWM_FW_CMD_ID_AND_COLOR(in->in_id, in->in_color)); + time_cmd.id = htole32(sc->sc_time_event_uid); + + if (iwm_send_time_event_cmd(sc, _cmd) == 0) + sc->sc_flags &= ~IWM_FLAG_TE_ACTIVE; + + DELAY(100); } /* @@ -5422,7 +5485,6 @@ iwm_auth(struct iwm_softc *sc) else duration = IEEE80211_DUR_TU; iwm_protect_session(sc, in, duration, in->in_ni.ni_intval / 2); - DELAY(100); return 0; @@ -5448,6 +5510,8 @@ iwm_deauth(struct iwm_softc *sc) splassert(IPL_NET); + iwm_unprotect_session(sc, in); + if (sc->sc_flags & IWM_FLAG_STA_ACTIVE) { err = iwm_rm_sta_cmd(sc, in); if (err) { @@ -6451,6
update Mesa to 17.1.6
cd /usr/xenocara/lib ftp https://mesa.freedesktop.org/archive/mesa-17.1.6.tar.gz ftp http://jsg.id.au/mesa-update/mesa.diff.gz tar zxf mesa-17.1.6.tar.gz gunzip mesa.diff.gz patch -p0 < mesa.diff sed -i 's/mesa$/mesa-17.1.6/' Makefile build xenocara as normal Interested in radeon r300/r600 reports in particular.