linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felix Fietkau <nbd@openwrt.org>
To: Vivek Natarajan <vivek.natraj@gmail.com>
Cc: linux-wireless@vger.kernel.org, linville@tuxdriver.com,
	mcgrof@qca.qualcomm.com,
	Johannes Berg <johannes@sipsolutions.net>,
	Kalle Valo <kvalo@qca.qualcomm.com>
Subject: Re: [PATCH 09/12] ath9k: optimize ath9k_ps_restore
Date: Thu, 22 Sep 2011 07:54:33 -0600	[thread overview]
Message-ID: <4E7B3E19.2020001@openwrt.org> (raw)
In-Reply-To: <CAJqpcCQ9gpKG1ivvDReSyvMq9i5kxwDmRZwvNbYfRhwByOOC4w@mail.gmail.com>

On 2011-09-21 11:49 PM, Vivek Natarajan wrote:
> On Thu, Sep 15, 2011 at 12:54 AM, Felix Fietkau<nbd@openwrt.org>  wrote:
>>  ath_hw_cycle_counters_update only needs to be called if the power state
>>  changes. Most of the time this does not happen, even when ps_usecount
>>  goes down to 0.
>>
>>  Signed-off-by: Felix Fietkau<nbd@openwrt.org>
>>  ---
>>    drivers/net/wireless/ath/ath9k/main.c |   17 +++++++++++------
>>    1 files changed, 11 insertions(+), 6 deletions(-)
>>
>>  diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
>>  index a75810a..a16f539 100644
>>  --- a/drivers/net/wireless/ath/ath9k/main.c
>>  +++ b/drivers/net/wireless/ath/ath9k/main.c
>>  @@ -111,24 +111,29 @@ void ath9k_ps_wakeup(struct ath_softc *sc)
>>    void ath9k_ps_restore(struct ath_softc *sc)
>>    {
>>          struct ath_common *common = ath9k_hw_common(sc->sc_ah);
>>  +       enum ath9k_power_mode mode;
>>          unsigned long flags;
>>
>>          spin_lock_irqsave(&sc->sc_pm_lock, flags);
>>          if (--sc->ps_usecount != 0)
>>                  goto unlock;
>>
>>  -       spin_lock(&common->cc_lock);
>>  -       ath_hw_cycle_counters_update(common);
>>  -       spin_unlock(&common->cc_lock);
>>  -
>>          if (sc->ps_idle)
>>  -               ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP);
>>  +               mode = ATH9K_PM_FULL_SLEEP;
>>          else if (sc->ps_enabled&&
>>                   !(sc->ps_flags&  (PS_WAIT_FOR_BEACON |
>>                                PS_WAIT_FOR_CAB |
>>                                PS_WAIT_FOR_PSPOLL_DATA |
>>                                PS_WAIT_FOR_TX_ACK)))
>>  -               ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_NETWORK_SLEEP);
>>  +               mode = ATH9K_PM_NETWORK_SLEEP;
>
> What is the use of setting the mode above if you use NETWORK_SLEEP by
> default in the below code.
Yes, I forgot to change it in the call below. I'll send a fix ASAP.

>>  +       else
>>  +               goto unlock;
>>  +
>>  +       spin_lock(&common->cc_lock);
>>  +       ath_hw_cycle_counters_update(common);
>>  +       spin_unlock(&common->cc_lock);
>>  +
>>  +       ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_NETWORK_SLEEP);
>
> huh???
>
> It shows this patch was never tested and please clarify what you tried
> to achieve with this patch. Do you ever test a patch before sending it
> upstream?
>
> There is no wonder Johannes reports that power save is completely
> broken with ath9k if we have patches like these. We have better work
> to concentrate on, than to fix the regression your patch introduces
> every time.
>
> Please fix this and __test__ properly.
I did test this patch, and while it clearly has a bug (always setting 
network sleep instead of full sleep), I don't think this would break 
powersave. The only consequence I can think of is more battery drain 
when the card is idle and not connected.

What this patch achieves is this: ath9k_ps_restore is called frequently 
from functions handling the data path, also setting ps_usecount to 0 
frequently. That caused excessive calls to ath_hw_cycle_counters_update 
vasting a noticeable amount of CPU cycles (showed up during profiling).
My patch changes the code to only call ath_hw_cycle_counters_update 
before the card's power state changes.

- Felix

      reply	other threads:[~2011-09-22 13:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-14 19:24 [PATCH 01/12] ath9k: remove ATH_TX_XRETRY and BUF_XRETRY flags Felix Fietkau
2011-09-14 19:24 ` [PATCH 02/12] ath9k: reduce the number of functions that access the tx descriptor Felix Fietkau
2011-09-14 19:24   ` [PATCH 03/12] ath9k: move ath_buf_set_rate to remove a forward declaration Felix Fietkau
2011-09-14 19:24     ` [PATCH 04/12] ath9k: call ath9k_hw_set_desc_link for beacon descriptors Felix Fietkau
2011-09-14 19:24       ` [PATCH 05/12] ath9k_hw: do not recalculate the descriptor checksum in ar9003_hw_fill_txdesc Felix Fietkau
2011-09-14 19:24         ` [PATCH 06/12] ath9k_hw: add a new API for setting tx descriptors Felix Fietkau
2011-09-14 19:24           ` [PATCH 07/12] ath9k: use the " Felix Fietkau
2011-09-14 19:24             ` [PATCH 08/12] ath9k_hw: remove the old tx descriptor API Felix Fietkau
2011-09-14 19:24               ` [PATCH 09/12] ath9k: optimize ath9k_ps_restore Felix Fietkau
2011-09-14 19:24                 ` [PATCH 10/12] ath9k: remove a redundant check in ath_tx_form_aggr Felix Fietkau
2011-09-14 19:24                   ` [PATCH 11/12] ath9k: optimize ath_tx_rc_status usage Felix Fietkau
2011-09-14 19:24                     ` [PATCH 12/12] ath9k: do not insert padding into tx buffers on AR9380+ Felix Fietkau
2011-09-19 14:40                       ` Rajkumar Manoharan
2011-09-19 15:03                         ` Felix Fietkau
2011-09-19 16:47                           ` Rajkumar Manoharan
2011-09-19 17:39                             ` Felix Fietkau
2011-09-22  5:49                 ` [PATCH 09/12] ath9k: optimize ath9k_ps_restore Vivek Natarajan
2011-09-22 13:54                   ` Felix Fietkau [this message]

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=4E7B3E19.2020001@openwrt.org \
    --to=nbd@openwrt.org \
    --cc=johannes@sipsolutions.net \
    --cc=kvalo@qca.qualcomm.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=mcgrof@qca.qualcomm.com \
    --cc=vivek.natraj@gmail.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).