summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-loopback-test.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* spi: loopback-test: implement testing with no CSOleksij Rempel2017-07-261-3/+9
| | | | | | | | | To run spi-loopback-tests on HW without modifications, we need to disable Chip Select. This should avoid surprising side effects for SPI devices by testing patterns. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: loopback-test: make several module parameters staticColin Ian King2017-07-181-7/+7
| | | | | | | | | | Several module parameters are local to the source, so make them static. Cleans up several sparse warnings such as: "symbol 'loop_req' was not declared. Should it be static?" Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: loopback-test: provide loop_req option.Oleksij Rempel2017-07-171-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | Provide a module parameter to request internal loop by the SPI master controller. This should make loop testing easier without extra HW modification. For test automation a logic analyzer is recommended for host controller-independent verification. An example test rig configuration and procedure: i.MX6S RIoRBoard Logic Analyzer ----------------------------------------- (J13 4) GND ------------- GND (J13 6) CSPI3-CLK ------> PIN 3 (J13 8) CSPI3-MOSI <----- PIN 2 ^ - internal loop configured by SPI_LOOP | or can be user external jamper. (J13 10) CSPI3-MISO -----> PIN 1 grab some data and decode it: sigrok-cli -d fx2lafw --time 160000 --config samplerate=10m \ --channels 0-2 -o dump.sr sigrok-cli -i dump.sr -P spi:mosi=1:clk=2 > result_for_regression_tests Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: loopback-test: Fix kfree() NULL pointer error.Arvind Yadav2017-06-281-6/+6
| | | | | | | | Here, rx/tx allocation can fail. So avoid kvfree call with NULL pointer. Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: loopback-test: fix spelling mistake: "reruning" -> "rerunning"Colin Ian King2017-06-281-1/+1
| | | | | | | trivial fix to spelling mistake in dev_info error message Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Mark Brown <broonie@kernel.org>
*-. Merge remote-tracking branches 'spi/topic/spidev', 'spi/topic/spidev-test', ↵Mark Brown2017-04-261-41/+78
|\ \ | | | | | | | | | 'spi/topic/sunxi', 'spi/topic/tegra' and 'spi/topic/test' into spi-next
| | * spi: loopback-test: fix spelling mistake: "minimam" -> "minimum"Colin Ian King2017-03-301-1/+1
| | | | | | | | | | | | | | | | | | | | | trivial fix to spelling mistake in dev_err error message Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | * spi: loopback-test: fix potential integer overflow on multipleColin Ian King2017-03-201-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A multiplication of 8U * xfer-len with the type of a 32 bit unsigned int is evaluated using 32 bit arithmetic and then used in a context that expects an expression of type unsigned long long (64 bits). Avoid any potential overflow by casting BITS_PER_BYTE to unsigned long long. Detected by CoverityScan, CID#1419691 ("Unintentional integer overflow") Fixes: ea9936f324356 ("spi: loopback-test: add elapsed time check") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | * spi: loopback-test: add test spi_message with delay after transfersAkinobu Mita2017-03-171-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | This adds a new test to check whether the spi_transfer.delay_usecs setting has properly taken effect. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | * spi: loopback-test: add elapsed time checkAkinobu Mita2017-03-171-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | This adds checks whether the elapsed time is longer than the minimam estimated time. The estimated time is calculated with the total transfer length per clock rate and optional spi_transfer.delay_usecs. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | * spi: loopback-test: add ability to test zero-length transferAkinobu Mita2017-03-171-38/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The spi-loopback-test module currently cannot test the spi_message including a zero-length transfer. Because the zero-length transfer is treated as a special value in several meanings. 1. The number of spi_transfer to execute in one test case is described by spi_test.transfer_count. It is normally computed by counting number of transfers with len > 0 in spi_test.transfers array. This change stops the detection for the number of spi_transfer. Each spi_test.transfer_count needs to be filled by hand now. 2. The spi_test.iterate_len is a list of transfer length to iterate on. This list is terminated by zero, so zero-length transfer cannot be included. This changes the terminal value from 0 to -1. 3. The length for the spi_transfer masked by spi_test.iterate_transfer_mask is iterated. Before starting the iteration, the default value which is statically initialized is applied. In order to specify the default value, zero-length is reserved. Currently, the default values are always '1'. So this removes this trick and add '1' to iterate_len list. By applying all these changes, the spi-loopback-test can execute spi messages with zero-length transfer. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | * spi: loopback-test: don't skip comparing the first byte of rx_bufAkinobu Mita2017-03-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | When the loopback parameter is set, rx_buf are compared with tx_buf after the spi_message is executed. But the first byte of buffer is not checked. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | * spi: loopback-test: correct mismatched test description and configurationAkinobu Mita2017-03-171-2/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | The test "two tx-transfers - alter first" actually alters the second not the first transfer. Similarly the test "two tx-transfers - alter second" actually alters the first not the second transfer. The mismatches for the two symmetrical tests cancel each other's mistakes. But it's better to fix the mismatches to avoid confusion. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | spi: loopback-test: fix compile error on x86Frode Isaksen2017-03-171-0/+1
| | | | | | | | | | | | | | | | Fix compile error caused by missing vmalloc() definition on x86 (and maybe other platforms) by including vmalloc.h. Signed-off-by: Frode Isaksen <fisaksen@baylibre.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | spi: loopback-test: add option to use vmalloc'ed buffersFrode Isaksen2017-03-151-7/+27
|/ | | | | | | | | | | | Using vmalloc'ed buffers will use one SG entry for each page, that may provoke DMA errors for large transfers. Also vmalloc'ed buffers may cause errors on CPU's with VIVT cache. Add this option to catch these errors when testing. Note that to catch VIVT cache errors, checking the rx range has to be disabled, so this option has been added as well. Signed-off-by: Frode Isaksen <fisaksen@baylibre.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: loopback-test: mark rx_ranges_cmp() staticBaoyou Xie2016-09-011-1/+1
| | | | | | | | | | | | | We get 1 warning when building kernel with W=1: drivers/spi/spi-loopback-test.c:408:5: warning: no previous prototype for 'rx_ranges_cmp' [-Wmissing-prototypes] In fact, this function is only used in the file in which it is declared and don't need a declaration, but can be made static. So this patch marks it 'static'. Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: loopback-test: fix spelling mistake: "missmatch" -> "mismatch"Colin Ian King2016-06-281-1/+1
| | | | | | | trivial fix to spelling mistake in dev_err message Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: fix counting in spi-loopback-test codeArnd Bergmann2016-01-151-0/+1
| | | | | | | | | | | | | | | | | These variables are always used uninitialized: drivers/spi/spi-loopback-test.c: In function 'spi_test_run_iter': drivers/spi/spi-loopback-test.c:768:17: warning: 'rx_count' may be used uninitialized in this function [-Wmaybe-uninitialized] drivers/spi/spi-loopback-test.c:762:17: warning: 'tx_count' may be used uninitialized in this function [-Wmaybe-uninitialized] Adding an explicit initialization seems to be the only workable solution here, to make the code behave correctly and build without warning. Fixes: 84e0c4e5e2c4 ("spi: add loopback test driver to allow for spi_master regression tests") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: loopback: fix typo in MODULE_PARM_DESCDan Carpenter2016-01-081-1/+1
| | | | | | | | There should be an 's' on "dump_message" so it matches the module_param. Fixes: 84e0c4e5e2c4 ('spi: add loopback test driver to allow for spi_master regression tests') Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: loopback-test: spi_check_rx_ranges can get always doneMartin Sperl2016-01-051-5/+14
| | | | | | | | The spi_check_rx_ranges can always get executed independent of if we have a real loopback situation. Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: loopback-test: rename method spi_test_fill_tx to spi_test_fill_patternMartin Sperl2016-01-051-3/+4
| | | | | | | | Rename method spi_test_fill_tx to spi_test_fill_pattern to better describe what it does. Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: loopback-test: write rx pattern also when running without tx_bufMartin Sperl2016-01-051-4/+4
| | | | | | | | | | Currently the rx_buf does not get set with the SPI_TEST_PATTERN_UNWRITTEN when tx_buf == NULL in the transfer. Reorder code so that it gets done also under this specific condition. Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: loopback: match configuration of test to descriptionMartin Sperl2015-12-131-1/+1
| | | | | | | | | | The test "two tx+rx transfers - alter second" actually modifies the first not the second transfer, which - in conjunction with testing the read data - results also in overwriting data read earlier. Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: loopback: fix printk format issues with size_tMartin Sperl2015-12-131-3/+3
| | | | | | | Fixes the reported printk format issues reported by kbuild-test-robot. Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: add loopback test driver to allow for spi_master regression testsMartin Sperl2015-12-131-0/+995
This driver is submitting lots of distinct spi-messages messages with all kinds of alignments and length pattern. Also distinct kinds of transfer pattern tests are implemented (rx, tx, rx/tx, tx+tx, tx+rx,...) Right now on a raspberry pi 752 distinct spi_messages are executed in 13 different scenarios. Configuration of additional test-pattern is easy, so that when new bugs in drivers get detected the relevant transfer pattern can also get added to the test framework, so that such situations are detected in other drivers as well. The idea behind this driver is to make it possible to also detect regressions in spi_master implementations when changes occur. Potentially these tests could get executed automatically in a test-server-farm. Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Signed-off-by: Mark Brown <broonie@kernel.org>