Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967312AbdCXTdk (ORCPT ); Fri, 24 Mar 2017 15:33:40 -0400 Received: from mail-bl2nam02on0068.outbound.protection.outlook.com ([104.47.38.68]:53371 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S967054AbdCXT37 (ORCPT ); Fri, 24 Mar 2017 15:29:59 -0400 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; From: Wendy Liang To: CC: , , "Wendy Liang" , Wendy Liang , Michal Simek Subject: [RFC LINUX PATCH 08/19] remoteproc: add a function to set fw checksum rsc Date: Fri, 24 Mar 2017 12:22:24 -0700 Message-ID: <1490383355-23176-9-git-send-email-jliang@xilinx.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1490383355-23176-1-git-send-email-jliang@xilinx.com> References: <1490383355-23176-1-git-send-email-jliang@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.1.0.1062-22962.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.83;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(39860400002)(39850400002)(39410400002)(39450400003)(39840400002)(2980300002)(438002)(199003)(189002)(9170700003)(356003)(47776003)(36386004)(5660300001)(2906002)(33646002)(50226002)(5003940100001)(110136004)(9786002)(107886003)(38730400002)(4326008)(2950100002)(8936002)(81166006)(77096006)(106466001)(8676002)(54906002)(2351001)(50986999)(76176999)(305945005)(48376002)(6916009)(6666003)(36756003)(50466002)(189998001)(107986001)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR02MB1377;H:xsj-pvapsmtpgw01;FPR:;SPF:Pass;MLV:sfv;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;CY1NAM02FT057;1:8OzHVFYzQnDcthOlal9aa4+WxzhKyP6HPYv9CT/eMhCpy1TVoSN7Ithj/8u2U5hbno3gvk6QEcZAw5+ISpletw7lZAs9SQvEN6IlcEBk1qbtrfAinF2W2/ZiLqZOQknfHjV+yhr76GfLPLQjhe+uL7zYnB4hSy/LrupZ8M2LJ+F0hAqGcwdJBj+XvGDqyBlVJy4retkuuX9GgU0vuww4B+Xv73phD2vQFyL6c7PE3Cgw7VXMz+HJ56c1WZaIZX8fNZLe4d7Qd1WH3iK3gmQBM4M/JbB8gyoe0Qs2oocz/koKy1/tSEUhIKAUKWNMBOwOmt6vGhw705JTB+p6ST5v7xLAytLECy21BFL9IZhg8kxTLrOBrW6Ef40lHuUiwPKn9XaE6ryD4ACN7Z+ygvp+We/EgafuPLGE1EbnZU8jqY1tc+HFuoD4bMRpBOn4nhYeTohihZoU7p6Cjiklep0Q1sLcOlBfXsAihW6IvTRphZWrz5qgwzrnCmckBUE+Mazt0lXfT7d8IytJQ5evNAEGWHeYsDHxbHCKcbvRJ3kicV6vYGlm3SpievsneduyyWq4OhQCHHFn7FvKiHgyBqlDqQ== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 22dde848-257b-47c1-d404-08d472ec2276 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(8251501002)(2017030254075);SRVR:BY2PR02MB1377; X-Microsoft-Exchange-Diagnostics: 1;BY2PR02MB1377;3:lPujs/kzFdFS4HpERcx+x/04Ll2pi1uQChO7MLxViCpKRQyXn/SBm+bNMcUWlgT8bshhIRXXUyfVEnwW7T1SGyJL3NVQY7NlzVYSG+A+FQTYxbJPJvxHP6SbqKYdoMkK01q+3U+gaH32O5oRpez1mXPkDPVzuR7EbBWeSSOeIAHCwORa5pHus9p4XKkx0lcBbz0V8R6CruNV9POTX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NkxYZ/kiSW8ABjw3ATRkvwF7EFR70IMCyg3QrQHWFKYimqK5bBw4aZyKLfUszx2ZICjfFTGKXifJ5hNbfT4OaBMFAqYxckVYR9YFUoiowTeJL/kSqaUS5IgqzOhUAB4RBmJj9q/SEqtzDz4ZEpBvvvgHby89wForZZz+Razn3r8L5BY7gJb+51nC9HtgPtylT4g6do6xQAsw+Myq5mfgmwQE41CQgxa6W4tEx/cCMsYbStMfICDVgqIvofGQfax3R3yyi7B131bqMR1LtlzsFcmIxBHdLgQntVDB1b+VQZusQGztmoEAZ23BYS7/5E5HsEBfG8DE1Zsz4EANNF4ypeQ/v4Y4zKqzspkaB/quw/7zXsn6NsWWbT1roeM/J8qWzYVDjPIm7f8680ijZn9F/JFE2+Z4fi0y+SYMn27OHOV2KZu0Dads9sYxFZcDkQyT6Z X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(13015025)(8121501046)(13017025)(13024025)(5005006)(13018025)(13023025)(3002001)(10201501046)(6055026)(6041248)(20161123564025)(20161123560025)(20161123562025)(20161123558025)(20161123555025)(6072148);SRVR:BY2PR02MB1377;BCL:0;PCL:0;RULEID:;SRVR:BY2PR02MB1377; X-Microsoft-Exchange-Diagnostics: 1;BY2PR02MB1377;4:ej0xBi5gKKdMCc4vMd8NxQSxPypliNU7V3XgmjqPidHiElrv2yctODntOcy+fHDQQw7I/As+ApGO3HA7uBTdcuCN2uSykDKLN6lji5iKeh/qCRO2cemgA65OQKRUmyKJAsavTOZCaNhEFsVGiHRMt+b4qgQ5h1QV+25/5HzxO2Mwt6OuweGngcu28AuP/18h5Bmspbf7BzUU6urgDkxo4czpODhIidfvcprxGGHLeFmm+3iUh8zT+qsUb9KizLqKt+mVx/ubmc2fDG0qe8YKB5mFExN55N636I17kwvmFVWtnzzxLWFsFJ9ec2CvPG50MY5cacf6WDBKipOn0vOTxUa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bZdOiKcShSQRnmKEFd5Gsitpd2YYn1r7pyUT5bq2DMxyFE49rGrtZyGzvjlKJTbwFfaEj4ONepvPKgCkJh9X4ztCBVnuq9KWxN1RRhffPKW3e9awV0HQsfHH0Y4nnjpa1FvhuyuUHyk+lUJUZB6w1evJrjgW74dk4w0kBsYnA=;5:65UZN85sS2hr9BSEZd5l3s7b+1G6ZfHekO1DJ61JATa3+29hsiXWJIM8ujPCW0t4jc1Y9rqwpAC4pn3T8ofhlj76bbpzCCqXjbNq6TnLMjF9F6VzzrzJgstMZOxriS0BqjiLSDdLdQJhi0jKvuVKFQ==;24:7XOJ+t0KfxAcvX0NFbREbJUy9NdTA1yDdFZhNIKvtCLsx/KyHOPMXyYmE/YWDfgcry/dS+1e7IF33t5P02pHw2TvKeASitGpZYMvvut6DSw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY2PR02MB1377;7:vCRbFovuWqPyDoYlH0b4roUbMB3uD2wPS8gj9zb0viuTMCsb8FnEGBDpCSkznDiZrjLQ7uiXGZMrGYhkI/oPirwbnMn5SdDnNK9NT12Uevpt2nisIykjbmlwEQziFhMW5zm968hm13llixi06z4rLxTD6Lgua9ANK8Ooqf9LV+qwR6FefoPUcxOlFTO43F6/QOFIJfVM88lN2zbxMnZrFnqtvBbHdo6TVysZzoLJ9eDCx9KDDxefN2OvSV9s/YBQRH/Ti9vOimR8s0mXJZxKhsC2KX5A39XgeaG/BGJDU+OcGpD8s33FteZdu6Q8szPudxDvluAc5t0iPBm2SOVjAg== X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2017 19:29:48.0112 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.83];Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR02MB1377 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2273 Lines: 79 From: Wendy Liang Add a function to set the firmware checksum resource. The function will call the firmware loader to calculate the firmware checksum and set it to the resource table. Signed-off-by: Wendy Liang Signed-off-by: Michal Simek --- drivers/remoteproc/remoteproc_core.c | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index f13f56d..447c28b 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -897,6 +897,60 @@ static bool rproc_is_running(struct rproc *rproc) return (rproc->state == RPROC_RUNNING) ? true : false; } +/** + * rproc_handle_fw_chksum() - handle firmware checksum resource + * @rproc: rproc handle + * @fw: firmware + * @offset: returns fw_chksum resource offset. + * + * This function will handle request to set the firmware checksum. + */ +static +struct fw_rsc_fw_chksum *rproc_handle_fw_chksum(struct rproc *rproc, + const struct firmware *fw, int *offset) +{ + struct fw_rsc_fw_chksum *rsc = NULL; + int i, tablesz; + struct device *dev = &rproc->dev; + struct resource_table *table; + + /* look for the resource table */ + table = rproc_find_rsc_table(rproc, fw, &tablesz); + if (!table) { + dev_err(dev, "Failed to find resource table\n"); + return NULL; + } + + for (i = 0; i < rproc->table_ptr->num; i++) { + int ret = 0; + int tmpoffset = rproc->table_ptr->offset[i]; + struct fw_rsc_hdr *hdr = (void *)rproc->table_ptr + tmpoffset; + int avail = tablesz - tmpoffset - sizeof(*hdr); + + if (hdr->type != RSC_FW_CHKSUM) + continue; + + rsc = (struct fw_rsc_fw_chksum *)((void *)hdr + sizeof(*hdr)); + if (sizeof(*rsc) > avail) { + dev_err(dev, "firmware checksum rsc is truncated\n"); + return NULL; + } + if (rproc->fw_ops->get_chksum) { + ret = rproc->fw_ops->get_chksum(rproc, fw, + rsc->algo, rsc->chksum, sizeof(rsc->chksum)); + if (ret) { + dev_err(dev, + "failed to get firmware chksum.\n"); + return NULL; + } + } + *offset = tmpoffset + sizeof(*hdr); + return rsc; + } + + return NULL; +} + /* * check if the remote needs start. */ -- 1.9.1