Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3085291rwe; Mon, 29 Aug 2022 05:42:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR6cZQVqVF8mltEkVfIBH2kTXS1PArjQ5bi7pokqOzwLTRc5kmuWAELtjDlNIZMTIl25JWnL X-Received: by 2002:a63:d00a:0:b0:42a:3d80:10a with SMTP id z10-20020a63d00a000000b0042a3d80010amr13435501pgf.288.1661776930989; Mon, 29 Aug 2022 05:42:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661776930; cv=none; d=google.com; s=arc-20160816; b=bVGy201wKA2DbJmNgUq8C4e/shVmrqTCqsDEW4bDu2f7z3FOMv+q3BCPEygJ/y+bxR N6080SbvFdkcWNgqLMqa+1+4KQUrRjwwYplFxK8YgObvKyyfJZf1gn7gxlPETZRBgXu+ 8uY+UxTn5sFfH5VhHxVueN5EAXzUygTE6aCEbisePdxMKuPBD/eYbbiDE5TMefUjHVE2 2L9mplnV/L0XIQ113/kbslUOijR59vF07cyldYS15nDkO7f0KWvVH/m+iDdKPlagtOrQ dCPaPt8dcZLvLl26RzQC/Tr/K6P9E89Whwl5G8TIxuGtCWUbfhrg5Z9VnP4t2egojhly 8NPg== 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=aB5IfV3OsSNh/zS8e7nZyJzGmclruWDHc2HosJxQyLk=; b=EodRTQqWkwUUFKogUB2DaHVeTSSvLCV+56D9hrB7mfl8vzBjqJm/RClmjNhxE+mlvK f+R8dvPOl3PL5rjgHYsGOQ5ug9fgjQ7W09+lh24CELuemL7/EJyY63S5pXAFfK7qyX0L y4K5Ve3JUt7FesqnDYhotZSGRgRGbIcsZgWT+HEsE8y9pvgwdPuDXkqttpJf513y+B1B zcrsmUmXYNBotfOjLRkT1seqc0eUUhupE7615WfCHEMGnZzBiP84kCk8wKZuoryXYSqe FKrDFaMNfvDc+Ifk6hY7MwRo856OmoQThAumg+zUz9NctsSIM395N4isEs9u6smOFfjw w28Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="xqM/g+uR"; 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 c23-20020a634e17000000b00429b4bd247asi8452553pgb.397.2022.08.29.05.41.59; Mon, 29 Aug 2022 05:42:10 -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="xqM/g+uR"; 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 S231394AbiH2LQQ (ORCPT + 99 others); Mon, 29 Aug 2022 07:16:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231563AbiH2LOG (ORCPT ); Mon, 29 Aug 2022 07:14:06 -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 3BDAC63F15; Mon, 29 Aug 2022 04:10:16 -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 0E6EC611C2; Mon, 29 Aug 2022 11:07:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9730CC433D6; Mon, 29 Aug 2022 11:07:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661771270; bh=2jqoQJ423K4tztFRdNO+0o7cvRFn3+7ghfhrBOmWg9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xqM/g+uRClzJasfOMljJ/2Mw+i7OrU9qHSLaQccXejkmzRcutZZdEi2PO3z2FdWUJ rEfnkvnPFT5ZWVwHwSg2z0A1NYOK+M6EjwCSwlg/B6irjTqPVi/GgK9Eh8feT8FM4r bGmqYmp0JO5h0yUrwPCfiT00xpEe7hjuSxboA+tI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Wang , Deren Wu , Felix Fietkau Subject: [PATCH 5.19 011/158] mt76: mt7921: fix command timeout in AP stop period Date: Mon, 29 Aug 2022 12:57:41 +0200 Message-Id: <20220829105809.301913190@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220829105808.828227973@linuxfoundation.org> References: <20220829105808.828227973@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.1 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,T_SCC_BODY_TEXT_LINE 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: Deren Wu commit 9d958b60ebc2434f2b7eae83d77849e22d1059eb upstream. Due to AP stop improperly, mt7921 driver would face random command timeout by chip fw problem. Migrate AP start/stop process to .start_ap/.stop_ap and congiure BSS network settings in both hooks. The new flow is shown below. * AP start .start_ap() configure BSS network resource set BSS to connected state .bss_info_changed() enable fw beacon offload * AP stop .bss_info_changed() disable fw beacon offload (skip this command) .stop_ap() set BSS to disconnected state (beacon offload disabled automatically) destroy BSS network resource Fixes: 116c69603b01 ("mt76: mt7921: Add AP mode support") Signed-off-by: Sean Wang Signed-off-by: Deren Wu Signed-off-by: Felix Fietkau Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 2 drivers/net/wireless/mediatek/mt76/mt7921/main.c | 47 +++++++++++++++---- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 5 -- drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h | 2 4 files changed, 43 insertions(+), 13 deletions(-) --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c @@ -1403,6 +1403,8 @@ int mt76_connac_mcu_uni_add_bss(struct m else conn_type = CONNECTION_INFRA_AP; basic_req.basic.conn_type = cpu_to_le32(conn_type); + /* Fully active/deactivate BSS network in AP mode only */ + basic_req.basic.active = enable; break; case NL80211_IFTYPE_STATION: if (vif->p2p) --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -653,15 +653,6 @@ static void mt7921_bss_info_changed(stru } } - if (changed & BSS_CHANGED_BEACON_ENABLED && info->enable_beacon) { - struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv; - - mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.wcid, - true); - mt7921_mcu_sta_update(dev, NULL, vif, true, - MT76_STA_INFO_STATE_NONE); - } - if (changed & (BSS_CHANGED_BEACON | BSS_CHANGED_BEACON_ENABLED)) mt7921_mcu_uni_add_beacon_offload(dev, hw, vif, @@ -1500,6 +1491,42 @@ mt7921_channel_switch_beacon(struct ieee mt7921_mutex_release(dev); } +static int +mt7921_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif) +{ + struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv; + struct mt7921_phy *phy = mt7921_hw_phy(hw); + struct mt7921_dev *dev = mt7921_hw_dev(hw); + int err; + + err = mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.wcid, + true); + if (err) + return err; + + err = mt7921_mcu_set_bss_pm(dev, vif, true); + if (err) + return err; + + return mt7921_mcu_sta_update(dev, NULL, vif, true, + MT76_STA_INFO_STATE_NONE); +} + +static void +mt7921_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif) +{ + struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv; + struct mt7921_phy *phy = mt7921_hw_phy(hw); + struct mt7921_dev *dev = mt7921_hw_dev(hw); + int err; + + err = mt7921_mcu_set_bss_pm(dev, vif, false); + if (err) + return; + + mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.wcid, false); +} + const struct ieee80211_ops mt7921_ops = { .tx = mt7921_tx, .start = mt7921_start, @@ -1510,6 +1537,8 @@ const struct ieee80211_ops mt7921_ops = .conf_tx = mt7921_conf_tx, .configure_filter = mt7921_configure_filter, .bss_info_changed = mt7921_bss_info_changed, + .start_ap = mt7921_start_ap, + .stop_ap = mt7921_stop_ap, .sta_state = mt7921_sta_state, .sta_pre_rcu_remove = mt76_sta_pre_rcu_remove, .set_key = mt7921_set_key, --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c @@ -1020,7 +1020,7 @@ mt7921_mcu_uni_bss_bcnft(struct mt7921_d &bcnft_req, sizeof(bcnft_req), true); } -static int +int mt7921_mcu_set_bss_pm(struct mt7921_dev *dev, struct ieee80211_vif *vif, bool enable) { @@ -1049,9 +1049,6 @@ mt7921_mcu_set_bss_pm(struct mt7921_dev }; int err; - if (vif->type != NL80211_IFTYPE_STATION) - return 0; - err = mt76_mcu_send_msg(&dev->mt76, MCU_CE_CMD(SET_BSS_ABORT), &req_hdr, sizeof(req_hdr), false); if (err < 0 || !enable) --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h @@ -280,6 +280,8 @@ int mt7921_wpdma_reset(struct mt7921_dev int mt7921_wpdma_reinit_cond(struct mt7921_dev *dev); void mt7921_dma_cleanup(struct mt7921_dev *dev); int mt7921_run_firmware(struct mt7921_dev *dev); +int mt7921_mcu_set_bss_pm(struct mt7921_dev *dev, struct ieee80211_vif *vif, + bool enable); int mt7921_mcu_sta_update(struct mt7921_dev *dev, struct ieee80211_sta *sta, struct ieee80211_vif *vif, bool enable, enum mt76_sta_info_state state);