rtw88: use read_poll_timeout instead of fixed sleep
[ Upstream commit 02a55c0009a55b204e1e5c17295431f0a9e7d3b6 ] In current wow flow, driver calls rtw_wow_fw_start and sleep for 100ms, to wait firmware finish preliminary work and then update the value of WOWLAN_WAKE_REASON register to zero. But later firmware will start wow function with power-saving mode, in which mode the value of WOWLAN_WAKE_REASON register is 0xea. So driver may get 0xea value and return fail. We use read_poll_timeout instead to check the value to avoid this issue. Signed-off-by: Chin-Yen Lee <timlee@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20210728014335.8785-2-pkshih@realtek.com Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
9baf6f8ca2
commit
2fd1964f75
@@ -283,15 +283,26 @@ static void rtw_wow_rx_dma_start(struct rtw_dev *rtwdev)
|
|||||||
|
|
||||||
static int rtw_wow_check_fw_status(struct rtw_dev *rtwdev, bool wow_enable)
|
static int rtw_wow_check_fw_status(struct rtw_dev *rtwdev, bool wow_enable)
|
||||||
{
|
{
|
||||||
/* wait 100ms for wow firmware to finish work */
|
int ret;
|
||||||
msleep(100);
|
u8 check;
|
||||||
|
u32 check_dis;
|
||||||
|
|
||||||
if (wow_enable) {
|
if (wow_enable) {
|
||||||
if (rtw_read8(rtwdev, REG_WOWLAN_WAKE_REASON))
|
ret = read_poll_timeout(rtw_read8, check, !check, 1000,
|
||||||
|
100000, true, rtwdev,
|
||||||
|
REG_WOWLAN_WAKE_REASON);
|
||||||
|
if (ret)
|
||||||
goto wow_fail;
|
goto wow_fail;
|
||||||
} else {
|
} else {
|
||||||
if (rtw_read32_mask(rtwdev, REG_FE1IMR, BIT_FS_RXDONE) ||
|
ret = read_poll_timeout(rtw_read32_mask, check_dis,
|
||||||
rtw_read32_mask(rtwdev, REG_RXPKT_NUM, BIT_RW_RELEASE))
|
!check_dis, 1000, 100000, true, rtwdev,
|
||||||
|
REG_FE1IMR, BIT_FS_RXDONE);
|
||||||
|
if (ret)
|
||||||
|
goto wow_fail;
|
||||||
|
ret = read_poll_timeout(rtw_read32_mask, check_dis,
|
||||||
|
!check_dis, 1000, 100000, false, rtwdev,
|
||||||
|
REG_RXPKT_NUM, BIT_RW_RELEASE);
|
||||||
|
if (ret)
|
||||||
goto wow_fail;
|
goto wow_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user