From patchwork Sat May 20 06:46:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Yi" X-Patchwork-Id: 9738479 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 77C026041F for ; Sat, 20 May 2017 06:52:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CE97284DA for ; Sat, 20 May 2017 06:52:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6152E285C2; Sat, 20 May 2017 06:52:27 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 D721F285BD for ; Sat, 20 May 2017 06:52:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756697AbdETGwV (ORCPT ); Sat, 20 May 2017 02:52:21 -0400 Received: from mga05.intel.com ([192.55.52.43]:26831 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756650AbdETGwT (ORCPT ); Sat, 20 May 2017 02:52:19 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP; 19 May 2017 23:52:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,367,1491289200"; d="scan'208";a="1150535750" Received: from yi-patch.an.intel.com ([10.122.105.158]) by fmsmga001.fm.intel.com with ESMTP; 19 May 2017 23:52:17 -0700 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 Subject: [PATCHv2 3/3] test: add no_cache to driver_data load tester Date: Sat, 20 May 2017 01:46:59 -0500 Message-Id: <1495262819-981-4-git-send-email-yi1.li@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495262819-981-1-git-send-email-yi1.li@linux.intel.com> References: <1495262819-981-1-git-send-email-yi1.li@linux.intel.com> Sender: linux-fpga-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Yi Li This adds a no_cache flag to simple sync and async test. Signed-off-by: Yi Li --- lib/test_driver_data.c | 43 +++++++++++++++++++++++-- tools/testing/selftests/firmware/driver_data.sh | 36 +++++++++++++++++++++ 2 files changed, 76 insertions(+), 3 deletions(-) diff --git a/lib/test_driver_data.c b/lib/test_driver_data.c index 488cc6e..fa7f52b 100644 --- a/lib/test_driver_data.c +++ b/lib/test_driver_data.c @@ -64,6 +64,10 @@ int num_test_devs; * struct driver_data_reg_params @optional field for more information. * @keep: whether or not we wish to free the driver_data on our own, refer to * the struct driver_data_req_params @keep field for more information. + * @no_cache: whether or not we wish to use the internal caching mechanism + * to assist drivers from fetching driver data at resume time after + * suspend, refer to the struct driver_data_req_params .req + * DRIVER_DATA_REQ_NO_CACHE for more information. * @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 @@ -112,6 +116,7 @@ struct test_config { bool async; bool optional; bool keep; + bool no_cache; bool enable_opt_cb; bool use_api_versioning; u8 api_min; @@ -337,6 +342,9 @@ static ssize_t config_show(struct device *dev, len += snprintf(buf+len, PAGE_SIZE, "keep:\t\t%s\n", config->keep ? "true" : "false"); + len += snprintf(buf+len, PAGE_SIZE, + "no_cache:\t\t%s\n", + config->no_cache ? "true" : "false"); mutex_unlock(&test_dev->config_mutex); @@ -452,7 +460,8 @@ static int trigger_config_sync(struct driver_data_test_device *test_dev) DRIVER_DATA_SYNC_OPT_CB(config_sync_req_default_cb, test_dev), .reqs = (config->optional ? DRIVER_DATA_REQ_OPTIONAL : 0) | - (config->keep ? DRIVER_DATA_REQ_KEEP : 0), + (config->keep ? DRIVER_DATA_REQ_KEEP : 0) | + (config->no_cache ? DRIVER_DATA_REQ_NO_CACHE : 0), }; const struct driver_data_req_params *req_params; @@ -518,19 +527,22 @@ static int trigger_config_async(struct driver_data_test_device *test_dev) const struct driver_data_req_params req_params_default = { DRIVER_DATA_DEFAULT_ASYNC(config_async_req_cb, test_dev), .reqs = (config->optional ? DRIVER_DATA_REQ_OPTIONAL : 0) | - (config->keep ? DRIVER_DATA_REQ_KEEP : 0), + (config->keep ? DRIVER_DATA_REQ_KEEP : 0) | + (config->no_cache ? DRIVER_DATA_REQ_NO_CACHE : 0), }; const struct driver_data_req_params req_params_opt_cb = { DRIVER_DATA_DEFAULT_ASYNC(config_async_req_cb, test_dev), DRIVER_DATA_ASYNC_OPT_CB(config_async_req_default_cb, test_dev), .reqs = (config->optional ? DRIVER_DATA_REQ_OPTIONAL : 0) | - (config->keep ? DRIVER_DATA_REQ_KEEP : 0), + (config->keep ? DRIVER_DATA_REQ_KEEP : 0) | + (config->no_cache ? DRIVER_DATA_REQ_NO_CACHE : 0), }; const struct driver_data_req_params req_params_api = { DRIVER_DATA_API_CB(config_async_req_api_cb, test_dev), DRIVER_DATA_API(config->api_min, config->api_max, config->api_name_postfix), .reqs = (config->optional ? DRIVER_DATA_REQ_OPTIONAL : 0) | (config->keep ? DRIVER_DATA_REQ_KEEP : 0) | + (config->no_cache ? DRIVER_DATA_REQ_NO_CACHE : 0) | (config->use_api_versioning ? DRIVER_DATA_REQ_USE_API_VERSIONING : 0), }; const struct driver_data_req_params *req_params; @@ -656,6 +668,7 @@ static int __driver_data_config_init(struct test_config *config) config->async = false; config->optional = false; config->keep = false; + config->no_cache = false; config->enable_opt_cb = false; config->use_api_versioning = false; config->api_min = 0; @@ -975,6 +988,29 @@ static ssize_t config_keep_show(struct device *dev, } static DEVICE_ATTR(config_keep, 0644, config_keep_show, config_keep_store); +static ssize_t config_no_cache_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->no_cache); +} + +static ssize_t config_no_cache_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->no_cache); +} +static DEVICE_ATTR(config_no_cache, 0644, config_no_cache_show, + config_no_cache_store); + static ssize_t config_enable_opt_cb_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -1132,6 +1168,7 @@ static struct attribute *test_dev_attrs[] = { TEST_DRIVER_DATA_DEV_ATTR(config_async), TEST_DRIVER_DATA_DEV_ATTR(config_optional), TEST_DRIVER_DATA_DEV_ATTR(config_keep), + TEST_DRIVER_DATA_DEV_ATTR(config_no_cache), TEST_DRIVER_DATA_DEV_ATTR(config_use_api_versioning), TEST_DRIVER_DATA_DEV_ATTR(config_enable_opt_cb), TEST_DRIVER_DATA_DEV_ATTR(config_api_min), diff --git a/tools/testing/selftests/firmware/driver_data.sh b/tools/testing/selftests/firmware/driver_data.sh index c830d04..82fae0a 100755 --- a/tools/testing/selftests/firmware/driver_data.sh +++ b/tools/testing/selftests/firmware/driver_data.sh @@ -212,6 +212,22 @@ config_disable_keep() fi } +config_set_no_cache() +{ + if ! echo -n 1 >$DIR/config_no_cache; then + echo "$0: Unable to set to no_cache" >&2 + exit 1 + fi +} + +config_disable_no_cache() +{ + if ! echo -n 0 >$DIR/config_no_cache; then + echo "$0: Unable to disable no_cache option" >&2 + exit 1 + fi +} + config_enable_opt_cb() { if ! echo -n 1 >$DIR/config_enable_opt_cb; then @@ -525,10 +541,30 @@ driver_data_test_0004a() config_expect_result ${FUNCNAME[0]} SUCCESS } +driver_data_test_0004s_no_cache() +{ + driver_data_set_sync_defaults + config_set_no_cache + config_trigger ${FUNCNAME[0]} + config_file_should_match ${FUNCNAME[0]} + config_expect_result ${FUNCNAME[0]} SUCCESS +} + +driver_data_test_0004a_no_cache() +{ + driver_data_set_async_defaults + config_set_no_cache + config_trigger ${FUNCNAME[0]} + config_file_should_match ${FUNCNAME[0]} + config_expect_result ${FUNCNAME[0]} SUCCESS +} + driver_data_test_0004() { driver_data_test_0004s driver_data_test_0004a + driver_data_test_0004s_no_cache + driver_data_test_0004a_no_cache } driver_data_test_0005s()