Re: [PATCH v2 1/3] drivers/cxl: introduce cxl_region_driver field for cxl_region
From: Gregory Price
Date: Wed Jan 14 2026 - 13:23:24 EST
On Wed, Jan 14, 2026 at 10:15:28AM -0800, Alison Schofield wrote:
> 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.
>
Can do.
> > + /* PMEM drivers cannot be changed */
> > + if (cxlr->mode == CXL_PARTMODE_PMEM)
> > + return -EBUSY;
>
> why isn't above "if (cxlr->driver == CXL_REGION_DRIVER_PMEM)"
>
I wanted to future-proof against someone trying to do something silly
like changing PMEM to come up as REGION_DRIVER_NONE and then scootching
past the check here. But I can change to
if (cxlr->mode == CXL_PARTMODE_PMEM ||
cxlr->driver CXL_REGION_DRIVER_PMEM)
to make this even more explicit.
~Gregory