From patchwork Tue Dec 17 20:26:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalle Valo X-Patchwork-Id: 13912463 X-Patchwork-Delegate: quic_jjohnson@quicinc.com Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D59EA1F9EAD for ; Tue, 17 Dec 2024 20:26:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734467181; cv=none; b=O1ibFVmjilRW1zmOQNBXYkfcQdrAQ4MnBcy5J2nauLybRJN9l2MTNeQXlf7PLLFEYxqFTQYXZokeZdfmJ+Bk69RY8k8knn4LZorTdDYIKtsoO/mrjRTIeKJbr2JXqlZfAG/DyFgsKHcgaclgWR5gOP2y7KLkAs1Fg871Zs6z1WM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734467181; c=relaxed/simple; bh=oHhMU+EKio682SB2+Dh1hNm9yIecNFwww1aqgC/Qv50=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Gi6cuhcxch6FVG61HDwHaFhjPzsTHCJPkoMLbk72EvucIj41OrN50qRDv+d9bJOB6zLOoVzMTIGIut1nkhyNZmjgprQMYhXlDlcg+GabUEqDLC5CA7l+bdTHlfoPF6pEUmLOleaGuohyThl/fh5hc6oB75AWpesnoDEKGTR+l+A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UnVRgpu5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UnVRgpu5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC24CC4CEDD; Tue, 17 Dec 2024 20:26:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734467181; bh=oHhMU+EKio682SB2+Dh1hNm9yIecNFwww1aqgC/Qv50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UnVRgpu5leLLhjvxgOkwrCuxsBcwxrb/MwHGZeGFnOSoQBJpLRN4mdKl8a9ZV7Gtb s8A8Pl7NMtZCEe/qdPdtIBzP5DfkIbLl1n6dM6PCbad7QiGtz1ZMKphIqo4qgLZ1v8 ONc3S67ROBtiVKPsBAoRdamlUIs+O0S9MWnkBeopvikQCQrhRtdJiFdBGJQnhXbigD jfq4gl1PmREURcxOuASqmIpl5pZQmxNGnnIffmw0sqfRreMIFXYw3gU6Od93Vgah4p hB18k/6jZpuBve56SeTvISE9fYI2EwFw1BumrrgmX0aYvds16eXJ4d18uQAzTMWRpH hWTnTKXRdJ80A== From: Kalle Valo To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org Subject: [PATCH 1/4] wifi: ath12k: Decrease ath12k_mac_op_remain_on_channel() stack usage Date: Tue, 17 Dec 2024 22:26:15 +0200 Message-Id: <20241217202618.1329312-2-kvalo@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241217202618.1329312-1-kvalo@kernel.org> References: <20241217202618.1329312-1-kvalo@kernel.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jeff Johnson Building the ath12k driver with llvm-18.1.7-x86_64 produces the warning: drivers/net/wireless/ath/ath12k/mac.c:10028:12: warning: stack frame size (1080) exceeds limit (1024) in 'ath12k_mac_op_remain_on_channel' [-Wframe-larger-than] A major contributor to the stack usage in this function is: struct ath12k_wmi_scan_req_arg arg; Avoid the excess stack usage by dynamically allocating arg instead of declaring it on the stack. As part of the effort use __free() for both this new allocation as well as the existing chan_list allocation, and since then no central cleanup is required, replace all cleanup gotos with returns. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1 Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3 Signed-off-by: Jeff Johnson Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath12k/mac.c | 76 ++++++++++++--------------- 1 file changed, 33 insertions(+), 43 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index 186765fa95f5..05d2c75e5df2 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -10054,7 +10054,6 @@ static int ath12k_mac_op_remain_on_channel(struct ieee80211_hw *hw, { struct ath12k_vif *ahvif = ath12k_vif_to_ahvif(vif); struct ath12k_hw *ah = ath12k_hw_to_ah(hw); - struct ath12k_wmi_scan_req_arg arg; struct ath12k_link_vif *arvif; struct ath12k *ar; u32 scan_time_msec; @@ -10065,10 +10064,8 @@ static int ath12k_mac_op_remain_on_channel(struct ieee80211_hw *hw, lockdep_assert_wiphy(hw->wiphy); ar = ath12k_mac_select_scan_device(hw, vif, chan->center_freq); - if (!ar) { - ret = -EINVAL; - goto exit; - } + if (!ar) + return -EINVAL; /* check if any of the links of ML VIF is already started on * radio(ar) correpsondig to given scan frequency and use it, @@ -10087,15 +10084,11 @@ static int ath12k_mac_op_remain_on_channel(struct ieee80211_hw *hw, * always on the same band for the vif */ if (arvif->is_created) { - if (WARN_ON(!arvif->ar)) { - ret = -EINVAL; - goto exit; - } + if (WARN_ON(!arvif->ar)) + return -EINVAL; - if (ar != arvif->ar && arvif->is_started) { - ret = -EBUSY; - goto exit; - } + if (ar != arvif->ar && arvif->is_started) + return -EBUSY; if (ar != arvif->ar) { ath12k_mac_remove_link_interface(hw, arvif); @@ -10112,7 +10105,7 @@ static int ath12k_mac_op_remain_on_channel(struct ieee80211_hw *hw, if (ret) { ath12k_warn(ar->ab, "unable to create scan vdev for roc: %d\n", ret); - goto exit; + return ret; } } @@ -10140,37 +10133,41 @@ static int ath12k_mac_op_remain_on_channel(struct ieee80211_hw *hw, spin_unlock_bh(&ar->data_lock); if (ret) - goto exit; + return ret; scan_time_msec = hw->wiphy->max_remain_on_channel_duration * 2; - memset(&arg, 0, sizeof(arg)); - ath12k_wmi_start_scan_init(ar, &arg); - arg.num_chan = 1; - arg.chan_list = kcalloc(arg.num_chan, sizeof(*arg.chan_list), - GFP_KERNEL); - if (!arg.chan_list) { - ret = -ENOMEM; - goto exit; - } + struct ath12k_wmi_scan_req_arg *arg __free(kfree) = + kzalloc(sizeof(*arg), GFP_KERNEL); + if (!arg) + return -ENOMEM; - arg.vdev_id = arvif->vdev_id; - arg.scan_id = ATH12K_SCAN_ID; - arg.chan_list[0] = chan->center_freq; - arg.dwell_time_active = scan_time_msec; - arg.dwell_time_passive = scan_time_msec; - arg.max_scan_time = scan_time_msec; - arg.scan_f_passive = 1; - arg.burst_duration = duration; + ath12k_wmi_start_scan_init(ar, arg); + arg->num_chan = 1; - ret = ath12k_start_scan(ar, &arg); + u32 *chan_list __free(kfree) = kcalloc(arg->num_chan, sizeof(*chan_list), + GFP_KERNEL); + if (!chan_list) + return -ENOMEM; + + arg->chan_list = chan_list; + arg->vdev_id = arvif->vdev_id; + arg->scan_id = ATH12K_SCAN_ID; + arg->chan_list[0] = chan->center_freq; + arg->dwell_time_active = scan_time_msec; + arg->dwell_time_passive = scan_time_msec; + arg->max_scan_time = scan_time_msec; + arg->scan_f_passive = 1; + arg->burst_duration = duration; + + ret = ath12k_start_scan(ar, arg); if (ret) { ath12k_warn(ar->ab, "failed to start roc scan: %d\n", ret); spin_lock_bh(&ar->data_lock); ar->scan.state = ATH12K_SCAN_IDLE; spin_unlock_bh(&ar->data_lock); - goto free_chan_list; + return ret; } ret = wait_for_completion_timeout(&ar->scan.on_channel, 3 * HZ); @@ -10179,20 +10176,13 @@ static int ath12k_mac_op_remain_on_channel(struct ieee80211_hw *hw, ret = ath12k_scan_stop(ar); if (ret) ath12k_warn(ar->ab, "failed to stop scan: %d\n", ret); - ret = -ETIMEDOUT; - goto free_chan_list; + return -ETIMEDOUT; } ieee80211_queue_delayed_work(hw, &ar->scan.timeout, msecs_to_jiffies(duration)); - ret = 0; - -free_chan_list: - kfree(arg.chan_list); - -exit: - return ret; + return 0; } static void ath12k_mac_op_set_rekey_data(struct ieee80211_hw *hw, From patchwork Tue Dec 17 20:26:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalle Valo X-Patchwork-Id: 13912464 X-Patchwork-Delegate: quic_jjohnson@quicinc.com Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0203C1F9EC1 for ; Tue, 17 Dec 2024 20:26:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734467183; cv=none; b=IwJxQiLGNI1GtdPvFjW2nPNR13pYInc+1tobubV3Yme8juHgXzq1jeGcbtvRXrhNV5ZdQLlC62l61qD4smTivQyG0+X6Tb1N23p+j0WRqnIuIZ7eQH7tPlJrW7PaPzHdetJeDHiYNxV2d5DsP6CQm/+A51Prr4B6tiOKrgE0x+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734467183; c=relaxed/simple; bh=VQm3hiNA3kQgkmtCDPPom8HziQB3vh3sJutG7be7roQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RyqsEPFbNdmPO4mRL0XGlgcbX0IQfKgdv5TZpJyus7ZQ3byBwNONgfa7oyj4hR0WIjBEghutdNO+94u4zKDYd9OOvjR+LJFDk9glH3w0nrT8HnD5kcr6217L58BF/XUry2e33s4YtKGhsPelWigaPZaNzBP0+YKJrzMmDmQKFu0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WRLlI3z+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WRLlI3z+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7144C4CED3; Tue, 17 Dec 2024 20:26:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734467182; bh=VQm3hiNA3kQgkmtCDPPom8HziQB3vh3sJutG7be7roQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WRLlI3z+9qlYlrUL2d4MkKeCsOIhiJ6Ddd4O0qbRt6zBNNp+/S3HfKooLgMCADkeu p4Y5Kbb+CQja4CQoecFwAY6ZMnQFWcRQOXHPH2YPTU2nw5+LWcbbMtjdtsheL39qSi Dl11sU6ZSZQUJAJN2lK/Tm7BI6aQ7R/1IvphNxOS57lqgaB/oO5iTyf+lVuAuy/Iu5 MmgDlFki8RHbRawIkd092HvzMmDRZzy2+Ats5zGNZnRnTf7v5BvtsaHlY6yFKetbwT 1HlLyZ2f1ryAVc3HC/sEtEaCAea1bV3KV4p9uXGNO41Jd+G4EjewQNOjv2yCSKD1L7 X5mt0HYPs5qbg== From: Kalle Valo To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org Subject: [PATCH 2/4] wifi: ath12k: Decrease ath12k_bss_assoc() stack usage Date: Tue, 17 Dec 2024 22:26:16 +0200 Message-Id: <20241217202618.1329312-3-kvalo@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241217202618.1329312-1-kvalo@kernel.org> References: <20241217202618.1329312-1-kvalo@kernel.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jeff Johnson Currently when building ath12k with gcc-14.2.0 the following warning is observed: drivers/net/wireless/ath/ath12k/mac.c: In function 'ath12k_bss_assoc': drivers/net/wireless/ath/ath12k/mac.c:3080:1: warning: the frame size of 1040 bytes is larger than 1024 bytes [-Wframe-larger-than=] A major contributor to the stack usage in this function is: struct ath12k_wmi_peer_assoc_arg peer_arg; Avoid the excess stack usage by dynamically allocating peer_arg instead of declaring it on the stack. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1 Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3 Signed-off-by: Jeff Johnson Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath12k/mac.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index 05d2c75e5df2..2a30a11903c5 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -3133,7 +3133,6 @@ static void ath12k_bss_assoc(struct ath12k *ar, struct ath12k_vif *ahvif = arvif->ahvif; struct ieee80211_vif *vif = ath12k_ahvif_to_vif(ahvif); struct ath12k_wmi_vdev_up_params params = {}; - struct ath12k_wmi_peer_assoc_arg peer_arg = {}; struct ieee80211_link_sta *link_sta; u8 link_id = bss_conf->link_id; struct ath12k_link_sta *arsta; @@ -3145,6 +3144,11 @@ static void ath12k_bss_assoc(struct ath12k *ar, lockdep_assert_wiphy(ath12k_ar_to_hw(ar)->wiphy); + struct ath12k_wmi_peer_assoc_arg *peer_arg __free(kfree) = + kzalloc(sizeof(*peer_arg), GFP_KERNEL); + if (!peer_arg) + return; + ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac vdev %i link id %u assoc bssid %pM aid %d\n", arvif->vdev_id, link_id, arvif->bssid, ahvif->aid); @@ -3177,11 +3181,11 @@ static void ath12k_bss_assoc(struct ath12k *ar, return; } - ath12k_peer_assoc_prepare(ar, arvif, arsta, &peer_arg, false); + ath12k_peer_assoc_prepare(ar, arvif, arsta, peer_arg, false); rcu_read_unlock(); - ret = ath12k_wmi_send_peer_assoc_cmd(ar, &peer_arg); + ret = ath12k_wmi_send_peer_assoc_cmd(ar, peer_arg); if (ret) { ath12k_warn(ar->ab, "failed to run peer assoc for %pM vdev %i: %d\n", bss_conf->bssid, arvif->vdev_id, ret); From patchwork Tue Dec 17 20:26:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalle Valo X-Patchwork-Id: 13912465 X-Patchwork-Delegate: quic_jjohnson@quicinc.com Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00F131F9ED4 for ; Tue, 17 Dec 2024 20:26:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734467184; cv=none; b=YqYyEdse1MiIrWS5j/S5/nHJteF1ZY5MQBQkSrjDZaZyJGrCOT/Mw28qn2PHpcc8DW3G8iMrszQWVXR1Eh0DnJR1FUtGccHDHbb1yZsWUeFmf8GYoEYSwWIXaqrMr9tWk7fsfMKqRPc4rfp1VMPm+oVBwp5EjBJ5FcBk3mYMN60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734467184; c=relaxed/simple; bh=szKv4c+yIO8qpqVrfikQ7GZl6LC2oSeWMMQ6QkdbdLs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mmQk45AL1DK59hnIa+X7y/qgTnl3Y0lm9iO2FbOzI0t9B70+IkIIwAj4+wUjYhm4wWT2bGVpVl181rVMTnEISfbGKPRDAKAdy3uJljqaEmwh72eh8J5vfutVTYW9WXV184qxPZ89bs3XigPsaFzWspjOks4HhdkY3uQEU9xoclI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oPe7YA12; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oPe7YA12" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1A77C4CED7; Tue, 17 Dec 2024 20:26:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734467183; bh=szKv4c+yIO8qpqVrfikQ7GZl6LC2oSeWMMQ6QkdbdLs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oPe7YA12IiP7UuVtrgt9k7bcZKqTM914yb2GhTqIREs9gWk62KjasVBtHx/BvVQGe n7diYP2LJJPTAWXXsFKr7RelCB9MT0dghkNSiRY94n0Pz0JraN6eo3uOu6JPt7jvXT BZbwYY23mIJzMmauR4wUtxdEVFTzPQXmczwOu1s7DLZ9WL9JawMiafj03olqYg1yrs YA/HY6XuolzIFLnYjYqrsRwUbSd07hKsiERBwpfsj/pTTPz0xnybWhF9NScve5kDGT FHIUjgdpfGCTHF+4otkj/PqOI+JyRmCAuv4DZsFt7D+BbP3uodgEWWoKt0MbUQhgDm dBrRsWJ0mRXzA== From: Kalle Valo To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org Subject: [PATCH 3/4] wifi: ath12k: Decrease ath12k_sta_rc_update_wk() stack usage Date: Tue, 17 Dec 2024 22:26:17 +0200 Message-Id: <20241217202618.1329312-4-kvalo@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241217202618.1329312-1-kvalo@kernel.org> References: <20241217202618.1329312-1-kvalo@kernel.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jeff Johnson Currently when building ath12k with llvm-18.1.7-x86_64 the following warning is observed: drivers/net/wireless/ath/ath12k/mac.c:4946:13: warning: stack frame size (1112) exceeds limit (1024) in 'ath12k_sta_rc_update_wk' [-Wframe-larger-than] A major contributor to the stack usage in this function is: struct ath12k_wmi_peer_assoc_arg peer_arg; Avoid the excess stack usage by dynamically allocating peer_arg instead of declaring it on the stack. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1 Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3 Signed-off-by: Jeff Johnson Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath12k/mac.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index 2a30a11903c5..10293e9c1d49 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -4956,7 +4956,6 @@ static void ath12k_sta_rc_update_wk(struct wiphy *wiphy, struct wiphy_work *wk) u32 changed, bw, nss, smps, bw_prev; int err, num_vht_rates; const struct cfg80211_bitrate_mask *mask; - struct ath12k_wmi_peer_assoc_arg peer_arg; enum wmi_phy_mode peer_phymode; struct ath12k_link_sta *arsta; struct ieee80211_vif *vif; @@ -4992,9 +4991,14 @@ static void ath12k_sta_rc_update_wk(struct wiphy *wiphy, struct wiphy_work *wk) nss = min(nss, max(ath12k_mac_max_ht_nss(ht_mcs_mask), ath12k_mac_max_vht_nss(vht_mcs_mask))); + struct ath12k_wmi_peer_assoc_arg *peer_arg __free(kfree) = + kzalloc(sizeof(*peer_arg), GFP_KERNEL); + if (!peer_arg) + return; + if (changed & IEEE80211_RC_BW_CHANGED) { - ath12k_peer_assoc_h_phymode(ar, arvif, arsta, &peer_arg); - peer_phymode = peer_arg.peer_phymode; + ath12k_peer_assoc_h_phymode(ar, arvif, arsta, peer_arg); + peer_phymode = peer_arg->peer_phymode; if (bw > bw_prev) { /* Phymode shows maximum supported channel width, if we @@ -5096,9 +5100,9 @@ static void ath12k_sta_rc_update_wk(struct wiphy *wiphy, struct wiphy_work *wk) * other rates using peer_assoc command. */ ath12k_peer_assoc_prepare(ar, arvif, arsta, - &peer_arg, true); + peer_arg, true); - err = ath12k_wmi_send_peer_assoc_cmd(ar, &peer_arg); + err = ath12k_wmi_send_peer_assoc_cmd(ar, peer_arg); if (err) ath12k_warn(ar->ab, "failed to run peer assoc for STA %pM vdev %i: %d\n", arsta->addr, arvif->vdev_id, err); From patchwork Tue Dec 17 20:26:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalle Valo X-Patchwork-Id: 13912466 X-Patchwork-Delegate: quic_jjohnson@quicinc.com Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3F2D1F9EDD for ; Tue, 17 Dec 2024 20:26:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734467184; cv=none; b=EE4WvTrEdbopxq/k6uDhTx/INkrWHiwbrM8MMlRhhrrBOetXdAx1Qla9mM6GnYwKChsBZPkwwlB2SXtPLIPUHVKRaloQhkNFvfSfVA0GwWqjCIuuGn2qjkQ2H47QXKIfGniIRvl0gbFj+841aMUauwZl3Wrtm7Gkqd/X82+fDpg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734467184; c=relaxed/simple; bh=F/8ASNPPjOaxz0JijoyrX+VIjLjW8UFlW6ev+Y8FGTo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QYwc4mXRUKZ4OFu91btu+JVyATjx/+aeTYKaalk+cUfWUcqt+DlwwRG0+5WYeLzgv4VAHRffGPel8955TAbb/pdPiWEJLUzSyV1+EVFBaAo+DwPjRg7eqI40GtOO3/Fp9XHfjaLfzEC9By9B6JkUqD0WWeO0jHBWtPH6f4TCj48= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=d1f67aaR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="d1f67aaR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08203C4CED3; Tue, 17 Dec 2024 20:26:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734467184; bh=F/8ASNPPjOaxz0JijoyrX+VIjLjW8UFlW6ev+Y8FGTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d1f67aaRc2+G2cWv7Q17OgeduFtKjphATL9FgXJQonasr3bN6IylUu+JOOZKsy5hg XCx+ESMXTIAvMERTz4IjKNHlkmK7hNPoINqKNbQl7vVsHcgK3CEXIjs+zVrVm91mUI c1pdh1dOVGT88OGUnnvx1O1Ksh3KECJKuKvEWeFFUGXJcgyqYh6PRx/lGpuL6EnZ6s Nzt5rHvJNMONSsdLWxoCGoPpdOGAzoigOIl5zKOpIlw5AVMAAjeTWkvaLbDZftVUDe ye8t8RfJZAQYKEOoTiaI3ZpbOnj9sL91xgWow1uoF3N8/RmqVESW8oAW9J58rH4Hdh pmauThGAi5rNw== From: Kalle Valo To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org Subject: [PATCH 4/4] wifi: ath12k: Decrease ath12k_mac_station_assoc() stack usage Date: Tue, 17 Dec 2024 22:26:18 +0200 Message-Id: <20241217202618.1329312-5-kvalo@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241217202618.1329312-1-kvalo@kernel.org> References: <20241217202618.1329312-1-kvalo@kernel.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jeff Johnson Building the ath12k driver with llvm-18.1.7-x86_64 produces the warning: drivers/net/wireless/ath/ath12k/mac.c:5606:12: warning: stack frame size (1176) exceeds limit (1024) in 'ath12k_mac_op_sta_state' [-Wframe-larger-than] ath12k_mac_op_sta_state() itself does not consume much stack, but it calls ath12k_mac_handle_link_sta_state() which in turn calls ath12k_mac_station_add(). Since those are both static functions with only one caller, it is suspected that these both get inlined, and their stack usage is reported for ath12k_mac_op_sta_state(). A major contributor to the ath12k_mac_station_assoc() stack usage is: struct ath12k_wmi_peer_assoc_arg peer_arg; Avoid the excess stack usage by dynamically allocating peer_arg instead of declaring it on the stack. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1 Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3 Signed-off-by: Jeff Johnson Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath12k/mac.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index 10293e9c1d49..6f10813d9378 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -4834,7 +4834,6 @@ static int ath12k_mac_station_assoc(struct ath12k *ar, { struct ieee80211_vif *vif = ath12k_ahvif_to_vif(arvif->ahvif); struct ieee80211_sta *sta = ath12k_ahsta_to_sta(arsta->ahsta); - struct ath12k_wmi_peer_assoc_arg peer_arg; struct ieee80211_link_sta *link_sta; int ret; struct cfg80211_chan_def def; @@ -4854,14 +4853,19 @@ static int ath12k_mac_station_assoc(struct ath12k *ar, band = def.chan->band; mask = &arvif->bitrate_mask; - ath12k_peer_assoc_prepare(ar, arvif, arsta, &peer_arg, reassoc); + struct ath12k_wmi_peer_assoc_arg *peer_arg __free(kfree) = + kzalloc(sizeof(*peer_arg), GFP_KERNEL); + if (!peer_arg) + return -ENOMEM; - if (peer_arg.peer_nss < 1) { + ath12k_peer_assoc_prepare(ar, arvif, arsta, peer_arg, reassoc); + + if (peer_arg->peer_nss < 1) { ath12k_warn(ar->ab, - "invalid peer NSS %d\n", peer_arg.peer_nss); + "invalid peer NSS %d\n", peer_arg->peer_nss); return -EINVAL; } - ret = ath12k_wmi_send_peer_assoc_cmd(ar, &peer_arg); + ret = ath12k_wmi_send_peer_assoc_cmd(ar, peer_arg); if (ret) { ath12k_warn(ar->ab, "failed to run peer assoc for STA %pM vdev %i: %d\n", arsta->addr, arvif->vdev_id, ret);