[PATCH ath-next v5] wifi: ath12k: avoid dynamic alloc when parsing wmi tb
Nicolas Escande
nico.escande at gmail.com
Thu Apr 2 03:47:17 PDT 2026
On Tue Mar 31, 2026 at 4:44 AM CEST, Baochen Qiang wrote:
[...]
>> @@ -11239,3 +11149,30 @@ int ath12k_wmi_send_mlo_link_set_active_cmd(struct ath12k_base *ab,
>> dev_kfree_skb(skb);
>> return ret;
>> }
>> +
>> +int ath12k_wmi_alloc(void)
>> +{
>> + guard(mutex)(&ath12k_wmi_mutex);
>> +
>> + if (!ath12k_wmi_tb)
>> + ath12k_wmi_tb = __alloc_percpu(WMI_TAG_MAX * sizeof(void *),
>> + __alignof__(void *));
>> + if (!ath12k_wmi_tb)
>> + return -ENOMEM;
>
> better move the second testing inside ?
>
> if (!ath12k_wmi_tb) {
> ath12k_wmi_tb = alloc();
> if (!ath12k_wmi_tb)
> return -ENOMEM;
> }
I tend to prefer not over indenting when I can avoid it but ok.
>
>> +
>> + ath12k_wmi_refcount++;
>> + return 0;
>> +}
>> +
>> +void ath12k_wmi_free(void)
>> +{
>> + guard(mutex)(&ath12k_wmi_mutex);
>> +
>> + if (!WARN_ON(ath12k_wmi_refcount - 1 < 0))
>
> better to use refcount_t and its APIs?
Indeed I'm not familiar with them but I'll look into it
>
>> + ath12k_wmi_refcount--;
>> +
>> + if (!ath12k_wmi_refcount) {
>> + free_percpu(ath12k_wmi_tb);
>> + ath12k_wmi_tb = NULL;
>> + }
>> +}
More information about the ath12k
mailing list