linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH libgpiod 0/3] bindings: fix ordering of releasing of gpiosim resources
@ 2025-02-03 13:25 Bartosz Golaszewski
  2025-02-03 13:25 ` [PATCH libgpiod 1/3] bindings: cxx: tests: disable GPIO simulator before releasing it Bartosz Golaszewski
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2025-02-03 13:25 UTC (permalink / raw)
  To: Vincent Fazio, Kent Gibson, Linus Walleij, Erik Schilling,
	Phil Howard, Viresh Kumar, Koichiro Den
  Cc: Bartosz Golaszewski, linux-gpio

Linux kernel commit 8bd76b3d3f3a ("gpio: sim: lock up configfs that an
instantiated device depends on") uncovered resource management issues in
bindings tests (C++, python and rust). This series addresses them.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
Bartosz Golaszewski (3):
      bindings: cxx: tests: disable GPIO simulator before releasing it
      bindings: python: tests: disable device before releasing the bank
      bindings: rust: tests: disable device before dropping the resources

 bindings/cxx/tests/gpiosim.cpp       |  2 +-
 bindings/python/tests/gpiosim/ext.c  | 11 ++++++-----
 bindings/rust/gpiosim-sys/src/sim.rs |  6 ++++++
 3 files changed, 13 insertions(+), 6 deletions(-)
---
base-commit: d6457b28e29a8edadcb619d389878ea99cd4bab4
change-id: 20250203-fix-gpiosim-in-bindings-d6b4e041f653

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


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

* [PATCH libgpiod 1/3] bindings: cxx: tests: disable GPIO simulator before releasing it
  2025-02-03 13:25 [PATCH libgpiod 0/3] bindings: fix ordering of releasing of gpiosim resources Bartosz Golaszewski
@ 2025-02-03 13:25 ` Bartosz Golaszewski
  2025-02-03 13:25 ` [PATCH libgpiod 2/3] bindings: python: tests: disable device before releasing the bank Bartosz Golaszewski
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2025-02-03 13:25 UTC (permalink / raw)
  To: Vincent Fazio, Kent Gibson, Linus Walleij, Erik Schilling,
	Phil Howard, Viresh Kumar, Koichiro Den
  Cc: Bartosz Golaszewski, linux-gpio

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

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 <bartosz.golaszewski@linaro.org>
---
 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


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

* [PATCH libgpiod 2/3] bindings: python: tests: disable device before releasing the bank
  2025-02-03 13:25 [PATCH libgpiod 0/3] bindings: fix ordering of releasing of gpiosim resources Bartosz Golaszewski
  2025-02-03 13:25 ` [PATCH libgpiod 1/3] bindings: cxx: tests: disable GPIO simulator before releasing it Bartosz Golaszewski
@ 2025-02-03 13:25 ` Bartosz Golaszewski
  2025-02-03 13:25 ` [PATCH libgpiod 3/3] bindings: rust: tests: disable device before dropping the resources Bartosz Golaszewski
  2025-02-05 13:35 ` [PATCH libgpiod 0/3] bindings: fix ordering of releasing of gpiosim resources Bartosz Golaszewski
  3 siblings, 0 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2025-02-03 13:25 UTC (permalink / raw)
  To: Vincent Fazio, Kent Gibson, Linus Walleij, Erik Schilling,
	Phil Howard, Viresh Kumar, Koichiro Den
  Cc: Bartosz Golaszewski, linux-gpio

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

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.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 bindings/python/tests/gpiosim/ext.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/bindings/python/tests/gpiosim/ext.c b/bindings/python/tests/gpiosim/ext.c
index 272e6f7..cb5611a 100644
--- a/bindings/python/tests/gpiosim/ext.c
+++ b/bindings/python/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


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

* [PATCH libgpiod 3/3] bindings: rust: tests: disable device before dropping the resources
  2025-02-03 13:25 [PATCH libgpiod 0/3] bindings: fix ordering of releasing of gpiosim resources Bartosz Golaszewski
  2025-02-03 13:25 ` [PATCH libgpiod 1/3] bindings: cxx: tests: disable GPIO simulator before releasing it Bartosz Golaszewski
  2025-02-03 13:25 ` [PATCH libgpiod 2/3] bindings: python: tests: disable device before releasing the bank Bartosz Golaszewski
@ 2025-02-03 13:25 ` Bartosz Golaszewski
  2025-02-04  4:18   ` Viresh Kumar
  2025-02-05 13:35 ` [PATCH libgpiod 0/3] bindings: fix ordering of releasing of gpiosim resources Bartosz Golaszewski
  3 siblings, 1 reply; 7+ messages in thread
