From: Dave Jiang <dave.jiang@intel.com>
To: linux-cxl@vger.kernel.org
Cc: dave@stgolabs.net, jonathan.cameron@huawei.com,
alison.schofield@intel.com, ira.weiny@intel.com,
dan.j.williams@intel.com
Subject: Re: [PATCH] cxl: Fix devm device for cxl_fwctl initialization
Date: Fri, 18 Apr 2025 09:37:34 -0700 [thread overview]
Message-ID: <c6a21d00-b268-4488-bccc-d4be270033e5@intel.com> (raw)
In-Reply-To: <20250418002933.406439-1-dave.jiang@intel.com>
On 4/17/25 5:29 PM, Dave Jiang wrote:
> Testing revealed error message of 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.
>
> Fixes: 858ce2f56b52 ("cxl: Add FWCTL support to CXL")
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Applied to cxl/fixes
> ---
> drivers/cxl/core/features.c | 4 ++--
> drivers/cxl/pci.c | 2 +-
> include/cxl/features.h | 5 +++--
> tools/testing/cxl/test/mem.c | 2 +-
> 4 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/cxl/core/features.c b/drivers/cxl/core/features.c
> index f4daefe3180e..150a1776480a 100644
> --- a/drivers/cxl/core/features.c
> +++ b/drivers/cxl/core/features.c
> @@ -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");
> diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
> index 7b14a154463c..785aa2af5eaa 100644
> --- a/drivers/cxl/pci.c
> +++ b/drivers/cxl/pci.c
> @@ -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");
>
> diff --git a/include/cxl/features.h b/include/cxl/features.h
> index a3bb34694c06..5f7f842765a5 100644
> --- a/include/cxl/features.h
> +++ b/include/cxl/features.h
> @@ -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;
> }
> diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c
> index f2957a3e36fe..bf9caa908f89 100644
> --- a/tools/testing/cxl/test/mem.c
> +++ b/tools/testing/cxl/test/mem.c
> @@ -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");
>
prev parent reply other threads:[~2025-04-18 16:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-18 0:29 [PATCH] cxl: Fix devm device for cxl_fwctl initialization Dave Jiang
2025-04-18 1:45 ` Dan Williams
2025-04-18 16:04 ` Alison Schofield
2025-04-18 16:37 ` Dave Jiang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c6a21d00-b268-4488-bccc-d4be270033e5@intel.com \
--to=dave.jiang@intel.com \
--cc=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave@stgolabs.net \
--cc=ira.weiny@intel.com \
--cc=jonathan.cameron@huawei.com \
--cc=linux-cxl@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox