Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp793725imm; Fri, 27 Jul 2018 06:17:10 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfWo8cOPfTGfIa52AXEVK03svh2VZrxdZUyX8U5viJJTLDwIx4q9zYCfoeucdzLBujrqvcw X-Received: by 2002:a63:ac57:: with SMTP id z23-v6mr5942004pgn.74.1532697430448; Fri, 27 Jul 2018 06:17:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532697430; cv=none; d=google.com; s=arc-20160816; b=CkthgvoHJDDmgF+Ky0Uk60Z7vLW+3ck6vunLZ1eyM5t1TYVPObkxDJq4Wy0kC3dNV/ Yug2TvpIQ4+5anC78KmsywsxIXEXDHgP3snFaMJbRR0jnbY7jyGVcOsFR817dpi7bV4W vQjmThQVmu0vFzwcbBIEJjTwdRa83ZhFwnu9IA4+mgb+ppEowhTZ1uePeVUhrZMEVp+4 xp2Nr6SpUslNTlxrgLtb47X3WaqByfK005bfefVfDrzbRW3gJTZsPMZJM8SFQs99ig7A M2O7E4rj2boTZB2veoVd3ZUG7DVA1VAkmPK5ED2L4XJvSfgB14VOiZe69GNQr582AIlt AY5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=bonyMP6ToHXcnmBe8uNkrs7Gb5UrnzaxnxHSphica2U=; b=HRR+99jtdtfRNyStdM+qQtfder0HTKGjcCyq0mxrYMvkEjHOqj8uaLzA/4HE53tFIw sNb3Hs59GcuNm7z7gtk+58NNSjKSdvragVdD5iv3+DbWbB/kuJueSoDncwsM0saKTzlA JWjLPb160VRbykXYWEEmfjqRm8Z237ufHZIHW+YCyhXvnHIC4mo01qHL+lRVMC8IJt/H g6Pvgel7QimJj9idrp/MSI07oBGXD7v1nQTx1b3In07Xvu7FsnGKWQ6TOjT5ifwNXCtW 2k+ku1d+p6NPPHZu4NI3e6eTgXMuXpTGxuojWqzdgbfwTYS2v/f3alBGfVL8zdDZKvRB 2ppQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bi1-v6si3378887plb.399.2018.07.27.06.16.55; Fri, 27 Jul 2018 06:17:10 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388770AbeG0Oha (ORCPT + 99 others); Fri, 27 Jul 2018 10:37:30 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:55205 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732124AbeG0Oh3 (ORCPT ); Fri, 27 Jul 2018 10:37:29 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w6RDEJ11016198; Fri, 27 Jul 2018 15:15:32 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2kg26xrjwa-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 27 Jul 2018 15:15:32 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E7D9638; Fri, 27 Jul 2018 13:15:31 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag7node2.st.com [10.75.127.20]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id CDCE4577E; Fri, 27 Jul 2018 13:15:31 +0000 (GMT) Received: from localhost (10.75.127.49) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 27 Jul 2018 15:15:31 +0200 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH v4 14/17] remoteproc: keystone: declare reserved memory region for vdev device Date: Fri, 27 Jul 2018 15:14:49 +0200 Message-ID: <1532697292-14272-15-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1532697292-14272-1-git-send-email-loic.pallardy@st.com> References: <1532697292-14272-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG3NODE2.st.com (10.75.127.8) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-27_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch introduces keystone_rproc_parse_fw() to declare a carveout region based on reserved memory for vdev buffer allocation, if a memory region has been declared on rproc DT node. Signed-off-by: Loic Pallardy --- drivers/remoteproc/keystone_remoteproc.c | 53 +++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/drivers/remoteproc/keystone_remoteproc.c b/drivers/remoteproc/keystone_remoteproc.c index aaac311..ef542f2 100644 --- a/drivers/remoteproc/keystone_remoteproc.c +++ b/drivers/remoteproc/keystone_remoteproc.c @@ -293,11 +293,56 @@ static void *keystone_rproc_da_to_va(struct rproc *rproc, u64 da, int len) return (__force void *)va; } +/* + * Custom function to register platform specific memory region(s) + * before loading firmware resource table thanks to generic + * rproc_elf_load_rsc_table() function. + */ +static int keystone_rproc_parse_fw(struct rproc *rproc, + const struct firmware *fw) +{ + struct device *dev = rproc->dev.parent; + struct rproc_mem_entry *mem; + struct device_node *node; + struct resource res; + int err; + + node = of_parse_phandle(dev->of_node, "memory-region", 0); + if (!node) { + dev_warn(dev, "No memory-region specified\n"); + goto out; + } + + err = of_address_to_resource(node, 0, &res); + if (err) { + dev_err(dev, "Bad memory-region definition\n"); + return err; + } + + /* Register memory region for vdev buffer allocation */ + mem = rproc_of_resm_mem_entry_init(dev, 0, resource_size(&res), + res.start, "vdev0buffer"); + + if (!mem) + return -ENOMEM; + + rproc_add_carveout(rproc, mem); + +out: + return rproc_elf_load_rsc_table(rproc, fw); +} + static const struct rproc_ops keystone_rproc_ops = { - .start = keystone_rproc_start, - .stop = keystone_rproc_stop, - .kick = keystone_rproc_kick, - .da_to_va = keystone_rproc_da_to_va, + .start = keystone_rproc_start, + .stop = keystone_rproc_stop, + .kick = keystone_rproc_kick, + .da_to_va = keystone_rproc_da_to_va, + .parse_fw = keystone_rproc_parse_fw, + .load = rproc_elf_load_segments, + .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table, + .sanity_check = rproc_elf_sanity_check, + .get_boot_addr = rproc_elf_get_boot_addr, + }; static int keystone_rproc_of_get_memories(struct platform_device *pdev, -- 1.9.1