aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-loopback-test.c
diff options
context:
space:
mode:
authorFrode Isaksen <fisaksen@baylibre.com>2017-02-23 13:02:01 -0500
committerMark Brown <broonie@kernel.org>2017-03-15 15:35:53 -0400
commit576333a1fb940767e8638fafea908214682e8acd (patch)
treefb264a862d4a829073c69f0105bae4327d0bb077 /drivers/spi/spi-loopback-test.c
parentfafd67940774733fa97f4b09412aea6981b82e0a (diff)
spi: loopback-test: add option to use vmalloc'ed buffers
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>
Diffstat (limited to 'drivers/spi/spi-loopback-test.c')
-rw-r--r--drivers/spi/spi-loopback-test.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/drivers/spi/spi-loopback-test.c b/drivers/spi/spi-loopback-test.c
index 50e620f4e8fe..35960515382e 100644
--- a/drivers/spi/spi-loopback-test.c
+++ b/drivers/spi/spi-loopback-test.c
@@ -55,6 +55,18 @@ module_param(run_only_test, int, 0);
55MODULE_PARM_DESC(run_only_test, 55MODULE_PARM_DESC(run_only_test,
56 "only run the test with this number (0-based !)"); 56 "only run the test with this number (0-based !)");
57 57
58/* use vmalloc'ed buffers */
59int use_vmalloc;
60module_param(use_vmalloc, int, 0644);
61MODULE_PARM_DESC(use_vmalloc,
62 "use vmalloc'ed buffers instead of kmalloc'ed");
63
64/* check rx ranges */
65int check_ranges = 1;
66module_param(check_ranges, int, 0644);
67MODULE_PARM_DESC(check_ranges,
68 "checks rx_buffer pattern are valid");
69
58/* the actual tests to execute */ 70/* the actual tests to execute */
59static struct spi_test spi_tests[] = { 71static struct spi_test spi_tests[] = {
60 { 72 {
@@ -492,9 +504,11 @@ static int spi_test_check_loopback_result(struct spi_device *spi,
492 int ret; 504 int ret;
493 505
494 /* checks rx_buffer pattern are valid with loopback or without */ 506 /* checks rx_buffer pattern are valid with loopback or without */
495 ret = spi_check_rx_ranges(spi, msg, rx); 507 if (check_ranges) {
496 if (ret) 508 ret = spi_check_rx_ranges(spi, msg, rx);
497 return ret; 509 if (ret)
510 return ret;
511 }
498 512
499 /* if we run without loopback, then return now */ 513 /* if we run without loopback, then return now */
500 if (!loopback) 514 if (!loopback)
@@ -965,13 +979,19 @@ int spi_test_run_tests(struct spi_device *spi,
965 /* allocate rx/tx buffers of 128kB size without devm 979 /* allocate rx/tx buffers of 128kB size without devm
966 * in the hope that is on a page boundary 980 * in the hope that is on a page boundary
967 */ 981 */
968 rx = kzalloc(SPI_TEST_MAX_SIZE_PLUS, GFP_KERNEL); 982 if (use_vmalloc)
983 rx = vmalloc(SPI_TEST_MAX_SIZE_PLUS);
984 else
985 rx = kzalloc(SPI_TEST_MAX_SIZE_PLUS, GFP_KERNEL);
969 if (!rx) { 986 if (!rx) {
970 ret = -ENOMEM; 987 ret = -ENOMEM;
971 goto out; 988 goto out;
972 } 989 }
973 990
974 tx = kzalloc(SPI_TEST_MAX_SIZE_PLUS, GFP_KERNEL); 991 if (use_vmalloc)
992 tx = vmalloc(SPI_TEST_MAX_SIZE_PLUS);
993 else
994 tx = kzalloc(SPI_TEST_MAX_SIZE_PLUS, GFP_KERNEL);
975 if (!tx) { 995 if (!tx) {
976 ret = -ENOMEM; 996 ret = -ENOMEM;
977 goto out; 997 goto out;
@@ -999,8 +1019,8 @@ int spi_test_run_tests(struct spi_device *spi,
999 } 1019 }
1000 1020
1001out: 1021out:
1002 kfree(rx); 1022 kvfree(rx);
1003 kfree(tx); 1023 kvfree(tx);
1004 return ret; 1024 return ret;
1005} 1025}
1006EXPORT_SYMBOL_GPL(spi_test_run_tests); 1026EXPORT_SYMBOL_GPL(spi_test_run_tests);