Message ID | 20240319215836.48178-1-martin@wetterwald.eu |
---|---|
State | Rejected, archived |
Delegated to: | Peter Robinson |
Headers | show |
Series | [v2] rpi: Copy eth MAC address from fw DT to loaded DT | expand |
I reworked the commit message because I noticed the upstream Linux kernel has a difference with the Raspberry Pi fork of the kernel regarding the algorithm used to determine the MAC address of the smsc95xx. There is no smsc95xx.macaddr in the upstream kernel, and using the upstream kernel is actually the real use case for the patch. I'm now wondering whether some users are using the module parameter smsc95xx.macaddr of the Raspberry Pi fork of the kernel to try to change the MAC, and put one which is not the factory default? Does this use case exists? If this is the case, the current algorithm in the forked kernel would mean that, the FDT-provided MAC would have priority over anything set in the module parameter. This is already the case anyway when people give to the forked kernel the firmware-provided FDT (smsc95xx.macaddr is ignored). So this patch aligns behaviors. But we should be aware that applying this patch would change the behavior in the following situation (all conditions need to be true): - Forked kernel is used - Fresh FDT (not firmware one) is provided to the kernel - Custom (not factory) MAC was set in smsc95xx.macaddr parameter Martin
Hi Martin, > I reworked the commit message because I noticed the upstream Linux kernel has a > difference with the Raspberry Pi fork of the kernel regarding the algorithm > used to determine the MAC address of the smsc95xx. So looking at this on an original 3B because that's what I had booted for other testing. > There is no smsc95xx.macaddr in the upstream kernel, and using the upstream > kernel is actually the real use case for the patch. In most cases in device tree this is dealt with aliases [1] to ethernet0, 1 etc. In the U-Boot env I have two env set, ethaddr and usbethaddr both to the same MAC address with b8:27:eb prefix which is assigned to RPi foundation [2]. When I boot Linux I get that MAC address on the interface as expected. > I'm now wondering whether some users are using the module parameter > smsc95xx.macaddr of the Raspberry Pi fork of the kernel to try to change the > MAC, and put one which is not the factory default? I would have thought that the recent RPi kernels would also fall back to the upstream variation too if their fork option wasn't available. > Does this use case exists? If this is the case, the current algorithm in the > forked kernel would mean that, the FDT-provided MAC would have priority over > anything set in the module parameter. > This is already the case anyway when people give to the forked kernel the > firmware-provided FDT (smsc95xx.macaddr is ignored). So this patch aligns > behaviors. > But we should be aware that applying this patch would change the behavior in > the following situation (all conditions need to be true): > - Forked kernel is used > - Fresh FDT (not firmware one) is provided to the kernel > - Custom (not factory) MAC was set in smsc95xx.macaddr parameter Can we take a step back, I'm still unsure what you're trying to resolve here. For me with the upstream U-Boot and the upstream kernel I get the vendor MAC address as I would expect. It should work on any kernel/DT combo as long as the ether ethernet alias is present in the DT. Peter [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/broadcom/bcm283x-rpi-smsc9514.dtsi#n3 [2] https://maclookup.app/search/result?mac=b8:27:eb:
diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c index 2851ebc985..b36a893047 100644 --- a/board/raspberrypi/rpi/rpi.c +++ b/board/raspberrypi/rpi/rpi.c @@ -566,6 +566,9 @@ void update_fdt_from_fw(void *fdt, void *fw_fdt) /* address of the PHY device as provided by the firmware */ copy_property(fdt, fw_fdt, "ethernet0/mdio@e14/ethernet-phy@1", "reg"); + + /* MAC address of the NIC as provided by the firmware */ + copy_property(fdt, fw_fdt, "ethernet0", "local-mac-address"); } int ft_board_setup(void *blob, struct bd_info *bd)