[PATCH ath-next] wifi: ath12k: avoid dynamic alloc when parsing wmi tb
Nicolas Escande
nico.escande at gmail.com
Tue Mar 10 03:31:00 PDT 2026
On Tue Mar 10, 2026 at 3:05 AM CET, Baochen Qiang wrote:
[...]
>> diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h
>> index 59c193b24764..ebe7b94fd712 100644
>> --- a/drivers/net/wireless/ath/ath12k/core.h
>> +++ b/drivers/net/wireless/ath/ath12k/core.h
>> @@ -19,6 +19,7 @@
>> #include <linux/average.h>
>> #include <linux/of.h>
>> #include <linux/rhashtable.h>
>> +#include <linux/percpu.h>
>> #include "qmi.h"
>> #include "htc.h"
>> #include "wmi.h"
>> @@ -937,6 +938,7 @@ struct ath12k_base {
>> struct device *dev;
>> struct ath12k_qmi qmi;
>> struct ath12k_wmi_base wmi_ab;
>> + void __percpu *wmi_tb;
>
> any reason why my v1 suggestion is not considered?
>
I considered it but I for sure did not write enough about it in the changelog.
Sorry about that, see my thoughts bellow.
> instead of allocating it per device, how about making it global and define/allocate once
> when loading driver. This way we may save some memory in case where more than one devices
> get probed?
So what I did try first is to use DEFINE_PER_CPU() directly in wmi.c to have
this as a static array, directly in the compilation unit where it is used.
But this failled at runtime as the allocated size it too big and it would have
needed modifying the max alloc size that the module loader would allow.
My second option was to add something in the module_init so ath12k_wifi7_init().
But as there is no ath12k 'global' struct, it meant adding a global variable to
hold the per cpu array, that would be alloced in wifi7/core.c and used in wmi.c.
And that felt weird too, the wifi version specific part of it at least.
So I stayed with the per ath12k_base, which as relatively low overhead for a
clean consistant interface.
But if you guys don't want it that way, I can rework it. Just tell me in more
details what you think is the right way and I can modify it.
Thanks
More information about the ath12k
mailing list