* Re: [PATCH] cxl/acpi: Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch
2026-03-05 20:40 [PATCH] cxl/acpi: Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch Keith Busch
@ 2026-03-05 22:12 ` Gregory Price
2026-03-05 22:43 ` Keith Busch
2026-03-06 1:07 ` dan.j.williams
2026-03-06 15:23 ` Dave Jiang
2 siblings, 1 reply; 10+ messages in thread
From: Gregory Price @ 2026-03-05 22:12 UTC (permalink / raw)
To: Keith Busch; +Cc: linux-cxl, dan.j.williams, dave.jiang, Keith Busch
On Thu, Mar 05, 2026 at 12:40:56PM -0800, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
>
> 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")
> Signed-off-by: Keith Busch <kbusch@kernel.org>
> ---
> drivers/cxl/Kconfig | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/cxl/Kconfig b/drivers/cxl/Kconfig
> index 4589bf11d3fe0..80aeb0d556bd7 100644
> --- a/drivers/cxl/Kconfig
> +++ b/drivers/cxl/Kconfig
> @@ -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/20260302200429.803417-1-gourry@gourry.net/
Not sure which one we want here
~Gregory
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] cxl/acpi: Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch
2026-03-05 22:12 ` Gregory Price
@ 2026-03-05 22:43 ` Keith Busch
2026-03-05 22:56 ` Gregory Price
0 siblings, 1 reply; 10+ messages in thread
From: Keith Busch @ 2026-03-05 22:43 UTC (permalink / raw)
To: Gregory Price; +Cc: Keith Busch, linux-cxl, dan.j.williams, dave.jiang
On Thu, Mar 05, 2026 at 05:12:31PM -0500, Gregory Price wrote:
> > @@ -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/20260302200429.803417-1-gourry@gourry.net/
>
> 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. :)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] cxl/acpi: Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch
2026-03-05 22:43 ` Keith Busch
@ 2026-03-05 22:56 ` Gregory Price
2026-03-05 23:26 ` Keith Busch
0 siblings, 1 reply; 10+ messages in thread
From: Gregory Price @ 2026-03-05 22:56 UTC (permalink / raw)
To: Keith Busch; +Cc: Keith Busch, linux-cxl, dan.j.williams, dave.jiang
On Thu, Mar 05, 2026 at 03:43:17PM -0700, Keith Busch wrote:
> On Thu, Mar 05, 2026 at 05:12:31PM -0500, Gregory Price wrote:
> > > @@ -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/20260302200429.803417-1-gourry@gourry.net/
> >
> > 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. :)
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] cxl/acpi: Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch
2026-03-05 22:56 ` Gregory Price
@ 2026-03-05 23:26 ` Keith Busch
0 siblings, 0 replies; 10+ messages in thread
From: Keith Busch @ 2026-03-05 23:26 UTC (permalink / raw)
To: Gregory Price; +Cc: Keith Busch, linux-cxl, dan.j.williams, dave.jiang
On Thu, Mar 05, 2026 at 05:56:06PM -0500, Gregory Price wrote:
> > 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.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] cxl/acpi: Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch
2026-03-05 20:40 [PATCH] cxl/acpi: Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch Keith Busch
2026-03-05 22:12 ` Gregory Price
@ 2026-03-06 1:07 ` dan.j.williams
2026-03-06 1:26 ` Keith Busch
2026-03-06 15:23 ` Dave Jiang
2 siblings, 1 reply; 10+ messages in thread
From: dan.j.williams @ 2026-03-06 1:07 UTC (permalink / raw)
To: Keith Busch, linux-cxl; +Cc: dan.j.williams, dave.jiang, gourry, Keith Busch
Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
>
> 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")
> Signed-off-by: Keith Busch <kbusch@kernel.org>
> ---
> drivers/cxl/Kconfig | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/cxl/Kconfig b/drivers/cxl/Kconfig
> index 4589bf11d3fe0..80aeb0d556bd7 100644
> --- a/drivers/cxl/Kconfig
> +++ b/drivers/cxl/Kconfig
> @@ -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< --
diff --git a/drivers/cxl/Kconfig b/drivers/cxl/Kconfig
index 4589bf11d3fe..277877da8263 100644
--- a/drivers/cxl/Kconfig
+++ b/drivers/cxl/Kconfig
@@ -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
diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c
index 127537628817..a42ad5035958 100644
--- a/drivers/cxl/acpi.c
+++ b/drivers/cxl/acpi.c
@@ -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;
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH] cxl/acpi: Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch
2026-03-06 1:07 ` dan.j.williams
@ 2026-03-06 1:26 ` Keith Busch
2026-03-06 1:55 ` dan.j.williams
0 siblings, 1 reply; 10+ messages in thread
From: Keith Busch @ 2026-03-06 1:26 UTC (permalink / raw)
To: dan.j.williams; +Cc: Keith Busch, linux-cxl, dave.jiang, gourry
On Thu, Mar 05, 2026 at 05:07:28PM -0800, dan.j.williams@intel.com wrote:
> > The call from cxl_acpi_probe() is guarded by
> > IS_ENABLED(CONFIG_CXL_PMEM), which evaluates to true for both =y and =m.
<snip>
> 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.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] cxl/acpi: Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch
2026-03-06 1:26 ` Keith Busch
@ 2026-03-06 1:55 ` dan.j.williams
2026-03-06 10:50 ` Jonathan Cameron
0 siblings, 1 reply; 10+ messages in thread
From: dan.j.williams @ 2026-03-06 1:55 UTC (permalink / raw)
To: Keith Busch, dan.j.williams; +Cc: Keith Busch, linux-cxl, dave.jiang, gourry
Keith Busch wrote:
> On Thu, Mar 05, 2026 at 05:07:28PM -0800, dan.j.williams@intel.com wrote:
> > > The call from cxl_acpi_probe() is guarded by
> > > IS_ENABLED(CONFIG_CXL_PMEM), which evaluates to true for both =y and =m.
>
> <snip>
>
> > 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,
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
...this is better than what I proposed.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] cxl/acpi: Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch
2026-03-06 1:55 ` dan.j.williams
@ 2026-03-06 10:50 ` Jonathan Cameron
0 siblings, 0 replies; 10+ messages in thread
From: Jonathan Cameron @ 2026-03-06 10:50 UTC (permalink / raw)
To: dan.j.williams; +Cc: Keith Busch, Keith Busch, linux-cxl, dave.jiang, gourry
On Thu, 5 Mar 2026 17:55:43 -0800
dan.j.williams@intel.com wrote:
> Keith Busch wrote:
> > On Thu, Mar 05, 2026 at 05:07:28PM -0800, dan.j.williams@intel.com wrote:
> > > > The call from cxl_acpi_probe() is guarded by
> > > > IS_ENABLED(CONFIG_CXL_PMEM), which evaluates to true for both =y and =m.
> >
> > <snip>
> >
> > > 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,
>
> Reviewed-by: Dan Williams <dan.j.williams@intel.com>
>
> ...this is better than what I proposed.
>
I prefer Keith's solution to Gregory's just because of removing a surprising foot gun.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] cxl/acpi: Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch
2026-03-05 20:40 [PATCH] cxl/acpi: Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch Keith Busch
2026-03-05 22:12 ` Gregory Price
2026-03-06 1:07 ` dan.j.williams
@ 2026-03-06 15:23 ` Dave Jiang
2 siblings, 0 replies; 10+ messages in thread
From: Dave Jiang @ 2026-03-06 15:23 UTC (permalink / raw)
To: Keith Busch, linux-cxl; +Cc: dan.j.williams, gourry, Keith Busch
On 3/5/26 1:40 PM, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
>
> 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")
> Signed-off-by: Keith Busch <kbusch@kernel.org>
Applied to cxl/fixes
93d0fcdddc9e7be9d4f42acbe57bc90dbb0fe75d
> ---
> drivers/cxl/Kconfig | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/cxl/Kconfig b/drivers/cxl/Kconfig
> index 4589bf11d3fe0..80aeb0d556bd7 100644
> --- a/drivers/cxl/Kconfig
> +++ b/drivers/cxl/Kconfig
> @@ -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
^ permalink raw reply [flat|nested] 10+ messages in thread