Re: [PATCH v16 08/18] cxl: Move cxl_rwsem into built-in code

From: Richard Cheng

Date: Fri Oct 30 2026 - 02:27:18 EST


On Thu, Oct 29, 2026 at 02:56:53PM +0800, Srirangan Madhavan wrote:
> Keep the region and DPA locks available to built-in CXL state management
> when cxl_core is modular.
>
> Signed-off-by: Srirangan Madhavan <smadhavan@xxxxxxxxxx>

Reviewed-by: Richard Cheng <icheng@xxxxxxxxxx>

> ---
> drivers/cxl/core/Makefile | 2 +-
> drivers/cxl/core/hdm.c | 5 -----
> drivers/cxl/core/hdm_state.c | 15 +++++++++++++++
> 3 files changed, 16 insertions(+), 6 deletions(-)
> create mode 100644 drivers/cxl/core/hdm_state.c
>
> diff --git a/drivers/cxl/core/Makefile b/drivers/cxl/core/Makefile
> index 6703c1729396..9971efb237fb 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-$(subst m,y,$(CONFIG_CXL_BUS)) += hdm_regs.o
> +obj-$(subst m,y,$(CONFIG_CXL_BUS)) += hdm_regs.o hdm_state.o
> obj-$(CONFIG_CXL_SUSPEND) += suspend.o
>
> ccflags-y += -I$(srctree)/drivers/cxl
> diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
> index 5b5f5f22ea32..85f9abf58a42 100644
> --- a/drivers/cxl/core/hdm.c
> +++ b/drivers/cxl/core/hdm.c
> @@ -17,11 +17,6 @@
> * for enumerating these registers and capabilities.
> */
>
> -struct cxl_rwsem cxl_rwsem = {
> - .region = __RWSEM_INITIALIZER(cxl_rwsem.region),
> - .dpa = __RWSEM_INITIALIZER(cxl_rwsem.dpa),
> -};
> -
> static int add_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld)
> {
> int rc;
> diff --git a/drivers/cxl/core/hdm_state.c b/drivers/cxl/core/hdm_state.c
> new file mode 100644
> index 000000000000..c9cc019902ef
> --- /dev/null
> +++ b/drivers/cxl/core/hdm_state.c
> @@ -0,0 +1,15 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/* Copyright (c) 2026 NVIDIA Corporation & Affiliates */
> +#include <linux/export.h>
> +#include <linux/rwsem.h>
> +
> +#include <cxl/hdm.h>
> +
> +#include "cxl.h"
> +#include "core.h"
> +
> +struct cxl_rwsem cxl_rwsem = {
> + .region = __RWSEM_INITIALIZER(cxl_rwsem.region),
> + .dpa = __RWSEM_INITIALIZER(cxl_rwsem.dpa),
> +};
> +EXPORT_SYMBOL_FOR_MODULES(cxl_rwsem, "cxl_core");
> --
> 2.43.0
>