From: Jonathan Cameron <jic23@kernel.org>
To: Wadim Mueller <wafgo01@gmail.com>
Cc: "Maxwell Doose" <maxwell@maxwelld.cc>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Jonathan Cameron" <jonathan.cameron@oss.qualcomm.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
"Li Youhong" <dayou5941@163.com>,
"Li Youhong" <liyouhong@kylinos.cn>,
"Brendan Higgins" <brendan.higgins@linux.dev>,
"David Gow" <david@davidgow.net>,
"Rae Moar" <raemoar63@gmail.com>,
linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com
Subject: Re: [PATCH 2/2] iio: flow: slf3s: add KUnit tests for the PM regulator balance
Date: Sat, 5 Sep 2026 02:31:47 +0100 [thread overview]
Message-ID: <20260905023147.006d181c@jic23-huawei> (raw)
In-Reply-To: <20260904-iio-slf3s-pm-regulator-kunit-v1-2-5ea61e6d6db2@gmail.com>
On Fri, 04 Sep 2026 21:24:26 +0200
Wadim Mueller <wafgo01@gmail.com> wrote:
> Bind the driver to an emulated SLF3S on a fake I2C adapter, back it with
> a regulator whose enable and disable callbacks are counted, and check
> that the two stay paired across suspend and resume - including the cycles
> in which the sensor NACKs a command or the supply refuses to come up.
>
> The suspend/resume helpers reproduce the PM core's rule that a resume
> callback only runs after a suspend callback that returned 0, so that the
> tests cannot construct an ordering the core never produces. One of the
> tests relies on it: it cycles the device ten times with rotating failure
> injection and asserts that the driver's enable count never climbs above
> one.
>
> Signed-off-by: Wadim Mueller <wafgo01@gmail.com>
Interesting approach to testing the flows.
I'm not sure we want to carry this level of testing for a driver in the
tree. Would like to hear the views of others on this.
There is some really nice stuff in here. Makes me wonder if we should
build a specific test device + driver that would hit all the widest possible
set of corner cases that aren't device specific. The one slightly unusual
thing for this device is the error on telling to stop when it is already stopped.
A couple of things I noted whilst taking a first look.
I'll want to take some time when I'm a lot more awake than I am today
to look at this closely.
Thanks!
Jonathan
> diff --git a/drivers/iio/flow/slf3s-kunit.c b/drivers/iio/flow/slf3s-kunit.c
> new file mode 100644
> index 000000000000..d5e2db855838
> --- /dev/null
> +++ b/drivers/iio/flow/slf3s-kunit.c
> @@ -0,0 +1,734 @@
> +
> +static void slf3s_fake_put_word(struct slf3s_fake *f, u8 *dst, u16 val)
> +{
> + dst[0] = val >> 8;
> + dst[1] = val & 0xff;
Use a put_unaligned_be16() for this.
> + dst[2] = crc8(f->crc_table, dst, 2, SLF3S_TEST_CRC8_INIT);
> +}
> +static int slf3s_test_init(struct kunit *test)
> +{
> + struct regulator_consumer_supply *supply;
> + struct regulator_init_data *init_data;
> + struct i2c_board_info info = { };
> + struct regulator_config config = { };
> + struct slf3s_test_ctx *ctx;
> + struct device *parent;
> + char *consumer;
> + int ret;
> +
> + ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL);
> + KUNIT_ASSERT_NOT_NULL(test, ctx);
> + test->priv = ctx;
> +
> + /* Actions run in reverse, so destroy after the unbind takes the locks. */
> + mutex_init(&ctx->fake.lock);
> + ret = kunit_add_action_or_reset(test, slf3s_test_destroy_mutex,
> + &ctx->fake.lock);
> + KUNIT_ASSERT_EQ(test, ret, 0);
> +
> + mutex_init(&ctx->reg.lock);
> + ret = kunit_add_action_or_reset(test, slf3s_test_destroy_mutex,
> + &ctx->reg.lock);
> + KUNIT_ASSERT_EQ(test, ret, 0);
Given those are deep in the emulation which is not what we are testing, do
we need to bother with the mutex destroy calls? That is only there
for some debugging of locks that isn't relevant here I think.
> +
> + crc8_populate_msb(ctx->fake.crc_table, SLF3S_TEST_CRC8_POLY);
> + ctx->fake.state = SLF3S_FAKE_OFF;
prev parent reply other threads:[~2026-09-05 1:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260905023147.006d181c@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=brendan.higgins@linux.dev \
--cc=david@davidgow.net \
--cc=dayou5941@163.com \
--cc=dlechner@baylibre.com \
--cc=jonathan.cameron@oss.qualcomm.com \
--cc=kunit-dev@googlegroups.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=liyouhong@kylinos.cn \
--cc=maxwell@maxwelld.cc \
--cc=nuno.sa@analog.com \
--cc=raemoar63@gmail.com \
--cc=wafgo01@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).