@@ -1,10 +1,11 @@
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_CXL_BUS) += core/
-obj-$(CONFIG_CXL_MEM) += cxl_pci.o cxl_region.o
+obj-$(CONFIG_CXL_MEM) += cxl_mem.o cxl_pci.o cxl_region.o
obj-$(CONFIG_CXL_ACPI) += cxl_acpi.o
obj-$(CONFIG_CXL_PMEM) += cxl_pmem.o
cxl_acpi-y := acpi.o
+cxl_mem-y := mem.o
cxl_pci-y := pci.o
cxl_acpi-y := acpi.o
cxl_pmem-y := pmem.o
@@ -740,6 +740,8 @@ static int cxl_device_id(struct device *dev)
return CXL_DEVICE_NVDIMM;
if (is_cxl_region(dev))
return CXL_DEVICE_REGION;
+ if (is_cxl_memdev(dev))
+ return CXL_DEVICE_ENDPOINT;
return 0;
}
@@ -217,3 +217,8 @@ devm_cxl_add_memdev(struct device *host, struct cxl_mem *cxlm,
return ERR_PTR(rc);
}
EXPORT_SYMBOL_GPL(devm_cxl_add_memdev);
+
+bool is_cxl_memdev(struct device *dev)
+{
+ return dev->type == &cxl_memdev_type;
+}
@@ -321,6 +321,7 @@ enum cxl_driver_id {
CXL_DEVICE_NVDIMM_BRIDGE,
CXL_DEVICE_NVDIMM,
CXL_DEVICE_REGION,
+ CXL_DEVICE_ENDPOINT,
};
struct cxl_driver {
new file mode 100644
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright(c) 2021 Intel Corporation. All rights reserved. */
+#include <linux/device.h>
+#include <linux/module.h>
+#include "mem.h"
+
+/**
+ * DOC: cxl mem
+ *
+ * CXL memory endpoint devices are CXL capable devices that are participating in
+ * CXL.mem protocol. Their functionality builds on top of the CXL.io protocol
+ * that allows enumerating and configuring a CXL endpoint via standard PCI
+ * mechanisms.
+ */
+
+static int cxl_memdev_probe(struct device *dev)
+{
+ return -EOPNOTSUPP;
+}
+
+static void cxl_memdev_remove(struct device *dev)
+{
+}
+
+static struct cxl_driver cxl_memdev_driver = {
+ .name = "cxl_memdev",
+ .probe = cxl_memdev_probe,
+ .remove = cxl_memdev_remove,
+ .id = CXL_DEVICE_ENDPOINT,
+};
+
+static __init int cxl_memdev_init(void)
+{
+ return cxl_driver_register(&cxl_memdev_driver);
+}
+
+static __exit void cxl_memdev_exit(void)
+{
+ cxl_driver_unregister(&cxl_memdev_driver);
+}
+
+MODULE_LICENSE("GPL v2");
+module_init(cxl_memdev_init);
+module_exit(cxl_memdev_exit);
+MODULE_IMPORT_NS(CXL);
@@ -98,4 +98,6 @@ static inline bool is_cxl_mem_capable(struct cxl_memdev *cxlmd)
return false;
}
+bool is_cxl_memdev(struct device *dev);
+
#endif /* __CXL_MEM_H__ */
CXL endpoints that participate in the CXL.mem protocol require extra control to ensure architectural constraints are met for device management. This driver will implement those controls. Signed-off-by: Ben Widawsky <ben.widawsky@intel.com> --- drivers/cxl/Makefile | 3 ++- drivers/cxl/core/bus.c | 2 ++ drivers/cxl/core/memdev.c | 5 +++++ drivers/cxl/cxl.h | 1 + drivers/cxl/mem.c | 45 +++++++++++++++++++++++++++++++++++++++ drivers/cxl/mem.h | 2 ++ 6 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 drivers/cxl/mem.c