@@ -1404,6 +1404,9 @@ struct cxl_memdev_state *cxl_memdev_state_create(struct device *dev)
mds->cxlds.reg_map.host = dev;
mds->cxlds.reg_map.resource = CXL_RESOURCE_NONE;
mds->cxlds.type = CXL_DEVTYPE_CLASSMEM;
+ INIT_LIST_HEAD(&mds->unmatched_perf_list);
+ INIT_LIST_HEAD(&mds->ram_perf_list);
+ INIT_LIST_HEAD(&mds->pmem_perf_list);
return mds;
}
@@ -6,6 +6,7 @@
#include <linux/cdev.h>
#include <linux/uuid.h>
#include <linux/rcuwait.h>
+#include <linux/node.h>
#include "cxl.h"
/* CXL 2.0 8.2.8.5.1.1 Memory Device Status Register */
@@ -391,6 +392,20 @@ enum cxl_devtype {
CXL_DEVTYPE_CLASSMEM,
};
+/**
+ * struct perf_prop - performance property entry
+ * @list - list entry
+ * @dpa_range - range for DPA address
+ * @coord - QoS performance data (i.e. latency, bandwidth)
+ * @qos_class - QoS Class cookies
+ */
+struct perf_prop_entry {
+ struct list_head list;
+ struct range dpa_range;
+ struct access_coordinate coord;
+ int qos_class;
+};
+
/**
* struct cxl_dev_state - The driver device state
*
@@ -455,6 +470,9 @@ struct cxl_dev_state {
* @security: security driver state info
* @fw: firmware upload / activation state
* @mbox_send: @dev specific transport for transmitting mailbox commands
+ * @ram_perf_list: performance data entries matched to RAM
+ * @pmem_qos_class: performance data entries matched to PMEM
+ * @unmatched_perf_list: unmatched performance data entries list
*
* See CXL 3.0 8.2.9.8.2 Capacity Configuration and Label Storage for
* details on capacity parameters.
@@ -475,6 +493,11 @@ struct cxl_memdev_state {
u64 active_persistent_bytes;
u64 next_volatile_bytes;
u64 next_persistent_bytes;
+
+ struct list_head ram_perf_list;
+ struct list_head pmem_perf_list;
+ struct list_head unmatched_perf_list;
+
struct cxl_event_state event;
struct cxl_poison_state poison;
struct cxl_security_state security;
@@ -106,6 +106,42 @@ static int cxl_port_perf_data_calculate(struct cxl_port *port,
return 0;
}
+static void cxl_memdev_set_qos_class(struct cxl_dev_state *cxlds,
+ struct xarray *dsmas_xa)
+{
+ struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlds);
+ struct range pmem_range = {
+ .start = cxlds->pmem_res.start,
+ .end = cxlds->pmem_res.end,
+ };
+ struct range ram_range = {
+ .start = cxlds->ram_res.start,
+ .end = cxlds->ram_res.end,
+ };
+ struct perf_prop_entry *perf;
+ struct dsmas_entry *dent;
+ unsigned long index;
+
+ xa_for_each(dsmas_xa, index, dent) {
+ perf = devm_kzalloc(cxlds->dev, sizeof(*perf), GFP_KERNEL);
+ if (!perf)
+ return;
+
+ perf->dpa_range = dent->dpa_range;
+ perf->coord = dent->coord;
+ perf->qos_class = dent->qos_class;
+
+ if (resource_size(&cxlds->ram_res) &&
+ range_contains(&ram_range, &dent->dpa_range))
+ list_add_tail(&perf->list, &mds->ram_perf_list);
+ else if (resource_size(&cxlds->pmem_res) &&
+ range_contains(&pmem_range, &dent->dpa_range))
+ list_add_tail(&perf->list, &mds->pmem_perf_list);
+ else
+ list_add_tail(&perf->list, &mds->unmatched_perf_list);
+ }
+}
+
static int cxl_switch_port_probe(struct cxl_port *port)
{
struct cxl_hdm *cxlhdm;
@@ -197,13 +233,18 @@ static int cxl_endpoint_port_probe(struct cxl_port *port)
rc = cxl_cdat_endpoint_process(port, &dsmas_xa);
if (rc < 0) {
dev_dbg(&port->dev, "Failed to parse CDAT: %d\n", rc);
- } else {
- rc = cxl_port_perf_data_calculate(port, &dsmas_xa);
- if (rc)
- dev_dbg(&port->dev,
- "Failed to do perf coord calculations.\n");
+ goto out;
+ }
+
+ rc = cxl_port_perf_data_calculate(port, &dsmas_xa);
+ if (rc) {
+ dev_dbg(&port->dev,
+ "Failed to do perf coord calculations.\n");
+ goto out;
}
+ cxl_memdev_set_qos_class(cxlds, &dsmas_xa);
+out:
cxl_cdat_dsmas_xa_destroy(&dsmas_xa);
}