* [PATCH 1/2] wifi: rtw88: Don't use static local variable in rtw8822b_set_tx_power_index_by_rate
@ 2025-01-26 14:03 Bitterblue Smith
2025-01-26 14:04 ` [PATCH 2/2] wifi: rtw88: Don't use static local variable in rtw8821c_set_tx_power_index_by_rate Bitterblue Smith
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Bitterblue Smith @ 2025-01-26 14:03 UTC (permalink / raw)
To: linux-wireless@vger.kernel.org; +Cc: Ping-Ke Shih
Some users want to plug two identical USB devices at the same time.
This static variable could theoretically cause them to use incorrect
TX power values.
Move the variable to the caller and pass a pointer to it to
rtw8822b_set_tx_power_index_by_rate().
Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
---
drivers/net/wireless/realtek/rtw88/rtw8822b.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.c b/drivers/net/wireless/realtek/rtw88/rtw8822b.c
index 7f03903ddf4b..23a29019752d 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8822b.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.c
@@ -935,11 +935,11 @@ static void query_phy_status(struct rtw_dev *rtwdev, u8 *phy_status,
}
static void
-rtw8822b_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path, u8 rs)
+rtw8822b_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path,
+ u8 rs, u32 *phy_pwr_idx)
{
struct rtw_hal *hal = &rtwdev->hal;
static const u32 offset_txagc[2] = {0x1d00, 0x1d80};
- static u32 phy_pwr_idx;
u8 rate, rate_idx, pwr_index, shift;
int j;
@@ -947,12 +947,12 @@ rtw8822b_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path, u8 rs)
rate = rtw_rate_section[rs][j];
pwr_index = hal->tx_pwr_tbl[path][rate];
shift = rate & 0x3;
- phy_pwr_idx |= ((u32)pwr_index << (shift * 8));
+ *phy_pwr_idx |= ((u32)pwr_index << (shift * 8));
if (shift == 0x3) {
rate_idx = rate & 0xfc;
rtw_write32(rtwdev, offset_txagc[path] + rate_idx,
- phy_pwr_idx);
- phy_pwr_idx = 0;
+ *phy_pwr_idx);
+ *phy_pwr_idx = 0;
}
}
}
@@ -960,11 +960,13 @@ rtw8822b_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path, u8 rs)
static void rtw8822b_set_tx_power_index(struct rtw_dev *rtwdev)
{
struct rtw_hal *hal = &rtwdev->hal;
+ u32 phy_pwr_idx = 0;
int rs, path;
for (path = 0; path < hal->rf_path_num; path++) {
for (rs = 0; rs < RTW_RATE_SECTION_MAX; rs++)
- rtw8822b_set_tx_power_index_by_rate(rtwdev, path, rs);
+ rtw8822b_set_tx_power_index_by_rate(rtwdev, path, rs,
+ &phy_pwr_idx);
}
}
--
2.48.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/2] wifi: rtw88: Don't use static local variable in rtw8821c_set_tx_power_index_by_rate
2025-01-26 14:03 [PATCH 1/2] wifi: rtw88: Don't use static local variable in rtw8822b_set_tx_power_index_by_rate Bitterblue Smith
@ 2025-01-26 14:04 ` Bitterblue Smith
2025-01-27 6:04 ` Ping-Ke Shih
2025-01-27 6:03 ` [PATCH 1/2] wifi: rtw88: Don't use static local variable in rtw8822b_set_tx_power_index_by_rate Ping-Ke Shih
2025-02-03 2:43 ` Ping-Ke Shih
2 siblings, 1 reply; 6+ messages in thread
From: Bitterblue Smith @ 2025-01-26 14:04 UTC (permalink / raw)
To: linux-wireless@vger.kernel.org; +Cc: Ping-Ke Shih
Some users want to plug two identical USB devices at the same time.
This static variable could theoretically cause them to use incorrect
TX power values.
Move the variable to the caller and pass a pointer to it to
rtw8821c_set_tx_power_index_by_rate().
Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
---
drivers/net/wireless/realtek/rtw88/rtw8821c.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821c.c b/drivers/net/wireless/realtek/rtw88/rtw8821c.c
index eb7e34c545d0..cc152248407c 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8821c.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8821c.c
@@ -680,11 +680,11 @@ static void query_phy_status(struct rtw_dev *rtwdev, u8 *phy_status,
}
static void
-rtw8821c_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path, u8 rs)
+rtw8821c_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path,
+ u8 rs, u32 *phy_pwr_idx)
{
struct rtw_hal *hal = &rtwdev->hal;
static const u32 offset_txagc[2] = {0x1d00, 0x1d80};
- static u32 phy_pwr_idx;
u8 rate, rate_idx, pwr_index, shift;
int j;
@@ -692,12 +692,12 @@ rtw8821c_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path, u8 rs)
rate = rtw_rate_section[rs][j];
pwr_index = hal->tx_pwr_tbl[path][rate];
shift = rate & 0x3;
- phy_pwr_idx |= ((u32)pwr_index << (shift * 8));
+ *phy_pwr_idx |= ((u32)pwr_index << (shift * 8));
if (shift == 0x3 || rate == DESC_RATEVHT1SS_MCS9) {
rate_idx = rate & 0xfc;
rtw_write32(rtwdev, offset_txagc[path] + rate_idx,
- phy_pwr_idx);
- phy_pwr_idx = 0;
+ *phy_pwr_idx);
+ *phy_pwr_idx = 0;
}
}
}
@@ -705,6 +705,7 @@ rtw8821c_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path, u8 rs)
static void rtw8821c_set_tx_power_index(struct rtw_dev *rtwdev)
{
struct rtw_hal *hal = &rtwdev->hal;
+ u32 phy_pwr_idx = 0;
int rs, path;
for (path = 0; path < hal->rf_path_num; path++) {
@@ -712,7 +713,8 @@ static void rtw8821c_set_tx_power_index(struct rtw_dev *rtwdev)
if (rs == RTW_RATE_SECTION_HT_2S ||
rs == RTW_RATE_SECTION_VHT_2S)
continue;
- rtw8821c_set_tx_power_index_by_rate(rtwdev, path, rs);
+ rtw8821c_set_tx_power_index_by_rate(rtwdev, path, rs,
+ &phy_pwr_idx);
}
}
}
--
2.48.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 1/2] wifi: rtw88: Don't use static local variable in rtw8822b_set_tx_power_index_by_rate
2025-01-26 14:03 [PATCH 1/2] wifi: rtw88: Don't use static local variable in rtw8822b_set_tx_power_index_by_rate Bitterblue Smith
2025-01-26 14:04 ` [PATCH 2/2] wifi: rtw88: Don't use static local variable in rtw8821c_set_tx_power_index_by_rate Bitterblue Smith
@ 2025-01-27 6:03 ` Ping-Ke Shih
2025-01-27 23:17 ` Bitterblue Smith
2025-02-03 2:43 ` Ping-Ke Shih
2 siblings, 1 reply; 6+ messages in thread
From: Ping-Ke Shih @ 2025-01-27 6:03 UTC (permalink / raw)
To: Bitterblue Smith, linux-wireless@vger.kernel.org
Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>
> Some users want to plug two identical USB devices at the same time.
> This static variable could theoretically cause them to use incorrect
> TX power values.
>
> Move the variable to the caller and pass a pointer to it to
> rtw8822b_set_tx_power_index_by_rate().
>
> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
By the way, if you interest to cleanup rtw88 and avoid this kind of limits,
we can check symbols of output of "objdump -t *.o | grep "\.data".
Patches are welcome.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] wifi: rtw88: Don't use static local variable in rtw8822b_set_tx_power_index_by_rate
2025-01-27 6:03 ` [PATCH 1/2] wifi: rtw88: Don't use static local variable in rtw8822b_set_tx_power_index_by_rate Ping-Ke Shih
@ 2025-01-27 23:17 ` Bitterblue Smith
0 siblings, 0 replies; 6+ messages in thread
From: Bitterblue Smith @ 2025-01-27 23:17 UTC (permalink / raw)
To: Ping-Ke Shih, linux-wireless@vger.kernel.org
On 27/01/2025 08:03, Ping-Ke Shih wrote:
> Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>>
>> Some users want to plug two identical USB devices at the same time.
>> This static variable could theoretically cause them to use incorrect
>> TX power values.
>>
>> Move the variable to the caller and pass a pointer to it to
>> rtw8822b_set_tx_power_index_by_rate().
>>
>> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
>
> Acked-by: Ping-Ke Shih <pkshih@realtek.com>
>
> By the way, if you interest to cleanup rtw88 and avoid this kind of limits,
> we can check symbols of output of "objdump -t *.o | grep "\.data".
> Patches are welcome.
>
I see some tables that should be const. I will send a patch.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] wifi: rtw88: Don't use static local variable in rtw8822b_set_tx_power_index_by_rate
2025-01-26 14:03 [PATCH 1/2] wifi: rtw88: Don't use static local variable in rtw8822b_set_tx_power_index_by_rate Bitterblue Smith
2025-01-26 14:04 ` [PATCH 2/2] wifi: rtw88: Don't use static local variable in rtw8821c_set_tx_power_index_by_rate Bitterblue Smith
2025-01-27 6:03 ` [PATCH 1/2] wifi: rtw88: Don't use static local variable in rtw8822b_set_tx_power_index_by_rate Ping-Ke Shih
@ 2025-02-03 2:43 ` Ping-Ke Shih
2 siblings, 0 replies; 6+ messages in thread
From: Ping-Ke Shih @ 2025-02-03 2:43 UTC (permalink / raw)
To: Bitterblue Smith, linux-wireless@vger.kernel.org; +Cc: Ping-Ke Shih
Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
> Some users want to plug two identical USB devices at the same time.
> This static variable could theoretically cause them to use incorrect
> TX power values.
>
> Move the variable to the caller and pass a pointer to it to
> rtw8822b_set_tx_power_index_by_rate().
>
> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
> Acked-by: Ping-Ke Shih <pkshih@realtek.com>
2 patch(es) applied to rtw-next branch of rtw.git, thanks.
00451eb3bec7 wifi: rtw88: Don't use static local variable in rtw8822b_set_tx_power_index_by_rate
0d1d165eff9d wifi: rtw88: Don't use static local variable in rtw8821c_set_tx_power_index_by_rate
---
https://github.com/pkshih/rtw.git
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-02-03 2:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-26 14:03 [PATCH 1/2] wifi: rtw88: Don't use static local variable in rtw8822b_set_tx_power_index_by_rate Bitterblue Smith
2025-01-26 14:04 ` [PATCH 2/2] wifi: rtw88: Don't use static local variable in rtw8821c_set_tx_power_index_by_rate Bitterblue Smith
2025-01-27 6:04 ` Ping-Ke Shih
2025-01-27 6:03 ` [PATCH 1/2] wifi: rtw88: Don't use static local variable in rtw8822b_set_tx_power_index_by_rate Ping-Ke Shih
2025-01-27 23:17 ` Bitterblue Smith
2025-02-03 2:43 ` Ping-Ke Shih
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox