Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ACPI: HMAT: refactor hmat_register_target_device to hmem_register_device

In preparation for exposing "Soft Reserved" memory ranges without an HMAT,
move the hmem device registration to its own compilation unit and make the
implementation generic.

The generic implementation drops usage acpi_map_pxm_to_online_node() that
was translating ACPI proximity domain values and instead relies on
numa_map_to_online_node() to determine the numa node for the device.

[joao.m.martins@oracle.com: CONFIG_DEV_DAX_HMEM_DEVICES should depend on CONFIG_DAX=y]
Link: https://lkml.kernel.org/r/8f34727f-ec2d-9395-cb18-969ec8a5d0d4@oracle.com

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brice Goglin <Brice.Goglin@inria.fr>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: David Airlie <airlied@linux.ie>
Cc: David Hildenbrand <david@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Jason Gunthorpe <jgg@mellanox.com>
Cc: Jeff Moyer <jmoyer@redhat.com>
Cc: Jia He <justin.he@arm.com>
Cc: Joao Martins <joao.m.martins@oracle.com>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Mike Rapoport <rppt@linux.ibm.com>
Cc: Paul Mackerras <paulus@ozlabs.org>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Wei Yang <richard.weiyang@linux.alibaba.com>
Cc: Will Deacon <will@kernel.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Hulk Robot <hulkci@huawei.com>
Cc: Jason Yan <yanaijie@huawei.com>
Cc: "Jérôme Glisse" <jglisse@redhat.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: kernel test robot <lkp@intel.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Vivek Goyal <vgoyal@redhat.com>
Link: https://lkml.kernel.org/r/159643096584.4062302.5035370788475153738.stgit@dwillia2-desk3.amr.corp.intel.com
Link: https://lore.kernel.org/r/158318761484.2216124.2049322072599482736.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Dan Williams and committed by
Linus Torvalds
c01044cc 88e9a5b7

