Skip to contentSkip to conversation

ACPI: NFIT: Use fallback node id when numa info in NFIT table is incorrect

PATCH In review Jia He 2 participants 2 messages Sep 22, 2021

Subsystems (2)
lore
Share & tools
lore

Jia He

author
#0 lore raw

PATCH 1/1 ACPI: NFIT: Use fallback node id when numa info in NFIT table is incorrect

When ACPI NFIT table is failing to populate correct numa information on arm64, dax_kmem will get NUMA_NO_NODE from the NFIT driver.

Without this patch, pmem can't be probed as RAM devices on arm64 guest:
$ndctl create-namespace -fe namespace0.0 --mode=devdax --map=dev -s 1g -a 128M kmem dax0.0: rejecting DAX region [mem 0x240400000-0x2bfffffff] with invalid node: -1
kmem: probe of dax0.0 failed with error -22

---
 drivers/acpi/nfit/core.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/acpi/nfit/core.c +12 -0
index a3ef6cce644c..7dd80acf92c7 100644
@@ -3007,6 +3007,18 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc,
 		ndr_desc->target_node = NUMA_NO_NODE;
 	}
 
+	/* Fallback to address based numa information if node lookup failed */
+	if (ndr_desc->numa_node == NUMA_NO_NODE) {
+		ndr_desc->numa_node = memory_add_physaddr_to_nid(spa->address);
+		dev_info(acpi_desc->dev, "changing numa node from %d to %d for nfit region [%pa-%pa]",
+			NUMA_NO_NODE, ndr_desc->numa_node, &res.start, &res.end);
+	}
+	if (ndr_desc->target_node == NUMA_NO_NODE) {
+		ndr_desc->target_node = phys_to_target_node(spa->address);
+		dev_info(acpi_desc->dev, "changing target node from %d to %d for nfit region [%pa-%pa]",
+			NUMA_NO_NODE, ndr_desc->numa_node, &res.start, &res.end);
+	}
+
 	/*
 	 * Persistence domain bits are hierarchical, if
 	 * ACPI_NFIT_CAPABILITY_CACHE_FLUSH is set then
Signature · 1 line
2.17.1
#1 lore raw
Quoted 9 lines · Jia He

When ACPI NFIT table is failing to populate correct numa information on arm64, dax_kmem will get NUMA_NO_NODE from the NFIT driver.

Without this patch, pmem can't be probed as RAM devices on arm64 guest:
$ndctl create-namespace -fe namespace0.0 --mode=devdax --map=dev -s 1g -a 128M kmem dax0.0: rejecting DAX region [mem 0x240400000-0x2bfffffff] with invalid node: -1
kmem: probe of dax0.0 failed with error -22

I'll add:

Fixes c221c0b0308f ("device-dax: "Hotplug" persistent memory for use

like normal RAM")

...other than that, looks good to me.

Quoted 32 lines
---
 drivers/acpi/nfit/core.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/acpi/nfit/core.c +12 -1
index a3ef6cce644c..7dd80acf92c7 100644
@@ -3007,6 +3007,18 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc,
                ndr_desc->target_node = NUMA_NO_NODE;
        }
 
+       /* Fallback to address based numa information if node lookup failed */
+       if (ndr_desc->numa_node == NUMA_NO_NODE) {
+               ndr_desc->numa_node = memory_add_physaddr_to_nid(spa->address);
+               dev_info(acpi_desc->dev, "changing numa node from %d to %d for nfit region [%pa-%pa]",
+                       NUMA_NO_NODE, ndr_desc->numa_node, &res.start, &res.end);
+       }
+       if (ndr_desc->target_node == NUMA_NO_NODE) {
+               ndr_desc->target_node = phys_to_target_node(spa->address);
+               dev_info(acpi_desc->dev, "changing target node from %d to %d for nfit region [%pa-%pa]",
+                       NUMA_NO_NODE, ndr_desc->numa_node, &res.start, &res.end);
+       }
+
        /*
         * Persistence domain bits are hierarchical, if
         * ACPI_NFIT_CAPABILITY_CACHE_FLUSH is set then
--

2.17.1