cxl/pmem: Register 'pmem' / cxl_nvdimm devices
authorDan Williams <dan.j.williams@intel.com>
Tue, 15 Jun 2021 23:36:31 +0000 (16:36 -0700)
committerDan Williams <dan.j.williams@intel.com>
Tue, 15 Jun 2021 23:47:34 +0000 (16:47 -0700)
commit21083f51521fb0f60dbac591f175c3ed48435af4
treef9b813ffc5cd6d524b55a1888bb5c2d136c5fe76
parent2bbafda405c04cfed1b57b761d13ada3154c0f89
cxl/pmem: Register 'pmem' / cxl_nvdimm devices

While a memX device on /sys/bus/cxl represents a CXL memory expander
control interface, a pmemX device represents the persistent memory
sub-functionality. It bridges the CXL subystem to the libnvdimm nmemX
control interface.

With this skeleton ndctl can now see persistent memory devices on a
"CXL" bus. Later patches add support for translating libnvdimm native
commands to CXL commands.

# ndctl list -BDiu -b CXL
{
  "provider":"CXL",
  "dev":"ndbus1",
  "dimms":[
    {
      "dev":"nmem1",
      "state":"disabled"
    },
    {
      "dev":"nmem0",
      "state":"disabled"
    }
  ]
}

Given nvdimm_bus_unregister() removes all devices on an ndbus0 the
cxl_pmem infrastructure needs to arrange ->remove() to be triggered on
cxl_nvdimm devices to keep their enabled state synchronized with the
registration state of their corresponding device on the nvdimm_bus. In
other words, always arrange for cxl_nvdimm_driver.remove() to unregister
nvdimms from an nvdimm_bus ahead of the bus being unregistered.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/162380012696.3039556.4293801691038740850.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/cxl/core.c
drivers/cxl/cxl.h
drivers/cxl/mem.h
drivers/cxl/pci.c
drivers/cxl/pmem.c