Skip to contentSkip to conversation

libgpiod: fix ptests failure

PATCH New Bartosz Golaszewski 1 participant 2 messages Feb 4, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 libgpiod: fix ptests failure

From: Bartosz Golaszewski <[email protected]>

Linux kernel commit 8bd76b3d3f3a ("gpio: sim: lock up configfs that an instantiated device depends on") revealed an issue in libgpiod bindings tests where a GPIO simulator device is not disabled before removing its configfs entries.

Add a patch (already submitted upstream) that fixes the observed ptest failures.

---
 ...ts-disable-GPIO-simulator-before-rel.patch | 34 +++++++++++++++++++
 .../recipes-support/libgpiod/libgpiod_2.2.bb  |  5 ++-
 2 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-bindings-cxx-tests-disable-GPIO-simulator-before-rel.patch
meta-oe/recipes-support/libgpiod/libgpiod-2.x/0001-bindings-cxx-tests-disable-GPIO-simulator-before-rel.patch new file +34 -0
new file mode 100644
index 0000000000..9747613aa6
@@ -0,0 +1,34 @@
+From 7df2bb4f51281166633d4acbcff5763150add3fa Mon Sep 17 00:00:00 2001
+From: Bartosz Golaszewski <[email protected]>
+Date: Mon, 3 Feb 2025 13:20:41 +0100
+Subject: [PATCH] bindings: cxx: tests: disable GPIO simulator before releasing it
+
+Linux kernel commit 8bd76b3d3f3a ("gpio: sim: lock up configfs that an
+instantiated device depends on") uncovered an issue in C++ bindings
+tests where the GPIO simulator device is not disabled before removing its
+configfs entries. Add a call to gpiosim_dev_disable() to the
+gpiosim::chip's destructor.
+
+Signed-off-by: Bartosz Golaszewski <[email protected]>
+
+Upstream-Status: Submitted [https://lore.kernel.org/all/[email protected]/]
+---
+ bindings/cxx/tests/gpiosim.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/bindings/cxx/tests/gpiosim.cpp b/bindings/cxx/tests/gpiosim.cpp
+index 4bda5a2..cdecd8d 100644
+--- a/bindings/cxx/tests/gpiosim.cpp
++++ b/bindings/cxx/tests/gpiosim.cpp
+@@ -115,7 +115,7 @@ chip::chip(chip&& other)
+ 
+ chip::~chip()
+ {
+-
++	::gpiosim_dev_disable(this->_m_priv->dev.get());
+ }
+ 
+ chip& chip::operator=(chip&& other)
+-- 
+2.45.2
+
meta-oe/recipes-support/libgpiod/libgpiod_2.2.bb +4 -1
index 259ee04d28..054d378451 100644
@@ -11,7 +11,10 @@ LIC_FILES_CHKSUM = " \
 
 FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}-2.x:"
 
-SRC_URI += "file://gpio-manager.init"
+SRC_URI += " \
+    file://gpio-manager.init \
+    file://0001-bindings-cxx-tests-disable-GPIO-simulator-before-rel.patch \
+"
 
 SRC_URI[sha256sum] = "ee29735890eb1cc0e4b494001da5163d1a9c4735343201d22485db313601ca07"
 
Signature · 1 line
2.45.2
#1 lore raw

PATCH 2/2 python3-gpiod: fix ptest failure

From: Bartosz Golaszewski <[email protected]>

Linux kernel commit 8bd76b3d3f3a ("gpio: sim: lock up configfs that an instantiated device depends on") revealed an issue in libgpiod bindings tests where a GPIO simulator device is not disabled before removing its configfs entries.

Add a patch (already submitted upstream) that fixes the observed ptest failures.

---
 ...tests-disable-device-before-releasin.patch | 49 +++++++++++++++++++
 .../python/python3-gpiod_2.2.3.bb             |  5 +-
 2 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 meta-python/recipes-devtools/python/python3-gpiod/0001-bindings-python-tests-disable-device-before-releasin.patch
meta-python/recipes-devtools/python/python3-gpiod/0001-bindings-python-tests-disable-device-before-releasin.patch new file +49 -0
new file mode 100644
index 0000000000..9025e0d72d
@@ -0,0 +1,49 @@
+From ad91b034e7575074998b3e480b592e3ae6d00def Mon Sep 17 00:00:00 2001
+From: Bartosz Golaszewski <[email protected]>
+Date: Tue, 4 Feb 2025 09:36:13 +0100
+Subject: [PATCH] bindings: python: tests: disable device before releasing the
+ bank
+
+Linux kernel commit 8bd76b3d3f3a ("gpio: sim: lock up configfs that an
+instantiated device depends on") uncovered an issue in Python bindings
+tests where the GPIO simulator device is not disabled before removing its
+configfs entries. Reorder the operations in chip_finalize() in order to
+disable the device first (if needed) before releasing any other
+resources.
+
+Upstream-Status: Submitted [https://lore.kernel.org/all/[email protected]/]
+
+Signed-off-by: Bartosz Golaszewski <[email protected]>
+---
+ tests/gpiosim/ext.c | 11 ++++++-----
+ 1 file changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/tests/gpiosim/ext.c b/tests/gpiosim/ext.c
+index 272e6f7..cb5611a 100644
+--- a/tests/gpiosim/ext.c
++++ b/tests/gpiosim/ext.c
+@@ -96,15 +96,16 @@ static int chip_init(chip_object *self,
+ 
+ static void chip_finalize(chip_object *self)
+ {
+-	if (self->bank)
+-		gpiosim_bank_unref(self->bank);
+-
+ 	if (self->dev) {
+ 		if (gpiosim_dev_is_live(self->dev))
+ 			gpiosim_dev_disable(self->dev);
+-
+-		gpiosim_dev_unref(self->dev);
+ 	}
++
++	if (self->bank)
++		gpiosim_bank_unref(self->bank);
++
++	if (self->dev)
++		gpiosim_dev_unref(self->dev);
+ }
+ 
+ static void chip_dealloc(PyObject *self)
+-- 
+2.45.2
+
meta-python/recipes-devtools/python/python3-gpiod_2.2.3.bb +4 -1
index 58908ad0d5..bdc7e52ca5 100644
@@ -5,7 +5,10 @@ LICENSE = "GPL-2.0-or-later & LGPL-2.1-or-later & CC-BY-SA-4.0"
 # package is spun out.
 LIC_FILES_CHKSUM = "file://setup.py;beginline=241;endline=241;md5=f5ddb56912b7f20bf94aa4d1bdcd3533"
 
-SRC_URI += "file://run-ptest"
+SRC_URI += " \
+    file://run-ptest \
+    file://0001-bindings-python-tests-disable-device-before-releasin.patch \
+"
 
 SRC_URI[sha256sum] = "b916c3741dfc4dbcf6224b39e50765f672b137896287715709d49e9f063304c5"
 
Signature · 1 line
2.45.2