From patchwork Wed Dec 20 06:56:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10125057 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 57DD06019C for ; Wed, 20 Dec 2017 06:57:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E32229649 for ; Wed, 20 Dec 2017 06:57:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4302E2964F; Wed, 20 Dec 2017 06:57:11 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 B741029649 for ; Wed, 20 Dec 2017 06:57:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932419AbdLTG5J (ORCPT ); Wed, 20 Dec 2017 01:57:09 -0500 Received: from mail-co1nam03on0060.outbound.protection.outlook.com ([104.47.40.60]:46796 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932386AbdLTG5E (ORCPT ); Wed, 20 Dec 2017 01:57:04 -0500 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; bh=aXtbTzpCZz2ttu94iFbfZTr4wkJ/DVcz3PymFFHxvPg=; b=SDZKXVy+ZkhZWtZev+yyZPBcjTfIDS0dYGmrHys+NktJVwIL0EnfBFxog/JYHVbsh1/eDX5C3DqseoSYNtFJnt5s2xCr7hZEPFOm/5jz6D+AWjaVm/4CVqbi3YVwwk/TSa922G5MYG5FR4AilSCZ6DvSLOePoRtPdcJNaZw8pgI= Received: from CO2PR07CA0078.namprd07.prod.outlook.com (2603:10b6:100::46) by DM5PR0701MB3815.namprd07.prod.outlook.com (2603:10b6:4:7f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.323.15; Wed, 20 Dec 2017 06:57:02 +0000 Received: from BN1AFFO11FD043.protection.gbl (2a01:111:f400:7c10::161) by CO2PR07CA0078.outlook.office365.com (2603:10b6:100::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.323.15 via Frontend Transport; Wed, 20 Dec 2017 06:57:02 +0000 Authentication-Results: spf=permerror (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=none action=none header.from=cavium.com; Received-SPF: PermError (protection.outlook.com: domain of cavium.com used an invalid SPF mechanism) Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BN1AFFO11FD043.mail.protection.outlook.com (10.58.52.190) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.302.6 via Frontend Transport; Wed, 20 Dec 2017 06:56:48 +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, 19 Dec 2017 22:56:46 -0800 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 vBK6ukNd021578; Tue, 19 Dec 2017 22:56:46 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id vBK6ukbE021577; Tue, 19 Dec 2017 22:56:46 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH 08/43] qla2xxx: Chip reset uses wrong lock during IO flush. Date: Tue, 19 Dec 2017 22:56:09 -0800 Message-ID: <20171220065644.21511-9-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20171220065644.21511-1-himanshu.madhani@cavium.com> References: <20171220065644.21511-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)(376002)(39380400002)(39860400002)(346002)(2980300002)(448002)(189003)(199004)(2950100002)(16586007)(8676002)(6666003)(81166006)(5660300001)(50466002)(8936002)(50226002)(48376002)(86362001)(356003)(42186006)(72206003)(316002)(54906003)(110136005)(69596002)(81156014)(87636003)(80596001)(305945005)(85326001)(478600001)(106466001)(1076002)(59450400001)(47776003)(76176011)(36756003)(51416003)(2906002)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR0701MB3815; H:CAEXCH02.caveonetworks.com; FPR:; SPF:PermError; PTR:50-232-66-26-static.hfc.comcastbusiness.net; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD043; 1:XswU7K/+TCv6ssDnTTiuCGcLycZ0jGD2Uhr1gpkvOO6nCrCAE/MNoa228Bg4PjiPvwPEM3HuHOL8e1RLLfF82bwysWmH22CiMuckpugUOe+7GTdrGnsmNvk/6GgryE/A X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2457ce03-86f2-4220-e52a-08d54776d79b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:DM5PR0701MB3815; X-Microsoft-Exchange-Diagnostics: 1; DM5PR0701MB3815; 3:WE5j17bogb7Zrfzri/W3d/mNZDfJ5+ycgXk3EKqLnXQckp2hN+N/i2qdnJIMRA40LNVt8e7f+XZML3kWr41Rolaa7r+DFfJRha7md9nz6wmWO9qj3xiSrIJbVTJu0ADP4o4llDlaUZZ0YjxjKjTlOzPOgAOuJ3+X6oA3794styg14TzKIzciL7RFURDC3vZEhkgXQfcJZDEZALWPDtjgD6IVw52LIypQLKR6k9EZUgvGfxVo2krNUkfrZdRipbpz1eDcOZHvdUBO2xoEPXAxvkSkn8jOGh0TBpTj8fbf75Megb7C2/KS5ph6Z0c1CmL5PJakI2Uv5AdHOG5grlZO7DLgNIaWWMHbVNL54LPGkRQ=; 25:RAhgxW1VqNmqGLCjOtoWys8XUvDqg/iBvvmfpGVk4/L0yXJZPt332cGyTx+ZfKS0u+EjyM9t3Ci4wrTwoNERf2ORxniMteJtj7GWAca6hxTPTmT/a8cl9XjtrUX5okl4njyhqWhlZfgB3F0Pe9EsFbb7NqMlEB1F0XjiFqS2y5LoHclHOD3l3RSdzyh5A0M7gA4S0xvXr96/juTclJbshLx3W+sn7ssL1jJfNIOB9+GJqcozRbcg3Y9uRTmJbAaF1KjgQ5V1OLL0JJt3HJn+Xlrwp27gTQSYDcH4hn9uCEP0ntIlg0qAXRox5PIJyzBWYRgHsR0n0iSbOb5b6oqRow== X-MS-TrafficTypeDiagnostic: DM5PR0701MB3815: X-Microsoft-Exchange-Diagnostics: 1; DM5PR0701MB3815; 31:l2w031Pz8XRVPVEnG9ojpeNoBwheURQJwJRswqNk+g8o1MKcA9fzfUZFq3wPgS++pLvimG64Rp7iHoQ0siZOXQv66Cbj2ewub2t0fWnZB+Ze/Z1WiD+SNvRp4y3o5dgdsSumZwnoQq/XF3p+lhv4F3NYsrZhQyRzKCVcquRKXrFMpZyan5f4cwECOfptr/i3Fuyvi4vvYn37CEH9n40twpySUt9l79TSTHmXOmEmCHY=; 20:8UrlFGYpeL68Th+PiHI9WxDwonqo2k7AUDeGPMy+hAesnXz74g5B2i40VTPLEWKiUCVlf/kbgo/rjlv4QSslRhl0dekGTPYoFi1o5QLUcEIyCgFgVA+z58/3u+hj49QajfiJ8fI8nvUyiSRCwUW3EWMw7bejbnMMKoPxuXTjTPb6AQA6PZdAtxhzmi4RnGCsLxs/Ve+PgkafWw0JLdnyqVtfUpFtFLg0hHguzujClDZ8RY+snNx+CvAG7ynQp4IbbBJbJLiXxHB2AQBZ6ZQLehdcdUaI8BvHUjo111493XOwcrw4s9z75N/kYgxQdg9y1CwCgWWBrKWdfY6FXtD32/0Jy9otB4diE1jWnFP5Sn8g+KsooOW27va96xAfa+qKHwWB0bHN0qBdkkAjs2cuOWpDuqORud+L+uXjqOpp4hQ3yPRFFo1jLx0YpwdrodYl2CO2SUc/xD9I/OYwS0JNM89IxHM/+bm1m8yHPBN4II2TFvlM812yNjvzrZa/emYN X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3231023)(3002001)(6041268)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:DM5PR0701MB3815; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:DM5PR0701MB3815; X-Microsoft-Exchange-Diagnostics: 1; DM5PR0701MB3815; 4:NeQZSSeHkFiPqIvuIqZH1c9xD91yuwwVlkogwGzMjESy1/g2GMX0nwTQayeahtXDL/AezM9E957GAFr+TPOJwAKjvd5SSfgmXJNKLmHsAlb70KbGCUGlddcfPSm8V2Mn9UFYsrMCjBsvUAVuGtQRaF5s3M48e/XOwWgGIy5J48ILzDU9/7qE6dkabKDmKgnkZYej6EsI76XDWnaNnS1pDaE+GOIn5YBtCJc5AkKqUut8dL4PD6Wk68V4Z/vwrbTpMScqKLbQd22sMWrhIfMOEw== X-Forefront-PRVS: 0527DFA348 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR0701MB3815; 23:MFa4KjgO4u8RKUwWowEUAHr24aYTFuZhKJ51Pn0?= =?us-ascii?Q?WdLD5KMt52o6okq83gVz1YBguYJIFFbSbMTJ42bRGyaArakrT4h02kU5NBp0?= =?us-ascii?Q?cQsWXWuP8lmnY7b7IdQuYOQhZPzqDjD5Dx6tgO0FoUoquJL+RCs9aogfpq9m?= =?us-ascii?Q?6VAVdpRcSwynFU90GalbmhKmRYt3oQTAQ3vbhohd2aWH7ITHL+9IUhWYDAjv?= =?us-ascii?Q?tOcOU+o+ZpSOx8sljhT0OP7WpoL9FjvD3RdoXtFs8C3NKPCsqxL2/W1fhRNO?= =?us-ascii?Q?f44jWNWPVUVY6qfSCY2USbCez6y1jHT/KiKXNJ+dCkBWjoiNM2eLd/kP5w4+?= =?us-ascii?Q?XFsUkYgweEqBbJas17Z+JDy43+nZT8yrAkpVjtSlg3/lXMzW34DfUJbFkos+?= =?us-ascii?Q?uF7zC/+3BYfFPQpH3R7mU+R9akwBI4MNhWXgnXzD02L84VofmBY+mcfYHmh5?= =?us-ascii?Q?T02CFRuUP0xMCDhUxWSNEvOu+K9k6klH0PTPW/7wYdPXoG2XdVJOIdxcd8kD?= =?us-ascii?Q?KqagP/oinalN68M/Y2hWzfgl95oIJtK4DHK8PlUzLw2x/vUJelsTXKIXNUWc?= =?us-ascii?Q?w6CIXQu9+z7WhfVgMd1koMc59JkN+rlBr0V5gaD0kML0gdaxuBGz+GyjRBfj?= =?us-ascii?Q?Ysolp6aFy8yxGHZJDKdJhDKFT3pGs19kArzUR7mUhSeKPftzn4jsrpHWoqZp?= =?us-ascii?Q?zZ2WLDlNQ64yoZVum1SXdWhXE9TPwmjyM5yj0eNeP96dcKNeJZqijLoDILLl?= =?us-ascii?Q?5j8BSmpLrFNGrBCbA+R0Y5tbq7eXeJatVA0vYvBBkrNz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UKnczUiDpJCqCg312Tw3eoOIAdsbGWsJvvQY30J3xCRm4tB0DCJgOB8i1brwWV+pGZozqeDTTV4Z8K1G2RJYDsBHOSMIdDZBpBgD9rtAvzKOh3w/MY8mcoKWByieHFnFCpCFG99VK34XP/3KDtb/EOwhv94Np SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2017 06:56:48.8392 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2457ce03-86f2-4220-e52a-08d54776d79b 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: DM5PR0701MB3815 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 As part of chip reset, all commands from all QPairs are flushed. This patch fixes code to use Q Pair lock for flush instead of using old hardware_lock. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_os.c | 139 +++++++++++++++++++----------------------- 1 file changed, 64 insertions(+), 75 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 7f361e93c593..4a542a5a976d 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -1709,94 +1709,83 @@ qla2x00_loop_reset(scsi_qla_host_t *vha) return QLA_SUCCESS; } -void -qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) +static void +__qla2x00_abort_all_cmds(struct qla_qpair *qp, int res) { - int que, cnt, status; + int cnt; unsigned long flags; srb_t *sp; + scsi_qla_host_t *vha = qp->vha; struct qla_hw_data *ha = vha->hw; struct req_que *req; struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; struct qla_tgt_cmd *cmd; uint8_t trace = 0; - spin_lock_irqsave(&ha->hardware_lock, flags); - for (que = 0; que < ha->max_req_queues; que++) { - req = ha->req_q_map[que]; - if (!req) - continue; - if (!req->outstanding_cmds) - continue; - for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { - sp = req->outstanding_cmds[cnt]; - if (sp) { - req->outstanding_cmds[cnt] = NULL; - if (sp->cmd_type == TYPE_SRB) { - if (sp->type == SRB_NVME_CMD || - sp->type == SRB_NVME_LS) { - sp_get(sp); - spin_unlock_irqrestore( - &ha->hardware_lock, flags); - qla_nvme_abort(ha, sp); - spin_lock_irqsave( - &ha->hardware_lock, 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); - spin_unlock_irqrestore( - &ha->hardware_lock, flags); - status = qla2xxx_eh_abort( - GET_CMD_SP(sp)); - spin_lock_irqsave( - &ha->hardware_lock, 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); - } - qla_put_iocbs(sp->qpair, &sp->iores); - sp->done(sp, res); - } else { - 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; - } - cmd = (struct qla_tgt_cmd *)sp; - qlt_abort_cmd_on_host_reset(cmd->vha, - cmd); + spin_lock_irqsave(qp->qp_lock_ptr, flags); + req = qp->req; + for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { + sp = req->outstanding_cmds[cnt]; + if (sp) { + req->outstanding_cmds[cnt] = NULL; + if (sp->cmd_type == TYPE_SRB) { + /* + * Don't abort commands in adapter during EEH + * recovery as it's not accessible/responding. + */ + if (GET_CMD_SP(sp) && !ha->flags.eeh_busy && + (!test_bit(ABORT_ISP_ACTIVE, + &vha->dpc_flags)) && + (sp->type == SRB_SCSI_CMD)) { + /* + * 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); + spin_unlock_irqrestore(qp->qp_lock_ptr, + flags); + qla2xxx_eh_abort(GET_CMD_SP(sp)); + spin_lock_irqsave(qp->qp_lock_ptr, + flags); } + qla_put_iocbs(sp->qpair, &sp->iores); + sp->done(sp, res); + } else { + 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; + } + cmd = (struct qla_tgt_cmd *)sp; + qlt_abort_cmd_on_host_reset(cmd->vha, cmd); } } } - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(qp->qp_lock_ptr, flags); +} + +void +qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) +{ + int que; + struct qla_hw_data *ha = vha->hw; + + __qla2x00_abort_all_cmds(ha->base_qpair, res); + + for (que = 0; que < ha->max_qpairs; que++) { + if (!ha->queue_pair_map[que]) + continue; + + __qla2x00_abort_all_cmds(ha->queue_pair_map[que], res); + } } static int