Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH 0/2] iio: flow: slf3s: fix and test the vdd supply balance
@ 2026-09-04 19:24 Wadim Mueller
  2026-09-04 19:24 ` [PATCH 1/2] iio: flow: slf3s: keep the vdd supply balanced across suspend/resume Wadim Mueller
  2026-09-04 19:24 ` [PATCH 2/2] iio: flow: slf3s: add KUnit tests for the PM regulator balance Wadim Mueller
  0 siblings, 2 replies; 5+ messages in thread
From: Wadim Mueller @ 2026-09-04 19:24 UTC (permalink / raw)
  To: Maxwell Doose, Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko
  Cc: Jonathan Cameron, linux-iio, linux-kernel, Li Youhong, Li Youhong,
	Brendan Higgins, David Gow, Rae Moar, linux-kselftest, kunit-dev,
	Wadim Mueller

Li Youhong reported that slf3s_resume() leaves vdd enabled when the
measurement restart fails [1].  The report is right, but the patch and
my own Reviewed-by on it were both too narrow.

Andy asked whether the regulator refcount can go sideways here.  It
cannot.  device_suspend() sets power.is_suspended only when the callback
returned 0, and device_resume() returns before the callback when the
flag is clear.  So the two alternate and the count stays in {0, 1}.
Please drop my Reviewed-by, the reasoning in it is wrong.

Three things do go wrong though:

 - resume enables vdd, start_meas() fails, the supply stays on.

 - the part is then powered but idle, so it NACKs the stop command.
   suspend() returns early on that error and never disables vdd, so the
   system cannot suspend any more until rebind.  This one hurts most.

 - if regulator_enable() fails in resume, the next suspend disables a
   supply that was never enabled: "unbalanced disables" in the regulator
   core, and -EIO.  Unbind hits the same case.

The original patch fixes the first one only.

Patch 1 tracks the supply state and drives enable/disable from it.
Patch 2 adds KUnit tests with a fake i2c adapter and a counting
regulator, so no hardware is needed:

  ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/iio/flow

Four of the eight tests fail without patch 1.

[1] https://lore.kernel.org/linux-iio/20260901025010.356735-1-dayou5941@163.com/

Signed-off-by: Wadim Mueller <wafgo01@gmail.com>
---
Wadim Mueller (2):
      iio: flow: slf3s: keep the vdd supply balanced across suspend/resume
      iio: flow: slf3s: add KUnit tests for the PM regulator balance

 MAINTAINERS                    |   2 +
 drivers/iio/flow/.kunitconfig  |   6 +
 drivers/iio/flow/Kconfig       |  15 +
 drivers/iio/flow/Makefile      |   1 +
 drivers/iio/flow/slf3s-kunit.c | 734 +++++++++++++++++++++++++++++++++++++++++
 drivers/iio/flow/slf3s.c       |  35 +-
 6 files changed, 787 insertions(+), 6 deletions(-)
---
base-commit: bc35965f6940a9bf834d54187b6088b8eb09206d
change-id: 20260904-iio-slf3s-pm-regulator-kunit-43ee079b36f0

Best regards,
-- 
Wadim Mueller <wafgo01@gmail.com>


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

end of thread, other threads:[~2026-09-05  1:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04 19:24 [PATCH 0/2] iio: flow: slf3s: fix and test the vdd supply balance Wadim Mueller
2026-09-04 19:24 ` [PATCH 1/2] iio: flow: slf3s: keep the vdd supply balanced across suspend/resume Wadim Mueller
2026-09-05  1:13   ` Jonathan Cameron
2026-09-04 19:24 ` [PATCH 2/2] iio: flow: slf3s: add KUnit tests for the PM regulator balance Wadim Mueller
2026-09-05  1:31   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox