Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH ath-next 0/3] wifi: ath6kl: fix issues found on big-endian MIPS
@ 2026-11-29 15:47 Josef Schlehofer
  2026-11-29 15:47 ` [PATCH ath-next 1/3] wifi: ath6kl: use little-endian BMI command fields Josef Schlehofer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Josef Schlehofer @ 2026-11-29 15:47 UTC (permalink / raw)
  To: Jeff Johnson; +Cc: linux-wireless

While bringing up an AR6006 on a big-endian MIPS router (QCA9563), I
found three issues in ath6kl that do not depend on the new chip:

- BMI command fields are sent in host byte order.
- API 1 firmware is freed with vfree() although kmemdup() allocated
  it.
- Firmware capabilities are read as bytes instead of with test_bit().

All three fixes were tested on the router with backports 6.18.55
(OpenWrt 25.12, kernel 6.12), using local AR6006 support patches. On
ath-next they build cleanly with W=1 for big- and little-endian MIPS.

AR6006 support will follow separately. The firmware question is here:
https://lore.kernel.org/r/20261129142154.53536-1-pepe.schlehofer@gmail.com

Josef Schlehofer (3):
  wifi: ath6kl: use little-endian BMI command fields
  wifi: ath6kl: use kvfree() for firmware
  wifi: ath6kl: use test_bit() for firmware capabilities

 drivers/net/wireless/ath/ath6kl/bmi.c  | 55 ++++++++++++++------------
 drivers/net/wireless/ath/ath6kl/core.c |  2 +-
 drivers/net/wireless/ath/ath6kl/init.c | 11 +-----
 3 files changed, 32 insertions(+), 36 deletions(-)


base-commit: 18d0bedbb5f0538396cb7f763ed9cd1dd69c5b23
-- 
2.54.0 (Apple Git-157)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH ath-next 1/3] wifi: ath6kl: use little-endian BMI command fields
  2026-11-29 15:47 [PATCH ath-next 0/3] wifi: ath6kl: fix issues found on big-endian MIPS Josef Schlehofer
@ 2026-11-29 15:47 ` Josef Schlehofer
  2026-11-29 15:47 ` [PATCH ath-next 2/3] wifi: ath6kl: use kvfree() for firmware Josef Schlehofer
  2026-11-29 15:47 ` [PATCH ath-next 3/3] wifi: ath6kl: use test_bit() for firmware capabilities Josef Schlehofer
  2 siblings, 0 replies; 4+ messages in thread
From: Josef Schlehofer @ 2026-11-29 15:47 UTC (permalink / raw)
  To: Jeff Johnson; +Cc: linux-wireless, stable

BMI command fields are little-endian, but ath6kl copies u32 values in
host byte order. This makes BMI commands fail on big-endian hosts, and
the first one, BMI_GET_TARGET_INFO, times out.

Use put_unaligned_le32() and cpu_to_le32() for the request fields and
get_unaligned_le32() for the 32-bit replies of BMI_EXECUTE and
BMI_READ_SOC_REGISTER. Memory payloads stay as they are. Also decode
the target info fields in the log messages with le32_to_cpu().

Fixes: bdcd81707973 ("Add ath6kl cleaned up driver")
Cc: stable@vger.kernel.org
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
---
Tested on a big-endian QCA9563 with an AR6006 hw1.1 USB device, using
local AR6006 support patches. Target info, register accesses, memory
writes and the LZ upload work, and the firmware boots. This chip does
not use BMI_EXECUTE or BMI_SET_APP_START.

 drivers/net/wireless/ath/ath6kl/bmi.c | 55 ++++++++++++++-------------
 1 file changed, 29 insertions(+), 26 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/bmi.c b/drivers/net/wireless/ath/ath6kl/bmi.c
index 5a9e93fd1..771cd7270 100644
--- a/drivers/net/wireless/ath/ath6kl/bmi.c
+++ b/drivers/net/wireless/ath/ath6kl/bmi.c
@@ -15,6 +15,8 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include <linux/unaligned.h>
+
 #include "core.h"
 #include "hif-ops.h"
 #include "target.h"
@@ -23,7 +25,7 @@
 int ath6kl_bmi_done(struct ath6kl *ar)
 {
 	int ret;
-	u32 cid = BMI_DONE;
+	__le32 cid = cpu_to_le32(BMI_DONE);
 
 	if (ar->bmi.done_sent) {
 		ath6kl_dbg(ATH6KL_DBG_BMI, "bmi done skipped\n");
@@ -46,13 +48,14 @@ int ath6kl_bmi_get_target_info(struct ath6kl *ar,
 {
 	int ret;
 	u32 cid = BMI_GET_TARGET_INFO;
+	__le32 cmd = cpu_to_le32(cid);
 
 	if (ar->bmi.done_sent) {
 		ath6kl_err("bmi done sent already, cmd %d disallowed\n", cid);
 		return -EACCES;
 	}
 
-	ret = ath6kl_hif_bmi_write(ar, (u8 *)&cid, sizeof(cid));
+	ret = ath6kl_hif_bmi_write(ar, (u8 *)&cmd, sizeof(cmd));
 	if (ret) {
 		ath6kl_err("Unable to send get target info: %d\n", ret);
 		return ret;
@@ -102,13 +105,13 @@ int ath6kl_bmi_get_target_info(struct ath6kl *ar,
 
 		if (ret) {
 			ath6kl_err("Unable to read target info (%d bytes): %d\n",
-				   targ_info->byte_count, ret);
+				   le32_to_cpu(targ_info->byte_count), ret);
 			return ret;
 		}
 	}
 
 	ath6kl_dbg(ATH6KL_DBG_BMI, "target info (ver: 0x%x type: 0x%x)\n",
-		   targ_info->version, targ_info->type);
+		   le32_to_cpu(targ_info->version), le32_to_cpu(targ_info->type));
 
 	return 0;
 }
@@ -143,11 +146,11 @@ int ath6kl_bmi_read(struct ath6kl *ar, u32 addr, u8 *buf, u32 len)
 		rx_len = (len_remain < ar->bmi.max_data_size) ?
 					len_remain : ar->bmi.max_data_size;
 		offset = 0;
-		memcpy(&(ar->bmi.cmd_buf[offset]), &cid, sizeof(cid));
+		put_unaligned_le32(cid, &ar->bmi.cmd_buf[offset]);
 		offset += sizeof(cid);
-		memcpy(&(ar->bmi.cmd_buf[offset]), &addr, sizeof(addr));
+		put_unaligned_le32(addr, &ar->bmi.cmd_buf[offset]);
 		offset += sizeof(addr);
-		memcpy(&(ar->bmi.cmd_buf[offset]), &rx_len, sizeof(rx_len));
+		put_unaligned_le32(rx_len, &ar->bmi.cmd_buf[offset]);
 		offset += sizeof(len);
 
 		ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset);
@@ -215,11 +218,11 @@ int ath6kl_bmi_write(struct ath6kl *ar, u32 addr, u8 *buf, u32 len)
 		}
 
 		offset = 0;
-		memcpy(&(ar->bmi.cmd_buf[offset]), &cid, sizeof(cid));
+		put_unaligned_le32(cid, &ar->bmi.cmd_buf[offset]);
 		offset += sizeof(cid);
-		memcpy(&(ar->bmi.cmd_buf[offset]), &addr, sizeof(addr));
+		put_unaligned_le32(addr, &ar->bmi.cmd_buf[offset]);
 		offset += sizeof(addr);
-		memcpy(&(ar->bmi.cmd_buf[offset]), &tx_len, sizeof(tx_len));
+		put_unaligned_le32(tx_len, &ar->bmi.cmd_buf[offset]);
 		offset += sizeof(tx_len);
 		memcpy(&(ar->bmi.cmd_buf[offset]), src, tx_len);
 		offset += tx_len;
@@ -259,11 +262,11 @@ int ath6kl_bmi_execute(struct ath6kl *ar, u32 addr, u32 *param)
 		   addr, *param);
 
 	offset = 0;
-	memcpy(&(ar->bmi.cmd_buf[offset]), &cid, sizeof(cid));
+	put_unaligned_le32(cid, &ar->bmi.cmd_buf[offset]);
 	offset += sizeof(cid);
-	memcpy(&(ar->bmi.cmd_buf[offset]), &addr, sizeof(addr));
+	put_unaligned_le32(addr, &ar->bmi.cmd_buf[offset]);
 	offset += sizeof(addr);
-	memcpy(&(ar->bmi.cmd_buf[offset]), param, sizeof(*param));
+	put_unaligned_le32(*param, &ar->bmi.cmd_buf[offset]);
 	offset += sizeof(*param);
 
 	ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset);
@@ -278,7 +281,7 @@ int ath6kl_bmi_execute(struct ath6kl *ar, u32 addr, u32 *param)
 		return ret;
 	}
 
-	memcpy(param, ar->bmi.cmd_buf, sizeof(*param));
+	*param = get_unaligned_le32(ar->bmi.cmd_buf);
 
 	return 0;
 }
@@ -305,9 +308,9 @@ int ath6kl_bmi_set_app_start(struct ath6kl *ar, u32 addr)
 	ath6kl_dbg(ATH6KL_DBG_BMI, "bmi set app start: addr: 0x%x\n", addr);
 
 	offset = 0;
-	memcpy(&(ar->bmi.cmd_buf[offset]), &cid, sizeof(cid));
+	put_unaligned_le32(cid, &ar->bmi.cmd_buf[offset]);
 	offset += sizeof(cid);
-	memcpy(&(ar->bmi.cmd_buf[offset]), &addr, sizeof(addr));
+	put_unaligned_le32(addr, &ar->bmi.cmd_buf[offset]);
 	offset += sizeof(addr);
 
 	ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset);
@@ -341,9 +344,9 @@ int ath6kl_bmi_reg_read(struct ath6kl *ar, u32 addr, u32 *param)
 	ath6kl_dbg(ATH6KL_DBG_BMI, "bmi read SOC reg: addr: 0x%x\n", addr);
 
 	offset = 0;
-	memcpy(&(ar->bmi.cmd_buf[offset]), &cid, sizeof(cid));
+	put_unaligned_le32(cid, &ar->bmi.cmd_buf[offset]);
 	offset += sizeof(cid);
-	memcpy(&(ar->bmi.cmd_buf[offset]), &addr, sizeof(addr));
+	put_unaligned_le32(addr, &ar->bmi.cmd_buf[offset]);
 	offset += sizeof(addr);
 
 	ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset);
@@ -357,7 +360,7 @@ int ath6kl_bmi_reg_read(struct ath6kl *ar, u32 addr, u32 *param)
 		ath6kl_err("Unable to read from the device: %d\n", ret);
 		return ret;
 	}
-	memcpy(param, ar->bmi.cmd_buf, sizeof(*param));
+	*param = get_unaligned_le32(ar->bmi.cmd_buf);
 
 	return 0;
 }
@@ -386,11 +389,11 @@ int ath6kl_bmi_reg_write(struct ath6kl *ar, u32 addr, u32 param)
 		    addr, param);
 
 	offset = 0;
-	memcpy(&(ar->bmi.cmd_buf[offset]), &cid, sizeof(cid));
+	put_unaligned_le32(cid, &ar->bmi.cmd_buf[offset]);
 	offset += sizeof(cid);
-	memcpy(&(ar->bmi.cmd_buf[offset]), &addr, sizeof(addr));
+	put_unaligned_le32(addr, &ar->bmi.cmd_buf[offset]);
 	offset += sizeof(addr);
-	memcpy(&(ar->bmi.cmd_buf[offset]), &param, sizeof(param));
+	put_unaligned_le32(param, &ar->bmi.cmd_buf[offset]);
 	offset += sizeof(param);
 
 	ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset);
@@ -432,9 +435,9 @@ int ath6kl_bmi_lz_data(struct ath6kl *ar, u8 *buf, u32 len)
 			  len_remain : (ar->bmi.max_data_size - header);
 
 		offset = 0;
-		memcpy(&(ar->bmi.cmd_buf[offset]), &cid, sizeof(cid));
+		put_unaligned_le32(cid, &ar->bmi.cmd_buf[offset]);
 		offset += sizeof(cid);
-		memcpy(&(ar->bmi.cmd_buf[offset]), &tx_len, sizeof(tx_len));
+		put_unaligned_le32(tx_len, &ar->bmi.cmd_buf[offset]);
 		offset += sizeof(tx_len);
 		memcpy(&(ar->bmi.cmd_buf[offset]), &buf[len - len_remain],
 		       tx_len);
@@ -477,9 +480,9 @@ int ath6kl_bmi_lz_stream_start(struct ath6kl *ar, u32 addr)
 		    addr);
 
 	offset = 0;
-	memcpy(&(ar->bmi.cmd_buf[offset]), &cid, sizeof(cid));
+	put_unaligned_le32(cid, &ar->bmi.cmd_buf[offset]);
 	offset += sizeof(cid);
-	memcpy(&(ar->bmi.cmd_buf[offset]), &addr, sizeof(addr));
+	put_unaligned_le32(addr, &ar->bmi.cmd_buf[offset]);
 	offset += sizeof(addr);
 
 	ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset);
-- 
2.54.0 (Apple Git-157)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH ath-next 2/3] wifi: ath6kl: use kvfree() for firmware
  2026-11-29 15:47 [PATCH ath-next 0/3] wifi: ath6kl: fix issues found on big-endian MIPS Josef Schlehofer
  2026-11-29 15:47 ` [PATCH ath-next 1/3] wifi: ath6kl: use little-endian BMI command fields Josef Schlehofer
@ 2026-11-29 15:47 ` Josef Schlehofer
  2026-11-29 15:47 ` [PATCH ath-next 3/3] wifi: ath6kl: use test_bit() for firmware capabilities Josef Schlehofer
  2 siblings, 0 replies; 4+ messages in thread
From: Josef Schlehofer @ 2026-11-29 15:47 UTC (permalink / raw)
  To: Jeff Johnson; +Cc: linux-wireless, stable

ar->fw is allocated with vmalloc() for API 2 and later firmware, but
with kmemdup() for API 1 firmware and for testmode firmware. vfree()
only handles the former, so unloading the driver in the kmemdup() case
warns "Trying to vfree() nonexistent vm area" and leaks the buffer.
Use kvfree() to handle both.

Observed when unloading an AR6006 hw1.1 with fw.ram.bin. With this
patch the warning is gone (tested on a big-endian QCA9563 with
backports 6.18.55).

Fixes: 8437754c8335 ("ath6kl: Use vmalloc instead of kmalloc for fw")
Cc: stable@vger.kernel.org
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
---
 drivers/net/wireless/ath/ath6kl/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c
index 648110cd3..1ed773eca 100644
--- a/drivers/net/wireless/ath/ath6kl/core.c
+++ b/drivers/net/wireless/ath/ath6kl/core.c
@@ -348,7 +348,7 @@ void ath6kl_core_cleanup(struct ath6kl *ar)
 
 	kfree(ar->fw_board);
 	kfree(ar->fw_otp);
-	vfree(ar->fw);
+	kvfree(ar->fw);
 	kfree(ar->fw_patch);
 	kfree(ar->fw_testscript);
 
-- 
2.54.0 (Apple Git-157)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH ath-next 3/3] wifi: ath6kl: use test_bit() for firmware capabilities
  2026-11-29 15:47 [PATCH ath-next 0/3] wifi: ath6kl: fix issues found on big-endian MIPS Josef Schlehofer
  2026-11-29 15:47 ` [PATCH ath-next 1/3] wifi: ath6kl: use little-endian BMI command fields Josef Schlehofer
  2026-11-29 15:47 ` [PATCH ath-next 2/3] wifi: ath6kl: use kvfree() for firmware Josef Schlehofer
@ 2026-11-29 15:47 ` Josef Schlehofer
  2 siblings, 0 replies; 4+ messages in thread
From: Josef Schlehofer @ 2026-11-29 15:47 UTC (permalink / raw)
  To: Jeff Johnson; +Cc: linux-wireless

fw_capabilities is an unsigned long bitmap filled with __set_bit().
ath6kl_init_get_fwcaps() reads it as bytes, which reports the wrong
capabilities on big-endian hosts. Use test_bit() to check each
capability.

With 64BIT_RATES, MAP_LP_ENDPOINT and NO_IP_CHECKSUM set, a big-endian
MIPS host printed "rssi-scan-thold,tx-err-notify" instead. With this
patch it prints all three (tested on a QCA9563 with backports
6.18.55).

Fixes: e72c27464cce ("ath6kl: print firmware capabilities")
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
---
 drivers/net/wireless/ath/ath6kl/init.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
index 6481da4c1..b91d96cb2 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -1660,18 +1660,11 @@ static const char *ath6kl_init_get_fw_capa_name(unsigned int id)
 
 static void ath6kl_init_get_fwcaps(struct ath6kl *ar, char *buf, size_t buf_len)
 {
-	u8 *data = (u8 *) ar->fw_capabilities;
 	size_t trunc_len, len = 0;
-	int i, index, bit;
+	int i;
 	char *trunc = "...";
 
 	for (i = 0; i < ATH6KL_FW_CAPABILITY_MAX; i++) {
-		index = i / 8;
-		bit = i % 8;
-
-		if (index >= sizeof(ar->fw_capabilities) * 4)
-			break;
-
 		if (buf_len - len < 4) {
 			ath6kl_warn("firmware capability buffer too small!\n");
 
@@ -1682,7 +1675,7 @@ static void ath6kl_init_get_fwcaps(struct ath6kl *ar, char *buf, size_t buf_len)
 			return;
 		}
 
-		if (data[index] & (1 << bit)) {
+		if (test_bit(i, ar->fw_capabilities)) {
 			len += scnprintf(buf + len, buf_len - len, "%s,",
 					    ath6kl_init_get_fw_capa_name(i));
 		}
-- 
2.54.0 (Apple Git-157)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-29 15:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 15:47 [PATCH ath-next 0/3] wifi: ath6kl: fix issues found on big-endian MIPS Josef Schlehofer
2026-11-29 15:47 ` [PATCH ath-next 1/3] wifi: ath6kl: use little-endian BMI command fields Josef Schlehofer
2026-11-29 15:47 ` [PATCH ath-next 2/3] wifi: ath6kl: use kvfree() for firmware Josef Schlehofer
2026-11-29 15:47 ` [PATCH ath-next 3/3] wifi: ath6kl: use test_bit() for firmware capabilities Josef Schlehofer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox