ACK: [PATCH] [SRU][X/raspi2] RaspberryPi3+: read ethernet mac adress from device tree
Khaled Elmously
khalid.elmously at canonical.com
Tue Oct 23 04:35:59 UTC 2018
On 2018-10-18 15:24:13 , Paolo Pisati wrote:
> BugLink: http://bugs.launchpad.net/bugs/1798578
>
> Impact:
>
> The RaspberryPi3+ board came with an usb's to ethernet lan78xx nic adapter -
> this chip has no external eeprom, nor internal preprogrammed mac address and
> as such, after every reboot, it generates a random ethernet mac address.
>
> The lan78xx driver is able to read its mac address from the device tree passed
> to the kernel (see d093067 "lan78xx: Read MAC address from DT if present"),
> making it possible to have reproducible/fixed mac addresses, but unfortunately
> this feature isn't working in our Xenial/raspi2 kernel (while it's working fine
> in Bionc/raspi2).
>
> After some debugging i found that the usb_net struct backing the lan78xx
> driver, had no clue about the dt node it was associated, making this piece of
> code constantly evaluates to NULL:
>
> static void lan78xx_init_mac_address(struct lan78xx_net *dev)
> ...
> mac_addr = of_get_mac_address(dev->udev->dev.of_node);
> ...
>
> There "of_node" was always NULL.
>
> After more debugging, i found that the feature to bind usb_net devices and
> device tree nodes was introduced in the Linux 4.6 cycle, and as such Xenial
> didn't have it.
>
> Fix:
>
> Apply the patch and recompile
>
> How to test:
>
> Upon boot of the RaspberryPi3+ board (and after the dtb has been loaded into
> memory), stop at the uboot prompt and check the usbeether device node:
>
> U-Boot> fdt print /soc/usb/usb1 at 1/usb1_1 at 1/usbether at 1
> usbether at 1 {
> local-mac-address = [b8 27 eb ce 07 ba];
> compatible = "usb424,7800";
> reg = <0x00000001>;
> microchip,eee-enabled;
> microchip,tx-lpi-timer = <0x00000258>;
> phandle = <0x00000024>;
> };
>
> the "local-mac-address" has been filled by the Broadcom bootloader, and
> contains the lan78xx's mac address.
>
> Then proceed with the boot routine, read the user prompt, and check eth0's mac
> address:
>
> $ ifconfig eth0 | grep HWaddr eth0 Link encap:Ethernet HWaddr b8:27:eb:ce:07:ba
>
> If it's the same as above, the fix worked.
>
> Regression:
>
> The patch has been in upstream since v4.6-rc1, and it changes a very small
> portion of code, so i'll say it's regression potential is very low / none.
>
> Peter Chen (1):
> USB: core: let USB device know device node
>
> .../devicetree/bindings/usb/usb-device.txt | 28 +++++++++++++
> drivers/usb/core/Makefile | 2 +-
> drivers/usb/core/of.c | 47 ++++++++++++++++++++++
> drivers/usb/core/usb.c | 10 +++++
> include/linux/usb/of.h | 7 ++++
> 5 files changed, 93 insertions(+), 1 deletion(-)
> create mode 100644 Documentation/devicetree/bindings/usb/usb-device.txt
> create mode 100644 drivers/usb/core/of.c
>
Acked-by: Khalid Elmously <khalid.elmously at canonical.com>
More information about the kernel-team
mailing list