From patchwork Thu Mar 1 16:23:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 130322 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3004283edc; Thu, 1 Mar 2018 08:24:26 -0800 (PST) X-Google-Smtp-Source: AG47ELszz83s9qCsbActStaS45lmu57o+T2/UmTwIev9XPLiFSC6eM1RuYbaX4hUxvD2VD2iERHN X-Received: by 2002:a17:902:52ca:: with SMTP id a68-v6mr2409190pli.179.1519921466434; Thu, 01 Mar 2018 08:24:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519921466; cv=none; d=google.com; s=arc-20160816; b=0EcE4lRcHEx32DT+5aI/I6EF6eOpY4Mo09tNYGG8UICGBh7yvFR6aMKLghkKf7ff6N n4jvsU/fvq14bxuX+iBzzpCRv1Q6PO1od5SjOUge1WsRuKbYVPLaRFnuSeWaGXV21P1e ivHpoOW21dDH+1OXlHpBR/lPw0A9rj2yPpsgu5DN36RpTx7EHFv9D/5Nfm+goU1q48nq USP/Eq/ST0FEJKT6IAhvhhPHOH9ZpkHep2H4vZ/6m3WuuWjFhsXGsviPxh7vFenZZxBQ slTHGXijOL3ZW0VosGrKivyDIV+DY0aMQJsrxK9JMol7vkgp3k6NIujP92MttxNVsCwL ODxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=T2pZ4ttMqucA4V9EFK25gU0CoP72kvbF1L4Fbyhn9ho=; b=JcLLBLqKRMunPOhcZhBldXz763wVvWIJiIcuETSjEBj8DPX2GWWMyYjOdf3EGjyehp tA7GN7Y3kuePYEZhlg52RO5s236Lf0LGQ1q52MD67uK3KJMUhFziUhiEjqVe8McO4Uo+ EGR4lO+p5HZXcB6+X6wp+66xUv0L8WXnY4XTgOVTi/fhDscYA/fmbumqycOaQgezX6ok L1NPuogD5mev/oboj/nKDbY0smRrTXywwoV0rVpDHuIiGhLv+5uIyQzNG/LgySKWRRov 0uDvSjYITERvxM01eFjIv3SkXHtT13KQOyum2dvG/D8OZg6hjpggb9BpPE8g/G4Sh9uy VgPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x2-v6si3206173plv.672.2018.03.01.08.24.26; Thu, 01 Mar 2018 08:24:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033025AbeCAQYX (ORCPT + 28 others); Thu, 1 Mar 2018 11:24:23 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:24347 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032976AbeCAQYR (ORCPT ); Thu, 1 Mar 2018 11:24:17 -0500 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w21GJFjV032289; Thu, 1 Mar 2018 17:24:16 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2gaxpwtgfp-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 01 Mar 2018 17:24:16 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8BDBE31; Thu, 1 Mar 2018 16:24:15 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag7node2.st.com [10.75.127.20]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 7975E5200; Thu, 1 Mar 2018 16:24:15 +0000 (GMT) Received: from localhost (10.75.127.44) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 1 Mar 2018 17:24:14 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v3 07/13] remoteproc: introduce rproc_find_carveout_by_name function Date: Thu, 1 Mar 2018 17:23:54 +0100 Message-ID: <1519921440-21356-8-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> References: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG4NODE2.st.com (10.75.127.11) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-01_08:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch provides a new function to find a carveout according to a name. If match found, this function returns a pointer on the corresponding carveout (rproc_mem_entry structure). Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 91aa22b..7a500cb 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -216,6 +216,49 @@ void *rproc_da_to_va(struct rproc *rproc, u64 da, int len) } EXPORT_SYMBOL(rproc_da_to_va); +/** + * rproc_find_carveout_by_name() - lookup the carveout region by a name + * @rproc: handle of a remote processor + * @name,..: carveout name to find (standard printf format) + * + * Platform driver has the capability to register some pre-allacoted carveout + * (physically contiguous memory regions) before rproc firmware loading and + * associated resource table analysis. These regions may be dedicated memory + * regions internal to the coprocessor or specified DDR region with specific + * attributes + * + * This function is a helper function with which we can go over the + * allocated carveouts and return associated region characteristics like + * coprocessor address, length or processor virtual address. + * + * The function returns a valid pointer on carveout entry on success + * or NULL on failure. + */ +struct rproc_mem_entry * +rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...) +{ + va_list args; + char _name[32]; + struct rproc_mem_entry *carveout, *mem = NULL; + + va_start(args, name); + snprintf(_name, sizeof(_name), name, args); + va_end(args); + + if (!name) + return NULL; + + list_for_each_entry(carveout, &rproc->carveouts, node) { + /* Compare carveout and requested names */ + if (!strcmp(carveout->name, name)) { + mem = carveout; + break; + } + } + + return mem; +} + int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) { struct rproc *rproc = rvdev->rproc;