From patchwork Sat Oct 22 07:22:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7349 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1095319wrr; Sat, 22 Oct 2022 01:02:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4zg3PPJXIORxmB4TfAsX8PGVBY4K6Z6exiPY/g3BezumCwFrzfD2DtUKmgeR8cAwaGPgLi X-Received: by 2002:a17:902:724b:b0:183:16f:fae4 with SMTP id c11-20020a170902724b00b00183016ffae4mr23428498pll.88.1666425743808; Sat, 22 Oct 2022 01:02:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666425743; cv=none; d=google.com; s=arc-20160816; b=RFjsJR5amnol5sWZB000A78jhBcBJdum1RtXDj+vS+3dmx9C6E0VCaWdAtCdYxpmry EUHzOu6V6JlTLtNYQ4ytJ+u7mrw/t4zQEpavRB0RlBlx624y51ErqIaxC+h6vyFA8r6P iVVrUD+/X7+GjmH1te5X+5Aq/5JHJc7xNPP0UIk2Qh74jW+DsIqoiIdWS4mfdb5Wy66q +vpUUFfDsDVWfySBwwglpqq1Y4DOVrYyDK0qG7Zxrt2gdz1qEVQVMWHNHdqFnlL2d6jw dG9SutjjeH19b5OZSbY4TjnqKH9lC6s0Q+Q6QO9O9MYBwuDiADv7OVj+x5NUYHQ9M2PY 99mg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XTTYSkJlAKmiU/5kYrdMqtu+6fizvv5IXkdcFhS/23g=; b=m2ZhF5axjz+866qsGdrkmZhvgBEAxyPWHtND8N5aHdMyC/slARHrbUGroob2Pq5fEE flfozVpDac2HcRnvCxQqbxIZCVhL3t4W98vfwWM5L1b1K19vEacYvP95VXmZwe0TSE13 uMAQC8HibY4ylVpDDGOoTrpDOw5IVT9jxAak+7hPj3dmBego2OV3OrSJ87/w9hDK67nf d/nZhk32tohcRIF0wZ5AWJfQyEpMSDpds3UH8Eo4bV/Z8M4HIKvKapVBG5oHT4cQ5ySC l9HQL4+4c0EN0npXb1Rdsf9WTCtti/yFQVyOEDhLfBPCkUesWy9Ur27vN4mlO+8Aw00F UXdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="a/EJbPL9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h21-20020a056a001a5500b00562a1cb3661si29650622pfv.272.2022.10.22.01.02.08; Sat, 22 Oct 2022 01:02:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b="a/EJbPL9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232468AbiJVIBm (ORCPT + 99 others); Sat, 22 Oct 2022 04:01:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232218AbiJVHy0 (ORCPT ); Sat, 22 Oct 2022 03:54:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6534951D8; Sat, 22 Oct 2022 00:47:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5FEB6B82E17; Sat, 22 Oct 2022 07:46:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C95FFC433D6; Sat, 22 Oct 2022 07:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424785; bh=kUpBrIVqSlkp2SOCGgG54sjDPu8ZawxljH/7Mfewagg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a/EJbPL9p4PN61+z3JkI4qwD6Vs888Kh6WjbO1Al7YnTCBg1imq2NegOV0jz7FQKH EIiwoVgSTVuTPlcORinvekoetKhCiCu3Tze8Sm5G2Anxled4v50lBuHfau/5aQJweg YZeRNjYWp4UMeIUUwqc7jHC7UJyQOElwsqohRDHY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bitterblue Smith , Jes Sorensen , Kalle Valo , Sasha Levin Subject: [PATCH 5.19 276/717] wifi: rtl8xxxu: Fix AIFS written to REG_EDCA_*_PARAM Date: Sat, 22 Oct 2022 09:22:35 +0200 Message-Id: <20221022072503.020943027@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747374040396067958?= X-GMAIL-MSGID: =?utf-8?q?1747374040396067958?= From: Bitterblue Smith [ Upstream commit 5574d3290449916397f3092dcd2bac92415498e1 ] ieee80211_tx_queue_params.aifs is not supposed to be written directly to the REG_EDCA_*_PARAM registers. Instead process it like the vendor drivers do. It's kinda hacky but it works. This change boosts the download speed and makes it more stable. Tested with RTL8188FU but all the other supported chips should also benefit. Fixes: 26f1fad29ad9 ("New driver: rtl8xxxu (mac80211)") Signed-off-by: Bitterblue Smith Acked-by: Jes Sorensen Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/038cc03f-3567-77ba-a7bd-c4930e3b2fad@gmail.com Signed-off-by: Sasha Levin --- .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c index 5f9d6cce1114..57b5370a256b 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c @@ -4560,6 +4560,53 @@ rtl8xxxu_wireless_mode(struct ieee80211_hw *hw, struct ieee80211_sta *sta) return network_type; } +static void rtl8xxxu_set_aifs(struct rtl8xxxu_priv *priv, u8 slot_time) +{ + u32 reg_edca_param[IEEE80211_NUM_ACS] = { + [IEEE80211_AC_VO] = REG_EDCA_VO_PARAM, + [IEEE80211_AC_VI] = REG_EDCA_VI_PARAM, + [IEEE80211_AC_BE] = REG_EDCA_BE_PARAM, + [IEEE80211_AC_BK] = REG_EDCA_BK_PARAM, + }; + u32 val32; + u16 wireless_mode = 0; + u8 aifs, aifsn, sifs; + int i; + + if (priv->vif) { + struct ieee80211_sta *sta; + + rcu_read_lock(); + sta = ieee80211_find_sta(priv->vif, priv->vif->bss_conf.bssid); + if (sta) + wireless_mode = rtl8xxxu_wireless_mode(priv->hw, sta); + rcu_read_unlock(); + } + + if (priv->hw->conf.chandef.chan->band == NL80211_BAND_5GHZ || + (wireless_mode & WIRELESS_MODE_N_24G)) + sifs = 16; + else + sifs = 10; + + for (i = 0; i < IEEE80211_NUM_ACS; i++) { + val32 = rtl8xxxu_read32(priv, reg_edca_param[i]); + + /* It was set in conf_tx. */ + aifsn = val32 & 0xff; + + /* aifsn not set yet or already fixed */ + if (aifsn < 2 || aifsn > 15) + continue; + + aifs = aifsn * slot_time + sifs; + + val32 &= ~0xff; + val32 |= aifs; + rtl8xxxu_write32(priv, reg_edca_param[i], val32); + } +} + static void rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_bss_conf *bss_conf, u32 changed) @@ -4679,6 +4726,8 @@ rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, else val8 = 20; rtl8xxxu_write8(priv, REG_SLOT, val8); + + rtl8xxxu_set_aifs(priv, val8); } if (changed & BSS_CHANGED_BSSID) {