From patchwork Wed Jul 18 21:26:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10533309 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B7569600F4 for ; Wed, 18 Jul 2018 21:28:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A740529885 for ; Wed, 18 Jul 2018 21:28:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B68329A37; Wed, 18 Jul 2018 21:28:17 +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 EB76229885 for ; Wed, 18 Jul 2018 21:28:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729122AbeGRWIC (ORCPT ); Wed, 18 Jul 2018 18:08:02 -0400 Received: from mail-bl2nam02on0056.outbound.protection.outlook.com ([104.47.38.56]:20992 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729914AbeGRWIC (ORCPT ); Wed, 18 Jul 2018 18:08:02 -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=VB8Pr7Dc5FEhQDq+JjH//Q7iJrDQB5NZt3B0rp1RDss=; b=oW4NCM+fjUwji1CLdswCG5gU6OQQiL8cUic+QCS34HbQnf0BuAzsFcJM3iG3tm57NIV90efhiHQY477m5jv3DwTQ8fqyNTVfRVNFtp4cDEioEEiNuw6SiWJx1ONO2te75QlZzAdMtLvCufBjw4PDdrNhpZWXxmK5QaRbEMr4NPE= Received: from DM5PR07CA0038.namprd07.prod.outlook.com (2603:10b6:3:16::24) by SN1PR07MB4080.namprd07.prod.outlook.com (2603:10b6:802:2e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.952.19; Wed, 18 Jul 2018 21:27:10 +0000 Received: from DM3NAM05FT029.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e51::205) by DM5PR07CA0038.outlook.office365.com (2603:10b6:3:16::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.973.16 via Frontend Transport; Wed, 18 Jul 2018 21:27:10 +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 DM3NAM05FT029.mail.protection.outlook.com (10.152.98.140) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.995.0 via Frontend Transport; Wed, 18 Jul 2018 21:27:09 +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; Wed, 18 Jul 2018 14:26:57 -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 w6ILQu2W013404; Wed, 18 Jul 2018 14:26:56 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w6ILQupT013403; Wed, 18 Jul 2018 14:26:56 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH 11/12] qla2xxx: Fix race between switch cmd completion and timeout Date: Wed, 18 Jul 2018 14:26:53 -0700 Message-ID: <20180718212654.13325-12-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180718212654.13325-1-himanshu.madhani@cavium.com> References: <20180718212654.13325-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)(396003)(39860400002)(376002)(346002)(136003)(2980300002)(438002)(199004)(189003)(106466001)(47776003)(8676002)(86362001)(81156014)(305945005)(5660300001)(81166006)(48376002)(8936002)(36756003)(80596001)(356003)(106002)(69596002)(14444005)(1076002)(2906002)(316002)(42186006)(110136005)(16586007)(54906003)(4326008)(50466002)(186003)(336012)(11346002)(486006)(2616005)(476003)(72206003)(44832011)(26005)(446003)(51416003)(126002)(478600001)(87636003)(76176011)(50226002)(6666003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR07MB4080; 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; DM3NAM05FT029; 1:arkLNRaw3+3iwTwylFvXbvjSu+ZCSbQfYxew1nHKswmuRnpDc1woB9w1lXB07KzwZ7egMgLx2R091aYxFmZ9fHms7dtdh/WiqmIGNSMvL3uwt5ZM2nU0qNw6GkesUsBp X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b4fc0781-1ed7-4cec-3e4c-08d5ecf5385c X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4608076)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060); SRVR:SN1PR07MB4080; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB4080; 3:9ruBmKBpOLhEpSbK8grNK4lRLBF5VeBvvYk310voUKD/gMBvwy4N6xOldTJIHzf6d+VUDXXcH9URbYd8heCFkCT8sn7uwLPY89EYBzI36ovGozUeaGU8OjFIdhLxdD3ZS3QIsiqRjCM3Gg2cVfoxwTSoZtNQtB1XLGJF+PFV+ZeWQTWaXvwGlkyel++4hrJxEDVNRHnCTguX3iZZap6I3iJElfba0xrfDNZKpA9cBNV0wd0xGeQ98bvkFA2gGzeGLTl1f+0cBnHxSNjtGkx7pKrOxXG0Yzi2XZm1gJFt2qF4f5EJEjBeS1dsJ50X0jwKuK0mkd3KT0JUzPwgp1CG+Lcc58615MGEBFtXJC0NkBU=; 25:c7RYCTBPOEDWNfX8eo3F53iaXj1H4mkwQmPR0WxFOpbuRXs7qTLhL9GeYjGL7W03k/YyYOa6VeZcq+98OTu8JuY4jMwzV3gMigCeFKd1O41jlJ9apZvyUALXhDq2m88fH8RMeK/WAV37axUmLi2JUuDN+9kF7DyoHsRYyn6+QQDz7ieZE/00PnN6qyEuIX8fgMcscEtuyfGxeRqfS1WGRb0gthmS01P/X0im5lv6Fu5n+YsquYQIhryGFgg7KlK1ItOJn+qmKyB2HqHxBrHWWiZWjOXIVzVKhmRXHRNx6Y6h+7avT62yCpktMjBtRb8RK2A+qQDs6ofCMI8bWwGl/A== X-MS-TrafficTypeDiagnostic: SN1PR07MB4080: X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB4080; 31:9ML77yuJhGzhWaQ8+tRMC/WyVcx996M58iRVzWmguQaN7AaBonKCYSmws8HNDFIIe7NCaW84yohN+QwP6ZLHtAWYZVSOCdcN1qQi1YnNnyKD5ognAxdfQ8+3ubgE9Jg3JotjPXgWLvudVKsZkCoF5c1GfRUlIS/XIdnfzYE4JIIYnpJELe+pgmf18qgI4rOFGpf3fYuIM8317HPzcdGZIqN8xvmqxXtsM8utGNSgiDc=; 20:IP+8TWRprz3kkrsqSu4GxAVxELO4YUg9ZQj39r/LloWYB+qDdL9DnK4Np3uVZQtLHrhkUV3KjjLf39GI1dzBAjAkF+WhP3Xtq28aTgSc7Glx8t0fd1N1c9qXKfdmR7fMkjGx2nIBbKkNTv8sprFn3tzSXTfxjNC4SF28X6XfcfT8IL1PiIbO7ZJydwfnl0IH58y4MPgqwrlRwkicoHLqBIvd8gGjqwivp3A6mjdnQqfZBBdCxJimyA2tK2Ss1itEz/4ysg4mT1SXXt/ixUoYqZqTTn4SPUMCLKCibf7oy3gIac5vc97PeoeBaZpq8rwzM5AKlIFbpDzL7RDKaCwUpRmHriYLeIJDz9VTHkHlumiEIuPDPmWWEftwSkisK7+AmaAJOvhbcy8Ab3v/2dUbkSHyT/ymWAnZlpCDfTUBML8F7WKNxCA6ictypDr1jVfIKQRESQavmVNSoMBGv1+aYZOEoE9AhG8Fi67ir5PIcX+LrFIPwK0bndOrZlZwFXLR 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)(10201501046)(93006095)(93004095)(3231311)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(20161123564045)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:SN1PR07MB4080; BCL:0; PCL:0; RULEID:; SRVR:SN1PR07MB4080; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB4080; 4:2rEHoY8cKhXcug8/r9uWdcDR+2DkMY4pjWN/AoyPNqAbJAZDn0k4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W?= =?us-ascii?Q?fhoSHFbCWXfrLrltOyMkLHeTjAbJam7hS0zzwTdlIWWIqOu8vWsTSnsKgGnH?= =?us-ascii?Q?HqEgcqIUqd0m/XCPRApZVyHZ97yvqrZarbi3b67bEcKdP4PDUglqbmz4a1nS?= =?us-ascii?Q?uLf1Xz43uU3AkOOSXPK3alnzYhtw4BM3ZbtCE8+guySibfdybqXWG+/X1M7H?= =?us-ascii?Q?5XaIbbz4nVZB/uNNgDqrjYtLYel96AVk/2z6T/uI0FQFTJigMk0jiwLybCv+?= =?us-ascii?Q?dmKp+ByHX8GAvIyLzP5ootJnAG6J5pvbxqe55q6AJUkfmL15EomOgWlOuLd1?= =?us-ascii?Q?7buxCoeuty7Z2cPLBn4Mn10ts1UjqyiEcp6GkBaLkoIr3aavH1f++M7c3/+Y?= =?us-ascii?Q?cmVJQhv6psOe46AgVUw38EYiir47OJqaDQQsV1JBZkqwVAXY+HOfHS53xsAo?= =?us-ascii?Q?NzAGcDx0KVspWisVXS3NuRq3aEWecSpZppMb9G0nL8oCJSbv9JDnBAlwe5Uh?= =?us-ascii?Q?m+krkNYoKpsppJ/jFjiTqNxAeq3PfV+?= X-Microsoft-Antispam-Message-Info: t6caZp54c7Z8tXnmtI1R9j12fgfgh42cE74yeOWrpGHw1b0b8xlz4xKhWTU3aIkSDmDrzedSv+1Ba0PYYoOmVchODawBFD1upmAkQ7UMWUGquInPHpSZpuQbx8aWyIzryY6o9M6sr6k9B+oSnb0tgOJjaHOxC+RVw3brkKh7L5OdmWdnq6QdyBlkG6MC3ARraPQoJGB7mhFWnI2tWBjfztk/Y0pfmLzXW+Gbv4Yn2EUJKK6g5IfCZ9OQR0cKqyc70Jz8RCoCWwNe8/fIzc5HKpKlmBStV0+J2g2uWhZsKuPysCsBTwE+bmKrm6GI9I6tIWs2WzEuXi6+V4wCgVycaeDoTPSUReKshoRr5qPhfiU= X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB4080; 6:hsUA4ny4vyqombQe0nW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G2GC7DoBi X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2018 21:27:09.6536 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b4fc0781-1ed7-4cec-3e4c-08d5ecf5385c 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: SN1PR07MB4080 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 Fix race condition between switch cmd completion and timeout timer. Timer has popped triggers command free. On IOCB completion, stale sp point was reused. Instead, an abort will be sent to FW to nudge the command out of FW, where the normal completion will take place. RIP: 0010:qla2x00_chk_ms_status+0xf3/0x1b0 [qla2xxx] Call Trace: qla24xx_els_ct_entry.isra.15+0x1d4/0x2b0 [qla2xxx] qla24xx_msix_rsp_q+0x39/0xf0 [qla2xxx] qla24xx_process_response_queue+0xbc/0x2b0 [qla2xxx] qla24xx_msix_rsp_q+0x8a/0xf0 [qla2xxx] __handle_irq_event_percpu+0xa0/0x1f0 Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_def.h | 1 + drivers/scsi/qla2xxx/qla_gbl.h | 2 +- drivers/scsi/qla2xxx/qla_init.c | 75 ++++++++++++++++++++++++++++++----------- 3 files changed, 58 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 9a98f1c73f5e..416b5ac29666 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -313,6 +313,7 @@ struct srb_cmd { #define SRB_CRC_CTX_DMA_VALID BIT_2 /* DIF: context DMA valid */ #define SRB_CRC_PROT_DMA_VALID BIT_4 /* DIF: prot DMA valid */ #define SRB_CRC_CTX_DSD_VALID BIT_5 /* DIF: dsd_list valid */ +#define SRB_WAKEUP_ON_COMP BIT_6 /* To identify if a srb is of T10-CRC type. @sp => srb_t pointer */ #define IS_PROT_IO(sp) (sp->flags & SRB_CRC_CTX_DSD_VALID) diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index 00fbd49a9a7a..6f2a37220a55 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -213,7 +213,7 @@ extern int qla24xx_post_upd_fcport_work(struct scsi_qla_host *, fc_port_t *); void qla2x00_handle_login_done_event(struct scsi_qla_host *, fc_port_t *, uint16_t *); int qla24xx_post_gnl_work(struct scsi_qla_host *, fc_port_t *); -int qla24xx_async_abort_cmd(srb_t *); +int qla24xx_async_abort_cmd(srb_t *, bool); int qla24xx_post_relogin_work(struct scsi_qla_host *vha); /* diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index addfc53a7bb5..f6211bd7c86e 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -50,16 +50,15 @@ qla2x00_sp_timeout(struct timer_list *t) { srb_t *sp = from_timer(sp, t, u.iocb_cmd.timer); struct srb_iocb *iocb; - scsi_qla_host_t *vha = sp->vha; struct req_que *req; unsigned long flags; - spin_lock_irqsave(&vha->hw->hardware_lock, flags); - req = vha->hw->req_q_map[0]; + spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags); + req = sp->qpair->req; req->outstanding_cmds[sp->handle] = NULL; iocb = &sp->u.iocb_cmd; + spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags); iocb->timeout(sp); - spin_unlock_irqrestore(&vha->hw->hardware_lock, flags); } void @@ -100,6 +99,8 @@ qla2x00_async_iocb_timeout(void *data) srb_t *sp = data; fc_port_t *fcport = sp->fcport; struct srb_iocb *lio = &sp->u.iocb_cmd; + int rc, h; + unsigned long flags; if (fcport) { ql_dbg(ql_dbg_disc, fcport->vha, 0x2071, @@ -114,11 +115,26 @@ qla2x00_async_iocb_timeout(void *data) switch (sp->type) { case SRB_LOGIN_CMD: - /* Retry as needed. */ - lio->u.logio.data[0] = MBS_COMMAND_ERROR; - lio->u.logio.data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ? - QLA_LOGIO_LOGIN_RETRIED : 0; - sp->done(sp, QLA_FUNCTION_TIMEOUT); + rc = qla24xx_async_abort_cmd(sp, false); + if (rc) { + /* Retry as needed. */ + lio->u.logio.data[0] = MBS_COMMAND_ERROR; + lio->u.logio.data[1] = + lio->u.logio.flags & SRB_LOGIN_RETRIED ? + QLA_LOGIO_LOGIN_RETRIED : 0; + spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags); + for (h = 1; h < sp->qpair->req->num_outstanding_cmds; + h++) { + if (sp->qpair->req->outstanding_cmds[h] == + sp) { + sp->qpair->req->outstanding_cmds[h] = + NULL; + break; + } + } + spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags); + sp->done(sp, QLA_FUNCTION_TIMEOUT); + } break; case SRB_LOGOUT_CMD: case SRB_CT_PTHRU_CMD: @@ -127,7 +143,21 @@ qla2x00_async_iocb_timeout(void *data) case SRB_NACK_PRLI: case SRB_NACK_LOGO: case SRB_CTRL_VP: - sp->done(sp, QLA_FUNCTION_TIMEOUT); + rc = qla24xx_async_abort_cmd(sp, false); + if (rc) { + spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags); + for (h = 1; h < sp->qpair->req->num_outstanding_cmds; + h++) { + if (sp->qpair->req->outstanding_cmds[h] == + sp) { + sp->qpair->req->outstanding_cmds[h] = + NULL; + break; + } + } + spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags); + sp->done(sp, QLA_FUNCTION_TIMEOUT); + } break; } } @@ -1596,7 +1626,7 @@ qla24xx_abort_iocb_timeout(void *data) struct srb_iocb *abt = &sp->u.iocb_cmd; abt->u.abt.comp_status = CS_TIMEOUT; - complete(&abt->u.abt.comp); + sp->done(sp, QLA_FUNCTION_TIMEOUT); } static void @@ -1605,12 +1635,16 @@ qla24xx_abort_sp_done(void *ptr, int res) srb_t *sp = ptr; struct srb_iocb *abt = &sp->u.iocb_cmd; - if (del_timer(&sp->u.iocb_cmd.timer)) - complete(&abt->u.abt.comp); + if (del_timer(&sp->u.iocb_cmd.timer)) { + if (sp->flags & SRB_WAKEUP_ON_COMP) + complete(&abt->u.abt.comp); + else + sp->free(sp); + } } int -qla24xx_async_abort_cmd(srb_t *cmd_sp) +qla24xx_async_abort_cmd(srb_t *cmd_sp, bool wait) { scsi_qla_host_t *vha = cmd_sp->vha; fc_port_t *fcport = cmd_sp->fcport; @@ -1625,6 +1659,8 @@ qla24xx_async_abort_cmd(srb_t *cmd_sp) abt_iocb = &sp->u.iocb_cmd; sp->type = SRB_ABT_CMD; sp->name = "abort"; + if (wait) + sp->flags = SRB_WAKEUP_ON_COMP; abt_iocb->timeout = qla24xx_abort_iocb_timeout; init_completion(&abt_iocb->u.abt.comp); @@ -1648,10 +1684,11 @@ qla24xx_async_abort_cmd(srb_t *cmd_sp) "Abort command issued - hdl=%x, target_id=%x\n", cmd_sp->handle, fcport->tgt_id); - wait_for_completion(&abt_iocb->u.abt.comp); - - rval = abt_iocb->u.abt.comp_status == CS_COMPLETE ? - QLA_SUCCESS : QLA_FUNCTION_FAILED; + if (wait) { + wait_for_completion(&abt_iocb->u.abt.comp); + rval = abt_iocb->u.abt.comp_status == CS_COMPLETE ? + QLA_SUCCESS : QLA_FUNCTION_FAILED; + } done_free_sp: sp->free(sp); @@ -1687,7 +1724,7 @@ qla24xx_async_abort_command(srb_t *sp) return qlafx00_fx_disc(vha, &vha->hw->mr.fcport, FXDISC_ABORT_IOCTL); - return qla24xx_async_abort_cmd(sp); + return qla24xx_async_abort_cmd(sp, true); } static void