[PATCH] libnvdimm/bus: return the outvar 'cmd_rc' error code in __nd_ioctl()
by Vaibhav Jain
Presently the error code returned via out variable 'cmd_rc' from the
nvdimm-bus controller function is ignored when called from
__nd_ioctl() and never communicated back to user-space code that called
an ioctl on dimm/bus.
This minor patch updates __nd_ioctl() to propagate the value of out
variable 'cmd_rc' back to user-space in case it reports an error.
Signed-off-by: Vaibhav Jain <vaibhav(a)linux.ibm.com>
---
drivers/nvdimm/bus.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index a8b515968569..5b687a27fdf2 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -1153,6 +1153,11 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
if (rc < 0)
goto out_unlock;
+ if (cmd_rc < 0) {
+ rc = cmd_rc;
+ goto out_unlock;
+ }
+
if (!nvdimm && cmd == ND_CMD_CLEAR_ERROR && cmd_rc >= 0) {
struct nd_cmd_clear_error *clear_err = buf;
--
2.24.1
10 months, 3 weeks
[ndctl PATCH] ndctl/list: Drop named list objects from verbose
listing
by Dan Williams
The only expected difference between "ndctl list -R" and "ndctl list
-Rv" is some additional output fields. Instead it currently results in
the region array being contained in a named "regions" list object.
# ndctl list -R -r 0
[
{
"dev":"region0",
"size":4294967296,
"available_size":0,
"max_available_extent":0,
"type":"pmem",
"persistence_domain":"unknown"
}
]
# ndctl list -Rv -r 0
{
"regions":[
{
"dev":"region0",
"size":4294967296,
"available_size":0,
"max_available_extent":0,
"type":"pmem",
"numa_node":0,
"target_node":2,
"persistence_domain":"unknown",
"namespaces":[
{
"dev":"namespace0.0",
"mode":"fsdax",
"map":"mem",
"size":4294967296,
"sector_size":512,
"blockdev":"pmem0",
"numa_node":0,
"target_node":2
}
]
}
]
}
Drop the named list, by not including namespaces in the listing. Extra
objects only appear at the -vv level. "ndctl list -v" and "ndctl list
-Nv" are synonyms and behave as expected.
# ndctl list -Rv -r 0
[
{
"dev":"region0",
"size":4294967296,
"available_size":0,
"max_available_extent":0,
"type":"pmem",
"numa_node":0,
"target_node":2,
"persistence_domain":"unknown"
}
]
Another side effect of this change is that it allows for:
ndctl list -Rvvv
...to only show the verbose region details vs assuming that namespaces
and dimms etc also need to be added.
Signed-off-by: Dan Williams <dan.j.williams(a)intel.com>
---
Documentation/ndctl/ndctl-list.txt | 46 ++++++++++++++++++++++++++++++++++++
ndctl/list.c | 10 +++++---
2 files changed, 52 insertions(+), 4 deletions(-)
diff --git a/Documentation/ndctl/ndctl-list.txt b/Documentation/ndctl/ndctl-list.txt
index f9c7434d3b0b..75fd11876395 100644
--- a/Documentation/ndctl/ndctl-list.txt
+++ b/Documentation/ndctl/ndctl-list.txt
@@ -234,6 +234,52 @@ include::xable-bus-options.txt[]
- *-vvv*
Everything '-vv' provides, plus --health, --capabilities,
--idle, and --firmware.
+::
+ The verbosity can also be scoped by the object type. For example
+ to just list regions with capabilities and media error info.
+----
+# ndctl list -Ru -vvv -r 0
+{
+ "dev":"region0",
+ "size":"4.00 GiB (4.29 GB)",
+ "available_size":0,
+ "max_available_extent":0,
+ "type":"pmem",
+ "numa_node":0,
+ "target_node":2,
+ "capabilities":[
+ {
+ "mode":"sector",
+ "sector_sizes":[
+ 512,
+ 520,
+ 528,
+ 4096,
+ 4104,
+ 4160,
+ 4224
+ ]
+ },
+ {
+ "mode":"fsdax",
+ "alignments":[
+ 4096,
+ 2097152,
+ 1073741824
+ ]
+ },
+ {
+ "mode":"devdax",
+ "alignments":[
+ 4096,
+ 2097152,
+ 1073741824
+ ]
+ }
+ ],
+ "persistence_domain":"unknown"
+}
+----
include::human-option.txt[]
diff --git a/ndctl/list.c b/ndctl/list.c
index 607996a85784..125a9fe34cb8 100644
--- a/ndctl/list.c
+++ b/ndctl/list.c
@@ -507,12 +507,14 @@ int cmd_list(int argc, const char **argv, struct ndctl_ctx *ctx)
list.health = true;
list.capabilities = true;
case 2:
- list.dimms = true;
- list.buses = true;
- list.regions = true;
+ if (num_list_flags() == 0) {
+ list.dimms = true;
+ list.buses = true;
+ list.regions = true;
+ list.namespaces = true;
+ }
case 1:
list.media_errors = true;
- list.namespaces = true;
list.dax = true;
case 0:
break;
10 months, 3 weeks
[PATCH v3 1/3] libnvdimm/of_pmem: factor out region registration
by Alistair Delva
From: Kenny Root <kroot(a)google.com>
Factor out region registration for 'reg' node. A follow-up change will
use of_pmem_register_region() to handle memory-region nodes too.
Signed-off-by: Kenny Root <kroot(a)google.com>
Signed-off-by: Alistair Delva <adelva(a)google.com>
Reviewed-by: "Oliver O'Halloran" <oohall(a)gmail.com>
Cc: Rob Herring <robh+dt(a)kernel.org>
Cc: Dan Williams <dan.j.williams(a)intel.com>
Cc: Vishal Verma <vishal.l.verma(a)intel.com>
Cc: Dave Jiang <dave.jiang(a)intel.com>
Cc: Ira Weiny <ira.weiny(a)intel.com>
Cc: devicetree(a)vger.kernel.org
Cc: linux-nvdimm(a)lists.01.org
Cc: kernel-team(a)android.com
---
[v3: adelva: remove duplicate "From:"]
drivers/nvdimm/of_pmem.c | 60 +++++++++++++++++++++++-----------------
1 file changed, 35 insertions(+), 25 deletions(-)
diff --git a/drivers/nvdimm/of_pmem.c b/drivers/nvdimm/of_pmem.c
index 8224d1431ea9..fdf54494e8c9 100644
--- a/drivers/nvdimm/of_pmem.c
+++ b/drivers/nvdimm/of_pmem.c
@@ -14,6 +14,39 @@ struct of_pmem_private {
struct nvdimm_bus *bus;
};
+static void of_pmem_register_region(struct platform_device *pdev,
+ struct nvdimm_bus *bus,
+ struct device_node *np,
+ struct resource *res, bool is_volatile)
+{
+ struct nd_region_desc ndr_desc;
+ struct nd_region *region;
+
+ /*
+ * NB: libnvdimm copies the data from ndr_desc into it's own
+ * structures so passing a stack pointer is fine.
+ */
+ memset(&ndr_desc, 0, sizeof(ndr_desc));
+ ndr_desc.numa_node = dev_to_node(&pdev->dev);
+ ndr_desc.target_node = ndr_desc.numa_node;
+ ndr_desc.res = res;
+ ndr_desc.of_node = np;
+ set_bit(ND_REGION_PAGEMAP, &ndr_desc.flags);
+
+ if (is_volatile)
+ region = nvdimm_volatile_region_create(bus, &ndr_desc);
+ else
+ region = nvdimm_pmem_region_create(bus, &ndr_desc);
+
+ if (!region)
+ dev_warn(&pdev->dev,
+ "Unable to register region %pR from %pOF\n",
+ ndr_desc.res, np);
+ else
+ dev_dbg(&pdev->dev, "Registered region %pR from %pOF\n",
+ ndr_desc.res, np);
+}
+
static int of_pmem_region_probe(struct platform_device *pdev)
{
struct of_pmem_private *priv;
@@ -46,31 +79,8 @@ static int of_pmem_region_probe(struct platform_device *pdev)
is_volatile ? "volatile" : "non-volatile", np);
for (i = 0; i < pdev->num_resources; i++) {
- struct nd_region_desc ndr_desc;
- struct nd_region *region;
-
- /*
- * NB: libnvdimm copies the data from ndr_desc into it's own
- * structures so passing a stack pointer is fine.
- */
- memset(&ndr_desc, 0, sizeof(ndr_desc));
- ndr_desc.numa_node = dev_to_node(&pdev->dev);
- ndr_desc.target_node = ndr_desc.numa_node;
- ndr_desc.res = &pdev->resource[i];
- ndr_desc.of_node = np;
- set_bit(ND_REGION_PAGEMAP, &ndr_desc.flags);
-
- if (is_volatile)
- region = nvdimm_volatile_region_create(bus, &ndr_desc);
- else
- region = nvdimm_pmem_region_create(bus, &ndr_desc);
-
- if (!region)
- dev_warn(&pdev->dev, "Unable to register region %pR from %pOF\n",
- ndr_desc.res, np);
- else
- dev_dbg(&pdev->dev, "Registered region %pR from %pOF\n",
- ndr_desc.res, np);
+ of_pmem_register_region(pdev, bus, np, &pdev->resource[i],
+ is_volatile);
}
return 0;
--
2.25.0.265.gbab2e86ba0-goog
10 months, 3 weeks
[ndctl PATCH 0/2] ndctl: Cross-arch compatible namespace alignment
by Dan Williams
A follow-up to the region-align kernel enabling, [1], update ndctl to
enumerate region alignment, and update the unit tests to account for the
kernel's default compatible alignment.
Given that changing the default is a surefire way to create incompatible
namespaces I do not think it makes sense to plumb region alignment
through the create-namespace interface. Only expert users would be
expected to trawl through sysfs and set a non-default alignment. I.e.
the lack of documentation and enabling for setting this value in the
ndctl man pages is deliberate.
---
Dan Williams (2):
ndctl/region: Support ndctl_region_{get,set}_align()
ndctl/namespace: Improve namespace action failure messages
ndctl/lib/libndctl.c | 35 ++++++++++++++++++++
ndctl/lib/libndctl.sym | 2 +
ndctl/libndctl.h | 2 +
ndctl/list.c | 5 +++
ndctl/namespace.c | 82 ++++++++++++++++++++++++++++++++----------------
test/blk_namespaces.c | 1 +
test/dpa-alloc.c | 10 +++++-
test/dsm-fail.c | 5 ++-
test/libndctl.c | 10 +++++-
test/parent-uuid.c | 1 +
10 files changed, 121 insertions(+), 32 deletions(-)
10 months, 3 weeks
[PATCH 1/2] acpi/nfit: improve bounds checking for 'func'
by Dan Carpenter
The 'func' variable can come from the user in the __nd_ioctl(). If it's
too high then the (1 << func) shift in acpi_nfit_clear_to_send() is
undefined. In acpi_nfit_ctl() we pass 'func' to test_bit(func, &dsm_mask)
which could result in an out of bounds access.
To fix these issues, I introduced the NVDIMM_CMD_MAX (31) define and
updated nfit_dsm_revid() to use that define as well instead of magic
numbers.
Fixes: 11189c1089da ("acpi/nfit: Fix command-supported detection")
Signed-off-by: Dan Carpenter <dan.carpenter(a)oracle.com>
---
drivers/acpi/nfit/core.c | 10 ++++++----
drivers/acpi/nfit/nfit.h | 1 +
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/acpi/nfit/nfit.h b/drivers/acpi/nfit/nfit.h
index 24241941181c..b317f4043705 100644
--- a/drivers/acpi/nfit/nfit.h
+++ b/drivers/acpi/nfit/nfit.h
@@ -34,6 +34,7 @@
| ACPI_NFIT_MEM_NOT_ARMED | ACPI_NFIT_MEM_MAP_FAILED)
#define NVDIMM_FAMILY_MAX NVDIMM_FAMILY_HYPERV
+#define NVDIMM_CMD_MAX 31
#define NVDIMM_STANDARD_CMDMASK \
(1 << ND_CMD_SMART | 1 << ND_CMD_SMART_THRESHOLD | 1 << ND_CMD_DIMM_FLAGS \
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index a3320f93616d..d0090f71585c 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -360,7 +360,7 @@ static union acpi_object *acpi_label_info(acpi_handle handle)
static u8 nfit_dsm_revid(unsigned family, unsigned func)
{
- static const u8 revid_table[NVDIMM_FAMILY_MAX+1][32] = {
+ static const u8 revid_table[NVDIMM_FAMILY_MAX+1][NVDIMM_CMD_MAX+1] = {
[NVDIMM_FAMILY_INTEL] = {
[NVDIMM_INTEL_GET_MODES] = 2,
[NVDIMM_INTEL_GET_FWINFO] = 2,
@@ -386,7 +386,7 @@ static u8 nfit_dsm_revid(unsigned family, unsigned func)
if (family > NVDIMM_FAMILY_MAX)
return 0;
- if (func > 31)
+ if (func > NVDIMM_CMD_MAX)
return 0;
id = revid_table[family][func];
if (id == 0)
@@ -492,7 +492,8 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
* Check for a valid command. For ND_CMD_CALL, we also have to
* make sure that the DSM function is supported.
*/
- if (cmd == ND_CMD_CALL && !test_bit(func, &dsm_mask))
+ if (cmd == ND_CMD_CALL &&
+ (func > NVDIMM_CMD_MAX || !test_bit(func, &dsm_mask)))
return -ENOTTY;
else if (!test_bit(cmd, &cmd_mask))
return -ENOTTY;
@@ -3492,7 +3493,8 @@ static int acpi_nfit_clear_to_send(struct nvdimm_bus_descriptor *nd_desc,
if (nvdimm && cmd == ND_CMD_CALL &&
call_pkg->nd_family == NVDIMM_FAMILY_INTEL) {
func = call_pkg->nd_command;
- if ((1 << func) & NVDIMM_INTEL_SECURITY_CMDMASK)
+ if (func > NVDIMM_CMD_MAX ||
+ (1 << func) & NVDIMM_INTEL_SECURITY_CMDMASK)
return -EOPNOTSUPP;
}
--
2.11.0
10 months, 4 weeks
[ndctl,RFC 0/3] Enable to run multiple monitor daemons as system services
by Keisuke Sugita
Hello, this is my first OSS contribution!
This patch is to monitor specific dimms, regions, buses,
namespaces, or dimm-events where users set up to monitor
independently and concurrently by running multiple monitor
daemons as system services.
Users will be able to monitor multiple elements and check each log file
by this patch.
So far, users can only run a single monitor daemon because units name
is fixed to "ndctl-monitor.service" now, and then users cannot monitor
multiple elements concurrently. For example, users want to monitor
a specific bus and namespace, but they are not able to do now.
I solve this problem by instance name of systemd.
Keisuke Sugita (3):
ndctl: Documentation: Write how to use multiple monitor daemon concullently
ndctl: ndctl-monitor@.service: Add new unit file for multi daemon support
ndctl: Makefile.am: make ndctl-monitor@.service in compiling
Documentation/ndctl/ndctl-monitor.txt | 11 +++++++++++
ndctl/Makefile.am | 1 +
ndctl/ndctl-monitor@.service | 9 +++++++++
3 files changed, 21 insertions(+)
create mode 100644 ndctl/ndctl-monitor@.service
--
2.24.1
10 months, 4 weeks
[PATCH v2 1/3] libnvdimm/of_pmem: factor out region registration
by Alistair Delva
From: Kenny Root <kroot(a)google.com>
From: Kenny Root <kroot(a)google.com>
Factor out region registration for 'reg' node. A follow-up change will
use of_pmem_register_region() to handle memory-region nodes too.
Signed-off-by: Kenny Root <kroot(a)google.com>
Signed-off-by: Alistair Delva <adelva(a)google.com>
Reviewed-by: "Oliver O'Halloran" <oohall(a)gmail.com>
Cc: Rob Herring <robh+dt(a)kernel.org>
Cc: Dan Williams <dan.j.williams(a)intel.com>
Cc: Vishal Verma <vishal.l.verma(a)intel.com>
Cc: Dave Jiang <dave.jiang(a)intel.com>
Cc: Ira Weiny <ira.weiny(a)intel.com>
Cc: devicetree(a)vger.kernel.org
Cc: linux-nvdimm(a)lists.01.org
Cc: kernel-team(a)android.com
---
drivers/nvdimm/of_pmem.c | 60 +++++++++++++++++++++++-----------------
1 file changed, 35 insertions(+), 25 deletions(-)
diff --git a/drivers/nvdimm/of_pmem.c b/drivers/nvdimm/of_pmem.c
index 8224d1431ea9..fdf54494e8c9 100644
--- a/drivers/nvdimm/of_pmem.c
+++ b/drivers/nvdimm/of_pmem.c
@@ -14,6 +14,39 @@ struct of_pmem_private {
struct nvdimm_bus *bus;
};
+static void of_pmem_register_region(struct platform_device *pdev,
+ struct nvdimm_bus *bus,
+ struct device_node *np,
+ struct resource *res, bool is_volatile)
+{
+ struct nd_region_desc ndr_desc;
+ struct nd_region *region;
+
+ /*
+ * NB: libnvdimm copies the data from ndr_desc into it's own
+ * structures so passing a stack pointer is fine.
+ */
+ memset(&ndr_desc, 0, sizeof(ndr_desc));
+ ndr_desc.numa_node = dev_to_node(&pdev->dev);
+ ndr_desc.target_node = ndr_desc.numa_node;
+ ndr_desc.res = res;
+ ndr_desc.of_node = np;
+ set_bit(ND_REGION_PAGEMAP, &ndr_desc.flags);
+
+ if (is_volatile)
+ region = nvdimm_volatile_region_create(bus, &ndr_desc);
+ else
+ region = nvdimm_pmem_region_create(bus, &ndr_desc);
+
+ if (!region)
+ dev_warn(&pdev->dev,
+ "Unable to register region %pR from %pOF\n",
+ ndr_desc.res, np);
+ else
+ dev_dbg(&pdev->dev, "Registered region %pR from %pOF\n",
+ ndr_desc.res, np);
+}
+
static int of_pmem_region_probe(struct platform_device *pdev)
{
struct of_pmem_private *priv;
@@ -46,31 +79,8 @@ static int of_pmem_region_probe(struct platform_device *pdev)
is_volatile ? "volatile" : "non-volatile", np);
for (i = 0; i < pdev->num_resources; i++) {
- struct nd_region_desc ndr_desc;
- struct nd_region *region;
-
- /*
- * NB: libnvdimm copies the data from ndr_desc into it's own
- * structures so passing a stack pointer is fine.
- */
- memset(&ndr_desc, 0, sizeof(ndr_desc));
- ndr_desc.numa_node = dev_to_node(&pdev->dev);
- ndr_desc.target_node = ndr_desc.numa_node;
- ndr_desc.res = &pdev->resource[i];
- ndr_desc.of_node = np;
- set_bit(ND_REGION_PAGEMAP, &ndr_desc.flags);
-
- if (is_volatile)
- region = nvdimm_volatile_region_create(bus, &ndr_desc);
- else
- region = nvdimm_pmem_region_create(bus, &ndr_desc);
-
- if (!region)
- dev_warn(&pdev->dev, "Unable to register region %pR from %pOF\n",
- ndr_desc.res, np);
- else
- dev_dbg(&pdev->dev, "Registered region %pR from %pOF\n",
- ndr_desc.res, np);
+ of_pmem_register_region(pdev, bus, np, &pdev->resource[i],
+ is_volatile);
}
return 0;
--
2.25.0.265.gbab2e86ba0-goog
10 months, 4 weeks
[PATCH v2] dax: Add missing annotations for dax_read_lock() and dax_read_unlock()
by Jules Irenge
Sparse reports warnings at dax_read_lock() and dax_read_unlock()
warning: context imbalance in dax_read_lock() - wrong count at exit
warning: context imbalance in dax_read_unlock() - unexpected unlock
The root cause is the missing annotations at dax_read_lock()
and dax_read_unlock()
Add the missing __acquires(&dax_srcu) annotation to dax_read_lock()
Add the missing __releases(&dax_srcu) annotation to dax_read_unlock()
Signed-off-by: Jules Irenge <jbi.octave(a)gmail.com>
---
Changes since V1
Correct commit log typing mistakes
drivers/dax/super.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index 26a654dbc69a..f872a2fb98d4 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -28,13 +28,13 @@ static struct super_block *dax_superblock __read_mostly;
static struct hlist_head dax_host_list[DAX_HASH_SIZE];
static DEFINE_SPINLOCK(dax_host_lock);
-int dax_read_lock(void)
+int dax_read_lock(void) __acquires(&dax_srcu)
{
return srcu_read_lock(&dax_srcu);
}
EXPORT_SYMBOL_GPL(dax_read_lock);
-void dax_read_unlock(int id)
+void dax_read_unlock(int id) __releases(&dax_srcu)
{
srcu_read_unlock(&dax_srcu, id);
}
--
2.24.1
11 months
[PATCH 1/2] libnvdimm/of_pmem: handle memory-region in DT
by Alistair Delva
From: Kenny Root <kroot(a)google.com>
Add support for parsing the 'memory-region' DT property in addition to
the 'reg' DT property. This enables use cases where the pmem region is
not in I/O address space or dedicated memory (e.g. a bootloader
carveout).
Signed-off-by: Kenny Root <kroot(a)google.com>
Signed-off-by: Alistair Delva <adelva(a)google.com>
Cc: "Oliver O'Halloran" <oohall(a)gmail.com>
Cc: Rob Herring <robh+dt(a)kernel.org>
Cc: Dan Williams <dan.j.williams(a)intel.com>
Cc: Vishal Verma <vishal.l.verma(a)intel.com>
Cc: Dave Jiang <dave.jiang(a)intel.com>
Cc: Ira Weiny <ira.weiny(a)intel.com>
Cc: devicetree(a)vger.kernel.org
Cc: linux-nvdimm(a)lists.01.org
Cc: kernel-team(a)android.com
---
drivers/nvdimm/of_pmem.c | 75 ++++++++++++++++++++++++++--------------
1 file changed, 50 insertions(+), 25 deletions(-)
diff --git a/drivers/nvdimm/of_pmem.c b/drivers/nvdimm/of_pmem.c
index 8224d1431ea9..a68e44fb0041 100644
--- a/drivers/nvdimm/of_pmem.c
+++ b/drivers/nvdimm/of_pmem.c
@@ -14,13 +14,47 @@ struct of_pmem_private {
struct nvdimm_bus *bus;
};
+static void of_pmem_register_region(struct platform_device *pdev,
+ struct nvdimm_bus *bus,
+ struct device_node *np,
+ struct resource *res, bool is_volatile)
+{
+ struct nd_region_desc ndr_desc;
+ struct nd_region *region;
+
+ /*
+ * NB: libnvdimm copies the data from ndr_desc into it's own
+ * structures so passing a stack pointer is fine.
+ */
+ memset(&ndr_desc, 0, sizeof(ndr_desc));
+ ndr_desc.numa_node = dev_to_node(&pdev->dev);
+ ndr_desc.target_node = ndr_desc.numa_node;
+ ndr_desc.res = res;
+ ndr_desc.of_node = np;
+ set_bit(ND_REGION_PAGEMAP, &ndr_desc.flags);
+
+ if (is_volatile)
+ region = nvdimm_volatile_region_create(bus, &ndr_desc);
+ else
+ region = nvdimm_pmem_region_create(bus, &ndr_desc);
+
+ if (!region)
+ dev_warn(&pdev->dev,
+ "Unable to register region %pR from %pOF\n",
+ ndr_desc.res, np);
+ else
+ dev_dbg(&pdev->dev, "Registered region %pR from %pOF\n",
+ ndr_desc.res, np);
+}
+
static int of_pmem_region_probe(struct platform_device *pdev)
{
struct of_pmem_private *priv;
- struct device_node *np;
+ struct device_node *mrp, *np;
struct nvdimm_bus *bus;
+ struct resource res;
bool is_volatile;
- int i;
+ int i, ret;
np = dev_of_node(&pdev->dev);
if (!np)
@@ -46,31 +80,22 @@ static int of_pmem_region_probe(struct platform_device *pdev)
is_volatile ? "volatile" : "non-volatile", np);
for (i = 0; i < pdev->num_resources; i++) {
- struct nd_region_desc ndr_desc;
- struct nd_region *region;
-
- /*
- * NB: libnvdimm copies the data from ndr_desc into it's own
- * structures so passing a stack pointer is fine.
- */
- memset(&ndr_desc, 0, sizeof(ndr_desc));
- ndr_desc.numa_node = dev_to_node(&pdev->dev);
- ndr_desc.target_node = ndr_desc.numa_node;
- ndr_desc.res = &pdev->resource[i];
- ndr_desc.of_node = np;
- set_bit(ND_REGION_PAGEMAP, &ndr_desc.flags);
-
- if (is_volatile)
- region = nvdimm_volatile_region_create(bus, &ndr_desc);
- else
- region = nvdimm_pmem_region_create(bus, &ndr_desc);
+ of_pmem_register_region(pdev, bus, np, &pdev->resource[i],
+ is_volatile);
+ }
- if (!region)
- dev_warn(&pdev->dev, "Unable to register region %pR from %pOF\n",
- ndr_desc.res, np);
+ i = 0;
+ while ((mr_np = of_parse_phandle(np, "memory-region", i++))) {
+ ret = of_address_to_resource(mr_np, 0, &res);
+ if (ret)
+ dev_warn(
+ &pdev->dev,
+ "Unable to acquire memory-region from %pOF: %d\n",
+ mr_np, ret);
else
- dev_dbg(&pdev->dev, "Registered region %pR from %pOF\n",
- ndr_desc.res, np);
+ of_pmem_register_region(pdev, bus, np, &res,
+ is_volatile);
+ of_node_put(mr_np);
}
return 0;
--
2.25.0.265.gbab2e86ba0-goog
11 months
[PATCH 02/30] dax: Add missing annotations ofr dax_read_lock() and dax_read_unlock()
by Jules Irenge
Sparse reports warning at dax_read_lock() and at dax_read_unlock()
warning: context imbalance in dax_read_lock() - wrong count at exit
warning: context imbalance in dax_read_unlock() - unexpected unlock
The root cause is the mnissing annotations at dax_read_lock()
and dax_read_unlock()
Add the missing __acquires(&dax_srcu) notations to dax_read_lock()
Add the missing __releases(&dax_srcu) annotation to dax_read_unlock()
Signed-off-by: Jules Irenge <jbi.octave(a)gmail.com>
---
drivers/dax/super.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index 26a654dbc69a..f872a2fb98d4 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -28,13 +28,13 @@ static struct super_block *dax_superblock __read_mostly;
static struct hlist_head dax_host_list[DAX_HASH_SIZE];
static DEFINE_SPINLOCK(dax_host_lock);
-int dax_read_lock(void)
+int dax_read_lock(void) __acquires(&dax_srcu)
{
return srcu_read_lock(&dax_srcu);
}
EXPORT_SYMBOL_GPL(dax_read_lock);
-void dax_read_unlock(int id)
+void dax_read_unlock(int id) __releases(&dax_srcu)
{
srcu_read_unlock(&dax_srcu, id);
}
--
2.24.1
11 months