From patchwork Tue Jun 21 06:33:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vivek Natarajan X-Patchwork-Id: 899872 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5L6Y0Io015243 for ; Tue, 21 Jun 2011 06:34:00 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751088Ab1FUGdz (ORCPT ); Tue, 21 Jun 2011 02:33:55 -0400 Received: from mail-gx0-f174.google.com ([209.85.161.174]:37468 "EHLO mail-gx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751084Ab1FUGdy convert rfc822-to-8bit (ORCPT ); Tue, 21 Jun 2011 02:33:54 -0400 Received: by gxk21 with SMTP id 21so612304gxk.19 for ; Mon, 20 Jun 2011 23:33:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=6UfoY2NwV1fxjawqS3Pawqgwms1f0538vyihAsSRkns=; b=HjXYQrbHOL4PKijMTGd8R1mTZQ9X4PMPl6eGiHQYfofd3DL+VNiD0qN3W3qDK4kBeK zOme1K9Ajnct3o/+wJAzivThR1zQ18YVJE6Zs35m5DR/qWqqr54GL1ASr2OISQaVsSne S/QVVrl1tno41AStVBlzWI1iZORNEJ+lRac/M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=VyBoM4/HVQv9QkZpj/6gkc1ocGJWgE5dOseSt9Sq7mkE1fCZHnPYGr4+xfLlOY2cTP NPsBZhyy7/G0OnVU/x3RtXEKF34seOhcQxBWTVyWH2+UDiUH/isJDpWPG4WJWZdAFKZt By/JNMYXyZOPaRVBKJXpusZLKm364CYdPkgKE= MIME-Version: 1.0 Received: by 10.236.180.38 with SMTP id i26mr9707363yhm.205.1308638033530; Mon, 20 Jun 2011 23:33:53 -0700 (PDT) Received: by 10.236.209.170 with HTTP; Mon, 20 Jun 2011 23:33:53 -0700 (PDT) In-Reply-To: References: <1308425533-20854-1-git-send-email-arik@wizery.com> Date: Tue, 21 Jun 2011 12:03:53 +0530 Message-ID: Subject: Re: [RFC] mac80211: dynamic PS - don't enter PS when TX frames are pending From: Vivek Natarajan To: Arik Nemtsov Cc: linux-wireless@vger.kernel.org, Johannes Berg , Sam Leffler Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 21 Jun 2011 06:34:00 +0000 (UTC) On Tue, Jun 21, 2011 at 11:13 AM, Arik Nemtsov wrote: > On Tue, Jun 21, 2011 at 07:55, Vivek Natarajan wrote: >>> >>> +       /* don't enter PS if dynamic PS is enabled and TX frames are pending */ >>> +       if (local->hw.conf.dynamic_ps_timeout > 0 && >>> +           !local->disable_dynamic_ps && drv_tx_frames_pending(local)) { >> >> netif_tx_stop_all_queues has to be called before checking >> frames_pending(), so that we can make sure no data is transmitted in >> the time between checking frames_pending and transmitting null data >> frames. If it is not done, this might cause some power save states >> mismatch between the AP and the station in some corner cases. > > That's a good point. But I guess its only relevant to drivers using > IEEE80211_HW_PS_NULLFUNC_STACK. > Still seems racy to me - even if queues are stopped it doesn't mean > mac80211 is not in the middle of ieee80211_tx(). Is there a way to > make sure? Well, I can't find any way to stop this race. :) Atleast the other race could be fixed with stop_queues. How about the below patch? I am not sure about the disable_dynamic_ps and its BT/WLAN antenna sharing. Please add that if you see it as appropriate. drv_flush(local, false); Vivek. --- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index faca503..67ecad1 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -778,15 +778,14 @@ void ieee80211_dynamic_ps_enable_work(struct work_struct *work) } spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); - if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) && - (!(ifmgd->flags & IEEE80211_STA_NULLFUNC_ACKED))) { + if (!(ifmgd->flags & IEEE80211_STA_NULLFUNC_ACKED)) { netif_tx_stop_all_queues(sdata->dev); if (drv_tx_frames_pending(local)) mod_timer(&local->dynamic_ps_timer, jiffies + msecs_to_jiffies( local->hw.conf.dynamic_ps_timeout)); - else { + else if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) { ieee80211_send_nullfunc(local, sdata, 1); /* Flush to get the tx status of nullfunc frame */