linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem
@ 2020-01-15  6:47 frowand.list
  2020-01-15  6:47 ` [RFC PATCH 1/2] " frowand.list
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: frowand.list @ 2020-01-15  6:47 UTC (permalink / raw)
  To: Rob Herring, Geert Uytterhoeven, pantelis.antoniou, 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.

This series is a work in progress and I have not properly reviewed
it yet myself.  The work behind the series has resulted in my
following several paths and distractions, resulting in more delay
than I would desire in continuing to review Geert's RFC patches.
I am thus releasing these patches as an RFC so that my work
behind the review is visible and available for Geert and other
reviewers of his patch.

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


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


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                         | 632 ++++++++++++++++++++++++--
 8 files changed, 719 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] 11+ messages in thread

* [RFC PATCH 1/2] of: unittest: add overlay gpio test to catch gpio hog problem
  2020-01-15  6:47 [RFC PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem frowand.list
@ 2020-01-15  6:47 ` frowand.list
  2020-01-21 23:02   ` Rob Herring
  2020-01-15  6:47 ` [RFC PATCH 2/2] of: unittest: annotate warnings triggered by unittest frowand.list
  2020-01-15 17:28 ` [RFC PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem Frank Rowand
  2 siblings, 1 reply; 11+ messages in thread
From: frowand.list @ 2020-01-15  6:47 UTC (permalink / raw)
  To: Rob Herring, Geert Uytterhoeven, pantelis.antoniou, 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.
  - The lines over 80 characters are consistent with unittest.c style
  - The undocumented compatibles are restricted to use by unittest
    and should not be documented under Documentation

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

 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                         | 257 ++++++++++++++++++++++++++
 8 files changed, 374 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..db0a6f4103a4 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,153 @@ 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
+	 */
+
+	probe_pass_count = unittest_gpio_probe_pass_count;
+	chip_request_count = unittest_gpio_chip_request_count;
+
+	/*
+	 * 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
+	 */
+
+	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");
+
+	/*
+	 * messages are the result of the probes, after the
+	 * driver is registered
+	 */
+
+	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");
+
+	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.
+	 *
+	 * overlay_gpio_03 contains gpio node and child gpio hog node
+	 *
+	 * - apply overlay_gpio_03
+	 *
+	 * apply overlay will result in
+	 *   - probe and processing gpio hog.
+	 */
+
+	probe_pass_count = unittest_gpio_probe_pass_count;
+	chip_request_count = unittest_gpio_chip_request_count;
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "GPIO line <<int>> (line-D-input) hogged as input\n");
+
+	/* overlay_gpio_03 contains gpio node and child gpio hog node */
+
+	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);
+
+	/*
+	 * overlay_gpio_04a contains gpio node
+	 *
+	 * - apply overlay_gpio_04a
+	 *
+	 * apply the overlay will result in
+	 *   - probe for overlay_gpio_04a
+	 */
+
+	probe_pass_count = unittest_gpio_probe_pass_count;
+	chip_request_count = unittest_gpio_chip_request_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");
+
+	/*
+	 * overlay_gpio_04b contains child gpio hog node
+	 *
+	 * - apply overlay_gpio_04b
+	 *
+	 * apply the overlay will result in
+	 *   - processing gpio for overlay_gpio_04b
+	 */
+
+	EXPECT_BEGIN(KERN_INFO,
+		     "GPIO line <<int>> (line-C-input) hogged as input\n");
+
+	/* overlay_gpio_04b contains child gpio hog node */
+
+	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 +2485,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 +2540,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 +2570,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] 11+ messages in thread

* [RFC PATCH 2/2] of: unittest: annotate warnings triggered by unittest
  2020-01-15  6:47 [RFC PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem frowand.list
  2020-01-15  6:47 ` [RFC PATCH 1/2] " frowand.list
@ 2020-01-15  6:47 ` frowand.list
  2020-01-15 17:28 ` [RFC PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem Frank Rowand
  2 siblings, 0 replies; 11+ messages in thread
From: frowand.list @ 2020-01-15  6:47 UTC (permalink / raw)
  To: Rob Herring, Geert Uytterhoeven, pantelis.antoniou, 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 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>
---
 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 db0a6f4103a4..d15cb3e1feb7 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);
@@ -2727,6 +2969,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");
@@ -2841,15 +3084,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");
 
@@ -2873,6 +3187,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))
@@ -2891,7 +3207,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] 11+ messages in thread

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

On 1/15/20 12:47 AM, 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.
> 
> This series is a work in progress and I have not properly reviewed
> it yet myself.  The work behind the series has resulted in my
> following several paths and distractions, resulting in more delay
> than I would desire in continuing to review Geert's RFC patches.
> I am thus releasing these patches as an RFC so that my work
> behind the review is visible and available for Geert and other
> reviewers of his patch.
> 
> 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
> 

I will reply to this email with examples of console boot message
changes as a result of this patch series.

(1) boot before patches
(2) boot after this patch series
(3) messages from (2) processed by of_unittest_expect
(4) meesages from boot after Geert's patches on top of this patch
    series processed by of_unittest_expect

-Frank

> 
> [1] https://lore.kernel.org/linux-devicetree/20191230133852.5890-1-geert+renesas@glider.be/
> 
> 
> 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                         | 632 ++++++++++++++++++++++++--
>  8 files changed, 719 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
> 


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

* Re: [RFC PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem
  2020-01-15 17:28 ` [RFC PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem Frank Rowand
@ 2020-01-15 18:03   ` Frank Rowand
  2020-01-15 18:03   ` Frank Rowand
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Frank Rowand @ 2020-01-15 18:03 UTC (permalink / raw)
  To: Rob Herring, Geert Uytterhoeven, pantelis.antoniou, Pantelis Antoniou
  Cc: devicetree, linux-kernel, Alan Tull

On 1/15/20 11:28 AM, Frank Rowand wrote:
> On 1/15/20 12:47 AM, frowand.list@gmail.com wrote:
>> From: Frank Rowand <frank.rowand@sony.com>

< snip >

> I will reply to this email with examples of console boot message
> changes as a result of this patch series.
> 
> (1) boot before patches
> (2) boot after this patch series
> (3) messages from (2) processed by of_unittest_expect
> (4) messages from boot after Geert's patches on top of this patch
>     series processed by of_unittest_expect

< snip >

(1) boot before patches

============================================================

Android 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 --
[590] fastboot: processing commands
[750] fastboot: download:00f2f000
[1250] fastboot: boot
[1270] Found Appeneded Flattened Device tree
[1270] 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
[1290] Updating device tree: start
[1290] Updating device tree: done
[1300] booting linux @ 0x8000, ramdisk @ 0x2000000 (9533134), tags/device tree @ 0x1e00000
[1300] Turn off MIPI_VIDEO_PANEL.
[1300] Continuous splash enabled, keeping panel alive.
Booting Linux on physical CPU 0x0
Linux version 5.5.0-rc2 (frowand@xps8900) (gcc version 4.6.x-google 20120106 (prerelease) (GCC)) #27 SMP PREEMPT Wed Jan 15 11:15:34 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: 1664564K/1967104K available (8192K kernel code, 858K rwdata, 3788K rodata, 1024K init, 268K bss, 40396K 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
sdhci_msm f98a4900.sdhci: Got CD GPIO
s2: supplied by regulator-dummy
s2: Bringing 0uV into 500000-500000uV
s3: supplied by regulator-dummy
s3: Bringing 0uV into 500000-500000uV
sdhci_msm f98a4900.sdhci: Got CD GPIO
rtc-pm8xxx fc4cf000.spmi:pm8941@0:rtc@6000: setting system clock to 1970-01-03T12:10:11 UTC (216611)
Duplicate name in testcase-data, renamed to "duplicate-name#1"
s4: supplied by regulator-dummy
### dt-test ### start of unittest - you will see error messages
s4: Bringing 0uV into 500000-500000uV
OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-data/phandle-tests/provider1
s5: supplied by regulator-dummy
OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-data/phandle-tests/provider1
s6: supplied by regulator-dummy
OF: /testcase-data/phandle-tests/consumer-a: could not find phandle
s7: supplied by regulator-dummy
OF: /testcase-data/phandle-tests/consumer-a: could not find phandle
s8: supplied by regulator-dummy
OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1
s1: supplied by regulator-dummy
OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1
s1: Bringing 0uV into 1300000-1300000uV
OF: /testcase-data/phandle-tests/consumer-b: could not get #phandle-missing-cells for /testcase-data/phandle-tests/provider1
s2: supplied by regulator-dummy
OF: /testcase-data/phandle-tests/consumer-b: could not find phandle
sdhci_msm f98a4900.sdhci: Got CD GPIO
OF: /testcase-data/phandle-tests/consumer-b: #phandle-cells = 2 found -1
s2: Bringing 0uV into 2150000-2150000uV
platform testcase-data:testcase-device2: IRQ index 0 not found
s3: supplied by regulator-dummy
OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest0/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-unittest1/status
l1: supplied by s1
OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest2/status
l1: Bringing 0uV into 1225000-1225000uV
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
OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest5/status
l2: supplied by s3
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
OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest7/status
l2: Bringing 0uV into 1200000-1200000uV
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
l3: supplied by s1
OF: overlay: node_overlaps_later_cs: #6 overlaps with #7 @/testcase-data/overlay-node/test-bus/test-unittest8
sdhci_msm f98a4900.sdhci: Got CD GPIO
OF: overlay: overlay #6 is not topmost
l3: Bringing 0uV into 1225000-1225000uV
l4: 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
l4: 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
sdhci_msm f98a4900.sdhci: Got CD GPIO
l5: supplied by s2
i2c i2c-1: Added multiplexed i2c bus 3
l5: Bringing 0uV into 1800000-1800000uV
sdhci_msm f98a4900.sdhci: Got CD GPIO
l6: supplied by s2
l6: Bringing 0uV into 1800000-1800000uV
sdhci_msm f98a4900.sdhci: Got CD GPIO
OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/status
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
l7: supplied by s2
l7: Bringing 0uV into 1800000-1800000uV
OF: overlay: ERROR: multiple fragments add and/or delete node /testcase-data-2/substation@100/motor-1/controller
sdhci_msm f98a4900.sdhci: Got CD GPIO
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
l8: supplied by regulator-dummy
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
l8: Bringing 0uV into 1800000-1800000uV
### dt-test ### end of unittest - 242 passed, 0 failed
l9: supplied by regulator-dummy
ALSA device list:
l9: Bringing 0uV into 1800000-1800000uV
  No soundcards found.
l10: supplied by regulator-dummy
l10: Bringing 0uV into 1800000-1800000uV
l11: su�[    2.990221] l12: supplied by s2
l12: Bringing 0uV into 1800000-1800000uV
Freeing unused kernel memory: 1024K
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
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
Run /init as init process
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.117387] lvs2: supplied by s3
create directory '/dev': File exists
lvs3: supplied by s3
5vs1: supplied by s4
5vs2: supplied by s4
/init: line 25: can't create /proc/sys/kernel/hotplug: nonexistent directory
mdev: unknown user/group 'root:uucp' on line 34
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
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
mmcblk0rpmb: mmc0:0001 SEM16G partition 3 4.00 MiB, chardev (247:0)
 mmcblk0: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 p20
mmc1: new ultra high speed DDR50 SDHC card at address aaaa
mmcblk1: mmc1:aaaa SU16G 14.8 GiB 
 mmcblk1: p1
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-rc2 (frowand@xps8900) (gcc version 4.6.x-google 20120106 (prerelease) (GCC)) #27 SMP PREEMPT Wed Jan 15 11:15:34 CST 2020
/ # 

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

* Re: [RFC PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem
  2020-01-15 17:28 ` [RFC PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem Frank Rowand
  2020-01-15 18:03   ` Frank Rowand
@ 2020-01-15 18:03   ` Frank Rowand
  2020-01-15 18:04   ` Frank Rowand
  2020-01-15 18:05   ` Frank Rowand
  3 siblings, 0 replies; 11+ messages in thread
From: Frank Rowand @ 2020-01-15 18:03 UTC (permalink / raw)
  To: Rob Herring, Geert Uytterhoeven, pantelis.antoniou, Pantelis Antoniou
  Cc: devicetree, linux-kernel, Alan Tull

On 1/15/20 11:28 AM, Frank Rowand wrote:
> On 1/15/20 12:47 AM, frowand.list@gmail.com wrote:
>> From: Frank Rowand <frank.rowand@sony.com>

< snip >

> I will reply to this email with examples of console boot message
> changes as a result of this patch series.
> 
> (1) boot before patches
> (2) boot after this patch series
> (3) messages from (2) processed by of_unittest_expect
> (4) messages from boot after Geert's patches on top of this patch
>     series processed by of_unittest_expect

< snip >

2) boot after this patch series

A small amount of verbosity added to the boot messages.

The expected messages annotations are sufficient to determine
what messages are expected to be triggered by unittest, but
are not especially easy to read through and validate

============================================================

Android 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
[760] fastboot: download:00f30000
[1250] fastboot: boot
[1270] Found Appeneded Flattened Device tree
[1270] 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
[1290] Updating device tree: start
[1300] Updating device tree: done
[1300] booting linux @ 0x8000, ramdisk @ 0x2000000 (9533134), tags/device tree @ 0x1e00000
[1310] Turn off MIPI_VIDEO_PANEL.
[1310] Continuous splash enabled, keeping panel alive.
Booting Linux on physical CPU 0x0
Linux version 5.5.0-rc2-00002-gbc60035cbebc-dirty (frowand@xps8900) (gcc version 4.6.x-google 20120106 (prerelease) (GCC)) #26 SMP PREEMPT Wed Jan 15 11:12:23 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, 3804K 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-03T12:08:21 UTC (216501)
### dt-test ### start of unittest - you will see error messages
### dt-test ### EXPECT \ : Duplicate name in testcase-data, renamed to "duplicate-name#1"
Duplicate name in testcase-data, renamed to "duplicate-name#1"
s7: supplied by regulator-dummy
s8: supplied by regulator-dummy
### dt-test ### EXPECT / : Duplicate name in testcase-data, renamed to "duplicate-name#1"
### dt-test ### EXPECT \ : 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 get #phandle-cells-missing for /testcase-data/phandle-tests/provider1
### dt-test ### EXPECT / : OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-data/phandle-tests/provider1
### dt-test ### EXPECT \ : OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-data/phandle-tests/provider1
s1: supplied by regulator-dummy
OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-data/phandle-tests/provider1
s1: Bringing 0uV into 1300000-1300000uV
### dt-test ### EXPECT / : OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-data/phandle-tests/provider1
### dt-test ### EXPECT \ : OF: /testcase-data/phandle-tests/consumer-a: could not find phandle
s2: supplied by regulator-dummy
OF: /testcase-data/phandle-tests/consumer-a: could not find phandle
sdhci_msm f98a4900.sdhci: Got CD GPIO
### dt-test ### EXPECT / : OF: /testcase-data/phandle-tests/consumer-a: could not find phandle
### dt-test ### EXPECT \ : OF: /testcase-data/phandle-tests/consumer-a: could not find phandle
OF: /testcase-data/phandle-tests/consumer-a: could not find phandle
s2: Bringing 0uV into 2150000-2150000uV
### dt-test ### EXPECT / : OF: /testcase-data/phandle-tests/consumer-a: could not find phandle
### dt-test ### EXPECT \ : OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1
s3: supplied by regulator-dummy
OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1
s3: Bringing 0uV into 1800000-1800000uV
### dt-test ### EXPECT / : OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1
### dt-test ### EXPECT \ : OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1
l1: supplied by s1
OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1
l1: Bringing 0uV into 1225000-1225000uV
### dt-test ### EXPECT / : OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1
### dt-test ### EXPECT \ : OF: /testcase-data/phandle-tests/consumer-b: could not get #phandle-missing-cells for /testcase-data/phandle-tests/provider1
l2: supplied by s3
OF: /testcase-data/phandle-tests/consumer-b: could not get #phandle-missing-cells for /testcase-data/phandle-tests/provider1
### dt-test ### EXPECT / : OF: /testcase-data/phandle-tests/consumer-b: could not get #phandle-missing-cells for /testcase-data/phandle-tests/provider1
### dt-test ### EXPECT \ : OF: /testcase-data/phandle-tests/consumer-b: could not find phandle
l2: Bringing 0uV into 1200000-1200000uV
OF: /testcase-data/phandle-tests/consumer-b: could not find phandle
l3: supplied by s1
### dt-test ### EXPECT / : OF: /testcase-data/phandle-tests/consumer-b: could not find phandle
### dt-test ### EXPECT \ : OF: /testcase-data/phandle-tests/consumer-b: #phandle-cells = 2 found -1
l3: Bringing 0uV into 1225000-1225000uV
OF: /testcase-data/phandle-tests/consumer-b: #phandle-cells = 2 found -1
l4: supplied by s1
### dt-test ### EXPECT / : OF: /testcase-data/phandle-tests/consumer-b: #phandle-cells = 2 found -1
### dt-test ### EXPECT \ : platform testcase-data:testcase-device2: IRQ index 0 not found
l4: Bringing 0uV into 1225000-1225000uV
platform testcase-data:testcase-device2: IRQ index 0 not found
l5: supplied by s2
### dt-test ### EXPECT / : platform testcase-data:testcase-device2: IRQ index 0 not found
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest0/status
l5: Bringing 0uV into 1800000-1800000uV
OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest0/status
l6: supplied by s2
sdhci_msm f98a4900.sdhci: Got CD GPIO
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest0/status
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest1/status
OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest1/status
l6: Bringing 0uV into 1800000-1800000uV
l7: supplied by s2
l7: Bringing 0uV into 1800000-1800000uV
sdhci_msm f98a4900.sdhci: Got CD GPIO
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest1/status
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest2/status
l8: supplied by regulator-dummy
OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest2/status
l8: Bringing 0uV into 1800000-1800000uV
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest2/status
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest3/status
l9: supplied by regulator-dummy
OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest3/status
l9: Bringing 0uV into 1800000-1800000uV
sdhci_msm f98a4900.sdhci: Got CD GPIO
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest3/status
l10: supplied by regulator-dummy
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest5/status
OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest5/status
l10: Bringing 0uV into 1800000-1800000uV
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest5/status
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest6/status
l11: supplied by s1
OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest6/status
l11: Bringing 0uV into 1300000-1300000uV
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest6/status
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest7/status
l12: supplied by s2
OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest7/status
l12: Bringing 0uV into 1800000-1800000uV
sdhci_msm f98a4900.sdhci: Got CD GPIO
l13: supplied by regulator-dummy
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest7/status
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest8/status
l13: Bringing 0uV into 1800000-1800000uV
OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest8/status
l14: supplied by s2
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest8/status
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest8/property-foo
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
l14: Bringing 0uV into 1800000-1800000uV
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest8/property-foo
### dt-test ### EXPECT \ : OF: overlay: node_overlaps_later_cs: #6 overlaps with #7 @/testcase-data/overlay-node/test-bus/test-unittest8
### dt-test ### EXPECT \ : OF: overlay: overlay #6 is not topmost
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
### dt-test ### EXPECT / : OF: overlay: overlay #6 is not topmost
### dt-test ### EXPECT / : OF: overlay: node_overlaps_later_cs: #6 overlaps with #7 @/testcase-data/overlay-node/test-bus/test-unittest8
l15: supplied by s2
### dt-test ### EXPECT \ : i2c i2c-1: Added multiplexed i2c bus 2
i2c i2c-1: Added multiplexed i2c bus 2
l15: Bringing 0uV into 2050000-2050000uV
### dt-test ### EXPECT / : i2c i2c-1: Added multiplexed i2c bus 2
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest12/status
l16: supplied by regulator-dummy
OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest12/status
l16: Bringing 0uV into 2700000-2700000uV
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest12/status
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest13/status
l17: supplied by regulator-dummy
sdhci_msm f98a4900.sdhci: Got CD GPIO
l17: Bringing 0uV into 2700000-2700000uV
OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest13/status
l18: supplied by regulator-dummy
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest13/status
### dt-test ### EXPECT \ : i2c i2c-1: Added multiplexed i2c bus 3
l18: Bringing 0uV into 2850000-2850000uV
i2c i2c-1: Added multiplexed i2c bus 3
l19: supplied by regulator-dummy
sdhci_msm f98a4900.sdhci: Got CD GPIO
l19: Bringing 0uV into 3300000-3300000uV
### dt-test ### EXPECT / : i2c i2c-1: Added multiplexed i2c bus 3
### dt-test ### EXPECT \ : GPIO line <<int>> (line-B-input) hogged as input
l20: supplied by regulator-dummy
### dt-test ### EXPECT \ : GPIO line <<int>> (line-A-input) hogged as input
l20: Bringing 0uV into 2950000-2950000uV
GPIO line 315 (line-B-input) hogged as input
l21: supplied by regulator-dummy
GPIO line 309 (line-A-input) hogged as input
l21: Bringing 0uV into 2950000-2950000uV
### dt-test ### EXPECT / : GPIO line <<int>> (line-A-input) hogged as input
l22: supplied by regulator-dummy
### dt-test ### EXPECT / : GPIO line <<int>> (line-B-input) hogged as input
l22: Bringing 0uV into 3000000-3000000uV
### dt-test ### EXPECT \ : GPIO line <<int>> (line-D-input) hogged as input
l23: supplied by regulator-dummy
GPIO line 307 (line-D-input) hogged as input
l23: Bringing 0uV into 3000000-3000000uV
### dt-test ### EXPECT / : GPIO line <<int>> (line-D-input) hogged as input
l24: supplied by regulator-dummy
### dt-test ### EXPECT \ : GPIO line <<int>> (line-C-input) hogged as input
l24: Bringing 0uV into 3075000-3075000uV
mmc0: SDHCI controller on f9824900.sdhci [f9824900.sdhci] using ADMA
lvs1: supplied by s3
### dt-test ### EXPECT / : GPIO line <<int>> (line-C-input) hogged as input
lvs2: supplied by s3
### dt-test ### FAIL of_unittest_overlay_gpio():2668 unittest_gpio_chip_request() called 0 times (expected 1 time)
lvs3: supplied by s3
sdhci_msm f98a4900.sdhci: Got CD GPIO
5vs1: supplied by s4
5vs2: supplied by s4
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/status
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/status
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/ride@100/track@30/incline-up
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/ride@100/track@40/incline-up
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/status
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/color
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/rate
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/hvac_2
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200
mmc1: SDHCI controller on f98a4900.sdhci [f98a4900.sdhci] using ADMA
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200_left
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200_right
OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/status
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
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200_right
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200_left
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/ride_200
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/hvac_2
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/rate
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/color
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/lights@40000/status
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/ride@100/track@40/incline-up
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/ride@100/track@30/incline-up
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/status
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/status
### dt-test ### EXPECT \ : OF: overlay: ERROR: multiple fragments add and/or delete node /testcase-data-2/substation@100/motor-1/controller
### dt-test ### EXPECT \ : OF: overlay: ERROR: multiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/controller/name
OF: overlay: ERROR: multiple fragments add and/or delete node /testcase-data-2/substation@100/motor-1/controller
OF: overlay: ERROR: multiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/controller/name
### dt-test ### EXPECT / : OF: overlay: ERROR: multiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/controller/name
### dt-test ### EXPECT / : OF: overlay: ERROR: multiple fragments add and/or delete node /testcase-data-2/substation@100/motor-1/controller
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/motor-1/rpm_avail
### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/motor-1/rpm_avail
### dt-test ### EXPECT \ : OF: overlay: ERROR: multiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/rpm_avail
mmc1: new ultra high speed DDR50 SDHC card at address aaaa
OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/motor-1/rpm_avail
mmcblk1: mmc1:aaaa SU16G 14.8 GiB 
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
 mmcblk1: p1
### dt-test ### EXPECT / : OF: overlay: ERROR: multiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/rpm_avail
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/motor-1/rpm_avail
### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/motor-1/rpm_avail
### dt-test ### end of unittest - 258 passed, 1 failed
mmc0: new HS200 MMC card at address 0001
ALSA device list:
  No soundcards found.
mmcblk0: mmc0:0001 SEM16[    4.341533] mmcblk0boot1: mmc0:0001 SEM16G partition 2 4.00 MiB
mmcblk0rpmb: mmc0:0001 SEM16G partition 3 4.00 MiB, chardev (247:0)
Freeing unused kernel memory: 1024K
Run /init as init process
 mmcblk0: 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/mmcblk0
EXT4-fs (mmcblk0p12): mounted filesystem with ordered data mode. Opts: (null)
EXT4-fs (mmcblk0p13): recovery complete
EXT4-fs (mmcblk0p13): mounted filesystem with ordered data mode. Opts: (null)
/ # [    5.288378] random: fast init done

/ # cat /proc/version
Linux version 5.5.0-rc2-00002-gbc60035cbebc-dirty (frowand@xps8900) (gcc version 4.6.x-google 20120106 (prerelease) (GCC)) #26 SMP PREEMPT Wed Jan 15 11:12:23 CST 2020
/ # 

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

* Re: [RFC PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem
  2020-01-15 17:28 ` [RFC PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem Frank Rowand
  2020-01-15 18:03   ` Frank Rowand
  2020-01-15 18:03   ` Frank Rowand
@ 2020-01-15 18:04   ` Frank Rowand
  2020-01-15 18:05   ` Frank Rowand
  3 siblings, 0 replies; 11+ messages in thread
From: Frank Rowand @ 2020-01-15 18:04 UTC (permalink / raw)
  To: Rob Herring, Geert Uytterhoeven, pantelis.antoniou, Pantelis Antoniou
  Cc: devicetree, linux-kernel, Alan Tull

On 1/15/20 11:28 AM, Frank Rowand wrote:
> On 1/15/20 12:47 AM, frowand.list@gmail.com wrote:
>> From: Frank Rowand <frank.rowand@sony.com>

< snip >

> I will reply to this email with examples of console boot message
> changes as a result of this patch series.
> 
> (1) boot before patches
> (2) boot after this patch series
> (3) messages from (2) processed by of_unittest_expect
> (4) messages from boot after Geert's patches on top of this patch
>     series processed by of_unittest_expect

< snip >

(3) messages from (2) processed by of_unittest_expect

Much easier to read than (2).  The first two columns contain
flags to point out lines that might be interesting.  This version
of of_unittest_expect has five spaces following the flag columns,
that will be fixed to be one space.

  EXPECT begin and EXPECT end lines are suppressed.
  Lines that match an EXPECT line are flagged with a leading 'ok'.
  Lines reporting a of_unittest_expect warning or error are flagged with a leading '**'.
  Lines reporting start or end of the unittests are flagged with a leading '->'.
  Lines reporting a unittest test FAIL are flagged with a leading '>>'.

The lines with a leading '**' are reporting that an expected message
was not found.  The messages do exist, but of_unittest_expect is not
yet smart enough to realize that '<<int>>' in the EXPECT messages are
meant to match an integer value.

The new unittest fail message to show the issue that Geert reported
is flagged with the leading '>>'.

The various messages triggered by unittest are flagged with 'ok'.

============================================================

       Android 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
       [760] fastboot: download:00f30000
       [1250] fastboot: boot
       [1270] Found Appeneded Flattened Device tree
       [1270] 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
       [1290] Updating device tree: start
       [1300] Updating device tree: done
       [1300] booting linux @ 0x8000, ramdisk @ 0x2000000 (9533134), tags/device tree @ 0x1e00000
       [1310] Turn off MIPI_VIDEO_PANEL.
       [1310] Continuous splash enabled, keeping panel alive.
       Booting Linux on physical CPU 0x0
       Linux version 5.5.0-rc2-00002-gbc60035cbebc-dirty (frowand@xps8900) (gcc version 4.6.x-google 20120106 (prerelease) (GCC)) #26 SMP PREEMPT Wed Jan 15 11:12:23 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, 3804K 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-03T12:08:21 UTC (216501)
->     ### 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
ok     OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-data/phandle-tests/provider1
       s1: Bringing 0uV into 1300000-1300000uV
       s2: supplied by regulator-dummy
ok     OF: /testcase-data/phandle-tests/consumer-a: could not find phandle
       sdhci_msm f98a4900.sdhci: Got CD GPIO
ok     OF: /testcase-data/phandle-tests/consumer-a: could not find phandle
       s2: Bringing 0uV into 2150000-2150000uV
       s3: supplied by regulator-dummy
ok     OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1
       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-b: could not get #phandle-missing-cells for /testcase-data/phandle-tests/provider1
       l2: Bringing 0uV into 1200000-1200000uV
ok     OF: /testcase-data/phandle-tests/consumer-b: could not find phandle
       l3: supplied by s1
       l3: Bringing 0uV into 1225000-1225000uV
ok     OF: /testcase-data/phandle-tests/consumer-b: #phandle-cells = 2 found -1
       l4: supplied by s1
       l4: Bringing 0uV into 1225000-1225000uV
ok     platform testcase-data:testcase-device2: IRQ index 0 not found
       l5: supplied by s2
       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-unittest0/status
       l6: supplied by s2
       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-unittest1/status
       l6: Bringing 0uV into 1800000-1800000uV
       l7: supplied by s2
       l7: Bringing 0uV into 1800000-1800000uV
       sdhci_msm f98a4900.sdhci: Got CD GPIO
       l8: 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
       l8: Bringing 0uV into 1800000-1800000uV
       l9: supplied by regulator-dummy
ok     OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest3/status
       l9: Bringing 0uV into 1800000-1800000uV
       sdhci_msm f98a4900.sdhci: Got CD GPIO
       l10: supplied by regulator-dummy
ok     OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest5/status
       l10: Bringing 0uV into 1800000-1800000uV
       l11: supplied by s1
ok     OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest6/status
       l11: Bringing 0uV into 1300000-1300000uV
       l12: supplied by s2
ok     OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest7/status
       l12: Bringing 0uV into 1800000-1800000uV
       sdhci_msm f98a4900.sdhci: Got CD GPIO
       l13: supplied by regulator-dummy
       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-unittest8/status
       l14: supplied by s2
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
       l14: Bringing 0uV into 1800000-1800000uV
ok     OF: overlay: node_overlaps_later_cs: #6 overlaps with #7 @/testcase-data/overlay-node/test-bus/test-unittest8
ok     OF: overlay: overlay #6 is not topmost
       l15: supplied by s2
ok     i2c i2c-1: Added multiplexed i2c bus 2
       l15: Bringing 0uV into 2050000-2050000uV
       l16: 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
       l16: Bringing 0uV into 2700000-2700000uV
       l17: supplied by regulator-dummy
       sdhci_msm f98a4900.sdhci: Got CD GPIO
       l17: Bringing 0uV into 2700000-2700000uV
ok     OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest13/status
       l18: supplied by regulator-dummy
       l18: Bringing 0uV into 2850000-2850000uV
ok     i2c i2c-1: Added multiplexed i2c bus 3
       l19: supplied by regulator-dummy
       sdhci_msm f98a4900.sdhci: Got CD GPIO
       l19: Bringing 0uV into 3300000-3300000uV
       l20: supplied by regulator-dummy
       l20: Bringing 0uV into 2950000-2950000uV
       GPIO line 315 (line-B-input) hogged as input
       l21: supplied by regulator-dummy
       GPIO line 309 (line-A-input) hogged as input
       l21: Bringing 0uV into 2950000-2950000uV
**     (of_unittest_expect WARNING - not found ---> ) GPIO line <<int>> (line-A-input) hogged as input
       l22: supplied by regulator-dummy
**     (of_unittest_expect WARNING - not found ---> ) GPIO line <<int>> (line-B-input) hogged as input
       l22: Bringing 0uV into 3000000-3000000uV
       l23: supplied by regulator-dummy
       GPIO line 307 (line-D-input) hogged as input
       l23: Bringing 0uV into 3000000-3000000uV
**     (of_unittest_expect WARNING - not found ---> ) GPIO line <<int>> (line-D-input) hogged as input
       l24: supplied by regulator-dummy
       l24: Bringing 0uV into 3075000-3075000uV
       mmc0: SDHCI controller on f9824900.sdhci [f9824900.sdhci] using ADMA
       lvs1: supplied by s3
**     (of_unittest_expect WARNING - not found ---> ) GPIO line <<int>> (line-C-input) hogged as input
       lvs2: supplied by s3
>>     ### dt-test ### FAIL of_unittest_overlay_gpio():2668 unittest_gpio_chip_request() called 0 times (expected 1 time)
       lvs3: supplied by s3
       sdhci_msm f98a4900.sdhci: Got CD GPIO
       5vs1: supplied by s4
       5vs2: supplied by s4
       mmc1: SDHCI controller on f98a4900.sdhci [f98a4900.sdhci] using ADMA
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
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
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
       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/substation@100/motor-1/rpm_avail
       mmcblk1: mmc1:aaaa SU16G 14.8 GiB 
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
        mmcblk1: p1
->     ### dt-test ### end of unittest - 258 passed, 1 failed
       mmc0: new HS200 MMC card at address 0001
       ALSA device list:
         No soundcards found.
       mmcblk0: mmc0:0001 SEM16[    4.341533] mmcblk0boot1: mmc0:0001 SEM16G partition 2 4.00 MiB
       mmcblk0rpmb: mmc0:0001 SEM16G partition 3 4.00 MiB, chardev (247:0)
       Freeing unused kernel memory: 1024K
       Run /init as init process
        mmcblk0: 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/mmcblk0
       EXT4-fs (mmcblk0p12): mounted filesystem with ordered data mode. Opts: (null)
       EXT4-fs (mmcblk0p13): recovery complete
       EXT4-fs (mmcblk0p13): mounted filesystem with ordered data mode. Opts: (null)
       / # [    5.288378] random: fast init done
       
       / # cat /proc/version
       Linux version 5.5.0-rc2-00002-gbc60035cbebc-dirty (frowand@xps8900) (gcc version 4.6.x-google 20120106 (prerelease) (GCC)) #26 SMP PREEMPT Wed Jan 15 11:12:23 CST 2020
       / # 

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

* Re: [RFC PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem
  2020-01-15 17:28 ` [RFC PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem Frank Rowand
                     ` (2 preceding siblings ...)
  2020-01-15 18:04   ` Frank Rowand
@ 2020-01-15 18:05   ` Frank Rowand
  3 siblings, 0 replies; 11+ messages in thread
From: Frank Rowand @ 2020-01-15 18:05 UTC (permalink / raw)
  To: Rob Herring, Geert Uytterhoeven, pantelis.antoniou, Pantelis Antoniou
  Cc: devicetree, linux-kernel, Alan Tull

On 1/15/20 11:28 AM, Frank Rowand wrote:
> On 1/15/20 12:47 AM, frowand.list@gmail.com wrote:
>> From: Frank Rowand <frank.rowand@sony.com>

< snip >

> (1) boot before patches
> (2) boot after this patch series
> (3) messages from (2) processed by of_unittest_expect
> (4) messages from boot after Geert's patches on top of this patch
>     series processed by of_unittest_expect

< snip >

4) messages from boot after Geert's patches on top of this patch
   series processed by of_unittest_expect

No unittest fails, so the line flagged with '>>' in (3) is no
longer present.

============================================================

       Android 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 --
       [590] fastboot: processing commands
       [750] fastboot: download:00f30000
       [1250] fastboot: boot
       [1260] Found Appeneded Flattened Device tree
       [1270] 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
       [1280] Updating device tree: start
       [1290] Updating device tree: done
       [1290] booting linux @ 0x8000, ramdisk @ 0x2000000 (9533134), tags/device tree @ 0x1e00000
       [1300] Turn off MIPI_VIDEO_PANEL.
       [1300] Continuous splash enabled, keeping panel alive.
       Booting Linux on physical CPU 0x0
       Linux version 5.5.0-rc2-00002-gbc60035cbebc-dirty (frowand@xps8900) (gcc version 4.6.x-google 20120106 (prerelease) (GCC)) #25 SMP PREEMPT Wed Jan 15 00:19:58 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, 3804K 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
       rtc-pm8xxx fc4cf000.spmi:pm8941@0:rtc@6000: setting system clock to 1970-01-03T01:15:24 UTC (177324)
->     ### dt-test ### start of unittest - you will see error messages
       s1: supplied by regulator-dummy
ok     Duplicate name in testcase-data, renamed to "duplicate-name#1"
       s1: Bringing 0uV into 675000-675000uV
       s2: supplied by regulator-dummy
ok     OF: /testcase-data/phandle-tests/consumer-a: could not get #phandle-cells-missing for /testcase-data/phandle-tests/provider1
       s2: 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
       s3: supplied by regulator-dummy
ok     OF: /testcase-data/phandle-tests/consumer-a: could not find phandle
       s3: Bringing 0uV into 500000-500000uV
ok     OF: /testcase-data/phandle-tests/consumer-a: could not find phandle
       s4: supplied by regulator-dummy
ok     OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1
       s4: Bringing 0uV into 500000-500000uV
       s5: supplied by regulator-dummy
ok     OF: /testcase-data/phandle-tests/consumer-a: #phandle-cells = 3 found -1
       s6: supplied by regulator-dummy
ok     OF: /testcase-data/phandle-tests/consumer-b: could not get #phandle-missing-cells for /testcase-data/phandle-tests/provider1
       s7: supplied by regulator-dummy
ok     OF: /testcase-data/phandle-tests/consumer-b: could not find phandle
       s8: supplied by regulator-dummy
       s1: supplied by regulator-dummy
ok     OF: /testcase-data/phandle-tests/consumer-b: #phandle-cells = 2 found -1
       s1: Bringing 0uV into 1300000-1300000uV
ok     platform testcase-data:testcase-device2: IRQ index 0 not found
       s2: supplied by regulator-dummy
       s2: Bringing 0uV into 2150000-2150000uV
ok     OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest0/status
       sdhci_msm f98a4900.sdhci: Got CD GPIO
       s3: supplied by regulator-dummy
ok     OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest1/status
       s3: Bringing 0uV into 1800000-1800000uV
       l1: supplied by s1
ok     OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest2/status
       l1: Bringing 0uV into 1225000-1225000uV
       l2: supplied by s3
ok     OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest3/status
       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-unittest5/status
       sdhci_msm f98a4900.sdhci: Got CD GPIO
       l3: Bringing 0uV into 1225000-1225000uV
ok     OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest6/status
       l4: supplied by s1
ok     OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest7/status
       l4: Bringing 0uV into 1225000-1225000uV
       l5: supplied by s2
ok     OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest8/status
       l5: Bringing 0uV into 1800000-1800000uV
       l6: supplied by s2
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
       l6: Bringing 0uV into 1800000-1800000uV
ok     OF: overlay: node_overlaps_later_cs: #6 overlaps with #7 @/testcase-data/overlay-node/test-bus/test-unittest8
ok     OF: overlay: overlay #6 is not topmost
       l7: supplied by s2
ok     i2c i2c-1: Added multiplexed i2c bus 2
       l7: Bringing 0uV into 1800000-1800000uV
       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/i2c-test-bus/test-unittest12/status
       l8: 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
       sdhci_msm f98a4900.sdhci: Got CD GPIO
       l8: Bringing 0uV into 1800000-1800000uV
ok     i2c i2c-1: Added multiplexed i2c bus 3
       sdhci_msm f98a4900.sdhci: Got CD GPIO
       l9: supplied by regulator-dummy
       l9: Bringing 0uV into 1800000-1800000uV
       GPIO line 315 (line-B-input) hogged as input
       sdhci_msm f98a4900.sdhci: Got CD GPIO
       GPIO line 309 (line-A-input) hogged as input
       sdhci_msm f98a4900.sdhci: Got CD GPIO
**     (of_unittest_expect WARNING - not found ---> ) GPIO line <<int>> (line-A-input) hogged as input
       l10: supplied by regulator-dummy
**     (of_unittest_expect WARNING - not found ---> ) GPIO line <<int>> (line-B-input) hogged as input
       l10: Bringing 0uV into 1800000-1800000uV
       GPIO line 307 (line-D-input) hogged as input
       sdhci_msm f98a4900.sdhci: Got CD GPIO
**     (of_unittest_expect WARNING - not found ---> ) GPIO line <<int>> (line-D-input) hogged as input
       l11: supplied by s1
       sdhci_msm f98a4900.sdhci: Got CD GPIO
       GPIO line 301 (line-C-input) hogged as input
       l11: Bringing 0uV into 1300000-1300000uV
**     (of_unittest_expect WARNING - not found ---> ) GPIO line <<int>> (line-C-input) hogged as input
       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
ok     OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/substation@100/status
       l14: Bringing 0uV into 1800000-1800000uV
       sdhci_msm f98a4900.sdhci: Got CD GPIO
ok     OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data-2/fairway-1/status
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
       l15: supplied by s2
       l15: Bringing 0uV into 2050000-2050000uV
       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
ok     OF: overlay: ERROR: multiple fragments add and/or delete node /testcase-data-2/substation@100/motor-1/controller
       l18: Bringing 0uV into 2850000-2850000uV
ok     OF: overlay: ERROR: multiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/controller/name
       l19: supplied by regulator-dummy
       l19: Bringing 0uV into 3300000-3300000uV
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
       l20: supplied by regulator-dummy
->     ### dt-test ### end of unittest - 259 passed, 0 failed
       l20: Bringing 0uV into 2950000-2950000uV
       ALSA device list:
       l21: supplied by regulator-dummy
         No soundcard�[    4.252703] l22: supplied by regulator-dummy
       l22: Bringing 0uV into 3000000-3000000uV
       Freeing unused kernel memory: 1024K
       l23: supplied by regulator-dummy
       Run /init as init process
       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
       lvs2: supplied by s3
       lvs3: supplied by s3
       5vs1: supplied by s4
       mkdir: can't create directory '/dev': File exists
       5vs2: supplied by s4
       /init: line 25: can't create /proc/sys/kernel/hotplug: nonexistent directory
       mmc0: SDHCI controller on f9824900.sdhci [f9824900.sdhci] using ADMA
       sdhci_msm f98a4900.sdhci: Got CD GPIO
       mdev: unknown user/group 'root:uucp' on line 34
       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 
       mmcblk0boot0: mmc0:0001 SEM16G partition 1 4.00 MiB
       mmcblk0boot1: mmc0:0001 SEM16G partition 2 4.00 MiB
       mmcblk0rpmb: mmc0:0001 SEM16G partition 3 4.00 MiB, chardev (247:0)
       mmc1: new ultra high speed DDR50 SDHC card at address aaaa
        mmcblk0: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 p20
       mmcblk1: mmc1:aaaa SU16G 14.8 GiB 
        mmcblk1: p1
       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-rc2-00002-gbc60035cbebc-dirty (frowand@xps8900) (gcc version 4.6.x-google 20120106 (prerelease) (GCC)) #25 SMP PREEMPT Wed Jan 15 00:19:58 CST 2020
       / # 

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

* Re: [RFC PATCH 1/2] of: unittest: add overlay gpio test to catch gpio hog problem
  2020-01-15  6:47 ` [RFC PATCH 1/2] " frowand.list
@ 2020-01-21 23:02   ` Rob Herring
  2020-01-23  2:32     ` Frank Rowand
  2020-01-28  2:34     ` Frank Rowand
  0 siblings, 2 replies; 11+ messages in thread
From: Rob Herring @ 2020-01-21 23:02 UTC (permalink / raw)
  To: frowand.list
  Cc: Geert Uytterhoeven, pantelis.antoniou, Pantelis Antoniou,
	devicetree, linux-kernel, Alan Tull

On Wed, Jan 15, 2020 at 12:47:07AM -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.
> 
> [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.
>   - The lines over 80 characters are consistent with unittest.c style
>   - The undocumented compatibles are restricted to use by unittest
>     and should not be documented under Documentation
> 
> This unittest was also valuable in that it allowed me to explore
> possible issues related to the proposed solution to the gpio hog
> problem.
> 
>  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                         | 257 ++++++++++++++++++++++++++
>  8 files changed, 374 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 {

gpio@0

> +		compatible = "unittest-gpio";

There's a mock GPIO driver and I think there was a binding proposed at 
some point for some sort of GPIO testing device binding. Maybe that can 
save another test driver.

> +		reg = <0>;
> +		gpio-controller;
> +		#gpio-cells = <2>;
> +		ngpios = <2>;
> +		gpio-line-names = "line-A", "line-B";
> +
> +		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..db0a6f4103a4 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__)

When I first saw this, I thought of kunit...

Just wondering if this is a standard way to express this, and if not, is 
there?

> +
> +struct unittest_gpio_dev {
> +	void __iomem *base;
> +	struct gpio_chip chip;
> +	spinlock_t gpio_lock;

base and gpio_lock aren't used.

> +};
> +
> +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,153 @@ 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
> +	 */
> +
> +	probe_pass_count = unittest_gpio_probe_pass_count;
> +	chip_request_count = unittest_gpio_chip_request_count;
> +
> +	/*
> +	 * 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
> +	 */
> +
> +	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");
> +
> +	/*
> +	 * messages are the result of the probes, after the
> +	 * driver is registered
> +	 */
> +
> +	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");
> +
> +	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.
> +	 *
> +	 * overlay_gpio_03 contains gpio node and child gpio hog node
> +	 *
> +	 * - apply overlay_gpio_03
> +	 *
> +	 * apply overlay will result in
> +	 *   - probe and processing gpio hog.
> +	 */
> +
> +	probe_pass_count = unittest_gpio_probe_pass_count;
> +	chip_request_count = unittest_gpio_chip_request_count;
> +
> +	EXPECT_BEGIN(KERN_INFO,
> +		     "GPIO line <<int>> (line-D-input) hogged as input\n");
> +
> +	/* overlay_gpio_03 contains gpio node and child gpio hog node */
> +
> +	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);
> +
> +	/*
> +	 * overlay_gpio_04a contains gpio node
> +	 *
> +	 * - apply overlay_gpio_04a
> +	 *
> +	 * apply the overlay will result in
> +	 *   - probe for overlay_gpio_04a
> +	 */
> +
> +	probe_pass_count = unittest_gpio_probe_pass_count;
> +	chip_request_count = unittest_gpio_chip_request_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");
> +
> +	/*
> +	 * overlay_gpio_04b contains child gpio hog node
> +	 *
> +	 * - apply overlay_gpio_04b
> +	 *
> +	 * apply the overlay will result in
> +	 *   - processing gpio for overlay_gpio_04b
> +	 */
> +
> +	EXPECT_BEGIN(KERN_INFO,
> +		     "GPIO line <<int>> (line-C-input) hogged as input\n");
> +
> +	/* overlay_gpio_04b contains child gpio hog node */
> +
> +	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 +2485,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 +2540,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 +2570,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	[flat|nested] 11+ messages in thread

* Re: [RFC PATCH 1/2] of: unittest: add overlay gpio test to catch gpio hog problem
  2020-01-21 23:02   ` Rob Herring
@ 2020-01-23  2:32     ` Frank Rowand
  2020-01-28  2:34     ` Frank Rowand
  1 sibling, 0 replies; 11+ messages in thread
From: Frank Rowand @ 2020-01-23  2:32 UTC (permalink / raw)
  To: Rob Herring
  Cc: Geert Uytterhoeven, pantelis.antoniou, devicetree, linux-kernel,
	Alan Tull

Hi Rob,

Thanks for the corrections.

On 1/21/20 5:02 PM, Rob Herring wrote:
> On Wed, Jan 15, 2020 at 12:47:07AM -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.
>>
>> [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.
>>   - The lines over 80 characters are consistent with unittest.c style
>>   - The undocumented compatibles are restricted to use by unittest
>>     and should not be documented under Documentation
>>
>> This unittest was also valuable in that it allowed me to explore
>> possible issues related to the proposed solution to the gpio hog
>> problem.
>>
>>  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                         | 257 ++++++++++++++++++++++++++
>>  8 files changed, 374 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 {
> 
> gpio@0

Will fix, and same for other nodes.

> 
>> +		compatible = "unittest-gpio";
> 
> There's a mock GPIO driver and I think there was a binding proposed at 
> some point for some sort of GPIO testing device binding. Maybe that can 
> save another test driver.
> 
>> +		reg = <0>;
>> +		gpio-controller;
>> +		#gpio-cells = <2>;
>> +		ngpios = <2>;
>> +		gpio-line-names = "line-A", "line-B";
>> +
>> +		line_b {
> 
> line-b

Will fix, and same for other nodes.

> 
>> +			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..db0a6f4103a4 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__)
> 
> When I first saw this, I thought of kunit...
> 
> Just wondering if this is a standard way to express this, and if not, is 
> there?

Kunit does not contain this concept.  EXPECT_BEGIN() and EXPECT_END() are
reporting what messages to the console will be triggered by the test.  The
messages are outside the control of the test and are a side effect of the
test.

This is a way of annotating what warning or error messages will appear on
the console, so that someone seeing those messages on the console will
be able to determine that the messages are not reporting a bug.

This is not a concept that is in the test output standard that kunit follows.
When I modify the devicetree unittests to use the kunit infrastructure, this
is an enhancement that will need to to added to kunit.  This specific
implementation, or a variant that is more kunit aware, will be an RFC
that I will have to submit to kunit.

> 
>> +
>> +struct unittest_gpio_dev {
>> +	void __iomem *base;
>> +	struct gpio_chip chip;
>> +	spinlock_t gpio_lock;
> 
> base and gpio_lock aren't used.
> 

Removed.

-Frank

>> +};
>> +
>> +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,153 @@ 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
>> +	 */
>> +
>> +	probe_pass_count = unittest_gpio_probe_pass_count;
>> +	chip_request_count = unittest_gpio_chip_request_count;
>> +
>> +	/*
>> +	 * 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
>> +	 */
>> +
>> +	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");
>> +
>> +	/*
>> +	 * messages are the result of the probes, after the
>> +	 * driver is registered
>> +	 */
>> +
>> +	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");
>> +
>> +	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.
>> +	 *
>> +	 * overlay_gpio_03 contains gpio node and child gpio hog node
>> +	 *
>> +	 * - apply overlay_gpio_03
>> +	 *
>> +	 * apply overlay will result in
>> +	 *   - probe and processing gpio hog.
>> +	 */
>> +
>> +	probe_pass_count = unittest_gpio_probe_pass_count;
>> +	chip_request_count = unittest_gpio_chip_request_count;
>> +
>> +	EXPECT_BEGIN(KERN_INFO,
>> +		     "GPIO line <<int>> (line-D-input) hogged as input\n");
>> +
>> +	/* overlay_gpio_03 contains gpio node and child gpio hog node */
>> +
>> +	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);
>> +
>> +	/*
>> +	 * overlay_gpio_04a contains gpio node
>> +	 *
>> +	 * - apply overlay_gpio_04a
>> +	 *
>> +	 * apply the overlay will result in
>> +	 *   - probe for overlay_gpio_04a
>> +	 */
>> +
>> +	probe_pass_count = unittest_gpio_probe_pass_count;
>> +	chip_request_count = unittest_gpio_chip_request_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");
>> +
>> +	/*
>> +	 * overlay_gpio_04b contains child gpio hog node
>> +	 *
>> +	 * - apply overlay_gpio_04b
>> +	 *
>> +	 * apply the overlay will result in
>> +	 *   - processing gpio for overlay_gpio_04b
>> +	 */
>> +
>> +	EXPECT_BEGIN(KERN_INFO,
>> +		     "GPIO line <<int>> (line-C-input) hogged as input\n");
>> +
>> +	/* overlay_gpio_04b contains child gpio hog node */
>> +
>> +	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 +2485,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 +2540,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 +2570,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	[flat|nested] 11+ messages in thread

* Re: [RFC PATCH 1/2] of: unittest: add overlay gpio test to catch gpio hog problem
  2020-01-21 23:02   ` Rob Herring
  2020-01-23  2:32     ` Frank Rowand
@ 2020-01-28  2:34     ` Frank Rowand
  1 sibling, 0 replies; 11+ messages in thread
From: Frank Rowand @ 2020-01-28  2:34 UTC (permalink / raw)
  To: Rob Herring
  Cc: Geert Uytterhoeven, pantelis.antoniou, Pantelis Antoniou,
	devicetree, linux-kernel, Alan Tull

On 1/21/20 5:02 PM, Rob Herring wrote:
> On Wed, Jan 15, 2020 at 12:47:07AM -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.
>>
>> [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.
>>   - The lines over 80 characters are consistent with unittest.c style
>>   - The undocumented compatibles are restricted to use by unittest
>>     and should not be documented under Documentation
>>
>> This unittest was also valuable in that it allowed me to explore
>> possible issues related to the proposed solution to the gpio hog
>> problem.
>>
>>  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                         | 257 ++++++++++++++++++++++++++
>>  8 files changed, 374 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 {
> 
> gpio@0
> 
>> +		compatible = "unittest-gpio";
> 
> There's a mock GPIO driver and I think there was a binding proposed at 
> some point for some sort of GPIO testing device binding. Maybe that can 
> save another test driver.

I did not reply to this comment in my first reply.

Thanks for pointing out that driver, I was not aware of it.

The existing driver is way larger and more complicated than the one that
is in this patch.

I needed to add global (to unittest.c) variables to count how many times
some gpio driver functions are called to be able to determine whether
the gpio infrastructure was calling the specific functions as gpio and
gpio hog nodes were being added.  It would be pretty ugly to put those
counters in the more generic gpio test driver.

-Frank

> 
>> +		reg = <0>;
>> +		gpio-controller;
>> +		#gpio-cells = <2>;
>> +		ngpios = <2>;
>> +		gpio-line-names = "line-A", "line-B";
>> +
>> +		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..db0a6f4103a4 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__)
> 
> When I first saw this, I thought of kunit...
> 
> Just wondering if this is a standard way to express this, and if not, is 
> there?
> 
>> +
>> +struct unittest_gpio_dev {
>> +	void __iomem *base;
>> +	struct gpio_chip chip;
>> +	spinlock_t gpio_lock;
> 
> base and gpio_lock aren't used.
> 
>> +};
>> +
>> +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,153 @@ 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
>> +	 */
>> +
>> +	probe_pass_count = unittest_gpio_probe_pass_count;
>> +	chip_request_count = unittest_gpio_chip_request_count;
>> +
>> +	/*
>> +	 * 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
>> +	 */
>> +
>> +	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");
>> +
>> +	/*
>> +	 * messages are the result of the probes, after the
>> +	 * driver is registered
>> +	 */
>> +
>> +	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");
>> +
>> +	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.
>> +	 *
>> +	 * overlay_gpio_03 contains gpio node and child gpio hog node
>> +	 *
>> +	 * - apply overlay_gpio_03
>> +	 *
>> +	 * apply overlay will result in
>> +	 *   - probe and processing gpio hog.
>> +	 */
>> +
>> +	probe_pass_count = unittest_gpio_probe_pass_count;
>> +	chip_request_count = unittest_gpio_chip_request_count;
>> +
>> +	EXPECT_BEGIN(KERN_INFO,
>> +		     "GPIO line <<int>> (line-D-input) hogged as input\n");
>> +
>> +	/* overlay_gpio_03 contains gpio node and child gpio hog node */
>> +
>> +	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);
>> +
>> +	/*
>> +	 * overlay_gpio_04a contains gpio node
>> +	 *
>> +	 * - apply overlay_gpio_04a
>> +	 *
>> +	 * apply the overlay will result in
>> +	 *   - probe for overlay_gpio_04a
>> +	 */
>> +
>> +	probe_pass_count = unittest_gpio_probe_pass_count;
>> +	chip_request_count = unittest_gpio_chip_request_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");
>> +
>> +	/*
>> +	 * overlay_gpio_04b contains child gpio hog node
>> +	 *
>> +	 * - apply overlay_gpio_04b
>> +	 *
>> +	 * apply the overlay will result in
>> +	 *   - processing gpio for overlay_gpio_04b
>> +	 */
>> +
>> +	EXPECT_BEGIN(KERN_INFO,
>> +		     "GPIO line <<int>> (line-C-input) hogged as input\n");
>> +
>> +	/* overlay_gpio_04b contains child gpio hog node */
>> +
>> +	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 +2485,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 +2540,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 +2570,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	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-01-28  2:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-15  6:47 [RFC PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem frowand.list
2020-01-15  6:47 ` [RFC PATCH 1/2] " frowand.list
2020-01-21 23:02   ` Rob Herring
2020-01-23  2:32     ` Frank Rowand
2020-01-28  2:34     ` Frank Rowand
2020-01-15  6:47 ` [RFC PATCH 2/2] of: unittest: annotate warnings triggered by unittest frowand.list
2020-01-15 17:28 ` [RFC PATCH 0/2] of: unittest: add overlay gpio test to catch gpio hog problem Frank Rowand
2020-01-15 18:03   ` Frank Rowand
2020-01-15 18:03   ` Frank Rowand
2020-01-15 18:04   ` Frank Rowand
2020-01-15 18:05   ` 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).