From patchwork Fri Mar 8 05:17:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Madhani X-Patchwork-Id: 10844191 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 7B835180E for ; Fri, 8 Mar 2019 05:18:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 653652EAB9 for ; Fri, 8 Mar 2019 05:18:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59F652EAD9; Fri, 8 Mar 2019 05:18:48 +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 3C78C2EACC for ; Fri, 8 Mar 2019 05:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726336AbfCHFSq (ORCPT ); Fri, 8 Mar 2019 00:18:46 -0500 Received: from mail-eopbgr680068.outbound.protection.outlook.com ([40.107.68.68]:21378 "EHLO NAM04-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726328AbfCHFSq (ORCPT ); Fri, 8 Mar 2019 00:18:46 -0500 Received: from DM5PR07CA0113.namprd07.prod.outlook.com (2603:10b6:4:ae::42) by MWHPR07MB3007.namprd07.prod.outlook.com (2603:10b6:300:e0::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.18; Fri, 8 Mar 2019 05:18:43 +0000 Received: from CO1NAM05FT062.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e50::207) by DM5PR07CA0113.outlook.office365.com (2603:10b6:4:ae::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1686.17 via Frontend Transport; Fri, 8 Mar 2019 05:18:43 +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 CO1NAM05FT062.mail.protection.outlook.com (10.152.96.180) 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 05:18:42 +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; Thu, 7 Mar 2019 21:17:34 -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 x285HXYF030827; Thu, 7 Mar 2019 21:17:33 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id x285HXQp030826; Thu, 7 Mar 2019 21:17:33 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH 10/14] qla2xxx: Correction and improvement to fwdt processing Date: Thu, 7 Mar 2019 21:17:00 -0800 Message-ID: <20190308051704.30752-11-hmadhani@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20190308051704.30752-1-hmadhani@marvell.com> References: <20190308051704.30752-1-hmadhani@marvell.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131964959229295716;(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)(39860400002)(376002)(396003)(346002)(136003)(2980300002)(1110001)(1109001)(339900001)(189003)(199004)(80596001)(36756003)(1076003)(48376002)(26826003)(68736007)(50226002)(50466002)(47776003)(305945005)(76176011)(110136005)(42186006)(51416003)(16586007)(316002)(53936002)(8936002)(36906005)(26005)(6666004)(356004)(2906002)(5660300002)(54906003)(81156014)(8676002)(81166006)(97736004)(336012)(69596002)(105606002)(446003)(2616005)(476003)(126002)(86362001)(11346002)(486006)(498600001)(87636003)(106466001)(4326008)(85426001);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR07MB3007;H:CAEXCH02.caveonetworks.com;FPR:;SPF:Fail;LANG:en;PTR:InfoDomainNonexistent;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2007f042-6957-4144-ee34-08d6a385881f X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(5600127)(711020)(4605104)(2017052603328);SRVR:MWHPR07MB3007; X-MS-TrafficTypeDiagnostic: MWHPR07MB3007: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 0970508454 X-Microsoft-Exchange-Diagnostics: 1;MWHPR07MB3007;23:A8SprthWdQL3Sjgb6R5XVn5BrKXsCx0rO46kY5KodmzsrmKweYIwitgtj0vzp5KeY2qZLqU0s/n6Uv6N3srbYIhstrqphMk/FCewG4gLMrKmyYbscF+GhqvJ5sp4F7xBwc5w6Hc3/Ts5xhsgyeeK0nOK9+IIKyVrMv8TYrGdfgG6E7ttJdLNnZsp9ITTpxjQFe0S2KgMNRaQwNzOSrtYqs9bwwPpQBv87jAfC5sGQoeWUBEoT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dUToxY9aFU2nlFzYz9jRk4io4AVK9+Qww/FH78jIwzA4/fnnM1z3FScFOx3tPLZgE0ocMJQZeotejsr/NUJ88ryoP3AhExgOOEY3A1XURpNDEXhvE1kSrULygUHhGbIsmkZSZiOqHHPjOByRXu6fVkBx1CRfftCeDROs0fY4fwhbQaPLUidX+DVDY9/EBbUNofaoGV4uf4PEpbWvYAPPg2xTYcmnwZFlPh5HJSICMUosSmWYXDoFQBwlxpsdj7Y51U19OBUODs82hl0rfC+VBktTm1k+p/gDDqJ59x07tfp3LFX+QA0Wsy2Slhw/4SDudpc1UYwvEu88mOyycqQte5gmQXGTlSwAFE4= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2019 05:18:42.6343 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2007f042-6957-4144-ee34-08d6a385881f 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: MWHPR07MB3007 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 | 51 ++++++++++++++++++++++------------------- drivers/scsi/qla2xxx/qla_tmpl.h | 2 +- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_tmpl.c b/drivers/scsi/qla2xxx/qla_tmpl.c index fab09bcefc72..07ebebcbc0db 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); } } @@ -697,9 +697,9 @@ static struct qla27xx_fwdt_entry * qla27xx_fwdt_entry_t275(struct scsi_qla_host *vha, struct qla27xx_fwdt_entry *ent, void *buf, ulong *len) { - ulong offset = offsetof(typeof(*ent), t275.buffer); - ulong length = le32_to_cpu(ent->t275.length); ulong size = le32_to_cpu(ent->hdr.size); + ulong length = le32_to_cpu(ent->t275.length); + ulong offset = offsetof(typeof(*ent), t275.buffer); void *buffer = ent->t275.buffer; ql_dbg(ql_dbg_misc + ql_dbg_verbose, vha, 0xd213, @@ -711,10 +711,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 = cpu_to_le32(length); } qla27xx_insertbuf(buffer, length, buf, len); @@ -726,17 +726,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(ent->t276.cond1); - ulong cond2 = le32_to_cpu(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(ent->t276.cond1); + ulong cond2 = le32_to_cpu(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); @@ -842,25 +847,25 @@ qla27xx_walk_template(struct scsi_qla_host *vha, { struct qla27xx_fwdt_entry *ent = (void *)tmp + le32_to_cpu(tmp->entry_offset); - ulong count = le32_to_cpu(tmp->entry_count); - ulong type = 0; + ulong type; + tmp->count = le32_to_cpu(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(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, "%s: missing end entry\n", __func__); + + cpu_to_le32s(&tmp->count); /* endianize residual count */ } static void 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;