Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3503082pxb; Mon, 4 Apr 2022 19:04:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymPwCyEgCsETGJbv2UgmQ/AfJyX4U+FuCPeNEmOcpiLuKGJGx1qL0saBnXjnTVJiy4UKKu X-Received: by 2002:a17:90a:fe12:b0:1ca:b7e8:1086 with SMTP id ck18-20020a17090afe1200b001cab7e81086mr1360123pjb.213.1649124264517; Mon, 04 Apr 2022 19:04:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649124264; cv=none; d=google.com; s=arc-20160816; b=p0OoBzcd85vebv+SsXSAxJUxyBYyLG29xzVXHoGbAxowqru2o/29qyFCS3o9hY9Rjj E1X4FpqZ0OMQRxuG4/paPNJmN2145cqy75WY5usTZ2cexTgzK//Q0udezmsx41hahspA G/A/Ch1+Iq2vRq8vLfF0P0khArOQDKyr8cUL29epdA98V1uBUvigVtN8ZtJN/slESLlj 5iwweHiNGjmjYov8LBXHAyeIP+IFUI5nQyXPs/YKosto3tlBY/JNSvkOjO0Wom6XGQMZ Cn8LJmJHRqa2ovOjev+MQPFRtJvWah9w3fYpL8sTOdfNuVXWuyVD69IXrI5CERnsNhFQ 69ZA== 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=tJTtMecSDEKZveQytB8eelQPTgYJh7RZzXI2TGe/mLY=; b=u9YaEwblZnl1jgVgyGYZ8tyG14RwCP9gkRPt3XCCrW/hdAYasURy8Nlh/YOditoUYW 7VvP9piaU7JUqe6e6kgeK7KKbY20+GxI2yi/i3F7Pgrfm5gI9ZXbB3hZY5dAItdZZ79B UraoPkG8ucd2NyMDqbHYc0f6DkUyt6UKGWt7WA1ZggyMjKyYKNI5Vu/+K+IufbU9wKW+ Ib0MWB7vsCIlL6GADvRsuRwX72hquen1GVWECXOM3iuYnSK8ieXBGvI1MSUOpOIChSKc fmKby/oxso5N/4i+er1PQXPKMdMsKUK7s5On4PwD8Y3Mmh4AVtD1pIstJ/xm9cF9lpKt Dx2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toke.dk header.s=20161023 header.b=hgq637AS; 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 o2-20020a170902bcc200b00153b2d1641csi10664409pls.36.2022.04.04.19.04.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 19:04:24 -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=hgq637AS; 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 D44CB215465; Mon, 4 Apr 2022 17:27:43 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379081AbiDDVSn (ORCPT + 69 others); Mon, 4 Apr 2022 17:18:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379832AbiDDSOV (ORCPT ); Mon, 4 Apr 2022 14:14:21 -0400 Received: from mail.toke.dk (mail.toke.dk [45.145.95.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 600AC3EA8F; Mon, 4 Apr 2022 11:12:24 -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=1649095942; bh=t7buVznG3yYA/clRrtCyeVOjJjj86PX29F+Mo7FFbD4=; h=From:To:Cc:Subject:Date:From; b=hgq637ASRyJWWnpb/5p+PzMyiwCmOZ1E7FjoJroS8IjnYnPBEyiAnozUq4Y/4O/Zv WBms5xwx7I26Q4XR4Zp1Gb/P0Gdtc9QBBglKjvQeeognTIjidKHl3mNCG/GuzSXTvv zbDR2M6WhuKDO55eUOEn3lsGFz1zxtTAV+2xGJ2lZ1c/Hf+HUjrjrjn6Q7aEVYAhEL uDjO0cEOOp3nJXy3jc3Xiy2ligDg+8BhzKQqZa1MUfxJuCLyI4peA5R2Ga/iP1vyNE o6p7ATmqefViqKsIkik/jBSDExZGlXvFe9flumwCL1ob8uXetNEKzcG0jQaKB0LG6E WfBrU6/4AY8DA== 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 v2] ath9k: Fix usage of driver-private space in tx_info Date: Mon, 4 Apr 2022 20:11:51 +0200 Message-Id: <20220404181151.2669173-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/xmit.c | 30 ++++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) 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