Use pause() rather than tsleep() on stack variables and function pointers.

This commit is contained in:
John Baldwin 2007-02-27 17:23:29 +00:00
parent 84d37a463a
commit 4d70511ac3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=167086
19 changed files with 38 additions and 44 deletions

View File

@ -1280,14 +1280,13 @@ static int
fwohci_itx_disable(struct firewire_comm *fc, int dmach)
{
struct fwohci_softc *sc = (struct fwohci_softc *)fc;
int sleepch;
OWRITE(sc, OHCI_ITCTLCLR(dmach),
OHCI_CNTL_DMA_RUN | OHCI_CNTL_CYCMATCH_S);
OWRITE(sc, OHCI_IT_MASKCLR, 1 << dmach);
OWRITE(sc, OHCI_IT_STATCLR, 1 << dmach);
/* XXX we cannot free buffers until the DMA really stops */
tsleep((void *)&sleepch, FWPRI, "fwitxd", hz);
pause("fwitxd", hz);
fwohci_db_free(&sc->it[dmach]);
sc->it[dmach].xferq.flag &= ~FWXFERQ_RUNNING;
return 0;
@ -1297,13 +1296,12 @@ static int
fwohci_irx_disable(struct firewire_comm *fc, int dmach)
{
struct fwohci_softc *sc = (struct fwohci_softc *)fc;
int sleepch;
OWRITE(sc, OHCI_IRCTLCLR(dmach), OHCI_CNTL_DMA_RUN);
OWRITE(sc, OHCI_IR_MASKCLR, 1 << dmach);
OWRITE(sc, OHCI_IR_STATCLR, 1 << dmach);
/* XXX we cannot free buffers until the DMA really stops */
tsleep((void *)&sleepch, FWPRI, "fwirxd", hz);
pause("fwirxd", hz);
fwohci_db_free(&sc->ir[dmach]);
sc->ir[dmach].xferq.flag &= ~FWXFERQ_RUNNING;
return 0;

View File

@ -2114,7 +2114,7 @@ END_DEBUG
sbp_logout_all(sbp);
/* XXX wait for logout completion */
tsleep(&i, FWPRI, "sbpdtc", hz/2);
pause("sbpdtc", hz/2);
for (i = 0 ; i < SBP_NUM_TARGETS ; i ++)
sbp_free_target(&sbp->targets[i]);

View File

@ -2357,7 +2357,7 @@ static void hpt_worker_thread(void)
#if (__FreeBSD_version < 500000)
YIELD_THREAD;
#else
tsleep((caddr_t)hpt_worker_thread, PPAUSE, "sched", 1);
pause("sched", 1);
#endif
if (SIGISMEMBER(curproc->p_siglist, SIGSTOP)) {
/* abort rebuilding process. */
@ -2391,7 +2391,7 @@ static void hpt_worker_thread(void)
/*
#ifdef DEBUG
if (SIGISMEMBER(curproc->p_siglist, SIGSTOP))
tsleep((caddr_t)hpt_worker_thread, PPAUSE, "hptrdy", 2*hz);
pause("hptrdy", 2*hz);
#endif
*/
#if (__FreeBSD_version >= 500043)
@ -2399,7 +2399,7 @@ static void hpt_worker_thread(void)
#else
kproc_suspend_loop(curproc);
#endif
tsleep((caddr_t)hpt_worker_thread, PPAUSE, "hptrdy", 2*hz); /* wait for something to do */
pause("hptrdy", 2*hz); /* wait for something to do */
}
}

View File

@ -206,7 +206,7 @@ lock_driver_idle(IAL_ADAPTER_T *pAdapter)
#if (__FreeBSD_version < 500000)
YIELD_THREAD;
#else
tsleep(lock_driver_idle, PPAUSE, "switch", 1);
pause("switch", 1);
#endif
oldspl = lock_driver();
}
@ -421,7 +421,7 @@ int Kernel_DeviceIoControl(_VBUS_ARG
unlock_driver(oldspl);
while (!pArray->u.array.rf_rebuilding)
{
tsleep((caddr_t)Kernel_DeviceIoControl, PPAUSE, "pause", 1);
pause("pause", 1);
if ( timeout >= hz*3)
break;
timeout ++;
@ -486,7 +486,7 @@ hpt_set_array_state(DEVICEID idArray, DWORD state)
while (!pVDevice->u.array.rf_rebuilding)
{
tsleep((caddr_t)hpt_set_array_state, PPAUSE, "pause", 1);
pause("pause", 1);
if ( timeout >= hz*20)
break;
timeout ++;
@ -511,7 +511,7 @@ hpt_set_array_state(DEVICEID idArray, DWORD state)
while (pVDevice->u.array.rf_abort_rebuild)
{
tsleep((caddr_t)hpt_set_array_state, PPAUSE, "pause", 1);
pause("pause", 1);
if ( timeout >= hz*20)
break;
timeout ++;
@ -535,7 +535,7 @@ hpt_set_array_state(DEVICEID idArray, DWORD state)
while (!pVDevice->u.array.rf_verifying)
{
tsleep((caddr_t)hpt_set_array_state, PPAUSE, "pause", 1);
pause("pause", 1);
if ( timeout >= hz*20)
break;
timeout ++;
@ -554,7 +554,7 @@ hpt_set_array_state(DEVICEID idArray, DWORD state)
while (pVDevice->u.array.rf_abort_rebuild)
{
tsleep((caddr_t)hpt_set_array_state, PPAUSE, "pause", 1);
pause("pause", 1);
if ( timeout >= hz*80)
break;
timeout ++;
@ -575,7 +575,7 @@ hpt_set_array_state(DEVICEID idArray, DWORD state)
while (!pVDevice->u.array.rf_initializing)
{
tsleep((caddr_t)hpt_set_array_state, PPAUSE, "pause", 1);
pause("pause", 1);
if ( timeout >= hz*80)
break;
timeout ++;
@ -594,7 +594,7 @@ hpt_set_array_state(DEVICEID idArray, DWORD state)
while (pVDevice->u.array.rf_abort_rebuild)
{
tsleep((caddr_t)hpt_set_array_state, PPAUSE, "pause", 1);
pause("pause", 1);
if ( timeout >= hz*80)
break;
timeout ++;
@ -949,7 +949,7 @@ hpt_rebuild_data_block(IAL_ADAPTER_T *pAdapter, PVDevice pArray, UCHAR flags)
#if (__FreeBSD_version < 500000)
YIELD_THREAD;
#else
tsleep(hpt_rebuild_data_block, PPAUSE, "switch", 1);
pause("switch", 1);
#endif
oldspl = lock_driver();
}

View File

@ -571,8 +571,8 @@ pmc_debugflags_sysctl_handler(SYSCTL_HANDLER_ARGS)
* We prevent further scheduling of the PMC by marking it as in
* state 'DELETED'. If the runcount of the PMC is non-zero then
* this PMC is currently running on a CPU somewhere. The thread
* doing the PMCRELEASE operation waits by repeatedly doing an
* tsleep() till the runcount comes to zero.
* doing the PMCRELEASE operation waits by repeatedly doing a
* pause() till the runcount comes to zero.
*
*/
@ -638,7 +638,7 @@ pmc_select_cpu(int cpu)
/*
* Force a context switch.
*
* We do this by tsleep'ing for 1 tick -- invoking mi_switch() is not
* We do this by pause'ing for 1 tick -- invoking mi_switch() is not
* guaranteed to force a context switch.
*/
@ -646,7 +646,7 @@ static void
pmc_force_context_switch(void)
{
(void) tsleep((void *) pmc_force_context_switch, 0, "pmcctx", 1);
pause("pmcctx", 1);
}
/*

View File

@ -175,7 +175,7 @@ ssif_polled_request(struct ipmi_softc *sc, struct ipmi_request *req)
smbus_release_bus(smbus, dev);
/* Give the BMC 100ms to chew on the request. */
tsleep(&error, 0, "ssifwt", hz / 10);
pause("ssifwt", hz / 10);
/* Try to read the first packet. */
read_start:
@ -190,7 +190,7 @@ ssif_polled_request(struct ipmi_softc *sc, struct ipmi_request *req)
device_printf(dev, "SSIF: READ_START retry\n");
#endif
/* Give the BMC another 10ms. */
tsleep(&error, 0, "ssifwt", hz / 100);
pause("ssifwt", hz / 100);
goto read_start;
}
if (error) {
@ -328,7 +328,7 @@ ssif_loop(void *arg)
break;
/* Wait 60 ms between retries. */
tsleep(&ok, 0, "retry", 60 * hz / 1000);
pause("retry", 60 * hz / 1000);
#ifdef SSIF_RETRY_DEBUG
device_printf(sc->ipmi_dev,
"SSIF: Retrying request (%d)\n", i + 1);
@ -343,7 +343,7 @@ ssif_loop(void *arg)
IPMI_UNLOCK(sc);
/* Enforce 10ms between requests. */
tsleep(&ok, 0, "delay", hz / 100);
pause("delay", hz / 100);
IPMI_LOCK(sc);
}

View File

@ -103,7 +103,7 @@ pccard_read_cis(struct pccard_softc *sc)
* XXX seem to indicate that a delay is required. The old
* XXX delay was 1s. This delay is .1s.
*/
tsleep(&state, 0, "pccard", hz / 10);
pause("pccard", hz / 10);
if (pccard_scan_cis(device_get_parent(sc->dev), sc->dev,
pccard_parse_cis_tuple, &state) == -1)
state.card->error++;

View File

@ -284,7 +284,7 @@ random_kthread(void *arg __unused)
/* Found nothing, so don't belabour the issue */
if (!active)
tsleep(&harvestfifo, 0, "-", hz / 10);
pause("-", hz / 10);
}

View File

@ -1293,7 +1293,7 @@ waitfor_status_bits(struct scd_softc *sc, int bits_set, int bits_clear)
{
break;
}
tsleep(waitfor_status_bits, PZERO - 1, "waitfor", hz/10);
pause("waitfor", hz/10);
}
}
if ((c & bits_set) == bits_set &&

View File

@ -307,7 +307,7 @@ usb_delay_ms(usbd_bus_handle bus, u_int ms)
if (bus->use_polling || cold)
delay((ms+1) * 1000);
else
tsleep(&ms, PRIBIO, "usbdly", (ms*hz+999)/1000 + 1);
pause("usbdly", (ms*hz+999)/1000 + 1);
}
/* Delay given a device handle. */

View File

@ -818,7 +818,7 @@ uvscom_open(void *addr, int portno)
/* unit is not ready */
for (i = UVSCOM_UNIT_WAIT; i > 0; --i) {
tsleep(&err, TTIPRI, "uvsop", hz); /* XXX */
pause("uvsop", hz); /* XXX */
if (ISSET(sc->sc_usr, UVSCOM_USTAT_MASK))
break;
}

View File

@ -1199,7 +1199,7 @@ smbfs_smb_trans2find2(struct smbfs_fctx *ctx)
* I've didn't notice any problem, but put code
* for it.
*/
tsleep(&flags, PVFS, "fix95", tvtohz(&tv));
pause("fix95", tvtohz(&tv));
}
#endif
}

View File

@ -228,7 +228,7 @@ g_dev_close(struct cdev *dev, int flags, int fmt, struct thread *td)
break;
if (cp->nstart == cp->nend)
break;
tsleep(&i, PRIBIO, "gdevwclose", hz / 10);
pause("gdevwclose", hz / 10);
i += hz / 10;
}
if (cp->acr == 0 && cp->acw == 0 && cp->nstart != cp->nend) {
@ -366,7 +366,7 @@ g_dev_strategy(struct bio *bp)
bp2 = g_clone_bio(bp);
if (bp2 != NULL)
break;
tsleep(&bp, PRIBIO, "gdstrat", hz / 10);
pause("gdstrat", hz / 10);
}
KASSERT(bp2 != NULL, ("XXX: ENOMEM in a bad place"));
bp2->bio_done = g_dev_done;
@ -416,7 +416,7 @@ g_dev_orphan(struct g_consumer *cp)
/* Wait for the cows to come home */
while (cp->nstart != cp->nend)
tsleep(&dev, PRIBIO, "gdevorphan", hz / 10);
pause("gdevorphan", hz / 10);
if (cp->acr > 0 || cp->acw > 0 || cp->ace > 0)
g_access(cp, -cp->acr, -cp->acw, -cp->ace);

View File

@ -492,7 +492,7 @@ g_io_schedule_down(struct thread *tp __unused)
g_bioq_unlock(&g_bio_run_down);
if (pace > 0) {
CTR1(KTR_GEOM, "g_down pacing self (pace %d)", pace);
tsleep(&error, PRIBIO, "g_down", hz/10);
pause("g_down", hz/10);
pace--;
}
error = g_io_check(bp);

View File

@ -140,8 +140,7 @@ xenix_nap(struct thread *td, struct xenix_nap_args *uap)
DPRINTF(("IBCS2: 'xenix nap %d ms'\n", uap->millisec));
period = (long)uap->millisec / (1000/hz);
if (period)
while (tsleep(&period, PPAUSE, "nap", period)
!= EWOULDBLOCK) ;
pause("nap", period);
return 0;
}

View File

@ -473,11 +473,10 @@ XXX this is broken
static void
schedcpu_thread(void)
{
int nowake;
for (;;) {
schedcpu();
tsleep(&nowake, 0, "-", hz);
pause("-", hz);
}
}

View File

@ -162,7 +162,6 @@ ncp_sock_send(struct socket *so, struct mbuf *top, struct ncp_rq *rqp)
struct ncp_conn *conn = rqp->nr_conn;
struct mbuf *m;
int error, flags=0;
int sendwait;
for (;;) {
m = m_copym(top, 0, M_COPYALL, M_TRYWAIT);
@ -172,7 +171,7 @@ ncp_sock_send(struct socket *so, struct mbuf *top, struct ncp_rq *rqp)
break;
if (rqp->rexmit == 0) break;
rqp->rexmit--;
tsleep(&sendwait, PWAIT, "ncprsn", conn->li.timeout * hz);
pause("ncprsn", conn->li.timeout * hz);
error = ncp_chkintr(conn, td);
if (error == EINTR) break;
}

View File

@ -759,7 +759,7 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td)
}
/* XXX: Is this needed ? */
tsleep(&error, PZERO + 8, "bootpw", 10);
pause("bootpw", hz/10);
/* Set netmask to 255.0.0.0 */

View File

@ -1626,7 +1626,6 @@ swap_pager_swapoff(struct swdevt *sp)
}
mtx_unlock(&swhash_mtx);
if (sp->sw_used) {
int dummy;
/*
* Objects may be locked or paging to the device being
* removed, so we will miss their pages and need to
@ -1638,7 +1637,7 @@ swap_pager_swapoff(struct swdevt *sp)
panic("swapoff: failed to locate %d swap blocks",
sp->sw_used);
}
tsleep(&dummy, PVM, "swpoff", hz / 20);
pause("swpoff", hz / 20);
goto full_rescan;
}
}