hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/nvdimm/dimm.c
....@@ -1,14 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of version 2 of the GNU General Public License as
6
- * published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope that it will be useful, but
9
- * WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
- * General Public License for more details.
124 */
135 #include <linux/vmalloc.h>
146 #include <linux/module.h>
....@@ -26,6 +18,12 @@
2618 struct nvdimm_drvdata *ndd;
2719 int rc;
2820
21
+ rc = nvdimm_security_setup_events(dev);
22
+ if (rc < 0) {
23
+ dev_err(dev, "security event setup failed: %d\n", rc);
24
+ return rc;
25
+ }
26
+
2927 rc = nvdimm_check_config_data(dev);
3028 if (rc) {
3129 /* not required for non-aliased nvdimm, ex. NVDIMM-N */
....@@ -34,7 +32,11 @@
3432 return rc;
3533 }
3634
37
- /* reset locked, to be validated below... */
35
+ /*
36
+ * The locked status bit reflects explicit status codes from the
37
+ * label reading commands, revalidate it each time the driver is
38
+ * activated and re-reads the label area.
39
+ */
3840 nvdimm_clear_locked(dev);
3941
4042 ndd = kzalloc(sizeof(*ndd), GFP_KERNEL);
....@@ -50,6 +52,16 @@
5052 ndd->dev = dev;
5153 get_device(dev);
5254 kref_init(&ndd->kref);
55
+
56
+ /*
57
+ * Attempt to unlock, if the DIMM supports security commands,
58
+ * otherwise the locked indication is determined by explicit
59
+ * status codes from the label reading commands.
60
+ */
61
+ rc = nvdimm_security_unlock(dev);
62
+ if (rc < 0)
63
+ dev_dbg(dev, "failed to unlock dimm: %d\n", rc);
64
+
5365
5466 /*
5567 * EACCES failures reading the namespace label-area-properties
....@@ -75,7 +87,7 @@
7587 * DIMM capacity. We fail the dimm probe to prevent regions from
7688 * attempting to parse the label area.
7789 */
78
- rc = nvdimm_init_config_data(ndd);
90
+ rc = nd_label_data_init(ndd);
7991 if (rc == -EACCES)
8092 nvdimm_set_locked(dev);
8193 if (rc)
....@@ -84,14 +96,10 @@
8496 dev_dbg(dev, "config data size: %d\n", ndd->nsarea.config_size);
8597
8698 nvdimm_bus_lock(dev);
87
- ndd->ns_current = nd_label_validate(ndd);
88
- ndd->ns_next = nd_label_next_nsindex(ndd->ns_current);
89
- nd_label_copy(ndd, to_next_namespace_index(ndd),
90
- to_current_namespace_index(ndd));
9199 if (ndd->ns_current >= 0) {
92100 rc = nd_label_reserve_dpa(ndd);
93101 if (rc == 0)
94
- nvdimm_set_aliasing(dev);
102
+ nvdimm_set_labeling(dev);
95103 }
96104 nvdimm_bus_unlock(dev);
97105