Skip to content

Commit dc91567

Browse files
committed
cxl: Fix devm host device for CXL fwctl initialization
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: 858ce2f ("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>
1 parent 36aace1 commit dc91567

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

drivers/cxl/core/features.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ static void free_memdev_fwctl(void *_fwctl_dev)
677677
fwctl_put(fwctl_dev);
678678
}
679679

680-
int devm_cxl_setup_fwctl(struct cxl_memdev *cxlmd)
680+
int devm_cxl_setup_fwctl(struct device *host, struct cxl_memdev *cxlmd)
681681
{
682682
struct cxl_dev_state *cxlds = cxlmd->cxlds;
683683
struct cxl_features_state *cxlfs;
@@ -700,7 +700,7 @@ int devm_cxl_setup_fwctl(struct cxl_memdev *cxlmd)
700700
if (rc)
701701
return rc;
702702

703-
return devm_add_action_or_reset(&cxlmd->dev, free_memdev_fwctl,
703+
return devm_add_action_or_reset(host, free_memdev_fwctl,
704704
no_free_ptr(fwctl_dev));
705705
}
706706
EXPORT_SYMBOL_NS_GPL(devm_cxl_setup_fwctl, "CXL");

drivers/cxl/pci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
10181018
if (rc)
10191019
return rc;
10201020

1021-
rc = devm_cxl_setup_fwctl(cxlmd);
1021+
rc = devm_cxl_setup_fwctl(&pdev->dev, cxlmd);
10221022
if (rc)
10231023
dev_dbg(&pdev->dev, "No CXL FWCTL setup\n");
10241024

include/cxl/features.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct cxl_memdev;
6666
#ifdef CONFIG_CXL_FEATURES
6767
inline struct cxl_features_state *to_cxlfs(struct cxl_dev_state *cxlds);
6868
int devm_cxl_setup_features(struct cxl_dev_state *cxlds);
69-
int devm_cxl_setup_fwctl(struct cxl_memdev *cxlmd);
69+
int devm_cxl_setup_fwctl(struct device *host, struct cxl_memdev *cxlmd);
7070
#else
7171
static inline struct cxl_features_state *to_cxlfs(struct cxl_dev_state *cxlds)
7272
{
@@ -78,7 +78,8 @@ static inline int devm_cxl_setup_features(struct cxl_dev_state *cxlds)
7878
return -EOPNOTSUPP;
7979
}
8080

81-
static inline int devm_cxl_setup_fwctl(struct cxl_memdev *cxlmd)
81+
static inline int devm_cxl_setup_fwctl(struct device *host,
82+
struct cxl_memdev *cxlmd)
8283
{
8384
return -EOPNOTSUPP;
8485
}

tools/testing/cxl/test/mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1780,7 +1780,7 @@ static int cxl_mock_mem_probe(struct platform_device *pdev)
17801780
if (rc)
17811781
return rc;
17821782

1783-
rc = devm_cxl_setup_fwctl(cxlmd);
1783+
rc = devm_cxl_setup_fwctl(&pdev->dev, cxlmd);
17841784
if (rc)
17851785
dev_dbg(dev, "No CXL FWCTL setup\n");
17861786

0 commit comments

Comments
 (0)