@@ -24,6 +24,7 @@ void qla2x00_bsg_job_done(srb_t *sp, int res)
24
24
{
25
25
struct bsg_job * bsg_job = sp -> u .bsg_job ;
26
26
struct fc_bsg_reply * bsg_reply = bsg_job -> reply ;
27
+ struct completion * comp = sp -> comp ;
27
28
28
29
ql_dbg (ql_dbg_user , sp -> vha , 0x7009 ,
29
30
"%s: sp hdl %x, result=%x bsg ptr %p\n" ,
@@ -35,6 +36,9 @@ void qla2x00_bsg_job_done(srb_t *sp, int res)
35
36
bsg_reply -> result = res ;
36
37
bsg_job_done (bsg_job , bsg_reply -> result ,
37
38
bsg_reply -> reply_payload_rcv_len );
39
+
40
+ if (comp )
41
+ complete (comp );
38
42
}
39
43
40
44
void qla2x00_bsg_sp_free (srb_t * sp )
@@ -3061,14 +3065,19 @@ qla24xx_bsg_request(struct bsg_job *bsg_job)
3061
3065
3062
3066
static bool qla_bsg_found (struct qla_qpair * qpair , struct bsg_job * bsg_job )
3063
3067
{
3064
- bool found = false ;
3068
+ bool found , do_bsg_done ;
3065
3069
struct fc_bsg_reply * bsg_reply = bsg_job -> reply ;
3066
3070
scsi_qla_host_t * vha = shost_priv (fc_bsg_to_shost (bsg_job ));
3067
3071
struct qla_hw_data * ha = vha -> hw ;
3068
3072
srb_t * sp = NULL ;
3069
3073
int cnt ;
3070
3074
unsigned long flags ;
3071
3075
struct req_que * req ;
3076
+ int rval ;
3077
+ DECLARE_COMPLETION_ONSTACK (comp );
3078
+ uint32_t ratov_j ;
3079
+
3080
+ found = do_bsg_done = false;
3072
3081
3073
3082
spin_lock_irqsave (qpair -> qp_lock_ptr , flags );
3074
3083
req = qpair -> req ;
@@ -3080,42 +3089,104 @@ static bool qla_bsg_found(struct qla_qpair *qpair, struct bsg_job *bsg_job)
3080
3089
sp -> type == SRB_ELS_CMD_HST ||
3081
3090
sp -> type == SRB_ELS_CMD_HST_NOLOGIN ) &&
3082
3091
sp -> u .bsg_job == bsg_job ) {
3083
- req -> outstanding_cmds [cnt ] = NULL ;
3084
- spin_unlock_irqrestore (qpair -> qp_lock_ptr , flags );
3085
-
3086
- if (!ha -> flags .eeh_busy && ha -> isp_ops -> abort_command (sp )) {
3087
- ql_log (ql_log_warn , vha , 0x7089 ,
3088
- "mbx abort_command failed.\n" );
3089
- bsg_reply -> result = - EIO ;
3090
- } else {
3091
- ql_dbg (ql_dbg_user , vha , 0x708a ,
3092
- "mbx abort_command success.\n" );
3093
- bsg_reply -> result = 0 ;
3094
- }
3095
- /* ref: INIT */
3096
- kref_put (& sp -> cmd_kref , qla2x00_sp_release );
3097
3092
3098
3093
found = true;
3099
- goto done ;
3094
+ sp -> comp = & comp ;
3095
+ break ;
3100
3096
}
3101
3097
}
3102
3098
spin_unlock_irqrestore (qpair -> qp_lock_ptr , flags );
3103
3099
3104
- done :
3105
- return found ;
3100
+ if (!found )
3101
+ return false;
3102
+
3103
+ if (ha -> flags .eeh_busy ) {
3104
+ /* skip over abort. EEH handling will return the bsg. Wait for it */
3105
+ rval = QLA_SUCCESS ;
3106
+ ql_dbg (ql_dbg_user , vha , 0x802c ,
3107
+ "eeh encounter. bsg %p sp=%p handle=%x \n" ,
3108
+ bsg_job , sp , sp -> handle );
3109
+ } else {
3110
+ rval = ha -> isp_ops -> abort_command (sp );
3111
+ ql_dbg (ql_dbg_user , vha , 0x802c ,
3112
+ "Aborting bsg %p sp=%p handle=%x rval=%x\n" ,
3113
+ bsg_job , sp , sp -> handle , rval );
3114
+ }
3115
+
3116
+ switch (rval ) {
3117
+ case QLA_SUCCESS :
3118
+ /* Wait for the command completion. */
3119
+ ratov_j = ha -> r_a_tov / 10 * 4 * 1000 ;
3120
+ ratov_j = msecs_to_jiffies (ratov_j );
3121
+
3122
+ if (!wait_for_completion_timeout (& comp , ratov_j )) {
3123
+ ql_log (ql_log_info , vha , 0x7089 ,
3124
+ "bsg abort timeout. bsg=%p sp=%p handle %#x .\n" ,
3125
+ bsg_job , sp , sp -> handle );
3126
+
3127
+ do_bsg_done = true;
3128
+ } else {
3129
+ /* fw had returned the bsg */
3130
+ ql_dbg (ql_dbg_user , vha , 0x708a ,
3131
+ "bsg abort success. bsg %p sp=%p handle=%#x\n" ,
3132
+ bsg_job , sp , sp -> handle );
3133
+ do_bsg_done = false;
3134
+ }
3135
+ break ;
3136
+ default :
3137
+ ql_log (ql_log_info , vha , 0x704f ,
3138
+ "bsg abort fail. bsg=%p sp=%p rval=%x.\n" ,
3139
+ bsg_job , sp , rval );
3140
+
3141
+ do_bsg_done = true;
3142
+ break ;
3143
+ }
3144
+
3145
+ if (!do_bsg_done )
3146
+ return true;
3147
+
3148
+ spin_lock_irqsave (qpair -> qp_lock_ptr , flags );
3149
+ /*
3150
+ * recheck to make sure it's still the same bsg_job due to
3151
+ * qp_lock_ptr was released earlier.
3152
+ */
3153
+ if (req -> outstanding_cmds [cnt ] &&
3154
+ req -> outstanding_cmds [cnt ]-> u .bsg_job != bsg_job ) {
3155
+ /* fw had returned the bsg */
3156
+ spin_unlock_irqrestore (qpair -> qp_lock_ptr , flags );
3157
+ return true;
3158
+ }
3159
+ req -> outstanding_cmds [cnt ] = NULL ;
3160
+ spin_unlock_irqrestore (qpair -> qp_lock_ptr , flags );
3161
+
3162
+ /* ref: INIT */
3163
+ sp -> comp = NULL ;
3164
+ kref_put (& sp -> cmd_kref , qla2x00_sp_release );
3165
+ bsg_reply -> result = - ENXIO ;
3166
+ bsg_reply -> reply_payload_rcv_len = 0 ;
3167
+
3168
+ ql_dbg (ql_dbg_user , vha , 0x7051 ,
3169
+ "%s bsg_job_done : bsg %p result %#x sp %p.\n" ,
3170
+ __func__ , bsg_job , bsg_reply -> result , sp );
3171
+
3172
+ bsg_job_done (bsg_job , bsg_reply -> result , bsg_reply -> reply_payload_rcv_len );
3173
+
3174
+ return true;
3106
3175
}
3107
3176
3108
3177
int
3109
3178
qla24xx_bsg_timeout (struct bsg_job * bsg_job )
3110
3179
{
3111
- struct fc_bsg_reply * bsg_reply = bsg_job -> reply ;
3180
+ struct fc_bsg_request * bsg_request = bsg_job -> request ;
3112
3181
scsi_qla_host_t * vha = shost_priv (fc_bsg_to_shost (bsg_job ));
3113
3182
struct qla_hw_data * ha = vha -> hw ;
3114
3183
int i ;
3115
3184
struct qla_qpair * qpair ;
3116
3185
3117
- ql_log (ql_log_info , vha , 0x708b , "%s CMD timeout. bsg ptr %p.\n" ,
3118
- __func__ , bsg_job );
3186
+ ql_log (ql_log_info , vha , 0x708b ,
3187
+ "%s CMD timeout. bsg ptr %p msgcode %x vendor cmd %x\n" ,
3188
+ __func__ , bsg_job , bsg_request -> msgcode ,
3189
+ bsg_request -> rqst_data .h_vendor .vendor_cmd [0 ]);
3119
3190
3120
3191
if (qla2x00_isp_reg_stat (ha )) {
3121
3192
ql_log (ql_log_info , vha , 0x9007 ,
@@ -3136,7 +3207,6 @@ qla24xx_bsg_timeout(struct bsg_job *bsg_job)
3136
3207
}
3137
3208
3138
3209
ql_log (ql_log_info , vha , 0x708b , "SRB not found to abort.\n" );
3139
- bsg_reply -> result = - ENXIO ;
3140
3210
3141
3211
done :
3142
3212
return 0 ;
0 commit comments