Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3518427pxb; Mon, 4 Apr 2022 19:38:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2B7MTXho2OBPPL8I9sCdSLP0cQjbwR31C7XZUmNoRcHsxNEM90tqRu0fNtwJyBBlBlfnd X-Received: by 2002:a05:6a00:2124:b0:4fa:739f:2386 with SMTP id n4-20020a056a00212400b004fa739f2386mr1400390pfj.68.1649126309452; Mon, 04 Apr 2022 19:38:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649126309; cv=none; d=google.com; s=arc-20160816; b=Qw2CGi+KTd4KRapCRW27TRHdck+sDRV5K6Z/pmlPTzGjtQsSsD4Rga7RU3Er5Rumsp nGGp+HLb/DqnYebbp/dE6RlfufySMQpcoiJe6KZoADqbpvUim4Ez5AdBvCor3WkJjugT AGcUcYaywBwJ8KjIi97a6zmHvRKqmYClCDWnsdyET9UKhMybYExiuw9/70r26nZ9OodK D3gZ8M+1+aWRAEd4grp/xqsIAuvJiX3V6C6Y9VUsQrIMnG6YyaM6O70mExpDnMISgc1i KxWwVV8LWDWPUFx3VtJgYB1RrOSsgAF8VxkDtGRjtyEEVbldrz39jFv1qgz70QHLmTez VFGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :from; bh=YNeulz4f2LUy9RJFWyNOnrMQpVi4qXnCvp9Gz3CfbYM=; b=DEigvT2gE1U5AR7GYqtpqo+c8VoOLQ7KDOxqjQw18QEXWinDSsPmHarVor7kphnkxS k8M+99Aj3DUBmR2u0LxBQRaHQKQXoqKYbSwRWmVfwafIzcCowsbBYAoSDO8ETLCevIQE /3QNzYlrB2CyHZanqYLeYh1gTZTxNSb/yUFIdZDbuCaXApLQaA4peDpV0N/FMMCTK1mr YG2vhQxl6tiD8HRP9oSqFGTEWAzBOCJPLrZMNsR9G5n935iKD2CYqkPEhmXj3XP3832t +7rKv3SQsEHKg/DQY6ZCIIUGRlvJtMqCsCWUihe3fdoSsst9eWFUW0w3N7gwOU2pqqFz ajWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toke.dk header.s=20161023 header.b=xiHQqBAi; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=toke.dk Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f7-20020a654007000000b003847a033b69si9601511pgp.296.2022.04.04.19.38.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 19:38:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@toke.dk header.s=20161023 header.b=xiHQqBAi; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=toke.dk Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 846DC33CC40; Mon, 4 Apr 2022 18:02:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379150AbiDDVSt (ORCPT + 69 others); Mon, 4 Apr 2022 17:18:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379547AbiDDR3h (ORCPT ); Mon, 4 Apr 2022 13:29:37 -0400 Received: from mail.toke.dk (mail.toke.dk [45.145.95.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 697BB24BF9; Mon, 4 Apr 2022 10:27:40 -0700 (PDT) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=toke.dk; s=20161023; t=1649093259; bh=IJU11DU/QrW9iqVMiJGOGZmJCQr5ziv8W0ZcyFcdZtI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=xiHQqBAiJOBp+9qWJrK7CTfzc661kLgsXSKbhEY1sRFhL9184sblR/y8X6yxw4XjC 0wdCKmjaqcTgQMFZnZ9keGbvI58fVttpjipCPPRYKkae+oHnoLzSuEa4ZN0saAyjNy nYwTmPWKDiqzgtGvslYoe88SI8NBBO3JqDLS6M6CfQd8+QDzVtybRwbpbvuf68ysWc VwdfelinAO4n7S2KtUlFgz5QfvJf3mMxzPoRwjeJvAKUvEYKeTtYR8nV1Epn6f0F/z g3pcGXPaMJ4XXJzAut0/PZcgyhvFLzfB94VyZVqW0ty4upa5taRaMbXGTZFgeG/zMi Kzw5h2jewLz6w== To: Peter Seiderer Cc: Kalle Valo , linux-wireless@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v5.18] ath9k: Save rate counts before clearing tx status area In-Reply-To: <20220404181118.515b60ad@gmx.net> References: <20220402122752.2347797-1-toke@toke.dk> <20220404181118.515b60ad@gmx.net> Date: Mon, 04 Apr 2022 19:27:38 +0200 X-Clacks-Overhead: GNU Terry Pratchett Message-ID: <87lewkep2t.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Peter Seiderer writes: > Hello Toke, > > On Sat, 2 Apr 2022 14:27:51 +0200, Toke H=C3=B8iland-J=C3=B8rgensen wrote: > >> From: Toke H=C3=B8iland-J=C3=B8rgensen >>=20 >> The ieee80211_tx_info_clear_status() helper also clears the rate counts,= so >> we should restore them after clearing. However, we can get rid of the >> existing clearing of the counts of invalid rates. Rearrange the code a b= it >> so the order fits the indexes, and so the setting of the count to >> hw->max_rate_tries on underrun is not immediately overridden. >>=20 >> Cc: stable@vger.kernel.org >> Reported-by: Peter Seiderer >> Fixes: 037250f0a45c ("ath9k: Properly clear TX status area before report= ing to mac80211") >> Signed-off-by: Toke H=C3=B8iland-J=C3=B8rgensen >> --- >> drivers/net/wireless/ath/ath9k/xmit.c | 25 +++++++++++++++---------- >> 1 file changed, 15 insertions(+), 10 deletions(-) >>=20 >> diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireles= s/ath/ath9k/xmit.c >> index cbcf96ac303e..ac7efecff29c 100644 >> --- a/drivers/net/wireless/ath/ath9k/xmit.c >> +++ b/drivers/net/wireless/ath/ath9k/xmit.c >> @@ -2551,16 +2551,19 @@ static void ath_tx_rc_status(struct ath_softc *s= c, struct ath_buf *bf, >> struct ieee80211_tx_info *tx_info =3D IEEE80211_SKB_CB(skb); >> struct ieee80211_hw *hw =3D sc->hw; >> struct ath_hw *ah =3D sc->sc_ah; >> - u8 i, tx_rateindex; >> + u8 i, tx_rateindex, tries[IEEE80211_TX_MAX_RATES]; >> + >> + tx_rateindex =3D ts->ts_rateindex; >> + WARN_ON(tx_rateindex >=3D hw->max_rates); >> + >> + for (i =3D 0; i < tx_rateindex; i++) >> + tries[i] =3D tx_info->status.rates[i].count; >>=20=20 >> ieee80211_tx_info_clear_status(tx_info); >>=20=20 >> if (txok) >> tx_info->status.ack_signal =3D ts->ts_rssi; >>=20=20 >> - tx_rateindex =3D ts->ts_rateindex; >> - WARN_ON(tx_rateindex >=3D hw->max_rates); >> - >> if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { >> tx_info->flags |=3D IEEE80211_TX_STAT_AMPDU; >>=20=20 >> @@ -2569,6 +2572,14 @@ static void ath_tx_rc_status(struct ath_softc *sc= , struct ath_buf *bf, >> tx_info->status.ampdu_len =3D nframes; >> tx_info->status.ampdu_ack_len =3D nframes - nbad; >>=20=20 >> + for (i =3D 0; i < tx_rateindex; i++) >> + tx_info->status.rates[i].count =3D tries[i]; >> + >> + tx_info->status.rates[tx_rateindex].count =3D ts->ts_longretry + 1; >> + >> + for (i =3D tx_rateindex + 1; i < hw->max_rates; i++) >> + tx_info->status.rates[i].idx =3D -1; >> + >> if ((ts->ts_status & ATH9K_TXERR_FILT) =3D=3D 0 && >> (tx_info->flags & IEEE80211_TX_CTL_NO_ACK) =3D=3D 0) { >> /* >> @@ -2591,12 +2602,6 @@ static void ath_tx_rc_status(struct ath_softc *sc= , struct ath_buf *bf, >> hw->max_rate_tries; >> } > > The full lines above read: > > 2597 if (unlikely(ts->ts_flags & (ATH9K_TX_DATA_UNDERRUN | > 2598 ATH9K_TX_DELIM_UNDERRUN= )) && > 2599 ieee80211_is_data(hdr->frame_control) &&=20 > 2600 ah->tx_trig_level >=3D sc->sc_ah->config.max_txt= rig_level ) > 2601 tx_info->status.rates[tx_rateindex].count =3D > 2602 hw->max_rate_tries; > 2603 } > > So this patch fixes by drive-by a overwrite of > tx_info->status.rates[tx_rateindex].count... Yeah, that was intentional; the setting of tx_info->status.rates[tx_rateindex].count you quoted never had any effect, which I'm assuming is not deliberate :) >>=20=20 >> - for (i =3D tx_rateindex + 1; i < hw->max_rates; i++) { >> - tx_info->status.rates[i].count =3D 0; >> - tx_info->status.rates[i].idx =3D -1; >> - } >> - >> - tx_info->status.rates[tx_rateindex].count =3D ts->ts_longretry + 1; >> } >>=20=20 >> static void ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq) > > Otherwise looks good ;-), would like to give a Reviewed-by/Tested-by but = still > affected by the underlying ieee80211_tx_info status vs. rate_driver_data = overwrite > as mentioned in the other thread (see [1])... No worries, I'll respin with a fix for that as well (as soon as I figure out the right way to fix it), so just wait until v2 and give that a spin instead :) -Toke