From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.61]) by mx.groups.io with SMTP id smtpd.web12.2577.1571054896805728014 for ; Mon, 14 Oct 2019 05:08:17 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OwQhRgZk; spf=pass (domain: redhat.com, ip: 205.139.110.61, mailfrom: philmd@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571054895; 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=n0zRE1v8cdP4xHiq7KIURc/vgrNfBnQKjf613ur0U7o=; b=OwQhRgZkA2L3jJdU4TcJCzWvFotObZ1P9wkJ0uxOOs7FxJLMNKp6ioFFotPqYGrRizsmhE wCFsSBelKroHeBFoZrI0Cfg7H2u0ONEGMqOcrKl8K/TcmXvGGywdaB+3RIHce2oZAx31zQ 4QoqTmlCKCb5pZA/Vrj89F04IfmXZtg= 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-250-c4QIDpVAM-uzCrf1_sd-AQ-1; Mon, 14 Oct 2019 08:08:13 -0400 Received: by mail-wm1-f72.google.com with SMTP id r187so6068720wme.0 for ; Mon, 14 Oct 2019 05:08:13 -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=HOPFhSukp33UUUw0Q4TgbEC7tLoNthxM41TJ+s4LBUM=; b=DPtjnnlKejbM0AiYCERr+vLxOq4nE27ovG4Pb1HSBb9O7635JiQ1ZlSj5SZyamMV8u 1RoYCJOqTx+z+o0MbR7YPMZ/yobzBShwPjTuAZV+qsPg1vpbKjPZmdaK2XVC1LV7bN07 piYvFRUqX+s8/eP5KP76qTwpWd2lNPBcOG1v8viuPSWjiq06+IYn+AOl4Xv/xmJGptYr cdau6aVG9c1pA07ISx4N6jmdNLE+0f+FFJOVVkQP9HH2ZR/bFzqt/YDkx1+N3OurWslK APEf9vRLApgEtxcMc+dmWa6fSnLBpuom3HCSglE3ZlkHHwjwz50Epl9xQjzFsh1U0zl3 UDtw== X-Gm-Message-State: APjAAAXVOfdYPMUDm5d1TUEZGuw/AntZGAgD8B+EeC9k3VcFxI8iiLbK BL394adDDXEZ+gJrYo12k2tJLAqP/ZuqDcCB7V9LOposai1/NvxSFzDWjxYp3tyznGo2QBUywmz kyUwxteSQ5vDLpw== X-Received: by 2002:a05:600c:2489:: with SMTP id 9mr13845104wms.23.1571054891808; Mon, 14 Oct 2019 05:08:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKpXqnPxs/8TXePN30pGb7gEVzMyIW5NqwyL6MZa7yGAKc85DkTUCxFrOBhWiKGagHHaMHQA== X-Received: by 2002:a05:600c:2489:: with SMTP id 9mr13845093wms.23.1571054891559; Mon, 14 Oct 2019 05:08:11 -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 n3sm8271286wrr.50.2019.10.14.05.08.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Oct 2019 05:08:11 -0700 (PDT) Subject: Re: [edk2-devel] [edk2-platforms][PATCH v3 5/5] Platform/RPi3/PlatformSmbiosDxe: Derive RAM size from board revision To: Pete Batard , 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> <2c9a0255-3a90-cfde-f5bd-1893c01b299a@akeo.ie> From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= Message-ID: <25a46221-1fc5-7795-2b5f-7564809579ae@redhat.com> Date: Mon, 14 Oct 2019 14:08:10 +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: <2c9a0255-3a90-cfde-f5bd-1893c01b299a@akeo.ie> X-MC-Unique: c4QIDpVAM-uzCrf1_sd-AQ-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 2:03 PM, Pete Batard wrote: > On 2019.10.14 12:53, Philippe Mathieu-Daud=C3=A9 wrote: >> On 10/14/19 1:44 PM, Pete Batard wrote: >>> Hi Philippe, >>> >>> 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=20 >>>>> amount of >>>>> 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/PlatformSmbiosDx= e.c=20 >>>>> | 18 ++++++++++++------ >>>>> =C2=A0 1 file changed, 12 insertions(+), 6 deletions(-) >>>>> >>>>> diff --git=20 >>>>> a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbios= Dxe.c=20 >>>>> b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbios= Dxe.c=20 >>>>> >>>>> index b5dcff897a59..5abc82b8d363 100644 >>>>> ---=20 >>>>> a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbios= Dxe.c=20 >>>>> >>>>> +++=20 >>>>> b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbios= Dxe.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 >=20 > Comment to add: >=20 > // The memory layout used in all known Pi SoC's starts at 0 Thanks, Leif do you mind amending this comment? Reviewed-by: Philippe Mathieu-Daude >>>>> +=C2=A0 mMemArrMapInfoType19.StartingAddress =3D 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=20 >>> used for the various Raspberry Pi platforms), this is what the=20 >>> documentation says. >>> >>> If you look at something like=20 >>> https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripheral= s.pdf=20 >>> (which, as per the Pi Foundation, also applies to the later models)=20 >>> and especially the memory layout graphic that you see early in the=20 >>> document, you can find that the ARM base RAM address is indeed set to= =20 >>> 0 always. >>> >>> At this stage, we have no reason to think that we are going to=20 >>> 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= =20 >> going to use tricks to allow more than 4GB of RAM on the Raspberry Pi= =20 >> 4, so I was wondering, since they provide a firmware API call to get=20 >> the RAM base address. >=20 > Well the thing is, this patch comes straight from work that is being=20 > carried out to add support for the Pi 4 to edk2-platforms. So we pretty= =20 > much already validated that 0 is what needs to be used for the Pi 4 as= =20 > well... OK, good news :) >> 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=20 >> would amend it previous to push). >=20 > Sure. Comment added above. Thanks! > Regards, >=20 > /Pete >=20 >> >> Otherwise your patch looks OK. >> >> Regards, >> >> Phil. >> >>>>> +=C2=A0 // The minimum RAM size used on any Raspberry Pi model is 25= 6 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 memor= y size: %r\n",=20 >>>>> Status)); >>>>> +=C2=A0=C2=A0=C2=A0 DEBUG ((DEBUG_WARNING, "Couldn't get the board m= emory 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 / = 1024; >>>>> -=C2=A0=C2=A0=C2=A0 mMemArrMapInfoType19.EndingAddress =3D (Base + S= ize - 1) / 1024; >>>>> +=C2=A0=C2=A0=C2=A0 //=20 >>>>> www.raspberrypi.org/documentation/hardware/raspberrypi/revision-code= s/README.md=20 >>>>> >>>>> +=C2=A0=C2=A0=C2=A0 // Bits [20-22] indicate the amount of memory st= arting with=20 >>>>> 256MB (000b) >>>>> +=C2=A0=C2=A0=C2=A0 // and doubling in size for each value (001b =3D= 512 MB, 010b =3D=20 >>>>> 1GB, etc.) >>>>> +=C2=A0=C2=A0=C2=A0 mMemArrMapInfoType19.EndingAddress <<=3D (BoardR= evision >> 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*)&mMemArr= MapInfoType19,=20 >>>>> mMemArrMapInfoType19Strings, NULL); >>>>> =C2=A0 } >>>>> >>>> >>> >>> >>>=20 >>> >> >=20