OSDN Git Service

wifi: rtw88: fix race condition when doing H2C command
authorJi-Pin Jou <neo_jou@realtek.com>
Thu, 24 Nov 2022 06:44:42 +0000 (14:44 +0800)
committerKalle Valo <kvalo@kernel.org>
Mon, 28 Nov 2022 13:58:05 +0000 (15:58 +0200)
commit823092a53556ebf8656623d0e857626d30fe1e18
tree5176dd023fb80ffcf815dd086a1e6122fa32ed98
parent3ca7f0b2523cac5d436cd09758db07e10b1a322a
wifi: rtw88: fix race condition when doing H2C command

For SDIO/USB interface, since the tranferring speed is slower than
that in PCIE, it may have race condition when the driver sets down
H2C command to the FW.

In the function rtw_fw_send_h2c_command, before the patch, box_reg
is written first, then box_ex_reg is written. FW starts to work and
fetch the value of box_ex_reg,  when the most significant byte of
box_reg(4 bytes) is written. Meanwhile, for SDIO/USB interface,
since the transferring speed is slow, the driver is still in writing
the new value of box_ex_reg through the bus, and FW may get the
wrong value of box_ex_reg at the moment.

To prevent the above driver/FW racing situation, box_ex_reg is
written first then box_reg. Furthermore, it is written in 4 bytes at
a time, instead of written in one byte one by one. It can increase
the speed for SDIO/USB interface.

Signed-off-by: Ji-Pin Jou <neo_jou@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Tested-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20221124064442.28042-1-pkshih@realtek.com
drivers/net/wireless/realtek/rtw88/fw.c
drivers/net/wireless/realtek/rtw88/fw.h