linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI: NFIT: Use fallback node id when numa info in NFIT table is incorrect
@ 2021-09-22 15:29 Jia He
  2021-09-22 18:02 ` Dan Williams
  0 siblings, 1 reply; 2+ messages in thread
From: Jia He @ 2021-09-22 15:29 UTC (permalink / raw)
  To: Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny
  Cc: Rafael J. Wysocki, Len Brown, nvdimm, linux-acpi, 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

Suggested-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Jia He <justin.he@arm.com>
---
 drivers/acpi/nfit/core.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index a3ef6cce644c..7dd80acf92c7 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ACPI: NFIT: Use fallback node id when numa info in NFIT table is incorrect
  2021-09-22 15:29 [PATCH] ACPI: NFIT: Use fallback node id when numa info in NFIT table is incorrect Jia He
@ 2021-09-22 18:02 ` Dan Williams
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Williams @ 2021-09-22 18:02 UTC (permalink / raw)
  To: Jia He
  Cc: Vishal Verma, Dave Jiang, Ira Weiny, Rafael J. Wysocki,
	Len Brown, Linux NVDIMM, Linux ACPI

On Wed, Sep 22, 2021 at 8:29 AM Jia He <justin.he@arm.com> wrote:
>
> 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:

Cc: <stable@vger.kernel.org>
Fixes: c221c0b0308f ("device-dax: "Hotplug" persistent memory for use
like normal RAM")

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

> Suggested-by: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Jia He <justin.he@arm.com>
> ---
>  drivers/acpi/nfit/core.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
> index a3ef6cce644c..7dd80acf92c7 100644
> --- a/drivers/acpi/nfit/core.c
> +++ b/drivers/acpi/nfit/core.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-22 18:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-22 15:29 [PATCH] ACPI: NFIT: Use fallback node id when numa info in NFIT table is incorrect Jia He
2021-09-22 18:02 ` Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).