Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1445814ybz; Thu, 16 Apr 2020 09:17:07 -0700 (PDT) X-Google-Smtp-Source: APiQypI22KVcm4j2xIqUi51JR748LIlIJ027FpA5EExGReInQTaS2F2upL0p3NkbxC3PvTMKY3PN X-Received: by 2002:a17:906:2418:: with SMTP id z24mr10325553eja.42.1587053826911; Thu, 16 Apr 2020 09:17:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587053826; cv=none; d=google.com; s=arc-20160816; b=PBARxSPBMaoMpwmew9eG28NV39GioSwellwnrN+Qg+hxFWgY0RAkfShvwSTKxHmk25 qqxo5Ipa+2JZdkUTC4x3kHT0K4NALqjEtOeWAYWzXZgQC/h/p4TSiI1K+xo0GkMjK9QD 1vYgEDgRHq63oeq2DWmAAVIoExCaWw1eUqmA2zCvtXCzp6bhyNwM5Qq4QRE2bCsw1qla HaNXkgdEOulEB79VAT8Wo50EhuNulZ/QlbhIrcw1y2OeoC0/8iuN4eo3PcDGrGp1C9sT iOLKB+40f8oBwtqGo1xe5Ixysvxb/44idULebpVITOBQIxGU0FCZAyezQ44vpexgi27N OZjw== 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:dkim-signature; bh=eeai/sSDA7yw0YAME0STQXmQf2U/BhDMnF4JiuPgFGA=; b=OK/XbOqUji/BRvVQuuPO7hwW/kzfjxUTZbqKcvImK8gTPyrWCSX97zFV/cs5V3Dgdl jMCDzVoric7rcd3qSHclebOZnXb9W6gLd3keEYSANddapI/YBCrZp1pvxbzuk3rogxOP 5lksLCRcxXVnMlLzlOpxwmXFblc+j52COzKY0NGyvkiYoajtCcSUHKA+mw42JfMtluUH HRijSCaMm30A8izDTAKBi2ZJveyR6oC5nHs5fqiZ4aHhzoc9d32W+pPWK0CC72UdnRBi uOgKK7FT5fprEc5p3OR0wQ770Uiq2+0OoRxTC9WXAsA+OQu/kC2fpJIznAlfjCzzWD2+ YN3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=bcnSKedP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id by8si8186268ejb.525.2020.04.16.09.16.44; Thu, 16 Apr 2020 09:17:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=bcnSKedP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2895360AbgDPQO5 (ORCPT + 99 others); Thu, 16 Apr 2020 12:14:57 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:4002 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2636557AbgDPQO3 (ORCPT ); Thu, 16 Apr 2020 12:14:29 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03GGDTqs026413; Thu, 16 Apr 2020 18:14:26 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=eeai/sSDA7yw0YAME0STQXmQf2U/BhDMnF4JiuPgFGA=; b=bcnSKedPRhpuXMGraK7fOequ647brxc0twauwXsfPDLuUr6ADcgmdS7LFCYJk99eDQhL Y7WeZi/RWbBzeNmcen8C0lAJFOFIuMqlzOyCKtPbWbHt1iFbZxChtOJDYbmhBFIooe3m zBTaagj7COUYEBoPbnfRye7vRjLPa6XYdFyDpLILZqknErg994I4hh4gvw/bhZLbvde3 wfSWzvQsFBJb8W1+MLdAOWcUJORX4xyohu5huMFlY4ikRAdHXPHE/raRq/3iCE/Z8xKV oL2LoTanrdBVCHbu2GhhI2T0TeTwRC+J/ucDp5Fuw/bED3/8/upTkr3Z/db01svb9Scs zA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30dn8s3knd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 18:14:26 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B56FC10002A; Thu, 16 Apr 2020 18:14:25 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id AA3AD2B2D2A; Thu, 16 Apr 2020 18:14:25 +0200 (CEST) Received: from localhost (10.75.127.45) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 16 Apr 2020 18:14:25 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [RFC 13/18] remoteproc: Add memory default allocator helper Date: Thu, 16 Apr 2020 18:13:26 +0200 Message-ID: <20200416161331.7606-14-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> References: <20200416161331.7606-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG1NODE1.st.com (10.75.127.1) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_06:2020-04-14,2020-04-16 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a default basic allocator based on ioremap, to allocate carveout memories. These functions can be used by platforms that do not need specific management of the memory region (no MPU, no IOMMU, ...) Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 50 ++++++++++++++++++++++++ drivers/remoteproc/remoteproc_internal.h | 2 + 2 files changed, 52 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 9238aa292644..f9d04e59081c 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -220,6 +220,56 @@ void *rproc_da_to_va(struct rproc *rproc, u64 da, int len) } EXPORT_SYMBOL(rproc_da_to_va); +/** + * rproc_default_mem_alloc() - Simple mmap of the memory + * @rproc: handle of a remote processor + * @mem: memory entry descriptor + * + * Memory allocator for basic remote processors that do not need to manage + * specific memory allocation ( no MPU; no IOMMU, ....). In this case the + * memory is just mapped in in kernel space. + * + * Return: 0 on success else error + */ +int rproc_default_mem_alloc(struct rproc *rproc, struct rproc_mem_entry *mem) +{ + struct device *dev = rproc->dev.parent; + void *va; + + dev_dbg(dev, "map memory: %pa+%x\n", &mem->dma, mem->len); + va = ioremap_wc(mem->dma, mem->len); + if (IS_ERR_OR_NULL(va)) { + dev_err(dev, "Unable to map memory region: %pa+%x\n", + &mem->dma, mem->len); + return -ENOMEM; + } + + /* Update memory entry va */ + mem->va = va; + + return 0; +} +EXPORT_SYMBOL(rproc_default_mem_alloc); + +/** + * rproc_default_mem_release() - release of the mmaped memory + * @rproc: handle of a remote processor + * @mem: memory entry descriptor + * + * Memory release for basic remote processors allocated by + * @rproc_default_mem_alloc + * + * Return: 0 on success else error + */ +int rproc_default_mem_release(struct rproc *rproc, struct rproc_mem_entry *mem) +{ + dev_dbg(rproc->dev.parent, "unmap memory: %pa\n", &mem->dma); + iounmap(mem->va); + + return 0; +} +EXPORT_SYMBOL(rproc_default_mem_release); + /** * rproc_find_carveout_by_name() - lookup the carveout region by a name * @rproc: handle of a remote processor diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 5139cca646ca..608aeea564b4 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -65,6 +65,8 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw); int rproc_elf_load_rsc_table(struct rproc *rproc, const struct firmware *fw); struct resource_table *rproc_elf_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *fw); +int rproc_default_mem_alloc(struct rproc *rproc, struct rproc_mem_entry *mem); +int rproc_default_mem_release(struct rproc *rproc, struct rproc_mem_entry *mem); struct rproc_mem_entry * rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...); int rproc_check_carveout_da(struct rproc *rproc, struct rproc_mem_entry *mem, -- 2.17.1