public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Pete Batard" <pete@akeo.ie>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: edk2-devel-groups-io <devel@edk2.groups.io>,
	"Leif Lindholm" <leif@nuviainc.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Jeremy Linton" <lintonrjeremy@gmail.com>
Subject: Re: [edk2-platforms][PATCH v2 2/3] Platform/RPi: Add PlatformPcdLib to set the Genet MAC address
Date: Sat, 1 Feb 2020 12:32:39 +0000	[thread overview]
Message-ID: <b9ec6d3c-0876-62ed-3c0f-b626e9e45ed6@akeo.ie> (raw)
In-Reply-To: <CAKv+Gu-RMYc4itraLLaOnBqP4=ZBe0uiO70edMbp6-6XRats5w@mail.gmail.com>

On 2020.02.01 09:48, Ard Biesheuvel wrote:
> On Sat, 1 Feb 2020 at 09:25, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>>
>> On Fri, 31 Jan 2020 at 19:45, Pete Batard <pete@akeo.ie> wrote:
>>>
>>> On 2020.01.31 17:53, Ard Biesheuvel wrote:
>>>> On Fri, 31 Jan 2020 at 18:48, Pete Batard <pete@akeo.ie> wrote:
>>>>>
>>>>> Hi Ard,
>>>>>
>>>>> On 2020.01.31 17:05, Ard Biesheuvel wrote:
>>>>>> On Fri, 24 Jan 2020 at 12:54, Pete Batard <pete@akeo.ie> wrote:
>>>>>>>
>>>>>>> The Genet driver stub used by the Raspberry Pi 4 platform is
>>>>>>> designed to set the MAC address according to a PCD.
>>>>>>>
>>>>>>> To be able to set that PCD at runtime, by using the Raspberry
>>>>>>> Pi firmware interface, that has a dedicated call to retrieve
>>>>>>> the MAC address, and satisfy driver dependencies in a generic
>>>>>>> manner, we create a new PlatformPcdLib that can be referenced
>>>>>>> by the Genet driver, to set the MAC PCD before use there.
>>>>>>>
>>>>>>> While it is currently only tailored around MAC PCD population
>>>>>>> for Genet, we do expect this PCD library to be extended in the
>>>>>>> future, to provide additional PCD facilities for other drivers.
>>>>>>>
>>>>>>> Signed-off-by: Pete Batard <pete@akeo.ie>
>>>>>>> ---
>>>>>>>     Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.c   | 51 ++++++++++++++++++++
>>>>>>>     Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.inf | 43 +++++++++++++++++
>>>>>>>     2 files changed, 94 insertions(+)
>>>>>>>
>>>>>>> diff --git a/Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.c b/Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.c
>>>>>>> new file mode 100644
>>>>>>> index 000000000000..792073a903e9
>>>>>>> --- /dev/null
>>>>>>> +++ b/Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.c
>>>>>>> @@ -0,0 +1,51 @@
>>>>>>> +/** @file
>>>>>>> + *
>>>>>>> + *  Copyright (c) 2020, Pete Batard <pete@akeo.ie>
>>>>>>> + *
>>>>>>> + *  SPDX-License-Identifier: BSD-2-Clause-Patent
>>>>>>> + *
>>>>>>> + **/
>>>>>>> +
>>>>>>> +#include <Library/DebugLib.h>
>>>>>>> +#include <Library/PcdLib.h>
>>>>>>> +#include <Library/PrintLib.h>
>>>>>>> +#include <Library/UefiBootServicesTableLib.h>
>>>>>>> +#include <Library/UefiLib.h>
>>>>>>> +#include <Library/UefiRuntimeServicesTableLib.h>
>>>>>>> +#include <Protocol/RpiFirmware.h>
>>>>>>> +
>>>>>>> +EFI_STATUS
>>>>>>> +EFIAPI
>>>>>>> +PlatformPcdLibConstructor (
>>>>>>> +  IN EFI_HANDLE ImageHandle,
>>>>>>> +  IN EFI_SYSTEM_TABLE *SystemTable
>>>>>>> +  )
>>>>>>> +{
>>>>>>> +
>>>>>>> +  //
>>>>>>> +  // If Genet is in use and a MAC address PCD has not been set, do it here.
>>>>>>> +  //
>>>>>>> +#if (FixedPcdGet64 (PcdBcmGenetRegistersAddress) != 0)
>>>>>>
>>>>>> I still don't see why we need this conditional. This is a fixed PCD,
>>>>>> so it must be set in the .DSC. If you are going to set it in the .DSC,
>>>>>> why include this driver in the first place?
>>>>>
>>>>> Let's consider this:
>>>>>
>>>>> 1. We expand on PlatformPcdLib to do more than set the MAC Address PCD
>>>>> for the Pi 4. For instance, we use it to set some other PCD, that is
>>>>> specific to the Pi 3, or for an upcoming Pi. In this usage, we would be
>>>>> using PlatformPcdLib with a .DSC where PcdBcmGenetRegistersAddress is
>>>>> not set and therefore defaults to 0.
>>>>>
>>>>
>>>> I don't think a single PlatformPcdLib is realistic, since you'd need
>>>> to link it into different drivers via NULL resolution, all of which
>>>> would inherited the conjunction of all the DEPEX clauses, potentially
>>>> causing circular dependencies.
>>>>
>>>> I'd much rather have either a named library class in BcmGenet.dec
>>>> scope that the platform can implement to provide the MAC, or one that
>>>> can be used via NULL resolution (in cases where it is imaginable that
>>>> the driver does not need the MAC to be provided at all)
>>>
>>> Yes, but the problem is, right now, I have no idea what the Genet driver
>>> is going to look like, so we need a solution that is unlikely to
>>> interfere with what's going to happen in terms of Genet driver
>>> expansion. And this is the least intrusive solution I identified (which
>>> means it will also be easiest to remove if we decide to supersede it).
>>>
>>
>> If the genet stub driver morphs into something more elaborate, it will
>> still require a platform specific way to discover the MAC the
>> platforms wants it to use.
>>
>>> I personally don't think a named library is the better solution because,
>>> ideally, we should have two independent drivers (not libraries), one for
>>> UMAC and one for Genet, considering that we really want is have the
>>> platform rely on a UMAC hardware service implementation since we are
>>> dealing with 2 separate hardware functions, that pertain to networking
>>> but that are not directly related. So if you want to go towards the
>>> "There has to be a better solution that this" route, I'm would actually
>>> push for a separate driver rather than a library. But then I expect that
>>> we're going to create all kinds of problems for Jeremy when he produces
>>> his Genet implementation, which is precisely why I steered away from
>>> doing that in the first place. There are also other alternatives, such
>>> as implementing Simple Network Driver protocol, since this appears to
>>> provide means to set the MAC, but this too is going to interfere with
>>> Jeremy's effort.
>>>
>>> So, and I hope this doesn't come as offensive because this is not my
>>> intention here, I'm afraid that, unless someone else takes that matter
>>> into their own hand, the current proposal is the best you're gonna get,
>>> unless you want to produce that named library class yourself (which,
>>> again, I still don't view as the better solution if that's what we are
>>> looking for).
>>>
>>
>> OK
>>
>>> What also bothers me is that you did state at the end of [1] that:
>>>
>>>   > I don't mind this approach, but in general, I'd be happier with a
>>>   > specific library class to discover the MAC address.
>>>
>>> which I took as a tacit approval that, even if you didn't exactly like
>>> it, you were still okay with applying this patchset as long as the other
>>> issues were addressed. So I hope you can appreciate that I can't go
>>> around with expecting approval on the general approach of a patchset,
>>> only to see it suddenly rejected by the same person one week later...
>>>
>>
>> That was before you refused to remove the #if PcdGet64() == 0

I actually have no problem at all removing that line.

My take away until just now was that you did not understand why the line 
was there, not that you really wanted to see it gone.

For the current use of this driver (RPi4 platform only), I'm fine with 
not having the line, and only adding it at a later stage if/as needed.

> Apologies if that came out grumpy.

Same for me. I'm not that intractable about PlatformPcdLib, but if 
there's something you really don't want to see in it, please don't be 
afraid to explicitly state so.

Therefore, unless you are fine with removing it yourself during 
integration, I can send a v2 that removes the #ifdef condition.

> 
> The reality is that it is highly unlikely that the genet driver will
> ever be usable in another platform without substantial rework,

Well, I genuinely have no idea what the genet driver is going to look 
like, so I'm not willing to make any predictions one way or another. All 
I know is that Broadcom appear to have released 5 versions of the genet 
hardware, so they don't seem intent on retiring it, which means we might 
see it being used on other platforms.

> so the
> kind of future proofing that we're doing here is both too much and too
> little. If you are concerned about timelines, just keep it simple and
> inflexible, and we can refactor it later. By that time, I will also
> hopefully have more bandwidth to look at this stuff.
> 
> Unrelated: you don't happen to be at FOSDEM do you?

I wish I was, but I'm afraid not. Maybe next year...

Regards,

/Pete


  reply	other threads:[~2020-02-01 12:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24 11:54 [edk2-platforms][PATCH v2 0/3] Platform/RPi4: Add Genet network driver stub Pete Batard
2020-01-24 11:54 ` [edk2-platforms][PATCH v2 1/3] Silicon/Broadcom/Net: Add Genet stub driver to setup MAC Pete Batard
2020-01-24 11:54 ` [edk2-platforms][PATCH v2 2/3] Platform/RPi: Add PlatformPcdLib to set the Genet MAC address Pete Batard
2020-01-31 17:05   ` Ard Biesheuvel
2020-01-31 17:48     ` Pete Batard
2020-01-31 17:53       ` Ard Biesheuvel
2020-01-31 18:45         ` Pete Batard
2020-02-01  8:25           ` Ard Biesheuvel
2020-02-01  9:48             ` Ard Biesheuvel
2020-02-01 12:32               ` Pete Batard [this message]
     [not found]     ` <15EF09ECF7E17D89.704@groups.io>
2020-01-31 17:53       ` [edk2-devel] " Pete Batard
2020-01-24 11:54 ` [edk2-platforms][PATCH v2 3/3] Platform/RPi4: Enable Broadcom Genet stub driver Pete Batard

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-list 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=b9ec6d3c-0876-62ed-3c0f-b626e9e45ed6@akeo.ie \
    --to=devel@edk2.groups.io \
    /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