wifi: ath11k: fix wrong usage of resource_size() causing firmware panic
Subsystems (2)
PATCH 1/1 wifi: ath11k: fix wrong usage of resource_size() causing firmware panic
On converting to the of_reserved_mem_region_to_resource() helper with commit 900730dc4705 ("wifi: ath: Use of_reserved_mem_region_to_resource() for "memory-region"") a logic error was introduced in the ath11k_core_coldboot_cal_support() if condition.
The original code checked for hremote_node presence and skipped ath11k_core_coldboot_cal_support() in the other switch case but now everything is driven entirely on the values of the resource struct.
resource_size() (in this case) is wrongly assumed to return a size of zero if the passed resource struct is init to zero. This is not the case as a resource struct should be always init with correct values (or at best set the end value to -1 to signal it's not configured) (the return value of resource_size() for a resource struct with start and end set to zero is 1)
On top of this, using resource_size() to check if a resource struct is initialized or not is generally wrong and other measure should be used instead.
To better handle this, use the DEFINE_RES macro to initialize the resource struct and set the IORESOURCE_UNSET flag by default.
Replace the resource_size() check with checking for the resource struct flags and check if it's IORESOURCE_UNSET.
This change effectively restore the original logic and restore correct loading of the ath11k firmware (restoring correct functionality of Wi-Fi)
--- drivers/net/wireless/ath/ath11k/qmi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath11k/qmi.c +2 -2
@@ -2039,8 +2039,8 @@ static int ath11k_qmi_alloc_target_mem_chunk(struct ath11k_base *ab)static int ath11k_qmi_assign_target_mem_chunk (struct ath11k_base *ab) { +struct resource res =DEFINE_RES (0 ,0 ,IORESOURCE_UNSET );struct device *dev = ab->dev; -struct resource res = {};u32 host_ddr_sz;int i, idx, ret;
@@ -2086,7 +2086,7 @@ static int ath11k_qmi_assign_target_mem_chunk(struct ath11k_base *ab) }if (ath11k_core_coldboot_cal_support (ab)) { -if (resource_size (&res)) { +if (res.flags !=IORESOURCE_UNSET ) { ab->qmi.target_mem[idx].paddr = res.start + host_ddr_sz; ab->qmi.target_mem[idx].iaddr =
Signature · 1 line
2.51.0