From patchwork Fri Jan 19 20:29:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10175957 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 70F776055D for ; Fri, 19 Jan 2018 20:29:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 610F8212DB for ; Fri, 19 Jan 2018 20:29:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54B5B287BD; Fri, 19 Jan 2018 20:29:49 +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 41E30212DB for ; Fri, 19 Jan 2018 20:29:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932321AbeASU3r (ORCPT ); Fri, 19 Jan 2018 15:29:47 -0500 Received: from mail-bl2nam02on0049.outbound.protection.outlook.com ([104.47.38.49]:7344 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932166AbeASU3p (ORCPT ); Fri, 19 Jan 2018 15:29:45 -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=e88QvZO2bXpQZ+TAFFgJWnLlbaVLfeZzmALDO8l+UAU=; b=HBoatXSNxvmW1wfILDxXaFsDlksUwqIzVUX+gqc58xOV7GxbSR4Y7vK1RI/fcobKHtsdHssPhxQzRJGP30O53DF4XopbYi9rG39DEuMQMUt+0iyxhDQPY9P49r7Ex7pclnCyC42+Zge4WWDPS0kN0vC9xw83bhp08RSMS/dwjjY= Received: from CO2PR07CA0061.namprd07.prod.outlook.com (2603:10b6:100::29) by CY4PR0701MB3812.namprd07.prod.outlook.com (2603:10b6:910:94::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.407.7; Fri, 19 Jan 2018 20:29:43 +0000 Received: from BL2FFO11FD054.protection.gbl (2a01:111:f400:7c09::162) by CO2PR07CA0061.outlook.office365.com (2603:10b6:100::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.428.17 via Frontend Transport; Fri, 19 Jan 2018 20:29:43 +0000 Authentication-Results: spf=fail (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; HansenPartnership.com; dkim=none (message not signed) header.d=none;HansenPartnership.com; dmarc=none action=none header.from=cavium.com; Received-SPF: Fail (protection.outlook.com: domain of cavium.com does not designate 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 BL2FFO11FD054.mail.protection.outlook.com (10.173.161.182) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.428.12 via Frontend Transport; Fri, 19 Jan 2018 20:29:42 +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; Fri, 19 Jan 2018 12:29:33 -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 w0JKTX1d013286; Fri, 19 Jan 2018 12:29:33 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w0JKTXSi013285; Fri, 19 Jan 2018 12:29:33 -0800 From: Himanshu Madhani To: , , , , , CC: , Subject: [PATCH 3/5] qla2xxx: Add changes for devloss timeout in driver Date: Fri, 19 Jan 2018 12:29:26 -0800 Message-ID: <20180119202928.13239-4-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180119202928.13239-1-himanshu.madhani@cavium.com> References: <20180119202928.13239-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)(376002)(346002)(39860400002)(396003)(39380400002)(2980300002)(1109001)(1110001)(339900001)(199004)(189003)(5660300001)(8936002)(1076002)(76176011)(50226002)(106466001)(50466002)(36756003)(6666003)(336011)(26005)(2906002)(2950100002)(48376002)(2201001)(16586007)(8676002)(305945005)(72206003)(47776003)(85426001)(110136005)(316002)(575784001)(42186006)(59450400001)(54906003)(356003)(86362001)(81166006)(105606002)(81156014)(51416003)(69596002)(80596001)(87636003)(478600001)(4326008)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR0701MB3812; H:CAEXCH02.caveonetworks.com; FPR:; SPF:Fail; PTR:50-232-66-26-static.hfc.comcastbusiness.net; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD054; 1:Q5BJigNcQ+v4U0TrI2BGGVinep8NyCe2Y0QmPlYYN/uIzRqTfd99Fiqn4FT/YXvk91W/wEJ7aUOUoK7gUK+X8W7qGU2r4KlQqHeANnQ3ddnpZCEdMGU9vL+KrodMelIH X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 099c5be4-f6a9-4d3c-e0a8-08d55f7b5f7e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534125)(4602075)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:CY4PR0701MB3812; X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3812; 3:2QI60EhlfdYggWAM7wMVfZwLGhEatSD+sZbi7lXhEWtsq2TzrZGe2WNjA+s8e954oCU/XzgOCxfJ+8tcYhRwS+Cg/NDOdHtSGx1eB5Npt5I+FycbTvMBlLtvjVSlhS17ZndPTdDmBof/IEZda7fVtUak2bfjAOfFaqNb3qaGgtJI4A8bFElk+MRIzQbO9OWM74a0G6F0ceQgj0255t0jljvHl7Xch8XyMmImxtzU+7HOrMbb6Ejg99ja74lc/c0BZBvgyLUyZ10Ckj8ZnqIJ9ydPX3px8+ZXh9tqtXEfRvZ9az7qtQ3cu7STwwIlLYIRj8MqyrhF8QU4LTj8e7Ir07q+m0oVm8UffZ8RIvC4lCg=; 25:Ffx8SXa51OsDbYh1GW1TmAWIS5rA8ODt8TfnSVAnSHnAyONsD0cE7Ie6hHMal03YcdBYfqrgjAoIPXaKh+fvO606V5WlUWBq60jzGNoLiDcPnXdJTRnw6QFbuPPdHvgQbdb9/Xg/5ehk6vgapJ+zF099AzFjj2cS0p6fKvEJ1EOFW+KLMrgncRcMfzrY4ckcUAQRewd/f61mVV5JbK0b8/9gq0cJdOe8v7N+JJjfybmSFC+JFycYaGdNW3Kf2/0K9D+DwYQvt73mlIaSB2YyN+02iZpDb0QAmF6U36WI3ODAbhUAQBcu0SJSxitqkVg0dC7rRUC3xcdJ3bT20tq1Cw== X-MS-TrafficTypeDiagnostic: CY4PR0701MB3812: X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3812; 31:xSaSeefWOzfKUjqvDB87c4zhBLu5KovMTOidFtx2CqJWpsptqLg7mQXGUoslK42pFTvqKjHA1qo40mXjYNzlLs++z79Lw/ncXjodF6MQN8h0706czjaWF9LcnToT13yRo8nuVdnS7I4rILaBDjdy/GQv+FT1BzZtphDYuMkrzeCQb+UL4kcdfnVEkh9Ul6vNU9iwtM2dfZa14kxxYGqtkn+63MJa87EaQToZwS15wt8=; 20:PYwZd2zWeqPmOD1aSFz7verwBAbJ0cdakVMO88Pvxs+4Y7HT4qlkZsp66hix5XTgfWR6bPsFZlbmX4aM7mzbYyppLxkLg9ObUaKAw4Kz/T/8t2grcqp8nllVWzAMyhNCGj35eZZp0+CxVIRcmV8IW47VQ62I/6lekIFrLCUTQ3F30K/YoW+5fDghu3GU37PJYMRo/BSetf+TUaWLjvSgKE1BqGTlBhmGANa7nhKdb5TlLiLmzRn/xd4AFuYEXRIr/xxeLSX9V49EGzUiOCTukWA/lzK/YNZGVIh8OYNWAhuI+D91AYAmdeZ9fRGXkRXhXY8jrdsbPKkM6cKE2dhn1bfu9xfF/PdvI1eh19VJgPR5t9NLlnnp0oWeShAAZ6SdxagNYj1lgkLoUrNSdXGuR2cVV+oLIhnhnCSrAdQzvHz5nlcJaMmRuGz9OXGapPhD66FZatHK2FtPs4lL7oe+pA8kAuJGFk26SLsxSi/izcOaGxjHmyEW3nF39Jed6dD2 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)(3002001)(93006095)(93001095)(3231023)(2400081)(944501161)(10201501046)(6041268)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:CY4PR0701MB3812; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CY4PR0701MB3812; X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3812; 4:Qp1XMeIRSwIvMEAJKxOJlD4xCd8eCS7swDbO4mqjAjZREsCvU0wuu/jnhqovQMXXqfKBEZOMHp1X42GLzbjtUwrtkS3Yni7RqL39GjySpeIqeXR6nD7xDvpW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9wDrpN7KklV54leBlYrw4nxsysrQiHwoECwELJGwgcENaIxOt0j76NRjMj1Tz+/MuksjvE0mqagmV9RwOZf6raicmFv7rziVVrR14zaIlUim3yK4kpKS1KZnc=; 24:etf4TjS2FGE+VvvKOUTXkjRmiH5ttf6ArcGr/hKtDhB9o7IwdkV6NIoCkbnFz/ILo2PAPrUE3+rn5XlJZKd9gimaNctddnlV8+wgYIIvH/c=; 7:wwHrrGf752EYwmGHCSIRkvhuXRmJVbOwOte5dlxpLgZ8skFuAJ95zBwHW3tR/17gkSDoG6+UNTXlir6Ns3rhD+KNKwvuCs+XnyCg7wRa/+tUZzp7a4tEAQ9LFfkjZAGBmKoRqSWHC1AskPN4cJIZx034F442Wxcw1BSBpjfOgX342DiO8KyoUbmaUVwEz/lyw8AAngzbmq2t89wxRl7/eIRTxEgIAlapt2mlkkxF08tq2W398WpJidscUlZW6H76 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2018 20:29:42.6971 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 099c5be4-f6a9-4d3c-e0a8-08d55f7b5f7e 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: CY4PR0701MB3812 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: Darren Trapp Add support for error recovery within devloss timeout, now that FC-NVMe transport support devloss timeout. Signed-off-by: Darren Trapp Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_def.h | 1 + drivers/scsi/qla2xxx/qla_init.c | 8 +++ drivers/scsi/qla2xxx/qla_isr.c | 5 +- drivers/scsi/qla2xxx/qla_nvme.c | 142 +++++++++++++++++--------------------- drivers/scsi/qla2xxx/qla_nvme.h | 6 +- drivers/scsi/qla2xxx/qla_target.c | 13 ++-- drivers/scsi/qla2xxx/qla_target.h | 2 +- 7 files changed, 87 insertions(+), 90 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index be7d6824581a..56f78dce4d3c 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -2355,6 +2355,7 @@ typedef struct fc_port { #define NVME_PRLI_SP_DISCOVERY BIT_3 uint8_t nvme_flag; #define NVME_FLAG_REGISTERED 4 +#define NVME_FLAG_DELETING 2 struct fc_port *conflict; unsigned char logout_completed; diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index e7e51ac0bb46..5b6f3c53fdcf 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -5516,6 +5516,14 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha) break; } + if (fcport->fc4f_nvme) { + if (fcport->disc_state == DSC_DELETE_PEND) { + fcport->disc_state = DSC_GNL; + vha->fcport_count--; + fcport->login_succ = 0; + } + } + if (found) { spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); continue; diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index 14109d86c3f6..d1e7fd905f16 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -1908,7 +1908,7 @@ qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, void *tsk) } else { switch (le16_to_cpu(sts->comp_status)) { case CS_COMPLETE: - ret = 0; + ret = QLA_SUCCESS; break; case CS_ABORTED: @@ -1920,7 +1920,8 @@ qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, void *tsk) "NVME-%s ERR Handling - hdl=%x completion status(%x) resid=%x ox_id=%x\n", sp->name, sp->handle, sts->comp_status, le32_to_cpu(sts->residual_len), sts->ox_id); - fd->transferred_length = fd->payload_length; + fd->transferred_length = 0; + iocb->u.nvme.rsp_pyld_len = 0; ret = QLA_ABORTED; break; diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c index 162a523b985e..a8e81fc14c44 100644 --- a/drivers/scsi/qla2xxx/qla_nvme.c +++ b/drivers/scsi/qla2xxx/qla_nvme.c @@ -16,15 +16,13 @@ static void qla_nvme_unregister_remote_port(struct work_struct *); int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport) { - struct nvme_rport *rport; + struct qla_nvme_rport *rport; + struct nvme_fc_port_info req; int ret; if (!IS_ENABLED(CONFIG_NVME_FC)) return 0; - if (fcport->nvme_flag & NVME_FLAG_REGISTERED) - return 0; - if (!vha->flags.nvme_enabled) { ql_log(ql_log_info, vha, 0x2100, "%s: Not registering target since Host NVME is not enabled\n", @@ -33,38 +31,35 @@ int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport) } if (!(fcport->nvme_prli_service_param & - (NVME_PRLI_SP_TARGET | NVME_PRLI_SP_DISCOVERY))) + (NVME_PRLI_SP_TARGET | NVME_PRLI_SP_DISCOVERY)) || + (fcport->nvme_flag & NVME_FLAG_REGISTERED)) return 0; INIT_WORK(&fcport->nvme_del_work, qla_nvme_unregister_remote_port); - rport = kzalloc(sizeof(*rport), GFP_KERNEL); - if (!rport) { - ql_log(ql_log_warn, vha, 0x2101, - "%s: unable to alloc memory\n", __func__); - return -ENOMEM; - } - rport->req.port_name = wwn_to_u64(fcport->port_name); - rport->req.node_name = wwn_to_u64(fcport->node_name); - rport->req.port_role = 0; + memset(&req, 0, sizeof(struct nvme_fc_port_info)); + req.port_name = wwn_to_u64(fcport->port_name); + req.node_name = wwn_to_u64(fcport->node_name); + req.port_role = 0; + req.dev_loss_tmo = NVME_FC_DEV_LOSS_TMO; if (fcport->nvme_prli_service_param & NVME_PRLI_SP_INITIATOR) - rport->req.port_role = FC_PORT_ROLE_NVME_INITIATOR; + req.port_role = FC_PORT_ROLE_NVME_INITIATOR; if (fcport->nvme_prli_service_param & NVME_PRLI_SP_TARGET) - rport->req.port_role |= FC_PORT_ROLE_NVME_TARGET; + req.port_role |= FC_PORT_ROLE_NVME_TARGET; if (fcport->nvme_prli_service_param & NVME_PRLI_SP_DISCOVERY) - rport->req.port_role |= FC_PORT_ROLE_NVME_DISCOVERY; + req.port_role |= FC_PORT_ROLE_NVME_DISCOVERY; - rport->req.port_id = fcport->d_id.b24; + req.port_id = fcport->d_id.b24; ql_log(ql_log_info, vha, 0x2102, "%s: traddr=nn-0x%016llx:pn-0x%016llx PortID:%06x\n", - __func__, rport->req.node_name, rport->req.port_name, - rport->req.port_id); + __func__, req.node_name, req.port_name, + req.port_id); - ret = nvme_fc_register_remoteport(vha->nvme_local_port, &rport->req, + ret = nvme_fc_register_remoteport(vha->nvme_local_port, &req, &fcport->nvme_remote_port); if (ret) { ql_log(ql_log_warn, vha, 0x212e, @@ -73,10 +68,11 @@ int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport) return ret; } - fcport->nvme_remote_port->private = fcport; - fcport->nvme_flag |= NVME_FLAG_REGISTERED; + rport = fcport->nvme_remote_port->private; rport->fcport = fcport; list_add_tail(&rport->list, &vha->nvme_rport_list); + + fcport->nvme_flag |= NVME_FLAG_REGISTERED; return 0; } @@ -174,26 +170,23 @@ static void qla_nvme_sp_done(void *ptr, int res) if (!atomic_dec_and_test(&sp->ref_count)) return; - if (!(sp->fcport->nvme_flag & NVME_FLAG_REGISTERED)) - goto rel; - - if (unlikely(res == QLA_FUNCTION_FAILED)) - fd->status = NVME_SC_INTERNAL; - else + if (res == QLA_SUCCESS) fd->status = 0; + else + fd->status = NVME_SC_INTERNAL; fd->rcv_rsplen = nvme->u.nvme.rsp_pyld_len; list_add_tail(&nvme->u.nvme.entry, &sp->qpair->nvme_done_list); + return; -rel: - qla2xxx_rel_qpair_sp(sp->qpair, sp); } static void qla_nvme_ls_abort(struct nvme_fc_local_port *lport, struct nvme_fc_remote_port *rport, struct nvmefc_ls_req *fd) { struct nvme_private *priv = fd->private; - fc_port_t *fcport = rport->private; + struct qla_nvme_rport *qla_rport = rport->private; + fc_port_t *fcport = qla_rport->fcport; srb_t *sp = priv->sp; int rval; struct qla_hw_data *ha = fcport->vha->hw; @@ -218,7 +211,8 @@ static void qla_nvme_ls_complete(struct work_struct *work) static int qla_nvme_ls_req(struct nvme_fc_local_port *lport, struct nvme_fc_remote_port *rport, struct nvmefc_ls_req *fd) { - fc_port_t *fcport = rport->private; + struct qla_nvme_rport *qla_rport = rport->private; + fc_port_t *fcport = qla_rport->fcport; struct srb_iocb *nvme; struct nvme_private *priv = fd->private; struct scsi_qla_host *vha; @@ -226,9 +220,6 @@ static int qla_nvme_ls_req(struct nvme_fc_local_port *lport, struct qla_hw_data *ha; srb_t *sp; - if (!(fcport->nvme_flag & NVME_FLAG_REGISTERED)) - return rval; - vha = fcport->vha; ha = vha->hw; /* Alloc SRB structure */ @@ -275,7 +266,8 @@ static void qla_nvme_fcp_abort(struct nvme_fc_local_port *lport, struct nvme_private *priv = fd->private; srb_t *sp = priv->sp; int rval; - fc_port_t *fcport = rport->private; + struct qla_nvme_rport *qla_rport = rport->private; + fc_port_t *fcport = qla_rport->fcport; struct qla_hw_data *ha = fcport->vha->hw; rval = ha->isp_ops->abort_command(sp); @@ -288,11 +280,10 @@ static void qla_nvme_fcp_abort(struct nvme_fc_local_port *lport, static void qla_nvme_poll(struct nvme_fc_local_port *lport, void *hw_queue_handle) { - struct scsi_qla_host *vha = lport->private; - unsigned long flags; struct qla_qpair *qpair = hw_queue_handle; + unsigned long flags; + struct scsi_qla_host *vha = lport->private; - /* Acquire ring specific lock */ spin_lock_irqsave(&qpair->qp_lock, flags); qla24xx_process_response_queue(vha, qpair->rsp); spin_unlock_irqrestore(&qpair->qp_lock, flags); @@ -495,6 +486,7 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port *lport, srb_t *sp; struct qla_qpair *qpair = hw_queue_handle; struct nvme_private *priv; + struct qla_nvme_rport *qla_rport = rport->private; if (!fd) { ql_log(ql_log_warn, NULL, 0x2134, "NO NVMe FCP request\n"); @@ -502,14 +494,14 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port *lport, } priv = fd->private; - fcport = rport->private; + fcport = qla_rport->fcport; if (!fcport) { ql_log(ql_log_warn, NULL, 0x210e, "No fcport ptr\n"); return rval; } vha = fcport->vha; - if ((!qpair) || (!(fcport->nvme_flag & NVME_FLAG_REGISTERED))) + if (!qpair) return -EBUSY; /* Alloc SRB structure */ @@ -552,22 +544,27 @@ static void qla_nvme_localport_delete(struct nvme_fc_local_port *lport) static void qla_nvme_remoteport_delete(struct nvme_fc_remote_port *rport) { fc_port_t *fcport; - struct nvme_rport *r_port, *trport; + struct qla_nvme_rport *qla_rport = rport->private, *trport; - fcport = rport->private; + fcport = qla_rport->fcport; fcport->nvme_remote_port = NULL; fcport->nvme_flag &= ~NVME_FLAG_REGISTERED; - list_for_each_entry_safe(r_port, trport, + list_for_each_entry_safe(qla_rport, trport, &fcport->vha->nvme_rport_list, list) { - if (r_port->fcport == fcport) { - list_del(&r_port->list); + if (qla_rport->fcport == fcport) { + list_del(&qla_rport->list); break; } } - kfree(r_port); complete(&fcport->nvme_del_done); + if (!test_bit(UNLOADING, &fcport->vha->dpc_flags)) { + INIT_WORK(&fcport->free_work, qlt_free_session_done); + schedule_work(&fcport->free_work); + } + + fcport->nvme_flag &= ~(NVME_FLAG_REGISTERED | NVME_FLAG_DELETING); ql_log(ql_log_info, fcport->vha, 0x2110, "remoteport_delete of %p completed.\n", fcport); } @@ -587,7 +584,7 @@ static struct nvme_fc_port_template qla_nvme_fc_transport = { .max_dif_sgl_segments = 64, .dma_boundary = 0xFFFFFFFF, .local_priv_sz = 8, - .remote_priv_sz = 0, + .remote_priv_sz = sizeof(struct qla_nvme_rport), .lsrqst_priv_sz = sizeof(struct nvme_private), .fcprqst_priv_sz = sizeof(struct nvme_private), }; @@ -606,22 +603,6 @@ static int qla_nvme_wait_on_command(srb_t *sp) return ret; } -static int qla_nvme_wait_on_rport_del(fc_port_t *fcport) -{ - int ret = QLA_SUCCESS; - int timeout; - - timeout = wait_for_completion_timeout(&fcport->nvme_del_done, - msecs_to_jiffies(2000)); - if (!timeout) { - ret = QLA_FUNCTION_FAILED; - ql_log(ql_log_info, fcport->vha, 0x2111, - "timed out waiting for fcport=%p to delete\n", fcport); - } - - return ret; -} - void qla_nvme_abort(struct qla_hw_data *ha, struct srb *sp) { int rval; @@ -636,7 +617,7 @@ static void qla_nvme_unregister_remote_port(struct work_struct *work) { struct fc_port *fcport = container_of(work, struct fc_port, nvme_del_work); - struct nvme_rport *rport, *trport; + struct qla_nvme_rport *qla_rport, *trport; if (!IS_ENABLED(CONFIG_NVME_FC)) return; @@ -644,51 +625,52 @@ static void qla_nvme_unregister_remote_port(struct work_struct *work) ql_log(ql_log_warn, NULL, 0x2112, "%s: unregister remoteport on %p\n",__func__, fcport); - list_for_each_entry_safe(rport, trport, + list_for_each_entry_safe(qla_rport, trport, &fcport->vha->nvme_rport_list, list) { - if (rport->fcport == fcport) { + if (qla_rport->fcport == fcport) { ql_log(ql_log_info, fcport->vha, 0x2113, "%s: fcport=%p\n", __func__, fcport); init_completion(&fcport->nvme_del_done); nvme_fc_unregister_remoteport( fcport->nvme_remote_port); - qla_nvme_wait_on_rport_del(fcport); + wait_for_completion(&fcport->nvme_del_done); + break; } } } void qla_nvme_delete(struct scsi_qla_host *vha) { - struct nvme_rport *rport, *trport; + struct qla_nvme_rport *qla_rport, *trport; fc_port_t *fcport; int nv_ret; if (!IS_ENABLED(CONFIG_NVME_FC)) return; - list_for_each_entry_safe(rport, trport, &vha->nvme_rport_list, list) { - fcport = rport->fcport; + list_for_each_entry_safe(qla_rport, trport, + &vha->nvme_rport_list, list) { + fcport = qla_rport->fcport; ql_log(ql_log_info, fcport->vha, 0x2114, "%s: fcport=%p\n", __func__, fcport); init_completion(&fcport->nvme_del_done); nvme_fc_unregister_remoteport(fcport->nvme_remote_port); - qla_nvme_wait_on_rport_del(fcport); + wait_for_completion(&fcport->nvme_del_done); } if (vha->nvme_local_port) { init_completion(&vha->nvme_del_done); + ql_log(ql_log_info, vha, 0x2116, + "unregister localport=%p\n", + vha->nvme_local_port); nv_ret = nvme_fc_unregister_localport(vha->nvme_local_port); - if (nv_ret == 0) - ql_log(ql_log_info, vha, 0x2116, - "unregistered localport=%p\n", - vha->nvme_local_port); - else + if (nv_ret) ql_log(ql_log_info, vha, 0x2115, "Unregister of localport failed\n"); - wait_for_completion_timeout(&vha->nvme_del_done, - msecs_to_jiffies(5000)); + else + wait_for_completion(&vha->nvme_del_done); } } diff --git a/drivers/scsi/qla2xxx/qla_nvme.h b/drivers/scsi/qla2xxx/qla_nvme.h index 7f05fa1c77db..7becfc1b3e69 100644 --- a/drivers/scsi/qla2xxx/qla_nvme.h +++ b/drivers/scsi/qla2xxx/qla_nvme.h @@ -14,6 +14,9 @@ #include "qla_def.h" +/* default dev loss time (seconds) before transport tears down ctrl */ +#define NVME_FC_DEV_LOSS_TMO 30 + #define NVME_ATIO_CMD_OFF 32 #define NVME_FIRST_PACKET_CMDLEN (64 - NVME_ATIO_CMD_OFF) #define Q2T_NVME_NUM_TAGS 2048 @@ -31,8 +34,7 @@ struct nvme_private { int comp_status; }; -struct nvme_rport { - struct nvme_fc_port_info req; +struct qla_nvme_rport { struct list_head list; struct fc_port *fcport; }; diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index fc89af8fe256..14359656591e 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -961,7 +961,7 @@ qlt_send_first_logo(struct scsi_qla_host *vha, qlt_port_logo_t *logo) logo->cmd_count, res); } -static void qlt_free_session_done(struct work_struct *work) +void qlt_free_session_done(struct work_struct *work) { struct fc_port *sess = container_of(work, struct fc_port, free_work); @@ -1169,11 +1169,14 @@ void qlt_unreg_sess(struct fc_port *sess) sess->last_rscn_gen = sess->rscn_gen; sess->last_login_gen = sess->login_gen; - if (sess->nvme_flag & NVME_FLAG_REGISTERED) + if (sess->nvme_flag & NVME_FLAG_REGISTERED && + !(sess->nvme_flag & NVME_FLAG_DELETING)) { + sess->nvme_flag |= NVME_FLAG_DELETING; schedule_work(&sess->nvme_del_work); - - INIT_WORK(&sess->free_work, qlt_free_session_done); - schedule_work(&sess->free_work); + } else { + INIT_WORK(&sess->free_work, qlt_free_session_done); + schedule_work(&sess->free_work); + } } EXPORT_SYMBOL(qlt_unreg_sess); diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h index bb67b5a284a8..728ce74358e7 100644 --- a/drivers/scsi/qla2xxx/qla_target.h +++ b/drivers/scsi/qla2xxx/qla_target.h @@ -1016,7 +1016,7 @@ extern void qlt_fc_port_deleted(struct scsi_qla_host *, fc_port_t *, int); extern int __init qlt_init(void); extern void qlt_exit(void); extern void qlt_update_vp_map(struct scsi_qla_host *, int); - +extern void qlt_free_session_done(struct work_struct *); /* * This macro is used during early initializations when host->active_mode * is not set. Right now, ha value is ignored.