All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rtw88: use shorter delay time to poll PS state
@ 2020-01-07 14:27 yhchuang
  2020-01-09 10:34 ` Chris Chiu
  2020-01-26 15:43 ` Kalle Valo
  0 siblings, 2 replies; 3+ messages in thread
From: yhchuang @ 2020-01-07 14:27 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless, briannorris

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

When TX packet arrives, driver should leave deep PS state to make
sure the DMA is working. After requested to leave deep PS state,
driver needs to poll the PS state to check if the mode has been
changed successfully. The driver used to check the state of the
hardware every 20 msecs, which means upon the first failure of
state check, the CPU is delayed 20 msecs for next check. This is
harmful for some time-sensitive applications such as media players.

So, use shorter delay time each check from 20 msecs to 100 usecs.
The state should be changed in several tries. But we still need
to reserve ~15 msecs in total in case of the state just took too
long to be changed successfully. If the states of driver and the
hardware is not synchronized, the power state could be locked
forever, which mean we could never enter/leave the PS state.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
---
 drivers/net/wireless/realtek/rtw88/ps.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw88/ps.c b/drivers/net/wireless/realtek/rtw88/ps.c
index 913e6f47130f..7a189a9926fe 100644
--- a/drivers/net/wireless/realtek/rtw88/ps.c
+++ b/drivers/net/wireless/realtek/rtw88/ps.c
@@ -91,11 +91,11 @@ void rtw_power_mode_change(struct rtw_dev *rtwdev, bool enter)
 			return;
 
 		/* check confirm power mode has left power save state */
-		for (polling_cnt = 0; polling_cnt < 3; polling_cnt++) {
+		for (polling_cnt = 0; polling_cnt < 50; polling_cnt++) {
 			polling = rtw_read8(rtwdev, rtwdev->hci.cpwm_addr);
 			if ((polling ^ confirm) & BIT_RPWM_TOGGLE)
 				return;
-			mdelay(20);
+			udelay(100);
 		}
 
 		/* in case of fw/hw missed the request, retry */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] rtw88: use shorter delay time to poll PS state
  2020-01-07 14:27 [PATCH] rtw88: use shorter delay time to poll PS state yhchuang
@ 2020-01-09 10:34 ` Chris Chiu
  2020-01-26 15:43 ` Kalle Valo
  1 sibling, 0 replies; 3+ messages in thread
From: Chris Chiu @ 2020-01-09 10:34 UTC (permalink / raw)
  To: Tony Chuang; +Cc: Kalle Valo, linux-wireless, Brian Norris

On Tue, Jan 7, 2020 at 10:27 PM <yhchuang@realtek.com> wrote:
>
> From: Yan-Hsuan Chuang <yhchuang@realtek.com>
>
> When TX packet arrives, driver should leave deep PS state to make
> sure the DMA is working. After requested to leave deep PS state,
> driver needs to poll the PS state to check if the mode has been
> changed successfully. The driver used to check the state of the
> hardware every 20 msecs, which means upon the first failure of
> state check, the CPU is delayed 20 msecs for next check. This is
> harmful for some time-sensitive applications such as media players.
>
> So, use shorter delay time each check from 20 msecs to 100 usecs.
> The state should be changed in several tries. But we still need
> to reserve ~15 msecs in total in case of the state just took too
> long to be changed successfully. If the states of driver and the
> hardware is not synchronized, the power state could be locked
> forever, which mean we could never enter/leave the PS state.
>
> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Reviewed-by: Chris Chiu <chiu@endlessm.com>
> ---
>  drivers/net/wireless/realtek/rtw88/ps.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtw88/ps.c b/drivers/net/wireless/realtek/rtw88/ps.c
> index 913e6f47130f..7a189a9926fe 100644
> --- a/drivers/net/wireless/realtek/rtw88/ps.c
> +++ b/drivers/net/wireless/realtek/rtw88/ps.c
> @@ -91,11 +91,11 @@ void rtw_power_mode_change(struct rtw_dev *rtwdev, bool enter)
>                         return;
>
>                 /* check confirm power mode has left power save state */
> -               for (polling_cnt = 0; polling_cnt < 3; polling_cnt++) {
> +               for (polling_cnt = 0; polling_cnt < 50; polling_cnt++) {
>                         polling = rtw_read8(rtwdev, rtwdev->hci.cpwm_addr);
>                         if ((polling ^ confirm) & BIT_RPWM_TOGGLE)
>                                 return;
> -                       mdelay(20);
> +                       udelay(100);
>                 }
>
>                 /* in case of fw/hw missed the request, retry */
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] rtw88: use shorter delay time to poll PS state
  2020-01-07 14:27 [PATCH] rtw88: use shorter delay time to poll PS state yhchuang
  2020-01-09 10:34 ` Chris Chiu
@ 2020-01-26 15:43 ` Kalle Valo
  1 sibling, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2020-01-26 15:43 UTC (permalink / raw)
  To: yhchuang; +Cc: linux-wireless, briannorris

<yhchuang@realtek.com> wrote:

> From: Yan-Hsuan Chuang <yhchuang@realtek.com>
> 
> When TX packet arrives, driver should leave deep PS state to make
> sure the DMA is working. After requested to leave deep PS state,
> driver needs to poll the PS state to check if the mode has been
> changed successfully. The driver used to check the state of the
> hardware every 20 msecs, which means upon the first failure of
> state check, the CPU is delayed 20 msecs for next check. This is
> harmful for some time-sensitive applications such as media players.
> 
> So, use shorter delay time each check from 20 msecs to 100 usecs.
> The state should be changed in several tries. But we still need
> to reserve ~15 msecs in total in case of the state just took too
> long to be changed successfully. If the states of driver and the
> hardware is not synchronized, the power state could be locked
> forever, which mean we could never enter/leave the PS state.
> 
> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
> Reviewed-by: Chris Chiu <chiu@endlessm.com>

Patch applied to wireless-drivers-next.git, thanks.

6b6c150b8464 rtw88: use shorter delay time to poll PS state

-- 
https://patchwork.kernel.org/patch/11320947/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-26 15:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-07 14:27 [PATCH] rtw88: use shorter delay time to poll PS state yhchuang
2020-01-09 10:34 ` Chris Chiu
2020-01-26 15:43 ` Kalle Valo

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.