From patchwork Thu Mar 1 16:23:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 130335 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3008924edc; Thu, 1 Mar 2018 08:28:49 -0800 (PST) X-Google-Smtp-Source: AG47ELsltsVzRKvoBd1uTANjpwK48vQjv/tiAV6yrK3XeMygldTxYCC/1y8flQkghso9+pOj/+dX X-Received: by 10.99.50.66 with SMTP id y63mr2038039pgy.207.1519921729063; Thu, 01 Mar 2018 08:28:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519921729; cv=none; d=google.com; s=arc-20160816; b=gg55jstyaSmWCy2F5cYeD9QzrK9hZn3gHzFsagZHLyOVEtjQhVvKwzoUCKXW89K1pQ dG4dDTKkjei7qdnyHq/8jbeP8AnFfdPnt0aX9sJzEMrToX0sWJma7WujgOhmJ/isdXRU hPoI4Wt3WsApEYsJ752Zq4nQnKnpEb7GhRlKJB6JQBJnClEAQQwWwqPIGsl3gYtuZciL YHPOV7dgon8PuCV9zpVOwpZ1IR69ElPGBuzlD4USYMm4H+JjQ0Fz1Cjy/SEQok4oMn2b IELQoIsOK5ANhw/thqemPq0T8DVEP8sTQYTDt6n5qoLFli0FC8XBR92HDWREv4ZzjKzA C/OQ== 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=LpeWcJuykvIf/S34map9joqOCR+J9RDmguMDUy6CrqE=; b=g+MUO9T2aQZncmFQHkI0nqPxtNsweE1GTNIVYcKAL6u2r0iPf7O/NsvE13qfVMq1o3 8CUMANujxZlNhPSWSOCofgazsYHm44eQSMSPQB4yZ2OA0gpYlMEDS/JIfRXHvuM2fsW+ UE2cN4hgmLsVvZawizy9MQ9L97mgZ2IuGplm16L67PvNPzkCClDeYXOWv7ncCUzjUkxb S6R4Oesv7k9khv5YHxXKbC5u5ahy3dIhpz+KDE2exd/bkhyIhOpzJ3dQtmHIg+JytAkf ToIPk1RMjrejuzQj1S4mq4MYuDUFf9+iFS5H5gcXE7qKXT9cs1BNwrqMpz06OmWEkd6G QrhQ== 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 z66si3241714pfk.135.2018.03.01.08.28.48; Thu, 01 Mar 2018 08:28:49 -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 S1033137AbeCAQ1p (ORCPT + 28 others); Thu, 1 Mar 2018 11:27:45 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:37092 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032936AbeCAQYP (ORCPT ); Thu, 1 Mar 2018 11:24:15 -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 w21GJFjU032289; Thu, 1 Mar 2018 17:24:13 +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 2gaxpwtgff-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 01 Mar 2018 17:24:13 +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 D47DD34; Thu, 1 Mar 2018 16:24:11 +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 BA92151FD; Thu, 1 Mar 2018 16:24:11 +0000 (GMT) Received: from localhost (10.75.127.45) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 1 Mar 2018 17:24:10 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v3 02/13] remoteproc: add rproc_va_to_pa function Date: Thu, 1 Mar 2018 17:23:49 +0100 Message-ID: <1519921440-21356-3-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.45] X-ClientProxiedBy: SFHDAG5NODE3.st.com (10.75.127.15) 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 new function translates CPU virtual address in CPU physical one according to virtual address location. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) -- 1.9.1 Acked-by: Bjorn Andersson diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 56b33e4..eb1b779 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -139,6 +139,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 @@ -708,7 +724,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;