From patchwork Wed Dec 20 06:56:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10125065 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 65D7D6019C for ; Wed, 20 Dec 2017 06:57:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B9EE29649 for ; Wed, 20 Dec 2017 06:57:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 506B92964F; Wed, 20 Dec 2017 06:57:18 +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 88EBE29649 for ; Wed, 20 Dec 2017 06:57:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932461AbdLTG5Q (ORCPT ); Wed, 20 Dec 2017 01:57:16 -0500 Received: from mail-sn1nam02on0074.outbound.protection.outlook.com ([104.47.36.74]:18597 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932372AbdLTG5H (ORCPT ); Wed, 20 Dec 2017 01:57:07 -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=Qpmcv4n+ypAsVg18BVhyrJj/phoOkaOSIdKcSGGwTxI=; b=lEKRxsAiOkPQomyzaMd4QW/ZGxhuTHf18O0tuwIL7pxA/G9PnlI+S+GHgIoRTy0/e4Eo0u9TZvn/Ot556TJMkcH3PfJYUAsGcko3PUG1HtJ8botSIToRZbGrSOB+FnLr6pk7/UpNUFzaa3ii4g6BaiZe1O3fUxMXU9+vPcIRGZE= Received: from CO2PR07CA0078.namprd07.prod.outlook.com (2603:10b6:100::46) by MWHPR0701MB3818.namprd07.prod.outlook.com (2603:10b6:301:7f::23) 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:05 +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:05 +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:51 +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:47 -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 vBK6ulWi021590; Tue, 19 Dec 2017 22:56:47 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id vBK6ulwg021589; Tue, 19 Dec 2017 22:56:47 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH 11/43] qla2xxx: Move work element processing out of DPC thread Date: Tue, 19 Dec 2017 22:56:12 -0800 Message-ID: <20171220065644.21511-12-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)(376002)(39860400002)(39380400002)(396003)(346002)(2980300002)(448002)(199004)(189003)(59450400001)(76176011)(8936002)(54906003)(50466002)(110136005)(575784001)(48376002)(50226002)(87636003)(80596001)(36756003)(81166006)(8676002)(81156014)(72206003)(86362001)(316002)(85326001)(16586007)(69596002)(4326008)(42186006)(51416003)(5660300001)(2950100002)(478600001)(6666003)(2906002)(356003)(1076002)(47776003)(106466001)(305945005); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR0701MB3818; H:CAEXCH02.caveonetworks.com; FPR:; SPF:PermError; PTR:50-232-66-26-static.hfc.comcastbusiness.net; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD043; 1:cHe3dOdXDwQf3077XIXpQ7PD6n/0WRD3B+oDEYaCdMlyvZ1uKWmsP0TZF432vnyEY5hjwD6Rf9rNEhlS6aM21jHb1kD+8Zj9YsyP2b4w6noHdU42+ha5Ro5i+0VEXtrh X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: daedbdd1-0ded-488d-438a-08d54776d954 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:MWHPR0701MB3818; X-Microsoft-Exchange-Diagnostics: 1; MWHPR0701MB3818; 3:ePGsCSbea2MnKCISLzC033lVsYMUZKpJG6zyNf1kKthV0CtaWaFmD6MBMZEtYBCVF+XhW0mK4Mt9FDNwGsma7hHTEbavP1AhLvzmLoU/OHKM7dzdwRIYone9LebZAaRxGKI2zMBTbriYqxWhC43aN+eICqqZbE5DrdUmeRkQ6CCCa4iuqJxf/bVqQVy0B1ip/rESfTj77iVxG+0kh2nYBBJa8M5TaYpuHxmzFe/aaxsNnsBKkp5UB6R8+kbRJNbIbqqmAHjbu+xQx8FGv+dmEAC9cQ9pL19djMF0rGjGwLlvm0rW+SQuaZD+PMqmvkiJj7nhhEgWZOXyC3yBkB0FGRSVjILBrDmg2NoOPjPaucw=; 25:5j1/MwPlK8iSJ1hej6TOpgUjc/15AwSeOEa2IFbJZq67dAsbJ1GIzTjJMEOILBBNVA5raJAWqFyRa767GPNPLG4Hvva7QxBez8T/1xmiOUQW5DH8NITlzssB8jL+p+wufq2Y2tBOD7AFdvkvggY+hq5ItGSvjUAnm8hBogMT8xU11tw7o0DK9YVvnVIL8P+EKmU8Fe/WL2CT65sS1RYaSXgFhmnTNoIgamr3vgR3bf4XtsMQAveqy1KeEmW7VPJr761zhISnrYVIatyHy2sguVgAWDnM6wn1j2N04CELEjOtMyqc9FmWhgZ8puZyQVU3g67amTL8YLKKe5bw/45VdA== X-MS-TrafficTypeDiagnostic: MWHPR0701MB3818: X-Microsoft-Exchange-Diagnostics: 1; MWHPR0701MB3818; 31:dA8/Q5IWmGqraYaLKs0+g7uXSJwcjASKpi28SxCrcCc0k0I9Jq9opzNWxrRLEthdKlRPrjjybzdxdqokU+Em7Kt88xfHscMgJafiglhXM97ZmgOEYsEHWt7mDbBmci4MbP3EswdVw07Ny7l3iMoFespuix4bE2Y0WTmjUmBa6O7iMUITsSqlxqro1Pt4xlyBGyqqI+DTAj3aKbBSDU34IgFCVlWeQV2b2EdWQE3isfk=; 20:IFpsfIMpZCa5PzbaAfUM+s0rK1IaW24OnWtAJYC3AMSbtsOlwn/ko97op3hePIPVKRpPNvmnBKT1ySk/YVF6EBUShnU/twjDNfcdwOaLrB5f/XJb7SGtRN5o4cJ5HDjjIyT3c+2yJ2Ua0VEk91dOCSNdYEFmi+iQWBOsbL8TMvgNelc00bCkALkw/0bKsmHHG7e1ngfuxlmC+9Jt5zbyb3dd8FkCNTpHZKsxhmeYMjMLtr+7AF1JuZcGWdot4r1cVoYw9433qCvtFVNNsGa4daBDlwGWbo6RLJ0RMse+tbQJbSnBvblnvkqdTsD0gohndC0PxwcQC0VWg9p01E/oX/MqbpRqDfFm8ouutl0sDZtv2NIbPUvcPmdJ5Pl5cD929+vewyd2mRKVp92Jl7fxdI67Zt8hJ6aDf3PcN4aaJNK1oGCXIlQHMxYEk3IIoJNNYP6gxvpRy31zBupppiMRkoG+DEy/ABUtoHlHpI8Gg6mJPg9zfVX6CaPu7sSAn9dC X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231023)(10201501046)(3002001)(6041268)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:MWHPR0701MB3818; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:MWHPR0701MB3818; X-Microsoft-Exchange-Diagnostics: 1; MWHPR0701MB3818; 4:Oa7+8amp43PcIUWQJ3T8f5ApfB0pa3zkaQrfy747L6brDVemdOqBjM6f7G2VV1dt1PwI2aMmvJCTwymrwjFDJem38jYx8Q2Wmvm246Kan14zmRKupJeY6rSPwAoGcnLZJFMlkUGh3df/iSdK6fU+66TuKE/iRpXLzY9u/c7KZWNo01H31yO4+ZzuvD7hCKCMsGHga+iwjxJsCW8M0BLw9YGypXDKy03DWbL+xlqHo08P/U8+pQ8IWsb9djBqbKQU4upIbraMu5Ytm6N7Jixe+w== X-Forefront-PRVS: 0527DFA348 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR0701MB3818; 23:ZJwqhan3F6+qO+3g183VlYLv2s14JGIrHXPTujV?= =?us-ascii?Q?udfWXefHkBm0zgKGc0EdRh+Mr5XBM8aN+1MVTNzfoMO0KNonTUig0ovyia1E?= =?us-ascii?Q?GtVZQozisfMwmECmuat106tDbbkekXXBsqSsZ+UYaMeHZBeKdWO1D4l3uap8?= =?us-ascii?Q?iR0x+IGPkhU5t9YZlujitUC1NGo9ugOIo7esjZHee6MyqBsWU7KsJvWp4e6B?= =?us-ascii?Q?oV+oldMDPOSrRtWnMgB3Jg2AFu1wDb21v8rcn8QAGziw1oM3XqLGELYBBqy9?= =?us-ascii?Q?oZussx6snu4XCgd7t7OyQTXgy23rXJ7AY5da/I5JXouRHl/P2X7CzZ8H9Afn?= =?us-ascii?Q?Cfyf+7Z2XndGPjtm15rwDvIGJIH8FDYYAcY54SIz9pnT1EdkEbHI56yPTYi/?= =?us-ascii?Q?9m/EPBB20OUk1S/bjnC9SlFqv0vThQdLV9hwtdw/jqcSV4jF1Qe7eGKHmcGa?= =?us-ascii?Q?vDgXZ2lyO/Udp2JRZLuvNhyYMxnD0hMjeRYFUatd41q9qlsW8wHnmXXfg/cZ?= =?us-ascii?Q?j+GAHiM5hGwSs0dJ1BGDCbpK6qalBASeOtVnrQbd+u3mvGFT2LbJA+6+qNbC?= =?us-ascii?Q?dp9ENPeKhniSA0YYH0DeYz4SSpIqKFBdYxxFDy1FukC4HFGHB/l78BgWu2hJ?= =?us-ascii?Q?vh/uYUOdWrZ6ZsOws3IEQpEd8MkZDkszQJjAaI9i4KjGQ2HT3MuY/8yrrm79?= =?us-ascii?Q?ooThKUznZybp/5/6n6qzBFKI6kurDFAUQp3BTeBoiM5vcaA5XVSCn3wbY9vy?= =?us-ascii?Q?A2NgDKwAIh3bI2UGD+3Dy3NKgGofwhFs4c5uqjx3FIOQ+qh1EZv3M0lImko0?= =?us-ascii?Q?gd+l8GUcER9DRBx7MG3Qv7pPd00+W99FZ5MKVZCA7198wobSxmoiSqRw6img?= =?us-ascii?Q?WE08JQWsDbSLqOv1mCLQhni16xlCJLHCx7F60JbmZFcGSKcor6mDMXF+nAj0?= =?us-ascii?Q?MxVDGoFwWFIlNo33UM9bpr3RKmDA/mN8x2oaU3La/8lPZeNBhYD9VdERHk9z?= =?us-ascii?Q?i3nMY9ohoTx+00HzJ5xTp3lDhRaxaSrNtZHh5GANnrtF2jg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; MWHPR0701MB3818; 6:st/WvXmJd3RyX4g9fh/ZExRVPXB9XW77kngiXJLo8/3aHu5m3q+GkD+sFHrQxeElcUUslFQ/0QVbeSljuFLGg3FeVPk4SPYZE5JRCc7ajndyNOJ1uJtVme0cKb6kqIjQ5utH8yyVlbsaOoV9IuL+GhuBwLjOC2SSiuULcXIb+f62utGQhXexTplFLmfHZf7IlV32rPflZ6oLAaxTPQOFWi5foshRyii1ungLOGDQOdfNvr0LVgTcroOFTfPe6YxLH+jlPWSvhrNTQ6uuVp1rmPXUI/Sc3V4clyFRe+E6w9E7R7ZIdym+h7iZf47Ls26ENBYPR0pSbbzV+u01T1rFGBtkgGD7oRzuXH2eUcBfuKE=; 5:UExIXiofEjW4igZrPM65GzN5hFZogi9AzKx/XilMkHYrCGk5RLNTyfe1a2xZJVoGjzMItk+wVPhqRTaAOKgRCLWbV3QREHDzqHRbxYZGIIlADxWbc4seNySYdU7gjXjOlzy95jEUFtblU3pxHxgiKGLMj1hIKiZmZPl7kZZQ3q8=; 24:06RMePv1IoezMrZKX4KEBzvVHuQxl6/cW6yvhiCOytfGsUpgoL9nFLiF/lqDQhvjRB0HEoYIPav25gHQgaL00u+HZJxMWnmrN1lIDDQ+syc=; 7:RLRrHoAVa1W2RaPNp23JABugyeLt2sukif+5FMemnsxCd5rOglN1Qh15M+efexHSVC36PLR9MwUjz2h0VGwOFUU/JATCY1jaGL5q2xhAdQ/n9kHdftGORTXQTT5ZGSaQIAJgz9+Y2l49UdfM12J752hGQxVuHvE/es6DXgcOgtvtva+RZ8TmNMSzcDz9SMdBHvoPGNvPpLGaEx2BzaRaS72KfNlPWLO9X3mxVCl0E0BZnu4DzwK0j7W6XR36rqPQ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2017 06:56:51.7252 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: daedbdd1-0ded-488d-438a-08d54776d954 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: MWHPR0701MB3818 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 DPC thread can stall during switch scan due to slow switch response. This will stall other work element that needs attention. Moving work element processing and relogin logic out of DPC thread and into its own work queue. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_def.h | 6 ++-- drivers/scsi/qla2xxx/qla_gbl.h | 2 +- drivers/scsi/qla2xxx/qla_init.c | 1 + drivers/scsi/qla2xxx/qla_mid.c | 6 +--- drivers/scsi/qla2xxx/qla_os.c | 76 +++++++++++++++++++++++++++++++---------- 5 files changed, 63 insertions(+), 28 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 18b393453002..a2c0f3d78b35 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -3183,6 +3183,7 @@ enum qla_work_type { QLA_EVT_UPD_FCPORT, QLA_EVT_GNL, QLA_EVT_NACK, + QLA_EVT_RELOGIN, }; @@ -3513,10 +3514,6 @@ struct qlt_hw_data { #define LEAK_EXCHG_THRESH_HOLD_PERCENT 75 /* 75 percent */ -#define QLA_EARLY_LINKUP(_ha) \ - ((_ha->flags.n2n_ae || _ha->flags.lip_ae) && \ - _ha->flags.fw_started && !_ha->flags.fw_init_done) - /* * Qlogic host adapter specific data structure. */ @@ -4222,6 +4219,7 @@ typedef struct scsi_qla_host { #define SET_ZIO_THRESHOLD_NEEDED 28 #define DETECT_SFP_CHANGE 29 #define N2N_LOGIN_NEEDED 30 +#define IOCB_WORK_ACTIVE 31 unsigned long pci_flags; #define PFLG_DISCONNECTED 0 /* PCI device removed */ diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index 66dcbdb91244..fb1c9ffdc05a 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -204,7 +204,7 @@ void qla2x00_handle_login_done_event(struct scsi_qla_host *, fc_port_t *, uint16_t *); int qla24xx_post_gnl_work(struct scsi_qla_host *, fc_port_t *); int qla24xx_async_abort_cmd(srb_t *); - +int qla24xx_post_relogin_work(struct scsi_qla_host *vha); /* * Global Functions in qla_mid.c source file. */ diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 0a1c287c2d66..61b74fd220a3 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -901,6 +901,7 @@ void qla24xx_handle_gpdb_event(scsi_qla_host_t *vha, struct event_arg *ea) __func__, fcport->port_name, fcport->last_rscn_gen, fcport->rscn_gen, fcport->last_login_gen, fcport->login_gen); + set_bit(RELOGIN_NEEDED, &vha->dpc_flags); return; } else if (ea->sp->gen1 != fcport->rscn_gen) { ql_dbg(ql_dbg_disc, vha, 0x20d4, "%s %d %8phC post gidpn\n", diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c index fc61fef5e305..b2fda398a098 100644 --- a/drivers/scsi/qla2xxx/qla_mid.c +++ b/drivers/scsi/qla2xxx/qla_mid.c @@ -319,8 +319,6 @@ qla2x00_do_dpc_vp(scsi_qla_host_t *vha) ql_dbg(ql_dbg_dpc + ql_dbg_verbose, vha, 0x4012, "Entering %s vp_flags: 0x%lx.\n", __func__, vha->vp_flags); - qla2x00_do_work(vha); - /* Check if Fw is ready to configure VP first */ if (test_bit(VP_CONFIG_OK, &base_vha->vp_flags)) { if (test_and_clear_bit(VP_IDX_ACQUIRED, &vha->vp_flags)) { @@ -354,9 +352,7 @@ qla2x00_do_dpc_vp(scsi_qla_host_t *vha) ql_dbg(ql_dbg_dpc, vha, 0x4018, "Relogin needed scheduled.\n"); - qla2x00_relogin(vha); - ql_dbg(ql_dbg_dpc, vha, 0x4019, - "Relogin needed end.\n"); + qla24xx_post_relogin_work(vha); } } diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 4a542a5a976d..66e6fe73a035 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -2683,14 +2683,22 @@ static void qla2x00_iocb_work_fn(struct work_struct *work) { struct scsi_qla_host *vha = container_of(work, struct scsi_qla_host, iocb_work); - int cnt = 0; + struct qla_hw_data *ha = vha->hw; + struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); + int i = 20; + unsigned long flags; + + if (test_bit(UNLOADING, &base_vha->dpc_flags)) + return; - while (!list_empty(&vha->work_list)) { + while (!list_empty(&vha->work_list) && i > 0) { qla2x00_do_work(vha); - cnt++; - if (cnt > 10) - break; + i--; } + + spin_lock_irqsave(&vha->work_lock, flags); + clear_bit(IOCB_WORK_ACTIVE, &vha->dpc_flags); + spin_unlock_irqrestore(&vha->work_lock, flags); } /* @@ -3192,7 +3200,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) host->can_queue, base_vha->req, base_vha->mgmt_svr_loop_id, host->sg_tablesize); - ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM, 0); + ha->wq = alloc_workqueue("qla2xxx_wq", 0, 0); if (ha->mqenable) { bool mq = false; @@ -4544,6 +4552,7 @@ struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, INIT_LIST_HEAD(&vha->gnl.fcports); INIT_LIST_HEAD(&vha->nvme_rport_list); INIT_LIST_HEAD(&vha->gpnid_list); + INIT_WORK(&vha->iocb_work, qla2x00_iocb_work_fn); spin_lock_init(&vha->work_lock); spin_lock_init(&vha->cmd_list_lock); @@ -4596,15 +4605,18 @@ int qla2x00_post_work(struct scsi_qla_host *vha, struct qla_work_evt *e) { unsigned long flags; + bool q = false; spin_lock_irqsave(&vha->work_lock, flags); list_add_tail(&e->list, &vha->work_list); + + if (!test_and_set_bit(IOCB_WORK_ACTIVE, &vha->dpc_flags)) + q = true; + spin_unlock_irqrestore(&vha->work_lock, flags); - if (QLA_EARLY_LINKUP(vha->hw)) - schedule_work(&vha->iocb_work); - else - qla2xxx_wake_dpc(vha); + if (q) + queue_work(vha->hw->wq, &vha->iocb_work); return QLA_SUCCESS; } @@ -4736,6 +4748,9 @@ void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e) fcport->d_id = e->u.new_sess.id; if (pla) { fcport->fw_login_state = DSC_LS_PLOGI_PEND; + memcpy(fcport->node_name, + pla->iocb.u.isp24.u.plogi.node_name, + WWN_SIZE); qlt_plogi_ack_link(vha, pla, fcport, QLT_PLOGI_LINK_SAME_WWN); /* we took an extra ref_count to prevent PLOGI ACK when * fcport/sess has not been created. @@ -4886,6 +4901,9 @@ qla2x00_do_work(struct scsi_qla_host *vha) case QLA_EVT_GPNID_DONE: qla24xx_async_gpnid_done(vha, e->u.iosb.sp); break; + case QLA_EVT_RELOGIN: + qla2x00_relogin(vha); + break; case QLA_EVT_NEW_SESS: qla24xx_create_new_sess(vha, e); break; @@ -4917,6 +4935,20 @@ qla2x00_do_work(struct scsi_qla_host *vha) } } +int qla24xx_post_relogin_work(struct scsi_qla_host *vha) +{ + struct qla_work_evt *e; + + e = qla2x00_alloc_work(vha, QLA_EVT_RELOGIN); + + if (!e) { + set_bit(RELOGIN_NEEDED, &vha->dpc_flags); + return QLA_FUNCTION_FAILED; + } + + return qla2x00_post_work(vha, e); +} + /* Relogins all the fcports of a vport * Context: dpc thread */ @@ -4972,6 +5004,9 @@ void qla2x00_relogin(struct scsi_qla_host *vha) if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) break; } + + ql_dbg(ql_dbg_disc, vha, 0x400e, + "Relogin end.\n"); } /* Schedule work on any of the dpc-workqueues */ @@ -5747,8 +5782,6 @@ qla2x00_do_dpc(void *data) if (test_bit(UNLOADING, &base_vha->dpc_flags)) break; - qla2x00_do_work(base_vha); - if (IS_P3P_TYPE(ha)) { if (IS_QLA8044(ha)) { if (test_and_clear_bit(ISP_UNRECOVERABLE, @@ -5936,11 +5969,9 @@ qla2x00_do_dpc(void *data) base_vha->relogin_jif = jiffies + HZ; clear_bit(RELOGIN_NEEDED, &base_vha->dpc_flags); - ql_dbg(ql_dbg_dpc, base_vha, 0x400d, + ql_dbg(ql_dbg_disc, base_vha, 0x400d, "Relogin scheduled.\n"); - qla2x00_relogin(base_vha); - ql_dbg(ql_dbg_dpc, base_vha, 0x400e, - "Relogin end.\n"); + qla24xx_post_relogin_work(base_vha); } } loop_resync_check: @@ -6200,8 +6231,17 @@ qla2x00_timer(struct timer_list *t) } /* Process any deferred work. */ - if (!list_empty(&vha->work_list)) - start_dpc++; + if (!list_empty(&vha->work_list)) { + unsigned long flags; + bool q = false; + + spin_lock_irqsave(&vha->work_lock, flags); + if (!test_and_set_bit(IOCB_WORK_ACTIVE, &vha->dpc_flags)) + q = true; + spin_unlock_irqrestore(&vha->work_lock, flags); + if (q) + queue_work(vha->hw->wq, &vha->iocb_work); + } /* * FC-NVME