* spi: tests driver to test basic alignment/length issues via loopback
@ 2015-11-25 18:56 Martin Sperl
[not found] ` <753FCC7B-67D9-495B-A6C1-D49793502C90-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Martin Sperl @ 2015-11-25 18:56 UTC (permalink / raw)
To: linux-spi; +Cc: Mark Brown
Hi!
While writing a patch that allows spi_masters (and maybe also the
framework) to modify a submitted spi_message so that the resulting
spi_message fits the “limitations” of the HW (this basically works
already, but I still need to split it into several patches and run
further testing before submitting...) I had to generate a test
harness to make sure that all situations were taken care of properly.
So I had to write a small test driver that allows for generate all sorts
of spi_messages with different length, rx/tx_buf alignments and more to
get generated - right now it submits something like 360 distinct
spi_messages:
* transfers starting on a page with rx and tx_buf set
* length: 1, 16, 32, 64, 128, 256, 1024, 4096, 128k
* alignment of rx_buf/tx_buf to 0, 1, 2, 3 ([0:sizeof(int)[)
(if your spi_master defines dma_alignment, then [0:dma_alignment[)
* a total of 144 spi-messages
* transfer starting on (page_size - 4) with rx and tx_buf set
* same as above
* a total of 144 spi-messages
* tx-only transfers
* same as above, but only alignment for tx
* total of 36 spi-messages
* rx-only transfers
* same as above, but only alignment for rx
* total of 36 spi-messages
Currently no multi-transfers are tested, but in principle these can
get defined very easily.
It is quite extensible and has already helped me identify some regressions
that the “modify” framework was introducing on the raspberry Pi.
For complete testing the only thing it requires is MOSI connected to MISO.
and then it can detect lots of situations:
* incomplete writes in rx_buf
* writes outside of spi_transfer.rx_buf (dma writing to much)
* alignment issues
There is also several distinct tx-payload generators that can get used to
identify some issues - it may also help when using a logic-analyzer to see
the data that is really sent out.
Obviously it is not perfect and is only tested using 4 wire mode, but it
may act as a “tool” to test for some basic regressions.
So I wonder if there would be some interest in having such a test driver
in the kernel for use during spi_master development.
If interested, you can have a look at: https://github.com/msperl/spi-test <https://github.com/msperl/spi-test>
and if that seems to fulfill a requirement, then I can submit it as a
patch.
Thanks,
Martin--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread[parent not found: <753FCC7B-67D9-495B-A6C1-D49793502C90-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>]
* Re: spi: tests driver to test basic alignment/length issues via loopback [not found] ` <753FCC7B-67D9-495B-A6C1-D49793502C90-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org> @ 2015-11-26 9:32 ` Geert Uytterhoeven [not found] ` <CAMuHMdVpds0hOD=4uh1ZA+pfk9wHQJiuJodgXJDG0VcmYRXkeQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2015-11-26 9:54 ` Geert Uytterhoeven 2015-11-26 12:18 ` Mark Brown 2 siblings, 1 reply; 6+ messages in thread From: Geert Uytterhoeven @ 2015-11-26 9:32 UTC (permalink / raw) To: Martin Sperl; +Cc: linux-spi, Mark Brown Hi Martin, On Wed, Nov 25, 2015 at 7:56 PM, Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org> wrote: > So I had to write a small test driver that allows for generate all sorts > of spi_messages with different length, rx/tx_buf alignments and more to > get generated - right now it submits something like 360 distinct > spi_messages: Thanks! > * transfers starting on a page with rx and tx_buf set > * length: 1, 16, 32, 64, 128, 256, 1024, 4096, 128k I think you should add a few lengths that are not powers of two (e.g. prime numbers). Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <CAMuHMdVpds0hOD=4uh1ZA+pfk9wHQJiuJodgXJDG0VcmYRXkeQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: spi: tests driver to test basic alignment/length issues via loopback [not found] ` <CAMuHMdVpds0hOD=4uh1ZA+pfk9wHQJiuJodgXJDG0VcmYRXkeQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2015-11-26 9:48 ` Martin Sperl 0 siblings, 0 replies; 6+ messages in thread From: Martin Sperl @ 2015-11-26 9:48 UTC (permalink / raw) To: Geert Uytterhoeven; +Cc: linux-spi, Mark Brown On 26.11.2015 10:32, Geert Uytterhoeven wrote: > On Wed, Nov 25, 2015 at 7:56 PM, Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org> wrote: >> So I had to write a small test driver that allows for generate all sorts >> of spi_messages with different length, rx/tx_buf alignments and more to >> get generated - right now it submits something like 360 distinct >> spi_messages: > > Thanks! So I take that as a yes... >> * transfers starting on a page with rx and tx_buf set >> * length: 1, 16, 32, 64, 128, 256, 1024, 4096, 128k > > I think you should add a few lengths that are not powers of two > (e.g. prime numbers). it is just requires to assign more values to .iterate_len. (on top of the default length). One of the tests looks like this: { .description = "tx/rx-transfer - crossing PAGE_SIZE", .fill_option = FILL_COUNT_8, /* 8-bit counter */ .iterate_len = {16, 32, 64, 128, 256, 1024, PAGE_SIZE, SPI_TEST_MAX_SIZE, }, .iterate_tx_align = sizeof(int), .iterate_rx_align = sizeof(int), .transfers = { { .len = 1, .tx_buf = TX(PAGE_SIZE - 4), .rx_buf = RX(PAGE_SIZE - 4), }, }, }, and it produces 144 variations in the case of sizeof(int) == 4 Adding additional transfers is as simple as adding more descriptions to .transfers (which is an array of spi_transfers)... Adding additional tests is as simple as adding another such structure... I will add some more features (making alignment and length iterateable per transfer) and then I will submit it as: drivers/spi/spi-test.c If it should be called differently then please tell me. Ciao, Martin -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: spi: tests driver to test basic alignment/length issues via loopback [not found] ` <753FCC7B-67D9-495B-A6C1-D49793502C90-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org> 2015-11-26 9:32 ` Geert Uytterhoeven @ 2015-11-26 9:54 ` Geert Uytterhoeven [not found] ` <CAMuHMdX6AVqhDUyvxgPGOdVYi4LPAm7CCGD-M7sUQCbXZJ+49w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2015-11-26 12:18 ` Mark Brown 2 siblings, 1 reply; 6+ messages in thread From: Geert Uytterhoeven @ 2015-11-26 9:54 UTC (permalink / raw) To: Martin Sperl; +Cc: linux-spi, Mark Brown Hi Martin, On Wed, Nov 25, 2015 at 7:56 PM, Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org> wrote: > For complete testing the only thing it requires is MOSI connected to MISO. > and then it can detect lots of situations: BTW, with several SPI drivers, you can set SPI_LOOP instead. This can be useful on boards where the SPI pins are not available on expansion headers, or where the pins are used for other functions. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <CAMuHMdX6AVqhDUyvxgPGOdVYi4LPAm7CCGD-M7sUQCbXZJ+49w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: spi: tests driver to test basic alignment/length issues via loopback [not found] ` <CAMuHMdX6AVqhDUyvxgPGOdVYi4LPAm7CCGD-M7sUQCbXZJ+49w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2015-11-26 10:02 ` Martin Sperl 0 siblings, 0 replies; 6+ messages in thread From: Martin Sperl @ 2015-11-26 10:02 UTC (permalink / raw) To: Geert Uytterhoeven; +Cc: linux-spi, Mark Brown On 26.11.2015 10:54, Geert Uytterhoeven wrote: > Hi Martin, > > On Wed, Nov 25, 2015 at 7:56 PM, Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org> wrote: >> For complete testing the only thing it requires is MOSI connected to MISO. >> and then it can detect lots of situations: > > BTW, with several SPI drivers, you can set SPI_LOOP instead. > This can be useful on boards where the SPI pins are not available on > expansion headers, or where the pins are used for other functions. I thought of adding spi_msg to the spi_test structure as well, but as spi_message_init clears all the data in spi_message, I did not want to take that step... Also I fear that with SPI_LOOP some drivers may take some short-cuts copying the data directly without going via the HW, which would result in testing a different code-path than in reality and thus resulting in bogus positive results. Anyway: we can always extend it to include these kinds of things later. (maybe even add auto-detection if there is a flag for it...) Martin -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: spi: tests driver to test basic alignment/length issues via loopback [not found] ` <753FCC7B-67D9-495B-A6C1-D49793502C90-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org> 2015-11-26 9:32 ` Geert Uytterhoeven 2015-11-26 9:54 ` Geert Uytterhoeven @ 2015-11-26 12:18 ` Mark Brown 2 siblings, 0 replies; 6+ messages in thread From: Mark Brown @ 2015-11-26 12:18 UTC (permalink / raw) To: Martin Sperl; +Cc: linux-spi [-- Attachment #1: Type: text/plain, Size: 234 bytes --] On Wed, Nov 25, 2015 at 07:56:22PM +0100, Martin Sperl wrote: > So I wonder if there would be some interest in having such a test driver > in the kernel for use during spi_master development. Sure, please submit patches for review. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 473 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-11-26 12:18 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-25 18:56 spi: tests driver to test basic alignment/length issues via loopback Martin Sperl
[not found] ` <753FCC7B-67D9-495B-A6C1-D49793502C90-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-11-26 9:32 ` Geert Uytterhoeven
[not found] ` <CAMuHMdVpds0hOD=4uh1ZA+pfk9wHQJiuJodgXJDG0VcmYRXkeQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-11-26 9:48 ` Martin Sperl
2015-11-26 9:54 ` Geert Uytterhoeven
[not found] ` <CAMuHMdX6AVqhDUyvxgPGOdVYi4LPAm7CCGD-M7sUQCbXZJ+49w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-11-26 10:02 ` Martin Sperl
2015-11-26 12:18 ` Mark Brown
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox