Re: [PATCH v2 1/3] drivers/cxl: introduce cxl_region_driver field for cxl_region

From: Alison Schofield

Date: Wed Jan 14 2026 - 13:15:40 EST


On Tue, Jan 13, 2026 at 03:21:36PM -0500, Gregory Price wrote:
> The CXL driver presently has 3 modes of managing a cxl_region:
> - no specific driver (bios-onlined SystemRAM)
> - dax_region (all other RAM regions, for now)
> - pmem_region (all PMEM regions)
>
> Formalize these into specific "region drivers".
>
> enum cxl_region_driver {
> CXL_REGION_DRIVER_NONE,
> CXL_REGION_DRIVER_DAX,
> CXL_REGION_DRIVER_PMEM
> };
>
> $cat regionN/region_driver
> [none,dax,pmem]
>
> The intent is to clarify how to to add additional drivers (sysram,
> dynamic_capacity, etc) in the future, and to allow switching the
> driver selection via a sysfs entry `regionN/region_driver`.

Needs description in Documentation/ABI/testing/sysfs-bus-cxl
I think that will help me understand the switching we expect
to support.


> All RAM regions will be defaulted to CXL_CONTROL_DAX.

CXL_CONTROL_DAX ?

>
> Auto-regions will either be static sysram (BIOS-onlined) and has no
> region controller associated with it - or if the SP bit was set a
> DAX device will be created. This will be discovered at probe time.
>
> Signed-off-by: Gregory Price <gourry@xxxxxxxxxx>

snip

> +static ssize_t region_driver_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t len)
> +{
> + struct cxl_region *cxlr = to_cxl_region(dev);
> + struct cxl_region_params *p = &cxlr->params;
> + int rc;
> +
> + ACQUIRE(rwsem_write_kill, rwsem)(&cxl_rwsem.region);
> + if ((rc = ACQUIRE_ERR(rwsem_write_kill, &rwsem)))
> + return rc;
> +
> + if (p->state >= CXL_CONFIG_COMMIT)
> + return -EBUSY;
> +
> + /* PMEM drivers cannot be changed */
> + if (cxlr->mode == CXL_PARTMODE_PMEM)
> + return -EBUSY;

why isn't above "if (cxlr->driver == CXL_REGION_DRIVER_PMEM)"

> +
> + /* NONE type is not a valid selection for manually probed regions */
> + if (sysfs_streq(buf, "dax"))
> + cxlr->driver = CXL_REGION_DRIVER_DAX;
> + else
> + return -EINVAL;
> +
> + return len;
> +}