A remain-on-channel request whose channel set fails leaves the phy off channel on the ROC chandef. mac80211 ends such a request without a driver call. The band thus stays off channel until a later ROC or scan, a chanctx change or a full reset. Until then it sends no beacons and no station data, and the radar detector stays off. Go back to the operating chandef and notify the return, as the end of a ROC does. Fixes: 6939b97ddad3 ("wifi: mt76: fix deadlock in remain-on-channel") Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/channel.c | 22 +++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/channel.c b/drivers/net/wireless/mediatek/mt76/channel.c index 6d9ca6dfecb7..b3c17f76b101 100644 --- a/drivers/net/wireless/mediatek/mt76/channel.c +++ b/drivers/net/wireless/mediatek/mt76/channel.c @@ -392,6 +392,19 @@ mt76_vif_roc_phy(struct mt76_dev *dev, struct ieee80211_vif *vif) return NULL; } +static void mt76_roc_chandef_restore(struct mt76_phy *phy) +{ + struct mt76_dev *dev = phy->dev; + + if (phy->chanctx && phy->main_chandef.chan && phy->offchannel && + !test_bit(MT76_MCU_RESET, &dev->phy.state)) { + __mt76_set_channel(phy, &phy->main_chandef, false); + mt76_offchannel_notify(phy, false); + } else { + phy->offchannel = false; + } +} + void mt76_roc_complete(struct mt76_phy *phy) { struct mt76_vif_link *mlink = mt76_dereference(phy->roc_link, phy->dev); @@ -402,13 +415,7 @@ void mt76_roc_complete(struct mt76_phy *phy) if (mlink && mlink->mvif->roc_phy == phy) WRITE_ONCE(mlink->mvif->roc_phy, NULL); - if (phy->chanctx && phy->main_chandef.chan && phy->offchannel && - !test_bit(MT76_MCU_RESET, &dev->phy.state)) { - __mt76_set_channel(phy, &phy->main_chandef, false); - mt76_offchannel_notify(phy, false); - } else { - phy->offchannel = false; - } + mt76_roc_chandef_restore(phy); rcu_assign_pointer(phy->roc_link, NULL); mt76_put_vif_phy_link(phy, phy->roc_vif, mlink); phy->roc_vif = NULL; @@ -485,6 +492,7 @@ int mt76_remain_on_channel(struct ieee80211_hw *hw, struct ieee80211_vif *vif, ret = __mt76_set_channel(phy, &chandef, offchannel); if (ret) { WRITE_ONCE(mlink->mvif->roc_phy, NULL); + mt76_roc_chandef_restore(phy); phy->roc_vif = NULL; rcu_assign_pointer(phy->roc_link, NULL); mt76_put_vif_phy_link(phy, vif, mlink); -- 2.47.3