Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp7994943rwl; Tue, 10 Jan 2023 07:50:28 -0800 (PST) X-Google-Smtp-Source: AMrXdXtvJjZm9w1fS83yLBeQtpzCACV4FQFNdGucbTQm/E5OyxhwHLXZ8FmKyDN30y3vUC+4UcDH X-Received: by 2002:a17:907:a688:b0:84d:1c67:97d7 with SMTP id vv8-20020a170907a68800b0084d1c6797d7mr13119559ejc.30.1673365828539; Tue, 10 Jan 2023 07:50:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673365828; cv=none; d=google.com; s=arc-20160816; b=PKAUsOvYGX0DZRUq3wVlCuNx/6z2xlvSaBKkZgBfzGXNPaB4+9eNLCVxrwpqCbVUHZ yLNiMvWkBlFMccRRGSWnNOg1PYd0qE8jH+HCqcu30Fh3GVSgpCoNn/0hpqe5QYEmwH4n FpjUpMVb1sy3csMspLwPBhE/gd55o4e/3uwVuioU+wq3Pis/M1jk0NTFeIILhqCM+6Bi g0poXW1QQJ7xc8tfAU40ikN8n37NSI4vg5VkSTEuPU3vS6IS2dDmsU4hLFoVjCFGRXpL h2rc5Z28aD8uw7KyW7X3y30QdcrA6jtsKkGNUYjFXHeIjFalKrcYMDopa5l2yuwLoZSS OWwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :to:from:content-language:subject:user-agent:mime-version:date :dkim-signature:message-id; bh=wYSLW4NUGAri3UL9pCD9Bz03e82LFswGFT2qW1bLvMg=; b=x0vC25DSIJv0X2Ic/5G69gXiyKboYnFgoknvhdU6IKOmo6tR0wB2JnXSb5YODeQtXM Z42K/jP+gBqDf/V+PNzgXGovkhrOCfe0C5Ux1YeljiCzF510/NrzpB3wOirY+T8b1l7Z nNv+m+2eO6ZYbLk6eA4FLPIB7zRvwHhPRGihgDNKmi+ZfKDl01QpbDs1kYHml2dXj4AX VXvC8gli0LRR15+75q/T0UvMYseYGne0fw8wiP1xKn1r9G52dyKNlSm8VfJTE6kPPRPl S6OTyXPhMfTbzr/0lpp9VaiJDcjo+6SoCv603IUIKv7u7BQyuMJOVAaApPW83tt30qP5 QYOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wetzel-home.de header.s=wetzel-home header.b=oBfHQ7QJ; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wetzel-home.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be5-20020a1709070a4500b0084c9f6cbe3asi11298968ejc.843.2023.01.10.07.50.09; Tue, 10 Jan 2023 07:50:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@wetzel-home.de header.s=wetzel-home header.b=oBfHQ7QJ; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wetzel-home.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234748AbjAJPoM (ORCPT + 65 others); Tue, 10 Jan 2023 10:44:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238372AbjAJPn3 (ORCPT ); Tue, 10 Jan 2023 10:43:29 -0500 Received: from ns2.wdyn.eu (ns2.wdyn.eu [5.252.227.236]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C4B7DE010; Tue, 10 Jan 2023 07:43:28 -0800 (PST) Message-ID: <53b23ee9-a333-120e-8b58-cfa3a9bdaefc@wetzel-home.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wetzel-home.de; s=wetzel-home; t=1673365407; bh=joeZ0isSpFWCfJo9bP7lRZdTrlAemheFG8yfUEmmw0s=; h=Date:Subject:From:To:References:In-Reply-To; b=oBfHQ7QJtk5sWEMyXs1jUUCKUM6vy9bmoUBwseZQqoOK64dyvDGQpalE18Lze85HU O3zZ2NDPT4JWbsFu0S/zYsjJKHaNdL1lcjq/5NZcsMJOB/MKuWC6F+aXbM6XEYX79/ MNaJ350fvM8rvdfGcW86uzJUkUbDRnoMansGYTzg= Date: Tue, 10 Jan 2023 16:43:27 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: ieee80211_handle_wake_tx_queue and dynamic ps regression Content-Language: en-US From: Alexander Wetzel To: Bryan O'Donoghue , linux-kernel@vger.kernel.org, johannes.berg@intel.com, Kalle Valo , linux-wireless@vger.kernel.org References: <19015168-c747-17b7-f0ae-9d2ee27d221c@linaro.org> <06f76774-1b2e-f563-7128-7d5b9547dfe9@linaro.org> <205fb221-f7ad-8f03-2c16-54dcbf5ecaf9@wetzel-home.de> In-Reply-To: <205fb221-f7ad-8f03-2c16-54dcbf5ecaf9@wetzel-home.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On 10.01.23 16:23, Alexander Wetzel wrote: > On 10.01.23 15:47, Bryan O'Donoghue wrote: >> On 10/01/2023 12:44, Bryan O'Donoghue wrote: >>> + linux-wireless >>> On 10/01/2023 12:35, Bryan O'Donoghue wrote: >>>> commit a790cc3a4fad75048295571a350b95b87e022a5a >>>> (wake_tx_queue-broken-23-08-01) >>>> Author: Alexander Wetzel >>>> Date:   Sun Oct 9 18:30:39 2022 +0200 >>>> >>>>      wifi: mac80211: add wake_tx_queue callback to drivers >>>> >>>> is causing a regression with >>>> >>>> - CONF_PS = 1 >>>> - CONF_DYNAMIC_PS = 0 >>>> - ieee80211_handle_wake_tx_queue >>>> >>>> In this case we get stuck in a loop similar to this >>>> >>>> // IEEE80211_CONF_CHANGE_PS >>>> [   17.255480] wcn36xx: wcn36xx_change_ps/312 enable >>>> [   18.088835] ieee80211_tx_h_dynamic_ps/263 setting >>>> IEEE80211_QUEUE_STOP_REASON_PS >>>> [   18.088906] ieee80211_handle_wake_tx_queue/334 entry >>>> [   18.091505] ieee80211_dynamic_ps_disable_work/2250 calling >>>> ieee80211_hw_config() >>>> [   18.095370] ieee80211_handle_wake_tx_queue/338 wake_tx_push_queue >>>> >>>> // IEEE80211_CONF_CHANGE_PS >>>> [   18.102625] wcn36xx: wcn36xx_change_ps/312 disable >>>> [   18.107643] wake_tx_push_queue/303 entry >>>> >>>> // txq is stopped here reason == IEEE80211_QUEUE_STOP_REASON_PS >>>> [   18.107654] wake_tx_push_queue/311 q_stopped bitmask 0x00000002 >>>> IEEE80211_QUEUE_STOP_REASON_PS true >>>> [   18.107661] wake_tx_push_queue/324 exit >>>> [   18.107667] ieee80211_handle_wake_tx_queue/342 exit >>>> [   18.115560] ieee80211_handle_wake_tx_queue/334 entry >>>> [   18.139937] ieee80211_handle_wake_tx_queue/338 wake_tx_push_queue >>>> [   18.145163] wake_tx_push_queue/303 entry >>>> [   18.150016] ieee80211_dynamic_ps_disable_work/2252 completed >>>> ieee80211_hw_config() >>>> >>>> // now we unset IEEE80211_QUEUE_STOP_REASON_PS but too late >>>> [   18.151145] wake_tx_push_queue/311 q_stopped bitmask 0x00000002 >>>> IEEE80211_QUEUE_STOP_REASON_PS true >>>> [   18.155263] ieee80211_dynamic_ps_disable_work/2254 clearing >>>> IEEE80211_QUEUE_STOP_REASON_PS >>>> [   18.162531] wake_tx_push_queue/324 exit >>>> [   18.162548] ieee80211_handle_wake_tx_queue/342 exit >>>> [   18.183639] ieee80211_dynamic_ps_disable_work/2259 cleared >>>> IEEE80211_QUEUE_STOP_REASON_PS >>>> >>>> // IEEE80211_CONF_CHANGE_PS runs again >>>> [   18.215487] wcn36xx: wcn36xx_change_ps/312 enable >>>> >>>> We get stuck in that loop. Packets getting transmitted is a rare >>>> event, most are dropped. >> > > I'll need some time digest that... I report back once I get it. Looks like the the commit https://patchwork.kernel.org/project/linux-wireless/patch/20221230121850.218810-1-alexander@wetzel-home.de/ has a good chance to solve the issue: 1) Queues are stopped due to PS 2) Then there is a TX attempt. But due to the (PS) queue stop wake_tx_push_queue() aborts the queue run 3) Then we hit the bug the patch fixes: The queue is not marked to have pending packets and thus packets on it are not transmitted. Packets get only send when you happen to try tx when the queue is operational. (And then you will get all the packets sitting in the queue.) Does that make sense? And more crucial, is the patch fixing that for you? > >> BTW I considered implementing a wcn36xx specific wake_tx callback - >> which maybe should be done anyway. >> >> I _don't_ see other drivers checking for q_stopped & >> IEEE80211_QUEUE_STOP_REASON_PS >> >> Should they be ? >> > > No, they should not. > > My take is, that this is a bug in mac80211. I submitted patches to > fixing that, they have just been accepted: > > https://patchwork.kernel.org/project/linux-wireless/patch/20221230121850.218810-1-alexander@wetzel-home.de/ > > and > > https://patchwork.kernel.org/project/linux-wireless/patch/20230106223141.98696-1-alexander@wetzel-home.de/ > > > Can you test if these also help here? > > > >> If they should check IEEE80211_QUEUE_STOP_REASON_PS, then right now, >> they don't. If they shouldn't check IEEE80211_QUEUE_STOP_REASON_PS >> then neither should the generic replacement >> ieee80211_handle_wake_tx_queue() >> >> --- >> bod >