From patchwork Thu Mar 1 16:23:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 130321 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3004109edc; Thu, 1 Mar 2018 08:24:17 -0800 (PST) X-Google-Smtp-Source: AG47ELv+pv2CTp+WEsddutpn9oZvdP2lAZ/dqsMr8VqluNL0qXT9Vf4fbmxdEbNiYHdr9iz5aznk X-Received: by 10.98.194.87 with SMTP id l84mr2516442pfg.6.1519921457805; Thu, 01 Mar 2018 08:24:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519921457; cv=none; d=google.com; s=arc-20160816; b=mH0aFX6PjHH0Y4qqlaFypQ4g0AtSHtgD7vBDTpFPPD4yUv+W2gEqp816NCUaBDTY1X 9Abto+U910QM29V3kk5rCVq3TQguw8xNlySMnFBh/7NLB8b39buqaaPhRWlZvcNu9Qp1 Zw3L0BEKmEOlY/F6n6W45zhWoOeI4sZy527cDJO6vu2ZdtyEhmC2tNr05CWNMRJlxJSn LcmKvItDTmv210L65BOgLTBEeanF6nDeiyITQJWr328op8CDiiOxgMiGhuHQZf/UAwyN O1RXqH3TYqp2qTAZfzN06cGXj4X3AQUv6DO4dSbsXb/JnHyHozm9N7KRk90h2JqtU42K Ll5Q== 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=9UiL+0x0iUTxyTQNP9WDZJgttFahGETNTD85JAxdG3w=; b=mygdlJ+ZhLpCkozC+O9wR/D1eLTu3NqNZ080wXArtqc+hQytJ+LThwSG+Budbk3EJc qBMC+St65q/VJTPTTdHaVmwxrLCERDZELTS1pdJJgBJnVdf5Db0EYDaDG1EPY+tx7kiB JAdzcqiC9NYBPMGPzrmnOAIUw2mOEOlqYUjlKZxJIDtpgwd8mticeHoobgAi814EHSDF 2vvyk6thRQcYLffsF0+V0MHmWBo+5YOfWz6GFh0+nuGN+sB9sJRcHjd+KNTBjmQ1/npz hLdaEZyp0k01Y9uX7PYtVh+4lhnpOf8jHO/4lIGlpwUa6s3fst3UHtZFGvR4aMGehLBw dfgw== 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 x2-v6si3206173plv.672.2018.03.01.08.24.17; Thu, 01 Mar 2018 08:24:17 -0800 (PST) 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 S1032971AbeCAQYP (ORCPT + 28 others); Thu, 1 Mar 2018 11:24:15 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:61627 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032698AbeCAQYN (ORCPT ); Thu, 1 Mar 2018 11:24:13 -0500 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 w21GJQYX025446; Thu, 1 Mar 2018 17:24:11 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2gax28ujkc-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 01 Mar 2018 17:24:11 +0100 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 A998E31; Thu, 1 Mar 2018 16:24:10 +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 8F1ED51FD; Thu, 1 Mar 2018 16:24:10 +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; Thu, 1 Mar 2018 17:24:09 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v3 01/13] remoteproc: configure IOMMU only if device address requested Date: Thu, 1 Mar 2018 17:23:48 +0100 Message-ID: <1519921440-21356-2-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> References: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG7NODE2.st.com (10.75.127.20) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-01_08:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If there is no IOMMU associate to remote processor device, remoteproc_core won't be able to satisfy device address requested in firmware resource table. Return an error as configuration won't be coherent. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 4170dfb..56b33e4 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -654,7 +654,15 @@ static int rproc_handle_carveout(struct rproc *rproc, * to use the iommu-based DMA API: we expect 'dma' to contain the * physical address in this case. */ - if (rproc->domain) { + + if (rsc->da != FW_RSC_ADDR_ANY && !rproc->domain) { + dev_err(dev->parent, + "Bad carveout rsc configuration\n"); + ret = -ENOMEM; + goto dma_free; + } + + if (rsc->da != FW_RSC_ADDR_ANY && rproc->domain) { mapping = kzalloc(sizeof(*mapping), GFP_KERNEL); if (!mapping) { ret = -ENOMEM; From patchwork Thu Mar 1 16:23:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 130335 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3008924edc; Thu, 1 Mar 2018 08:28:49 -0800 (PST) X-Google-Smtp-Source: AG47ELsltsVzRKvoBd1uTANjpwK48vQjv/tiAV6yrK3XeMygldTxYCC/1y8flQkghso9+pOj/+dX X-Received: by 10.99.50.66 with SMTP id y63mr2038039pgy.207.1519921729063; Thu, 01 Mar 2018 08:28:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519921729; cv=none; d=google.com; s=arc-20160816; b=gg55jstyaSmWCy2F5cYeD9QzrK9hZn3gHzFsagZHLyOVEtjQhVvKwzoUCKXW89K1pQ dG4dDTKkjei7qdnyHq/8jbeP8AnFfdPnt0aX9sJzEMrToX0sWJma7WujgOhmJ/isdXRU hPoI4Wt3WsApEYsJ752Zq4nQnKnpEb7GhRlKJB6JQBJnClEAQQwWwqPIGsl3gYtuZciL YHPOV7dgon8PuCV9zpVOwpZ1IR69ElPGBuzlD4USYMm4H+JjQ0Fz1Cjy/SEQok4oMn2b IELQoIsOK5ANhw/thqemPq0T8DVEP8sTQYTDt6n5qoLFli0FC8XBR92HDWREv4ZzjKzA C/OQ== 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=LpeWcJuykvIf/S34map9joqOCR+J9RDmguMDUy6CrqE=; b=g+MUO9T2aQZncmFQHkI0nqPxtNsweE1GTNIVYcKAL6u2r0iPf7O/NsvE13qfVMq1o3 8CUMANujxZlNhPSWSOCofgazsYHm44eQSMSPQB4yZ2OA0gpYlMEDS/JIfRXHvuM2fsW+ UE2cN4hgmLsVvZawizy9MQ9L97mgZ2IuGplm16L67PvNPzkCClDeYXOWv7ncCUzjUkxb S6R4Oesv7k9khv5YHxXKbC5u5ahy3dIhpz+KDE2exd/bkhyIhOpzJ3dQtmHIg+JytAkf ToIPk1RMjrejuzQj1S4mq4MYuDUFf9+iFS5H5gcXE7qKXT9cs1BNwrqMpz06OmWEkd6G QrhQ== 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 z66si3241714pfk.135.2018.03.01.08.28.48; Thu, 01 Mar 2018 08:28:49 -0800 (PST) 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 S1033137AbeCAQ1p (ORCPT + 28 others); Thu, 1 Mar 2018 11:27:45 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:37092 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032936AbeCAQYP (ORCPT ); Thu, 1 Mar 2018 11:24:15 -0500 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w21GJFjU032289; Thu, 1 Mar 2018 17:24:13 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2gaxpwtgff-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 01 Mar 2018 17:24:13 +0100 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 D47DD34; Thu, 1 Mar 2018 16:24:11 +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 BA92151FD; Thu, 1 Mar 2018 16:24:11 +0000 (GMT) Received: from localhost (10.75.127.45) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 1 Mar 2018 17:24:10 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v3 02/13] remoteproc: add rproc_va_to_pa function Date: Thu, 1 Mar 2018 17:23:49 +0100 Message-ID: <1519921440-21356-3-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> References: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG5NODE3.st.com (10.75.127.15) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-01_08:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This new function translates CPU virtual address in CPU physical one according to virtual address location. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) -- 1.9.1 Acked-by: Bjorn Andersson diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 56b33e4..eb1b779 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -139,6 +139,22 @@ static void rproc_disable_iommu(struct rproc *rproc) iommu_domain_free(domain); } +static phys_addr_t rproc_va_to_pa(void *cpu_addr) +{ + /* + * Return physical address according to virtual address location + * - in vmalloc: if region ioremapped or defined as dma_alloc_coherent + * - in kernel: if region allocated in generic dma memory pool + */ + if (is_vmalloc_addr(cpu_addr)) { + return page_to_phys(vmalloc_to_page(cpu_addr)) + + offset_in_page(cpu_addr); + } + + WARN_ON(!virt_addr_valid(cpu_addr)); + return virt_to_phys(cpu_addr); +} + /** * rproc_da_to_va() - lookup the kernel virtual address for a remoteproc address * @rproc: handle of a remote processor @@ -708,7 +724,7 @@ static int rproc_handle_carveout(struct rproc *rproc, * In this case, the device address and the physical address * are the same. */ - rsc->pa = dma; + rsc->pa = (u32)rproc_va_to_pa(va); carveout->va = va; carveout->len = rsc->len; From patchwork Thu Mar 1 16:23:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 130333 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3007971edc; Thu, 1 Mar 2018 08:27:51 -0800 (PST) X-Google-Smtp-Source: AG47ELvljbtu6pZ/ivvSv1WuB4UBQWgCqTgIjaaHa39NJzcY2M3U3hsinHr6qgjIxB9Oh+hea1Zm X-Received: by 10.101.93.71 with SMTP id e7mr2032505pgt.248.1519921671450; Thu, 01 Mar 2018 08:27:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519921671; cv=none; d=google.com; s=arc-20160816; b=raFpOSvH3FfunV/EBNbvyNaQ0If8bsck920QhjqS3L+S/lq6Ms9jc5qbCQ4VB3rdBI fly+zfwZOlrhvPxFeKuoBFor3vo5k8GsnfVVGYeYW3rdXJvqDrJcDWL2a8uppYagnPs3 znQ96GeCFsEZJ1uSN0VezwKdSo/J5jXeDEE59c08I1b8tPK5tAIPY/54nGjnEwriJUgJ 7HXGgXG3W3vG78qyab/qA6tZblcJqfG4EEvTSiPahS/1amJ6NHikqVeIkZa9xMO+0ftb iad2gnUL2pUTQaO1m9rNn7EJPPFB+gyzNhfuc42t+kij/UmxVsOQIniCqWcQmhWVJzDV k3wQ== 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=yo6MsyMPlyWPIajVQOw1q4Ed083B8RrWZfE1M7Ithk8=; b=nQIqFe+YMbfy32srISkv/E3QQwg6zBdQh/2kzqyXDDywlIkTcQV7HR0URbXcp2zMhW 2o9UbjuirVmdNGok7QY2u/8yyx+Vtmyz1l+h+NRS+w+9hCTwHMCz/4V6gYc5P2LILlp1 Bhqyyy0M6Fm6jxHSoGTlVX4rwjU7bQIaZwYkOVvk4uDVqyG6DNY9dj/mAPMPtsgM56QV 6F7+giDTqI+Z6rNX3mAoCoBLe2GB3xwH/CyG8V1LOzX7MTs21CKcWoNm2HJbWQLYt1dO ZRsZhluituPqKQaJstm4eX94gyPvR/zOgWtF4krf+CnJWcdvtmaGFQSN9IeMbr0klyEU DG5A== 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 q4-v6si3267529plb.29.2018.03.01.08.27.51; Thu, 01 Mar 2018 08:27:51 -0800 (PST) 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 S1033150AbeCAQ1r (ORCPT + 28 others); Thu, 1 Mar 2018 11:27:47 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:19567 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032933AbeCAQYO (ORCPT ); Thu, 1 Mar 2018 11:24:14 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w21GIdOJ028249; Thu, 1 Mar 2018 17:24:13 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2gbwb1dpjn-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 01 Mar 2018 17:24:13 +0100 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 B7B2038; Thu, 1 Mar 2018 16:24:12 +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 89CBA51FD; Thu, 1 Mar 2018 16:24:12 +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; Thu, 1 Mar 2018 17:24:11 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v3 03/13] remoteproc: add release ops in rproc_mem_entry struct Date: Thu, 1 Mar 2018 17:23:50 +0100 Message-ID: <1519921440-21356-4-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> References: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG8NODE3.st.com (10.75.127.24) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-01_08:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Memory entry could be allocated in different ways (ioremap, dma_alloc_coherent, internal RAM allocator...). This patch introduces a release ops in rproc_mem_entry structure to associate dedicated release mechanism to each memory entry descriptor in order to keep remoteproc core generic. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 23 +++++++++++++++++++++-- include/linux/remoteproc.h | 5 ++++- 2 files changed, 25 insertions(+), 3 deletions(-) -- 1.9.1 Acked-by: Bjorn Andersson diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index eb1b779..5f11536 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -597,6 +597,24 @@ static int rproc_handle_devmem(struct rproc *rproc, struct fw_rsc_devmem *rsc, } /** + * rproc_release_carveout() - release acquired carveout + * @rproc: rproc handle + * @mem: the memory entry to release + * + * This function releases specified memory entry @mem allocated via + * dma_alloc_coherent() function by @rproc. + */ +static int rproc_release_carveout(struct rproc *rproc, + struct rproc_mem_entry *mem) +{ + struct device *dev = &rproc->dev; + + /* clean up carveout allocations */ + dma_free_coherent(dev->parent, mem->len, mem->va, mem->dma); + return 0; +} + +/** * rproc_handle_carveout() - handle phys contig memory allocation requests * @rproc: rproc handle * @rsc: the resource entry @@ -730,6 +748,7 @@ static int rproc_handle_carveout(struct rproc *rproc, carveout->len = rsc->len; carveout->dma = dma; carveout->da = rsc->da; + carveout->release = rproc_release_carveout; list_add_tail(&carveout->node, &rproc->carveouts); @@ -863,8 +882,8 @@ static void rproc_resource_cleanup(struct rproc *rproc) /* clean up carveout allocations */ list_for_each_entry_safe(entry, tmp, &rproc->carveouts, node) { - dma_free_coherent(dev->parent, entry->len, entry->va, - entry->dma); + if (entry->release) + entry->release(rproc, entry); list_del(&entry->node); kfree(entry); } diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 728d421..dedc138 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -305,12 +305,15 @@ struct fw_rsc_vdev { struct fw_rsc_vdev_vring vring[0]; } __packed; +struct rproc; + /** * struct rproc_mem_entry - memory entry descriptor * @va: virtual address * @dma: dma address * @len: length, in bytes * @da: device address + * @release: release associated memory * @priv: associated data * @node: list node */ @@ -321,9 +324,9 @@ struct rproc_mem_entry { u32 da; void *priv; struct list_head node; + int (*release)(struct rproc *rproc, struct rproc_mem_entry *mem); }; -struct rproc; struct firmware; /** From patchwork Thu Mar 1 16:23:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 130329 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3006201edc; Thu, 1 Mar 2018 08:26:11 -0800 (PST) X-Google-Smtp-Source: AG47ELuhHeDw0oda2hXkuaXnngvyyRyog1Ld6BPaqykXQhTI+RKiU7utape2gY5JnRmmhB9DEHIj X-Received: by 2002:a17:902:8b82:: with SMTP id ay2-v6mr2425118plb.12.1519921571737; Thu, 01 Mar 2018 08:26:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519921571; cv=none; d=google.com; s=arc-20160816; b=xklvOPfgrlnOUzF1VC6H3ozKaQGqKRhiOtS1uDwXY1zxN8eXeaCVLK8fzLb6yl2VU+ nvfPt5lyheEfqwFuGNvK6/SDDYu7evbJjPAaWbvf8L+4mys+vXXIni9qO0gHF3uyKZsh Xzx868Lk7Fj4O2zX2QF4tHKna+lJ4HyorV3tkw5QLqlRTl9Eee63bnvB2Z6FJfgFXc/d PveqKGJRPAL6wOZRm+s2eZWSssRFDPl800hClfPoxQgmPC9Ck21QoaILQLfwV/20CXsU niL8cs+GfDnm0G4oom5wRMOr3I26ozlnMccjTAvGOp9WKMvhjuoc29I89udLxp01YEJR f0ZQ== 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=cQmWSV6UzqHtqFk1IDj1qgd5zLQl4YYVp7srPPW4suk=; b=dmag3Xk/cV711ItUS9oBraUnYmVxeYz9CLoDPDP5JzzbiEZTR+3poG6k8gamD9upCF s+dvjQmZiivdcdhwE3JBXSGqs3y7ptlBSgDObWq4/huVnuNfPz6jRPLvt45IdEnJcsjv Vj5i4xJOjQCuXMw6pR73De+fIa1Sxw2z+lXkefShszfc5Q6r5gC9eXHeqUh2s1ReeVwS 0BiJycZbYyWJI0pjad2pPMZAmAqIp7ILEofTQ13rp4hgvPLx2zcdhm2xVnYGJYByrFw8 9VLaMq1wcd1m5x8Eqy1RJrpHAYIrOXhTqH9pF7KAYFxbQcZoKZhYBD3q4jS2u4SXBrCC 2eAg== 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 n3si2657723pgc.12.2018.03.01.08.26.11; Thu, 01 Mar 2018 08:26:11 -0800 (PST) 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 S1032995AbeCAQYT (ORCPT + 28 others); Thu, 1 Mar 2018 11:24:19 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:43966 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032698AbeCAQYQ (ORCPT ); Thu, 1 Mar 2018 11:24:16 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w21GJKNv002391; Thu, 1 Mar 2018 17:24:14 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2gaytjb7jt-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 01 Mar 2018 17:24:14 +0100 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 617D53A; Thu, 1 Mar 2018 16:24:13 +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 4F39C51FD; Thu, 1 Mar 2018 16:24:13 +0000 (GMT) Received: from localhost (10.75.127.51) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 1 Mar 2018 17:24:12 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v3 04/13] remoteproc: add name in rproc_mem_entry struct Date: Thu, 1 Mar 2018 17:23:51 +0100 Message-ID: <1519921440-21356-5-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> References: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.51] X-ClientProxiedBy: SFHDAG7NODE2.st.com (10.75.127.20) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-01_08:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add name field in struct rproc_mem_entry. This new field will be used to match memory area requested in resource table with pre-registered carveout. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 1 + drivers/remoteproc/remoteproc_debugfs.c | 1 + include/linux/remoteproc.h | 2 ++ 3 files changed, 4 insertions(+) -- 1.9.1 Acked-by: Bjorn Andersson diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 5f11536..f73a0cf 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -749,6 +749,7 @@ static int rproc_handle_carveout(struct rproc *rproc, carveout->dma = dma; carveout->da = rsc->da; carveout->release = rproc_release_carveout; + strlcpy(carveout->name, rsc->name, sizeof(carveout->name)); list_add_tail(&carveout->node, &rproc->carveouts); diff --git a/drivers/remoteproc/remoteproc_debugfs.c b/drivers/remoteproc/remoteproc_debugfs.c index a204883..fc0e570 100644 --- a/drivers/remoteproc/remoteproc_debugfs.c +++ b/drivers/remoteproc/remoteproc_debugfs.c @@ -260,6 +260,7 @@ static int rproc_carveouts_show(struct seq_file *seq, void *p) list_for_each_entry(carveout, &rproc->carveouts, node) { seq_puts(seq, "Carveout memory entry:\n"); + seq_printf(seq, "\tName: %s\n", carveout->name); seq_printf(seq, "\tVirtual address: %p\n", carveout->va); seq_printf(seq, "\tDMA address: %pad\n", &carveout->dma); seq_printf(seq, "\tDevice address: 0x%x\n", carveout->da); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index dedc138..2202c08 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -315,6 +315,7 @@ struct fw_rsc_vdev { * @da: device address * @release: release associated memory * @priv: associated data + * @name: associated memory region name (optional) * @node: list node */ struct rproc_mem_entry { @@ -323,6 +324,7 @@ struct rproc_mem_entry { int len; u32 da; void *priv; + char name[32]; struct list_head node; int (*release)(struct rproc *rproc, struct rproc_mem_entry *mem); }; From patchwork Thu Mar 1 16:23:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 130327 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3005513edc; Thu, 1 Mar 2018 08:25:33 -0800 (PST) X-Google-Smtp-Source: AG47ELusFbB/n5VZZTAj/9EFhHPXnlb2I0Bz+DHp9YKc05i0K1MMzRTJR4SxHrpqb+moyGB35hPy X-Received: by 10.99.184.1 with SMTP id p1mr1981685pge.96.1519921533271; Thu, 01 Mar 2018 08:25:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519921533; cv=none; d=google.com; s=arc-20160816; b=crn8F6r61ug+ujLopmb2r9gn8Tsh5JkrvRYmqtfNDBv9JGoW3sFR0ZKD15+QgxmguZ JkRJ0khNjY48KVGUhSyxFMtbdeiXXmQ5g6mRUep2VGyDnhUBsVndLoSb9tKwsWqunkSW D+2+08VD6z0hkzf8AGbOAAEYkaWiXdDNThVWDQu2QSYWAzCUs22+9+FuqkINnzr030i/ q0Xbg0QX+A2XaiyE/LU1SX9E0gzJVp6yF9/UpntTHYtyJghx1wIFDnaGjCu36TqhzGBr Af4Cy9znEWcTl6m79J1bZMOJFdG5XL8YYjKNZGNlRpO3Tkdtl79sOFdXzyIRUm2upBlO 1eAA== 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=wgXwVSprgxIijd2eNwTQQiKzFbY+nfes5BLDt6RAEh8=; b=Q2el1VnrB2+Gf93aCE2IXf56kIXZAbV7YFolGcuX9AC3jdHCyGI4BYmYo4A4od3XDT 2FAiWyzpNM7Rc5hCzaVyYGVBuTZMhvKIcqPuzmBJCz/WDTvx3CnNyLnf0nedE8GKJeMb dKclIRpzZ4ERCpMWA3gR/hxkxJ0PZaqqrU5kwl/3ATieo/QgyZJjOKnZfKjc1m1je4RK vVxFH53njTIzusxgBPSmEcjBaqMooa/rmfOW/TcP2c5h5Q3fOs630x2FjmPa1xrOPeUb IJj1Vmg1CK43MKgmtOCl3nZOofabJmLOvFRTF56Y+h8T0EnQvXNMe/0eNPVSWyOAi7g0 WSog== 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 v61-v6si3245065plb.698.2018.03.01.08.25.33; Thu, 01 Mar 2018 08:25:33 -0800 (PST) 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 S1033009AbeCAQYV (ORCPT + 28 others); Thu, 1 Mar 2018 11:24:21 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:15371 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032974AbeCAQYQ (ORCPT ); Thu, 1 Mar 2018 11:24:16 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w21GIeV6028256; Thu, 1 Mar 2018 17:24:14 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2gbwb1dpjr-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 01 Mar 2018 17:24:14 +0100 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 30BDE34; Thu, 1 Mar 2018 16:24:14 +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 0FF1F51FF; Thu, 1 Mar 2018 16:24:14 +0000 (GMT) Received: from localhost (10.75.127.45) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 1 Mar 2018 17:24:13 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v3 05/13] remoteproc: add helper function to allocate and init rproc_mem_entry struct Date: Thu, 1 Mar 2018 17:23:52 +0100 Message-ID: <1519921440-21356-6-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> References: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG2NODE2.st.com (10.75.127.5) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-01_08:, , 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_mem_entry_init helper function to simplify rproc_mem_entry structure allocation and filling by client. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 64 +++++++++++++++++++++++++++--------- include/linux/remoteproc.h | 5 +++ 2 files changed, 53 insertions(+), 16 deletions(-) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index f73a0cf..4c92b7d 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -636,7 +636,7 @@ static int rproc_handle_carveout(struct rproc *rproc, struct fw_rsc_carveout *rsc, int offset, int avail) { - struct rproc_mem_entry *carveout, *mapping; + struct rproc_mem_entry *carveout, *mapping = NULL; struct device *dev = &rproc->dev; dma_addr_t dma; void *va; @@ -656,16 +656,11 @@ static int rproc_handle_carveout(struct rproc *rproc, dev_dbg(dev, "carveout rsc: name: %s, da 0x%x, pa 0x%x, len 0x%x, flags 0x%x\n", rsc->name, rsc->da, rsc->pa, rsc->len, rsc->flags); - carveout = kzalloc(sizeof(*carveout), GFP_KERNEL); - if (!carveout) - return -ENOMEM; - va = dma_alloc_coherent(dev->parent, rsc->len, &dma, GFP_KERNEL); if (!va) { dev_err(dev->parent, "failed to allocate dma memory: len 0x%x\n", rsc->len); - ret = -ENOMEM; - goto free_carv; + return -ENOMEM; } dev_dbg(dev, "carveout va %p, dma %pad, len 0x%x\n", @@ -744,27 +739,64 @@ static int rproc_handle_carveout(struct rproc *rproc, */ rsc->pa = (u32)rproc_va_to_pa(va); - carveout->va = va; - carveout->len = rsc->len; - carveout->dma = dma; - carveout->da = rsc->da; - carveout->release = rproc_release_carveout; - strlcpy(carveout->name, rsc->name, sizeof(carveout->name)); + carveout = rproc_mem_entry_init(dev, va, dma, rsc->len, rsc->da, + rproc_release_carveout, rsc->name); + if (!carveout) + goto free_carv; list_add_tail(&carveout->node, &rproc->carveouts); return 0; +free_carv: + kfree(carveout); free_mapping: kfree(mapping); dma_free: dma_free_coherent(dev->parent, rsc->len, va, dma); -free_carv: - kfree(carveout); return ret; } -/* +/** + * rproc_mem_entry_init() - allocate and initialize rproc_mem_entry struct + * @dev: pointer on device struct + * @va: virtual address + * @dma: dma address + * @len: memory carveout length + * @da: device address + * @release: memory carveout function + * @name: carveout name + * + * This function allocates a rproc_mem_entry struct and fill it with parameters + * provided by client. + */ +struct rproc_mem_entry *rproc_mem_entry_init(struct device *dev, + void *va, dma_addr_t dma, int len, u32 da, + int (*release)(struct rproc *, struct rproc_mem_entry *), + const char *name, ...) +{ + struct rproc_mem_entry *mem; + va_list args; + + mem = devm_kzalloc(dev, sizeof(*mem), GFP_KERNEL); + if (!mem) + return ERR_PTR(-ENOMEM); + + mem->va = va; + mem->dma = dma; + mem->da = da; + mem->len = len; + mem->release = release; + + va_start(args, name); + snprintf(mem->name, sizeof(mem->name), name, args); + va_end(args); + + return mem; +} +EXPORT_SYMBOL(rproc_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 2202c08..59b60f1 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -536,6 +536,11 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, int rproc_del(struct rproc *rproc); void rproc_free(struct rproc *rproc); +struct rproc_mem_entry *rproc_mem_entry_init(struct device *dev, + void *va, dma_addr_t dma, int len, u32 da, + int (*release)(struct rproc *, struct rproc_mem_entry *), + 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); From patchwork Thu Mar 1 16:23:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 130332 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3007236edc; Thu, 1 Mar 2018 08:27:09 -0800 (PST) X-Google-Smtp-Source: AG47ELtr6Bpdh3YlSrTa3OBPB5CDpp8zWXPFuzoosVDhq4E1gpTMvAgDZWyPc3UIIq6rfXEzl7a8 X-Received: by 10.99.99.2 with SMTP id x2mr2012817pgb.406.1519921629767; Thu, 01 Mar 2018 08:27:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519921629; cv=none; d=google.com; s=arc-20160816; b=ONYHnPMNGIul2eXqqZfYgSx1o017Fh4UqSNJFH9gUxa27fmEGSYSl8bb7uwNDWb4kY V2NPgSEAe/DrXZGkvuPuzCKesH/E+3kuPR6Ncdlw3kV0/vm9Xz+yQntMjTRiYk9MKmjp tpv+RF8BXF8uNpPwt3E7GyEIPj5wesvO3/5EB7AGK7iA7P3De3SB6S6cfl3zxdGZxWE2 UeuklQnc0AolYGS7n489OeqEdEVr+IY8EAeD8k/RpKSORUxbT5U7U9oFl59LqBWFMKUZ Xah8ZHPGjNC3XPq20xtTXTggnG/91qXytyEe23UilUnwLgKhq1ZaUQpCSII70FrEzpTP VwOg== 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=lh47TjiOe3oFNa5M+BasTuWi//cPNhXuYMNec9gJZGY=; b=E8k9CoBAUDh7MjImM2P/sLYrz1zX7x2ObFpidKZc2iQDM/l5EpWUrc8DqSQptgkfj+ 58nKGIcetBNr01WhBIeoXAKVvsFD79DMFWpq/1QcIqyBd2FPrFBKY6SCjb0A3vLyzvvh OtCvpXJJE9Rn9IRjJ66avb+3qwNqfVsmKLgxottg9STazTiI0HLECiD7MXkSSgbi5Ad1 cGs07lFGhu9/8WtppjBgLAcha/+twaCQe53QE53VdItSftxh11K4o3Dnm78pFwRp4GSU 8vPhfl2fu2QXK9apswi2nTCMn5gdCkMCtasv1TLkrHPFQwcbLe2mp3I59mkMeSRdLCDv KUFg== 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 o6-v6si879364pls.583.2018.03.01.08.27.09; Thu, 01 Mar 2018 08:27:09 -0800 (PST) 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 S1033074AbeCAQ1H (ORCPT + 28 others); Thu, 1 Mar 2018 11:27:07 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:31503 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032975AbeCAQYR (ORCPT ); Thu, 1 Mar 2018 11:24:17 -0500 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 w21GJQYY025446; Thu, 1 Mar 2018 17:24:15 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2gax28ujkh-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 01 Mar 2018 17:24:15 +0100 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 E2FA438; Thu, 1 Mar 2018 16:24:14 +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 BF5F45200; Thu, 1 Mar 2018 16:24:14 +0000 (GMT) Received: from localhost (10.75.127.44) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 1 Mar 2018 17:24:14 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v3 06/13] remoteproc: introduce rproc_add_carveout function Date: Thu, 1 Mar 2018 17:23:53 +0100 Message-ID: <1519921440-21356-7-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> References: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG1NODE3.st.com (10.75.127.3) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-01_08:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch introduces a new API to allow platform driver to register platform specific carveout regions. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 14 ++++++++++++++ include/linux/remoteproc.h | 2 ++ 2 files changed, 16 insertions(+) -- 1.9.1 Acked-by: Bjorn Andersson diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 4c92b7d..91aa22b 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -758,6 +758,20 @@ static int rproc_handle_carveout(struct rproc *rproc, } /** + * rproc_add_carveout() - register an allocated carveout region + * @rproc: rproc handle + * @mem: memory entry to register + * + * This function registers specified memory entry in @rproc carveouts list. + * Specified carveout should have been allocated before registering. + */ +void rproc_add_carveout(struct rproc *rproc, struct rproc_mem_entry *mem) +{ + list_add_tail(&mem->node, &rproc->carveouts); +} +EXPORT_SYMBOL(rproc_add_carveout); + +/** * rproc_mem_entry_init() - allocate and initialize rproc_mem_entry struct * @dev: pointer on device struct * @va: virtual address diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 59b60f1..4aa30bd 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -536,6 +536,8 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, int rproc_del(struct rproc *rproc); void rproc_free(struct rproc *rproc); +void rproc_add_carveout(struct rproc *rproc, struct rproc_mem_entry *mem); + struct rproc_mem_entry *rproc_mem_entry_init(struct device *dev, void *va, dma_addr_t dma, int len, u32 da, int (*release)(struct rproc *, struct rproc_mem_entry *), From patchwork Thu Mar 1 16:23:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 130322 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3004283edc; Thu, 1 Mar 2018 08:24:26 -0800 (PST) X-Google-Smtp-Source: AG47ELszz83s9qCsbActStaS45lmu57o+T2/UmTwIev9XPLiFSC6eM1RuYbaX4hUxvD2VD2iERHN X-Received: by 2002:a17:902:52ca:: with SMTP id a68-v6mr2409190pli.179.1519921466434; Thu, 01 Mar 2018 08:24:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519921466; cv=none; d=google.com; s=arc-20160816; b=0EcE4lRcHEx32DT+5aI/I6EF6eOpY4Mo09tNYGG8UICGBh7yvFR6aMKLghkKf7ff6N n4jvsU/fvq14bxuX+iBzzpCRv1Q6PO1od5SjOUge1WsRuKbYVPLaRFnuSeWaGXV21P1e ivHpoOW21dDH+1OXlHpBR/lPw0A9rj2yPpsgu5DN36RpTx7EHFv9D/5Nfm+goU1q48nq USP/Eq/ST0FEJKT6IAhvhhPHOH9ZpkHep2H4vZ/6m3WuuWjFhsXGsviPxh7vFenZZxBQ slTHGXijOL3ZW0VosGrKivyDIV+DY0aMQJsrxK9JMol7vkgp3k6NIujP92MttxNVsCwL ODxg== 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=T2pZ4ttMqucA4V9EFK25gU0CoP72kvbF1L4Fbyhn9ho=; b=JcLLBLqKRMunPOhcZhBldXz763wVvWIJiIcuETSjEBj8DPX2GWWMyYjOdf3EGjyehp tA7GN7Y3kuePYEZhlg52RO5s236Lf0LGQ1q52MD67uK3KJMUhFziUhiEjqVe8McO4Uo+ EGR4lO+p5HZXcB6+X6wp+66xUv0L8WXnY4XTgOVTi/fhDscYA/fmbumqycOaQgezX6ok L1NPuogD5mev/oboj/nKDbY0smRrTXywwoV0rVpDHuIiGhLv+5uIyQzNG/LgySKWRRov 0uDvSjYITERvxM01eFjIv3SkXHtT13KQOyum2dvG/D8OZg6hjpggb9BpPE8g/G4Sh9uy VgPg== 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 x2-v6si3206173plv.672.2018.03.01.08.24.26; Thu, 01 Mar 2018 08:24:26 -0800 (PST) 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 S1033025AbeCAQYX (ORCPT + 28 others); Thu, 1 Mar 2018 11:24:23 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:24347 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032976AbeCAQYR (ORCPT ); Thu, 1 Mar 2018 11:24:17 -0500 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w21GJFjV032289; Thu, 1 Mar 2018 17:24:16 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2gaxpwtgfp-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 01 Mar 2018 17:24:16 +0100 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 8BDBE31; Thu, 1 Mar 2018 16:24:15 +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 7975E5200; Thu, 1 Mar 2018 16:24:15 +0000 (GMT) Received: from localhost (10.75.127.44) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 1 Mar 2018 17:24:14 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v3 07/13] remoteproc: introduce rproc_find_carveout_by_name function Date: Thu, 1 Mar 2018 17:23:54 +0100 Message-ID: <1519921440-21356-8-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> References: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG4NODE2.st.com (10.75.127.11) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-01_08:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch provides a new function to find a carveout according to a name. If match found, this function returns a pointer on the corresponding carveout (rproc_mem_entry structure). Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 91aa22b..7a500cb 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -216,6 +216,49 @@ void *rproc_da_to_va(struct rproc *rproc, u64 da, int len) } EXPORT_SYMBOL(rproc_da_to_va); +/** + * rproc_find_carveout_by_name() - lookup the carveout region by a name + * @rproc: handle of a remote processor + * @name,..: carveout name to find (standard printf format) + * + * Platform driver has the capability to register some pre-allacoted carveout + * (physically contiguous memory regions) before rproc firmware loading and + * associated resource table analysis. These regions may be dedicated memory + * regions internal to the coprocessor or specified DDR region with specific + * attributes + * + * This function is a helper function with which we can go over the + * allocated carveouts and return associated region characteristics like + * coprocessor address, length or processor virtual address. + * + * The function returns a valid pointer on carveout entry on success + * or NULL on failure. + */ +struct rproc_mem_entry * +rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...) +{ + va_list args; + char _name[32]; + struct rproc_mem_entry *carveout, *mem = NULL; + + va_start(args, name); + snprintf(_name, sizeof(_name), name, args); + va_end(args); + + if (!name) + return NULL; + + list_for_each_entry(carveout, &rproc->carveouts, node) { + /* Compare carveout and requested names */ + if (!strcmp(carveout->name, name)) { + mem = carveout; + break; + } + } + + return mem; +} + int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) { struct rproc *rproc = rvdev->rproc; From patchwork Thu Mar 1 16:23:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 130331 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3006796edc; Thu, 1 Mar 2018 08:26:46 -0800 (PST) X-Google-Smtp-Source: AG47ELuNi901g+H2kC1vb4wHc8sFDgGeBYRY6VAWSaPgHfL1L5GIqjCgHh9gYu1aJfn6g7oNYv4z X-Received: by 10.98.211.198 with SMTP id z67mr2575128pfk.0.1519921606541; Thu, 01 Mar 2018 08:26:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519921606; cv=none; d=google.com; s=arc-20160816; b=cxNWaLx2eDnawXRysoav2lconDKWqhRG/dtdhtrrteVqZ/Hvk5phXYEvNueUqYtQda Ak6PJhgSLkdIrWeSybAHgtnHrclpUGBEfDyqnN0OHy3hRRGB3j/B6nIgHNa8MwixyHQW neSLJkKtxykHVk9wLA9H5ac0Xt0b5GES/KEV3725Xy1R40XbEvvuw65vDX7KhkPfAuUO 8eZ6X5UVgA88EiKauvEJfTfWbJVjpuLtu8LsTtwnd02pc1vDziHFA5J8pVFM3S6h5VRc nNdLFAOlKm0AwyUdrXVhw3k61Nm/LwJGvKO0WmKbShTR0DFOxODr6kgvsOcTJcorqxP4 OuMg== 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=zYyxEcM25Kt1a1I8BIDz7pM7rPWqYzAb2Q89cZccnQU=; b=bn65agoD+FguT8II4cOTFeuc+y8N+MkdBDs5OMf93HwQMfKdxY85jiDIOGXnBQTOk8 U687fmui6oUE26R0UZ+LilohIO6U7XBZV/zZx68nhtfDqSTwMesrWp1Ifz3J/NXme+uw loWWx2ci+LbRCcfHntWvumaz8+rMTT/VHCyBpKg2LLPxs3hSotdNCu8EgmWpl8SFaTD3 HorE8HXBz+6myypBCB/Dyuzq6Rdjq5BylvBuqb007y0IXmGjTc0EjkVjz6Rw2eE9oRgn uh8URKsMuDDTY5F7s6FVUntBmP1IddFlllfb2elBNoTUscTtwKbhx28Zbmz4MPgC/eMA wfKQ== 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 n127si2647952pga.171.2018.03.01.08.26.46; Thu, 01 Mar 2018 08:26:46 -0800 (PST) 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 S1033124AbeCAQ0n (ORCPT + 28 others); Thu, 1 Mar 2018 11:26:43 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:43970 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032977AbeCAQYT (ORCPT ); Thu, 1 Mar 2018 11:24:19 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w21GJKq5002395; Thu, 1 Mar 2018 17:24:16 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2gaytjb7jw-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 01 Mar 2018 17:24:16 +0100 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 6100D34; Thu, 1 Mar 2018 16:24:16 +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 4158E51FF; Thu, 1 Mar 2018 16:24:16 +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; Thu, 1 Mar 2018 17:24:15 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v3 08/13] remoteproc: add prepare and unprepare ops Date: Thu, 1 Mar 2018 17:23:55 +0100 Message-ID: <1519921440-21356-9-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> References: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.49] 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.10432:, , definitions=2018-03-01_08:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On some SoC architecture, it is needed to enable HW like clock, bus, regulator, memory region... before loading co-processor firmware. This patch introduces prepare and unprepare ops to execute platform specific function before firmware loading and after stop execution. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 20 +++++++++++++++++++- include/linux/remoteproc.h | 4 ++++ 2 files changed, 23 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 7a500cb..0ebbc4f 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1058,12 +1058,22 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) return ret; } + /* Prepare rproc for firmware loading if needed */ + if (rproc->ops->prepare) { + ret = rproc->ops->prepare(rproc); + if (ret) { + dev_err(dev, "can't prepare rproc %s: %d\n", + rproc->name, ret); + goto disable_iommu; + } + } + rproc->bootaddr = rproc_get_boot_addr(rproc, fw); /* load resource table */ ret = rproc_load_rsc_table(rproc, fw); if (ret) - goto disable_iommu; + goto unprepare_rproc; /* reset max_notifyid */ rproc->max_notifyid = -1; @@ -1086,6 +1096,10 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) kfree(rproc->cached_table); rproc->cached_table = NULL; rproc->table_ptr = NULL; +unprepare_rproc: + /* release HW resources if needed */ + if (rproc->ops->unprepare) + rproc->ops->unprepare(rproc); disable_iommu: rproc_disable_iommu(rproc); return ret; @@ -1331,6 +1345,10 @@ void rproc_shutdown(struct rproc *rproc) /* clean up all acquired resources */ rproc_resource_cleanup(rproc); + /* release HW resources if needed */ + if (rproc->ops->unprepare) + rproc->ops->unprepare(rproc); + rproc_disable_iommu(rproc); /* Free the copy of the resource table */ diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 4aa30bd..dcfa601 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -333,6 +333,8 @@ struct rproc_mem_entry { /** * struct rproc_ops - platform-specific device handlers + * @prepare: prepare device for code loading + * @unprepare: unprepare device after stop * @start: power on the device and boot it * @stop: power off the device * @kick: kick a virtqueue (virtqueue id given as a parameter) @@ -345,6 +347,8 @@ struct rproc_mem_entry { * @get_boot_addr: get boot address to entry point specified in firmware */ struct rproc_ops { + int (*prepare)(struct rproc *rproc); + int (*unprepare)(struct rproc *rproc); int (*start)(struct rproc *rproc); int (*stop)(struct rproc *rproc); void (*kick)(struct rproc *rproc, int vqid); From patchwork Thu Mar 1 16:23:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 130330 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3006240edc; Thu, 1 Mar 2018 08:26:13 -0800 (PST) X-Google-Smtp-Source: AG47ELsk6yK6mrsg6VjPWZS4vJr2zXmaGqE7IymU3ERUPvny/dMSWpDv9b9AA3pqso/S79TKjQqY X-Received: by 2002:a17:902:aa87:: with SMTP id d7-v6mr2402491plr.237.1519921573402; Thu, 01 Mar 2018 08:26:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519921573; cv=none; d=google.com; s=arc-20160816; b=DYwwg89nwXA9bxXsDzGwRhjdEipUbInjhwaP5+Xoy+xYouVz5wk8lBeUI3+gHuv7Kq TuFnVuyLkXHemZxoOFbloVTy8ivLFzA+Tq3YefVVXddCA6Oej083pGBZd3gITgS8h13r h1T2+ukHZu/lSRHQ8Kd3gkHAC+u9Fmps39/46p1dKW1G7FCMsvIcHkOCsauR7CbMgii+ pQqqe94oa89WlPYydtl9QZi3m2ZfZv9+w+zROLGso48Fa3J0VpCQwYallskjYcfxxLdL rO/NiIbvit5P3T+I8pfgUduJ2eRgbH8G+cluWfp8LOPoDJWPglMkUd0/826QizKZQEtM w48A== 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=JmBF2xWgiHjsLnxcIfj1h59uq6YBRkGGPAgVHStyBPc=; b=Dqxn3FpkEYoL9sYoKUQ7CmwPsZd9Sa+oLZyjlPNhocWKn8Bk2JTTdvf3GdY65d0hIw uEDzWAOKAS0gypRgsvRVt0kDopbcXLBfgSmH0/jc6Mk+5tKc6x/fcnTcq2MEBDVHBO2r 42Lzy9Zebw0kIFi+h+7lznhu/0jKKvlwkB6DiDSta2EpgBRvZ/YsOCDE8XKA8RAvhKOY 7BoQLJ0spQwJALHs2CJqIBVZ5m4IOy0a4pJ23A1y2Rh2vPu6c6xPBGoQLYcQ9AHFjZOj qGublfxJK2mwdrCoQ6LMsRXuxkeAFIwzz8CGn3/sPHK39QopAN6/YpT6GJFVF6jAmTeA UzDQ== 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 n3si2657723pgc.12.2018.03.01.08.26.13; Thu, 01 Mar 2018 08:26:13 -0800 (PST) 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 S1033102AbeCAQ0K (ORCPT + 28 others); Thu, 1 Mar 2018 11:26:10 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:50735 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032981AbeCAQYT (ORCPT ); Thu, 1 Mar 2018 11:24:19 -0500 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 w21GJPRf025428; Thu, 1 Mar 2018 17:24:17 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2gax28ujkm-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 01 Mar 2018 17:24:17 +0100 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 1CF9738; Thu, 1 Mar 2018 16:24:17 +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 01EC251FD; Thu, 1 Mar 2018 16:24:17 +0000 (GMT) Received: from localhost (10.75.127.44) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 1 Mar 2018 17:24:16 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v3 09/13] remoteproc: modify rproc_handle_carveout to support pre-registered region Date: Thu, 1 Mar 2018 17:23:56 +0100 Message-ID: <1519921440-21356-10-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> References: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG5NODE1.st.com (10.75.127.13) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-01_08:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In current version rproc_handle_carveout function support only dynamic region allocation. This patch extends rproc_handle_carveout function to support pre-registered region. Match is done on region name, then requested device address and length are checked. If no name match found, original allocation is used. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 49 +++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 0ebbc4f..49b28a0 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -679,7 +679,7 @@ static int rproc_handle_carveout(struct rproc *rproc, struct fw_rsc_carveout *rsc, int offset, int avail) { - struct rproc_mem_entry *carveout, *mapping = NULL; + struct rproc_mem_entry *carveout, *mapping = NULL, *mem; struct device *dev = &rproc->dev; dma_addr_t dma; void *va; @@ -699,6 +699,51 @@ static int rproc_handle_carveout(struct rproc *rproc, dev_dbg(dev, "carveout rsc: name: %s, da 0x%x, pa 0x%x, len 0x%x, flags 0x%x\n", rsc->name, rsc->da, rsc->pa, rsc->len, rsc->flags); + /* Check carveout rsc already part of a registered carveout */ + /* Search by name */ + mem = rproc_find_carveout_by_name(rproc, rsc->name); + if (mem) { + int delta = 0; + + if (rsc->da != FW_RSC_ADDR_ANY) { + delta = rsc->da - mem->da; + + /* Check requested resource belongs to registered carveout */ + if (delta < 0) { + dev_err(dev->parent, + "Registered carveout doesn't fit da request\n"); + return -ENOMEM; + } + + if (delta + rsc->len > mem->len) { + dev_err(dev->parent, + "Registered carveout doesn't fit len request\n"); + return -ENOMEM; + } + } else { + /* Check requested resource length */ + if (rsc->len > mem->len) { + dev_err(dev->parent, + "Registered carveout doesn't fit len request\n"); + return -ENOMEM; + } + /* Update resource da with registered resource value */ + rsc->da = mem->da; + } + + /* + * Update resource pa + * Use va if defined else dma to generate pa + */ + if (mem->va) + rsc->pa = rproc_va_to_pa(mem->va) + delta; + else + rsc->pa = (u32)mem->dma + delta; + + return 0; + } + + /* No registered carveout found, allocate a new one */ va = dma_alloc_coherent(dev->parent, rsc->len, &dma, GFP_KERNEL); if (!va) { dev_err(dev->parent, @@ -761,6 +806,8 @@ static int rproc_handle_carveout(struct rproc *rproc, dev_dbg(dev, "carveout mapped 0x%x to %pad\n", rsc->da, &dma); + } else { + rsc->da = (u32)dma; } /* From patchwork Thu Mar 1 16:23:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 130328 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3005778edc; Thu, 1 Mar 2018 08:25:47 -0800 (PST) X-Google-Smtp-Source: AG47ELuUKO9/3b/vujusGy9Qh83+Kb8vAEdjG1OXvPnFjhZ2A6U1jQbEP97L5me/dLAtT+9tltOP X-Received: by 10.101.77.195 with SMTP id q3mr1933308pgt.283.1519921546887; Thu, 01 Mar 2018 08:25:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519921546; cv=none; d=google.com; s=arc-20160816; b=vv5p+wb6MmR8Yz8LN4fG8kaoW+30pv30gxCNWR2lrFsc3CZOTcxPTnRHvS91mwRSMf eEH8SSDwxLVqp82DSzjsg0ddPlnJ5f37Ed9K8i1LI1mK98tFyr+taQhHXPOFLW6bK+5i 6jO55XcgQvXzEdK9l11xZt5bQL4Bc92SIVq696qPzkThKzjeJOKseZClgZqrqfJPcpwb w2hBWh+xNtGW7VnGEVeO9kPlzyJStkbg2kJex4BZKarr7p51eaNMMkbeHFU0oI44C4D8 JjFlNMPQq0Ftv7iL+7xXsGua9KgtMFYxUlW8xxc5SEdMUmSUnPQhfCjnHX8xPEmgdiAl HJKQ== 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=vkbH0TdUtnuK+94fNYDxlc5pOLaAZJglE6J2hSeFgN0=; b=Xl5LQD3v5rZe+xVv3b6cINFo2hBBDxacaDo0nwMa4CLqqehUcMizdVsmTTtvHf3Ctw 0xeTSWE6MkOPxYk+vO1LzH35wo3k22DUe5uobX+Wwnhq9cO3HAW/4t0AdYfIKam2VlgF KejGP+MO0fi6SZuWZzMwqnAAGIM88YHRpNAnZg/QqwBJxoMBRI5oxk07VEdVDIANs9xI XZ4nNPKNK4qxl97RsuzegObuiqqOBzVXltvOLfsUlZAmQj4S/oxpp9ipQMjrqtQ+qbu9 MMFWPrhG2cY5dVm/YgO44W8VsXNQ7GYaIvzLfGRziJoX/g9wU9uKJeHMB3HFqKu+b7ne 8K3A== 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 u36si2650325pgn.702.2018.03.01.08.25.46; Thu, 01 Mar 2018 08:25:46 -0800 (PST) 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 S1033084AbeCAQZm (ORCPT + 28 others); Thu, 1 Mar 2018 11:25:42 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:22475 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032994AbeCAQYU (ORCPT ); Thu, 1 Mar 2018 11:24:20 -0500 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 w21GJQYZ025446; Thu, 1 Mar 2018 17:24:18 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2gax28ujkq-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 01 Mar 2018 17:24:18 +0100 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 D1DF33D; Thu, 1 Mar 2018 16:24:17 +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 B3B1B5202; Thu, 1 Mar 2018 16:24:17 +0000 (GMT) Received: from localhost (10.75.127.45) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 1 Mar 2018 17:24:16 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v3 10/13] remoteproc: modify vring allocation to support pre-registered region Date: Thu, 1 Mar 2018 17:23:57 +0100 Message-ID: <1519921440-21356-11-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> References: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG7NODE3.st.com (10.75.127.21) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-01_08:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Current version of rproc_alloc_vring function supports only dynamic vring allocation. This patch proposes to manage vrings like memory carveouts to commonize memory management codeand to rely on rproc_handle_carveout and rproc_find_carveout_by_name functions for vrings allocation. This patch sets vrings names to vdev"x"vring"y" as no name defined in firmware resource table. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 58 +++++++++++++++++++++++++----------- include/linux/remoteproc.h | 3 +- 2 files changed, 42 insertions(+), 19 deletions(-) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 49b28a0..3041772 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -52,6 +52,10 @@ typedef int (*rproc_handle_resources_t)(struct rproc *rproc, typedef int (*rproc_handle_resource_t)(struct rproc *rproc, void *, int offset, int avail); +static int rproc_handle_carveout(struct rproc *rproc, + struct fw_rsc_carveout *rsc, + int offset, int avail); + /* Unique indices for remoteproc devices */ static DEFINE_IDA(rproc_dev_index); @@ -265,23 +269,45 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) struct device *dev = &rproc->dev; struct rproc_vring *rvring = &rvdev->vring[i]; struct fw_rsc_vdev *rsc; - dma_addr_t dma; - void *va; int ret, size, notifyid; + struct fw_rsc_carveout rsc_carveout; + struct rproc_mem_entry *mem; /* actual size of vring (in bytes) */ size = PAGE_ALIGN(vring_size(rvring->len, rvring->align)); - /* - * Allocate non-cacheable memory for the vring. In the future - * this call will also configure the IOMMU for us - */ - va = dma_alloc_coherent(dev->parent, size, &dma, GFP_KERNEL); - if (!va) { - dev_err(dev->parent, "dma_alloc_coherent failed\n"); + rsc = (void *)rproc->table_ptr + rvdev->rsc_offset; + + /* Create virtual firmware carveout resource */ + rsc_carveout.da = rsc->vring[i].da; + rsc_carveout.pa = FW_RSC_ADDR_ANY; + rsc_carveout.len = size; + rsc_carveout.flags = 0; + rsc_carveout.reserved = 0; + snprintf(rsc_carveout.name, sizeof(rsc_carveout.name), "vdev%dvring%d", + rvdev->index, i); + + /* Do vring carveout allocation */ + ret = rproc_handle_carveout(rproc, &rsc_carveout, 0, + sizeof(rsc_carveout)); + if (ret) { + dev_err(dev->parent, "Failled to process vring carveout\n"); return -EINVAL; } + /* Retrieve memory entry */ + mem = rproc_find_carveout_by_name(rproc, rsc_carveout.name); + if (!mem) { + dev_err(dev->parent, "Failled to find vring carveout\n"); + return -ENOMEM; + } + + /* Verify carveout is well mapped */ + if (!mem->va) { + dev_err(dev->parent, "Invalid vring carveout\n"); + return -ENOMEM; + } + /* * Assign an rproc-wide unique index for this vring * TODO: assign a notifyid for rvdev updates as well @@ -290,7 +316,6 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) ret = idr_alloc(&rproc->notifyids, rvring, 0, 0, GFP_KERNEL); if (ret < 0) { dev_err(dev, "idr_alloc failed: %d\n", ret); - dma_free_coherent(dev->parent, size, va, dma); return ret; } notifyid = ret; @@ -300,10 +325,9 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) rproc->max_notifyid = notifyid; dev_dbg(dev, "vring%d: va %p dma %pad size 0x%x idr %d\n", - i, va, &dma, size, notifyid); + i, mem->va, &mem->dma, size, notifyid); - rvring->va = va; - rvring->dma = dma; + rvring->va = mem->va; rvring->notifyid = notifyid; /* @@ -312,8 +336,8 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) * set up the iommu. In this case the device address (da) will * hold the physical address and not the device address. */ - rsc = (void *)rproc->table_ptr + rvdev->rsc_offset; - rsc->vring[i].da = dma; + if (rsc->vring[i].da == FW_RSC_ADDR_ANY) + rsc->vring[i].da = mem->da; rsc->vring[i].notifyid = notifyid; return 0; } @@ -345,12 +369,10 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) void rproc_free_vring(struct rproc_vring *rvring) { - int size = PAGE_ALIGN(vring_size(rvring->len, rvring->align)); struct rproc *rproc = rvring->rvdev->rproc; int idx = rvring->rvdev->vring - rvring; struct fw_rsc_vdev *rsc; - dma_free_coherent(rproc->dev.parent, size, rvring->va, rvring->dma); idr_remove(&rproc->notifyids, rvring->notifyid); /* reset resource entry info */ @@ -406,6 +428,7 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, struct device *dev = &rproc->dev; struct rproc_vdev *rvdev; int i, ret; + static int index; /* make sure resource isn't truncated */ if (sizeof(*rsc) + rsc->num_of_vrings * sizeof(struct fw_rsc_vdev_vring) @@ -437,6 +460,7 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, rvdev->id = rsc->id; rvdev->rproc = rproc; + rvdev->index = index++; /* parse the vrings */ for (i = 0; i < rsc->num_of_vrings; i++) { diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index dcfa601..0c9d0f6 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -486,7 +486,6 @@ struct rproc_subdev { /** * struct rproc_vring - remoteproc vring state * @va: virtual address - * @dma: dma address * @len: length, in bytes * @da: device address * @align: vring alignment @@ -496,7 +495,6 @@ struct rproc_subdev { */ struct rproc_vring { void *va; - dma_addr_t dma; int len; u32 da; u32 align; @@ -522,6 +520,7 @@ struct rproc_vdev { struct rproc_subdev subdev; unsigned int id; + unsigned int index; struct list_head node; struct rproc *rproc; struct virtio_device vdev; From patchwork Thu Mar 1 16:23:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 130325 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3004854edc; Thu, 1 Mar 2018 08:24:57 -0800 (PST) X-Google-Smtp-Source: AG47ELszo2nqZTvcBVweMvGtlhIiveWeOlJeC7ZQCaI9M0XIm7G8ua8NR3uk5Q8YxhYb2FWdNZm6 X-Received: by 2002:a17:902:b416:: with SMTP id x22-v6mr2382070plr.279.1519921497720; Thu, 01 Mar 2018 08:24:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519921497; cv=none; d=google.com; s=arc-20160816; b=ssqfoH697btkUPD9ELUXIIwOuYPJhKEUks9JNUMQ9hiK5GvyAEPQUP5HSh9Gv6+nLc fLzfbSoqiIPpOfSKVcgzNio+ylTYms4cPsKT+a8r8ka/uExVLrYxFsQ7B7SGNW3+/H9L nWq6QjclQf5FMUIltWqCODi/mLSkD/6i6vsLHN37II7uIW0oDmGT3Fh0jfwVBzUd/oHk NTp0yKRBDvMkASkb9l4zYsveZr1djjTk5XQq8Fz56yI1eQPopMkADWKYhhMtuz4qqKVC sYlNuE59YHea4cg593rTbRtW4gPCK6RntbobXM8BhJEyqdgBLWW/ldpffOIdec6P8ots g7hg== 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=wCBahKe0nmd8eoP3kinO9cC25POc/aPO7+ODX/Ht5do=; b=w09q2zxQaVPm8KSz+E/7RhoV+hlluNMnfcn6bvwtssWri3RgO1cYdKfxymnSxiiLSv wNbbxA41JmOSAbiLmZsxAlIN4Lzd9O4Xv174TJ8eU0whRVWMLxKOKeEWcU99jhQCm9lv LE1WNdJSht0UFU03Nrb1jFZ4L9PEAAWhXtDUiDZl/s3+27IdF3yDVR9EchUPgzr5KxPM KRWxLJPJ700rPLnXnhSTd3/nOf1M6dWcNHpff/z7HSd+thhULXbuvQLQqZy3KOUWzlAZ /iaWLEU/K9kRoJl/OxpBwR1j28xxA/ec+N1w6OD1b6GszY5SyTl9mkSlGcejJEN/t2QA LTVA== 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 f18-v6si310931plr.726.2018.03.01.08.24.57; Thu, 01 Mar 2018 08:24:57 -0800 (PST) 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 S1033066AbeCAQYw (ORCPT + 28 others); Thu, 1 Mar 2018 11:24:52 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:6823 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032997AbeCAQYV (ORCPT ); Thu, 1 Mar 2018 11:24:21 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w21GIdON028249; Thu, 1 Mar 2018 17:24:19 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2gbwb1dpk2-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 01 Mar 2018 17:24:19 +0100 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 AA74A31; Thu, 1 Mar 2018 16:24:18 +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 7E7E951FF; Thu, 1 Mar 2018 16:24:18 +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; Thu, 1 Mar 2018 17:24:17 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v3 11/13] remoteproc: create vdev subdevice with specific dma memory pool Date: Thu, 1 Mar 2018 17:23:58 +0100 Message-ID: <1519921440-21356-12-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> References: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG5NODE2.st.com (10.75.127.14) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-01_08:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch creates a dedicated vdev subdevice for each vdev declared in firmware resource table and associates carveout named "vdev%dbuffer" (with %d vdev index in resource table) if any as dma coherent memory pool. Then vdev subdevice is used as parent for virtio device. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 40 ++++++++++++++++++++++++++++++++++ drivers/remoteproc/remoteproc_virtio.c | 2 +- include/linux/remoteproc.h | 1 + 3 files changed, 42 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 3041772..61c9927 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -427,8 +427,10 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, { struct device *dev = &rproc->dev; struct rproc_vdev *rvdev; + struct rproc_mem_entry *carveout; int i, ret; static int index; + char name[16]; /* make sure resource isn't truncated */ if (sizeof(*rsc) + rsc->num_of_vrings * sizeof(struct fw_rsc_vdev_vring) @@ -479,6 +481,41 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, goto unwind_vring_allocations; } + /* Initialise vdev subdevice */ + snprintf(name, sizeof(name), "vdev%dbuffer", rvdev->index); + rvdev->dev.parent = rproc->dev.parent; + dev_set_name(&rvdev->dev, "%s#%s", dev_name(rvdev->dev.parent), name); + dev_set_drvdata(&rvdev->dev, rvdev); + dma_set_coherent_mask(&rvdev->dev, DMA_BIT_MASK(32)); + + ret = device_register(&rvdev->dev); + if (ret) + goto unwind_vring_allocations; + + /* Try to find dedicated vdev buffer carveout */ + carveout = rproc_find_carveout_by_name(rproc, name); + + if (carveout) { + phys_addr_t pa; + + if (carveout->va) { + dev_warn(dev, "vdev %d buffer carveout already mapped\n", + rvdev->index); + pa = rproc_va_to_pa(carveout->va); + } else { + /* Use dma address as carveout no memmapped yet */ + pa = (phys_addr_t)carveout->dma; + } + + /* Associate vdev buffer memory pool to vdev subdevice */ + ret = dmam_declare_coherent_memory(&rvdev->dev, pa, + carveout->da, + carveout->len, + DMA_MEMORY_EXCLUSIVE); + if (ret < 0) + goto unregister_device; + } + list_add_tail(&rvdev->node, &rproc->rvdevs); rproc_add_subdev(rproc, &rvdev->subdev, @@ -486,6 +523,9 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, return 0; +unregister_device: + put_device(&rvdev->dev); + unwind_vring_allocations: for (i--; i >= 0; i--) rproc_free_vring(&rvdev->vring[i]); diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index b0633fd..f80014f 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c @@ -303,7 +303,7 @@ static void rproc_virtio_dev_release(struct device *dev) int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id) { struct rproc *rproc = rvdev->rproc; - struct device *dev = &rproc->dev; + struct device *dev = &rvdev->dev; struct virtio_device *vdev = &rvdev->vdev; int ret; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 0c9d0f6..dfc44af7 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -518,6 +518,7 @@ struct rproc_vdev { struct kref refcount; struct rproc_subdev subdev; + struct device dev; unsigned int id; unsigned int index; From patchwork Thu Mar 1 16:23:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 130326 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3005301edc; Thu, 1 Mar 2018 08:25:21 -0800 (PST) X-Google-Smtp-Source: AG47ELsIKLfwBVBxWl8s/hTmBExdiKW+MfnXx/oEZO0/xCCNGYpGgdTy/aMeVgEk9ngEz4RRhCnH X-Received: by 2002:a17:902:8d93:: with SMTP id v19-v6mr2398134plo.371.1519921521696; Thu, 01 Mar 2018 08:25:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519921521; cv=none; d=google.com; s=arc-20160816; b=k9FXDj5D+0o2hY2Iv8jN5Eb2p3GM2A2uuFt7/bOgXGJF7hLRTRLgaq7NhZQYDYIT7S ZhzhiN7PL54lYnOE9/Ok9VxGQVvaEwsFJVcsEKUtaIRCT7Xhcm5dJSAexhYDSA/zfy7w JYgl5Kajq+eYZ42Pf6NOlsZ/xpSbW9b0BC7na7oDaz5TxB/YtLQq91iEm4QpGbdoRyJj ZAqYUqqVxPcC2maPbukE1YxKsW769+oF1Q33Jd1tyd48rsatV3ZAATjNZO5//TxVengY mrvTMbp+YRa2wJeSNtWYgcR3m1tGb2WFvUnzkV5CcoYgNpczrVkJFwvdPSbg272wRu+y ftKw== 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=sqnuwsqWwmdvrfACd7LE39ynzZ0aitsI0IuRp5+UIxQ=; b=XBGRBBGo3LwpWpaoABDvvTZBj0l+PFeHxrQugkVxweJ5GsLccYKLH4TMpd2DLJein7 j0vdJTayA96UZpPwW9m/+pFfpAqWceCZcqUVguJF73YpONbvV+74XG7MZJiymuQpy5dC vzwVnt95R3o5sBLCb60plXDPoAhWMxwi08GRvxhoNmo3qNWdJDg1tRSo1gumrIlqzFYX uTGdCUgCKXjxpoZCssnYxA0sec7jeuMzh0beawTMFvnaML9H6MtUZmPXfA4/u0+OcdXT DckbFupc/sqsK+xWG1rwILgEE3/zrJ1JA4GhH7A5pZuIf2mSgS8CfqvJSIuVC0pivkYn 6ovA== 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 f18-v6si310931plr.726.2018.03.01.08.25.21; Thu, 01 Mar 2018 08:25:21 -0800 (PST) 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 S1033053AbeCAQYu (ORCPT + 28 others); Thu, 1 Mar 2018 11:24:50 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:40168 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032974AbeCAQYW (ORCPT ); Thu, 1 Mar 2018 11:24:22 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w21GIhrg028304; Thu, 1 Mar 2018 17:24:20 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2gbwb1dpk3-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 01 Mar 2018 17:24:20 +0100 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 48B6E3A; Thu, 1 Mar 2018 16:24:19 +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 32D2151FF; Thu, 1 Mar 2018 16:24:19 +0000 (GMT) Received: from localhost (10.75.127.44) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 1 Mar 2018 17:24:18 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v3 12/13] rpmsg: virtio: allocate buffer from parent Date: Thu, 1 Mar 2018 17:23:59 +0100 Message-ID: <1519921440-21356-13-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> References: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG8NODE2.st.com (10.75.127.23) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-01_08:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remoteproc is now capable to create one specific sub-device per virtio link to associate a dedicated memory pool. This implies to change device used by virtio_rpmsg for buffer allocation from grand-parent to parent. Signed-off-by: Loic Pallardy --- drivers/rpmsg/virtio_rpmsg_bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index 82b8300..6dd25c6 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -920,7 +920,7 @@ static int rpmsg_probe(struct virtio_device *vdev) total_buf_space = vrp->num_bufs * vrp->buf_size; /* allocate coherent memory for the buffers */ - bufs_va = dma_alloc_coherent(vdev->dev.parent->parent, + bufs_va = dma_alloc_coherent(vdev->dev.parent, total_buf_space, &vrp->bufs_dma, GFP_KERNEL); if (!bufs_va) { From patchwork Thu Mar 1 16:24:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 130323 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3004511edc; Thu, 1 Mar 2018 08:24:39 -0800 (PST) X-Google-Smtp-Source: AG47ELvsNOog5nX+C8aHgi6WbAw+21/08Q+aGlOv83ft3Sldvbtbc3L/V/Zn9pIje+3ny7tilwMZ X-Received: by 10.98.223.143 with SMTP id d15mr2515580pfl.208.1519921479212; Thu, 01 Mar 2018 08:24:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519921479; cv=none; d=google.com; s=arc-20160816; b=SzuMFP1yPmOIpW/6oVBwNG+P7ljV7KZCZqiPIFMFYQvfMYGqg60z6Qxn+bIib52PSG 8SNG2A7U7kFBVkW4b+/J2QEQJhgPl8nnrwHQbc5lp2TI72HBX3hxpvKwS2z+cWrd1G0Y s3IGO+VTRHqeYWUoF5bEpIxWgu4Ydtg64wyCqf6tvQAvwRisaj/i3mLw8TAJsv+mj8DZ lPAsrl91zoINz49r+3xwsADOgOatpYnp+WVkAFgA2RCC71XZU4yC7myCnuALQ98xXeAC gAzPi/GjQZLFpRBjPcX5dpWAeKF+Fc39g0f5NND+rKuFFMm2fQV9ab8Ihssc7sgCM1LI JR4A== 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=lFXJiyUOnOQp1YKrRJMNX3XrOZDofigCwSXFs5f7h5k=; b=DQ0ikGrkSYNlKKARlBeGurbd9Rt9cEX4e71vIwmjZah2xVKAJc2mQSGOlL/lCFRD7m 0LzVuxSUcCvRVvd4htJu2U2Xdovo4zBoJ50yZCLUEZElt001bHAFLmwI0sMODSrO04Mg d3CmykpgF7DYGoyJPuLK/zryX+7c8HOLpqVeWlILcBF84E1HTmGv7HCBURoI7v9NXmwz cs3Y5qnkm0YypGuhhGSVX5vE5X2SBOc0ZytzAZ01QrIXaIyR0KCQRqrXluH4MRZciaxZ fCNvVGgZMI9zJT0vjKdKQXXKUeYNNNUvnNQd/xICGP807fhONh3TAVvneE9qKONfMJS5 xhDw== 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 o4si2625645pgp.285.2018.03.01.08.24.38; Thu, 01 Mar 2018 08:24:39 -0800 (PST) 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 S1033039AbeCAQYf (ORCPT + 28 others); Thu, 1 Mar 2018 11:24:35 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:28834 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1033011AbeCAQYW (ORCPT ); Thu, 1 Mar 2018 11:24:22 -0500 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 w21GJQYa025446; Thu, 1 Mar 2018 17:24:20 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2gax28ujks-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 01 Mar 2018 17:24:20 +0100 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 1CD9031; Thu, 1 Mar 2018 16:24:20 +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 0928151FF; Thu, 1 Mar 2018 16:24:20 +0000 (GMT) Received: from localhost (10.75.127.51) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 1 Mar 2018 17:24:19 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v3 13/13] remoteproc: st: add reserved memory support Date: Thu, 1 Mar 2018 17:24:00 +0100 Message-ID: <1519921440-21356-14-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> References: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.51] X-ClientProxiedBy: SFHDAG5NODE2.st.com (10.75.127.14) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-01_08:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ST remote processor needs some specified memory regions for firmware and IPC. Memory regions are defined as reserved memory and should be registered in remoteproc core thanks to rproc_add_carveout function before rproc_start. For this, st rproc driver implements prepare ops. Signed-off-by: Loic Pallardy --- drivers/remoteproc/st_remoteproc.c | 68 +++++++++++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 8 deletions(-) -- 1.9.1 diff --git a/drivers/remoteproc/st_remoteproc.c b/drivers/remoteproc/st_remoteproc.c index aacef0e..72a19a0 100644 --- a/drivers/remoteproc/st_remoteproc.c +++ b/drivers/remoteproc/st_remoteproc.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -91,6 +92,64 @@ static void st_rproc_kick(struct rproc *rproc, int vqid) dev_err(dev, "failed to send message via mbox: %d\n", ret); } +static int st_rproc_mem_release(struct rproc *rproc, + struct rproc_mem_entry *mem) +{ + struct device *dev = rproc->dev.parent; + + devm_iounmap(dev, mem->va); + + return 0; +} + +static int st_rproc_prepare(struct rproc *rproc) +{ + struct device *dev = rproc->dev.parent; + struct device_node *np = dev->of_node; + struct rproc_mem_entry *mem; + void *va; + struct reserved_mem *rmem; + struct of_phandle_iterator it; + int err; + + of_phandle_iterator_init(&it, np, "memory-region", NULL, 0); + while ((err = of_phandle_iterator_next(&it)) == 0) { + va = NULL; + rmem = of_reserved_mem_lookup(it.node); + + /* No need to map vdev buffer */ + if (strcmp(it.node->name, "vdev0buffer")) { + va = devm_ioremap_wc(dev, rmem->base, rmem->size); + if (!va) { + dev_err(dev, "Unable to map memory region: %pa+%zx\n", + &rmem->base, rmem->size); + return -EBUSY; + } + + /* Register memory region */ + mem = rproc_mem_entry_init(dev, va, + (dma_addr_t)rmem->base, + rmem->size, rmem->base, + st_rproc_mem_release, + it.node->name); + } else { + /* Register vdev buffer */ + mem = rproc_mem_entry_init(dev, NULL, + (dma_addr_t)rmem->base, + rmem->size, rmem->base, + NULL, + it.node->name); + } + + if (!mem) + return -ENOMEM; + + rproc_add_carveout(rproc, mem); + } + + return 0; +} + static int st_rproc_start(struct rproc *rproc) { struct st_rproc *ddata = rproc->priv; @@ -161,6 +220,7 @@ static int st_rproc_stop(struct rproc *rproc) .kick = st_rproc_kick, .start = st_rproc_start, .stop = st_rproc_stop, + .prepare = st_rproc_prepare, }; /* @@ -254,12 +314,6 @@ static int st_rproc_parse_dt(struct platform_device *pdev) return -EINVAL; } - err = of_reserved_mem_device_init(dev); - if (err) { - dev_err(dev, "Failed to obtain shared memory\n"); - return err; - } - err = clk_prepare(ddata->clk); if (err) dev_err(dev, "failed to get clock\n"); @@ -387,8 +441,6 @@ static int st_rproc_remove(struct platform_device *pdev) clk_disable_unprepare(ddata->clk); - of_reserved_mem_device_release(&pdev->dev); - for (i = 0; i < ST_RPROC_MAX_VRING * MBOX_MAX; i++) mbox_free_channel(ddata->mbox_chan[i]);