@@ -714,7 +714,7 @@ qla2x00_sp_compl(void *ptr, int res)
714
714
{
715
715
srb_t * sp = ptr ;
716
716
struct scsi_cmnd * cmd = GET_CMD_SP (sp );
717
- wait_queue_head_t * cwaitq = sp -> cwaitq ;
717
+ struct completion * comp = sp -> comp ;
718
718
719
719
if (atomic_read (& sp -> ref_count ) == 0 ) {
720
720
ql_dbg (ql_dbg_io , sp -> vha , 0x3015 ,
@@ -724,15 +724,15 @@ qla2x00_sp_compl(void *ptr, int res)
724
724
WARN_ON (atomic_read (& sp -> ref_count ) == 0 );
725
725
return ;
726
726
}
727
- if (! atomic_dec_and_test ( & sp -> ref_count ))
728
- return ;
727
+
728
+ atomic_dec ( & sp -> ref_count ) ;
729
729
730
730
sp -> free (sp );
731
731
cmd -> result = res ;
732
732
CMD_SP (cmd ) = NULL ;
733
733
cmd -> scsi_done (cmd );
734
- if (cwaitq )
735
- wake_up ( cwaitq );
734
+ if (comp )
735
+ complete ( comp );
736
736
qla2x00_rel_sp (sp );
737
737
}
738
738
@@ -825,7 +825,7 @@ qla2xxx_qpair_sp_compl(void *ptr, int res)
825
825
{
826
826
srb_t * sp = ptr ;
827
827
struct scsi_cmnd * cmd = GET_CMD_SP (sp );
828
- wait_queue_head_t * cwaitq = sp -> cwaitq ;
828
+ struct completion * comp = sp -> comp ;
829
829
830
830
if (atomic_read (& sp -> ref_count ) == 0 ) {
831
831
ql_dbg (ql_dbg_io , sp -> fcport -> vha , 0x3079 ,
@@ -835,15 +835,15 @@ qla2xxx_qpair_sp_compl(void *ptr, int res)
835
835
WARN_ON (atomic_read (& sp -> ref_count ) == 0 );
836
836
return ;
837
837
}
838
- if (! atomic_dec_and_test ( & sp -> ref_count ))
839
- return ;
838
+
839
+ atomic_dec ( & sp -> ref_count ) ;
840
840
841
841
sp -> free (sp );
842
842
cmd -> result = res ;
843
843
CMD_SP (cmd ) = NULL ;
844
844
cmd -> scsi_done (cmd );
845
- if (cwaitq )
846
- wake_up ( cwaitq );
845
+ if (comp )
846
+ complete ( comp );
847
847
qla2xxx_rel_qpair_sp (sp -> qpair , sp );
848
848
}
849
849
@@ -1286,7 +1286,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
1286
1286
unsigned int id ;
1287
1287
uint64_t lun ;
1288
1288
unsigned long flags ;
1289
- int rval , wait = 0 ;
1289
+ int rval ;
1290
1290
struct qla_hw_data * ha = vha -> hw ;
1291
1291
struct qla_qpair * qpair ;
1292
1292
@@ -1299,7 +1299,6 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
1299
1299
ret = fc_block_scsi_eh (cmd );
1300
1300
if (ret != 0 )
1301
1301
return ret ;
1302
- ret = SUCCESS ;
1303
1302
1304
1303
sp = (srb_t * ) CMD_SP (cmd );
1305
1304
if (!sp )
@@ -1310,7 +1309,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
1310
1309
return SUCCESS ;
1311
1310
1312
1311
spin_lock_irqsave (qpair -> qp_lock_ptr , flags );
1313
- if (! CMD_SP ( cmd ) ) {
1312
+ if (sp -> type != SRB_SCSI_CMD || GET_CMD_SP ( sp ) != cmd ) {
1314
1313
/* there's a chance an interrupt could clear
1315
1314
the ptr as part of done & free */
1316
1315
spin_unlock_irqrestore (qpair -> qp_lock_ptr , flags );
@@ -1331,66 +1330,31 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
1331
1330
"Aborting from RISC nexus=%ld:%d:%llu sp=%p cmd=%p handle=%x\n" ,
1332
1331
vha -> host_no , id , lun , sp , cmd , sp -> handle );
1333
1332
1334
- /* Get a reference to the sp and drop the lock.*/
1335
1333
rval = ha -> isp_ops -> abort_command (sp );
1336
- if (rval ) {
1337
- if (rval == QLA_FUNCTION_PARAMETER_ERROR )
1338
- ret = SUCCESS ;
1339
- else
1340
- ret = FAILED ;
1341
-
1342
- ql_dbg (ql_dbg_taskm , vha , 0x8003 ,
1343
- "Abort command mbx failed cmd=%p, rval=%x.\n" , cmd , rval );
1344
- } else {
1345
- ql_dbg (ql_dbg_taskm , vha , 0x8004 ,
1346
- "Abort command mbx success cmd=%p.\n" , cmd );
1347
- wait = 1 ;
1348
- }
1334
+ ql_dbg (ql_dbg_taskm , vha , 0x8003 ,
1335
+ "Abort command mbx cmd=%p, rval=%x.\n" , cmd , rval );
1349
1336
1350
- spin_lock_irqsave (qpair -> qp_lock_ptr , flags );
1351
-
1352
- /*
1353
- * Releasing of the SRB and associated command resources
1354
- * is managed through ref_count.
1355
- * Whether we need to wait for the abort completion or complete
1356
- * the abort handler should be based on the ref_count.
1357
- */
1358
- if (atomic_read (& sp -> ref_count ) > 1 ) {
1337
+ switch (rval ) {
1338
+ case QLA_SUCCESS :
1359
1339
/*
1360
- * The command is not yet completed. We need to wait for either
1361
- * command completion or abort completion.
1340
+ * The command has been aborted. That means that the firmware
1341
+ * won't report a completion.
1362
1342
*/
1363
- DECLARE_WAIT_QUEUE_HEAD_ONSTACK (eh_waitq );
1364
- uint32_t ratov = ha -> r_a_tov /10 ;
1365
-
1366
- /* Go ahead and release the extra ref_count obtained earlier */
1367
- sp -> done (sp , DID_RESET << 16 );
1368
- sp -> cwaitq = & eh_waitq ;
1369
-
1370
- if (!wait_event_lock_irq_timeout (eh_waitq ,
1371
- CMD_SP (cmd ) == NULL , * qpair -> qp_lock_ptr ,
1372
- msecs_to_jiffies (4 * ratov * 1000 ))) {
1373
- /*
1374
- * The abort got dropped, LOGO will be sent and the
1375
- * original command will be completed with CS_TIMEOUT
1376
- * completion
1377
- */
1378
- ql_dbg (ql_dbg_taskm , vha , 0xffff ,
1379
- "%s: Abort wait timer (4 * R_A_TOV[%d]) expired\n" ,
1380
- __func__ , ha -> r_a_tov );
1381
- sp -> cwaitq = NULL ;
1382
- ret = FAILED ;
1383
- goto end ;
1384
- }
1385
- } else {
1386
- /* Command completed while processing the abort */
1387
- sp -> done (sp , DID_RESET << 16 );
1343
+ sp -> done (sp , DID_ABORT << 16 );
1344
+ ret = SUCCESS ;
1345
+ break ;
1346
+ default :
1347
+ /*
1348
+ * Either abort failed or abort and completion raced. Let
1349
+ * the SCSI core retry the abort in the former case.
1350
+ */
1351
+ ret = FAILED ;
1352
+ break ;
1388
1353
}
1389
- end :
1390
- spin_unlock_irqrestore (qpair -> qp_lock_ptr , flags );
1354
+
1391
1355
ql_log (ql_log_info , vha , 0x801c ,
1392
- "Abort command issued nexus=%ld:%d:%llu -- %d %x.\n" ,
1393
- vha -> host_no , id , lun , wait , ret );
1356
+ "Abort command issued nexus=%ld:%d:%llu -- %x.\n" ,
1357
+ vha -> host_no , id , lun , ret );
1394
1358
1395
1359
return ret ;
1396
1360
}
@@ -1766,42 +1730,34 @@ static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res,
1766
1730
__releases (qp - > qp_lock_ptr )
1767
1731
__acquires (qp - > qp_lock_ptr )
1768
1732
{
1733
+ DECLARE_COMPLETION_ONSTACK (comp );
1769
1734
scsi_qla_host_t * vha = qp -> vha ;
1770
1735
struct qla_hw_data * ha = vha -> hw ;
1736
+ int rval ;
1771
1737
1772
- if (sp -> type == SRB_NVME_CMD || sp -> type == SRB_NVME_LS ) {
1773
- if (!sp_get (sp )) {
1774
- /* got sp */
1775
- spin_unlock_irqrestore (qp -> qp_lock_ptr , * flags );
1776
- qla_nvme_abort (ha , sp , res );
1777
- spin_lock_irqsave (qp -> qp_lock_ptr , * flags );
1778
- }
1779
- } else if (GET_CMD_SP (sp ) && !ha -> flags .eeh_busy &&
1780
- !test_bit (ABORT_ISP_ACTIVE , & vha -> dpc_flags ) &&
1781
- !qla2x00_isp_reg_stat (ha ) && sp -> type == SRB_SCSI_CMD ) {
1782
- /*
1783
- * Don't abort commands in adapter during EEH recovery as it's
1784
- * not accessible/responding.
1785
- *
1786
- * Get a reference to the sp and drop the lock. The reference
1787
- * ensures this sp->done() call and not the call in
1788
- * qla2xxx_eh_abort() ends the SCSI cmd (with result 'res').
1789
- */
1790
- if (!sp_get (sp )) {
1791
- int status ;
1738
+ if (sp_get (sp ))
1739
+ return ;
1792
1740
1793
- spin_unlock_irqrestore (qp -> qp_lock_ptr , * flags );
1794
- status = qla2xxx_eh_abort (GET_CMD_SP (sp ));
1795
- spin_lock_irqsave (qp -> qp_lock_ptr , * flags );
1796
- /*
1797
- * Get rid of extra reference caused
1798
- * by early exit from qla2xxx_eh_abort
1799
- */
1800
- if (status == FAST_IO_FAIL )
1801
- atomic_dec (& sp -> ref_count );
1741
+ if (sp -> type == SRB_NVME_CMD || sp -> type == SRB_NVME_LS ||
1742
+ (sp -> type == SRB_SCSI_CMD && !ha -> flags .eeh_busy &&
1743
+ !test_bit (ABORT_ISP_ACTIVE , & vha -> dpc_flags ) &&
1744
+ !qla2x00_isp_reg_stat (ha ))) {
1745
+ sp -> comp = & comp ;
1746
+ rval = ha -> isp_ops -> abort_command (sp );
1747
+ spin_unlock_irqrestore (qp -> qp_lock_ptr , * flags );
1748
+
1749
+ switch (rval ) {
1750
+ case QLA_SUCCESS :
1751
+ sp -> done (sp , res );
1752
+ break ;
1753
+ case QLA_FUNCTION_PARAMETER_ERROR :
1754
+ wait_for_completion (& comp );
1755
+ break ;
1802
1756
}
1757
+
1758
+ spin_lock_irqsave (qp -> qp_lock_ptr , * flags );
1759
+ sp -> comp = NULL ;
1803
1760
}
1804
- sp -> done (sp , res );
1805
1761
}
1806
1762
1807
1763
static void
0 commit comments