@@ -40,6 +40,8 @@ MODULE_PARM_DESC(ql4xextended_error_logging,
4040 "Option to enable extended error logging, "
4141 "Default is 0 - no logging, 1 - debug logging" );
4242
43+ int ql4_mod_unload = 0 ;
44+
4345/*
4446 * SCSI host template entry points
4547 */
@@ -422,6 +424,9 @@ static int qla4xxx_queuecommand(struct scsi_cmnd *cmd,
422424 goto qc_host_busy ;
423425 }
424426
427+ if (test_bit (DPC_RESET_HA_INTR , & ha -> dpc_flags ))
428+ goto qc_host_busy ;
429+
425430 spin_unlock_irq (ha -> host -> host_lock );
426431
427432 srb = qla4xxx_get_new_srb (ha , ddb_entry , cmd , done );
@@ -707,16 +712,12 @@ static int qla4xxx_cmd_wait(struct scsi_qla_host *ha)
707712 return stat ;
708713}
709714
710- /**
711- * qla4xxx_soft_reset - performs soft reset.
712- * @ha: Pointer to host adapter structure.
713- **/
714- int qla4xxx_soft_reset (struct scsi_qla_host * ha )
715+ static void qla4xxx_hw_reset (struct scsi_qla_host * ha )
715716{
716- uint32_t max_wait_time ;
717- unsigned long flags = 0 ;
718- int status = QLA_ERROR ;
719717 uint32_t ctrl_status ;
718+ unsigned long flags = 0 ;
719+
720+ DEBUG2 (printk (KERN_ERR "scsi%ld: %s\n" , ha -> host_no , __func__ ));
720721
721722 spin_lock_irqsave (& ha -> hardware_lock , flags );
722723
@@ -733,6 +734,20 @@ int qla4xxx_soft_reset(struct scsi_qla_host *ha)
733734 readl (& ha -> reg -> ctrl_status );
734735
735736 spin_unlock_irqrestore (& ha -> hardware_lock , flags );
737+ }
738+
739+ /**
740+ * qla4xxx_soft_reset - performs soft reset.
741+ * @ha: Pointer to host adapter structure.
742+ **/
743+ int qla4xxx_soft_reset (struct scsi_qla_host * ha )
744+ {
745+ uint32_t max_wait_time ;
746+ unsigned long flags = 0 ;
747+ int status = QLA_ERROR ;
748+ uint32_t ctrl_status ;
749+
750+ qla4xxx_hw_reset (ha );
736751
737752 /* Wait until the Network Reset Intr bit is cleared */
738753 max_wait_time = RESET_INTR_TOV ;
@@ -966,10 +981,12 @@ static void qla4xxx_do_dpc(struct work_struct *work)
966981 struct scsi_qla_host * ha =
967982 container_of (work , struct scsi_qla_host , dpc_work );
968983 struct ddb_entry * ddb_entry , * dtemp ;
984+ int status = QLA_ERROR ;
969985
970986 DEBUG2 (printk ("scsi%ld: %s: DPC handler waking up."
971- "flags = 0x%08lx, dpc_flags = 0x%08lx\n" ,
972- ha -> host_no , __func__ , ha -> flags , ha -> dpc_flags ));
987+ "flags = 0x%08lx, dpc_flags = 0x%08lx ctrl_stat = 0x%08x\n" ,
988+ ha -> host_no , __func__ , ha -> flags , ha -> dpc_flags ,
989+ readw (& ha -> reg -> ctrl_status )));
973990
974991 /* Initialization not yet finished. Don't do anything yet. */
975992 if (!test_bit (AF_INIT_DONE , & ha -> flags ))
@@ -983,31 +1000,28 @@ static void qla4xxx_do_dpc(struct work_struct *work)
9831000 test_bit (DPC_RESET_HA , & ha -> dpc_flags ))
9841001 qla4xxx_recover_adapter (ha , PRESERVE_DDB_LIST );
9851002
986- if (test_and_clear_bit (DPC_RESET_HA_INTR , & ha -> dpc_flags )) {
1003+ if (test_bit (DPC_RESET_HA_INTR , & ha -> dpc_flags )) {
9871004 uint8_t wait_time = RESET_INTR_TOV ;
988- unsigned long flags = 0 ;
989-
990- qla4xxx_flush_active_srbs (ha );
9911005
992- spin_lock_irqsave (& ha -> hardware_lock , flags );
9931006 while ((readw (& ha -> reg -> ctrl_status ) &
9941007 (CSR_SOFT_RESET | CSR_FORCE_SOFT_RESET )) != 0 ) {
9951008 if (-- wait_time == 0 )
9961009 break ;
997-
998- spin_unlock_irqrestore (& ha -> hardware_lock ,
999- flags );
1000-
10011010 msleep (1000 );
1002-
1003- spin_lock_irqsave (& ha -> hardware_lock , flags );
10041011 }
1005- spin_unlock_irqrestore (& ha -> hardware_lock , flags );
1006-
10071012 if (wait_time == 0 )
10081013 DEBUG2 (printk ("scsi%ld: %s: SR|FSR "
10091014 "bit not cleared-- resetting\n" ,
10101015 ha -> host_no , __func__ ));
1016+ qla4xxx_flush_active_srbs (ha );
1017+ if (ql4xxx_lock_drvr_wait (ha ) == QLA_SUCCESS ) {
1018+ qla4xxx_process_aen (ha , FLUSH_DDB_CHANGED_AENS );
1019+ status = qla4xxx_initialize_adapter (ha ,
1020+ PRESERVE_DDB_LIST );
1021+ }
1022+ clear_bit (DPC_RESET_HA_INTR , & ha -> dpc_flags );
1023+ if (status == QLA_SUCCESS )
1024+ qla4xxx_enable_intrs (ha );
10111025 }
10121026 }
10131027
@@ -1062,7 +1076,7 @@ static void qla4xxx_free_adapter(struct scsi_qla_host *ha)
10621076
10631077 /* Issue Soft Reset to put firmware in unknown state */
10641078 if (ql4xxx_lock_drvr_wait (ha ) == QLA_SUCCESS )
1065- qla4xxx_soft_reset (ha );
1079+ qla4xxx_hw_reset (ha );
10661080
10671081 /* Remove timer thread, if present */
10681082 if (ha -> timer_active )
@@ -1198,7 +1212,6 @@ static int __devinit qla4xxx_probe_adapter(struct pci_dev *pdev,
11981212 INIT_LIST_HEAD (& ha -> free_srb_q );
11991213
12001214 mutex_init (& ha -> mbox_sem );
1201- init_waitqueue_head (& ha -> mailbox_wait_queue );
12021215
12031216 spin_lock_init (& ha -> hardware_lock );
12041217
@@ -1665,6 +1678,7 @@ static int __init qla4xxx_module_init(void)
16651678
16661679static void __exit qla4xxx_module_exit (void )
16671680{
1681+ ql4_mod_unload = 1 ;
16681682 pci_unregister_driver (& qla4xxx_pci_driver );
16691683 iscsi_unregister_transport (& qla4xxx_iscsi_transport );
16701684 kmem_cache_destroy (srb_cachep );
0 commit comments