Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/164367759016.324231.105551648350470000.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>

+7 -2
+2
drivers/cxl/acpi.c
··· 342 342 return 0; 343 343 } 344 344 345 + cxl_device_lock(&root_port->dev); 345 346 rc = cxl_add_dport(root_port, match, uid, ctx.chbcr); 347 + cxl_device_unlock(&root_port->dev); 346 348 if (rc) { 347 349 dev_err(host, "failed to add downstream port: %s\n", 348 350 dev_name(match));
+1 -2
drivers/cxl/core/port.c
··· 519 519 { 520 520 struct cxl_dport *dup; 521 521 522 - cxl_device_lock(&port->dev); 522 + device_lock_assert(&port->dev); 523 523 dup = find_dport(port, new->port_id); 524 524 if (dup) 525 525 dev_err(&port->dev, ··· 528 528 dev_name(dup->dport)); 529 529 else 530 530 list_add_tail(&new->list, &port->dports); 531 - cxl_device_unlock(&port->dev); 532 531 533 532 return dup ? -EEXIST : 0; 534 533 }
+4
tools/testing/cxl/mock_acpi.c
··· 57 57 58 58 /* TODO walk DVSEC to find component register base */ 59 59 port_num = FIELD_GET(PCI_EXP_LNKCAP_PN, lnkcap); 60 + cxl_device_lock(&port->dev); 60 61 rc = cxl_add_dport(port, &pdev->dev, port_num, CXL_RESOURCE_NONE); 62 + cxl_device_unlock(&port->dev); 61 63 if (rc) { 62 64 dev_err(dev, "failed to add dport: %s (%d)\n", 63 65 dev_name(&pdev->dev), rc); ··· 80 78 struct device *dev = ctx->dev; 81 79 int rc; 82 80 81 + cxl_device_lock(&port->dev); 83 82 rc = cxl_add_dport(port, &pdev->dev, pdev->id, CXL_RESOURCE_NONE); 83 + cxl_device_unlock(&port->dev); 84 84 if (rc) { 85 85 dev_err(dev, "failed to add dport: %s (%d)\n", 86 86 dev_name(&pdev->dev), rc);