From patchwork Wed Oct 19 08:26:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4689 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp213076wrs; Wed, 19 Oct 2022 02:09:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5r2Iu4H2mkTacjhNS3jweBfVGotgEf4h2rvHceQC7CcZkLpWDbOlV18ahWyvKlbaIp5chx X-Received: by 2002:a17:906:1ec5:b0:78d:b3d1:183b with SMTP id m5-20020a1709061ec500b0078db3d1183bmr5794758ejj.709.1666170546762; Wed, 19 Oct 2022 02:09:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666170546; cv=none; d=google.com; s=arc-20160816; b=TGhiHjuJQUYar2uyzVPsR0OBnY2GoxSU31MVsZcjfSfFxbH5hFh10VURpausS273lR vLdOBCr6G18X3cC4CfZi1FSRuFENQZ33UQacqQrfks+m1PutjbEtWhl1nFN2/vSvTZBo yDNQIUrmuUkx2UMah8v3d41UC7tniAubK7diwp+Et87QsrYAbTGM6e2PZZejbQ3u7nNO GT5uuKV/+neMYjCWq1ex/pgo9JWbkUc5X1qpGtGewMvcmbiHF8hLWUC0gfNaA93Zho70 hTLYfyvQjg3ZJacC+pVss6gJpdZaXEexZF5lRQFyesOHBbC+qs/hCUss5EVDQbbsLPP/ e9cw== 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=EEITlSytrn0CYt5c6KigYEaip61DSfN8ymywDT4Tvm4=; b=rIpI3udZdUytonaHBvNixBO/VDtbwri80KY4q4JqFY90CV5aXHrLcFCEQ3ifMgLY5U leuSIu3u9fibDAYr3dcyl0KH7cHptP17Ge8qRASl6wxnHeHTCGh/0jO8Dm4ifWAWuQPx HFzlnu5RHcVoNFhurpX6SMC9i6aLDoxcuJw40MFtwrTzqYPeuPwqYXI7ftA1YpKhB7Q5 CfuqyBs9sAwf7GpjgrODw9NlFkWZQQfoLdki5XcmkuvE5F+I1oMuhjU9Kfifrk2Z/C0B uO1bn7UgTZVlg/mbV+g7eljhiiD21kwnl+pXUk3wj1zlVMsAvbvUezLSv/KnMeBi+9tl jgZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eQ1ObCn0; 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 h17-20020a05640250d100b0045ca3839229si827786edb.274.2022.10.19.02.08.41; Wed, 19 Oct 2022 02:09:06 -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=eQ1ObCn0; 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 S232302AbiJSJFa (ORCPT + 99 others); Wed, 19 Oct 2022 05:05:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232343AbiJSJEB (ORCPT ); Wed, 19 Oct 2022 05:04:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CBD7A8365; Wed, 19 Oct 2022 01:56:59 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 1A0D56186E; Wed, 19 Oct 2022 08:52:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31F0EC433C1; Wed, 19 Oct 2022 08:52:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169574; bh=oHE9tJqv8CS6nL9BapG4VAu818gukBIxqWQHi+694Ok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eQ1ObCn0VjuCHnkDMT4jozTL/qghmqR5rIkd90mEMLNFnRPNtD+b+sR/ARn+oPQEX 1xUkVq/aBiaOMQNayJaaL284DPTdFBOqgP7COJBmq4kQuieIxQgRPj/apZ5YNpx6bq Rsa5ndtoz8D+SW6UBJLWdgync7slbByEWL/lpqNU= 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 6.0 327/862] wifi: rtl8xxxu: Fix AIFS written to REG_EDCA_*_PARAM Date: Wed, 19 Oct 2022 10:26:54 +0200 Message-Id: <20221019083304.476481771@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747106447680756312?= X-GMAIL-MSGID: =?utf-8?q?1747106447680756312?= 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 d8f5b4bb1fa9..08f9d17dce12 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, u64 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) {