linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem
@ 2020-01-29  5:46 frowand.list
  2020-01-29  5:46 ` [PATCH 1/2] " frowand.list
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: frowand.list @ 2020-01-29  5:46 UTC (permalink / raw)
  To: Rob Herring, Geert Uytterhoeven, pantelis.antoniou
  Cc: devicetree, linux-kernel, Alan Tull

From: Frank Rowand <frank.rowand@sony.com>

Geert reports that gpio hog nodes are not properly processed when
the gpio hog node is added via an overlay reply and provides an
RFC patch to fix the problem [1].

Add a unittest that shows the problem.  Unittest will report "1 failed"
test before applying Geert's RFC patch and "0 failed" after applying
Geert's RFC patch.

I did not have a development system for which it would be easy to
experiment with applying an overlay containing a gpio hog, so I
instead created this unittest that uses a fake gpio node.

Some tests in the devicetree unittests result in printk messages
from the code being tested.  It can be difficult to determine
whether the messages are the result of unittest or are potentially
reporting bugs that should be fixed.  The most recent example of
a person asking whether to be concerned about these messages is [2].

Patch 2 adds annotations for all messages triggered by unittests,
except KERN_DEBUG messages.  (KERN_DEBUG is a special case due to the
possible interaction of CONFIG_DYNAMIC_DEBUG.)

The annotations added in patch 2/2 add a small amount of verbosity
to the console output.  I have created a proof of concept tool to
explore (1) how test harnesses could use the annotations and
(2) how to make the resulting console output easier to read and
understand as a human being.  The tool 'of_unittest_expect' is
available at https://github.com/frowand/dt_tools

The format of the annotations is expected to change when unittests
are converted to use the kunit infrastructure when the broader
testing community has an opportunity to discuss the implementation
of annotations of test triggered messages.

[1] https://lore.kernel.org/linux-devicetree/20191230133852.5890-1-geert+renesas@glider.be/
[2] https://lore.kernel.org/r/6021ac63-b5e0-ed3d-f964-7c6ef579cd68@huawei.com

Frank Rowand (2):
  of: unittest: add overlay gpio test to catch gpio hog problem
  of: unittest: annotate warnings triggered by unittest

 drivers/of/unittest-data/Makefile             |   8 +-
 drivers/of/unittest-data/overlay_gpio_01.dts  |  23 +
 drivers/of/unittest-data/overlay_gpio_02a.dts |  16 +
 drivers/of/unittest-data/overlay_gpio_02b.dts |  16 +
 drivers/of/unittest-data/overlay_gpio_03.dts  |  23 +
 drivers/of/unittest-data/overlay_gpio_04a.dts |  16 +
 drivers/of/unittest-data/overlay_gpio_04b.dts |  16 +
 drivers/of/unittest.c                         | 630 ++++++++++++++++++++++++--
 8 files changed, 717 insertions(+), 31 deletions(-)
 create mode 100644 drivers/of/unittest-data/overlay_gpio_01.dts
 create mode 100644 drivers/of/unittest-data/overlay_gpio_02a.dts
 create mode 100644 drivers/of/unittest-data/overlay_gpio_02b.dts
 create mode 100644 drivers/of/unittest-data/overlay_gpio_03.dts
 create mode 100644 drivers/of/unittest-data/overlay_gpio_04a.dts
 create mode 100644 drivers/of/unittest-data/overlay_gpio_04b.dts

-- 
Frank Rowand <frank.rowand@sony.com>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/2] of: unittest: add overlay gpio test to catch gpio hog problem
  2020-01-29  5:46 [PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem frowand.list
@ 2020-01-29  5:46 ` frowand.list
  2020-02-19 21:56   ` Rob Herring
  2020-01-29  5:46 ` [PATCH 2/2] of: unittest: annotate warnings triggered by unittest frowand.list
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: frowand.list @ 2020-01-29  5:46 UTC (permalink / raw)
  To: Rob Herring, Geert Uytterhoeven, pantelis.antoniou
  Cc: devicetree, linux-kernel, Alan Tull

From: Frank Rowand <frank.rowand@sony.com>

Geert reports that gpio hog nodes are not properly processed when
the gpio hog node is added via an overlay reply and provides an
RFC patch to fix the problem [1].

Add a unittest that shows the problem.  Unittest will report "1 failed"
test before applying Geert's RFC patch and "0 failed" after applying
Geert's RFC patch.

[1] https://lore.kernel.org/linux-devicetree/20191230133852.5890-1-geert+renesas@glider.be/

Signed-off-by: Frank Rowand <frank.rowand@sony.com>
---

There are checkpatch warnings.
  - New files are in a directory already covered by MAINTAINERS
  - The undocumented compatibles are restricted to use by unittest
    and should not be documented under Documentation
  - The printk() KERN_<LEVEL> warnings are false positives.  The level
    is supplied by a define parameter instead of a hard coded constant
  - The lines over 80 characters are consistent with unittest.c style

This unittest was also valuable in that it allowed me to explore
possible issues related to the proposed solution to the gpio hog
problem.

changes since RFC:
  - fixed node names in overlays
  - removed unused fields from struct unittest_gpio_dev
  - of_unittest_overlay_gpio() cleaned up comments
  - of_unittest_overlay_gpio() moved saving global values into
    probe_pass_count and chip_request_count more tightly around
    test code expected to trigger changes in the global values

 drivers/of/unittest-data/Makefile             |   8 +-
 drivers/of/unittest-data/overlay_gpio_01.dts  |  23 +++
 drivers/of/unittest-data/overlay_gpio_02a.dts |  16 ++
 drivers/of/unittest-data/overlay_gpio_02b.dts |  16 ++
 drivers/of/unittest-data/overlay_gpio_03.dts  |  23 +++
 drivers/of/unittest-data/overlay_gpio_04a.dts |  16 ++
 drivers/of/unittest-data/overlay_gpio_04b.dts |  16 ++
 drivers/of/unittest.c                         | 255 ++++++++++++++++++++++++++
 8 files changed, 372 insertions(+), 1 deletion(-)
 create mode 100644 drivers/of/unittest-data/overlay_gpio_01.dts
 create mode 100644 drivers/of/unittest-data/overlay_gpio_02a.dts
 create mode 100644 drivers/of/unittest-data/overlay_gpio_02b.dts
 create mode 100644 drivers/of/unittest-data/overlay_gpio_03.dts
 create mode 100644 drivers/of/unittest-data/overlay_gpio_04a.dts
 create mode 100644 drivers/of/unittest-data/overlay_gpio_04b.dts

diff --git a/drivers/of/unittest-data/Makefile b/drivers/of/unittest-data/Makefile
index 9b6807065827..009f4045c8e4 100644
--- a/drivers/of/unittest-data/Makefile
+++ b/drivers/of/unittest-data/Makefile
@@ -21,7 +21,13 @@ obj-$(CONFIG_OF_OVERLAY) += overlay.dtb.o \
 			    overlay_bad_add_dup_prop.dtb.o \
 			    overlay_bad_phandle.dtb.o \
 			    overlay_bad_symbol.dtb.o \
-			    overlay_base.dtb.o
+			    overlay_base.dtb.o \
+			    overlay_gpio_01.dtb.o \
+			    overlay_gpio_02a.dtb.o \
+			    overlay_gpio_02b.dtb.o \
+			    overlay_gpio_03.dtb.o \
+			    overlay_gpio_04a.dtb.o \
+			    overlay_gpio_04b.dtb.o
 
 # enable creation of __symbols__ node
 DTC_FLAGS_overlay += -@
diff --git a/drivers/of/unittest-data/overlay_gpio_01.dts b/drivers/of/unittest-data/overlay_gpio_01.dts
new file mode 100644
index 000000000000..f039e8bce3b6
--- /dev/null
+++ b/drivers/of/unittest-data/overlay_gpio_01.dts
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+/plugin/;
+
+&unittest_test_bus {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	gpio_01 {
+		compatible = "unittest-gpio";
+		reg = <0>;
+		gpio-controller;
+		#gpio-cells = <2>;
+		ngpios = <2>;
+		gpio-line-names = "line-A", "line-B";
+
+		line_b {
+			gpio-hog;
+			gpios = <2 0>;
+			input;
+			line-name = "line-B-input";
+		};
+	};
+};
diff --git a/drivers/of/unittest-data/overlay_gpio_02a.dts b/drivers/of/unittest-data/overlay_gpio_02a.dts
new file mode 100644
index 000000000000..cdafab604793
--- /dev/null
+++ b/drivers/of/unittest-data/overlay_gpio_02a.dts
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+/plugin/;
+
+&unittest_test_bus {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	gpio_02 {
+		compatible = "unittest-gpio";
+		reg = <1>;
+		gpio-controller;
+		#gpio-cells = <2>;
+		ngpios = <2>;
+		gpio-line-names = "line-A", "line-B";
+	};
+};
diff --git a/drivers/of/unittest-data/overlay_gpio_02b.dts b/drivers/of/unittest-data/overlay_gpio_02b.dts
new file mode 100644
index 000000000000..0cea0dccafba
--- /dev/null
+++ b/drivers/of/unittest-data/overlay_gpio_02b.dts
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+/plugin/;
+
+&unittest_test_bus {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	gpio_02 {
+		line_a {
+			gpio-hog;
+			gpios = <1 0>;
+			input;
+			line-name = "line-A-input";
+		};
+	};
+};
diff --git a/drivers/of/unittest-data/overlay_gpio_03.dts b/drivers/of/unittest-data/overlay_gpio_03.dts
new file mode 100644
index 000000000000..1d5c680fa254
--- /dev/null
+++ b/drivers/of/unittest-data/overlay_gpio_03.dts
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+/plugin/;
+
+&unittest_test_bus {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	gpio_03 {
+		compatible = "unittest-gpio";
+		reg = <0>;
+		gpio-controller;
+		#gpio-cells = <2>;
+		ngpios = <2>;
+		gpio-line-names = "line-A", "line-B", "line-C", "line-D";
+
+		line_d {
+			gpio-hog;
+			gpios = <4 0>;
+			input;
+			line-name = "line-D-input";
+		};
+	};
+};
diff --git a/drivers/of/unittest-data/overlay_gpio_04a.dts b/drivers/of/unittest-data/overlay_gpio_04a.dts
new file mode 100644
index 000000000000..d2482cde310e
--- /dev/null
+++ b/drivers/of/unittest-data/overlay_gpio_04a.dts
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+/plugin/;
+
+&unittest_test_bus {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	gpio_04 {
+		compatible = "unittest-gpio";
+		reg = <1>;
+		gpio-controller;
+		#gpio-cells = <2>;
+		ngpios = <2>;
+		gpio-line-names = "line-A", "line-B", "line-C", "line-D";
+	};
+};
diff --git a/drivers/of/unittest-data/overlay_gpio_04b.dts b/drivers/of/unittest-data/overlay_gpio_04b.dts
new file mode 100644
index 000000000000..70ad05d759f9
--- /dev/null
+++ b/drivers/of/unittest-data/overlay_gpio_04b.dts
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+/plugin/;
+
+&unittest_test_bus {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	gpio_04 {
+		line_c {
+			gpio-hog;
+			gpios = <3 0>;
+			input;
+			line-name = "line-C-input";
+		};
+	};
+};
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 68b87587b2ef..b1cf9972d866 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -24,6 +24,7 @@
 
 #include <linux/i2c.h>
 #include <linux/i2c-mux.h>
+#include <linux/gpio/driver.h>
 
 #include <linux/bitops.h>
 
@@ -46,6 +47,101 @@
 	failed; \
 })
 
