Received: by 10.223.185.116 with SMTP id b49csp7632739wrg; Thu, 1 Mar 2018 08:31:32 -0800 (PST) X-Google-Smtp-Source: AG47ELvs35UU/V3Cqm64ygIZraOYI9XK7PPuNOZuD2j1fefy6/z+emrozK7+wtMp53Z77CFw0XlQ X-Received: by 2002:a17:902:2006:: with SMTP id n6-v6mr2440957pla.149.1519921892655; Thu, 01 Mar 2018 08:31:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519921892; cv=none; d=google.com; s=arc-20160816; b=oUhIa31uUdtxKMWuJj/6G9myOOHpvT8gyKFKs6RcWnIVIZqg6uqP4AkAFujJKVAIxd wgsZbE33XcWrrWK5o54gyrLZL+FrsE2l7R9YdomPanNbWrHAQRsmgzp+hjkqm+ss1DzJ lfJetgcewmSd+FgUi+qg7TYW+KWgBCZYcND9CXsJkT3+6oDXWmwPuuYDze834Vv2nDWQ fVFq7+Wr1T8hOw/GWQKniwlZIJN9g+1iEUSqlM+tVafpaCiZCRojAdXw40sVVDwRlzq/ Ce6694yW5cOcW87iraJUuLxjGn+f1mHlKQ3d1rrAhIt0dJegu6CjijB8GUMAc36JJqZN O/sw== 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 x19si163737pfh.145.2018.03.01.08.31.18; Thu, 01 Mar 2018 08:31:32 -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 S1033134AbeCAQ1p (ORCPT + 99 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 Content-Type: text/plain 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(-) 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; -- 1.9.1