Received: by 10.223.185.116 with SMTP id b49csp7627320wrg; Thu, 1 Mar 2018 08:26:28 -0800 (PST) X-Google-Smtp-Source: AG47ELu7rXb3Ll2qEi0nMmtGObqmDNYC3WwOoRXaBaDTjHh+/c1fOFQvbybvFexVyPJSrQmEndUe X-Received: by 2002:a17:902:968e:: with SMTP id n14-v6mr2457253plp.21.1519921588609; Thu, 01 Mar 2018 08:26:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519921588; cv=none; d=google.com; s=arc-20160816; b=wXpbvi3EPleywS8ikxEStD2cGdX7fFYoh+/fZBWN+9wXWox8XoDvJCRG8DNSSDsK0W IK9zmRdZW91NdKITFbM3BvpzmmsQ2VG5coJnkUWR/1zN4hneLk9XOdPFeVGY8iipIIAf sjWt8Fi4djqVx/to6l8KpzlKUkIGr3hNrU0yxZL+sDZg6Bb97UDkKGmtJburdB5CfiKH 75K30m5i9Ho5TonAQs2yDVqJCqNzencBruQZw+o6UQx/maUmMFNxhngcTtAVfOlo4qBb 8silMP41RyYSQ3HajuQtj5si0X5GTOssEyVOztDL777AN7HTONumRL3NVwH3y3Jvj3LT SZZA== 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 p12-v6si3383630pll.191.2018.03.01.08.26.13; Thu, 01 Mar 2018 08:26:28 -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 S1033022AbeCAQYW (ORCPT + 99 others); Thu, 1 Mar 2018 11:24:22 -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 Content-Type: text/plain 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(+) 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; -- 1.9.1