Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp799699rwi; Wed, 19 Oct 2022 03:10:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4hpkx3d2jziLZH8/+g49ZfODGqNAarykJH26xiBzhbic4Qu2/L680VoMERos0gi7hC+j6b X-Received: by 2002:a17:90b:4ad1:b0:20a:b974:19a0 with SMTP id mh17-20020a17090b4ad100b0020ab97419a0mr8699120pjb.178.1666174197950; Wed, 19 Oct 2022 03:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666174197; cv=none; d=google.com; s=arc-20160816; b=LcpZPSgLrMG9iv1McLL30PYk/qNNNEIlYT+uc5rZIb+Ech5duhzc92z21VBumvDre/ fsee6Zp1fVg7NdDeVz4swzwy00s/x6sSsIJygyv3/7nXeiO3fI6IWpmph9kBrCQNANIt JdAx9bh/miF0M6xfm0z4YRKEk2zJiNOT5jlu2kMAcrHogPno5kzCLGy8mnk5StaOnlFU ror9eAH+/RqavrcZ6nW+dxvi5Hy/s9ArzoSb6snKgCvqitP/HaV7f0Cex/PNKq/CiwwT GqBT0nVnqex+V4aaBQqHGeTO7x0M+wR04iCVRZRMluJ0R93urQWdo50ynDvLGxUphwAC oCuw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s3-20020a170902c64300b001865a9586c1si293460pls.59.2022.10.19.03.09.42; Wed, 19 Oct 2022 03:09:57 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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) { -- 2.35.1