@@ -162,7 +162,6 @@ static int cxl_port_perf_data_calculate(struct cxl_port *port,
struct xarray *dsmas_xa)
{
struct access_coordinate c;
- struct cxl_port *root_port;
struct cxl_root *cxl_root;
struct dsmas_entry *dent;
int valid_entries = 0;
@@ -175,8 +174,7 @@ static int cxl_port_perf_data_calculate(struct cxl_port *port,
return rc;
}
- root_port = find_cxl_root(port);
- cxl_root = to_cxl_root(root_port);
+ cxl_root = find_cxl_root(port);
if (!cxl_root->ops || !cxl_root->ops->qos_class)
return -EOPNOTSUPP;
@@ -193,7 +191,8 @@ static int cxl_port_perf_data_calculate(struct cxl_port *port,
dent->coord.write_bandwidth);
dent->entries = 1;
- rc = cxl_root->ops->qos_class(root_port, &dent->coord, 1, &qos_class);
+ rc = cxl_root->ops->qos_class(&cxl_root->port, &dent->coord, 1,
+ &qos_class);
if (rc != 1)
continue;
@@ -351,14 +350,17 @@ static int cxl_qos_class_verify(struct cxl_memdev *cxlmd)
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlds);
LIST_HEAD(__discard);
struct list_head *discard __free(dpa_perf) = &__discard;
+ struct cxl_port *root_port;
int rc;
- struct cxl_port *root_port __free(put_cxl_root) =
+ struct cxl_root *cxl_root __free(put_cxl_root) =
find_cxl_root(cxlmd->endpoint);
- if (!root_port)
+ if (!cxl_root)
return -ENODEV;
+ root_port = &cxl_root->port;
+
/* Check that the QTG IDs are all sane between end device and root decoders */
cxl_qos_match(root_port, &mds->ram_perf_list, discard);
cxl_qos_match(root_port, &mds->pmem_perf_list, discard);
@@ -64,14 +64,16 @@ static int match_nvdimm_bridge(struct device *dev, void *data)
struct cxl_nvdimm_bridge *cxl_find_nvdimm_bridge(struct cxl_memdev *cxlmd)
{
- struct cxl_port *port = find_cxl_root(cxlmd->endpoint);
+ struct cxl_root *cxl_root = find_cxl_root(cxlmd->endpoint);
+ struct cxl_port *port;
struct device *dev;
- if (!port)
+ if (!cxl_root)
return NULL;
+ port = &cxl_root->port;
dev = device_find_child(&port->dev, NULL, match_nvdimm_bridge);
- put_device(&port->dev);
+ put_cxl_root(cxl_root);
if (!dev)
return NULL;
@@ -972,7 +972,7 @@ static bool dev_is_cxl_root_child(struct device *dev)
return false;
}
-struct cxl_port *find_cxl_root(struct cxl_port *port)
+struct cxl_root *find_cxl_root(struct cxl_port *port)
{
struct cxl_port *iter = port;
@@ -982,18 +982,18 @@ struct cxl_port *find_cxl_root(struct cxl_port *port)
if (!iter)
return NULL;
get_device(&iter->dev);
- return iter;
+ return to_cxl_root(iter);
}
EXPORT_SYMBOL_NS_GPL(find_cxl_root, CXL);
-void put_cxl_root(struct cxl_port *port)
+void put_cxl_root(struct cxl_root *cxl_root)
{
- if (!port)
+ if (!cxl_root)
return;
- put_device(&port->dev);
+ put_device(&cxl_root->port.dev);
}
-EXPORT_SYMBOL_NS_GPL(put_cxl_root);
+EXPORT_SYMBOL_NS_GPL(put_cxl_root, CXL);
static struct cxl_dport *find_dport(struct cxl_port *port, int id)
{
@@ -734,9 +734,9 @@ struct cxl_port *devm_cxl_add_port(struct device *host,
struct cxl_dport *parent_dport);
struct cxl_root *devm_cxl_add_root(struct device *host,
const struct cxl_root_ops *ops);
-struct cxl_port *find_cxl_root(struct cxl_port *port);
-void put_cxl_root(struct cxl_port *port);
-DEFINE_FREE(put_cxl_root, struct cxl_port *, if (_T) put_cxl_root(_T))
+struct cxl_root *find_cxl_root(struct cxl_port *port);
+void put_cxl_root(struct cxl_root *cxl_root);
+DEFINE_FREE(put_cxl_root, struct cxl_root *, if (_T) put_cxl_root(_T))
int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd);
void cxl_bus_rescan(void);
@@ -95,7 +95,8 @@ static int cxl_endpoint_port_probe(struct cxl_port *port)
struct cxl_memdev *cxlmd = to_cxl_memdev(port->uport_dev);
struct cxl_dev_state *cxlds = cxlmd->cxlds;
struct cxl_hdm *cxlhdm;
- struct cxl_port *root;
+ struct cxl_root *cxl_root;
+ struct cxl_port *root_port;
int rc;
rc = cxl_dvsec_rr_decode(cxlds->dev, cxlds->cxl_dvsec, &info);
@@ -130,14 +131,15 @@ static int cxl_endpoint_port_probe(struct cxl_port *port)
* This can't fail in practice as CXL root exit unregisters all
* descendant ports and that in turn synchronizes with cxl_port_probe()
*/
- root = find_cxl_root(port);
+ cxl_root = find_cxl_root(port);
+ root_port = &cxl_root->port;
/*
* Now that all endpoint decoders are successfully enumerated, try to
* assemble regions from committed decoders
*/
- device_for_each_child(&port->dev, root, discover_region);
- put_device(&root->dev);
+ device_for_each_child(&root_port->dev, root_port, discover_region);
+ put_cxl_root(cxl_root);
return 0;
}
Commit 790815902ec6 ("cxl: Add support for _DSM Function for retrieving QTG ID") introduced 'struct cxl_root', however all usages have been worked indirectly through cxl_port. Refactor code such as find_cxl_root() function to use 'struct cxl_root' directly. Suggested-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com> --- v4: - Adjust ordering of patches to move this to 2nd place. (Dan) --- drivers/cxl/core/cdat.c | 14 ++++++++------ drivers/cxl/core/pmem.c | 8 +++++--- drivers/cxl/core/port.c | 12 ++++++------ drivers/cxl/cxl.h | 6 +++--- drivers/cxl/port.c | 10 ++++++---- 5 files changed, 28 insertions(+), 22 deletions(-)