* [PATCH ath-next v4 1/9] wifi: ath12k: fix SLUB BUG - Object already free in ath12k_reg_free()
2025-04-08 6:06 [PATCH ath-next v4 0/9] wifi: ath12k: fixes for rmmod and recovery issues with hardware grouping Aditya Kumar Singh
@ 2025-04-08 6:06 ` Aditya Kumar Singh
2025-04-08 9:50 ` Vasanthakumar Thiagarajan
2025-04-08 6:06 ` [PATCH ath-next v4 2/9] wifi: ath12k: add reference counting for core attachment to hardware group Aditya Kumar Singh
` (8 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Aditya Kumar Singh @ 2025-04-08 6:06 UTC (permalink / raw)
To: Johannes Berg, Jeff Johnson, Karthikeyan Periyasamy, Kalle Valo,
Harshitha Prem
Cc: Jeff Johnson, linux-wireless, ath12k, linux-kernel, Aditya Kumar Singh
During rmmod of ath12k module with SLUB debug enabled, following print is
seen -
=============================================================================
BUG kmalloc-1k (Not tainted): Object already free
-----------------------------------------------------------------------------
Allocated in ath12k_reg_build_regd+0x94/0xa20 [ath12k] age=10470 cpu=0 pid=0
__kmalloc_noprof+0xf4/0x368
ath12k_reg_build_regd+0x94/0xa20 [ath12k]
ath12k_wmi_op_rx+0x199c/0x2c14 [ath12k]
ath12k_htc_rx_completion_handler+0x398/0x554 [ath12k]
ath12k_ce_per_engine_service+0x248/0x368 [ath12k]
ath12k_pci_ce_workqueue+0x28/0x50 [ath12k]
process_one_work+0x14c/0x28c
bh_worker+0x22c/0x27c
workqueue_softirq_action+0x80/0x90
tasklet_action+0x14/0x3c
handle_softirqs+0x108/0x240
__do_softirq+0x14/0x20
Freed in ath12k_reg_free+0x40/0x74 [ath12k] age=136 cpu=2 pid=166
kfree+0x148/0x248
ath12k_reg_free+0x40/0x74 [ath12k]
ath12k_core_hw_group_destroy+0x68/0xac [ath12k]
ath12k_core_deinit+0xd8/0x124 [ath12k]
ath12k_pci_remove+0x6c/0x130 [ath12k]
pci_device_remove+0x44/0xe8
device_remove+0x4c/0x80
device_release_driver_internal+0x1d0/0x22c
driver_detach+0x50/0x98
bus_remove_driver+0x70/0xf4
driver_unregister+0x30/0x60
pci_unregister_driver+0x24/0x9c
ath12k_pci_exit+0x18/0x24 [ath12k]
__arm64_sys_delete_module+0x1a0/0x2a8
invoke_syscall+0x48/0x110
el0_svc_common.constprop.0+0x40/0xe0
Slab 0xfffffdffc0033600 objects=10 used=6 fp=0xffff000000cdcc00 flags=0x3fffe0000000240(workingset|head|node=0|zone=0|lastcpupid=0x1ffff)
Object 0xffff000000cdcc00 @offset=19456 fp=0xffff000000cde400
[...]
This issue arises because in ath12k_core_hw_group_destroy(), each device
calls ath12k_core_soc_destroy() for itself and all its partners within the
same group. Since ath12k_core_hw_group_destroy() is invoked for each
device, this results in a double free condition, eventually causing the
SLUB bug.
To resolve this, set the freed pointers to NULL. And since there could be
a race condition to read these pointers, guard these with the available
mutex lock.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
Fixes: 6f245ea0ec6c ("wifi: ath12k: introduce device group abstraction")
Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/reg.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/wireless/ath/ath12k/reg.c b/drivers/net/wireless/ath/ath12k/reg.c
index 893650f76fb2d9f24177d524c5a979693b543657..3260df2ad60059117d5340c27a3b82fdcfabd02b 100644
--- a/drivers/net/wireless/ath/ath12k/reg.c
+++ b/drivers/net/wireless/ath/ath12k/reg.c
@@ -817,8 +817,12 @@ void ath12k_reg_free(struct ath12k_base *ab)
{
int i;
+ mutex_lock(&ab->core_lock);
for (i = 0; i < ab->hw_params->max_radios; i++) {
kfree(ab->default_regd[i]);
kfree(ab->new_regd[i]);
+ ab->default_regd[i] = NULL;
+ ab->new_regd[i] = NULL;
}
+ mutex_unlock(&ab->core_lock);
}
--
2.34.1
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH ath-next v4 1/9] wifi: ath12k: fix SLUB BUG - Object already free in ath12k_reg_free()
2025-04-08 6:06 ` [PATCH ath-next v4 1/9] wifi: ath12k: fix SLUB BUG - Object already free in ath12k_reg_free() Aditya Kumar Singh
@ 2025-04-08 9:50 ` Vasanthakumar Thiagarajan
0 siblings, 0 replies; 20+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-04-08 9:50 UTC (permalink / raw)
To: Aditya Kumar Singh, Johannes Berg, Jeff Johnson,
Karthikeyan Periyasamy, Kalle Valo, Harshitha Prem
Cc: Jeff Johnson, linux-wireless, ath12k, linux-kernel
On 4/8/2025 11:36 AM, Aditya Kumar Singh wrote:
> During rmmod of ath12k module with SLUB debug enabled, following print is
> seen -
>
> =============================================================================
> BUG kmalloc-1k (Not tainted): Object already free
> -----------------------------------------------------------------------------
>
> Allocated in ath12k_reg_build_regd+0x94/0xa20 [ath12k] age=10470 cpu=0 pid=0
> __kmalloc_noprof+0xf4/0x368
> ath12k_reg_build_regd+0x94/0xa20 [ath12k]
> ath12k_wmi_op_rx+0x199c/0x2c14 [ath12k]
> ath12k_htc_rx_completion_handler+0x398/0x554 [ath12k]
> ath12k_ce_per_engine_service+0x248/0x368 [ath12k]
> ath12k_pci_ce_workqueue+0x28/0x50 [ath12k]
> process_one_work+0x14c/0x28c
> bh_worker+0x22c/0x27c
> workqueue_softirq_action+0x80/0x90
> tasklet_action+0x14/0x3c
> handle_softirqs+0x108/0x240
> __do_softirq+0x14/0x20
> Freed in ath12k_reg_free+0x40/0x74 [ath12k] age=136 cpu=2 pid=166
> kfree+0x148/0x248
> ath12k_reg_free+0x40/0x74 [ath12k]
> ath12k_core_hw_group_destroy+0x68/0xac [ath12k]
> ath12k_core_deinit+0xd8/0x124 [ath12k]
> ath12k_pci_remove+0x6c/0x130 [ath12k]
> pci_device_remove+0x44/0xe8
> device_remove+0x4c/0x80
> device_release_driver_internal+0x1d0/0x22c
> driver_detach+0x50/0x98
> bus_remove_driver+0x70/0xf4
> driver_unregister+0x30/0x60
> pci_unregister_driver+0x24/0x9c
> ath12k_pci_exit+0x18/0x24 [ath12k]
> __arm64_sys_delete_module+0x1a0/0x2a8
> invoke_syscall+0x48/0x110
> el0_svc_common.constprop.0+0x40/0xe0
> Slab 0xfffffdffc0033600 objects=10 used=6 fp=0xffff000000cdcc00 flags=0x3fffe0000000240(workingset|head|node=0|zone=0|lastcpupid=0x1ffff)
> Object 0xffff000000cdcc00 @offset=19456 fp=0xffff000000cde400
> [...]
>
> This issue arises because in ath12k_core_hw_group_destroy(), each device
> calls ath12k_core_soc_destroy() for itself and all its partners within the
> same group. Since ath12k_core_hw_group_destroy() is invoked for each
> device, this results in a double free condition, eventually causing the
> SLUB bug.
>
> To resolve this, set the freed pointers to NULL. And since there could be
> a race condition to read these pointers, guard these with the available
> mutex lock.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-QCAHKSWPL_SILICONZ-1
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> Fixes: 6f245ea0ec6c ("wifi: ath12k: introduce device group abstraction")
> Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH ath-next v4 2/9] wifi: ath12k: add reference counting for core attachment to hardware group
2025-04-08 6:06 [PATCH ath-next v4 0/9] wifi: ath12k: fixes for rmmod and recovery issues with hardware grouping Aditya Kumar Singh
2025-04-08 6:06 ` [PATCH ath-next v4 1/9] wifi: ath12k: fix SLUB BUG - Object already free in ath12k_reg_free() Aditya Kumar Singh
@ 2025-04-08 6:06 ` Aditya Kumar Singh
2025-04-08 9:51 ` Vasanthakumar Thiagarajan
2025-04-08 6:06 ` [PATCH ath-next v4 3/9] wifi: ath12k: fix failed to set mhi state error during reboot with hardware grouping Aditya Kumar Singh
` (7 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Aditya Kumar Singh @ 2025-04-08 6:06 UTC (permalink / raw)
To: Johannes Berg, Jeff Johnson, Karthikeyan Periyasamy, Kalle Valo,
Harshitha Prem
Cc: Jeff Johnson, linux-wireless, ath12k, linux-kernel, Aditya Kumar Singh
Currently, driver does not manage reference counting for attaching and
detaching cores to/from hardware groups. This can lead to issues when
multiple cores are involved. Or with same core, attach/detach is called
multiple times back to back.
Fix this issue by using reference counting.
With that, it is now ensured that the core is properly attached or detached
from the hardware group and even back to back calls will not alter the
count.
Additionally, add some debug logs during the attachment and detachment
events for better debugging and tracking.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-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: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/core.c | 47 +++++++++++++++++++++++++++++++---
drivers/net/wireless/ath/ath12k/core.h | 15 +----------
2 files changed, 44 insertions(+), 18 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c
index 0e71935b272033c5322e76a01e931087ced875ca..8a571a615313d2f1190fe9afae02dfd385ede7a3 100644
--- a/drivers/net/wireless/ath/ath12k/core.c
+++ b/drivers/net/wireless/ath/ath12k/core.c
@@ -640,9 +640,49 @@ struct reserved_mem *ath12k_core_get_reserved_mem(struct ath12k_base *ab,
return rmem;
}
+static inline
+void ath12k_core_to_group_ref_get(struct ath12k_base *ab)
+{
+ struct ath12k_hw_group *ag = ab->ag;
+
+ lockdep_assert_held(&ag->mutex);
+
+ if (ab->hw_group_ref) {
+ ath12k_dbg(ab, ATH12K_DBG_BOOT, "core already attached to group %d\n",
+ ag->id);
+ return;
+ }
+
+ ab->hw_group_ref = true;
+ ag->num_started++;
+
+ ath12k_dbg(ab, ATH12K_DBG_BOOT, "core attached to group %d, num_started %d\n",
+ ag->id, ag->num_started);
+}
+
+static inline
+void ath12k_core_to_group_ref_put(struct ath12k_base *ab)
+{
+ struct ath12k_hw_group *ag = ab->ag;
+
+ lockdep_assert_held(&ag->mutex);
+
+ if (!ab->hw_group_ref) {
+ ath12k_dbg(ab, ATH12K_DBG_BOOT, "core already de-attached from group %d\n",
+ ag->id);
+ return;
+ }
+
+ ab->hw_group_ref = false;
+ ag->num_started--;
+
+ ath12k_dbg(ab, ATH12K_DBG_BOOT, "core de-attached from group %d, num_started %d\n",
+ ag->id, ag->num_started);
+}
+
static void ath12k_core_stop(struct ath12k_base *ab)
{
- ath12k_core_stopped(ab);
+ ath12k_core_to_group_ref_put(ab);
if (!test_bit(ATH12K_FLAG_CRASH_FLUSH, &ab->dev_flags))
ath12k_qmi_firmware_stop(ab);
@@ -879,9 +919,8 @@ static int ath12k_core_start(struct ath12k_base *ab)
ath12k_acpi_set_dsm_func(ab);
- if (!test_bit(ATH12K_FLAG_RECOVERY, &ab->dev_flags))
- /* Indicate the core start in the appropriate group */
- ath12k_core_started(ab);
+ /* Indicate the core start in the appropriate group */
+ ath12k_core_to_group_ref_get(ab);
return 0;
diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h
index e8d2a0c859f6260d48c4c636793cf3a24c1c61b6..75fb4a99af9442e3c3f042602cc5b26842aa5231 100644
--- a/drivers/net/wireless/ath/ath12k/core.h
+++ b/drivers/net/wireless/ath/ath12k/core.h
@@ -1121,6 +1121,7 @@ struct ath12k_base {
struct ath12k_wsi_info wsi_info;
enum ath12k_firmware_mode fw_mode;
struct ath12k_ftm_event_obj ftm_event_obj;
+ bool hw_group_ref;
/* must be last */
u8 drv_priv[] __aligned(sizeof(void *));
@@ -1375,20 +1376,6 @@ static inline struct ath12k_hw_group *ath12k_ab_to_ag(struct ath12k_base *ab)
return ab->ag;
}
-static inline void ath12k_core_started(struct ath12k_base *ab)
-{
- lockdep_assert_held(&ab->ag->mutex);
-
- ab->ag->num_started++;
-}
-
-static inline void ath12k_core_stopped(struct ath12k_base *ab)
-{
- lockdep_assert_held(&ab->ag->mutex);
-
- ab->ag->num_started--;
-}
-
static inline struct ath12k_base *ath12k_ag_to_ab(struct ath12k_hw_group *ag,
u8 device_id)
{
--
2.34.1
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH ath-next v4 2/9] wifi: ath12k: add reference counting for core attachment to hardware group
2025-04-08 6:06 ` [PATCH ath-next v4 2/9] wifi: ath12k: add reference counting for core attachment to hardware group Aditya Kumar Singh
@ 2025-04-08 9:51 ` Vasanthakumar Thiagarajan
0 siblings, 0 replies; 20+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-04-08 9:51 UTC (permalink / raw)
To: Aditya Kumar Singh, Johannes Berg, Jeff Johnson,
Karthikeyan Periyasamy, Kalle Valo, Harshitha Prem
Cc: Jeff Johnson, linux-wireless, ath12k, linux-kernel
On 4/8/2025 11:36 AM, Aditya Kumar Singh wrote:
> Currently, driver does not manage reference counting for attaching and
> detaching cores to/from hardware groups. This can lead to issues when
> multiple cores are involved. Or with same core, attach/detach is called
> multiple times back to back.
>
> Fix this issue by using reference counting.
>
> With that, it is now ensured that the core is properly attached or detached
> from the hardware group and even back to back calls will not alter the
> count.
>
> Additionally, add some debug logs during the attachment and detachment
> events for better debugging and tracking.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-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: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH ath-next v4 3/9] wifi: ath12k: fix failed to set mhi state error during reboot with hardware grouping
2025-04-08 6:06 [PATCH ath-next v4 0/9] wifi: ath12k: fixes for rmmod and recovery issues with hardware grouping Aditya Kumar Singh
2025-04-08 6:06 ` [PATCH ath-next v4 1/9] wifi: ath12k: fix SLUB BUG - Object already free in ath12k_reg_free() Aditya Kumar Singh
2025-04-08 6:06 ` [PATCH ath-next v4 2/9] wifi: ath12k: add reference counting for core attachment to hardware group Aditya Kumar Singh
@ 2025-04-08 6:06 ` Aditya Kumar Singh
2025-04-08 9:52 ` Vasanthakumar Thiagarajan
2025-04-08 6:06 ` [PATCH ath-next v4 4/9] wifi: ath12k: fix ATH12K_FLAG_REGISTERED flag handling Aditya Kumar Singh
` (6 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Aditya Kumar Singh @ 2025-04-08 6:06 UTC (permalink / raw)
To: Johannes Berg, Jeff Johnson, Karthikeyan Periyasamy, Kalle Valo,
Harshitha Prem
Cc: Jeff Johnson, linux-wireless, ath12k, linux-kernel, Aditya Kumar Singh
With hardware grouping, during reboot, whenever a device is removed, it
powers down itself and all its partner devices in the same group. Now this
is done by all devices and hence there is multiple power down for devices
and hence the following error messages can be seen:
ath12k_pci 0002:01:00.0: failed to set mhi state POWER_OFF(3) in current mhi state (0x0)
ath12k_pci 0002:01:00.0: failed to set mhi state: POWER_OFF(3)
ath12k_pci 0002:01:00.0: failed to set mhi state DEINIT(1) in current mhi state (0x0)
ath12k_pci 0002:01:00.0: failed to set mhi state: DEINIT(1)
ath12k_pci 0003:01:00.0: failed to set mhi state POWER_OFF(3) in current mhi state (0x0)
ath12k_pci 0003:01:00.0: failed to set mhi state: POWER_OFF(3)
ath12k_pci 0003:01:00.0: failed to set mhi state DEINIT(1) in current mhi state (0x0)
ath12k_pci 0003:01:00.0: failed to set mhi state: DEINIT(1)
ath12k_pci 0004:01:00.0: failed to set mhi state POWER_OFF(3) in current mhi state (0x0)
ath12k_pci 0004:01:00.0: failed to set mhi state: POWER_OFF(3)
To prevent this, check if the ATH12K_PCI_FLAG_INIT_DONE flag is already
set before powering down. If it is set, it indicates that another partner
device has already performed the power down, and this device can skip this
step.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-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: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/pci.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/wireless/ath/ath12k/pci.c b/drivers/net/wireless/ath/ath12k/pci.c
index 7f1bb150f326b317157f6721d990d61a27f38d6a..aae1989c686bda37c12544e72338bbfbc5f75042 100644
--- a/drivers/net/wireless/ath/ath12k/pci.c
+++ b/drivers/net/wireless/ath/ath12k/pci.c
@@ -1487,6 +1487,9 @@ void ath12k_pci_power_down(struct ath12k_base *ab, bool is_suspend)
{
struct ath12k_pci *ab_pci = ath12k_pci_priv(ab);
+ if (!test_bit(ATH12K_PCI_FLAG_INIT_DONE, &ab_pci->flags))
+ return;
+
/* restore aspm in case firmware bootup fails */
ath12k_pci_aspm_restore(ab_pci);
--
2.34.1
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH ath-next v4 3/9] wifi: ath12k: fix failed to set mhi state error during reboot with hardware grouping
2025-04-08 6:06 ` [PATCH ath-next v4 3/9] wifi: ath12k: fix failed to set mhi state error during reboot with hardware grouping Aditya Kumar Singh
@ 2025-04-08 9:52 ` Vasanthakumar Thiagarajan
0 siblings, 0 replies; 20+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-04-08 9:52 UTC (permalink / raw)
To: Aditya Kumar Singh, Johannes Berg, Jeff Johnson,
Karthikeyan Periyasamy, Kalle Valo, Harshitha Prem
Cc: Jeff Johnson, linux-wireless, ath12k, linux-kernel
On 4/8/2025 11:36 AM, Aditya Kumar Singh wrote:
> With hardware grouping, during reboot, whenever a device is removed, it
> powers down itself and all its partner devices in the same group. Now this
> is done by all devices and hence there is multiple power down for devices
> and hence the following error messages can be seen:
>
> ath12k_pci 0002:01:00.0: failed to set mhi state POWER_OFF(3) in current mhi state (0x0)
> ath12k_pci 0002:01:00.0: failed to set mhi state: POWER_OFF(3)
> ath12k_pci 0002:01:00.0: failed to set mhi state DEINIT(1) in current mhi state (0x0)
> ath12k_pci 0002:01:00.0: failed to set mhi state: DEINIT(1)
> ath12k_pci 0003:01:00.0: failed to set mhi state POWER_OFF(3) in current mhi state (0x0)
> ath12k_pci 0003:01:00.0: failed to set mhi state: POWER_OFF(3)
> ath12k_pci 0003:01:00.0: failed to set mhi state DEINIT(1) in current mhi state (0x0)
> ath12k_pci 0003:01:00.0: failed to set mhi state: DEINIT(1)
> ath12k_pci 0004:01:00.0: failed to set mhi state POWER_OFF(3) in current mhi state (0x0)
> ath12k_pci 0004:01:00.0: failed to set mhi state: POWER_OFF(3)
>
> To prevent this, check if the ATH12K_PCI_FLAG_INIT_DONE flag is already
> set before powering down. If it is set, it indicates that another partner
> device has already performed the power down, and this device can skip this
> step.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-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: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH ath-next v4 4/9] wifi: ath12k: fix ATH12K_FLAG_REGISTERED flag handling
2025-04-08 6:06 [PATCH ath-next v4 0/9] wifi: ath12k: fixes for rmmod and recovery issues with hardware grouping Aditya Kumar Singh
` (2 preceding siblings ...)
2025-04-08 6:06 ` [PATCH ath-next v4 3/9] wifi: ath12k: fix failed to set mhi state error during reboot with hardware grouping Aditya Kumar Singh
@ 2025-04-08 6:06 ` Aditya Kumar Singh
2025-04-08 9:52 ` Vasanthakumar Thiagarajan
2025-04-08 6:06 ` [PATCH ath-next v4 5/9] wifi: ath12k: fix firmware assert during reboot with hardware grouping Aditya Kumar Singh
` (5 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Aditya Kumar Singh @ 2025-04-08 6:06 UTC (permalink / raw)
To: Johannes Berg, Jeff Johnson, Karthikeyan Periyasamy, Kalle Valo,
Harshitha Prem
Cc: Jeff Johnson, linux-wireless, ath12k, linux-kernel, Aditya Kumar Singh
Commit a5686ae820fa ("wifi: ath12k: move ATH12K_FLAG_REGISTERED handling to
ath12k_mac_register()") relocated the setting of the ATH12K_FLAG_REGISTERED
flag to the ath12k_mac_register() function. However, this function only
accesses the first device (ab) via ag->ab[0], resulting in the flag being
set only for the first device in the group. Similarly,
ath12k_mac_unregister() only unsets the flag for the first device. The flag
should actually be set for all devices in the group to avoid issues during
recovery.
Hence, move setting and clearing of this flag in the function
ath12k_core_hw_group_start() and ath12k_core_hw_group_stop() respectively.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
Fixes: a5686ae820fa ("wifi: ath12k: move ATH12K_FLAG_REGISTERED handling to ath12k_mac_register()")
Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/core.c | 5 +++++
drivers/net/wireless/ath/ath12k/mac.c | 6 ------
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c
index 8a571a615313d2f1190fe9afae02dfd385ede7a3..cb2a99d110d5c9ec2c092fe1a2b776b6265c4126 100644
--- a/drivers/net/wireless/ath/ath12k/core.c
+++ b/drivers/net/wireless/ath/ath12k/core.c
@@ -958,6 +958,9 @@ static void ath12k_core_hw_group_stop(struct ath12k_hw_group *ag)
ab = ag->ab[i];
if (!ab)
continue;
+
+ clear_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags);
+
ath12k_core_device_cleanup(ab);
}
@@ -1093,6 +1096,8 @@ static int ath12k_core_hw_group_start(struct ath12k_hw_group *ag)
mutex_lock(&ab->core_lock);
+ set_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags);
+
ret = ath12k_core_pdev_create(ab);
if (ret) {
ath12k_err(ab, "failed to create pdev core %d\n", ret);
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 2b6bdc3d2b11a8a5f5733352826c724c671fd49a..5c3c9267e937484cc5f5a7d8032fb3911b4e921c 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -11773,7 +11773,6 @@ void ath12k_mac_mlo_teardown(struct ath12k_hw_group *ag)
int ath12k_mac_register(struct ath12k_hw_group *ag)
{
- struct ath12k_base *ab = ag->ab[0];
struct ath12k_hw *ah;
int i;
int ret;
@@ -11786,8 +11785,6 @@ int ath12k_mac_register(struct ath12k_hw_group *ag)
goto err;
}
- set_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags);
-
return 0;
err:
@@ -11804,12 +11801,9 @@ int ath12k_mac_register(struct ath12k_hw_group *ag)
void ath12k_mac_unregister(struct ath12k_hw_group *ag)
{
- struct ath12k_base *ab = ag->ab[0];
struct ath12k_hw *ah;
int i;
- clear_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags);
-
for (i = ag->num_hw - 1; i >= 0; i--) {
ah = ath12k_ag_to_ah(ag, i);
if (!ah)
--
2.34.1
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH ath-next v4 4/9] wifi: ath12k: fix ATH12K_FLAG_REGISTERED flag handling
2025-04-08 6:06 ` [PATCH ath-next v4 4/9] wifi: ath12k: fix ATH12K_FLAG_REGISTERED flag handling Aditya Kumar Singh
@ 2025-04-08 9:52 ` Vasanthakumar Thiagarajan
0 siblings, 0 replies; 20+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-04-08 9:52 UTC (permalink / raw)
To: Aditya Kumar Singh, Johannes Berg, Jeff Johnson,
Karthikeyan Periyasamy, Kalle Valo, Harshitha Prem
Cc: Jeff Johnson, linux-wireless, ath12k, linux-kernel
On 4/8/2025 11:36 AM, Aditya Kumar Singh wrote:
> Commit a5686ae820fa ("wifi: ath12k: move ATH12K_FLAG_REGISTERED handling to
> ath12k_mac_register()") relocated the setting of the ATH12K_FLAG_REGISTERED
> flag to the ath12k_mac_register() function. However, this function only
> accesses the first device (ab) via ag->ab[0], resulting in the flag being
> set only for the first device in the group. Similarly,
> ath12k_mac_unregister() only unsets the flag for the first device. The flag
> should actually be set for all devices in the group to avoid issues during
> recovery.
>
> Hence, move setting and clearing of this flag in the function
> ath12k_core_hw_group_start() and ath12k_core_hw_group_stop() respectively.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-QCAHKSWPL_SILICONZ-1
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> Fixes: a5686ae820fa ("wifi: ath12k: move ATH12K_FLAG_REGISTERED handling to ath12k_mac_register()")
> Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH ath-next v4 5/9] wifi: ath12k: fix firmware assert during reboot with hardware grouping
2025-04-08 6:06 [PATCH ath-next v4 0/9] wifi: ath12k: fixes for rmmod and recovery issues with hardware grouping Aditya Kumar Singh
` (3 preceding siblings ...)
2025-04-08 6:06 ` [PATCH ath-next v4 4/9] wifi: ath12k: fix ATH12K_FLAG_REGISTERED flag handling Aditya Kumar Singh
@ 2025-04-08 6:06 ` Aditya Kumar Singh
2025-04-08 9:53 ` Vasanthakumar Thiagarajan
2025-04-08 6:06 ` [PATCH ath-next v4 6/9] wifi: ath12k: fix ath12k_core_pre_reconfigure_recovery() with grouping Aditya Kumar Singh
` (4 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Aditya Kumar Singh @ 2025-04-08 6:06 UTC (permalink / raw)
To: Johannes Berg, Jeff Johnson, Karthikeyan Periyasamy, Kalle Valo,
Harshitha Prem
Cc: Jeff Johnson, linux-wireless, ath12k, linux-kernel, Aditya Kumar Singh
At present, during PCI shutdown, the power down is only executed for a
single device. However, when operating in a group, all devices need to be
powered down simultaneously. Failure to do so will result in a firmware
assertion.
Hence, introduce a new ath12k_pci_hw_group_power_down() and call it during
power down. This will ensure that all partner devices are properly powered
down.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-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: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/pci.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/ath/ath12k/pci.c b/drivers/net/wireless/ath/ath12k/pci.c
index aae1989c686bda37c12544e72338bbfbc5f75042..8ee532dcc2652ef4b92bc4c4346af47b783a6708 100644
--- a/drivers/net/wireless/ath/ath12k/pci.c
+++ b/drivers/net/wireless/ath/ath12k/pci.c
@@ -1757,13 +1757,34 @@ static void ath12k_pci_remove(struct pci_dev *pdev)
ath12k_core_free(ab);
}
+static void ath12k_pci_hw_group_power_down(struct ath12k_hw_group *ag)
+{
+ struct ath12k_base *ab;
+ int i;
+
+ if (!ag)
+ return;
+
+ mutex_lock(&ag->mutex);
+
+ for (i = 0; i < ag->num_devices; i++) {
+ ab = ag->ab[i];
+ if (!ab)
+ continue;
+
+ ath12k_pci_power_down(ab, false);
+ }
+
+ mutex_unlock(&ag->mutex);
+}
+
static void ath12k_pci_shutdown(struct pci_dev *pdev)
{
struct ath12k_base *ab = pci_get_drvdata(pdev);
struct ath12k_pci *ab_pci = ath12k_pci_priv(ab);
ath12k_pci_set_irq_affinity_hint(ab_pci, NULL);
- ath12k_pci_power_down(ab, false);
+ ath12k_pci_hw_group_power_down(ab->ag);
}
static __maybe_unused int ath12k_pci_pm_suspend(struct device *dev)
--
2.34.1
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH ath-next v4 5/9] wifi: ath12k: fix firmware assert during reboot with hardware grouping
2025-04-08 6:06 ` [PATCH ath-next v4 5/9] wifi: ath12k: fix firmware assert during reboot with hardware grouping Aditya Kumar Singh
@ 2025-04-08 9:53 ` Vasanthakumar Thiagarajan
0 siblings, 0 replies; 20+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-04-08 9:53 UTC (permalink / raw)
To: Aditya Kumar Singh, Johannes Berg, Jeff Johnson,
Karthikeyan Periyasamy, Kalle Valo, Harshitha Prem
Cc: Jeff Johnson, linux-wireless, ath12k, linux-kernel
On 4/8/2025 11:36 AM, Aditya Kumar Singh wrote:
> At present, during PCI shutdown, the power down is only executed for a
> single device. However, when operating in a group, all devices need to be
> powered down simultaneously. Failure to do so will result in a firmware
> assertion.
>
> Hence, introduce a new ath12k_pci_hw_group_power_down() and call it during
> power down. This will ensure that all partner devices are properly powered
> down.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-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: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH ath-next v4 6/9] wifi: ath12k: fix ath12k_core_pre_reconfigure_recovery() with grouping
2025-04-08 6:06 [PATCH ath-next v4 0/9] wifi: ath12k: fixes for rmmod and recovery issues with hardware grouping Aditya Kumar Singh
` (4 preceding siblings ...)
2025-04-08 6:06 ` [PATCH ath-next v4 5/9] wifi: ath12k: fix firmware assert during reboot with hardware grouping Aditya Kumar Singh
@ 2025-04-08 6:06 ` Aditya Kumar Singh
2025-04-08 9:55 ` Vasanthakumar Thiagarajan
2025-04-08 6:06 ` [PATCH ath-next v4 7/9] wifi: ath12k: handle ath12k_core_restart() with hardware grouping Aditya Kumar Singh
` (3 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Aditya Kumar Singh @ 2025-04-08 6:06 UTC (permalink / raw)
To: Johannes Berg, Jeff Johnson, Karthikeyan Periyasamy, Kalle Valo,
Harshitha Prem
Cc: Jeff Johnson, linux-wireless, ath12k, linux-kernel, Aditya Kumar Singh
Currently, ath12k_core_pre_reconfigure_recovery() reconfigures all radios
within the same group. During grouping and driver going for a recovery,
this function is called as many times as there are devices in the group.
Consequently, it performs the same reconfiguration multiple times, which
is unnecessary.
To prevent this, add a check to continue if the action has already been
taken.
To simplify the management of various flags, the reason for hardware queues
being stopped is used as a check instead of introducing a new flag.
While at it, also add missing wiphy locks. Wiphy lock is required since
ath12k_mac_drain_tx() which is called by
ath12k_core_pre_reconfigure_recovery() needs this lock to be held by the
caller.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-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: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/core.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c
index cb2a99d110d5c9ec2c092fe1a2b776b6265c4126..0fb3e57cd254ede767528e47e1d9d183257e5b71 100644
--- a/drivers/net/wireless/ath/ath12k/core.c
+++ b/drivers/net/wireless/ath/ath12k/core.c
@@ -1411,6 +1411,18 @@ static void ath12k_core_pre_reconfigure_recovery(struct ath12k_base *ab)
ah->state == ATH12K_HW_STATE_TM)
continue;
+ wiphy_lock(ah->hw->wiphy);
+
+ /* If queue 0 is stopped, it is safe to assume that all
+ * other queues are stopped by driver via
+ * ieee80211_stop_queues() below. This means, there is
+ * no need to stop it again and hence continue
+ */
+ if (ieee80211_queue_stopped(ah->hw, 0)) {
+ wiphy_unlock(ah->hw->wiphy);
+ continue;
+ }
+
ieee80211_stop_queues(ah->hw);
for (j = 0; j < ah->num_radio; j++) {
@@ -1439,6 +1451,8 @@ static void ath12k_core_pre_reconfigure_recovery(struct ath12k_base *ab)
ar->monitor_vdev_created = false;
ar->monitor_started = false;
}
+
+ wiphy_unlock(ah->hw->wiphy);
}
wake_up(&ab->wmi_ab.tx_credits_wq);
--
2.34.1
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH ath-next v4 6/9] wifi: ath12k: fix ath12k_core_pre_reconfigure_recovery() with grouping
2025-04-08 6:06 ` [PATCH ath-next v4 6/9] wifi: ath12k: fix ath12k_core_pre_reconfigure_recovery() with grouping Aditya Kumar Singh
@ 2025-04-08 9:55 ` Vasanthakumar Thiagarajan
0 siblings, 0 replies; 20+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-04-08 9:55 UTC (permalink / raw)
To: Aditya Kumar Singh, Johannes Berg, Jeff Johnson,
Karthikeyan Periyasamy, Kalle Valo, Harshitha Prem
Cc: Jeff Johnson, linux-wireless, ath12k, linux-kernel
On 4/8/2025 11:36 AM, Aditya Kumar Singh wrote:
> Currently, ath12k_core_pre_reconfigure_recovery() reconfigures all radios
> within the same group. During grouping and driver going for a recovery,
> this function is called as many times as there are devices in the group.
> Consequently, it performs the same reconfiguration multiple times, which
> is unnecessary.
>
> To prevent this, add a check to continue if the action has already been
> taken.
>
> To simplify the management of various flags, the reason for hardware queues
> being stopped is used as a check instead of introducing a new flag.
>
> While at it, also add missing wiphy locks. Wiphy lock is required since
> ath12k_mac_drain_tx() which is called by
> ath12k_core_pre_reconfigure_recovery() needs this lock to be held by the
> caller.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-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: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH ath-next v4 7/9] wifi: ath12k: handle ath12k_core_restart() with hardware grouping
2025-04-08 6:06 [PATCH ath-next v4 0/9] wifi: ath12k: fixes for rmmod and recovery issues with hardware grouping Aditya Kumar Singh
` (5 preceding siblings ...)
2025-04-08 6:06 ` [PATCH ath-next v4 6/9] wifi: ath12k: fix ath12k_core_pre_reconfigure_recovery() with grouping Aditya Kumar Singh
@ 2025-04-08 6:06 ` Aditya Kumar Singh
2025-04-08 9:56 ` Vasanthakumar Thiagarajan
2025-04-08 6:06 ` [PATCH ath-next v4 8/9] wifi: ath12k: handle ath12k_core_reset() " Aditya Kumar Singh
` (2 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Aditya Kumar Singh @ 2025-04-08 6:06 UTC (permalink / raw)
To: Johannes Berg, Jeff Johnson, Karthikeyan Periyasamy, Kalle Valo,
Harshitha Prem
Cc: Jeff Johnson, linux-wireless, ath12k, linux-kernel, Aditya Kumar Singh
Currently, when ath12k_core_restart() is called and the ab->is_reset flag
is set, it invokes ieee80211_restart_hw() for all hardware in the same
group. However, other hardware might still be in the recovery process,
making this call inappropriate with grouping into picture.
To address this, add a condition to check if the group is ready. If the
group is not ready, do not call ieee80211_restart_hw().
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-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: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/core.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c
index 0fb3e57cd254ede767528e47e1d9d183257e5b71..a1c9b8771e9c4c84548da2cb4054b0403aa8c759 100644
--- a/drivers/net/wireless/ath/ath12k/core.c
+++ b/drivers/net/wireless/ath/ath12k/core.c
@@ -1560,12 +1560,22 @@ static void ath12k_core_restart(struct work_struct *work)
ath12k_dbg(ab, ATH12K_DBG_BOOT, "reset success\n");
}
+ mutex_lock(&ag->mutex);
+
+ if (!ath12k_core_hw_group_start_ready(ag)) {
+ mutex_unlock(&ag->mutex);
+ goto exit_restart;
+ }
+
for (i = 0; i < ag->num_hw; i++) {
- ah = ath12k_ag_to_ah(ab->ag, i);
+ ah = ath12k_ag_to_ah(ag, i);
ieee80211_restart_hw(ah->hw);
}
+
+ mutex_unlock(&ag->mutex);
}
+exit_restart:
complete(&ab->restart_completed);
}
--
2.34.1
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH ath-next v4 7/9] wifi: ath12k: handle ath12k_core_restart() with hardware grouping
2025-04-08 6:06 ` [PATCH ath-next v4 7/9] wifi: ath12k: handle ath12k_core_restart() with hardware grouping Aditya Kumar Singh
@ 2025-04-08 9:56 ` Vasanthakumar Thiagarajan
0 siblings, 0 replies; 20+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-04-08 9:56 UTC (permalink / raw)
To: Aditya Kumar Singh, Johannes Berg, Jeff Johnson,
Karthikeyan Periyasamy, Kalle Valo, Harshitha Prem
Cc: Jeff Johnson, linux-wireless, ath12k, linux-kernel
On 4/8/2025 11:36 AM, Aditya Kumar Singh wrote:
> Currently, when ath12k_core_restart() is called and the ab->is_reset flag
> is set, it invokes ieee80211_restart_hw() for all hardware in the same
> group. However, other hardware might still be in the recovery process,
> making this call inappropriate with grouping into picture.
>
> To address this, add a condition to check if the group is ready. If the
> group is not ready, do not call ieee80211_restart_hw().
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-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: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH ath-next v4 8/9] wifi: ath12k: handle ath12k_core_reset() with hardware grouping
2025-04-08 6:06 [PATCH ath-next v4 0/9] wifi: ath12k: fixes for rmmod and recovery issues with hardware grouping Aditya Kumar Singh
` (6 preceding siblings ...)
2025-04-08 6:06 ` [PATCH ath-next v4 7/9] wifi: ath12k: handle ath12k_core_restart() with hardware grouping Aditya Kumar Singh
@ 2025-04-08 6:06 ` Aditya Kumar Singh
2025-04-08 9:58 ` Vasanthakumar Thiagarajan
2025-04-08 6:06 ` [PATCH ath-next v4 9/9] wifi: ath12k: reset MLO global memory during recovery Aditya Kumar Singh
2025-04-12 4:24 ` [PATCH ath-next v4 0/9] wifi: ath12k: fixes for rmmod and recovery issues with hardware grouping Jeff Johnson
9 siblings, 1 reply; 20+ messages in thread
From: Aditya Kumar Singh @ 2025-04-08 6:06 UTC (permalink / raw)
To: Johannes Berg, Jeff Johnson, Karthikeyan Periyasamy, Kalle Valo,
Harshitha Prem
Cc: Jeff Johnson, linux-wireless, ath12k, linux-kernel, Aditya Kumar Singh
Currently, in ath12k_core_reset(), the device is powered up immediately
after a power down. However, with hardware grouping, when one device
asserts, all partner devices also asserts. If there is a delay in
processing these asserts, by the time this device powers up, other devices
might still be asserting, leading to an overall recovery failure.
To prevent this issue, ensure all asserts for a group are processed before
initiating the power-up sequence.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-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: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/core.c | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c
index a1c9b8771e9c4c84548da2cb4054b0403aa8c759..55db189d82346438272c94f25b62dd0db8716efb 100644
--- a/drivers/net/wireless/ath/ath12k/core.c
+++ b/drivers/net/wireless/ath/ath12k/core.c
@@ -1582,7 +1582,8 @@ static void ath12k_core_restart(struct work_struct *work)
static void ath12k_core_reset(struct work_struct *work)
{
struct ath12k_base *ab = container_of(work, struct ath12k_base, reset_work);
- int reset_count, fail_cont_count;
+ struct ath12k_hw_group *ag = ab->ag;
+ int reset_count, fail_cont_count, i;
long time_left;
if (!(test_bit(ATH12K_FLAG_QMI_FW_READY_COMPLETE, &ab->dev_flags))) {
@@ -1641,9 +1642,31 @@ static void ath12k_core_reset(struct work_struct *work)
ath12k_hif_ce_irq_disable(ab);
ath12k_hif_power_down(ab, false);
- ath12k_hif_power_up(ab);
- ath12k_dbg(ab, ATH12K_DBG_BOOT, "reset started\n");
+ /* prepare for power up */
+ ab->qmi.num_radios = U8_MAX;
+
+ mutex_lock(&ag->mutex);
+ ath12k_core_to_group_ref_put(ab);
+
+ if (ag->num_started > 0) {
+ ath12k_dbg(ab, ATH12K_DBG_BOOT,
+ "waiting for %d partner device(s) to reset\n",
+ ag->num_started);
+ mutex_unlock(&ag->mutex);
+ return;
+ }
+
+ for (i = 0; i < ag->num_devices; i++) {
+ ab = ag->ab[i];
+ if (!ab)
+ continue;
+
+ ath12k_hif_power_up(ab);
+ ath12k_dbg(ab, ATH12K_DBG_BOOT, "reset started\n");
+ }
+
+ mutex_unlock(&ag->mutex);
}
int ath12k_core_pre_init(struct ath12k_base *ab)
--
2.34.1
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH ath-next v4 8/9] wifi: ath12k: handle ath12k_core_reset() with hardware grouping
2025-04-08 6:06 ` [PATCH ath-next v4 8/9] wifi: ath12k: handle ath12k_core_reset() " Aditya Kumar Singh
@ 2025-04-08 9:58 ` Vasanthakumar Thiagarajan
0 siblings, 0 replies; 20+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-04-08 9:58 UTC (permalink / raw)
To: Aditya Kumar Singh, Johannes Berg, Jeff Johnson,
Karthikeyan Periyasamy, Kalle Valo, Harshitha Prem
Cc: Jeff Johnson, linux-wireless, ath12k, linux-kernel
On 4/8/2025 11:36 AM, Aditya Kumar Singh wrote:
> Currently, in ath12k_core_reset(), the device is powered up immediately
> after a power down. However, with hardware grouping, when one device
> asserts, all partner devices also asserts. If there is a delay in
> processing these asserts, by the time this device powers up, other devices
> might still be asserting, leading to an overall recovery failure.
>
> To prevent this issue, ensure all asserts for a group are processed before
> initiating the power-up sequence.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-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: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH ath-next v4 9/9] wifi: ath12k: reset MLO global memory during recovery
2025-04-08 6:06 [PATCH ath-next v4 0/9] wifi: ath12k: fixes for rmmod and recovery issues with hardware grouping Aditya Kumar Singh
` (7 preceding siblings ...)
2025-04-08 6:06 ` [PATCH ath-next v4 8/9] wifi: ath12k: handle ath12k_core_reset() " Aditya Kumar Singh
@ 2025-04-08 6:06 ` Aditya Kumar Singh
2025-04-08 10:00 ` Vasanthakumar Thiagarajan
2025-04-12 4:24 ` [PATCH ath-next v4 0/9] wifi: ath12k: fixes for rmmod and recovery issues with hardware grouping Jeff Johnson
9 siblings, 1 reply; 20+ messages in thread
From: Aditya Kumar Singh @ 2025-04-08 6:06 UTC (permalink / raw)
To: Johannes Berg, Jeff Johnson, Karthikeyan Periyasamy, Kalle Valo,
Harshitha Prem
Cc: Jeff Johnson, linux-wireless, ath12k, linux-kernel, Aditya Kumar Singh
When operating with multiple devices grouped together, the firmware stores
data related to the state machine of each partner device in the MLO global
memory region. If the firmware crashes, it updates the state to 'crashed'.
During recovery, this memory is shared with the firmware again, and upon
detecting the 'crashed' state, it reasserts. This leads to a loop of
firmware asserts and it never recovers.
Hence to fix this issue, once all devices in the group have been asserted
and powered down, reset the MLO global memory region.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-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: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/core.c | 3 +++
drivers/net/wireless/ath/ath12k/qmi.c | 22 ++++++++++++++++++++++
drivers/net/wireless/ath/ath12k/qmi.h | 2 ++
3 files changed, 27 insertions(+)
diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c
index 55db189d82346438272c94f25b62dd0db8716efb..9b23329f1bf2a1a84f2b5dee1b67db469d3a8ce5 100644
--- a/drivers/net/wireless/ath/ath12k/core.c
+++ b/drivers/net/wireless/ath/ath12k/core.c
@@ -1657,6 +1657,9 @@ static void ath12k_core_reset(struct work_struct *work)
return;
}
+ /* Prepare MLO global memory region for power up */
+ ath12k_qmi_reset_mlo_mem(ag);
+
for (i = 0; i < ag->num_devices; i++) {
ab = ag->ab[i];
if (!ab)
diff --git a/drivers/net/wireless/ath/ath12k/qmi.c b/drivers/net/wireless/ath/ath12k/qmi.c
index 7df6c6eebed6855ab42519610962d2b21825d9ec..c867130f1ddc87ba3ea65d03a6fe99a06c6fe2ab 100644
--- a/drivers/net/wireless/ath/ath12k/qmi.c
+++ b/drivers/net/wireless/ath/ath12k/qmi.c
@@ -2439,6 +2439,28 @@ int ath12k_qmi_respond_fw_mem_request(struct ath12k_base *ab)
return ret;
}
+void ath12k_qmi_reset_mlo_mem(struct ath12k_hw_group *ag)
+{
+ struct target_mem_chunk *mlo_chunk;
+ int i;
+
+ lockdep_assert_held(&ag->mutex);
+
+ if (!ag->mlo_mem.init_done || ag->num_started)
+ return;
+
+ for (i = 0; i < ARRAY_SIZE(ag->mlo_mem.chunk); i++) {
+ mlo_chunk = &ag->mlo_mem.chunk[i];
+
+ if (mlo_chunk->v.addr)
+ /* TODO: Mode 0 recovery is the default mode hence resetting the
+ * whole memory region for now. Once Mode 1 support is added, this
+ * needs to be handled properly
+ */
+ memset(mlo_chunk->v.addr, 0, mlo_chunk->size);
+ }
+}
+
static void ath12k_qmi_free_mlo_mem_chunk(struct ath12k_base *ab,
struct target_mem_chunk *chunk,
int idx)
diff --git a/drivers/net/wireless/ath/ath12k/qmi.h b/drivers/net/wireless/ath/ath12k/qmi.h
index 7c44ced22c6f610fc32b1db9c073de73020d8e16..96e6c3daecfea48efc8fb65ccfddcd516ef2f3ce 100644
--- a/drivers/net/wireless/ath/ath12k/qmi.h
+++ b/drivers/net/wireless/ath/ath12k/qmi.h
@@ -42,6 +42,7 @@
#define ATH12K_BOARD_ID_DEFAULT 0xFF
struct ath12k_base;
+struct ath12k_hw_group;
enum ath12k_qmi_file_type {
ATH12K_QMI_FILE_TYPE_BDF_GOLDEN = 0,
@@ -622,5 +623,6 @@ void ath12k_qmi_deinit_service(struct ath12k_base *ab);
int ath12k_qmi_init_service(struct ath12k_base *ab);
void ath12k_qmi_free_resource(struct ath12k_base *ab);
void ath12k_qmi_trigger_host_cap(struct ath12k_base *ab);
+void ath12k_qmi_reset_mlo_mem(struct ath12k_hw_group *ag);
#endif
--
2.34.1
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH ath-next v4 9/9] wifi: ath12k: reset MLO global memory during recovery
2025-04-08 6:06 ` [PATCH ath-next v4 9/9] wifi: ath12k: reset MLO global memory during recovery Aditya Kumar Singh
@ 2025-04-08 10:00 ` Vasanthakumar Thiagarajan
0 siblings, 0 replies; 20+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-04-08 10:00 UTC (permalink / raw)
To: Aditya Kumar Singh, Johannes Berg, Jeff Johnson,
Karthikeyan Periyasamy, Kalle Valo, Harshitha Prem
Cc: Jeff Johnson, linux-wireless, ath12k, linux-kernel
On 4/8/2025 11:36 AM, Aditya Kumar Singh wrote:
> When operating with multiple devices grouped together, the firmware stores
> data related to the state machine of each partner device in the MLO global
> memory region. If the firmware crashes, it updates the state to 'crashed'.
> During recovery, this memory is shared with the firmware again, and upon
> detecting the 'crashed' state, it reasserts. This leads to a loop of
> firmware asserts and it never recovers.
>
> Hence to fix this issue, once all devices in the group have been asserted
> and powered down, reset the MLO global memory region.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-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: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH ath-next v4 0/9] wifi: ath12k: fixes for rmmod and recovery issues with hardware grouping
2025-04-08 6:06 [PATCH ath-next v4 0/9] wifi: ath12k: fixes for rmmod and recovery issues with hardware grouping Aditya Kumar Singh
` (8 preceding siblings ...)
2025-04-08 6:06 ` [PATCH ath-next v4 9/9] wifi: ath12k: reset MLO global memory during recovery Aditya Kumar Singh
@ 2025-04-12 4:24 ` Jeff Johnson
9 siblings, 0 replies; 20+ messages in thread
From: Jeff Johnson @ 2025-04-12 4:24 UTC (permalink / raw)
To: Johannes Berg, Jeff Johnson, Karthikeyan Periyasamy, Kalle Valo,
Harshitha Prem, Aditya Kumar Singh
Cc: linux-wireless, ath12k, linux-kernel
On Tue, 08 Apr 2025 11:36:28 +0530, Aditya Kumar Singh wrote:
> With hardware grouping, there is a kernel crash with signature -
>
> $ rmmod ath12k.ko
> Unable to handle kernel paging request at virtual address 000000000000d1a8
> [...]
> Call trace:
> ath12k_reg_free+0x14/0x74 [ath12k] (P)
> ath12k_core_hw_group_destroy+0x7c/0xb4 [ath12k] (L)
> ath12k_core_hw_group_destroy+0x7c/0xb4 [ath12k]
> ath12k_core_deinit+0xd8/0x124 [ath12k]
> ath12k_pci_remove+0x6c/0x130 [ath12k]
> pci_device_remove+0x44/0xe8
> device_remove+0x4c/0x80
> device_release_driver_internal+0x1d0/0x22c
> driver_detach+0x50/0x98
> bus_remove_driver+0x70/0xf4
> driver_unregister+0x30/0x60
> pci_unregister_driver+0x24/0x9c
> ath12k_pci_exit+0x18/0x24 [ath12k]
> __arm64_sys_delete_module+0x1a0/0x2a8
> invoke_syscall+0x48/0x110
> el0_svc_common.constprop.0+0x40/0xe0
> do_el0_svc+0x1c/0x28
> el0_svc+0x30/0xd0
> el0t_64_sync_handler+0x10c/0x138
> el0t_64_sync+0x198/0x19c
> Code: a9bd7bfd 910003fd a9025bf5 91402015 (f968d6a1)
> ---[ end trace 0000000000000000 ]---
> Segmentation fault
>
> [...]
Applied, thanks!
[1/9] wifi: ath12k: fix SLUB BUG - Object already free in ath12k_reg_free()
commit: 6d019abc402f58b25a7cab30b2d9af2f3173e4df
[2/9] wifi: ath12k: add reference counting for core attachment to hardware group
commit: 62f3878fa290cb21535459311fe1dc008cd381da
[3/9] wifi: ath12k: fix failed to set mhi state error during reboot with hardware grouping
commit: dce7aec6b1f74b0a46b901ab8de1f7bd0515f733
[4/9] wifi: ath12k: fix ATH12K_FLAG_REGISTERED flag handling
commit: 6af396942bf132a1a49523e8fe2f816dc1ebd913
[5/9] wifi: ath12k: fix firmware assert during reboot with hardware grouping
commit: 1d55625bc2a1c2a8c68153b020e1e097ea27f1b0
[6/9] wifi: ath12k: fix ath12k_core_pre_reconfigure_recovery() with grouping
commit: 718ead261feba32b00f8ef1d3dff7527106b9458
[7/9] wifi: ath12k: handle ath12k_core_restart() with hardware grouping
commit: 3e1312f01b508d3f77147bec5286caef074e5d9e
[8/9] wifi: ath12k: handle ath12k_core_reset() with hardware grouping
commit: 929069c1bdb70c6332c15f3978d4c8830bc43efd
[9/9] wifi: ath12k: reset MLO global memory during recovery
commit: f5755c23ed8a4603194f6425828a2760f814e117
Best regards,
--
Jeff Johnson <jeff.johnson@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 20+ messages in thread