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
1105 struct device *dev = cxlds->dev;1105 struct device *dev = cxlds->dev;
1106 int rc;1106 int rc;
1107 1107
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
1108 cxlds->dpa_res =1115 cxlds->dpa_res =
1109 (struct resource)DEFINE_RES_MEM(0, cxlds->total_bytes);1116 (struct resource)DEFINE_RES_MEM(0, cxlds->total_bytes);
1110 1117
@@ -1118,12 +1125,10 @@ int cxl_mem_create_range_info(struct cxl_dev_state *cxlds) · 7 unmodified lines
1118 cxlds->persistent_only_bytes, "pmem");1125 cxlds->persistent_only_bytes, "pmem");
1119 }1126 }
1120 1127
1121 if (cxlds->media_ready) {1128 rc = cxl_mem_get_partition_info(cxlds);
1122 rc = cxl_mem_get_partition_info(cxlds);1129 if (rc) {
1123 if (rc) {1130 dev_err(dev, "Failed to query partition information\n");
1124 dev_err(dev, "Failed to query partition information\n");1131 return rc;
1125 return rc;
1126 }
1127 }1132 }
1128 1133
1129 rc = add_dpa_res(dev, &cxlds->dpa_res, &cxlds->ram_res, 0,1134 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