Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp794583imm; Fri, 27 Jul 2018 06:18:04 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeoFQMntUCD5L8582jD/+ZCfcKWp5eq4kxEWbI8Jy8zv3t/Tq/f3KsHvJ3eiUdXmjc81Mag X-Received: by 2002:a62:cc4d:: with SMTP id a74-v6mr6717292pfg.200.1532697484244; Fri, 27 Jul 2018 06:18:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532697484; cv=none; d=google.com; s=arc-20160816; b=sGItcWQM0HeYstZV5kmNQ5nPKttuQkU73fTEtHVU1l3yLkoFL90Jz644E4dGeeFCMU OhekvvxS5x9sLcqqJyDzmjuFz/QDnNgHV6TyPZnIMzT6MlEc+QRPKo9kQ3cyLvlTgFDy lG1Z/5azKMtOxUPAw0WQYPJRLvxcPq/yj9oV7qg8pZ+ZS8y+NOAP5TQZy+hiT8bgNbgC 69lZwIPoIMDNVu5dbRnbiwmPcN6pa0ygl2ioNNP8S/CfSy17DYR/1cBKOABGAkAvcoqu k/UEbApx29RHWP4BzgT1UChOFF+NCDnviF2Q52JdEgHISyRYgC/3cycD446biGjKdmpY XZzw== 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=MSUXWCe7DU2ElRflWW5l/3VZhdQHDGFRLu+FX4fCplk=; b=g/DAyYG9BH6VvQw78O9mF38QHewn6INo4zn4lX4kpd1nWVdTZSihykKAGD8r4UxZxx 5w6MdjOB/X24UhrwGLWpnkq3VvvhDAvuR2qH0EwQMkAdypsDl3mJLjhK7YA8HEPwVp0j JCF0ltFgu84pWFehpWctxl2SV28yplET5fQtYnX6LLzsHRELHZw5Y3KDkymveafNY/SF 7sqFkaql2ukyy2FTDA1jMORvlCm+dJ9Azlwbo0D+bOy6e3xcqi9pMMF+Wso17pRol5/+ 7VG5Ospl5eqNMVBNrs/2KWCC7qr6JgXvExMwoq2b4h9sAHYx5WSBb1izEszgO9avWJaM Y7fQ== 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 31-v6si3664522pld.84.2018.07.27.06.17.49; Fri, 27 Jul 2018 06:18:04 -0700 (PDT) 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 S2388616AbeG0OhZ (ORCPT + 99 others); Fri, 27 Jul 2018 10:37:25 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:39855 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388468AbeG0OhY (ORCPT ); Fri, 27 Jul 2018 10:37:24 -0400 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 w6RDE1rD014441; Fri, 27 Jul 2018 15:15:25 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2kg1tj8ptj-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 27 Jul 2018 15:15:25 +0200 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 092C531; Fri, 27 Jul 2018 13:15:25 +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 E4AA0577A; Fri, 27 Jul 2018 13:15:24 +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; Fri, 27 Jul 2018 15:15:24 +0200 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH v4 07/17] remoteproc: introduce rproc_find_carveout_by_name function Date: Fri, 27 Jul 2018 15:14:42 +0200 Message-ID: <1532697292-14272-8-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1532697292-14272-1-git-send-email-loic.pallardy@st.com> References: <1532697292-14272-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.50] 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.10434:,, definitions=2018-07-27_06:,, 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 | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index fe6c4e4..77b39ba 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -217,6 +217,48 @@ 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. + * + * Return: 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; + + if (!name) + return NULL; + + va_start(args, name); + vsnprintf(_name, sizeof(_name), name, args); + va_end(args); + + 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