* [PATCH] wifi: ath12k: order hw group devices by WSI index
@ 2026-09-27 1:23 Benoit Masson
2026-09-28 15:26 ` Rameshkumar Sundaram
0 siblings, 1 reply; 4+ messages in thread
From: Benoit Masson @ 2026-09-27 1:23 UTC (permalink / raw)
To: Jeff Johnson; +Cc: linux-wireless, ath12k, stable, Karthikeyan Periyasamy
On multi-chip (WSI/MLO) platforms the devices of a hardware group are
added to ag->ab[] in PCI probe completion order (ab->device_id =
ag->num_probed++). PCI probe is asynchronous, so the order in which the
chips complete firmware bring-up is not stable across boots.
ath12k_mac_allocate() builds the wiphy radio array directly from
ag->ab[], and takes the wiphy device from the first entry. As a result
both the wiphy sysfs path and the mapping of radio indices to bands
change from boot to boot on boards such as the TP-Link Archer BE800,
which has three single-band QCN9274/QCN9224 radios in one group. A
persisted hostapd configuration that pins radio0 to a band then attaches
to a random band.
Order the devices used to build pdev_map[] by ab->wsi_info.index, which
is derived deterministically from the device tree WSI ring and the
qcom,wsi-controller node. ath12k already uses wsi_info.index as the
canonical per-device index for the firmware link IDs in
ath12k_host_cap_hw_link_id_init().
Note that ag->ab[] itself is left untouched: the unassign path indexes it
by ab->device_id, which is the probe-order id.
Fixes: 6f245ea0ec6c ("wifi: ath12k: introduce device group abstraction")
Cc: stable@vger.kernel.org # 6.14+
Signed-off-by: Benoit Masson <yahoo@perenite.com>
---
drivers/net/wireless/ath/ath12k/mac.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 99bf5cf..6505255 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -15444,6 +15444,7 @@ static void ath12k_mac_set_device_defaults(struct ath12k_base *ab)
int ath12k_mac_allocate(struct ath12k_hw_group *ag)
{
struct ath12k_pdev_map pdev_map[ATH12K_GROUP_MAX_RADIO];
+ struct ath12k_base *ab_order[ATH12K_MAX_DEVICES] = {};
int mac_id, device_id, total_radio, num_hw;
struct ath12k_base *ab;
struct ath12k_hw *ah;
@@ -15467,6 +15468,21 @@ int ath12k_mac_allocate(struct ath12k_hw_group *ag)
if (WARN_ON(total_radio > ATH12K_GROUP_MAX_RADIO))
return -ENOSPC;
+ /*
+ * Order the devices deterministically by WSI index instead of PCI
+ * probe completion order, so that the wiphy and the radio index to
+ * band mapping do not change from boot to boot.
+ */
+ for (i = 0; i < ag->num_devices; i++) {
+ ab = ag->ab[i];
+ if (!ab)
+ continue;
+ if (WARN_ON(ab->wsi_info.index >= ATH12K_MAX_DEVICES))
+ return -EINVAL;
+
+ ab_order[ab->wsi_info.index] = ab;
+ }
+
/* All pdev get combined and register as single wiphy based on
* hardware group which participate in multi-link operation else
* each pdev get register separately.
@@ -15483,12 +15499,12 @@ int ath12k_mac_allocate(struct ath12k_hw_group *ag)
mac_id = 0;
for (i = 0; i < num_hw; i++) {
for (j = 0; j < radio_per_hw; j++) {
- if (device_id >= ag->num_devices || !ag->ab[device_id]) {
+ if (device_id >= ag->num_devices || !ab_order[device_id]) {
ret = -ENOSPC;
goto err;
}
- ab = ag->ab[device_id];
+ ab = ab_order[device_id];
/*
* the assumption is all devices within an ah
--
2.54.0 (Apple Git-157)
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] wifi: ath12k: order hw group devices by WSI index
2026-09-27 1:23 [PATCH] wifi: ath12k: order hw group devices by WSI index Benoit Masson
@ 2026-09-28 15:26 ` Rameshkumar Sundaram
2026-09-28 15:43 ` [PATCH] wifi: ath12k: assign device id from the " Benoit Masson
0 siblings, 1 reply; 4+ messages in thread
From: Rameshkumar Sundaram @ 2026-09-28 15:26 UTC (permalink / raw)
To: Benoit Masson, Jeff Johnson
Cc: linux-wireless, ath12k, stable, Karthikeyan Periyasamy
On 9/27/2026 6:53 AM, Benoit Masson wrote:
> On multi-chip (WSI/MLO) platforms the devices of a hardware group are
> added to ag->ab[] in PCI probe completion order (ab->device_id =
> ag->num_probed++). PCI probe is asynchronous, so the order in which the
> chips complete firmware bring-up is not stable across boots.
>
> ath12k_mac_allocate() builds the wiphy radio array directly from
> ag->ab[], and takes the wiphy device from the first entry. As a result
> both the wiphy sysfs path and the mapping of radio indices to bands
> change from boot to boot on boards such as the TP-Link Archer BE800,
> which has three single-band QCN9274/QCN9224 radios in one group. A
> persisted hostapd configuration that pins radio0 to a band then attaches
> to a random band.
>
> Order the devices used to build pdev_map[] by ab->wsi_info.index, which
> is derived deterministically from the device tree WSI ring and the
> qcom,wsi-controller node. ath12k already uses wsi_info.index as the
> canonical per-device index for the firmware link IDs in
> ath12k_host_cap_hw_link_id_init().
>
> Note that ag->ab[] itself is left untouched: the unassign path indexes it
> by ab->device_id, which is the probe-order id.
>
> Fixes: 6f245ea0ec6c ("wifi: ath12k: introduce device group abstraction")
> Cc: stable@vger.kernel.org # 6.14+
> Signed-off-by: Benoit Masson <yahoo@perenite.com>
> ---
> drivers/net/wireless/ath/ath12k/mac.c | 20 ++++++++++++++++++--
> 1 file changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
> index 99bf5cf..6505255 100644
> --- a/drivers/net/wireless/ath/ath12k/mac.c
> +++ b/drivers/net/wireless/ath/ath12k/mac.c
> @@ -15444,6 +15444,7 @@ static void ath12k_mac_set_device_defaults(struct ath12k_base *ab)
> int ath12k_mac_allocate(struct ath12k_hw_group *ag)
> {
> struct ath12k_pdev_map pdev_map[ATH12K_GROUP_MAX_RADIO];
> + struct ath12k_base *ab_order[ATH12K_MAX_DEVICES] = {};
> int mac_id, device_id, total_radio, num_hw;
> struct ath12k_base *ab;
> struct ath12k_hw *ah;
> @@ -15467,6 +15468,21 @@ int ath12k_mac_allocate(struct ath12k_hw_group *ag)
> if (WARN_ON(total_radio > ATH12K_GROUP_MAX_RADIO))
> return -ENOSPC;
>
> + /*
> + * Order the devices deterministically by WSI index instead of PCI
> + * probe completion order, so that the wiphy and the radio index to
> + * band mapping do not change from boot to boot.
> + */
> + for (i = 0; i < ag->num_devices; i++) {
> + ab = ag->ab[i];
> + if (!ab)
> + continue;
> + if (WARN_ON(ab->wsi_info.index >= ATH12K_MAX_DEVICES))
> + return -EINVAL;
> +
> + ab_order[ab->wsi_info.index] = ab;
Maintaining the ab/ar ordering in ah based on the WSI index feels like
the wrong layer. The WSI index is a property of a device's position in
the group (ag) based on DT.
Did we consider placing ab into ag->ab[] deterministically based on
wsi_info.index? Do you foresee any issues with that?
something like below in ath12k_core_hw_group_assign(),
- ab->device_id = ag->num_probed++;
+ ag->num_probed++;
+ ab->device_id = wsi->index;
ag->ab[ab->device_id] = ab;
If that works, ath12k_mac_allocate() wouldn't need the new ab_order[]
array at all. It could simply iterate over ag->ab[i] directly.
> + }
> +
> /* All pdev get combined and register as single wiphy based on
> * hardware group which participate in multi-link operation else
> * each pdev get register separately.
> @@ -15483,12 +15499,12 @@ int ath12k_mac_allocate(struct ath12k_hw_group *ag)
> mac_id = 0;
> for (i = 0; i < num_hw; i++) {
> for (j = 0; j < radio_per_hw; j++) {
> - if (device_id >= ag->num_devices || !ag->ab[device_id]) {
> + if (device_id >= ag->num_devices || !ab_order[device_id]) {
> ret = -ENOSPC;
> goto err;
> }
>
> - ab = ag->ab[device_id];
> + ab = ab_order[device_id];
>
> /*
> * the assumption is all devices within an ah
--
Ramesh
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH] wifi: ath12k: assign device id from the WSI index
2026-09-28 15:26 ` Rameshkumar Sundaram
@ 2026-09-28 15:43 ` Benoit Masson
2026-09-28 18:07 ` Jeff Johnson
0 siblings, 1 reply; 4+ messages in thread
From: Benoit Masson @ 2026-09-28 15:43 UTC (permalink / raw)
To: Rameshkumar Sundaram; +Cc: linux-wireless, ath12k, stable, Jeff Johnson
Devices of a hardware group are added to ag->ab[] in PCI probe
completion order (ab->device_id = ag->num_probed++). The wiphy radio
array is built from ag->ab[] and the wiphy device is taken from its
first entry, so the wiphy path and the radio index to band mapping
change on every boot.
Store each ab in ag->ab[] at its wsi_info.index, which is derived from
the device tree WSI ring. The group order is then deterministic.
ag->num_probed remains the group device counter. The unassign path is
unchanged, it already indexes ag->ab[] by ab->device_id.
Verified on TP-Link Archer BE800 (three single-band radios in one
group): the wiphy path and the radio index to band mapping are
identical across cold boots.
Fixes: 6f245ea0ec6c ("wifi: ath12k: introduce device group abstraction")
Cc: stable@vger.kernel.org # 6.14+
Signed-off-by: Benoit Masson <yahoo@perenite.com>
---
Changes in v2:
- Set ab->device_id from wsi_info.index in ath12k_core_hw_group_assign()
instead of reordering pdev_map[] in ath12k_mac_allocate(), as suggested
by Rameshkumar. mac.c is no longer modified.
---
drivers/net/wireless/ath/ath12k/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c
index 262a204..f43319f 100644
--- a/drivers/net/wireless/ath/ath12k/core.c
+++ b/drivers/net/wireless/ath/ath12k/core.c
@@ -2029,7 +2029,8 @@ exit:
goto invalid_group;
}
- ab->device_id = ag->num_probed++;
+ ag->num_probed++;
+ ab->device_id = wsi->index;
ag->ab[ab->device_id] = ab;
ab->ag = ag;
--
2.54.0 (Apple Git-157)
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] wifi: ath12k: assign device id from the WSI index
2026-09-28 15:43 ` [PATCH] wifi: ath12k: assign device id from the " Benoit Masson
@ 2026-09-28 18:07 ` Jeff Johnson
0 siblings, 0 replies; 4+ messages in thread
From: Jeff Johnson @ 2026-09-28 18:07 UTC (permalink / raw)
To: Benoit Masson, Rameshkumar Sundaram
Cc: linux-wireless, ath12k, stable, Jeff Johnson
On 9/28/2026 8:43 AM, Benoit Masson wrote:
> Devices of a hardware group are added to ag->ab[] in PCI probe
> completion order (ab->device_id = ag->num_probed++). The wiphy radio
> array is built from ag->ab[] and the wiphy device is taken from its
> first entry, so the wiphy path and the radio index to band mapping
> change on every boot.
you don't describe why this is is a problem, and hence why it should be
considered for backporting to stable kernels.
>
> Store each ab in ag->ab[] at its wsi_info.index, which is derived from
> the device tree WSI ring. The group order is then deterministic.
> ag->num_probed remains the group device counter. The unassign path is
> unchanged, it already indexes ag->ab[] by ab->device_id.
>
> Verified on TP-Link Archer BE800 (three single-band radios in one
> group): the wiphy path and the radio index to band mapping are
> identical across cold boots.
>
> Fixes: 6f245ea0ec6c ("wifi: ath12k: introduce device group abstraction")
> Cc: stable@vger.kernel.org # 6.14+
> Signed-off-by: Benoit Masson <yahoo@perenite.com>
SOB doesn't match your From address. So you either need to change your SOB,
update your From address in your e-mail agent, or add a From: tag to you patch
so that From == SOB
> ---
> Changes in v2:
> - Set ab->device_id from wsi_info.index in ath12k_core_hw_group_assign()
> instead of reordering pdev_map[] in ath12k_mac_allocate(), as suggested
> by Rameshkumar. mac.c is no longer modified.
your e-mail subject doesn't reflect that this is a v2, and it was threaded
instead of being sent as a separate e-mail thread.
when you send a v3 that addresses the above please make sure to use a properly
versioned subject and send as a separate thread.
Thanks
/jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-28 18:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-27 1:23 [PATCH] wifi: ath12k: order hw group devices by WSI index Benoit Masson
2026-09-28 15:26 ` Rameshkumar Sundaram
2026-09-28 15:43 ` [PATCH] wifi: ath12k: assign device id from the " Benoit Masson
2026-09-28 18:07 ` Jeff Johnson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox