Skip to contentSkip to conversation

cxl/acpi: Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch

PATCH Applied Keith Busch 6 participants 10 messages Mar 5 – Mar 6 CXL

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cxl/acpi: Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch

From: Keith Busch <[email protected]>

Commit e7e222ad73d9 moves devm_cxl_add_nvdimm_bridge() into the cxl_pmem file, which has independent config compile options for built-in or module. The call from cxl_acpi_probe() is guarded by IS_ENABLED(CONFIG_CXL_PMEM), which evaluates to true for both =y and =m.

When CONFIG_CXL_PMEM=m, a built-in cxl_acpi attempts to reference a symbol exported by a module, which fails to link. CXL_PMEM cannot simply be promoted to =y in this configuration because it depends on LIBNVDIMM, which may itself be =m.

Add a Kconfig dependency to prevent CXL_ACPI from being built-in when CXL_PMEM is a module. This contrains CXL_ACPI to =m when CXL_PMEM=m, while still allowing CXL_ACPI to be freely configured when CXL_PMEM is either built-in or disabled.

Fixes e7e222ad73d9 ("cxl: Move devm_cxl_add_nvdimm_bridge() to cxl_pmem.ko")
---
 drivers/cxl/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/cxl/Kconfig +1 -0
index 4589bf11d3fe0..80aeb0d556bd7 100644
@@ -59,6 +59,7 @@ config CXL_ACPI
 	tristate "CXL ACPI: Platform Support"
 	depends on ACPI
 	depends on ACPI_NUMA
+	depends on CXL_PMEM || !CXL_PMEM
 	default CXL_BUS
 	select ACPI_TABLE_LIB
 	select ACPI_HMAT
Signature · 1 line
2.47.3
#1 lore raw
Quoted 28 lines · Keith Busch

From: Keith Busch <[email protected]>

Commit e7e222ad73d9 moves devm_cxl_add_nvdimm_bridge() into the cxl_pmem file, which has independent config compile options for built-in or module. The call from cxl_acpi_probe() is guarded by IS_ENABLED(CONFIG_CXL_PMEM), which evaluates to true for both =y and =m.

When CONFIG_CXL_PMEM=m, a built-in cxl_acpi attempts to reference a symbol exported by a module, which fails to link. CXL_PMEM cannot simply be promoted to =y in this configuration because it depends on LIBNVDIMM, which may itself be =m.

Add a Kconfig dependency to prevent CXL_ACPI from being built-in when CXL_PMEM is a module. This contrains CXL_ACPI to =m when CXL_PMEM=m, while still allowing CXL_ACPI to be freely configured when CXL_PMEM is either built-in or disabled.

Fixes e7e222ad73d9 ("cxl: Move devm_cxl_add_nvdimm_bridge() to cxl_pmem.ko")
---
 drivers/cxl/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/cxl/Kconfig +0 -0
index 4589bf11d3fe0..80aeb0d556bd7 100644

drivers/cxl/Kconfig config CXL_ACPI · line 62

Quoted 4 lines
drivers/cxl/Kconfig +1 -0
@@ -59,6 +59,7 @@ config CXL_ACPI
 	tristate "CXL ACPI: Platform Support"
 	depends on ACPI
 	depends on ACPI_NUMA
+	depends on CXL_PMEM || !CXL_PMEM

Trivially looking at this it looks funky lol

alternatively:

https://lore.kernel.org/linux-cxl/[email protected]/

Not sure which one we want here

~Gregory

#2 lore raw
Quoted 8 lines · Gregory Price

drivers/cxl/Kconfig config CXL_ACPI · line 62

Quoted 5 lines
drivers/cxl/Kconfig +1 -0
@@ -59,6 +59,7 @@ config CXL_ACPI
 	tristate "CXL ACPI: Platform Support"
 	depends on ACPI
 	depends on ACPI_NUMA
+	depends on CXL_PMEM || !CXL_PMEM

Trivially looking at this it looks funky lol

Quoted 5 lines

alternatively:

https://lore.kernel.org/linux-cxl/[email protected]/

Not sure which one we want here

Yeah, I found your proposal just minutes after sending mine.

I agree this is whacky syntax, but it's a somewhat common Kconfig pattern (see NF_CONNTRACK in net/ipv4/netfilter/Kconfig).

Anyway, my proposal here should force demotion to "m" for CXL_ACPI if PMEM is also "m", where your proposal should force a failure path at compile time if ACPI=y and PMEM=m. I really don't know if there's any preference at all, I also just wanted the kernel build to complete successfuly. :)

#3 lore raw
Quoted 17 lines · Keith Busch
Quoted 8 lines · Gregory Price

drivers/cxl/Kconfig config CXL_ACPI · line 62

Quoted 5 lines
drivers/cxl/Kconfig +1 -0
@@ -59,6 +59,7 @@ config CXL_ACPI
 	tristate "CXL ACPI: Platform Support"
 	depends on ACPI
 	depends on ACPI_NUMA
+	depends on CXL_PMEM || !CXL_PMEM

Trivially looking at this it looks funky lol

Quoted 5 lines

alternatively:

https://lore.kernel.org/linux-cxl/[email protected]/

Not sure which one we want here

Yeah, I found your proposal just minutes after sending mine.

Quoted 8 lines

I agree this is whacky syntax, but it's a somewhat common Kconfig pattern (see NF_CONNTRACK in net/ipv4/netfilter/Kconfig).

Anyway, my proposal here should force demotion to "m" for CXL_ACPI if PMEM is also "m", where your proposal should force a failure path at compile time if ACPI=y and PMEM=m. I really don't know if there's any preference at all, I also just wanted the kernel build to complete successfuly. :)

my proposal allows compilation but fails during probe because the symbol is IS_REACHABLE()=false, but yeah, i have no idea what we want here.

I somewhat prefer not to auto-convert config settings, as packaging changes can be painful - but I can investigate whether this will break us.

~Gregory

#4 lore raw
Quoted 8 lines · Gregory Price
Quoted 5 lines

Anyway, my proposal here should force demotion to "m" for CXL_ACPI if PMEM is also "m", where your proposal should force a failure path at compile time if ACPI=y and PMEM=m. I really don't know if there's any preference at all, I also just wanted the kernel build to complete successfuly. :)

my proposal allows compilation but fails during probe because the symbol is IS_REACHABLE()=false, but yeah, i have no idea what we want here.

Indeed, I didn't mean to suggest your solution may not build. I only mean the forced runtime error path was decided at compile time. And I'm totally okay with doing that if it's preferred over forcing module demotion.

#5 lore raw
In reply to Keith Busch
Quoted 28 lines · Keith Busch

From: Keith Busch <[email protected]>

Commit e7e222ad73d9 moves devm_cxl_add_nvdimm_bridge() into the cxl_pmem file, which has independent config compile options for built-in or module. The call from cxl_acpi_probe() is guarded by IS_ENABLED(CONFIG_CXL_PMEM), which evaluates to true for both =y and =m.

When CONFIG_CXL_PMEM=m, a built-in cxl_acpi attempts to reference a symbol exported by a module, which fails to link. CXL_PMEM cannot simply be promoted to =y in this configuration because it depends on LIBNVDIMM, which may itself be =m.

Add a Kconfig dependency to prevent CXL_ACPI from being built-in when CXL_PMEM is a module. This contrains CXL_ACPI to =m when CXL_PMEM=m, while still allowing CXL_ACPI to be freely configured when CXL_PMEM is either built-in or disabled.

Fixes e7e222ad73d9 ("cxl: Move devm_cxl_add_nvdimm_bridge() to cxl_pmem.ko")
---
 drivers/cxl/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/cxl/Kconfig +0 -0
index 4589bf11d3fe0..80aeb0d556bd7 100644

drivers/cxl/Kconfig config CXL_ACPI · line 62

Quoted 4 lines
drivers/cxl/Kconfig +1 -0
@@ -59,6 +59,7 @@ config CXL_ACPI
 	tristate "CXL ACPI: Platform Support"
 	depends on ACPI
 	depends on ACPI_NUMA
+	depends on CXL_PMEM || !CXL_PMEM

So I do not think this is sufficient because there is no devm_cxl_add_nvdimm_bridge() stub in the CONFIG_CXL_PMEM=n case, right?

I came up with this. I do not like that it puts ifdefs in the code, but then again I do not think add_root_nvdimm_bridge() is big enough to deserve its own C file.

-- 8< --

drivers/cxl/Kconfig +5 -0
index 4589bf11d3fe..277877da8263 100644
@@ -75,6 +75,11 @@ config CXL_ACPI
 
 	  If unsure say 'm'.
 
+config CXL_ACPI_PMEM
+	def_bool y
+	depends on CXL_ACPI
+	depends on CXL_PMEM >= CXL_ACPI
+
 config CXL_PMEM
 	tristate "CXL PMEM: Persistent Memory Support"
 	depends on LIBNVDIMM
drivers/cxl/acpi.c +14 -3
index 127537628817..a42ad5035958 100644
@@ -741,6 +741,7 @@ static int add_host_bridge_uport(struct device *match, void *arg)
 	return 0;
 }
 
+#ifdef CONFIG_CXL_ACPI_PMEM
 static int add_root_nvdimm_bridge(struct device *match, void *data)
 {
 	struct cxl_decoder *cxld;
@@ -765,6 +766,18 @@ static int add_root_nvdimm_bridge(struct device *match, void *data)
 	return 1;
 }
 
+static int setup_pmem(struct cxl_port *root_port)
+{
+	return device_for_each_child(&root_port->dev, root_port,
+				     add_root_nvdimm_bridge);
+}
+#else
+static int setup_pmem(struct cxl_port *root_port)
+{
+	return 0;
+}
+#endif
+
 static struct lock_class_key cxl_root_key;
 
 static void cxl_acpi_lock_reset_class(void *dev)
