From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11678C433DF for ; Fri, 21 Aug 2020 23:23:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C54AA207DF for ; Fri, 21 Aug 2020 23:23:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598052191; bh=DlRESH2rNVPfCwYmyg3V+EJFk/FZvlcJo78YSIeSnjg=; h=Date:From:To:Subject:Reply-To:List-ID:From; b=BgWEHsrclLw55p+C0f3BMgRkMjallZ081KN9UAC10oWQBtdlR3GjJMpUkKwsujmWM x2J7WWAv7t+Y8yUMlSjRNh8EACTrCprBlhnZY0NNV8xxsUIEZa6tBcyKtnb8AUop1T TxI/sbCyN0eimJOsgGE/b6GeoEQpKxO8y4Yc2bAw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726697AbgHUXXL (ORCPT ); Fri, 21 Aug 2020 19:23:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:57238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726541AbgHUXXL (ORCPT ); Fri, 21 Aug 2020 19:23:11 -0400 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6CEE0207CD; Fri, 21 Aug 2020 23:23:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598052190; bh=DlRESH2rNVPfCwYmyg3V+EJFk/FZvlcJo78YSIeSnjg=; h=Date:From:To:Subject:From; b=Sh6rE2UjP5OA42R2r1isNvt6DESR0CJ0l4QflF00YWNl0xSUfiMoLtQXwNGPlCtQQ LKbWCZ9WJ88LeA7MazmFXlZ2HQgkBRjY6Oykvb9dIXeQ7ZZrJwXM7wnX8oyEPvEfhv 7H53mdVTUB8RpCre+bRgaYAlFtC78bdldK5ePdOo= Date: Fri, 21 Aug 2020 16:23:07 -0700 From: akpm@linux-foundation.org To: airlied@linux.ie, ard.biesheuvel@linaro.org, ardb@kernel.org, benh@kernel.crashing.org, bp@alien8.de, Brice.Goglin@inria.fr, bskeggs@redhat.com, catalin.marinas@arm.com, dan.j.williams@intel.com, daniel@ffwll.ch, dave.hansen@linux.intel.com, dave.jiang@intel.com, david@redhat.com, gregkh@linuxfoundation.org, hpa@zytor.com, ira.weiny@intel.com, jgg@mellanox.com, jmoyer@redhat.com, joao.m.martins@oracle.com, Jonathan.Cameron@huawei.com, justin.he@arm.com, luto@kernel.org, mingo@redhat.com, mm-commits@vger.kernel.org, mpe@ellerman.id.au, pasha.tatashin@soleen.com, paulus@ozlabs.org, peterz@infradead.org, rafael.j.wysocki@intel.com, rafael@kernel.org, richardw.yang@linux.intel.com, rjw@rjwysocki.net, rppt@linux.ibm.com, tglx@linutronix.de, thomas.lendacky@amd.com, vishal.l.verma@intel.com, will@kernel.org Subject: + acpi-hmat-attach-a-device-for-each-soft-reserved-range.patch added to -mm tree Message-ID: <20200821232307.WPEeYyY-s%akpm@linux-foundation.org> User-Agent: s-nail v14.8.16 Sender: mm-commits-owner@vger.kernel.org Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The patch titled Subject: ACPI: HMAT: attach a device for each soft-reserved range has been added to the -mm tree. Its filename is acpi-hmat-attach-a-device-for-each-soft-reserved-range.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/acpi-hmat-attach-a-device-for-each-soft-reserved-range.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/acpi-hmat-attach-a-device-for-each-soft-reserved-range.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Dan Williams Subject: ACPI: HMAT: attach a device for each soft-reserved range The hmem enabling in commit cf8741ac57ed ("ACPI: NUMA: HMAT: Register "soft reserved" memory as an "hmem" device") only registered ranges to the hmem driver for each soft-reservation that also appeared in the HMAT. While this is meant to encourage platform firmware to "do the right thing" and publish an HMAT, the corollary is that platforms that fail to publish an accurate HMAT will strand memory from Linux usage. Additionally, the "efi_fake_mem" kernel command line option enabling will strand memory by default without an HMAT. Arrange for "soft reserved" memory that goes unclaimed by HMAT entries to be published as raw resource ranges for the hmem driver to consume. Include a module parameter to disable either this fallback behavior, or the hmat enabling from creating hmem devices. The module parameter requires the hmem device enabling to have unique name in the module namespace: "device_hmem". The driver depends on the architecture providing phys_to_target_node() which is only x86 via numa_meminfo() and arm64 via a generic memblock implementation. Link: https://lkml.kernel.org/r/159643098298.4062302.17587338161136144730.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams Reviewed-by: Joao Martins Cc: Jonathan Cameron Cc: Brice Goglin Cc: Ard Biesheuvel Cc: "Rafael J. Wysocki" Cc: Jeff Moyer Cc: Catalin Marinas Cc: Will Deacon Cc: Andy Lutomirski Cc: Ard Biesheuvel Cc: Benjamin Herrenschmidt Cc: Ben Skeggs Cc: Borislav Petkov Cc: Daniel Vetter Cc: Dave Hansen Cc: Dave Jiang Cc: David Airlie Cc: David Hildenbrand Cc: Greg Kroah-Hartman Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: Ira Weiny Cc: Jason Gunthorpe Cc: Jia He Cc: Michael Ellerman Cc: Mike Rapoport Cc: Paul Mackerras Cc: Pavel Tatashin Cc: Peter Zijlstra Cc: "Rafael J. Wysocki" Cc: "Rafael J. Wysocki" Cc: Thomas Gleixner Cc: Tom Lendacky Cc: Vishal Verma Cc: Wei Yang Signed-off-by: Andrew Morton --- drivers/dax/hmem/Makefile | 3 ++- drivers/dax/hmem/device.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) --- a/drivers/dax/hmem/device.c~acpi-hmat-attach-a-device-for-each-soft-reserved-range +++ a/drivers/dax/hmem/device.c @@ -5,6 +5,9 @@ #include #include +static bool nohmem; +module_param_named(disable, nohmem, bool, 0444); + void hmem_register_device(int target_nid, struct resource *r) { /* define a clean / non-busy resource for the platform device */ @@ -17,6 +20,9 @@ void hmem_register_device(int target_nid struct memregion_info info; int rc, id; + if (nohmem) + return; + rc = region_intersects(res.start, resource_size(&res), IORESOURCE_MEM, IORES_DESC_SOFT_RESERVED); if (rc != REGION_INTERSECTS) @@ -63,3 +69,32 @@ out_resource: out_pdev: memregion_free(id); } + +static __init int hmem_register_one(struct resource *res, void *data) +{ + /* + * If the resource is not a top-level resource it was already + * assigned to a device by the HMAT parsing. + */ + if (res->parent != &iomem_resource) { + pr_info("HMEM: skip %pr, already claimed\n", res); + return 0; + } + + hmem_register_device(phys_to_target_node(res->start), res); + + return 0; +} + +static __init int hmem_init(void) +{ + walk_iomem_res_desc(IORES_DESC_SOFT_RESERVED, + IORESOURCE_MEM, 0, -1, NULL, hmem_register_one); + return 0; +} + +/* + * As this is a fallback for address ranges unclaimed by the ACPI HMAT + * parsing it must be at an initcall level greater than hmat_init(). + */ +late_initcall(hmem_init); --- a/drivers/dax/hmem/Makefile~acpi-hmat-attach-a-device-for-each-soft-reserved-range +++ a/drivers/dax/hmem/Makefile @@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_DEV_DAX_HMEM) += dax_hmem.o -obj-$(CONFIG_DEV_DAX_HMEM_DEVICES) += device.o +obj-$(CONFIG_DEV_DAX_HMEM_DEVICES) += device_hmem.o +device_hmem-y := device.o dax_hmem-y := hmem.o _ Patches currently in -mm which might be from dan.j.williams@intel.com are x86-numa-cleanup-configuration-dependent-command-line-options.patch x86-numa-add-nohmat-option.patch efi-fake_mem-arrange-for-a-resource-entry-per-efi_fake_mem-instance.patch acpi-hmat-refactor-hmat_register_target_device-to-hmem_register_device.patch resource-report-parent-to-walk_iomem_res_desc-callback.patch mm-memory_hotplug-introduce-default-phys_to_target_node-implementation.patch acpi-hmat-attach-a-device-for-each-soft-reserved-range.patch device-dax-drop-the-dax_regionpfn_flags-attribute.patch device-dax-move-instance-creation-parameters-to-struct-dev_dax_data.patch device-dax-make-pgmap-optional-for-instance-creation.patch device-dax-kill-dax_kmem_res.patch device-dax-add-an-allocation-interface-for-device-dax-instances.patch device-dax-introduce-seed-devices.patch drivers-base-make-device_find_child_by_name-compatible-with-sysfs-inputs.patch device-dax-add-resize-support.patch mm-memremap_pages-convert-to-struct-range.patch mm-memremap_pages-support-multiple-ranges-per-invocation.patch device-dax-add-dis-contiguous-resource-support.patch device-dax-introduce-mapping-devices.patch