Print this page
XXXX introduce drv_sectohz


 453         if (error != 0) {
 454                 return (error);
 455         }
 456 
 457         mutex_init(&si_log_mutex, NULL, MUTEX_DRIVER, NULL);
 458 
 459         if ((error = sata_hba_init(&modlinkage)) != 0) {
 460                 mutex_destroy(&si_log_mutex);
 461                 ddi_soft_state_fini(&si_statep);
 462                 return (error);
 463         }
 464 
 465         error = mod_install(&modlinkage);
 466         if (error != 0) {
 467                 sata_hba_fini(&modlinkage);
 468                 mutex_destroy(&si_log_mutex);
 469                 ddi_soft_state_fini(&si_statep);
 470                 return (error);
 471         }
 472 
 473         si_watchdog_tick = drv_usectohz((clock_t)si_watchdog_timeout * 1000000);
 474 
 475         return (error);
 476 }
 477 
 478 /*
 479  * si3124 module uninitialize.
 480  *
 481  */
 482 int
 483 _fini(void)
 484 {
 485         int     error;
 486 
 487         error = mod_remove(&modlinkage);
 488         if (error != 0) {
 489                 return (error);
 490         }
 491 
 492         /* Remove the resources allocated in _init(). */
 493         sata_hba_fini(&modlinkage);


2326 
2327 /*
2328  * Polls for the completion of the command. This is safe with both
2329  * interrupts enabled or disabled.
2330  */
2331 static void
2332 si_poll_cmd(
2333         si_ctl_state_t *si_ctlp,
2334         si_port_state_t *si_portp,
2335         int port,
2336         int slot,
2337         sata_pkt_t *satapkt)
2338 {
2339         uint32_t slot_status;
2340         int pkt_timeout_ticks;
2341         uint32_t port_intr_status;
2342         int in_panic = ddi_in_panic();
2343 
2344         SIDBG_P(SIDBG_ENTRY, si_portp, "si_poll_cmd entered: port: 0x%x", port);
2345 
2346         pkt_timeout_ticks = drv_usectohz((clock_t)satapkt->satapkt_time *
2347             1000000);
2348 
2349 
2350         /* we start out with SATA_PKT_COMPLETED as the satapkt_reason */
2351         satapkt->satapkt_reason = SATA_PKT_COMPLETED;
2352 
2353         do {
2354                 slot_status = ddi_get32(si_ctlp->sictl_port_acc_handle,
2355                     (uint32_t *)(PORT_SLOT_STATUS(si_ctlp, port)));
2356 
2357                 if (slot_status & SI_SLOT_MASK & (0x1 << slot)) {
2358                         if (in_panic) {
2359                                 /*
2360                                  * If we are in panic, we can't rely on
2361                                  * timers; so, busy wait instead of delay().
2362                                  */
2363                                 mutex_exit(&si_portp->siport_mutex);
2364                                 drv_usecwait(SI_1MS_USECS);
2365                                 mutex_enter(&si_portp->siport_mutex);
2366                         } else {
2367                                 mutex_exit(&si_portp->siport_mutex);




 453         if (error != 0) {
 454                 return (error);
 455         }
 456 
 457         mutex_init(&si_log_mutex, NULL, MUTEX_DRIVER, NULL);
 458 
 459         if ((error = sata_hba_init(&modlinkage)) != 0) {
 460                 mutex_destroy(&si_log_mutex);
 461                 ddi_soft_state_fini(&si_statep);
 462                 return (error);
 463         }
 464 
 465         error = mod_install(&modlinkage);
 466         if (error != 0) {
 467                 sata_hba_fini(&modlinkage);
 468                 mutex_destroy(&si_log_mutex);
 469                 ddi_soft_state_fini(&si_statep);
 470                 return (error);
 471         }
 472 
 473         si_watchdog_tick = drv_sectohz((clock_t)si_watchdog_timeout);
 474 
 475         return (error);
 476 }
 477 
 478 /*
 479  * si3124 module uninitialize.
 480  *
 481  */
 482 int
 483 _fini(void)
 484 {
 485         int     error;
 486 
 487         error = mod_remove(&modlinkage);
 488         if (error != 0) {
 489                 return (error);
 490         }
 491 
 492         /* Remove the resources allocated in _init(). */
 493         sata_hba_fini(&modlinkage);


2326 
2327 /*
2328  * Polls for the completion of the command. This is safe with both
2329  * interrupts enabled or disabled.
2330  */
2331 static void
2332 si_poll_cmd(
2333         si_ctl_state_t *si_ctlp,
2334         si_port_state_t *si_portp,
2335         int port,
2336         int slot,
2337         sata_pkt_t *satapkt)
2338 {
2339         uint32_t slot_status;
2340         int pkt_timeout_ticks;
2341         uint32_t port_intr_status;
2342         int in_panic = ddi_in_panic();
2343 
2344         SIDBG_P(SIDBG_ENTRY, si_portp, "si_poll_cmd entered: port: 0x%x", port);
2345 
2346         pkt_timeout_ticks = drv_sectohz((clock_t)satapkt->satapkt_time);

2347 
2348 
2349         /* we start out with SATA_PKT_COMPLETED as the satapkt_reason */
2350         satapkt->satapkt_reason = SATA_PKT_COMPLETED;
2351 
2352         do {
2353                 slot_status = ddi_get32(si_ctlp->sictl_port_acc_handle,
2354                     (uint32_t *)(PORT_SLOT_STATUS(si_ctlp, port)));
2355 
2356                 if (slot_status & SI_SLOT_MASK & (0x1 << slot)) {
2357                         if (in_panic) {
2358                                 /*
2359                                  * If we are in panic, we can't rely on
2360                                  * timers; so, busy wait instead of delay().
2361                                  */
2362                                 mutex_exit(&si_portp->siport_mutex);
2363                                 drv_usecwait(SI_1MS_USECS);
2364                                 mutex_enter(&si_portp->siport_mutex);
2365                         } else {
2366                                 mutex_exit(&si_portp->siport_mutex);