From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) by mx.groups.io with SMTP id smtpd.web10.2499.1571054632058547408 for ; Mon, 14 Oct 2019 05:03:52 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=j+HVIjcT; spf=none, err=permanent DNS error (domain: akeo.ie, ip: 209.85.221.53, mailfrom: pete@akeo.ie) Received: by mail-wr1-f53.google.com with SMTP id v8so19421155wrt.2 for ; Mon, 14 Oct 2019 05:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akeo-ie.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=icsYXBcmTBHkkohVmBvuHCiUaeBMou2/FeMKqZ9GGpI=; b=j+HVIjcTObRTi6P+eetp/gkEMN9OMz0QIoJ9tVhb48M3hrM+ZfyjfhwYtsxv9H+x6A sRBh4EkQjBlb4/5IzmmBdNSzYycaCX6RBeMNFH3VO8bnrkF4c+YW6kdt/hWG43T6ChY8 07zxhG8dgPFYPxrYmC6EcfLEOI1c70RKXs9sUsQisuaxmhxBlBe16SZwdk2PB8cVFbvY yONclIjp7P4RIz9ueVmyJYxer/e+8BibL9qaJ62zbJ665tedY82q3Igth5NlDqi2nk2O 8iMwbnmDhcbCP58DJlB4MoODefwTqfuuxSVd+aAck03hyRJIaAXP8+iFzKaDiNWNX3BA omYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=icsYXBcmTBHkkohVmBvuHCiUaeBMou2/FeMKqZ9GGpI=; b=Px5PWikFiydkddlARhqYrYvUJbad/FdHa2ZFz9VjMEtJbalUgkBHkHfHP5yxQPy65+ rG7u+Uox+ZY8iwabwKvzSM+UATcJmp0n58XjthBnKipQdBUhkT1Z3QG7Xql7P4IiRU78 AO33UtUeoZgIqBQ/DhZ9xTt0wUj1VdTIdYMXIaU/e/1T+E22BfTzaklhO0Caiz3v8mwQ aqk2LPF5QhfnEnU5DqlXFRZNXEYjrYbI6taPzvmpnuN5M6z8qvJuOzKw9+tBbLFfy807 nFYWvTo/rKPtxvBsl1fW54CpyPWhdbaQY5whJpzYEv1J45fXoWpICdwlt7gZ8k8J7I4N 7FOA== X-Gm-Message-State: APjAAAWNwLGregy0sZwWWjDG5W9KvYs8KWISf9GZaP+3kxfc391W97Mz nFLUdNeS1DNF9awJJhdy82JPag== X-Google-Smtp-Source: APXvYqwH2lSTiivo8tTOJFNPeXrwc5GAFb2V/uZp261NUxXupvCnpNqAEBtdNznT9fGnEEctEwTkZg== X-Received: by 2002:adf:94c5:: with SMTP id 63mr27203082wrr.199.1571054630563; Mon, 14 Oct 2019 05:03:50 -0700 (PDT) Return-Path: Received: from [10.0.0.122] ([84.203.40.122]) by smtp.googlemail.com with ESMTPSA id g1sm15082067wrv.68.2019.10.14.05.03.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 05:03:49 -0700 (PDT) Subject: Re: [edk2-devel] [edk2-platforms][PATCH v3 5/5] Platform/RPi3/PlatformSmbiosDxe: Derive RAM size from board revision To: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= , devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org References: <20191011110746.1952-1-pete@akeo.ie> <20191011110746.1952-6-pete@akeo.ie> <6782958e-fe36-8296-803a-ba8b90e4f985@redhat.com> From: "Pete Batard" Message-ID: <2c9a0255-3a90-cfde-f5bd-1893c01b299a@akeo.ie> Date: Mon, 14 Oct 2019 13:03:48 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <6782958e-fe36-8296-803a-ba8b90e4f985@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit 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 >>>> Reviewed-by: Leif Lindholm >>>> --- >>>> 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); >>>>   } >>>> >>> >> >> >> >> >