All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: "Marcin Ślusarz" <marcin.slusarz@gmail.com>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Cc: "Marcin Ślusarz" <mslusarz@renau.com>
Subject: RE: wifi: rtw88: 8821CU hangs after some number of power-off/on cycles
Date: Tue, 28 May 2024 03:52:03 +0000	[thread overview]
Message-ID: <9bfc8f01e99b43e485b2afc6ae4fd661@realtek.com> (raw)
In-Reply-To: <20240527173454.459264-1-marcin.slusarz@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 333 bytes --]

Marcin Ślusarz <marcin.slusarz@gmail.com> wrote:
> 
> I found out that the reason for those hangs is a power-off+on sequence that's
> triggered by the above steps.

To avoid power-off/on sequence once device becomes idle, I would like to add
a ips_disabled helper. Please revert your changes and apply my attached patch.



[-- Attachment #2: 0001-wifi-rtw88-8821cu-disable-idle-power-save-for-8821CU.patch --]
[-- Type: application/octet-stream, Size: 3624 bytes --]

From e12845f1f6aab639375c5fa5e156d41474572b92 Mon Sep 17 00:00:00 2001
From: Ping-Ke Shih <pkshih@realtek.com>
Date: Tue, 28 May 2024 11:48:13 +0800
Subject: [PATCH] wifi: rtw88: 8821cu: disable idle power save for 8821CU
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This chip fails to reliably wake up from power off.

Change-Id: I295de3c71fe91af37e8cc39b70728a8ba7e94b2f
Reported-by: Marcin Ślusarz <marcin.slusarz@gmail.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
 mac80211.c | 2 +-
 main.c     | 4 ++--
 main.h     | 2 ++
 ps.c       | 5 ++++-
 ps.h       | 2 +-
 usb.c      | 3 +++
 wow.c      | 2 +-
 7 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/mac80211.c b/mac80211.c
index 78078d65c88f..5202ba74c20a 100644
--- a/mac80211.c
+++ b/mac80211.c
@@ -99,7 +99,7 @@ static int rtw_ops_config(struct ieee80211_hw *hw, u32 changed)
 	if ((changed & IEEE80211_CONF_CHANGE_IDLE) &&
 	    (hw->conf.flags & IEEE80211_CONF_IDLE) &&
 	    !test_bit(RTW_FLAG_SCANNING, rtwdev->flags))
-		rtw_enter_ips(rtwdev);
+		rtw_enter_ips(rtwdev, false);
 
 out:
 	mutex_unlock(&rtwdev->mutex);
diff --git a/main.c b/main.c
index 567f9d4373c4..9c9ecddb5046 100644
--- a/main.c
+++ b/main.c
@@ -306,7 +306,7 @@ static void rtw_ips_work(struct work_struct *work)
 
 	mutex_lock(&rtwdev->mutex);
 	if (rtwdev->hw->conf.flags & IEEE80211_CONF_IDLE)
-		rtw_enter_ips(rtwdev);
+		rtw_enter_ips(rtwdev, false);
 	mutex_unlock(&rtwdev->mutex);
 }
 
@@ -660,7 +660,7 @@ free:
 	rtw_iterate_stas_atomic(rtwdev, rtw_reset_sta_iter, rtwdev);
 	rtw_iterate_vifs_atomic(rtwdev, rtw_reset_vif_iter, rtwdev);
 	bitmap_zero(rtwdev->hw_port, RTW_PORT_NUM);
-	rtw_enter_ips(rtwdev);
+	rtw_enter_ips(rtwdev, true);
 }
 
 static void rtw_fw_recovery_work(struct work_struct *work)
diff --git a/main.h b/main.h
index d9afb585d423..659bc862d4ca 100644
--- a/main.h
+++ b/main.h
@@ -2283,6 +2283,8 @@ struct rtw_dev {
 	bool beacon_loss;
 	struct completion lps_leave_check;
 
+	bool ips_disabled;
+
 	struct dentry *debugfs;
 
 	u8 sta_cnt;
diff --git a/ps.c b/ps.c
index b171e62d2d57..41de4ecc9bc3 100644
--- a/ps.c
+++ b/ps.c
@@ -24,8 +24,11 @@ static int rtw_ips_pwr_up(struct rtw_dev *rtwdev)
 	return ret;
 }
 
