int		t,l; 
qla2x00_timer(scsi_qla_host_t *ha){	int		t,l;	unsigned long	cpu_flags = 0;	fc_port_t	*fcport;	os_lun_t *lq;	os_tgt_t *tq;	int		start_dpc = 0;	int		index;	srb_t		*sp;	/*	 * We try and restart any request in the retry queue every second.	 */	if (!list_empty(&ha->retry_queue)) {		set_bit(PORT_RESTART_NEEDED, &ha->dpc_flags);		start_dpc++;	}	/*	 * We try and restart any request in the scsi_retry queue every second.	 */	if (!list_empty(&ha->scsi_retry_queue)) {		set_bit(SCSI_RESTART_NEEDED, &ha->dpc_flags);		start_dpc++;	}	/*	 * Ports - Port down timer.	 *	 * Whenever, a port is in the LOST state we start decrementing its port	 * down timer every second until it reaches zero. Once  it reaches zero	 * the port it marked DEAD. 	 */	t = 0;	list_for_each_entry(fcport, &ha->fcports, list) {		if (fcport->port_type != FCT_TARGET)			continue;		if (atomic_read(&fcport->state) == FCS_DEVICE_LOST) {			if (atomic_read(&fcport->port_down_timer) == 0)				continue;			if (atomic_dec_and_test(&fcport->port_down_timer) != 0) 				atomic_set(&fcport->state, FCS_DEVICE_DEAD);						DEBUG(printk("scsi(%ld): fcport-%d - port retry count: "			    "%d remainning\n",			    ha->host_no,			    t, atomic_read(&fcport->port_down_timer)));		}		t++;	} /* End of for fcport  */	/*	 * LUNS - lun suspend timer.	 *	 * Whenever, a lun is suspended the timer starts decrementing its	 * suspend timer every second until it reaches zero. Once  it reaches	 * zero the lun retry count is decremented. 	 */	/*	 * FIXME(dg) - Need to convert this linear search of luns into a search	 * of a list of suspended luns.	 */	for (t = 0; t < ha->max_targets; t++) {		if ((tq = ha->otgt[t]) == NULL)			continue;		for (l = 0; l < ha->max_luns; l++) {			if ((lq = (os_lun_t *) tq->olun[l]) == NULL)				continue;			spin_lock_irqsave(&lq->q_lock, cpu_flags);			if (lq->q_state == LUN_STATE_WAIT &&				atomic_read(&lq->q_timer) != 0) {				if (atomic_dec_and_test(&lq->q_timer) != 0) {					/*					 * A delay should immediately					 * transition to a READY state					 */					if (test_and_clear_bit(LUN_EXEC_DELAYED,					    &lq->q_flag)) {						lq->q_state = LUN_STATE_READY;					}					else {						lq->q_count++;						if (lq->q_count == lq->q_max)							lq->q_state =							    LUN_STATE_TIMEOUT;						else							lq->q_state =							    LUN_STATE_RUN;					}				}				DEBUG3(printk("scsi(%ld): lun%d - timer %d, "				    "count=%d, max=%d, state=%d\n",				    ha->host_no,				    l,				    atomic_read(&lq->q_timer),				    lq->q_count, lq->q_max, lq->q_state));			}			spin_unlock_irqrestore(&lq->q_lock, cpu_flags);		} /* End of for luns  */	} /* End of for targets  */	/* Loop down handler. */	if (atomic_read(&ha->loop_down_timer) > 0 &&	    !(test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags)) && ha->flags.online) {		if (atomic_read(&ha->loop_down_timer) ==		    ha->loop_down_abort_time) {			DEBUG(printk("scsi(%ld): Loop Down - aborting the "			    "queues before time expire\n",			    ha->host_no));			if (!IS_QLA2100(ha) && ha->link_down_timeout)				atomic_set(&ha->loop_state, LOOP_DEAD); 			/* Schedule an ISP abort to return any tape commands. */			spin_lock_irqsave(&ha->hardware_lock, cpu_flags);			for (index = 1; index < MAX_OUTSTANDING_COMMANDS;			    index++) {				sp = ha->outstanding_cmds[index];				if (!sp)					continue;				if (!(sp->fclun->fcport->flags &				    FCF_TAPE_PRESENT))					continue;				set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);				break;			}			spin_unlock_irqrestore(&ha->hardware_lock, cpu_flags);			set_bit(ABORT_QUEUES_NEEDED, &ha->dpc_flags);			start_dpc++;		}		/* if the loop has been down for 4 minutes, reinit adapter */		if (atomic_dec_and_test(&ha->loop_down_timer) != 0) {			DEBUG(printk("scsi(%ld): Loop down exceed 4 mins - "			    "restarting queues.\n",			    ha->host_no));			set_bit(RESTART_QUEUES_NEEDED, &ha->dpc_flags);			start_dpc++;			if (!(ha->device_flags & DFLG_NO_CABLE)) {				DEBUG(printk("scsi(%ld): Loop down - "				    "aborting ISP.\n",				    ha->host_no));				qla_printk(KERN_WARNING, ha,				    "Loop down - aborting ISP.\n");				set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);			}		}		DEBUG3(printk("scsi(%ld): Loop Down - seconds remainning %d\n",		    ha->host_no,		    atomic_read(&ha->loop_down_timer)));	}	/*	 * Done Q Handler -- dgFIXME This handler will kick off doneq if we	 * haven't process it in 2 seconds.	 */	if (!list_empty(&ha->done_queue))		qla2x00_done(ha);	/* Schedule the DPC routine if needed */	if ((test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) ||	    test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags) ||	    start_dpc ||	    test_bit(LOGIN_RETRY_NEEDED, &ha->dpc_flags) ||	    test_bit(RELOGIN_NEEDED, &ha->dpc_flags)) &&	    ha->dpc_wait && !ha->dpc_active) {		up(ha->dpc_wait);	}	qla2x00_restart_timer(ha, WATCH_INTERVAL);}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/f4f051ebb40e74ad0ba02d2cb3a6c16b0393472b/qla_os.c/clean/drivers/scsi/qla2xxx/qla_os.c