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.
This commit is contained in:
Justin T. Gibbs 2003-12-19 18:34:30 +00:00
parent cd3d9d6c3c
commit 670c55996b

View File

@ -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 <sys/cdefs.h>
@ -118,6 +118,39 @@ aic_terminate_recovery_thread(struct aic_softc *aic)
aic_unlock(aic, &s);
}
static void
aic_recovery_thread(void *arg)
{
struct aic_softc *aic;
u_long s;
#if __FreeBSD_version >= 500000
mtx_lock(&Giant);
#endif
aic = (struct aic_softc *)arg;
aic_lock(aic, &s);
for (;;) {
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
mtx_unlock(&Giant);
#endif
kthread_exit(0);
}
void
aic_calc_geometry(struct ccb_calc_geometry *ccg, int extended)
{
@ -141,29 +174,3 @@ aic_calc_geometry(struct ccb_calc_geometry *ccg, int extended)
#endif
}
static void
aic_recovery_thread(void *arg)
{
struct aic_softc *aic;
u_long s;
#if __FreeBSD_version >= 500000
mtx_lock(&Giant);
#endif
aic = (struct aic_softc *)arg;
aic_lock(aic, &s);
while ((aic->flags & AIC_SHUTDOWN_RECOVERY) == 0) {
while (LIST_EMPTY(&aic->timedout_scbs) != 0)
tsleep(aic, PUSER, "idle", 0);
aic_unlock(aic, &s);
aic_recover_commands(aic);
aic_lock(aic, &s);
}
wakeup(aic->platform_data);
aic_unlock(aic, &s);
#if __FreeBSD_version >= 500000
mtx_unlock(&Giant);
#endif
kthread_exit(0);
}