-int rtw_enter_ips(struct rtw_dev *rtwdev)
+int rtw_enter_ips(struct rtw_dev *rtwdev, bool force)
 {
+	if (!force && rtwdev->ips_disabled)
+		return 0;
+
 	if (!test_bit(RTW_FLAG_POWERON, rtwdev->flags))
 		return 0;
 
diff --git a/ps.h b/ps.h
index 5ae83d2526cf..92057d01cbec 100644
--- a/ps.h
+++ b/ps.h
@@ -15,7 +15,7 @@
 #define LEAVE_LPS_TRY_CNT	5
 #define LEAVE_LPS_TIMEOUT	msecs_to_jiffies(100)
 
-int rtw_enter_ips(struct rtw_dev *rtwdev);
+int rtw_enter_ips(struct rtw_dev *rtwdev, bool force);
 int rtw_leave_ips(struct rtw_dev *rtwdev);
 
 void rtw_power_mode_change(struct rtw_dev *rtwdev, bool enter);
diff --git a/usb.c b/usb.c
index a0188511099a..9ca06db6302f 100644
--- a/usb.c
+++ b/usb.c
@@ -854,6 +854,9 @@ int rtw_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	rtwdev->hci.ops = &rtw_usb_ops;
 	rtwdev->hci.type = RTW_HCI_TYPE_USB;
 
+	if (rtwdev->chip->id == RTW_CHIP_TYPE_8821C)
+		rtwdev->ips_disabled = true;
+
 	rtwusb = rtw_get_usb_priv(rtwdev);
 	rtwusb->rtwdev = rtwdev;
 
diff --git a/wow.c b/wow.c
index c86cfc47361a..2163e1dab630 100644
--- a/wow.c
+++ b/wow.c
@@ -677,7 +677,7 @@ static int rtw_wow_restore_ps(struct rtw_dev *rtwdev)
 	int ret = 0;
 
 	if (rtw_wow_no_link(rtwdev) && rtwdev->wow.ips_enabled)
-		ret = rtw_enter_ips(rtwdev);
+		ret = rtw_enter_ips(rtwdev, false);
 
 	return ret;
 }
-- 
2.25.1


  parent reply	other threads:[~2024-05-28  3:52 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-27 17:34 wifi: rtw88: 8821CU hangs after some number of power-off/on cycles Marcin Ślusarz
2024-05-27 17:34 ` [PATCH 1/2] wifi: rtw88: use RTW_FLAG_RUNNING for deciding whether to enter/leave IPS Marcin Ślusarz
2024-05-28  3:56   ` Ping-Ke Shih
2024-05-28 10:53     ` Marcin Ślusarz
2024-05-27 17:34 ` [PATCH 2/2] wifi: rtw88: disable power offs for 8821C Marcin Ślusarz
2024-05-27 18:43 ` wifi: rtw88: 8821CU hangs after some number of power-off/on cycles Bitterblue Smith
2024-05-28 10:42   ` Marcin Ślusarz
2024-05-28 12:25     ` Bitterblue Smith
2024-05-28 12:38       ` Marcin Ślusarz
2024-05-28  3:52 ` Ping-Ke Shih [this message]
2024-05-28 10:52   ` Marcin Ślusarz
2024-05-29  1:52     ` Ping-Ke Shih
2024-05-29 15:53       ` Marcin Ślusarz
2024-05-30  3:13         ` Ping-Ke Shih
2024-06-03 14:52           ` Marcin Ślusarz
2024-06-03 14:55             ` [PATCH] wifi: rtw88/usb: stop rx work before potential power off Marcin Ślusarz
2024-06-04  0:57               ` Ping-Ke Shih
2024-06-14 11:35                 ` Marcin Ślusarz
2024-06-14 12:13                   ` [PATCH v2 1/2] wifi: rtw88: 8821cu: keep power on always for 8821CU Marcin Ślusarz
2024-06-14 12:13                     ` [PATCH v2 2/2] wifi: rtw88/usb: stop rx work before potential power off Marcin Ślusarz
2024-06-17  1:56                       ` Ping-Ke Shih
2024-06-17  1:40                     ` [PATCH v2 1/2] wifi: rtw88: 8821cu: keep power on always for 8821CU Ping-Ke Shih
2024-06-17  1:47                   ` [PATCH] wifi: rtw88/usb: stop rx work before potential power off Ping-Ke Shih
2024-06-03 14:56             ` [PATCH] wifi: rtw88: usb: drop rx skbs when device is not running Marcin Ślusarz
2024-06-04  0:50             ` wifi: rtw88: 8821CU hangs after some number of power-off/on cycles Ping-Ke Shih
2024-06-14 11:42               ` Marcin Ślusarz

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=9bfc8f01e99b43e485b2afc6ae4fd661@realtek.com \
    --to=pkshih@realtek.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=marcin.slusarz@gmail.com \
    --cc=mslusarz@renau.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.