@@ -952,9 +965,7 @@ static int cxl_acpi_probe(struct platform_device *pdev)
 	if (rc < 0)
 		return rc;
 
-	if (IS_ENABLED(CONFIG_CXL_PMEM))
-		rc = device_for_each_child(&root_port->dev, root_port,
-					   add_root_nvdimm_bridge);
+	rc = setup_pmem(root_port);
 	if (rc < 0)
 		return rc;
 
#6 lore raw
Quoted 2 lines · On Thu, Mar 05, 2026 at 05:07:28PM -0800, [email protected] wrote:
Quoted 2 lines

The call from cxl_acpi_probe() is guarded by IS_ENABLED(CONFIG_CXL_PMEM), which evaluates to true for both =y and =m.

<snip>

Quoted 2 lines

So I do not think this is sufficient because there is no devm_cxl_add_nvdimm_bridge() stub in the CONFIG_CXL_PMEM=n case, right?

It's called from a preprocesser "#if 0" section, so it shouldn't be compiled in. At least it seems perfectly fine in local testing, but is that compiler specific? I think this should have been optimized out.

Reviewed-by
#7 lore raw
Quoted 4 lines · Keith Busch
Quoted 2 lines · On Thu, Mar 05, 2026 at 05:07:28PM -0800, [email protected] wrote:
Quoted 2 lines

The call from cxl_acpi_probe() is guarded by IS_ENABLED(CONFIG_CXL_PMEM), which evaluates to true for both =y and =m.

Quoted 8 lines

<snip>

Quoted 2 lines

So I do not think this is sufficient because there is no devm_cxl_add_nvdimm_bridge() stub in the CONFIG_CXL_PMEM=n case, right?

It's called from a preprocesser "#if 0" section, so it shouldn't be compiled in. At least it seems perfectly fine in local testing, but is that compiler specific? I think this should have been optimized out.

Oh, duh, yes, the IS_ENABLED() stays there. Hmm, this indeed looks like it does everything right. I forgot that the dependency checker will make sure that you can not select CXL_ACPI=y and CXL_PMEM=m.

So,

...this is better than what I proposed.

Reviewed-by
#8 lore raw
Quoted 18 lines · On Thu, 5 Mar 2026 17:55:43 -0800 [email protected] wrote:
Quoted 4 lines · Keith Busch
Quoted 2 lines · On Thu, Mar 05, 2026 at 05:07:28PM -0800, [email protected] wrote:
Quoted 2 lines

The call from cxl_acpi_probe() is guarded by IS_ENABLED(CONFIG_CXL_PMEM), which evaluates to true for both =y and =m.

Quoted 8 lines

<snip>

Quoted 2 lines

So I do not think this is sufficient because there is no devm_cxl_add_nvdimm_bridge() stub in the CONFIG_CXL_PMEM=n case, right?

It's called from a preprocesser "#if 0" section, so it shouldn't be compiled in. At least it seems perfectly fine in local testing, but is that compiler specific? I think this should have been optimized out.

Oh, duh, yes, the IS_ENABLED() stays there. Hmm, this indeed looks like it does everything right. I forgot that the dependency checker will make sure that you can not select CXL_ACPI=y and CXL_PMEM=m.

Quoted 6 lines

So,

...this is better than what I proposed.

I prefer Keith's solution to Gregory's just because of removing a surprising foot gun.

maintainer Applied
#9 lore raw
In reply to Keith Busch
Quoted 12 lines · Keith Busch

From: Keith Busch <[email protected]>

Commit e7e222ad73d9 moves devm_cxl_add_nvdimm_bridge() into the cxl_pmem file, which has independent config compile options for built-in or module. The call from cxl_acpi_probe() is guarded by IS_ENABLED(CONFIG_CXL_PMEM), which evaluates to true for both =y and =m.

When CONFIG_CXL_PMEM=m, a built-in cxl_acpi attempts to reference a symbol exported by a module, which fails to link. CXL_PMEM cannot simply be promoted to =y in this configuration because it depends on LIBNVDIMM, which may itself be =m.

Quoted 7 lines

Add a Kconfig dependency to prevent CXL_ACPI from being built-in when CXL_PMEM is a module. This contrains CXL_ACPI to =m when CXL_PMEM=m, while still allowing CXL_ACPI to be freely configured when CXL_PMEM is either built-in or disabled.

Fixes e7e222ad73d9 ("cxl: Move devm_cxl_add_nvdimm_bridge() to cxl_pmem.ko")

Applied to cxl/fixes
93d0fcdddc9e7be9d4f42acbe57bc90dbb0fe75d

Quoted 16 lines
---
 drivers/cxl/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/cxl/Kconfig +1 -0
index 4589bf11d3fe0..80aeb0d556bd7 100644
@@ -59,6 +59,7 @@ config CXL_ACPI
 	tristate "CXL ACPI: Platform Support"
 	depends on ACPI
 	depends on ACPI_NUMA
+	depends on CXL_PMEM || !CXL_PMEM
 	default CXL_BUS
 	select ACPI_TABLE_LIB
 	select ACPI_HMAT