From patchwork Thu Aug 30 16:35:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10582317 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 7DAB65A4 for ; Thu, 30 Aug 2018 16:36:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A8712C0EF for ; Thu, 30 Aug 2018 16:36:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EBF02C132; Thu, 30 Aug 2018 16:36:12 +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 B55B92C0EF for ; Thu, 30 Aug 2018 16:36:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727711AbeH3UjI (ORCPT ); Thu, 30 Aug 2018 16:39:08 -0400 Received: from mail-sn1nam02on0077.outbound.protection.outlook.com ([104.47.36.77]:29472 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727676AbeH3UjI (ORCPT ); Thu, 30 Aug 2018 16:39:08 -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=CWG8HQFSOfyy4a2I4Y3pWjla0sIctTODaukZHxMh0IQ=; b=Iq90IWNIMFHdeCwp5gExV18JacX3WHzpRgYaCg8OCwc1URQUgkK21GeIAN3WJBYHCOaLqP2dEmkrhnWV4eth/9xwPemP1lb8mtTLweNiEM1F+EYipltEMqLLy1GfoUUv1N6fPiMf5Ub5x6iho/uk2Kv7aSfJJq70UjuJqeasMKc= Received: from BYAPR07CA0046.namprd07.prod.outlook.com (2603:10b6:a03:60::23) by SN6PR07MB4399.namprd07.prod.outlook.com (2603:10b6:805:58::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.14; Thu, 30 Aug 2018 16:36:07 +0000 Received: from CO1NAM05FT023.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e50::203) by BYAPR07CA0046.outlook.office365.com (2603:10b6:a03:60::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1101.15 via Frontend Transport; Thu, 30 Aug 2018 16:36:06 +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 CO1NAM05FT023.mail.protection.outlook.com (10.152.96.131) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.1122.2 via Frontend Transport; Thu, 30 Aug 2018 16:36:06 +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, 30 Aug 2018 09:35:51 -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 w7UGZqdt027363; Thu, 30 Aug 2018 09:35:52 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w7UGZqXw027362; Thu, 30 Aug 2018 09:35:52 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH 10/14] qla2xxx: Remove all rports if fabric scan retry fails Date: Thu, 30 Aug 2018 09:35:46 -0700 Message-ID: <20180830163550.27288-11-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180830163550.27288-1-himanshu.madhani@cavium.com> References: <20180830163550.27288-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)(39860400002)(396003)(376002)(136003)(346002)(2980300002)(438002)(199004)(189003)(8676002)(14444005)(36756003)(486006)(186003)(2616005)(446003)(4326008)(305945005)(5660300001)(72206003)(6666003)(478600001)(87636003)(42186006)(110136005)(51416003)(44832011)(476003)(126002)(11346002)(316002)(81156014)(81166006)(336012)(26005)(356003)(16586007)(106002)(76176011)(54906003)(47776003)(1076002)(50226002)(86362001)(8936002)(50466002)(48376002)(106466001)(2906002)(80596001)(69596002);DIR:OUT;SFP:1101;SCL:1;SRVR:SN6PR07MB4399;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;CO1NAM05FT023;1:IhteROUJHnB5WoXutMr/kzIxzvf19MCtZMagRZdKEr7MFTKzHF9sTOfVbh7IhWDoO+E7LHU9pPaY4Hr8HAfCnLcDbAUpyuLaAAEs4OveFHNn3Q1wP+6NQm0yvG7SI098 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 91b02f15-10bc-4cf2-634b-08d60e96af37 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(5600074)(711020)(4608076)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060);SRVR:SN6PR07MB4399; X-Microsoft-Exchange-Diagnostics: 1;SN6PR07MB4399;3:YbuKduAgy/jfpOJXrrf0saVELL38mboiZaKdCG9OCaHPvwvroXh5dFFHaeuyQwvQbKxrLK3XMS2arW+SqaPd5xJHtov+f7uDDB9xWJvsHKU9QmvGqdomg8KxRUWolyFxpHfcV8EbJJsF7DaRhSmE+z49rNSO3W/NUtBmfoyT+eKZN9UFmg/cCyeF3ZmW8fwunY7LrqGziSG12wwWCwhbejOV6R0z4Uj8FTvTt97erzCCp3b114kTWBs0PFq2BYwRgjcL7ECyGmbkV89LBPcp2HTK9VVnGcmBSiWU45q1islEQGaGm1HJctM9xwegJvhV+e99lPddJ4Rv0aOzlMh3WCurQk5oAwVRK8edzTaVqzo=;25:dl2USFwiyLgQuFARbmExYTMUjst3ruCaDY6LqpKBE7e3EHEaO+jDH5xXpfANpcVrvkRhX7iuZYBMYeOYJnyjq3yRSc7dHJVNO7Ehq/+aYN42opBZQlHa0n5lYazPzK9cXlOPP+IQiAj/F2Vm6BAGNr33oCafL9jZ8TgzYkR1g9DuMJVPBTvHLa8pkQv1XR4Q9I9Oxt1+lM8G8cBWArGVMM/ZONlfraYEX2rpWZ3yc3F4F4Ga/pa+dOAFr/1IymnT9CQgwTgDZelAqInsLl7nvodZnyDwFaK7HlCJ2QwdOLHpoRzX6KtlAFeZ0H8aXj3xwWnfvgbZ1jrfKOW+rrs9ng== X-MS-TrafficTypeDiagnostic: SN6PR07MB4399: X-Microsoft-Exchange-Diagnostics: 1;SN6PR07MB4399;31:JEItMxX5RcAhbg5apv4ZuJjvwLDH4hXcSzFiQbEp/s2G5GkEZyconazrnYWYMLuGHzkMDdFglSTpFec4rpf6YS4yzhOY2BLFhK8/el8yxXWj4qy3VufDWwtEhZ/mTPXGZ7DI0UzEZFnynYSFWIjRCvT412ZSUwvZHK0vJQN6fvsEXjThdvnH3RyiHy4P+HOwMDKDjmX3xsi091xKA1OS/79PxWBWa7etSpQIIeL5hgo=;20:wTgIZJ5iiKr8BsmmBT5EC+5mbKp9E1PG18Pdad4/XDqAnu0KTes8fK6NcIzfxoq3WJG0xgeVeB0pZLajiY7NRpeWQzxU5EmOgh3NPSUP+jn9/+2zCY9++tVxjNC54QQaFhleiHAPV/9PgnvCPTZfIuzXIfXtAl/7mMEoxxHHgytoQgPKO72byBYwhHJTTgb4MC33FbLRfidLFyHw6Qyru4U9Lafio2GIJx693qCfYrczoXRe4LHyfAwGhYJrsn9ebph0BWSCG5IEcQxgGt+sz0/bG24K/+Ncrd1Snvto5qfww8wut4dFuAXFstKZ5WkZn4WTH2L6Q5rPHVCDa+4YQMozKnHZerI2oYEvM/G0ltwfGk7QbOj0LS+EhHQum5Pc3I7U0d94F1oGRcl+/sXN5g1bQuQhZtmhfttHHTJFajmnx7h2LJJ0Fcl8FscUwwP7LYUynFJ77z33LKTkecvu0IvyKSDUtUPBdeRVUsKhQK17DrrzrHZ4kxjzPc9pdcvY X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(163750095850); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231311)(944501410)(52105095)(93006095)(93004095)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016);SRVR:SN6PR07MB4399;BCL:0;PCL:0;RULEID:;SRVR:SN6PR07MB4399; X-Microsoft-Exchange-Diagnostics: 1;SN6PR07MB4399;4:p9SEpzZl0aZ8SW5qu2Inaa5fEXbTKyMgAQWWJwyIK8uio7+7FjL6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XpiwnpTecxR7Ddq+t6NeDkoo0tA7lcgnnX0kYIwEMYo31Gkl05Ro109nzVbz44ighVSVDzSJxqv046SL0NL458L9b1pTXbFECIkNv3WNrOxiI1dhlP+xrk6u5dkzjhC4TvJZzReGk9rDoP1dqUpXOeZJtxM0InFJce3gP7qrk9SMIt7fJFiQNzyYBO/Q9Hck8pLUi1KW0k+8lQ==;5:G9L7lOKRDuN81R1rVs8PDx7h5mTro3nbieZDqQ1o5oftrltGQu9bEkz7ksrxHGWds90Kt5IC6m8sh65s6ii7nQd8iQG2E8IFopfZ5Qb2oG+SU29BAaHrOTO9FfD+MKuoEEkpT59KdxK3qEpWKwQd2E32hTy5Okqnm1reAfWs8tQ=;7:WRvN3xI56XK3VsPq1x44qqIoq2eMu/YYRJbv5VXlPmf/NyeN/TOiti6ckJn7fz4BHr7Y2a/xRPPdrpGyBe3qe2tjzLzFRDagC2hO+3VPapBUggRQZq1GIGYyi4uD6qRcioWh2n2WEq/oZIkGqnM6vl4qs+R8FPYtQc6a/4C7cy8KyPJbEL4Te/BnC2fcFZm2wGTaGpRaeKyAPrNeQ0rQDXy6jboJ/tpejVLkZih6/CbZ593bvVxg2hnrqNitEZet SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2018 16:36:06.4373 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 91b02f15-10bc-4cf2-634b-08d60e96af37 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: SN6PR07MB4399 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 When all fabric scan retries fail, remove all RPorts, DMA resources for the command otherwise we have stale Rports. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_gs.c | 128 +++++++++++++++++++++--------------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c index 1cb27eb46731..85cbe59b4f58 100644 --- a/drivers/scsi/qla2xxx/qla_gs.c +++ b/drivers/scsi/qla2xxx/qla_gs.c @@ -3995,6 +3995,41 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, srb_t *sp) } } +static int qla2x00_post_gnnft_gpnft_done_work(struct scsi_qla_host *vha, + srb_t *sp, int cmd) +{ + struct qla_work_evt *e; + + if (cmd != QLA_EVT_GPNFT_DONE && cmd != QLA_EVT_GNNFT_DONE) + return QLA_PARAMETER_ERROR; + + e = qla2x00_alloc_work(vha, cmd); + if (!e) + return QLA_FUNCTION_FAILED; + + e->u.iosb.sp = sp; + + return qla2x00_post_work(vha, e); +} + +static int qla2x00_post_nvme_gpnft_done_work(struct scsi_qla_host *vha, + srb_t *sp, int cmd) +{ + struct qla_work_evt *e; + + if (cmd != QLA_EVT_GPNFT) + return QLA_PARAMETER_ERROR; + + e = qla2x00_alloc_work(vha, cmd); + if (!e) + return QLA_FUNCTION_FAILED; + + e->u.gpnft.fc4_type = FC4_TYPE_NVME; + e->u.gpnft.sp = sp; + + return qla2x00_post_work(vha, e); +} + static void qla2x00_find_free_fcp_nvme_slot(struct scsi_qla_host *vha, struct srb *sp) { @@ -4095,22 +4130,36 @@ static void qla2x00_async_gpnft_gnnft_sp_done(void *s, int res) { struct srb *sp = s; struct scsi_qla_host *vha = sp->vha; - struct qla_work_evt *e; struct ct_sns_req *ct_req = (struct ct_sns_req *)sp->u.iocb_cmd.u.ctarg.req; u16 cmd = be16_to_cpu(ct_req->command); u8 fc4_type = sp->gen2; unsigned long flags; + int rc; /* gen2 field is holding the fc4type */ ql_dbg(ql_dbg_disc, vha, 0xffff, "Async done-%s res %x FC4Type %x\n", sp->name, res, sp->gen2); + sp->rc = res; if (res) { unsigned long flags; + const char *name = sp->name; + + /* + * We are in an Interrupt context, queue up this + * sp for GNNFT_DONE work. This will allow all + * the resource to get freed up. + */ + rc = qla2x00_post_gnnft_gpnft_done_work(vha, sp, + QLA_EVT_GNNFT_DONE); + if (rc) { + /* Cleanup here to prevent memory leak */ + qla24xx_sp_unmap(vha, sp); + sp->free(sp); + } - sp->free(sp); spin_lock_irqsave(&vha->work_lock, flags); vha->scan.scan_flags &= ~SF_SCANNING; vha->scan.scan_retry++; @@ -4121,9 +4170,9 @@ static void qla2x00_async_gpnft_gnnft_sp_done(void *s, int res) set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); qla2xxx_wake_dpc(vha); } else { - ql_dbg(ql_dbg_disc, sp->vha, 0xffff, - "Async done-%s rescan failed on all retries\n", - sp->name); + ql_dbg(ql_dbg_disc, vha, 0xffff, + "Async done-%s rescan failed on all retries.\n", + name); } return; } @@ -4138,80 +4187,31 @@ static void qla2x00_async_gpnft_gnnft_sp_done(void *s, int res) vha->scan.scan_flags &= ~SF_SCANNING; spin_unlock_irqrestore(&vha->work_lock, flags); - e = qla2x00_alloc_work(vha, QLA_EVT_GPNFT); - if (!e) { - /* - * please ignore kernel warning. Otherwise, - * we have mem leak. - */ - if (sp->u.iocb_cmd.u.ctarg.req) { - dma_free_coherent(&vha->hw->pdev->dev, - sp->u.iocb_cmd.u.ctarg.req_allocated_size, - sp->u.iocb_cmd.u.ctarg.req, - sp->u.iocb_cmd.u.ctarg.req_dma); - sp->u.iocb_cmd.u.ctarg.req = NULL; - } - if (sp->u.iocb_cmd.u.ctarg.rsp) { - dma_free_coherent(&vha->hw->pdev->dev, - sp->u.iocb_cmd.u.ctarg.rsp_allocated_size, - sp->u.iocb_cmd.u.ctarg.rsp, - sp->u.iocb_cmd.u.ctarg.rsp_dma); - sp->u.iocb_cmd.u.ctarg.rsp = NULL; - } - - ql_dbg(ql_dbg_disc, vha, 0xffff, - "Async done-%s unable to alloc work element\n", - sp->name); - sp->free(sp); + sp->rc = res; + rc = qla2x00_post_nvme_gpnft_done_work(vha, sp, QLA_EVT_GPNFT); + if (!rc) { + qla24xx_sp_unmap(vha, sp); set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); return; } - e->u.gpnft.fc4_type = FC4_TYPE_NVME; - sp->rc = res; - e->u.gpnft.sp = sp; - - qla2x00_post_work(vha, e); - return; } if (cmd == GPN_FT_CMD) { del_timer(&sp->u.iocb_cmd.timer); - e = qla2x00_alloc_work(vha, QLA_EVT_GPNFT_DONE); + rc = qla2x00_post_gnnft_gpnft_done_work(vha, sp, + QLA_EVT_GPNFT_DONE); } else { - e = qla2x00_alloc_work(vha, QLA_EVT_GNNFT_DONE); + rc = qla2x00_post_gnnft_gpnft_done_work(vha, sp, + QLA_EVT_GNNFT_DONE); } - if (!e) { - /* please ignore kernel warning. Otherwise, we have mem leak. */ - if (sp->u.iocb_cmd.u.ctarg.req) { - dma_free_coherent(&vha->hw->pdev->dev, - sp->u.iocb_cmd.u.ctarg.req_allocated_size, - sp->u.iocb_cmd.u.ctarg.req, - sp->u.iocb_cmd.u.ctarg.req_dma); - sp->u.iocb_cmd.u.ctarg.req = NULL; - } - if (sp->u.iocb_cmd.u.ctarg.rsp) { - dma_free_coherent(&vha->hw->pdev->dev, - sp->u.iocb_cmd.u.ctarg.rsp_allocated_size, - sp->u.iocb_cmd.u.ctarg.rsp, - sp->u.iocb_cmd.u.ctarg.rsp_dma); - sp->u.iocb_cmd.u.ctarg.rsp = NULL; - } - - ql_dbg(ql_dbg_disc, vha, 0xffff, - "Async done-%s unable to alloc work element\n", - sp->name); - sp->free(sp); + if (rc) { + qla24xx_sp_unmap(vha, sp); set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); return; } - - sp->rc = res; - e->u.iosb.sp = sp; - - qla2x00_post_work(vha, e); } /*