From patchwork Thu Aug 4 09:21:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 73255 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1290272qga; Thu, 4 Aug 2016 02:25:44 -0700 (PDT) X-Received: by 10.66.73.166 with SMTP id m6mr123234254pav.122.1470302744558; Thu, 04 Aug 2016 02:25:44 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id gg3si8070281pac.136.2016.08.04.02.25.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Aug 2016 02:25:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bVEtO-0006ip-Nn; Thu, 04 Aug 2016 09:24:42 +0000 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bVErj-0005Ox-Ue for linux-arm-kernel@lists.infradead.org; Thu, 04 Aug 2016 09:23:03 +0000 Received: by mail-wm0-x230.google.com with SMTP id i5so370064178wmg.0 for ; Thu, 04 Aug 2016 02:22:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MtniGgZ1gouz9bBPSSKJek1gpZJtqhbSzVRotWq+g4w=; b=cPS9VJOwBN0xmVbgKLcq+BZJfyVSFB2EgJ1CK6CIUdfk6CFIeznISHex99GGPZqPPA wPbsfmWpNoU65qSUWUzgu4oPlBEL0lNSRt6GruntucMQlfl33J53LUJGL8CWw/oo4Xe8 2NiEICJ+1/NSwhbiMHW7MHCphmBGIEqh/9Ang= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MtniGgZ1gouz9bBPSSKJek1gpZJtqhbSzVRotWq+g4w=; b=ZTwjvI5zUgR2MUOSwrRG2EZNRhnvc9/7O+3IV1ORXDEoAcO7ZGNYrlt8mYEq675OUi zDYk2IoDBYW8h73VT1q94R/GzfKOYWZBmbFM1r3jufe6mMKOIbXgwybbz62z1LDnCgyb tjGKha/2366BVfJeLeZk28FoAPKV9CLQH1ZkNEje1RUcHIsQFRB6GoENOSF6PDMuU1rv nWjfBQf40fTRWGFkNY66nPoI6ACj3xC9AHQ1sYMaYPIqYqbEoRH8G1n7t7cDTtQ6KJeO QC9/upLbEngjti/HdMlw7gcjcWOViPHCr1zzl8tR5i6MjARKQtjaXcf2dMpfd4voK6Mc 6PTA== X-Gm-Message-State: AEkoousKMRWPHX1l66T7hkoiOq5LPoxjcJUXM/oei7HNJOyiOxGYyHzthaqXmhBQsCX606rB X-Received: by 10.28.206.141 with SMTP id e135mr6377wmg.0.1470302558023; Thu, 04 Aug 2016 02:22:38 -0700 (PDT) Received: from localhost.localdomain (host86-185-202-8.range86-185.btcentralplus.com. [86.185.202.8]) by smtp.gmail.com with ESMTPSA id d64sm2615461wmc.22.2016.08.04.02.22.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Aug 2016 02:22:37 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/9] remoteproc: core: Add function to amend an existing resource table entry Date: Thu, 4 Aug 2016 10:21:49 +0100 Message-Id: <20160804092153.23032-6-lee.jones@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160804092153.23032-1-lee.jones@linaro.org> References: <20160804092153.23032-1-lee.jones@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160804_022300_335456_E2CCB2B8 X-CRM114-Status: GOOD ( 13.84 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:230 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ohad@wizery.com, kernel@stlinux.com, loic.pallardy@st.com, linux-remoteproc@vger.kernel.org, patrice.chotard@st.com, bjorn.andersson@linaro.org, Lee Jones MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Sometimes the firmware does not know best. When a firmware is built, it can be loaded with a resource table, usually detailing shared; memory, virtual device, trace log information etc. However, some vendors require this hard-coded information to be amended with new/improved information obtained from Device Tree for instance. Until now, no method exists which allows the resource table to be amended. The addition of this function changes that. It is now possible to pull in a resource table and amend it before it is finally shared with the remote device. Signed-off-by: Lee Jones --- drivers/remoteproc/remoteproc_core.c | 63 ++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) -- 2.9.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 0abfa2b..3318ebd 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -917,6 +917,69 @@ int rproc_request_resource(struct rproc *rproc, u32 type, void *resource) } EXPORT_SYMBOL(rproc_request_resource); +static int rproc_update_resource_table_entry(struct rproc *rproc, + struct rproc_request_resource *request, + struct resource_table *table, int size) +{ + struct fw_rsc_carveout *tblc, *newc; + struct fw_rsc_devmem *tbld, *newd; + struct fw_rsc_trace *tblt, *newt; + int updated = true; + int i; + + for (i = 0; i < table->num; i++) { + int offset = table->offset[i]; + struct fw_rsc_hdr *hdr = (void *)table + offset; + void *rsc = (void *)hdr + sizeof(*hdr); + + if (request->type != hdr->type) + continue; + + switch (hdr->type) { + case RSC_CARVEOUT: + tblc = rsc; + newc = request->resource; + + if (strncmp(newc->name, tblc->name, + sizeof(*tblc->name))) + break; + + memcpy(tblc, newc, request->size); + + return updated; + case RSC_DEVMEM: + tbld = rsc; + newd = request->resource; + + if (strncmp(newd->name, tbld->name, + sizeof(*tbld->name))) + break; + + memcpy(tbld, newd, request->size); + + return updated; + case RSC_TRACE: + tblt = rsc; + newt = request->resource; + + if (strncmp(newt->name, tblt->name, + sizeof(*tblt->name))) + break; + + memcpy(tblt, newt, request->size); + + return updated; + default: + dev_err(&rproc->dev, + "Unsupported resource type: %d\n", + hdr->type); + return -EINVAL; + } + } + + return !updated; +} + /* * take a firmware and boot a remote processor with it. */