mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 05:32:00 +00:00
cxl: Explicitly initialize resources when media is not ready
When media is not ready do not assume that the capacity information from the identify command is valid, i.e. ->total_bytes ->partition_align_bytes ->{volatile,persistent}_only_bytes. Explicitly zero out the capacity resources and exit early. Given zero-init of those fields this patch is functionally equivalent to the prior state, but it improves readability and robustness going forward. Signed-off-by: Dave Jiang <dave.jiang@intel.com> Link: https://lore.kernel.org/r/168506118166.3004974.13523455340007852589.stgit@djiang5-mobl3 Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
a70fc4ed20
commit
793a539ac7
@ -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 = DEFINE_RES_MEM(0, 0);
|
||||
cxlds->ram_res = DEFINE_RES_MEM(0, 0);
|
||||
cxlds->pmem_res = 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,
|
||||
|
Loading…
Reference in New Issue
Block a user