From c2c66700aca21af5b8cea41c68262dc2bace2174 Mon Sep 17 00:00:00 2001 From: Saket Jha Date: Tue, 14 Jul 2020 14:33:16 -0700 Subject: [PATCH] qcacld-3.0: Add PM QoS CPU affinity support on 5.x kernel Enable PM QoS support for 5.x kernel by adopting dev PM QoS APIs to request device structures for CPUs and then requesting QoS on those CPU devices. Change-Id: I9c7565b44a72145e11178fe360f413ff578142cf CRs-Fixed: 2734025 --- Kbuild | 1 + configs/default_defconfig | 1 + core/hdd/inc/wlan_hdd_main.h | 11 ++-- core/hdd/src/wlan_hdd_main.c | 98 +++++++++++++++++++++++++++++------- 4 files changed, 88 insertions(+), 23 deletions(-) diff --git a/Kbuild b/Kbuild index 5e05c70685..78ff372f45 100644 --- a/Kbuild +++ b/Kbuild @@ -3172,6 +3172,7 @@ endif cppflags-$(CONFIG_WLAN_FEATURE_LL_MODE) += -DWLAN_FEATURE_LL_MODE cppflags-$(CONFIG_WLAN_CLD_PM_QOS) += -DCLD_PM_QOS +cppflags-$(CONFIG_WLAN_CLD_DEV_PM_QOS) += -DCLD_DEV_PM_QOS cppflags-$(CONFIG_REO_DESC_DEFER_FREE) += -DREO_DESC_DEFER_FREE cppflags-$(CONFIG_WLAN_FEATURE_11AX) += -DWLAN_FEATURE_11AX cppflags-$(CONFIG_WLAN_FEATURE_11AX) += -DWLAN_FEATURE_11AX_BSS_COLOR diff --git a/configs/default_defconfig b/configs/default_defconfig index 68196eee26..6f796bd94e 100644 --- a/configs/default_defconfig +++ b/configs/default_defconfig @@ -513,6 +513,7 @@ CONFIG_RX_OL := y CONFIG_TX_TID_OVERRIDE := y CONFIG_DP_TXRX_SOC_ATTACH := y CONFIG_WLAN_CLD_PM_QOS := y +CONFIG_WLAN_CLD_DEV_PM_QOS := y CONFIG_DISABLE_DP_STATS := n CONFIG_MAX_ALLOC_PAGE_SIZE := y CONFIG_REO_DESC_DEFER_FREE := y diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h index d8dbc181f3..98159f6d93 100644 --- a/core/hdd/inc/wlan_hdd_main.h +++ b/core/hdd/inc/wlan_hdd_main.h @@ -111,8 +111,7 @@ #include "qdf_periodic_work.h" #endif -#if defined(CLD_PM_QOS) && \ - (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) +#ifdef CLD_PM_QOS #include #endif @@ -1684,6 +1683,8 @@ struct hdd_fw_ver_info { * @rx_aggregation: rx aggregation enable or disable state * @gro_force_flush: gro force flushed indication flag * @current_pcie_gen_speed: current pcie gen speed + * @pm_qos_req: pm_qos request for all cpu cores + * @qos_cpu_mask: voted cpu core mask */ struct hdd_context { struct wlan_objmgr_psoc *psoc; @@ -1993,8 +1994,10 @@ struct hdd_context { qdf_time_t runtime_resume_start_time_stamp; qdf_time_t runtime_suspend_done_time_stamp; -#if defined(CLD_PM_QOS) && \ - (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) +#if defined(CLD_PM_QOS) && defined(CLD_DEV_PM_QOS) + struct dev_pm_qos_request pm_qos_req[NR_CPUS]; + struct cpumask qos_cpu_mask; +#elif defined(CLD_PM_QOS) struct pm_qos_request pm_qos_req; #endif #ifdef WLAN_FEATURE_PKT_CAPTURE diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 9007ff9879..c53b299a07 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -9106,10 +9106,11 @@ static void hdd_clear_rps_cpu_mask(struct hdd_context *hdd_ctx) hdd_send_rps_disable_ind(adapter); } -#if defined(CLD_PM_QOS) && \ - (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) +#ifdef CLD_PM_QOS #define PLD_REMOVE_PM_QOS(x) #define PLD_REQUEST_PM_QOS(x, y) +#define HDD_PM_QOS_HIGH_TPUT_LATENCY_US 1 + /** * hdd_pm_qos_update_cpu_mask() - Prepare CPU mask for PM_qos voting * @mask: return variable of cpumask for the TPUT @@ -9133,6 +9134,18 @@ static inline void hdd_pm_qos_update_cpu_mask(cpumask_t *mask, } } +#ifdef FEATURE_RUNTIME_PM +static inline bool hdd_is_dynamic_runtime_pm_enabled(struct hdd_context *hdd_ctx) +{ + return hdd_ctx->config->runtime_pm == hdd_runtime_pm_dynamic; +} +#else +static inline bool hdd_is_dynamic_runtime_pm_enabled(struct hdd_context *hdd_ctx) +{ + return true; +} +#endif + #ifdef MSM_PLATFORM #define COPY_CPU_MASK(a, b) cpumask_copy(a, b) #define DUMP_CPU_AFFINE() hdd_info("Set cpu_mask %*pb for affine_cores", \ @@ -9142,6 +9155,7 @@ static inline void hdd_pm_qos_update_cpu_mask(cpumask_t *mask, #define DUMP_CPU_AFFINE() /* no-op*/ #endif +#ifdef CLD_DEV_PM_QOS /** * hdd_pm_qos_update_request() - API to request for pm_qos * @hdd_ctx: handle to hdd context @@ -9149,56 +9163,100 @@ static inline void hdd_pm_qos_update_cpu_mask(cpumask_t *mask, * * Return: none */ -#ifdef FEATURE_RUNTIME_PM static inline void hdd_pm_qos_update_request(struct hdd_context *hdd_ctx, cpumask_t *pm_qos_cpu_mask) { - COPY_CPU_MASK(&hdd_ctx->pm_qos_req.cpus_affine, pm_qos_cpu_mask); + int cpu; + unsigned int latency; + + cpumask_copy(&hdd_ctx->qos_cpu_mask, pm_qos_cpu_mask); - /* Latency value to be read from INI */ if (cpumask_empty(pm_qos_cpu_mask) && - hdd_ctx->config->runtime_pm == hdd_runtime_pm_dynamic) - pm_qos_update_request(&hdd_ctx->pm_qos_req, - PM_QOS_DEFAULT_VALUE); + hdd_is_dynamic_runtime_pm_enabled(hdd_ctx)) + latency = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE; else - pm_qos_update_request(&hdd_ctx->pm_qos_req, 1); + latency = HDD_PM_QOS_HIGH_TPUT_LATENCY_US; + + for_each_cpu(cpu, &hdd_ctx->qos_cpu_mask) { + dev_pm_qos_update_request(&hdd_ctx->pm_qos_req[cpu], + latency); + } } -#else + +static inline void hdd_pm_qos_add_request(struct hdd_context *hdd_ctx) +{ + struct device *cpu_dev; + int cpu; + + qdf_cpumask_clear(&hdd_ctx->qos_cpu_mask); + hdd_pm_qos_update_cpu_mask(&hdd_ctx->qos_cpu_mask, false); + + for_each_possible_cpu(cpu) { + cpu_dev = get_cpu_device(cpu); + + dev_pm_qos_add_request(cpu_dev, &hdd_ctx->pm_qos_req[cpu], + DEV_PM_QOS_RESUME_LATENCY, + PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE); + hdd_debug("Set qos_cpu_mask %*pb for affine_cores", + cpumask_pr_args(&hdd_ctx->qos_cpu_mask)); + } +} + +static inline void hdd_pm_qos_remove_request(struct hdd_context *hdd_ctx) +{ + int cpu; + + for_each_possible_cpu(cpu) { + dev_pm_qos_remove_request(&hdd_ctx->pm_qos_req[cpu]); + hdd_debug("Remove dev_pm_qos_request for all cpus: %d", cpu); + } + qdf_cpumask_clear(&hdd_ctx->qos_cpu_mask); +} + +#else /* CLD_DEV_PM_QOS */ + +/** + * hdd_pm_qos_update_request() - API to request for pm_qos + * @hdd_ctx: handle to hdd context + * @pm_qos_cpu_mask: cpu_mask to apply + * + * Return: none + */ static inline void hdd_pm_qos_update_request(struct hdd_context *hdd_ctx, cpumask_t *pm_qos_cpu_mask) { COPY_CPU_MASK(&hdd_ctx->pm_qos_req.cpus_affine, pm_qos_cpu_mask); - /* Latency value to be read from INI */ - if (cpumask_empty(pm_qos_cpu_mask)) + if (cpumask_empty(pm_qos_cpu_mask) && + hdd_is_dynamic_runtime_pm_enabled(hdd_ctx)) pm_qos_update_request(&hdd_ctx->pm_qos_req, PM_QOS_DEFAULT_VALUE); else pm_qos_update_request(&hdd_ctx->pm_qos_req, 1); } -#endif #if defined(CONFIG_SMP) && defined(MSM_PLATFORM) /** - * hdd_update_pm_qos_affine_cores() - Update PM_qos request for AFFINE_CORES + * hdd_set_default_pm_qos_mask() - Update PM_qos request for AFFINE_CORES * @hdd_ctx: handle to hdd context * * Return: none */ -static inline void hdd_update_pm_qos_affine_cores(struct hdd_context *hdd_ctx) +static inline void hdd_set_default_pm_qos_mask(struct hdd_context *hdd_ctx) { hdd_ctx->pm_qos_req.type = PM_QOS_REQ_AFFINE_CORES; qdf_cpumask_clear(&hdd_ctx->pm_qos_req.cpus_affine); hdd_pm_qos_update_cpu_mask(&hdd_ctx->pm_qos_req.cpus_affine, false); } #else -static inline void hdd_update_pm_qos_affine_cores(struct hdd_context *hdd_ctx) +static inline void hdd_set_default_pm_qos_mask(struct hdd_context *hdd_ctx) { } #endif + static inline void hdd_pm_qos_add_request(struct hdd_context *hdd_ctx) { - hdd_update_pm_qos_affine_cores(hdd_ctx); + hdd_set_default_pm_qos_mask(hdd_ctx); pm_qos_add_request(&hdd_ctx->pm_qos_req, PM_QOS_CPU_DMA_LATENCY, PM_QOS_DEFAULT_VALUE); DUMP_CPU_AFFINE(); @@ -9208,7 +9266,9 @@ static inline void hdd_pm_qos_remove_request(struct hdd_context *hdd_ctx) { pm_qos_remove_request(&hdd_ctx->pm_qos_req); } -#else +#endif /* CLD_DEV_PM_QOS */ + +#else /* CLD_PM_QOS */ #define PLD_REMOVE_PM_QOS(x) pld_remove_pm_qos(x) #define PLD_REQUEST_PM_QOS(x, y) pld_request_pm_qos(x, y) @@ -9229,7 +9289,7 @@ static inline void hdd_pm_qos_update_request(struct hdd_context *hdd_ctx, cpumask_t *pm_qos_cpu_mask) { } -#endif +#endif /* CLD_PM_QOS */ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) static inline void hdd_low_tput_gro_flush_skip_check(