From 447b9395ffecca6815016016ac664b8c42a2720b Mon Sep 17 00:00:00 2001 From: Rakesh Pillai Date: Sun, 30 Aug 2020 00:39:21 -0700 Subject: [PATCH] qcacld-3.0: Add sysfs entry to control SWLM Add sysfs entry to enable or disable the Software latency manager runtime. Change-Id: Iaa920c7c71586b3200322a704003abcf95840edc CRs-Fixed: 2769035 --- Kbuild | 3 + core/hdd/inc/wlan_hdd_sysfs_swlm.h | 49 +++++++++ core/hdd/src/wlan_hdd_sysfs.c | 3 + core/hdd/src/wlan_hdd_sysfs_swlm.c | 154 +++++++++++++++++++++++++++++ 4 files changed, 209 insertions(+) create mode 100644 core/hdd/inc/wlan_hdd_sysfs_swlm.h create mode 100644 core/hdd/src/wlan_hdd_sysfs_swlm.c diff --git a/Kbuild b/Kbuild index 7f2cbc7df4e4..f22dca2e2a4c 100644 --- a/Kbuild +++ b/Kbuild @@ -366,6 +366,9 @@ HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_dl_modes.o endif HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_policy_mgr.o HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_dp_aggregation.o +ifeq ($(CONFIG_DP_SWLM), y) +HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_swlm.o +endif endif ifeq ($(CONFIG_QCACLD_FEATURE_FW_STATE), y) diff --git a/core/hdd/inc/wlan_hdd_sysfs_swlm.h b/core/hdd/inc/wlan_hdd_sysfs_swlm.h new file mode 100644 index 000000000000..2298af541e3a --- /dev/null +++ b/core/hdd/inc/wlan_hdd_sysfs_swlm.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2020 The Linux Foundation. All rights reserved. + * + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all + * copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _WLAN_HDD_SYSFS_SWLM_H_ +#define _WLAN_HDD_SYSFS_SWLM_H_ + +#ifdef WLAN_DP_FEATURE_SW_LATENCY_MGR +/** + * hdd_sysfs_dp_swlm_create() - Create SWLM specific sysfs entry + * @driver_kobject: Driver kobject + * + * Returns: none + */ +int hdd_sysfs_dp_swlm_create(struct kobject *driver_kobject); + +/** + * hdd_sysfs_dp_swlm_destroy() - Destroy SWLM specific sysfs entry + * @driver_kobject: Driver kobject + * + * Returns: none + */ +void hdd_sysfs_dp_swlm_destroy(struct kobject *driver_kobject); +#else +static inline int hdd_sysfs_dp_swlm_create(struct kobject *driver_kobject) +{ + return 0; +} + +static inline void hdd_sysfs_dp_swlm_destroy(struct kobject *driver_kobject) +{ +} +#endif /* WLAN_DP_FEATURE_SW_LATENCY_MGR */ + +#endif diff --git a/core/hdd/src/wlan_hdd_sysfs.c b/core/hdd/src/wlan_hdd_sysfs.c index beebfb239983..a8fcac78a51e 100644 --- a/core/hdd/src/wlan_hdd_sysfs.c +++ b/core/hdd/src/wlan_hdd_sysfs.c @@ -75,6 +75,7 @@ #include #include #include +#include #define MAX_PSOC_ID_SIZE 10 @@ -781,12 +782,14 @@ void hdd_create_sysfs_files(struct hdd_context *hdd_ctx) hdd_sysfs_pm_pcl_create(driver_kobject); hdd_sysfs_pm_dbs_create(driver_kobject); hdd_sysfs_dp_aggregation_create(driver_kobject); + hdd_sysfs_dp_swlm_create(driver_kobject); } } void hdd_destroy_sysfs_files(void) { if (QDF_GLOBAL_MISSION_MODE == hdd_get_conparam()) { + hdd_sysfs_dp_swlm_destroy(driver_kobject); hdd_sysfs_dp_aggregation_destroy(driver_kobject); hdd_sysfs_pm_dbs_destroy(driver_kobject); hdd_sysfs_pm_pcl_destroy(driver_kobject); diff --git a/core/hdd/src/wlan_hdd_sysfs_swlm.c b/core/hdd/src/wlan_hdd_sysfs_swlm.c new file mode 100644 index 000000000000..f47657bd58eb --- /dev/null +++ b/core/hdd/src/wlan_hdd_sysfs_swlm.c @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2020 The Linux Foundation. All rights reserved. + * + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all + * copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + +static ssize_t +__hdd_sysfs_dp_swlm_show(struct hdd_context *hdd_ctx, + struct kobj_attribute *attr, char *buf) +{ + ol_txrx_soc_handle soc_hdl = cds_get_context(QDF_MODULE_ID_SOC); + + if (!wlan_hdd_validate_modules_state(hdd_ctx)) + return -EINVAL; + + return scnprintf(buf, PAGE_SIZE, "dp_swlm enable: %d\n", + cdp_soc_is_swlm_enabled(soc_hdl)); +} + +static ssize_t hdd_sysfs_dp_swlm_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buf) +{ + struct osif_psoc_sync *psoc_sync; + struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); + ssize_t errno_size; + int ret; + + ret = wlan_hdd_validate_context(hdd_ctx); + if (ret != 0) + return ret; + + errno_size = osif_psoc_sync_op_start(wiphy_dev(hdd_ctx->wiphy), + &psoc_sync); + if (errno_size) + return errno_size; + + errno_size = __hdd_sysfs_dp_swlm_show(hdd_ctx, attr, buf); + + osif_psoc_sync_op_stop(psoc_sync); + + return errno_size; +} + +static ssize_t +__hdd_sysfs_dp_swlm_store(struct hdd_context *hdd_ctx, + struct kobj_attribute *attr, const char *buf, + size_t count) +{ + char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1]; + char *sptr, *token; + uint32_t value; + int ret; + ol_txrx_soc_handle dp_soc = cds_get_context(QDF_MODULE_ID_SOC); + + if (!wlan_hdd_validate_modules_state(hdd_ctx) || !dp_soc) + return -EINVAL; + + ret = hdd_sysfs_validate_and_copy_buf(buf_local, sizeof(buf_local), + buf, count); + + if (ret) { + hdd_err_rl("invalid input"); + return ret; + } + + sptr = buf_local; + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou32(token, 0, &value)) + return -EINVAL; + + hdd_debug("dp_swlm: %d", value); + + cdp_soc_set_swlm_enable(dp_soc, value); + + return count; +} + +static ssize_t +hdd_sysfs_dp_swlm_store(struct kobject *kobj, + struct kobj_attribute *attr, + char const *buf, size_t count) +{ + struct osif_psoc_sync *psoc_sync; + struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); + ssize_t errno_size; + int ret; + + ret = wlan_hdd_validate_context(hdd_ctx); + if (ret != 0) + return ret; + + errno_size = osif_psoc_sync_op_start(wiphy_dev(hdd_ctx->wiphy), + &psoc_sync); + if (errno_size) + return errno_size; + + errno_size = __hdd_sysfs_dp_swlm_store(hdd_ctx, attr, + buf, count); + + osif_psoc_sync_op_stop(psoc_sync); + + return errno_size; +} + +static struct kobj_attribute dp_swlm_attribute = + __ATTR(dp_swlm, 0664, hdd_sysfs_dp_swlm_show, + hdd_sysfs_dp_swlm_store); + +int hdd_sysfs_dp_swlm_create(struct kobject *driver_kobject) +{ + int error; + + if (!driver_kobject) { + hdd_err("could not get driver kobject!"); + return -EINVAL; + } + + error = sysfs_create_file(driver_kobject, + &dp_swlm_attribute.attr); + if (error) + hdd_err("could not create dp_swlm sysfs file"); + + return error; +} + +void hdd_sysfs_dp_swlm_destroy(struct kobject *driver_kobject) +{ + if (!driver_kobject) { + hdd_err("could not get driver kobject!"); + return; + } + + sysfs_remove_file(driver_kobject, &dp_swlm_attribute.attr); +}