From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.81]) by mx.groups.io with SMTP id smtpd.web12.2441.1571054012699024543 for ; Mon, 14 Oct 2019 04:53:32 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=c5L6SGhx; spf=pass (domain: redhat.com, ip: 207.211.31.81, mailfrom: philmd@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571054011; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uulcfjtxYWxlJfhOMrld+iEwiXcS5QvnRlV7zrKFfjE=; b=c5L6SGhxbzHEoQ0Zzg/4FlCrPKKquP7BXFZ0Hn0xmQIaRIW773cGhfATWGrTtSF8eC47Mr Sp1r0ugQqjyqhO9zINWyPfxyXptdPls1xB17oM4VcAxqsbvMQc4danli2Fxr/BXePH2HRm O4km8kOi3ZwfAx4Sy6IUMngpnyALVhg= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-53-Dz_Pd_gINQOBRZFeZpQ0Xw-1; Mon, 14 Oct 2019 07:53:30 -0400 Received: by mail-wm1-f72.google.com with SMTP id 190so7043770wme.4 for ; Mon, 14 Oct 2019 04:53:29 -0700 (PDT) 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=SpPkTP5Woq7hYedEviUaD+xuXe8bkrUmS2jSGDRUTEI=; b=gS9i+yWoBip+/kS+1e0tln+F+p3Fx2f6TJiWcYmNT/eCDrSNL6zJ71dO5PPZ/eqLUf z94N+JszOOckTG+7kVRaBshZoJvA38eGAZefbQ7J4Uhj4CeicPLFp+kufrh6JjD2r/Nn 0d4bR4nqA6sTd55qkrVwsQYznxfG7mpGPqe2MQ2rky9vEMaTzv05FYeeAPdYnS7qJzIH b/+OEHb5iqWDxVGGQ5aOU2XGiUgsbycqfWXBh8I5DBt5q5B43CtiYLZo4RvkVsW1zlrw BViF9ghKY5DUrMNrITTLQo/oji7T88zK/M5pVqonZ/vNqsltm3Q5T72oNvOXA6raI8pT YkRQ== X-Gm-Message-State: APjAAAU/NlpiZXdpROPKGRn+JQ+a33AvopT/6DaXfCJno7MWIAQ5oksE /8G7nFq9/jmB5jb4LtsNV/qaA522XIateOMUU43Y5XkLKgYULGJfuZwapjFGEnp74tsTeroD2I7 EzR9CgDehyyguXA== X-Received: by 2002:adf:fa50:: with SMTP id y16mr26964642wrr.171.1571054008226; Mon, 14 Oct 2019 04:53:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJaFSbhlk1ZfxOKb10f8zl82StK6X8IBq0jxslcRPPIFU3bwgO6YsHfNRYNlvejKTZ/Rc6fg== X-Received: by 2002:adf:fa50:: with SMTP id y16mr26964626wrr.171.1571054007928; Mon, 14 Oct 2019 04:53:27 -0700 (PDT) Return-Path: Received: from [192.168.1.35] (46.red-83-42-66.dynamicip.rima-tde.net. [83.42.66.46]) by smtp.gmail.com with ESMTPSA id t123sm31096230wma.40.2019.10.14.04.53.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Oct 2019 04:53:27 -0700 (PDT) Subject: Re: [edk2-devel] [edk2-platforms][PATCH v3 5/5] Platform/RPi3/PlatformSmbiosDxe: Derive RAM size from board revision To: devel@edk2.groups.io, pete@akeo.ie Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org References: <20191011110746.1952-1-pete@akeo.ie> <20191011110746.1952-6-pete@akeo.ie> From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= Message-ID: <6782958e-fe36-8296-803a-ba8b90e4f985@redhat.com> Date: Mon, 14 Oct 2019 13:53:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 In-Reply-To: X-MC-Unique: Dz_Pd_gINQOBRZFeZpQ0Xw-1 X-Mimecast-Spam-Score: 0 Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable On 10/14/19 1:44 PM, Pete Batard wrote: > Hi Philippe, >=20 > On 2019.10.14 11:01, Philippe Mathieu-Daud=C3=A9 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 o= f >>> RAM available as bits [20-22] report the effective RAM size for the=20 >>> 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=20 >>> | 18 ++++++++++++------ >>> =C2=A0 1 file changed, 12 insertions(+), 6 deletions(-) >>> >>> diff --git=20 >>> a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDx= e.c=20 >>> b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDx= e.c=20 >>> >>> index b5dcff897a59..5abc82b8d363 100644 >>> ---=20 >>> a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDx= e.c=20 >>> >>> +++=20 >>> b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDx= e.c=20 >>> >>> @@ -866,16 +866,22 @@ MemArrMapInfoUpdateSmbiosType19 ( >>> =C2=A0=C2=A0=C2=A0 ) >>> =C2=A0 { >>> =C2=A0=C2=A0=C2=A0 EFI_STATUS Status; >>> -=C2=A0 UINT32 Base; >>> -=C2=A0 UINT32 Size; >>> +=C2=A0 UINT32 BoardRevision =3D 0; >>> -=C2=A0 Status =3D mFwProtocol->GetArmMem (&Base, &Size); >>> +=C2=A0 // Note: Type 19 addresses are expressed in KB, not bytes >>> +=C2=A0 mMemArrMapInfoType19.StartingAddress =3D 0; >> >> Now you assume the ARM base RAM address is always 0, why? >=20 > Because, in the case that is of interest to us here (Broadcom SoCs used= =20 > for the various Raspberry Pi platforms), this is what the documentation= =20 > says. >=20 > If you look at something like=20 > https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.= pdf=20 > (which, as per the Pi Foundation, also applies to the later models) and= =20 > especially the memory layout graphic that you see early in the document,= = =20 > you can find that the ARM base RAM address is indeed set to 0 always. >=20 > At this stage, we have no reason to think that we are going to contend= =20 > 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=20 going to use tricks to allow more than 4GB of RAM on the Raspberry Pi 4,= =20 so I was wondering, since they provide a firmware API call to get the=20 RAM base address. Maybe you can add a comment that we expect all following boards to use=20 RAM base at 0 (simply replying to this email, and eventually Leif would=20 amend it previous to push). Otherwise your patch looks OK. Regards, Phil. >>> +=C2=A0 // The minimum RAM size used on any Raspberry Pi model is 256 = MB >>> +=C2=A0 mMemArrMapInfoType19.EndingAddress =3D 256 * 1024; >>> +=C2=A0 Status =3D mFwProtocol->GetModelRevision (&BoardRevision); >>> =C2=A0=C2=A0=C2=A0 if (Status !=3D EFI_SUCCESS) { >>> -=C2=A0=C2=A0=C2=A0 DEBUG ((DEBUG_ERROR, "Couldn't get the ARM memory = size: %r\n",=20 >>> Status)); >>> +=C2=A0=C2=A0=C2=A0 DEBUG ((DEBUG_WARNING, "Couldn't get the board mem= ory size -=20 >>> defaulting to 256 MB: %r\n", Status)); >>> =C2=A0=C2=A0=C2=A0 } else { >>> -=C2=A0=C2=A0=C2=A0 mMemArrMapInfoType19.StartingAddress =3D Base / 10= 24; >>> -=C2=A0=C2=A0=C2=A0 mMemArrMapInfoType19.EndingAddress =3D (Base + Siz= e - 1) / 1024; >>> +=C2=A0=C2=A0=C2=A0 //=20 >>> www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/= README.md=20 >>> >>> +=C2=A0=C2=A0=C2=A0 // Bits [20-22] indicate the amount of memory star= ting with=20 >>> 256MB (000b) >>> +=C2=A0=C2=A0=C2=A0 // and doubling in size for each value (001b =3D 5= 12 MB, 010b =3D=20 >>> 1GB, etc.) >>> +=C2=A0=C2=A0=C2=A0 mMemArrMapInfoType19.EndingAddress <<=3D (BoardRev= ision >> 20) &=20 >>> 0x07; >>> =C2=A0=C2=A0=C2=A0 } >>> +=C2=A0 mMemArrMapInfoType19.EndingAddress -=3D 1; >>> =C2=A0=C2=A0=C2=A0 LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mMemArrMa= pInfoType19,=20 >>> mMemArrMapInfoType19Strings, NULL); >>> =C2=A0 } >>> >> >=20 >=20 >=20 >=20