+90 -65
+6 -62
drivers/acpi/numa/hmat.c
··· 24 24 #include <linux/mutex.h> 25 25 #include <linux/node.h> 26 26 #include <linux/sysfs.h> 27 + #include <linux/dax.h> 27 28 28 29 static u8 hmat_revision; 29 30 static int hmat_disable __initdata; ··· 641 640 node_set_perf_attrs(mem_nid, &target->hmem_attrs, 0); 642 641 } 643 642 644 - static void hmat_register_target_device(struct memory_target *target, 645 - struct resource *r) 646 - { 647 - /* define a clean / non-busy resource for the platform device */ 648 - struct resource res = { 649 - .start = r->start, 650 - .end = r->end, 651 - .flags = IORESOURCE_MEM, 652 - }; 653 - struct platform_device *pdev; 654 - struct memregion_info info; 655 - int rc, id; 656 - 657 - rc = region_intersects(res.start, resource_size(&res), IORESOURCE_MEM, 658 - IORES_DESC_SOFT_RESERVED); 659 - if (rc != REGION_INTERSECTS) 660 - return; 661 - 662 - id = memregion_alloc(GFP_KERNEL); 663 - if (id < 0) { 664 - pr_err("memregion allocation failure for %pr\n", &res); 665 - return; 666 - } 667 - 668 - pdev = platform_device_alloc("hmem", id); 669 - if (!pdev) { 670 - pr_err("hmem device allocation failure for %pr\n", &res); 671 - goto out_pdev; 672 - } 673 - 674 - pdev->dev.numa_node = acpi_map_pxm_to_online_node(target->memory_pxm); 675 - info = (struct memregion_info) { 676 - .target_node = acpi_map_pxm_to_node(target->memory_pxm), 677 - }; 678 - rc = platform_device_add_data(pdev, &info, sizeof(info)); 679 - if (rc < 0) { 680 - pr_err("hmem memregion_info allocation failure for %pr\n", &res); 681 - goto out_pdev; 682 - } 683 - 684 - rc = platform_device_add_resources(pdev, &res, 1); 685 - if (rc < 0) { 686 - pr_err("hmem resource allocation failure for %pr\n", &res); 687 - goto out_resource; 688 - } 689 - 690 - rc = platform_device_add(pdev); 691 - if (rc < 0) { 692 - dev_err(&pdev->dev, "device add failed for %pr\n", &res); 693 - goto out_resource; 694 - } 695 - 696 - return; 697 - 698 - out_resource: 699 - put_device(&pdev->dev); 700 - out_pdev: 701 - memregion_free(id); 702 - } 703 - 704 643 static void hmat_register_target_devices(struct memory_target *target) 705 644 { 706 645 struct resource *res; ··· 652 711 if (!IS_ENABLED(CONFIG_DEV_DAX_HMEM)) 653 712 return; 654 713 655 - for (res = target->memregions.child; res; res = res->sibling) 656 - hmat_register_target_device(target, res); 714 + for (res = target->memregions.child; res; res = res->sibling) { 715 + int target_nid = acpi_map_pxm_to_node(target->memory_pxm); 716 + 717 + hmem_register_device(target_nid, res); 718 + } 657 719 } 658 720 659 721 static void hmat_register_target(struct memory_target *target)
+4
drivers/dax/Kconfig
··· 48 48 49 49 Say M if unsure. 50 50 51 + config DEV_DAX_HMEM_DEVICES 52 + depends on DEV_DAX_HMEM && DAX=y 53 + def_bool y 54 + 51 55 config DEV_DAX_KMEM 52 56 tristate "KMEM DAX: volatile-use of persistent memory" 53 57 default DEV_DAX
+1 -2
drivers/dax/Makefile
··· 2 2 obj-$(CONFIG_DAX) += dax.o 3 3 obj-$(CONFIG_DEV_DAX) += device_dax.o 4 4 obj-$(CONFIG_DEV_DAX_KMEM) += kmem.o 5 - obj-$(CONFIG_DEV_DAX_HMEM) += dax_hmem.o 6 5 7 6 dax-y := super.o 8 7 dax-y += bus.o 9 8 device_dax-y := device.o 10 - dax_hmem-y := hmem.o 11 9 12 10 obj-y += pmem/ 11 + obj-y += hmem/
+1 -1
drivers/dax/hmem.c drivers/dax/hmem/hmem.c
··· 3 3 #include <linux/memregion.h> 4 4 #include <linux/module.h> 5 5 #include <linux/pfn_t.h> 6 - #include "bus.h" 6 + #include "../bus.h" 7 7 8 8 static int dax_hmem_probe(struct platform_device *pdev) 9 9 {
+5
drivers/dax/hmem/Makefile
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + obj-$(CONFIG_DEV_DAX_HMEM) += dax_hmem.o 3 + obj-$(CONFIG_DEV_DAX_HMEM_DEVICES) += device.o 4 + 5 + dax_hmem-y := hmem.o
+65
drivers/dax/hmem/device.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include <linux/platform_device.h> 3 + #include <linux/memregion.h> 4 + #include <linux/module.h> 5 + #include <linux/dax.h> 6 + #include <linux/mm.h> 7 + 8 + void hmem_register_device(int target_nid, struct resource *r) 9 + { 10 + /* define a clean / non-busy resource for the platform device */ 11 + struct resource res = { 12 + .start = r->start, 13 + .end = r->end, 14 + .flags = IORESOURCE_MEM, 15 + }; 16 + struct platform_device *pdev; 17 + struct memregion_info info; 18 + int rc, id; 19 + 20 + rc = region_intersects(res.start, resource_size(&res), IORESOURCE_MEM, 21 + IORES_DESC_SOFT_RESERVED); 22 + if (rc != REGION_INTERSECTS) 23 + return; 24 + 25 + id = memregion_alloc(GFP_KERNEL); 26 + if (id < 0) { 27 + pr_err("memregion allocation failure for %pr\n", &res); 28 + return; 29 + } 30 + 31 + pdev = platform_device_alloc("hmem", id); 32 + if (!pdev) { 33 + pr_err("hmem device allocation failure for %pr\n", &res); 34 + goto out_pdev; 35 + } 36 + 37 + pdev->dev.numa_node = numa_map_to_online_node(target_nid); 38 + info = (struct memregion_info) { 39 + .target_node = target_nid, 40 + }; 41 + rc = platform_device_add_data(pdev, &info, sizeof(info)); 42 + if (rc < 0) { 43 + pr_err("hmem memregion_info allocation failure for %pr\n", &res); 44 + goto out_pdev; 45 + } 46 + 47 + rc = platform_device_add_resources(pdev, &res, 1); 48 + if (rc < 0) { 49 + pr_err("hmem resource allocation failure for %pr\n", &res); 50 + goto out_resource; 51 + } 52 + 53 + rc = platform_device_add(pdev); 54 + if (rc < 0) { 55 + dev_err(&pdev->dev, "device add failed for %pr\n", &res); 56 + goto out_resource; 57 + } 58 + 59 + return; 60 + 61 + out_resource: 62 + put_device(&pdev->dev); 63 + out_pdev: 64 + memregion_free(id); 65 + }
+8
include/linux/dax.h
··· 238 238 return mapping->host && IS_DAX(mapping->host); 239 239 } 240 240 241 + #ifdef CONFIG_DEV_DAX_HMEM_DEVICES 242 + void hmem_register_device(int target_nid, struct resource *r); 243 + #else 244 + static inline void hmem_register_device(int target_nid, struct resource *r) 245 + { 246 + } 247 + #endif 248 + 241 249 #endif