Re: enabling powerd on RPi

From: Mark Millard <marklmi_at_yahoo.com>
Date: Thu, 28 Dec 2023 20:22:16 UTC
On Dec 28, 2023, at 11:11, Mike Karels <mike@karels.net> wrote:

> I am looking at enabling powerd by default on the Raspberry Pi 4 and maybe
> others.  There is a bug from 2021 on the subject which has gotten some recent
> discussion, https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=256836.  Also,
> problems come up from time to time about performance problems because people
> don't know to enable powerd.  It makes FreeBSD look much slower than Linux.

If performance comparison to linux is a driving issue, seeing what
linux does about sdram_freq and sdram_freq_min may be relevant. This
may be in whole, or in part, based on the RPi* firmware version the:

https://www.raspberrypi.com/documentation/computers/config_txt.html#overclocking-options
and its:
"This table gives the default values for the options on various
Raspberry Pi models, all frequencies are stated in MHz."

content has varied as firmware releases have been made. But I've not
always found that the two match for FreeBSD. This might be because
they mixed firmware and linux defaults without being explicit,
something I've run into before. (I'll note that the history of the
documented defaults is available via giuthub, even if somewhat messy
as they restructured the documentation over time.)

For the RPi4B's and Pi 400's the modern tables indicate
sdram_freq_min=3200 is the default. It used to be sdram_freq_min=400 .
Recent testing of stable/14 snapshots with RPI4B's has shown the 400
figure is in use. Only the RPi4B's, Pi 400's, and Pi5 show non-400
defaults in the modern table.

Another such example is that RPi4B Rev 1.4+ is documented to have
arm_freq=1800 by default if arm_boot=1 in config.txt . Otherwise
RPi4B's are documented to use 1500 as the default.

But FreeBSD does not end up with the documented figures: ending up
matching the default arm_freq_min=600 instead of (all but Pi0/W,
Pi1, and Pi 5 are documhted to have the 600). My guess is that
FreeBSD makes its own assignments. Note that the default
arm_freq_min is model dependent if Pi0/W, Pi1, or [someday] Pi 5
are to be covered.

> The simplest action is to enable powerd by default on the arm64-aarch64-RPI
> images.  This would affect RPi 4 and variants, also RPI 3* and later RPi 2.
> I enabled powerd on an RPi 3B+, and it seems to have no issues; it seems
> to work.  Does anyone know of a disadvantage of enabling powerd on RPI
> images for all targets?

Serial port configurations that attempt to use the mini-uart have
problems with core_freq changes changing the serial console
frequency in use. (mini-uart used for bluetooth instead has such
issues too.) Which UART is used by default varies by model, the
bluetooth capable families (so, e.g., not Pi2) having the
mini-uart for the serial port and full UART for bluetooth. (I'm
not clear on the v1.1 vs. v1.2 for the RPi2B's.) core_freq and
core_freq_min also vary by model.

There is a core_freq_min. core_freq and core_freq_min defaults
are documented as model specific. hdmi_enable_4kp60 use
changes the default for core_freq and core_freq_min as well.
There is enable_uart=1 to force the core clock to be fixed
for seerial use, which frequency is dependent on force_turbo=1
vs. not.

I do not know what FreeBSD does about such things if it does
not match such documentation.

There is:

https://www.raspberrypi.com/documentation/computers/configuration.html#configuring-uarts

that says, in part,

QUOTE
In order to use the mini UART, you need to configure the
Raspberry Pi to use a fixed VPU core clock frequency
END QUOTE

I'll also note that arm_64bit=1 is the default for the RPi4B's,
Pi 400, CM4, and CM4S these days, but not for the rest that are
64=bit capable (ignoring RPi5's, which do not have the parameter).
I do not know what FreeBSD does about such things if it does
not match such documentation.

> The alternative would be to configure at the first
> boot, although I'm not positive of a definitive way to identify the RPi
> variants.  Maybe just looking for a dev.cpu.0.freq sysctl node would
> suffice.
> 
> If no one objects, I will make changes to enable powerd on RPI snapshots
> for 15-current, and we can see what happens.



===
Mark Millard
marklmi at yahoo.com