Commit c978f1b1 authored by Dan Williams's avatar Dan Williams

cxl/port: Up-level cxl_add_dport() locking requirements to the caller

In preparation for moving dport enumeration into the core, require the
port device lock to be acquired by the caller.
Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/164367759016.324231.105551648350470000.stgit@dwillia2-desk3.amr.corp.intel.comSigned-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent a46cfc0f
...@@ -342,7 +342,9 @@ static int add_host_bridge_dport(struct device *match, void *arg) ...@@ -342,7 +342,9 @@ static int add_host_bridge_dport(struct device *match, void *arg)
return 0; return 0;
} }
cxl_device_lock(&root_port->dev);
rc = cxl_add_dport(root_port, match, uid, ctx.chbcr); rc = cxl_add_dport(root_port, match, uid, ctx.chbcr);
cxl_device_unlock(&root_port->dev);
if (rc) { if (rc) {
dev_err(host, "failed to add downstream port: %s\n", dev_err(host, "failed to add downstream port: %s\n",
dev_name(match)); dev_name(match));
......
...@@ -519,7 +519,7 @@ static int add_dport(struct cxl_port *port, struct cxl_dport *new) ...@@ -519,7 +519,7 @@ static int add_dport(struct cxl_port *port, struct cxl_dport *new)
{ {
struct cxl_dport *dup; struct cxl_dport *dup;
cxl_device_lock(&port->dev); device_lock_assert(&port->dev);
dup = find_dport(port, new->port_id); dup = find_dport(port, new->port_id);
if (dup) if (dup)
dev_err(&port->dev, dev_err(&port->dev,
...@@ -528,7 +528,6 @@ static int add_dport(struct cxl_port *port, struct cxl_dport *new) ...@@ -528,7 +528,6 @@ static int add_dport(struct cxl_port *port, struct cxl_dport *new)
dev_name(dup->dport)); dev_name(dup->dport));
else else
list_add_tail(&new->list, &port->dports); list_add_tail(&new->list, &port->dports);
cxl_device_unlock(&port->dev);
return dup ? -EEXIST : 0; return dup ? -EEXIST : 0;
} }
......
...@@ -57,7 +57,9 @@ static int match_add_root_port(struct pci_dev *pdev, void *data) ...@@ -57,7 +57,9 @@ static int match_add_root_port(struct pci_dev *pdev, void *data)
/* TODO walk DVSEC to find component register base */ /* TODO walk DVSEC to find component register base */
port_num = FIELD_GET(PCI_EXP_LNKCAP_PN, lnkcap); port_num = FIELD_GET(PCI_EXP_LNKCAP_PN, lnkcap);
cxl_device_lock(&port->dev);
rc = cxl_add_dport(port, &pdev->dev, port_num, CXL_RESOURCE_NONE); rc = cxl_add_dport(port, &pdev->dev, port_num, CXL_RESOURCE_NONE);
cxl_device_unlock(&port->dev);
if (rc) { if (rc) {
dev_err(dev, "failed to add dport: %s (%d)\n", dev_err(dev, "failed to add dport: %s (%d)\n",
dev_name(&pdev->dev), rc); dev_name(&pdev->dev), rc);
...@@ -78,7 +80,9 @@ static int mock_add_root_port(struct platform_device *pdev, void *data) ...@@ -78,7 +80,9 @@ static int mock_add_root_port(struct platform_device *pdev, void *data)
struct device *dev = ctx->dev; struct device *dev = ctx->dev;
int rc; int rc;
cxl_device_lock(&port->dev);
rc = cxl_add_dport(port, &pdev->dev, pdev->id, CXL_RESOURCE_NONE); rc = cxl_add_dport(port, &pdev->dev, pdev->id, CXL_RESOURCE_NONE);
cxl_device_unlock(&port->dev);
if (rc) { if (rc) {
dev_err(dev, "failed to add dport: %s (%d)\n", dev_err(dev, "failed to add dport: %s (%d)\n",
dev_name(&pdev->dev), rc); dev_name(&pdev->dev), rc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment