Commit 81beea55 authored by Dan Williams's avatar Dan Williams
Browse files

nvdimm: Drop nd_device_lock()



Now that all NVDIMM subsystem locking is validated with custom lock
classes, there is no need for the custom usage of the lockdep_mutex.

Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
Link: https://lore.kernel.org/r/165055521979.3745911.10751769706032029999.stgit@dwillia2-desk3.amr.corp.intel.com


Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 1550a17a
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -50,14 +50,14 @@ static ssize_t sector_size_store(struct device *dev,
	struct nd_btt *nd_btt = to_nd_btt(dev);
	ssize_t rc;

	nd_device_lock(dev);
	device_lock(dev);
	nvdimm_bus_lock(dev);
	rc = nd_size_select_store(dev, buf, &nd_btt->lbasize,
			btt_lbasize_supported);
	dev_dbg(dev, "result: %zd wrote: %s%s", rc, buf,
			buf[len - 1] == '\n' ? "" : "\n");
	nvdimm_bus_unlock(dev);
	nd_device_unlock(dev);
	device_unlock(dev);

	return rc ? rc : len;
}
@@ -79,11 +79,11 @@ static ssize_t uuid_store(struct device *dev,
	struct nd_btt *nd_btt = to_nd_btt(dev);
	ssize_t rc;

	nd_device_lock(dev);
	device_lock(dev);
	rc = nd_uuid_store(dev, &nd_btt->uuid, buf, len);
	dev_dbg(dev, "result: %zd wrote: %s%s", rc, buf,
			buf[len - 1] == '\n' ? "" : "\n");
	nd_device_unlock(dev);
	device_unlock(dev);

	return rc ? rc : len;
}
@@ -108,13 +108,13 @@ static ssize_t namespace_store(struct device *dev,
	struct nd_btt *nd_btt = to_nd_btt(dev);
	ssize_t rc;

	nd_device_lock(dev);
	device_lock(dev);
	nvdimm_bus_lock(dev);
	rc = nd_namespace_store(dev, &nd_btt->ndns, buf, len);
	dev_dbg(dev, "result: %zd wrote: %s%s", rc, buf,
			buf[len - 1] == '\n' ? "" : "\n");
	nvdimm_bus_unlock(dev);
	nd_device_unlock(dev);
	device_unlock(dev);

	return rc;
}
@@ -126,14 +126,14 @@ static ssize_t size_show(struct device *dev,
	struct nd_btt *nd_btt = to_nd_btt(dev);
	ssize_t rc;

	nd_device_lock(dev);
	device_lock(dev);
	if (dev->driver)
		rc = sprintf(buf, "%llu\n", nd_btt->size);
	else {
		/* no size to convey if the btt instance is disabled */
		rc = -ENXIO;
	}
	nd_device_unlock(dev);
	device_unlock(dev);

	return rc;
}
+9 −15
Original line number Diff line number Diff line
@@ -88,10 +88,7 @@ static int nvdimm_bus_probe(struct device *dev)
			dev->driver->name, dev_name(dev));

	nvdimm_bus_probe_start(nvdimm_bus);
	debug_nvdimm_lock(dev);
	rc = nd_drv->probe(dev);
	debug_nvdimm_unlock(dev);

	if ((rc == 0 || rc == -EOPNOTSUPP) &&
			dev->parent && is_nd_region(dev->parent))
		nd_region_advance_seeds(to_nd_region(dev->parent), dev);
@@ -111,11 +108,8 @@ static void nvdimm_bus_remove(struct device *dev)
	struct module *provider = to_bus_provider(dev);
	struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);

	if (nd_drv->remove) {
		debug_nvdimm_lock(dev);
	if (nd_drv->remove)
		nd_drv->remove(dev);
		debug_nvdimm_unlock(dev);
	}

	dev_dbg(&nvdimm_bus->dev, "%s.remove(%s)\n", dev->driver->name,
			dev_name(dev));
@@ -139,7 +133,7 @@ static void nvdimm_bus_shutdown(struct device *dev)

void nd_device_notify(struct device *dev, enum nvdimm_event event)
{
	nd_device_lock(dev);
	device_lock(dev);
	if (dev->driver) {
		struct nd_device_driver *nd_drv;

@@ -147,7 +141,7 @@ void nd_device_notify(struct device *dev, enum nvdimm_event event)
		if (nd_drv->notify)
			nd_drv->notify(dev, event);
	}
	nd_device_unlock(dev);
	device_unlock(dev);
}
EXPORT_SYMBOL(nd_device_notify);

@@ -569,9 +563,9 @@ void nd_device_unregister(struct device *dev, enum nd_async_mode mode)
		 * or otherwise let the async path handle it if the
		 * unregistration was already queued.
		 */
		nd_device_lock(dev);
		device_lock(dev);
		killed = kill_device(dev);
		nd_device_unlock(dev);
		device_unlock(dev);

		if (!killed)
			return;
@@ -930,10 +924,10 @@ void wait_nvdimm_bus_probe_idle(struct device *dev)
		if (nvdimm_bus->probe_active == 0)
			break;
		nvdimm_bus_unlock(dev);
		nd_device_unlock(dev);
		device_unlock(dev);
		wait_event(nvdimm_bus->wait,
				nvdimm_bus->probe_active == 0);
		nd_device_lock(dev);
		device_lock(dev);
		nvdimm_bus_lock(dev);
	} while (true);
}
@@ -1167,7 +1161,7 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
		goto out;
	}

	nd_device_lock(dev);
	device_lock(dev);
	nvdimm_bus_lock(dev);
	rc = nd_cmd_clear_to_send(nvdimm_bus, nvdimm, func, buf);
	if (rc)
@@ -1189,7 +1183,7 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,

out_unlock:
	nvdimm_bus_unlock(dev);
	nd_device_unlock(dev);
	device_unlock(dev);
out:
	kfree(in_env);
	kfree(out_env);
+5 −5
Original line number Diff line number Diff line
@@ -215,7 +215,7 @@ EXPORT_SYMBOL_GPL(to_nvdimm_bus_dev);
 *
 * Enforce that uuids can only be changed while the device is disabled
 * (driver detached)
 * LOCKING: expects nd_device_lock() is held on entry
 * LOCKING: expects device_lock() is held on entry
 */
int nd_uuid_store(struct device *dev, uuid_t **uuid_out, const char *buf,
		size_t len)
@@ -316,15 +316,15 @@ static DEVICE_ATTR_RO(provider);

static int flush_namespaces(struct device *dev, void *data)
{
	nd_device_lock(dev);
	nd_device_unlock(dev);
	device_lock(dev);
	device_unlock(dev);
	return 0;
}

static int flush_regions_dimms(struct device *dev, void *data)
{
	nd_device_lock(dev);
	nd_device_unlock(dev);
	device_lock(dev);
	device_unlock(dev);
	device_for_each_child(dev, NULL, flush_namespaces);
	return 0;
}
+4 −4
Original line number Diff line number Diff line
@@ -341,9 +341,9 @@ static ssize_t available_slots_show(struct device *dev,
{
	ssize_t rc;

	nd_device_lock(dev);
	device_lock(dev);
	rc = __available_slots_show(dev_get_drvdata(dev), buf);
	nd_device_unlock(dev);
	device_unlock(dev);

	return rc;
}
@@ -386,12 +386,12 @@ static ssize_t security_store(struct device *dev,
	 * done while probing is idle and the DIMM is not in active use
	 * in any region.
	 */
	nd_device_lock(dev);
	device_lock(dev);
	nvdimm_bus_lock(dev);
	wait_nvdimm_bus_probe_idle(dev);
	rc = nvdimm_security_store(dev, buf, len);
	nvdimm_bus_unlock(dev);
	nd_device_unlock(dev);
	device_unlock(dev);

	return rc;
}
+18 −18
Original line number Diff line number Diff line
@@ -264,7 +264,7 @@ static ssize_t alt_name_store(struct device *dev,
	struct nd_region *nd_region = to_nd_region(dev->parent);
	ssize_t rc;

	nd_device_lock(dev);
	device_lock(dev);
	nvdimm_bus_lock(dev);
	wait_nvdimm_bus_probe_idle(dev);
	rc = __alt_name_store(dev, buf, len);
@@ -272,7 +272,7 @@ static ssize_t alt_name_store(struct device *dev,
		rc = nd_namespace_label_update(nd_region, dev);
	dev_dbg(dev, "%s(%zd)\n", rc < 0 ? "fail " : "", rc);
	nvdimm_bus_unlock(dev);
	nd_device_unlock(dev);
	device_unlock(dev);

	return rc < 0 ? rc : len;
}
@@ -846,7 +846,7 @@ static ssize_t size_store(struct device *dev,
	if (rc)
		return rc;

	nd_device_lock(dev);
	device_lock(dev);
	nvdimm_bus_lock(dev);
	wait_nvdimm_bus_probe_idle(dev);
	rc = __size_store(dev, val);
@@ -868,7 +868,7 @@ static ssize_t size_store(struct device *dev,
	dev_dbg(dev, "%llx %s (%d)\n", val, rc < 0 ? "fail" : "success", rc);

	nvdimm_bus_unlock(dev);
	nd_device_unlock(dev);
	device_unlock(dev);

	return rc < 0 ? rc : len;
}
@@ -1043,7 +1043,7 @@ static ssize_t uuid_store(struct device *dev,
	} else
		return -ENXIO;

	nd_device_lock(dev);
	device_lock(dev);
	nvdimm_bus_lock(dev);
	wait_nvdimm_bus_probe_idle(dev);
	if (to_ndns(dev)->claim)
@@ -1059,7 +1059,7 @@ static ssize_t uuid_store(struct device *dev,
	dev_dbg(dev, "result: %zd wrote: %s%s", rc, buf,
			buf[len - 1] == '\n' ? "" : "\n");
	nvdimm_bus_unlock(dev);
	nd_device_unlock(dev);
	device_unlock(dev);

	return rc < 0 ? rc : len;
}
@@ -1118,7 +1118,7 @@ static ssize_t sector_size_store(struct device *dev,
	} else
		return -ENXIO;

	nd_device_lock(dev);
	device_lock(dev);
	nvdimm_bus_lock(dev);
	if (to_ndns(dev)->claim)
		rc = -EBUSY;
@@ -1129,7 +1129,7 @@ static ssize_t sector_size_store(struct device *dev,
	dev_dbg(dev, "result: %zd %s: %s%s", rc, rc < 0 ? "tried" : "wrote",
			buf, buf[len - 1] == '\n' ? "" : "\n");
	nvdimm_bus_unlock(dev);
	nd_device_unlock(dev);
	device_unlock(dev);

	return rc ? rc : len;
}
@@ -1239,9 +1239,9 @@ static ssize_t holder_show(struct device *dev,
	struct nd_namespace_common *ndns = to_ndns(dev);
	ssize_t rc;

	nd_device_lock(dev);
	device_lock(dev);
	rc = sprintf(buf, "%s\n", ndns->claim ? dev_name(ndns->claim) : "");
	nd_device_unlock(dev);
	device_unlock(dev);

	return rc;
}
@@ -1278,7 +1278,7 @@ static ssize_t holder_class_store(struct device *dev,
	struct nd_region *nd_region = to_nd_region(dev->parent);
	int rc;

	nd_device_lock(dev);
	device_lock(dev);
	nvdimm_bus_lock(dev);
	wait_nvdimm_bus_probe_idle(dev);
	rc = __holder_class_store(dev, buf);
@@ -1286,7 +1286,7 @@ static ssize_t holder_class_store(struct device *dev,
		rc = nd_namespace_label_update(nd_region, dev);
	dev_dbg(dev, "%s(%d)\n", rc < 0 ? "fail " : "", rc);
	nvdimm_bus_unlock(dev);
	nd_device_unlock(dev);
	device_unlock(dev);

	return rc < 0 ? rc : len;
}
@@ -1297,7 +1297,7 @@ static ssize_t holder_class_show(struct device *dev,
	struct nd_namespace_common *ndns = to_ndns(dev);
	ssize_t rc;

	nd_device_lock(dev);
	device_lock(dev);
	if (ndns->claim_class == NVDIMM_CCLASS_NONE)
		rc = sprintf(buf, "\n");
	else if ((ndns->claim_class == NVDIMM_CCLASS_BTT) ||
@@ -1309,7 +1309,7 @@ static ssize_t holder_class_show(struct device *dev,
		rc = sprintf(buf, "dax\n");
	else
		rc = sprintf(buf, "<unknown>\n");
	nd_device_unlock(dev);
	device_unlock(dev);

	return rc;
}
@@ -1323,7 +1323,7 @@ static ssize_t mode_show(struct device *dev,
	char *mode;
	ssize_t rc;

	nd_device_lock(dev);
	device_lock(dev);
	claim = ndns->claim;
	if (claim && is_nd_btt(claim))
		mode = "safe";
@@ -1336,7 +1336,7 @@ static ssize_t mode_show(struct device *dev,
	else
		mode = "raw";
	rc = sprintf(buf, "%s\n", mode);
	nd_device_unlock(dev);
	device_unlock(dev);

	return rc;
}
@@ -1456,8 +1456,8 @@ struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev)
		 * Flush any in-progess probes / removals in the driver
		 * for the raw personality of this namespace.
		 */
		nd_device_lock(&ndns->dev);
		nd_device_unlock(&ndns->dev);
		device_lock(&ndns->dev);
		device_unlock(&ndns->dev);
		if (ndns->dev.driver) {
			dev_dbg(&ndns->dev, "is active, can't bind %s\n",
					dev_name(dev));
Loading