Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3499407pxb; Mon, 4 Apr 2022 18:57:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqkn7732/baXHNoWBH/+m/G1kkWEV4Q8SjHk2w0lheNRWyGTLRnM4TV7/76/hYlg9WUXuy X-Received: by 2002:aa7:81c6:0:b0:4fa:70a2:2063 with SMTP id c6-20020aa781c6000000b004fa70a22063mr1002236pfn.71.1649123855439; Mon, 04 Apr 2022 18:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649123855; cv=none; d=google.com; s=arc-20160816; b=NQEhgbTd7HBO+iFSzXEe9FSAuVqvDIwp51BLcK/b1aCLQSuMdPk62dxq1/PYrr7LQK LNvjqvyKJrodxnMlTY96NU3paQMHqZTBvUBC9nJjnzoAWoB+Fs2GqD++AgtH0KqpYBpf i622vKz7iIjZYIomNYkqBBgS8oZVgAn983Vlv8KFuzEqgjw6OTlROm8On1P0wnRkyi+0 3c3SIft4GnAUZa6eKjzhazxVO2/uW+v9Xk7E7JvjMER2XTMi/I+smCS7HjxD1P/JMkYt ab6cYDlakU9RilGGLsiTpe7n76sfKcjvkkTsON2BNQk+bP7MmJz6sP6WwceVVUo3wwl0 4VdQ== 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:subject:cc:to:dkim-signature:from; bh=Gu9quEVGntvDYkRIyx6hrRG+3AOLNTC+y7W2ucTlRSo=; b=AFKENiaRS9Nn11f/0b920FqkEmFUsX++bavh54SKFtHmJXl44ylm4wHPBzH3GFut4y 83X6zh9lux2f4Wq5dCSSWAsaMd7cO6/yUAURTectKkUUlUabdQl6ro7Y0w80+eWYvgAg PIQFN3jODmy+S+QXcxiPhzLVyrm5lNfiDeS3cPPQOHUEaRZv7p1gVyUmkitWY9wqbeJJ tDxn8JUWwztOPmR9MTKDKws+I6ntN6BWEAPmWehTj06yzg3f/X98r/ASTMh0gMD0cAD2 5s+1CxjrH5Pshx/wPvkd9x85iyFMaBoKHArdyg1sVQHZNTWgHONTKBAr7xc0DsahSNaO w4tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toke.dk header.s=20161023 header.b=ssUleUv1; spf=softfail (google.com: domain of transitioning linux-wireless-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id d5-20020a636805000000b003822f3c787bsi11683601pgc.374.2022.04.04.18.57.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 18:57:35 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-wireless-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@toke.dk header.s=20161023 header.b=ssUleUv1; spf=softfail (google.com: domain of transitioning linux-wireless-owner@vger.kernel.org does not designate 23.128.96.19 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 878003F7DF1; Mon, 4 Apr 2022 18:02:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379096AbiDDVSo (ORCPT + 69 others); Mon, 4 Apr 2022 17:18:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380647AbiDDUuJ (ORCPT ); Mon, 4 Apr 2022 16:50:09 -0400 Received: from mail.toke.dk (mail.toke.dk [IPv6:2a0c:4d80:42:2001::664]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83DE113E9A; Mon, 4 Apr 2022 13:48:11 -0700 (PDT) From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=toke.dk; s=20161023; t=1649105290; bh=RiAyHNU78+NrUELRbly548BXFw5z7NQdyQvOAmmrXHA=; h=From:To:Cc:Subject:Date:From; b=ssUleUv1UhL+reEKU8Utjd1ZhfMl3vaYpLHe8AJY5EtGgylhTZfprZK50iWxSoMCC j4GxFzyfvHwpHgyiuSP7Oil962QouK91+CmEIubU/mSiua65qinAWReZtBnf40XwCH odM4aanlIaZ4micEf3DrdPPT7k2zOz+jEQQE8CQYH9S3YfRLcgB0lVE7FyDhayyqez f6cvfnJm1xYuJeFDg7XPpSyf+XiObB7pd1mZ034hSBcNcc05Gid2A8pVTCPduKG2+e e6p99f3yFYlTY4aNnYY5OQY+CWRfLf7PJ9eQTrgEw1pueQuABwHH7AgzDUYmM5U3WI Me8fh/mmSTOPQ== To: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , Kalle Valo Cc: linux-wireless@vger.kernel.org, =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , stable@vger.kernel.org, Peter Seiderer Subject: [PATCH for-5.18 v3] ath9k: Fix usage of driver-private space in tx_info Date: Mon, 4 Apr 2022 22:48:00 +0200 Message-Id: <20220404204800.2681133-1-toke@toke.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 From: Toke Høiland-Jørgensen The ieee80211_tx_info_clear_status() helper also clears the rate counts and the driver-private part of struct ieee80211_tx_info, so using it breaks quite a few other things. So back out of using it, and instead define a ath-internal helper that only clears the area between the status_driver_data and the rates info. Combined with moving the ath_frame_info struct to status_driver_data, this avoids clearing anything we shouldn't be, and so we can keep the existing code for handling the rate information. While fixing this I also noticed that the setting of tx_info->status.rates[tx_rateindex].count on hardware underrun errors was always immediately overridden by the normal setting of the same fields, so rearrange the code so that the underrun detection actually takes effect. The new helper could be generalised to a 'memset_between()' helper, but leave it as a driver-internal helper for now since this needs to go to stable. Cc: stable@vger.kernel.org Reported-by: Peter Seiderer Fixes: 037250f0a45c ("ath9k: Properly clear TX status area before reporting to mac80211") Signed-off-by: Toke Høiland-Jørgensen --- drivers/net/wireless/ath/ath9k/main.c | 2 +- drivers/net/wireless/ath/ath9k/xmit.c | 30 ++++++++++++++++++--------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 98090e40e1cf..e2791d45f5f5 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -839,7 +839,7 @@ static bool ath9k_txq_list_has_key(struct list_head *txq_list, u32 keyix) continue; txinfo = IEEE80211_SKB_CB(bf->bf_mpdu); - fi = (struct ath_frame_info *)&txinfo->rate_driver_data[0]; + fi = (struct ath_frame_info *)&txinfo->status.status_driver_data[0]; if (fi->keyix == keyix) return true; } diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index cbcf96ac303e..db83cc4ba810 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -141,8 +141,8 @@ static struct ath_frame_info *get_frame_info(struct sk_buff *skb) { struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); BUILD_BUG_ON(sizeof(struct ath_frame_info) > - sizeof(tx_info->rate_driver_data)); - return (struct ath_frame_info *) &tx_info->rate_driver_data[0]; + sizeof(tx_info->status.status_driver_data)); + return (struct ath_frame_info *) &tx_info->status.status_driver_data[0]; } static void ath_send_bar(struct ath_atx_tid *tid, u16 seqno) @@ -2542,6 +2542,16 @@ static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf, spin_unlock_irqrestore(&sc->tx.txbuflock, flags); } +static void ath_clear_tx_status(struct ieee80211_tx_info *tx_info) +{ + void *ptr = &tx_info->status; + + memset(ptr + sizeof(tx_info->status.rates), 0, + sizeof(tx_info->status) - + sizeof(tx_info->status.rates) - + sizeof(tx_info->status.status_driver_data)); +} + static void ath_tx_rc_status(struct ath_softc *sc, struct ath_buf *bf, struct ath_tx_status *ts, int nframes, int nbad, int txok) @@ -2553,7 +2563,7 @@ static void ath_tx_rc_status(struct ath_softc *sc, struct ath_buf *bf, struct ath_hw *ah = sc->sc_ah; u8 i, tx_rateindex; - ieee80211_tx_info_clear_status(tx_info); + ath_clear_tx_status(tx_info); if (txok) tx_info->status.ack_signal = ts->ts_rssi; @@ -2569,6 +2579,13 @@ static void ath_tx_rc_status(struct ath_softc *sc, struct ath_buf *bf, tx_info->status.ampdu_len = nframes; tx_info->status.ampdu_ack_len = nframes - nbad; + tx_info->status.rates[tx_rateindex].count = ts->ts_longretry + 1; + + for (i = tx_rateindex + 1; i < hw->max_rates; i++) { + tx_info->status.rates[i].count = 0; + tx_info->status.rates[i].idx = -1; + } + if ((ts->ts_status & ATH9K_TXERR_FILT) == 0 && (tx_info->flags & IEEE80211_TX_CTL_NO_ACK) == 0) { /* @@ -2590,13 +2607,6 @@ static void ath_tx_rc_status(struct ath_softc *sc, struct ath_buf *bf, tx_info->status.rates[tx_rateindex].count = hw->max_rate_tries; } - - for (i = tx_rateindex + 1; i < hw->max_rates; i++) { - tx_info->status.rates[i].count = 0; - tx_info->status.rates[i].idx = -1; - } - - tx_info->status.rates[tx_rateindex].count = ts->ts_longretry + 1; } static void ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq) -- 2.35.1