diff options
Diffstat (limited to 'usr/src/uts/common/io')
55 files changed, 242 insertions, 284 deletions
diff --git a/usr/src/uts/common/io/bridge.c b/usr/src/uts/common/io/bridge.c index 1382dd9d0b..4d3110bdd1 100644 --- a/usr/src/uts/common/io/bridge.c +++ b/usr/src/uts/common/io/bridge.c @@ -429,7 +429,7 @@ bridge_ioc_listfwd(void *karg, intptr_t arg, int mode, cred_t *cred, int *rvalp) bcopy(bfp->bf_dest, blf->blf_dest, ETHERADDRL); blf->blf_trill_nick = bfp->bf_trill_nick; blf->blf_ms_age = - drv_hztousec(lbolt - bfp->bf_lastheard) / 1000; + drv_hztousec(ddi_get_lbolt() - bfp->bf_lastheard) / 1000; blf->blf_is_local = (bfp->bf_flags & BFF_LOCALADDR) != 0; blf->blf_linkid = bfp->bf_links[0]->bl_linkid; @@ -904,7 +904,7 @@ fwd_alloc(const uint8_t *addr, uint_t nlinks, uint16_t nick) KM_NOSLEEP); if (bfp != NULL) { bcopy(addr, bfp->bf_dest, ETHERADDRL); - bfp->bf_lastheard = lbolt; + bfp->bf_lastheard = ddi_get_lbolt(); bfp->bf_maxlinks = nlinks; bfp->bf_links = (bridge_link_t **)(bfp + 1); bfp->bf_trill_nick = nick; @@ -1436,7 +1436,7 @@ bridge_timer(void *arg) while ((bfp = bfnext) != NULL) { bfnext = AVL_NEXT(&bip->bi_fwd, bfp); if (!(bfp->bf_flags & BFF_LOCALADDR) && - (lbolt - bfp->bf_lastheard) > age_limit) { + (ddi_get_lbolt() - bfp->bf_lastheard) > age_limit) { ASSERT(bfp->bf_flags & BFF_INTREE); avl_remove(&bip->bi_fwd, bfp); bfp->bf_flags &= ~BFF_INTREE; @@ -1608,7 +1608,7 @@ bridge_learn(bridge_link_t *blp, const uint8_t *saddr, uint16_t ingress_nick, if (bfp->bf_trill_nick == ingress_nick) { for (i = 0; i < bfp->bf_nlinks; i++) { if (bfp->bf_links[i] == blp) { - bfp->bf_lastheard = lbolt; + bfp->bf_lastheard = ddi_get_lbolt(); fwd_unref(bfp); return; } diff --git a/usr/src/uts/common/io/bscbus.c b/usr/src/uts/common/io/bscbus.c index 188770f08f..b1f1ec9567 100644 --- a/usr/src/uts/common/io/bscbus.c +++ b/usr/src/uts/common/io/bscbus.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * * The "bscbus" driver provides access to the LOMlite2 virtual registers, @@ -927,7 +927,6 @@ bscbus_cmd(HANDLE_TYPE *hdlp, ptrdiff_t vreg, uint_t val, uint_t cmd) { struct bscbus_channel_state *csp; clock_t start; - clock_t tick; uint8_t status; /* @@ -1018,8 +1017,8 @@ bscbus_cmd(HANDLE_TYPE *hdlp, ptrdiff_t vreg, uint_t val, uint_t cmd) (csp->cmdstate != BSCBUS_CMDSTATE_ERROR)) { ASSERT(csp->cmdstate != BSCBUS_CMDSTATE_IDLE); - tick = ddi_get_lbolt() + csp->poll_hz; - if ((cv_timedwait(csp->lo_cv, csp->lo_mutex, tick) == -1) && + if ((cv_reltimedwait(csp->lo_cv, csp->lo_mutex, + csp->poll_hz, TR_CLOCK_TICK) == -1) && csp->cmdstate != BSCBUS_CMDSTATE_READY && csp->cmdstate != BSCBUS_CMDSTATE_ERROR) { if (!csp->interrupt_failed) { diff --git a/usr/src/uts/common/io/bscv.c b/usr/src/uts/common/io/bscv.c index 77de4d47b7..829268c822 100644 --- a/usr/src/uts/common/io/bscv.c +++ b/usr/src/uts/common/io/bscv.c @@ -3128,9 +3128,8 @@ bscv_event_daemon(void *arg) if (ssp->event_sleep) { ssp->task_flags |= TASK_SLEEPING_FLG; /* Sleep until there is something to do */ - (void) cv_timedwait(&ssp->task_cv, - &ssp->task_mu, - poll_period + ddi_get_lbolt()); + (void) cv_reltimedwait(&ssp->task_cv, + &ssp->task_mu, poll_period, TR_CLOCK_TICK); ssp->task_flags &= ~TASK_SLEEPING_FLG; ssp->event_sleep = B_FALSE; } diff --git a/usr/src/uts/common/io/comstar/port/fcoet/fcoet.c b/usr/src/uts/common/io/comstar/port/fcoet/fcoet.c index 5478888c16..6271f35b86 100644 --- a/usr/src/uts/common/io/comstar/port/fcoet/fcoet.c +++ b/usr/src/uts/common/io/comstar/port/fcoet/fcoet.c @@ -759,9 +759,8 @@ fcoet_watchdog(void *arg) } atomic_or_32(&ss->ss_flags, SS_FLAG_DOG_WAITING); - (void) cv_timedwait(&ss->ss_watch_cv, - &ss->ss_watch_mutex, ddi_get_lbolt() + - (clock_t)tmp_delay); + (void) cv_reltimedwait(&ss->ss_watch_cv, &ss->ss_watch_mutex, + (clock_t)tmp_delay, TR_CLOCK_TICK); atomic_and_32(&ss->ss_flags, ~SS_FLAG_DOG_WAITING); } diff --git a/usr/src/uts/common/io/comstar/port/fct/discovery.c b/usr/src/uts/common/io/comstar/port/fct/discovery.c index 96a80c2558..a9e16bb39d 100644 --- a/usr/src/uts/common/io/comstar/port/fct/discovery.c +++ b/usr/src/uts/common/io/comstar/port/fct/discovery.c @@ -180,8 +180,8 @@ fct_port_worker(void *arg) } atomic_or_32(&iport->iport_flags, IPORT_WORKER_DOING_TIMEDWAIT); - (void) cv_timedwait(&iport->iport_worker_cv, - &iport->iport_worker_lock, ddi_get_lbolt() + dl); + (void) cv_reltimedwait(&iport->iport_worker_cv, + &iport->iport_worker_lock, dl, TR_CLOCK_TICK); atomic_and_32(&iport->iport_flags, ~IPORT_WORKER_DOING_TIMEDWAIT); } else { @@ -192,9 +192,9 @@ fct_port_worker(void *arg) if (tmp_delay < 0) { tmp_delay = (int64_t)short_delay; } - (void) cv_timedwait(&iport->iport_worker_cv, - &iport->iport_worker_lock, ddi_get_lbolt() + - (clock_t)tmp_delay); + (void) cv_reltimedwait(&iport->iport_worker_cv, + &iport->iport_worker_lock, (clock_t)tmp_delay, + TR_CLOCK_TICK); atomic_and_32(&iport->iport_flags, ~IPORT_WORKER_DOING_WAIT); } diff --git a/usr/src/uts/common/io/comstar/port/iscsit/iscsit_isns.c b/usr/src/uts/common/io/comstar/port/iscsit/iscsit_isns.c index c74139877d..a8714f88a5 100644 --- a/usr/src/uts/common/io/comstar/port/iscsit/iscsit_isns.c +++ b/usr/src/uts/common/io/comstar/port/iscsit/iscsit_isns.c @@ -1101,8 +1101,8 @@ isnst_monitor(void *arg) break; DTRACE_PROBE(iscsit__isns__monitor__sleep); - (void) cv_timedwait(&isns_idle_cv, &isns_monitor_mutex, - ddi_get_lbolt() + monitor_idle_interval); + (void) cv_reltimedwait(&isns_idle_cv, &isns_monitor_mutex, + monitor_idle_interval, TR_CLOCK_TICK); DTRACE_PROBE1(iscsit__isns__monitor__wakeup, boolean_t, isns_monitor_thr_running); } diff --git a/usr/src/uts/common/io/comstar/port/qlt/qlt.c b/usr/src/uts/common/io/comstar/port/qlt/qlt.c index ae1ed80a0b..4f4e078cd7 100644 --- a/usr/src/uts/common/io/comstar/port/qlt/qlt.c +++ b/usr/src/uts/common/io/comstar/port/qlt/qlt.c @@ -2446,8 +2446,8 @@ qlt_mailbox_command(qlt_state_t *qlt, mbox_cmd_t *mcp) qlt_mbox_wait_loop:; /* Wait for mailbox command completion */ - if (cv_timedwait(&qlt->mbox_cv, &qlt->mbox_lock, ddi_get_lbolt() - + drv_usectohz(MBOX_TIMEOUT)) < 0) { + if (cv_reltimedwait(&qlt->mbox_cv, &qlt->mbox_lock, + drv_usectohz(MBOX_TIMEOUT), TR_CLOCK_TICK) < 0) { (void) snprintf(info, 80, "qlt_mailbox_command: qlt-%p, " "cmd-0x%02X timed out", (void *)qlt, qlt->mcp->to_fw[0]); info[79] = 0; @@ -3147,9 +3147,9 @@ qlt_deregister_remote_port(fct_local_port_t *port, fct_remote_port_t *rp) qlt->rp_id_in_dereg = rp->rp_id; qlt_submit_preq_entries(qlt, 1); - dereg_req_timer = ddi_get_lbolt() + drv_usectohz(DEREG_RP_TIMEOUT); - if (cv_timedwait(&qlt->rp_dereg_cv, - &qlt->preq_lock, dereg_req_timer) > 0) { + dereg_req_timer = drv_usectohz(DEREG_RP_TIMEOUT); + if (cv_reltimedwait(&qlt->rp_dereg_cv, &qlt->preq_lock, + dereg_req_timer, TR_CLOCK_TICK) > 0) { ret = qlt->rp_dereg_status; } else { ret = FCT_BUSY; @@ -4874,13 +4874,14 @@ qlt_firmware_dump(fct_local_port_t *port, stmf_state_change_info_t *ssci) */ mutex_enter(&qlt->mbox_lock); if (qlt->mbox_io_state != MBOX_STATE_UNKNOWN) { + clock_t timeout = drv_usectohz(1000000); /* * Wait to grab the mailboxes */ for (retries = 0; (qlt->mbox_io_state != MBOX_STATE_READY) && (qlt->mbox_io_state != MBOX_STATE_UNKNOWN); retries++) { - (void) cv_timedwait(&qlt->mbox_cv, &qlt->mbox_lock, - ddi_get_lbolt() + drv_usectohz(1000000)); + (void) cv_reltimedwait(&qlt->mbox_cv, &qlt->mbox_lock, + timeout, TR_CLOCK_TICK); if (retries > 5) { mutex_exit(&qlt->mbox_lock); EL(qlt, "can't drain out mailbox commands\n"); diff --git a/usr/src/uts/common/io/comstar/stmf/stmf.c b/usr/src/uts/common/io/comstar/stmf/stmf.c index 0a89a6dc6b..3e67d5fc9e 100644 --- a/usr/src/uts/common/io/comstar/stmf/stmf.c +++ b/usr/src/uts/common/io/comstar/stmf/stmf.c @@ -5713,7 +5713,7 @@ stmf_worker_task(void *arg) stmf_data_buf_t *dbuf; stmf_lu_t *lu; clock_t wait_timer = 0; - clock_t wait_ticks; + clock_t wait_ticks, wait_delta = 0; uint32_t old, new; uint8_t curcmd; uint8_t abort_free; @@ -5739,6 +5739,7 @@ stmf_worker_loop:; dec_qdepth = 0; if (wait_timer && (ddi_get_lbolt() >= wait_timer)) { wait_timer = 0; + wait_delta = 0; if (w->worker_wait_head) { ASSERT(w->worker_wait_tail); if (w->worker_task_head == NULL) @@ -5815,6 +5816,7 @@ out_itask_flag_loop: w->worker_wait_tail = itask; if (wait_timer == 0) { wait_timer = ddi_get_lbolt() + wait_ticks; + wait_delta = wait_ticks; } } else if ((--(itask->itask_ncmds)) != 0) { itask->itask_worker_next = NULL; @@ -5900,12 +5902,15 @@ out_itask_flag_loop: if ((w->worker_flags & STMF_WORKER_TERMINATE) && (wait_timer == 0)) { if (w->worker_ref_count == 0) goto stmf_worker_loop; - else + else { wait_timer = ddi_get_lbolt() + 1; + wait_delta = 1; + } } w->worker_flags &= ~STMF_WORKER_ACTIVE; if (wait_timer) { - (void) cv_timedwait(&w->worker_cv, &w->worker_lock, wait_timer); + (void) cv_reltimedwait(&w->worker_cv, &w->worker_lock, + wait_delta, TR_CLOCK_TICK); } else { cv_wait(&w->worker_cv, &w->worker_lock); } @@ -6902,8 +6907,8 @@ stmf_svc_loop: } stmf_state.stmf_svc_flags &= ~STMF_SVC_ACTIVE; - (void) cv_timedwait(&stmf_state.stmf_cv, &stmf_state.stmf_lock, - ddi_get_lbolt() + td); + (void) cv_reltimedwait(&stmf_state.stmf_cv, + &stmf_state.stmf_lock, td, TR_CLOCK_TICK); stmf_state.stmf_svc_flags |= STMF_SVC_ACTIVE; } goto stmf_svc_loop; diff --git a/usr/src/uts/common/io/drm/drmP.h b/usr/src/uts/common/io/drm/drmP.h index e04dc759c7..4c6934db87 100644 --- a/usr/src/uts/common/io/drm/drmP.h +++ b/usr/src/uts/common/io/drm/drmP.h @@ -222,22 +222,22 @@ typedef struct drm_wait_queue { mutex_exit(&(q)->lock); \ } -#define jiffies ddi_get_lbolt() -#define DRM_WAIT_ON(ret, q, timeout, condition) \ -mutex_enter(&(q)->lock); \ -while (!(condition)) { \ - ret = cv_timedwait_sig(&(q)->cv, &(q)->lock, jiffies + timeout); \ - if (ret == -1) { \ - ret = EBUSY; \ - break; \ - } else if (ret == 0) { \ - ret = EINTR; \ - break; \ - } else { \ - ret = 0; \ - } \ -} \ -mutex_exit(&(q)->lock); +#define DRM_WAIT_ON(ret, q, timeout, condition) \ + mutex_enter(&(q)->lock); \ + while (!(condition)) { \ + ret = cv_reltimedwait_sig(&(q)->cv, &(q)->lock, timeout,\ + TR_CLOCK_TICK); \ + if (ret == -1) { \ + ret = EBUSY; \ + break; \ + } else if (ret == 0) { \ + ret = EINTR; \ + break; \ + } else { \ + ret = 0; \ + } \ + } \ + mutex_exit(&(q)->lock); #define DRM_GETSAREA() \ { \ @@ -397,7 +397,7 @@ typedef struct drm_lock_data { /* Uniq. identifier of holding process */ kcondvar_t lock_cv; /* lock queue - SOLARIS Specific */ kmutex_t lock_mutex; /* lock - SOLARIS Specific */ - unsigned long lock_time; /* Time of last lock in jiffies */ + unsigned long lock_time; /* Time of last lock in clock ticks */ } drm_lock_data_t; /* diff --git a/usr/src/uts/common/io/drm/drm_lock.c b/usr/src/uts/common/io/drm/drm_lock.c index 69a43a7598..6930a47e03 100644 --- a/usr/src/uts/common/io/drm/drm_lock.c +++ b/usr/src/uts/common/io/drm/drm_lock.c @@ -140,7 +140,7 @@ drm_lock(DRM_IOCTL_ARGS) for (;;) { if (drm_lock_take(&dev->lock, lock.context)) { dev->lock.filp = fpriv; - dev->lock.lock_time = jiffies; + dev->lock.lock_time = ddi_get_lbolt(); break; /* Got lock */ } ret = cv_wait_sig(&(dev->lock.lock_cv), diff --git a/usr/src/uts/common/io/e1000g/e1000g_tx.c b/usr/src/uts/common/io/e1000g/e1000g_tx.c index 1b752b8100..9d58d9b127 100644 --- a/usr/src/uts/common/io/e1000g/e1000g_tx.c +++ b/usr/src/uts/common/io/e1000g/e1000g_tx.c @@ -733,7 +733,7 @@ e1000g_fill_tx_ring(e1000g_tx_ring_t *tx_ring, LIST_DESCRIBER *pending_list, first_packet = NULL; } - packet->tickstamp = lbolt64; + packet->tickstamp = ddi_get_lbolt64(); previous_packet = packet; packet = (p_tx_sw_packet_t) @@ -1053,7 +1053,7 @@ e1000g_recycle(e1000g_tx_ring_t *tx_ring) * with then there is no reason to check the rest * of the queue. */ - delta = lbolt64 - packet->tickstamp; + delta = ddi_get_lbolt64() - packet->tickstamp; break; } } diff --git a/usr/src/uts/common/io/ecpp.c b/usr/src/uts/common/io/ecpp.c index d2aa9a05f1..c7c03826b5 100644 --- a/usr/src/uts/common/io/ecpp.c +++ b/usr/src/uts/common/io/ecpp.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -774,9 +774,9 @@ ecpp_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) * Wait if there's any activity on the port */ if ((pp->e_busy == ECPP_BUSY) || (pp->e_busy == ECPP_FLUSH)) { - (void) cv_timedwait(&pp->pport_cv, &pp->umutex, - ddi_get_lbolt() + - SUSPEND_TOUT * drv_usectohz(1000000)); + (void) cv_reltimedwait(&pp->pport_cv, &pp->umutex, + SUSPEND_TOUT * drv_usectohz(1000000), + TR_CLOCK_TICK); if ((pp->e_busy == ECPP_BUSY) || (pp->e_busy == ECPP_FLUSH)) { pp->suspended = FALSE; diff --git a/usr/src/uts/common/io/emul64_bsd.c b/usr/src/uts/common/io/emul64_bsd.c index 8077ec90da..3d91f696bf 100644 --- a/usr/src/uts/common/io/emul64_bsd.c +++ b/usr/src/uts/common/io/emul64_bsd.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -1369,8 +1369,8 @@ emul64_yield_check() ticks = drv_usectohz(emul64_yield_length); if (ticks == 0) ticks = 1; - (void) cv_timedwait(&emul64_yield_cv, - &emul64_yield_mutex, ddi_get_lbolt() + ticks); + (void) cv_reltimedwait(&emul64_yield_cv, &emul64_yield_mutex, + ticks, TR_CLOCK_TICK); emul64_io_count = 0; emul64_waiting = FALSE; diff --git a/usr/src/uts/common/io/fcoe/fcoe_fc.c b/usr/src/uts/common/io/fcoe/fcoe_fc.c index ba7b6cbad5..1aab1e5128 100644 --- a/usr/src/uts/common/io/fcoe/fcoe_fc.c +++ b/usr/src/uts/common/io/fcoe/fcoe_fc.c @@ -210,8 +210,8 @@ tx_frame: MAC_TX_NO_ENQUEUE, &ret_mblk); if (ret_cookie != NULL) { mutex_enter(&mac->fm_mutex); - (void) cv_timedwait(&mac->fm_tx_cv, &mac->fm_mutex, - ddi_get_lbolt() + drv_usectohz(100000)); + (void) cv_reltimedwait(&mac->fm_tx_cv, &mac->fm_mutex, + drv_usectohz(100000), TR_CLOCK_TICK); mutex_exit(&mac->fm_mutex); if (mac->fm_state == FCOE_MAC_STATE_OFFLINE) { diff --git a/usr/src/uts/common/io/fibre-channel/fca/qlc/ql_api.c b/usr/src/uts/common/io/fibre-channel/fca/qlc/ql_api.c index 48e17432cc..fa7c2c44ce 100644 --- a/usr/src/uts/common/io/fibre-channel/fca/qlc/ql_api.c +++ b/usr/src/uts/common/io/fibre-channel/fca/qlc/ql_api.c @@ -2481,7 +2481,7 @@ ql_els_send(opaque_t fca_handle, fc_packet_t *pkt) { ql_adapter_state_t *ha; int rval; - clock_t timer; + clock_t timer = drv_usectohz(30000000); ls_code_t els; la_els_rjt_t rjt; ql_srb_t *sp = (ql_srb_t *)pkt->pkt_fca_private; @@ -2501,11 +2501,8 @@ ql_els_send(opaque_t fca_handle, fc_packet_t *pkt) ha->task_daemon_flags |= SUSPENDED_WAKEUP_FLG; /* 30 seconds from now */ - timer = ddi_get_lbolt(); - timer += drv_usectohz(30000000); - - if (cv_timedwait(&ha->pha->cv_dr_suspended, - &ha->pha->task_daemon_mutex, timer) == -1) { + if (cv_reltimedwait(&ha->pha->cv_dr_suspended, + &ha->pha->task_daemon_mutex, timer, TR_CLOCK_TICK) == -1) { /* * The timeout time 'timer' was * reached without the condition @@ -2832,7 +2829,7 @@ static int ql_getmap(opaque_t fca_handle, fc_lilpmap_t *mapbuf) { ql_adapter_state_t *ha; - clock_t timer; + clock_t timer = drv_usectohz(30000000); int rval = FC_SUCCESS; ha = ql_fca_handle_to_state(fca_handle); @@ -2852,11 +2849,8 @@ ql_getmap(opaque_t fca_handle, fc_lilpmap_t *mapbuf) ha->task_daemon_flags |= SUSPENDED_WAKEUP_FLG; /* 30 seconds from now */ - timer = ddi_get_lbolt(); - timer += drv_usectohz(30000000); - - if (cv_timedwait(&ha->pha->cv_dr_suspended, - &ha->pha->task_daemon_mutex, timer) == -1) { + if (cv_reltimedwait(&ha->pha->cv_dr_suspended, + &ha->pha->task_daemon_mutex, timer, TR_CLOCK_TICK) == -1) { /* * The timeout time 'timer' was * reached without the condition @@ -11474,7 +11468,7 @@ static int ql_dump_firmware(ql_adapter_state_t *vha) { int rval; - clock_t timer; + clock_t timer = drv_usectohz(30000000); ql_adapter_state_t *ha = vha->pha; QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance); @@ -11513,11 +11507,8 @@ ql_dump_firmware(ql_adapter_state_t *vha) ha->task_daemon_flags |= SUSPENDED_WAKEUP_FLG; /* 30 seconds from now */ - timer = ddi_get_lbolt(); - timer += drv_usectohz(30000000); - - if (cv_timedwait(&ha->cv_dr_suspended, - &ha->task_daemon_mutex, timer) == -1) { + if (cv_reltimedwait(&ha->cv_dr_suspended, + &ha->task_daemon_mutex, timer, TR_CLOCK_TICK) == -1) { /* * The timeout time 'timer' was * reached without the condition @@ -11593,18 +11584,15 @@ ql_binary_fw_dump(ql_adapter_state_t *vha, int lock_needed) if (lock_needed == TRUE) { /* Acquire mailbox register lock. */ MBX_REGISTER_LOCK(ha); - + timer = (ha->mcp->timeout + 2) * drv_usectohz(1000000); /* Check for mailbox available, if not wait for signal. */ while (ha->mailbox_flags & MBX_BUSY_FLG) { ha->mailbox_flags = (uint8_t) (ha->mailbox_flags | MBX_WANT_FLG); /* 30 seconds from now */ - timer = ddi_get_lbolt(); - timer += (ha->mcp->timeout + 2) * - drv_usectohz(1000000); - if (cv_timedwait(&ha->cv_mbx_wait, &ha->mbx_mutex, - timer) == -1) { + if (cv_reltimedwait(&ha->cv_mbx_wait, &ha->mbx_mutex, + timer, TR_CLOCK_TICK) == -1) { /* * The timeout time 'timer' was * reached without the condition @@ -15619,7 +15607,7 @@ ql_unbind_dma_buffer(ql_adapter_state_t *ha, dma_mem_t *mem) static int ql_suspend_adapter(ql_adapter_state_t *ha) { - clock_t timer; + clock_t timer = 32 * drv_usectohz(1000000); QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance); @@ -15636,10 +15624,8 @@ ql_suspend_adapter(ql_adapter_state_t *ha) (ha->mailbox_flags | MBX_WANT_FLG); /* 30 seconds from now */ - timer = ddi_get_lbolt(); - timer += 32 * drv_usectohz(1000000); - if (cv_timedwait(&ha->cv_mbx_wait, &ha->mbx_mutex, - timer) == -1) { + if (cv_reltimedwait(&ha->cv_mbx_wait, &ha->mbx_mutex, + timer, TR_CLOCK_TICK) == -1) { /* Release mailbox register lock. */ MBX_REGISTER_UNLOCK(ha); diff --git a/usr/src/uts/common/io/fibre-channel/fca/qlc/ql_mbx.c b/usr/src/uts/common/io/fibre-channel/fca/qlc/ql_mbx.c index 8771808a8d..db57b0408d 100644 --- a/usr/src/uts/common/io/fibre-channel/fca/qlc/ql_mbx.c +++ b/usr/src/uts/common/io/fibre-channel/fca/qlc/ql_mbx.c @@ -110,10 +110,9 @@ ql_mailbox_command(ql_adapter_state_t *vha, mbx_cmd_t *mcp) } /* Set timeout after command that is running. */ - timer = ddi_get_lbolt(); - timer += (mcp->timeout + 20) * drv_usectohz(1000000); - cv_stat = cv_timedwait_sig(&ha->cv_mbx_wait, - &ha->pha->mbx_mutex, timer); + timer = (mcp->timeout + 20) * drv_usectohz(1000000); + cv_stat = cv_reltimedwait_sig(&ha->cv_mbx_wait, + &ha->pha->mbx_mutex, timer, TR_CLOCK_TICK); if (cv_stat == -1 || cv_stat == 0) { /* * The timeout time 'timer' was @@ -162,14 +161,12 @@ ql_mailbox_command(ql_adapter_state_t *vha, mbx_cmd_t *mcp) !(ha->task_daemon_flags & (TASK_THREAD_CALLED | TASK_DAEMON_POWERING_DOWN)) && !ddi_in_panic()) { + timer = mcp->timeout * drv_usectohz(1000000); while (!(ha->mailbox_flags & (MBX_INTERRUPT | MBX_ABORT)) && !(ha->task_daemon_flags & ISP_ABORT_NEEDED)) { - /* 30 seconds from now */ - timer = ddi_get_lbolt(); - timer += mcp->timeout * drv_usectohz(1000000); - if (cv_timedwait(&ha->cv_mbx_intr, &ha->pha->mbx_mutex, - timer) == -1) { + if (cv_reltimedwait(&ha->cv_mbx_intr, + &ha->pha->mbx_mutex, timer, TR_CLOCK_TICK) == -1) { /* * The timeout time 'timer' was * reached without the condition @@ -3924,7 +3921,7 @@ ql_stop_firmware(ql_adapter_state_t *ha) * ha: adapter state pointer. * mem: pointer to dma memory object for command. * dev: Device address (A0h or A2h). - * addr: Data address on SFP EEPROM (0–255). + * addr: Data address on SFP EEPROM (0-255). * * Returns: * ql local function return status code. diff --git a/usr/src/uts/common/io/fibre-channel/ulp/fcp.c b/usr/src/uts/common/io/fibre-channel/ulp/fcp.c index 06ea627d6c..f423ccd4f6 100644 --- a/usr/src/uts/common/io/fibre-channel/ulp/fcp.c +++ b/usr/src/uts/common/io/fibre-channel/ulp/fcp.c @@ -10172,7 +10172,7 @@ fcp_handle_port_attach(opaque_t ulph, fc_ulp_port_info_t *pinfo, } /* note the attach time */ - pptr->port_attach_time = lbolt64; + pptr->port_attach_time = ddi_get_lbolt64(); /* all done */ return (res); @@ -15661,7 +15661,7 @@ fcp_scsi_bus_config(dev_info_t *parent, uint_t flag, struct fcp_port *pptr = fcp_dip2port(parent); reset_delay = (int64_t)(USEC_TO_TICK(FCP_INIT_WAIT_TIMEOUT)) - - (lbolt64 - pptr->port_attach_time); + (ddi_get_lbolt64() - pptr->port_attach_time); if (reset_delay < 0) { reset_delay = 0; } @@ -15706,7 +15706,7 @@ fcp_scsi_bus_config(dev_info_t *parent, uint_t flag, ddi_get_lbolt() + (clock_t)reset_delay); reset_delay = (int64_t)(USEC_TO_TICK(FCP_INIT_WAIT_TIMEOUT)) - - (lbolt64 - pptr->port_attach_time); + (ddi_get_lbolt64() - pptr->port_attach_time); } mutex_exit(&pptr->port_mutex); /* drain taskq to make sure nodes are created */ diff --git a/usr/src/uts/common/io/ib/adapters/hermon/hermon_stats.c b/usr/src/uts/common/io/ib/adapters/hermon/hermon_stats.c index 222d077eb5..bd35303075 100644 --- a/usr/src/uts/common/io/ib/adapters/hermon/hermon_stats.c +++ b/usr/src/uts/common/io/ib/adapters/hermon/hermon_stats.c @@ -729,6 +729,7 @@ hermon_kstat_perfcntr64_update_thread(void *arg) hermon_state_t *state = (hermon_state_t *)arg; hermon_ks_info_t *ksi = state->hs_ks_info; uint_t i; + clock_t delta = drv_usectohz(1000000); mutex_enter(&ksi->hki_perfcntr64_lock); /* @@ -743,9 +744,8 @@ hermon_kstat_perfcntr64_update_thread(void *arg) } } /* sleep for a second */ - (void) cv_timedwait(&ksi->hki_perfcntr64_cv, - &ksi->hki_perfcntr64_lock, - ddi_get_lbolt() + drv_usectohz(1000000)); + (void) cv_reltimedwait(&ksi->hki_perfcntr64_cv, + &ksi->hki_perfcntr64_lock, delta, TR_CLOCK_TICK); } ksi->hki_perfcntr64_flags = 0; mutex_exit(&ksi->hki_perfcntr64_lock); diff --git a/usr/src/uts/common/io/ib/clients/rds/rdsib_buf.c b/usr/src/uts/common/io/ib/clients/rds/rdsib_buf.c index b8a0e2fb30..e2a7c43ada 100644 --- a/usr/src/uts/common/io/ib/clients/rds/rdsib_buf.c +++ b/usr/src/uts/common/io/ib/clients/rds/rdsib_buf.c @@ -963,8 +963,8 @@ rds_get_send_buf(rds_ep_t *ep, uint_t nbuf) if (spool->pool_nfree < nbuf) { /* wait for buffers to become available */ spool->pool_cv_count += nbuf; - ret = cv_timedwait_sig(&spool->pool_cv, &spool->pool_lock, - ddi_get_lbolt() + drv_usectohz(waittime)); + ret = cv_reltimedwait_sig(&spool->pool_cv, &spool->pool_lock, + drv_usectohz(waittime), TR_CLOCK_TICK); /* ret = cv_wait_sig(&spool->pool_cv, &spool->pool_lock); */ if (ret == 0) { /* signal pending */ diff --git a/usr/src/uts/common/io/ib/mgt/ibdm/ibdm.c b/usr/src/uts/common/io/ib/mgt/ibdm/ibdm.c index 8ac5b06efa..7f2abe7114 100644 --- a/usr/src/uts/common/io/ib/mgt/ibdm/ibdm.c +++ b/usr/src/uts/common/io/ib/mgt/ibdm/ibdm.c @@ -4702,13 +4702,14 @@ void ibdm_ibnex_port_settle_wait(ib_guid_t hca_guid, int dft_wait) { time_t wait_time; + clock_t delta; mutex_enter(&ibdm.ibdm_hl_mutex); while ((wait_time = ibdm_get_waittime(hca_guid, dft_wait)) > 0) { - (void) cv_timedwait(&ibdm.ibdm_port_settle_cv, - &ibdm.ibdm_hl_mutex, - ddi_get_lbolt() + drv_usectohz(wait_time * 1000000)); + delta = wait_time * drv_usectohz(wait_time * 1000000); + (void) cv_reltimedwait(&ibdm.ibdm_port_settle_cv, + &ibdm.ibdm_hl_mutex, delta, TR_CLOCK_TICK); } mutex_exit(&ibdm.ibdm_hl_mutex); diff --git a/usr/src/uts/common/io/idm/idm_impl.c b/usr/src/uts/common/io/idm/idm_impl.c index 273465734a..a271c22036 100644 --- a/usr/src/uts/common/io/idm/idm_impl.c +++ b/usr/src/uts/common/io/idm/idm_impl.c @@ -1079,7 +1079,7 @@ void idm_wd_thread(void *arg) { idm_conn_t *ic; - clock_t wake_time; + clock_t wake_time = SEC_TO_TICK(IDM_WD_INTERVAL); clock_t idle_time; /* Record the thread id for thread_join() */ @@ -1164,9 +1164,8 @@ idm_wd_thread(void *arg) mutex_exit(&ic->ic_state_mutex); } - wake_time = ddi_get_lbolt() + SEC_TO_TICK(IDM_WD_INTERVAL); - (void) cv_timedwait(&idm.idm_wd_cv, &idm.idm_global_mutex, - wake_time); + (void) cv_reltimedwait(&idm.idm_wd_cv, &idm.idm_global_mutex, + wake_time, TR_CLOCK_TICK); } mutex_exit(&idm.idm_global_mutex); diff --git a/usr/src/uts/common/io/ipw/ipw2100.c b/usr/src/uts/common/io/ipw/ipw2100.c index 4e22a3b195..8c6bdbbe6f 100644 --- a/usr/src/uts/common/io/ipw/ipw2100.c +++ b/usr/src/uts/common/io/ipw/ipw2100.c @@ -1071,13 +1071,14 @@ ipw2100_cmd(struct ipw2100_softc *sc, uint32_t type, void *buf, size_t len) /* * wait for command done */ + clk = drv_usectohz(1000000); /* 1 second */ mutex_enter(&sc->sc_ilock); while (sc->sc_done == 0) { /* * pending for the response */ - clk = ddi_get_lbolt() + drv_usectohz(1000000); /* 1 second */ - if (cv_timedwait(&sc->sc_cmd_cond, &sc->sc_ilock, clk) < 0) + if (cv_reltimedwait(&sc->sc_cmd_cond, &sc->sc_ilock, + clk, TR_CLOCK_TICK) < 0) break; } mutex_exit(&sc->sc_ilock); diff --git a/usr/src/uts/common/io/ipw/ipw2100_hw.c b/usr/src/uts/common/io/ipw/ipw2100_hw.c index 9b0b34e800..f8c7d10583 100644 --- a/usr/src/uts/common/io/ipw/ipw2100_hw.c +++ b/usr/src/uts/common/io/ipw/ipw2100_hw.c @@ -1,5 +1,5 @@ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -30,8 +30,6 @@ * SUCH DAMAGE. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Intel Wireless PRO/2100 mini-PCI adapter driver * ipw2100_hw.c is used to handle hardware operation and firmware operations. @@ -483,12 +481,13 @@ ipw2100_load_fw(struct ipw2100_softc *sc) /* * wait for interrupt to notify fw initialization is done */ + clk = drv_usectohz(5000000); /* 5 second */ while (!(sc->sc_flags & IPW2100_FLAG_FW_INITED)) { /* * wait longer for the fw initialized */ - clk = ddi_get_lbolt() + drv_usectohz(5000000); /* 5 second */ - if (cv_timedwait(&sc->sc_fw_cond, &sc->sc_ilock, clk) < 0) + if (cv_reltimedwait(&sc->sc_fw_cond, &sc->sc_ilock, clk, + TR_CLOCK_TICK) < 0) break; } mutex_exit(&sc->sc_ilock); diff --git a/usr/src/uts/common/io/iwi/ipw2200.c b/usr/src/uts/common/io/iwi/ipw2200.c index 505a946a07..d52e069496 100644 --- a/usr/src/uts/common/io/iwi/ipw2200.c +++ b/usr/src/uts/common/io/iwi/ipw2200.c @@ -1014,12 +1014,12 @@ ipw2200_cmd(struct ipw2200_softc *sc, /* * Wait for command done */ + clk = drv_usectohz(5000000); mutex_enter(&sc->sc_ilock); while (sc->sc_done[idx] == 0) { /* pending */ - clk = ddi_get_lbolt() + drv_usectohz(5000000); /* 5 second */ - if (cv_timedwait(&sc->sc_cmd_status_cond, &sc->sc_ilock, clk) - < 0) + if (cv_reltimedwait(&sc->sc_cmd_status_cond, &sc->sc_ilock, + clk, TR_CLOCK_TICK) < 0) break; } mutex_exit(&sc->sc_ilock); diff --git a/usr/src/uts/common/io/iwi/ipw2200_hw.c b/usr/src/uts/common/io/iwi/ipw2200_hw.c index 8a25125d53..65f27024b4 100644 --- a/usr/src/uts/common/io/iwi/ipw2200_hw.c +++ b/usr/src/uts/common/io/iwi/ipw2200_hw.c @@ -1,5 +1,5 @@ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -30,8 +30,6 @@ * SUCH DAMAGE. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Intel Wireless PRO/2200 mini-PCI adapter driver * ipw2200_hw.c is used t handle hardware operations and firmware operations. @@ -376,7 +374,7 @@ ipw2200_load_fw(struct ipw2200_softc *sc, uint8_t *buf, size_t size) uint32_t src, dst, ctl, len, sum, off; uint32_t sentinel; int ntries, err, cnt, i; - clock_t clk; + clock_t clk = drv_usectohz(5000000); /* 5 second */ ipw2200_imem_put32(sc, 0x3000a0, 0x27000); @@ -500,8 +498,8 @@ ipw2200_load_fw(struct ipw2200_softc *sc, uint8_t *buf, size_t size) /* * There is an enhancement! we just change from 1s to 5s */ - clk = ddi_get_lbolt() + drv_usectohz(5000000); /* 5 second */ - if (cv_timedwait(&sc->sc_fw_cond, &sc->sc_ilock, clk) < 0) + if (cv_reltimedwait(&sc->sc_fw_cond, &sc->sc_ilock, clk, + TR_CLOCK_TICK) < 0) break; } mutex_exit(&sc->sc_ilock); diff --git a/usr/src/uts/common/io/lvm/md/md_subr.c b/usr/src/uts/common/io/lvm/md/md_subr.c index 69ac3da188..5297c56dc5 100644 --- a/usr/src/uts/common/io/lvm/md/md_subr.c +++ b/usr/src/uts/common/io/lvm/md/md_subr.c @@ -1346,6 +1346,7 @@ callb_md_cpr(void *arg, int code) { callb_cpr_t *cp = (callb_cpr_t *)arg; int ret = 0; /* assume success */ + clock_t delta; mutex_enter(cp->cc_lockp); @@ -1368,10 +1369,11 @@ callb_md_cpr(void *arg, int code) mutex_exit(&md_cpr_resync.md_resync_mutex); cp->cc_events |= CALLB_CPR_START; + delta = CPR_KTHREAD_TIMEOUT_SEC * hz; while (!(cp->cc_events & CALLB_CPR_SAFE)) - /* cv_timedwait() returns -1 if it times out. */ - if ((ret = cv_timedwait(&cp->cc_callb_cv, cp->cc_lockp, - lbolt + CPR_KTHREAD_TIMEOUT_SEC * hz)) == -1) + /* cv_reltimedwait() returns -1 if it times out. */ + if ((ret = cv_reltimedwait(&cp->cc_callb_cv, + cp->cc_lockp, delta, TR_CLOCK_TICK)) == -1) break; break; @@ -4202,6 +4204,7 @@ callb_md_mrs_cpr(void *arg, int code) { callb_cpr_t *cp = (callb_cpr_t *)arg; int ret = 0; /* assume success */ + clock_t delta; mutex_enter(cp->cc_lockp); @@ -4214,10 +4217,11 @@ callb_md_mrs_cpr(void *arg, int code) */ md_mn_clear_commd_present(); cp->cc_events |= CALLB_CPR_START; + delta = CPR_KTHREAD_TIMEOUT_SEC * hz; while (!(cp->cc_events & CALLB_CPR_SAFE)) /* cv_timedwait() returns -1 if it times out. */ - if ((ret = cv_timedwait(&cp->cc_callb_cv, cp->cc_lockp, - lbolt + CPR_KTHREAD_TIMEOUT_SEC * hz)) == -1) + if ((ret = cv_reltimedwait(&cp->cc_callb_cv, + cp->cc_lockp, delta, TR_CLOCK_TICK)) == -1) break; break; diff --git a/usr/src/uts/common/io/lvm/raid/raid.c b/usr/src/uts/common/io/lvm/raid/raid.c index 22ae2f547c..2240e46aa9 100644 --- a/usr/src/uts/common/io/lvm/raid/raid.c +++ b/usr/src/uts/common/io/lvm/raid/raid.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -959,7 +959,8 @@ raid_build_incore(void *p, int snarfing) MD_RAID_COPY_RESYNC; else preserve_flags |= - MD_RAID_REGEN_RESYNC; + /* CSTYLED */ + MD_RAID_REGEN_RESYNC; } } } else { /* no hot spares */ @@ -3307,7 +3308,6 @@ raid_write(mr_unit_t *un, md_raidcs_t *cs) md_raidps_t *ps; mdi_unit_t *ui; minor_t mnum; - clock_t timeout; ASSERT(IO_READER_HELD(un)); ps = cs->cs_ps; @@ -3333,11 +3333,10 @@ raid_write(mr_unit_t *un, md_raidcs_t *cs) */ while (raid_check_pw(cs)) { mutex_enter(&un->un_mx); - (void) drv_getparm(LBOLT, &timeout); - timeout += md_wr_wait; un->un_rflags |= MD_RFLAG_NEEDPW; STAT_INC(raid_prewrite_waits); - (void) cv_timedwait(&un->un_cv, &un->un_mx, timeout); + (void) cv_reltimedwait(&un->un_cv, &un->un_mx, md_wr_wait, + TR_CLOCK_TICK); un->un_rflags &= ~MD_RFLAG_NEEDPW; mutex_exit(&un->un_mx); } diff --git a/usr/src/uts/common/io/mac/mac_sched.c b/usr/src/uts/common/io/mac/mac_sched.c index ff3cba81ed..b8ebe45a82 100644 --- a/usr/src/uts/common/io/mac/mac_sched.c +++ b/usr/src/uts/common/io/mac/mac_sched.c @@ -274,8 +274,9 @@ boolean_t mac_latency_optimize = B_TRUE; ASSERT(MUTEX_HELD(&(mac_srs)->srs_lock)); \ ASSERT(((mac_srs)->srs_type & SRST_TX) || \ MUTEX_HELD(&(mac_srs)->srs_bw->mac_bw_lock)); \ - if ((mac_srs)->srs_bw->mac_bw_curr_time != lbolt) { \ - (mac_srs)->srs_bw->mac_bw_curr_time = lbolt; \ + clock_t now = ddi_get_lbolt(); \ + if ((mac_srs)->srs_bw->mac_bw_curr_time != now) { \ + (mac_srs)->srs_bw->mac_bw_curr_time = now; \ (mac_srs)->srs_bw->mac_bw_used = 0; \ if ((mac_srs)->srs_bw->mac_bw_state & SRS_BW_ENFORCED) \ (mac_srs)->srs_bw->mac_bw_state &= ~SRS_BW_ENFORCED; \ @@ -1813,14 +1814,16 @@ mac_rx_srs_drain_bw(mac_soft_ring_set_t *mac_srs, uint_t proc_type) int cnt = 0; mac_client_impl_t *mcip = mac_srs->srs_mcip; mac_srs_rx_t *srs_rx = &mac_srs->srs_rx; + clock_t now; ASSERT(MUTEX_HELD(&mac_srs->srs_lock)); ASSERT(mac_srs->srs_type & SRST_BW_CONTROL); again: /* Check if we are doing B/W control */ mutex_enter(&mac_srs->srs_bw->mac_bw_lock); - if (mac_srs->srs_bw->mac_bw_curr_time != lbolt) { - mac_srs->srs_bw->mac_bw_curr_time = lbolt; + now = ddi_get_lbolt(); + if (mac_srs->srs_bw->mac_bw_curr_time != now) { + mac_srs->srs_bw->mac_bw_curr_time = now; mac_srs->srs_bw->mac_bw_used = 0; if (mac_srs->srs_bw->mac_bw_state & SRS_BW_ENFORCED) mac_srs->srs_bw->mac_bw_state &= ~SRS_BW_ENFORCED; @@ -2860,6 +2863,7 @@ mac_tx_bw_mode(mac_soft_ring_set_t *mac_srs, mblk_t *mp_chain, mblk_t *tail; mac_tx_cookie_t cookie = NULL; mac_srs_tx_t *srs_tx = &mac_srs->srs_tx; + clock_t now; ASSERT(TX_BANDWIDTH_MODE(mac_srs)); ASSERT(mac_srs->srs_type & SRST_BW_CONTROL); @@ -2886,8 +2890,9 @@ mac_tx_bw_mode(mac_soft_ring_set_t *mac_srs, mblk_t *mp_chain, return (cookie); } MAC_COUNT_CHAIN(mac_srs, mp_chain, tail, cnt, sz); - if (mac_srs->srs_bw->mac_bw_curr_time != lbolt) { - mac_srs->srs_bw->mac_bw_curr_time = lbolt; + now = ddi_get_lbolt(); + if (mac_srs->srs_bw->mac_bw_curr_time != now) { + mac_srs->srs_bw->mac_bw_curr_time = now; mac_srs->srs_bw->mac_bw_used = 0; } else if (mac_srs->srs_bw->mac_bw_used > mac_srs->srs_bw->mac_bw_limit) { @@ -2962,6 +2967,7 @@ mac_tx_srs_drain(mac_soft_ring_set_t *mac_srs, uint_t proc_type) boolean_t is_subflow; mac_tx_stats_t stats; mac_srs_tx_t *srs_tx = &mac_srs->srs_tx; + clock_t now; saved_pkt_count = 0; ASSERT(mutex_owned(&mac_srs->srs_lock)); @@ -3028,8 +3034,9 @@ mac_tx_srs_drain(mac_soft_ring_set_t *mac_srs, uint_t proc_type) mac_srs->srs_bw->mac_bw_limit) continue; - if (mac_srs->srs_bw->mac_bw_curr_time != lbolt) { - mac_srs->srs_bw->mac_bw_curr_time = lbolt; + now = ddi_get_lbolt(); + if (mac_srs->srs_bw->mac_bw_curr_time != now) { + mac_srs->srs_bw->mac_bw_curr_time = now; mac_srs->srs_bw->mac_bw_used = sz; continue; } @@ -3114,8 +3121,9 @@ mac_tx_srs_drain(mac_soft_ring_set_t *mac_srs, uint_t proc_type) mac_srs->srs_bw->mac_bw_limit) continue; - if (mac_srs->srs_bw->mac_bw_curr_time != lbolt) { - mac_srs->srs_bw->mac_bw_curr_time = lbolt; + now = ddi_get_lbolt(); + if (mac_srs->srs_bw->mac_bw_curr_time != now) { + mac_srs->srs_bw->mac_bw_curr_time = now; mac_srs->srs_bw->mac_bw_used = 0; continue; } diff --git a/usr/src/uts/common/io/mii/mii.c b/usr/src/uts/common/io/mii/mii.c index 2ce85886dc..5e95471f94 100644 --- a/usr/src/uts/common/io/mii/mii.c +++ b/usr/src/uts/common/io/mii/mii.c @@ -2139,9 +2139,8 @@ _mii_task(void *_mh) break; default: - (void) cv_timedwait(&mh->m_cv, &mh->m_lock, - ddi_get_lbolt() + drv_usectohz(wait)); - break; + (void) cv_reltimedwait(&mh->m_cv, &mh->m_lock, + drv_usectohz(wait), TR_CLOCK_TICK); } } diff --git a/usr/src/uts/common/io/mms/dmd/dmd.c b/usr/src/uts/common/io/mms/dmd/dmd.c index 30d38d7ad2..2b6db211b7 100644 --- a/usr/src/uts/common/io/mms/dmd/dmd.c +++ b/usr/src/uts/common/io/mms/dmd/dmd.c @@ -18,7 +18,7 @@ * * CDDL HEADER END * - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -3349,7 +3349,6 @@ dmd_signal_drm(dmd_drm_t *drm) drm_reply_t *rep = &drm->drm_shr_rep; int inst = drm->drm_inst; pid_t pid = drm->drm_cur_pid; - clock_t cur_ticks; clock_t to; int rc = 0; @@ -3399,13 +3398,14 @@ dmd_signal_drm(dmd_drm_t *drm) */ DMD_DEBUG((CE_CONT, "[%d:%d] Waiting for drive manager " "to get request\n", inst, pid)); + + /* Seconds to wait for DM */ + to = drv_usectohz(DMD_WAIT_DM_GET_SEC * 1000000); + while ((drm->drm_shr_flags & DRM_SHR_REQ_VALID) && (drm->drm_shr_flags & DRM_SHR_WAIT_RESUME)) { - cur_ticks = ddi_get_lbolt(); - to = cur_ticks + drv_usectohz(DMD_WAIT_DM_GET_SEC * 1000000); - /* Seconds to wait for DM */ - rc = cv_timedwait(&drm->drm_shr_res_cv, - &drm->drm_shr_mutex, to); + rc = cv_reltimedwait(&drm->drm_shr_res_cv, + &drm->drm_shr_mutex, to, TR_CLOCK_TICK); if (rc == -1) { /* timedout */ DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_signal_drm: " diff --git a/usr/src/uts/common/io/net80211/net80211_ioctl.c b/usr/src/uts/common/io/net80211/net80211_ioctl.c index f541e52902..93212719e3 100644 --- a/usr/src/uts/common/io/net80211/net80211_ioctl.c +++ b/usr/src/uts/common/io/net80211/net80211_ioctl.c @@ -686,11 +686,11 @@ static void wifi_wait_scan(struct ieee80211com *ic) { ieee80211_impl_t *im = ic->ic_private; + clock_t delta = drv_usectohz(WAIT_SCAN_MAX * 1000); while ((ic->ic_flags & (IEEE80211_F_SCAN | IEEE80211_F_ASCAN)) != 0) { - if (cv_timedwait_sig(&im->im_scan_cv, &ic->ic_genlock, - ddi_get_lbolt() + drv_usectohz(WAIT_SCAN_MAX * 1000)) != - 0) { + if (cv_reltimedwait_sig(&im->im_scan_cv, &ic->ic_genlock, + delta, TR_CLOCK_TICK) != 0) { break; } } diff --git a/usr/src/uts/common/io/nxge/nxge_mac.c b/usr/src/uts/common/io/nxge/nxge_mac.c index 8a8c8652ca..12e79eb97e 100644 --- a/usr/src/uts/common/io/nxge/nxge_mac.c +++ b/usr/src/uts/common/io/nxge/nxge_mac.c @@ -5469,11 +5469,9 @@ nxge_link_monitor(p_nxge_t nxgep, link_mon_enable_t enable) } nxgep->poll_state = LINK_MONITOR_STOPPING; - rv = cv_timedwait(&nxgep->poll_cv, - &nxgep->poll_lock, - ddi_get_lbolt() + + rv = cv_reltimedwait(&nxgep->poll_cv, &nxgep->poll_lock, drv_usectohz(LM_WAIT_MULTIPLIER * - LINK_MONITOR_PERIOD)); + LINK_MONITOR_PERIOD), TR_CLOCK_TICK); if (rv == -1) { NXGE_DEBUG_MSG((nxgep, MAC_CTL, "==> stopping port %d: " diff --git a/usr/src/uts/common/io/pciex/hotplug/pcishpc.c b/usr/src/uts/common/io/pciex/hotplug/pcishpc.c index cc92020517..272ea39a2d 100644 --- a/usr/src/uts/common/io/pciex/hotplug/pcishpc.c +++ b/usr/src/uts/common/io/pciex/hotplug/pcishpc.c @@ -1719,9 +1719,9 @@ pcishpc_attn_btn_handler(pcie_hp_slot_t *slot_p) PCIE_HP_LED_BLINK); /* wait for 5 seconds before taking any action */ - if (cv_timedwait(&slot_p->hs_attn_btn_cv, + if (cv_reltimedwait(&slot_p->hs_attn_btn_cv, &slot_p->hs_ctrl->hc_mutex, - ddi_get_lbolt() + SEC_TO_TICK(5)) == -1) { + SEC_TO_TICK(5), TR_CLOCK_TICK) == -1) { /* * It is a time out; * make sure the ATTN pending flag is diff --git a/usr/src/uts/common/io/rsm/rsm.c b/usr/src/uts/common/io/rsm/rsm.c index 70840c0c60..a9512f8da3 100644 --- a/usr/src/uts/common/io/rsm/rsm.c +++ b/usr/src/uts/common/io/rsm/rsm.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -3263,7 +3263,6 @@ rsm_unpublish(rsmseg_t *seg, int mode) rsm_access_entry_t *rsmpi_acl; int acl_len; int e; - clock_t ticks; adapter_t *adapter; DBG_DEFINE(category, RSM_KERNEL_AGENT | RSM_EXPORT); @@ -3377,10 +3376,9 @@ rsm_unpublish(rsmseg_t *seg, int mode) /* can be fine tuned when we have better numbers */ /* A long term fix would be to send cv_signal */ /* from the intr callback routine */ - (void) drv_getparm(LBOLT, &ticks); - ticks += drv_usectohz(1000); - /* currently nobody signals this wait */ - (void) cv_timedwait(&seg->s_cv, &seg->s_lock, ticks); + /* currently nobody signals this wait */ + (void) cv_reltimedwait(&seg->s_cv, &seg->s_lock, + drv_usectohz(1000), TR_CLOCK_TICK); DBG_PRINTF((category, RSM_ERR, "rsm_unpublish: SEG_IN_USE\n")); @@ -5294,7 +5292,6 @@ rsmipc_send(rsm_node_id_t dest, rsmipc_request_t *req, rsmipc_reply_t *reply) int credit_check = 0; int retry_cnt = 0; int min_retry_cnt = 10; - clock_t ticks; rsm_send_t is; rsmipc_slot_t *rslot; adapter_t *adapter; @@ -5646,10 +5643,8 @@ again: } /* wait for a reply signal, a SIGINT, or 5 sec. timeout */ - (void) drv_getparm(LBOLT, &ticks); - ticks += drv_usectohz(5000000); - e = cv_timedwait_sig(&rslot->rsmipc_cv, &rslot->rsmipc_lock, - ticks); + e = cv_reltimedwait_sig(&rslot->rsmipc_cv, &rslot->rsmipc_lock, + drv_usectohz(5000000), TR_CLOCK_TICK); if (e < 0) { /* timed out - retry */ e = RSMERR_TIMEOUT; @@ -5878,7 +5873,6 @@ rsmipc_send_controlmsg(path_t *path, int msgtype) int e; int retry_cnt = 0; int min_retry_cnt = 10; - clock_t timeout; adapter_t *adapter; rsm_send_t is; rsm_send_q_handle_t ipc_handle; @@ -5946,9 +5940,8 @@ rsmipc_send_controlmsg(path_t *path, int msgtype) "rsmipc_send_controlmsg:rsm_send error=%d", e)); if (++retry_cnt == min_retry_cnt) { /* backoff before retry */ - timeout = ddi_get_lbolt() + drv_usectohz(10000); - (void) cv_timedwait(&path->sendq_token.sendq_cv, - &path->mutex, timeout); + (void) cv_reltimedwait(&path->sendq_token.sendq_cv, + &path->mutex, drv_usectohz(10000), TR_CLOCK_TICK); retry_cnt = 0; } } while (path->state == RSMKA_PATH_ACTIVE); diff --git a/usr/src/uts/common/io/sata/adapters/nv_sata/nv_sata.c b/usr/src/uts/common/io/sata/adapters/nv_sata/nv_sata.c index fad9286e02..e597576cd3 100644 --- a/usr/src/uts/common/io/sata/adapters/nv_sata/nv_sata.c +++ b/usr/src/uts/common/io/sata/adapters/nv_sata/nv_sata.c @@ -6898,8 +6898,8 @@ nv_sgp_activity_led_ctl(void *arg) mutex_enter(&cmn->nvs_tlock); ticks = drv_usectohz(cmn->nvs_taskq_delay); if (ticks > 0) - (void) cv_timedwait(&cmn->nvs_cv, &cmn->nvs_tlock, - ddi_get_lbolt() + ticks); + (void) cv_reltimedwait(&cmn->nvs_cv, &cmn->nvs_tlock, + ticks, TR_CLOCK_TICK); mutex_exit(&cmn->nvs_tlock); } while (ticks > 0); } diff --git a/usr/src/uts/common/io/sata/impl/sata.c b/usr/src/uts/common/io/sata/impl/sata.c index eca21dde57..53af17ce53 100644 --- a/usr/src/uts/common/io/sata/impl/sata.c +++ b/usr/src/uts/common/io/sata/impl/sata.c @@ -16653,7 +16653,7 @@ sata_event_daemon(void *arg) _NOTE(ARGUNUSED(arg)) #endif sata_hba_inst_t *sata_hba_inst; - clock_t lbolt; + clock_t delta; SATADBG1(SATA_DBG_EVENTS_DAEMON, NULL, "SATA event daemon started\n", NULL); @@ -16715,11 +16715,11 @@ loop: * wait timeout. Exit if there is a termination request (driver * unload). */ + delta = drv_usectohz(SATA_EVNT_DAEMON_SLEEP_TIME); do { - lbolt = ddi_get_lbolt(); - lbolt += drv_usectohz(SATA_EVNT_DAEMON_SLEEP_TIME); mutex_enter(&sata_event_mutex); - (void) cv_timedwait(&sata_event_cv, &sata_event_mutex, lbolt); + (void) cv_reltimedwait(&sata_event_cv, &sata_event_mutex, + delta, TR_CLOCK_TICK); if (sata_event_thread_active != 0) { mutex_exit(&sata_event_mutex); diff --git a/usr/src/uts/common/io/scsi/adapters/iscsi/iscsi_login.c b/usr/src/uts/common/io/scsi/adapters/iscsi/iscsi_login.c index 5f821deb95..d0aa21bf86 100644 --- a/usr/src/uts/common/io/scsi/adapters/iscsi/iscsi_login.c +++ b/usr/src/uts/common/io/scsi/adapters/iscsi/iscsi_login.c @@ -2111,6 +2111,7 @@ iscsi_login_connect(iscsi_conn_t *icp) struct sockaddr *addr; idm_conn_req_t cr; idm_status_t rval; + clock_t lbolt; ASSERT(icp != NULL); isp = icp->conn_sess; diff --git a/usr/src/uts/common/io/scsi/adapters/iscsi/iscsi_thread.c b/usr/src/uts/common/io/scsi/adapters/iscsi/iscsi_thread.c index 976dca3ac9..6f99c98448 100644 --- a/usr/src/uts/common/io/scsi/adapters/iscsi/iscsi_thread.c +++ b/usr/src/uts/common/io/scsi/adapters/iscsi/iscsi_thread.c @@ -325,8 +325,8 @@ iscsi_thread_wait( if (timeout == -1) { cv_wait(&thread->sign.cdv, &thread->sign.mtx); } else { - rtn = cv_timedwait(&thread->sign.cdv, &thread->sign.mtx, - (ddi_get_lbolt() + timeout)); + rtn = cv_reltimedwait(&thread->sign.cdv, &thread->sign.mtx, + timeout, TR_CLOCK_TICK); } /* Check the signals. */ diff --git a/usr/src/uts/common/io/scsi/adapters/mpt_sas/mptsas_impl.c b/usr/src/uts/common/io/scsi/adapters/mpt_sas/mptsas_impl.c index b0e2c4891d..5b32a808bc 100644 --- a/usr/src/uts/common/io/scsi/adapters/mpt_sas/mptsas_impl.c +++ b/usr/src/uts/common/io/scsi/adapters/mpt_sas/mptsas_impl.c @@ -1315,8 +1315,8 @@ mptsas_update_flash(mptsas_t *mpt, caddr_t ptrbuffer, uint32_t size, MPTSAS_START_CMD(mpt, request_desc_low, 0); rvalue = 0; - (void) cv_timedwait(&mpt->m_fw_cv, &mpt->m_mutex, - MPTSAS_CV_TIMEOUT(60)); + (void) cv_reltimedwait(&mpt->m_fw_cv, &mpt->m_mutex, + drv_usectohz(60 * MICROSEC), TR_CLOCK_TICK); if (!(cmd->cmd_flags & CFLAG_FINISHED)) { if ((mptsas_restart_ioc(mpt)) == DDI_FAILURE) { mptsas_log(mpt, CE_WARN, "mptsas_restart_ioc failed"); diff --git a/usr/src/uts/common/io/scsi/adapters/scsi_vhci/scsi_vhci.c b/usr/src/uts/common/io/scsi/adapters/scsi_vhci/scsi_vhci.c index a942c35993..9e8be4b259 100644 --- a/usr/src/uts/common/io/scsi/adapters/scsi_vhci/scsi_vhci.c +++ b/usr/src/uts/common/io/scsi/adapters/scsi_vhci/scsi_vhci.c @@ -5182,9 +5182,9 @@ vhci_pathinfo_offline(dev_info_t *vdip, mdi_pathinfo_t *pip, int flags) VHCI_DEBUG(1, (CE_NOTE, vdip, "!vhci_pathinfo_offline: " "%d cmds pending on path: 0x%p\n", svp->svp_cmds, (void *)pip)); while (svp->svp_cmds != 0) { - if (cv_timedwait(&svp->svp_cv, &svp->svp_mutex, - ddi_get_lbolt() + - drv_usectohz(vhci_path_quiesce_timeout * 1000000)) == -1) { + if (cv_reltimedwait(&svp->svp_cv, &svp->svp_mutex, + drv_usectohz(vhci_path_quiesce_timeout * 1000000), + TR_CLOCK_TICK) == -1) { /* * The timeout time reached without the condition * being signaled. @@ -7369,9 +7369,9 @@ vhci_quiesce_lun(struct scsi_vhci_lun *vlun) svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); mutex_enter(&svp->svp_mutex); while (svp->svp_cmds != 0) { - if (cv_timedwait(&svp->svp_cv, &svp->svp_mutex, - ddi_get_lbolt() + drv_usectohz - (vhci_path_quiesce_timeout * 1000000)) == -1) { + if (cv_reltimedwait(&svp->svp_cv, &svp->svp_mutex, + drv_usectohz(vhci_path_quiesce_timeout * 1000000), + TR_CLOCK_TICK) == -1) { mutex_exit(&svp->svp_mutex); mdi_rele_path(pip); VHCI_DEBUG(1, (CE_WARN, NULL, diff --git a/usr/src/uts/common/io/scsi/impl/scsi_watch.c b/usr/src/uts/common/io/scsi/impl/scsi_watch.c index 7a0ad8aed0..9cc8b6e3a2 100644 --- a/usr/src/uts/common/io/scsi/impl/scsi_watch.c +++ b/usr/src/uts/common/io/scsi/impl/scsi_watch.c @@ -426,7 +426,6 @@ void scsi_watch_suspend(opaque_t token) { struct scsi_watch_request *swr = (struct scsi_watch_request *)NULL; - clock_t now; clock_t halfsec_delay = drv_usectohz(500000); SW_DEBUG(0, sw_label, SCSI_DEBUG, "scsi_watch_suspend:\n"); @@ -454,9 +453,8 @@ scsi_watch_suspend(opaque_t token) * till all outstanding cmds are complete */ swr->swr_what = SWR_SUSPEND_REQUESTED; - now = ddi_get_lbolt(); - (void) cv_timedwait(&sw.sw_cv, &sw.sw_mutex, - now + halfsec_delay); + (void) cv_reltimedwait(&sw.sw_cv, &sw.sw_mutex, + halfsec_delay, TR_CLOCK_TICK); } else { swr->swr_what = SWR_SUSPENDED; break; @@ -656,7 +654,6 @@ static void scsi_watch_thread() { struct scsi_watch_request *swr, *next; - clock_t now; clock_t last_delay = 0; clock_t next_delay = 0; clock_t onesec = drv_usectohz(1000000); @@ -819,7 +816,6 @@ head: } else { next_delay = exit_delay; } - now = ddi_get_lbolt(); mutex_enter(&cpr_mutex); if (!sw_cmd_count) { @@ -832,7 +828,8 @@ head: * signalled, the delay is not accurate but that doesn't * really matter */ - (void) cv_timedwait(&sw.sw_cv, &sw.sw_mutex, now + next_delay); + (void) cv_reltimedwait(&sw.sw_cv, &sw.sw_mutex, next_delay, + TR_CLOCK_TICK); mutex_exit(&sw.sw_mutex); mutex_enter(&cpr_mutex); if (sw_cpr_flag == 1) { diff --git a/usr/src/uts/common/io/sdcard/impl/sda_slot.c b/usr/src/uts/common/io/sdcard/impl/sda_slot.c index 0e908ecd26..8de0539039 100644 --- a/usr/src/uts/common/io/sdcard/impl/sda_slot.c +++ b/usr/src/uts/common/io/sdcard/impl/sda_slot.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -718,9 +718,9 @@ sda_slot_thread(void *arg) if ((slot->s_xfrp != NULL) || (slot->s_reap)) { /* Wait 3 sec (reap attempts). */ - (void) cv_timedwait(&slot->s_evcv, - &slot->s_evlock, - ddi_get_lbolt() + drv_usectohz(3000000)); + (void) cv_reltimedwait(&slot->s_evcv, + &slot->s_evlock, drv_usectohz(3000000), + TR_CLOCK_TICK); } else { (void) cv_wait(&slot->s_evcv, &slot->s_evlock); } diff --git a/usr/src/uts/common/io/softmac/softmac_pkt.c b/usr/src/uts/common/io/softmac/softmac_pkt.c index 01b8f70abc..4641fb3372 100644 --- a/usr/src/uts/common/io/softmac/softmac_pkt.c +++ b/usr/src/uts/common/io/softmac/softmac_pkt.c @@ -122,8 +122,8 @@ softmac_output(softmac_lower_t *slp, mblk_t *mp, t_uscalar_t dl_prim, mutex_enter(&slp->sl_mutex); while (slp->sl_pending_prim != DL_PRIM_INVAL) { - if (cv_timedwait(&slp->sl_cv, &slp->sl_mutex, - lbolt + ACKTIMEOUT) == -1) + if (cv_reltimedwait(&slp->sl_cv, &slp->sl_mutex, ACKTIMEOUT, + TR_CLOCK_TICK) == -1) break; } diff --git a/usr/src/uts/common/io/usb/hcd/ehci/ehci_isoch.c b/usr/src/uts/common/io/usb/hcd/ehci/ehci_isoch.c index e9c517300c..d1e85fe9b9 100644 --- a/usr/src/uts/common/io/usb/hcd/ehci/ehci_isoch.c +++ b/usr/src/uts/common/io/usb/hcd/ehci/ehci_isoch.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -266,8 +266,6 @@ ehci_wait_for_isoc_completion( ehci_state_t *ehcip, ehci_pipe_private_t *pp) { - clock_t xfer_cmpl_time_wait; - ASSERT(mutex_owned(&ehcip->ehci_int_mutex)); if (pp->pp_itw_head == NULL) { @@ -275,12 +273,8 @@ ehci_wait_for_isoc_completion( return; } - /* Get the number of clock ticks to wait */ - xfer_cmpl_time_wait = drv_usectohz(EHCI_XFER_CMPL_TIMEWAIT * 1000000); - - (void) cv_timedwait(&pp->pp_xfer_cmpl_cv, - &ehcip->ehci_int_mutex, - ddi_get_lbolt() + xfer_cmpl_time_wait); + (void) cv_reltimedwait(&pp->pp_xfer_cmpl_cv, &ehcip->ehci_int_mutex, + drv_usectohz(EHCI_XFER_CMPL_TIMEWAIT * 1000000), TR_CLOCK_TICK); if (pp->pp_itw_head) { USB_DPRINTF_L2(PRINT_MASK_LISTS, ehcip->ehci_log_hdl, diff --git a/usr/src/uts/common/io/usb/hcd/ehci/ehci_util.c b/usr/src/uts/common/io/usb/hcd/ehci/ehci_util.c index dc413417f2..76f333ccf6 100644 --- a/usr/src/uts/common/io/usb/hcd/ehci/ehci_util.c +++ b/usr/src/uts/common/io/usb/hcd/ehci/ehci_util.c @@ -1197,8 +1197,8 @@ ehci_init_check_status(ehci_state_t *ehcip) ehcip->ehci_flags |= EHCI_CV_INTR; /* We need to add a delay to allow the chip time to start running */ - (void) cv_timedwait(&ehcip->ehci_async_schedule_advance_cv, - &ehcip->ehci_int_mutex, ddi_get_lbolt() + sof_time_wait); + (void) cv_reltimedwait(&ehcip->ehci_async_schedule_advance_cv, + &ehcip->ehci_int_mutex, sof_time_wait, TR_CLOCK_TICK); /* * Check EHCI host controller is running, otherwise return failure. diff --git a/usr/src/uts/common/io/usb/hcd/ehci/ehci_xfer.c b/usr/src/uts/common/io/usb/hcd/ehci/ehci_xfer.c index d956029c61..a6afec8afd 100644 --- a/usr/src/uts/common/io/usb/hcd/ehci/ehci_xfer.c +++ b/usr/src/uts/common/io/usb/hcd/ehci/ehci_xfer.c @@ -3734,7 +3734,6 @@ ehci_wait_for_transfers_completion( ehci_pipe_private_t *pp) { ehci_trans_wrapper_t *next_tw = pp->pp_tw_head; - clock_t xfer_cmpl_time_wait; ehci_qtd_t *qtd; USB_DPRINTF_L4(PRINT_MASK_LISTS, @@ -3781,12 +3780,8 @@ ehci_wait_for_transfers_completion( return; } - /* Get the number of clock ticks to wait */ - xfer_cmpl_time_wait = drv_usectohz(EHCI_XFER_CMPL_TIMEWAIT * 1000000); - - (void) cv_timedwait(&pp->pp_xfer_cmpl_cv, - &ehcip->ehci_int_mutex, - ddi_get_lbolt() + xfer_cmpl_time_wait); + (void) cv_reltimedwait(&pp->pp_xfer_cmpl_cv, &ehcip->ehci_int_mutex, + drv_usectohz(EHCI_XFER_CMPL_TIMEWAIT * 1000000), TR_CLOCK_TICK); if (pp->pp_count_done_qtds) { diff --git a/usr/src/uts/common/io/usb/hcd/openhci/ohci.c b/usr/src/uts/common/io/usb/hcd/openhci/ohci.c index 8f5a21c573..b181fbb2c2 100644 --- a/usr/src/uts/common/io/usb/hcd/openhci/ohci.c +++ b/usr/src/uts/common/io/usb/hcd/openhci/ohci.c @@ -1687,8 +1687,8 @@ ohci_init_ctlr(ohci_state_t *ohcip) ASSERT(Get_OpReg(hcr_intr_enable) & HCR_INTR_SOF); - (void) cv_timedwait(&ohcip->ohci_SOF_cv, - &ohcip->ohci_int_mutex, ddi_get_lbolt() + sof_time_wait); + (void) cv_reltimedwait(&ohcip->ohci_SOF_cv, + &ohcip->ohci_int_mutex, sof_time_wait, TR_CLOCK_TICK); /* Wait for the SOF or timeout event */ if (ohcip->ohci_sof_flag == B_FALSE) { @@ -10221,8 +10221,8 @@ ohci_wait_for_sof(ohci_state_t *ohcip) ASSERT(Get_OpReg(hcr_intr_enable) & HCR_INTR_SOF); /* Wait for the SOF or timeout event */ - rval = cv_timedwait(&ohcip->ohci_SOF_cv, - &ohcip->ohci_int_mutex, ddi_get_lbolt() + sof_time_wait); + rval = cv_reltimedwait(&ohcip->ohci_SOF_cv, + &ohcip->ohci_int_mutex, sof_time_wait, TR_CLOCK_TICK); /* * Get the current usb frame number after woken up either @@ -10412,7 +10412,6 @@ ohci_wait_for_transfers_completion( { ohci_trans_wrapper_t *head_tw = pp->pp_tw_head; ohci_trans_wrapper_t *next_tw; - clock_t xfer_cmpl_time_wait; ohci_td_t *tailp, *headp, *nextp; ohci_td_t *head_td, *next_td; ohci_ed_t *ept = pp->pp_ept; @@ -10488,12 +10487,8 @@ ohci_wait_for_transfers_completion( return; } - /* Get the number of clock ticks to wait */ - xfer_cmpl_time_wait = drv_usectohz(OHCI_XFER_CMPL_TIMEWAIT * 1000000); - - (void) cv_timedwait(&pp->pp_xfer_cmpl_cv, - &ohcip->ohci_int_mutex, - ddi_get_lbolt() + xfer_cmpl_time_wait); + (void) cv_reltimedwait(&pp->pp_xfer_cmpl_cv, &ohcip->ohci_int_mutex, + drv_usectohz(OHCI_XFER_CMPL_TIMEWAIT * 1000000), TR_CLOCK_TICK); if (pp->pp_count_done_tds) { diff --git a/usr/src/uts/common/io/usb/hcd/uhci/uhciutil.c b/usr/src/uts/common/io/usb/hcd/uhci/uhciutil.c index 27b4048506..9ba005f05b 100644 --- a/usr/src/uts/common/io/usb/hcd/uhci/uhciutil.c +++ b/usr/src/uts/common/io/usb/hcd/uhci/uhciutil.c @@ -4750,7 +4750,7 @@ uhci_wait_for_sof(uhci_state_t *uhcip) int n, error; ushort_t cmd_reg; usb_frame_number_t before_frame_number, after_frame_number; - clock_t time, rval; + clock_t rval; USB_DPRINTF_L4(PRINT_MASK_LISTS, uhcip->uhci_log_hdl, "uhci_wait_for_sof: uhcip = %p", (void *)uhcip); @@ -4768,9 +4768,8 @@ uhci_wait_for_sof(uhci_state_t *uhcip) SetTD_ioc(uhcip, uhcip->uhci_sof_td, 1); uhcip->uhci_cv_signal = B_TRUE; - time = ddi_get_lbolt() + UHCI_ONE_SECOND; - rval = cv_timedwait(&uhcip->uhci_cv_SOF, - &uhcip->uhci_int_mutex, time); + rval = cv_reltimedwait(&uhcip->uhci_cv_SOF, + &uhcip->uhci_int_mutex, UHCI_ONE_SECOND, TR_CLOCK_TICK); after_frame_number = uhci_get_sw_frame_number(uhcip); if ((rval == -1) && diff --git a/usr/src/uts/common/io/usb/hwa/hwahc/hwahc_util.c b/usr/src/uts/common/io/usb/hwa/hwahc/hwahc_util.c index 318faae8d8..65d828afeb 100644 --- a/usr/src/uts/common/io/usb/hwa/hwahc/hwahc_util.c +++ b/usr/src/uts/common/io/usb/hwa/hwahc/hwahc_util.c @@ -159,7 +159,6 @@ static void hwahc_wait_for_xfer_completion(hwahc_state_t *hwahcp, hwahc_pipe_private_t *pp) { wusb_wa_rpipe_hdl_t *hdl = pp->pp_rp; - clock_t xfer_cmpl_time_wait; mutex_enter(&hdl->rp_mutex); if (hdl->rp_state != WA_RPIPE_STATE_ACTIVE) { @@ -170,9 +169,8 @@ hwahc_wait_for_xfer_completion(hwahc_state_t *hwahcp, hwahc_pipe_private_t *pp) mutex_exit(&hdl->rp_mutex); /* wait 3s */ - xfer_cmpl_time_wait = drv_usectohz(3000000); - (void) cv_timedwait(&pp->pp_xfer_cmpl_cv, &hwahcp->hwahc_mutex, - ddi_get_lbolt() + xfer_cmpl_time_wait); + (void) cv_reltimedwait(&pp->pp_xfer_cmpl_cv, &hwahcp->hwahc_mutex, + drv_usectohz(3000000), TR_CLOCK_TICK); mutex_enter(&hdl->rp_mutex); if (hdl->rp_state == WA_RPIPE_STATE_ACTIVE) { diff --git a/usr/src/uts/common/io/usb/usba/hubdi.c b/usr/src/uts/common/io/usb/usba/hubdi.c index a9cf1e714f..8a04aca273 100644 --- a/usr/src/uts/common/io/usb/usba/hubdi.c +++ b/usr/src/uts/common/io/usb/usba/hubdi.c @@ -4609,7 +4609,7 @@ hubd_reset_port(hubd_t *hubd, usb_port_t port) uint16_t status; uint16_t change; int i; - clock_t current_time; + clock_t delta; USB_DPRINTF_L4(DPRINT_MASK_PORT, hubd->h_log_handle, "hubd_reset_port: port=%d", port); @@ -4646,6 +4646,7 @@ hubd_reset_port(hubd_t *hubd, usb_port_t port) /* * wait for port status change event */ + delta = drv_usectohz(hubd_device_delay / 10); for (i = 0; i < hubd_retry_enumerate; i++) { /* * start polling ep1 for receiving notification on @@ -4657,12 +4658,9 @@ hubd_reset_port(hubd_t *hubd, usb_port_t port) * sleep a max of 100ms for reset completion * notification to be received */ - current_time = ddi_get_lbolt(); if (hubd->h_port_reset_wait & port_mask) { - rval = cv_timedwait(&hubd->h_cv_reset_port, - &hubd->h_mutex, - current_time + - drv_usectohz(hubd_device_delay / 10)); + rval = cv_reltimedwait(&hubd->h_cv_reset_port, + &hubd->h_mutex, delta, TR_CLOCK_TICK); if ((rval <= 0) && (hubd->h_port_reset_wait & port_mask)) { /* we got woken up because of a timeout */ @@ -8606,7 +8604,7 @@ usba_hubdi_decr_power_budget(dev_info_t *dip, usba_device_t *child_ud) static int hubd_wait_for_hotplug_exit(hubd_t *hubd) { - clock_t until = ddi_get_lbolt() + drv_usectohz(1000000); + clock_t until = drv_usectohz(1000000); int rval; ASSERT(mutex_owned(HUBD_MUTEX(hubd))); @@ -8614,8 +8612,8 @@ hubd_wait_for_hotplug_exit(hubd_t *hubd) if (hubd->h_hotplug_thread) { USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, "waiting for hubd hotplug thread exit"); - rval = cv_timedwait(&hubd->h_cv_hotplug_dev, - &hubd->h_mutex, until); + rval = cv_reltimedwait(&hubd->h_cv_hotplug_dev, + &hubd->h_mutex, until, TR_CLOCK_TICK); if ((rval <= 0) && (hubd->h_hotplug_thread)) { diff --git a/usr/src/uts/common/io/usb/usba/wa.c b/usr/src/uts/common/io/usb/usba/wa.c index 535f67f2c2..24da7f7ced 100644 --- a/usr/src/uts/common/io/usb/usba/wa.c +++ b/usr/src/uts/common/io/usb/usba/wa.c @@ -2432,8 +2432,8 @@ wusb_wa_xfer_timeout_handler(void *arg) * aborted, wait it. */ if ((wr->wr_has_aborted == 0) && - (cv_timedwait(&wr->wr_cv, &hdl->rp_mutex, - ddi_get_lbolt() + drv_usectohz(100 * 1000)) + (cv_reltimedwait(&wr->wr_cv, &hdl->rp_mutex, + drv_usectohz(100 * 1000), TR_CLOCK_TICK) >= 0)) { /* 100ms, random number, long enough? */ diff --git a/usr/src/uts/common/io/vscan/vscan_door.c b/usr/src/uts/common/io/vscan/vscan_door.c index 674a61f382..efd5ca083d 100644 --- a/usr/src/uts/common/io/vscan/vscan_door.c +++ b/usr/src/uts/common/io/vscan/vscan_door.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -105,9 +105,9 @@ vscan_door_close(void) /* wait for any in-progress requests to complete */ time_left = SEC_TO_TICK(vs_door_close_timeout); while ((vscan_door_call_count > 0) && (time_left > 0)) { - timeout = lbolt + time_left; - time_left = cv_timedwait(&vscan_door_cv, - &vscan_door_mutex, timeout); + timeout = time_left; + time_left = cv_reltimedwait(&vscan_door_cv, &vscan_door_mutex, + timeout, TR_CLOCK_TICK); } if (time_left == -1) diff --git a/usr/src/uts/common/io/vscan/vscan_drv.c b/usr/src/uts/common/io/vscan/vscan_drv.c index 989c835d83..6247eea5f7 100644 --- a/usr/src/uts/common/io/vscan/vscan_drv.c +++ b/usr/src/uts/common/io/vscan/vscan_drv.c @@ -20,11 +20,10 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ - #include <sys/stat.h> #include <sys/ddi.h> #include <sys/sunddi.h> @@ -519,10 +518,9 @@ vscan_drv_close(dev_t dev, int flag, int otyp, cred_t *credp) static void vscan_drv_delayed_disable(void) { - clock_t timeout = lbolt + SEC_TO_TICK(vs_reconnect_timeout); - mutex_enter(&vscan_drv_mutex); - (void) cv_timedwait(&vscan_drv_cv, &vscan_drv_mutex, timeout); + (void) cv_reltimedwait(&vscan_drv_cv, &vscan_drv_mutex, + SEC_TO_TICK(vs_reconnect_timeout), TR_CLOCK_TICK); if (vscan_drv_state == VS_DRV_DELAYED_DISABLE) { vscan_svc_disable(); diff --git a/usr/src/uts/common/io/vscan/vscan_svc.c b/usr/src/uts/common/io/vscan/vscan_svc.c index bb07530321..e26fa9e292 100644 --- a/usr/src/uts/common/io/vscan/vscan_svc.c +++ b/usr/src/uts/common/io/vscan/vscan_svc.c @@ -20,12 +20,10 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/stat.h> #include <sys/ddi.h> #include <sys/sunddi.h> @@ -502,9 +500,9 @@ vscan_svc_scan_file(vnode_t *vp, cred_t *cr, int async) ++(req->vsr_refcnt); time_left = SEC_TO_TICK(vs_scan_wait); while ((time_left > 0) && (req->vsr_state != VS_SVC_REQ_COMPLETE)) { - timeout = lbolt + time_left; - time_left = cv_timedwait_sig(&(req->vsr_cv), - &vscan_svc_mutex, timeout); + timeout = time_left; + time_left = cv_reltimedwait_sig(&(req->vsr_cv), + &vscan_svc_mutex, timeout, TR_CLOCK_TICK); } if (time_left == -1) { @@ -589,8 +587,8 @@ vscan_svc_reql_handler(void) DTRACE_PROBE2(vscan__req__counts, char *, "handler wait", vscan_svc_counts_t *, &vscan_svc_counts); - (void) cv_timedwait(&vscan_svc_reql_cv, &vscan_svc_mutex, - lbolt + SEC_TO_TICK(VS_REQL_HANDLER_TIMEOUT)); + (void) cv_reltimedwait(&vscan_svc_reql_cv, &vscan_svc_mutex, + SEC_TO_TICK(VS_REQL_HANDLER_TIMEOUT), TR_CLOCK_TICK); DTRACE_PROBE2(vscan__req__counts, char *, "handler wake", vscan_svc_counts_t *, &vscan_svc_counts); diff --git a/usr/src/uts/common/io/winlockio.c b/usr/src/uts/common/io/winlockio.c index 454bd0f60e..67ff79046a 100644 --- a/usr/src/uts/common/io/winlockio.c +++ b/usr/src/uts/common/io/winlockio.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -1402,8 +1402,8 @@ seglock_lockfault(devmap_cookie_t dhp, SegProc *sdp, SegLock *lp, uint_t rw) * locksleep cv and thus kick the other timed waiters * and cause everyone to restart in a new timedwait */ - rval = cv_timedwait_sig(&lp->locksleep, - &lp->mutex, ddi_get_lbolt() + lp->timeout); + rval = cv_reltimedwait_sig(&lp->locksleep, + &lp->mutex, lp->timeout, TR_CLOCK_TICK); } /* |