From ac5db06d6ae7882465311f097fed80f50844e577 Mon Sep 17 00:00:00 2001 From: gibbs Date: Fri, 19 Dec 2003 18:34:30 +0000 Subject: Move all of the recovery thread routines next to each other. Correct the recovery thread's loop so that it will terminate properly on shutdown. We also clear the recovery_thread proc pointer so that any additional calls to aic_terminate_recovery_thread() will not attempt to kill a thread that doesn't exist. Lastly, code the loop so that termination will still be successfull even if the termination request occurs just prior to us entering the loop or while the recovery thread is off recovering commands. --- sys/dev/aic7xxx/aic_osm_lib.c | 59 ++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 26 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/aic7xxx/aic_osm_lib.c b/sys/dev/aic7xxx/aic_osm_lib.c index 409cfce..295044c 100644 --- a/sys/dev/aic7xxx/aic_osm_lib.c +++ b/sys/dev/aic7xxx/aic_osm_lib.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/aic_osm_lib.c#4 $ + * $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/aic_osm_lib.c#5 $ */ #include @@ -118,29 +118,6 @@ aic_terminate_recovery_thread(struct aic_softc *aic) aic_unlock(aic, &s); } -void -aic_calc_geometry(struct ccb_calc_geometry *ccg, int extended) -{ -#if __FreeBSD_version >= 500000 - cam_calc_geometry(ccg, extended); -#else - uint32_t size_mb; - uint32_t secs_per_cylinder; - - size_mb = ccg->volume_size / ((1024L * 1024L) / ccg->block_size); - if (size_mb > 1024 && extended) { - ccg->heads = 255; - ccg->secs_per_track = 63; - } else { - ccg->heads = 64; - ccg->secs_per_track = 32; - } - secs_per_cylinder = ccg->heads * ccg->secs_per_track; - ccg->cylinders = ccg->volume_size / secs_per_cylinder; - ccg->ccb_h.status = CAM_REQ_CMP; -#endif -} - static void aic_recovery_thread(void *arg) { @@ -152,14 +129,20 @@ aic_recovery_thread(void *arg) #endif aic = (struct aic_softc *)arg; aic_lock(aic, &s); - while ((aic->flags & AIC_SHUTDOWN_RECOVERY) == 0) { + for (;;) { - while (LIST_EMPTY(&aic->timedout_scbs) != 0) + if (LIST_EMPTY(&aic->timedout_scbs) != 0 + && (aic->flags & AIC_SHUTDOWN_RECOVERY) == 0) tsleep(aic, PUSER, "idle", 0); + + if ((aic->flags & AIC_SHUTDOWN_RECOVERY) != 0) + break; + aic_unlock(aic, &s); aic_recover_commands(aic); aic_lock(aic, &s); } + aic->platform_data->recovery_thread = NULL; wakeup(aic->platform_data); aic_unlock(aic, &s); #if __FreeBSD_version >= 500000 @@ -167,3 +150,27 @@ aic_recovery_thread(void *arg) #endif kthread_exit(0); } + +void +aic_calc_geometry(struct ccb_calc_geometry *ccg, int extended) +{ +#if __FreeBSD_version >= 500000 + cam_calc_geometry(ccg, extended); +#else + uint32_t size_mb; + uint32_t secs_per_cylinder; + + size_mb = ccg->volume_size / ((1024L * 1024L) / ccg->block_size); + if (size_mb > 1024 && extended) { + ccg->heads = 255; + ccg->secs_per_track = 63; + } else { + ccg->heads = 64; + ccg->secs_per_track = 32; + } + secs_per_cylinder = ccg->heads * ccg->secs_per_track; + ccg->cylinders = ccg->volume_size / secs_per_cylinder; + ccg->ccb_h.status = CAM_REQ_CMP; +#endif +} + -- cgit v1.1