@@ -861,68 +861,129 @@ static u8 aac_eh_tmf_hard_reset_fib(struct aac_dev *aac, struct fib *fib,
861
861
}
862
862
863
863
/*
864
- * aac_eh_reset - Reset command handling
864
+ * aac_eh_dev_reset - Device reset command handling
865
865
* @scsi_cmd: SCSI command block causing the reset
866
866
*
867
867
*/
868
- static int aac_eh_reset (struct scsi_cmnd * cmd )
868
+ static int aac_eh_dev_reset (struct scsi_cmnd * cmd )
869
869
{
870
870
struct scsi_device * dev = cmd -> device ;
871
871
struct Scsi_Host * host = dev -> host ;
872
872
struct aac_dev * aac = (struct aac_dev * )host -> hostdata ;
873
873
int count ;
874
874
u32 bus , cid ;
875
+ struct fib * fib ;
875
876
int ret = FAILED ;
876
- int status = 0 ;
877
-
877
+ int status ;
878
+ u8 command ;
878
879
879
880
bus = aac_logical_to_phys (scmd_channel (cmd ));
880
881
cid = scmd_id (cmd );
881
- if (bus < AAC_MAX_BUSES && cid < AAC_MAX_TARGETS &&
882
- aac -> hba_map [bus ][cid ].devtype == AAC_DEVTYPE_NATIVE_RAW ) {
883
- struct fib * fib ;
884
- int status ;
885
- u8 command ;
882
+ if (bus >= AAC_MAX_BUSES || cid >= AAC_MAX_TARGETS ||
883
+ aac -> hba_map [bus ][cid ].devtype != AAC_DEVTYPE_NATIVE_RAW )
884
+ return FAILED ;
886
885
887
- pr_err ("%s: Host adapter reset request. SCSI hang ?\n" ,
888
- AAC_DRIVERNAME );
886
+ pr_err ("%s: Host adapter reset request. SCSI hang ?\n" ,
887
+ AAC_DRIVERNAME );
889
888
890
- fib = aac_fib_alloc (aac );
891
- if (!fib )
892
- return ret ;
889
+ fib = aac_fib_alloc (aac );
890
+ if (!fib )
891
+ return ret ;
893
892
894
893
895
- if (aac -> hba_map [bus ][cid ].reset_state == 0 ) {
896
- /* start a HBA_TMF_LUN_RESET TMF request */
897
- command = aac_eh_tmf_lun_reset_fib (aac , fib ,
898
- bus , cid ,
899
- cmd -> device -> lun );
900
- aac -> hba_map [bus ][cid ].reset_state ++ ;
901
- } else if (aac -> hba_map [bus ][cid ].reset_state >= 1 ) {
902
- /* already tried, start a hard reset now */
903
- command = aac_eh_tmf_hard_reset_fib (aac , fib , bus , cid );
904
- aac -> hba_map [bus ][cid ].reset_state = 0 ;
894
+ /* start a HBA_TMF_LUN_RESET TMF request */
895
+ command = aac_eh_tmf_lun_reset_fib (aac , fib , bus , cid ,
896
+ cmd -> device -> lun );
897
+
898
+ cmd -> SCp .sent_command = 0 ;
899
+
900
+ status = aac_hba_send (command , fib ,
901
+ (fib_callback ) aac_hba_callback ,
902
+ (void * ) cmd );
903
+
904
+ /* Wait up to 15 seconds for completion */
905
+ for (count = 0 ; count < 15 ; ++ count ) {
906
+ if (cmd -> SCp .sent_command ) {
907
+ ret = SUCCESS ;
908
+ break ;
905
909
}
906
- cmd -> SCp .sent_command = 0 ;
910
+ msleep (1000 );
911
+ }
907
912
908
- status = aac_hba_send (command , fib ,
909
- (fib_callback ) aac_hba_callback ,
910
- (void * ) cmd );
913
+ return ret ;
914
+ }
911
915
912
- /* Wait up to 15 seconds for completion */
913
- for (count = 0 ; count < 15 ; ++ count ) {
914
- if (cmd -> SCp .sent_command ) {
915
- ret = SUCCESS ;
916
- break ;
917
- }
918
- msleep (1000 );
916
+ /*
917
+ * aac_eh_target_reset - Target reset command handling
918
+ * @scsi_cmd: SCSI command block causing the reset
919
+ *
920
+ */
921
+ static int aac_eh_target_reset (struct scsi_cmnd * cmd )
922
+ {
923
+ struct scsi_device * dev = cmd -> device ;
924
+ struct Scsi_Host * host = dev -> host ;
925
+ struct aac_dev * aac = (struct aac_dev * )host -> hostdata ;
926
+ int count ;
927
+ u32 bus , cid ;
928
+ int ret = FAILED ;
929
+ struct fib * fib ;
930
+ int status ;
931
+ u8 command ;
932
+
933
+ bus = aac_logical_to_phys (scmd_channel (cmd ));
934
+ cid = scmd_id (cmd );
935
+ if (bus >= AAC_MAX_BUSES || cid >= AAC_MAX_TARGETS ||
936
+ aac -> hba_map [bus ][cid ].devtype != AAC_DEVTYPE_NATIVE_RAW )
937
+ return FAILED ;
938
+
939
+ pr_err ("%s: Host adapter reset request. SCSI hang ?\n" ,
940
+ AAC_DRIVERNAME );
941
+
942
+ fib = aac_fib_alloc (aac );
943
+ if (!fib )
944
+ return ret ;
945
+
946
+
947
+ /* already tried, start a hard reset now */
948
+ command = aac_eh_tmf_hard_reset_fib (aac , fib , bus , cid );
949
+
950
+ cmd -> SCp .sent_command = 0 ;
951
+
952
+ status = aac_hba_send (command , fib ,
953
+ (fib_callback ) aac_hba_callback ,
954
+ (void * ) cmd );
955
+
956
+ /* Wait up to 15 seconds for completion */
957
+ for (count = 0 ; count < 15 ; ++ count ) {
958
+ if (cmd -> SCp .sent_command ) {
959
+ ret = SUCCESS ;
960
+ break ;
919
961
}
962
+ msleep (1000 );
963
+ }
920
964
921
- if (ret == SUCCESS )
922
- return ret ;
965
+ return ret ;
966
+ }
967
+
968
+ /*
969
+ * aac_eh_bus_reset - Bus reset command handling
970
+ * @scsi_cmd: SCSI command block causing the reset
971
+ *
972
+ */
973
+ static int aac_eh_bus_reset (struct scsi_cmnd * cmd )
974
+ {
975
+ struct scsi_device * dev = cmd -> device ;
976
+ struct Scsi_Host * host = dev -> host ;
977
+ struct aac_dev * aac = (struct aac_dev * )host -> hostdata ;
978
+ int count ;
979
+ u32 bus , cid ;
980
+ int status = 0 ;
923
981
924
- } else {
925
982
983
+ bus = aac_logical_to_phys (scmd_channel (cmd ));
984
+ cid = scmd_id (cmd );
985
+ if (bus >= AAC_MAX_BUSES || cid >= AAC_MAX_TARGETS ||
986
+ aac -> hba_map [bus ][cid ].devtype != AAC_DEVTYPE_NATIVE_RAW ) {
926
987
/* Mark the assoc. FIB to not complete, eh handler does this */
927
988
for (count = 0 ;
928
989
count < (host -> can_queue + AAC_NUM_MGT_FIB );
@@ -1409,7 +1470,9 @@ static struct scsi_host_template aac_driver_template = {
1409
1470
.change_queue_depth = aac_change_queue_depth ,
1410
1471
.sdev_attrs = aac_dev_attrs ,
1411
1472
.eh_abort_handler = aac_eh_abort ,
1412
- .eh_bus_reset_handler = aac_eh_reset ,
1473
+ .eh_device_reset_handler = aac_eh_dev_reset ,
1474
+ .eh_target_reset_handler = aac_eh_target_reset ,
1475
+ .eh_bus_reset_handler = aac_eh_bus_reset ,
1413
1476
.eh_host_reset_handler = aac_eh_host_reset ,
1414
1477
.can_queue = AAC_NUM_IO_FIB ,
1415
1478
.this_id = MAXIMUM_NUM_CONTAINERS ,
0 commit comments