* [PATCH wireless] wifi: mt76: mt7915: add module param to select 5 GHz or 6 GHz on MT7916
@ 2024-10-10 8:38 Felix Fietkau
2024-10-10 14:34 ` Ben Greear
0 siblings, 1 reply; 3+ messages in thread
From: Felix Fietkau @ 2024-10-10 8:38 UTC (permalink / raw)
To: linux-wireless; +Cc: kvalo, Steven Liu, Evelyn Tsai, Paul, Shayne Chen
From: Shayne Chen <shayne.chen@mediatek.com>
Due to a limitation in available memory, the MT7916 firmware can only
handle either 5 GHz or 6 GHz at a time. It does not support runtime
switching without a full restart.
On older firmware, this accidentally worked to some degree due to missing
checks, but couldn't be supported properly, because it left the 6 GHz
channels uncalibrated.
Newer firmware refuses to start on either band if the passed EEPROM
data indicates support for both.
Deal with this limitation by using a module parameter to specify the
preferred band in case both are supported.
Fixes: b4d093e321bd ("mt76: mt7915: add 6 GHz support")
Cc: stable@vger.kernel.org
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../wireless/mediatek/mt76/mt7915/eeprom.c | 21 +++++++++++++++++--
.../net/wireless/mediatek/mt76/mt7915/init.c | 4 ++--
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c
index bfdbc15abaa9..928e0b07a9bf 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c
@@ -2,9 +2,14 @@
/* Copyright (C) 2020 MediaTek Inc. */
#include <linux/firmware.h>
+#include <linux/moduleparam.h>
#include "mt7915.h"
#include "eeprom.h"
+static bool enable_6ghz;
+module_param(enable_6ghz, bool, 0644);
+MODULE_PARM_DESC(enable_6ghz, "Enable 6 GHz instead of 5 GHz on hardware that supports both");
+
static int mt7915_eeprom_load_precal(struct mt7915_dev *dev)
{
struct mt76_dev *mdev = &dev->mt76;
@@ -170,8 +175,20 @@ static void mt7915_eeprom_parse_band_config(struct mt7915_phy *phy)
phy->mt76->cap.has_6ghz = true;
return;
case MT_EE_V2_BAND_SEL_5GHZ_6GHZ:
- phy->mt76->cap.has_5ghz = true;
- phy->mt76->cap.has_6ghz = true;
+ if (enable_6ghz) {
+ phy->mt76->cap.has_6ghz = true;
+ u8p_replace_bits(&eeprom[MT_EE_WIFI_CONF + band],
+ MT_EE_V2_BAND_SEL_6GHZ,
+ MT_EE_WIFI_CONF0_BAND_SEL);
+ } else {
+ phy->mt76->cap.has_5ghz = true;
+ u8p_replace_bits(&eeprom[MT_EE_WIFI_CONF + band],
+ MT_EE_V2_BAND_SEL_5GHZ,
+ MT_EE_WIFI_CONF0_BAND_SEL);
+ }
+ /* force to buffer mode */
+ dev->flash_mode = true;
+
return;
default:
phy->mt76->cap.has_2ghz = true;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
index 6bef96e3d2a3..f82216d1bda0 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
@@ -1239,14 +1239,14 @@ int mt7915_register_device(struct mt7915_dev *dev)
if (ret)
goto unreg_dev;
- ieee80211_queue_work(mt76_hw(dev), &dev->init_work);
-
if (phy2) {
ret = mt7915_register_ext_phy(dev, phy2);
if (ret)
goto unreg_thermal;
}
+ ieee80211_queue_work(mt76_hw(dev), &dev->init_work);
+
dev->recovery.hw_init_done = true;
ret = mt7915_init_debugfs(&dev->phy);
--
2.46.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH wireless] wifi: mt76: mt7915: add module param to select 5 GHz or 6 GHz on MT7916
2024-10-10 8:38 [PATCH wireless] wifi: mt76: mt7915: add module param to select 5 GHz or 6 GHz on MT7916 Felix Fietkau
@ 2024-10-10 14:34 ` Ben Greear
2024-10-12 14:27 ` Felix Fietkau
0 siblings, 1 reply; 3+ messages in thread
From: Ben Greear @ 2024-10-10 14:34 UTC (permalink / raw)
To: Felix Fietkau, linux-wireless
Cc: kvalo, Steven Liu, Evelyn Tsai, Paul, Shayne Chen
On 10/10/24 01:38, Felix Fietkau wrote:
> From: Shayne Chen <shayne.chen@mediatek.com>
>
> Due to a limitation in available memory, the MT7916 firmware can only
> handle either 5 GHz or 6 GHz at a time. It does not support runtime
> switching without a full restart.
Can this also be implemented so that we can change the module parameter,
force the radio to do a hard reset, and change bands that way, without
having to do a reboot?
Thanks,
Ben
>
> On older firmware, this accidentally worked to some degree due to missing
> checks, but couldn't be supported properly, because it left the 6 GHz
> channels uncalibrated.
> Newer firmware refuses to start on either band if the passed EEPROM
> data indicates support for both.
>
> Deal with this limitation by using a module parameter to specify the
> preferred band in case both are supported.
>
> Fixes: b4d093e321bd ("mt76: mt7915: add 6 GHz support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
> ---
> .../wireless/mediatek/mt76/mt7915/eeprom.c | 21 +++++++++++++++++--
> .../net/wireless/mediatek/mt76/mt7915/init.c | 4 ++--
> 2 files changed, 21 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c
> index bfdbc15abaa9..928e0b07a9bf 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c
> @@ -2,9 +2,14 @@
> /* Copyright (C) 2020 MediaTek Inc. */
>
> #include <linux/firmware.h>
> +#include <linux/moduleparam.h>
> #include "mt7915.h"
> #include "eeprom.h"
>
> +static bool enable_6ghz;
> +module_param(enable_6ghz, bool, 0644);
> +MODULE_PARM_DESC(enable_6ghz, "Enable 6 GHz instead of 5 GHz on hardware that supports both");
> +
> static int mt7915_eeprom_load_precal(struct mt7915_dev *dev)
> {
> struct mt76_dev *mdev = &dev->mt76;
> @@ -170,8 +175,20 @@ static void mt7915_eeprom_parse_band_config(struct mt7915_phy *phy)
> phy->mt76->cap.has_6ghz = true;
> return;
> case MT_EE_V2_BAND_SEL_5GHZ_6GHZ:
> - phy->mt76->cap.has_5ghz = true;
> - phy->mt76->cap.has_6ghz = true;
> + if (enable_6ghz) {
> + phy->mt76->cap.has_6ghz = true;
> + u8p_replace_bits(&eeprom[MT_EE_WIFI_CONF + band],
> + MT_EE_V2_BAND_SEL_6GHZ,
> + MT_EE_WIFI_CONF0_BAND_SEL);
> + } else {
> + phy->mt76->cap.has_5ghz = true;
> + u8p_replace_bits(&eeprom[MT_EE_WIFI_CONF + band],
> + MT_EE_V2_BAND_SEL_5GHZ,
> + MT_EE_WIFI_CONF0_BAND_SEL);
> + }
> + /* force to buffer mode */
> + dev->flash_mode = true;
> +
> return;
> default:
> phy->mt76->cap.has_2ghz = true;
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
> index 6bef96e3d2a3..f82216d1bda0 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
> @@ -1239,14 +1239,14 @@ int mt7915_register_device(struct mt7915_dev *dev)
> if (ret)
> goto unreg_dev;
>
> - ieee80211_queue_work(mt76_hw(dev), &dev->init_work);
> -
> if (phy2) {
> ret = mt7915_register_ext_phy(dev, phy2);
> if (ret)
> goto unreg_thermal;
> }
>
> + ieee80211_queue_work(mt76_hw(dev), &dev->init_work);
> +
> dev->recovery.hw_init_done = true;
>
> ret = mt7915_init_debugfs(&dev->phy);
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH wireless] wifi: mt76: mt7915: add module param to select 5 GHz or 6 GHz on MT7916
2024-10-10 14:34 ` Ben Greear
@ 2024-10-12 14:27 ` Felix Fietkau
0 siblings, 0 replies; 3+ messages in thread
From: Felix Fietkau @ 2024-10-12 14:27 UTC (permalink / raw)
To: Ben Greear, linux-wireless
Cc: kvalo, Steven Liu, Evelyn Tsai, Paul, Shayne Chen
On 10.10.24 16:34, Ben Greear wrote:
> On 10/10/24 01:38, Felix Fietkau wrote:
>> From: Shayne Chen <shayne.chen@mediatek.com>
>>
>> Due to a limitation in available memory, the MT7916 firmware can only
>> handle either 5 GHz or 6 GHz at a time. It does not support runtime
>> switching without a full restart.
>
> Can this also be implemented so that we can change the module parameter,
> force the radio to do a hard reset, and change bands that way, without
> having to do a reboot?
It probably can be, but that requires more work and testing. I'd prefer
to do that separately at some point in a follow-up patch.
- Felix
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-12 14:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-10 8:38 [PATCH wireless] wifi: mt76: mt7915: add module param to select 5 GHz or 6 GHz on MT7916 Felix Fietkau
2024-10-10 14:34 ` Ben Greear
2024-10-12 14:27 ` Felix Fietkau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox