Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src-draft/trunk]: src/sys/dev/pci Revert mtsleep to kpause conversions as th...



details:   https://anonhg.NetBSD.org/src-all/rev/aaff7a0cad81
branches:  trunk
changeset: 375296:aaff7a0cad81
user:      Nathanial Sloss <nat%netbsd.org@localhost>
date:      Fri Apr 28 22:38:34 2023 +1000

description:
Revert mtsleep to kpause conversions as they are wrong.

Revert commits 1034627:aaa3cc6beacd and 1034590:0a019dd260e8

These will need to be handled properly with cv_* functions.

diffstat:

 sys/dev/pci/if_ipw.c |   8 ++------
 sys/dev/pci/if_iwm.c |  17 +++++++++++------
 2 files changed, 13 insertions(+), 12 deletions(-)

diffs (94 lines):

diff -r b3234b296ecc -r aaff7a0cad81 sys/dev/pci/if_ipw.c
--- a/sys/dev/pci/if_ipw.c      Fri Apr 28 02:24:03 2023 +1000
+++ b/sys/dev/pci/if_ipw.c      Fri Apr 28 22:38:34 2023 +1000
@@ -1428,7 +1428,6 @@ static int
 ipw_cmd(struct ipw_softc *sc, uint32_t type, void *data, uint32_t len)
 {
        struct ipw_soft_bd *sbd;
-       int error = 0;
 
        sbd = &sc->stbd_list[sc->txcur];
 
@@ -1461,10 +1460,7 @@ ipw_cmd(struct ipw_softc *sc, uint32_t t
        CSR_WRITE_4(sc, IPW_CSR_TX_WRITE, sc->txcur);
 
        /* Wait at most one second for command to complete */
-       if ((error = kpause("ipwcmd", false, hz, NULL)) != EWOULDBLOCK)
-               return error;
-
-       return 0;
+       return tsleep(&sc->cmd, 0, "ipwcmd", hz);
 }
 
 static int
@@ -2014,7 +2010,7 @@ ipw_load_firmware(struct ipw_softc *sc, 
            IPW_CTL_ALLOW_STANDBY);
 
        /* wait at most one second for firmware initialization to complete */
-       if ((error = kpause("ipwinit", false, hz, NULL)) != 0) {
+       if ((error = tsleep(sc, 0, "ipwinit", hz)) != 0) {
                aprint_error_dev(sc->sc_dev,
                    "timeout waiting for firmware initialization "
                    "to complete\n");
diff -r b3234b296ecc -r aaff7a0cad81 sys/dev/pci/if_iwm.c
--- a/sys/dev/pci/if_iwm.c      Fri Apr 28 02:24:03 2023 +1000
+++ b/sys/dev/pci/if_iwm.c      Fri Apr 28 22:38:34 2023 +1000
@@ -702,7 +702,7 @@ iwm_read_firmware(struct iwm_softc *sc, 
                fw->fw_status = IWM_FW_STATUS_INPROGRESS;
        } else {
                while (fw->fw_status == IWM_FW_STATUS_INPROGRESS)
-                       kpause("iwmfwp", false, hz, &sc->sc_lock);
+                       mtsleep(&sc->sc_fw, 0, "iwmfwp", 0, &sc->sc_lock);
        }
        status = fw->fw_status;
 
@@ -3477,7 +3477,8 @@ iwm_firmware_load_chunk(struct iwm_softc
        /* Wait for this segment to load. */
        err = 0;
        while (!sc->sc_fw_chunk_done) {
-               err = kpause("iwmfw", false, mstohz(5000), &sc->sc_lock);
+               err = mtsleep(&sc->sc_fw, 0, "iwmfw", mstohz(5000),
+                   &sc->sc_lock);
                if (err)
                        break;
        }
@@ -3693,7 +3694,8 @@ iwm_load_firmware(struct iwm_softc *sc, 
 
        /* wait for the firmware to load */
        for (w = 0; !sc->sc_uc.uc_intr && w < 10; w++)
-               err = kpause("iwmuc", false, mstohz(100), &sc->sc_lock);
+               err = mtsleep(&sc->sc_uc, 0, "iwmuc", mstohz(100),
+                   &sc->sc_lock);
        if (err || !sc->sc_uc.uc_ok) {
                aprint_error_dev(sc->sc_dev,
                    "could not load firmware (error %d, ok %d)\n",
@@ -3869,7 +3871,8 @@ iwm_run_init_mvm_ucode(struct iwm_softc 
         * from the firmware
         */
        while (!sc->sc_init_complete) {
-               err = kpause("iwminit", false, mstohz(2000), &sc->sc_lock);
+               err = mtsleep(&sc->sc_init_complete, 0, "iwminit",
+                   mstohz(2000), &sc->sc_lock);
                if (err)
                        break;
        }
@@ -4320,7 +4323,8 @@ iwm_send_cmd(struct iwm_softc *sc, struc
        if (wantresp) {
                KASSERT(!async);
                while (sc->sc_wantresp != IWM_CMD_RESP_IDLE)
-                       kpause("iwmcmdsl", false, hz, &sc->sc_lock);
+                       mtsleep(&sc->sc_wantresp, 0, "iwmcmdsl", 0,
+                           &sc->sc_lock);
                sc->sc_wantresp = ring->qid << 16 | ring->cur;
        }
 
@@ -4445,7 +4449,8 @@ iwm_send_cmd(struct iwm_softc *sc, struc
 
        if (!async) {
                int generation = sc->sc_generation;
-               err = kpause("iwmcmd", false, mstohz(2000), &sc->sc_lock);
+               err = mtsleep(desc, PCATCH, "iwmcmd", mstohz(2000),
+                   &sc->sc_lock);
                if (err == 0) {
                        /* if hardware is no longer up, return error */
                        if (generation != sc->sc_generation) {



Home | Main Index | Thread Index | Old Index