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);