From patchwork Mon Dec 22 19:08:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 42542 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B7C8D25BA1 for ; Mon, 22 Dec 2014 19:12:28 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id p9sf3223024lbv.5 for ; Mon, 22 Dec 2014 11:12:27 -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=N+W3lcTm4RNsrY26H/0yFKIiGU0aj0BxCa5aF2wGDts=; b=J5ul+IofDeBHgYh+nzuylpf8sftAcatdpTfB1twEBRkDja/gBz3Cv2/HJPiqiuiR5z 56Wil7CWQWQtIVqmTVFUSAxNPfmlG6eNUDM/ojVHm8rQrgjjmYAuzguMC30WfJoB+QZ6 hCOmF6M9YLiLYsFBh7KbqCWQAV45QaaEBLIBUQ7NYax5d+roQg0rh5+9GnCWxy5tFInK VM+P1G2dwvkF62uOq+kTBEbdxNLp1JgA6u+rcatEhBPyg5BeBeXtRtPCs/p5XR77aw2l aJ2ggbqkKk+HU/AeVLEMZnmppvZnbPWDs4qdmF8Zvx+Mai02G1xBsDdjIIQwMSIC3fja M80g== X-Gm-Message-State: ALoCoQkmtwyc0HpIgHM2R1qESpC55ykPlRvi7Jf6MXtmgTU7lDVOb648Hv83jbqlBAAX1ogOhTjP X-Received: by 10.112.141.98 with SMTP id rn2mr169893lbb.2.1419275547669; Mon, 22 Dec 2014 11:12:27 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.170 with SMTP id p10ls1659020lal.35.gmail; Mon, 22 Dec 2014 11:12:27 -0800 (PST) X-Received: by 10.152.22.67 with SMTP id b3mr23932915laf.82.1419275547527; Mon, 22 Dec 2014 11:12:27 -0800 (PST) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id ar8si19363882lbc.64.2014.12.22.11.12.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Dec 2014 11:12:27 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by mail-la0-f41.google.com with SMTP id hv19so4430079lab.14 for ; Mon, 22 Dec 2014 11:12:27 -0800 (PST) X-Received: by 10.152.5.226 with SMTP id v2mr23590852lav.34.1419275547397; Mon, 22 Dec 2014 11:12:27 -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.142.69 with SMTP id ru5csp1118729lbb; Mon, 22 Dec 2014 11:12:26 -0800 (PST) X-Received: by 10.68.240.233 with SMTP id wd9mr7289901pbc.69.1419275545578; Mon, 22 Dec 2014 11:12:25 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ua8si26107064pbc.215.2014.12.22.11.12.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Dec 2014 11:12:25 -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 1Y38NV-00086v-5F; Mon, 22 Dec 2014 19:10:49 +0000 Received: from mail-wg0-f46.google.com ([74.125.82.46]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y38MJ-0006Q1-LG for linux-arm-kernel@lists.infradead.org; Mon, 22 Dec 2014 19:09:37 +0000 Received: by mail-wg0-f46.google.com with SMTP id x13so7412562wgg.19 for ; Mon, 22 Dec 2014 11:09:13 -0800 (PST) X-Received: by 10.180.75.42 with SMTP id z10mr34167698wiv.70.1419275353727; Mon, 22 Dec 2014 11:09:13 -0800 (PST) Received: from ards-macbook-pro.local ([41.248.55.245]) by mx.google.com with ESMTPSA id t6sm24758726wjf.49.2014.12.22.11.09.09 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Dec 2014 11:09:12 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, leif.lindholm@linaro.org, roy.franz@linaro.org, mark.rutland@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, matt.fleming@intel.com, bp@alien8.de, dyoung@redhat.com, msalter@redhat.com, grant.likely@linaro.org Subject: [PATCH 4/8] memblock: introduce memblock_add_phys() and memblock_is_physmem() Date: Mon, 22 Dec 2014 19:08:38 +0000 Message-Id: <1419275322-29811-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1419275322-29811-1-git-send-email-ard.biesheuvel@linaro.org> References: <1419275322-29811-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141222_110935_867505_6CCB84DA X-CRM114-Status: UNSURE ( 9.96 ) X-CRM114-Notice: Please train this message. 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 [74.125.82.46 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [74.125.82.46 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: 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.215.41 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 This introduces the following functions: - memblock_add_phys(), that registers regions in the 'physmem' memblock map if CONFIG_HAVE_MEMBLOCK_PHYS_MAP is set; otherwise, it is a nop - memblock_is_physmem(), returns whether a physical address is classified as physical memory. Signed-off-by: Ard Biesheuvel --- include/linux/memblock.h | 10 ++++++++++ mm/memblock.c | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/linux/memblock.h b/include/linux/memblock.h index e8cc45307f8f..d32fe838c6ca 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -365,6 +365,16 @@ static inline unsigned long memblock_region_reserved_end_pfn(const struct memblo #define __initdata_memblock #endif +#ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP +int memblock_add_phys(phys_addr_t base, phys_addr_t size); +int memblock_is_physmem(phys_addr_t addr); +#else +static inline int memblock_add_phys(phys_addr_t base, phys_addr_t size) +{ + return 0; +} +#endif /* CONFIG_HAVE_MEMBLOCK_PHYS_MAP */ + #else static inline phys_addr_t memblock_alloc(phys_addr_t size, phys_addr_t align) { diff --git a/mm/memblock.c b/mm/memblock.c index c27353beb260..107aa5ee2d7b 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -586,6 +586,14 @@ int __init_memblock memblock_add(phys_addr_t base, phys_addr_t size) MAX_NUMNODES, 0); } +#ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP +int __init_memblock memblock_add_phys(phys_addr_t base, phys_addr_t size) +{ + return memblock_add_range(&memblock.physmem, base, size, + MAX_NUMNODES, 0); +} +#endif + /** * memblock_isolate_range - isolate given range into disjoint memblocks * @type: memblock type to isolate range for @@ -1398,6 +1406,13 @@ int __init_memblock memblock_is_memory(phys_addr_t addr) return memblock_search(&memblock.memory, addr) != -1; } +#ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP +int __init_memblock memblock_is_physmem(phys_addr_t addr) +{ + return memblock_search(&memblock.physmem, addr) != -1; +} +#endif + #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP int __init_memblock memblock_search_pfn_nid(unsigned long pfn, unsigned long *start_pfn, unsigned long *end_pfn)