Now that all NVDIMM subsystem locking is validated with custom lock classes, there is no need for the custom usage of the lockdep_mutex.
Unified · Split
| @@ -50,14 +50,14 @@ static ssize_t sector_size_store(struct device *dev, · 49 unmodified lines | ||
| 50 | 50 | struct nd_btt *nd_btt = to_nd_btt(dev); |
| 51 | 51 | ssize_t rc; |
| 52 | 52 | |
| 53 | − nd_device_lock(dev); | |
| 53 | + device_lock(dev); | |
| 54 | 54 | nvdimm_bus_lock(dev); |
| 55 | 55 | rc = nd_size_select_store(dev, buf, &nd_btt->lbasize, |
| 56 | 56 | btt_lbasize_supported); |
| 57 | 57 | dev_dbg(dev, "result: %zd wrote: %s%s", rc, buf, |
| 58 | 58 | buf[len - 1] == '\n' ? "" : "\n"); |
| 59 | 59 | nvdimm_bus_unlock(dev); |
| 60 | − nd_device_unlock(dev); | |
| 60 | + device_unlock(dev); | |
| 61 | 61 | |
| 62 | 62 | return rc ? rc : len; |
| 63 | 63 | } |
| @@ -79,11 +79,11 @@ static ssize_t uuid_store(struct device *dev, · 15 unmodified lines | ||
| 79 | 79 | struct nd_btt *nd_btt = to_nd_btt(dev); |
| 80 | 80 | ssize_t rc; |
| 81 | 81 | |
| 82 | − nd_device_lock(dev); | |
| 82 | + device_lock(dev); | |
| 83 | 83 | rc = nd_uuid_store(dev, &nd_btt->uuid, buf, len); |
| 84 | 84 | dev_dbg(dev, "result: %zd wrote: %s%s", rc, buf, |
| 85 | 85 | buf[len - 1] == '\n' ? "" : "\n"); |
| 86 | − nd_device_unlock(dev); | |
| 86 | + device_unlock(dev); | |
| 87 | 87 | |
| 88 | 88 | return rc ? rc : len; |
| 89 | 89 | } |
| @@ -108,13 +108,13 @@ static ssize_t namespace_store(struct device *dev, · 18 unmodified lines | ||
| 108 | 108 | struct nd_btt *nd_btt = to_nd_btt(dev); |
| 109 | 109 | ssize_t rc; |
| 110 | 110 | |
| 111 | − nd_device_lock(dev); | |
| 111 | + device_lock(dev); | |
| 112 | 112 | nvdimm_bus_lock(dev); |
| 113 | 113 | rc = nd_namespace_store(dev, &nd_btt->ndns, buf, len); |
| 114 | 114 | dev_dbg(dev, "result: %zd wrote: %s%s", rc, buf, |
| 115 | 115 | buf[len - 1] == '\n' ? "" : "\n"); |
| 116 | 116 | nvdimm_bus_unlock(dev); |
| 117 | − nd_device_unlock(dev); | |
| 117 | + device_unlock(dev); | |
| 118 | 118 | |
| 119 | 119 | return rc; |
| 120 | 120 | } |
| @@ -126,14 +126,14 @@ static ssize_t size_show(struct device *dev, · 5 unmodified lines | ||
| 126 | 126 | struct nd_btt *nd_btt = to_nd_btt(dev); |
| 127 | 127 | ssize_t rc; |
| 128 | 128 | |
| 129 | − nd_device_lock(dev); | |
| 129 | + device_lock(dev); | |
| 130 | 130 | if (dev->driver) |
| 131 | 131 | rc = sprintf(buf, "%llu\n", nd_btt->size); |
| 132 | 132 | else { |
| 133 | 133 | /* no size to convey if the btt instance is disabled */ |
| 134 | 134 | rc = -ENXIO; |
| 135 | 135 | } |
| 136 | − nd_device_unlock(dev); | |
| 136 | + device_unlock(dev); | |
| 137 | 137 | |
| 138 | 138 | return rc; |
| 139 | 139 | } |
| @@ -88,10 +88,7 @@ static int nvdimm_bus_probe(struct device *dev) · 87 unmodified lines | ||
| 88 | 88 | dev->driver->name, dev_name(dev)); |
| 89 | 89 | |
| 90 | 90 | nvdimm_bus_probe_start(nvdimm_bus); |
| 91 | − debug_nvdimm_lock(dev); | |
| 92 | 91 | rc = nd_drv->probe(dev); |
| 93 | − debug_nvdimm_unlock(dev); | |
| 94 | − | |
| 95 | 92 | if ((rc == 0 || rc == -EOPNOTSUPP) && |
| 96 | 93 | dev->parent && is_nd_region(dev->parent)) |
| 97 | 94 | nd_region_advance_seeds(to_nd_region(dev->parent), dev); |
| @@ -111,11 +108,8 @@ static void nvdimm_bus_remove(struct device *dev) · 13 unmodified lines | ||
| 111 | 108 | struct module *provider = to_bus_provider(dev); |
| 112 | 109 | struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); |
| 113 | 110 | |
| 114 | − if (nd_drv->remove) { | |
| 115 | − debug_nvdimm_lock(dev); | |
| 111 | + if (nd_drv->remove) | |
| 116 | 112 | nd_drv->remove(dev); |
| 117 | − debug_nvdimm_unlock(dev); | |
| 118 | − } | |
| 119 | 113 | |
| 120 | 114 | dev_dbg(&nvdimm_bus->dev, "%s.remove(%s)\n", dev->driver->name, |
| 121 | 115 | dev_name(dev)); |
| @@ -139,7 +133,7 @@ static void nvdimm_bus_shutdown(struct device *dev) · 17 unmodified lines | ||
| 139 | 133 | |
| 140 | 134 | void nd_device_notify(struct device *dev, enum nvdimm_event event) |
| 141 | 135 | { |
| 142 | − nd_device_lock(dev); | |
| 136 | + device_lock(dev); | |
| 143 | 137 | if (dev->driver) { |
| 144 | 138 | struct nd_device_driver *nd_drv; |
| 145 | 139 | |
| @@ -147,7 +141,7 @@ void nd_device_notify(struct device *dev, enum nvdimm_event event) · 1 unmodified line | ||
| 147 | 141 | if (nd_drv->notify) |
| 148 | 142 | nd_drv->notify(dev, event); |
| 149 | 143 | } |
| 150 | − nd_device_unlock(dev); | |
| 144 | + device_unlock(dev); | |
| 151 | 145 | } |
| 152 | 146 | EXPORT_SYMBOL(nd_device_notify); |
| 153 | 147 | |
| @@ -569,9 +563,9 @@ void nd_device_unregister(struct device *dev, enum nd_async_mode mode) · 415 unmodified lines | ||
| 569 | 563 | * or otherwise let the async path handle it if the |
| 570 | 564 | * unregistration was already queued. |
| 571 | 565 | */ |
| 572 | − nd_device_lock(dev); | |
| 566 | + device_lock(dev); | |
| 573 | 567 | killed = kill_device(dev); |
| 574 | − nd_device_unlock(dev); | |
| 568 | + device_unlock(dev); | |
| 575 | 569 | |
| 576 | 570 | if (!killed) |
| 577 | 571 | return; |
| @@ -930,10 +924,10 @@ void wait_nvdimm_bus_probe_idle(struct device *dev) · 352 unmodified lines | ||
| 930 | 924 | if (nvdimm_bus->probe_active == 0) |
| 931 | 925 | break; |
| 932 | 926 | nvdimm_bus_unlock(dev); |
| 933 | − nd_device_unlock(dev); | |
| 927 | + device_unlock(dev); | |
| 934 | 928 | wait_event(nvdimm_bus->wait, |
| 935 | 929 | nvdimm_bus->probe_active == 0); |
| 936 | − nd_device_lock(dev); | |
| 930 | + device_lock(dev); | |
| 937 | 931 | nvdimm_bus_lock(dev); |
| 938 | 932 | } while (true); |
| 939 | 933 | } |
| @@ -1167,7 +1161,7 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm, · 227 unmodified lines | ||
| 1167 | 1161 | goto out; |
| 1168 | 1162 | } |
| 1169 | 1163 | |
| 1170 | − nd_device_lock(dev); | |
| 1164 | + device_lock(dev); | |
| 1171 | 1165 | nvdimm_bus_lock(dev); |
| 1172 | 1166 | rc = nd_cmd_clear_to_send(nvdimm_bus, nvdimm, func, buf); |
| 1173 | 1167 | if (rc) |
| @@ -1189,7 +1183,7 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm, · 15 unmodified lines | ||
| 1189 | 1183 | |
| 1190 | 1184 | out_unlock: |
| 1191 | 1185 | nvdimm_bus_unlock(dev); |
| 1192 | − nd_device_unlock(dev); | |
| 1186 | + device_unlock(dev); | |
| 1193 | 1187 | out: |
| 1194 | 1188 | kfree(in_env); |
| 1195 | 1189 | kfree(out_env); |
| @@ -215,7 +215,7 @@ EXPORT_SYMBOL_GPL(to_nvdimm_bus_dev); · 214 unmodified lines | ||
| 215 | 215 | * |
| 216 | 216 | * Enforce that uuids can only be changed while the device is disabled |
| 217 | 217 | * (driver detached) |
| 218 | − * LOCKING: expects nd_device_lock() is held on entry | |
| 218 | + * LOCKING: expects device_lock() is held on entry | |
| 219 | 219 | */ |
| 220 | 220 | int nd_uuid_store(struct device *dev, uuid_t **uuid_out, const char *buf, |
| 221 | 221 | size_t len) |
| @@ -316,15 +316,15 @@ static DEVICE_ATTR_RO(provider); · 94 unmodified lines | ||
| 316 | 316 | |
| 317 | 317 | static int flush_namespaces(struct device *dev, void *data) |
| 318 | 318 | { |
| 319 | − nd_device_lock(dev); | |
| 320 | − nd_device_unlock(dev); | |
| 319 | + device_lock(dev); | |
| 320 | + device_unlock(dev); | |
| 321 | 321 | return 0; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | static int flush_regions_dimms(struct device *dev, void *data) |
| 325 | 325 | { |
| 326 | − nd_device_lock(dev); | |
| 327 | − nd_device_unlock(dev); | |
| 326 | + device_lock(dev); | |
| 327 | + device_unlock(dev); | |
| 328 | 328 | device_for_each_child(dev, NULL, flush_namespaces); |
| 329 | 329 | return 0; |
| 330 | 330 | } |
| @@ -341,9 +341,9 @@ static ssize_t available_slots_show(struct device *dev, · 340 unmodified lines | ||
| 341 | 341 | { |
| 342 | 342 | ssize_t rc; |
| 343 | 343 | |
| 344 | − nd_device_lock(dev); | |
| 344 | + device_lock(dev); | |
| 345 | 345 | rc = __available_slots_show(dev_get_drvdata(dev), buf); |
| 346 | − nd_device_unlock(dev); | |
| 346 | + device_unlock(dev); | |
| 347 | 347 | |
| 348 | 348 | return rc; |
| 349 | 349 | } |
| @@ -386,12 +386,12 @@ static ssize_t security_store(struct device *dev, · 36 unmodified lines | ||
| 386 | 386 | * done while probing is idle and the DIMM is not in active use |
| 387 | 387 | * in any region. |
| 388 | 388 | */ |
| 389 | − nd_device_lock(dev); | |
| 389 | + device_lock(dev); | |
| 390 | 390 | nvdimm_bus_lock(dev); |
| 391 | 391 | wait_nvdimm_bus_probe_idle(dev); |
| 392 | 392 | rc = nvdimm_security_store(dev, buf, len); |
| 393 | 393 | nvdimm_bus_unlock(dev); |
| 394 | − nd_device_unlock(dev); | |
| 394 | + device_unlock(dev); | |
| 395 | 395 | |
| 396 | 396 | return rc; |
| 397 | 397 | } |
| @@ -264,7 +264,7 @@ static ssize_t alt_name_store(struct device *dev, · 263 unmodified lines | ||
| 264 | 264 | struct nd_region *nd_region = to_nd_region(dev->parent); |
| 265 | 265 | ssize_t rc; |
| 266 | 266 | |
| 267 | − nd_device_lock(dev); | |
| 267 | + device_lock(dev); | |
| 268 | 268 | nvdimm_bus_lock(dev); |
| 269 | 269 | wait_nvdimm_bus_probe_idle(dev); |
| 270 | 270 | rc = __alt_name_store(dev, buf, len); |
| @@ -272,7 +272,7 @@ static ssize_t alt_name_store(struct device *dev, · 1 unmodified line | ||
| 272 | 272 | rc = nd_namespace_label_update(nd_region, dev); |
| 273 | 273 | dev_dbg(dev, "%s(%zd)\n", rc < 0 ? "fail " : "", rc); |
| 274 | 274 | nvdimm_bus_unlock(dev); |
| 275 | − nd_device_unlock(dev); | |
| 275 | + device_unlock(dev); | |
| 276 | 276 | |
| 277 | 277 | return rc < 0 ? rc : len; |
| 278 | 278 | } |
| @@ -846,7 +846,7 @@ static ssize_t size_store(struct device *dev, · 567 unmodified lines | ||
| 846 | 846 | if (rc) |
| 847 | 847 | return rc; |
| 848 | 848 | |
| 849 | − nd_device_lock(dev); | |
| 849 | + device_lock(dev); | |
| 850 | 850 | nvdimm_bus_lock(dev); |
| 851 | 851 | wait_nvdimm_bus_probe_idle(dev); |
| 852 | 852 | rc = __size_store(dev, val); |
| @@ -868,7 +868,7 @@ static ssize_t size_store(struct device *dev, · 15 unmodified lines | ||
| 868 | 868 | dev_dbg(dev, "%llx %s (%d)\n", val, rc < 0 ? "fail" : "success", rc); |
| 869 | 869 | |
| 870 | 870 | nvdimm_bus_unlock(dev); |
| 871 | − nd_device_unlock(dev); | |
| 871 | + device_unlock(dev); | |
| 872 | 872 | |
| 873 | 873 | return rc < 0 ? rc : len; |
| 874 | 874 | } |
| @@ -1043,7 +1043,7 @@ static ssize_t uuid_store(struct device *dev, · 168 unmodified lines | ||
| 1043 | 1043 | } else |
| 1044 | 1044 | return -ENXIO; |
| 1045 | 1045 | |
| 1046 | − nd_device_lock(dev); | |
| 1046 | + device_lock(dev); | |
| 1047 | 1047 | nvdimm_bus_lock(dev); |
| 1048 | 1048 | wait_nvdimm_bus_probe_idle(dev); |
| 1049 | 1049 | if (to_ndns(dev)->claim) |
| @@ -1059,7 +1059,7 @@ static ssize_t uuid_store(struct device *dev, · 9 unmodified lines | ||
| 1059 | 1059 | dev_dbg(dev, "result: %zd wrote: %s%s", rc, buf, |
| 1060 | 1060 | buf[len - 1] == '\n' ? "" : "\n"); |
| 1061 | 1061 | nvdimm_bus_unlock(dev); |
| 1062 | − nd_device_unlock(dev); | |
| 1062 | + device_unlock(dev); | |
| 1063 | 1063 | |
| 1064 | 1064 | return rc < 0 ? rc : len; |
| 1065 | 1065 | } |
| @@ -1118,7 +1118,7 @@ static ssize_t sector_size_store(struct device *dev, · 52 unmodified lines | ||
| 1118 | 1118 | } else |
| 1119 | 1119 | return -ENXIO; |
| 1120 | 1120 | |
| 1121 | − nd_device_lock(dev); | |
| 1121 | + device_lock(dev); | |
| 1122 | 1122 | nvdimm_bus_lock(dev); |
| 1123 | 1123 | if (to_ndns(dev)->claim) |
| 1124 | 1124 | rc = -EBUSY; |
| @@ -1129,7 +1129,7 @@ static ssize_t sector_size_store(struct device *dev, · 4 unmodified lines | ||
| 1129 | 1129 | dev_dbg(dev, "result: %zd %s: %s%s", rc, rc < 0 ? "tried" : "wrote", |
| 1130 | 1130 | buf, buf[len - 1] == '\n' ? "" : "\n"); |
| 1131 | 1131 | nvdimm_bus_unlock(dev); |
| 1132 | − nd_device_unlock(dev); | |
| 1132 | + device_unlock(dev); | |
| 1133 | 1133 | |
| 1134 | 1134 | return rc ? rc : len; |
| 1135 | 1135 | } |
| @@ -1239,9 +1239,9 @@ static ssize_t holder_show(struct device *dev, · 103 unmodified lines | ||
| 1239 | 1239 | struct nd_namespace_common *ndns = to_ndns(dev); |
| 1240 | 1240 | ssize_t rc; |
| 1241 | 1241 | |
| 1242 | − nd_device_lock(dev); | |
| 1242 | + device_lock(dev); | |
| 1243 | 1243 | rc = sprintf(buf, "%s\n", ndns->claim ? dev_name(ndns->claim) : ""); |
| 1244 | − nd_device_unlock(dev); | |
| 1244 | + device_unlock(dev); | |
| 1245 | 1245 | |
| 1246 | 1246 | return rc; |
| 1247 | 1247 | } |
| @@ -1278,7 +1278,7 @@ static ssize_t holder_class_store(struct device *dev, · 30 unmodified lines | ||
| 1278 | 1278 | struct nd_region *nd_region = to_nd_region(dev->parent); |
| 1279 | 1279 | int rc; |
| 1280 | 1280 | |
| 1281 | − nd_device_lock(dev); | |
| 1281 | + device_lock(dev); | |
| 1282 | 1282 | nvdimm_bus_lock(dev); |
| 1283 | 1283 | wait_nvdimm_bus_probe_idle(dev); |
| 1284 | 1284 | rc = __holder_class_store(dev, buf); |
| @@ -1286,7 +1286,7 @@ static ssize_t holder_class_store(struct device *dev, · 1 unmodified line | ||
| 1286 | 1286 | rc = nd_namespace_label_update(nd_region, dev); |
| 1287 | 1287 | dev_dbg(dev, "%s(%d)\n", rc < 0 ? "fail " : "", rc); |
| 1288 | 1288 | nvdimm_bus_unlock(dev); |
| 1289 | − nd_device_unlock(dev); | |
| 1289 | + device_unlock(dev); | |
| 1290 | 1290 | |
| 1291 | 1291 | return rc < 0 ? rc : len; |
| 1292 | 1292 | } |
| @@ -1297,7 +1297,7 @@ static ssize_t holder_class_show(struct device *dev, · 4 unmodified lines | ||
| 1297 | 1297 | struct nd_namespace_common *ndns = to_ndns(dev); |
| 1298 | 1298 | ssize_t rc; |
| 1299 | 1299 | |
| 1300 | − nd_device_lock(dev); | |
| 1300 | + device_lock(dev); | |
| 1301 | 1301 | if (ndns->claim_class == NVDIMM_CCLASS_NONE) |
| 1302 | 1302 | rc = sprintf(buf, "\n"); |
| 1303 | 1303 | else if ((ndns->claim_class == NVDIMM_CCLASS_BTT) || |
| @@ -1309,7 +1309,7 @@ static ssize_t holder_class_show(struct device *dev, · 5 unmodified lines | ||
| 1309 | 1309 | rc = sprintf(buf, "dax\n"); |
| 1310 | 1310 | else |
| 1311 | 1311 | rc = sprintf(buf, "<unknown>\n"); |
| 1312 | − nd_device_unlock(dev); | |
| 1312 | + device_unlock(dev); | |
| 1313 | 1313 | |
| 1314 | 1314 | return rc; |
| 1315 | 1315 | } |
| @@ -1323,7 +1323,7 @@ static ssize_t mode_show(struct device *dev, · 7 unmodified lines | ||
| 1323 | 1323 | char *mode; |
| 1324 | 1324 | ssize_t rc; |
| 1325 | 1325 | |
| 1326 | − nd_device_lock(dev); | |
| 1326 | + device_lock(dev); | |
| 1327 | 1327 | claim = ndns->claim; |
| 1328 | 1328 | if (claim && is_nd_btt(claim)) |
| 1329 | 1329 | mode = "safe"; |
| @@ -1336,7 +1336,7 @@ static ssize_t mode_show(struct device *dev, · 6 unmodified lines | ||
| 1336 | 1336 | else |
| 1337 | 1337 | mode = "raw"; |
| 1338 | 1338 | rc = sprintf(buf, "%s\n", mode); |
| 1339 | − nd_device_unlock(dev); | |
| 1339 | + device_unlock(dev); | |
| 1340 | 1340 | |
| 1341 | 1341 | return rc; |
| 1342 | 1342 | } |
| @@ -1456,8 +1456,8 @@ struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev) · 113 unmodified lines | ||
| 1456 | 1456 | * Flush any in-progess probes / removals in the driver |
| 1457 | 1457 | * for the raw personality of this namespace. |
| 1458 | 1458 | */ |
| 1459 | − nd_device_lock(&ndns->dev); | |
| 1460 | − nd_device_unlock(&ndns->dev); | |
| 1459 | + device_lock(&ndns->dev); | |
| 1460 | + device_unlock(&ndns->dev); | |
| 1461 | 1461 | if (ndns->dev.driver) { |
| 1462 | 1462 | dev_dbg(&ndns->dev, "is active, can't bind %s\n", |
| 1463 | 1463 | dev_name(dev)); |
| @@ -161,70 +161,4 @@ static inline void devm_nsio_disable(struct device *dev, · 160 unmodified lines | ||
| 161 | 161 | { |
| 162 | 162 | } |
| 163 | 163 | #endif |
| 164 | − | |
| 165 | −#ifdef CONFIG_PROVE_NVDIMM_LOCKING | |
| 166 | −extern struct class *nd_class; | |
| 167 | − | |
| 168 | −enum { | |
| 169 | − LOCK_BUS, | |
| 170 | − LOCK_NDCTL, | |
| 171 | − LOCK_REGION, | |
| 172 | − LOCK_DIMM = LOCK_REGION, | |
| 173 | − LOCK_NAMESPACE, | |
| 174 | − LOCK_CLAIM, | |
| 175 | −}; | |
| 176 | − | |
| 177 | −static inline void debug_nvdimm_lock(struct device *dev) | |
| 178 | −{ | |
| 179 | − if (is_nd_region(dev)) | |
| 180 | − mutex_lock_nested(&dev->lockdep_mutex, LOCK_REGION); | |
| 181 | − else if (is_nvdimm(dev)) | |
| 182 | − mutex_lock_nested(&dev->lockdep_mutex, LOCK_DIMM); | |
| 183 | − else if (is_nd_btt(dev) || is_nd_pfn(dev) || is_nd_dax(dev)) | |
| 184 | − mutex_lock_nested(&dev->lockdep_mutex, LOCK_CLAIM); | |
| 185 | − else if (dev->parent && (is_nd_region(dev->parent))) | |
| 186 | − mutex_lock_nested(&dev->lockdep_mutex, LOCK_NAMESPACE); | |
| 187 | − else if (is_nvdimm_bus(dev)) | |
| 188 | − mutex_lock_nested(&dev->lockdep_mutex, LOCK_BUS); | |
| 189 | − else if (dev->class && dev->class == nd_class) | |
| 190 | − mutex_lock_nested(&dev->lockdep_mutex, LOCK_NDCTL); | |
| 191 | − else | |
| 192 | − dev_WARN(dev, "unknown lock level\n"); | |
| 193 | −} | |
| 194 | − | |
| 195 | −static inline void debug_nvdimm_unlock(struct device *dev) | |
| 196 | −{ | |
| 197 | − mutex_unlock(&dev->lockdep_mutex); | |
| 198 | −} | |
| 199 | − | |
| 200 | −static inline void nd_device_lock(struct device *dev) | |
| 201 | −{ | |
| 202 | − device_lock(dev); | |
| 203 | − debug_nvdimm_lock(dev); | |
| 204 | −} | |
| 205 | − | |
| 206 | −static inline void nd_device_unlock(struct device *dev) | |
| 207 | −{ | |
| 208 | − debug_nvdimm_unlock(dev); | |
| 209 | − device_unlock(dev); | |
| 210 | −} | |
| 211 | −#else | |
| 212 | −static inline void nd_device_lock(struct device *dev) | |
| 213 | −{ | |
| 214 | − device_lock(dev); | |
| 215 | −} | |
| 216 | − | |
| 217 | −static inline void nd_device_unlock(struct device *dev) | |
| 218 | −{ | |
| 219 | − device_unlock(dev); | |
| 220 | −} | |
| 221 | − | |
| 222 | −static inline void debug_nvdimm_lock(struct device *dev) | |
| 223 | −{ | |
| 224 | −} | |
| 225 | − | |
| 226 | −static inline void debug_nvdimm_unlock(struct device *dev) | |
| 227 | −{ | |
| 228 | −} | |
| 229 | −#endif | |
| 230 | 164 | #endif /* __ND_CORE_H__ */ |
| @@ -55,7 +55,7 @@ static ssize_t mode_store(struct device *dev, · 54 unmodified lines | ||
| 55 | 55 | struct nd_pfn *nd_pfn = to_nd_pfn_safe(dev); |
| 56 | 56 | ssize_t rc = 0; |
| 57 | 57 | |
| 58 | − nd_device_lock(dev); | |
| 58 | + device_lock(dev); | |
| 59 | 59 | nvdimm_bus_lock(dev); |
| 60 | 60 | if (dev->driver) |
| 61 | 61 | rc = -EBUSY; |
| @@ -77,7 +77,7 @@ static ssize_t mode_store(struct device *dev, · 15 unmodified lines | ||
| 77 | 77 | dev_dbg(dev, "result: %zd wrote: %s%s", rc, buf, |
| 78 | 78 | buf[len - 1] == '\n' ? "" : "\n"); |
| 79 | 79 | nvdimm_bus_unlock(dev); |
| 80 | − nd_device_unlock(dev); | |
| 80 | + device_unlock(dev); | |
| 81 | 81 | |
| 82 | 82 | return rc ? rc : len; |
| 83 | 83 | } |
| @@ -123,14 +123,14 @@ static ssize_t align_store(struct device *dev, · 39 unmodified lines | ||
| 123 | 123 | unsigned long aligns[MAX_NVDIMM_ALIGN] = { [0] = 0, }; |
| 124 | 124 | ssize_t rc; |
| 125 | 125 | |
| 126 | − nd_device_lock(dev); | |
| 126 | + device_lock(dev); | |
| 127 | 127 | nvdimm_bus_lock(dev); |
| 128 | 128 | rc = nd_size_select_store(dev, buf, &nd_pfn->align, |
| 129 | 129 | nd_pfn_supported_alignments(aligns)); |
| 130 | 130 | dev_dbg(dev, "result: %zd wrote: %s%s", rc, buf, |
| 131 | 131 | buf[len - 1] == '\n' ? "" : "\n"); |
| 132 | 132 | nvdimm_bus_unlock(dev); |
| 133 | − nd_device_unlock(dev); | |
| 133 | + device_unlock(dev); | |
| 134 | 134 | |
| 135 | 135 | return rc ? rc : len; |
| 136 | 136 | } |
| @@ -152,11 +152,11 @@ static ssize_t uuid_store(struct device *dev, · 15 unmodified lines | ||
| 152 | 152 | struct nd_pfn *nd_pfn = to_nd_pfn_safe(dev); |
| 153 | 153 | ssize_t rc; |
| 154 | 154 | |
| 155 | − nd_device_lock(dev); | |
| 155 | + device_lock(dev); | |
| 156 | 156 | rc = nd_uuid_store(dev, &nd_pfn->uuid, buf, len); |
| 157 | 157 | dev_dbg(dev, "result: %zd wrote: %s%s", rc, buf, |
| 158 | 158 | buf[len - 1] == '\n' ? "" : "\n"); |
| 159 | − nd_device_unlock(dev); | |
| 159 | + device_unlock(dev); | |
| 160 | 160 | |
| 161 | 161 | return rc ? rc : len; |
| 162 | 162 | } |
| @@ -181,13 +181,13 @@ static ssize_t namespace_store(struct device *dev, · 18 unmodified lines | ||
| 181 | 181 | struct nd_pfn *nd_pfn = to_nd_pfn_safe(dev); |
| 182 | 182 | ssize_t rc; |
| 183 | 183 | |
| 184 | − nd_device_lock(dev); | |
| 184 | + device_lock(dev); | |
| 185 | 185 | nvdimm_bus_lock(dev); |
| 186 | 186 | rc = nd_namespace_store(dev, &nd_pfn->ndns, buf, len); |
| 187 | 187 | dev_dbg(dev, "result: %zd wrote: %s%s", rc, buf, |
| 188 | 188 | buf[len - 1] == '\n' ? "" : "\n"); |
| 189 | 189 | nvdimm_bus_unlock(dev); |
| 190 | − nd_device_unlock(dev); | |
| 190 | + device_unlock(dev); | |
| 191 | 191 | |
| 192 | 192 | return rc; |
| 193 | 193 | } |
| @@ -199,7 +199,7 @@ static ssize_t resource_show(struct device *dev, · 5 unmodified lines | ||
| 199 | 199 | struct nd_pfn *nd_pfn = to_nd_pfn_safe(dev); |
| 200 | 200 | ssize_t rc; |
| 201 | 201 | |
| 202 | − nd_device_lock(dev); | |
| 202 | + device_lock(dev); | |
| 203 | 203 | if (dev->driver) { |
| 204 | 204 | struct nd_pfn_sb *pfn_sb = nd_pfn->pfn_sb; |
| 205 | 205 | u64 offset = __le64_to_cpu(pfn_sb->dataoff); |
| @@ -213,7 +213,7 @@ static ssize_t resource_show(struct device *dev, · 7 unmodified lines | ||
| 213 | 213 | /* no address to convey if the pfn instance is disabled */ |
| 214 | 214 | rc = -ENXIO; |
| 215 | 215 | } |
| 216 | − nd_device_unlock(dev); | |
| 216 | + device_unlock(dev); | |
| 217 | 217 | |
| 218 | 218 | return rc; |
| 219 | 219 | } |
| @@ -225,7 +225,7 @@ static ssize_t size_show(struct device *dev, · 5 unmodified lines | ||
| 225 | 225 | struct nd_pfn *nd_pfn = to_nd_pfn_safe(dev); |
| 226 | 226 | ssize_t rc; |
| 227 | 227 | |
| 228 | − nd_device_lock(dev); | |
| 228 | + device_lock(dev); | |
| 229 | 229 | if (dev->driver) { |
| 230 | 230 | struct nd_pfn_sb *pfn_sb = nd_pfn->pfn_sb; |
| 231 | 231 | u64 offset = __le64_to_cpu(pfn_sb->dataoff); |
| @@ -241,7 +241,7 @@ static ssize_t size_show(struct device *dev, · 9 unmodified lines | ||
| 241 | 241 | /* no size to convey if the pfn instance is disabled */ |
| 242 | 242 | rc = -ENXIO; |
| 243 | 243 | } |
| 244 | − nd_device_unlock(dev); | |
| 244 | + device_unlock(dev); | |
| 245 | 245 | |
| 246 | 246 | return rc; |
| 247 | 247 | } |
| @@ -573,7 +573,7 @@ static void nd_pmem_remove(struct device *dev) · 572 unmodified lines | ||
| 573 | 573 | nvdimm_namespace_detach_btt(to_nd_btt(dev)); |
| 574 | 574 | else { |
| 575 | 575 | /* |
| 576 | − * Note, this assumes nd_device_lock() context to not | |
| 576 | + * Note, this assumes device_lock() context to not | |
| 577 | 577 | * race nd_pmem_notify() |
| 578 | 578 | */ |
| 579 | 579 | sysfs_put(pmem->bb_state); |
| @@ -95,7 +95,7 @@ static void nd_region_remove(struct device *dev) · 94 unmodified lines | ||
| 95 | 95 | nvdimm_bus_unlock(dev); |
| 96 | 96 | |
| 97 | 97 | /* |
| 98 | − * Note, this assumes nd_device_lock() context to not race | |
| 98 | + * Note, this assumes device_lock() context to not race | |
| 99 | 99 | * nd_region_notify() |
| 100 | 100 | */ |
| 101 | 101 | sysfs_put(nd_region->bb_state); |
| @@ -279,7 +279,7 @@ static ssize_t set_cookie_show(struct device *dev, · 278 unmodified lines | ||
| 279 | 279 | * the v1.1 namespace label cookie definition. To read all this |
| 280 | 280 | * data we need to wait for probing to settle. |
| 281 | 281 | */ |
| 282 | − nd_device_lock(dev); | |
| 282 | + device_lock(dev); | |
| 283 | 283 | nvdimm_bus_lock(dev); |
| 284 | 284 | wait_nvdimm_bus_probe_idle(dev); |
| 285 | 285 | if (nd_region->ndr_mappings) { |
| @@ -296,7 +296,7 @@ static ssize_t set_cookie_show(struct device *dev, · 10 unmodified lines | ||
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | 298 | nvdimm_bus_unlock(dev); |
| 299 | − nd_device_unlock(dev); | |
| 299 | + device_unlock(dev); | |
| 300 | 300 | |
| 301 | 301 | if (rc) |
| 302 | 302 | return rc; |
| @@ -353,12 +353,12 @@ static ssize_t available_size_show(struct device *dev, · 50 unmodified lines | ||
| 353 | 353 | * memory nvdimm_bus_lock() is dropped, but that's userspace's |
| 354 | 354 | * problem to not race itself. |
| 355 | 355 | */ |
| 356 | − nd_device_lock(dev); | |
| 356 | + device_lock(dev); | |
| 357 | 357 | nvdimm_bus_lock(dev); |
| 358 | 358 | wait_nvdimm_bus_probe_idle(dev); |
| 359 | 359 | available = nd_region_available_dpa(nd_region); |
| 360 | 360 | nvdimm_bus_unlock(dev); |
| 361 | − nd_device_unlock(dev); | |
| 361 | + device_unlock(dev); | |
| 362 | 362 | |
| 363 | 363 | return sprintf(buf, "%llu\n", available); |
| 364 | 364 | } |
| @@ -370,12 +370,12 @@ static ssize_t max_available_extent_show(struct device *dev, · 5 unmodified lines | ||
| 370 | 370 | struct nd_region *nd_region = to_nd_region(dev); |
| 371 | 371 | unsigned long long available = 0; |
| 372 | 372 | |
| 373 | − nd_device_lock(dev); | |
| 373 | + device_lock(dev); | |
| 374 | 374 | nvdimm_bus_lock(dev); |
| 375 | 375 | wait_nvdimm_bus_probe_idle(dev); |
| 376 | 376 | available = nd_region_allocatable_dpa(nd_region); |
| 377 | 377 | nvdimm_bus_unlock(dev); |
| 378 | − nd_device_unlock(dev); | |
| 378 | + device_unlock(dev); | |
| 379 | 379 | |
| 380 | 380 | return sprintf(buf, "%llu\n", available); |
| 381 | 381 | } |
| @@ -549,12 +549,12 @@ static ssize_t region_badblocks_show(struct device *dev, · 167 unmodified lines | ||
| 549 | 549 | struct nd_region *nd_region = to_nd_region(dev); |
| 550 | 550 | ssize_t rc; |
| 551 | 551 | |
| 552 | − nd_device_lock(dev); | |
| 552 | + device_lock(dev); | |
| 553 | 553 | if (dev->driver) |
| 554 | 554 | rc = badblocks_show(&nd_region->bb, buf, 0); |
| 555 | 555 | else |
| 556 | 556 | rc = -ENXIO; |
| 557 | − nd_device_unlock(dev); | |
| 557 | + device_unlock(dev); | |
| 558 | 558 | |
| 559 | 559 | return rc; |
| 560 | 560 | } |
| @@ -1544,23 +1544,6 @@ config CSD_LOCK_WAIT_DEBUG · 1543 unmodified lines | ||
| 1544 | 1544 | include the IPI handler function currently executing (if any) |
| 1545 | 1545 | and relevant stack traces. |
| 1546 | 1546 | |
| 1547 | −choice | |
| 1548 | − prompt "Lock debugging: prove subsystem device_lock() correctness" | |
| 1549 | − depends on PROVE_LOCKING | |
| 1550 | − help | |
| 1551 | − For subsystems that have instrumented their usage of the device_lock() | |
| 1552 | − with nested annotations, enable lock dependency checking. The locking | |
| 1553 | − hierarchy 'subclass' identifiers are not compatible across | |
| 1554 | − sub-systems, so only one can be enabled at a time. | |
| 1555 | − | |
| 1556 | −config PROVE_NVDIMM_LOCKING | |
| 1557 | − bool "NVDIMM" | |
| 1558 | − depends on LIBNVDIMM | |
| 1559 | − help | |
| 1560 | − Enable lockdep to validate nd_device_lock() usage. | |
| 1561 | − | |
| 1562 | −endchoice | |
| 1563 | − | |
| 1564 | 1547 | endmenu # lock debugging |
| 1565 | 1548 | |
| 1566 | 1549 | config TRACE_IRQFLAGS |