From patchwork Thu Aug 2 20:16:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10554181 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 A8B011708 for ; Thu, 2 Aug 2018 20:17:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 937992C451 for ; Thu, 2 Aug 2018 20:17:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87C9B2C48D; Thu, 2 Aug 2018 20:17:35 +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 BF4F52C451 for ; Thu, 2 Aug 2018 20:17:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729034AbeHBWKP (ORCPT ); Thu, 2 Aug 2018 18:10:15 -0400 Received: from mail-co1nam03on0048.outbound.protection.outlook.com ([104.47.40.48]:16060 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727355AbeHBWKP (ORCPT ); Thu, 2 Aug 2018 18:10:15 -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=trG9i0XC2SGxq9w7DQzGVg7LkAhOg5wW9nt01/O8+do=; b=UeNuBPcG3pG7IVENCcNKKVGmHYeYxLllgwLPh8kv3y89WZoFuJ0BPa5Dl4kN6ll0AglinIn9ymYnDrCfpj7TKqHyaODgB0htnhk+eq3GGDj1waH0VdR0rm7k3EvpEjIDu+45vF3W+AYLQap/05MdWOKpxJqb/3i+muKMBm0vaRE= Received: from DM5PR07CA0089.namprd07.prod.outlook.com (2603:10b6:4:ae::18) by BY1PR0701MB1381.namprd07.prod.outlook.com (2a01:111:e400:4810::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.14; Thu, 2 Aug 2018 20:17:14 +0000 Received: from BY2NAM05FT006.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e52::206) by DM5PR07CA0089.outlook.office365.com (2603:10b6:4:ae::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1017.14 via Frontend Transport; Thu, 2 Aug 2018 20:17:13 +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 BY2NAM05FT006.mail.protection.outlook.com (10.152.100.143) 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; Thu, 2 Aug 2018 20:17:13 +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; Thu, 2 Aug 2018 13:17:01 -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 w72KH0HO007986; Thu, 2 Aug 2018 13:17:00 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w72KH0x3007985; Thu, 2 Aug 2018 13:17:00 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH v3 12/16] qla2xxx: Fix race between switch cmd completion and timeout Date: Thu, 2 Aug 2018 13:16:54 -0700 Message-ID: <20180802201658.7903-13-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180802201658.7903-1-himanshu.madhani@cavium.com> References: <20180802201658.7903-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)(136003)(39860400002)(396003)(376002)(346002)(2980300002)(438002)(199004)(189003)(72206003)(336012)(51416003)(44832011)(54906003)(26005)(110136005)(16586007)(81156014)(478600001)(81166006)(126002)(42186006)(446003)(106002)(11346002)(87636003)(36756003)(186003)(48376002)(486006)(2616005)(50466002)(476003)(76176011)(316002)(8676002)(5660300001)(4326008)(8936002)(2906002)(106466001)(47776003)(50226002)(86362001)(6666003)(356003)(14444005)(69596002)(80596001)(1076002)(305945005);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1381;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;BY2NAM05FT006;1:SPJU9vr8Yss/h8E0PeCblkG3xiFfaBY3wORdebHXWgfE3xxsVlL5V4Sm2hKAUHqXaBZ2npuNvQNsFFZLw1MbQVBaU0AT2oeEW1VRLILds80oTJ0qSEhVCjZ06nXdJ+rd X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 52ea8b14-c0d1-4727-29c0-08d5f8b4ef63 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4608076)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060);SRVR:BY1PR0701MB1381; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1381;3:w/D9ALQnBpSAHNDFp8xx6bKRqgabyt1Q/7GR6zCLeYqKk0BzcyS8yOvdvY2vN7Wupl/ljtjRLaKr3arWjl476fN7LmzTZo4yzHQiHXMifldMt2AZeEfe2oShNzHs77RXmdmQAh+9KoYdLXZ21JoFV/Cyj/zyOO7lSpAo0Sl4AgIU+pLaPTiEsEeFlAx6iqYw6ggvF4OGQS0bcmBrIu78LMn3P0ClHxmbg5XyROKdZ8cPyAeIZ2LH8VaHJTp1qxq97pQbDXeLBJaSFZ4+4KFEdIY6GX3Ec115GQEdQXCS7A5irkkOj+4TjPVNPccoNqxLGH2wn1GKlz0LJRyjVBjb9iavX58uspa2JQmy9D/c76A=;25:p6pqKCqpLddKb9Quj3pmOdSeL7/v+6xRyfP3r++gxI2ukxirSmYNcpJCEh48JG2V9BDkwvW6RgfGHtRpjmzBXTM1YUEIF3lhzKv+is9OKYklqL7RDyMxOnrxHCmCOIxev//530pzjyr10O+S1KgR/dd5G9LAgdz3vo2zxs3W15t4hhANiwgHd+tnrX8qQzVPVUQb5XXx8/nDksKCNhGjmk4E9YjLwD64zFsc4oKyzTOj93+P2pjYbLtgCEAP7fMt6o6t4FNm7kMZ8wP6PvVaa0DqPCe7KSSCd/BuFMQIDpUvdI/3FzTLpRECPlU9wya3t+KRqRDnf99tKj9AGiLwjw== X-MS-TrafficTypeDiagnostic: BY1PR0701MB1381: X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1381;31:gIFrO0rrk6mDPYGCXEu3ncQ6ZBWzB+CM30MaIjxl0bGOMOANY36kHdk6NP3uyAcNEnoTjFDCMKmrTES+nfSHOBoH/4J2wjE0M9E8Uot+fJQ6hkcL1Tx/exiEktDlRqDiXwxz76yaJg/l4+s7b2sag3FOJqxod3QXn+7evwx8/PAQ5oWnFWG7tHrvVGpR4t8Rm994s5lcDKYjFj+JPLjCrGirPSPamWMw69XcvgYkF3E=;20:ZRnDDwOn/+9r3evO6bSNmzEdTV3OtlC7z59/eW+pJmqF+IyJyhyAD5Q9aMfi4HU3pneeJrj5Pbbd945R4u9g3OdZXCrlx+cD9urJrOWggjJ9ws/ZtTYTydcseWCEGIp8t7h+Hf262x3RuPvCc/PrpLcHn0STxy8fn3jdsms2OZop9Bx2kobwcCWn1+zMM0el2aSOf2NiYGmeteenN7Igss0ffMqYWd9sPCXDv9w3kr1NFlABuw/lhd5C3gQfw21ZaEjAo3sbiamdl4GrP+6c/vfCuFs5uDAq+JBC7S2qc8UXrOlANTyqzY+HLKsb4BxHiwLTCmw2Ss+yrJqc7QEkjIeJGX9eP2uAtdkCEAVmNYVIqTeLPia6AK0q/Y7KDh2YfEx/JeMzwfC6d/kxJpfjy9nsUSVhXawOLtAso/Psyxit6CnOjRobLJN7i3i0FsplWxmf8e+qtucXpvhxzvVix1Y0AJE5x9sxIjLiYOeF5kX8v890xi+VIfe1J94piLPT 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)(10201501046)(93006095)(93004095)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016);SRVR:BY1PR0701MB1381;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1381; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1381;4:wFmRdck10EiVyWk3KMNAHpl5EZNSDXGW98Z08+xr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H4fkOskH/x9XSuhK4So+2gaGlrQ6T6aLvpci/Pw191fXuTqNK1wcdsp1S4WVEMeYUjDiaBD1ZfTqNf2FuLB32WCi8dxCNZ/j3gsdTqUG1g5IvW6yhZXVev2RCpn3s/zLgM9EJSvve+6AHGndflxlKeUmSF4w8Ht+Hmd02xaA==;5:9C9a2id+0tz7OHHYvIsoWUbrpfxEKqwGrUXL6YA4vpfQkS0pZzO2Yuj8MYOBouG8s2j7K0Jz5yEKMEcAzRzSXCcwX/hUbhREBvOd0arv1hq1rwOhhQDllekKPS8sBZyFLgHOTGeSzJw6UFaw4bO/5yyXXIKzIPveDO6Pu+Bn0Hw=;7:9MuifNPaWmNwtng/EnXL4GihGUNX2W+CdCaCLA2YI/YS/0ahSdT0xmoPg3XwwL5YcMACzdN6jv64a3Dcl3gmwb1IDrprpbl1gAAMjSRXZnHxRh1ucvNjPdjBdJq4pt0HRDATHNo+ht40Lg3eyni3sBzYPim+EOFi7aLhj0T7Z1YEpV11DQYInG619LL9kE2wkf2z1OzJExx04bviPI9RyIHLxpjFGJ5pZNxNI5hUyMmARaXF49abAQSxhbkOEKiN SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2018 20:17:13.4816 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 52ea8b14-c0d1-4727-29c0-08d5f8b4ef63 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: BY1PR0701MB1381 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 9d1a8b2c41a9..75538383de5b 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; } } @@ -1594,7 +1624,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 @@ -1603,12 +1633,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; @@ -1623,6 +1657,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); @@ -1646,10 +1682,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); @@ -1685,7 +1722,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