* [PATCH wireless-next] wifi: mt76: fix of_get_mac_address error handling @ 2026-04-27 5:17 Rosen Penev 2026-04-27 7:00 ` Lorenzo Bianconi 2026-06-18 21:47 ` Klara Modin 0 siblings, 2 replies; 6+ messages in thread From: Rosen Penev @ 2026-04-27 5:17 UTC (permalink / raw) To: linux-wireless Cc: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen, Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno, open list:ARM/Mediatek SoC support, moderated list:ARM/Mediatek SoC support, moderated list:ARM/Mediatek SoC support Check return value instead of is_valid_ether_addr. The latter is handled by the former. Signed-off-by: Rosen Penev <rosenp@gmail.com> --- drivers/net/wireless/mediatek/mt76/eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c index 93d91264687f..0f6ccf6ed53d 100644 --- a/drivers/net/wireless/mediatek/mt76/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c @@ -93,7 +93,7 @@ mt76_eeprom_override(struct mt76_phy *phy) if (err == -EPROBE_DEFER) return err; - if (!is_valid_ether_addr(phy->macaddr)) { + if (err) { eth_random_addr(phy->macaddr); dev_info(dev->dev, "Invalid MAC address, using random address %pM\n", -- 2.54.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH wireless-next] wifi: mt76: fix of_get_mac_address error handling 2026-04-27 5:17 [PATCH wireless-next] wifi: mt76: fix of_get_mac_address error handling Rosen Penev @ 2026-04-27 7:00 ` Lorenzo Bianconi 2026-06-18 21:47 ` Klara Modin 1 sibling, 0 replies; 6+ messages in thread From: Lorenzo Bianconi @ 2026-04-27 7:00 UTC (permalink / raw) To: Rosen Penev Cc: linux-wireless, Felix Fietkau, Ryder Lee, Shayne Chen, Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno, open list:ARM/Mediatek SoC support, moderated list:ARM/Mediatek SoC support, moderated list:ARM/Mediatek SoC support [-- Attachment #1: Type: text/plain, Size: 894 bytes --] > Check return value instead of is_valid_ether_addr. The latter is handled > by the former. > > Signed-off-by: Rosen Penev <rosenp@gmail.com> Acked-by: Lorenzo Bianconi <lorenzo@kernel.org> > --- > drivers/net/wireless/mediatek/mt76/eeprom.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c > index 93d91264687f..0f6ccf6ed53d 100644 > --- a/drivers/net/wireless/mediatek/mt76/eeprom.c > +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c > @@ -93,7 +93,7 @@ mt76_eeprom_override(struct mt76_phy *phy) > if (err == -EPROBE_DEFER) > return err; > > - if (!is_valid_ether_addr(phy->macaddr)) { > + if (err) { > eth_random_addr(phy->macaddr); > dev_info(dev->dev, > "Invalid MAC address, using random address %pM\n", > -- > 2.54.0 > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH wireless-next] wifi: mt76: fix of_get_mac_address error handling 2026-04-27 5:17 [PATCH wireless-next] wifi: mt76: fix of_get_mac_address error handling Rosen Penev 2026-04-27 7:00 ` Lorenzo Bianconi @ 2026-06-18 21:47 ` Klara Modin 2026-06-18 23:01 ` Rosen Penev 1 sibling, 1 reply; 6+ messages in thread From: Klara Modin @ 2026-06-18 21:47 UTC (permalink / raw) To: Rosen Penev Cc: linux-wireless, Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen, Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno, open list:ARM/Mediatek SoC support, moderated list:ARM/Mediatek SoC support, moderated list:ARM/Mediatek SoC support Hi, On 2026-04-26 22:17:46 -0700, Rosen Penev wrote: > Check return value instead of is_valid_ether_addr. The latter is handled > by the former. > > Signed-off-by: Rosen Penev <rosenp@gmail.com> > --- > drivers/net/wireless/mediatek/mt76/eeprom.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c > index 93d91264687f..0f6ccf6ed53d 100644 > --- a/drivers/net/wireless/mediatek/mt76/eeprom.c > +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c > @@ -93,7 +93,7 @@ mt76_eeprom_override(struct mt76_phy *phy) > if (err == -EPROBE_DEFER) > return err; > > - if (!is_valid_ether_addr(phy->macaddr)) { > + if (err) { > eth_random_addr(phy->macaddr); > dev_info(dev->dev, > "Invalid MAC address, using random address %pM\n", > -- > 2.54.0 > Recently I have started to see randomized MAC-addresses on my x86 laptop with a MT7922 and the above message printed in the kernel log. I have CONFIG_OF turned on, but since this is an ACPI system the device is not described by any device tree and the earlier of_get_mac_address() likely fails with -ENODEV. Looking at the !CONFIG_OF stub for of_get_mac_address it always returns -ENODEV, meaning this will always randomize the mac in that case too. Reverting this patch fixes the issue and the correct MAC address is used. I'm not sure if there is any case where of_get_mac_addres() could fail in a way that results in a valid MAC address but it seems unlikely to me. Regards, Klara Modin ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH wireless-next] wifi: mt76: fix of_get_mac_address error handling 2026-06-18 21:47 ` Klara Modin @ 2026-06-18 23:01 ` Rosen Penev 2026-06-18 23:51 ` Klara Modin 0 siblings, 1 reply; 6+ messages in thread From: Rosen Penev @ 2026-06-18 23:01 UTC (permalink / raw) To: Klara Modin Cc: linux-wireless, Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen, Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno, open list:ARM/Mediatek SoC support, moderated list:ARM/Mediatek SoC support, moderated list:ARM/Mediatek SoC support On Thu, Jun 18, 2026 at 2:47 PM Klara Modin <klarasmodin@gmail.com> wrote: > > Hi, > > On 2026-04-26 22:17:46 -0700, Rosen Penev wrote: > > Check return value instead of is_valid_ether_addr. The latter is handled > > by the former. > > > > Signed-off-by: Rosen Penev <rosenp@gmail.com> > > --- > > drivers/net/wireless/mediatek/mt76/eeprom.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c > > index 93d91264687f..0f6ccf6ed53d 100644 > > --- a/drivers/net/wireless/mediatek/mt76/eeprom.c > > +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c > > @@ -93,7 +93,7 @@ mt76_eeprom_override(struct mt76_phy *phy) > > if (err == -EPROBE_DEFER) > > return err; > > > > - if (!is_valid_ether_addr(phy->macaddr)) { > > + if (err) { > > eth_random_addr(phy->macaddr); > > dev_info(dev->dev, > > "Invalid MAC address, using random address %pM\n", > > -- > > 2.54.0 > > > > Recently I have started to see randomized MAC-addresses on my x86 laptop > with a MT7922 and the above message printed in the kernel log. I have > CONFIG_OF turned on, but since this is an ACPI system the device is not > described by any device tree and the earlier of_get_mac_address() likely > fails with -ENODEV. Looking at the !CONFIG_OF stub for > of_get_mac_address it always returns -ENODEV, meaning this will always > randomize the mac in that case too. IIRC, the normal device_get_mac_address supports nvmem now. Does that fix your use case? > > Reverting this patch fixes the issue and the correct MAC address is > used. I'm not sure if there is any case where of_get_mac_addres() could > fail in a way that results in a valid MAC address but it seems unlikely > to me. > > Regards, > Klara Modin ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH wireless-next] wifi: mt76: fix of_get_mac_address error handling 2026-06-18 23:01 ` Rosen Penev @ 2026-06-18 23:51 ` Klara Modin 2026-06-19 1:50 ` Rosen Penev 0 siblings, 1 reply; 6+ messages in thread From: Klara Modin @ 2026-06-18 23:51 UTC (permalink / raw) To: Rosen Penev Cc: linux-wireless, Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen, Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno, open list:ARM/Mediatek SoC support, moderated list:ARM/Mediatek SoC support, moderated list:ARM/Mediatek SoC support On 2026-06-18 16:01:45 -0700, Rosen Penev wrote: > On Thu, Jun 18, 2026 at 2:47 PM Klara Modin <klarasmodin@gmail.com> wrote: > > > > Hi, > > > > On 2026-04-26 22:17:46 -0700, Rosen Penev wrote: > > > Check return value instead of is_valid_ether_addr. The latter is handled > > > by the former. > > > > > > Signed-off-by: Rosen Penev <rosenp@gmail.com> > > > --- > > > drivers/net/wireless/mediatek/mt76/eeprom.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c > > > index 93d91264687f..0f6ccf6ed53d 100644 > > > --- a/drivers/net/wireless/mediatek/mt76/eeprom.c > > > +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c > > > @@ -93,7 +93,7 @@ mt76_eeprom_override(struct mt76_phy *phy) > > > if (err == -EPROBE_DEFER) > > > return err; > > > > > > - if (!is_valid_ether_addr(phy->macaddr)) { > > > + if (err) { > > > eth_random_addr(phy->macaddr); > > > dev_info(dev->dev, > > > "Invalid MAC address, using random address %pM\n", > > > -- > > > 2.54.0 > > > > > > > Recently I have started to see randomized MAC-addresses on my x86 laptop > > with a MT7922 and the above message printed in the kernel log. I have > > CONFIG_OF turned on, but since this is an ACPI system the device is not > > described by any device tree and the earlier of_get_mac_address() likely > > fails with -ENODEV. Looking at the !CONFIG_OF stub for > > of_get_mac_address it always returns -ENODEV, meaning this will always > > randomize the mac in that case too. > IIRC, the normal device_get_mac_address supports nvmem now. Does that > fix your use case? I tried this: diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c index b99d7452800f..243a8f2c7bda 100644 --- a/drivers/net/wireless/mediatek/mt76/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c @@ -174,10 +174,9 @@ int mt76_eeprom_override(struct mt76_phy *phy) { struct mt76_dev *dev = phy->dev; - struct device_node *np = dev->dev->of_node; int err; - err = of_get_mac_address(np, phy->macaddr); + err = device_get_mac_address(dev->dev, phy->macaddr); if (err == -EPROBE_DEFER) return err; but I still get a random MAC. > > > > Reverting this patch fixes the issue and the correct MAC address is > > used. I'm not sure if there is any case where of_get_mac_addres() could > > fail in a way that results in a valid MAC address but it seems unlikely > > to me. > > > > Regards, > > Klara Modin ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH wireless-next] wifi: mt76: fix of_get_mac_address error handling 2026-06-18 23:51 ` Klara Modin @ 2026-06-19 1:50 ` Rosen Penev 0 siblings, 0 replies; 6+ messages in thread From: Rosen Penev @ 2026-06-19 1:50 UTC (permalink / raw) To: Klara Modin, Rosen Penev Cc: linux-wireless, Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen, Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno, open list:ARM/Mediatek SoC support, moderated list:ARM/Mediatek SoC support, moderated list:ARM/Mediatek SoC support On Thu Jun 18, 2026 at 4:51 PM PDT, Klara Modin wrote: > On 2026-06-18 16:01:45 -0700, Rosen Penev wrote: >> On Thu, Jun 18, 2026 at 2:47 PM Klara Modin <klarasmodin@gmail.com> wrote: >> > >> > Hi, >> > >> > On 2026-04-26 22:17:46 -0700, Rosen Penev wrote: >> > > Check return value instead of is_valid_ether_addr. The latter is handled >> > > by the former. >> > > >> > > Signed-off-by: Rosen Penev <rosenp@gmail.com> >> > > --- >> > > drivers/net/wireless/mediatek/mt76/eeprom.c | 2 +- >> > > 1 file changed, 1 insertion(+), 1 deletion(-) >> > > >> > > diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c >> > > index 93d91264687f..0f6ccf6ed53d 100644 >> > > --- a/drivers/net/wireless/mediatek/mt76/eeprom.c >> > > +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c >> > > @@ -93,7 +93,7 @@ mt76_eeprom_override(struct mt76_phy *phy) >> > > if (err == -EPROBE_DEFER) >> > > return err; >> > > >> > > - if (!is_valid_ether_addr(phy->macaddr)) { >> > > + if (err) { >> > > eth_random_addr(phy->macaddr); >> > > dev_info(dev->dev, >> > > "Invalid MAC address, using random address %pM\n", >> > > -- >> > > 2.54.0 >> > > >> > >> > Recently I have started to see randomized MAC-addresses on my x86 laptop >> > with a MT7922 and the above message printed in the kernel log. I have >> > CONFIG_OF turned on, but since this is an ACPI system the device is not >> > described by any device tree and the earlier of_get_mac_address() likely >> > fails with -ENODEV. Looking at the !CONFIG_OF stub for >> > of_get_mac_address it always returns -ENODEV, meaning this will always >> > randomize the mac in that case too. > >> IIRC, the normal device_get_mac_address supports nvmem now. Does that >> fix your use case? > > I tried this: > > diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c > index b99d7452800f..243a8f2c7bda 100644 > --- a/drivers/net/wireless/mediatek/mt76/eeprom.c > +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c > @@ -174,10 +174,9 @@ int > mt76_eeprom_override(struct mt76_phy *phy) > { > struct mt76_dev *dev = phy->dev; > - struct device_node *np = dev->dev->of_node; > int err; > > - err = of_get_mac_address(np, phy->macaddr); > + err = device_get_mac_address(dev->dev, phy->macaddr); > if (err == -EPROBE_DEFER) > return err; > > > but I still get a random MAC. Then the original patch should be reverted. Unfortunate that it doesn't workq > >> > >> > Reverting this patch fixes the issue and the correct MAC address is >> > used. I'm not sure if there is any case where of_get_mac_addres() could >> > fail in a way that results in a valid MAC address but it seems unlikely >> > to me. >> > >> > Regards, >> > Klara Modin ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-06-19 1:50 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-04-27 5:17 [PATCH wireless-next] wifi: mt76: fix of_get_mac_address error handling Rosen Penev 2026-04-27 7:00 ` Lorenzo Bianconi 2026-06-18 21:47 ` Klara Modin 2026-06-18 23:01 ` Rosen Penev 2026-06-18 23:51 ` Klara Modin 2026-06-19 1:50 ` Rosen Penev
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox