| From 2016d1f146684a17c813c957b5c8bd51bd25b47f Mon Sep 17 00:00:00 2001 |
| From: Evelyn Tsai <evelyn.tsai@mediatek.com> |
| Date: Sat, 29 Jul 2023 04:53:47 +0800 |
| Subject: [PATCH] wifi: mt76: mt7915: fix txpower issues |
| |
| --- |
| eeprom.c | 4 ++-- |
| mac80211.c | 2 +- |
| mt7915/debugfs.c | 48 ++++++++++++++++++++++++++---------------------- |
| mt7915/init.c | 2 +- |
| mt7915/main.c | 3 ++- |
| mt7915/mcu.h | 2 +- |
| 6 files changed, 33 insertions(+), 28 deletions(-) |
| |
| diff --git a/eeprom.c b/eeprom.c |
| index ea54b7a..f9f048c 100644 |
| --- a/eeprom.c |
| +++ b/eeprom.c |
| @@ -283,7 +283,7 @@ s8 mt76_get_rate_power_limits(struct mt76_phy *phy, |
| u32 ru_rates = ARRAY_SIZE(dest->ru[0]); |
| char band; |
| size_t len; |
| - s8 max_power = 0; |
| + s8 max_power = -127; |
| s8 txs_delta; |
| |
| if (!mcs_rates) |
| @@ -321,7 +321,7 @@ s8 mt76_get_rate_power_limits(struct mt76_phy *phy, |
| if (!np) |
| return target_power; |
| |
| - txs_delta = mt76_get_txs_delta(np, hweight8(phy->antenna_mask)); |
| + txs_delta = mt76_get_txs_delta(np, hweight16(phy->chainmask)); |
| |
| val = mt76_get_of_array(np, "rates-cck", &len, ARRAY_SIZE(dest->cck)); |
| mt76_apply_array_limit(dest->cck, ARRAY_SIZE(dest->cck), val, |
| diff --git a/mac80211.c b/mac80211.c |
| index 8540738..0a08161 100644 |
| --- a/mac80211.c |
| +++ b/mac80211.c |
| @@ -1486,7 +1486,7 @@ int mt76_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| int *dbm) |
| { |
| struct mt76_phy *phy = hw->priv; |
| - int n_chains = hweight8(phy->antenna_mask); |
| + int n_chains = hweight16(phy->chainmask); |
| int delta = mt76_tx_power_nss_delta(n_chains); |
| |
| *dbm = DIV_ROUND_UP(phy->txpower_cur + delta, 2); |
| diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c |
| index 6c3696c..93e549c 100644 |
| --- a/mt7915/debugfs.c |
| +++ b/mt7915/debugfs.c |
| @@ -950,9 +950,9 @@ mt7915_xmit_queues_show(struct seq_file *file, void *data) |
| |
| DEFINE_SHOW_ATTRIBUTE(mt7915_xmit_queues); |
| |
| -#define mt7915_txpower_puts(rate) \ |
| +#define mt7915_txpower_puts(rate, _len) \ |
| ({ \ |
| - len += scnprintf(buf + len, sz - len, "%-16s:", #rate " (TMAC)"); \ |
| + len += scnprintf(buf + len, sz - len, "%-*s:", _len, #rate " (TMAC)"); \ |
| for (i = 0; i < mt7915_sku_group_len[SKU_##rate]; i++, offs++) \ |
| len += scnprintf(buf + len, sz - len, " %6d", txpwr[offs]); \ |
| len += scnprintf(buf + len, sz - len, "\n"); \ |
| @@ -994,43 +994,47 @@ mt7915_rate_txpower_get(struct file *file, char __user *user_buf, |
| len += scnprintf(buf + len, sz - len, |
| "\nPhy%d Tx power table (channel %d)\n", |
| phy != &dev->phy, phy->mt76->chandef.chan->hw_value); |
| - len += scnprintf(buf + len, sz - len, "%-16s %6s %6s %6s %6s\n", |
| + len += scnprintf(buf + len, sz - len, "%-23s %6s %6s %6s %6s\n", |
| " ", "1m", "2m", "5m", "11m"); |
| - mt7915_txpower_puts(CCK); |
| + mt7915_txpower_puts(CCK, 23); |
| |
| len += scnprintf(buf + len, sz - len, |
| - "%-16s %6s %6s %6s %6s %6s %6s %6s %6s\n", |
| + "%-23s %6s %6s %6s %6s %6s %6s %6s %6s\n", |
| " ", "6m", "9m", "12m", "18m", "24m", "36m", "48m", |
| "54m"); |
| - mt7915_txpower_puts(OFDM); |
| + mt7915_txpower_puts(OFDM, 23); |
| |
| len += scnprintf(buf + len, sz - len, |
| - "%-16s %6s %6s %6s %6s %6s %6s %6s %6s\n", |
| + "%-23s %6s %6s %6s %6s %6s %6s %6s %6s\n", |
| " ", "mcs0", "mcs1", "mcs2", "mcs3", "mcs4", |
| "mcs5", "mcs6", "mcs7"); |
| - mt7915_txpower_puts(HT_BW20); |
| + mt7915_txpower_puts(HT_BW20, 23); |
| |
| len += scnprintf(buf + len, sz - len, |
| - "%-16s %6s %6s %6s %6s %6s %6s %6s %6s %6s\n", |
| + "%-23s %6s %6s %6s %6s %6s %6s %6s %6s %6s\n", |
| " ", "mcs0", "mcs1", "mcs2", "mcs3", "mcs4", "mcs5", |
| "mcs6", "mcs7", "mcs32"); |
| - mt7915_txpower_puts(HT_BW40); |
| + mt7915_txpower_puts(HT_BW40, 23); |
| |
| len += scnprintf(buf + len, sz - len, |
| - "%-16s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s\n", |
| + "%-23s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s\n", |
| " ", "mcs0", "mcs1", "mcs2", "mcs3", "mcs4", "mcs5", |
| "mcs6", "mcs7", "mcs8", "mcs9", "mcs10", "mcs11"); |
| - mt7915_txpower_puts(VHT_BW20); |
| - mt7915_txpower_puts(VHT_BW40); |
| - mt7915_txpower_puts(VHT_BW80); |
| - mt7915_txpower_puts(VHT_BW160); |
| - mt7915_txpower_puts(HE_RU26); |
| - mt7915_txpower_puts(HE_RU52); |
| - mt7915_txpower_puts(HE_RU106); |
| - mt7915_txpower_puts(HE_RU242); |
| - mt7915_txpower_puts(HE_RU484); |
| - mt7915_txpower_puts(HE_RU996); |
| - mt7915_txpower_puts(HE_RU2x996); |
| + mt7915_txpower_puts(VHT_BW20, 23); |
| + mt7915_txpower_puts(VHT_BW40, 23); |
| + mt7915_txpower_puts(VHT_BW80, 23); |
| + mt7915_txpower_puts(VHT_BW160, 23); |
| + mt7915_txpower_puts(HE_RU26, 23); |
| + mt7915_txpower_puts(HE_RU52, 23); |
| + mt7915_txpower_puts(HE_RU106, 23); |
| + len += scnprintf(buf + len, sz - len, "BW20/"); |
| + mt7915_txpower_puts(HE_RU242, 18); |
| + len += scnprintf(buf + len, sz - len, "BW40/"); |
| + mt7915_txpower_puts(HE_RU484, 18); |
| + len += scnprintf(buf + len, sz - len, "BW80/"); |
| + mt7915_txpower_puts(HE_RU996, 18); |
| + len += scnprintf(buf + len, sz - len, "BW160/"); |
| + mt7915_txpower_puts(HE_RU2x996, 17); |
| |
| reg = is_mt7915(&dev->mt76) ? MT_WF_PHY_TPC_CTRL_STAT(band) : |
| MT_WF_PHY_TPC_CTRL_STAT_MT7916(band); |
| diff --git a/mt7915/init.c b/mt7915/init.c |
| index bcd3717..15b719f 100644 |
| --- a/mt7915/init.c |
| +++ b/mt7915/init.c |
| @@ -281,7 +281,7 @@ static void mt7915_led_set_brightness(struct led_classdev *led_cdev, |
| void mt7915_init_txpower(struct mt7915_dev *dev, |
| struct ieee80211_supported_band *sband) |
| { |
| - int i, n_chains = hweight8(dev->mphy.antenna_mask); |
| + int i, n_chains = hweight16(dev->mphy.chainmask); |
| int nss_delta = mt76_tx_power_nss_delta(n_chains); |
| int pwr_delta = mt7915_eeprom_get_power_delta(dev, sband->band); |
| struct mt76_power_limits limits; |
| diff --git a/mt7915/main.c b/mt7915/main.c |
| index 86f794f..d7dfae8 100644 |
| --- a/mt7915/main.c |
| +++ b/mt7915/main.c |
| @@ -479,7 +479,7 @@ static int mt7915_config(struct ieee80211_hw *hw, u32 changed) |
| |
| mutex_lock(&dev->mt76.mutex); |
| |
| - if (changed & IEEE80211_CONF_CHANGE_MONITOR) { |
| + if (changed & (IEEE80211_CONF_CHANGE_MONITOR | IEEE80211_CONF_CHANGE_CHANNEL)) { |
| bool enabled = !!(hw->conf.flags & IEEE80211_CONF_MONITOR); |
| bool band = phy->mt76->band_idx; |
| |
| @@ -1062,6 +1062,7 @@ mt7915_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant) |
| mt76_set_stream_caps(phy->mt76, true); |
| mt7915_set_stream_vht_txbf_caps(phy); |
| mt7915_set_stream_he_caps(phy); |
| + mt7915_mcu_set_txpower_sku(phy); |
| |
| mutex_unlock(&dev->mt76.mutex); |
| |
| diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
| index aebacc7..8f36546 100644 |
| --- a/mt7915/mcu.h |
| +++ b/mt7915/mcu.h |
| @@ -574,7 +574,7 @@ static inline s8 |
| mt7915_get_power_bound(struct mt7915_phy *phy, s8 txpower) |
| { |
| struct mt76_phy *mphy = phy->mt76; |
| - int n_chains = hweight8(mphy->antenna_mask); |
| + int n_chains = hweight16(mphy->chainmask); |
| |
| txpower = mt76_get_sar_power(mphy, mphy->chandef.chan, txpower * 2); |
| txpower -= mt76_tx_power_nss_delta(n_chains); |
| -- |
| 2.18.0 |
| |