Skip to content

Commit f29a824

Browse files
committed
cxl/pci: Clarify devm host for memdev relative setup
It is all too easy to get confused about @dev usage in the CXL driver stack. Before adding a new cxl_pci_probe() setup operation that has a devm lifetime dependent on @cxlds->dev binding, but also references @cxlmd->dev, and prints messages, rework the devm_cxl_add_memdev() and cxl_memdev_setup_fw_upload() function signatures to make this distinction explicit. I.e. pass in the devm context as an @host argument rather than infer it from other objects. This is in preparation for adding a devm_cxl_sanitize_setup_notifier(). Note the whitespace fixup near the change of the devm_cxl_add_memdev() signature. That uncaught typo originated in the patch that added cxl_memdev_security_init(). Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 2627c99 commit f29a824

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

drivers/cxl/core/memdev.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -960,12 +960,12 @@ static const struct fw_upload_ops cxl_memdev_fw_ops = {
960960
.cleanup = cxl_fw_cleanup,
961961
};
962962

963-
static void devm_cxl_remove_fw_upload(void *fwl)
963+
static void cxl_remove_fw_upload(void *fwl)
964964
{
965965
firmware_upload_unregister(fwl);
966966
}
967967

968-
int cxl_memdev_setup_fw_upload(struct cxl_memdev_state *mds)
968+
int devm_cxl_setup_fw_upload(struct device *host, struct cxl_memdev_state *mds)
969969
{
970970
struct cxl_dev_state *cxlds = &mds->cxlds;
971971
struct device *dev = &cxlds->cxlmd->dev;
@@ -978,10 +978,9 @@ int cxl_memdev_setup_fw_upload(struct cxl_memdev_state *mds)
978978
&cxl_memdev_fw_ops, mds);
979979
if (IS_ERR(fwl))
980980
return PTR_ERR(fwl);
981-
982-
return devm_add_action_or_reset(cxlds->dev, devm_cxl_remove_fw_upload, fwl);
981+
return devm_add_action_or_reset(host, cxl_remove_fw_upload, fwl);
983982
}
984-
EXPORT_SYMBOL_NS_GPL(cxl_memdev_setup_fw_upload, CXL);
983+
EXPORT_SYMBOL_NS_GPL(devm_cxl_setup_fw_upload, CXL);
985984

986985
static const struct file_operations cxl_memdev_fops = {
987986
.owner = THIS_MODULE,
@@ -1019,9 +1018,10 @@ static int cxl_memdev_security_init(struct cxl_memdev *cxlmd)
10191018
}
10201019

10211020
return devm_add_action_or_reset(cxlds->dev, put_sanitize, mds);
1022-
}
1021+
}
10231022

1024-
struct cxl_memdev *devm_cxl_add_memdev(struct cxl_dev_state *cxlds)
1023+
struct cxl_memdev *devm_cxl_add_memdev(struct device *host,
1024+
struct cxl_dev_state *cxlds)
10251025
{
10261026
struct cxl_memdev *cxlmd;
10271027
struct device *dev;
@@ -1053,7 +1053,7 @@ struct cxl_memdev *devm_cxl_add_memdev(struct cxl_dev_state *cxlds)
10531053
if (rc)
10541054
goto err;
10551055

1056-
rc = devm_add_action_or_reset(cxlds->dev, cxl_memdev_unregister, cxlmd);
1056+
rc = devm_add_action_or_reset(host, cxl_memdev_unregister, cxlmd);
10571057
if (rc)
10581058
return ERR_PTR(rc);
10591059
return cxlmd;

drivers/cxl/cxlmem.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ static inline bool is_cxl_endpoint(struct cxl_port *port)
8484
return is_cxl_memdev(port->uport_dev);
8585
}
8686

87-
struct cxl_memdev *devm_cxl_add_memdev(struct cxl_dev_state *cxlds);
87+
struct cxl_memdev *devm_cxl_add_memdev(struct device *host,
88+
struct cxl_dev_state *cxlds);
8889
struct cxl_memdev_state;
89-
int cxl_memdev_setup_fw_upload(struct cxl_memdev_state *mds);
90+
int devm_cxl_setup_fw_upload(struct device *host, struct cxl_memdev_state *mds);
9091
int devm_cxl_dpa_reserve(struct cxl_endpoint_decoder *cxled,
9192
resource_size_t base, resource_size_t len,
9293
resource_size_t skipped);

drivers/cxl/pci.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,11 +867,11 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
867867
if (rc)
868868
return rc;
869869

870-
cxlmd = devm_cxl_add_memdev(cxlds);
870+
cxlmd = devm_cxl_add_memdev(&pdev->dev, cxlds);
871871
if (IS_ERR(cxlmd))
872872
return PTR_ERR(cxlmd);
873873

874-
rc = cxl_memdev_setup_fw_upload(mds);
874+
rc = devm_cxl_setup_fw_upload(&pdev->dev, mds);
875875
if (rc)
876876
return rc;
877877

tools/testing/cxl/test/mem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,11 +1450,11 @@ static int cxl_mock_mem_probe(struct platform_device *pdev)
14501450
mdata->mes.mds = mds;
14511451
cxl_mock_add_event_logs(&mdata->mes);
14521452

1453-
cxlmd = devm_cxl_add_memdev(cxlds);
1453+
cxlmd = devm_cxl_add_memdev(&pdev->dev, cxlds);
14541454
if (IS_ERR(cxlmd))
14551455
return PTR_ERR(cxlmd);
14561456

1457-
rc = cxl_memdev_setup_fw_upload(mds);
1457+
rc = devm_cxl_setup_fw_upload(&pdev->dev, mds);
14581458
if (rc)
14591459
return rc;
14601460

0 commit comments

Comments
 (0)