public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Pete Batard" <pete@akeo.ie>
To: "Mario Bălănică" <mariobalanica02@gmail.com>, devel@edk2.groups.io
Subject: Re: [edk2-devel] [edk2-platforms][PATCH 1/1] Platform/RaspberryPi: Fix mini UART baud divisor calculation
Date: Sat, 3 Apr 2021 17:01:31 +0100	[thread overview]
Message-ID: <a5e8bb2c-a9b1-7d7e-94be-dfc930bfefc0@akeo.ie> (raw)
In-Reply-To: <31669.1617463027621445802@groups.io>

On 2021.04.03 16:17, Mario Bălănică wrote:
> I've submitted this patch because the mini UART serial console produces 
> garbage since UEFI v1.25 (due to the wrong baud rate).

OK.

When you fix something like this, please mention that there was a 
regression that requires fixing, in the commit message.

> It has been tested on the firmware shipped with UEFI v1.24 and it works 
> fine. I don't see any reason to test it on older versions than this.

Well, my worry is that you are removing this part:

 > -#if (RPI_MODEL == 4)
 > -  Divisor = MmioRead32(BCM2836_CM_BASE + 
BCM2836_CM_VPU_CLOCK_DIVISOR) & 0xFFFFFF;
 > -  if (Divisor != 0)
 > -    BaseClockRate = (BaseClockRate << 12) / Divisor;
 > -#endif

which was added due to serial issues with older versions of the firmware 
(much older than the one included in 1.24), to make it compatible with 
versions of start4.elf where the Pi Foundation had suffled the serial 
clock rates yet again.

I guess if we can't make both newer versions and these older versions 
work with the same code, we have to stick with what works for newer 
ones. But I'm still wondering what changed in the Pi firmware to make 
applying this divisor computation fail, especially as this was supposed 
to alleviate the precise serial baudrate issue you are trying to fix.

> The core clock is not fixed. I've made PcdSerialClockRate patchable here:
> 
>     @@ -465,6 +464,9 @@ [PcdsFixedAtBuild.common]
>     gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor|L"EDK2"
>     gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE
> 
>     +[PcdsPatchableInModule]
>     + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|500000000
>     +
> 
> 500 MHz is the default clock rate (assuming it hasn't been changed in 
> config.txt).
> The PCD gets patched in both the PEI and DXE phases to the value read 
> from mailbox.

Yeah, I had missed that.

I suppose we can go with what you suggest. But I'm still worried that 
the Pi Foundation are going to shuffle their clocks again in a future 
firmware, and that we'll be modifying this code yet again, as your patch 
is pretty much reverting the code to what we used to have... until we 
found it got broken by a newly introduced Pi Foundation firmware.

Regards,

/Pete

  reply	other threads:[~2021-04-03 16:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-02 17:51 [edk2-platforms][PATCH 1/1] Platform/RaspberryPi: Fix mini UART baud divisor calculation Mario Bălănică
2021-04-03  7:36 ` Ard Biesheuvel
2021-04-03 12:47   ` Mario Bălănică
2021-04-03 14:35     ` Pete Batard
2021-04-03 15:17       ` [edk2-devel] " Mario Bălănică
2021-04-03 16:01         ` Pete Batard [this message]
2021-04-03 16:15           ` Mario Bălănică
2021-04-03 16:48             ` Pete Batard
2021-04-03 16:55               ` Mario Bălănică
2021-04-03 17:32                 ` Mario Bălănică
2021-04-03 18:11                 ` Pete Batard
2021-04-03 22:45                   ` Mario Bălănică
2021-04-06 11:48                     ` 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=a5e8bb2c-a9b1-7d7e-94be-dfc930bfefc0@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