From patchwork Thu Feb 23 18:02:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frode Isaksen X-Patchwork-Id: 9588757 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9400460210 for ; Thu, 23 Feb 2017 18:03:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 894FE2877E for ; Thu, 23 Feb 2017 18:03:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DC5C2878B; Thu, 23 Feb 2017 18:03:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 298122877E for ; Thu, 23 Feb 2017 18:03:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751213AbdBWSDS (ORCPT ); Thu, 23 Feb 2017 13:03:18 -0500 Received: from mail-wm0-f41.google.com ([74.125.82.41]:35211 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751119AbdBWSDR (ORCPT ); Thu, 23 Feb 2017 13:03:17 -0500 Received: by mail-wm0-f41.google.com with SMTP id v186so179343934wmd.0 for ; Thu, 23 Feb 2017 10:03:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7F+Kht5C+1/E9ZkyhBYLA/mSWZ28jrqXzcS/C0pjQzg=; b=kaEJWA83tlZGfQAsjN8p6yAl5PbSQXQOccYiZpZrfmQ5DgcS41wJW+GiKXnzRGbxUm 8I+2qQEGaM9/udS2O9hByHD4xdphaR4lbwDF+N90FZ5/4oky/0WJDVGKC9WrgVGbiTSy Yy1VSeWlYVISa2vEjlA3/lWLZpPVSQABf9O9fkLv3ig9s/qpFHPrHTwpAfq14DYaAPLB e/Esj9t0A+OVMgPYdM47AEzgPh2iSv+323zWv9aBNSa7+8KTOdYXEo9o0jAG6HDc7Rep LZCjBi19KB9S6ed5tHUMA4Io/v5jImEavy5f+KLb7fq2d14rdFV4hXSNeAvG1XEBaqXy eObQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7F+Kht5C+1/E9ZkyhBYLA/mSWZ28jrqXzcS/C0pjQzg=; b=bobuqt7D7mwchebWoU56vWRjI7aMsSbs9RUDwYwEBXcWGeQeSAErLVwSDqwAXGRZCo Pf+HqXn/ykZJ8TEywOiS9IiLJYpssaa+pM+SjpeuCsWs/uvLvO3tX4k1WUDu7ecKXCHl KKgbhsV/VFt7VDu361qAnOajfUek10YKos+TDSBDGMdbYKclxjXI8QEgSp39K/9P2yzm HWjuzoTFgNB0tDLNKKvf1AXzdWhrBA1vOITBHlHneGmNCg9hwo8F/WqeG4ZgRxidvSpX Tt+EzT+HAq/+uRkjRsDqA47f27uBI8PnrgkzyEPWtucUMoUJEhSbjhpQPQvUfg+4vVqG Go2A== X-Gm-Message-State: AMke39mqn4UAp6+bEhLDEgMZS5F1XX5YvQz7XExsDCOLIouPquvNmJQvptLnf5WHXrceq+Qq X-Received: by 10.28.213.142 with SMTP id m136mr3957106wmg.90.1487872995877; Thu, 23 Feb 2017 10:03:15 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id z134sm7739182wmc.20.2017.02.23.10.03.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Feb 2017 10:03:15 -0800 (PST) From: Frode Isaksen To: nsekhar@ti.com, khilman@baylibre.com, ptitiano@baylibre.com, linux-arm-kernel@lists.infradead.org Cc: broonie@kernel.org, linux-spi@vger.kernel.org, Frode Isaksen Subject: [PATCH v3 6/6] spi: loopback-test: add option to use vmalloc'ed buffers Date: Thu, 23 Feb 2017 19:02:01 +0100 Message-Id: <1487872921-26628-7-git-send-email-fisaksen@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487872921-26628-1-git-send-email-fisaksen@baylibre.com> References: <1487872921-26628-1-git-send-email-fisaksen@baylibre.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/spi/spi-loopback-test.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-loopback-test.c b/drivers/spi/spi-loopback-test.c index 50e620f..3596051 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); MODULE_PARM_DESC(run_only_test, "only run the test with this number (0-based !)"); +/* use vmalloc'ed buffers */ +int use_vmalloc; +module_param(use_vmalloc, int, 0644); +MODULE_PARM_DESC(use_vmalloc, + "use vmalloc'ed buffers instead of kmalloc'ed"); + +/* check rx ranges */ +int check_ranges = 1; +module_param(check_ranges, int, 0644); +MODULE_PARM_DESC(check_ranges, + "checks rx_buffer pattern are valid"); + /* the actual tests to execute */ static struct spi_test spi_tests[] = { { @@ -492,9 +504,11 @@ static int spi_test_check_loopback_result(struct spi_device *spi, int ret; /* checks rx_buffer pattern are valid with loopback or without */ - ret = spi_check_rx_ranges(spi, msg, rx); - if (ret) - return ret; + if (check_ranges) { + ret = spi_check_rx_ranges(spi, msg, rx); + if (ret) + return ret; + } /* if we run without loopback, then return now */ if (!loopback) @@ -965,13 +979,19 @@ int spi_test_run_tests(struct spi_device *spi, /* allocate rx/tx buffers of 128kB size without devm * in the hope that is on a page boundary */ - rx = kzalloc(SPI_TEST_MAX_SIZE_PLUS, GFP_KERNEL); + if (use_vmalloc) + rx = vmalloc(SPI_TEST_MAX_SIZE_PLUS); + else + rx = kzalloc(SPI_TEST_MAX_SIZE_PLUS, GFP_KERNEL); if (!rx) { ret = -ENOMEM; goto out; } - tx = kzalloc(SPI_TEST_MAX_SIZE_PLUS, GFP_KERNEL); + if (use_vmalloc) + tx = vmalloc(SPI_TEST_MAX_SIZE_PLUS); + else + tx = kzalloc(SPI_TEST_MAX_SIZE_PLUS, GFP_KERNEL); if (!tx) { ret = -ENOMEM; goto out; @@ -999,8 +1019,8 @@ int spi_test_run_tests(struct spi_device *spi, } out: - kfree(rx); - kfree(tx); + kvfree(rx); + kvfree(tx); return ret; } EXPORT_SYMBOL_GPL(spi_test_run_tests);