From patchwork Mon Oct 24 11:28:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9086 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp445779wru; Mon, 24 Oct 2022 06:13:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM74awZ6bGCR+ZRjj6G6/HTSmWVlIA17Dpj6QidImzoA8LF2JKCnaWtIJwg0tf95jl0RQs+i X-Received: by 2002:a17:902:70c4:b0:178:54cf:d397 with SMTP id l4-20020a17090270c400b0017854cfd397mr32480422plt.24.1666617189385; Mon, 24 Oct 2022 06:13:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666617189; cv=none; d=google.com; s=arc-20160816; b=VttzUP2cPr0zItMcpgGiTbd9ik4YpQQa6gO/ibQLCTmtyJz+9d6BvZuJAbKTHq+Qax ogzSG9jJ12dKXTkVypJYWpDLJHBRFgAwbquXTbu4rgNDFo7EqHcMDNJ0KZU94qOiD/3t blYcMhKhxZd5bA/C2kQd2BoD4HNc1B3SEsIz5vSibEZsTBa1fpsupkktVu70LeZiIAgp bPZGXMvWwPRAGv4S7c6R42VGiIhMvd9BEFjaz01D9EffeFAeCy4D4cz9P0CFoeG4yejb ffhHKqH4x2XuRP/HSLzqndE/VMYTLlKxyejSgNx899dKedtMphlD7nV13P7RBPdSkbHz /dBg== 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=gzFUDS5IfEZ2Fv8S4vhD1fx7F0HqG+23CP50S6IZPn8=; b=dtZA0LsnrnVZrsCpzqmwuiWyz2pZmKbdK2nvO5K7B5cNr7dTtU0Vj0J3pHsbdaYj6W KXTpYVVThWFQ7j+8cIYmViy68c/6ZoXTbNwsbudD756Jwynuua210IKiFsvI7p9j9Rum LX6bvyK8t/Mm+EYblgASR5pMhP3sstSRhI2xWhEJgJyB6T3WJrV/G2XL2zgu51sYK79Y uU1OeJqM0IGspQX4R01WWkP9OSSDEmOTAPZbnZIh5lswFHD9MvWy+bdN7Rd2aYUqWT+O usHvIQl5yyzUPFDK68nKxBi7oqMtYahE9Hcri6EuAkL3h0bnXk4tGaoW3HvS935lH5Gl fTFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YoebTVL3; 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 z4-20020a6552c4000000b0046439853c62si34819507pgp.127.2022.10.24.06.12.54; Mon, 24 Oct 2022 06:13:09 -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=YoebTVL3; 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 S235420AbiJXNMh (ORCPT + 99 others); Mon, 24 Oct 2022 09:12:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235609AbiJXNJH (ORCPT ); Mon, 24 Oct 2022 09:09:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 661269E6A4; Mon, 24 Oct 2022 05:22:00 -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 78DEB612A8; Mon, 24 Oct 2022 12:21:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86202C433C1; Mon, 24 Oct 2022 12:21:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614092; bh=mmJf2WmHjYvNc14I4worNIpdJc0e+5xAMFPez2Swz+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YoebTVL3mwfN/JVgxnzwG2dNVKyb7WL0gfxjxVWcHNvehJMzWyqrMHdxekbterUYT EvEa7dExeS3LDM3LkRqJ+7kJsqmxR6xHrBqzppI0R8kfwqc2UVuxvFglrl4hs7yWAV GxQI0qP3EME1X+Ql8aw6SZh2scNo1StVtx+CupAs= 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.10 130/390] wifi: rtl8xxxu: Fix AIFS written to REG_EDCA_*_PARAM Date: Mon, 24 Oct 2022 13:28:47 +0200 Message-Id: <20221024113028.213257065@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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?1747574785842429132?= X-GMAIL-MSGID: =?utf-8?q?1747574785842429132?= 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 7818a7ea0498..e34cd6fed7e8 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c @@ -4507,6 +4507,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) @@ -4592,6 +4639,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) {