From patchwork Wed Jul 25 17:01:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10544459 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 912D2112E for ; Wed, 25 Jul 2018 17:01:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79CDC2A86B for ; Wed, 25 Jul 2018 17:01:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E3EA2A844; Wed, 25 Jul 2018 17:01:41 +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 B4F142A869 for ; Wed, 25 Jul 2018 17:01:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729511AbeGYSOM (ORCPT ); Wed, 25 Jul 2018 14:14:12 -0400 Received: from mail-eopbgr690077.outbound.protection.outlook.com ([40.107.69.77]:21536 "EHLO NAM04-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729450AbeGYSOM (ORCPT ); Wed, 25 Jul 2018 14:14:12 -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=dulVkzt+lMp9QcbEPZHph6SSLgyEbL/tU/q7O+ygp2E=; b=NS9+oeJwZLsH3HnOCAhYAGUtbUmFLzbcKzbyZfZgpnjxg0ARxQNkzrARra0lM66KCIWvwpWRGaSn8zpAht3qGox1ynlf65ki/joyr6royfXlHM6Zw5BM0MtXe/qpzUylezUb8myTu9R9nJzdl8XIybGoedizMksVmEOdyC5Gbiw= Received: from DM5PR07CA0028.namprd07.prod.outlook.com (2603:10b6:3:16::14) by SN1PR07MB1472.namprd07.prod.outlook.com (2a01:111:e400:5838::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.21; Wed, 25 Jul 2018 17:01:37 +0000 Received: from DM3NAM05FT022.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e51::208) by DM5PR07CA0028.outlook.office365.com (2603:10b6:3:16::14) 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, 25 Jul 2018 17:01:37 +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 DM3NAM05FT022.mail.protection.outlook.com (10.152.98.132) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P256) id 15.20.1017.0 via Frontend Transport; Wed, 25 Jul 2018 17:01:36 +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, 25 Jul 2018 10:01:23 -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 w6PH1Mck010352; Wed, 25 Jul 2018 10:01:22 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w6PH1McB010351; Wed, 25 Jul 2018 10:01:22 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH 12/16] qla2xxx: Fix race between switch cmd completion and timeout Date: Wed, 25 Jul 2018 10:01:16 -0700 Message-ID: <20180725170120.10269-13-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180725170120.10269-1-himanshu.madhani@cavium.com> References: <20180725170120.10269-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)(136003)(376002)(39860400002)(346002)(2980300002)(438002)(189003)(199004)(54906003)(356003)(336012)(476003)(8676002)(76176011)(186003)(11346002)(126002)(2616005)(1076002)(446003)(5660300001)(106466001)(8936002)(26005)(81156014)(486006)(51416003)(81166006)(44832011)(106002)(6666003)(50226002)(47776003)(2906002)(87636003)(14444005)(48376002)(478600001)(50466002)(80596001)(4326008)(110136005)(42186006)(86362001)(316002)(36756003)(16586007)(69596002)(72206003)(305945005);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR07MB1472;H:CAEXCH02.caveonetworks.com;FPR:;SPF:Pass;LANG:en;PTR:50-232-66-26-static.hfc.comcastbusiness.net;MX:1;A:1; X-Microsoft-Exchange-Diagnostics: 1;DM3NAM05FT022;1:jiqPE979jxf6VnlLKe2YmOoWbSC+AGyqJkhEH/1DlMhaTVa01VzXMVrZawPwBZcflyjdHeiaWEFCq2TDKMzc7s8pC82JuyHiM/6K1oOy6BIAFA/HHChGALKjcubKeIK4 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ec6b95b0-59b8-4930-78be-08d5f2504863 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600073)(711020)(4608076)(2017052603328)(7153060);SRVR:SN1PR07MB1472; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB1472;3:D8Au+xDti2tiIg+aBlvGfAoqRrIBNI/TssiDDMDr+yYNtza2RQkbB7NofP0Nsiyhcw0sIQUTlT9+YlDJObJFHFbxiqnQL6JJvZGFKUItgRWs4+k3nWAv4rsZKW2UBtLuuLBNi1wDFEsKSNaPNtIQrC1OhgZsLPWUImJ78KBgM/AM7HKriKTZH3Z1tmHsERuuPYffo2NNYXZEX47+vN3fr0T4Yva7suj6F09raU9jV0X4J41Q0fwWPTFmh8dXpV15xqB6fY5VBCHU/0upWEm3aR6fdJDxU6pdlMdaKfy8B6NTyMPFI9ZQlQKW0/KGBBveD+KCD9+i3/GrQPOVE9TmNqhvrLjqo44tV01jDydZVJU=;25:04f89mzvYU9fFH1/hGbn8z3PgpAbJomtTQVubjKcEATmKEUzAgsTxbX1+WPbSVwNnBKU7+R71Tn3mvSvR10WmgU1cSdrayrIu4AiTAdtk7t0QOnGJk7dm1UjjAzm7qb1WfE6WfLxEMsJkyRSPWgNeiXFg6BQmLo2iRsxi0mGyUGKPp6wG+N4eHLKvln7ZpIp1HjoJ6LLRAf/ywj6hhUSvJ6a1eSCcy0WzIRUAC8UYSX0vjkjyXk2RMX70hQZuiO1cgcn3/9ipXBH52emDi1v0z6cWgly0y5JPPZdCHAiTBGqXJEkSRoz1aRwjebwATnEZWkX6IwO7KRYsQLAhLUu1w== X-MS-TrafficTypeDiagnostic: SN1PR07MB1472: X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB1472;31:DVBzQKYdULZDX1mBBNq2QBjh5RSG86BAgoXrZwLLSJenoEsxcgOmgAeDkDtTN1k263EP+SHg3mZ2rE7gf3aZLc8PN0klhyxPHHsqZ1pKHSzC8wGxjO2jCrjooBOmsQyqM8kED+2HMUrjok5liNLaCMK4tIjrvZ2PJP7uKYqlB0osob0ol033Bhq8SHyRAC4qWuPGEH8EGZ/cubNqTxsqwOwfDejdiNKc/BPjC7k+8/A=;20:HfhA+70Wiv72L16d8+sEj2u0o8Kp03y92kWaPkITU85mBNTxcNF7UTEI/TkgN0jeToV4hgcPqGfclM2bQbpSXE7cs+ylRYOim1O+npmiJIMIn/PIBlcQQvAiHjAn1EQiW/R4wtTifqV4z4URuiUHZ+nKnQ6sKoitNAsH5cizlQAQozyEnG7REvBmx+TKPv6VG2vZt1zOh1FDQRrw53OLk8i6Vfd2GPq1nJ1ktf9AoCwlLHcSQLTGzTvOPDMfpYqVFhur4gbpVjwwRzErr5rY7ZGqby2itALo5MY85owOjcxSncqHFXtZObMk2bu8mnTeoUsWNvc/72oZDyJhQWqxa6YJESKTQpnlSOPNjQdOTmgHv1o8qZedMH0YAv6YO0eqholsxEOxTFjKXDC0U6bhHHy7fLO7MyEZfhFEoGrKPO4fF5UzKTIUFNrSF4WXZ3xZCOooFWKL1hxlhJrStDzbt4ZxUEl1s0o75qGcJqeurRoDbrSMJUEANJz1Mf0hfhKV 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)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016);SRVR:SN1PR07MB1472;BCL:0;PCL:0;RULEID:;SRVR:SN1PR07MB1472; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB1472;4:uT+DN5e03fcp/NPl971irCQbpzVJCmBLdb0U9shCn3cpMgYAJTgh3LYuGkV0piBpQ+k6v2x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GErT6iag7HgzPvwDmuNFlKx4rxhMoihCjfKntGMDj49Iv5HsdMkAmvHWYJXZMLShRwj4jQlTIZnQ+89QmSqCmQySBfGg2OeREx1fk+8Su51lQjq5CCgPgkq5FyZJ0+JMMYswHsAmTUi6tllZ2GKJZvRXxHt+g==;5:rYjlPh56HqQZwSV0pvv55qr4+g0Jlb/cnxxLyT8Dl18xe92JGN41WvKbk1WuhUbjZYT9rBlTQTAp/PJqDMvZr/yAF3QnXOt5DnKhzVlB+TfnbIVHAUsalA9UjZaPBVotSwjp0oxCkq5ESULmQupc83+QiiEHFJHwK2GEYCaX3ek=;7:ECIfhOEgd8uyeuqzUdvg4vcSm7pdT0ZN1qDt+HwiimFfe813m8wdf9m0tUBKOOoqOwcK3MWdEfP/SwfV3BwlxQXNrrkoZmILxd/IbmX/mS8hVmhgY+vqEDWfryaxJs4LX2OcDbxJ1vWWZ9/rRPhZYOIX6ROCO+tulbOUJ9V4HJUH30wlZNGSvD+MYjAv2xyZEzgWw4xtC76uOZPpuPjT2rn6aWpG2C02hkrFsuhj1qnTn2QRtDO5u5bg0+G/L/zX SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2018 17:01:36.5608 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec6b95b0-59b8-4930-78be-08d5f2504863 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: SN1PR07MB1472 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 ddcaa0786f37..c93e318e8d86 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 ad0662a71a17..b164b80de232 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); void qla2x00_wait_for_sess_deletion(scsi_qla_host_t *); diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index eea378592bc5..6d12da271a39 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; } } @@ -1595,7 +1625,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 @@ -1604,12 +1634,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; @@ -1624,6 +1658,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); @@ -1647,10 +1683,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); @@ -1686,7 +1723,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