]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cxl: Fix devm host device for CXL fwctl initialization
authorDave Jiang <dave.jiang@intel.com>
Fri, 18 Apr 2025 00:29:33 +0000 (17:29 -0700)
committerDave Jiang <dave.jiang@intel.com>
Fri, 18 Apr 2025 16:33:04 +0000 (09:33 -0700)
Testing revealed the following error message for a CXL memdev that has
Feature support:
[   56.690430] cxl mem0: Resources present before probing

Attach the allocation of cxl_fwctl to the parent device of cxl_memdev.
devm_add_* calls for cxl_memdev should not happen before the memdev
probe function or outside the scope of the memdev driver.

cxl_test missed this bug because cxl_test always arranges for the
cxl_mem driver to be loaded before cxl_mock_mem runs. So the driver core
always finds the devres list idle in that case.

[DJ: Updated subject title and added commit log suggestion from djbw]

Fixes: 858ce2f56b52 ("cxl: Add FWCTL support to CXL")
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Link: https://lore.kernel.org/linux-cxl/6801aea053466_71fe2944c@dwillia2-xfh.jf.intel.com.notmuch/
Link: https://patch.msgid.link/20250418002933.406439-1-dave.jiang@intel.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
drivers/cxl/core/features.c
drivers/cxl/pci.c
include/cxl/features.h
tools/testing/cxl/test/mem.c

index f4daefe3180e52318827a0e7c02d6a27d810fb32..150a1776480ab0002dd895697d23435a361108a2 100644 (file)
@@ -677,7 +677,7 @@ static void free_memdev_fwctl(void *_fwctl_dev)
        fwctl_put(fwctl_dev);
 }
 
-int devm_cxl_setup_fwctl(struct cxl_memdev *cxlmd)
+int devm_cxl_setup_fwctl(struct device *host, struct cxl_memdev *cxlmd)
 {
        struct cxl_dev_state *cxlds = cxlmd->cxlds;
        struct cxl_features_state *cxlfs;
@@ -700,7 +700,7 @@ int devm_cxl_setup_fwctl(struct cxl_memdev *cxlmd)
        if (rc)
                return rc;
 
-       return devm_add_action_or_reset(&cxlmd->dev, free_memdev_fwctl,
+       return devm_add_action_or_reset(host, free_memdev_fwctl,
                                        no_free_ptr(fwctl_dev));
 }
 EXPORT_SYMBOL_NS_GPL(devm_cxl_setup_fwctl, "CXL");
index 7b14a154463c597de8ec97937f8ead4b1d516070..785aa2af5eaac4989b00be4a809db765a591ab92 100644 (file)
@@ -1018,7 +1018,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        if (rc)
                return rc;
 
-       rc = devm_cxl_setup_fwctl(cxlmd);
+       rc = devm_cxl_setup_fwctl(&pdev->dev, cxlmd);
        if (rc)
                dev_dbg(&pdev->dev, "No CXL FWCTL setup\n");
 
index a3bb34694c06d88ebd0e82126abaa191366b10bb..5f7f842765a5f31ec82921083d88659f7947263b 100644 (file)
@@ -66,7 +66,7 @@ struct cxl_memdev;
 #ifdef CONFIG_CXL_FEATURES
 inline struct cxl_features_state *to_cxlfs(struct cxl_dev_state *cxlds);
 int devm_cxl_setup_features(struct cxl_dev_state *cxlds);
-int devm_cxl_setup_fwctl(struct cxl_memdev *cxlmd);
+int devm_cxl_setup_fwctl(struct device *host, struct cxl_memdev *cxlmd);
 #else
 static inline struct cxl_features_state *to_cxlfs(struct cxl_dev_state *cxlds)
 {
@@ -78,7 +78,8 @@ static inline int devm_cxl_setup_features(struct cxl_dev_state *cxlds)
        return -EOPNOTSUPP;
 }
 
-static inline int devm_cxl_setup_fwctl(struct cxl_memdev *cxlmd)
+static inline int devm_cxl_setup_fwctl(struct device *host,
+                                      struct cxl_memdev *cxlmd)
 {
        return -EOPNOTSUPP;
 }
index f2957a3e36fe7fbfa5c87278794517b63f6ad8b4..bf9caa908f894c43ef383f402e465e4480c7a631 100644 (file)
@@ -1780,7 +1780,7 @@ static int cxl_mock_mem_probe(struct platform_device *pdev)
        if (rc)
                return rc;
 
-       rc = devm_cxl_setup_fwctl(cxlmd);
+       rc = devm_cxl_setup_fwctl(&pdev->dev, cxlmd);
        if (rc)
                dev_dbg(dev, "No CXL FWCTL setup\n");