]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: ath12k: handle thermal throttle stats WMI event
authorMaharaja Kennadyrajan <maharaja.kennadyrajan@oss.qualcomm.com>
Mon, 13 Apr 2026 15:38:36 +0000 (21:08 +0530)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Thu, 30 Apr 2026 21:24:08 +0000 (14:24 -0700)
Add handling for WMI_THERM_THROT_STATS_EVENTID by defining the
wmi_therm_throt_stats_event TLV and parsing pdev_id, temperature and
throttle level.

The firmware can emit this event periodically, including when the
throttle level is 0.

Log the received thermal throttle stats to get the current temperature level,
temperature and thermal throttling levels.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.6-01243-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c5-00302-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.115823.3

Signed-off-by: Maharaja Kennadyrajan <maharaja.kennadyrajan@oss.qualcomm.com>
Reviewed-by: Rameshkumar Sundaram <rameshkumar.sundaram@oss.qualcomm.com>
Reviewed-by: Baochen Qiang <baochen.qiang@oss.qualcomm.com>
Link: https://patch.msgid.link/20260413153840.1969931-2-maharaja.kennadyrajan@oss.qualcomm.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
drivers/net/wireless/ath/ath12k/wmi.c
drivers/net/wireless/ath/ath12k/wmi.h

index fdac05ee11f0a8462fda8404e838eca9c593b5ce..0a0c07ac0c48842ef0083c096d90ea4f6f89185b 100644 (file)
@@ -8750,6 +8750,42 @@ exit:
        rcu_read_unlock();
 }
 
+static void ath12k_wmi_thermal_throt_stats_event(struct ath12k_base *ab,
+                                                struct sk_buff *skb)
+{
+       const struct wmi_therm_throt_stats_event *ev;
+       struct ath12k *ar;
+       const void **tb;
+
+       tb = ath12k_wmi_tlv_parse(ab, skb);
+       if (IS_ERR(tb)) {
+               ath12k_err(ab, "failed to parse thermal throttling stats tlv: %ld\n",
+                          PTR_ERR(tb));
+               return;
+       }
+
+       ev = tb[WMI_TAG_THERM_THROT_STATS_EVENT];
+       if (!ev) {
+               ath12k_err(ab, "failed to fetch thermal throt stats ev\n");
+               return;
+       }
+
+       rcu_read_lock();
+       ar = ath12k_mac_get_ar_by_pdev_id(ab, le32_to_cpu(ev->pdev_id));
+       if (!ar) {
+               ath12k_warn(ab, "received thermal_throt_stats in invalid pdev %u\n",
+                           le32_to_cpu(ev->pdev_id));
+               rcu_read_unlock();
+               return;
+       }
+       rcu_read_unlock();
+
+       ath12k_dbg(ab, ATH12K_DBG_WMI,
+                  "thermal stats ev level %u pdev_id %u temp %u throt_levels %u\n",
+                  le32_to_cpu(ev->level), le32_to_cpu(ev->pdev_id),
+                  le32_to_cpu(ev->temp), le32_to_cpu(ev->therm_throt_levels));
+}
+
 static void ath12k_fils_discovery_event(struct ath12k_base *ab,
                                        struct sk_buff *skb)
 {
@@ -9799,6 +9835,9 @@ static void ath12k_wmi_op_rx(struct ath12k_base *ab, struct sk_buff *skb)
        case WMI_PDEV_TEMPERATURE_EVENTID:
                ath12k_wmi_pdev_temperature_event(ab, skb);
                break;
+       case WMI_THERM_THROT_STATS_EVENTID:
+               ath12k_wmi_thermal_throt_stats_event(ab, skb);
+               break;
        case WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID:
                ath12k_wmi_pdev_dma_ring_buf_release_event(ab, skb);
                break;
index 28ab8129a29f52af07e05e8b1146b846b8d1dad0..bbda2c441d0b00370d28e31876665eb88f91f3f0 100644 (file)
@@ -870,6 +870,7 @@ enum wmi_tlv_event_id {
        WMI_READ_DATA_FROM_FLASH_EVENTID,
        WMI_REPORT_RX_AGGR_FAILURE_EVENTID,
        WMI_PKGID_EVENTID,
+       WMI_THERM_THROT_STATS_EVENTID,
        WMI_GPIO_INPUT_EVENTID = WMI_TLV_CMD(WMI_GRP_GPIO),
        WMI_UPLOADH_EVENTID,
        WMI_CAPTUREH_EVENTID,
@@ -4120,6 +4121,13 @@ enum set_init_cc_flags {
        ALPHA_IS_SET,
 };
 
+struct wmi_therm_throt_stats_event {
+       __le32 pdev_id;
+       __le32 temp;
+       __le32 level;
+       __le32 therm_throt_levels;
+} __packed;
+
 struct ath12k_wmi_init_country_arg {
        union {
                u16 country_code;