From patchwork Thu Aug 4 09:21:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 73248 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1289705qga; Thu, 4 Aug 2016 02:24:35 -0700 (PDT) X-Received: by 10.98.29.201 with SMTP id d192mr124345834pfd.142.1470302675281; Thu, 04 Aug 2016 02:24:35 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q1si13787689pan.173.2016.08.04.02.24.32; Thu, 04 Aug 2016 02:24:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758365AbcHDJY3 (ORCPT + 27 others); Thu, 4 Aug 2016 05:24:29 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:35401 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757395AbcHDJXt (ORCPT ); Thu, 4 Aug 2016 05:23:49 -0400 Received: by mail-wm0-f42.google.com with SMTP id f65so476970340wmi.0 for ; Thu, 04 Aug 2016 02:22:40 -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=4G7BOemQ5fR1RNWTA858I6H54kpho/7uYoXETPuTlu4=; b=aMQDSskREY7/QH2G4ZTxWEdc40b2N0J3IXQnGbEKK9+k7hejtJqyKVm3fXBOLMzLvo pRrHToPrb7SgAE304B5hEbCiTFmTcp/gbj9YCW58pOkYh2b0ZCOnlO1LO5v7FL0tQ7M4 nj7ijBt+Qd+yYvWw3ax66O8NRnK0/KhNSHFfo= 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=4G7BOemQ5fR1RNWTA858I6H54kpho/7uYoXETPuTlu4=; b=K2eI9DDj5wkLfqv2Lw/w2XGZaVo83aOvzPAzjIaZBZa9a84NQdlnYgKPtdC4I8KJ/q beTVgNhon4IembR7BN92RU4k4IDqRlxMrCy6mpA4NZVXEymBfn4KcLw0bEZQPewyacTU P+JNU7/mBjCcCSoLDqhTMYwG8rABjvLCCAfO0M90s7hjoPe1aP3AMGf6r3m2ehJGq/ar vic6sSdv0g7H+ER4rh70c4bDQWXY+8+ODVhnls6WuOpW6vhgAZ7KKXsmPNYqwUnSwn1I nV+44Lrl9koI+QUMEWnzfckMG7uv/4r4Upvd+f485KlX5JjtNioTaL0NViBbr/S9PSnn xaiQ== X-Gm-Message-State: AEkoouvKtAr1nd6lsjsbPPVUAqlQrEQ5hgwSNnCspSmuaXiNFR4UbwJsUN0NjDHVcx1EE5Z2 X-Received: by 10.194.187.7 with SMTP id fo7mr65633160wjc.162.1470302559768; Thu, 04 Aug 2016 02:22:39 -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.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Aug 2016 02:22:39 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: kernel@stlinux.com, patrice.chotard@st.com, ohad@wizery.com, bjorn.andersson@linaro.org, linux-remoteproc@vger.kernel.org, loic.pallardy@st.com, Lee Jones Subject: [PATCH 7/9] remoteproc: core: Add function to over-ride current resource table Date: Thu, 4 Aug 2016 10:21:51 +0100 Message-Id: <20160804092153.23032-8-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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Most of the new resource table handling function are now in place, so it's time to put it all together. Once new resource table information has been requested, the structures will be held in a holding pen until boot-time. During boot-time rproc_apply_resource_overrides() will be invoked which in turn will pull the new information out of the holding pen and edit the table accordingly. Signed-off-by: Lee Jones --- drivers/remoteproc/remoteproc_core.c | 65 ++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) -- 2.9.0 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 111350e..6b4e29a 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1035,6 +1035,65 @@ rproc_add_resource_table_entry(struct rproc *rproc, return table; } +static struct resource_table* +rproc_apply_resource_overrides(struct rproc *rproc, + struct resource_table **orig_table, + int *tablesz) +{ + struct rproc_request_resource *resource; + struct resource_table *table = *orig_table; + int size = *tablesz; + + if (!table && size != 0) { + dev_err(&rproc->dev, "No table present but table size is set\n"); + return ERR_PTR(-EINVAL); + } + + mutex_lock(&rproc->lock); + + rproc_dump_resource_table(rproc, table, size); + + if (!table) { + size = sizeof(*table); + table = devm_kzalloc(&rproc->dev, size, GFP_KERNEL); + if (!table) { + table = ERR_PTR(-ENOMEM); + goto out; + } + table->ver = 1; + } + + list_for_each_entry(resource, &rproc->override_resources, node) { + int updated = 0; + + /* If we already have a table, update it with the new values. */ + updated = rproc_update_resource_table_entry(rproc, resource, + table, size); + if (updated < 0) { + table = ERR_PTR(updated); + goto out; + } + if (updated) + continue; + + /* Didn't find matching resource entry -- creating a new one. */ + table = rproc_add_resource_table_entry(rproc, resource, + table, &size); + if (IS_ERR(table)) + goto out; + + *orig_table = table; + } + + rproc_dump_resource_table(rproc, table, size); + + *tablesz = size; + + out: + mutex_unlock(&rproc->lock); + return table; +} + /* * take a firmware and boot a remote processor with it. */ @@ -1153,6 +1212,12 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context) if (!table) goto out; + if (!list_empty(&rproc->override_resources)) { + table = rproc_apply_resource_overrides(rproc, &table, &tablesz); + if (IS_ERR(table)) + goto out; + } + rproc->table_csum = crc32(0, table, tablesz); /*