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