History

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.

Dave Jiang committed 3 years ago

Commit 793a5391 parent a70fc4e1 file · +11 −6Browse files

Unified · Split

drivers/cxl/core/mbox.c+11−6
@@ -1105,6 +1105,13 @@ int cxl_mem_create_range_info(struct cxl_dev_state *cxlds) · 1104 unmodified lines
11051105 struct device *dev = cxlds->dev;
11061106 int rc;
11071107
1108+ if (!cxlds->media_ready) {
1109+ cxlds->dpa_res = DEFINE_RES_MEM(0, 0);
1110+ cxlds->ram_res = DEFINE_RES_MEM(0, 0);
1111+ cxlds->pmem_res = DEFINE_RES_MEM(0, 0);
1112+ return 0;
1113+ }
1114+
11081115 cxlds->dpa_res =
11091116 (struct resource)DEFINE_RES_MEM(0, cxlds->total_bytes);
11101117
@@ -1118,12 +1125,10 @@ int cxl_mem_create_range_info(struct cxl_dev_state *cxlds) · 7 unmodified lines
11181125 cxlds->persistent_only_bytes, "pmem");
11191126 }
11201127
1121− if (cxlds->media_ready) {
1122− rc = cxl_mem_get_partition_info(cxlds);
1123− if (rc) {
1124− dev_err(dev, "Failed to query partition information\n");
1125− return rc;
1126− }
1128+ rc = cxl_mem_get_partition_info(cxlds);
1129+ if (rc) {
1130+ dev_err(dev, "Failed to query partition information\n");
1131+ return rc;
11271132 }
11281133
11291134 rc = add_dpa_res(dev, &cxlds->dpa_res, &cxlds->ram_res, 0,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t