From: Alexander Wilhelm <alexander.wilhelm@westermo.com>
To: Jeff Johnson <jjohnson@kernel.org>,
Baochen Qiang <baochen.qiang@oss.qualcomm.com>
Cc: linux-wireless@vger.kernel.org, ath12k@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] wifi: ath12k: fix SPT vaddr handling on big endian systems
Date: Wed, 25 Mar 2026 14:01:48 +0100 [thread overview]
Message-ID: <20260325-fix-rx-tx-description-virtual-address-v1-1-f7ae6efc79aa@westermo.com> (raw)
SPT pages store descriptor addresses in their vaddr field as little endian
64 bit values. Treating these entries as native pointers produces invalid
addresses on big endian systems.
Convert vaddr to __le64 and update all access paths. Write descriptor
addresses as endian annotated 64 bit values and load them by converting
back to native pointers. Return __le64* instead of void* from the SPT
lookup and translate the stored value in the descriptor getters.
This ensures correct and consistent handling of descriptor addresses on big
endian systems, while little endian systems remain unaffected.
Signed-off-by: Alexander Wilhelm <alexander.wilhelm@westermo.com>
---
drivers/net/wireless/ath/ath12k/dp.c | 26 ++++++++++++++++----------
drivers/net/wireless/ath/ath12k/dp.h | 2 +-
2 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/dp.c b/drivers/net/wireless/ath/ath12k/dp.c
index 1c82d927d27b..2076ae65e9e7 100644
--- a/drivers/net/wireless/ath/ath12k/dp.c
+++ b/drivers/net/wireless/ath/ath12k/dp.c
@@ -1149,8 +1149,8 @@ static u32 ath12k_dp_cc_cookie_gen(u16 ppt_idx, u16 spt_idx)
return (u32)ppt_idx << ATH12K_CC_PPT_SHIFT | spt_idx;
}
-static void *ath12k_dp_cc_get_desc_addr_ptr(struct ath12k_dp *dp,
- u16 ppt_idx, u16 spt_idx)
+static __le64 *ath12k_dp_cc_get_desc_addr_ptr(struct ath12k_dp *dp,
+ u16 ppt_idx, u16 spt_idx)
{
return dp->spt_info[ppt_idx].vaddr + spt_idx;
}
@@ -1158,8 +1158,9 @@ static void *ath12k_dp_cc_get_desc_addr_ptr(struct ath12k_dp *dp,
struct ath12k_rx_desc_info *ath12k_dp_get_rx_desc(struct ath12k_dp *dp,
u32 cookie)
{
- struct ath12k_rx_desc_info **desc_addr_ptr;
u16 start_ppt_idx, end_ppt_idx, ppt_idx, spt_idx;
+ __le64 *desc_addr_ptr;
+ uintptr_t desc_addr;
ppt_idx = u32_get_bits(cookie, ATH12K_DP_CC_COOKIE_PPT);
spt_idx = u32_get_bits(cookie, ATH12K_DP_CC_COOKIE_SPT);
@@ -1174,16 +1175,18 @@ struct ath12k_rx_desc_info *ath12k_dp_get_rx_desc(struct ath12k_dp *dp,
ppt_idx = ppt_idx - dp->rx_ppt_base;
desc_addr_ptr = ath12k_dp_cc_get_desc_addr_ptr(dp, ppt_idx, spt_idx);
+ desc_addr = (uintptr_t)le64_to_cpu(*desc_addr_ptr);
- return *desc_addr_ptr;
+ return (struct ath12k_rx_desc_info *)desc_addr;
}
EXPORT_SYMBOL(ath12k_dp_get_rx_desc);
struct ath12k_tx_desc_info *ath12k_dp_get_tx_desc(struct ath12k_dp *dp,
u32 cookie)
{
- struct ath12k_tx_desc_info **desc_addr_ptr;
u16 start_ppt_idx, end_ppt_idx, ppt_idx, spt_idx;
+ __le64 *desc_addr_ptr;
+ uintptr_t desc_addr;
ppt_idx = u32_get_bits(cookie, ATH12K_DP_CC_COOKIE_PPT);
spt_idx = u32_get_bits(cookie, ATH12K_DP_CC_COOKIE_SPT);
@@ -1198,19 +1201,22 @@ struct ath12k_tx_desc_info *ath12k_dp_get_tx_desc(struct ath12k_dp *dp,
return NULL;
desc_addr_ptr = ath12k_dp_cc_get_desc_addr_ptr(dp, ppt_idx, spt_idx);
+ desc_addr = (uintptr_t)le64_to_cpu(*desc_addr_ptr);
- return *desc_addr_ptr;
+ return (struct ath12k_tx_desc_info *)desc_addr;
}
EXPORT_SYMBOL(ath12k_dp_get_tx_desc);
static int ath12k_dp_cc_desc_init(struct ath12k_base *ab)
{
struct ath12k_dp *dp = ath12k_ab_to_dp(ab);
- struct ath12k_rx_desc_info *rx_descs, **rx_desc_addr;
- struct ath12k_tx_desc_info *tx_descs, **tx_desc_addr;
+ struct ath12k_rx_desc_info *rx_descs;
+ struct ath12k_tx_desc_info *tx_descs;
u32 num_rx_spt_pages = ATH12K_NUM_RX_SPT_PAGES(ab);
u32 i, j, pool_id, tx_spt_page;
u32 ppt_idx, cookie_ppt_idx;
+ __le64 *rx_desc_addr;
+ __le64 *tx_desc_addr;
spin_lock_bh(&dp->rx_desc_lock);
@@ -1246,7 +1252,7 @@ static int ath12k_dp_cc_desc_init(struct ath12k_base *ab)
/* Update descriptor VA in SPT */
rx_desc_addr = ath12k_dp_cc_get_desc_addr_ptr(dp, ppt_idx, j);
- *rx_desc_addr = &rx_descs[j];
+ *rx_desc_addr = cpu_to_le64((u64)(uintptr_t)&rx_descs[j]);
}
}
@@ -1286,7 +1292,7 @@ static int ath12k_dp_cc_desc_init(struct ath12k_base *ab)
/* Update descriptor VA in SPT */
tx_desc_addr =
ath12k_dp_cc_get_desc_addr_ptr(dp, ppt_idx, j);
- *tx_desc_addr = &tx_descs[j];
+ *tx_desc_addr = cpu_to_le64((u64)(uintptr_t)&tx_descs[j]);
}
}
spin_unlock_bh(&dp->tx_desc_lock[pool_id]);
diff --git a/drivers/net/wireless/ath/ath12k/dp.h b/drivers/net/wireless/ath/ath12k/dp.h
index f8cfc7bb29dd..0d7fc2aea241 100644
--- a/drivers/net/wireless/ath/ath12k/dp.h
+++ b/drivers/net/wireless/ath/ath12k/dp.h
@@ -357,7 +357,7 @@ struct ath12k_tx_desc_params {
struct ath12k_spt_info {
dma_addr_t paddr;
- u64 *vaddr;
+ __le64 *vaddr;
};
struct ath12k_reo_queue_ref {
---
base-commit: 988707e4b5a73aa78f2fa260727c36fe725fa816
change-id: 20260325-fix-rx-tx-description-virtual-address-91f511690671
Best regards,
--
Alexander Wilhelm <alexander.wilhelm@westermo.com>
reply other threads:[~2026-03-25 13:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260325-fix-rx-tx-description-virtual-address-v1-1-f7ae6efc79aa@westermo.com \
--to=alexander.wilhelm@westermo.com \
--cc=ath12k@lists.infradead.org \
--cc=baochen.qiang@oss.qualcomm.com \
--cc=jjohnson@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox