From: Ping-Ke Shih <pkshih@realtek.com>
To: <kvalo@kernel.org>
Cc: <leo.li@realtek.com>, <timlee@realtek.com>, <phhuang@realtek.com>,
<linux-wireless@vger.kernel.org>
Subject: [PATCH v2 1/5] wifi: rtw89: add retry to change power_mode state
Date: Fri, 19 Aug 2022 14:48:07 +0800 [thread overview]
Message-ID: <20220819064811.37700-2-pkshih@realtek.com> (raw)
In-Reply-To: <20220819064811.37700-1-pkshih@realtek.com>
From: Chin-Yen Lee <timlee@realtek.com>
When starting to send heavy traffic in low power mode,
driver will call multiple tx wake notify to wake firmware
within a short time. In this situation, firmware may miss
power mode change request from driver and leads to status
error. So we change driver to call power_mode_change at most
three times to make sure firmware could get the request.
Signed-off-by: Chin-Yen Lee <timlee@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
drivers/net/wireless/realtek/rtw89/mac.c | 23 +++++++++++++++++------
drivers/net/wireless/realtek/rtw89/mac.h | 1 +
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw89/mac.c b/drivers/net/wireless/realtek/rtw89/mac.c
index 93124b815825f..61c7e79714925 100644
--- a/drivers/net/wireless/realtek/rtw89/mac.c
+++ b/drivers/net/wireless/realtek/rtw89/mac.c
@@ -1053,18 +1053,29 @@ void rtw89_mac_power_mode_change(struct rtw89_dev *rtwdev, bool enter)
enum rtw89_rpwm_req_pwr_state state;
unsigned long delay = enter ? 10 : 150;
int ret;
+ int i;
if (enter)
state = rtw89_mac_get_req_pwr_state(rtwdev);
else
state = RTW89_MAC_RPWM_REQ_PWR_STATE_ACTIVE;
- rtw89_mac_send_rpwm(rtwdev, state, false);
- ret = read_poll_timeout_atomic(rtw89_mac_check_cpwm_state, ret, !ret,
- delay, 15000, false, rtwdev, state);
- if (ret)
- rtw89_err(rtwdev, "firmware failed to ack for %s ps mode\n",
- enter ? "entering" : "leaving");
+ for (i = 0; i < RPWM_TRY_CNT; i++) {
+ rtw89_mac_send_rpwm(rtwdev, state, false);
+ ret = read_poll_timeout_atomic(rtw89_mac_check_cpwm_state, ret,
+ !ret, delay, 15000, false,
+ rtwdev, state);
+ if (!ret)
+ break;
+
+ if (i == RPWM_TRY_CNT - 1)
+ rtw89_err(rtwdev, "firmware failed to ack for %s ps mode\n",
+ enter ? "entering" : "leaving");
+ else
+ rtw89_debug(rtwdev, RTW89_DBG_UNEXP,
+ "%d time firmware failed to ack for %s ps mode\n",
+ i + 1, enter ? "entering" : "leaving");
+ }
}
void rtw89_mac_notify_wake(struct rtw89_dev *rtwdev)
diff --git a/drivers/net/wireless/realtek/rtw89/mac.h b/drivers/net/wireless/realtek/rtw89/mac.h
index f66619354734d..986e359a82237 100644
--- a/drivers/net/wireless/realtek/rtw89/mac.h
+++ b/drivers/net/wireless/realtek/rtw89/mac.h
@@ -11,6 +11,7 @@
#define ADDR_CAM_ENT_SIZE 0x40
#define BSSID_CAM_ENT_SIZE 0x08
#define HFC_PAGE_UNIT 64
+#define RPWM_TRY_CNT 3
enum rtw89_mac_hwmod_sel {
RTW89_DMAC_SEL = 0,
--
2.25.1
next prev parent reply other threads:[~2022-08-19 6:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-19 6:48 [PATCH v2 0/5] wifi: rtw89: correct MAC and PCI settings Ping-Ke Shih
2022-08-19 6:48 ` Ping-Ke Shih [this message]
2022-09-02 8:36 ` [PATCH v2 1/5] wifi: rtw89: add retry to change power_mode state Kalle Valo
2022-08-19 6:48 ` [PATCH v2 2/5] wifi: rtw89: 8852c: set TBTT shift configuration Ping-Ke Shih
2022-08-19 6:48 ` [PATCH v2 3/5] wifi: rtw89: pci: fix PCI PHY auto adaption by using software restore Ping-Ke Shih
2022-08-19 6:48 ` [PATCH v2 4/5] wifi: rtw89: pci: enable CLK_REQ, ASPM, L1 and L1ss for 8852c Ping-Ke Shih
2023-02-07 20:49 ` Bjorn Helgaas
2023-02-08 9:15 ` Ping-Ke Shih
2023-02-08 22:03 ` Bjorn Helgaas
2023-02-13 1:46 ` Ping-Ke Shih
2023-02-13 21:16 ` Bjorn Helgaas
2022-08-19 6:48 ` [PATCH v2 5/5] wifi: rtw89: pci: correct suspend/resume setting for variant chips Ping-Ke Shih
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=20220819064811.37700-2-pkshih@realtek.com \
--to=pkshih@realtek.com \
--cc=kvalo@kernel.org \
--cc=leo.li@realtek.com \
--cc=linux-wireless@vger.kernel.org \
--cc=phhuang@realtek.com \
--cc=timlee@realtek.com \
/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;
as well as URLs for NNTP newsgroup(s).