From patchwork Wed Aug 1 06:13:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10551757 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 A6BCC1708 for ; Wed, 1 Aug 2018 06:13:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 962662A5FC for ; Wed, 1 Aug 2018 06:13:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A8782A64D; Wed, 1 Aug 2018 06:13:58 +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 DB9032A5FC for ; Wed, 1 Aug 2018 06:13:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733237AbeHAH5y (ORCPT ); Wed, 1 Aug 2018 03:57:54 -0400 Received: from mail-sn1nam01on0046.outbound.protection.outlook.com ([104.47.32.46]:9984 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733192AbeHAH5y (ORCPT ); Wed, 1 Aug 2018 03:57:54 -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=vaURhft9TNxojcJOSshPQDonXV/1FJ1uyP6fb+S6Nk8=; b=Mk5O3oK9gAwuMttcwWj+gCBqM4BAPm7NdWHNlDZU8EAeiXNQxj4Rq8ntk8y3JbMpUzwwTbjR+4rLbNFW8csEGnyvfgm+NidIxeaXwU7/8UXvdEQ+jUs0dXC3ViZ5jQNjvOAUA0xGelZVfyjXjBwRudL8JkfxjA6MGFYxMTG+3ok= Received: from SN4PR0701CA0007.namprd07.prod.outlook.com (2603:10b6:803:28::17) by SN1PR07MB1470.namprd07.prod.outlook.com (2a01:111:e400:5838::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.14; Wed, 1 Aug 2018 06:13:50 +0000 Received: from BY2NAM05FT053.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e52::207) by SN4PR0701CA0007.outlook.office365.com (2603:10b6:803:28::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1017.14 via Frontend Transport; Wed, 1 Aug 2018 06:13:49 +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 BY2NAM05FT053.mail.protection.outlook.com (10.152.100.190) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.1038.3 via Frontend Transport; Wed, 1 Aug 2018 06:13:49 +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, 31 Jul 2018 23:13:37 -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 w716DcR9028793; Tue, 31 Jul 2018 23:13:38 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w716Dcre028792; Tue, 31 Jul 2018 23:13:38 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH v2 12/16] qla2xxx: Fix race between switch cmd completion and timeout Date: Tue, 31 Jul 2018 23:13:31 -0700 Message-ID: <20180801061335.28709-13-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180801061335.28709-1-himanshu.madhani@cavium.com> References: <20180801061335.28709-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)(979002)(396003)(376002)(136003)(39850400004)(346002)(2980300002)(438002)(199004)(189003)(8676002)(50466002)(316002)(87636003)(8936002)(305945005)(6666003)(52396003)(44832011)(51416003)(356003)(2616005)(86362001)(14444005)(76176011)(47776003)(72206003)(48376002)(42186006)(11346002)(478600001)(69596002)(16586007)(80596001)(126002)(110136005)(1076002)(81156014)(81166006)(476003)(486006)(4326008)(446003)(106002)(336012)(2906002)(36756003)(106466001)(5660300001)(26005)(186003)(50226002)(54906003)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR07MB1470;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;BY2NAM05FT053;1:tN3c/JBUKT69Z5jLF7gFpiqfdoR0ADga4kBl03DVPyktC85dgmTpN2LOFzqNfbYU/lyIYF3hJ2vR6UsW92yVJHjHQp+xt2Yz9HFjisil5XwGVJ2b0fra07p7fjqn5eBA X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bcc6ab4c-7a67-4537-39c4-08d5f775f294 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4608076)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060);SRVR:SN1PR07MB1470; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB1470;3:fH+rtyzdUJXM8XTd97JN1Y8fi5x5BCMMYZBEMFqJe9Fjelj8A1x7Egxp2J21pemVWZ4QgmhB++tdzmXbB59v/Lo8lz9ug4sELzjYvXr14rXbkw3/gkwHE/qkZESQjhIOd1B+KpIFxQ6HCk1YtARLPnKe9BqTbqW64mLqtNwCosobX7rnb3ctbuIGlfswY/EUmdpGqHYq8ZXE5ih803J9YCQQvs8VJBlS7v2MkM45FjKrf+dvIK9lBf7K6W0ygUeGURArFRA089ZkxzWr+Zt1dWmVXPjJftECJYyd+RM/9551/1aWIzItix7QhAFdRVv1fR3lFCrKZWzh5pbNJC/zss2TE+7MiTbrPOEV+Haa2/U=;25:3K8XvV/WT4jY+aJ4aHBSL+FBF+LpBlD0qtmkdKsOPwM7tC20QkbcvwkysLIpO4oAE5tQD4m5jWvAyjR9dBF25YawESZHkANN9//6W+uU0nGUqfVSWDvMcTR+qUS1E19TzC7n5YHgFja1vJfYIQHqOC1s48cEezf+GvRQbHNQTOS5Oa1GEcrqJSoeCwRvxudMDoi9t1GxIjVLRnsOAPnDaHoNpTv+v0g0axh8BM8j06w6Rny/lqaHkKwtUfxEGJMYG6fgk8Cl38WbGvckaUE3zN3ujKKMQ3D/DeetYcFht3dLv45aAarRXjFu/ZnpG18zVRRc9MkzyBYUE+fFXCo3NQ== X-MS-TrafficTypeDiagnostic: SN1PR07MB1470: X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB1470;31:/n0IvUDJ0/rLhUTwSEKwDvtsbyDRuA+FbJyCc5ONDFj+soIO94DbkJh7Xa18zixB74YJEun/TsrLs+wr2A/Yn+D51k72gk8NVNUfHjkBIrNmceUac9KfrenxkBdZBInFZkrOrDzjT2FXen/8OcvIxVSsgsyLDG7L6HISoRjQvEfLl7uEwL69XfU8F8kTfoneGi1KuCuLT3mqmDNIE/IS6gEQsStz85CaSWRAO2DfmMo=;20:q9KSOrF03jYNHH1TiUHnxRoxHJwA8az+pK6vkDV3rr2w8hkuS/QzRLKX+cQgm9SYEibX+mMaPs/2+VElP7xk72o8rJ9b33+ah+kequXT/lKlUsGmXhlFmUGwxU7k2b6/7PYwJPYG8R/CH7Z19mtJo8l4yosylGY/myZRC9acjYvtcO+z/0dCe8tI8FYgjs4NOBOY0eXKGo8W8d61aFet/WI1Tb6mNz8gggtzaYTGhVZ6kTjN0Jis7v2jdSaHj0kE32vM47S3eFoz7ToVAXShRtdkDdGCmAEuSfcD5TqV3QaNN3XyC4aWmrs8AxOMaDzqIyoWHaz36tNCZjXYD1fc+noeFHXg58GwgZnDKS1ph0YvBw2tqP3XEstkq4lpP1dfdoFH2zvTxm1TRZ0v1Rey0OBaeNdo5RVxygrkOvjvzrCO+1ppvoPSHifPiVo62zAKWp6J2w0iwSCev/FYhJAsM3d4VtgcIlLkZqKIGyEBb7hvE9FIPlYbobkjtInjcU4Y 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)(8121501046)(5005006)(3002001)(93006095)(93004095)(10201501046)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011)(7699016);SRVR:SN1PR07MB1470;BCL:0;PCL:0;RULEID:;SRVR:SN1PR07MB1470; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB1470;4:pDTKOnpgAqGwFTxIyIWSX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ti1iwMGIFNA+Y8aKhKHJRL69EvmXiKI/jMg8XaWZvNhzZOzInVOgokUre7ajiyffY4/YCOKRm9uWMSCoZzD2QCso5IYhgESNpbbKv638ov7HxQ42vz1OthKUaIMqgmhv9cWiT6DdsWDcnBBOo2EM/8qOEKvIDv4X7AjKUZWnF6f8SHhqLZKAjJl9SGcxy1KCn+YPlGQw2oKyxzYGdhvMdlpWoSsTv8b+aL2FNaGz4g1qPZgDVFDFjQqp4zMW6+3oNAgWR69EG0BYLvuEd9XvSUW7Ro2Nhqg==;5:XzPlqbz76KwcajETKkxTwCS/pEteJu7rGPFJphNFuVds1vFfrFRMqifbz0g0IwLKUyu/OIRY8Qp2I6oqoDcDp7BaIpwGkvg6moVX+DhUX6tYavj6AIcRk0sev9ymyjqekCpH4giXsNsAKpOllYGluM2zzDQZ7u1zRryVl52PPB4=;7:QeQffeSYfMmddzpk5kbp4RKOQ1veMuGkvQsHYnqERD7CtYS292/9p3mIxzASc6Yb6akAjecV/TbS/a/ecBkXHTAooz6oyoRUA6eXJ031XxcDdp4bh2ArNkHZMbSBgjN1EtKrTalsreS/CDgz9lmUUt3C4J/eRW7bY8tULuGSQU+PdfFWlgNo8yFM0dS5PwosbvIY4MRs/yWSznqUHxNvyY3mnzcwBGall1RJ3caEEA9AiLuZ40hdGF0QM+LQSr+5 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2018 06:13:49.3796 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bcc6ab4c-7a67-4537-39c4-08d5f775f294 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: SN1PR07MB1470 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 40bcf938cf4f..0fc563572fad 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 e92f60a73bc3..b5c1a1dea087 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; } } @@ -1593,7 +1623,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 @@ -1602,12 +1632,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; @@ -1622,6 +1656,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); @@ -1645,10 +1681,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); @@ -1684,7 +1721,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