All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Rosen Penev <rosenp@gmail.com>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>, "Andrew Lunn" <andrew@lunn.ch>,
	"Shannon Nelson" <shannon.nelson@amd.com>,
	"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	"Breno Leitao" <leitao@debian.org>,
	"Jeff Johnson" <quic_jjohnson@quicinc.com>,
	"Christian Marangi" <ansuelsmth@gmail.com>,
	"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCHv6 net-next 6/7] net: ibm: emac: generate random MAC if not found
Date: Wed, 16 Oct 2024 08:36:37 +0100	[thread overview]
Message-ID: <20241016073637.GE2162@kernel.org> (raw)
In-Reply-To: <CAKxU2N87Nqa73M+wda3Phayu5dmkWEMhDXgxz=4bASV_-8D4yQ@mail.gmail.com>

On Tue, Oct 15, 2024 at 12:44:52PM -0700, Rosen Penev wrote:
> On Sat, Oct 12, 2024 at 6:16 AM Simon Horman <horms@kernel.org> wrote:
> >
> > On Fri, Oct 11, 2024 at 12:56:21PM -0700, Rosen Penev wrote:
> > > On this Cisco MX60W, u-boot sets the local-mac-address property.
> > > Unfortunately by default, the MAC is wrong and is actually located on a
> > > UBI partition. Which means nvmem needs to be used to grab it.
> > >
> > > In the case where that fails, EMAC fails to initialize instead of
> > > generating a random MAC as many other drivers do.
> > >
> > > Match behavior with other drivers to have a working ethernet interface.
> > >
> > > Signed-off-by: Rosen Penev <rosenp@gmail.com>
> > > ---
> > >  drivers/net/ethernet/ibm/emac/core.c | 9 ++++++---
> > >  1 file changed, 6 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
> > > index b9ccaae61c48..faa483790b29 100644
> > > --- a/drivers/net/ethernet/ibm/emac/core.c
> > > +++ b/drivers/net/ethernet/ibm/emac/core.c
> > > @@ -2937,9 +2937,12 @@ static int emac_init_config(struct emac_instance *dev)
> > >
> > >       /* Read MAC-address */
> > >       err = of_get_ethdev_address(np, dev->ndev);
> > > -     if (err)
> > > -             return dev_err_probe(&dev->ofdev->dev, err,
> > > -                                  "Can't get valid [local-]mac-address from OF !\n");
> > > +     if (err == -EPROBE_DEFER)
> > > +             return err;
> > > +     if (err) {
> > > +             dev_warn(&dev->ofdev->dev, "Can't get valid mac-address. Generating random.");
> > > +             eth_hw_addr_random(dev->ndev);
> > > +     }
> >
> > The above seems to take the random path for all errors other than
> > -EPROBE_DEFER. That seems too broad to me, and perhaps it would
> > be better to be more specific. Assuming the case that needs
> > to be covered is -EINVAL (a guess on my part), perhaps something like this
> > would work? (Completely untested!)
> >
> >         err = of_get_ethdev_address(np, dev->ndev);
> >         if (err == -EINVAL) {
> >                 /* An explanation should go here, mentioning Cisco MX60W
> >                  * Maybe the logic should even be specific to that hw?
> >                  */
> >                 dev_warn(&dev->ofdev->dev, "Can't get valid mac-address. Generating random.");
> >                 eth_hw_addr_random(dev->ndev);
> >         } else if (err) {
> >                 return dev_err_probe(&dev->ofdev->dev, err,
> >                                      "Can't get valid [local-]mac-address from OF !\n");
> >         }
> That's just yak shaving. besides 0 and EPROBE_DEFER,
> of_get_ethdev_address returns ENODEV, EINVAL, and maybe something
> else. I don't see a good enough reason to diverge from convention
> here. This same pattern is present in other drivers.

I assumed that more specific error detection would be appropriate, because
it seemed to be a rather specific case.  But if the pattern is present in
other drivers, then that is fine.

> >
> > Also, should this be a bug fix with a Fixes tag for net?
> No. It's more of a feature honestly.
> >
> > >
> > >       /* IAHT and GAHT filter parameterization */
> > >       if (emac_has_feature(dev, EMAC_FTR_EMAC4SYNC)) {
> > > --
> > > 2.47.0
> > >
> 

  reply	other threads:[~2024-10-16  7:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-11 19:56 [PATCHv6 net-next 0/7] ibm: emac: more cleanups Rosen Penev
2024-10-11 19:56 ` [PATCHv6 net-next 1/7] net: ibm: emac: use netif_receive_skb_list Rosen Penev
2024-10-12 13:22   ` Simon Horman
2024-10-11 19:56 ` [PATCHv6 net-next 2/7] net: ibm: emac: remove custom init/exit functions Rosen Penev
2024-10-12 12:59   ` Simon Horman
2024-10-11 19:56 ` [PATCHv6 net-next 3/7] net: ibm: emac: use devm_platform_ioremap_resource Rosen Penev
2024-10-12 13:23   ` Simon Horman
2024-10-11 19:56 ` [PATCHv6 net-next 4/7] net: ibm: emac: use platform_get_irq Rosen Penev
2024-10-12 13:23   ` Simon Horman
2024-10-11 19:56 ` [PATCHv6 net-next 5/7] net: ibm: emac: use devm for mutex_init Rosen Penev
2024-10-12 12:43   ` Simon Horman
2024-10-11 19:56 ` [PATCHv6 net-next 6/7] net: ibm: emac: generate random MAC if not found Rosen Penev
2024-10-12 13:16   ` Simon Horman
2024-10-15 19:44     ` Rosen Penev
2024-10-16  7:36       ` Simon Horman [this message]
2024-10-11 19:56 ` [PATCHv6 net-next 7/7] net: ibm: emac: use of_find_matching_node Rosen Penev
2024-10-12 13:21   ` Simon Horman
2024-10-15 19:45     ` Rosen Penev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241016073637.GE2162@kernel.org \
    --to=horms@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=ansuelsmth@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=quic_jjohnson@quicinc.com \
    --cc=rosenp@gmail.com \
    --cc=shannon.nelson@amd.com \
    --cc=u.kleine-koenig@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.