Skip to contentSkip to conversation

add error injection commands to nfit_test

PATCH Superseded Vishal Verma 3 participants 12 messages Oct 6, 2017 – Oct 9, 2017

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Vishal Verma

author maintainer
#0 lore raw

cover add error injection commands to nfit_test

These patches add error injection support to nfit_test by emulating the ACPI6.2 ARS error injection commands. The commands are sent via the ND_CMD_CALL interface, so only nfit_test knows of the various definitions related to this.

Note that this patch set will break ndctl unit tests unless the ndctl patches for error injection are also applied.

Dave Jiang (2):
libnvdimm: move poison list functions to a new 'badrange' file
nfit_test: add error injection DSMs

Vishal Verma (2):
libnvdimm, badrange: remove a WARN for list_empty
nfit_test: when clearing poison, also remove badrange entries

 drivers/acpi/nfit/core.c              |   2 +-
 drivers/acpi/nfit/mce.c               |   2 +-
 drivers/acpi/nfit/nfit.h              |   1 +
 drivers/nvdimm/Makefile               |   1 +
 drivers/nvdimm/badrange.c             | 293 ++++++++++++++++++++++++++++++++++
 drivers/nvdimm/bus.c                  |  24 +--
 drivers/nvdimm/core.c                 | 260 +-----------------------------
 drivers/nvdimm/nd-core.h              |   3 +-
 drivers/nvdimm/nd.h                   |   6 -
 include/linux/libnvdimm.h             |  21 ++-
 tools/testing/nvdimm/Kbuild           |   1 +
 tools/testing/nvdimm/test/nfit.c      | 199 +++++++++++++++++++----
 tools/testing/nvdimm/test/nfit_test.h |   4 +
 13 files changed, 503 insertions(+), 314 deletions(-)
 create mode 100644 drivers/nvdimm/badrange.c
Signature · 6 lines
2.9.5

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
author maintainer
#1 lore raw

PATCH 1/4 libnvdimm: move poison list functions to a new 'badrange' file

From: Dave Jiang <[email protected]>

From: Dave Jiang <[email protected]>

nfit_test needs to use the poison list manipulation code as well. Make it more generic and in the process rename poison to badrange, and move all the related helpers to a new file.

[vishal: add a missed include in bus.c for the new badrange functions]
---
 drivers/acpi/nfit/core.c  |   2 +-
 drivers/acpi/nfit/mce.c   |   2 +-
 drivers/nvdimm/Makefile   |   1 +
 drivers/nvdimm/badrange.c | 294 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/nvdimm/bus.c      |  24 ++--
 drivers/nvdimm/core.c     | 260 +---------------------------------------
 drivers/nvdimm/nd-core.h  |   3 +-
 drivers/nvdimm/nd.h       |   6 -
 include/linux/libnvdimm.h |  21 +++-
 9 files changed, 331 insertions(+), 282 deletions(-)
 create mode 100644 drivers/nvdimm/badrange.c
