public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Pete Batard" <pete@akeo.ie>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>, devel@edk2.groups.io
Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org
Subject: Re: [edk2-devel] [edk2-platforms][PATCH v3 5/5] Platform/RPi3/PlatformSmbiosDxe: Derive RAM size from board revision
Date: Mon, 14 Oct 2019 13:03:48 +0100	[thread overview]
Message-ID: <2c9a0255-3a90-cfde-f5bd-1893c01b299a@akeo.ie> (raw)
In-Reply-To: <6782958e-fe36-8296-803a-ba8b90e4f985@redhat.com>

On 2019.10.14 12:53, Philippe Mathieu-Daudé wrote:
> On 10/14/19 1:44 PM, Pete Batard wrote:
>> Hi Philippe,
>>
>> On 2019.10.14 11:01, Philippe Mathieu-Daudé wrote:
>>> Hi Pete,
>>>
>>> On 10/11/19 1:07 PM, Pete Batard wrote:
>>>> The board revision is the proper channel to use to detect the amount of
>>>> RAM available as bits [20-22] report the effective RAM size for the 
>>>> board
>>>> starting with 256 MB (000b) and doubling in size for each value.
>>>>
>>>> Signed-off-by: Pete Batard <pete@akeo.ie>
>>>> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
>>>> ---
>>>> Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c 
>>>> | 18 ++++++++++++------
>>>>   1 file changed, 12 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git 
>>>> a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c 
>>>> b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c 
>>>>
>>>> index b5dcff897a59..5abc82b8d363 100644
>>>> --- 
>>>> a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c 
>>>>
>>>> +++ 
>>>> b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c 
>>>>
>>>> @@ -866,16 +866,22 @@ MemArrMapInfoUpdateSmbiosType19 (
>>>>     )
>>>>   {
>>>>     EFI_STATUS Status;
>>>> -  UINT32 Base;
>>>> -  UINT32 Size;
>>>> +  UINT32 BoardRevision = 0;
>>>> -  Status = mFwProtocol->GetArmMem (&Base, &Size);
>>>> +  // Note: Type 19 addresses are expressed in KB, not bytes

Comment to add:

// The memory layout used in all known Pi SoC's starts at 0

>>>> +  mMemArrMapInfoType19.StartingAddress = 0;
>>>
>>> Now you assume the ARM base RAM address is always 0, why?
>>
>> Because, in the case that is of interest to us here (Broadcom SoCs 
>> used for the various Raspberry Pi platforms), this is what the 
>> documentation says.
>>
>> If you look at something like 
>> https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf 
>> (which, as per the Pi Foundation, also applies to the later models) 
>> and especially the memory layout graphic that you see early in the 
>> document, you can find that the ARM base RAM address is indeed set to 
>> 0 always.
>>
>> At this stage, we have no reason to think that we are going to contend 
>> with a model where the RAM base address isn't 0.
> 
> OK. I have no idea what are Broadcom plans, I read somewhere they were 
> going to use tricks to allow more than 4GB of RAM on the Raspberry Pi 4, 
> so I was wondering, since they provide a firmware API call to get the 
> RAM base address.

Well the thing is, this patch comes straight from work that is being 
carried out to add support for the Pi 4 to edk2-platforms. So we pretty 
much already validated that 0 is what needs to be used for the Pi 4 as 
well...

> Maybe you can add a comment that we expect all following boards to use 
> RAM base at 0 (simply replying to this email, and eventually Leif would 
> amend it previous to push).

Sure. Comment added above.

Regards,

/Pete

> 
> Otherwise your patch looks OK.
> 
> Regards,
> 
> Phil.
> 
>>>> +  // The minimum RAM size used on any Raspberry Pi model is 256 MB
>>>> +  mMemArrMapInfoType19.EndingAddress = 256 * 1024;
>>>> +  Status = mFwProtocol->GetModelRevision (&BoardRevision);
>>>>     if (Status != EFI_SUCCESS) {
>>>> -    DEBUG ((DEBUG_ERROR, "Couldn't get the ARM memory size: %r\n", 
>>>> Status));
>>>> +    DEBUG ((DEBUG_WARNING, "Couldn't get the board memory size - 
>>>> defaulting to 256 MB: %r\n", Status));
>>>>     } else {
>>>> -    mMemArrMapInfoType19.StartingAddress = Base / 1024;
>>>> -    mMemArrMapInfoType19.EndingAddress = (Base + Size - 1) / 1024;
>>>> +    // 
>>>> www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md 
>>>>
>>>> +    // Bits [20-22] indicate the amount of memory starting with 
>>>> 256MB (000b)
>>>> +    // and doubling in size for each value (001b = 512 MB, 010b = 
>>>> 1GB, etc.)
>>>> +    mMemArrMapInfoType19.EndingAddress <<= (BoardRevision >> 20) & 
>>>> 0x07;
>>>>     }
>>>> +  mMemArrMapInfoType19.EndingAddress -= 1;
>>>>     LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mMemArrMapInfoType19, 
>>>> mMemArrMapInfoType19Strings, NULL);
>>>>   }
>>>>
>>>
>>
>>
>> 
>>
> 


  reply	other threads:[~2019-10-14 12:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11 11:07 [edk2-platforms][PATCH v3 0/5] Various SMBIOS improvements Pete Batard
2019-10-11 11:07 ` [edk2-platforms][PATCH v3 1/5] Platform/RPi3/RpiFirmwareDxe: Add more query functions Pete Batard
2019-10-14  9:55   ` [edk2-devel] " Philippe Mathieu-Daudé
2019-10-11 11:07 ` [edk2-platforms][PATCH v3 2/5] Platform/RPi3/RpiFirmwareDxe: Improve serial number population Pete Batard
2019-10-11 11:07 ` [edk2-platforms][PATCH v3 3/5] Platform/RPi3/PlatformSmbiosDxe: Improve population of SMBIOS entries Pete Batard
2019-10-11 11:07 ` [edk2-platforms][PATCH v3 4/5] Platform/RPi3/PlatformSmbiosDxe: Populate BIOS major/minor from PCD Pete Batard
2019-10-11 11:07 ` [edk2-platforms][PATCH v3 5/5] Platform/RPi3/PlatformSmbiosDxe: Derive RAM size from board revision Pete Batard
2019-10-14 10:01   ` [edk2-devel] " Philippe Mathieu-Daudé
2019-10-14 11:44     ` Pete Batard
2019-10-14 11:53       ` Philippe Mathieu-Daudé
2019-10-14 12:03         ` Pete Batard [this message]
2019-10-14 12:08           ` Philippe Mathieu-Daudé
2019-10-14 12:17             ` Leif Lindholm
2019-10-15 20:00 ` [edk2-platforms][PATCH v3 0/5] Various SMBIOS improvements Leif Lindholm

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=2c9a0255-3a90-cfde-f5bd-1893c01b299a@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