From patchwork Fri Jul 27 13:14:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 143049 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp806694ljj; Fri, 27 Jul 2018 06:15:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcokhEAz7zxI4bwzdZk/T8vL3kW5b9soK4J2UDF9Qk7sGi3VgUmYSOB63j8SIejis0O9/bR X-Received: by 2002:a62:4147:: with SMTP id o68-v6mr6580092pfa.111.1532697327660; Fri, 27 Jul 2018 06:15:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532697327; cv=none; d=google.com; s=arc-20160816; b=ilnxNBNh3BRYH1Z5tx8vpnfRQGxQilfBfwGHMSl12VcEAkvTp4rx7Rya/nmhGCp2kM mTjb6GmeecLf7M+/LmFJ2qHtkg8Y/ZTtJpwEwoexNZAneVhqjAAcaY1mMfuo8GqphD7J ULfqgF72x7zaVvUuooS4QEDzf3tZPnBNLPQymagDljSVKkGDcyE5szv99oF4OWbrY/Kj BOn0viM8PZLPH27vsHnKH00x8FMowYJRCKqrEp6kxhVUGZgSQ6FQH+pud35eNn1vX81q aIEJpgCkCfnAg6MQZ4gHbAb+5JFqRmYK/m2lmjc45HwKnyJQfuYyfZYMU7CMJhggGpoy CX7g== 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=Mk5PSJv/y65Km+C/zhPHVNNtcOAlXH0JttrBMNiZUWk=; b=LVPkeQrVyl3+V1p5a65O1QSFynrNmUzLyximrBBP7x5uooQToBWvhkKkqZ/nitI7On L9dZzc9myXrEXI8hn4smfoLfxqJApyURCIRD7Cdquxh8BrZQUqlN8tcX2UBn+y+XC+zM jDNxlfJEpXTUSTpCUq9KVw+4jXUilTNk5AS5qB/xC4RZbi3CrVTrcb6v/IGs6ZDtxDIW BdbsOmWnxhlcB+Yr6agqzR/xmkD01u0mhIE3XuNCLmcri2/GLhmH6d/HVQTiJ+0GHR4p KEzGsXvx4Etvb/Ebsk3el/RY9sgXa3BZfcjtyDNy7JsLDcKI4me16/96f8qnkuspSYR6 xGNQ== 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 n1-v6si3509716pld.429.2018.07.27.06.15.27; Fri, 27 Jul 2018 06:15:27 -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 S2388449AbeG0OhS (ORCPT + 31 others); Fri, 27 Jul 2018 10:37:18 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:39847 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732452AbeG0OhR (ORCPT ); Fri, 27 Jul 2018 10:37:17 -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 w6RDE242014483; Fri, 27 Jul 2018 15:15:21 +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 2kg1tj8pt1-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 27 Jul 2018 15:15:21 +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 7DB0338; Fri, 27 Jul 2018 13:15:20 +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 4FCA75780; Fri, 27 Jul 2018 13:15:20 +0000 (GMT) Received: from localhost (10.75.127.51) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 27 Jul 2018 15:15:19 +0200 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH v4 02/17] remoteproc: add rproc_va_to_pa function Date: Fri, 27 Jul 2018 15:14:37 +0200 Message-ID: <1532697292-14272-3-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 X-Originating-IP: [10.75.127.51] X-ClientProxiedBy: SFHDAG4NODE3.st.com (10.75.127.12) 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 new function translates CPU virtual address in CPU physical one according to virtual address location. Signed-off-by: Loic Pallardy Acked-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_core.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 437fabf..8e5fe1e 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -140,6 +140,22 @@ static void rproc_disable_iommu(struct rproc *rproc) iommu_domain_free(domain); } +static phys_addr_t rproc_va_to_pa(void *cpu_addr) +{ + /* + * Return physical address according to virtual address location + * - in vmalloc: if region ioremapped or defined as dma_alloc_coherent + * - in kernel: if region allocated in generic dma memory pool + */ + if (is_vmalloc_addr(cpu_addr)) { + return page_to_phys(vmalloc_to_page(cpu_addr)) + + offset_in_page(cpu_addr); + } + + WARN_ON(!virt_addr_valid(cpu_addr)); + return virt_to_phys(cpu_addr); +} + /** * rproc_da_to_va() - lookup the kernel virtual address for a remoteproc address * @rproc: handle of a remote processor @@ -711,7 +727,7 @@ static int rproc_handle_carveout(struct rproc *rproc, * In this case, the device address and the physical address * are the same. */ - rsc->pa = dma; + rsc->pa = (u32)rproc_va_to_pa(va); carveout->va = va; carveout->len = rsc->len;