From: Dave Jiang <dave.jiang@intel.com>
To: dan.j.williams@intel.com
Cc: linux-cxl@vger.kernel.org, vishal.l.verma@intel.com,
ira.weiny@intel.com, alison.schofield@intel.com
Subject: [PATCH] cxl: Explicitly initialize resources when media is not ready
Date: Thu, 25 May 2023 17:33:01 -0700 [thread overview]
Message-ID: <168506118166.3004974.13523455340007852589.stgit@djiang5-mobl3> (raw)
When media is not ready, all media information are not read from the
device. Explicitly set zero out the resources instead of going through the
success code path with 0 size capacity to init the resources and return.
Fixes: e764f12208b9 ("cxl: Move cxl_await_media_ready() to before capacity info retrieval")
Suggested-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
drivers/cxl/core/mbox.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
index 2c8dc7e2b84d..e1d257051a7d 100644
--- a/drivers/cxl/core/mbox.c
+++ b/drivers/cxl/core/mbox.c
@@ -1105,6 +1105,13 @@ int cxl_mem_create_range_info(struct cxl_dev_state *cxlds)
struct device *dev = cxlds->dev;
int rc;
+ if (!cxlds->media_ready) {
+ cxlds->dpa_res = (struct resource)DEFINE_RES_MEM(0, 0);
+ cxlds->ram_res = (struct resource)DEFINE_RES_MEM(0, 0);
+ cxlds->pmem_res = (struct resource)DEFINE_RES_MEM(0, 0);
+ return 0;
+ }
+
cxlds->dpa_res =
(struct resource)DEFINE_RES_MEM(0, cxlds->total_bytes);
@@ -1118,12 +1125,10 @@ int cxl_mem_create_range_info(struct cxl_dev_state *cxlds)
cxlds->persistent_only_bytes, "pmem");
}
- if (cxlds->media_ready) {
- rc = cxl_mem_get_partition_info(cxlds);
- if (rc) {
- dev_err(dev, "Failed to query partition information\n");
- return rc;
- }
+ rc = cxl_mem_get_partition_info(cxlds);
+ if (rc) {
+ dev_err(dev, "Failed to query partition information\n");
+ return rc;
}
rc = add_dpa_res(dev, &cxlds->dpa_res, &cxlds->ram_res, 0,
next reply other threads:[~2023-05-26 0:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-26 0:33 Dave Jiang [this message]
2023-05-26 4:06 ` [PATCH] cxl: Explicitly initialize resources when media is not ready Dan Williams
2023-05-26 20:38 ` Dan Williams
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=168506118166.3004974.13523455340007852589.stgit@djiang5-mobl3 \
--to=dave.jiang@intel.com \
--cc=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=vishal.l.verma@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.