From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
To: sean.wang@mediatek.com
Cc: nbd@nbd.name, Soul.Huang@mediatek.com, YN.Chen@mediatek.com,
Leon.Yen@mediatek.com, Eric-SY.Chang@mediatek.com,
Deren.Wu@mediatek.com, km.lin@mediatek.com,
robin.chiu@mediatek.com, ch.yeh@mediatek.com,
posh.sun@mediatek.com, Eric.Liang@mediatek.com,
Stella.Chang@mediatek.com, jemele@google.com,
yenlinlai@google.com, linux-wireless@vger.kernel.org,
linux-mediatek@lists.infradead.org
Subject: Re: [PATCH v2 3/3] mt76: mt7921: fix sta_state incorrect implementation
Date: Wed, 2 Jun 2021 09:51:28 +0200 [thread overview]
Message-ID: <YLc4gHgI6FpIGzMZ@lore-desk> (raw)
In-Reply-To: <129b40e5ff277efc0a1b0ff9b8c3dfb8a44ad7fe.1622610746.git.objelf@gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 5791 bytes --]
> From: Sean Wang <sean.wang@mediatek.com>
>
> When .sta_state is implemented, mac80211 assumes that the station entry is
> usable after the NOTEXIST->NONE transition.
>
> So we should create the sta entry as early as possible in order that
> mac80211 pass assoc/auth frames to mt76 with the newly created sta entry,
> and add .sta_assoc to mt76 core to refresh the sta entry again when sta is
> being associated.
>
> Fixes: 8aa5a9b7361c ("mt76: mt7921: enable deep sleep at runtime")
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> ---
> v1->v2: Put back the careless change not belonged to the patch to keep
> mt7921_mcu_sta_add for BC entry and mt76_connac_mcu_uni_add_bss
> on the association.
> ---
> .../net/wireless/mediatek/mt76/mt7921/main.c | 53 ++++++++-----------
> .../wireless/mediatek/mt76/mt7921/mt7921.h | 2 +
> .../net/wireless/mediatek/mt76/mt7921/pci.c | 1 +
> 3 files changed, 26 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> index ece0cecf049d..ae07367a091a 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> @@ -610,15 +610,11 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> if (ret)
> return ret;
>
> - if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
> - mt76_connac_mcu_uni_add_bss(&dev->mphy, vif, &mvif->sta.wcid,
> - true);
> -
> mt7921_mac_wtbl_update(dev, idx,
> MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
>
> ret = mt7921_mcu_sta_add(dev, sta, vif, true,
> - MT76_STA_INFO_STATE_3);
> + MT76_STA_INFO_STATE_1);
> if (ret)
> return ret;
>
> @@ -627,6 +623,27 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> return 0;
> }
>
> +void mt7921_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> + struct ieee80211_sta *sta)
> +{
> + struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
> + struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv;
> + struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
> +
here you need to grab grub the dev mutex because mt76 code does not do it for
you
%s/mt76_connac_pm_wake(&dev->mphy, &dev->pm)/mt7921_mutex_acquire()/
> + mt76_connac_pm_wake(&dev->mphy, &dev->pm);
> +
> + if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
> + mt76_connac_mcu_uni_add_bss(&dev->mphy, vif, &mvif->sta.wcid,
> + true);
> +
> + mt7921_mac_wtbl_update(dev, msta->wcid.idx,
> + MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
> +
> + mt7921_mcu_sta_update(dev, sta, vif, MT76_STA_INFO_STATE_3);
> +
> + mt76_connac_power_save_sched(&dev->mphy, &dev->pm);
%s/mt76_connac_power_save_sched/mt7921_mutex_release/
> +}
> +
> void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> struct ieee80211_sta *sta)
> {
> @@ -781,22 +798,6 @@ mt7921_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
> return ret;
> }
>
> -static int
> -mt7921_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
> - struct ieee80211_sta *sta)
> -{
> - return mt76_sta_state(hw, vif, sta, IEEE80211_STA_NOTEXIST,
> - IEEE80211_STA_NONE);
> -}
> -
> -static int
> -mt7921_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
> - struct ieee80211_sta *sta)
> -{
> - return mt76_sta_state(hw, vif, sta, IEEE80211_STA_NONE,
> - IEEE80211_STA_NOTEXIST);
> -}
> -
> static int mt7921_sta_state(struct ieee80211_hw *hw,
> struct ieee80211_vif *vif,
> struct ieee80211_sta *sta,
> @@ -811,15 +812,7 @@ static int mt7921_sta_state(struct ieee80211_hw *hw,
> mt7921_mutex_release(dev);
> }
>
> - if (old_state == IEEE80211_STA_AUTH &&
> - new_state == IEEE80211_STA_ASSOC) {
> - return mt7921_sta_add(hw, vif, sta);
> - } else if (old_state == IEEE80211_STA_ASSOC &&
> - new_state == IEEE80211_STA_AUTH) {
> - return mt7921_sta_remove(hw, vif, sta);
> - }
> -
> - return 0;
> + return mt76_sta_state(hw, vif, sta, old_state, new_state);
> }
>
> static int
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> index 13d0f472b043..e97a74341ccd 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> @@ -264,6 +264,8 @@ int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
> struct ieee80211_vif *vif, bool enable, u8 state);
> int mt7921_mcu_sta_update(struct mt7921_dev *dev, struct ieee80211_sta *sta,
> struct ieee80211_vif *vif, u8 state);
> +void mt7921_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> + struct ieee80211_sta *sta);
> int mt7921_mcu_set_chan_info(struct mt7921_phy *phy, int cmd);
> int mt7921_mcu_set_tx(struct mt7921_dev *dev, struct ieee80211_vif *vif);
> int mt7921_mcu_set_eeprom(struct mt7921_dev *dev);
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> index 13263f50dc00..27906b2cd912 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> @@ -106,6 +106,7 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
> .rx_poll_complete = mt7921_rx_poll_complete,
> .sta_ps = mt7921_sta_ps,
> .sta_add = mt7921_mac_sta_add,
> + .sta_assoc = mt7921_mac_sta_assoc,
> .sta_remove = mt7921_mac_sta_remove,
> .update_survey = mt7921_update_channel,
> };
> --
> 2.25.1
>
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
next prev parent reply other threads:[~2021-06-02 8:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-02 5:24 [PATCH v2 1/3] mt76: connac: add mt76_connac_mcu_update_sta_cmd support sean.wang
2021-06-02 5:24 ` [PATCH v2 2/3] mt76: mt7921: add mt7921_mcu_sta_update support sean.wang
2021-06-02 8:00 ` Lorenzo Bianconi
2021-06-02 5:24 ` [PATCH v2 3/3] mt76: mt7921: fix sta_state incorrect implementation sean.wang
2021-06-02 7:51 ` Lorenzo Bianconi [this message]
2021-06-02 5:59 ` [PATCH v2 1/3] mt76: connac: add mt76_connac_mcu_update_sta_cmd support Felix Fietkau
2021-06-02 7:43 ` Lorenzo Bianconi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YLc4gHgI6FpIGzMZ@lore-desk \
--to=lorenzo.bianconi@redhat.com \
--cc=Deren.Wu@mediatek.com \
--cc=Eric-SY.Chang@mediatek.com \
--cc=Eric.Liang@mediatek.com \
--cc=Leon.Yen@mediatek.com \
--cc=Soul.Huang@mediatek.com \
--cc=Stella.Chang@mediatek.com \
--cc=YN.Chen@mediatek.com \
--cc=ch.yeh@mediatek.com \
--cc=jemele@google.com \
--cc=km.lin@mediatek.com \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=nbd@nbd.name \
--cc=posh.sun@mediatek.com \
--cc=robin.chiu@mediatek.com \
--cc=sean.wang@mediatek.com \
--cc=yenlinlai@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox