Skip to content

mt76: fix association failure on kernels without wiphy->n_radio - #22

Open
antonionesta wants to merge 1 commit into
hmtheboy154:backportfrom
antonionesta:fix-vif-phy-old-kernels
Open

mt76: fix association failure on kernels without wiphy->n_radio#22
antonionesta wants to merge 1 commit into
hmtheboy154:backportfrom
antonionesta:fix-vif-phy-old-kernels

Conversation

@antonionesta

Copy link
Copy Markdown

Commit fe503c3 ("mt7902e: Backport down to 6.6") wrapped the n_radio == 0 fast path in mt76_vif_phy() in a version guard, because wiphy->n_radio does not exist on older kernels. The guard removed the fast path instead of preserving its behaviour, so on any kernel below the guarded version mt76_vif_phy() falls through to the chanctx lookup.

That lookup is never valid for mt792x. The MT7902 firmware does not advertise MT792x_FW_CAP_CNM, so mt792x_get_mac80211_ops() clears ops->assign_vif_chanctx and mlink->ctx stays NULL forever. mt76_vif_phy() therefore returns NULL, mt76_sta_state() bails out with -EINVAL, and every association attempt fails with:

wlan0: failed to insert STA entry for the AP (error -22)

mt76_get_txpower() is broken by the same path and stops reporting TX power.

Even with a CNM-capable firmware the fall-through would be wrong: mt792x sets hw->chanctx_data_size to sizeof(struct mt792x_chanctx), whose first member is a struct mt792x_bss_conf pointer, so the struct mt76_chanctx cast would be a type confusion.

This driver never registers more than one radio, so the n_radio == 0 fast path always applies. Return hw->priv unconditionally on kernels lacking wiphy->n_radio, mirroring the #else pattern already used for mt76_get_survey() in the same commit.

Tested on 6.12.100+deb13-amd64: association completes and the link reaches HE-MCS 11 rates.

Fixes: fe503c3 ("mt7902e: Backport down to 6.6")

Commit fe503c3 ("mt7902e: Backport down to 6.6") wrapped the
n_radio == 0 fast path in mt76_vif_phy() in a version guard, because
wiphy->n_radio does not exist on older kernels. The guard removed the
fast path instead of preserving its behaviour, so on any kernel below
the guarded version mt76_vif_phy() falls through to the chanctx lookup.

That lookup is never valid for mt792x. The MT7902 firmware does not
advertise MT792x_FW_CAP_CNM, so mt792x_get_mac80211_ops() clears
ops->assign_vif_chanctx and mlink->ctx stays NULL forever.
mt76_vif_phy() therefore returns NULL, mt76_sta_state() bails out with
-EINVAL, and every association attempt fails with:

  wlan0: failed to insert STA entry for the AP (error -22)

mt76_get_txpower() is broken by the same path and stops reporting TX
power.

Even with a CNM-capable firmware the fall-through would be wrong:
mt792x sets hw->chanctx_data_size to sizeof(struct mt792x_chanctx),
whose first member is a struct mt792x_bss_conf pointer, so the
struct mt76_chanctx cast would be a type confusion.

This driver never registers more than one radio, so the n_radio == 0
fast path always applies. Return hw->priv unconditionally on kernels
lacking wiphy->n_radio, mirroring the #else pattern already used for
mt76_get_survey() in the same commit.

Tested on 6.12.100+deb13-amd64: association completes and the link
reaches HE-MCS 11 rates.

Fixes: fe503c3 ("mt7902e: Backport down to 6.6")
Signed-off-by: Antonio Nesta <antodj94@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant