developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 1 | From 6cb2b319acc161e61dd875536bb2c8ee86efcad8 Mon Sep 17 00:00:00 2001 |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 2 | From: Evelyn Tsai <evelyn.tsai@mediatek.com> |
| 3 | Date: Sat, 29 Jul 2023 04:53:47 +0800 |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 4/7] wifi: mt76: mt7915: fix txpower issues |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 5 | |
| 6 | --- |
| 7 | eeprom.c | 4 ++-- |
| 8 | mac80211.c | 2 +- |
| 9 | mt7915/debugfs.c | 48 ++++++++++++++++++++++++++---------------------- |
| 10 | mt7915/init.c | 2 +- |
developer | f0fd705 | 2023-08-14 20:23:42 +0800 | [diff] [blame] | 11 | mt7915/main.c | 1 + |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 12 | mt7915/mcu.h | 2 +- |
developer | f0fd705 | 2023-08-14 20:23:42 +0800 | [diff] [blame] | 13 | 6 files changed, 32 insertions(+), 27 deletions(-) |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 14 | |
| 15 | diff --git a/eeprom.c b/eeprom.c |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 16 | index 2558788..750e031 100644 |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 17 | --- a/eeprom.c |
| 18 | +++ b/eeprom.c |
developer | f0fd705 | 2023-08-14 20:23:42 +0800 | [diff] [blame] | 19 | @@ -338,7 +338,7 @@ s8 mt76_get_rate_power_limits(struct mt76_phy *phy, |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 20 | u32 ru_rates = ARRAY_SIZE(dest->ru[0]); |
| 21 | char band; |
| 22 | size_t len; |
| 23 | - s8 max_power = 0; |
| 24 | + s8 max_power = -127; |
| 25 | s8 txs_delta; |
| 26 | |
| 27 | if (!mcs_rates) |
developer | f0fd705 | 2023-08-14 20:23:42 +0800 | [diff] [blame] | 28 | @@ -376,7 +376,7 @@ s8 mt76_get_rate_power_limits(struct mt76_phy *phy, |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 29 | if (!np) |
| 30 | return target_power; |
| 31 | |
| 32 | - txs_delta = mt76_get_txs_delta(np, hweight8(phy->antenna_mask)); |
| 33 | + txs_delta = mt76_get_txs_delta(np, hweight16(phy->chainmask)); |
| 34 | |
| 35 | val = mt76_get_of_array(np, "rates-cck", &len, ARRAY_SIZE(dest->cck)); |
| 36 | mt76_apply_array_limit(dest->cck, ARRAY_SIZE(dest->cck), val, |
| 37 | diff --git a/mac80211.c b/mac80211.c |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 38 | index 12fcb2b..aaaf6a9 100644 |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 39 | --- a/mac80211.c |
| 40 | +++ b/mac80211.c |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 41 | @@ -1538,7 +1538,7 @@ int mt76_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 42 | int *dbm) |
| 43 | { |
| 44 | struct mt76_phy *phy = hw->priv; |
| 45 | - int n_chains = hweight8(phy->antenna_mask); |
| 46 | + int n_chains = hweight16(phy->chainmask); |
| 47 | int delta = mt76_tx_power_nss_delta(n_chains); |
| 48 | |
| 49 | *dbm = DIV_ROUND_UP(phy->txpower_cur + delta, 2); |
| 50 | diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 51 | index 6c3696c..93e549c 100644 |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 52 | --- a/mt7915/debugfs.c |
| 53 | +++ b/mt7915/debugfs.c |
| 54 | @@ -950,9 +950,9 @@ mt7915_xmit_queues_show(struct seq_file *file, void *data) |
| 55 | |
| 56 | DEFINE_SHOW_ATTRIBUTE(mt7915_xmit_queues); |
| 57 | |
| 58 | -#define mt7915_txpower_puts(rate) \ |
| 59 | +#define mt7915_txpower_puts(rate, _len) \ |
| 60 | ({ \ |
| 61 | - len += scnprintf(buf + len, sz - len, "%-16s:", #rate " (TMAC)"); \ |
| 62 | + len += scnprintf(buf + len, sz - len, "%-*s:", _len, #rate " (TMAC)"); \ |
| 63 | for (i = 0; i < mt7915_sku_group_len[SKU_##rate]; i++, offs++) \ |
| 64 | len += scnprintf(buf + len, sz - len, " %6d", txpwr[offs]); \ |
| 65 | len += scnprintf(buf + len, sz - len, "\n"); \ |
| 66 | @@ -994,43 +994,47 @@ mt7915_rate_txpower_get(struct file *file, char __user *user_buf, |
| 67 | len += scnprintf(buf + len, sz - len, |
| 68 | "\nPhy%d Tx power table (channel %d)\n", |
| 69 | phy != &dev->phy, phy->mt76->chandef.chan->hw_value); |
| 70 | - len += scnprintf(buf + len, sz - len, "%-16s %6s %6s %6s %6s\n", |
| 71 | + len += scnprintf(buf + len, sz - len, "%-23s %6s %6s %6s %6s\n", |
| 72 | " ", "1m", "2m", "5m", "11m"); |
| 73 | - mt7915_txpower_puts(CCK); |
| 74 | + mt7915_txpower_puts(CCK, 23); |
| 75 | |
| 76 | len += scnprintf(buf + len, sz - len, |
| 77 | - "%-16s %6s %6s %6s %6s %6s %6s %6s %6s\n", |
| 78 | + "%-23s %6s %6s %6s %6s %6s %6s %6s %6s\n", |
| 79 | " ", "6m", "9m", "12m", "18m", "24m", "36m", "48m", |
| 80 | "54m"); |
| 81 | - mt7915_txpower_puts(OFDM); |
| 82 | + mt7915_txpower_puts(OFDM, 23); |
| 83 | |
| 84 | len += scnprintf(buf + len, sz - len, |
| 85 | - "%-16s %6s %6s %6s %6s %6s %6s %6s %6s\n", |
| 86 | + "%-23s %6s %6s %6s %6s %6s %6s %6s %6s\n", |
| 87 | " ", "mcs0", "mcs1", "mcs2", "mcs3", "mcs4", |
| 88 | "mcs5", "mcs6", "mcs7"); |
| 89 | - mt7915_txpower_puts(HT_BW20); |
| 90 | + mt7915_txpower_puts(HT_BW20, 23); |
| 91 | |
| 92 | len += scnprintf(buf + len, sz - len, |
| 93 | - "%-16s %6s %6s %6s %6s %6s %6s %6s %6s %6s\n", |
| 94 | + "%-23s %6s %6s %6s %6s %6s %6s %6s %6s %6s\n", |
| 95 | " ", "mcs0", "mcs1", "mcs2", "mcs3", "mcs4", "mcs5", |
| 96 | "mcs6", "mcs7", "mcs32"); |
| 97 | - mt7915_txpower_puts(HT_BW40); |
| 98 | + mt7915_txpower_puts(HT_BW40, 23); |
| 99 | |
| 100 | len += scnprintf(buf + len, sz - len, |
| 101 | - "%-16s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s\n", |
| 102 | + "%-23s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s\n", |
| 103 | " ", "mcs0", "mcs1", "mcs2", "mcs3", "mcs4", "mcs5", |
| 104 | "mcs6", "mcs7", "mcs8", "mcs9", "mcs10", "mcs11"); |
| 105 | - mt7915_txpower_puts(VHT_BW20); |
| 106 | - mt7915_txpower_puts(VHT_BW40); |
| 107 | - mt7915_txpower_puts(VHT_BW80); |
| 108 | - mt7915_txpower_puts(VHT_BW160); |
| 109 | - mt7915_txpower_puts(HE_RU26); |
| 110 | - mt7915_txpower_puts(HE_RU52); |
| 111 | - mt7915_txpower_puts(HE_RU106); |
| 112 | - mt7915_txpower_puts(HE_RU242); |
| 113 | - mt7915_txpower_puts(HE_RU484); |
| 114 | - mt7915_txpower_puts(HE_RU996); |
| 115 | - mt7915_txpower_puts(HE_RU2x996); |
| 116 | + mt7915_txpower_puts(VHT_BW20, 23); |
| 117 | + mt7915_txpower_puts(VHT_BW40, 23); |
| 118 | + mt7915_txpower_puts(VHT_BW80, 23); |
| 119 | + mt7915_txpower_puts(VHT_BW160, 23); |
| 120 | + mt7915_txpower_puts(HE_RU26, 23); |
| 121 | + mt7915_txpower_puts(HE_RU52, 23); |
| 122 | + mt7915_txpower_puts(HE_RU106, 23); |
| 123 | + len += scnprintf(buf + len, sz - len, "BW20/"); |
| 124 | + mt7915_txpower_puts(HE_RU242, 18); |
| 125 | + len += scnprintf(buf + len, sz - len, "BW40/"); |
| 126 | + mt7915_txpower_puts(HE_RU484, 18); |
| 127 | + len += scnprintf(buf + len, sz - len, "BW80/"); |
| 128 | + mt7915_txpower_puts(HE_RU996, 18); |
| 129 | + len += scnprintf(buf + len, sz - len, "BW160/"); |
| 130 | + mt7915_txpower_puts(HE_RU2x996, 17); |
| 131 | |
| 132 | reg = is_mt7915(&dev->mt76) ? MT_WF_PHY_TPC_CTRL_STAT(band) : |
| 133 | MT_WF_PHY_TPC_CTRL_STAT_MT7916(band); |
| 134 | diff --git a/mt7915/init.c b/mt7915/init.c |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 135 | index 294876a..d8fd8d6 100644 |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 136 | --- a/mt7915/init.c |
| 137 | +++ b/mt7915/init.c |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 138 | @@ -278,7 +278,7 @@ static void mt7915_led_set_brightness(struct led_classdev *led_cdev, |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 139 | void mt7915_init_txpower(struct mt7915_dev *dev, |
| 140 | struct ieee80211_supported_band *sband) |
| 141 | { |
| 142 | - int i, n_chains = hweight8(dev->mphy.antenna_mask); |
| 143 | + int i, n_chains = hweight16(dev->mphy.chainmask); |
| 144 | int nss_delta = mt76_tx_power_nss_delta(n_chains); |
| 145 | int pwr_delta = mt7915_eeprom_get_power_delta(dev, sband->band); |
| 146 | struct mt76_power_limits limits; |
| 147 | diff --git a/mt7915/main.c b/mt7915/main.c |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 148 | index 449c2ee..96336b6 100644 |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 149 | --- a/mt7915/main.c |
| 150 | +++ b/mt7915/main.c |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 151 | @@ -1075,6 +1075,7 @@ mt7915_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant) |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 152 | mt76_set_stream_caps(phy->mt76, true); |
| 153 | mt7915_set_stream_vht_txbf_caps(phy); |
| 154 | mt7915_set_stream_he_caps(phy); |
| 155 | + mt7915_mcu_set_txpower_sku(phy); |
| 156 | |
| 157 | mutex_unlock(&dev->mt76.mutex); |
| 158 | |
| 159 | diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 160 | index aebacc7..8f36546 100644 |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 161 | --- a/mt7915/mcu.h |
| 162 | +++ b/mt7915/mcu.h |
| 163 | @@ -574,7 +574,7 @@ static inline s8 |
| 164 | mt7915_get_power_bound(struct mt7915_phy *phy, s8 txpower) |
| 165 | { |
| 166 | struct mt76_phy *mphy = phy->mt76; |
| 167 | - int n_chains = hweight8(mphy->antenna_mask); |
| 168 | + int n_chains = hweight16(mphy->chainmask); |
| 169 | |
| 170 | txpower = mt76_get_sar_power(mphy, mphy->chandef.chan, txpower * 2); |
| 171 | txpower -= mt76_tx_power_nss_delta(n_chains); |
| 172 | -- |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 173 | 2.18.0 |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 174 | |