linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH wireless] wifi: mt76: mt76x02: fix MT76x0 external LNA gain handling
@ 2023-09-19 19:47 Felix Fietkau
  2023-09-20  3:38 ` Kalle Valo
  2023-09-22  7:28 ` Kalle Valo
  0 siblings, 2 replies; 3+ messages in thread
From: Felix Fietkau @ 2023-09-19 19:47 UTC (permalink / raw)
  To: linux-wireless; +Cc: kvalo, Shiji Yang

On MT76x0, LNA gain should be applied for both external and internal LNA.
On MT76x2, LNA gain should be treated as 0 for external LNA.
Move the LNA type based logic to mt76x2 in order to fix mt76x0.

Fixes: 2daa67588f34 ("mt76x0: unify lna_gain parsing")
Reported-by: Shiji Yang <yangshiji66@outlook.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.c |  7 -------
 drivers/net/wireless/mediatek/mt76/mt76x2/eeprom.c  | 13 +++++++++++--
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.c b/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.c
index 0acabba2d1a5..5d402cf2951c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.c
@@ -131,15 +131,8 @@ u8 mt76x02_get_lna_gain(struct mt76x02_dev *dev,
 			s8 *lna_2g, s8 *lna_5g,
 			struct ieee80211_channel *chan)
 {
-	u16 val;
 	u8 lna;
 
-	val = mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_1);
-	if (val & MT_EE_NIC_CONF_1_LNA_EXT_2G)
-		*lna_2g = 0;
-	if (val & MT_EE_NIC_CONF_1_LNA_EXT_5G)
-		memset(lna_5g, 0, sizeof(s8) * 3);
-
 	if (chan->band == NL80211_BAND_2GHZ)
 		lna = *lna_2g;
 	else if (chan->hw_value <= 64)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt76x2/eeprom.c
index d5809408d1d3..8c01855885ce 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/eeprom.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/eeprom.c
@@ -256,7 +256,8 @@ void mt76x2_read_rx_gain(struct mt76x02_dev *dev)
 	struct ieee80211_channel *chan = dev->mphy.chandef.chan;
 	int channel = chan->hw_value;
 	s8 lna_5g[3], lna_2g;
-	u8 lna;
+	bool use_lna;
+	u8 lna = 0;
 	u16 val;
 
 	if (chan->band == NL80211_BAND_2GHZ)
@@ -275,7 +276,15 @@ void mt76x2_read_rx_gain(struct mt76x02_dev *dev)
 	dev->cal.rx.mcu_gain |= (lna_5g[1] & 0xff) << 16;
 	dev->cal.rx.mcu_gain |= (lna_5g[2] & 0xff) << 24;
 
-	lna = mt76x02_get_lna_gain(dev, &lna_2g, lna_5g, chan);
+	val = mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_1);
+	if (chan->band == NL80211_BAND_2GHZ)
+		use_lna = !(val & MT_EE_NIC_CONF_1_LNA_EXT_2G);
+	else
+		use_lna = !(val & MT_EE_NIC_CONF_1_LNA_EXT_5G);
+
+	if (use_lna)
+		lna = mt76x02_get_lna_gain(dev, &lna_2g, lna_5g, chan);
+
 	dev->cal.rx.lna_gain = mt76x02_sign_extend(lna, 8);
 }
 EXPORT_SYMBOL_GPL(mt76x2_read_rx_gain);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH wireless] wifi: mt76: mt76x02: fix MT76x0 external LNA gain handling
  2023-09-19 19:47 [PATCH wireless] wifi: mt76: mt76x02: fix MT76x0 external LNA gain handling Felix Fietkau
@ 2023-09-20  3:38 ` Kalle Valo
  2023-09-22  7:28 ` Kalle Valo
  1 sibling, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2023-09-20  3:38 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, Shiji Yang

Felix Fietkau <nbd@nbd.name> writes:

> On MT76x0, LNA gain should be applied for both external and internal LNA.
> On MT76x2, LNA gain should be treated as 0 for external LNA.
> Move the LNA type based logic to mt76x2 in order to fix mt76x0.
>
> Fixes: 2daa67588f34 ("mt76x0: unify lna_gain parsing")
> Reported-by: Shiji Yang <yangshiji66@outlook.com>
> Signed-off-by: Felix Fietkau <nbd@nbd.name>

I assigned this to me on patchwork.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH wireless] wifi: mt76: mt76x02: fix MT76x0 external LNA gain handling
  2023-09-19 19:47 [PATCH wireless] wifi: mt76: mt76x02: fix MT76x0 external LNA gain handling Felix Fietkau
  2023-09-20  3:38 ` Kalle Valo
@ 2023-09-22  7:28 ` Kalle Valo
  1 sibling, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2023-09-22  7:28 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, Shiji Yang

Felix Fietkau <nbd@nbd.name> wrote:

> On MT76x0, LNA gain should be applied for both external and internal LNA.
> On MT76x2, LNA gain should be treated as 0 for external LNA.
> Move the LNA type based logic to mt76x2 in order to fix mt76x0.
> 
> Fixes: 2daa67588f34 ("mt76x0: unify lna_gain parsing")
> Reported-by: Shiji Yang <yangshiji66@outlook.com>
> Signed-off-by: Felix Fietkau <nbd@nbd.name>

Patch applied to wireless.git, thanks.

684e45e120b8 wifi: mt76: mt76x02: fix MT76x0 external LNA gain handling

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20230919194747.31647-1-nbd@nbd.name/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-09-22  7:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-19 19:47 [PATCH wireless] wifi: mt76: mt76x02: fix MT76x0 external LNA gain handling Felix Fietkau
2023-09-20  3:38 ` Kalle Valo
2023-09-22  7:28 ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).