@@ -1047,9 +1047,9 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
1047
1047
{
1048
1048
u8 type ;
1049
1049
u8 hdr_status ;
1050
- struct fcpio_tag tag ;
1050
+ struct fcpio_tag ftag ;
1051
1051
u32 id ;
1052
- struct scsi_cmnd * sc ;
1052
+ struct scsi_cmnd * sc = NULL ;
1053
1053
struct fnic_io_req * io_req ;
1054
1054
struct fnic_stats * fnic_stats = & fnic -> fnic_stats ;
1055
1055
struct abort_stats * abts_stats = & fnic -> fnic_stats .abts_stats ;
@@ -1058,27 +1058,43 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
1058
1058
unsigned long flags ;
1059
1059
spinlock_t * io_lock ;
1060
1060
unsigned long start_time ;
1061
+ unsigned int tag ;
1061
1062
1062
- fcpio_header_dec (& desc -> hdr , & type , & hdr_status , & tag );
1063
- fcpio_tag_id_dec (& tag , & id );
1063
+ fcpio_header_dec (& desc -> hdr , & type , & hdr_status , & ftag );
1064
+ fcpio_tag_id_dec (& ftag , & id );
1064
1065
1065
- if ((id & FNIC_TAG_MASK ) >= fnic -> fnic_max_tag_id ) {
1066
+ tag = id & FNIC_TAG_MASK ;
1067
+ if (tag == fnic -> fnic_max_tag_id ) {
1068
+ if (!(id & FNIC_TAG_DEV_RST )) {
1069
+ shost_printk (KERN_ERR , fnic -> lport -> host ,
1070
+ "Tag out of range id 0x%x hdr status = %s\n" ,
1071
+ id , fnic_fcpio_status_to_str (hdr_status ));
1072
+ return ;
1073
+ }
1074
+ } else if (tag > fnic -> fnic_max_tag_id ) {
1066
1075
shost_printk (KERN_ERR , fnic -> lport -> host ,
1067
- "Tag out of range tag %x hdr status = %s\n" ,
1068
- id , fnic_fcpio_status_to_str (hdr_status ));
1076
+ "Tag out of range tag 0x %x hdr status = %s\n" ,
1077
+ tag , fnic_fcpio_status_to_str (hdr_status ));
1069
1078
return ;
1070
1079
}
1071
1080
1072
- sc = scsi_host_find_tag (fnic -> lport -> host , id & FNIC_TAG_MASK );
1081
+ if ((tag == fnic -> fnic_max_tag_id ) && (id & FNIC_TAG_DEV_RST )) {
1082
+ sc = fnic -> sgreset_sc ;
1083
+ io_lock = & fnic -> sgreset_lock ;
1084
+ } else {
1085
+ sc = scsi_host_find_tag (fnic -> lport -> host , id & FNIC_TAG_MASK );
1086
+ io_lock = fnic_io_lock_hash (fnic , sc );
1087
+ }
1088
+
1073
1089
WARN_ON_ONCE (!sc );
1074
1090
if (!sc ) {
1075
1091
atomic64_inc (& fnic_stats -> io_stats .sc_null );
1076
1092
shost_printk (KERN_ERR , fnic -> lport -> host ,
1077
1093
"itmf_cmpl sc is null - hdr status = %s tag = 0x%x\n" ,
1078
- fnic_fcpio_status_to_str (hdr_status ), id );
1094
+ fnic_fcpio_status_to_str (hdr_status ), tag );
1079
1095
return ;
1080
1096
}
1081
- io_lock = fnic_io_lock_hash ( fnic , sc );
1097
+
1082
1098
spin_lock_irqsave (io_lock , flags );
1083
1099
io_req = fnic_priv (sc )-> io_req ;
1084
1100
WARN_ON_ONCE (!io_req );
@@ -1089,7 +1105,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
1089
1105
shost_printk (KERN_ERR , fnic -> lport -> host ,
1090
1106
"itmf_cmpl io_req is null - "
1091
1107
"hdr status = %s tag = 0x%x sc 0x%p\n" ,
1092
- fnic_fcpio_status_to_str (hdr_status ), id , sc );
1108
+ fnic_fcpio_status_to_str (hdr_status ), tag , sc );
1093
1109
return ;
1094
1110
}
1095
1111
start_time = io_req -> start_time ;
@@ -1938,6 +1954,10 @@ static inline int fnic_queue_dr_io_req(struct fnic *fnic,
1938
1954
struct scsi_lun fc_lun ;
1939
1955
int ret = 0 ;
1940
1956
unsigned long intr_flags ;
1957
+ unsigned int tag = scsi_cmd_to_rq (sc )-> tag ;
1958
+
1959
+ if (tag == SCSI_NO_TAG )
1960
+ tag = io_req -> tag ;
1941
1961
1942
1962
spin_lock_irqsave (host -> host_lock , intr_flags );
1943
1963
if (unlikely (fnic_chk_state_flags_locked (fnic ,
@@ -1964,7 +1984,8 @@ static inline int fnic_queue_dr_io_req(struct fnic *fnic,
1964
1984
/* fill in the lun info */
1965
1985
int_to_scsilun (sc -> device -> lun , & fc_lun );
1966
1986
1967
- fnic_queue_wq_copy_desc_itmf (wq , scsi_cmd_to_rq (sc )-> tag | FNIC_TAG_DEV_RST ,
1987
+ tag |= FNIC_TAG_DEV_RST ;
1988
+ fnic_queue_wq_copy_desc_itmf (wq , tag ,
1968
1989
0 , FCPIO_ITMF_LUN_RESET , SCSI_NO_TAG ,
1969
1990
fc_lun .scsi_lun , io_req -> port_id ,
1970
1991
fnic -> config .ra_tov , fnic -> config .ed_tov );
@@ -2146,8 +2167,7 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
2146
2167
.ret = SUCCESS ,
2147
2168
};
2148
2169
2149
- if (new_sc )
2150
- iter_data .lr_sc = lr_sc ;
2170
+ iter_data .lr_sc = lr_sc ;
2151
2171
2152
2172
scsi_host_busy_iter (fnic -> lport -> host ,
2153
2173
fnic_pending_aborts_iter , & iter_data );
@@ -2230,8 +2250,14 @@ int fnic_device_reset(struct scsi_cmnd *sc)
2230
2250
mutex_lock (& fnic -> sgreset_mutex );
2231
2251
tag = fnic -> fnic_max_tag_id ;
2232
2252
new_sc = 1 ;
2233
- }
2234
- io_lock = fnic_io_lock_hash (fnic , sc );
2253
+ fnic -> sgreset_sc = sc ;
2254
+ io_lock = & fnic -> sgreset_lock ;
2255
+ FNIC_SCSI_DBG (KERN_INFO , fnic -> lport -> host ,
2256
+ "fcid: 0x%x lun: 0x%llx flags: 0x%x tag: 0x%x Issuing sgreset\n" ,
2257
+ rport -> port_id , sc -> device -> lun , fnic_priv (sc )-> flags , tag );
2258
+ } else
2259
+ io_lock = fnic_io_lock_hash (fnic , sc );
2260
+
2235
2261
spin_lock_irqsave (io_lock , flags );
2236
2262
io_req = fnic_priv (sc )-> io_req ;
2237
2263
@@ -2247,6 +2273,8 @@ int fnic_device_reset(struct scsi_cmnd *sc)
2247
2273
}
2248
2274
memset (io_req , 0 , sizeof (* io_req ));
2249
2275
io_req -> port_id = rport -> port_id ;
2276
+ io_req -> tag = tag ;
2277
+ io_req -> sc = sc ;
2250
2278
fnic_priv (sc )-> io_req = io_req ;
2251
2279
}
2252
2280
io_req -> dr_done = & tm_done ;
@@ -2400,8 +2428,10 @@ int fnic_device_reset(struct scsi_cmnd *sc)
2400
2428
(u64 )sc -> cmnd [4 ] << 8 | sc -> cmnd [5 ]),
2401
2429
fnic_flags_and_state (sc ));
2402
2430
2403
- if (new_sc )
2431
+ if (new_sc ) {
2432
+ fnic -> sgreset_sc = NULL ;
2404
2433
mutex_unlock (& fnic -> sgreset_mutex );
2434
+ }
2405
2435
2406
2436
FNIC_SCSI_DBG (KERN_DEBUG , fnic -> lport -> host ,
2407
2437
"Returning from device reset %s\n" ,
0 commit comments