+/*
+ * Expected message may have a message level other than KERN_INFO.
+ * Print the expected message only if the current loglevel will allow
+ * the actual message to print.
+ */
+#define EXPECT_BEGIN(level, fmt, ...) \
+	printk(level pr_fmt("EXPECT \\ : ") fmt, ##__VA_ARGS__)
+
+#define EXPECT_END(level, fmt, ...) \
+	printk(level pr_fmt("EXPECT / : ") fmt, ##__VA_ARGS__)
+
+struct unittest_gpio_dev {
+	void __iomem *base;
+	struct gpio_chip chip;
+	spinlock_t gpio_lock;
+};
+
+static int unittest_gpio_chip_request_count;
+static int unittest_gpio_probe_count;
+static int unittest_gpio_probe_pass_count;
+
+static int unittest_gpio_chip_request(struct gpio_chip *chip, unsigned int offset)
+{
+	unittest_gpio_chip_request_count++;
+
+	pr_debug("%s(): %s %d %d\n", __func__, chip->label, offset,
+		 unittest_gpio_chip_request_count);
+	return 0;
+}
+
+static int unittest_gpio_probe(struct platform_device *pdev)
+{
+	struct unittest_gpio_dev *devptr;
+	int ret;
+
+	unittest_gpio_probe_count++;
+
+	devptr = kzalloc(sizeof(*devptr), GFP_KERNEL);
+	if (!devptr)
+		return -ENOMEM;
+
+	spin_lock_init(&devptr->gpio_lock);
+
+	platform_set_drvdata(pdev, devptr);
+
+	devptr->chip.of_node = pdev->dev.of_node;
+	devptr->chip.label = "of-unittest-gpio";
+	devptr->chip.base = -1; /* dynamic allocation */
+	devptr->chip.ngpio = 5;
+	devptr->chip.request = unittest_gpio_chip_request;
+
+	ret = gpiochip_add_data(&devptr->chip, NULL);
+
+	unittest(!ret,
+		 "gpiochip_add_data() for node @%pOF failed, ret = %d\n", devptr->chip.of_node, ret);
+
+	if (!ret)
+		unittest_gpio_probe_pass_count++;
+	return ret;
+}
+
+static int unittest_gpio_remove(struct platform_device *pdev)
+{
+	struct unittest_gpio_dev *gdev = platform_get_drvdata(pdev);
+	struct device *dev = &pdev->dev;
+	struct device_node *np = pdev->dev.of_node;
+
+	dev_dbg(dev, "%s for node @%pOF\n", __func__, np);
+
+	if (!gdev)
+		return -EINVAL;
+
+	if (gdev->chip.base != -1)
+		gpiochip_remove(&gdev->chip);
+
+	platform_set_drvdata(pdev, NULL);
+	kfree(pdev);
+
+	return 0;
+}
+
+static const struct of_device_id unittest_gpio_id[] = {
+	{ .compatible = "unittest-gpio", },
+	{}
+};
+
+static struct platform_driver unittest_gpio_driver = {
+	.probe	= unittest_gpio_probe,
+	.remove	= unittest_gpio_remove,
+	.driver	= {
+		.name		= "unittest-gpio",
+		.of_match_table	= of_match_ptr(unittest_gpio_id),
+	},
+};
+
 static void __init of_unittest_find_node_by_name(void)
 {
 	struct device_node *np;
@@ -2183,6 +2279,151 @@ static inline void of_unittest_overlay_i2c_15(void) { }
 
 #endif
 
+static void __init of_unittest_overlay_gpio(void)
+{
+	int chip_request_count;
+	int probe_pass_count;
+	int ret;
+
+	/*
+	 * tests: apply overlays before registering driver
+	 * Similar to installing a driver as a module, the
+	 * driver is registered after applying the overlays.
+	 *
+	 * - apply overlay_gpio_01
+	 * - apply overlay_gpio_02a
+	 * - apply overlay_gpio_02b
+	 * - register driver
+	 *
+	 * register driver will result in
+	 *   - probe and processing gpio hog for overlay_gpio_01
+	 *   - probe for overlay_gpio_02a
+	 *   - processing gpio for overlay_gpio_02b
+	 *
+	 * overlay_gpio_01 contains gpio node and child gpio hog node
+	 * overlay_gpio_02a contains gpio node
+	 * overlay_gpio_02b contains child gpio hog node
+	 *
+	 * "GPIO line <<int>> (line-*-input) hogged as input"
+	 * messages are the result of the gpio driver probe
+	 * finding the gpio hog node.
+	 */
+
+	unittest(overlay_data_apply("overlay_gpio_01", NULL),
+		 "Adding overlay 'overlay_gpio_01' failed\n");
+
+	unittest(overlay_data_apply("overlay_gpio_02a", NULL),
+		 "Adding overlay 'overlay_gpio_02a' failed\n");
+
+	unittest(overlay_data_apply("overlay_gpio_02b", NULL),
+		 "Adding overlay 'overlay_gpio_02b' failed\n");
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "GPIO line <<int>> (line-B-input) hogged as input\n");
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "GPIO line <<int>> (line-A-input) hogged as input\n");
+
+	probe_pass_count = unittest_gpio_probe_pass_count;
+	chip_request_count = unittest_gpio_chip_request_count;
+
+	ret = platform_driver_register(&unittest_gpio_driver);
+	if (unittest(ret == 0, "could not register unittest gpio driver\n"))
+		return;
+
+	EXPECT_END(KERN_INFO,
+		   "GPIO line <<int>> (line-A-input) hogged as input\n");
+	EXPECT_END(KERN_INFO,
+		   "GPIO line <<int>> (line-B-input) hogged as input\n");
+
+	unittest(probe_pass_count + 2 == unittest_gpio_probe_pass_count,
+		 "unittest_gpio_probe() failed or not called\n");
+
+	unittest(chip_request_count + 2 == unittest_gpio_chip_request_count,
+		 "unittest_gpio_chip_request() called %d times (expected 1 time)\n",
+		 unittest_gpio_chip_request_count - chip_request_count);
+
+	/*
+	 * tests: apply overlays after registering driver
+	 *
+	 * Similar to a driver built-in to the kernel, the
+	 * driver is registered before applying the overlays.
+	 *
+	 * - apply overlay_gpio_03
+	 *
+	 * apply overlay will result in
+	 *   - probe and processing gpio hog.
+	 *
+	 * overlay_gpio_03 contains gpio node and child gpio hog node
+	 */
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "GPIO line <<int>> (line-D-input) hogged as input\n");
+
+	probe_pass_count = unittest_gpio_probe_pass_count;
+	chip_request_count = unittest_gpio_chip_request_count;
+
+	unittest(overlay_data_apply("overlay_gpio_03", NULL),
+		 "Adding overlay 'overlay_gpio_03' failed\n");
+
+	EXPECT_END(KERN_INFO,
+		   "GPIO line <<int>> (line-D-input) hogged as input\n");
+
+	unittest(probe_pass_count + 1 == unittest_gpio_probe_pass_count,
+		 "unittest_gpio_probe() failed or not called\n");
+
+	unittest(chip_request_count + 1 == unittest_gpio_chip_request_count,
+		 "unittest_gpio_chip_request() called %d times (expected 1 time)\n",
+		 unittest_gpio_chip_request_count - chip_request_count);
+
+	/*
+	 * tests: apply overlay containing gpio node but no gpio hog node
+	 *
+	 * - apply overlay_gpio_04a
+	 *
+	 * apply the overlay will result in
+	 *   - probe for overlay_gpio_04a
+	 *
+	 * overlay_gpio_04a contains gpio node
+	 */
+
+	probe_pass_count = unittest_gpio_probe_pass_count;
+
+	/* overlay_gpio_04a contains gpio node */
+
+	unittest(overlay_data_apply("overlay_gpio_04a", NULL),
+		 "Adding overlay 'overlay_gpio_04a' failed\n");
+
+	unittest(probe_pass_count + 1 == unittest_gpio_probe_pass_count,
+		 "unittest_gpio_probe() failed or not called\n");
+
+	/*
+	 * tests: apply overlay containing the gpio hog node
+	 *
+	 * - apply overlay_gpio_04b
+	 *
+	 * apply the overlay will result in
+	 *   - processing gpio for overlay_gpio_04b
+	 *
+	 * overlay_gpio_04b contains child gpio hog node
+	 */
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "GPIO line <<int>> (line-C-input) hogged as input\n");
+
+	chip_request_count = unittest_gpio_chip_request_count;
+
+	unittest(overlay_data_apply("overlay_gpio_04b", NULL),
+		 "Adding overlay 'overlay_gpio_04b' failed\n");
+
+	EXPECT_END(KERN_INFO,
+		   "GPIO line <<int>> (line-C-input) hogged as input\n");
+
+	unittest(chip_request_count + 1 == unittest_gpio_chip_request_count,
+		 "unittest_gpio_chip_request() called %d times (expected 1 time)\n",
+		 unittest_gpio_chip_request_count - chip_request_count);
+}
+
 static void __init of_unittest_overlay(void)
 {
 	struct device_node *bus_np = NULL;
@@ -2242,6 +2483,8 @@ static void __init of_unittest_overlay(void)
 	of_unittest_overlay_i2c_cleanup();
 #endif
 
+	of_unittest_overlay_gpio();
+
 	of_unittest_destroy_tracked_overlays();
 
 out:
@@ -2295,6 +2538,12 @@ struct overlay_info {
 OVERLAY_INFO_EXTERN(overlay_12);
 OVERLAY_INFO_EXTERN(overlay_13);
 OVERLAY_INFO_EXTERN(overlay_15);
+OVERLAY_INFO_EXTERN(overlay_gpio_01);
+OVERLAY_INFO_EXTERN(overlay_gpio_02a);
+OVERLAY_INFO_EXTERN(overlay_gpio_02b);
+OVERLAY_INFO_EXTERN(overlay_gpio_03);
+OVERLAY_INFO_EXTERN(overlay_gpio_04a);
+OVERLAY_INFO_EXTERN(overlay_gpio_04b);
 OVERLAY_INFO_EXTERN(overlay_bad_add_dup_node);
 OVERLAY_INFO_EXTERN(overlay_bad_add_dup_prop);
 OVERLAY_INFO_EXTERN(overlay_bad_phandle);
@@ -2319,6 +2568,12 @@ struct overlay_info {
 	OVERLAY_INFO(overlay_12, 0),
 	OVERLAY_INFO(overlay_13, 0),
 	OVERLAY_INFO(overlay_15, 0),
+	OVERLAY_INFO(overlay_gpio_01, 0),
+	OVERLAY_INFO(overlay_gpio_02a, 0),
+	OVERLAY_INFO(overlay_gpio_02b, 0),
+	OVERLAY_INFO(overlay_gpio_03, 0),
+	OVERLAY_INFO(overlay_gpio_04a, 0),
+	OVERLAY_INFO(overlay_gpio_04b, 0),
 	OVERLAY_INFO(overlay_bad_add_dup_node, -EINVAL),
 	OVERLAY_INFO(overlay_bad_add_dup_prop, -EINVAL),
 	OVERLAY_INFO(overlay_bad_phandle, -EINVAL),
-- 
Frank Rowand <frank.rowand@sony.com>


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/2] of: unittest: annotate warnings triggered by unittest
  2020-01-29  5:46 [PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem frowand.list
  2020-01-29  5:46 ` [PATCH 1/2] " frowand.list
@ 2020-01-29  5:46 ` frowand.list
  2020-01-29  6:01 ` [PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem Frank Rowand
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: frowand.list @ 2020-01-29  5:46 UTC (permalink / raw)
  To: Rob Herring, Geert Uytterhoeven, pantelis.antoniou
  Cc: devicetree, linux-kernel, Alan Tull

From: Frank Rowand <frank.rowand@sony.com>

Some tests in the devicetree unittests result in printk messages
from the code being tested.  It can be difficult to determine
whether the messages are the result of unittest or are potentially
reporting bugs that should be fixed.  The most recent example of
a person asking whether to be concerned about these messages is [1].

Add annotations for all messages triggered by unittests, except
KERN_DEBUG messages.  (KERN_DEBUG is a special case due to the
possible interaction of CONFIG_DYNAMIC_DEBUG.)

The annotations added in patch 2/2 add a small amount of verbosity
to the console output.  I have created a proof of concept tool to
explore (1) how test harnesses could use the annotations and
(2) how to make the resulting console output easier to read and
understand as a human being.  The tool 'of_unittest_expect' is
available at https://github.com/frowand/dt_tools

The format of the annotations is expected to change when unittests
are converted to use the kunit infrastructure when the broader
testing community has an opportunity to discuss the implementation
of annotations of test triggered messages.

[1] https://lore.kernel.org/r/6021ac63-b5e0-ed3d-f964-7c6ef579cd68@huawei.com

Signed-off-by: Frank Rowand <frank.rowand@sony.com>
---
changes since RFC:
  - none

 drivers/of/unittest.c | 375 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 345 insertions(+), 30 deletions(-)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index b1cf9972d866..59169d143caf 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -51,6 +51,9 @@
  * Expected message may have a message level other than KERN_INFO.
  * Print the expected message only if the current loglevel will allow
  * the actual message to print.
+ *
+ * Do not use EXPECT_BEGIN() or EXPECT_END() for messages generated by
+ * pr_debug().
  */
 #define EXPECT_BEGIN(level, fmt, ...) \
 	printk(level pr_fmt("EXPECT \\ : ") fmt, ##__VA_ARGS__)
@@ -540,29 +543,77 @@ static void __init of_unittest_parse_phandle_with_args(void)
 
 	/* Check for missing cells property */
 	memset(&args, 0, sizeof(args));
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-data/phandle-tests/provider1");
+
 	rc = of_parse_phandle_with_args(np, "phandle-list",
 					"#phandle-cells-missing", 0, &args);
+
+	EXPECT_END(KERN_INFO,
+		   "OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-data/phandle-tests/provider1");
+
 	unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-data/phandle-tests/provider1");
+
 	rc = of_count_phandle_with_args(np, "phandle-list",
 					"#phandle-cells-missing");
+
+	EXPECT_END(KERN_INFO,
+		   "OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-data/phandle-tests/provider1");
+
 	unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
 
 	/* Check for bad phandle in list */
 	memset(&args, 0, sizeof(args));
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: /testcase-data/phandle-tests/consumer-a: could not find phandle");
+
 	rc = of_parse_phandle_with_args(np, "phandle-list-bad-phandle",
 					"#phandle-cells", 0, &args);
+
+	EXPECT_END(KERN_INFO,
+		   "OF: /testcase-data/phandle-tests/consumer-a: could not find phandle");
+
 	unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: /testcase-data/phandle-tests/consumer-a: could not find phandle");
+
 	rc = of_count_phandle_with_args(np, "phandle-list-bad-phandle",
 					"#phandle-cells");
+
+	EXPECT_END(KERN_INFO,
+		   "OF: /testcase-data/phandle-tests/consumer-a: could not find phandle");
+
 	unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
 
 	/* Check for incorrectly formed argument list */
 	memset(&args, 0, sizeof(args));
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1");
+
 	rc = of_parse_phandle_with_args(np, "phandle-list-bad-args",
 					"#phandle-cells", 1, &args);
+
+	EXPECT_END(KERN_INFO,
+		   "OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1");
+
 	unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1");
+
 	rc = of_count_phandle_with_args(np, "phandle-list-bad-args",
 					"#phandle-cells");
+
+	EXPECT_END(KERN_INFO,
+		   "OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1");
+
 	unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
 }
 
@@ -673,20 +724,41 @@ static void __init of_unittest_parse_phandle_with_args_map(void)
 
 	/* Check for missing cells,map,mask property */
 	memset(&args, 0, sizeof(args));
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: /testcase-data/phandle-tests/consumer-b: could not get #phandle-missing-cells for /testcase-data/phandle-tests/provider1");
+
 	rc = of_parse_phandle_with_args_map(np, "phandle-list",
 					    "phandle-missing", 0, &args);
+	EXPECT_END(KERN_INFO,
+		   "OF: /testcase-data/phandle-tests/consumer-b: could not get #phandle-missing-cells for /testcase-data/phandle-tests/provider1");
+
 	unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
 
 	/* Check for bad phandle in list */
 	memset(&args, 0, sizeof(args));
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: /testcase-data/phandle-tests/consumer-b: could not find phandle");
+
 	rc = of_parse_phandle_with_args_map(np, "phandle-list-bad-phandle",
 					    "phandle", 0, &args);
+	EXPECT_END(KERN_INFO,
+		   "OF: /testcase-data/phandle-tests/consumer-b: could not find phandle");
+
 	unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
 
 	/* Check for incorrectly formed argument list */
 	memset(&args, 0, sizeof(args));
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: /testcase-data/phandle-tests/consumer-b: #phandle-cells = 2 found -1");
+
 	rc = of_parse_phandle_with_args_map(np, "phandle-list-bad-args",
 					    "phandle", 1, &args);
+	EXPECT_END(KERN_INFO,
+		   "OF: /testcase-data/phandle-tests/consumer-b: #phandle-cells = 2 found -1");
+
 	unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
 }
 
@@ -1217,7 +1289,15 @@ static void __init of_unittest_platform_populate(void)
 		np = of_find_node_by_path("/testcase-data/testcase-device2");
 		pdev = of_find_device_by_node(np);
 		unittest(pdev, "device 2 creation failed\n");
+
+		EXPECT_BEGIN(KERN_INFO,
+			     "platform testcase-data:testcase-device2: IRQ index 0 not found");
+
 		irq = platform_get_irq(pdev, 0);
+
+		EXPECT_END(KERN_INFO,
+			   "platform testcase-data:testcase-device2: IRQ index 0 not found");
+
 		unittest(irq < 0 && irq != -EPROBE_DEFER,
 			 "device parsing error failed - %d\n", irq);
 	}
@@ -1421,6 +1501,9 @@ static int __init unittest_data_add(void)
 		return 0;
 	}
 
+	EXPECT_BEGIN(KERN_INFO,
+		     "Duplicate name in testcase-data, renamed to \"duplicate-name#1\"");
+
 	/* attach the sub-tree to live tree */
 	np = unittest_data_node->child;
 	while (np) {
@@ -1431,6 +1514,9 @@ static int __init unittest_data_add(void)
 		np = next;
 	}
 
+	EXPECT_END(KERN_INFO,
+		   "Duplicate name in testcase-data, renamed to \"duplicate-name#1\"");
+
 	of_overlay_mutex_unlock();
 
 	return 0;
@@ -1773,8 +1859,18 @@ static int __init of_unittest_apply_revert_overlay_check(int overlay_nr,
 /* test activation of device */
 static void __init of_unittest_overlay_0(void)
 {
+	int ret;
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest0/status");
+
 	/* device should enable */
-	if (of_unittest_apply_overlay_check(0, 0, 0, 1, PDEV_OVERLAY))
+	ret = of_unittest_apply_overlay_check(0, 0, 0, 1, PDEV_OVERLAY);
+
+	EXPECT_END(KERN_INFO,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest0/status");
+
+	if (ret)
 		return;
 
 	unittest(1, "overlay test %d passed\n", 0);
@@ -1783,28 +1879,58 @@ static void __init of_unittest_overlay_0(void)
 /* test deactivation of device */
 static void __init of_unittest_overlay_1(void)
 {
+	int ret;
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest1/status");
+
 	/* device should disable */
-	if (of_unittest_apply_overlay_check(1, 1, 1, 0, PDEV_OVERLAY))
+	ret = of_unittest_apply_overlay_check(1, 1, 1, 0, PDEV_OVERLAY);
+
+	EXPECT_END(KERN_INFO,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest1/status");
+
+	if (ret)
 		return;
 
 	unittest(1, "overlay test %d passed\n", 1);
+
 }
 
 /* test activation of device */
 static void __init of_unittest_overlay_2(void)
 {
+	int ret;
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest2/status");
+
 	/* device should enable */
-	if (of_unittest_apply_overlay_check(2, 2, 0, 1, PDEV_OVERLAY))
-		return;
+	ret = of_unittest_apply_overlay_check(2, 2, 0, 1, PDEV_OVERLAY);
+
+	EXPECT_END(KERN_INFO,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest2/status");
 
+	if (ret)
+		return;
 	unittest(1, "overlay test %d passed\n", 2);
 }
 
 /* test deactivation of device */
 static void __init of_unittest_overlay_3(void)
 {
+	int ret;
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest3/status");
+
 	/* device should disable */
-	if (of_unittest_apply_overlay_check(3, 3, 1, 0, PDEV_OVERLAY))
+	ret = of_unittest_apply_overlay_check(3, 3, 1, 0, PDEV_OVERLAY);
+
+	EXPECT_END(KERN_INFO,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest3/status");
+
+	if (ret)
 		return;
 
 	unittest(1, "overlay test %d passed\n", 3);
@@ -1823,8 +1949,18 @@ static void __init of_unittest_overlay_4(void)
 /* test overlay apply/revert sequence */
 static void __init of_unittest_overlay_5(void)
 {
+	int ret;
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest5/status");
+
 	/* device should disable */
-	if (of_unittest_apply_revert_overlay_check(5, 5, 0, 1, PDEV_OVERLAY))
+	ret = of_unittest_apply_revert_overlay_check(5, 5, 0, 1, PDEV_OVERLAY);
+
+	EXPECT_END(KERN_INFO,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest5/status");
+
+	if (ret)
 		return;
 
 	unittest(1, "overlay test %d passed\n", 5);
@@ -1838,6 +1974,8 @@ static void __init of_unittest_overlay_6(void)
 	int before = 0, after = 1;
 	const char *overlay_name;
 
+	int ret;
+
 	/* unittest device must be in before state */
 	for (i = 0; i < 2; i++) {
 		if (of_unittest_device_exists(unittest_nr + i, PDEV_OVERLAY)
@@ -1852,18 +1990,41 @@ static void __init of_unittest_overlay_6(void)
 	}
 
 	/* apply the overlays */
-	for (i = 0; i < 2; i++) {
 
-		overlay_name = overlay_name_from_nr(overlay_nr + i);
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest6/status");
+
+	overlay_name = overlay_name_from_nr(overlay_nr + 0);
 
-		if (!overlay_data_apply(overlay_name, &ovcs_id)) {
-			unittest(0, "could not apply overlay \"%s\"\n",
-					overlay_name);
+	ret = overlay_data_apply(overlay_name, &ovcs_id);
+
+	if (!ret) {
+		unittest(0, "could not apply overlay \"%s\"\n", overlay_name);
+			return;
+	}
+	ov_id[0] = ovcs_id;
+	of_unittest_track_overlay(ov_id[0]);
+
+	EXPECT_END(KERN_INFO,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest6/status");
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest7/status");
+
+	overlay_name = overlay_name_from_nr(overlay_nr + 1);
+
+	ret = overlay_data_apply(overlay_name, &ovcs_id);
+
+	if (!ret) {
+		unittest(0, "could not apply overlay \"%s\"\n", overlay_name);
 			return;
-		}
-		ov_id[i] = ovcs_id;
-		of_unittest_track_overlay(ov_id[i]);
 	}
+	ov_id[1] = ovcs_id;
+	of_unittest_track_overlay(ov_id[1]);
+
+	EXPECT_END(KERN_INFO,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest7/status");
+
 
 	for (i = 0; i < 2; i++) {
 		/* unittest device must be in after state */
@@ -1904,6 +2065,7 @@ static void __init of_unittest_overlay_6(void)
 	}
 
 	unittest(1, "overlay test %d passed\n", 6);
+
 }
 
 /* test overlay application in sequence */
@@ -1912,26 +2074,65 @@ static void __init of_unittest_overlay_8(void)
 	int i, ov_id[2], ovcs_id;
 	int overlay_nr = 8, unittest_nr = 8;
 	const char *overlay_name;
+	int ret;
 
 	/* we don't care about device state in this test */
 
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest8/status");
+
+	overlay_name = overlay_name_from_nr(overlay_nr + 0);
+
+	ret = overlay_data_apply(overlay_name, &ovcs_id);
+	if (!ret)
+		unittest(0, "could not apply overlay \"%s\"\n", overlay_name);
+
+	EXPECT_END(KERN_INFO,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest8/status");
+
+	if (!ret)
+		return;
+
+	ov_id[0] = ovcs_id;
+	of_unittest_track_overlay(ov_id[0]);
+
+	overlay_name = overlay_name_from_nr(overlay_nr + 1);
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest8/property-foo");
+
 	/* apply the overlays */
-	for (i = 0; i < 2; i++) {
+	ret = overlay_data_apply(overlay_name, &ovcs_id);
 
-		overlay_name = overlay_name_from_nr(overlay_nr + i);
+	EXPECT_END(KERN_INFO,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest8/property-foo");
 
-		if (!overlay_data_apply(overlay_name, &ovcs_id)) {
-			unittest(0, "could not apply overlay \"%s\"\n",
-					overlay_name);
-			return;
-		}
-		ov_id[i] = ovcs_id;
-		of_unittest_track_overlay(ov_id[i]);
+	if (!ret) {
+		unittest(0, "could not apply overlay \"%s\"\n", overlay_name);
+		return;
 	}
 
+	ov_id[1] = ovcs_id;
+	of_unittest_track_overlay(ov_id[1]);
+
 	/* now try to remove first overlay (it should fail) */
 	ovcs_id = ov_id[0];
-	if (!of_overlay_remove(&ovcs_id)) {
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: overlay: node_overlaps_later_cs: #6 overlaps with #7 @/testcase-data/overlay-node/test-bus/test-unittest8");
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: overlay: overlay #6 is not topmost");
+
+	ret = of_overlay_remove(&ovcs_id);
+
+	EXPECT_END(KERN_INFO,
+		   "OF: overlay: overlay #6 is not topmost");
+
+	EXPECT_END(KERN_INFO,
+		   "OF: overlay: node_overlaps_later_cs: #6 overlaps with #7 @/testcase-data/overlay-node/test-bus/test-unittest8");
+
+	if (!ret) {
 		unittest(0, "%s was destroyed @\"%s\"\n",
 				overlay_name_from_nr(overlay_nr + 0),
 				unittest_path(unittest_nr,
@@ -1963,6 +2164,7 @@ static void __init of_unittest_overlay_10(void)
 
 	/* device should disable */
 	ret = of_unittest_apply_overlay_check(10, 10, 0, 1, PDEV_OVERLAY);
+
 	if (unittest(ret == 0,
 			"overlay test %d failed; overlay application\n", 10))
 		return;
@@ -1986,6 +2188,7 @@ static void __init of_unittest_overlay_11(void)
 	/* device should disable */
 	ret = of_unittest_apply_revert_overlay_check(11, 11, 0, 1,
 			PDEV_OVERLAY);
+
 	unittest(ret == 0, "overlay test %d failed; overlay apply\n", 11);
 }
 
@@ -2216,12 +2419,21 @@ static int of_unittest_overlay_i2c_init(void)
 		return ret;
 
 	ret = platform_driver_register(&unittest_i2c_bus_driver);
+
 	if (unittest(ret == 0,
 			"could not register unittest i2c bus driver\n"))
 		return ret;
 
 #if IS_BUILTIN(CONFIG_I2C_MUX)
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "i2c i2c-1: Added multiplexed i2c bus 2");
+
 	ret = i2c_add_driver(&unittest_i2c_mux_driver);
+
+	EXPECT_END(KERN_INFO,
+		   "i2c i2c-1: Added multiplexed i2c bus 2");
+
 	if (unittest(ret == 0,
 			"could not register unittest i2c mux driver\n"))
 		return ret;
@@ -2241,8 +2453,18 @@ static void of_unittest_overlay_i2c_cleanup(void)
 
 static void __init of_unittest_overlay_i2c_12(void)
 {
+	int ret;
+
 	/* device should enable */
-	if (of_unittest_apply_overlay_check(12, 12, 0, 1, I2C_OVERLAY))
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest12/status");
+
+	ret = of_unittest_apply_overlay_check(12, 12, 0, 1, I2C_OVERLAY);
+
+	EXPECT_END(KERN_INFO,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest12/status");
+
+	if (ret)
 		return;
 
 	unittest(1, "overlay test %d passed\n", 12);
@@ -2251,8 +2473,18 @@ static void __init of_unittest_overlay_i2c_12(void)
 /* test deactivation of device */
 static void __init of_unittest_overlay_i2c_13(void)
 {
+	int ret;
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest13/status");
+
 	/* device should disable */
-	if (of_unittest_apply_overlay_check(13, 13, 1, 0, I2C_OVERLAY))
+	ret = of_unittest_apply_overlay_check(13, 13, 1, 0, I2C_OVERLAY);
+
+	EXPECT_END(KERN_INFO,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest13/status");
+
+	if (ret)
 		return;
 
 	unittest(1, "overlay test %d passed\n", 13);
@@ -2265,8 +2497,18 @@ static void of_unittest_overlay_i2c_14(void)
 
 static void __init of_unittest_overlay_i2c_15(void)
 {
+	int ret;
+
 	/* device should enable */
-	if (of_unittest_apply_overlay_check(15, 15, 0, 1, I2C_OVERLAY))
+	EXPECT_BEGIN(KERN_INFO,
+		     "i2c i2c-1: Added multiplexed i2c bus 3");
+
+	ret = of_unittest_apply_overlay_check(15, 15, 0, 1, I2C_OVERLAY);
+
+	EXPECT_END(KERN_INFO,
+		   "i2c i2c-1: Added multiplexed i2c bus 3");
+
+	if (ret)
 		return;
 
 	unittest(1, "overlay test %d passed\n", 15);
@@ -2725,6 +2967,7 @@ static __init void of_unittest_overlay_high_level(void)
 	struct device_node *overlay_base_symbols;
 	struct device_node **pprev;
 	struct property *prop;
+	int ret;
 
 	if (!overlay_base_root) {
 		unittest(0, "overlay_base_root not initialized\n");
@@ -2839,15 +3082,86 @@ static __init void of_unittest_overlay_high_level(void)
 
 	/* now do the normal overlay usage test */
 
-	unittest(overlay_data_apply("overlay", NULL),
-		 "Adding overlay 'overlay' failed\n");
+	EXPECT_BEGIN(KERN_ERR,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/status");
+	EXPECT_BEGIN(KERN_ERR,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/status");
+	EXPECT_BEGIN(KERN_ERR,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/ride@100/track@30/incline-up");
+	EXPECT_BEGIN(KERN_ERR,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/ride@100/track@40/incline-up");
+	EXPECT_BEGIN(KERN_ERR,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/status");
+	EXPECT_BEGIN(KERN_ERR,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/color");
+	EXPECT_BEGIN(KERN_ERR,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/rate");
+	EXPECT_BEGIN(KERN_ERR,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/hvac_2");
+	EXPECT_BEGIN(KERN_ERR,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200");
+	EXPECT_BEGIN(KERN_ERR,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200_left");
+	EXPECT_BEGIN(KERN_ERR,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200_right");
+
+	ret = overlay_data_apply("overlay", NULL);
+
+	EXPECT_END(KERN_ERR,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200_right");
+	EXPECT_END(KERN_ERR,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200_left");
+	EXPECT_END(KERN_ERR,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200");
+	EXPECT_END(KERN_ERR,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/hvac_2");
+	EXPECT_END(KERN_ERR,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/rate");
+	EXPECT_END(KERN_ERR,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/color");
+	EXPECT_END(KERN_ERR,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/status");
+	EXPECT_END(KERN_ERR,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/ride@100/track@40/incline-up");
+	EXPECT_END(KERN_ERR,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/ride@100/track@30/incline-up");
+	EXPECT_END(KERN_ERR,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/status");
+	EXPECT_END(KERN_ERR,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/status");
+
+	unittest(ret, "Adding overlay 'overlay' failed\n");
+
+	EXPECT_BEGIN(KERN_ERR,
+		     "OF: overlay: ERROR: multiple fragments add and/or delete node /testcase-data-2/substation@100/motor-1/controller");
+	EXPECT_BEGIN(KERN_ERR,
+		     "OF: overlay: ERROR: multiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/controller/name");
 
 	unittest(overlay_data_apply("overlay_bad_add_dup_node", NULL),
 		 "Adding overlay 'overlay_bad_add_dup_node' failed\n");
 
+	EXPECT_END(KERN_ERR,
+		   "OF: overlay: ERROR: multiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/controller/name");
+	EXPECT_END(KERN_ERR,
+		   "OF: overlay: ERROR: multiple fragments add and/or delete node /testcase-data-2/substation@100/motor-1/controller");
+
+	EXPECT_BEGIN(KERN_ERR,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/motor-1/rpm_avail");
+	EXPECT_BEGIN(KERN_ERR,
+		     "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/motor-1/rpm_avail");
+	EXPECT_BEGIN(KERN_ERR,
+		     "OF: overlay: ERROR: multiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/rpm_avail");
+
 	unittest(overlay_data_apply("overlay_bad_add_dup_prop", NULL),
 		 "Adding overlay 'overlay_bad_add_dup_prop' failed\n");
 
+	EXPECT_END(KERN_ERR,
+		   "OF: overlay: ERROR: multiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/rpm_avail");
+	EXPECT_END(KERN_ERR,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/motor-1/rpm_avail");
+	EXPECT_END(KERN_ERR,
+		   "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/motor-1/rpm_avail");
+
 	unittest(overlay_data_apply("overlay_bad_phandle", NULL),
 		 "Adding overlay 'overlay_bad_phandle' failed\n");
 
@@ -2871,6 +3185,8 @@ static int __init of_unittest(void)
 	struct device_node *np;
 	int res;
 
+	pr_info("start of unittest - you will see error messages\n");
+
 	/* adding data for unittest */
 
 	if (IS_ENABLED(CONFIG_UML))
@@ -2889,7 +3205,6 @@ static int __init of_unittest(void)
 	}
 	of_node_put(np);
 
-	pr_info("start of unittest - you will see error messages\n");
 	of_unittest_check_tree_linkage();
 	of_unittest_check_phandles();
 	of_unittest_find_node_by_name();
-- 
Frank Rowand <frank.rowand@sony.com>


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem
  2020-01-29  5:46 [PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem frowand.list
  2020-01-29  5:46 ` [PATCH 1/2] " frowand.list
  2020-01-29  5:46 ` [PATCH 2/2] of: unittest: annotate warnings triggered by unittest frowand.list
@ 2020-01-29  6:01 ` Frank Rowand
  2020-01-29  6:02 ` Frank Rowand
  2020-01-29  6:03 ` Frank Rowand
  4 siblings, 0 replies; 9+ messages in thread
From: Frank Rowand @ 2020-01-29  6:01 UTC (permalink / raw)
  To: Rob Herring, Geert Uytterhoeven, pantelis.antoniou
  Cc: devicetree, linux-kernel, Alan Tull

On 1/28/20 11:46 PM, frowand.list@gmail.com wrote:
> From: Frank Rowand <frank.rowand@sony.com>
> 
> Geert reports that gpio hog nodes are not properly processed when
> the gpio hog node is added via an overlay reply and provides an
> RFC patch to fix the problem [1].
> 
> Add a unittest that shows the problem.  Unittest will report "1 failed"
> test before applying Geert's RFC patch and "0 failed" after applying
> Geert's RFC patch.
> 
> I did not have a development system for which it would be easy to
> experiment with applying an overlay containing a gpio hog, so I
> instead created this unittest that uses a fake gpio node.
> 
> Some tests in the devicetree unittests result in printk messages
> from the code being tested.  It can be difficult to determine
> whether the messages are the result of unittest or are potentially
> reporting bugs that should be fixed.  The most recent example of
> a person asking whether to be concerned about these messages is [2].
> 
> Patch 2 adds annotations for all messages triggered by unittests,
> except KERN_DEBUG messages.  (KERN_DEBUG is a special case due to the
> possible interaction of CONFIG_DYNAMIC_DEBUG.)
> 
> The annotations added in patch 2/2 add a small amount of verbosity
> to the console output.  I have created a proof of concept tool to
> explore (1) how test harnesses could use the annotations and
> (2) how to make the resulting console output easier to read and
> understand as a human being.  The tool 'of_unittest_expect' is
> available at https://github.com/frowand/dt_tools
> 
> The format of the annotations is expected to change when unittests
> are converted to use the kunit infrastructure when the broader
> testing community has an opportunity to discuss the implementation
> of annotations of test triggered messages.
> 
> [1] https://lore.kernel.org/linux-devicetree/20191230133852.5890-1-geert+renesas@glider.be/
> [2] https://lore.kernel.org/r/6021ac63-b5e0-ed3d-f964-7c6ef579cd68@huawei.com
> 
> Frank Rowand (2):
>   of: unittest: add overlay gpio test to catch gpio hog problem
>   of: unittest: annotate warnings triggered by unittest
> 
>  drivers/of/unittest-data/Makefile             |   8 +-
>  drivers/of/unittest-data/overlay_gpio_01.dts  |  23 +
>  drivers/of/unittest-data/overlay_gpio_02a.dts |  16 +
>  drivers/of/unittest-data/overlay_gpio_02b.dts |  16 +
>  drivers/of/unittest-data/overlay_gpio_03.dts  |  23 +
>  drivers/of/unittest-data/overlay_gpio_04a.dts |  16 +
>  drivers/of/unittest-data/overlay_gpio_04b.dts |  16 +
>  drivers/of/unittest.c                         | 630 ++++++++++++++++++++++++--
>  8 files changed, 717 insertions(+), 31 deletions(-)
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_01.dts
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_02a.dts
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_02b.dts
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_03.dts
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_04a.dts
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_04b.dts
> 

Console output after patch 1/2, filtered by 'of_unittest_expect':

   ndroid Bootloader - UART_DM Initialized!!!
   [0] welcome to lk
   
   [10] platform_init()
   [10] target_init()
   [10] Display Init: Start
   [10] display_init(),target_id=10.
   [30] Config MIPI_VIDEO_PANEL.
   [30] Turn on MIPI_VIDEO_PANEL.
   [50] Video lane tested successfully
   [50] Display Init: Done
   [80] Loading keystore failed status 5 [80] ERROR: scm_protect_keystore Failed[200] USB init ept @ 0xf96b000
   [220] fastboot_init()
   [220] udc_start()
   [350] -- reset --
   [350] -- portchange --
   [460] -- reset --
   [460] -- portchange --
   [650] fastboot: processing commands
   [780] fastboot: download:00f30800
   [1270] fastboot: boot
   [1290] Found Appeneded Flattened Device tree
   [1290] cmdline: console=ttyMSM0,115200,n8 androidboot.hardware=qcom maxcpus=2 msm_rtb.filter=0x37 ehci-hcd.park=3 norandmaps androidboot.emmc=true androidboot.serialno=40081c41 androidboot.baseband=apq
   [1310] Updating device tree: start
   [1310] Updating device tree: done
   [1320] booting linux @ 0x8000, ramdisk @ 0x2000000 (9533134), tags/device tree @ 0x1e00000
   [1320] Turn off MIPI_VIDEO_PANEL.
   [1320] Continuous splash enabled, keeping panel alive.
   Booting Linux on physical CPU 0x0
   Linux version 5.5.0-00001-gee85e8d1d8fe-dirty (frowand@xps8900) (gcc version 4.6.x-google 20120106 (prerelease) (GCC)) #6 SMP PREEMPT Tue Jan 28 23:00:59 CST 2020
   CPU: ARMv7 Processor [512f06f0] revision 0 (ARMv7), cr=10c5787d
   CPU: div instructions available: patching division code
   CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
   OF: fdt: Machine model: Qualcomm APQ8074 Dragonboard
   Memory policy: Data cache writealloc
   cma: Reserved 256 MiB at 0x70000000
   percpu: Embedded 19 pages/cpu s48192 r8192 d21440 u77824
   Built 1 zonelists, mobility grouping on.  Total pages: 490240
   Kernel command line: console=ttyMSM0,115200,n8 androidboot.hardware=qcom maxcpus=2 msm_rtb.filter=0x37 ehci-hcd.park=3 norandmaps androidboot.emmc=true androidboot.serialno=40081c41 androidboot.baseband=apq
   Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)
   Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
   mem auto-init: stack:off, heap alloc:off, heap free:off
   Memory: 1664560K/1967104K available (8192K kernel code, 859K rwdata, 3788K rodata, 1024K init, 268K bss, 40400K reserved, 262144K cma-reserved, 1048576K highmem)
   SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
   rcu: Preemptible hierarchical RCU implementation.
   	Tasks RCU enabled.
   rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
   NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
   random: get_random_bytes called from start_kernel+0x2fc/0x508 with crng_init=0
   arch_timer: cp15 and mmio timer(s) running at 19.20MHz (virt/virt).
   clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x46d987e47, max_idle_ns: 440795202767 ns
   sched_clock: 56 bits at 19MHz, resolution 52ns, wraps every 4398046511078ns
   Switching to timer-based delay loop, resolution 52ns
   Console: colour dummy device 80x30
   Calibrating delay loop (skipped), value calculated using timer frequency.. 38.40 BogoMIPS (lpj=192000)
   pid_max: default: 32768 minimum: 301
   Mount-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
   Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
   CPU: Testing write buffer coherency: ok
   CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
   Setting up static identity map for 0x300000 - 0x300060
   rcu: Hierarchical SRCU implementation.
   smp: Bringing up secondary CPUs ...
   CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
   smp: Brought up 1 node, 2 CPUs
   SMP: Total of 2 processors activated (76.80 BogoMIPS).
   CPU: All CPU(s) started in SVC mode.
   devtmpfs: initialized
   VFP support v0.3: implementor 51 architecture 64 part 6f variant 2 rev 0
   clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
   futex hash table entries: 1024 (order: 4, 65536 bytes, linear)
   pinctrl core: initialized pinctrl subsystem
   thermal_sys: Registered thermal governor 'step_wise'
   NET: Registered protocol family 16
   DMA: preallocated 256 KiB pool for atomic coherent allocations
   cpuidle: using governor menu
   hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
   hw-breakpoint: maximum watchpoint size is 8 bytes.
   iommu: Default domain type: Translated 
   vgaarb: loaded
   SCSI subsystem initialized
   usbcore: registered new interface driver usbfs
   usbcore: registered new interface driver hub
   usbcore: registered new device driver usb
   Advanced Linux Sound Architecture Driver Initialized.
   clocksource: Switched to clocksource arch_sys_counter
   NET: Registered protocol family 2
   tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)
   TCP established hash table entries: 8192 (order: 3, 32768 bytes, linear)
   TCP bind hash table entries: 8192 (order: 4, 65536 bytes, linear)
   TCP: Hash tables configured (established 8192 bind 8192)
   UDP hash table entries: 512 (order: 2, 16384 bytes, linear)
   UDP-Lite hash table entries: 512 (order: 2, 16384 bytes, linear)
   NET: Registered protocol family 1
   RPC: Registered named UNIX socket transport module.
   RPC: Registered udp transport module.
   RPC: Registered tcp transport module.
   RPC: Registered tcp NFSv4.1 backchannel transport module.
   PCI: CLS 0 bytes, default 64
   Trying to unpack rootfs image as initramfs...
   Freeing initrd memory: 9312K
   hw perfevents: enabled with armv7_krait PMU driver, 5 counters available
   Initialise system trusted keyrings
   workingset: timestamp_bits=30 max_order=19 bucket_order=0
   NFS: Registering the id_resolver key type
   Key type id_resolver registered
   Key type id_legacy registered
   Key type cifs.idmap registered
   jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
   fuse: init (API version 7.31)
   Key type asymmetric registered
   Asymmetric key parser 'x509' registered
   bounce: pool size: 64 pages
   Block layer SCSI generic (bsg) driver version 0.4 loaded (major 250)
   io scheduler mq-deadline registered
   io scheduler kyber registered
   msm_serial f991e000.serial: msm_serial: detected port #0
   msm_serial f991e000.serial: uartclk = 7372800
   f991e000.serial: ttyMSM0 at MMIO 0xf991e000 (irq = 28, base_baud = 460800) is a MSM
   msm_serial: console setup on port #0
   printk: console [ttyMSM0] enabled
   msm_serial: driver initialized
   brd: module loaded
   loop: module loaded
   SCSI Media Changer driver v0.25 
   spmi spmi-0: PMIC arbiter version v1 (0x20000002)
   s1: supplied by regulator-dummy
   s2: supplied by regulator-dummy
   s3: supplied by regulator-dummy
   s4: Bringing 5100000uV into 5000000-5000000uV
   l1: supplied by regulator-dummy
   l2: supplied by regulator-dummy
   l3: supplied by regulator-dummy
   l4: supplied by regulator-dummy
   l5: supplied by regulator-dummy
   l6: supplied by regulator-dummy
   l7: supplied by regulator-dummy
   l8: supplied by regulator-dummy
   l9: supplied by regulator-dummy
   l10: supplied by regulator-dummy
   l11: supplied by regulator-dummy
   l12: supplied by regulator-dummy
   l13: supplied by regulator-dummy
   l14: supplied by regulator-dummy
   l15: supplied by regulator-dummy
   l16: supplied by regulator-dummy
   l17: supplied by regulator-dummy
   l18: supplied by regulator-dummy
   l19: supplied by regulator-dummy
   l20: supplied by regulator-dummy
   l21: supplied by regulator-dummy
   l22: supplied by regulator-dummy
   l23: supplied by regulator-dummy
   l24: supplied by regulator-dummy
   lvs1: supplied by regulator-dummy
   lvs2: supplied by regulator-dummy
   lvs3: supplied by regulator-dummy
   5vs1: supplied by s4
   5vs2: supplied by s4
   libphy: Fixed MDIO Bus: probed
   SLIP: version 0.8.4-NET3.019-NEWTTY (dynamic channels, max=256) (6 bit encapsulation enabled).
   CSLIP: code copyright 1989 Regents of the University of California.
   usbcore: registered new interface driver ax88179_178a
   usbcore: registered new interface driver cdc_ether
   usbcore: registered new interface driver net1080
   usbcore: registered new interface driver cdc_subset
   usbcore: registered new interface driver cdc_ncm
   ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
   ehci-pci: EHCI PCI platform driver
   usbcore: registered new interface driver cdc_acm
   cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
   rtc-pm8xxx fc4cf000.spmi:pm8941@0:rtc@6000: registered as rtc0
   i2c /dev entries driver
   qcom-smbb fc4cf000.spmi:pm8941@0:charger@1000: Initializing SMBB rev 3
   otg-vbus: supplied by 5vs1
   cpuidle: enable-method property 'qcom,kpss-acc-v2' found operations
   cpuidle: enable-method property 'qcom,kpss-acc-v2' found operations
   cpuidle: enable-method property 'qcom,kpss-acc-v2' found operations
   cpuidle: enable-method property 'qcom,kpss-acc-v2' found operations
   sdhci: Secure Digital Host Controller Interface driver
   sdhci: Copyright(c) Pierre Ossman
   sdhci-pltfm: SDHCI platform and OF driver helper
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   usbcore: registered new interface driver usbhid
   usbhid: USB HID core driver
   oprofile: using timer interrupt.
   NET: Registered protocol family 17
   Key type dns_resolver registered
   Registering SWP/SWPB emulation handler
   Loading compiled-in X.509 certificates
   debugfs: Directory 'fc4a9000.thermal-sensor' with parent 'tsens' already present!
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   s1: supplied by regulator-dummy
   s1: Bringing 0uV into 675000-675000uV
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   rtc-pm8xxx fc4cf000.spmi:pm8941@0:rtc@6000: setting system clock to 1970-01-16T23:55:43 UTC (1382143)
   Duplicate name in testcase-data, renamed to "duplicate-name#1"
   s2: supplied by regulator-dummy
-> ### dt-test ### start of unittest - you will see error messages
   s2: Bringing 0uV into 500000-500000uV
   OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-data/phandle-tests/provider1
   s3: supplied by regulator-dummy
   OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-data/phandle-tests/provider1
   OF: /testcase-data/phandle-tests/consumer-a: could not find phandle
   s3: Bringing 0uV into 500000-500000uV
   OF: /testcase-data/phandle-tests/consumer-a: could not find phandle
   s4: supplied by regulator-dummy
   OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1
   s4: Bringing 0uV into 500000-500000uV
   OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1
   s5: supplied by regulator-dummy
   OF: /testcase-data/phandle-tests/consumer-b: could not get #phandle-missing-cells for /testcase-data/phandle-tests/provider1
   s6: supplied by regulator-dummy
   OF: /testcase-data/phandle-tests/consumer-b: could not find phandle
   s7: supplied by regulator-dummy
   OF: /testcase-data/phandle-tests/consumer-b: #phandle-cells = 2 found -1
   s8: supplied by regulator-dummy
   platform testcase-data:testcase-device2: IRQ index 0 not found
   s1: supplied by regulator-dummy
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest0/status
   s1: Bringing 0uV into 1300000-1300000uV
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest1/status
   s2: supplied by regulator-dummy
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest2/status
   s2: Bringing 0uV into 2150000-2150000uV
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest3/status
   s3: supplied by regulator-dummy
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest5/status
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest6/status
   s3: Bringing 0uV into 1800000-1800000uV
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest7/status
   l1: supplied by s1
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest8/status
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest8/property-foo
   l1: Bringing 0uV into 1225000-1225000uV
   OF: overlay: node_overlaps_later_cs: #6 overlaps with #7 @/testcase-data/overlay-node/test-bus/test-unittest8
   OF: overlay: overlay #6 is not topmost
   l2: supplied by s3
   l2: Bringing 0uV into 1200000-1200000uV
   l3: supplied by s1
   i2c i2c-1: Added multiplexed i2c bus 2
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest12/status
   l3: Bringing 0uV into 1225000-1225000uV
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest13/status
   l4: supplied by s1
   i2c i2c-1: Added multiplexed i2c bus 3
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   l4: Bringing 0uV into 1225000-1225000uV
   l5: supplied by s2
ok GPIO line 315 (line-B-input) hogged as input
   sdhci_msm f98a4900.sdhci: Got CD GPIO
ok GPIO line 309 (line-A-input) hogged as input
   l5: Bringing 0uV into 1800000-1800000uV
   l6: supplied by s2
   l6: Bringing 0uV into 1800000-1800000uV
ok GPIO line 307 (line-D-input) hogged as input
   l7: supplied by s2
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   l7: Bringing 0uV into 1800000-1800000uV
** of_unittest_expect WARNING - not found ---> GPIO line <<int>> (line-C-input) hogged as input
   l8: supplied by regulator-dummy
>> ### dt-test ### FAIL of_unittest_overlay_gpio():2424 unittest_gpio_chip_request() called 0 times (expected 1 time)
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/status
   l8: Bringing 0uV into 1800000-1800000uV
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/status
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/ride@100/track@30/incline-up
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/ride@100/track@40/incline-up
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/status
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/color
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/rate
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/hvac_2
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200_left
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200_right
   OF: overlay: ERROR: multiple fragments add and/or delete node /testcase-data-2/substation@100/motor-1/controller
   l9: supplied by regulator-dummy
   l9: Bringing 0uV into 1800000-1800000uV
   OF: overlay: ERROR: multiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/controller/name
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/motor-1/rpm_avail
   OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/motor-1/rpm_avail
   OF: overlay: ERROR: multiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/rpm_avail
-> ### dt-test ### end of unittest - 258 passed, 1 failed
   l10: supplied by regulator-dummy
   ALSA device list:
   sdhci_msm f98a4900.sdhci: Got CD GPIO
     No soundcard�[    3.059465] l11: supplied by s1
   l11: Bringing 0uV into 1300000-1300000uV
   Freeing unused kernel memory: 1024K
   l12: supplied by s2
   l12: Bringing 0uV into 1800000-1800000uV
   l13: supplied by regulator-dummy
   l13: Bringing 0uV into 1800000-1800000uV
   l14: supplied by s2
   l14: Bringing 0uV into 1800000-1800000uV
   l15: supplied by s2
   l15: Bringing 0uV into 2050000-2050000uV
   Run /init as init process
   l16: supplied by regulator-dummy
   l16: Bringing 0uV into 2700000-2700000uV
   l17: supplied by regulator-dummy
   l17: Bringing 0uV into 2700000-2700000uV
   l18: supplied by regulator-dummy
   l18: Bringing 0uV into 2850000-2850000uV
   l19: supplied by regulator-dummy
   l19: Bringing 0uV into 3300000-3300000uV
   l20: supplied by regulator-dummy
   l20: Bringing 0uV into 2950000-2950000uV
   l21: supplied by regulator-dummy
   l21: Bringing 0uV into 2950000-2950000uV
   l22: supplied by regulator-dummy
   l22: Bringing 0uV into 3000000-3000000uV
   l23: supplied by regulator-dummy
   l23: Bringing 0uV into 3000000-3000000uV
   l24: supplied by regulator-dummy
   l24: Bringing 0uV into 3075000-3075000uV
   lvs1: supplied by s3
   mkdir: can't create directory '/bin': File exists
   mkdir: can't [    3.194707] lvs2: supplied by s3
   create directory '/dev': File exists
   /init: line 25: can't crea[    3.203415] lvs3: supplied by s3
   te /proc/sys/kernel/hotplug: nonexistent directory
   mdev: unknow[    3.212141] 5vs1: supplied by s4
   n user/group 'root:uucp' on line 34
   5vs2: supplied by s4
   mmc0: SDHCI controller on f9824900.sdhci [f9824900.sdhci] using ADMA
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   mmc1: SDHCI controller on f98a4900.sdhci [f98a4900.sdhci] using ADMA
   mmc0: new HS200 MMC card at address 0001
   mmc1: new ultra high speed DDR50 SDHC card at address aaaa
   mmcblk0: mmc0:0001 SEM16G 14.7 GiB 
   mmcblk0boot0: mmc0:0001 SEM16G partition 1 4.00 MiB
   mmcblk0boot1: mmc0:0001 SEM16G partition 2 4.00 MiB
   mmcblk1: mmc1:aaaa SU16G 14.8 GiB 
   mmcblk0rpmb: mmc0:0001 SEM16G partition 3 4.00 MiB, chardev (247:0)
    mmcblk1: p1
    mmcblk0: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 p20
   Attempt to mount partitions: /usr/system /usr/data
   Mounting partitions from: /dev/mmcblk0
   EXT4-fs (mmcblk0p12): mounted filesystem with ordered data mode. Opts: (null)
   random: fast init done
   EXT4-fs (mmcblk0p13): recovery complete
   EXT4-fs (mmcblk0p13): mounted filesystem with ordered data mode. Opts: (null)
   / # 
   / # cat /proc/version
   Linux version 5.5.0-00001-gee85e8d1d8fe-dirty (frowand@xps8900) (gcc version 4.6.x-google 20120106 (prerelease) (GCC)) #6 SMP PREEMPT Tue Jan 28 23:00:59 CST 2020

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem
  2020-01-29  5:46 [PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem frowand.list
                   ` (2 preceding siblings ...)
  2020-01-29  6:01 ` [PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem Frank Rowand
@ 2020-01-29  6:02 ` Frank Rowand
  2020-01-29  6:03 ` Frank Rowand
  4 siblings, 0 replies; 9+ messages in thread
From: Frank Rowand @ 2020-01-29  6:02 UTC (permalink / raw)
  To: Rob Herring, Geert Uytterhoeven, pantelis.antoniou
  Cc: devicetree, linux-kernel, Alan Tull

On 1/28/20 11:46 PM, frowand.list@gmail.com wrote:
> From: Frank Rowand <frank.rowand@sony.com>
> 
> Geert reports that gpio hog nodes are not properly processed when
> the gpio hog node is added via an overlay reply and provides an
> RFC patch to fix the problem [1].
> 
> Add a unittest that shows the problem.  Unittest will report "1 failed"
> test before applying Geert's RFC patch and "0 failed" after applying
> Geert's RFC patch.
> 
> I did not have a development system for which it would be easy to
> experiment with applying an overlay containing a gpio hog, so I
> instead created this unittest that uses a fake gpio node.
> 
> Some tests in the devicetree unittests result in printk messages
> from the code being tested.  It can be difficult to determine
> whether the messages are the result of unittest or are potentially
> reporting bugs that should be fixed.  The most recent example of
> a person asking whether to be concerned about these messages is [2].
> 
> Patch 2 adds annotations for all messages triggered by unittests,
> except KERN_DEBUG messages.  (KERN_DEBUG is a special case due to the
> possible interaction of CONFIG_DYNAMIC_DEBUG.)
> 
> The annotations added in patch 2/2 add a small amount of verbosity
> to the console output.  I have created a proof of concept tool to
> explore (1) how test harnesses could use the annotations and
> (2) how to make the resulting console output easier to read and
> understand as a human being.  The tool 'of_unittest_expect' is
> available at https://github.com/frowand/dt_tools
> 
> The format of the annotations is expected to change when unittests
> are converted to use the kunit infrastructure when the broader
> testing community has an opportunity to discuss the implementation
> of annotations of test triggered messages.
> 
> [1] https://lore.kernel.org/linux-devicetree/20191230133852.5890-1-geert+renesas@glider.be/
> [2] https://lore.kernel.org/r/6021ac63-b5e0-ed3d-f964-7c6ef579cd68@huawei.com
> 
> Frank Rowand (2):
>   of: unittest: add overlay gpio test to catch gpio hog problem
>   of: unittest: annotate warnings triggered by unittest
> 
>  drivers/of/unittest-data/Makefile             |   8 +-
>  drivers/of/unittest-data/overlay_gpio_01.dts  |  23 +
>  drivers/of/unittest-data/overlay_gpio_02a.dts |  16 +
>  drivers/of/unittest-data/overlay_gpio_02b.dts |  16 +
>  drivers/of/unittest-data/overlay_gpio_03.dts  |  23 +
>  drivers/of/unittest-data/overlay_gpio_04a.dts |  16 +
>  drivers/of/unittest-data/overlay_gpio_04b.dts |  16 +
>  drivers/of/unittest.c                         | 630 ++++++++++++++++++++++++--
>  8 files changed, 717 insertions(+), 31 deletions(-)
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_01.dts
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_02a.dts
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_02b.dts
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_03.dts
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_04a.dts
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_04b.dts
> 

Console output after patch 2/2, filtered by 'of_unittest_expect':

   ndroid Bootloader - UART_DM Initialized!!!
   [0] welcome to lk
   
   [10] platform_init()
   [10] target_init()
   [10] Display Init: Start
   [10] display_init(),target_id=10.
   [30] Config MIPI_VIDEO_PANEL.
   [30] Turn on MIPI_VIDEO_PANEL.
   [50] Video lane tested successfully
   [50] Display Init: Done
   [80] Loading keystore failed status 5 [80] ERROR: scm_protect_keystore Failed[200] USB init ept @ 0xf96b000
   [220] fastboot_init()
   [220] udc_start()
   [340] -- reset --
   [350] -- portchange --
   [460] -- reset --
   [460] -- portchange --
   [650] fastboot: processing commands
   [770] fastboot: download:00f30800
   [1260] fastboot: boot
   [1280] Found Appeneded Flattened Device tree
   [1280] cmdline: console=ttyMSM0,115200,n8 androidboot.hardware=qcom maxcpus=2 msm_rtb.filter=0x37 ehci-hcd.park=3 norandmaps androidboot.emmc=true androidboot.serialno=40081c41 androidboot.baseband=apq
   [1300] Updating device tree: start
   [1310] Updating device tree: done
   [1310] booting linux @ 0x8000, ramdisk @ 0x2000000 (9533134), tags/device tree @ 0x1e00000
   [1320] Turn off MIPI_VIDEO_PANEL.
   [1320] Continuous splash enabled, keeping panel alive.
   Booting Linux on physical CPU 0x0
   Linux version 5.5.0-00002-g7d506dfcce24 (frowand@xps8900) (gcc version 4.6.x-google 20120106 (prerelease) (GCC)) #7 SMP PREEMPT Tue Jan 28 23:10:47 CST 2020
   CPU: ARMv7 Processor [512f06f0] revision 0 (ARMv7), cr=10c5787d
   CPU: div instructions available: patching division code
   CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
   OF: fdt: Machine model: Qualcomm APQ8074 Dragonboard
   Memory policy: Data cache writealloc
   cma: Reserved 256 MiB at 0x70000000
   percpu: Embedded 19 pages/cpu s48192 r8192 d21440 u77824
   Built 1 zonelists, mobility grouping on.  Total pages: 490240
   Kernel command line: console=ttyMSM0,115200,n8 androidboot.hardware=qcom maxcpus=2 msm_rtb.filter=0x37 ehci-hcd.park=3 norandmaps androidboot.emmc=true androidboot.serialno=40081c41 androidboot.baseband=apq
   Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)
   Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
   mem auto-init: stack:off, heap alloc:off, heap free:off
   Memory: 1664560K/1967104K available (8192K kernel code, 859K rwdata, 3800K rodata, 1024K init, 268K bss, 40400K reserved, 262144K cma-reserved, 1048576K highmem)
   SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
   rcu: Preemptible hierarchical RCU implementation.
   	Tasks RCU enabled.
   rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
   NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
   random: get_random_bytes called from start_kernel+0x2fc/0x508 with crng_init=0
   arch_timer: cp15 and mmio timer(s) running at 19.20MHz (virt/virt).
   clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x46d987e47, max_idle_ns: 440795202767 ns
   sched_clock: 56 bits at 19MHz, resolution 52ns, wraps every 4398046511078ns
   Switching to timer-based delay loop, resolution 52ns
   Console: colour dummy device 80x30
   Calibrating delay loop (skipped), value calculated using timer frequency.. 38.40 BogoMIPS (lpj=192000)
   pid_max: default: 32768 minimum: 301
   Mount-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
   Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
   CPU: Testing write buffer coherency: ok
   CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
   Setting up static identity map for 0x300000 - 0x300060
   rcu: Hierarchical SRCU implementation.
   smp: Bringing up secondary CPUs ...
   CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
   smp: Brought up 1 node, 2 CPUs
   SMP: Total of 2 processors activated (76.80 BogoMIPS).
   CPU: All CPU(s) started in SVC mode.
   devtmpfs: initialized
   VFP support v0.3: implementor 51 architecture 64 part 6f variant 2 rev 0
   clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
   futex hash table entries: 1024 (order: 4, 65536 bytes, linear)
   pinctrl core: initialized pinctrl subsystem
   thermal_sys: Registered thermal governor 'step_wise'
   NET: Registered protocol family 16
   DMA: preallocated 256 KiB pool for atomic coherent allocations
   cpuidle: using governor menu
   hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
   hw-breakpoint: maximum watchpoint size is 8 bytes.
   iommu: Default domain type: Translated 
   vgaarb: loaded
   SCSI subsystem initialized
   usbcore: registered new interface driver usbfs
   usbcore: registered new interface driver hub
   usbcore: registered new device driver usb
   Advanced Linux Sound Architecture Driver Initialized.
   clocksource: Switched to clocksource arch_sys_counter
   NET: Registered protocol family 2
   tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)
   TCP established hash table entries: 8192 (order: 3, 32768 bytes, linear)
   TCP bind hash table entries: 8192 (order: 4, 65536 bytes, linear)
   TCP: Hash tables configured (established 8192 bind 8192)
   UDP hash table entries: 512 (order: 2, 16384 bytes, linear)
   UDP-Lite hash table entries: 512 (order: 2, 16384 bytes, linear)
   NET: Registered protocol family 1
   RPC: Registered named UNIX socket transport module.
   RPC: Registered udp transport module.
   RPC: Registered tcp transport module.
   RPC: Registered tcp NFSv4.1 backchannel transport module.
   PCI: CLS 0 bytes, default 64
   Trying to unpack rootfs image as initramfs...
   Freeing initrd memory: 9312K
   hw perfevents: enabled with armv7_krait PMU driver, 5 counters available
   Initialise system trusted keyrings
   workingset: timestamp_bits=30 max_order=19 bucket_order=0
   NFS: Registering the id_resolver key type
   Key type id_resolver registered
   Key type id_legacy registered
   Key type cifs.idmap registered
   jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
   fuse: init (API version 7.31)
   Key type asymmetric registered
   Asymmetric key parser 'x509' registered
   bounce: pool size: 64 pages
   Block layer SCSI generic (bsg) driver version 0.4 loaded (major 250)
   io scheduler mq-deadline registered
   io scheduler kyber registered
   msm_serial f991e000.serial: msm_serial: detected port #0
   msm_serial f991e000.serial: uartclk = 7372800
   f991e000.serial: ttyMSM0 at MMIO 0xf991e000 (irq = 28, base_baud = 460800) is a MSM
   msm_serial: console setup on port #0
   printk: console [ttyMSM0] enabled
   msm_serial: driver initialized
   brd: module loaded
   loop: module loaded
   SCSI Media Changer driver v0.25 
   spmi spmi-0: PMIC arbiter version v1 (0x20000002)
   s1: supplied by regulator-dummy
   s2: supplied by regulator-dummy
   s3: supplied by regulator-dummy
   s4: Bringing 5100000uV into 5000000-5000000uV
   l1: supplied by regulator-dummy
   l2: supplied by regulator-dummy
   l3: supplied by regulator-dummy
   l4: supplied by regulator-dummy
   l5: supplied by regulator-dummy
   l6: supplied by regulator-dummy
   l7: supplied by regulator-dummy
   l8: supplied by regulator-dummy
   l9: supplied by regulator-dummy
   l10: supplied by regulator-dummy
   l11: supplied by regulator-dummy
   l12: supplied by regulator-dummy
   l13: supplied by regulator-dummy
   l14: supplied by regulator-dummy
   l15: supplied by regulator-dummy
   l16: supplied by regulator-dummy
   l17: supplied by regulator-dummy
   l18: supplied by regulator-dummy
   l19: supplied by regulator-dummy
   l20: supplied by regulator-dummy
   l21: supplied by regulator-dummy
   l22: supplied by regulator-dummy
   l23: supplied by regulator-dummy
   l24: supplied by regulator-dummy
   lvs1: supplied by regulator-dummy
   lvs2: supplied by regulator-dummy
   lvs3: supplied by regulator-dummy
   5vs1: supplied by s4
   5vs2: supplied by s4
   libphy: Fixed MDIO Bus: probed
   SLIP: version 0.8.4-NET3.019-NEWTTY (dynamic channels, max=256) (6 bit encapsulation enabled).
   CSLIP: code copyright 1989 Regents of the University of California.
   usbcore: registered new interface driver ax88179_178a
   usbcore: registered new interface driver cdc_ether
   usbcore: registered new interface driver net1080
   usbcore: registered new interface driver cdc_subset
   usbcore: registered new interface driver cdc_ncm
   ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
   ehci-pci: EHCI PCI platform driver
   usbcore: registered new interface driver cdc_acm
   cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
   rtc-pm8xxx fc4cf000.spmi:pm8941@0:rtc@6000: registered as rtc0
   i2c /dev entries driver
   qcom-smbb fc4cf000.spmi:pm8941@0:charger@1000: Initializing SMBB rev 3
   otg-vbus: supplied by 5vs1
   cpuidle: enable-method property 'qcom,kpss-acc-v2' found operations
   cpuidle: enable-method property 'qcom,kpss-acc-v2' found operations
   cpuidle: enable-method property 'qcom,kpss-acc-v2' found operations
   cpuidle: enable-method property 'qcom,kpss-acc-v2' found operations
   sdhci: Secure Digital Host Controller Interface driver
   sdhci: Copyright(c) Pierre Ossman
   sdhci-pltfm: SDHCI platform and OF driver helper
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   usbcore: registered new interface driver usbhid
   usbhid: USB HID core driver
   oprofile: using timer interrupt.
   NET: Registered protocol family 17
   Key type dns_resolver registered
   Registering SWP/SWPB emulation handler
   Loading compiled-in X.509 certificates
   debugfs: Directory 'fc4a9000.thermal-sensor' with parent 'tsens' already present!
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   s1: supplied by regulator-dummy
   s1: Bringing 0uV into 675000-675000uV
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   s2: supplied by regulator-dummy
   rtc-pm8xxx fc4cf000.spmi:pm8941@0:rtc@6000: setting system clock to 1970-01-17T00:05:31 UTC (1382731)
-> ### dt-test ### start of unittest - you will see error messages
   s2: Bringing 0uV into 500000-500000uV
ok Duplicate name in testcase-data, renamed to "duplicate-name#1"
   s3: supplied by regulator-dummy
   s3: Bringing 0uV into 500000-500000uV
ok OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-data/phandle-tests/provider1
   s4: supplied by regulator-dummy
   s4: Bringing 0uV into 500000-500000uV
ok OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-data/phandle-tests/provider1
   s5: supplied by regulator-dummy
   s6: supplied by regulator-dummy
ok OF: /testcase-data/phandle-tests/consumer-a: could not find phandle
   s7: supplied by regulator-dummy
ok OF: /testcase-data/phandle-tests/consumer-a: could not find phandle
   s8: supplied by regulator-dummy
   s1: supplied by regulator-dummy
ok OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1
   s1: Bringing 0uV into 1300000-1300000uV
   s2: supplied by regulator-dummy
ok OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   s2: Bringing 0uV into 2150000-2150000uV
ok OF: /testcase-data/phandle-tests/consumer-b: could not get #phandle-missing-cells for /testcase-data/phandle-tests/provider1
   s3: supplied by regulator-dummy
   s3: Bringing 0uV into 1800000-1800000uV
ok OF: /testcase-data/phandle-tests/consumer-b: could not find phandle
   l1: supplied by s1
ok OF: /testcase-data/phandle-tests/consumer-b: #phandle-cells = 2 found -1
   l1: Bringing 0uV into 1225000-1225000uV
   l2: supplied by s3
ok platform testcase-data:testcase-device2: IRQ index 0 not found
   l2: Bringing 0uV into 1200000-1200000uV
   l3: supplied by s1
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest0/status
   l3: Bringing 0uV into 1225000-1225000uV
   l4: supplied by s1
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest1/status
   l4: Bringing 0uV into 1225000-1225000uV
   l5: supplied by s2
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   l5: Bringing 0uV into 1800000-1800000uV
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest2/status
   l6: supplied by s2
   l6: Bringing 0uV into 1800000-1800000uV
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest3/status
   l7: supplied by s2
   l7: Bringing 0uV into 1800000-1800000uV
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest5/status
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   l8: supplied by regulator-dummy
   l8: Bringing 0uV into 1800000-1800000uV
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest6/status
   l9: supplied by regulator-dummy
   l9: Bringing 0uV into 1800000-1800000uV
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest7/status
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   l10: supplied by regulator-dummy
   l10: Bringing 0uV into 1800000-1800000uV
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest8/status
   l11: supplied by s1
   l11: Bringing 0uV into 1300000-1300000uV
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest8/property-foo
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   l12: supplied by s2
ok OF: overlay: node_overlaps_later_cs: #6 overlaps with #7 @/testcase-data/overlay-node/test-bus/test-unittest8
   l12: Bringing 0uV into 1800000-1800000uV
ok OF: overlay: overlay #6 is not topmost
   l13: supplied by regulator-dummy
ok i2c i2c-1: Added multiplexed i2c bus 2
   l13: Bringing 0uV into 1800000-1800000uV
   l14: supplied by s2
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   l14: Bringing 0uV into 1800000-1800000uV
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest12/status
   l15: supplied by s2
   l15: Bringing 0uV into 2050000-2050000uV
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest13/status
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   l16: supplied by regulator-dummy
   l16: Bringing 0uV into 2700000-2700000uV
ok i2c i2c-1: Added multiplexed i2c bus 3
   l17: supplied by regulator-dummy
   l17: Bringing 0uV into 2700000-2700000uV
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   l18: supplied by regulator-dummy
   l18: Bringing 0uV into 2850000-2850000uV
   l19: supplied by regulator-dummy
ok GPIO line 315 (line-B-input) hogged as input
   l19: Bringing 0uV into 3300000-3300000uV
ok GPIO line 309 (line-A-input) hogged as input
   l20: supplied by regulator-dummy
   l20: Bringing 0uV into 2950000-2950000uV
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   l21: supplied by regulator-dummy
   l21: Bringing 0uV into 2950000-2950000uV
   l22: supplied by regulator-dummy
ok GPIO line 307 (line-D-input) hogged as input
   l22: Bringing 0uV into 3000000-3000000uV
   l23: supplied by regulator-dummy
   l23: Bringing 0uV into 3000000-3000000uV
** of_unittest_expect WARNING - not found ---> GPIO line <<int>> (line-C-input) hogged as input
   l24: supplied by regulator-dummy
>> ### dt-test ### FAIL of_unittest_overlay_gpio():2666 unittest_gpio_chip_request() called 0 times (expected 1 time)
   l24: Bringing 0uV into 3075000-3075000uV
   lvs1: supplied by s3
   lvs2: supplied by s3
   mmc0: SDHCI controller on f98a4900.sdhci [f98a4900.sdhci] using ADMA
   lvs3: supplied by s3
   5vs1: supplied by s4
   5vs2: supplied by s4
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/status
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/status
   mmc1: SDHCI controller on f9824900.sdhci [f9824900.sdhci] using ADMA
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/ride@100/track@30/incline-up
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/ride@100/track@40/incline-up
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/status
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/color
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/rate
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/hvac_2
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200_left
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200_right
   mmc0: new ultra high speed DDR50 SDHC card at address aaaa
   mmcblk0: mmc0:aaaa SU16G 14.8 GiB 
ok OF: overlay: ERROR: multiple fragments add and/or delete node /testcase-data-2/substation@100/motor-1/controller
    mmcblk0: p1
ok OF: overlay: ERROR: multiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/controller/name
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/motor-1/rpm_avail
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/motor-1/rpm_avail
ok OF: overlay: ERROR: multiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/rpm_avail
-> ### dt-test ### end of unittest - 258 passed, 1 failed
   ALSA device[    4.328014] mmc1: new HS200 MMC card at address 0001
   Freeing unused kernel memory: 1024K
   Run /init as init process
   mmcblk1: mmc1:0001 SEM16G 14.7 GiB 
   mmcblk1boot0: mmc1:0001 SEM16G partition 1 4.00 MiB
   mmcblk1boot1: mmc1:0001 SEM16G partition 2 4.00 MiB
   mmcblk1rpmb: mmc1:0001 SEM16G partition 3 4.00 MiB, chardev (247:0)
    mmcblk1: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 p20
   mkdir: can't create directory '/bin': File exists
   mkdir: can't create directory '/dev': File exists
   /init: line 25: can't create /proc/sys/kernel/hotplug: nonexistent directory
   mdev: unknown user/group 'root:uucp' on line 34
   Attempt to mount partitions: /usr/system /usr/data
   Mounting partitions from: /dev/mmcblk1
   EXT4-fs (mmcblk1p12): mounted filesystem with ordered data mode. Opts: (null)
   random: fast init done
   EXT4-fs (mmcblk1p13): recovery complete
   EXT4-fs (mmcblk1p13): mounted filesystem with ordered data mode. Opts: (null)
   / # 
   / # cat /proc/version
   Linux version 5.5.0-00002-g7d506dfcce24 (frowand@xps8900) (gcc version 4.6.x-google 20120106 (prerelease) (GCC)) #7 SMP PREEMPT Tue Jan 28 23:10:47 CST 2020

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem
  2020-01-29  5:46 [PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem frowand.list
                   ` (3 preceding siblings ...)
  2020-01-29  6:02 ` Frank Rowand
@ 2020-01-29  6:03 ` Frank Rowand
  4 siblings, 0 replies; 9+ messages in thread
From: Frank Rowand @ 2020-01-29  6:03 UTC (permalink / raw)
  To: Rob Herring, Geert Uytterhoeven, pantelis.antoniou
  Cc: devicetree, linux-kernel, Alan Tull

On 1/28/20 11:46 PM, frowand.list@gmail.com wrote:
> From: Frank Rowand <frank.rowand@sony.com>
> 
> Geert reports that gpio hog nodes are not properly processed when
> the gpio hog node is added via an overlay reply and provides an
> RFC patch to fix the problem [1].
> 
> Add a unittest that shows the problem.  Unittest will report "1 failed"
> test before applying Geert's RFC patch and "0 failed" after applying
> Geert's RFC patch.
> 
> I did not have a development system for which it would be easy to
> experiment with applying an overlay containing a gpio hog, so I
> instead created this unittest that uses a fake gpio node.
> 
> Some tests in the devicetree unittests result in printk messages
> from the code being tested.  It can be difficult to determine
> whether the messages are the result of unittest or are potentially
> reporting bugs that should be fixed.  The most recent example of
> a person asking whether to be concerned about these messages is [2].
> 
> Patch 2 adds annotations for all messages triggered by unittests,
> except KERN_DEBUG messages.  (KERN_DEBUG is a special case due to the
> possible interaction of CONFIG_DYNAMIC_DEBUG.)
> 
> The annotations added in patch 2/2 add a small amount of verbosity
> to the console output.  I have created a proof of concept tool to
> explore (1) how test harnesses could use the annotations and
> (2) how to make the resulting console output easier to read and
> understand as a human being.  The tool 'of_unittest_expect' is
> available at https://github.com/frowand/dt_tools
> 
> The format of the annotations is expected to change when unittests
> are converted to use the kunit infrastructure when the broader
> testing community has an opportunity to discuss the implementation
> of annotations of test triggered messages.
> 
> [1] https://lore.kernel.org/linux-devicetree/20191230133852.5890-1-geert+renesas@glider.be/
> [2] https://lore.kernel.org/r/6021ac63-b5e0-ed3d-f964-7c6ef579cd68@huawei.com
> 
> Frank Rowand (2):
>   of: unittest: add overlay gpio test to catch gpio hog problem
>   of: unittest: annotate warnings triggered by unittest
> 
>  drivers/of/unittest-data/Makefile             |   8 +-
>  drivers/of/unittest-data/overlay_gpio_01.dts  |  23 +
>  drivers/of/unittest-data/overlay_gpio_02a.dts |  16 +
>  drivers/of/unittest-data/overlay_gpio_02b.dts |  16 +
>  drivers/of/unittest-data/overlay_gpio_03.dts  |  23 +
>  drivers/of/unittest-data/overlay_gpio_04a.dts |  16 +
>  drivers/of/unittest-data/overlay_gpio_04b.dts |  16 +
>  drivers/of/unittest.c                         | 630 ++++++++++++++++++++++++--
>  8 files changed, 717 insertions(+), 31 deletions(-)
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_01.dts
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_02a.dts
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_02b.dts
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_03.dts
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_04a.dts
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_04b.dts
> 

Console output after patch 2/2 _and_ Geert's RFC patches,   filtered
by 'of_unittest_expect':

   ndroid Bootloader - UART_DM Initialized!!!
   [0] welcome to lk
   
   [10] platform_init()
   [10] target_init()
   [10] Display Init: Start
   [10] display_init(),target_id=10.
   [30] Config MIPI_VIDEO_PANEL.
   [30] Turn on MIPI_VIDEO_PANEL.
   [50] Video lane tested successfully
   [50] Display Init: Done
   [80] Loading keystore failed status 5 [80] ERROR: scm_protect_keystore Failed[200] USB init ept @ 0xf96b000
   [220] fastboot_init()
   [220] udc_start()
   [340] -- reset --
   [350] -- portchange --
   [460] -- reset --
   [460] -- portchange --
   [650] fastboot: processing commands
   [780] fastboot: download:00f31000
   [1270] fastboot: boot
   [1290] Found Appeneded Flattened Device tree
   [1290] cmdline: console=ttyMSM0,115200,n8 androidboot.hardware=qcom maxcpus=2 msm_rtb.filter=0x37 ehci-hcd.park=3 norandmaps androidboot.emmc=true androidboot.serialno=40081c41 androidboot.baseband=apq
   [1310] Updating device tree: start
   [1320] Updating device tree: done
   [1320] booting linux @ 0x8000, ramdisk @ 0x2000000 (9533134), tags/device tree @ 0x1e00000
   [1330] Turn off MIPI_VIDEO_PANEL.
   [1330] Continuous splash enabled, keeping panel alive.
   Booting Linux on physical CPU 0x0
   Linux version 5.5.0-00002-g7d506dfcce24-dirty (frowand@xps8900) (gcc version 4.6.x-google 20120106 (prerelease) (GCC)) #8 SMP PREEMPT Tue Jan 28 23:13:07 CST 2020
   CPU: ARMv7 Processor [512f06f0] revision 0 (ARMv7), cr=10c5787d
   CPU: div instructions available: patching division code
   CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
   OF: fdt: Machine model: Qualcomm APQ8074 Dragonboard
   Memory policy: Data cache writealloc
   cma: Reserved 256 MiB at 0x70000000
   percpu: Embedded 19 pages/cpu s48192 r8192 d21440 u77824
   Built 1 zonelists, mobility grouping on.  Total pages: 490240
   Kernel command line: console=ttyMSM0,115200,n8 androidboot.hardware=qcom maxcpus=2 msm_rtb.filter=0x37 ehci-hcd.park=3 norandmaps androidboot.emmc=true androidboot.serialno=40081c41 androidboot.baseband=apq
   Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)
   Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
   mem auto-init: stack:off, heap alloc:off, heap free:off
   Memory: 1664560K/1967104K available (8192K kernel code, 859K rwdata, 3800K rodata, 1024K init, 268K bss, 40400K reserved, 262144K cma-reserved, 1048576K highmem)
   SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
   rcu: Preemptible hierarchical RCU implementation.
   	Tasks RCU enabled.
   rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
   NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
   random: get_random_bytes called from start_kernel+0x2fc/0x508 with crng_init=0
   arch_timer: cp15 and mmio timer(s) running at 19.20MHz (virt/virt).
   clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x46d987e47, max_idle_ns: 440795202767 ns
   sched_clock: 56 bits at 19MHz, resolution 52ns, wraps every 4398046511078ns
   Switching to timer-based delay loop, resolution 52ns
   Console: colour dummy device 80x30
   Calibrating delay loop (skipped), value calculated using timer frequency.. 38.40 BogoMIPS (lpj=192000)
   pid_max: default: 32768 minimum: 301
   Mount-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
   Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
   CPU: Testing write buffer coherency: ok
   CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
   Setting up static identity map for 0x300000 - 0x300060
   rcu: Hierarchical SRCU implementation.
   smp: Bringing up secondary CPUs ...
   CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
   smp: Brought up 1 node, 2 CPUs
   SMP: Total of 2 processors activated (76.80 BogoMIPS).
   CPU: All CPU(s) started in SVC mode.
   devtmpfs: initialized
   VFP support v0.3: implementor 51 architecture 64 part 6f variant 2 rev 0
   clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
   futex hash table entries: 1024 (order: 4, 65536 bytes, linear)
   pinctrl core: initialized pinctrl subsystem
   thermal_sys: Registered thermal governor 'step_wise'
   NET: Registered protocol family 16
   DMA: preallocated 256 KiB pool for atomic coherent allocations
   cpuidle: using governor menu
   hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
   hw-breakpoint: maximum watchpoint size is 8 bytes.
   iommu: Default domain type: Translated 
   vgaarb: loaded
   SCSI subsystem initialized
   usbcore: registered new interface driver usbfs
   usbcore: registered new interface driver hub
   usbcore: registered new device driver usb
   Advanced Linux Sound Architecture Driver Initialized.
   clocksource: Switched to clocksource arch_sys_counter
   NET: Registered protocol family 2
   tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)
   TCP established hash table entries: 8192 (order: 3, 32768 bytes, linear)
   TCP bind hash table entries: 8192 (order: 4, 65536 bytes, linear)
   TCP: Hash tables configured (established 8192 bind 8192)
   UDP hash table entries: 512 (order: 2, 16384 bytes, linear)
   UDP-Lite hash table entries: 512 (order: 2, 16384 bytes, linear)
   NET: Registered protocol family 1
   RPC: Registered named UNIX socket transport module.
   RPC: Registered udp transport module.
   RPC: Registered tcp transport module.
   RPC: Registered tcp NFSv4.1 backchannel transport module.
   PCI: CLS 0 bytes, default 64
   Trying to unpack rootfs image as initramfs...
   Freeing initrd memory: 9312K
   hw perfevents: enabled with armv7_krait PMU driver, 5 counters available
   Initialise system trusted keyrings
   workingset: timestamp_bits=30 max_order=19 bucket_order=0
   NFS: Registering the id_resolver key type
   Key type id_resolver registered
   Key type id_legacy registered
   Key type cifs.idmap registered
   jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
   fuse: init (API version 7.31)
   Key type asymmetric registered
   Asymmetric key parser 'x509' registered
   bounce: pool size: 64 pages
   Block layer SCSI generic (bsg) driver version 0.4 loaded (major 250)
   io scheduler mq-deadline registered
   io scheduler kyber registered
   msm_serial f991e000.serial: msm_serial: detected port #0
   msm_serial f991e000.serial: uartclk = 7372800
   f991e000.serial: ttyMSM0 at MMIO 0xf991e000 (irq = 28, base_baud = 460800) is a MSM
   msm_serial: console setup on port #0
   printk: console [ttyMSM0] enabled
   msm_serial: driver initialized
   brd: module loaded
   loop: module loaded
   SCSI Media Changer driver v0.25 
   spmi spmi-0: PMIC arbiter version v1 (0x20000002)
   s1: supplied by regulator-dummy
   s2: supplied by regulator-dummy
   s3: supplied by regulator-dummy
   s4: Bringing 5100000uV into 5000000-5000000uV
   l1: supplied by regulator-dummy
   l2: supplied by regulator-dummy
   l3: supplied by regulator-dummy
   l4: supplied by regulator-dummy
   l5: supplied by regulator-dummy
   l6: supplied by regulator-dummy
   l7: supplied by regulator-dummy
   l8: supplied by regulator-dummy
   l9: supplied by regulator-dummy
   l10: supplied by regulator-dummy
   l11: supplied by regulator-dummy
   l12: supplied by regulator-dummy
   l13: supplied by regulator-dummy
   l14: supplied by regulator-dummy
   l15: supplied by regulator-dummy
   l16: supplied by regulator-dummy
   l17: supplied by regulator-dummy
   l18: supplied by regulator-dummy
   l19: supplied by regulator-dummy
   l20: supplied by regulator-dummy
   l21: supplied by regulator-dummy
   l22: supplied by regulator-dummy
   l23: supplied by regulator-dummy
   l24: supplied by regulator-dummy
   lvs1: supplied by regulator-dummy
   lvs2: supplied by regulator-dummy
   lvs3: supplied by regulator-dummy
   5vs1: supplied by s4
   5vs2: supplied by s4
   libphy: Fixed MDIO Bus: probed
   SLIP: version 0.8.4-NET3.019-NEWTTY (dynamic channels, max=256) (6 bit encapsulation enabled).
   CSLIP: code copyright 1989 Regents of the University of California.
   usbcore: registered new interface driver ax88179_178a
   usbcore: registered new interface driver cdc_ether
   usbcore: registered new interface driver net1080
   usbcore: registered new interface driver cdc_subset
   usbcore: registered new interface driver cdc_ncm
   ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
   ehci-pci: EHCI PCI platform driver
   usbcore: registered new interface driver cdc_acm
   cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
   rtc-pm8xxx fc4cf000.spmi:pm8941@0:rtc@6000: registered as rtc0
   i2c /dev entries driver
   qcom-smbb fc4cf000.spmi:pm8941@0:charger@1000: Initializing SMBB rev 3
   otg-vbus: supplied by 5vs1
   cpuidle: enable-method property 'qcom,kpss-acc-v2' found operations
   cpuidle: enable-method property 'qcom,kpss-acc-v2' found operations
   cpuidle: enable-method property 'qcom,kpss-acc-v2' found operations
   cpuidle: enable-method property 'qcom,kpss-acc-v2' found operations
   sdhci: Secure Digital Host Controller Interface driver
   sdhci: Copyright(c) Pierre Ossman
   sdhci-pltfm: SDHCI platform and OF driver helper
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   usbcore: registered new interface driver usbhid
   usbhid: USB HID core driver
   oprofile: using timer interrupt.
   NET: Registered protocol family 17
   Key type dns_resolver registered
   Registering SWP/SWPB emulation handler
   Loading compiled-in X.509 certificates
   debugfs: Directory 'fc4a9000.thermal-sensor' with parent 'tsens' already present!
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   s1: supplied by regulator-dummy
   s1: Bringing 0uV into 675000-675000uV
   s2: supplied by regulator-dummy
   s2: Bringing 0uV into 500000-500000uV
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   s3: supplied by regulator-dummy
   s3: Bringing 0uV into 500000-500000uV
   s4: supplied by regulator-dummy
   s4: Bringing 0uV into 500000-500000uV
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   s5: supplied by regulator-dummy
   s6: supplied by regulator-dummy
   rtc-pm8xxx fc4cf000.spmi:pm8941@0:rtc@6000: setting system clock to 1970-01-17T00:07:48 UTC (1382868)
-> ### dt-test ### start of unittest - you will see error messages
ok Duplicate name in testcase-data, renamed to "duplicate-name#1"
   s7: supplied by regulator-dummy
   s8: supplied by regulator-dummy
ok OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-data/phandle-tests/provider1
   s1: supplied by regulator-dummy
   s1: Bringing 0uV into 1300000-1300000uV
ok OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-data/phandle-tests/provider1
   s2: supplied by regulator-dummy
   s2: Bringing 0uV into 2150000-2150000uV
ok OF: /testcase-data/phandle-tests/consumer-a: could not find phandle
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   s3: supplied by regulator-dummy
ok OF: /testcase-data/phandle-tests/consumer-a: could not find phandle
   s3: Bringing 0uV into 1800000-1800000uV
   l1: supplied by s1
ok OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1
   l1: Bringing 0uV into 1225000-1225000uV
   l2: supplied by s3
ok OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1
   l2: Bringing 0uV into 1200000-1200000uV
   l3: supplied by s1
ok OF: /testcase-data/phandle-tests/consumer-b: could not get #phandle-missing-cells for /testcase-data/phandle-tests/provider1
   l3: Bringing 0uV into 1225000-1225000uV
   l4: supplied by s1
ok OF: /testcase-data/phandle-tests/consumer-b: could not find phandle
   l4: Bringing 0uV into 1225000-1225000uV
   l5: supplied by s2
ok OF: /testcase-data/phandle-tests/consumer-b: #phandle-cells = 2 found -1
   l5: Bringing 0uV into 1800000-1800000uV
   l6: supplied by s2
ok platform testcase-data:testcase-device2: IRQ index 0 not found
   l6: Bringing 0uV into 1800000-1800000uV
   l7: supplied by s2
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest0/status
   l7: Bringing 0uV into 1800000-1800000uV
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   l8: supplied by regulator-dummy
   l8: Bringing 0uV into 1800000-1800000uV
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest1/status
   l9: supplied by regulator-dummy
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest2/status
   l9: Bringing 0uV into 1800000-1800000uV
   l10: supplied by regulator-dummy
   l10: Bringing 0uV into 1800000-1800000uV
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   l11: supplied by s1
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest3/status
   sdhci_msm f98a4900.sdhci: Got CD GPIO
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest5/status
   l11: Bringing 0uV into 1300000-1300000uV
   l12: supplied by s2
   l12: Bringing 0uV into 1800000-1800000uV
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   l13: supplied by regulator-dummy
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest6/status
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   l13: Bringing 0uV into 1800000-1800000uV
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest7/status
   l14: supplied by s2
   l14: Bringing 0uV into 1800000-1800000uV
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest8/status
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   l15: supplied by s2
   l15: Bringing 0uV into 2050000-2050000uV
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest8/property-foo
   l16: supplied by regulator-dummy
ok OF: overlay: node_overlaps_later_cs: #6 overlaps with #7 @/testcase-data/overlay-node/test-bus/test-unittest8
   l16: Bringing 0uV into 2700000-2700000uV
ok OF: overlay: overlay #6 is not topmost
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   l17: supplied by regulator-dummy
ok i2c i2c-1: Added multiplexed i2c bus 2
   l17: Bringing 0uV into 2700000-2700000uV
   l18: supplied by regulator-dummy
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest12/status
   l18: Bringing 0uV into 2850000-2850000uV
   l19: supplied by regulator-dummy
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest13/status
   l19: Bringing 0uV into 3300000-3300000uV
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   l20: supplied by regulator-dummy
   l20: Bringing 0uV into 2950000-2950000uV
ok i2c i2c-1: Added multiplexed i2c bus 3
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   l21: supplied by regulator-dummy
   l21: Bringing 0uV into 2950000-2950000uV
   l22: supplied by regulator-dummy
   l22: Bringing 0uV into 3000000-3000000uV
ok GPIO line 315 (line-B-input) hogged as input
   l23: supplied by regulator-dummy
ok GPIO line 309 (line-A-input) hogged as input
   l23: Bringing 0uV into 3000000-3000000uV
   l24: supplied by regulator-dummy
   l24: Bringing 0uV into 3075000-3075000uV
   lvs1: supplied by s3
ok GPIO line 307 (line-D-input) hogged as input
   lvs2: supplied by s3
   lvs3: supplied by s3
   mmc0: SDHCI controller on f9824900.sdhci [f9824900.sdhci] using ADMA
ok GPIO line 301 (line-C-input) hogged as input
   5vs1: supplied by s4
   sdhci_msm f98a4900.sdhci: Got CD GPIO
   5vs2: supplied by s4
   mmc1: SDHCI controller on f98a4900.sdhci [f98a4900.sdhci] using ADMA
   mmc0: new HS200 MMC card at address 0001
   mmcblk0: mmc0:0001 SEM16G 14.7 GiB 
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/status
   mmcblk0boot0: mmc0:0001 SEM16G partition 1 4.00 MiB
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/status
   mmcblk0boot1: mmc0:0001 SEM16G partition 2 4.00 MiB
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/ride@100/track@30/incline-up
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/ride@100/track@40/incline-up
   mmc1: new ultra high speed DDR50 SDHC card at address aaaa
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/status
   mmcblk0rpmb: mmc0:0001 SEM16G partition 3 4.00 MiB, chardev (247:0)
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/color
   mmcblk1: mmc1:aaaa SU16G 14.8 GiB 
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/rate
    mmcblk1: p1
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/hvac_2
    mmcblk0: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 p20
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200_left
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200_right
ok OF: overlay: ERROR: multiple fragments add and/or delete node /testcase-data-2/substation@100/motor-1/controller
ok OF: overlay: ERROR: multiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/controller/name
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/motor-1/rpm_avail
ok OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/motor-1/rpm_avail
ok OF: overlay: ERROR: multiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/rpm_avail
-> ### dt-test ### end of unittest - 259 passed, 0 failed
   ALSA devic[    4.369133] Freeing unused kernel memory: 1024K
   Run /init as init process
   mkdir: can't create directory '/bin': File exists
   mkdir: can't create directory '/dev': File exists
   /init: line 25: can't create /proc/sys/kernel/hotplug: nonexistent directory
   mdev: unknown user/group 'root:uucp' on line 34
   Attempt to mount partitions: /usr/system /usr/data
   Mounting partitions from: /dev/mmcblk0
   EXT4-fs (mmcblk0p12): mounted filesystem with ordered data mode. Opts: (null)
   random: fast init done
   EXT4-fs (mmcblk0p13): recovery complete
   EXT4-fs (mmcblk0p13): mounted filesystem with ordered data mode. Opts: (null)
   / # 
   / # cat /proc/version
   Linux version 5.5.0-00002-g7d506dfcce24-dirty (frowand@xps8900) (gcc version 4.6.x-google 20120106 (prerelease) (GCC)) #8 SMP PREEMPT Tue Jan 28 23:13:07 CST 2020 patch 2/2 _and_ Geert's RFC patches, filtered by 'of_unittest_expect':


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] of: unittest: add overlay gpio test to catch gpio hog problem
  2020-01-29  5:46 ` [PATCH 1/2] " frowand.list
@ 2020-02-19 21:56   ` Rob Herring
  2020-02-19 23:37     ` Frank Rowand
  0 siblings, 1 reply; 9+ messages in thread
From: Rob Herring @ 2020-02-19 21:56 UTC (permalink / raw)
  To: frowand.list
  Cc: Geert Uytterhoeven, pantelis.antoniou, devicetree, linux-kernel,
	Alan Tull

On Tue, Jan 28, 2020 at 11:46:04PM -0600, frowand.list@gmail.com wrote:
> From: Frank Rowand <frank.rowand@sony.com>
> 
> Geert reports that gpio hog nodes are not properly processed when
> the gpio hog node is added via an overlay reply and provides an
> RFC patch to fix the problem [1].
> 
> Add a unittest that shows the problem.  Unittest will report "1 failed"
> test before applying Geert's RFC patch and "0 failed" after applying
> Geert's RFC patch.

What's the status of that? I don't want to leave the tests failing at 
least outside of a kernel release.

> 
> [1] https://lore.kernel.org/linux-devicetree/20191230133852.5890-1-geert+renesas@glider.be/
> 
> Signed-off-by: Frank Rowand <frank.rowand@sony.com>
> ---
> 
> There are checkpatch warnings.
>   - New files are in a directory already covered by MAINTAINERS
>   - The undocumented compatibles are restricted to use by unittest
>     and should not be documented under Documentation
>   - The printk() KERN_<LEVEL> warnings are false positives.  The level
>     is supplied by a define parameter instead of a hard coded constant
>   - The lines over 80 characters are consistent with unittest.c style
> 
> This unittest was also valuable in that it allowed me to explore
> possible issues related to the proposed solution to the gpio hog
> problem.
> 
> changes since RFC:
>   - fixed node names in overlays
>   - removed unused fields from struct unittest_gpio_dev
>   - of_unittest_overlay_gpio() cleaned up comments
>   - of_unittest_overlay_gpio() moved saving global values into
>     probe_pass_count and chip_request_count more tightly around
>     test code expected to trigger changes in the global values
> 
>  drivers/of/unittest-data/Makefile             |   8 +-
>  drivers/of/unittest-data/overlay_gpio_01.dts  |  23 +++
>  drivers/of/unittest-data/overlay_gpio_02a.dts |  16 ++
>  drivers/of/unittest-data/overlay_gpio_02b.dts |  16 ++
>  drivers/of/unittest-data/overlay_gpio_03.dts  |  23 +++
>  drivers/of/unittest-data/overlay_gpio_04a.dts |  16 ++
>  drivers/of/unittest-data/overlay_gpio_04b.dts |  16 ++
>  drivers/of/unittest.c                         | 255 ++++++++++++++++++++++++++
>  8 files changed, 372 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_01.dts
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_02a.dts
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_02b.dts
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_03.dts
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_04a.dts
>  create mode 100644 drivers/of/unittest-data/overlay_gpio_04b.dts
> 
> diff --git a/drivers/of/unittest-data/Makefile b/drivers/of/unittest-data/Makefile
> index 9b6807065827..009f4045c8e4 100644
> --- a/drivers/of/unittest-data/Makefile
> +++ b/drivers/of/unittest-data/Makefile
> @@ -21,7 +21,13 @@ obj-$(CONFIG_OF_OVERLAY) += overlay.dtb.o \
>  			    overlay_bad_add_dup_prop.dtb.o \
>  			    overlay_bad_phandle.dtb.o \
>  			    overlay_bad_symbol.dtb.o \
> -			    overlay_base.dtb.o
> +			    overlay_base.dtb.o \
> +			    overlay_gpio_01.dtb.o \
> +			    overlay_gpio_02a.dtb.o \
> +			    overlay_gpio_02b.dtb.o \
> +			    overlay_gpio_03.dtb.o \
> +			    overlay_gpio_04a.dtb.o \
> +			    overlay_gpio_04b.dtb.o
>  
>  # enable creation of __symbols__ node
>  DTC_FLAGS_overlay += -@
> diff --git a/drivers/of/unittest-data/overlay_gpio_01.dts b/drivers/of/unittest-data/overlay_gpio_01.dts
> new file mode 100644
> index 000000000000..f039e8bce3b6
> --- /dev/null
> +++ b/drivers/of/unittest-data/overlay_gpio_01.dts
> @@ -0,0 +1,23 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/dts-v1/;
> +/plugin/;
> +
> +&unittest_test_bus {
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +	gpio_01 {

Missing unit address:

gpio@0


> +		compatible = "unittest-gpio";
> +		reg = <0>;
> +		gpio-controller;
> +		#gpio-cells = <2>;
> +		ngpios = <2>;
> +		gpio-line-names = "line-A", "line-B";
> +
> +		line_b {

Don't use '_'.

line-b

> +			gpio-hog;
> +			gpios = <2 0>;
> +			input;
> +			line-name = "line-B-input";
> +		};
> +	};
> +};
> diff --git a/drivers/of/unittest-data/overlay_gpio_02a.dts b/drivers/of/unittest-data/overlay_gpio_02a.dts
> new file mode 100644
> index 000000000000..cdafab604793
> --- /dev/null
> +++ b/drivers/of/unittest-data/overlay_gpio_02a.dts
> @@ -0,0 +1,16 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/dts-v1/;
> +/plugin/;
> +
> +&unittest_test_bus {
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +	gpio_02 {

gpio@1

...and a few more.

> +		compatible = "unittest-gpio";
> +		reg = <1>;
> +		gpio-controller;
> +		#gpio-cells = <2>;
> +		ngpios = <2>;
> +		gpio-line-names = "line-A", "line-B";
> +	};
> +};

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] of: unittest: add overlay gpio test to catch gpio hog problem
  2020-02-19 21:56   ` Rob Herring
@ 2020-02-19 23:37     ` Frank Rowand
  2020-02-20 18:53       ` Frank Rowand
  0 siblings, 1 reply; 9+ messages in thread
From: Frank Rowand @ 2020-02-19 23:37 UTC (permalink / raw)
  To: Rob Herring
  Cc: Geert Uytterhoeven, pantelis.antoniou, devicetree, linux-kernel,
	Alan Tull

On 2/19/20 3:56 PM, Rob Herring wrote:
> On Tue, Jan 28, 2020 at 11:46:04PM -0600, frowand.list@gmail.com wrote:
>> From: Frank Rowand <frank.rowand@sony.com>
>>
>> Geert reports that gpio hog nodes are not properly processed when
>> the gpio hog node is added via an overlay reply and provides an
>> RFC patch to fix the problem [1].
>>
>> Add a unittest that shows the problem.  Unittest will report "1 failed"
>> test before applying Geert's RFC patch and "0 failed" after applying
>> Geert's RFC patch.
> 
> What's the status of that? I don't want to leave the tests failing at 
> least outside of a kernel release.

I agree.  I would like to see my patches applied, showing the test fail,
immediately followed by Geert's fix.  So my series should not go in
until Geert's patch is ready.

> 
>>
>> [1] https://lore.kernel.org/linux-devicetree/20191230133852.5890-1-geert+renesas@glider.be/
>>
>> Signed-off-by: Frank Rowand <frank.rowand@sony.com>
>> ---
>>
>> There are checkpatch warnings.
>>   - New files are in a directory already covered by MAINTAINERS
>>   - The undocumented compatibles are restricted to use by unittest
>>     and should not be documented under Documentation
>>   - The printk() KERN_<LEVEL> warnings are false positives.  The level
>>     is supplied by a define parameter instead of a hard coded constant
>>   - The lines over 80 characters are consistent with unittest.c style
>>
>> This unittest was also valuable in that it allowed me to explore
>> possible issues related to the proposed solution to the gpio hog
>> problem.
>>
>> changes since RFC:
>>   - fixed node names in overlays
>>   - removed unused fields from struct unittest_gpio_dev
>>   - of_unittest_overlay_gpio() cleaned up comments
>>   - of_unittest_overlay_gpio() moved saving global values into
>>     probe_pass_count and chip_request_count more tightly around
>>     test code expected to trigger changes in the global values
>>
>>  drivers/of/unittest-data/Makefile             |   8 +-
>>  drivers/of/unittest-data/overlay_gpio_01.dts  |  23 +++
>>  drivers/of/unittest-data/overlay_gpio_02a.dts |  16 ++
>>  drivers/of/unittest-data/overlay_gpio_02b.dts |  16 ++
>>  drivers/of/unittest-data/overlay_gpio_03.dts  |  23 +++
>>  drivers/of/unittest-data/overlay_gpio_04a.dts |  16 ++
>>  drivers/of/unittest-data/overlay_gpio_04b.dts |  16 ++
>>  drivers/of/unittest.c                         | 255 ++++++++++++++++++++++++++
>>  8 files changed, 372 insertions(+), 1 deletion(-)
>>  create mode 100644 drivers/of/unittest-data/overlay_gpio_01.dts
>>  create mode 100644 drivers/of/unittest-data/overlay_gpio_02a.dts
>>  create mode 100644 drivers/of/unittest-data/overlay_gpio_02b.dts
>>  create mode 100644 drivers/of/unittest-data/overlay_gpio_03.dts
>>  create mode 100644 drivers/of/unittest-data/overlay_gpio_04a.dts
>>  create mode 100644 drivers/of/unittest-data/overlay_gpio_04b.dts
>>
>> diff --git a/drivers/of/unittest-data/Makefile b/drivers/of/unittest-data/Makefile
>> index 9b6807065827..009f4045c8e4 100644
>> --- a/drivers/of/unittest-data/Makefile
>> +++ b/drivers/of/unittest-data/Makefile
>> @@ -21,7 +21,13 @@ obj-$(CONFIG_OF_OVERLAY) += overlay.dtb.o \
>>  			    overlay_bad_add_dup_prop.dtb.o \
>>  			    overlay_bad_phandle.dtb.o \
>>  			    overlay_bad_symbol.dtb.o \
>> -			    overlay_base.dtb.o
>> +			    overlay_base.dtb.o \
>> +			    overlay_gpio_01.dtb.o \
>> +			    overlay_gpio_02a.dtb.o \
>> +			    overlay_gpio_02b.dtb.o \
>> +			    overlay_gpio_03.dtb.o \
>> +			    overlay_gpio_04a.dtb.o \
>> +			    overlay_gpio_04b.dtb.o
>>  
>>  # enable creation of __symbols__ node
>>  DTC_FLAGS_overlay += -@
>> diff --git a/drivers/of/unittest-data/overlay_gpio_01.dts b/drivers/of/unittest-data/overlay_gpio_01.dts
>> new file mode 100644
>> index 000000000000..f039e8bce3b6
>> --- /dev/null
>> +++ b/drivers/of/unittest-data/overlay_gpio_01.dts
>> @@ -0,0 +1,23 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/dts-v1/;
>> +/plugin/;
>> +
>> +&unittest_test_bus {
>> +	#address-cells = <1>;
>> +	#size-cells = <0>;
>> +	gpio_01 {
> 
> Missing unit address:
> 
> gpio@0

But my changelog claimed that I fixed that, isn't that
good enough?  :-)

/me pulls big brown paper bag over head.

And the same for all the issues you point out below, for the
second patch version in a row.

I'll re-spin on 5.6-rc1 and truly include the fixes.

-Frank


> 
> 
>> +		compatible = "unittest-gpio";
>> +		reg = <0>;
>> +		gpio-controller;
>> +		#gpio-cells = <2>;
>> +		ngpios = <2>;
>> +		gpio-line-names = "line-A", "line-B";
>> +
>> +		line_b {
> 
> Don't use '_'.
> 
> line-b
> 
>> +			gpio-hog;
>> +			gpios = <2 0>;
>> +			input;
>> +			line-name = "line-B-input";
>> +		};
>> +	};
>> +};
>> diff --git a/drivers/of/unittest-data/overlay_gpio_02a.dts b/drivers/of/unittest-data/overlay_gpio_02a.dts
>> new file mode 100644
>> index 000000000000..cdafab604793
>> --- /dev/null
>> +++ b/drivers/of/unittest-data/overlay_gpio_02a.dts
>> @@ -0,0 +1,16 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/dts-v1/;
>> +/plugin/;
>> +
>> +&unittest_test_bus {
>> +	#address-cells = <1>;
>> +	#size-cells = <0>;
>> +	gpio_02 {
> 
> gpio@1
> 
> ...and a few more.
> 
>> +		compatible = "unittest-gpio";
>> +		reg = <1>;
>> +		gpio-controller;
>> +		#gpio-cells = <2>;
>> +		ngpios = <2>;
>> +		gpio-line-names = "line-A", "line-B";
>> +	};
>> +};
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] of: unittest: add overlay gpio test to catch gpio hog problem
  2020-02-19 23:37     ` Frank Rowand
@ 2020-02-20 18:53       ` Frank Rowand
  0 siblings, 0 replies; 9+ messages in thread
From: Frank Rowand @ 2020-02-20 18:53 UTC (permalink / raw)
  To: Rob Herring
  Cc: Geert Uytterhoeven, pantelis.antoniou, devicetree, linux-kernel,
	Alan Tull

On 2/19/20 5:37 PM, Frank Rowand wrote:
> On 2/19/20 3:56 PM, Rob Herring wrote:
>> On Tue, Jan 28, 2020 at 11:46:04PM -0600, frowand.list@gmail.com wrote:
>>> From: Frank Rowand <frank.rowand@sony.com>
>>>
>>> Geert reports that gpio hog nodes are not properly processed when
>>> the gpio hog node is added via an overlay reply and provides an
>>> RFC patch to fix the problem [1].
>>>
>>> Add a unittest that shows the problem.  Unittest will report "1 failed"
>>> test before applying Geert's RFC patch and "0 failed" after applying
>>> Geert's RFC patch.
>>
>> What's the status of that? I don't want to leave the tests failing at 
>> least outside of a kernel release.
> 
> I agree.  I would like to see my patches applied, showing the test fail,
> immediately followed by Geert's fix.  So my series should not go in
> until Geert's patch is ready.

Geert has sent a v2 patch series.

I have sent a v2 of this patch, tested with v2 of Geert's patch series.

-Frank

> 
>>
>>>
>>> [1] https://lore.kernel.org/linux-devicetree/20191230133852.5890-1-geert+renesas@glider.be/
>>>
>>> Signed-off-by: Frank Rowand <frank.rowand@sony.com>
>>> ---
>>>
>>> There are checkpatch warnings.
>>>   - New files are in a directory already covered by MAINTAINERS
>>>   - The undocumented compatibles are restricted to use by unittest
>>>     and should not be documented under Documentation
>>>   - The printk() KERN_<LEVEL> warnings are false positives.  The level
>>>     is supplied by a define parameter instead of a hard coded constant
>>>   - The lines over 80 characters are consistent with unittest.c style
>>>
>>> This unittest was also valuable in that it allowed me to explore
>>> possible issues related to the proposed solution to the gpio hog
>>> problem.
>>>
>>> changes since RFC:
>>>   - fixed node names in overlays
>>>   - removed unused fields from struct unittest_gpio_dev
>>>   - of_unittest_overlay_gpio() cleaned up comments
>>>   - of_unittest_overlay_gpio() moved saving global values into
>>>     probe_pass_count and chip_request_count more tightly around
>>>     test code expected to trigger changes in the global values
>>>
>>>  drivers/of/unittest-data/Makefile             |   8 +-
>>>  drivers/of/unittest-data/overlay_gpio_01.dts  |  23 +++
>>>  drivers/of/unittest-data/overlay_gpio_02a.dts |  16 ++
>>>  drivers/of/unittest-data/overlay_gpio_02b.dts |  16 ++
>>>  drivers/of/unittest-data/overlay_gpio_03.dts  |  23 +++
>>>  drivers/of/unittest-data/overlay_gpio_04a.dts |  16 ++
>>>  drivers/of/unittest-data/overlay_gpio_04b.dts |  16 ++
>>>  drivers/of/unittest.c                         | 255 ++++++++++++++++++++++++++
>>>  8 files changed, 372 insertions(+), 1 deletion(-)
>>>  create mode 100644 drivers/of/unittest-data/overlay_gpio_01.dts
>>>  create mode 100644 drivers/of/unittest-data/overlay_gpio_02a.dts
>>>  create mode 100644 drivers/of/unittest-data/overlay_gpio_02b.dts
>>>  create mode 100644 drivers/of/unittest-data/overlay_gpio_03.dts
>>>  create mode 100644 drivers/of/unittest-data/overlay_gpio_04a.dts
>>>  create mode 100644 drivers/of/unittest-data/overlay_gpio_04b.dts
>>>
>>> diff --git a/drivers/of/unittest-data/Makefile b/drivers/of/unittest-data/Makefile
>>> index 9b6807065827..009f4045c8e4 100644
>>> --- a/drivers/of/unittest-data/Makefile
>>> +++ b/drivers/of/unittest-data/Makefile
>>> @@ -21,7 +21,13 @@ obj-$(CONFIG_OF_OVERLAY) += overlay.dtb.o \
>>>  			    overlay_bad_add_dup_prop.dtb.o \
>>>  			    overlay_bad_phandle.dtb.o \
>>>  			    overlay_bad_symbol.dtb.o \
>>> -			    overlay_base.dtb.o
>>> +			    overlay_base.dtb.o \
>>> +			    overlay_gpio_01.dtb.o \
>>> +			    overlay_gpio_02a.dtb.o \
>>> +			    overlay_gpio_02b.dtb.o \
>>> +			    overlay_gpio_03.dtb.o \
>>> +			    overlay_gpio_04a.dtb.o \
>>> +			    overlay_gpio_04b.dtb.o
>>>  
>>>  # enable creation of __symbols__ node
>>>  DTC_FLAGS_overlay += -@
>>> diff --git a/drivers/of/unittest-data/overlay_gpio_01.dts b/drivers/of/unittest-data/overlay_gpio_01.dts
>>> new file mode 100644
>>> index 000000000000..f039e8bce3b6
>>> --- /dev/null
>>> +++ b/drivers/of/unittest-data/overlay_gpio_01.dts
>>> @@ -0,0 +1,23 @@
>>> +// SPDX-License-Identifier: GPL-2.0
>>> +/dts-v1/;
>>> +/plugin/;
>>> +
>>> +&unittest_test_bus {
>>> +	#address-cells = <1>;
>>> +	#size-cells = <0>;
>>> +	gpio_01 {
>>
>> Missing unit address:
>>
>> gpio@0
> 
> But my changelog claimed that I fixed that, isn't that
> good enough?  :-)
> 
> /me pulls big brown paper bag over head.
> 
> And the same for all the issues you point out below, for the
> second patch version in a row.
> 
> I'll re-spin on 5.6-rc1 and truly include the fixes.
> 
> -Frank
> 
> 
>>
>>
>>> +		compatible = "unittest-gpio";
>>> +		reg = <0>;
>>> +		gpio-controller;
>>> +		#gpio-cells = <2>;
>>> +		ngpios = <2>;
>>> +		gpio-line-names = "line-A", "line-B";
>>> +
>>> +		line_b {
>>
>> Don't use '_'.
>>
>> line-b
>>
>>> +			gpio-hog;
>>> +			gpios = <2 0>;
>>> +			input;
>>> +			line-name = "line-B-input";
>>> +		};
>>> +	};
>>> +};
>>> diff --git a/drivers/of/unittest-data/overlay_gpio_02a.dts b/drivers/of/unittest-data/overlay_gpio_02a.dts
>>> new file mode 100644
>>> index 000000000000..cdafab604793
>>> --- /dev/null
>>> +++ b/drivers/of/unittest-data/overlay_gpio_02a.dts
>>> @@ -0,0 +1,16 @@
>>> +// SPDX-License-Identifier: GPL-2.0
>>> +/dts-v1/;
>>> +/plugin/;
>>> +
>>> +&unittest_test_bus {
>>> +	#address-cells = <1>;
>>> +	#size-cells = <0>;
>>> +	gpio_02 {
>>
>> gpio@1
>>
>> ...and a few more.
>>
>>> +		compatible = "unittest-gpio";
>>> +		reg = <1>;
>>> +		gpio-controller;
>>> +		#gpio-cells = <2>;
>>> +		ngpios = <2>;
>>> +		gpio-line-names = "line-A", "line-B";
>>> +	};
>>> +};
>>
> 
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-02-20 18:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-29  5:46 [PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem frowand.list
2020-01-29  5:46 ` [PATCH 1/2] " frowand.list
2020-02-19 21:56   ` Rob Herring
2020-02-19 23:37     ` Frank Rowand
2020-02-20 18:53       ` Frank Rowand
2020-01-29  5:46 ` [PATCH 2/2] of: unittest: annotate warnings triggered by unittest frowand.list
2020-01-29  6:01 ` [PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem Frank Rowand
2020-01-29  6:02 ` Frank Rowand
2020-01-29  6:03 ` Frank Rowand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).