From patchwork Thu Dec 28 20:33:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10135871 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 0AE7760318 for ; Thu, 28 Dec 2017 20:34:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0CB72AD58 for ; Thu, 28 Dec 2017 20:34:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5B492B1F6; Thu, 28 Dec 2017 20:34:26 +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 B9F4E2B7EC for ; Thu, 28 Dec 2017 20:34:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755273AbdL1UeX (ORCPT ); Thu, 28 Dec 2017 15:34:23 -0500 Received: from mail-sn1nam02on0044.outbound.protection.outlook.com ([104.47.36.44]:27840 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755271AbdL1UeL (ORCPT ); Thu, 28 Dec 2017 15:34:11 -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=yeWaRkP76h02PBOEtFwoFgwHHG/OIboy+XRDrpX+JYA=; b=AirL2OJ6/BRs0xgKEyx5J7vJMTbaB44f83FymIPqEbcgW4mLGB1568c9OfSeECUstlITRD4Idd7lrXWFPdSXPVAgCfYvVzm9vmijft6pV0+YU398QfUxRW/znr0wHpjKTYCypargR0FSa85rqIuFGkvWlzM400JZlGBbzeGrkDU= Received: from SN4PR0701CA0022.namprd07.prod.outlook.com (10.161.192.160) by SN1PR0701MB1952.namprd07.prod.outlook.com (10.163.131.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.366.8; Thu, 28 Dec 2017 20:34:09 +0000 Received: from BN1BFFO11FD006.protection.gbl (2a01:111:f400:7c10::1:154) by SN4PR0701CA0022.outlook.office365.com (2603:10b6:803:28::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.366.8 via Frontend Transport; Thu, 28 Dec 2017 20:34:09 +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 BN1BFFO11FD006.mail.protection.outlook.com (10.58.144.69) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.345.12 via Frontend Transport; Thu, 28 Dec 2017 20:33:49 +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, 28 Dec 2017 12:33:49 -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 vBSKXnNe002906; Thu, 28 Dec 2017 12:33:49 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id vBSKXnKW002904; Thu, 28 Dec 2017 12:33:49 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH v2 20/37] qla2xxx: Reduce the use of terminate exchange Date: Thu, 28 Dec 2017 12:33:28 -0800 Message-ID: <20171228203345.2702-21-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20171228203345.2702-1-himanshu.madhani@cavium.com> References: <20171228203345.2702-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)(396003)(39380400002)(346002)(39860400002)(376002)(2980300002)(448002)(189003)(199004)(72206003)(1076002)(86362001)(50466002)(48376002)(81156014)(8676002)(356003)(305945005)(110136005)(47776003)(106466001)(5660300001)(4326008)(2906002)(85326001)(54906003)(80596001)(87636003)(69596002)(478600001)(36756003)(8936002)(16586007)(50226002)(81166006)(316002)(59450400001)(2950100002)(51416003)(6666003)(76176011)(42186006); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0701MB1952; H:CAEXCH02.caveonetworks.com; FPR:; SPF:PermError; PTR:50-232-66-26-static.hfc.comcastbusiness.net; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD006; 1:Xu/OoyOX/5eAF25xprrt3GtZqspjvJ8GNk6JOoQ73ASrfEGsqpeujNRVxdg8MimGw4+EFsAf149IxBXWNyNN0DxwxGf+1WLUaBvAVC4DDzMN25HXF4/+UJboyXufjqnE X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ad3ea8a7-d3f1-49ee-124e-08d54e324d66 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:SN1PR0701MB1952; X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g6HTtTOfmINyVFr87yw9QLHUmhKn6X9am59f+5LSudKB77KUnFY/pbbvrSnIRrLZbzEv4evzGP3YJ4UM+LH1SEGYhi1/YVyufFooyofiKjLPiu06lwzjrYtzM3rDdn8SoCjW1aGdHysdqXoIoY0S4cA7EOLpTqDF2WJT6G/JFf2864wwIUBKenhzpNP+jZQCxjU7sgOFAf8STogEZKBCTHxkdIk5AwRpirvkccXF8o6lyHrW2fSV/283eODy/9FJdA2ObJrHO8KX1CincBIJXoViNNd93j6iWIHcW/iSMxvvBukvD4nJ/qNvfrE4H8h/or2F7eiLecXIH4lVB4+xX8/7dYkXbRXR6StBa5Re8/yKeOzR4DvYEk4ZKBVSKOdD5XQZ+PC8si/stmTj9+/RZ6L81zUqveWK00DliqA9d+cj5c88JbFf0xrIAAM8CHBAKtdyugWZS1Wwgs+Ih/5C3XWegA2XEbs22LoMZNlAYJx2QCT47VS/ 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)(3231023)(944501075)(10201501046)(3002001)(93006095)(93001095)(6041268)(20161123564045)(20161123560045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:SN1PR0701MB1952; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:SN1PR0701MB1952; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0701MB1952; 4:jbR1ZuDelOWc1GVNX0Limr3HGPucj4LNsgFZifFDCjKHt+PXzpmKc167vmS2dF8QkdxAlGTNZYhLFFVLAUQE00oUtoUP42StbS2TY9xUE7BHwidg58EsRe6pTkA0KwzuZHZVTeZ5iaNMpc2u9NV8QLiYlVMYhcIkuHi5U0IBPUaEf1MzdyBYwL5Z6vkGU8Q9wOgkIEatEmqvdEgWjYCduxxVeSp3jYxIKHilPXLJKkLajCdWNxTPaiYq8SBNR7ido9hEV0ISgYPaSPwBeUtORw== X-Forefront-PRVS: 05352A48BE X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR0701MB1952; 23:3P1qgxJeBzfbxP3qram7lUsqy8+k3WJMKmXOd5W?= =?us-ascii?Q?9h3hqvo8IE0dPO67rbyDfIB4YiDI79N5kuh/Uv9fALvyXOrIB897L7hr6FgB?= =?us-ascii?Q?Ot+NedZmN/G/eSxkyHGppRe3C/8xKV3GytHwpKP9GD/0+Jk4Pef9ayk2rqEM?= =?us-ascii?Q?LNx5b5M6tjCwRzmeOpRo9LNA8JJcvJhBKlbHNFAX8X5eqNqbc4WWKuJnhrXE?= =?us-ascii?Q?EzaeVLVQ1mDbfMOUKu4qX3wEDHPLlqGsyMszGUADciiD4coPbR45QLKz7Xdl?= =?us-ascii?Q?UK8NQF0gRlp3UQeNq9lbsbrgm48Uk6cBK7WYSs8y72sY3whaiFE6WEQQVvRk?= =?us-ascii?Q?9sI1erdf+jv7QgVysbDFNV34ylfpP+HqFsjw8eYTB+Ix0HfQfmN52/kL5PH6?= =?us-ascii?Q?kdWR6TB1V4F5Ul6ecwh5yeI5rdXtJeTmrItfT4CzCKiv/BMdo+j6FVSqEjYV?= =?us-ascii?Q?9sTyRrKtjElNH8ur7e3GPNCm7q4qY1DtzqDD15YmHngpyh+2yGg0mxEUUIgL?= =?us-ascii?Q?C6rLO/MBCNcH+VgdN6zWGf5LDaqvu3rfhPFIxIwMPGWh9Rjc18gzztw2IO47?= =?us-ascii?Q?79PYBUpoEQTRuab04LdESA8J10hXyn8CC9IARM3mY1fBi+JVgsxvZ34MaQfT?= =?us-ascii?Q?YwUgOndHNKtCdXfwVk9JGq30cO3VKRSgYXBd8bxHtwwLX8S7uS4kjXXsbynu?= =?us-ascii?Q?qCUtfIKU6kwqgFL/R9HZeefi8hknWnGa982mTCnQUTLZx7SdpbKNAwjRDwpL?= =?us-ascii?Q?oO+qxEyLRYWse5r3zSWE9j8vT4M5CZSHPYUJ0Z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FFO+SCjhh9oHfjQ4O6czIY7/wijJuMe0t/6vem+oD5iZRKPeSlqswNJ6Ll+TOJ0QV88uHT/A/d9jY40oEBHNR7r5W/PrbWSk0SZut+kPSoQ5BtGCUR+0jxCATXqKw9rUI7+qMmasTO152uPpGBwHwPOeCbOys+2na1fX/wr SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2017 20:33:49.3227 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ad3ea8a7-d3f1-49ee-124e-08d54e324d66 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: SN1PR0701MB1952 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 reduce usage of terminate exchange when command encounter resource bottle neck. Remote initiator view it as command drop. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_target.c | 140 ++++++++++++++++++++------------------ 1 file changed, 74 insertions(+), 66 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 5695fc249b73..b23d3a187758 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -75,7 +75,8 @@ MODULE_PARM_DESC(ql2xuctrlirq, int ql2x_ini_mode = QLA2XXX_INI_MODE_EXCLUSIVE; -static int temp_sam_status = SAM_STAT_BUSY; +static int qla_sam_status = SAM_STAT_BUSY; +static int tc_sam_status = SAM_STAT_TASK_SET_FULL; /* target core */ /* * From scsi/fc/fc_fcp.h @@ -4275,14 +4276,14 @@ static void qlt_create_sess_from_atio(struct work_struct *work) if (op->atio.u.raw.entry_count > 1) { ql_dbg(ql_dbg_tgt_mgt, vha, 0xf023, "Dropping multy entry atio %p\n", &op->atio); - goto out_term; + goto out_busy; } sess = qlt_make_local_sess(vha, s_id); /* sess has an extra creation ref. */ if (!sess) - goto out_term; + goto out_busy; /* * Now obtain a pre-allocated session tag using the original op->atio * packet header, and dispatch into __qlt_do_work() using the existing @@ -4293,7 +4294,7 @@ static void qlt_create_sess_from_atio(struct work_struct *work) struct qla_qpair *qpair = ha->base_qpair; spin_lock_irqsave(qpair->qp_lock_ptr, flags); - qlt_send_busy(qpair, &op->atio, SAM_STAT_BUSY); + qlt_send_busy(qpair, &op->atio, tc_sam_status); spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); spin_lock_irqsave(&ha->tgt.sess_lock, flags); @@ -4313,6 +4314,17 @@ static void qlt_create_sess_from_atio(struct work_struct *work) out_term: qlt_send_term_exchange(vha->hw->base_qpair, NULL, &op->atio, 0, 0); kfree(op); + return; +out_busy: + { + struct qla_qpair *qpair = ha->base_qpair; + + spin_lock_irqsave(qpair->qp_lock_ptr, flags); + qlt_send_busy(qpair, &op->atio, qla_sam_status); + spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); + kfree(op); + } + return; } /* ha->hardware_lock supposed to be held on entry */ @@ -4329,7 +4341,7 @@ static int qlt_handle_cmd_for_atio(struct scsi_qla_host *vha, if (unlikely(tgt->tgt_stop)) { ql_dbg(ql_dbg_io, vha, 0x3061, "New command while device %p is shutting down\n", tgt); - return -EFAULT; + return -ENODEV; } id.b.al_pa = atio->u.isp24.fcp_hdr.s_id[2]; @@ -4384,7 +4396,7 @@ static int qlt_handle_cmd_for_atio(struct scsi_qla_host *vha, spin_lock_irqsave(&ha->tgt.sess_lock, flags); ha->tgt.tgt_ops->put_sess(sess); spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); - return -ENOMEM; + return -EBUSY; } cmd->cmd_in_wq = 1; @@ -5485,7 +5497,6 @@ qlt_chk_qfull_thresh_hold(struct scsi_qla_host *vha, struct qla_qpair *qpair, struct atio_from_isp *atio, uint8_t ha_locked) { struct qla_hw_data *ha = vha->hw; - uint16_t status; unsigned long flags; if (ha->tgt.num_pend_cmds < Q_FULL_THRESH_HOLD(ha)) @@ -5493,8 +5504,7 @@ qlt_chk_qfull_thresh_hold(struct scsi_qla_host *vha, struct qla_qpair *qpair, if (!ha_locked) spin_lock_irqsave(&ha->hardware_lock, flags); - status = temp_sam_status; - qlt_send_busy(qpair, atio, status); + qlt_send_busy(qpair, atio, qla_sam_status); if (!ha_locked) spin_unlock_irqrestore(&ha->hardware_lock, flags); @@ -5509,7 +5519,7 @@ static void qlt_24xx_atio_pkt(struct scsi_qla_host *vha, struct qla_hw_data *ha = vha->hw; struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; int rc; - unsigned long flags; + unsigned long flags = 0; if (unlikely(tgt == NULL)) { ql_dbg(ql_dbg_tgt, vha, 0x3064, @@ -5533,8 +5543,7 @@ static void qlt_24xx_atio_pkt(struct scsi_qla_host *vha, "sending QUEUE_FULL\n", vha->vp_idx); if (!ha_locked) spin_lock_irqsave(&ha->hardware_lock, flags); - qlt_send_busy(ha->base_qpair, atio, - SAM_STAT_TASK_SET_FULL); + qlt_send_busy(ha->base_qpair, atio, qla_sam_status); if (!ha_locked) spin_unlock_irqrestore(&ha->hardware_lock, flags); @@ -5553,42 +5562,37 @@ static void qlt_24xx_atio_pkt(struct scsi_qla_host *vha, rc = qlt_handle_task_mgmt(vha, atio); } if (unlikely(rc != 0)) { - if (rc == -ESRCH) { - if (!ha_locked) - spin_lock_irqsave(&ha->hardware_lock, - flags); - -#if 1 /* With TERM EXCHANGE some FC cards refuse to boot */ - qlt_send_busy(ha->base_qpair, atio, - SAM_STAT_BUSY); -#else + if (!ha_locked) + spin_lock_irqsave(&ha->hardware_lock, flags); + switch (rc) { + case -ENODEV: + ql_dbg(ql_dbg_tgt, vha, 0xe05f, + "qla_target: Unable to send command to target\n"); + break; + case -EBADF: + ql_dbg(ql_dbg_tgt, vha, 0xe05f, + "qla_target: Unable to send command to target, sending TERM EXCHANGE for rsp\n"); qlt_send_term_exchange(ha->base_qpair, NULL, atio, 1, 0); -#endif - if (!ha_locked) - spin_unlock_irqrestore( - &ha->hardware_lock, flags); - } else { - if (tgt->tgt_stop) { - ql_dbg(ql_dbg_tgt, vha, 0xe059, - "qla_target: Unable to send " - "command to target for req, " - "ignoring.\n"); - } else { - ql_dbg(ql_dbg_tgt, vha, 0xe05a, - "qla_target(%d): Unable to send " - "command to target, sending BUSY " - "status.\n", vha->vp_idx); - if (!ha_locked) - spin_lock_irqsave( - &ha->hardware_lock, flags); - qlt_send_busy(ha->base_qpair, - atio, SAM_STAT_BUSY); - if (!ha_locked) - spin_unlock_irqrestore( - &ha->hardware_lock, flags); - } + break; + case -EBUSY: + ql_dbg(ql_dbg_tgt, vha, 0xe060, + "qla_target(%d): Unable to send command to target, sending BUSY status\n", + vha->vp_idx); + qlt_send_busy(ha->base_qpair, atio, + tc_sam_status); + break; + default: + ql_dbg(ql_dbg_tgt, vha, 0xe060, + "qla_target(%d): Unable to send command to target, sending BUSY status\n", + vha->vp_idx); + qlt_send_busy(ha->base_qpair, atio, + qla_sam_status); + break; } + if (!ha_locked) + spin_unlock_irqrestore(&ha->hardware_lock, + flags); } break; @@ -5671,27 +5675,31 @@ static void qlt_response_pkt(struct scsi_qla_host *vha, rc = qlt_handle_cmd_for_atio(vha, atio); if (unlikely(rc != 0)) { - if (rc == -ESRCH) { -#if 1 /* With TERM EXCHANGE some FC cards refuse to boot */ - qlt_send_busy(rsp->qpair, atio, 0); -#else - qlt_send_term_exchange(rsp->qpair, NULL, atio, 1, 0); -#endif - } else { - if (tgt->tgt_stop) { - ql_dbg(ql_dbg_tgt, vha, 0xe05f, - "qla_target: Unable to send " - "command to target, sending TERM " - "EXCHANGE for rsp\n"); - qlt_send_term_exchange(rsp->qpair, NULL, - atio, 1, 0); - } else { - ql_dbg(ql_dbg_tgt, vha, 0xe060, - "qla_target(%d): Unable to send " - "command to target, sending BUSY " - "status\n", vha->vp_idx); - qlt_send_busy(rsp->qpair, atio, 0); - } + switch (rc) { + case -ENODEV: + ql_dbg(ql_dbg_tgt, vha, 0xe05f, + "qla_target: Unable to send command to target\n"); + break; + case -EBADF: + ql_dbg(ql_dbg_tgt, vha, 0xe05f, + "qla_target: Unable to send command to target, sending TERM EXCHANGE for rsp\n"); + qlt_send_term_exchange(rsp->qpair, NULL, + atio, 1, 0); + break; + case -EBUSY: + ql_dbg(ql_dbg_tgt, vha, 0xe060, + "qla_target(%d): Unable to send command to target, sending BUSY status\n", + vha->vp_idx); + qlt_send_busy(rsp->qpair, atio, + tc_sam_status); + break; + default: + ql_dbg(ql_dbg_tgt, vha, 0xe060, + "qla_target(%d): Unable to send command to target, sending BUSY status\n", + vha->vp_idx); + qlt_send_busy(rsp->qpair, atio, + qla_sam_status); + break; } } }