From: yi1.li@linux.intel.com
To: mcgrof@kernel.org, atull@kernel.org, gregkh@linuxfoundation.org,
wagi@monom.org, dwmw2@infradead.org, rafal@milecki.pl,
arend.vanspriel@broadcom.com, rjw@rjwysocki.net,
moritz.fischer@ettus.com, pmladek@suse.com,
johannes.berg@intel.com, emmanuel.grumbach@intel.com,
luciano.coelho@intel.com, kvalo@codeaurora.org, luto@kernel.org,
takahiro.akashi@linaro.org, dhowells@redhat.com,
pjones@redhat.com
Cc: linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org,
Yi Li <yi1.li@linux.intel.com>
Subject: [PATCHv2 2/3] test: add streaming test to driver_data tester
Date: Sat, 20 May 2017 01:49:07 -0500 [thread overview]
Message-ID: <1495262948-1106-3-git-send-email-yi1.li@linux.intel.com> (raw)
In-Reply-To: <1495262948-1106-1-git-send-email-yi1.li@linux.intel.com>
From: Yi Li <yi1.li@linux.intel.com>
This adds streaming test case, which pre-allocate the buffer and ask
driver_data_request_sync API to read 4KB each. Since the dummy firmware
image is very small, the test only stream couple bytes.
A manual test method:
echo -n 'bigfile' > /sys/devices/virtual/misc/test_driver_data0/config_name
echo -n 0 > /sys/devices/virtual/misc/test_driver_data0/config_async
echo -n 1 > /sys/devices/virtual/misc/test_driver_data0/config_stream
echo -n 1 > /sys/devices/virtual/misc/test_driver_data0/config_no_cache
echo -n 1 > /sys/devices/virtual/misc/test_driver_data0/trigger_config
Signed-off-by: Yi Li <yi1.li@linux.intel.com>
---
lib/test_driver_data.c | 80 ++++++++++++++++++++++++-
tools/testing/selftests/firmware/driver_data.sh | 32 ++++++++++
2 files changed, 110 insertions(+), 2 deletions(-)
diff --git a/lib/test_driver_data.c b/lib/test_driver_data.c
index 13fb091..9cca0b7 100644
--- a/lib/test_driver_data.c
+++ b/lib/test_driver_data.c
@@ -72,6 +72,8 @@ int num_test_devs;
* @prealloc: if set, driver_data will use preallocated buffer for
* firmware_buf->data. The caller need to setup alloc_buf_size and
* alloc_buf in the driver_data_req_params structure.
+ * @stream: true if you want to trigger an streaming request. This will use
+ * driver_data_request_sync() with streaming flag.
* @enable_opt_cb: whether or not the optional callback should be set
* on a trigger. There is no equivalent setting on the struct
* driver_data_req_params as this is implementation specific, and in
@@ -118,6 +120,7 @@ struct test_config {
char *name;
char *default_name;
bool async;
+ bool stream;
bool optional;
bool keep;
bool no_cache;
@@ -353,6 +356,9 @@ static ssize_t config_show(struct device *dev,
len += snprintf(buf+len, PAGE_SIZE,
"prealloc:\t\t%s\n",
config->prealloc ? "true" : "false");
+ len += snprintf(buf+len, PAGE_SIZE,
+ "stream:\t\t%s\n",
+ config->stream ? "true" : "false");
mutex_unlock(&test_dev->config_mutex);
@@ -502,6 +508,47 @@ static int trigger_config_sync(struct driver_data_test_device *test_dev)
return ret;
}
+static int trigger_config_stream(struct driver_data_test_device *test_dev)
+{
+ struct test_config *config = &test_dev->config;
+ int ret;
+ char *path = NULL;
+ void *buf;
+ loff_t offset = 0;
+ size_t length = INT_MAX;
+ const struct driver_data_req_params req_params_default = {
+ DRIVER_DATA_DEFAULT_SYNC_REQS(config_sync_req_cb, test_dev,
+ DRIVER_DATA_REQ_NO_CACHE |
+ DRIVER_DATA_REQ_STREAMING),
+ .alloc_buf_size = SZ_4K,
+ .alloc_buf = &buf,
+ .img_offset = &offset,
+ .path = &path,
+ };
+ const struct driver_data_req_params *req_params = &req_params_default;
+
+ buf = kmalloc(SZ_4K, GFP_KERNEL);
+ if (!buf) {
+ dev_err(test_dev->dev, "%s: kmalloc buf failed\n", __func__);
+ return -ENOMEM;
+ }
+
+ while (length > 0) {
+ ret = driver_data_request_sync(config->name, req_params,
+ test_dev->dev);
+ if (ret)
+ dev_err(test_dev->dev, "sync load of '%s' failed: %d\n",
+ config->name, ret);
+ length -= test_dev->test_driver_data.size;
+ offset += test_dev->test_driver_data.size;
+ if (test_dev->test_driver_data.size < SZ_4K)
+ break;
+ }
+
+ kfree(buf);
+ return ret;
+}
+
static void config_async_req_cb(const struct firmware *driver_data,
void *context, int unused_error)
{
@@ -636,8 +683,12 @@ trigger_config_store(struct device *dev,
if (config->async)
ret = trigger_config_async(test_dev);
- else
- ret = trigger_config_sync(test_dev);
+ else {
+ if (config->stream)
+ ret = trigger_config_stream(test_dev);
+ else
+ ret = trigger_config_sync(test_dev);
+ }
config->test_result = ret;
@@ -707,6 +758,7 @@ static int __driver_data_config_init(struct test_config *config)
goto out;
config->async = false;
+ config->stream = false;
config->optional = false;
config->keep = false;
config->no_cache = false;
@@ -985,6 +1037,29 @@ static ssize_t config_async_show(struct device *dev,
}
static DEVICE_ATTR(config_async, 0644, config_async_show, config_async_store);
+static ssize_t config_stream_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct driver_data_test_device *test_dev = dev_to_test_dev(dev);
+ struct test_config *config = &test_dev->config;
+
+ return test_dev_config_update_bool(test_dev, buf, count,
+ &config->stream);
+}
+
+static ssize_t config_stream_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct driver_data_test_device *test_dev = dev_to_test_dev(dev);
+ struct test_config *config = &test_dev->config;
+
+ return test_dev_config_show_bool(test_dev, buf, config->stream);
+}
+static DEVICE_ATTR(config_stream, 0644, config_stream_show,
+ config_stream_store);
+
static ssize_t config_optional_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
@@ -1231,6 +1306,7 @@ static struct attribute *test_dev_attrs[] = {
TEST_DRIVER_DATA_DEV_ATTR(config_name),
TEST_DRIVER_DATA_DEV_ATTR(config_default_name),
TEST_DRIVER_DATA_DEV_ATTR(config_async),
+ TEST_DRIVER_DATA_DEV_ATTR(config_stream),
TEST_DRIVER_DATA_DEV_ATTR(config_optional),
TEST_DRIVER_DATA_DEV_ATTR(config_keep),
TEST_DRIVER_DATA_DEV_ATTR(config_no_cache),
diff --git a/tools/testing/selftests/firmware/driver_data.sh b/tools/testing/selftests/firmware/driver_data.sh
index dcbbc78..f63a703 100755
--- a/tools/testing/selftests/firmware/driver_data.sh
+++ b/tools/testing/selftests/firmware/driver_data.sh
@@ -41,6 +41,7 @@ ALL_TESTS="$ALL_TESTS 0010:10:1"
ALL_TESTS="$ALL_TESTS 0011:10:1"
ALL_TESTS="$ALL_TESTS 0012:1:1"
ALL_TESTS="$ALL_TESTS 0013:1:1"
+ALL_TESTS="$ALL_TESTS 0015:1:1"
# Not yet sure how to automate suspend test well yet. For now we expect a
# manual run. If using qemu you can resume a guest using something like the
@@ -244,6 +245,22 @@ config_disable_prealloc()
fi
}
+config_set_stream()
+{
+ if ! echo -n 1 >$DIR/config_stream ; then
+ echo "$0: Unable to unset to stream" >&2
+ exit 1
+ fi
+}
+
+config_disable_stream()
+{
+ if ! echo -n 0 >$DIR/config_stream ; then
+ echo "$0: Unable to set to stream" >&2
+ exit 1
+ fi
+}
+
config_enable_opt_cb()
{
if ! echo -n 1 >$DIR/config_enable_opt_cb; then
@@ -470,6 +487,12 @@ driver_data_set_async_defaults()
config_set_async
}
+driver_data_set_stream_defaults()
+{
+ config_reset
+ config_set_stream
+}
+
set_system_state()
{
STATE="mem"
@@ -886,6 +909,14 @@ driver_data_test_0014()
driver_data_test_0014a
}
+driver_data_test_0015()
+{
+ driver_data_set_stream_defaults
+ config_trigger ${FUNCNAME[0]}
+ config_file_should_match ${FUNCNAME[0]}
+ config_expect_result ${FUNCNAME[0]} SUCCESS
+}
+
list_tests()
{
echo "Test ID list:"
@@ -908,6 +939,7 @@ list_tests()
echo "0012 x $(get_test_count 0012) - Verify api call wills will hunt for files, ignore file"
echo "0013 x $(get_test_count 0013) - Verify api call works"
echo "0014 x $(get_test_count 0013) - Verify api call works with suspend + resume"
+ echo "0015 x $(get_test_count 0015) - Simple streaming loader"
}
test_reqs
--
2.7.4
next prev parent reply other threads:[~2017-05-20 6:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-20 6:49 [PATCHv2 0/3] Add streaming support to driver_data API yi1.li
2017-05-20 6:49 ` [PATCHv2 1/3] firmware: Add streaming support for driver_data_request_sync API yi1.li
2017-05-20 6:49 ` yi1.li [this message]
2017-05-20 6:49 ` [PATCHv2 3/3] fpga_mgr: Add streaming support through the new driver_data API yi1.li
2017-05-22 21:09 ` Alan Tull
2017-05-23 4:11 ` Li, Yi
2017-05-23 15:21 ` Alan Tull
2017-05-23 15:25 ` Alan Tull
2017-05-24 13:25 ` Li, Yi
2017-05-24 13:45 ` Li, Yi
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=1495262948-1106-3-git-send-email-yi1.li@linux.intel.com \
--to=yi1.li@linux.intel.com \
--cc=arend.vanspriel@broadcom.com \
--cc=atull@kernel.org \
--cc=dhowells@redhat.com \
--cc=dwmw2@infradead.org \
--cc=emmanuel.grumbach@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=johannes.berg@intel.com \
--cc=kvalo@codeaurora.org \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luciano.coelho@intel.com \
--cc=luto@kernel.org \
--cc=mcgrof@kernel.org \
--cc=moritz.fischer@ettus.com \
--cc=pjones@redhat.com \
--cc=pmladek@suse.com \
--cc=rafal@milecki.pl \
--cc=rjw@rjwysocki.net \
--cc=takahiro.akashi@linaro.org \
--cc=wagi@monom.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