From patchwork Tue Sep 4 21:19:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10587997 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9F2014E0 for ; Tue, 4 Sep 2018 21:19:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9899B28F76 for ; Tue, 4 Sep 2018 21:19:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CB942A127; Tue, 4 Sep 2018 21:19:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 595A328F76 for ; Tue, 4 Sep 2018 21:19:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727453AbeIEBqg (ORCPT ); Tue, 4 Sep 2018 21:46:36 -0400 Received: from mail-eopbgr700047.outbound.protection.outlook.com ([40.107.70.47]:12864 "EHLO NAM04-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727195AbeIEBqf (ORCPT ); Tue, 4 Sep 2018 21:46:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=binkdMVPHb2m/1quKLlUjOYX/um06P5VTQN3xc1kXqQ=; b=j8TcXFJ4TzzjE6BMbQ/ixSIOgLMyvpJnLx8mY3GqR3w+b8PNI6TytxJMZ4Cf00NQ8k3VnQyUcQY2MJixvI5ntlrxWqokc6lxZJqCQyefElfxdBphIve0as57Pj8nwI0ADEZU6TcQjMAtD+/jb6pVAQmEaKGyG7BZJ1KSU+CbB00= Received: from DM5PR07CA0055.namprd07.prod.outlook.com (2603:10b6:4:ad::20) by BYAPR07MB4391.namprd07.prod.outlook.com (2603:10b6:a02:c0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1101.18; Tue, 4 Sep 2018 21:19:38 +0000 Received: from CO1NAM05FT006.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e50::207) by DM5PR07CA0055.outlook.office365.com (2603:10b6:4:ad::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1101.14 via Frontend Transport; Tue, 4 Sep 2018 21:19:38 +0000 Authentication-Results: spf=pass (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=cavium.com; Received-SPF: Pass (protection.outlook.com: domain of cavium.com designates 50.232.66.26 as permitted sender) receiver=protection.outlook.com; client-ip=50.232.66.26; helo=CAEXCH02.caveonetworks.com; Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by CO1NAM05FT006.mail.protection.outlook.com (10.152.96.111) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.1143.1 via Frontend Transport; Tue, 4 Sep 2018 21:19:37 +0000 Received: from dut1171.mv.qlogic.com (172.29.51.171) by CAEXCH02.caveonetworks.com (10.17.4.29) with Microsoft SMTP Server id 14.2.347.0; Tue, 4 Sep 2018 14:19:22 -0700 Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id w84LJNtx032010; Tue, 4 Sep 2018 14:19:23 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w84LJNUT032009; Tue, 4 Sep 2018 14:19:23 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH 12/13] qla2xxx: Move ABTS code behind qpair Date: Tue, 4 Sep 2018 14:19:20 -0700 Message-ID: <20180904211921.31927-13-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180904211921.31927-1-himanshu.madhani@cavium.com> References: <20180904211921.31927-1-himanshu.madhani@cavium.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:50.232.66.26;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(346002)(376002)(39860400002)(396003)(136003)(2980300002)(438002)(199004)(189003)(50466002)(80596001)(69596002)(14444005)(2616005)(486006)(446003)(11346002)(476003)(44832011)(126002)(48376002)(2906002)(51416003)(336012)(316002)(16586007)(106002)(54906003)(110136005)(42186006)(76176011)(1076002)(4326008)(50226002)(81166006)(87636003)(478600001)(72206003)(5660300001)(81156014)(8936002)(106466001)(356003)(26005)(186003)(8676002)(86362001)(305945005)(36756003)(47776003);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR07MB4391;H:CAEXCH02.caveonetworks.com;FPR:;SPF:Pass;LANG:en;PTR:50-232-66-26-static.hfc.comcastbusiness.net;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;CO1NAM05FT006;1:h+RESUIC4HmvCPyTLa4CXSTZMmDIWRRBuYTnnNjy7zz3GV8ln9LWOcG0n8yID+0qIIpF1g4ceFR2XA7Idn8aDeq4NB9MBwx35lpPKGDynC68C3npYukGAXEyvfMONhpg X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2658fde6-0fa1-42dd-2410-08d612ac1ec0 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4608076)(2017052603328)(7153060);SRVR:BYAPR07MB4391; X-Microsoft-Exchange-Diagnostics: 1;BYAPR07MB4391;3:6i3jYzGzZgugblBsQnVRyVJ8vmnqOJzlG6OmcQjA2ROb4YTdG+aEq7HrLXnz5y+kXpQDjb/IiCO5EfwlCtA20FLaMo5bHWkp2JUHxwecgVDz9wu5MzVWojunnqKkvLU+dNlaJER+clsO8c9DLpBz9+fdW8l6plrXe27ZbHLx4tmeOZRZe5L+S8EbFVI42EYxfY/26uGMPQfbrjnrL/Pg2wrC1uHyzrx7VTV3VBsWVutd6KMEEzaskh4kFxiFKBlWw691HQMEUo0PwWwEhersn1izvuYlowWOhc6T64KwXZfBhdaKDd76WeEeOKGlDJJhJmXuxiRZsTTvAAlV3ZqVHjqC4ZFlMXK5kN4n6XD4658=;25:bXustCzzFh0ZRsK263tkJJ0ukI+C/ChoMulnMFeresTO0O7EEJPvbXbfeHN0Gp3vx8YjqmOdh3PePucLcyrc/1htBsxF720Rl7gOnTvk2prnHcuVUzJeZ5Trs14z3Qkoa5FRnjOyq5zMkSLMgvPTDjm/tD5kozBI8NYPbf+IwErWEzemorKDVnV7Q/W0tddAsM24k6YXgI75wC4nHoqrZi73zo9O1s/n2F0VEH6ySi0pqqsT9E6vG2Rd75Q5SdqI1voXqU2X2Dkma9nm512XC2oOrnF/mS8Ltxj54oZYHCgySnYWnDz4CDICb8yENFBqgsmB3rddm+xofeh1RoCZlg== X-MS-TrafficTypeDiagnostic: BYAPR07MB4391: X-Microsoft-Exchange-Diagnostics: 1;BYAPR07MB4391;31:vfQzTrCP62+XbEF/FPlX2fxrSAJGdxQZAiFtlT5dRu3+R2mnE3Rp/93ZTo7N1yZru5/l5etzCXyILaUn0FcaZ6Yq1Cm7xXuJ/2XKmiCh8V+SZwcB3kk45Cmbhn/5NCY/jqd+PVr+QlqeuGcRe/08vfWfynAxZMloqt1Eee39sXcgUMbK+cZV5PV3DQCG8GRLl0/zNDtIsYzo8PMunYyua7uwtNoLJBPMhkP569FUoRM=;20:DZXalwK4kLg90iIlcfQvr6vDgd3JRp8SD15/m6pDAJ9/8H3QgE6eaIwHaH1z41uB0NUJCTFKOZLMXOKq9FnlDlSZO4iv0fRezA1rqWDzVFtFzXDCefngqIitRGMSqKN+WE4dH5gzdIp6c+5PaQJs73LUZPLoo3GTN8xC0h1svPstlXbBIwJHD5ORTqy0COItbGqQPdG/RSYo+ladtiU0LF5uO3RGmlN0b9t0R3/l/JLfQtt5lIHkonmW2iT0lIc/b/U7nnsq8TRKStoUc7lTjMss7Q4aTNPVOPrgJUFQAjiabttiD7CEGNIXAG+sbvP3O7kK1iXIyQCqmzWvQP4AS+9oIFtwYvLGRFR7yKuv/FibGz9cF8JmHCBh2j7WoSR7P9vaAr5KIyS1nTroKmKAyNUMZt3hil/lpHmihbPwv1WCjJ4OfmMTgGcqs3CBgcIsGMdsc7gODiv4OsfdbN4quv9YZfXIWcEX3uXDOKGLhVRvuj6kD9BXAVPIr4WxW8qY X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(3231311)(944501410)(52105095)(93006095)(93004095)(10201501046)(149027)(150027)(6041310)(20161123562045)(20161123564045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016);SRVR:BYAPR07MB4391;BCL:0;PCL:0;RULEID:;SRVR:BYAPR07MB4391; X-Microsoft-Exchange-Diagnostics: 1;BYAPR07MB4391;4:zFdLtwQwwDU1Ch1rvzX2BMZOvIY4GKVINPPVySZHu0a9KI6rP1DqUODsjzWnIm5y1lggl6GYF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C+1cKcbGMcV/IJ/CIoyoF7jwoNllhDS70qjRKdiO2kF4YlpvXJChHONZrIBfjq5EymNk+8dScbhuRWdaWL3WlkLlqIfYQdbZFAHsMc6Sf9CPc7ir812aYKNqK6+ciFg+aEg30jqJIQ==;5:HdJ4OS6w4vfBWMSslvBjdWP9TaClmHVb6xEy/ppNcK4AUi2ypRWWw5iOaylerDfOi5M0WuJ8KlFkR+JWUpZSQzzNA7yEX7/FcSm1B57JX0fLify6i/S2XlTKvmTRkxGN8hhdf6gzceGJ3LH92DZiQ8jmVyMCYBUwbc8mxSbW4EQ=;7:LcZpCtXVhL920GMQudp+UempPnDJ/H45yM9RDfNbpY/9Qz0V6XiJMaTh5W2Y56aouv+R9bjxuCod1OrlKsA6jGtJOpKHnWWtfK9XFsFVur9CACVcv0Hw0FkWrhrV5qiYMH4fwGBNUtapj//+tk1TjA9sPIk8y9JPE5ED41L2A7Y9FBlPRMmG3sE3vnUQkaZI9NzuuDX57uyf6G9TDSxaJ+VeOms63PMzwiUd5FJnG7bXMHnzjBpuCUy7DWAR9/MB SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2018 21:19:37.6431 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2658fde6-0fa1-42dd-2410-08d612ac1ec0 X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=711e4ccf-2e9b-4bcf-a551-4094005b6194;Ip=[50.232.66.26];Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR07MB4391 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Quinn Tran Current abort code default to legacy single queue where hardware_lock is used to protect command search. This patch move this code behind the QPair where the qp_lock_ptr will reference the appropriate lock for either legacy/single queue or MQ. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_init.c | 12 ++- drivers/scsi/qla2xxx/qla_mbx.c | 7 +- drivers/scsi/qla2xxx/qla_os.c | 178 ++++++++++++++++++++++------------------ 3 files changed, 107 insertions(+), 90 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 245baf269656..cb2538a91f4c 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -1864,19 +1864,17 @@ qla24xx_async_abort_command(srb_t *sp) uint32_t handle; fc_port_t *fcport = sp->fcport; + struct qla_qpair *qpair = sp->qpair; struct scsi_qla_host *vha = fcport->vha; - struct qla_hw_data *ha = vha->hw; - struct req_que *req = vha->req; - - if (vha->flags.qpairs_available && sp->qpair) - req = sp->qpair->req; + struct req_que *req = qpair->req; - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(qpair->qp_lock_ptr, flags); for (handle = 1; handle < req->num_outstanding_cmds; handle++) { if (req->outstanding_cmds[handle] == sp) break; } - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); + if (handle == req->num_outstanding_cmds) { /* Command not found. */ return QLA_FUNCTION_FAILED; diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 3213017658a6..e016ee9c6d8e 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -3097,22 +3097,25 @@ qla24xx_abort_command(srb_t *sp) struct scsi_qla_host *vha = fcport->vha; struct qla_hw_data *ha = vha->hw; struct req_que *req = vha->req; + struct qla_qpair *qpair = sp->qpair; ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x108c, "Entered %s.\n", __func__); if (vha->flags.qpairs_available && sp->qpair) req = sp->qpair->req; + else + return QLA_FUNCTION_FAILED; if (ql2xasynctmfenable) return qla24xx_async_abort_command(sp); - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(qpair->qp_lock_ptr, flags); for (handle = 1; handle < req->num_outstanding_cmds; handle++) { if (req->outstanding_cmds[handle] == sp) break; } - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); if (handle == req->num_outstanding_cmds) { /* Command not found. */ return QLA_FUNCTION_FAILED; diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 6ce5a7326932..8a2ba6bb5d1b 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -14,6 +14,8 @@ #include #include #include +#include + #include #include #include @@ -1214,10 +1216,14 @@ qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha) return return_status; } -static void +static int sp_get(struct srb *sp) { - atomic_inc(&sp->ref_count); + if (!refcount_inc_not_zero((refcount_t*)&sp->ref_count)) + /* kref get fail */ + return ENXIO; + else + return 0; } #define ISP_REG_DISCONNECT 0xffffffffU @@ -1275,38 +1281,51 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) unsigned long flags; int rval, wait = 0; struct qla_hw_data *ha = vha->hw; + struct qla_qpair *qpair; if (qla2x00_isp_reg_stat(ha)) { ql_log(ql_log_info, vha, 0x8042, "PCI/Register disconnect, exiting.\n"); return FAILED; } - if (!CMD_SP(cmd)) - return SUCCESS; ret = fc_block_scsi_eh(cmd); if (ret != 0) return ret; ret = SUCCESS; - id = cmd->device->id; - lun = cmd->device->lun; - - spin_lock_irqsave(&ha->hardware_lock, flags); sp = (srb_t *) CMD_SP(cmd); - if (!sp) { - spin_unlock_irqrestore(&ha->hardware_lock, flags); + if (!sp) + return SUCCESS; + + qpair = sp->qpair; + if (!qpair) + return SUCCESS; + + spin_lock_irqsave(qpair->qp_lock_ptr, flags); + if (!CMD_SP(cmd)) { + /* there's a chance an interrupt could clear + the ptr as part of done & free */ + spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); + return SUCCESS; + } + + if (sp_get(sp)){ + /* ref_count is already 0 */ + spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); return SUCCESS; } + spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); + + id = cmd->device->id; + lun = cmd->device->lun; ql_dbg(ql_dbg_taskm, vha, 0x8002, "Aborting from RISC nexus=%ld:%d:%llu sp=%p cmd=%p handle=%x\n", vha->host_no, id, lun, sp, cmd, sp->handle); /* Get a reference to the sp and drop the lock.*/ - sp_get(sp); - spin_unlock_irqrestore(&ha->hardware_lock, flags); rval = ha->isp_ops->abort_command(sp); if (rval) { if (rval == QLA_FUNCTION_PARAMETER_ERROR) @@ -1322,14 +1341,29 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) wait = 1; } - spin_lock_irqsave(&ha->hardware_lock, flags); - sp->done(sp, 0); - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_lock_irqsave(qpair->qp_lock_ptr, flags); + /* + * Clear the slot in the oustanding_cmds array if we can't find the + * command to reclaim the resources. + */ + if (rval == QLA_FUNCTION_PARAMETER_ERROR) + vha->req->outstanding_cmds[sp->handle] = NULL; + + /* + * sp->done will do ref_count-- + * sp_get() took an extra count above + */ + sp->done(sp, DID_RESET << 16); /* Did the command return during mailbox execution? */ if (ret == FAILED && !CMD_SP(cmd)) ret = SUCCESS; + if (!CMD_SP(cmd)) + wait = 0; + + spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); + /* Wait for the command to be returned. */ if (wait) { if (qla2x00_eh_wait_on_command(cmd) != QLA_SUCCESS) { @@ -1723,7 +1757,6 @@ __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res) struct req_que *req; struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; struct qla_tgt_cmd *cmd; - uint8_t trace = 0; if (!ha->req_q_map) return; @@ -1735,82 +1768,65 @@ __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res) req->outstanding_cmds[cnt] = NULL; switch (sp->cmd_type) { case TYPE_SRB: - if (sp->cmd_type == TYPE_SRB) { - if (sp->type == SRB_NVME_CMD || - sp->type == SRB_NVME_LS) { - sp_get(sp); + if (sp->type == SRB_NVME_CMD || + sp->type == SRB_NVME_LS) { + if (!sp_get(sp)) { + /* got sp */ spin_unlock_irqrestore (qp->qp_lock_ptr, flags); qla_nvme_abort(ha, sp, res); spin_lock_irqsave - (qp->qp_lock_ptr, - flags); - } else if (GET_CMD_SP(sp) && - !ha->flags.eeh_busy && - (!test_bit(ABORT_ISP_ACTIVE, - &vha->dpc_flags)) && - (sp->type == SRB_SCSI_CMD)) { - /* - * Don't abort commands in - * adapter during EEH - * recovery as it's not - * accessible/responding. - * - * Get a reference to the sp - * and drop the lock. The - * reference ensures this - * sp->done() call and not the - * call in qla2xxx_eh_abort() - * ends the SCSI command (with - * result 'res'). - */ - sp_get(sp); + (qp->qp_lock_ptr, flags); + } + } else if (GET_CMD_SP(sp) && + !ha->flags.eeh_busy && + (!test_bit(ABORT_ISP_ACTIVE, + &vha->dpc_flags)) && + (sp->type == SRB_SCSI_CMD)) { + /* + * Don't abort commands in adapter + * during EEH recovery as it's not + * accessible/responding. + * + * Get a reference to the sp and drop + * the lock. The reference ensures this + * sp->done() call and not the call in + * qla2xxx_eh_abort() ends the SCSI cmd + * (with result 'res'). + */ + if (!sp_get(sp)) { spin_unlock_irqrestore - (qp->qp_lock_ptr, - flags); + (qp->qp_lock_ptr, flags); status = qla2xxx_eh_abort( GET_CMD_SP(sp)); spin_lock_irqsave - (qp->qp_lock_ptr, - flags); - /* - * Get rid of extra reference - * if immediate exit from - * ql2xxx_eh_abort - */ - if (status == FAILED && - (qla2x00_isp_reg_stat(ha))) - atomic_dec( - &sp->ref_count); - } - sp->done(sp, res); - break; - case TYPE_TGT_CMD: - if (!vha->hw->tgt.tgt_ops || - !tgt || qla_ini_mode_enabled(vha)) { - if (!trace) - ql_dbg(ql_dbg_tgt_mgt, - vha, 0xf003, - "HOST-ABORT-HNDLR: dpc_flags=%lx. Target mode disabled\n", - vha->dpc_flags); - continue; + (qp->qp_lock_ptr, flags); } - cmd = (struct qla_tgt_cmd *)sp; - qlt_abort_cmd_on_host_reset(cmd->vha, - cmd); - break; - case TYPE_TGT_TMCMD: - /* - * Currently, only ABTS response gets on - * the outstanding_cmds[] - */ - ha->tgt.tgt_ops->free_mcmd( - (struct qla_tgt_mgmt_cmd *)sp); - break; - default: - break; } + sp->done(sp, res); + break; + case TYPE_TGT_CMD: + if (!vha->hw->tgt.tgt_ops || !tgt || + qla_ini_mode_enabled(vha)) { + ql_dbg(ql_dbg_tgt_mgt, vha, 0xf003, + "HOST-ABORT-HNDLR: dpc_flags=%lx. Target mode disabled\n", + vha->dpc_flags); + continue; + } + cmd = (struct qla_tgt_cmd *)sp; + qlt_abort_cmd_on_host_reset(cmd->vha, cmd); + break; + case TYPE_TGT_TMCMD: + /* + * Currently, only ABTS response gets on the + * outstanding_cmds[] + */ + ha->tgt.tgt_ops->free_mcmd( + (struct qla_tgt_mgmt_cmd *)sp); + break; + default: + break; } } }