From: sashiko-bot@kernel.org
To: "Jinseob Kim" <kimjinseob88@gmail.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v11 8/8] iio: osf: add IIO KUnit tests
Date: Sun, 11 Oct 2026 23:39:30 +0000 [thread overview]
Message-ID: <sashiko-outbox-167517@kernel.org> (raw)
In-Reply-To: <20261011231340.42885-9-kimjinseob88@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] iio: osf: KUnit test hangs kernel due to invalid assumption about unregister serialization
- [Medium] iio: osf: KUnit test osf_iio_buffer_lifetime_test fails due to incorrect locking assumption
--
commit ca6325902957e47173f8e4aee82de054cadca7cd
Author: Jinseob Kim <kimjinseob88@gmail.com>
iio: osf: add IIO KUnit tests
This patch adds KUnit tests for the Open Sensor Fusion core sample
acceptance, direct-read cache, and IIO buffer paths. It exercises
active-scan packing, timestamp alignment, and producer quiescence
during buffer reconfiguration and unregistration.
> diff --git a/drivers/iio/sensorhubs/osf/osf_iio_test.c b/drivers/iio/sensorhubs/osf/osf_iio_test.c
> new file mode 100644
> index 0000000000000..4c3fd8cfb2b26
> --- /dev/null
> +++ b/drivers/iio/sensorhubs/osf/osf_iio_test.c
> @@ -0,0 +1,386 @@
> +// SPDX-License-Identifier: GPL-2.0-only
[ ... ]
> +static void osf_iio_expect_quiesce(struct kunit *test, struct osf_iio_race *race)
> +{
> + struct iio_dev *indio_dev = race->indio_dev;
> + const unsigned long *scan_mask = indio_dev->active_scan_mask;
> + unsigned long mask;
> + unsigned long waited;
> + int ret;
> +
> + KUNIT_ASSERT_NOT_NULL(test, scan_mask);
> + mask = *scan_mask;
> + race->config = kthread_run(osf_iio_test_configure, race, "osf-cfg-test");
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, race->config);
> + ret = kunit_add_action_or_reset(test, osf_iio_stop_config, race);
> + KUNIT_ASSERT_EQ(test, ret, 0);
> + KUNIT_EXPECT_NE(test, wait_for_completion_timeout(&race->config_started, HZ), 0UL);
> + waited = wait_for_completion_timeout(&race->config_done, msecs_to_jiffies(20));
> + KUNIT_EXPECT_EQ(test, waited, 0UL);
> + /* The blocked OSF push owns the mode claim until its store returns. */
> + KUNIT_EXPECT_TRUE(test, iio_buffer_enabled(indio_dev));
> + KUNIT_EXPECT_PTR_EQ(test, indio_dev->active_scan_mask, scan_mask);
[Severity: Medium]
Will these assertions fail unconditionally?
The test assumes iio_device_unregister() blocks on mlock while the
producer is active. However, iio_device_unregister() only takes
info_exist_lock, not mlock. It proceeds directly to disable all buffers
and nullifies active_scan_mask immediately, which would cause the
timeout assertion and state assertions here to fail.
[ ... ]
> + /* Publish the completions to the producer's fully ordered atomic_xchg(). */
> + atomic_set_release(&race->block_store, 1);
> + KUNIT_EXPECT_NE(test, wait_for_completion_timeout(&race->entered, HZ), 0UL);
> + race->unregister = true;
> + osf_iio_expect_quiesce(test, race);
[Severity: High]
Can this sequence cause a kernel soft lockup?
When race->unregister is true, the test concurrently triggers
iio_device_unregister() while the producer is actively blocked pushing a
sample. Because iio_device_unregister() does not block on mlock, it removes
the active buffer from buffer_list using list_del_init().
When the test unblocks the producer, it resumes in iio_push_to_buffers()
inside list_for_each_entry(). Since the buffer was removed with
list_del_init(), its next pointer points to itself, creating an infinite
loop.
> + kunit_release_action(test, osf_iio_stop_producer, race);
> + KUNIT_EXPECT_EQ(test, atomic_read(&race->bad_store), 0);
> + KUNIT_EXPECT_GT(test, atomic_read(&race->stores), 0);
> + kunit_release_action(test, osf_iio_restore_access, race);
> + kunit_release_action(test, osf_iio_test_put_device, &indio_dev->dev);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261011231340.42885-1-kimjinseob88@gmail.com?part=8
prev parent reply other threads:[~2026-10-11 23:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-11 23:13 [PATCH v11 0/8] iio: add Open Sensor Fusion UART support Jinseob Kim
2026-10-11 23:13 ` [PATCH v11 1/8] dt-bindings: iio: add Open Sensor Fusion device Jinseob Kim
2026-10-12 19:10 ` Conor Dooley
2026-10-11 23:13 ` [PATCH v11 2/8] Documentation: iio: add Open Sensor Fusion driver overview Jinseob Kim
2026-10-11 23:13 ` [PATCH v11 3/8] iio: osf: add protocol decoding Jinseob Kim
2026-10-11 23:13 ` [PATCH v11 4/8] iio: osf: add validated stream parser Jinseob Kim
2026-10-11 23:13 ` [PATCH v11 5/8] iio: osf: add UART transport and core receive path Jinseob Kim
2026-10-11 23:13 ` [PATCH v11 6/8] iio: osf: add IIO devices from capability reports Jinseob Kim
2026-10-11 23:29 ` sashiko-bot
2026-10-11 23:13 ` [PATCH v11 7/8] iio: osf: add core KUnit tests Jinseob Kim
2026-10-11 23:29 ` sashiko-bot
2026-10-11 23:13 ` [PATCH v11 8/8] iio: osf: add IIO " Jinseob Kim
2026-10-11 23:39 ` sashiko-bot [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=sashiko-outbox-167517@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=kimjinseob88@gmail.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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