wifi: mt76: fix of_get_mac_address error handling
Subsystems (3)
PATCH 1/1 wifi: mt76: fix of_get_mac_address error handling
Check return value instead of is_valid_ether_addr. The latter is handled by the former.
--- drivers/net/wireless/mediatek/mt76/eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/eeprom.c +1 -1
@@ -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",
Signature · 1 line
2.54.0
Quoted 4 lines
Check return value instead of
is_valid_ether_addr. The latter is handled by the former.Signed-off-by Rosen Penev <[email protected]>
Quoted 20 lines
--- drivers/net/wireless/mediatek/mt76/eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/wireless/mediatek/mt76/eeprom.c +1
-1@@ -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",Signature · 1 line
2.54.0
Hi,
Quoted 24 lines · Rosen Penev
Check return value instead of
is_valid_ether_addr. The latter is handled by the former.Signed-off-by Rosen Penev <[email protected]>--- drivers/net/wireless/mediatek/mt76/eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/wireless/mediatek/mt76/eeprom.c +1
-1@@ -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",Signature · 1 line
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
Quoted 20 lines · Klara Modin
Hi,
Quoted 16 lines · Rosen Penev
Check return value instead of
is_valid_ether_addr. The latter is handled by the former.Signed-off-by Rosen Penev <[email protected]>--- drivers/net/wireless/mediatek/mt76/eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/wireless/mediatek/mt76/eeprom.c +0
-0@@ -93,7 +93,7 @@ mt76_eeprom_override(struct mt76_phy *phy)if (err == -EPROBE_DEFER )return err;
Quoted 16 lines
Quoted 8 lines
drivers/net/wireless/mediatek/mt76/eeprom.c +1
-2-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_OFturned on, but since this is an ACPI system the device is not described by any device tree and the earlierof_get_mac_address()likely fails with-ENODEV. Looking at the !CONFIG_OF stub forof_get_mac_addressit 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?
Quoted 8 lines
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
Quoted 38 lines · Rosen Penev
Quoted 20 lines · Klara Modin
Hi,
Quoted 16 lines · Rosen Penev
Check return value instead of
is_valid_ether_addr. The latter is handled by the former.Signed-off-by Rosen Penev <[email protected]>--- drivers/net/wireless/mediatek/mt76/eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/wireless/mediatek/mt76/eeprom.c +0
-0@@ -93,7 +93,7 @@ mt76_eeprom_override(struct mt76_phy *phy)if (err == -EPROBE_DEFER )return err;Quoted 16 lines
Quoted 8 lines
drivers/net/wireless/mediatek/mt76/eeprom.c +1
-2-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_OFturned on, but since this is an ACPI system the device is not described by any device tree and the earlierof_get_mac_address()likely fails with-ENODEV. Looking at the !CONFIG_OF stub forof_get_mac_addressit always returns-ENODEV, meaning this will always randomize the mac in that case too.
Quoted 2 lines
IIRC, the normal
device_get_mac_addresssupports nvmem now. Does that fix your use case?
I tried this:
drivers/net/wireless/mediatek/mt76/eeprom.c +1 -2
@@ -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.
Quoted 8 lines
Quoted 8 lines
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
Quoted 61 lines · Klara Modin
Quoted 38 lines · Rosen Penev
Quoted 20 lines · Klara Modin
Hi,
Quoted 16 lines · Rosen Penev
Check return value instead of
is_valid_ether_addr. The latter is handled by the former.Signed-off-by Rosen Penev <[email protected]>--- drivers/net/wireless/mediatek/mt76/eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/wireless/mediatek/mt76/eeprom.c +0
-0@@ -93,7 +93,7 @@ mt76_eeprom_override(struct mt76_phy *phy)if (err == -EPROBE_DEFER )return err;Quoted 16 lines
Quoted 8 lines
drivers/net/wireless/mediatek/mt76/eeprom.c +1
-2-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_OFturned on, but since this is an ACPI system the device is not described by any device tree and the earlierof_get_mac_address()likely fails with-ENODEV. Looking at the !CONFIG_OF stub forof_get_mac_addressit always returns-ENODEV, meaning this will always randomize the mac in that case too.Quoted 2 lines
IIRC, the normal
device_get_mac_addresssupports nvmem now. Does that fix your use case?I tried this:
drivers/net/wireless/mediatek/mt76/eeprom.c +1
-2@@ -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;
Quoted 1 line
but I still get a random MAC.
Then the original patch should be reverted. Unfortunate that it doesn't workq
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
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
Quoted 10 lines · Rosen Penev
Quoted 9 lines · Klara Modin
Quoted 8 lines · Rosen Penev
Quoted 7 lines · Klara Modin
Quoted 6 lines · Rosen Penev
Check return value instead of
is_valid_ether_addr. The latter is handled by the former.Signed-off-by Rosen Penev <[email protected]>[...]Quoted 1 line
Quoted 1 line
Quoted 1 line
Recently I have started to see randomized MAC-addresses on my
x86 laptop
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
with a MT7922 and the above message printed in the kernel log. I have
CONFIG_OFturned on, but since this is an ACPI system the device is not described by any device tree and the earlierof_get_mac_address()likely fails with-ENODEV. Looking at the !CONFIG_OF stub forof_get_mac_addressit always returns-ENODEV, meaning this will always randomize the mac in that case too.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
IIRC, the normal
device_get_mac_addresssupports nvmem now. Does that fix your use case?I tried this:
[...]
but I still get a random MAC.Then the original patch should be reverted. Unfortunate that it doesn't workq
Happens, no worries, but seems nobody submitted such a revert yet since you posted that. Unless I'm missing something -- if so, please do not hesitate to tell me!
But if no revert is in the works, could you please submit one, given that it was your change that cause the problem?
Side note: Tobias (now CCed) ran into the same problem, too:
https://lore.kernel.org/all/[email protected]/
Makes me wonder if more people are affected by this and if we should try to mainline the revert rather sooner than later.
Ciao, Thorsten
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
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
Quoted 29 lines · Thorsten Leemhuis
Quoted 10 lines · Rosen Penev
Quoted 9 lines · Klara Modin
Quoted 8 lines · Rosen Penev
Quoted 7 lines · Klara Modin
Quoted 6 lines · Rosen Penev
Check return value instead of
is_valid_ether_addr. The latter is handled by the former.Signed-off-by Rosen Penev <[email protected]>[...]Quoted 1 line
Quoted 1 line
Quoted 1 line
Recently I have started to see randomized MAC-addresses on my
x86 laptop
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
with a MT7922 and the above message printed in the kernel log. I have
CONFIG_OFturned on, but since this is an ACPI system the device is not described by any device tree and the earlierof_get_mac_address()likely fails with-ENODEV. Looking at the !CONFIG_OF stub forof_get_mac_addressit always returns-ENODEV, meaning this will always randomize the mac in that case too.Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
IIRC, the normal
device_get_mac_addresssupports nvmem now. Does that fix your use case?I tried this:
[...]
but I still get a random MAC.Then the original patch should be reverted. Unfortunate that it doesn't workq
Quoted 6 lines
Happens, no worries, but seems nobody submitted such a revert yet since you posted that. Unless I'm missing something -- if so, please do not hesitate to tell me!
But if no revert is in the works, could you please submit one, given that it was your change that cause the problem?
https://lore.kernel.org/linux-wireless/[email protected]/T/#u
Quoted 20 lines
Side note: Tobias (now CCed) ran into the same problem, too:
https://lore.kernel.org/all/[email protected]/Makes me wonder if more people are affected by this and if we should try to mainline the revert rather sooner than later.
Ciao, Thorsten
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
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