From patchwork Tue Mar 3 11:03:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 45350 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2BCC821429 for ; Tue, 3 Mar 2015 11:12:15 +0000 (UTC) Received: by wghb13 with SMTP id b13sf28197599wgh.2 for ; Tue, 03 Mar 2015 03:12:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=aZxbf42b4xC/35O/EEADRDAo1Cd4MY0EOgdoYpW03SA=; b=NQUK6dvSS5/j7jx+446tmilZ1aR1go0WQZo6O9WxwzhgzZASXXdMoV1asCgKOv9Aqg l+8zC6NeAYSmAHSCiB6VZggRzoCVeCYk0XyQaLIIE9k9eNP+N6Vt2cqCnk5CxhRLSksG YQy30G1a13zbPJUlw58jOAnlqZz25cvFrlxVpbPLMZKCZkNUz4jeDNm0aqc49MqpfIRD CKqWgV1X9ghAIcI/fLlbxXFnvdb/lKajyU4VJyaYiQP3Y8AVeNBiSsR3DQP75x+Je6U+ lncQm3tXMHqsjJhrp1wNjfrRG/upDLhwDjF/pO+YLe8iX4478f0n0GeME6+FTIv4CGnI P8mA== X-Gm-Message-State: ALoCoQkwjzEwDEib01mNfqNP//N3JEC6v/MpahFXDsFqJnCEJSbPkVfN9ynym548ok98o5yZLvSX X-Received: by 10.180.160.176 with SMTP id xl16mr2877210wib.6.1425381134485; Tue, 03 Mar 2015 03:12:14 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.234.165 with SMTP id uf5ls24260lac.60.gmail; Tue, 03 Mar 2015 03:12:14 -0800 (PST) X-Received: by 10.112.224.3 with SMTP id qy3mr5825257lbc.36.1425381134193; Tue, 03 Mar 2015 03:12:14 -0800 (PST) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id i3si265628lbn.112.2015.03.03.03.12.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Mar 2015 03:12:14 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by lbiz11 with SMTP id z11so10334166lbi.3 for ; Tue, 03 Mar 2015 03:12:14 -0800 (PST) X-Received: by 10.152.28.5 with SMTP id x5mr27865127lag.112.1425381134057; Tue, 03 Mar 2015 03:12:14 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp491412lbj; Tue, 3 Mar 2015 03:12:13 -0800 (PST) X-Received: by 10.68.233.232 with SMTP id tz8mr54102160pbc.166.1425381132257; Tue, 03 Mar 2015 03:12:12 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id zh13si719342pab.22.2015.03.03.03.12.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Mar 2015 03:12:12 -0800 (PST) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YSkhz-0007Kw-EU; Tue, 03 Mar 2015 11:09:51 +0000 Received: from mail-wi0-f177.google.com ([209.85.212.177]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YSkcs-0002FJ-Hc for linux-arm-kernel@lists.infradead.org; Tue, 03 Mar 2015 11:04:42 +0000 Received: by wiwh11 with SMTP id h11so21697081wiw.1 for ; Tue, 03 Mar 2015 03:04:12 -0800 (PST) X-Received: by 10.180.206.143 with SMTP id lo15mr19675835wic.22.1425380652253; Tue, 03 Mar 2015 03:04:12 -0800 (PST) Received: from ards-macbook-pro.local ([213.143.61.132]) by mx.google.com with ESMTPSA id k6sm20058411wia.6.2015.03.03.03.04.09 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Mar 2015 03:04:11 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, roy.franz@linaro.org, leif.lindholm@linaro.org, catalin.marinas@arm.com, will.deacon@arm.com, grant.likely@linaro.org, robh@kernel.org, msalter@redhat.com Subject: [PATCH 1/5] of/fdt: allow FDT virtual address outside of linear direct mapping Date: Tue, 3 Mar 2015 12:03:46 +0100 Message-Id: <1425380630-3684-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1425380630-3684-1-git-send-email-ard.biesheuvel@linaro.org> References: <1425380630-3684-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150303_030434_784314_9A3FDC02 X-CRM114-Status: GOOD ( 12.70 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.177 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.177 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: matt.fleming@intel.com, Ard Biesheuvel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 The early FDT code reserves the physical region that contains the FDT, and uses __pa() to calculate the FDT's physical address. However, if the FDT is mapped outside of the linear direct mapping, __pa() cannot be used. So create a __weak default wrapper called fdt_virt_to_phys() around __pa(), and use that instead. This allows architectures to drop in their own virt/phys mapping for the FDT blob. Signed-off-by: Ard Biesheuvel --- I am aware that __weak functions are generally frowned upon, but in this case, I wonder if it is worth the trouble to add arch specific header files so we can include them here. drivers/of/fdt.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 3a896c9aeb74..b10ce880000b 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -547,6 +547,18 @@ static int __init __fdt_scan_reserved_mem(unsigned long node, const char *uname, } /** + * fdt_virt_to_phys - translate a virtual address inside the FDT image + * to its corresponding physical address + * + * This needs to be overridden by the architecture if the virtual mapping + * of the FDT is separate from the linear direct mapping of system RAM + */ +phys_addr_t __weak __init fdt_virt_to_phys(void *virt) +{ + return __pa(virt); +} + +/** * early_init_fdt_scan_reserved_mem() - create reserved memory regions * * This function grabs memory from early allocator for device exclusive use @@ -562,7 +574,7 @@ void __init early_init_fdt_scan_reserved_mem(void) return; /* Reserve the dtb region */ - early_init_dt_reserve_memory_arch(__pa(initial_boot_params), + early_init_dt_reserve_memory_arch(fdt_virt_to_phys(initial_boot_params), fdt_totalsize(initial_boot_params), 0);