From patchwork Fri Mar 8 23:11:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Madhani X-Patchwork-Id: 10845589 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 6DD924A0A for ; Fri, 8 Mar 2019 23:13:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51247308A0 for ; Fri, 8 Mar 2019 23:13:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4247D308B2; Fri, 8 Mar 2019 23:13:06 +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,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 97F7B308A0 for ; Fri, 8 Mar 2019 23:13:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726640AbfCHXNF (ORCPT ); Fri, 8 Mar 2019 18:13:05 -0500 Received: from mail-eopbgr770083.outbound.protection.outlook.com ([40.107.77.83]:64134 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726631AbfCHXNE (ORCPT ); Fri, 8 Mar 2019 18:13:04 -0500 Received: from DM6PR07CA0069.namprd07.prod.outlook.com (2603:10b6:5:74::46) by CO2PR07MB2535.namprd07.prod.outlook.com (2603:10b6:102:13::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.19; Fri, 8 Mar 2019 23:13:02 +0000 Received: from BY2NAM05FT019.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e52::209) by DM6PR07CA0069.outlook.office365.com (2603:10b6:5:74::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1686.18 via Frontend Transport; Fri, 8 Mar 2019 23:13:02 +0000 Authentication-Results: spf=fail (sender IP is 199.233.58.38) smtp.mailfrom=marvell.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=fail action=none header.from=marvell.com; Received-SPF: Fail (protection.outlook.com: domain of marvell.com does not designate 199.233.58.38 as permitted sender) receiver=protection.outlook.com; client-ip=199.233.58.38; helo=CAEXCH02.caveonetworks.com; Received: from CAEXCH02.caveonetworks.com (199.233.58.38) by BY2NAM05FT019.mail.protection.outlook.com (10.152.100.156) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.20.1686.5 via Frontend Transport; Fri, 8 Mar 2019 23:13:01 +0000 Received: from dut1171.mv.qlogic.com (10.112.88.18) by CAEXCH02.caveonetworks.com (10.67.98.110) with Microsoft SMTP Server (TLS) id 14.2.347.0; Fri, 8 Mar 2019 15:11: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 x28NBqq3019303; Fri, 8 Mar 2019 15:11:52 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id x28NBqem019302; Fri, 8 Mar 2019 15:11:52 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH v2 10/14] qla2xxx: Correction and improvement to fwdt processing Date: Fri, 8 Mar 2019 15:11:19 -0800 Message-ID: <20190308231123.19228-11-hmadhani@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20190308231123.19228-1-hmadhani@marvell.com> References: <20190308231123.19228-1-hmadhani@marvell.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131965603821276907;(abac79dc-c90b-41ba-8033-08d666125e47);(abac79dc-c90b-41ba-8033-08d666125e47) X-Forefront-Antispam-Report: CIP:199.233.58.38;IPV:CAL;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(346002)(39860400002)(376002)(396003)(136003)(2980300002)(1109001)(1110001)(339900001)(199004)(189003)(305945005)(26005)(87636003)(54906003)(476003)(486006)(446003)(2616005)(126002)(97736004)(336012)(5660300002)(105606002)(106466001)(26826003)(42186006)(2906002)(498600001)(47776003)(8676002)(4326008)(81156014)(48376002)(50466002)(11346002)(36756003)(53936002)(76176011)(80596001)(85426001)(110136005)(69596002)(51416003)(81166006)(16586007)(356004)(86362001)(316002)(6666004)(1076003)(68736007)(36906005)(50226002)(8936002);DIR:OUT;SFP:1101;SCL:1;SRVR:CO2PR07MB2535;H:CAEXCH02.caveonetworks.com;FPR:;SPF:Fail;LANG:en;PTR:InfoDomainNonexistent;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1fc175be-dbe5-45ce-00df-08d6a41b9ccd X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(5600127)(711020)(4605104)(2017052603328);SRVR:CO2PR07MB2535; X-MS-TrafficTypeDiagnostic: CO2PR07MB2535: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 0970508454 X-Microsoft-Exchange-Diagnostics: 1;CO2PR07MB2535;23:gVZL+sJ+YpH2eIg3Yy4ku/smDe20SahAR1eEP2/9e8vIKwWLzKwsFfzSxpqAQgHfhKSadoGkacN2AggA7YH1MntoTRyanPUHGrU9ej8STYPCRBP7vNr6Skc8GSPDe/8nIhNSDFA1MCb4Q+qcz4WOPUmNuB1Iq+qGh+BlSjjSgL/3hedgzCnXXBzNLvB9XfX84lxY+fTiTCwxAURegTBMaZgMKxe8hht5Ke5jTzxiocuALACH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WvFlGHzDCmziZDydBz0Q+7q3rpputQ791bUYvagtYhnmqge0lFmL78WbwZ2ETNzRT9jBfMyAcv8MX2KUOQZT9WP1G0A2nYIU01HZRVg3terb5mm7EdcgkCVJ3rljnKDxxdZVYvkfIYFnLZ8QeoggKJHjlFoFTHQZ/T/HvbH1RBAm/9FAHxJF//hmtTr+biYOCQi/A1yn7J+rbM2B0HzQ11mSHqrk54/s/y0/Jp+ddnkCZqMlQsSo1Y5qWcG+x6aXwR14Q+rH6GJ5Kppok2DgLIWkrGas8UUmFv2hJoDSuH++yCtSc+SgSeL9Oh3ECz7tB4qxbRVQTPtGrYTuh7GBTA7Wx3pPCRBjemPDSlSSLtMPac4CYfd0EQ= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2019 23:13:01.8734 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1fc175be-dbe5-45ce-00df-08d6a41b9ccd X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[199.233.58.38];Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR07MB2535 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: Joe Carnuccio This patch cleans up and fixes firmware dump template processing. These changes are added to support newer features for ISP27XX/ISP28XX. Signed-off-by: Joe Carnuccio Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_tmpl.c | 43 +++++++++++++++++++++++------------------ drivers/scsi/qla2xxx/qla_tmpl.h | 2 +- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_tmpl.c b/drivers/scsi/qla2xxx/qla_tmpl.c index b6fc90c65765..dfaed4bba374 100644 --- a/drivers/scsi/qla2xxx/qla_tmpl.c +++ b/drivers/scsi/qla2xxx/qla_tmpl.c @@ -99,9 +99,9 @@ static inline void qla27xx_write_reg(__iomem struct device_reg_24xx *reg, uint offset, uint32_t data, void *buf) { - __iomem void *window = (void __iomem *)reg + offset; - if (buf) { + void __iomem *window = (void __iomem *)reg + offset; + WRT_REG_DWORD(window, data); } } @@ -709,10 +709,10 @@ qla27xx_fwdt_entry_t275(struct scsi_qla_host *vha, goto done; } if (offset + length > size) { + length = size - offset; ql_dbg(ql_dbg_misc, vha, 0xd030, - "%s: buffer overflow\n", __func__); - qla27xx_skip_entry(ent, buf); - goto done; + "%s: buffer overflow, truncate [%lx]\n", __func__, length); + ent->t275.length = length; } qla27xx_insertbuf(buffer, length, buf, len); @@ -724,17 +724,22 @@ static struct qla27xx_fwdt_entry * qla27xx_fwdt_entry_t276(struct scsi_qla_host *vha, struct qla27xx_fwdt_entry *ent, void *buf, ulong *len) { - ulong cond1 = le32_to_cpu(*qla_fw_addr32(ent->t276.cond1)); - ulong cond2 = le32_to_cpu(*qla_fw_addr32(ent->t276.cond2)); - uint type = vha->hw->pdev->device >> 4 & 0xf; - uint func = vha->hw->port_no & 0x3; - ql_dbg(ql_dbg_misc + ql_dbg_verbose, vha, 0xd214, "%s: cond [%lx]\n", __func__, *len); - if (type != cond1 || func != cond2) { - ent = qla27xx_next_entry(ent); - qla27xx_skip_entry(ent, buf); + if (buf) { + ulong cond1 = le32_to_cpu(*qla_fw_addr32(ent->t276.cond1)); + ulong cond2 = le32_to_cpu(*qla_fw_addr32(ent->t276.cond2)); + uint type = vha->hw->pdev->device >> 4 & 0xf; + uint func = vha->hw->port_no & 0x3; + + if (type != cond1 || func != cond2) { + struct qla27xx_fwdt_template *tmp = buf; + + tmp->count--; + ent = qla27xx_next_entry(ent); + qla27xx_skip_entry(ent, buf); + } } return qla27xx_next_entry(ent); @@ -840,21 +845,21 @@ qla27xx_walk_template(struct scsi_qla_host *vha, { struct qla27xx_fwdt_entry *ent = (void *)tmp + le32_to_cpu(*qla_fw_addr32(tmp->entry_offset)); - ulong count = le32_to_cpu(*qla_fw_addr32(tmp->entry_count)); - ulong type = 0; + ulong type; + tmp->count = le32_to_cpu(*qla_fw_addr32(tmp->entry_count)); ql_dbg(ql_dbg_misc, vha, 0xd01a, - "%s: entry count %lx\n", __func__, count); - while (count--) { + "%s: entry count %u\n", __func__, tmp->count); + while (ent && tmp->count--) { type = le32_to_cpu(*qla_fw_addr32(ent->hdr.type)); ent = qla27xx_find_entry(type)(vha, ent, buf, len); if (!ent) break; } - if (count) + if (tmp->count) ql_dbg(ql_dbg_misc, vha, 0xd018, - "%s: entry count residual=+%lu\n", __func__, count); + "%s: entry count residual=+%u\n", __func__, tmp->count); if (ent) ql_dbg(ql_dbg_misc, vha, 0xd019, diff --git a/drivers/scsi/qla2xxx/qla_tmpl.h b/drivers/scsi/qla2xxx/qla_tmpl.h index 5c2c2a8a19c4..030633ee47f8 100644 --- a/drivers/scsi/qla2xxx/qla_tmpl.h +++ b/drivers/scsi/qla2xxx/qla_tmpl.h @@ -14,7 +14,7 @@ struct __packed qla27xx_fwdt_template { uint32_t template_type; uint32_t entry_offset; uint32_t template_size; - uint32_t reserved_1; + uint32_t count; /* borrow field for running/residual count */ uint32_t entry_count; uint32_t template_version;