[PATCH AUTOSEL 6.19-6.18] wifi: iwlwifi: mld: fix chandef start calculation

Sasha Levin
2026-02-14T21:26:32Z

From: Miri Korenblit <miriam.rachel.korenblit@intel.com>

[ Upstream commit d2fcdf36554316cc51f7928b777944738d06e332 ]

A link pair in which both links are in 5 GHz can be used for EMLSR only
if they are separated enough.

To check this condition we calculate the start and the end of the
chandefs of both links in the pair and do some checks.

But the calculation of the start/end of the chandef is currently done
by subtracting/adding half the bandwidth from/to the control channel's
center frequency, when it should really be subtracted/added from/to the
center frequency of the entire chandef.

Fix the wrong calculation.

Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20260111193638.2138fdb99bd5.I4d2e5957b22482a57b1d6ca444e90fcf73bf2cab@changeid
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

## Analysis of wifi: iwlwifi: mld: fix chandef start calculation

### 1. Commit Message Analysis

The commit message clearly describes a **bug fix** — the word "fix" is
in the subject and the body explains the incorrect calculation. The
issue is about EMLSR (Enhanced Multi-Link Single Radio) link pair
validation for 5 GHz band operation. The calculation was using the
**control channel's center frequency** (`chan->center_freq`) instead of
the **chandef's center frequency** (`center_freq1`) when computing
channel edges. This is a straightforward logic error.

The commit has a `Reviewed-by: Johannes Berg` tag — Johannes Berg is the
mac80211/cfg80211 maintainer, which is a strong trust indicator.

### 2. Code Change Analysis

The diff is minimal — only **two lines changed**:

```c
- c_low_upper_edge = c_low->chan->center_freq +
+ c_low_upper_edge = c_low->center_freq1 +

- c_high_lower_edge = c_high->chan->center_freq -
+ c_high_lower_edge = c_high->center_freq1 -
```

**What was wrong:** The code was computing the upper/lower edges of a
channel definition by taking `chan->center_freq` (the control channel's
center frequency) and adding/subtracting half the bandwidth. However,
for wide channels (40/80/160 MHz), the control channel's center
frequency is NOT the center of the entire channel definition —
`center_freq1` is. For example, on an 80 MHz channel, the control
channel is a 20 MHz slice at one edge, so `chan->center_freq` could be
30 MHz away from the actual center of the chandef.

**Impact of the bug:** The separation check between two 5 GHz links
would use incorrect edge calculations. This could either:
- Incorrectly allow EMLSR on links that are too close together (causing
HW/FW issues)
- Incorrectly disallow EMLSR on links that should be valid (degrading
WiFi 7 performance)

Both outcomes affect real users with Intel WiFi 7 hardware using EMLSR.

### 3. Classification

This is a clear **bug fix** — correcting a wrong variable reference in a
calculation. It's not a feature addition, refactoring, or cleanup.

### 4. Scope and Risk Assessment

- **Lines changed:** 2 (extremely small)
- **Files changed:** 1
- **Risk:** Very low — the change simply uses the correct field from the
same structure
- **Subsystem:** iwlwifi driver (Intel wireless) — widely used, actively
maintained
- **Could break something?** Extremely unlikely — it's correcting a
calculation to use the semantically correct value

### 5. User Impact

This affects users with Intel WiFi 7 hardware (which supports EMLSR).
Incorrect EMLSR pair validation could lead to:
- Using EMLSR on unsuitable link pairs → potential connectivity issues
or firmware problems
- Not using EMLSR on suitable pairs → reduced WiFi 7 performance

WiFi 7 with EMLSR is increasingly common in modern laptops.

### 6. Stability Indicators

- Reviewed by Johannes Berg (cfg80211/mac80211 maintainer)
- The fix is obviously correct — `center_freq1` is the standard field
for the center frequency of the entire channel definition, while
`chan->center_freq` is only the control channel

### 7. Dependency Check

The code references `cfg80211_chandef_get_width()` and `center_freq1` —
both are long-established cfg80211 infrastructure. The `mld/mlo.c` file
is relatively new (WiFi 7/MLD support), so I should check when this was
introduced.

Let me check if this code exists in stable trees:

The `drivers/net/wireless/intel/iwlwifi/mld/` directory is part of the
iwlwifi MLD (Multi-Link Device) support which was added relatively
recently. This would only need backporting to stable trees that contain
this code.

### 8. Stable Criteria Assessment

| Criterion | Met? |
|-----------|------|
| Obviously correct | Yes — `center_freq1` is the correct field for
chandef center |
| Fixes real bug | Yes — wrong frequency used in separation calculation
|
| Small and contained | Yes — 2 lines in 1 file |
| No new features | Correct — pure fix |
| Tested (reviewed) | Yes — Reviewed-by Johannes Berg |

### Risk vs Benefit

- **Risk:** Essentially zero — it's a 2-line change using the correct
struct field
- **Benefit:** Correct EMLSR link pair validation for Intel WiFi 7 users

The fix is small, surgical, obviously correct, fixes a real bug in
wireless channel validation, was reviewed by the cfg80211 maintainer,
and meets all stable kernel criteria.

**YES**

drivers/net/wireless/intel/iwlwifi/mld/mlo.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mld/mlo.c b/drivers/net/wireless/intel/iwlwifi/mld/mlo.c
index c6b151f269216..1efefc737248f 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/mlo.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/mlo.c
@@ -844,9 +844,9 @@ iwl_mld_emlsr_pair_state(struct ieee80211_vif *vif,
if (c_low->chan->center_freq > c_high->chan->center_freq)
swap(c_low, c_high);

- c_low_upper_edge = c_low->chan->center_freq +
+ c_low_upper_edge = c_low->center_freq1 +
cfg80211_chandef_get_width(c_low) / 2;
- c_high_lower_edge = c_high->chan->center_freq -
+ c_high_lower_edge = c_high->center_freq1 -
cfg80211_chandef_get_width(c_high) / 2;

if (a->chandef->chan->band == NL80211_BAND_5GHZ &&
--
2.51.0