Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp793794imm; Fri, 27 Jul 2018 06:17:15 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd0FTuAz3j0jmKv27K8iuXw7QLJivVQkvPKExseNcxr3udsn+Tihz1p3iqhDLSUHz+g/tLO X-Received: by 2002:a62:1603:: with SMTP id 3-v6mr6636251pfw.245.1532697435892; Fri, 27 Jul 2018 06:17:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532697435; cv=none; d=google.com; s=arc-20160816; b=Erz5CEFgyiL4ASDHc/oD9fbx8NMZoasiTsXLiDjqh7HlUreQLk2dsSnDbhfzPJQQVp 3aAxrKAVMnqzulIYG9K2LgBgXFgqhatMr0ouCNEhX68g+DpDBiNfxgXulkgImPcnwG+K KzWo+b2fBxY4zSWbVGTtSqAO1lJKfZ1JWCg70RWWKdAqrnbpwFoDErBEQBzRMnfnmg9k gPXBtcONsfFm0ljM4Vc6n6VpiMMIvi4ooVxHOXW1Rn9DjGs+WwApg031uRzJWKsLlz4k fTaGgEkaCd8eSRsFqSLhya7damf9jXR9p77T+uK7f27skol63giZGqhHleYfnhqQHXyl GJqg== 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 62-v6si4337184pfu.79.2018.07.27.06.17.01; Fri, 27 Jul 2018 06:17:15 -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 S2388410AbeG0OhS (ORCPT + 99 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 Content-Type: text/plain 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(-) 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; -- 1.9.1