On Wed, Jan 08, 2020 at 04:29:02PM +0100, Martin Pieuchot wrote:
> Convert sleeps of 1sec or more that follow the '* hz' idiom to
> tsleep_nsec(9).
>
> Ok?
OK bluhm@
> Index: dev/acpi/tipmic.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/acpi/tipmic.c,v
> retrieving revision 1.4
> diff -u -p -r1.4 tipmic.c
> --- dev/acpi/tipmic.c 4 Apr 2019 06:33:10 -0000 1.4
> +++ dev/acpi/tipmic.c 8 Jan 2020 15:19:32 -0000
> @@ -333,7 +333,8 @@ tipmic_thermal_opreg_handler(void *cooki
> splx(s);
>
> while (sc->sc_stat_adc == 0) {
> - if (tsleep(&sc->sc_stat_adc, PRIBIO, "tipmic", hz)) {
> + if (tsleep_nsec(&sc->sc_stat_adc, PRIBIO, "tipmic",
> + SEC_TO_NSEC(1))) {
> printf("%s: ADC timeout\n", sc->sc_dev.dv_xname);
> break;
> }
> Index: dev/i2c/iatp.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/i2c/iatp.c,v
> retrieving revision 1.6
> diff -u -p -r1.6 iatp.c
> --- dev/i2c/iatp.c 30 Jul 2018 15:56:30 -0000 1.6
> +++ dev/i2c/iatp.c 8 Jan 2020 15:19:33 -0000
> @@ -347,7 +347,8 @@ iatp_enable(void *v)
> {
> struct iatp_softc *sc = v;
>
> - if (sc->sc_busy && tsleep(&sc->sc_busy, PRIBIO, "iatp", hz) != 0) {
> + if (sc->sc_busy &&
> + tsleep_nsec(&sc->sc_busy, PRIBIO, "iatp", SEC_TO_NSEC(1)) != 0) {
> printf("%s: trying to enable but we're busy\n",
> sc->sc_dev.dv_xname);
> return 1;
> Index: dev/ic/rtwn.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/rtwn.c,v
> retrieving revision 1.48
> diff -u -p -r1.48 rtwn.c
> --- dev/ic/rtwn.c 31 Dec 2019 10:05:32 -0000 1.48
> +++ dev/ic/rtwn.c 8 Jan 2020 15:19:33 -0000
> @@ -1642,7 +1642,7 @@ sleep:
> * We must sleep for one second to let the firmware settle.
> * Accessing registers too early will hang the whole system.
> */
> - tsleep(®, 0, "rtwnrst", hz);
> + tsleep_nsec(®, 0, "rtwnrst", SEC_TO_NSEC(1));
> }
> }
>
> Index: dev/ic/z8530tty.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/z8530tty.c,v
> retrieving revision 1.31
> diff -u -p -r1.31 z8530tty.c
> --- dev/ic/z8530tty.c 19 Jul 2019 00:17:15 -0000 1.31
> +++ dev/ic/z8530tty.c 8 Jan 2020 15:19:34 -0000
> @@ -429,7 +429,7 @@ zs_shutdown(struct zstty_softc *zst)
> if (ISSET(tp->t_cflag, HUPCL) || ISSET(tp->t_state, TS_WOPEN)) {
> zs_modem(zst, 0);
> /* hold low for 1 second */
> - (void)tsleep(cs, TTIPRI, ttclos, hz);
> + tsleep_nsec(cs, TTIPRI, ttclos, SEC_TO_NSEC(1));
> }
>
> /* Turn off interrupts if not the console. */
> Index: dev/ic/bwfm.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/bwfm.c,v
> retrieving revision 1.67
> diff -u -p -r1.67 bwfm.c
> --- dev/ic/bwfm.c 9 Nov 2019 20:53:55 -0000 1.67
> +++ dev/ic/bwfm.c 8 Jan 2020 15:19:35 -0000
> @@ -1526,7 +1526,7 @@ bwfm_proto_bcdc_txctl(struct bwfm_softc
> return 1;
> }
>
> - if (tsleep(ctl, PWAIT, "bwfm", hz))
> + if (tsleep_nsec(ctl, PWAIT, "bwfm", SEC_TO_NSEC(1)))
> timeout = 1;
>
> TAILQ_FOREACH_SAFE(ctl, &sc->sc_bcdc_rxctlq, next, tmp) {
> Index: dev/ic/pgt.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/pgt.c,v
> retrieving revision 1.96
> diff -u -p -r1.96 pgt.c
> --- dev/ic/pgt.c 31 Dec 2019 10:05:32 -0000 1.96
> +++ dev/ic/pgt.c 8 Jan 2020 15:19:38 -0000
> @@ -521,7 +521,7 @@ trying_again:
> sc->sc_flags |= SC_NEEDS_FIRMWARE;
> error = pgt_reset(sc);
> if (error == 0) {
> - tsleep(&sc->sc_flags, 0, "pgtres", hz);
> + tsleep_nsec(&sc->sc_flags, 0, "pgtres", SEC_TO_NSEC(1));
> if (sc->sc_flags & SC_UNINITIALIZED) {
> printf("%s: not responding\n",
> sc->sc_dev.dv_xname);
> @@ -589,7 +589,7 @@ pgt_attach(struct device *self)
> if (error)
> return;
>
> - tsleep(&sc->sc_flags, 0, "pgtres", hz);
> + tsleep_nsec(&sc->sc_flags, 0, "pgtres", SEC_TO_NSEC(1));
> if (sc->sc_flags & SC_UNINITIALIZED) {
> printf("%s: not responding\n", sc->sc_dev.dv_xname);
> sc->sc_flags |= SC_NEEDS_FIRMWARE;
> Index: dev/pci/amdiic.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/amdiic.c,v
> retrieving revision 1.11
> diff -u -p -r1.11 amdiic.c
> --- dev/pci/amdiic.c 1 Oct 2013 20:06:00 -0000 1.11
> +++ dev/pci/amdiic.c 8 Jan 2020 15:21:49 -0000
> @@ -348,7 +348,8 @@ amdiic_i2c_exec(void *cookie, i2c_op_t o
> amdiic_intr(sc);
> } else {
> /* Wait for interrupt */
> - if (tsleep(sc, PRIBIO, "amdiic", AMDIIC_TIMEOUT * hz))
> + if (tsleep_nsec(sc, PRIBIO, "amdiic",
> + SEC_TO_NSEC(AMDIIC_TIMEOUT)))
> return (1);
> }
>
> Index: dev/pci/amdpm.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/amdpm.c,v
> retrieving revision 1.33
> diff -u -p -r1.33 amdpm.c
> --- dev/pci/amdpm.c 28 Apr 2018 15:44:59 -0000 1.33
> +++ dev/pci/amdpm.c 8 Jan 2020 15:22:10 -0000
> @@ -485,7 +485,8 @@ amdpm_i2c_exec(void *cookie, i2c_op_t op
> amdpm_intr(sc);
> } else {
> /* Wait for interrupt */
> - if (tsleep(sc, PRIBIO, "amdpm", AMDPM_SMBUS_TIMEOUT * hz))
> + if (tsleep_nsec(sc, PRIBIO, "amdpm",
> + SEC_TO_NSEC(AMDPM_SMBUS_TIMEOUT)))
> goto timeout;
> }
>
> Index: dev/pci/arc.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/arc.c,v
> retrieving revision 1.107
> diff -u -p -r1.107 arc.c
> --- dev/pci/arc.c 10 Sep 2015 18:10:33 -0000 1.107
> +++ dev/pci/arc.c 8 Jan 2020 15:19:43 -0000
> @@ -2571,7 +2571,7 @@ arc_unlock(struct arc_softc *sc)
> void
> arc_wait(struct arc_softc *sc)
> {
> - int s;
> + int error, s;
> u_int32_t int_mask;
>
> s = splbio();
> @@ -2579,7 +2579,8 @@ arc_wait(struct arc_softc *sc)
> case ARC_HBA_TYPE_A:
> int_mask = arc_read(sc, ARC_RA_INTRMASK) &
> ~ARC_RA_INTRMASK_DOORBELL;
> arc_write(sc, ARC_RA_INTRMASK, int_mask);
> - if (tsleep(sc, PWAIT, "arcdb", hz) == EWOULDBLOCK) {
> + error = tsleep_nsec(sc, PWAIT, "arcdb", SEC_TO_NSEC(1));
> + if (error == EWOULDBLOCK) {
> int_mask = arc_read(sc, ARC_RA_INTRMASK) |
> ARC_RA_INTRMASK_DOORBELL;
> arc_write(sc, ARC_RA_INTRMASK, int_mask);
> }
> @@ -2587,7 +2588,8 @@ arc_wait(struct arc_softc *sc)
> case ARC_HBA_TYPE_C:
> int_mask = arc_read(sc, ARC_RC_INTR_MASK) &
> ~ARC_RC_INTR_MASK_DOORBELL;
> arc_write(sc, ARC_RC_INTR_MASK, int_mask);
> - if (tsleep(sc, PWAIT, "arcdb", hz) == EWOULDBLOCK) {
> + error = tsleep_nsec(sc, PWAIT, "arcdb", SEC_TO_NSEC(1));
> + if (error == EWOULDBLOCK) {
> int_mask = arc_read(sc, ARC_RC_INTR_MASK) |
> ARC_RC_INTR_MASK_DOORBELL;
> arc_write(sc, ARC_RC_INTR_MASK, int_mask);
> }
> @@ -2595,7 +2597,8 @@ arc_wait(struct arc_softc *sc)
> case ARC_HBA_TYPE_D:
> int_mask = arc_read(sc, ARC_RD_INTR_ENABLE) |
> ARC_RD_INTR_ENABLE_DOORBELL;
> arc_write(sc, ARC_RD_INTR_ENABLE, int_mask);
> - if (tsleep(sc, PWAIT, "arcdb", hz) == EWOULDBLOCK) {
> + error = tsleep_nsec(sc, PWAIT, "arcdb", SEC_TO_NSEC(1));
> + if (error == EWOULDBLOCK) {
> int_mask = arc_read(sc, ARC_RD_INTR_ENABLE) &
> ~ARC_RD_INTR_ENABLE_DOORBELL;
> arc_write(sc, ARC_RD_INTR_ENABLE, int_mask);
> }
> @@ -2621,7 +2624,7 @@ arc_create_sensors(void *xat)
> * XXX * this is bollocks. the firmware has garbage coming out of it
> * so we have to wait a bit for it to finish spewing.
> */
> - tsleep(sc, PWAIT, "arcspew", 2 * hz);
> + tsleep_nsec(sc, PWAIT, "arcspew", SEC_TO_NSEC(2));
>
> bzero(&bi, sizeof(bi));
> if (arc_bio_inq(sc, &bi) != 0) {
> Index: dev/pci/cz.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/cz.c,v
> retrieving revision 1.21
> diff -u -p -r1.21 cz.c
> --- dev/pci/cz.c 19 Feb 2018 08:59:52 -0000 1.21
> +++ dev/pci/cz.c 8 Jan 2020 15:19:45 -0000
> @@ -921,7 +921,7 @@ cztty_shutdown(struct cztty_softc *sc)
> */
> if (ISSET(tp->t_cflag, HUPCL)) {
> cztty_modem(sc, 0);
> - (void) tsleep(tp, TTIPRI, ttclos, hz);
> + tsleep_nsec(tp, TTIPRI, ttclos, SEC_TO_NSEC(1));
> }
>
> /* Disable the channel. */
> Index: dev/pci/ichiic.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/ichiic.c,v
> retrieving revision 1.42
> diff -u -p -r1.42 ichiic.c
> --- dev/pci/ichiic.c 8 May 2019 15:20:05 -0000 1.42
> +++ dev/pci/ichiic.c 8 Jan 2020 15:22:37 -0000
> @@ -311,7 +311,8 @@ ichiic_i2c_exec(void *cookie, i2c_op_t o
> ichiic_intr(sc);
> } else {
> /* Wait for interrupt */
> - if (tsleep(sc, PRIBIO, "ichiic", ICHIIC_TIMEOUT * hz))
> + if (tsleep_nsec(sc, PRIBIO, "ichiic",
> + SEC_TO_NSEC(ICHIIC_TIMEOUT)))
> goto timeout;
> }
>
> Index: dev/pci/if_tht.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/if_tht.c,v
> retrieving revision 1.140
> diff -u -p -r1.140 if_tht.c
> --- dev/pci/if_tht.c 22 Jan 2017 10:17:38 -0000 1.140
> +++ dev/pci/if_tht.c 8 Jan 2020 15:19:46 -0000
> @@ -1066,7 +1066,7 @@ tht_down(struct tht_softc *sc)
>
> while (tht_fifo_writable(sc, &sc->sc_txt) < sc->sc_txt.tf_len &&
> tht_fifo_readable(sc, &sc->sc_txf) > 0)
> - tsleep(sc, 0, "thtdown", hz);
> + tsleep_nsec(sc, 0, "thtdown", SEC_TO_NSEC(1));
>
> sc->sc_imr = THT_IMR_DOWN(sc->sc_port);
> tht_write(sc, THT_REG_IMR, sc->sc_imr);
> Index: dev/pci/piixpm.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/piixpm.c,v
> retrieving revision 1.40
> diff -u -p -r1.40 piixpm.c
> --- dev/pci/piixpm.c 16 Dec 2019 21:39:40 -0000 1.40
> +++ dev/pci/piixpm.c 8 Jan 2020 15:22:54 -0000
> @@ -421,7 +421,8 @@ piixpm_i2c_exec(void *cookie, i2c_op_t o
> piixpm_intr(sc);
> } else {
> /* Wait for interrupt */
> - if (tsleep(sc, PRIBIO, "piixpm", PIIXPM_TIMEOUT * hz))
> + if (tsleep_nsec(sc, PRIBIO, "piixpm",
> + SEC_TO_NSEC(PIIXPM_TIMEOUT)))
> goto timeout;
> }
>
> Index: dev/pci/viapm.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/viapm.c,v
> retrieving revision 1.17
> diff -u -p -r1.17 viapm.c
> --- dev/pci/viapm.c 5 Jul 2018 10:09:11 -0000 1.17
> +++ dev/pci/viapm.c 8 Jan 2020 15:23:12 -0000
> @@ -602,7 +602,8 @@ viapm_i2c_exec(void *cookie, i2c_op_t op
> viapm_intr(sc);
> } else {
> /* Wait for interrupt */
> - if (tsleep(sc, PRIBIO, "iicexec", VIAPM_SMBUS_TIMEOUT * hz))
> + if (tsleep_nsec(sc, PRIBIO, "iicexec",
> + SEC_TO_NSEC(VIAPM_SMBUS_TIMEOUT)))
> goto timeout;
> }
>
> Index: dev/pci/if_bwfm_pci.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/if_bwfm_pci.c,v
> retrieving revision 1.29
> diff -u -p -r1.29 if_bwfm_pci.c
> --- dev/pci/if_bwfm_pci.c 7 Feb 2019 07:39:56 -0000 1.29
> +++ dev/pci/if_bwfm_pci.c 8 Jan 2020 15:19:47 -0000
> @@ -1971,7 +1971,7 @@ bwfm_pci_msgbuf_query_dcmd(struct bwfm_s
>
> bwfm_pci_ring_write_commit(sc, &sc->sc_ctrl_submit);
>
> - tsleep(ctl, PWAIT, "bwfm", hz);
> + tsleep_nsec(ctl, PWAIT, "bwfm", SEC_TO_NSEC(1));
> TAILQ_REMOVE(&sc->sc_ioctlq, ctl, next);
>
> if (ctl->m == NULL) {
> Index: dev/fdt/sximmc.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/fdt/sximmc.c,v
> retrieving revision 1.9
> diff -u -p -r1.9 sximmc.c
> --- dev/fdt/sximmc.c 10 Feb 2019 11:56:26 -0000 1.9
> +++ dev/fdt/sximmc.c 8 Jan 2020 15:19:52 -0000
> @@ -551,7 +551,8 @@ sximmc_wait_rint(struct sximmc_softc *sc
>
> while (retry > 0) {
> if (sc->sc_use_dma) {
> - error = tsleep(&sc->sc_intr_rint, PWAIT, "rint", hz);
> + error = tsleep_nsec(&sc->sc_intr_rint, PWAIT, "rint",
> + SEC_TO_NSEC(1));
> if (error && error != EWOULDBLOCK)
> return error;
> if (sc->sc_intr_rint & mask)
> Index: dev/fdt/dwmmc.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/fdt/dwmmc.c,v
> retrieving revision 1.21
> diff -u -p -r1.21 dwmmc.c
> --- dev/fdt/dwmmc.c 20 Sep 2019 20:46:15 -0000 1.21
> +++ dev/fdt/dwmmc.c 8 Jan 2020 15:19:55 -0000
> @@ -1007,7 +1007,8 @@ dwmmc_exec_command(sdmmc_chipset_handle_
>
> if (cmd->c_datalen > 0 && cmd->c_dmamap) {
> while (sc->sc_idsts == 0) {
> - error = tsleep(&sc->sc_idsts, PWAIT, "idsts", hz);
> + error = tsleep_nsec(&sc->sc_idsts, PWAIT, "idsts",
> + SEC_TO_NSEC(1));
> if (error) {
> cmd->c_error = error;
> dwmmc_dma_reset(sc, cmd);
> Index: kern/tty.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/tty.c,v
> retrieving revision 1.149
> diff -u -p -r1.149 tty.c
> --- kern/tty.c 31 Dec 2019 13:48:32 -0000 1.149
> +++ kern/tty.c 8 Jan 2020 15:20:01 -0000
> @@ -1687,7 +1687,8 @@ ttycheckoutq(struct tty *tp, int wait)
> return (0);
> }
> SET(tp->t_state, TS_ASLEEP);
> - tsleep(&tp->t_outq, PZERO - 1, "ttckoutq", hz);
> + tsleep_nsec(&tp->t_outq, PZERO - 1, "ttckoutq",
> + SEC_TO_NSEC(1));
> }
> splx(s);
> return (1);