From: "江宏辉 " <jiang_hh2019@163.com>
To: "Mark Brown" <broonie@kernel.org>
Cc: andy@kernel.org, andriy.shevchenko@linux.intel.com,
fancer.lancer@gmail.com, linux-spi@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] spi: Add KUnit coverage for DMA mapping error paths
Date: Thu, 6 Aug 2026 12:20:02 +0800 (CST) [thread overview]
Message-ID: <51604e4f.383b.19fd54cb92c.Coremail.jiang_hh2019@163.com> (raw)
In-Reply-To: <fbc72384-2f47-4577-859f-719d55a2a66a@sirena.org.uk>
Thanks for the review.
I'll address these comments in v2 and rework the test integration
as suggested.
At 2026-08-06 05:57:41, "Mark Brown" <broonie@kernel.org> wrote:
>On Wed, Aug 05, 2026 at 11:14:56PM +0800, Honghui Jiang wrote:
>> Add KUnit tests for the __spi_map_msg() error paths. The tests verify
>> that mappings created before a later TX or RX failure are unwound, their
>> flags are cleared, and cur_{tx,rx}_dma_dev point to the device used for
>> the mapping.
>
>The tests themselves look good but some style/integration stuff:
>
>> --- /dev/null
>> +++ b/drivers/spi/.kunitconfig
>> @@ -0,0 +1,4 @@
>> +CONFIG_KUNIT=y
>> +CONFIG_SPI=y
>> +CONFIG_SPI_MASTER=y
>> +CONFIG_SPI_KUNIT_TEST=y
>
>This also needs enabling in the KUnit defconfigs in
>tools/testing/kunit/configs.
>
>> index 05a852494..42e337c54 100644
>> --- a/drivers/spi/spi.c
>> +++ b/drivers/spi/spi.c
>> @@ -5146,3 +5146,7 @@ static int __init spi_init(void)
>> * include needing to have boardinfo data structures be much more public.
>> */
>> postcore_initcall(spi_init);
>> +
>> +#ifdef CONFIG_SPI_KUNIT_TEST
>> +#include "tests/spi_kunit.c"
>> +#endif
>
>If this is just so we can peer into the internals it'd be better to add
>a local header for internals and build as a separate translation unit
>like normal rather than doing this sort of bodge.
>
>> diff --git a/drivers/spi/tests/spi_kunit.c b/drivers/spi/tests/spi_kunit.c
>
>Everywhere else we use - as a separator.
>
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * KUnit tests for the SPI core DMA mapping error paths.
>> + *
>
>Please make the entire comment a C++ one so things look more intentional.
>
>> + * The invariant under test:
>> + *
>> + * When __spi_map_msg() returns an error, no transfer in the message may
>> + * still claim a DMA mapping. Any transfer that was mapped before the
>> + * failure must have an empty SG table and a cleared *_sg_mapped flag.
>> + * ctlr->cur_{tx,rx}_dma_dev must identify the device used for this map,
>> + * rather than a device retained from an earlier message.
>
>This is for one specific test, either this file should have a test
>specific name with everything else namespaced to make room for further
>tests or all this should go with the specific test. This looks like a
>DMA subsuite so possibly named after that? The same applies to internal
>identifiers.
next prev parent reply other threads:[~2026-08-06 4:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 15:14 [PATCH 0/2] spi: Fix DMA mapping ownership on partial map failure Honghui Jiang
2026-08-05 15:14 ` [PATCH 1/2] " Honghui Jiang
2026-08-06 19:34 ` Andy Shevchenko
2026-08-08 17:54 ` Honghui Jiang
2026-08-05 15:14 ` [PATCH 2/2] spi: Add KUnit coverage for DMA mapping error paths Honghui Jiang
2026-08-05 21:57 ` Mark Brown
2026-08-06 4:20 ` 江宏辉 [this message]
2026-08-06 19:32 ` Andy Shevchenko
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=51604e4f.383b.19fd54cb92c.Coremail.jiang_hh2019@163.com \
--to=jiang_hh2019@163.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andy@kernel.org \
--cc=broonie@kernel.org \
--cc=fancer.lancer@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
/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