Skip to content

Commit

Permalink
cxl/mem: Register CXL memX devices
Browse files Browse the repository at this point in the history
Create the /sys/bus/cxl hierarchy to enumerate memory devices
(per-endpoint control devices), memory address space devices (platform
address ranges with interleaving, performance, and persistence
attributes), and memory regions (active provisioned memory from an
address space device that is in use as System RAM or delegated to
libnvdimm as Persistent Memory regions).

For now, only the per-endpoint control devices are registered on the
'cxl' bus.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
  • Loading branch information
djbw authored and intel-lab-lkp committed Nov 11, 2020
1 parent 8f881aa commit 69b8720
Show file tree
Hide file tree
Showing 5 changed files with 359 additions and 6 deletions.
2 changes: 2 additions & 0 deletions drivers/cxl/Makefile
@@ -1,7 +1,9 @@
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_CXL_ACPI) += cxl_acpi.o
obj-$(CONFIG_CXL_MEM) += cxl_mem.o
obj-$(CONFIG_CXL_BUS_PROVIDER) += cxl_bus.o

ccflags-y += -DDEFAULT_SYMBOL_NAMESPACE=CXL
cxl_acpi-y := acpi.o
cxl_mem-y := mem.o
cxl_bus-y := bus.o
35 changes: 35 additions & 0 deletions drivers/cxl/bus.c
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: GPL-2.0-only
// Copyright(c) 2020 Intel Corporation. All rights reserved.
#include <linux/device.h>
#include <linux/module.h>

static struct bus_type cxl_bus_type = {
.name = "cxl",
};

int cxl_register(struct device *dev)
{
int rc;

dev->bus = &cxl_bus_type;
rc = device_add(dev);
if (rc)
put_device(dev);
return rc;
}
EXPORT_SYMBOL_GPL(cxl_register);

static __init int cxl_bus_init(void)
{
return bus_register(&cxl_bus_type);
}

static void cxl_bus_exit(void)
{
bus_unregister(&cxl_bus_type);
}

module_init(cxl_bus_init);
module_exit(cxl_bus_exit);
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Intel Corporation");
8 changes: 8 additions & 0 deletions drivers/cxl/bus.h
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: GPL-2.0-only
// Copyright(c) 2020 Intel Corporation. All rights reserved.
#ifndef __CXL_BUS_H__
#define __CXL_BUS_H__

int cxl_register(struct device *dev);

#endif /* __CXL_BUS_H__ */
33 changes: 33 additions & 0 deletions drivers/cxl/cxl.h
Expand Up @@ -3,6 +3,7 @@

#ifndef __CXL_H__
#define __CXL_H__
#include <linux/range.h>

/* Device */
#define CXLDEV_CAP_ARRAY_REG 0x0
Expand Down Expand Up @@ -52,12 +53,24 @@
#define CXLMDEV_RESET_NEEDED_HOT 3
#define CXLMDEV_RESET_NEEDED_CXL 4

struct cxl_memdev;
struct cxl_mem {
struct pci_dev *pdev;
void __iomem *regs;
struct cxl_memdev *cxlmd;

spinlock_t mbox_lock; /* Protects device mailbox and firmware */

struct {
struct range range;
} pmem;

struct {
struct range range;
} ram;

char firmware_version[0x10];

/* Cap 0000h */
struct {
void __iomem *regs;
Expand Down Expand Up @@ -130,4 +143,24 @@ static inline void cxl_mbox_payload_drain(struct cxl_mem *cxlm,
{
memcpy_fromio(output, cxlm->mbox.regs + CXLDEV_MB_PAYLOAD, length);
}

#define CXL_MBOX_IDENTIFY 0x4000

struct cxl_mbox_identify {
char fw_revision[0x10];
__le64 total_capacity;
__le64 volatile_capacity;
__le64 persistent_capacity;
__le64 partition_align;
__le16 info_event_log_size;
__le16 warning_event_log_size;
__le16 failure_event_log_size;
__le16 fatal_event_log_size;
__le32 lsa_size;
u8 poison_list_max_mer[3];
__le16 inject_poison_limit;
u8 poison_caps;
u8 qos_telemetry_caps;
} __packed;

#endif /* __CXL_H__ */

0 comments on commit 69b8720

Please sign in to comment.