From patchwork Thu Nov 30 03:40:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10084213 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 F3577602B9 for ; Thu, 30 Nov 2017 03:41:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA30029935 for ; Thu, 30 Nov 2017 03:41:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF2A829B02; Thu, 30 Nov 2017 03:41:40 +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 6442C29935 for ; Thu, 30 Nov 2017 03:41:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753491AbdK3Dlj (ORCPT ); Wed, 29 Nov 2017 22:41:39 -0500 Received: from mail-co1nam03on0079.outbound.protection.outlook.com ([104.47.40.79]:17710 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753482AbdK3Dla (ORCPT ); Wed, 29 Nov 2017 22:41:30 -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=DAghytrVxd2XyQh1l2NkQwj56GPzyVRp6VD3I6EQk78=; b=j0EJ06k20/c+nkajmge43NP+y3/mflCRvR1/pmUqTe0fLOhuo985WoKD46C7Inl5LeBFQIy2XMm3l/zm7ojPAKJso2mfLpbBrhAAE3FJ9tHYf7INn3rCTT8OhkAFsAGxNo3PJ+5hHlJ69hGiz/ryVSzNsOaI58t/BWRzUPu/5EM= Received: from CO2PR07CA0053.namprd07.prod.outlook.com (2603:10b6:100::21) by DM5PR0701MB3813.namprd07.prod.outlook.com (2603:10b6:4:7f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.260.4; Thu, 30 Nov 2017 03:41:28 +0000 Received: from BL2FFO11FD052.protection.gbl (2a01:111:f400:7c09::116) by CO2PR07CA0053.outlook.office365.com (2603:10b6:100::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.282.5 via Frontend Transport; Thu, 30 Nov 2017 03:41:28 +0000 Authentication-Results: spf=none (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: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BL2FFO11FD052.mail.protection.outlook.com (10.173.161.214) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.218.12 via Frontend Transport; Thu, 30 Nov 2017 03:41:27 +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; Wed, 29 Nov 2017 19:40:52 -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 vAU3eqoc015190; Wed, 29 Nov 2017 19:40:52 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id vAU3eq0e015189; Wed, 29 Nov 2017 19:40:52 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH v2 21/22] qla2xxx: Fix memory leak in dual/target mode Date: Wed, 29 Nov 2017 19:40:46 -0800 Message-ID: <20171130034047.15070-22-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20171130034047.15070-1-himanshu.madhani@cavium.com> References: <20171130034047.15070-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)(6009001)(346002)(376002)(2980300002)(428002)(199003)(189002)(42186006)(1076002)(16586007)(69596002)(8936002)(106466001)(189998001)(316002)(356003)(54906003)(110136005)(50226002)(50986010)(76176010)(47776003)(51416003)(80596001)(33646002)(87636003)(478600001)(101416001)(86362001)(50466002)(36756003)(72206003)(48376002)(2950100002)(2906002)(8676002)(4326008)(6666003)(305945005)(105586002)(81156014)(81166006)(5660300001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR0701MB3813; H:CAEXCH02.caveonetworks.com; FPR:; SPF:None; PTR:50-232-66-26-static.hfc.comcastbusiness.net; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD052; 1:udliy87xFwRCUor9Qdf48NzAA4h2bhB2kppcE6zEXOOskX9iNLomfr3+Q1KWf2IpFv/JVk04hdtobcyYcNOORi1xMB5c2DEMYTzL0U2lfxhyZoqvlMUODaIGqtLIrVhb X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d04547ff-bd37-4da6-8b60-08d537a43d03 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603280); SRVR:DM5PR0701MB3813; X-Microsoft-Exchange-Diagnostics: 1; DM5PR0701MB3813; 3:tQsupEGWBGA0plwjjRBLMq7unk9eZA8xp4d3MlgJhUNXKRaUxwRdBt49/Qs6e0OMvZHNSuK43Hzqmjdkw51KCvRJsAAD5FzTfO0VKGUouuQ9eAZfidexJuAqy03Mfb/Mqs6Atxp3TY6J4k4HCjdjFcA5Y2ifOjNhr5Yfkf6fZ8/ayX3qLpK6lztve8T9HKlNVWioUoeBT1SY0JD0P/h/noJKS30CqT38G738GqVv7qSspixMg4qvnB7PCnkBfCm2WrdtGIbWVTqMp9MDW335md/L1L3BzMRyefBwG9akq75Xf2ZmcdgwUuQnfJ/ACej3mVWJCKoRp3psIuVtxYcmnZV3FxAz3vr9nKGfptg2lxo=; 25:5NnHkqTtw4T3xL994M8MUkaTc905bRfWINqyGCmJP4O5I2wDKN0FDatvuRD/OtXdae5AXnBJ91Z3qEQF/PvSvvkJOqopecQpR9IKcRXM+Z/IPQjq7I4ImkmHrSlXCkpnJuejMTKWU8S0fxt75E2ULrwNAgOzjcyHdgy/rYAbrXwy4v1X52IkPLgxLalkxy+6IIAngppnRy/p/GVjNeRkMLLD6jLhe29MJ4zBwK2r6mf4kngSX+wjF7tvr+yP+NibBgypj+64dVXuzWHih02Z3uCTedGdLFtqyU85uhi4LTqYZX36yCavUDXH+714Aw78u61NbEdsEXAAWxUV682eIg== X-MS-TrafficTypeDiagnostic: DM5PR0701MB3813: X-Microsoft-Exchange-Diagnostics: 1; DM5PR0701MB3813; 31:qYkJ2cGNTPOBIvAgVcTOwDCxz77T6WR10SQnIKEDTWwDnLG/7qfVuiNxdFEeGysPZg/JDnzOGCIDW1CZf8XecnQ4oErxie1pCjCSYDoo8TWSfv1Uon8qWKZa8w710zwi67L+7LU9VrJfKmcQmpRnPRpl5hDZLINjbpUsWL02tdEiUE7FVZC2jfKXcOBkBEF4qCiAvLqhW7+hkfY/N/k9X4I+i5lpeBwuAFVr0mavShE=; 20:LAK7oclVSpSDc74IiksFB5SSW7NjNMwauQUQ1tk3e614ay0H3C5s9Qc2lX3WV2TSqaa+4ksYmDvS6jTwHw6nDgmQU/wdr18I0o0uuJPBLG8k8dYST+P+c9B8uysP29ukd/Rxp3e9MrEK1PQW+vEzOgm432E4Utv7Toh8yHLxLjbQwwpF7Jp+r4lQZ7rdXBfa+cXAbZTh2hzE66iGk2fPV9KEfxYkc3vhLQe4J1UaBx8OQqy9DslID5HWtYJfximU4/9100Uzz3ytB05KC6YqBYy3VnIV1y+5ve93LV0nfKXmrJsRGOgk1+G0FhHOH4tRU18K/OaMBq04tx5BH3RE2+22uO6wqZxLNB2YN6u1e2Ned8s0h2nfO9YGDxK+M+w4cWtgi90gjwGvsX98IDNFW/MpeLt23tH+YNDeLYqfZMoPtfbgeoY+BEqfiCbIbVEWYa5OvCb5qYrH2mFc9duXVi2osXY8eQJXOlpqsAKT73JUE3tew1Ru4ulyte6g19G6 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231022)(10201501046)(3002001)(6041248)(20161123560025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123562025)(20161123558100)(6072148)(201708071742011); SRVR:DM5PR0701MB3813; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:DM5PR0701MB3813; X-Microsoft-Exchange-Diagnostics: 1; DM5PR0701MB3813; 4:KuNRN9yrvPLMb/J0VzCLqU2+r4x0XxmivdWhFmWVtEstSKc1dyxxolP2cmnTmF+rx5Wb2EPxcj42smMUUW+qwAaOAxevFaNTcU8mBtVH4ErWYsigxW8igPDG2sGCbsxmNQSEYAaX6S7VLl+VgsbyGZpV2p6hzVsUDK1f1ZtWfA92QwUhsfs8+PHGCUS3sLhQ+vF+aZFSSXDA8XbRWVdw/OQbTuQ14aOkm1iBRPEH9NawG5TWfJyzcEj5rb9Eh7u+Rc6x41C3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QZw8IWerKqk09eCC8K5BdPupSEkrGYxWxLH3KnUoTCkAG/HMT7+jWSuYvzbU1Nxm9q4oBanzbvkjJvDGcL5Pf4jYP69GlKA1NUqz0pSkbU/3pq9zeZiYN33TrM8XkQSjIeQrpgeBXbVcefT0PGFHch8dhw9VpBzZDaWZIgQRJXgJxK8TImQoBdZirfYuPBHexdS7k SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2017 03:41:27.7167 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d04547ff-bd37-4da6-8b60-08d537a43d03 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: DM5PR0701MB3813 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 When driver is loaded in Target/Dual mode, it creates QPair to support MQ and allocates resources for each QPair. This Qpair initialization is delayed until the FW personality is changed to Dual/Target mode by issuing chip reset. At the time of chip reset firmware is re-initilized in correct personality all the QPairs are initialized by sending MBC_INITIALIZE_MULTIQ (001Fh). This patch fixes memory leak by adding check to issue MBC_INITIALIZE_MULTIQ command only while deleting rsp/req queue when the flag is set for initiator mode, and clean up QPair resources correctly during the driver unload. This MBX does not need to be issued for Target/Dual mode because chip reset will reset ISP. Fixes: d65237c7f0860 ("scsi: qla2xxx: Fix mailbox failure while deleting Queue pairs") Cc: # 4.10+ Signed-off-by: Himanshu Madhani Reviewed-by: Hannes Reinecke --- drivers/scsi/qla2xxx/qla_init.c | 4 +--- drivers/scsi/qla2xxx/qla_mid.c | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 57b8f43c5980..58663df38627 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -8220,9 +8220,6 @@ int qla2xxx_delete_qpair(struct scsi_qla_host *vha, struct qla_qpair *qpair) int ret = QLA_FUNCTION_FAILED; struct qla_hw_data *ha = qpair->hw; - if (!vha->flags.qpairs_req_created && !vha->flags.qpairs_rsp_created) - goto fail; - qpair->delete_in_progress = 1; while (atomic_read(&qpair->ref_count)) msleep(500); @@ -8230,6 +8227,7 @@ int qla2xxx_delete_qpair(struct scsi_qla_host *vha, struct qla_qpair *qpair) ret = qla25xx_delete_req_que(vha, qpair->req); if (ret != QLA_SUCCESS) goto fail; + ret = qla25xx_delete_rsp_que(vha, qpair->rsp); if (ret != QLA_SUCCESS) goto fail; diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c index 618ca272d01a..e538e6308885 100644 --- a/drivers/scsi/qla2xxx/qla_mid.c +++ b/drivers/scsi/qla2xxx/qla_mid.c @@ -575,14 +575,15 @@ qla25xx_free_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp) int qla25xx_delete_req_que(struct scsi_qla_host *vha, struct req_que *req) { - int ret = -1; + int ret = QLA_SUCCESS; - if (req) { + if (req && vha->flags.qpairs_req_created) { req->options |= BIT_0; ret = qla25xx_init_req_que(vha, req); + if (ret != QLA_SUCCESS) + return QLA_FUNCTION_FAILED; } - if (ret == QLA_SUCCESS) - qla25xx_free_req_que(vha, req); + qla25xx_free_req_que(vha, req); return ret; } @@ -590,14 +591,15 @@ qla25xx_delete_req_que(struct scsi_qla_host *vha, struct req_que *req) int qla25xx_delete_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp) { - int ret = -1; + int ret = QLA_SUCCESS; - if (rsp) { + if (rsp && vha->flags.qpairs_rsp_created) { rsp->options |= BIT_0; ret = qla25xx_init_rsp_que(vha, rsp); + if (ret != QLA_SUCCESS) + return QLA_FUNCTION_FAILED; } - if (ret == QLA_SUCCESS) - qla25xx_free_rsp_que(vha, rsp); + qla25xx_free_rsp_que(vha, rsp); return ret; }