Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp794112imm; Fri, 27 Jul 2018 06:17:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf16xpsI7oLl9d3eNSnMQnb/z7vhvWK/raOxe3Suo2rgeC0QJA8GONSEGJrroyqvBYye0+Y X-Received: by 2002:a65:665a:: with SMTP id z26-v6mr5998789pgv.193.1532697453851; Fri, 27 Jul 2018 06:17:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532697453; cv=none; d=google.com; s=arc-20160816; b=LES9JInubO8HaL6LC+tbQf93q6ruOQaD1YkO8Chz+Epbq34mXu6qwsQYHcqT037nBZ +BBPpA5WUzgWMHQEXuq4jI6Pmx+BICk2SXHDc1GyfZcqrJryG0Fwxd8W4wneT2C8nqdT wdLlPDXn3DhPpNGCs+/4O/zl5vweF+MvBgoJ1iAEeqptyKPGkPerZeqfEJwNte0BgSB7 Gjn4HlAeSA1fUB/xY+32850vN16l1Oggy8r6MHLnYM/7Wn4ipMjNP10GTcIzhvu2Eh40 KdvtIcyRXl4q9JaOelEkhqc9oT+BXp8qMT0ocu/08vfsRn4OZyt32Bzgdl82wcM2xBHN /wJg== 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=L5zCVhRUKKQ7fmLYZpB2xE7K4yGvjeygGTO1OkPy+Bg=; b=B/vbSRmPWRHBgV73ySqRDbSNgBOgiphXQGWIpsZvcJ9tbm8kqm8J0YxhovFKlB37NP nEHxZCGQ6B8RAeJNk1U0nUMoF85543YLtrRCkAw0BMhloYm6aVa8y+R3MN3wLA6far0N 60nILBj16BTZVR3LtN4L9MC//zvyBR+6NSRmKAH8tXli32ZazprQxmqIq4qUMehZUVXI qb2EcQhXwvIcmIGnM2xa3RwgotAO3/02Pf0xAFMgOZBAQ2IGedMMghvyKt4WsnxuqdvR rd6iSH00MCoiPvuywBA51WqSX3Q+nESl3+DH+Tr9suPXXK7IqAoTWGzE0HJbMm7HTh6X xEIA== 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 i10-v6si4476334pfe.119.2018.07.27.06.17.19; Fri, 27 Jul 2018 06:17:33 -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 S2388674AbeG0Oh0 (ORCPT + 99 others); Fri, 27 Jul 2018 10:37:26 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:25781 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732124AbeG0Oh0 (ORCPT ); Fri, 27 Jul 2018 10:37:26 -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 w6RDEJ0x016198; Fri, 27 Jul 2018 15:15:27 +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 2kg26xrjvt-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 27 Jul 2018 15:15:27 +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 2C30531; Fri, 27 Jul 2018 13:15:27 +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 0C7C5577E; Fri, 27 Jul 2018 13:15:27 +0000 (GMT) Received: from localhost (10.75.127.48) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 27 Jul 2018 15:15:26 +0200 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH v4 09/17] remoteproc: add helper function to allocate rproc_mem_entry from reserved memory Date: Fri, 27 Jul 2018 15:14:44 +0200 Message-ID: <1532697292-14272-10-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.48] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) 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 rproc_res_mem_entry_init() helper function to allocate a rproc_mem_entry structure from a reserved memory region. In that case, rproc_mem_entry structure has no alloc and release ops. It will be used to assigned the specified reserved memory to any rproc sub device. Relation between rproc_mem_entry and rproc sub device will be done by name. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 37 ++++++++++++++++++++++++++++++++++++ include/linux/remoteproc.h | 6 ++++++ 2 files changed, 43 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 2c51549..1e0fe3e 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -857,6 +857,7 @@ struct rproc_mem_entry * mem->alloc = alloc; mem->release = release; mem->rsc_offset = FW_RSC_ADDR_ANY; + mem->of_resm_idx = -1; va_start(args, name); vsnprintf(mem->name, sizeof(mem->name), name, args); @@ -867,6 +868,42 @@ struct rproc_mem_entry * EXPORT_SYMBOL(rproc_mem_entry_init); /** + * rproc_of_resm_mem_entry_init() - allocate and initialize rproc_mem_entry struct + * from a reserved memory phandle + * @dev: pointer on device struct + * @of_resm_idx: reserved memory phandle index in "memory-region" + * @len: memory carveout length + * @da: device address + * @name: carveout name + * + * This function allocates a rproc_mem_entry struct and fill it with parameters + * provided by client. + */ +struct rproc_mem_entry * +rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, int len, + u32 da, const char *name, ...) +{ + struct rproc_mem_entry *mem; + va_list args; + + mem = kzalloc(sizeof(*mem), GFP_KERNEL); + if (!mem) + return mem; + + mem->da = da; + mem->len = len; + mem->rsc_offset = FW_RSC_ADDR_ANY; + mem->of_resm_idx = of_resm_idx; + + va_start(args, name); + vsnprintf(mem->name, sizeof(mem->name), name, args); + va_end(args); + + return mem; +} +EXPORT_SYMBOL(rproc_of_resm_mem_entry_init); + +/** * A lookup table for resource handlers. The indices are defined in * enum fw_resource_type. */ diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index ea95b04..4cdd0c6 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -319,6 +319,7 @@ struct fw_rsc_vdev { * @node: list node * @rsc_offset: offset in resource table * @flags: iommu protection flags + * @of_resm_idx: reserved memory phandle index * @alloc: specific memory allocator function */ struct rproc_mem_entry { @@ -331,6 +332,7 @@ struct rproc_mem_entry { struct list_head node; u32 rsc_offset; u32 flags; + u32 of_resm_idx; int (*alloc)(struct rproc *rproc, struct rproc_mem_entry *mem); int (*release)(struct rproc *rproc, struct rproc_mem_entry *mem); }; @@ -573,6 +575,10 @@ struct rproc_mem_entry * int (*release)(struct rproc *, struct rproc_mem_entry *), const char *name, ...); +struct rproc_mem_entry * +rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, int len, + u32 da, const char *name, ...); + int rproc_boot(struct rproc *rproc); void rproc_shutdown(struct rproc *rproc); void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type); -- 1.9.1