devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Mason <slash.tmp@free.fr>
Cc: Mark Rutland <mark.rutland@arm.com>,
	DT <devicetree@vger.kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	Kevin Hilman <khilman@kernel.org>,
	netdev <netdev@vger.kernel.org>,
	Thibaud Cornic <thibaud_cornic@sigmadesigns.com>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: Initializing MAC address at run-time
Date: Thu, 19 Jan 2017 17:26:52 +0100	[thread overview]
Message-ID: <20170119162652.yef3ni6ylhzxpvgz@pengutronix.de> (raw)
In-Reply-To: <79fef293-74ec-dece-1941-747cd55f1ca2@free.fr>

Hello,

On Thu, Jan 19, 2017 at 04:31:56PM +0100, Mason wrote:
> Do you agree that such boot loader would execute code that is roughly
> identical to the one posted for illustration purposes?
>   1. find the MAC address to use for eth0
>   2. find the eth0 node in the DT
>   3. insert the right prop in the eth0 node

yes.
 
> In which case, it seems a waste to add the DT library to the boot
> loader, when the operation can be done in Linux, which requires the
> DT library anyway. (Additionally, adding DT support to some custom
> legacy boot loader might be a complex task.)

With this reasoning you can discuss away the bootloader. Linux relies on
a bootloader for a reason. It's there to initialize RAM and some further
things that Linux might not be able to and provide a machine description
to Linux (either in form of a dtb or an ATAG list) such that Linux
doesn't need to fiddle with machine specific stuff in early init code.

> >  c) Adapt the dtb before it is written to the boot medium.
> 
> This is not applicable, as the DTB is not written to the board.

Ah, then adapt the dtb before it is put into the tftp folder.

> >  d) Let the bootloader configure the device and teach the driver to pick
> >     up the mac from the device's address space.
> 
> I'm not sure what you call "the device" ?

The network device. IIRC the fec driver checks if there is something
configured in the two registers configuring the MAC before falling back
to a random MAC.

> >  e) Accept that the mac address is random during development, and make
> >     Userspace configure the MAC address, which is early enough for
> >     production use.
> 
> During development, some devs configure the DHCP server to provide
> a specific uImage and/or rootfs to their board, based on the MAC
> address. This scheme would fall apart with a random MAC.
> 
> > Not sure d) is considered ok today, but some drivers have this feature.
> > I'd say b) is the best choice.
> 
> In my mind, doing it early in Linux is similar in spirit to doing it
> at the boot loader stage, in that it's neatly separated from the rest
> of the setup.

Sure you can do this. But it won't be accepted mainline for sure.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

      reply	other threads:[~2017-01-19 16:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-18 14:03 Initializing MAC address at run-time Mason
     [not found] ` <e083ed68-0e8e-380e-23bd-5ad387c88575-GANU6spQydw@public.gmane.org>
2017-01-18 14:45   ` Mark Rutland
2017-01-18 15:35     ` Robin Murphy
2017-01-18 18:54 ` Uwe Kleine-König
2017-01-19 15:31   ` Mason
2017-01-19 16:26     ` Uwe Kleine-König [this message]

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=20170119162652.yef3ni6ylhzxpvgz@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=khilman@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=netdev@vger.kernel.org \
    --cc=slash.tmp@free.fr \
    --cc=thibaud_cornic@sigmadesigns.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).