Print this page
XXXX introduce drv_sectohz


3184         int try;
3185         int res = DDI_SUCCESS;
3186 
3187         mutex_enter(&ssp->task_mu);
3188 
3189         /* Wait for task daemon to stop running. */
3190         for (try = 0;
3191             ((ssp->task_flags & TASK_ALIVE_FLG) && try < 10);
3192             try++) {
3193                 /* Signal that the task daemon should stop */
3194                 ssp->task_flags |= TASK_STOP_FLG;
3195                 cv_signal(&ssp->task_cv);
3196                 /* Release task daemon lock. */
3197                 mutex_exit(&ssp->task_mu);
3198                 /*
3199                  * TODO - when the driver is modified to support
3200                  * system suspend or if this routine gets called
3201                  * during panic we should use drv_usecwait() rather
3202                  * than delay in those circumstances.
3203                  */
3204                 delay(drv_usectohz(1000000));
3205                 mutex_enter(&ssp->task_mu);
3206         }
3207 
3208         if (ssp->task_flags & TASK_ALIVE_FLG) {
3209                 res = DDI_FAILURE;
3210         }
3211         mutex_exit(&ssp->task_mu);
3212 
3213         return (res);
3214 }
3215 
3216 /*
3217  * function     - bscv_pause_event_daemon
3218  * description  - Attempt to pause the event daemon thread.
3219  * inputs       - LOM soft state structure pointer
3220  * outputs      - DDI_SUCCESS OR DDI_FAILURE
3221  */
3222 static int
3223 bscv_pause_event_daemon(bscv_soft_state_t *ssp)
3224 {


3230         }
3231 
3232         BSCV_TRACE(ssp, 'D', "bscv_pause_event_daemon",
3233             "Attempting to pause event daemon");
3234 
3235         mutex_enter(&ssp->task_mu);
3236         /* Signal that the task daemon should pause */
3237         ssp->task_flags |= TASK_PAUSE_FLG;
3238 
3239         /* Wait for task daemon to pause. */
3240         for (try = 0;
3241             (!(ssp->task_flags & TASK_SLEEPING_FLG) &&
3242             (ssp->task_flags & TASK_ALIVE_FLG) &&
3243             try < 10);
3244             try++) {
3245                 /* Paranoia */
3246                 ssp->task_flags |= TASK_PAUSE_FLG;
3247                 cv_signal(&ssp->task_cv);
3248                 /* Release task daemon lock. */
3249                 mutex_exit(&ssp->task_mu);
3250                 delay(drv_usectohz(1000000));
3251                 mutex_enter(&ssp->task_mu);
3252         }
3253         if ((ssp->task_flags & TASK_SLEEPING_FLG) ||
3254             !(ssp->task_flags & TASK_ALIVE_FLG)) {
3255                 mutex_exit(&ssp->task_mu);
3256                 BSCV_TRACE(ssp, 'D', "bscv_pause_event_daemon",
3257                     "Pause event daemon - success");
3258                 return (BSCV_SUCCESS);
3259         }
3260         mutex_exit(&ssp->task_mu);
3261         BSCV_TRACE(ssp, 'D', "bscv_pause_event_daemon",
3262             "Pause event daemon - failed");
3263         return (BSCV_FAILURE);
3264 }
3265 
3266 /*
3267  * function     - bscv_resume_event_daemon
3268  * description  - Resumethe event daemon thread.
3269  * inputs       - LOM soft state structure pointer
3270  * outputs      - None.




3184         int try;
3185         int res = DDI_SUCCESS;
3186 
3187         mutex_enter(&ssp->task_mu);
3188 
3189         /* Wait for task daemon to stop running. */
3190         for (try = 0;
3191             ((ssp->task_flags & TASK_ALIVE_FLG) && try < 10);
3192             try++) {
3193                 /* Signal that the task daemon should stop */
3194                 ssp->task_flags |= TASK_STOP_FLG;
3195                 cv_signal(&ssp->task_cv);
3196                 /* Release task daemon lock. */
3197                 mutex_exit(&ssp->task_mu);
3198                 /*
3199                  * TODO - when the driver is modified to support
3200                  * system suspend or if this routine gets called
3201                  * during panic we should use drv_usecwait() rather
3202                  * than delay in those circumstances.
3203                  */
3204                 delay(drv_sectohz(1));
3205                 mutex_enter(&ssp->task_mu);
3206         }
3207 
3208         if (ssp->task_flags & TASK_ALIVE_FLG) {
3209                 res = DDI_FAILURE;
3210         }
3211         mutex_exit(&ssp->task_mu);
3212 
3213         return (res);
3214 }
3215 
3216 /*
3217  * function     - bscv_pause_event_daemon
3218  * description  - Attempt to pause the event daemon thread.
3219  * inputs       - LOM soft state structure pointer
3220  * outputs      - DDI_SUCCESS OR DDI_FAILURE
3221  */
3222 static int
3223 bscv_pause_event_daemon(bscv_soft_state_t *ssp)
3224 {


3230         }
3231 
3232         BSCV_TRACE(ssp, 'D', "bscv_pause_event_daemon",
3233             "Attempting to pause event daemon");
3234 
3235         mutex_enter(&ssp->task_mu);
3236         /* Signal that the task daemon should pause */
3237         ssp->task_flags |= TASK_PAUSE_FLG;
3238 
3239         /* Wait for task daemon to pause. */
3240         for (try = 0;
3241             (!(ssp->task_flags & TASK_SLEEPING_FLG) &&
3242             (ssp->task_flags & TASK_ALIVE_FLG) &&
3243             try < 10);
3244             try++) {
3245                 /* Paranoia */
3246                 ssp->task_flags |= TASK_PAUSE_FLG;
3247                 cv_signal(&ssp->task_cv);
3248                 /* Release task daemon lock. */
3249                 mutex_exit(&ssp->task_mu);
3250                 delay(drv_sectohz(1));
3251                 mutex_enter(&ssp->task_mu);
3252         }
3253         if ((ssp->task_flags & TASK_SLEEPING_FLG) ||
3254             !(ssp->task_flags & TASK_ALIVE_FLG)) {
3255                 mutex_exit(&ssp->task_mu);
3256                 BSCV_TRACE(ssp, 'D', "bscv_pause_event_daemon",
3257                     "Pause event daemon - success");
3258                 return (BSCV_SUCCESS);
3259         }
3260         mutex_exit(&ssp->task_mu);
3261         BSCV_TRACE(ssp, 'D', "bscv_pause_event_daemon",
3262             "Pause event daemon - failed");
3263         return (BSCV_FAILURE);
3264 }
3265 
3266 /*
3267  * function     - bscv_resume_event_daemon
3268  * description  - Resumethe event daemon thread.
3269  * inputs       - LOM soft state structure pointer
3270  * outputs      - None.