From patchwork Thu Nov 30 16:46:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 120251 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp24781qgn; Thu, 30 Nov 2017 08:50:19 -0800 (PST) X-Google-Smtp-Source: AGs4zMbQq3cbx6YwQRMzO//2ILjra+kc44lr4ejf+LzuG94Qoz/q5aHUFwavNInpC7uI69Q3rNlE X-Received: by 10.99.60.83 with SMTP id i19mr2891333pgn.26.1512060619083; Thu, 30 Nov 2017 08:50:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512060619; cv=none; d=google.com; s=arc-20160816; b=S9XMZ0117aI+ICqj/nVhCmEvKiCzkvG/x01/MjtZO3NmIwbTCBZlLW9dMSqTxNav8w x2Wi6Hj93X90nwg0f6+whzSN5Kse5u62KubLn2lEstuyZsC2wWFof2TxEYzBinwgiIrH 6MyRZSUT3vBczH+P1Cva9J3l9jnWIiJMYV8jnJNs46Aw5AiSkJKb7Dym0fucEoEL1WPP qT054fNpkSq2H9/ZJ9VpIzbzu26x0QBXZ+gqDcbreoPhqwX9KNmlfsUJ7m1p8DwZUxIx /16O2e9oWW3Rc2fQuKCdoqzuGv86cVL3I/T3vQ8I0+E6byF+98gDhguiriRGBjZ6RM60 jwrA== 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=+p0JMoaaR1fg2nzsQic4PHrvT7oTwU5+n6sJI8MvLpA=; b=ot8rkU/Rsa1tlfNV919xj2kSZ+SnEaggDG/aI9+4heUZWNAXRLyShtCAsVteloPnqr 1gEuVyjjKMbLtCnvnU6XPpsABfiPYPh7iCpMUtzfplSmkvB23TEH4L3H2p3bPebpUg0J hfEaVUL0q4nWJryOVcIxC1ayoK0WoqYk2DyW0Es2BWF+dylHZChNEH5VGdfSMDCYHj/i oG1Wb7Zd6MyURZYi/C3is5P1YzJC03LDZYCDX0BAjTsy5iUN1phuD5eC/uxs0prvf4e9 a9i/n9M0b7Mn4/c7bG1KMwN3qdeWB7iynGcG0NEVIvWkiLSMUhCR+nyNup++vET79cdb ekNQ== 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 x12si3282939pgq.307.2017.11.30.08.50.18; Thu, 30 Nov 2017 08:50:19 -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 S1753521AbdK3QrQ (ORCPT + 28 others); Thu, 30 Nov 2017 11:47:16 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:14815 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753444AbdK3QrN (ORCPT ); Thu, 30 Nov 2017 11:47: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 vAUGiEpX001563; Thu, 30 Nov 2017 17:47: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 2eexh9v2r4-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 30 Nov 2017 17:47: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 501B431; Thu, 30 Nov 2017 16:47: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 374D45379; Thu, 30 Nov 2017 16:47:11 +0000 (GMT) Received: from localhost (10.75.127.46) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 30 Nov 2017 17:47:10 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v2 01/16] remoteproc: add rproc_va_to_pa function Date: Thu, 30 Nov 2017 17:46:36 +0100 Message-ID: <1512060411-729-2-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512060411-729-1-git-send-email-loic.pallardy@st.com> References: <1512060411-729-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] 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=2017-11-30_05:, , 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 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index eab14b4..faa18a7 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -139,6 +139,17 @@ static void rproc_disable_iommu(struct rproc *rproc) iommu_domain_free(domain); } +static phys_addr_t rproc_va_to_pa(void *cpu_addr) +{ + 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 @@ -700,7 +711,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 Nov 30 16:46:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 120255 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp26068qgn; Thu, 30 Nov 2017 08:51:38 -0800 (PST) X-Google-Smtp-Source: AGs4zMY1xktAgK+gbQ0YQ+ZiYc3NQRLxQGa1XucpE6lah0Wgm7XnyQJsCNlFVR6oBv4Io7XNOxNl X-Received: by 10.84.252.4 with SMTP id x4mr3103564pll.99.1512060698905; Thu, 30 Nov 2017 08:51:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512060698; cv=none; d=google.com; s=arc-20160816; b=goCHamgzteeyEpm240RsWMINwfUGtpxjBFdubSQPsNJXF+dXuHAhiFXEqHW4h9F3uO JkodIolefDJ8u6NPg4QN6m9XAlz3Wkty5wb/eOeA5ZKzdllr2x5suvNOI9hWCFyiFiYv Bn0STs0q1nyRRNteYldWrTQEDlwvEA9zfBPMBrq4u48U7h/EJ2MdTTpPbwNwdoIz9oLk GMD3Ya+w6AUkh6tqWWDlkGGPUWbcdudVbChqL3fTYubz7txymLR2MCaijMOzpGOWPANd vPjzXe4HTT0E5C/gUdDEM8G+NvXR3ld8l3kq5TRGxBOaL2fxu32Sq0xmpqEhpOfadJdT Dqcg== 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=OkuJivHxzUISNOQmCOdTuRlfzn2S1thnoD8Aw4ookqA=; b=mD20R2HW0ZX1O7+OKtx1XZTXEZ7nvgDcgNjIRvtdq3ThRXvl3isa5vCmEbx1Pjg7rb aHManf37BSnxLLSKTWxbZIsubDSQhSAIoYCCn5F/upqObyNoBEmCwRG+XIC3JVAUCfmy Xo3HFeUrSJdWQqM6blGeuhRDaeXUNgCwlN+OAqIhTMb6+0qpgLek0Xukq54pEadV/fv4 iKLgxmduKr2FgFRyT9TjFPPolNj9dHHsiNvRouv7SOyLUUkeeFj1k5hHjuDBya6a+TBP RJj53aJJ3cZi/QKSIsEDF+WgijHCg5EEbWrRM4lwuIje+hxkarQyVkRq5SyA9qUmCsSj mkEA== 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 t134si3233867pgb.511.2017.11.30.08.51.38; Thu, 30 Nov 2017 08:51:38 -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 S1753796AbdK3Qvf (ORCPT + 28 others); Thu, 30 Nov 2017 11:51:35 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:41543 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753477AbdK3QrO (ORCPT ); Thu, 30 Nov 2017 11:47:14 -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 vAUGiHCN001569; Thu, 30 Nov 2017 17:47:13 +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 2eexh9v2r7-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 30 Nov 2017 17:47: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 4306931; Thu, 30 Nov 2017 16:47: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 1D8C5537B; Thu, 30 Nov 2017 16:47:12 +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, 30 Nov 2017 17:47:11 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v2 02/16] remoteproc: add release ops in rproc_mem_entry struct Date: Thu, 30 Nov 2017 17:46:37 +0100 Message-ID: <1512060411-729-3-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512060411-729-1-git-send-email-loic.pallardy@st.com> References: <1512060411-729-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.51] X-ClientProxiedBy: SFHDAG3NODE2.st.com (10.75.127.8) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-30_05:, , 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 | 26 ++++++++++++++++++++++---- include/linux/remoteproc.h | 6 ++++-- 2 files changed, 26 insertions(+), 6 deletions(-) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index faa18a7..f23daf9 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -592,6 +592,25 @@ 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); + list_del(&mem->node); + kfree(mem); + return 0; +} + +/** * rproc_handle_carveout() - handle phys contig memory allocation requests * @rproc: rproc handle * @rsc: the resource entry @@ -717,6 +736,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); @@ -847,10 +867,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); - list_del(&entry->node); - kfree(entry); + if (entry->release) + entry->release(rproc, entry); } /* clean up remote vdev entries */ diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 44e630e..8780f2e 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 */ @@ -319,12 +322,11 @@ struct rproc_mem_entry { dma_addr_t dma; int len; u32 da; + int (*release)(struct rproc *rproc, struct rproc_mem_entry *mem); void *priv; struct list_head node; }; -struct rproc; - /** * struct rproc_ops - platform-specific device handlers * @start: power on the device and boot it From patchwork Thu Nov 30 16:46:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 120254 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp25372qgn; Thu, 30 Nov 2017 08:50:55 -0800 (PST) X-Google-Smtp-Source: AGs4zMbnMxud6yOPMGVwiFLt3S3clvPng4cmcVFVXJsRhUa2jy30CVSU74wa4vq87LhSZYpHrvDL X-Received: by 10.99.109.2 with SMTP id i2mr2986780pgc.269.1512060654977; Thu, 30 Nov 2017 08:50:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512060654; cv=none; d=google.com; s=arc-20160816; b=R21UTK9qMwdEa2w4vlxB9CcGFhxXEe/nYj4DUoLiiDMqXHyztFnYs0sBozqr3Z2xkr mrtz7ul4jFF5Ms1juZRJAZIlbcN43Zu5qj7z1O2PzIXbxVYca/llmbmLkRX71Tkgg0Tm AroJyresCFuWF2mvuglTpMLuKXdHhhPts68hhou10QtcuehVJhlHSXQK7IJg0VCHB2YN 4TSgCIJ3XGU388XvhYf5BRWSMQ/e4ekPZkYLRs4NjB3paDPzwoynctnQMj7tWWLVVxEc Vt0HYTa64c8uf1Hmf3DAiDYdFesmmLJ8KnLxYKeRYB41zHB3j1t0PycUJhbD2nlOGxgC krHg== 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=OGnuf/AzXk/2L6bJeDbKcupxE894ltzj74HbVsI9fig=; b=H0R4FZdWk+vKKHDWYhvKz4S4NKMN6uveH7xpScpMv8cZdiYtGtZFcg88GDmf4yj9Bm 4NY3aUmdMrkAOIPTlbWQgoUP1HShquS+ohwN8uorKwdHpWKhMJZUCAg32/l2dErE//Uo Xp2lt14dzo7TORku+3lfTfYtKVy5qL1pxB2NgqcguNepfmRJAsR6l9iMq1zw/2a4FTyS oFV13ZOO3UZ04mLxmeRI53XTCPrSwYFc9tAq9DEr0G5QiscK3lVOHZ7feaTO8HBrtw7i Dv6GUEVuc2VyJEIKI40sTIh+tDJRUwXh7rTOZ7mSr43v/YT0sAFiwLBvRvJsHJmcwxmJ 3Fgw== 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 i11si3512549pfk.351.2017.11.30.08.50.54; Thu, 30 Nov 2017 08:50:54 -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 S1753552AbdK3Qux (ORCPT + 28 others); Thu, 30 Nov 2017 11:50:53 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:59150 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753522AbdK3QrP (ORCPT ); Thu, 30 Nov 2017 11:47:15 -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 vAUGiIDx001572; Thu, 30 Nov 2017 17:47:13 +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 2eexh9v2r9-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 30 Nov 2017 17:47: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 09B1534; Thu, 30 Nov 2017 16:47: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 DD4A9537C; Thu, 30 Nov 2017 16:47: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, 30 Nov 2017 17:47:12 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v2 03/16] remoteproc: introduce rproc_add_carveout function Date: Thu, 30 Nov 2017 17:46:38 +0100 Message-ID: <1512060411-729-4-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512060411-729-1-git-send-email-loic.pallardy@st.com> References: <1512060411-729-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG8NODE1.st.com (10.75.127.22) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-30_05:, , 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 | 22 ++++++++++++++++++++++ drivers/remoteproc/remoteproc_internal.h | 7 +++++++ include/linux/remoteproc.h | 2 ++ 3 files changed, 31 insertions(+) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index f23daf9..279320a 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -737,6 +737,7 @@ static int rproc_handle_carveout(struct rproc *rproc, carveout->dma = dma; carveout->da = rsc->da; carveout->release = rproc_release_carveout; + carveout->priv = (void *)CARVEOUT_RSC_ALLOCATED; list_add_tail(&carveout->node, &rproc->carveouts); @@ -751,6 +752,27 @@ static int rproc_handle_carveout(struct rproc *rproc, return ret; } +/** + * 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. + */ +int rproc_add_carveout(struct rproc *rproc, struct rproc_mem_entry *mem) +{ + if (!rproc || !mem) + return -EINVAL; + + mem->priv = (void *)CARVEOUT_EXTERNAL; + + list_add_tail(&mem->node, &rproc->carveouts); + + return 0; +} +EXPORT_SYMBOL(rproc_add_carveout); + /* * A lookup table for resource handlers. The indices are defined in * enum fw_resource_type. diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index c1077be..69b22ac 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -23,6 +23,13 @@ #include #include +/* Indicate carveout origin */ +enum carveout_src { + CARVEOUT_RSC = 0, + CARVEOUT_RSC_ALLOCATED = 1, + CARVEOUT_EXTERNAL = 2, +}; + struct rproc; /** diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 8780f2e..5bd5175 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -522,6 +522,8 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, int rproc_del(struct rproc *rproc); void rproc_free(struct rproc *rproc); +int rproc_add_carveout(struct rproc *rproc, struct rproc_mem_entry *mem); + 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 Nov 30 16:46:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 120253 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp25065qgn; Thu, 30 Nov 2017 08:50:35 -0800 (PST) X-Google-Smtp-Source: AGs4zMYPnJtzjm2YY/j9sSuLqF2qwsv0eQ3Cm+QnDhmroMuAMAW2DKtbZDRQulCFgZYagW8LR760 X-Received: by 10.98.155.129 with SMTP id e1mr7369732pfk.119.1512060635130; Thu, 30 Nov 2017 08:50:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512060635; cv=none; d=google.com; s=arc-20160816; b=02+sxlDgd3noYbGQn3kufT91yWuZbSyXWkFtc43M8k3dF3rAF9oN4h7CdXW1p54k4s YjoF0AGJQ0dZfSlZKWbKK1r8zgAagPYs4SN2iMIe+juBcNv3YydOYnQsTyZ/S34XV/b7 S+WK0JlWGFFLeo3EpEZVQYWC/Qgn+4JZwFP1oTe+AhcBWZrVYui+m6JEjitsCt+hQFVN VUsMfZ6s8HyKXXApDTzSdznHuRlW6YPPlaawQQGTWaLmE0SuCm9H9GB82GKVc5/kOfse bdbkorAhAXOFUKORml49r+PbJm7tJi8tXpYdEgW0ijsYvDU711Q5NRfEpbY/XU+d+iZo sZkQ== 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=ouvP6P5WHynhrRXV45C5nh+umaspcEBsd9ktqVZcoeM=; b=c1QvOvaJTmy6eLfSAJRhOiL5OwpXxxdmfjg1Nv+xL9ioMObTM69Ei+4JsJ0ZGctZyg 4TVjFg3feupLGSrqelSuWykV5cgH8xz33CNeK6rUPQV1DlhIsRp332LHjLNH2xkd4qn8 eordXTuYC0oSIK/zvDAQ9TuNwiSmPZChro5bnufy9KrAZvERuav6Oqt/QEd3rQycMev8 5q1SQuZiA4/BxTngQI1qLdJkgsP4lx9tl4GTxYmSvZ67NF/3x/8ZSbEf45QScv2ulkN3 uq766EMh5Pnriiu3QffLGdZWehXqYUx2eEKO3welv0chmFG9wSyoCiswTGfjpzm3rvqF La9Q== 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 j1si3259945pgq.328.2017.11.30.08.50.34; Thu, 30 Nov 2017 08:50:35 -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 S1753821AbdK3Quc (ORCPT + 28 others); Thu, 30 Nov 2017 11:50:32 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:30554 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753560AbdK3QrQ (ORCPT ); Thu, 30 Nov 2017 11:47:16 -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 vAUGiEpa001563; Thu, 30 Nov 2017 17:47: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 2eexh9v2rf-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 30 Nov 2017 17:47: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 D6C5A41; Thu, 30 Nov 2017 16:47: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 B8A25537D; Thu, 30 Nov 2017 16:47:13 +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, 30 Nov 2017 17:47:13 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v2 04/16] remoteproc: introduce rproc_find_carveout_by_da Date: Thu, 30 Nov 2017 17:46:39 +0100 Message-ID: <1512060411-729-5-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512060411-729-1-git-send-email-loic.pallardy@st.com> References: <1512060411-729-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG6NODE3.st.com (10.75.127.18) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-30_05:, , 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 device address (da). If match found, this function returns CPU virtual address corresponding to specified da. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 279320a..78525d1 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -211,6 +211,48 @@ void *rproc_da_to_va(struct rproc *rproc, u64 da, int len) } EXPORT_SYMBOL(rproc_da_to_va); +/** + * rproc_find_carveout_by_da() - lookup the carveout region for a remoteproc address + * @rproc: handle of a remote processor + * @da: remoteproc device address to find + * @len: length of the memory region @da is pointing to + * + * 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 translate specific device addresse to virtual + * addresse so we can fill firmware resource table. + * + * The function returns a valid virtual address on success or NULL on failure. + */ +void *rproc_find_carveout_by_da(struct rproc *rproc, u64 da, int len) +{ + struct rproc_mem_entry *carveout; + void *va = NULL; + + list_for_each_entry(carveout, &rproc->carveouts, node) { + int offset = da - carveout->da; + + /* try next carveout if da is too small */ + if (offset < 0) + continue; + + /* try next carveout if da is too large */ + if (offset + len > carveout->len) + continue; + + va = carveout->va + offset; + + break; + } + + return va; +} + int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) { struct rproc *rproc = rvdev->rproc; From patchwork Thu Nov 30 16:46:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 120239 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp21655qgn; Thu, 30 Nov 2017 08:47:23 -0800 (PST) X-Google-Smtp-Source: AGs4zMYLZfv5h7tF+PoVbKfBQJfL7ry4HiHV1FMlH1+OqphVQ7A+qQsDNE8wNhtfmk0zQvlCXjvc X-Received: by 10.84.137.106 with SMTP id 97mr3260353plm.429.1512060443243; Thu, 30 Nov 2017 08:47:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512060443; cv=none; d=google.com; s=arc-20160816; b=my7Jir4KKLNSq+lsCn6zhG0QPPZfijcH2++HXiTeyWWf3ewk0C8MItGNUM9IHpHqp+ dGAzE/5qa+hSar3MB+RGGQnodhfew86tU9+lFxx6+zQkfG9tXUQSWkwJ32AMxRP1xkRu 9cO0tpufvQ5anueBvahmh0fAxuArTzaSrUb6YWuOEo1D69fCUG42yU+JlBKuHfderrei MCcK9LsqzO/Ayg1p0G0vMAGG3S1pATyIXOg3k7MBCHPdIChS2/P9udeXhaHGEluThHz8 wJJXcy0uyJS236o/M93qQ/VvhUnBcwowJ9M7z7oKdPnj56Wm/PF+OkQUh4q4zZX0IDB8 6yOw== 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=kfIybiZrRFmbLp69G04wDpzKWQ1RYst1WhIH+V4z+48=; b=MI5EEgtwbTRnd4dL2s1fxOpGeQMBU2Sc60ROuySGVCxUJMUgYbPOG53/fMJvjq47+i 9zRN5pO3EP8q7OApBpDy+ylJ8Zl4j51v+7s9WeZG3BmvuwHsN1qFRBWAUiEf+I4iO8Oi uWsm3i/J5oRdwtKKO04yQaiaIyMPDsUhQTgcnYc+vQhqzVA4WDTuR30eEcrYS6fC5K3F nbE7OWDm+RIQzAw52nNBmSePaPk31O8BzcAM3MPH5ao0r4lNRlBNprJqIWDFdZUaQjZq HLyleoIJvMghLoL7BWmM5k4DiFlxyAjYsD1rnkBq7oPT2yNKP4zbRzNn+SJGE4N5dbeN rA8Q== 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 k4si3231917pgf.300.2017.11.30.08.47.22; Thu, 30 Nov 2017 08:47:23 -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 S1753780AbdK3QrV (ORCPT + 28 others); Thu, 30 Nov 2017 11:47:21 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:19485 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753611AbdK3QrR (ORCPT ); Thu, 30 Nov 2017 11:47: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 vAUGiFI9001566; Thu, 30 Nov 2017 17:47: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 2eexh9v2rk-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 30 Nov 2017 17:47: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 D052042; Thu, 30 Nov 2017 16:47: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 9AAF2537A; Thu, 30 Nov 2017 16:47:14 +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, 30 Nov 2017 17:47:14 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v2 05/16] remoteproc: modify rproc_handle_carveout to support preallocated region Date: Thu, 30 Nov 2017 17:46:40 +0100 Message-ID: <1512060411-729-6-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512060411-729-1-git-send-email-loic.pallardy@st.com> References: <1512060411-729-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG4NODE1.st.com (10.75.127.10) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-30_05:, , 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 different carveout configurations: - fixed DA and fixed PA: check if already part of pre-registered carveouts (platform driver). If no, return error. - fixed DA and any PA: check if already part of pre-allocated carveouts (platform driver). If not found and rproc supports iommu, continue with dynamic allocation (DA will be used for iommu programming), else return error as no way to force DA. - any DA and any PA: use original dynamic allocation Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 78525d1..515a17a 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -184,6 +184,10 @@ void *rproc_da_to_va(struct rproc *rproc, u64 da, int len) struct rproc_mem_entry *carveout; void *ptr = NULL; + /* + * da_to_va platform driver is deprecated. Driver should register + * carveout thanks to rproc_add_carveout function + */ if (rproc->ops->da_to_va) { ptr = rproc->ops->da_to_va(rproc, da, len); if (ptr) @@ -677,6 +681,7 @@ static int rproc_handle_carveout(struct rproc *rproc, struct rproc_mem_entry *carveout, *mapping; struct device *dev = &rproc->dev; dma_addr_t dma; + phys_addr_t pa; void *va; int ret; @@ -698,6 +703,41 @@ static int rproc_handle_carveout(struct rproc *rproc, if (!carveout) return -ENOMEM; + /* Check carveout rsc already part of a registered carveout */ + if (rsc->da != FW_RSC_ADDR_ANY) { + va = rproc_find_carveout_by_da(rproc, rsc->da, rsc->len); + + if (va) { + /* Registered region found */ + pa = rproc_va_to_pa(va); + if (rsc->pa != FW_RSC_ADDR_ANY && rsc->pa != (u32)pa) { + /* Carveout doesn't match request */ + dev_err(dev->parent, + "Failed to find carveout fitting da and pa\n"); + return -ENOMEM; + } + + /* Update rsc table with physical address */ + rsc->pa = (u32)pa; + + /* Update carveouts list */ + carveout->va = va; + carveout->len = rsc->len; + carveout->da = rsc->da; + carveout->priv = (void *)CARVEOUT_RSC; + + list_add_tail(&carveout->node, &rproc->carveouts); + + return 0; + } + + if (!rproc->domain) { + dev_err(dev->parent, + "Bad carveout rsc configuration\n"); + return -ENOMEM; + } + } + va = dma_alloc_coherent(dev->parent, rsc->len, &dma, GFP_KERNEL); if (!va) { dev_err(dev->parent, From patchwork Thu Nov 30 16:46:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 120252 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp24809qgn; Thu, 30 Nov 2017 08:50:20 -0800 (PST) X-Google-Smtp-Source: AGs4zMZynkg3kA6RMK0XGj9wS7TdHMJv5QzfR9nC1WbwKTUDEaHQ9ALLAkMmtmUceEZJTy/173xA X-Received: by 10.98.220.218 with SMTP id c87mr7233353pfl.229.1512060620612; Thu, 30 Nov 2017 08:50:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512060620; cv=none; d=google.com; s=arc-20160816; b=TGr4O5sPRN0Ji/bU44J6ZNyqx2oBSsDD6j0WL7HgF0nIgjfBZIKZSJyhJXX88wLho/ +IyQeF0HIbiPC8G7Zss18c9IYchWcK6Kjh78M37CGUqmN83F7oQoSn0d8+jRmmVYWgyD nxOx81AKNC0pFqsx33iGfQDhUrZ7FVMUTqO0VSXCVo4irDz/T6WBIW2Ga1HnmoG/Sra3 sDeJcp40+fVBU9p4ImzcWDh6A7xG4YFknCCYWNc/0FzSZRaWU1PJtU1cYUsuGixsYYra uoCenR6Kwc2iAYHFhEUGo6TI0Daweh+VI92FRLtDjslxJF8sdWLnXgOVOlI/tx3k345P qibw== 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=1JNzVCW/3VbrVPcQvQdRzRBOTeGKXkeNsx5kGqTiL04=; b=KARImDOTsHNrKUvmRYnB0JR6YQAmt4s0YWhRGzEipz4nx9INDiQ8m/i8MNbSPA7cEn POhgyy7K36Os2KYrFTYSCctFfB9zf6AmjglDH1F8wd8UQlkyszYUTLkRIgAZJw0HBzaS fPpGdGF6EqtXat6w0u+8xQ3gYdQoyNJ6ngIVXuFfYhO5VDLekI3XpdOwWWww6ni6h72U D6VyGFv/whvBYFvDWFGv1zXK5mijqoee4qwJ7doUvwvwXXLflVKpmPjdEv5uoGaGfpkU mobk4/uGqinUqCoJOvvukmAz/S+nkZ1hFRzYNUApoqFxB5Wpe8Ep+TisP7iHSlZ5G2Jk dUxg== 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 x12si3282939pgq.307.2017.11.30.08.50.20; Thu, 30 Nov 2017 08:50:20 -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 S1753766AbdK3QuS (ORCPT + 28 others); Thu, 30 Nov 2017 11:50:18 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:43894 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753556AbdK3QrR (ORCPT ); Thu, 30 Nov 2017 11:47: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 vAUGiFIB001566; Thu, 30 Nov 2017 17:47: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 2eexh9v2rp-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 30 Nov 2017 17:47: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 943233D; Thu, 30 Nov 2017 16:47: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 60C4F537B; Thu, 30 Nov 2017 16:47: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, 30 Nov 2017 17:47:14 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v2 06/16] remoteproc: modify vring allocation to support preallocated region Date: Thu, 30 Nov 2017 17:46:41 +0100 Message-ID: <1512060411-729-7-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512060411-729-1-git-send-email-loic.pallardy@st.com> References: <1512060411-729-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=2017-11-30_05:, , 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 extends rproc_alloc_vring to verify if requested vring DA is already part or not of a registered carveout. If true, nothing to do, else just allocate vring as before. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 53 +++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 19 deletions(-) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 515a17a..bdc99cd 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -263,21 +263,41 @@ 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; + dma_addr_t dma = -1; void *va; int ret, size, notifyid; /* 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"); - return -EINVAL; + /* get vring resource table pointer */ + rsc = (void *)rproc->table_ptr + rvdev->rsc_offset; + + if (rsc->vring[i].da != FW_RSC_ADDR_ANY) { + va = rproc_find_carveout_by_da(rproc, rsc->vring[i].da, size); + + if (!va) { + /* No region not found */ + dev_err(dev->parent, "Pre-allocated vring not found\n"); + return -ENOMEM; + } + } else { + /* + * 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"); + return -EINVAL; + } + /* + * Let the rproc know the da of this vring. + * Not all platforms use dma_alloc_coherent to automatically + * set up the iommu. In this case the device address (da) will + * hold the physical address and not the device address. + */ + rsc->vring[i].da = dma; } /* @@ -288,7 +308,8 @@ 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); + if (dma != -1) + dma_free_coherent(dev->parent, size, va, dma); return ret; } notifyid = ret; @@ -304,14 +325,7 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) rvring->dma = dma; rvring->notifyid = notifyid; - /* - * Let the rproc know the notifyid and da of this vring. - * Not all platforms use dma_alloc_coherent to automatically - * 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; + /* Let the rproc know the notifyid of this vring. */ rsc->vring[i].notifyid = notifyid; return 0; } @@ -348,7 +362,8 @@ void rproc_free_vring(struct rproc_vring *rvring) int idx = rvring->rvdev->vring - rvring; struct fw_rsc_vdev *rsc; - dma_free_coherent(rproc->dev.parent, size, rvring->va, rvring->dma); + if (rvring->dma != -1) + dma_free_coherent(rproc->dev.parent, size, rvring->va, rvring->dma); idr_remove(&rproc->notifyids, rvring->notifyid); /* reset resource entry info */ From patchwork Thu Nov 30 16:46:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 120250 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp24375qgn; Thu, 30 Nov 2017 08:49:56 -0800 (PST) X-Google-Smtp-Source: AGs4zMbOA/i5IEyGAPoi+EMHv+E2bygPU7m3NANJTyLsgqm0k1fuLOVjDSAwkUDle5FMXuO75nTk X-Received: by 10.99.117.87 with SMTP id f23mr1797295pgn.133.1512060596215; Thu, 30 Nov 2017 08:49:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512060596; cv=none; d=google.com; s=arc-20160816; b=MrCeTSCb5hJOjCwN0vDChvAIymsti3MsIpcFZoOb5VPyHV124R0C2x+Ij1F0uY/+xq jQd2ny47VB5D2GTMIyxeMbUMm+3F9DGDfp0oyoyILefxkgmpk51fDTTHnejkGth5gP7W yeBjenCAckO2ouhOcjk9So0VCD4IfspCmpvS9yATZ4OgSR3IpNDnKm5dTyhkN+p4JhtD M8u5YzkCYNaqW6UlIFsmcVF6lBDKRQR9L5TH/nKAfsUoH9tDBpgA72ezSkBn/f0ub4Dp yVT5ex3CwRYyMJrtRgVyffb145UmthgjUySz6xNO6Z347/LnbVaj1eQYDdva1rulBVRz p+pw== 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=WJ/qcxZevF9kjlPWWVZ5naLNJjrDiVIIg9g6nGcsOhw=; b=lTL3KA7myfwrRbaA3rqjDhIytZr60K1ditrX+2wVbpe6dV15mYBOW4Uy/xfpgFUZsr ldhgpMsZGXLvsN86PxxGVyGSakodx7wVx8repFyoi5rvXjepSCl2ETd6uC97JFSaIUrX 3TuLgbvzy0CJSn3sVIMrVJZBg7tlUG+EDY3mQ59y9fEzW/jRzOjdZwEqsbSROl9wXTZy IKrU4EcqPNY6/e2UURIQB6v1A0EO/v5qs9xbjPKkoAAuX1+3UxwFFrN4wlUkSVbkj8Uh kuvee6zZ05igqbY8cA+sUZvy1twN+a21dd47Wx/VJbrUd0MtP/qCeWbDJzTG5I3b9M/X AAoQ== 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 m3si3437611pld.71.2017.11.30.08.49.55; Thu, 30 Nov 2017 08:49:56 -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 S1753724AbdK3Qtx (ORCPT + 28 others); Thu, 30 Nov 2017 11:49:53 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:40975 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753643AbdK3QrS (ORCPT ); Thu, 30 Nov 2017 11:47:18 -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 vAUGiJ7m017787; Thu, 30 Nov 2017 17:47: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 2ef09hkt55-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 30 Nov 2017 17:47: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 5A8A034; Thu, 30 Nov 2017 16:47: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 34FAA537A; Thu, 30 Nov 2017 16:47:16 +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, 30 Nov 2017 17:47:15 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v2 07/16] remoteproc: st: add reserved memory support Date: Thu, 30 Nov 2017 17:46:42 +0100 Message-ID: <1512060411-729-8-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512060411-729-1-git-send-email-loic.pallardy@st.com> References: <1512060411-729-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG3NODE2.st.com (10.75.127.8) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-30_05:, , 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. Memory region release is handled by ST driver itself on remove operation. Signed-off-by: Loic Pallardy --- drivers/remoteproc/st_remoteproc.c | 43 +++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 8 deletions(-) -- 1.9.1 diff --git a/drivers/remoteproc/st_remoteproc.c b/drivers/remoteproc/st_remoteproc.c index aacef0e..1549ce8 100644 --- a/drivers/remoteproc/st_remoteproc.c +++ b/drivers/remoteproc/st_remoteproc.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -208,8 +209,10 @@ static int st_rproc_parse_dt(struct platform_device *pdev) struct device *dev = &pdev->dev; struct rproc *rproc = platform_get_drvdata(pdev); struct st_rproc *ddata = rproc->priv; - struct device_node *np = dev->of_node; - int err; + struct device_node *node, *np = dev->of_node; + struct resource res; + struct rproc_mem_entry *mem; + int err, count, i; if (ddata->config->sw_reset) { ddata->sw_reset = devm_reset_control_get_exclusive(dev, @@ -254,10 +257,36 @@ 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; + count = of_count_phandle_with_args(np, "memory-region", NULL); + + for (i = 0; i < count; i++) { + node = of_parse_phandle(np, "memory-region", i); + if (!node) { + dev_err(dev, "No memory-region specified\n"); + return -EINVAL; + } + + err = of_address_to_resource(node, 0, &res); + if (err) { + dev_err(dev, "Bad memory-region definition\n"); + return err; + } + + mem = devm_kzalloc(dev, sizeof(*mem), GFP_KERNEL); + if (!mem) + return -ENOMEM; + + mem->dma = res.start; + mem->da = res.start; + mem->len = resource_size(&res); + mem->va = devm_ioremap_wc(dev, mem->dma, mem->len); + if (!mem->va) { + dev_err(dev, "Unable to map memory region: %pa+%zx\n", + &res.start, mem->len); + return -EBUSY; + } + + rproc_add_carveout(rproc, mem); } err = clk_prepare(ddata->clk); @@ -387,8 +416,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]); From patchwork Thu Nov 30 16:46:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 120248 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp24112qgn; Thu, 30 Nov 2017 08:49:41 -0800 (PST) X-Google-Smtp-Source: AGs4zMaaNV9jul/U+d5GlrBxKTuh1w6M7YYhdd6GMbm57eVRpRXBpE2R74SqWKMgQ2O6DZIMb5wF X-Received: by 10.159.254.19 with SMTP id r19mr3139380pls.271.1512060581465; Thu, 30 Nov 2017 08:49:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512060581; cv=none; d=google.com; s=arc-20160816; b=TlIZagClvy9W0iJwOzDkLWgmzHjPC5uUHH9inPuudG2ZMwgkKxBNd854uMjknUnY2c Cmts0UYaT4det4nADJfaeHqX8dly25TMCigLfe6//pMvcn+U8VWTdg5J4AN36AyIgwat VdpSRN8O71qIHczuKChwno97kLkpQ0NZ1jK6C/Tfc0xvs90TUiJWCvyNtn+4rhO92zoH RsM+pjhTvhswgRq7PyNNvPqqI/yycv5qvW6pWpqLqMaJ6CkEN39gLIvQPLlv85MonVbL 28MR9NgN3JRKFxvc0RGda4e0nEcOmTeQHawWLqTwNCbZqrqoNPUoN0nYxhS3sKiB3QBi 17qw== 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=fchbx1KjzorG4odxpMxrCOoy2aJwRMqSeubL5eNcz6M=; b=RWyUrQppMS770mbM9RgiDcQqcO+yr9yN8547SYDcvXDTqbMUL1aEruxjGsDjFJUpLf PXtqpajOhtOEqPGTTG7kWghWSpJBy/GcL7teUVtvA7F7kbIev99+zYxDC5XgbV/u5lWM 2o0fMAwPu0OcJt3VDa9SsZkg3XRoOjGEvFhqrDcWi74i3IXmosDV+birmKGrHfyGarrz EvjkQyJgkh/CJzZcANTAmZ0ss4ODwvWSjZs4D0o30VD2cCc9pVmH49LhmsZocLqsEH25 n3Yok0mpUAkQ6rX/IgnlmJ614GhKp+sqos06pU1rQ6EHYISMe+DOoBTzpFYyqMA61ndq OG8g== 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 l6si924819pgq.358.2017.11.30.08.49.41; Thu, 30 Nov 2017 08:49:41 -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 S1753714AbdK3Qti (ORCPT + 28 others); Thu, 30 Nov 2017 11:49:38 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:57880 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753762AbdK3QrT (ORCPT ); Thu, 30 Nov 2017 11:47: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 vAUGiEpd001563; Thu, 30 Nov 2017 17:47: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 2eexh9v2ru-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 30 Nov 2017 17:47: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 1A17B3D; Thu, 30 Nov 2017 16:47: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 F34F3537B; Thu, 30 Nov 2017 16:47:16 +0000 (GMT) Received: from localhost (10.75.127.50) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 30 Nov 2017 17:47:16 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v2 08/16] remoteproc: add name in rproc_mem_entry struct Date: Thu, 30 Nov 2017 17:46:43 +0100 Message-ID: <1512060411-729-9-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512060411-729-1-git-send-email-loic.pallardy@st.com> References: <1512060411-729-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.50] 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=2017-11-30_05:, , 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 struc 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 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index bdc99cd..cc53247 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -835,6 +835,7 @@ static int rproc_handle_carveout(struct rproc *rproc, carveout->da = rsc->da; carveout->release = rproc_release_carveout; carveout->priv = (void *)CARVEOUT_RSC_ALLOCATED; + strncpy(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 5bd5175..66e6863 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 { @@ -324,6 +325,7 @@ struct rproc_mem_entry { u32 da; int (*release)(struct rproc *rproc, struct rproc_mem_entry *mem); void *priv; + char name[32]; struct list_head node; }; From patchwork Thu Nov 30 16:46:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 120247 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp23813qgn; Thu, 30 Nov 2017 08:49:24 -0800 (PST) X-Google-Smtp-Source: AGs4zMYP0pg50cxrFlB3mMjdR/oKzbbuk0PVGAiQ+MRNKae5VDEk6+kGJC7UHFioN9laUctBmN5S X-Received: by 10.99.97.78 with SMTP id v75mr2950988pgb.60.1512060564614; Thu, 30 Nov 2017 08:49:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512060564; cv=none; d=google.com; s=arc-20160816; b=HxwYe7zqici9M9BPcmyX7ukOXYmgd05ZEDkSYoSje15W7o2CerI0fncyi6XZ54kOCV LDzQOw0lBTy8lwxkIce4VgxNBfBsgmqCkyV0jomR7/miLvQJ3g3KCVoVWN3WLNtL2a3D hoehHA2WtfzT5L5Xf5UwMsFwvBxEmhpWPZ16uEgML+v+5YElqhKp70YnrEMhBKlQeVie BHWq6GnA3eOBGUykiT/WOkjX14rXLrdTNnZgmgyuc9ypOWomecLQJ6oCuTcxHBZPnV3R NZKqo/+vbE89vCIwDZlWbxsrzsWMCbcCZfD17q8B51c8EzI0Im41naIx1Qyxr5imA+Ks 9Ibw== 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=uQd9qz5UoWXth8nFFMzUnzE4icdOnfkkdNQRg1M1Uys=; b=k2k+CknDe4+wpB5kWHxNlkTNzeQe9mHWF7synDAVRsRLYj04wgi3mTUjLd9YQ3rzS3 PTgaSsdk+GfUxiaTOiidX2u1yL9fLN1UVBFEvXp/M4qIMnYiy5dHmzhgl2XjP31/O7tp 23kkTzNubMK2FOFvgLxoiHzX/P0tBs69usFPmqiUJYWJ7IcDSbMoU7Ov+uzzffBl54fQ UcaouhYu+YQ762u/tbf/rGXqbTVHnvtD+2l57MGv5DqsOj7mFllcploKmX7xruSMvDoY tDr/ZoNxSRs35cdjRC0rxoRapQBRKFpnmGo1efyYUGQ2kukgwXNYDfZ7uzYEzzWRcXbM KvSg== 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 t3si3237393pgf.710.2017.11.30.08.49.24; Thu, 30 Nov 2017 08:49:24 -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 S1753681AbdK3QtV (ORCPT + 28 others); Thu, 30 Nov 2017 11:49:21 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:40986 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753489AbdK3QrU (ORCPT ); Thu, 30 Nov 2017 11:47:20 -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 vAUGiRAP017805; Thu, 30 Nov 2017 17:47: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 2ef09hkt59-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 30 Nov 2017 17:47: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 DD3E338; Thu, 30 Nov 2017 16:47: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 C1991537A; Thu, 30 Nov 2017 16:47:17 +0000 (GMT) Received: from localhost (10.75.127.47) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 30 Nov 2017 17:47:17 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v2 09/16] remoteproc: add memory device management support Date: Thu, 30 Nov 2017 17:46:44 +0100 Message-ID: <1512060411-729-10-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512060411-729-1-git-send-email-loic.pallardy@st.com> References: <1512060411-729-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] 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=2017-11-30_05:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch add functions to create and delete some remoteproc sub-devices with dedicated dma coherent region. These "memory devices" are identified by their name and will be used for carveout, vring, buffers allocation in specific memory region. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 134 ++++++++++++++++++++++++++++++++--- 1 file changed, 123 insertions(+), 11 deletions(-) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index cc53247..76d54bf 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -69,6 +69,127 @@ static const char *rproc_crash_to_string(enum rproc_crash_type type) return "unknown"; } +static phys_addr_t rproc_va_to_pa(void *cpu_addr) +{ + 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); +} + +struct rproc_memdev { + struct device dev; + struct rproc *rproc; + struct rproc_mem_entry *mem; +}; + +#define to_memdevice(d) container_of(d, struct rproc_memdev, dev) + +/** + * rproc_memdev_release() - release the existence of a memdevice + * + * @dev: the subdevice's dev + */ +static void rproc_memdev_release(struct device *dev) +{ + struct rproc_memdev *memd = to_memdevice(dev); + + kfree(memd); +} + +/** + * rproc_memdev_add() - add a memory-device on remote processor + * + * @rproc: the parent remote processor + * @mem: memory resource entry allow to define the dma coherent memory of memory-device + * + * This function add a memory-device child on rproc parent. This memory-device allow + * to define a new dma coherent memory area. When the rproc would alloc a + * dma coherent memory it's find the memory-device that match with physical memory + * asked (if there is no children that match, the rproc is the default device) + * + * Returns the memory-device handle on success, and error on failure. + */ +static struct rproc_memdev *rproc_memdev_add(struct rproc *rproc, + struct rproc_mem_entry *mem) +{ + struct rproc_memdev *memd; + int ret; + + if (!mem || strlen(mem->name) == 0) { + ret = -EINVAL; + goto err; + } + + memd = kzalloc(sizeof(*memd), GFP_KERNEL); + if (!memd) { + ret = -ENOMEM; + goto err; + } + + memd->rproc = rproc; + memd->mem = mem; + memd->dev.parent = rproc->dev.parent; + memd->dev.release = rproc_memdev_release; + dev_set_name(&memd->dev, "%s#%s", dev_name(memd->dev.parent), mem->name); + dev_set_drvdata(&memd->dev, memd); + + ret = device_register(&memd->dev); + if (ret) + goto err_dev; + + ret = dmam_declare_coherent_memory(&memd->dev, + rproc_va_to_pa(mem->va), mem->da, + mem->len, + DMA_MEMORY_EXCLUSIVE); + if (ret < 0) + goto err_dev; + + return memd; + +err_dev: + put_device(&memd->dev); +err: + dev_err(&rproc->dev, "unable to register subdev %s, err = %d\n", + (mem && strlen(mem->name)) ? mem->name : "unnamed", ret); + return ERR_PTR(ret); +} + +/** + * rproc_memdev_del() - delete a memory-device of remote processor + * + * @memdev: rproc memory-device + */ +static void rproc_memdev_del(struct rproc_memdev *memdev) +{ + if (get_device(&memdev->dev)) { + device_unregister(&memdev->dev); + put_device(&memdev->dev); + } +} + +/** + * rproc_memdev_unregister() - unregister memory-device of remote processor + * + * @dev: rproc memory-device + * @data: Not use (just to be compliant with device_for_each_child) + * + * This function is called by device_for_each_child function when unregister + * remote processor. + */ +static int rproc_memdev_unregister(struct device *dev, void *data) +{ + struct rproc_memdev *memd = to_memdevice(dev); + struct rproc *rproc = data; + + if (dev != &rproc->dev) + rproc_memdev_del(memd); + return 0; +} + /* * This is the IOMMU fault handler we register with the IOMMU API * (when relevant; not all remote processors access memory through @@ -139,17 +260,6 @@ static void rproc_disable_iommu(struct rproc *rproc) iommu_domain_free(domain); } -static phys_addr_t rproc_va_to_pa(void *cpu_addr) -{ - 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 @@ -1678,6 +1788,8 @@ int rproc_del(struct rproc *rproc) rproc_delete_debug_dir(rproc); + device_for_each_child(rproc->dev.parent, rproc, + rproc_memdev_unregister); /* the rproc is downref'ed as soon as it's removed from the klist */ mutex_lock(&rproc_list_mutex); list_del(&rproc->node); From patchwork Thu Nov 30 16:46:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 120246 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp23526qgn; Thu, 30 Nov 2017 08:49:07 -0800 (PST) X-Google-Smtp-Source: AGs4zMZF+ljUz5qATGBJGjTha78/APKrL+pANxi4PS+RYVhLkJUpe3cx0wGAlvce2XddE7CiCP2Y X-Received: by 10.99.190.72 with SMTP id g8mr2941348pgo.170.1512060547053; Thu, 30 Nov 2017 08:49:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512060547; cv=none; d=google.com; s=arc-20160816; b=Jc51dWGnf8qWqwpk9UjytBVUedxfIEdMZ536Wg0KqiTnelHdaycJYTuP6q0Exu0bj8 KZM+vRbmgPbD9CcCtzGhJH0M9CrBU2FMvHrYTR8UNRZ5yaWry3ElSCyfZ3S49BGuwPtT iKvWtSaGXDTNgs4T9CMqZseOfcpsMU1x9cyDLOEtW/1hmMyD/qBTCOzQjmWJ+0RGSn7T nMZEJlos5s1nqUqeNpWZeT8AlKYQi3ZECXKlChkjxujhgj6fhRWvHHzuMF2bNh2NbsZL eWOT6GvLx8ZINnr+YvWD6CR/LdkADLZGHYXzZSscMbCmFSG2LhKig7BVoPT0oCI+85r2 lr5g== 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=RKZcI9rHVcJ7ruyYvJojoAWTbDLqLY99JVwkjK+yoho=; b=eLpmB4c69T66BVCI+dMZcv0JhRLON2tQw7T3/GkBldBpOrqwkOSAywuP3T2YG+K4ce vUy/6ziVooyx3o6BkT+33zt0bRrgj7rAef5gl/kXiTD+pWN2NY29be9X0h9mNf09wtbR RgmbQLSew6iaUEtSep9kYbicW1GsJgOnTNjzCNSA5O6N4zMh8rpZLrkm03fDNEIUyQyN AvO31vm6ULFiMVvpJDIwnXqwYQ2rpbfefZ0oiEIACmpHZfUJXcnfjyK2+lK70clEYEEk hbmD7FOFPaizKadZig8PGbPhbwF/j43Ev8PbKmQE05IVp849S65soFGYegrQ3b3bRpd/ 9oZw== 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 n8si3427415pll.619.2017.11.30.08.49.06; Thu, 30 Nov 2017 08:49:07 -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 S1753626AbdK3QtG (ORCPT + 28 others); Thu, 30 Nov 2017 11:49:06 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:35506 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753769AbdK3QrU (ORCPT ); Thu, 30 Nov 2017 11:47: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 vAUGiHCQ001569; Thu, 30 Nov 2017 17:47:19 +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 2eexh9v2s0-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 30 Nov 2017 17:47: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 964A131; Thu, 30 Nov 2017 16:47: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 76BC3537A; Thu, 30 Nov 2017 16:47:18 +0000 (GMT) Received: from localhost (10.75.127.47) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 30 Nov 2017 17:47:18 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v2 10/16] remoteproc: add memory device registering in rproc_add_carveout Date: Thu, 30 Nov 2017 17:46:45 +0100 Message-ID: <1512060411-729-11-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512060411-729-1-git-send-email-loic.pallardy@st.com> References: <1512060411-729-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] 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=2017-11-30_05:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the possibility to associate a memory device to carveout. Due to some memory mapping constraints, remoteproc related memory allocations should be done in a specific memory region. Constraint is not coming from remoteproc firmware (with defined device address), but from remoteproc platform driver itself. In that case, platform driver has to register a carveout region with memory device. Memory device will be used for carveout, vring or buffer allocation accorfing to its name. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 14 +++++++++++++- drivers/remoteproc/st_remoteproc.c | 2 +- include/linux/remoteproc.h | 3 ++- 3 files changed, 16 insertions(+), 3 deletions(-) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 76d54bf..2b7effb 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -964,17 +964,29 @@ static int rproc_handle_carveout(struct rproc *rproc, * rproc_add_carveout() - register an allocated carveout region * @rproc: rproc handle * @mem: memory entry to register + * @memdev: true if carveout shoult be associated to a memory device * * This function registers specified memory entry in @rproc carveouts list. * Specified carveout should have been allocated before registering. */ -int rproc_add_carveout(struct rproc *rproc, struct rproc_mem_entry *mem) +int rproc_add_carveout(struct rproc *rproc, struct rproc_mem_entry *mem, bool memdev) { + struct rproc_memdev *memd; + if (!rproc || !mem) return -EINVAL; mem->priv = (void *)CARVEOUT_EXTERNAL; + if (memdev) { + memd = rproc_memdev_add(rproc, mem); + if (IS_ERR(memd)) + return -ENOMEM; + mem->memdev = memd; + } else { + mem->memdev = NULL; + } + list_add_tail(&mem->node, &rproc->carveouts); return 0; diff --git a/drivers/remoteproc/st_remoteproc.c b/drivers/remoteproc/st_remoteproc.c index 1549ce8..da42ec9 100644 --- a/drivers/remoteproc/st_remoteproc.c +++ b/drivers/remoteproc/st_remoteproc.c @@ -286,7 +286,7 @@ static int st_rproc_parse_dt(struct platform_device *pdev) return -EBUSY; } - rproc_add_carveout(rproc, mem); + rproc_add_carveout(rproc, mem, false); } err = clk_prepare(ddata->clk); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 66e6863..d7e7485 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -325,6 +325,7 @@ struct rproc_mem_entry { u32 da; int (*release)(struct rproc *rproc, struct rproc_mem_entry *mem); void *priv; + struct rproc_memdev *memdev; char name[32]; struct list_head node; }; @@ -524,7 +525,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, int rproc_del(struct rproc *rproc); void rproc_free(struct rproc *rproc); -int rproc_add_carveout(struct rproc *rproc, struct rproc_mem_entry *mem); +int rproc_add_carveout(struct rproc *rproc, struct rproc_mem_entry *mem, bool memdev); int rproc_boot(struct rproc *rproc); void rproc_shutdown(struct rproc *rproc); From patchwork Thu Nov 30 16:46:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 120240 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp21763qgn; Thu, 30 Nov 2017 08:47:30 -0800 (PST) X-Google-Smtp-Source: AGs4zMaMdLIvWBL1wcVVtsqb4OT1yKBs0Efrv0VdXNCngX/1616nAiskWxzQRjZFO51fifSf+Whj X-Received: by 10.98.245.68 with SMTP id n65mr7240437pfh.113.1512060450718; Thu, 30 Nov 2017 08:47:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512060450; cv=none; d=google.com; s=arc-20160816; b=BDKf4RxnIBPVboCf3nAkhgKbEk7x8OAt7TGuj5OkZk0Ht9c5UMywg67pLKDDzIf1Yq W5zDJMnsyLStmPPwAC/H3Y7/B8Bo8UeUV+r8ykXVY+tueKveeJAzwqR/46rx1x07JnNS pBDYFAShNSOcs93JrnIOKP8GT/cQ14cJDLfCcXsn/j0jLdt560bbpCfxJdpcsNeDQif5 OL47ZYzRHBeW6lk+35rz0xGEvm6ImUrs+x41loVaVQ1BEjxl5NWp0Z4SjAI3UsIomGSW Nl/0kpLoDUCZG6L6Fg7LfLWrGKngM+sHG0WA+oe4x9EzY+fPrQkoqxoB1G7OVf0/+aA1 w8bw== 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=QHFWNJgin0uiwINiDmNHkFBjm3eRIXF5q03YmYwazCg=; b=QCXJnqQGMMCGhelyXQjwbBTtqsHtudA7laGPuwaWXOSnO+pKB8IhfySCM+BNnxjgux N9dwXHpV05xkCyPVfulobFDUXxqKNdHWjMB71CHetDCi2iwp6O5cI+z0sJQOGlq2K8lY 1QTILxd6mxZJUXAYoCf9nAXLwB+V3QrQzig1BaBVDchbMUH1W+/r1ti7f0OzMQhK2ylY 5atG+8B0BQ/5hsYSOUf5lJSPl61cxVAPnKhVqg07dzBKaXgh2VK2fmO6/lGjmRqCyAL9 FMttBCe0AUb4+0N44Eq/Zf+5MDmCFCVCX+9reLBVfgWWYtZty0TFtA+kBJy9n6GMd+kP +yjg== 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 q14si3194300pgv.770.2017.11.30.08.47.30; Thu, 30 Nov 2017 08:47:30 -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 S1753826AbdK3Qr1 (ORCPT + 28 others); Thu, 30 Nov 2017 11:47:27 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:40996 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753774AbdK3QrV (ORCPT ); Thu, 30 Nov 2017 11:47:21 -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 vAUGiJ7o017787; Thu, 30 Nov 2017 17:47: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 2ef09hkt5d-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 30 Nov 2017 17:47: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 690BB34; Thu, 30 Nov 2017 16:47: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 51443537A; Thu, 30 Nov 2017 16:47:19 +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, 30 Nov 2017 17:47:18 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v2 11/16] remoteproc: introduce rproc_find_carveout_by_name function Date: Thu, 30 Nov 2017 17:46:46 +0100 Message-ID: <1512060411-729-12-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512060411-729-1-git-send-email-loic.pallardy@st.com> References: <1512060411-729-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.49] 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=2017-11-30_05:, , 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 point on the corresponding carveout. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 2b7effb..8d990b1 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -367,6 +367,42 @@ void *rproc_find_carveout_by_da(struct rproc *rproc, u64 da, int len) return va; } +/** + * rproc_find_carveout_by_name() - lookup the carveout region by a name + * @rproc: handle of a remote processor + * @name: carveout name to find + * + * 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, char *name) +{ + struct rproc_mem_entry *carveout, *mem = NULL; + + 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 Nov 30 16:46:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 120242 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp22530qgn; Thu, 30 Nov 2017 08:48:10 -0800 (PST) X-Google-Smtp-Source: AGs4zMY7ftvxqC36cQs322T+6ObTVMtmqxoqlZSB6aMc3Veau01b+lBjiWudIxDdnwUPsp9rSEW9 X-Received: by 10.84.138.1 with SMTP id 1mr3218397plo.156.1512060489953; Thu, 30 Nov 2017 08:48:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512060489; cv=none; d=google.com; s=arc-20160816; b=tE8h9DBKjtU3UZ62RtQbw8Y07jam7Ba+03aS38rulJeK7JuikKNtAlpOmSZsGfugpV kTaE2lB7gIuvDcaxHDN88lHVCi/v05LrYXcytTt91AbyvNiZ9FjZSmMK+jSpe/EniyGd a/+klkD7PTD1/VM2kI41I3I6pFZFMh2ZGsVs3Nnq0Rivy/nMhFHz0L3QqZ7uk0UFdzMZ FO/Hin4peh4iyDYk6iudteUqtHKq8t/74e+wUSzpJ3hyjoC9DMGlOI/swKUfG78HjDks Uzi/uhZtAfRhDHxQF5GvVf0rwzWYIDE/WhwS8TD+zdkZ366Gp7djt674LPJxZ/8Jme2G BWTg== 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=gI0IxMsjSDz8JbW3Rfir99Z8SJ27eF3nY1SsiUUtiXM=; b=J26LZXrudBy22ANNCR8Hh7tuqS+fMQHQiO3v5DGWBI/BF4UVQYscytSKRUlIz6uYs/ UN/Fz0nMficI5f/xakBVfL9i+mCGmvzxX/jm5cM0YMKhQEH08JzY2j/1IOxmVEahi9Fv Wu0K+mlqBzqJp4ALMyPlObkISqTGZM7xbGw8qvr6KweRAdlpkDUVp069O8ZB+1Dljzlp FVCt7QInvL4fAQHKX2UMbLD9HODQ3AuTF3e7VGWh9m6ncK5mb2SODOYZdNVz0aKIH82B 32Aao7q7jKuLUnQn5DD4yRiO60sbuDEa2n0avd/pFLS5vhHxk6lO5/ecIB9ObSA+eDW3 ZMdQ== 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 n18si3276098pgd.666.2017.11.30.08.48.09; Thu, 30 Nov 2017 08:48: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 S1753811AbdK3QrY (ORCPT + 28 others); Thu, 30 Nov 2017 11:47:24 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:59848 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753638AbdK3QrW (ORCPT ); Thu, 30 Nov 2017 11:47: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 vAUGiHCR001569; Thu, 30 Nov 2017 17:47: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 2eexh9v2s6-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 30 Nov 2017 17:47: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 47F3534; Thu, 30 Nov 2017 16:47: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 2B245537A; Thu, 30 Nov 2017 16:47:20 +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, 30 Nov 2017 17:47:19 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v2 12/16] remoteproc: look-up memory-device for vring allocation Date: Thu, 30 Nov 2017 17:46:47 +0100 Message-ID: <1512060411-729-13-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512060411-729-1-git-send-email-loic.pallardy@st.com> References: <1512060411-729-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.49] 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=2017-11-30_05:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch parse existing carveout list to find a memory area matching on name. Naming rule for search is the following one: - "vdevvring" to find a memory pool dedicated to one vring belonging to one specific vdev (vdev_id). - "vdevvrings> to find common memory pool for allocation of all vrings belonging to one specific vdev (vdev_id). This allows to cover different SoC requirements like allocating vrings at best location taking into account access performance in read and write for master and slave processors. If memory area found, memory device will be used as device for vring allocation, else rproc platform device will be used as today. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 25 +++++++++++++++++++++++-- include/linux/remoteproc.h | 2 ++ 2 files changed, 25 insertions(+), 2 deletions(-) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 8d990b1..6b5e2b2 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -410,8 +410,11 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) struct rproc_vring *rvring = &rvdev->vring[i]; struct fw_rsc_vdev *rsc; dma_addr_t dma = -1; + struct device *memdev = dev->parent; + struct rproc_mem_entry *carveout; void *va; int ret, size, notifyid; + char name[16]; /* actual size of vring (in bytes) */ size = PAGE_ALIGN(vring_size(rvring->len, rvring->align)); @@ -428,11 +431,27 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) return -ENOMEM; } } else { + /* Find any carveout matching vring */ + /* Try dedicated vdev j vring i pool. */ + snprintf(name, sizeof(name), "vdev%dvring%d", rvdev->index, i); + carveout = rproc_find_carveout_by_name(rproc, name); + + if (!carveout) { + /* Try dedicated vdev j vrings pool. */ + snprintf(name, sizeof(name), "vdev%dvring", rvdev->index); + carveout = rproc_find_carveout_by_name(rproc, name); + } + + if (carveout && carveout->memdev) + memdev = &carveout->memdev->dev; + + rvring->dev = memdev; + /* * 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); + va = dma_alloc_coherent(memdev, size, &dma, GFP_KERNEL); if (!va) { dev_err(dev->parent, "dma_alloc_coherent failed\n"); return -EINVAL; @@ -455,7 +474,7 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) if (ret < 0) { dev_err(dev, "idr_alloc failed: %d\n", ret); if (dma != -1) - dma_free_coherent(dev->parent, size, va, dma); + dma_free_coherent(memdev, size, va, dma); return ret; } notifyid = ret; @@ -565,6 +584,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) @@ -596,6 +616,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 d7e7485..fb293d3 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -480,6 +480,7 @@ struct rproc_subdev { * @vq: the virtqueue of this vring */ struct rproc_vring { + struct device *dev; void *va; dma_addr_t dma; int len; @@ -507,6 +508,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 Nov 30 16:46:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 120245 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp23256qgn; Thu, 30 Nov 2017 08:48:53 -0800 (PST) X-Google-Smtp-Source: AGs4zMZV7nDoTkpCTmlbCvCfCq7CyyRCeVyl/6Edsx5PaSm5j5xmF+0kMTAAiZivsWc2og/dLfcA X-Received: by 10.101.81.69 with SMTP id g5mr2974979pgq.324.1512060533002; Thu, 30 Nov 2017 08:48:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512060532; cv=none; d=google.com; s=arc-20160816; b=OIy/eAOrYtQoVFTfZ5/PKGqM2nbg47M+LAQkUZ5366+KdB+GXfozMiH8H3Q71dHKV/ eNod5gwpvLPsTZZAFeIIG0H5bQxAkXlFG2Pn9SK+vDXhHJpV2BjnoBp0c4czu4XFoAYg E0J3ZyX/JWCr2EfGl7dKV8o1DUex/v1LtPuT4IhGe40OSsfiRJlQnF16UDJpR/jVffFX 2MZLSkLHGAdAOSi7VeJ3ZTH6Z2B5Wc1vkCm8BZhEzq8xBTuFfXXT9Ugbwlsqfx3u4mLs UkUriN++7ajFNlw0J+9HlwBlBTvkVayZVdM89nk4wcXuo5Q0SlPX06E0NnTTom5DIW4o NwDg== 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=nbeu/AlQf1VF9MZsHCHaGduLHMlJzfI974Qqm8AZHNE=; b=VrVxcC3OE4zB6xyIVx4SbkiO579vgd9P3q1qpSKFjKOMHZ4EMV+L21fDUE/k5cXUxH kwAz5OkvAkHV+CiqHV+W1ZPGo4ofOgv1CECA4bYpw+gnW3B5OIEWDGEx8QOIzt83FSr0 kLGOVMGIo0eaIu3Ay0PXMm3kclQmt6xsaBX4o9VJQpd61F+oToj1grErpFE5aKga6ySr yFXvG5RLFKFx3mTCQdds65t9M42gdQeQIqRNwme687VzraFprWQBIHKc3m1XKDs7VP1z SxdrTk71E3ATep76U1Et9UoJqF16xs2hthjcxw+60M6b+YObDh/yBiH3OFENYCFYpNPp b9Fw== 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 k14si3228247pgp.518.2017.11.30.08.48.52; Thu, 30 Nov 2017 08:48:52 -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 S1753638AbdK3Qsu (ORCPT + 28 others); Thu, 30 Nov 2017 11:48:50 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:41004 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753416AbdK3QrX (ORCPT ); Thu, 30 Nov 2017 11:47:23 -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 vAUGicPV017825; Thu, 30 Nov 2017 17:47:21 +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 2ef09hkt5q-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 30 Nov 2017 17:47:21 +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 0B85131; Thu, 30 Nov 2017 16:47:21 +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 E72B05379; Thu, 30 Nov 2017 16:47:20 +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, 30 Nov 2017 17:47:20 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v2 13/16] remoteproc: look-up memory-device for virtio device allocation Date: Thu, 30 Nov 2017 17:46:48 +0100 Message-ID: <1512060411-729-14-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512060411-729-1-git-send-email-loic.pallardy@st.com> References: <1512060411-729-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=2017-11-30_05:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch parse existing carveout list to find a memory area matching on "vdevbuffer" name. If found, memory device will be used as parent for vdev creation, else rproc platform device will be used as today. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 13 +++++++++++++ drivers/remoteproc/remoteproc_virtio.c | 2 +- include/linux/remoteproc.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 6b5e2b2..9c12319 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -583,8 +583,11 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, { struct device *dev = &rproc->dev; struct rproc_vdev *rvdev; + struct device *memdev = dev->parent; + 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) @@ -637,6 +640,16 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, list_add_tail(&rvdev->node, &rproc->rvdevs); + /* Find associated registered carveout. */ + /* Try dedicated vdev buffer pool. */ + snprintf(name, sizeof(name), "vdev%dbuffer", rvdev->index); + carveout = rproc_find_carveout_by_name(rproc, name); + + if (carveout && carveout->memdev) + memdev = &carveout->memdev->dev; + + rvdev->dev = memdev; + rproc_add_subdev(rproc, &rvdev->subdev, rproc_vdev_do_probe, rproc_vdev_do_remove); diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index 2946348..1f7a444 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 fb293d3..b3d6656 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -506,6 +506,7 @@ struct rproc_vdev { struct kref refcount; struct rproc_subdev subdev; + struct device *dev; unsigned int id; unsigned int index; From patchwork Thu Nov 30 16:46:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 120244 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp23006qgn; Thu, 30 Nov 2017 08:48:37 -0800 (PST) X-Google-Smtp-Source: AGs4zMaIcNPSsrNLPYZk7f/7zc97K1sOK02f/Z+se4Ww+icji/vczYkJehVZSVlOrDwIkPOZ2ZqR X-Received: by 10.84.248.148 with SMTP id q20mr3320224pll.110.1512060517098; Thu, 30 Nov 2017 08:48:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512060517; cv=none; d=google.com; s=arc-20160816; b=mjxrzxPXoTtephbiTFxhClJkWqRxR+r4d0/Q4Z8Kl+wTHQhMHy5dek1VoK6l3MWA/S Jr4ETHJl4Q1DZWIhCjh/hlLbWoQlilDvohcyrKuftY/j6RU0hBHt1PWpg0mqQkep+/IX zzrMlzEar2kOGUCe5+xcq41LSXKeXZeHV9UR79rdJcauUYJ4dkw3trnkaMsXTtOpKIah pOcTRhJXRXhXERVSYuct7bIEEapfZZ6Ixl7AWvBlaknHsnNslqeXaRiYw4sH/AprHNW7 VBfuuu2YOnX1R1IPdwlMviD0X/n7TqMYH8UZZbuIfIA14rBoAAbni5ea6Ahvk0XpK/xF E/eg== 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=7mc6C/YT71dJnllfNBdE1bnwtkxLKqah2RqySk7dg5w=; b=kb0oFSnVTOPW+qLycUKfI6/xbrecFrayXCYATjBonp0+aCbZfQdasdY8DD+orSqM4Q n6peS7EKrcbf9NI9M7caNrVOIitEVhJVZ2VigajRFX7I9xIgcZa8pw81rqm4M8b/yAQs FtudMLTL64WWR8Muks3lHGyHomwuWPqLMYUejglOpckPNygnDhB0Cx7n1fXQrvXXdhS6 F63pUcRlWeNxmiuUhZfwPpuAApeSGjAKpipEWQ8WzZdPqXi7e+vhXKxtKcZDq3M8By5O 3L9rmxb3IHCp1FCqBolaTpxK7Ji6KpZZCV0bfClh6fTQTJql/U54yM1Qp05apWvswra3 gZPA== 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 k14si3228247pgp.518.2017.11.30.08.48.36; Thu, 30 Nov 2017 08:48:37 -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 S1753623AbdK3Qsf (ORCPT + 28 others); Thu, 30 Nov 2017 11:48:35 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:41006 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753789AbdK3QrY (ORCPT ); Thu, 30 Nov 2017 11:47:24 -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 vAUGiJ7s017787; Thu, 30 Nov 2017 17:47:22 +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 2ef09hkt5s-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 30 Nov 2017 17:47:22 +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 C48CA34; Thu, 30 Nov 2017 16:47:21 +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 B12EE537A; Thu, 30 Nov 2017 16:47:21 +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, 30 Nov 2017 17:47:21 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v2 14/16] remoteproc: look-up pre-registered carveout by name for carveout allocation Date: Thu, 30 Nov 2017 17:46:49 +0100 Message-ID: <1512060411-729-15-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512060411-729-1-git-send-email-loic.pallardy@st.com> References: <1512060411-729-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG3NODE3.st.com (10.75.127.9) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-30_05:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Look-up for a pre-registred carveout having the same name as requested one. If match found, pre-registed carevout is used and resource table updated. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 9c12319..8436185 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -873,7 +873,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, *mem; struct device *dev = &rproc->dev; dma_addr_t dma; phys_addr_t pa; @@ -899,6 +899,7 @@ static int rproc_handle_carveout(struct rproc *rproc, return -ENOMEM; /* Check carveout rsc already part of a registered carveout */ + /* By device address if any */ if (rsc->da != FW_RSC_ADDR_ANY) { va = rproc_find_carveout_by_da(rproc, rsc->da, rsc->len); @@ -933,6 +934,20 @@ static int rproc_handle_carveout(struct rproc *rproc, } } + /* By name */ + mem = rproc_find_carveout_by_name(rproc, rsc->name); + if (mem) { + /* + * Update resource table with registered carevout information + */ + rsc->len = mem->len; + rsc->da = mem->da; + rsc->pa = rproc_va_to_pa(mem->va); + /* no need to register as already match one for one */ + 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, From patchwork Thu Nov 30 16:46:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 120243 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp22576qgn; Thu, 30 Nov 2017 08:48:12 -0800 (PST) X-Google-Smtp-Source: AGs4zMa8F0tJa02wJWJKdz7jyOvOeliTKqSTPH4nfp/o/h0Virkt77wiKOdjefdpSi3X1TTzX8kE X-Received: by 10.99.121.74 with SMTP id u71mr3012429pgc.251.1512060492080; Thu, 30 Nov 2017 08:48:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512060492; cv=none; d=google.com; s=arc-20160816; b=C+IbXTiElvRxDs5mRmjBuulFU2b+NM/DkSV8z0VAWGUP34het5TaKtEpR4B42bYzUP 0ZLdshC4gWequURIkXRdElariWXW6pCB76vxhU3jtzRZumQ/Ii4muUHn2rVM5Psl57gw Zxg6H0oJEGYy7VtoHiI15+6a+G6PFbI57fo4S3pJ2kQVa9YPKjfZgUj8tj9NUwgrGTFH vNkeSd/RmWiW44UVJhr7P1yixLcdnJvyDJPSgk+27KPcNpI8/9XKYCaDD0/+7IBSP2UC tpEwGbGjqSpu8va3o94s5usDLMMswTHaUUPF/QoJBbu8dxiBuCXdIFVIGLPQ9hCMBOfc vczg== 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=A3QCZSlB67/VXK54VizyvU2BU6IfgUxN49lTWuJMo9I=; b=ZD3znpEnW79pOonkH40WomnYLXhID2P8mCotRI3qQPxZV87wj7s+NoLCbZ5fsNYgMq erjDTAYIAT5tVr1OrKpWGQmYKfiwdsEuKlJnb/T/smO+4cyHfMxjO5fM7YGn/lQB+dYJ vsHdvaPGAXRD6LmVhmKYDyX9hKg+m08R4vg/bWtuBhTw7OeZ+wdL1iEQacHlQYlwkZV2 pKeypSWke0JR4DAGElVmBq6kfFLvLv+v4wCcSozNbOrOqfuNrhKlmI9b6IhqsvmVz7xS m5OP60VfairLeOhBeRnceB/zsOnKvwLYS5WJDRDXWs2bi/aqW5i/KoHklWgP0AD1gt9/ ChaA== 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 n18si3276098pgd.666.2017.11.30.08.48.11; Thu, 30 Nov 2017 08:48:12 -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 S1753593AbdK3QsK (ORCPT + 28 others); Thu, 30 Nov 2017 11:48:10 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:58265 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753795AbdK3QrY (ORCPT ); Thu, 30 Nov 2017 11:47:24 -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 vAUGiHCT001569; Thu, 30 Nov 2017 17:47:23 +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 2eexh9v2se-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 30 Nov 2017 17:47:23 +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 8F1F538; Thu, 30 Nov 2017 16:47:22 +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 6F989537A; Thu, 30 Nov 2017 16:47:22 +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, 30 Nov 2017 17:47:22 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v2 15/16] remoteproc: st: associate memory device to memory regions Date: Thu, 30 Nov 2017 17:46:50 +0100 Message-ID: <1512060411-729-16-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512060411-729-1-git-send-email-loic.pallardy@st.com> References: <1512060411-729-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=2017-11-30_05:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Enable memory device creation for each memory region added by rproc_add_carveout function. Signed-off-by: Loic Pallardy --- drivers/remoteproc/st_remoteproc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/remoteproc/st_remoteproc.c b/drivers/remoteproc/st_remoteproc.c index da42ec9..bf83d82 100644 --- a/drivers/remoteproc/st_remoteproc.c +++ b/drivers/remoteproc/st_remoteproc.c @@ -279,6 +279,7 @@ static int st_rproc_parse_dt(struct platform_device *pdev) mem->dma = res.start; mem->da = res.start; mem->len = resource_size(&res); + strncpy(mem->name, node->name, sizeof(mem->name)); mem->va = devm_ioremap_wc(dev, mem->dma, mem->len); if (!mem->va) { dev_err(dev, "Unable to map memory region: %pa+%zx\n", @@ -286,7 +287,7 @@ static int st_rproc_parse_dt(struct platform_device *pdev) return -EBUSY; } - rproc_add_carveout(rproc, mem, false); + rproc_add_carveout(rproc, mem, true); } err = clk_prepare(ddata->clk); From patchwork Thu Nov 30 16:46:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 120241 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp22265qgn; Thu, 30 Nov 2017 08:47:56 -0800 (PST) X-Google-Smtp-Source: AGs4zMZNxb6FtK+ZHto3Dyt/LfEm1CCRazidmbWxwL7uPfgv7BSx23oFj74MZ+XtZoHJF06pJ/xN X-Received: by 10.99.147.77 with SMTP id w13mr2892369pgm.401.1512060476504; Thu, 30 Nov 2017 08:47:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512060476; cv=none; d=google.com; s=arc-20160816; b=wDp/QbEAJ6NopodFhOkkAZEWdBep0BGD60cpK9pVyNILxxUDee/EEKhjYx7YYhDelv IfR9KMfIioS0zHu/dHPgA9LMEBiL+Zmit6GadkLISQ550/n7Z3lQcYfyHB7l9CT6LEFh MVEp29jGTSOT6r3IHHpFXtaUfVhEmZDzIdCJT7ULXY2lpSMRfAcbuMltOuQ38CE1lTm2 njCwGDu1B3btdGVf5pt+yNhiyWn5h4bHRdrU6UfegwGp+uhrAa5W+z1+uSSG3BO434av MFIydFnD6rPNPX0WBF8+5luQWVdTgPhJnEM45UDxVsRyD3H5TzPRbh1uP+9Gmuo+sXEO lLIw== 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=y8HM7tcR8IGCtc+287mCDvzkRChEBuw83RblY2yWTN7wVoVdYzPMVcYCoP3x1Ix9c4 dw2T5+hDVQFvs7OCcISAy46rW/lZKxVlWfaJnBeLJ69AtoThAkq3t4owHqU5d+Z528Yt bqRnIwWbfeerqDOOGPXkotAu3Ax2RbOm0C3+X0Q7yOEEiW/iRE3WgTt10vYJbu+hafp2 zVuyVPvommIvlM7TnQAzA6p52kyQ0vG4BHS9fwVu4ScF9XY4hnafigIRWxUjZi5Dk/09 DifKZUhGldIrKv5q0QRsHyjOl+Phuhsqh+AL52G1Tk9iPOJNIchDo21YNWvlu01S6bwV ft1w== 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 y8si3302954pge.144.2017.11.30.08.47.56; Thu, 30 Nov 2017 08:47:56 -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 S1753486AbdK3Qrz (ORCPT + 28 others); Thu, 30 Nov 2017 11:47:55 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:61755 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753638AbdK3QrZ (ORCPT ); Thu, 30 Nov 2017 11:47:25 -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 vAUGhuap014355; Thu, 30 Nov 2017 17:47:23 +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 2ehn3n8xga-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 30 Nov 2017 17:47:23 +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 4CA8A34; Thu, 30 Nov 2017 16:47:23 +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 37EDE5379; Thu, 30 Nov 2017 16:47:23 +0000 (GMT) Received: from localhost (10.75.127.46) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 30 Nov 2017 17:47:22 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v2 16/16] rpmsg: virtio: allocate buffer from parent Date: Thu, 30 Nov 2017 17:46:51 +0100 Message-ID: <1512060411-729-17-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512060411-729-1-git-send-email-loic.pallardy@st.com> References: <1512060411-729-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] 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=2017-11-30_05:, , 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) {