From patchwork Wed Mar 15 16:48:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 9626187 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 3C2B560244 for ; Wed, 15 Mar 2017 16:50:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F06528641 for ; Wed, 15 Mar 2017 16:50:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23BD12866D; Wed, 15 Mar 2017 16:50:56 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 A950228641 for ; Wed, 15 Mar 2017 16:50:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753294AbdCOQuw (ORCPT ); Wed, 15 Mar 2017 12:50:52 -0400 Received: from mail-by2nam03on0056.outbound.protection.outlook.com ([104.47.42.56]:10636 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753096AbdCOQtK (ORCPT ); Wed, 15 Mar 2017 12:49:10 -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; bh=S1gVkq2eHs84IpewC76qsnda45xXc5dDxn9UW6Wi5pA=; b=OwkjcVJLAb12KBP2Z5+/vjVXS+k5N/UkoW4HPvoQ+AaN1AapY0BEFTO0XPmd9d1mTJlhYXN0/BoLUXmd7p051ZwXlzUQYzEfYQiFUWBL33irUMZhR5f9yxlyjmI6uZHQc0lQ+qi9sdIN8PEeFRJ7lyTqGHwivvFkhbl5rY9RdT8= Received: from BLUPR07CA082.namprd07.prod.outlook.com (10.160.24.37) by CO2PR0701MB712.namprd07.prod.outlook.com (10.141.245.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.961.17; Wed, 15 Mar 2017 16:49:08 +0000 Received: from BL2FFO11FD017.protection.gbl (2a01:111:f400:7c09::101) by BLUPR07CA082.outlook.office365.com (2a01:111:e400:8ae::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.961.17 via Frontend Transport; Wed, 15 Mar 2017 16:49:07 +0000 Authentication-Results: spf=none (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; linux-iscsi.org; dkim=none (message not signed) header.d=none; linux-iscsi.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 BL2FFO11FD017.mail.protection.outlook.com (10.173.161.35) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.961.10 via Frontend Transport; Wed, 15 Mar 2017 16:49:07 +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.309.2; Wed, 15 Mar 2017 09:48:57 -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 v2FGmv07017294; Wed, 15 Mar 2017 09:48:57 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id v2FGmv0Y017293; Wed, 15 Mar 2017 09:48:57 -0700 From: Himanshu Madhani To: , , CC: , , Subject: [PATCH v4 01/14] qla2xxx: Allow vref count to timeout on vport delete. Date: Wed, 15 Mar 2017 09:48:43 -0700 Message-ID: <20170315164856.17255-2-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170315164856.17255-1-himanshu.madhani@cavium.com> References: <20170315164856.17255-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)(39450400003)(39410400002)(2980300002)(428002)(199003)(189002)(9170700003)(76176999)(36756003)(101416001)(5003940100001)(5660300001)(2906002)(575784001)(105586002)(50986999)(47776003)(2950100002)(2201001)(6666003)(86362001)(8676002)(80596001)(305945005)(42186005)(107886003)(81166006)(48376002)(50226002)(8936002)(38730400002)(54906002)(8656002)(50466002)(33646002)(1076002)(189998001)(356003)(4326008)(87636001); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR0701MB712; H:CAEXCH02.caveonetworks.com; FPR:; SPF:None; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD017; 1:UnXJE/ElfgEOghYfC9dMZn8wKiloVqXrH94qdIJtj7xvUtL/hL/5ivYLGFw2X0Yxzm5yvaKIE3p73gF3W8l40zIDeR1OCqa/JZpRjStoignpjzzjDU2k2Sw51Hg5D8rvrGnlvo6VcuphKSt32sH5c/ofGmiuKdn4nDFBhgwcOW4mdg5/dzNUYi/k6SYWnqgzsMPwjHHmLcZ99D2Im6x96dhzeTJVinoYhpNE967HRNcIuO7OVLbkApMUa52tnFI4ndrPcfNKdbnV5JffYKhn18cvzGOPz2BqkjTPuJjK4HFmtJKUWffM4eL77wOXrnjS1C6VQcthzR9JwsA7zFL27QdLMrMcLo066kN9zK9R+niDrsJ04VKjBEwhuCxiHDZBqWOpW+U8t/maxZ6su5LyJPM9P+tJO4ADSMh2E733aGYAukA1OFToXMMVkDCE9adMIeF3adRJG/7hFRYWQJT+pVlUDCm63QgOo2QS4LyeOuK1p0yJlvewDZGuvjB2LJt7OtlX7QePR9+EQyULJND0o64hIMKOXsiZ1zLF+vl/pHo= X-MS-Office365-Filtering-Correlation-Id: 732550b8-65db-4e6d-4a3c-08d46bc33274 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CO2PR0701MB712; X-Microsoft-Exchange-Diagnostics: 1; CO2PR0701MB712; 3:igf1TnJXyhSR8dHg67UAYgNaHMB0zQ2WM36YOWTsxVR+9u2FGhiVpoZmiRvgwgS4aFtFsUiIfu7sC6J5och5872MHu/CB+VX4gl9fCK7GCFOvUNHzFnTujy9j0pgmhqPTULYXQA7SlYAxfPpFoHu3ubnW4LCIJ27KHuxGBDoCRPW1rWRv1ApFJM5qkgrlKU3HHc2dTC1njSkZ4lNfk4WQ7TbZzUAM1OqKiRjny8ma/n9cIi1GyPlF0PVk1zw1eSDbVdqj1nXt5L7XZ+4MDuLHaVLiicT2Xg97XUl+QA+JztghYsZ82LXWxHeKEypaOrZZpYgL2lVW9OnvklviQwyOXCzizHnj1j4qgTb0nnTS4dd3l8O9R0NBHG6KbQmYhM2; 25:shj2Sxtow1Yfwg/CJPk4jjYvOtTmGAjbMzqnz2c+8Up3tliPZ83KFFPJIhcGRFDX5+s6LBEngIkEHByvbFnSPsLPd+54pjw86AiorxsF/ps5jOVInEaVy5yysxOU07kwgCUTOchIRh6i5IM7IH8D/tsyfojzkj7agTSMg19qkZTk+YGubuAAi35JyIGv/y7Z7JzlyfL4xNejr7lrLs0OCtNNi5CZuVGLkqwTeOGM20osEdD0sIXzM/C2zJ/mZ1q33uFvyTn9YNIJ6qfBEZnjuPDjJQIrWRZBedl/o4ZLsvKUxApQCPmTYB3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change-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(13017025)(13015025)(13024025)(13023025)(13018025)(10201501046)(3002001)(6041248)(20161123564025)(20161123558025)(20161123555025)(20161123560025)(20161123562025)(6072148); SRVR:CO2PR0701MB712; BCL:0; PCL:0; RULEID:; SRVR:CO2PR0701MB712; X-Microsoft-Exchange-Diagnostics: 1; CO2PR0701MB712; 4:SWqekbHT4wRAlO8bOW/oXRzijp2eZd90RHpchZZ+8vrXxsxp3izW0CfXHHRmR8zY/DGNeDI6XFZ38ds1P9i0mI9iT1KZzFPQEebNCSgywwmSgMuruHWRs+PLB3zrtAFhqMZr2eoWwGwwALPfDOLjQbhmht28Q0a3n+rKoY/O0BG3AYqKmCZt/CvaG3I35N4oae2ec/fd1xf/2MV/0bWf762IQOo++lEEx/yGIzs9TTHslwZa3rCPkQFaxiP8dQPIlitT6yO7Zo8aRUjPZJz6KPq8EGSHKzKS10bGuZWhasi6kyxEMknAthST2MNUTmEY9id34vcqZyzu274wtZx2VumY1cur7ZrLgc+0xNA7YkjWoiFAQulrASFEXCfvPgxHiu71w4qBKetkWuXzt+fC+0ibiRQ9fdzgR81JMQgaquU3o4kwnLBXHgLHxNVMMfUZEj9mj3bP3TIaI4+oqhDnjmxCFTQWYydPwF2gvZJWvcm8K4eCz7FKoWlN4yl7kBZnDbOLtpEebiPLdpPUwtw31Lvv2c9hgiBWjfGkzmHWLAzQ9b/ltdVnOVc/VUb2LfbC2WD/iCXr9aYwWBqIf+LW0ZOzn+x9e3JQ5qC99jArmcoOZ+ZSNicwPtHfA7Bm3mul6UbQX9PxaFte5t471ZryEQ4UtZP94sz6LC7qkUBTLudKcZzxT7bRCDaV/eYG0FE9eUTAqh2p8ib9dC2/C8APLUN7gXGeK9F4f5lqDbrxbPVf92x24hSuMyvQhpsMOxHP X-Forefront-PRVS: 02475B2A01 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR0701MB712; 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E9fuFFgN?= =?us-ascii?Q?isp1uWz0Hfz9Xiv1kFz0scHbfz5aUzkfqqjFurfMxCMPqx5zAzSflpEmoWFn?= =?us-ascii?Q?AiCS4g7ZcW9gZHuGN3fUra4+V8+KxWNGxU7hqQKdcDFHbCZ9n91bYVoQjVAP?= =?us-ascii?Q?JD+vszwOARKrzHC7mkVRyWBe?= X-Microsoft-Exchange-Diagnostics: 1; CO2PR0701MB712; 6:FeWUgMoFZVI/vw5fqS1awEOfwZJ8uHywls7wQkgUTCIRr2bj9nIlo8ki2L4n5B4vVoncNGlEmCobMN+9FuChPkSKWOOPvGbVcY8E1ft0jdPWaXBR6oKdolJw1pbOL6U4VXG3T+JMn5T+a6q+ILFsqORQzCi9CT0O0c4oIlWjkdhV7NExCuRAZ4OENmuDYLiuqEPQraoplYSxo52zE1HwKLkQtcJjE0+TDRd4dG/VVoiSCcuJ9HInqCjFzkazn2/qd1Rc4oGHS8hq60ID+6PJU34sHJmUVMOzCRVq4AlrHcse6NX+tdBL+1wiK7YSQnMOXEWXZ8zxHznRtzpQwHm5n8c/q/pafUX5S3lrUAhJ5p0pmvNNQvw+628yt5URTCR9t6U8EJ57PeTRlTEewl1TzQ==; 5:ZmQV50bBA0nuVfMhL/Dn1OyKKmJXF/W/PNec9rU0TlQQw9yDZV0vkLKkiLTDs5iTARA+YNSnxH9/eFaxobaevS7VGkXpbLTts08v52/4TjUL8wwnhdoppgxFf+1p3OCsoJ6+qIM9HIotkKDDxy2UPg==; 24:/HC4l8nWShiYEzoCUDuuZoMiOsJhgrRHIGK8N/0IGF9MjTvT17jVW6M5wAWA2gXhFHUW7F4Hz7W0xsPG4tuYxYgJsW/GaPQI2XU8n3flDpY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CO2PR0701MB712; 7:WRNU6Rfv+0livhGAOiQoaziqHtWH0wbHvzcHqKaPXSRYPacEkshH5rZi4icwpLwOew4/VrvBxEGt+ibU3wvwd1GmxXu2sh+xMiDHWkrU3fnxdxfeeMsIj7fIzTQDWU/4h96TxWMTqUmqIFyiJtz535IqnnUFR8b93yoNzZ/4Ogtt9oEzqs8aNpQUgqrBdQ0oSxb0gkHj99Csekic9zXuC3dJqRaQXR3GNcmsfppMz36ohIe2ySeYHpbWQe9RKKgtf68WpCI/gLvQsDMkgovqfaCvuq5LB7hHZsRgcC4WrIZtTfZ3ljv8cettq18U071jyFRD332ogJpySzITsfdu9A== X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Mar 2017 16:49:07.1771 (UTC) 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: CO2PR0701MB712 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Joe Carnuccio Cc: Signed-off-by: Joe Carnuccio Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_attr.c | 4 +--- drivers/scsi/qla2xxx/qla_def.h | 6 +++++- drivers/scsi/qla2xxx/qla_init.c | 1 + drivers/scsi/qla2xxx/qla_mid.c | 14 ++++++++------ drivers/scsi/qla2xxx/qla_os.c | 1 + 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index f610103994af..435ff7fd6384 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c @@ -2154,8 +2154,6 @@ qla24xx_vport_delete(struct fc_vport *fc_vport) "Timer for the VP[%d] has stopped\n", vha->vp_idx); } - BUG_ON(atomic_read(&vha->vref_count)); - qla2x00_free_fcports(vha); mutex_lock(&ha->vport_lock); @@ -2166,7 +2164,7 @@ qla24xx_vport_delete(struct fc_vport *fc_vport) dma_free_coherent(&ha->pdev->dev, vha->gnl.size, vha->gnl.l, vha->gnl.ldma); - if (vha->qpair->vp_idx == vha->vp_idx) { + if (vha->qpair && vha->qpair->vp_idx == vha->vp_idx) { if (qla2xxx_delete_qpair(vha, vha->qpair) != QLA_SUCCESS) ql_log(ql_log_warn, vha, 0x7087, "Queue Pair delete failed.\n"); diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 625d438e3cce..8662ef4192db 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -4076,6 +4076,7 @@ typedef struct scsi_qla_host { /* Count of active session/fcport */ int fcport_count; wait_queue_head_t fcport_waitQ; + wait_queue_head_t vref_waitq; } scsi_qla_host_t; struct qla27xx_image_status { @@ -4131,14 +4132,17 @@ struct qla2_sgx { mb(); \ if (__vha->flags.delete_progress) { \ atomic_dec(&__vha->vref_count); \ + wake_up(&__vha->vref_waitq); \ __bail = 1; \ } else { \ __bail = 0; \ } \ } while (0) -#define QLA_VHA_MARK_NOT_BUSY(__vha) \ +#define QLA_VHA_MARK_NOT_BUSY(__vha) do { \ atomic_dec(&__vha->vref_count); \ + wake_up(&__vha->vref_waitq); \ +} while (0) \ #define QLA_QPAIR_MARK_BUSY(__qpair, __bail) do { \ atomic_inc(&__qpair->ref_count); \ diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 32fb9007f137..9f3740c68cc8 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -5148,6 +5148,7 @@ qla2x00_update_fcports(scsi_qla_host_t *base_vha) } } atomic_dec(&vha->vref_count); + wake_up(&vha->vref_waitq); } spin_unlock_irqrestore(&ha->vport_slock, flags); } diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c index c6d6f0d912ff..09a490c98763 100644 --- a/drivers/scsi/qla2xxx/qla_mid.c +++ b/drivers/scsi/qla2xxx/qla_mid.c @@ -74,13 +74,14 @@ qla24xx_deallocate_vp_id(scsi_qla_host_t *vha) * ensures no active vp_list traversal while the vport is removed * from the queue) */ - spin_lock_irqsave(&ha->vport_slock, flags); - while (atomic_read(&vha->vref_count)) { - spin_unlock_irqrestore(&ha->vport_slock, flags); - - msleep(500); + wait_event_timeout(vha->vref_waitq, atomic_read(&vha->vref_count), + 10*HZ); - spin_lock_irqsave(&ha->vport_slock, flags); + spin_lock_irqsave(&ha->vport_slock, flags); + if (atomic_read(&vha->vref_count)) { + ql_dbg(ql_dbg_vport, vha, 0xfffa, + "vha->vref_count=%u timeout\n", vha->vref_count.counter); + vha->vref_count = (atomic_t)ATOMIC_INIT(0); } list_del(&vha->list); qlt_update_vp_map(vha, RESET_VP_IDX); @@ -269,6 +270,7 @@ qla2x00_alert_all_vps(struct rsp_que *rsp, uint16_t *mb) spin_lock_irqsave(&ha->vport_slock, flags); atomic_dec(&vha->vref_count); + wake_up(&vha->vref_waitq); } i++; } diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 1fed235a1b4a..54d4e802bde0 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -4268,6 +4268,7 @@ struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, spin_lock_init(&vha->work_lock); spin_lock_init(&vha->cmd_list_lock); init_waitqueue_head(&vha->fcport_waitQ); + init_waitqueue_head(&vha->vref_waitq); vha->gnl.size = sizeof(struct get_name_list_extended) * (ha->max_loop_id + 1);