From: Bartosz Golaszewski @ 2025-02-03 13:25 UTC (permalink / raw)
  To: Vincent Fazio, Kent Gibson, Linus Walleij, Erik Schilling,
	Phil Howard, Viresh Kumar, Koichiro Den
  Cc: Bartosz Golaszewski, linux-gpio

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Linux kernel commit 8bd76b3d3f3a ("gpio: sim: lock up configfs that an
instantiated device depends on") uncovered an issue in Rust bindings
tests where the GPIO simulator device is not disabled before removing its
configfs entries. Implenent Drop for the Sim struct in order to disable
the simulator first before dropping its bank and device objects.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 bindings/rust/gpiosim-sys/src/sim.rs | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/bindings/rust/gpiosim-sys/src/sim.rs b/bindings/rust/gpiosim-sys/src/sim.rs
index 71b9453..e3cc95c 100644
--- a/bindings/rust/gpiosim-sys/src/sim.rs
+++ b/bindings/rust/gpiosim-sys/src/sim.rs
@@ -328,3 +328,9 @@ impl Sim {
         self.dev.disable()
     }
 }
+
+impl Drop for Sim {
+    fn drop(&mut self) {
+        self.dev.disable().unwrap()
+    }
+}

-- 
2.45.2


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

* Re: [PATCH libgpiod 3/3] bindings: rust: tests: disable device before dropping the resources
  2025-02-03 13:25 ` [PATCH libgpiod 3/3] bindings: rust: tests: disable device before dropping the resources Bartosz Golaszewski
@ 2025-02-04  4:18   ` Viresh Kumar
  2025-02-04  8:29     ` Bartosz Golaszewski
  0 siblings, 1 reply; 7+ messages in thread
From: Viresh Kumar @ 2025-02-04  4:18 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Vincent Fazio, Kent Gibson, Linus Walleij, Erik Schilling,
	Phil Howard, Koichiro Den, Bartosz Golaszewski, linux-gpio

On 03-02-25, 14:25, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> Linux kernel commit 8bd76b3d3f3a ("gpio: sim: lock up configfs that an
> instantiated device depends on") uncovered an issue in Rust bindings
> tests where the GPIO simulator device is not disabled before removing its
> configfs entries. Implenent Drop for the Sim struct in order to disable
> the simulator first before dropping its bank and device objects.
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
>  bindings/rust/gpiosim-sys/src/sim.rs | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/bindings/rust/gpiosim-sys/src/sim.rs b/bindings/rust/gpiosim-sys/src/sim.rs
> index 71b9453..e3cc95c 100644
> --- a/bindings/rust/gpiosim-sys/src/sim.rs
> +++ b/bindings/rust/gpiosim-sys/src/sim.rs
> @@ -328,3 +328,9 @@ impl Sim {
>          self.dev.disable()
>      }
>  }
> +
> +impl Drop for Sim {
> +    fn drop(&mut self) {
> +        self.dev.disable().unwrap()

Maybe self.disable().unwrap(), since we already have a method ?

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

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

* Re: [PATCH libgpiod 3/3] bindings: rust: tests: disable device before dropping the resources
  2025-02-04  4:18   ` Viresh Kumar
@ 2025-02-04  8:29     ` Bartosz Golaszewski
  0 siblings, 0 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2025-02-04  8:29 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Vincent Fazio, Kent Gibson, Linus Walleij, Erik Schilling,
	Phil Howard, Koichiro Den, Bartosz Golaszewski, linux-gpio

On Tue, Feb 4, 2025 at 5:18 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> On 03-02-25, 14:25, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > Linux kernel commit 8bd76b3d3f3a ("gpio: sim: lock up configfs that an
> > instantiated device depends on") uncovered an issue in Rust bindings
> > tests where the GPIO simulator device is not disabled before removing its
> > configfs entries. Implenent Drop for the Sim struct in order to disable
> > the simulator first before dropping its bank and device objects.
> >
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > ---
> >  bindings/rust/gpiosim-sys/src/sim.rs | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/bindings/rust/gpiosim-sys/src/sim.rs b/bindings/rust/gpiosim-sys/src/sim.rs
> > index 71b9453..e3cc95c 100644
> > --- a/bindings/rust/gpiosim-sys/src/sim.rs
> > +++ b/bindings/rust/gpiosim-sys/src/sim.rs
> > @@ -328,3 +328,9 @@ impl Sim {
> >          self.dev.disable()
> >      }
> >  }
> > +
> > +impl Drop for Sim {
> > +    fn drop(&mut self) {
> > +        self.dev.disable().unwrap()
>
> Maybe self.disable().unwrap(), since we already have a method ?
>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
>
> --
> viresh

Ah, right. I'll fix it when applying.

Bart

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

* Re: [PATCH libgpiod 0/3] bindings: fix ordering of releasing of gpiosim resources
  2025-02-03 13:25 [PATCH libgpiod 0/3] bindings: fix ordering of releasing of gpiosim resources Bartosz Golaszewski
                   ` (2 preceding siblings ...)
  2025-02-03 13:25 ` [PATCH libgpiod 3/3] bindings: rust: tests: disable device before dropping the resources Bartosz Golaszewski
@ 2025-02-05 13:35 ` Bartosz Golaszewski
  3 siblings, 0 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2025-02-05 13:35 UTC (permalink / raw)
  To: Vincent Fazio, Kent Gibson, Linus Walleij, Erik Schilling,
	Phil Howard, Viresh Kumar, Koichiro Den, Bartosz Golaszewski
  Cc: Bartosz Golaszewski, linux-gpio

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


On Mon, 03 Feb 2025 14:25:02 +0100, Bartosz Golaszewski wrote:
> Linux kernel commit 8bd76b3d3f3a ("gpio: sim: lock up configfs that an
> instantiated device depends on") uncovered resource management issues in
> bindings tests (C++, python and rust). This series addresses them.
> 
> 

Applied, thanks!

[1/3] bindings: cxx: tests: disable GPIO simulator before releasing it
      commit: 33a2c3dd585f5b57d7fd1f676c46194aa863b5c5
[2/3] bindings: python: tests: disable device before releasing the bank
      commit: 9949cdaf846167aa590cbb1301c8f49090651ab6
[3/3] bindings: rust: tests: disable device before dropping the resources
      commit: b376eaa86215efd725319ba3508c01d9c22dfd10

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

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

end of thread, other threads:[~2025-02-05 13:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-03 13:25 [PATCH libgpiod 0/3] bindings: fix ordering of releasing of gpiosim resources Bartosz Golaszewski
2025-02-03 13:25 ` [PATCH libgpiod 1/3] bindings: cxx: tests: disable GPIO simulator before releasing it Bartosz Golaszewski
2025-02-03 13:25 ` [PATCH libgpiod 2/3] bindings: python: tests: disable device before releasing the bank Bartosz Golaszewski
2025-02-03 13:25 ` [PATCH libgpiod 3/3] bindings: rust: tests: disable device before dropping the resources Bartosz Golaszewski
2025-02-04  4:18   ` Viresh Kumar
2025-02-04  8:29     ` Bartosz Golaszewski
2025-02-05 13:35 ` [PATCH libgpiod 0/3] bindings: fix ordering of releasing of gpiosim resources Bartosz Golaszewski

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).