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;