Re: [PATCH net-next] net: gianfar: fix NVMEM mac address
From: Rosen Penev
Date: Mon Sep 09 2024 - 13:53:06 EST
On Sun, Sep 8, 2024 at 9:22 PM Pavan Chebbi <pavan.chebbi@xxxxxxxxxxxx> wrote:
>
> On Mon, Sep 9, 2024 at 3:06 AM Rosen Penev <rosenp@xxxxxxxxx> wrote:
> >
> > If nvmem loads after the ethernet driver, mac address assignments will
> > not take effect. of_get_ethdev_address returns EPROBE_DEFER in such a
> > case so we need to handle that to avoid eth_hw_addr_random.
> >
> > Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
> > ---
>
> What is the issue you are facing with a random MAC address?
> If there is a real problem, this patch should go to the net, with a
> proper description and fixes tag.
Embedded devices usually store the mac address in some fixed offset on
flash. NVMEM deals with this.
I don't think net is appropriate given that there's not really a
commit to point to. nvmem is a fairly recent addition.
Similar commits in this vain are:
42404d8f1c01861b22ccfa1d70f950242720ae57
f7650d82e7dc501dfc5920c698bcc0591791a57c
f4693b81ea3802d2c28c868e1639e580d0da2d1f
be04024a24a93f761a7b2c5f2de46db0f3acdc74
>
> > drivers/net/ethernet/freescale/gianfar.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
> > index 634049c83ebe..9755ec947029 100644
> > --- a/drivers/net/ethernet/freescale/gianfar.c
> > +++ b/drivers/net/ethernet/freescale/gianfar.c
> > @@ -716,6 +716,8 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
> > priv->device_flags |= FSL_GIANFAR_DEV_HAS_BUF_STASHING;
> >
> > err = of_get_ethdev_address(np, dev);
> > + if (err == -EPROBE_DEFER)
> > + return err;
> > if (err) {
> > eth_hw_addr_random(dev);
> > dev_info(&ofdev->dev, "Using random MAC address: %pM\n", dev->dev_addr);
> > --
> > 2.46.0
> >
> >