drivers/acpi/nfit/core.c +1 -1
index a3ecd5e..4b157f8 100644
@@ -2240,7 +2240,7 @@ static int ars_status_process_records(struct acpi_nfit_desc *acpi_desc,
 		if (ars_status->out_length
 				< 44 + sizeof(struct nd_ars_record) * (i + 1))
 			break;
-		rc = nvdimm_bus_add_poison(nvdimm_bus,
+		rc = nvdimm_bus_add_badrange(nvdimm_bus,
 				ars_status->records[i].err_address,
 				ars_status->records[i].length);
 		if (rc)
drivers/acpi/nfit/mce.c +1 -1
index feeb95d..b929214 100644
@@ -67,7 +67,7 @@ static int nfit_handle_mce(struct notifier_block *nb, unsigned long val,
 			continue;
 
 		/* If this fails due to an -ENOMEM, there is little we can do */
-		nvdimm_bus_add_poison(acpi_desc->nvdimm_bus,
+		nvdimm_bus_add_badrange(acpi_desc->nvdimm_bus,
 				ALIGN(mce->addr, L1_CACHE_BYTES),
 				L1_CACHE_BYTES);
 		nvdimm_region_notify(nfit_spa->nd_region,
drivers/nvdimm/Makefile +1 -0
index 909554c..ca6d325 100644
@@ -20,6 +20,7 @@ libnvdimm-y += region_devs.o
 libnvdimm-y += region.o
 libnvdimm-y += namespace_devs.o
 libnvdimm-y += label.o
+libnvdimm-y += badrange.o
 libnvdimm-$(CONFIG_ND_CLAIM) += claim.o
 libnvdimm-$(CONFIG_BTT) += btt_devs.o
 libnvdimm-$(CONFIG_NVDIMM_PFN) += pfn_devs.o
drivers/nvdimm/badrange.c new file +294 -0

294 lines not on this page · raw message

drivers/nvdimm/bus.c +12 -12
index baf2839..0d4d0f4 100644
@@ -11,6 +11,7 @@
  * General Public License for more details.
  */
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include <linux/libnvdimm.h>
 #include <linux/sched/mm.h>
 #include <linux/vmalloc.h>
 #include <linux/uaccess.h>
@@ -221,7 +222,7 @@ static void nvdimm_account_cleared_poison(struct nvdimm_bus *nvdimm_bus,
 		phys_addr_t phys, u64 cleared)
 {
 	if (cleared > 0)
-		nvdimm_forget_poison(nvdimm_bus, phys, cleared);
+		badrange_forget(&nvdimm_bus->badrange, phys, cleared);
 
 	if (cleared > 0 && cleared / 512)
 		nvdimm_clear_badblocks_regions(nvdimm_bus, phys, cleared);
@@ -344,11 +345,10 @@ struct nvdimm_bus *nvdimm_bus_register(struct device *parent,
 		return NULL;
 	INIT_LIST_HEAD(&nvdimm_bus->list);
 	INIT_LIST_HEAD(&nvdimm_bus->mapping_list);
-	INIT_LIST_HEAD(&nvdimm_bus->poison_list);
 	init_waitqueue_head(&nvdimm_bus->probe_wait);
 	nvdimm_bus->id = ida_simple_get(&nd_ida, 0, 0, GFP_KERNEL);
 	mutex_init(&nvdimm_bus->reconfig_mutex);
-	spin_lock_init(&nvdimm_bus->poison_lock);
+	badrange_init(&nvdimm_bus->badrange);
 	if (nvdimm_bus->id < 0) {
 		kfree(nvdimm_bus);
 		return NULL;
@@ -395,15 +395,15 @@ static int child_unregister(struct device *dev, void *data)
 	return 0;
 }
 
-static void free_poison_list(struct list_head *poison_list)
+static void free_badrange_list(struct list_head *badrange_list)
 {
-	struct nd_poison *pl, *next;
+	struct badrange_entry *be, *next;
 
-	list_for_each_entry_safe(pl, next, poison_list, list) {
-		list_del(&pl->list);
-		kfree(pl);
+	list_for_each_entry_safe(be, next, badrange_list, list) {
+		list_del(&be->list);
+		kfree(be);
 	}
-	list_del_init(poison_list);
+	list_del_init(badrange_list);
 }
 
 static int nd_bus_remove(struct device *dev)
@@ -417,9 +417,9 @@ static int nd_bus_remove(struct device *dev)
 	nd_synchronize();
 	device_for_each_child(&nvdimm_bus->dev, NULL, child_unregister);
 
-	spin_lock(&nvdimm_bus->poison_lock);
-	free_poison_list(&nvdimm_bus->poison_list);
-	spin_unlock(&nvdimm_bus->poison_lock);
+	spin_lock(&nvdimm_bus->badrange.lock);
+	free_badrange_list(&nvdimm_bus->badrange.list);
+	spin_unlock(&nvdimm_bus->badrange.lock);
 
 	nvdimm_bus_destroy_ndctl(nvdimm_bus);
 
drivers/nvdimm/core.c +3 -257

268 lines not on this page · raw message

drivers/nvdimm/nd-core.h +1 -2
index 86bc19a..79274ea 100644
@@ -29,10 +29,9 @@ struct nvdimm_bus {
 	struct list_head list;
 	struct device dev;
 	int id, probe_active;
-	struct list_head poison_list;
 	struct list_head mapping_list;
 	struct mutex reconfig_mutex;
-	spinlock_t poison_lock;
+	struct badrange badrange;
 };
 
 struct nvdimm {
drivers/nvdimm/nd.h +0 -6
index 023fc93..377c800 100644
@@ -34,12 +34,6 @@ enum {
 	NVDIMM_IO_ATOMIC = 1,
 };
 
-struct nd_poison {
-	u64 start;
-	u64 length;
-	struct list_head list;
-};
-
 struct nvdimm_drvdata {
 	struct device *dev;
 	int nslabel_size;
include/linux/libnvdimm.h +18 -3
index 3eaad2f..f8109dd 100644
@@ -18,6 +18,18 @@
 #include <linux/sizes.h>
 #include <linux/types.h>
 #include <linux/uuid.h>
+#include <linux/spinlock.h>
+
+struct badrange_entry {
+	u64 start;
+	u64 length;
+	struct list_head list;
+};
+
+struct badrange {
+	struct list_head list;
+	spinlock_t lock;
+};
 
 enum {
 	/* when a dimm supports both PMEM and BLK access a label is required */
@@ -129,9 +141,12 @@ static inline struct nd_blk_region_desc *to_blk_region_desc(
 
 }
 
-int nvdimm_bus_add_poison(struct nvdimm_bus *nvdimm_bus, u64 addr, u64 length);
-void nvdimm_forget_poison(struct nvdimm_bus *nvdimm_bus,
-		phys_addr_t start, unsigned int len);
+void badrange_init(struct badrange *badrange);
+int badrange_add(struct badrange *badrange, u64 addr, u64 length);
+void badrange_forget(struct badrange *badrange, phys_addr_t start,
+		unsigned int len);
+int nvdimm_bus_add_badrange(struct nvdimm_bus *nvdimm_bus, u64 addr,
+		u64 length);
 struct nvdimm_bus *nvdimm_bus_register(struct device *parent,
 		struct nvdimm_bus_descriptor *nfit_desc);
 void nvdimm_bus_unregister(struct nvdimm_bus *nvdimm_bus);
Signature · 6 lines
2.9.5

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#2 lore raw

Re: [PATCH 1/4] libnvdimm: move poison list functions to a new 'badrange' file

Quoted 99 lines · Vishal Verma

From: Dave Jiang <[email protected]>

From: Dave Jiang <[email protected]>

nfit_test needs to use the poison list manipulation code as well. Make it more generic and in the process rename poison to badrange, and move all the related helpers to a new file.

[vishal: add a missed include in bus.c for the new badrange functions]
---
 drivers/acpi/nfit/core.c  |   2 +-
 drivers/acpi/nfit/mce.c   |   2 +-
 drivers/nvdimm/Makefile   |   1 +
 drivers/nvdimm/badrange.c | 294 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/nvdimm/bus.c      |  24 ++--
 drivers/nvdimm/core.c     | 260 +---------------------------------------
 drivers/nvdimm/nd-core.h  |   3 +-
 drivers/nvdimm/nd.h       |   6 -
 include/linux/libnvdimm.h |  21 +++-
 9 files changed, 331 insertions(+), 282 deletions(-)
 create mode 100644 drivers/nvdimm/badrange.c
drivers/acpi/nfit/core.c +1 -1
index a3ecd5e..4b157f8 100644
@@ -2240,7 +2240,7 @@ static int ars_status_process_records(struct acpi_nfit_desc *acpi_desc,
                if (ars_status->out_length
                                < 44 + sizeof(struct nd_ars_record) * (i + 1))
                        break;
-               rc = nvdimm_bus_add_poison(nvdimm_bus,
+               rc = nvdimm_bus_add_badrange(nvdimm_bus,
                                ars_status->records[i].err_address,
                                ars_status->records[i].length);
                if (rc)
drivers/acpi/nfit/mce.c +1 -1
index feeb95d..b929214 100644
@@ -67,7 +67,7 @@ static int nfit_handle_mce(struct notifier_block *nb, unsigned long val,
                        continue;
 
                /* If this fails due to an -ENOMEM, there is little we can do */
-               nvdimm_bus_add_poison(acpi_desc->nvdimm_bus,
+               nvdimm_bus_add_badrange(acpi_desc->nvdimm_bus,
                                ALIGN(mce->addr, L1_CACHE_BYTES),
                                L1_CACHE_BYTES);
                nvdimm_region_notify(nfit_spa->nd_region,
drivers/nvdimm/Makefile +1 -0
index 909554c..ca6d325 100644
@@ -20,6 +20,7 @@ libnvdimm-y += region_devs.o
 libnvdimm-y += region.o
 libnvdimm-y += namespace_devs.o
 libnvdimm-y += label.o
+libnvdimm-y += badrange.o
 libnvdimm-$(CONFIG_ND_CLAIM) += claim.o
 libnvdimm-$(CONFIG_BTT) += btt_devs.o
 libnvdimm-$(CONFIG_NVDIMM_PFN) += pfn_devs.o
drivers/nvdimm/badrange.c new file +31 -0
new file mode 100644
index 0000000..6ad782f
@@ -0,0 +1,294 @@
+/*
+ * Copyright(c) 2017 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+#include <linux/libnvdimm.h>
+#include <linux/badblocks.h>
+#include <linux/export.h>
+#include <linux/module.h>
+#include <linux/blkdev.h>
+#include <linux/device.h>
+#include <linux/ctype.h>
+#include <linux/ndctl.h>
+#include <linux/mutex.h>
+#include <linux/slab.h>
+#include <linux/io.h>
+#include "nd-core.h"
+#include "nd.h"
+
+void badrange_init(struct badrange *badrange)
+{
+       INIT_LIST_HEAD(&badrange->list);
+       spin_lock_init(&badrange->lock);
+}

drivers/nvdimm/badrange.c line 41

Quoted 10 lines
drivers/nvdimm/badrange.c new file +10 -0
+EXPORT_SYMBOL_GPL(badrange_init);
+
+static void append_badrange_entry(struct badrange *badrange,
+               struct badrange_entry *be, u64 addr, u64 length)
+{
+       lockdep_assert_held(&badrange->lock);
+       be->start = addr;
+       be->length = length;
+       list_add_tail(&be->list, &badrange->list);
+}

Small nit, can we rename the instance variable from 'be' to 'bre'? 'be' triggers all my 'big endian' neurons to fire. Other than that, looks good.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author maintainer
#3 lore raw

Re: [PATCH 1/4] libnvdimm: move poison list functions to a new 'badrange' file

Quoted 120 lines · Dan Williams

On Thu, Oct 5, 2017 at 6:53 PM, Vishal Verma <[email protected]

Quoted 119 lines

wrote:
From: Dave Jiang <[email protected]>

From: Dave Jiang <[email protected]>

nfit_test needs to use the poison list manipulation code as well. Make
it more generic and in the process rename poison to badrange, and move
all the related helpers to a new file.

[vishal: add a missed include in bus.c for the new badrange functions]

---
 drivers/acpi/nfit/core.c  |   2 +- drivers/acpi/nfit/mce.c   |   2 +- drivers/nvdimm/Makefile   |   1 + drivers/nvdimm/badrange.c | 294
++++++++++++++++++++++++++++++++++++++++++++++
 drivers/nvdimm/bus.c      |  24 ++-- drivers/nvdimm/core.c     | 260 +--------------------------------
-------
 drivers/nvdimm/nd-core.h  |   3 +-
 drivers/nvdimm/nd.h       |   6 - include/linux/libnvdimm.h |  21 +++-

 9 files changed, 331 insertions(+), 282 deletions(-)

 create mode 100644 drivers/nvdimm/badrange.c

drivers/acpi/nfit/core.c +0 -0
index a3ecd5e..4b157f8 100644
@@ -2240,7 +2240,7 @@ static int ars_status_process_records(struct
 acpi_nfit_desc *acpi_desc,

                if (ars_status->out_length
                                < 44 + sizeof(struct nd_ars_record)
* (i + 1))
                        break;
-               rc = nvdimm_bus_add_poison(nvdimm_bus,
+               rc = nvdimm_bus_add_badrange(nvdimm_bus, ars_status->records[i].err_address, ars_status->records[i].length); if (rc)

drivers/acpi/nfit/mce.c +0 -0
index feeb95d..b929214 100644
@@ -67,7 +67,7 @@ static int nfit_handle_mce(struct notifier_block
 *nb, unsigned long val,
                         continue;
 
                 /* If this fails due to an -ENOMEM, there is little

we can do */
-               nvdimm_bus_add_poison(acpi_desc->nvdimm_bus, +               nvdimm_bus_add_badrange(acpi_desc->nvdimm_bus, ALIGN(mce->addr, L1_CACHE_BYTES), L1_CACHE_BYTES); nvdimm_region_notify(nfit_spa->nd_region,

drivers/nvdimm/Makefile +0 -0
index 909554c..ca6d325 100644
@@ -20,6 +20,7 @@ libnvdimm-y += region_devs.o

 libnvdimm-y += region.o
 libnvdimm-y += namespace_devs.o
 libnvdimm-y += label.o
+libnvdimm-y += badrange.o
 libnvdimm-$(CONFIG_ND_CLAIM) += claim.o
 libnvdimm-$(CONFIG_BTT) += btt_devs.o
 libnvdimm-$(CONFIG_NVDIMM_PFN) += pfn_devs.o

drivers/nvdimm/badrange.c new file +4 -0
new file mode 100644
index 0000000..6ad782f
@@ -0,0 +1,294 @@
+/*
+ * Copyright(c) 2017 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or

modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */

drivers/nvdimm/badrange.c new file +25 -0
+#include <linux/libnvdimm.h>
+#include <linux/badblocks.h>
+#include <linux/export.h>
+#include <linux/module.h>
+#include <linux/blkdev.h>
+#include <linux/device.h>
+#include <linux/ctype.h>
+#include <linux/ndctl.h>
+#include <linux/mutex.h>
+#include <linux/slab.h>
+#include <linux/io.h>
+#include "nd-core.h"
+#include "nd.h"
+
+void badrange_init(struct badrange *badrange)
+{
+       INIT_LIST_HEAD(&badrange->list);
+       spin_lock_init(&badrange->lock);
+}
+EXPORT_SYMBOL_GPL(badrange_init);
+
+static void append_badrange_entry(struct badrange *badrange,
+               struct badrange_entry *be, u64 addr, u64 length)
+{
+       lockdep_assert_held(&badrange->lock);
Quoted 8 lines
Quoted 4 lines

+       be->start = addr;
+       be->length = length;
+       list_add_tail(&be->list, &badrange->list); +}

Small nit, can we rename the instance variable from 'be' to 'bre'? 'be' triggers all my 'big endian' neurons to fire. Other than that, looks good.

Yep done.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author maintainer
#4 lore raw

PATCH 2/4 nfit_test: add error injection DSMs

In reply to Vishal Verma

From: Dave Jiang <[email protected]>

From: Dave Jiang <[email protected]>

Add nfit_test emulation for the new ACPI 6.2 error injectino DSMs. This will allow unit tests to selectively inject the errors they wish to test for.

[vishal: Add badrange.o to nfit_test's Kbuild]
[vishal: Move injection functions to ND_CMD_CALL]
[vishal: Add support for the notification option]
---
 drivers/acpi/nfit/nfit.h              |   1 +
 tools/testing/nvdimm/Kbuild           |   1 +
 tools/testing/nvdimm/test/nfit.c      | 187 +++++++++++++++++++++++++++++-----
 tools/testing/nvdimm/test/nfit_test.h |   4 +
 4 files changed, 169 insertions(+), 24 deletions(-)
drivers/acpi/nfit/nfit.h +1 -0
index 7093bd5..7ddf48f 100644
@@ -75,6 +75,7 @@ enum {
 	NFIT_ARS_CAP_NONE = 1,
 	NFIT_ARS_F_OVERFLOW = 1,
 	NFIT_ARS_TIMEOUT = 90,
+	NFIT_ARS_INJECT_INVALID = 2,
 };
 
 enum nfit_root_notifiers {
tools/testing/nvdimm/Kbuild +1 -0
index d870520..3272ab5 100644
@@ -69,6 +69,7 @@ libnvdimm-y += $(NVDIMM_SRC)/region_devs.o
 libnvdimm-y += $(NVDIMM_SRC)/region.o
 libnvdimm-y += $(NVDIMM_SRC)/namespace_devs.o
 libnvdimm-y += $(NVDIMM_SRC)/label.o
+libnvdimm-y += $(NVDIMM_SRC)/badrange.o
 libnvdimm-$(CONFIG_ND_CLAIM) += $(NVDIMM_SRC)/claim.o
 libnvdimm-$(CONFIG_BTT) += $(NVDIMM_SRC)/btt_devs.o
 libnvdimm-$(CONFIG_NVDIMM_PFN) += $(NVDIMM_SRC)/pfn_devs.o
tools/testing/nvdimm/test/nfit.c +163 -24

313 lines not on this page · raw message

tools/testing/nvdimm/test/nfit_test.h +4 -0
index 735a452..b44f927 100644
@@ -34,6 +34,10 @@ struct nfit_test_resource {
 
 #define ND_TRANSLATE_SPA_STATUS_INVALID_SPA  2
 
+enum err_inj_options {
+	ND_ARS_ERR_INJ_OPT_NOTIFY = 0,
+};
+
 /* bus passthru commands */
 enum nfit_test_passthru_cmd {
 	NFIT_CMD_TRANSLATE_SPA = 5,
Signature · 6 lines
2.9.5

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#5 lore raw

Re: [PATCH 2/4] nfit_test: add error injection DSMs

Quoted 25 lines · Vishal Verma

From: Dave Jiang <[email protected]>

From: Dave Jiang <[email protected]>

Add nfit_test emulation for the new ACPI 6.2 error injectino DSMs. This will allow unit tests to selectively inject the errors they wish to test for.

[vishal: Add badrange.o to nfit_test's Kbuild]
[vishal: Move injection functions to ND_CMD_CALL]
[vishal: Add support for the notification option]
---
 drivers/acpi/nfit/nfit.h              |   1 +
 tools/testing/nvdimm/Kbuild           |   1 +
 tools/testing/nvdimm/test/nfit.c      | 187 +++++++++++++++++++++++++++++-----
 tools/testing/nvdimm/test/nfit_test.h |   4 +
 4 files changed, 169 insertions(+), 24 deletions(-)
drivers/acpi/nfit/nfit.h +0 -0
index 7093bd5..7ddf48f 100644

drivers/acpi/nfit/nfit.h enum { · line 78

Quoted 4 lines
drivers/acpi/nfit/nfit.h +1 -0
@@ -75,6 +75,7 @@ enum {
        NFIT_ARS_CAP_NONE = 1,
        NFIT_ARS_F_OVERFLOW = 1,
        NFIT_ARS_TIMEOUT = 90,
+       NFIT_ARS_INJECT_INVALID = 2,

If there is no usage of this define outside of nfit_test then it should be defined in tools/testing/nvdimm/test/nfit.h.

tools/testing/nvdimm/Kbuild libnvdimm-y += $(NVDIMM_SRC)/region_devs.o · line 72

Quoted 12 lines
drivers/acpi/nfit/nfit.h +0 -0
 };
 
 enum nfit_root_notifiers {
tools/testing/nvdimm/Kbuild +1 -0
index d870520..3272ab5 100644
@@ -69,6 +69,7 @@ libnvdimm-y += $(NVDIMM_SRC)/region_devs.o
 libnvdimm-y += $(NVDIMM_SRC)/region.o
 libnvdimm-y += $(NVDIMM_SRC)/namespace_devs.o
 libnvdimm-y += $(NVDIMM_SRC)/label.o
+libnvdimm-y += $(NVDIMM_SRC)/badrange.o

This hunk should go in the same patch that changes drivers/nvdimm/Makefile to add badrange.o so we don't have an nfit_test compile breakage gap between commits.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author maintainer
#6 lore raw

Re: [PATCH 2/4] nfit_test: add error injection DSMs

Quoted 2 lines · Dan Williams

On Thu, Oct 5, 2017 at 6:53 PM, Vishal Verma <[email protected]

Quoted 1 line

wrote:

[]

Quoted 5 lines
Quoted 2 lines

        NFIT_ARS_TIMEOUT = 90,
+       NFIT_ARS_INJECT_INVALID = 2,

If there is no usage of this define outside of nfit_test then it should be defined in tools/testing/nvdimm/test/nfit.h.

Yes moved.

Quoted 18 lines
Quoted 10 lines

 };

 enum nfit_root_notifiers {

tools/testing/nvdimm/Kbuild +0 -0
index d870520..3272ab5 100644
@@ -69,6 +69,7 @@ libnvdimm-y += $(NVDIMM_SRC)/region_devs.o
Quoted 4 lines

 libnvdimm-y += $(NVDIMM_SRC)/region.o
 libnvdimm-y += $(NVDIMM_SRC)/namespace_devs.o
 libnvdimm-y += $(NVDIMM_SRC)/label.o
+libnvdimm-y += $(NVDIMM_SRC)/badrange.o

This hunk should go in the same patch that changes drivers/nvdimm/Makefile to add badrange.o so we don't have an nfit_test compile breakage gap between commits.

The kernel's normal usage already has the kbuild change in the right place (patch 1). This adds the use of badrange functions to nfit_test for the first time, and hence the kbuild addition here.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#7 lore raw

Re: [PATCH 2/4] nfit_test: add error injection DSMs

Quoted 33 lines · Vishal L
Quoted 2 lines · Dan Williams

On Thu, Oct 5, 2017 at 6:53 PM, Vishal Verma <[email protected]

Quoted 1 line

wrote:

[]

Quoted 5 lines
Quoted 2 lines
        NFIT_ARS_TIMEOUT = 90,

+ NFIT_ARS_INJECT_INVALID = 2,

If there is no usage of this define outside of nfit_test then it should be defined in tools/testing/nvdimm/test/nfit.h.

Yes moved.

Quoted 18 lines
Quoted 10 lines

};

enum nfit_root_notifiers {

tools/testing/nvdimm/Kbuild +0 -0
index d870520..3272ab5 100644

tools/testing/nvdimm/Kbuild libnvdimm-y += $(NVDIMM_SRC)/region_devs.o · line 72

Quoted 4 lines
tools/testing/nvdimm/Kbuild +1 -0
@@ -69,6 +69,7 @@ libnvdimm-y += $(NVDIMM_SRC)/region_devs.o
 libnvdimm-y += $(NVDIMM_SRC)/region.o
 libnvdimm-y += $(NVDIMM_SRC)/namespace_devs.o
 libnvdimm-y += $(NVDIMM_SRC)/label.o
+libnvdimm-y += $(NVDIMM_SRC)/badrange.o

This hunk should go in the same patch that changes drivers/nvdimm/Makefile to add badrange.o so we don't have an nfit_test compile breakage gap between commits.

Quoted 3 lines

The kernel's normal usage already has the kbuild change in the right place (patch 1). This adds the use of badrange functions to nfit_test for the first time, and hence the kbuild addition here.

It's not the nfit_test usages I'm worried about. The internal calls in libnvdimm will break. Try building tools/testing/nvdimm/libnvdimm.ko with only patch1 applied.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author maintainer
#8 lore raw

Re: [PATCH 2/4] nfit_test: add error injection DSMs

Quoted 36 lines · Dan Williams
Quoted 34 lines · Vishal L
Quoted 3 lines · Dan Williams

On Thu, Oct 5, 2017 at 6:53 PM, Vishal Verma <vishal.l.verma@intel .com

Quoted 1 line

wrote:

[]

Quoted 5 lines
Quoted 2 lines

        NFIT_ARS_TIMEOUT = 90,
+       NFIT_ARS_INJECT_INVALID = 2,

If there is no usage of this define outside of nfit_test then it should be defined in tools/testing/nvdimm/test/nfit.h.

Yes moved.

Quoted 18 lines
Quoted 10 lines

 };

 enum nfit_root_notifiers {

tools/testing/nvdimm/Kbuild +0 -0
index d870520..3272ab5 100644
@@ -69,6 +69,7 @@ libnvdimm-y += $(NVDIMM_SRC)/region_devs.o
Quoted 4 lines

 libnvdimm-y += $(NVDIMM_SRC)/region.o
 libnvdimm-y += $(NVDIMM_SRC)/namespace_devs.o
 libnvdimm-y += $(NVDIMM_SRC)/label.o
+libnvdimm-y += $(NVDIMM_SRC)/badrange.o

This hunk should go in the same patch that changes drivers/nvdimm/Makefile to add badrange.o so we don't have an nfit_test compile breakage gap between commits.

Quoted 8 lines
Quoted 4 lines

The kernel's normal usage already has the kbuild change in the right place (patch 1). This adds the use of badrange functions to nfit_test
for the first time, and hence the kbuild addition here.

It's not the nfit_test usages I'm worried about. The internal calls in libnvdimm will break. Try building tools/testing/nvdimm/libnvdimm.ko with only patch1 applied.

Ah I see what the problem is, I'll send a v3
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author maintainer
#9 lore raw

PATCH 3/4 libnvdimm, badrange: remove a WARN for list_empty

In reply to Vishal Verma

Now that we're reusing the badrange functions for nfit_test, and that exposes badrange injection/clearing to userspace via the DSM paths, it is plausible that a user may call the clear DSM multiple times. Since it is harmless to do so, we can remove the WARN in badrange_forget.

Cc Dave Jiang <[email protected]>
Cc Dan Williams <[email protected]>
---
 drivers/nvdimm/badrange.c | 1 -
 1 file changed, 1 deletion(-)
drivers/nvdimm/badrange.c +0 -1
index 6ad782f..bfdec70 100644
@@ -114,7 +114,6 @@ void badrange_forget(struct badrange *badrange, phys_addr_t start,
 	struct badrange_entry *be, *next;
 
 	spin_lock(&badrange->lock);
-	WARN_ON_ONCE(list_empty(badrange_list));
 
 	/*
 	 * [start, clr_end] is the badrange interval being cleared.
Signature · 6 lines
2.9.5

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
author maintainer
#10 lore raw

PATCH 4/4 nfit_test: when clearing poison, also remove badrange entries

In reply to Vishal Verma

The injected badrange entries can only be cleared from the kernel's accounting by writing to the affected blocks, so when such a write sends the clear error DSM to nfit_test, also clear the ranges from nfit_test's badrange list. This lets an 'ARS Inject error status' DSM to return the correct status, omitting the cleared ranges.

Cc Dave Jiang <[email protected]>
Cc Dan Williams <[email protected]>
---
 tools/testing/nvdimm/test/nfit.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
tools/testing/nvdimm/test/nfit.c +4 -8
index 43f948e..e400418 100644
@@ -344,7 +344,8 @@ static int nfit_test_cmd_ars_status(struct ars_state *ars_state,
 	return 0;
 }
 
-static int nfit_test_cmd_clear_error(struct nd_cmd_clear_error *clear_err,
+static int nfit_test_cmd_clear_error(struct nfit_test *t,
+		struct nd_cmd_clear_error *clear_err,
 		unsigned int buf_len, int *cmd_rc)
 {
 	const u64 mask = NFIT_TEST_CLEAR_ERR_UNIT - 1;
@@ -354,12 +355,7 @@ static int nfit_test_cmd_clear_error(struct nd_cmd_clear_error *clear_err,
 	if ((clear_err->address & mask) || (clear_err->length & mask))
 		return -EINVAL;
 
-	/*
-	 * Report 'all clear' success for all commands even though a new
-	 * scrub will find errors again.  This is enough to have the
-	 * error removed from the 'badblocks' tracking in the pmem
-	 * driver.
-	 */
+	badrange_forget(&t->badrange, clear_err->address, clear_err->length);
 	clear_err->status = 0;
 	clear_err->cleared = clear_err->length;
 	*cmd_rc = 0;
@@ -687,7 +683,7 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
 					cmd_rc);
 			break;
 		case ND_CMD_CLEAR_ERROR:
-			rc = nfit_test_cmd_clear_error(buf, buf_len, cmd_rc);
+			rc = nfit_test_cmd_clear_error(t, buf, buf_len, cmd_rc);
 			break;
 		default:
 			return -ENOTTY;
Signature · 6 lines
2.9.5

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
maintainer Reviewed-by on v1 4/4
#11 lore raw

Re: [PATCH 4/4] nfit_test: when clearing poison, also remove badrange entries

Quoted 9 lines · Vishal Verma

The injected badrange entries can only be cleared from the kernel's accounting by writing to the affected blocks, so when such a write sends the clear error DSM to nfit_test, also clear the ranges from nfit_test's badrange list. This lets an 'ARS Inject error status' DSM to return the correct status, omitting the cleared ranges.

Cc Dave Jiang <[email protected]>
Cc Dan Williams <[email protected]>
Quoted 34 lines
---
 tools/testing/nvdimm/test/nfit.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
tools/testing/nvdimm/test/nfit.c +3 -7
index 43f948e..e400418 100644
@@ -344,7 +344,8 @@ static int nfit_test_cmd_ars_status(struct ars_state *ars_state,
 	return 0;
 }
 
-static int nfit_test_cmd_clear_error(struct nd_cmd_clear_error *clear_err,
+static int nfit_test_cmd_clear_error(struct nfit_test *t,
+		struct nd_cmd_clear_error *clear_err,
 		unsigned int buf_len, int *cmd_rc)
 {
 	const u64 mask = NFIT_TEST_CLEAR_ERR_UNIT - 1;
@@ -354,12 +355,7 @@ static int nfit_test_cmd_clear_error(struct nd_cmd_clear_error *clear_err,
 	if ((clear_err->address & mask) || (clear_err->length & mask))
 		return -EINVAL;
 
-	/*
-	 * Report 'all clear' success for all commands even though a new
-	 * scrub will find errors again.  This is enough to have the
-	 * error removed from the 'badblocks' tracking in the pmem
-	 * driver.
-	 */
+	badrange_forget(&t->badrange, clear_err->address, clear_err->length);
 	clear_err->status = 0;
 	clear_err->cleared = clear_err->length;
 	*cmd_rc = 0;

tools/testing/nvdimm/test/nfit.c static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc, · line 689

Quoted 8 lines
tools/testing/nvdimm/test/nfit.c +1 -1
@@ -687,7 +683,7 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
 					cmd_rc);
 			break;
 		case ND_CMD_CLEAR_ERROR:
-			rc = nfit_test_cmd_clear_error(buf, buf_len, cmd_rc);
+			rc = nfit_test_cmd_clear_error(t, buf, buf_len, cmd_rc);
 			break;
 		default:
 			return -ENOTTY;

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm