The cxl_mem_active_inc()/dec() and cxl_mem_active() helpers were initially introduced to coordinate suspend/resume behavior. However, upcoming changes will reuse these helpers to track cxl_mem_probe() activity during SOFT RESERVED region handling.
To reflect this broader purpose, rename suspend.c to probe_state.c and remove CONFIG_CXL_SUSPEND Kconfig option. These helpers are now always built into the CXL core subsystem. This ensures drivers like cxl_acpi to coordinate with cxl_mem for region setup and hotplug handling. Co-developed-by: Nathan Fontenot <nathan.fonte...@amd.com> Signed-off-by: Nathan Fontenot <nathan.fonte...@amd.com> Co-developed-by: Terry Bowman <terry.bow...@amd.com> Signed-off-by: Terry Bowman <terry.bow...@amd.com> Signed-off-by: Smita Koralahalli <smita.koralahallichannabasa...@amd.com> --- While these helpers are no longer specific to suspend, they couldn't be moved into files like memdev.c or mem.c, as those are built as modules. The problem is that cxl_mem_active() is invoked by core kernel components such as kernel/power/suspend.c and hibernate.c, which are built into vmlinux. If the helpers were moved into a module, it would result in unresolved symbol errors as symbols are not guaranteed to be available. One option would be to force memdev.o to be built-in, but that introduces unnecessary constraints, since it includes broader device management logic. Instead, I have renamed it to probe_state.c. --- drivers/cxl/Kconfig | 4 ---- drivers/cxl/core/Makefile | 2 +- drivers/cxl/core/{suspend.c => probe_state.c} | 5 ++++- drivers/cxl/cxlmem.h | 9 --------- include/linux/pm.h | 7 ------- 5 files changed, 5 insertions(+), 22 deletions(-) rename drivers/cxl/core/{suspend.c => probe_state.c} (83%) diff --git a/drivers/cxl/Kconfig b/drivers/cxl/Kconfig index 48b7314afdb8..d407d2c96a7a 100644 --- a/drivers/cxl/Kconfig +++ b/drivers/cxl/Kconfig @@ -189,10 +189,6 @@ config CXL_PORT default CXL_BUS tristate -config CXL_SUSPEND - def_bool y - depends on SUSPEND && CXL_MEM - config CXL_REGION bool "CXL: Region Support" default CXL_BUS diff --git a/drivers/cxl/core/Makefile b/drivers/cxl/core/Makefile index 79e2ef81fde8..0fa7aa530de4 100644 --- a/drivers/cxl/core/Makefile +++ b/drivers/cxl/core/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_CXL_BUS) += cxl_core.o -obj-$(CONFIG_CXL_SUSPEND) += suspend.o +obj-y += probe_state.o ccflags-y += -I$(srctree)/drivers/cxl CFLAGS_trace.o = -DTRACE_INCLUDE_PATH=. -I$(src) diff --git a/drivers/cxl/core/suspend.c b/drivers/cxl/core/probe_state.c similarity index 83% rename from drivers/cxl/core/suspend.c rename to drivers/cxl/core/probe_state.c index 29aa5cc5e565..5ba4b4de0e33 100644 --- a/drivers/cxl/core/suspend.c +++ b/drivers/cxl/core/probe_state.c @@ -8,7 +8,10 @@ static atomic_t mem_active; bool cxl_mem_active(void) { - return atomic_read(&mem_active) != 0; + if (IS_ENABLED(CONFIG_CXL_MEM)) + return atomic_read(&mem_active) != 0; + + return false; } void cxl_mem_active_inc(void) diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index 551b0ba2caa1..86e43475a1e1 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -883,17 +883,8 @@ static inline void devm_cxl_memdev_edac_release(struct cxl_memdev *cxlmd) { return; } #endif -#ifdef CONFIG_CXL_SUSPEND void cxl_mem_active_inc(void); void cxl_mem_active_dec(void); -#else -static inline void cxl_mem_active_inc(void) -{ -} -static inline void cxl_mem_active_dec(void) -{ -} -#endif int cxl_mem_sanitize(struct cxl_memdev *cxlmd, u16 cmd); diff --git a/include/linux/pm.h b/include/linux/pm.h index f0bd8fbae4f2..415928e0b6ca 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -35,14 +35,7 @@ static inline void pm_vt_switch_unregister(struct device *dev) } #endif /* CONFIG_VT_CONSOLE_SLEEP */ -#ifdef CONFIG_CXL_SUSPEND bool cxl_mem_active(void); -#else -static inline bool cxl_mem_active(void) -{ - return false; -} -#endif /* * Device power management -- 2.17.1