From patchwork Wed Jan 8 02:25:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Wang X-Patchwork-Id: 13930088 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ED921E77197 for ; Wed, 8 Jan 2025 03:09:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mMHTVC5omCIzKCyWSVas6ETdrQO9DyIoTSLU4TpmV5k=; b=UznzX/D+iF/QOhw1LGvwT3BuKi Mpp1pO1RHB/NgFnVogEH581/fhOf0f4Nv0xaLPILneg4pwvBdEgWNRq177pGp3gSid+m/C5HLxxWQ j44Zt1cuJrrE1m2G6QvE0B5kyA0/N3fUQXv/6S73cIWStpy31rjl+F6ghv5ZNu9yyRZglsAqTeeft cMnLzp92e+bxl0arV5qJMVv5oHRdlBE0NoX3yCuoKYa9gdSS9hfRqKot6ESADQ2UPpJVaBWCo1+OR sWUidp4NCAL7DC4vBwSxwGKUGf+3rKHThd5RIpjaDWu5FieCD5CKW1HBKptFHbGvw398E3XIQI/MZ 7RbydG0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tVMRz-00000006ysg-2EFP; Wed, 08 Jan 2025 03:09:43 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tVMRy-00000006ysW-0z8d for linux-mediatek@bombadil.infradead.org; Wed, 08 Jan 2025 03:09:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=mMHTVC5omCIzKCyWSVas6ETdrQO9DyIoTSLU4TpmV5k=; b=IgXfCJvQzQYD6bxywI994XzT20 9ueb3xbMMOKQ1R/9dXQ3o6o0xOlDfC4Y+BjBdWIjvqHKhOYtEZp+vPGx1CbiVucfCnQFE64LO5J/X GfWkHpLdYShFPO2YClECTXc3sBBpz1nvoPal5VlV7vIBpLNQCFIV5EK36tUUUssvNA+RLUUek/D8K eeagILWjvLSKBz1Y0o0zZnU2qAT3efK/4ELJKkE1tCJ4iTGnevYj6bdvDgOVLeKo6mToLAeqfwci9 +DRvBjvOYMhyFLckJqEMVOqMccTDvKmAk8hzppq1OQH77YzOtkPK+loOreR5yqK5L9rj4IRWveHsr hm70treA==; Received: from mail-oa1-f46.google.com ([209.85.160.46]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tVLlJ-00000009F61-11IV for linux-mediatek@lists.infradead.org; Wed, 08 Jan 2025 02:25:39 +0000 Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-29e5aedbebdso7547448fac.0 for ; Tue, 07 Jan 2025 18:25:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736303133; x=1736907933; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mMHTVC5omCIzKCyWSVas6ETdrQO9DyIoTSLU4TpmV5k=; b=W3NOsNC3LWKbox87Q71c4QRbMEjc/0cwLdDUiVoNQlmGJzF/GOs6xyA6c/yZwF7pwu UXdY4NwTCFlF+JMPWHb/snePRfZYR+pbESa5tu5uKXD8pACKrMv+RI9s1ixC2WPVfyXj 1CXX3kUTL35njhbXwnQ+xMvIqkkmD3vNG8sAl6XQCtDxPJ3qy97oknMj66elms7qYdwi ZjQQzus9zZVKEjcHfTGNkaZqvnizAdffYyaUvpUkDOD2T9lTf57JfFJ9XtXp12LzMcCG vTgKCEfF69oK+eJjJwcLrXZ6ZWWSUarQUL0YnA1uhQXmAjG2PqvBT8ypge5eaTCr/8DV 5+aQ== X-Forwarded-Encrypted: i=1; AJvYcCVP6p8PUNT/g8fc8TA99SPpKgUGS+7kLwVGrw/UBm2tQEl177G/ZvHhY1Mnb89iZiVhuyL3/ZQPZmMJqy0dKw==@lists.infradead.org X-Gm-Message-State: AOJu0YxNmTtOTJzZE932HQTc+FQswAjW/GFALGChhlZa95T9OIxHLfPw 5ywhwBRgZecUxD5a7rPJGPGjLNEc954eB8qEnxBaZaeDKDim97TBXWPRS/lP X-Gm-Gg: ASbGncsprdRux1+CzPNtbJSDjytBKbolc2qsyCMeirP+8mBRLFpcy2pRuaT6VIa/wXq c6q3qZaYUbzS/x5xTdRwZqfkZ3847isZYmPMUoidF4KecxgEX9ynxcZS799eml0H0trkAXARyNF 5C07ke38cOxpTESy1oRJd2frcfyJM67y7RpUuiU3iFjQF0fBqcLsrdBCYomLJbR5FH/APwetcC7 ml5z+Z0vY/wNwXtq4XydRBPcek3OJ/0olBs878biLCIk7U9bqSaEAUCliLIc2ldBKjt/B4smA== X-Google-Smtp-Source: AGHT+IGQa9k57yYFrsV2kb30+Ip/UeVPsLJ/gjUXW4EJquDZ30xFTxjbTqu4fk9CYmLSYObCuskDOA== X-Received: by 2002:a05:6870:ce07:b0:29e:24c7:2861 with SMTP id 586e51a60fabf-2aa066abf1bmr581936fac.13.1736303133345; Tue, 07 Jan 2025 18:25:33 -0800 (PST) Received: from sean-ThinkPad-T450s.lan ([207.191.35.252]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2a7d77f6340sm13072862fac.48.2025.01.07.18.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 18:25:31 -0800 (PST) From: sean.wang@kernel.org To: nbd@nbd.name, lorenzo.bianconi@redhat.com Cc: sean.wang@mediatek.com, deren.wu@mediatek.com, mingyen.hsieh@mediatek.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 6/6] wifi: mt76: mt7925: update the power-saving flow Date: Tue, 7 Jan 2025 18:25:09 -0800 Message-Id: <20250108022509.217803-6-sean.wang@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250108022509.217803-1-sean.wang@kernel.org> References: <20250108022509.217803-1-sean.wang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250108_022537_686798_5B95D8F6 X-CRM114-Status: GOOD ( 16.69 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Ming Yen Hsieh After joining MLO, ensure that all links are setup before enabling power-saving. Fixes: 86c051f2c418 ("wifi: mt76: mt7925: enabling MLO when the firmware supports it") Signed-off-by: Ming Yen Hsieh Signed-off-by: Sean Wang --- .../net/wireless/mediatek/mt76/mt7925/init.c | 1 + .../net/wireless/mediatek/mt76/mt7925/main.c | 65 ++++++++++++++++--- .../wireless/mediatek/mt76/mt7925/mt7925.h | 1 + drivers/net/wireless/mediatek/mt76/mt792x.h | 9 +++ 4 files changed, 67 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/init.c b/drivers/net/wireless/mediatek/mt76/mt7925/init.c index ddc654b9ea5e..7d829b511846 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/init.c @@ -222,6 +222,7 @@ int mt7925_register_device(struct mt792x_dev *dev) dev->mt76.tx_worker.fn = mt792x_tx_worker; INIT_DELAYED_WORK(&dev->pm.ps_work, mt792x_pm_power_save_work); + INIT_DELAYED_WORK(&dev->mlo_pm_work, mt7925_mlo_pm_work); INIT_WORK(&dev->pm.wake_work, mt792x_pm_wake_work); spin_lock_init(&dev->pm.wake.lock); mutex_init(&dev->pm.mutex); diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c index 4714c07cfbfe..ffe783b4fb71 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c @@ -426,6 +426,7 @@ mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mvif->bss_conf.vif = mvif; mvif->sta.vif = mvif; mvif->deflink_id = IEEE80211_LINK_UNSPECIFIED; + mvif->mlo_pm_state = MT792x_MLO_LINK_DISASSOC; ret = mt7925_mac_link_bss_add(dev, &vif->bss_conf, &mvif->sta.deflink); if (ret < 0) @@ -1285,6 +1286,8 @@ void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, mvif->wep_sta = NULL; ewma_rssi_init(&mvif->bss_conf.rssi); } + + mvif->mlo_pm_state = MT792x_MLO_LINK_DISASSOC; } EXPORT_SYMBOL_GPL(mt7925_mac_sta_remove); @@ -1356,6 +1359,38 @@ mt7925_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, return ret; } +static void +mt7925_mlo_pm_iter(void *priv, u8 *mac, struct ieee80211_vif *vif) +{ + struct mt792x_dev *dev = priv; + struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; + unsigned long valid = ieee80211_vif_is_mld(vif) ? + mvif->valid_links : BIT(0); + struct ieee80211_bss_conf *bss_conf; + int i; + + if (mvif->mlo_pm_state != MT792x_MLO_CHANGED_PS) + return; + + mt792x_mutex_acquire(dev); + for_each_set_bit(i, &valid, IEEE80211_MLD_MAX_NUM_LINKS) { + bss_conf = mt792x_vif_to_bss_conf(vif, i); + mt7925_mcu_uni_bss_ps(dev, bss_conf); + } + mt792x_mutex_release(dev); +} + +void mt7925_mlo_pm_work(struct work_struct *work) +{ + struct mt792x_dev *dev = container_of(work, struct mt792x_dev, + mlo_pm_work.work); + struct ieee80211_hw *hw = mt76_hw(dev); + + ieee80211_iterate_active_interfaces(hw, + IEEE80211_IFACE_ITER_RESUME_ALL, + mt7925_mlo_pm_iter, dev); +} + static bool is_valid_alpha2(const char *alpha2) { if (!alpha2) @@ -1905,6 +1940,9 @@ static void mt7925_vif_cfg_changed(struct ieee80211_hw *hw, mt7925_mcu_sta_update(dev, NULL, vif, true, MT76_STA_INFO_STATE_ASSOC); mt7925_mcu_set_beacon_filter(dev, vif, vif->cfg.assoc); + + if (ieee80211_vif_is_mld(vif)) + mvif->mlo_pm_state = MT792x_MLO_LINK_ASSOC; } if (changed & BSS_CHANGED_ARP_FILTER) { @@ -1915,9 +1953,19 @@ static void mt7925_vif_cfg_changed(struct ieee80211_hw *hw, } if (changed & BSS_CHANGED_PS) { - for_each_set_bit(i, &valid, IEEE80211_MLD_MAX_NUM_LINKS) { - bss_conf = mt792x_vif_to_bss_conf(vif, i); + if (hweight16(mvif->valid_links) < 2) { + /* legacy */ + bss_conf = &vif->bss_conf; mt7925_mcu_uni_bss_ps(dev, bss_conf); + } else { + if (mvif->mlo_pm_state == MT792x_MLO_LINK_ASSOC) { + mvif->mlo_pm_state = MT792x_MLO_CHANGED_PS_PENDING; + } else if (mvif->mlo_pm_state == MT792x_MLO_CHANGED_PS) { + for_each_set_bit(i, &valid, IEEE80211_MLD_MAX_NUM_LINKS) { + bss_conf = mt792x_vif_to_bss_conf(vif, i); + mt7925_mcu_uni_bss_ps(dev, bss_conf); + } + } } } @@ -1968,11 +2016,12 @@ static void mt7925_link_info_changed(struct ieee80211_hw *hw, if (changed & (BSS_CHANGED_QOS | BSS_CHANGED_BEACON_ENABLED)) mt7925_mcu_set_tx(dev, info); - if (changed & BSS_CHANGED_BSSID) { - if (ieee80211_vif_is_mld(vif) && - hweight16(mvif->valid_links) == 2) - /* Indicate the secondary setup done */ - mt7925_mcu_uni_bss_bcnft(dev, info, true); + if (mvif->mlo_pm_state == MT792x_MLO_CHANGED_PS_PENDING) { + /* Indicate the secondary setup done */ + mt7925_mcu_uni_bss_bcnft(dev, info, true); + + ieee80211_queue_delayed_work(hw, &dev->mlo_pm_work, 5 * HZ); + mvif->mlo_pm_state = MT792x_MLO_CHANGED_PS; } mt792x_mutex_release(dev); @@ -2056,8 +2105,6 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif, goto free; if (mconf != &mvif->bss_conf) { - mt7925_mcu_set_bss_pm(dev, link_conf, true); - err = mt7925_set_mlo_roc(phy, &mvif->bss_conf, vif->active_links); if (err < 0) diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h index f5c02e5f5066..cd7a7c293018 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h +++ b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h @@ -247,6 +247,7 @@ int mt7925_mcu_uni_tx_ba(struct mt792x_dev *dev, int mt7925_mcu_uni_rx_ba(struct mt792x_dev *dev, struct ieee80211_ampdu_params *params, bool enable); +void mt7925_mlo_pm_work(struct work_struct *work); void mt7925_scan_work(struct work_struct *work); void mt7925_roc_work(struct work_struct *work); int mt7925_mcu_uni_bss_ps(struct mt792x_dev *dev, diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h index 3f989e83f252..20d8b02d1b6f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x.h +++ b/drivers/net/wireless/mediatek/mt76/mt792x.h @@ -81,6 +81,13 @@ enum mt792x_reg_power_type { MT_AP_VLP, }; +enum mt792x_mlo_pm_state { + MT792x_MLO_LINK_DISASSOC, + MT792x_MLO_LINK_ASSOC, + MT792x_MLO_CHANGED_PS_PENDING, + MT792x_MLO_CHANGED_PS, +}; + DECLARE_EWMA(avg_signal, 10, 8) struct mt792x_link_sta { @@ -134,6 +141,7 @@ struct mt792x_vif { struct mt792x_phy *phy; u16 valid_links; u8 deflink_id; + enum mt792x_mlo_pm_state mlo_pm_state; struct work_struct csa_work; struct timer_list csa_timer; @@ -235,6 +243,7 @@ struct mt792x_dev { const struct mt792x_irq_map *irq_map; struct work_struct ipv6_ns_work; + struct delayed_work mlo_pm_work; /* IPv6 addresses for WoWLAN */ struct sk_buff_head ipv6_ns_list;