On Mon, 2 Nov 2026 at 10:33, Lorand Marton <[email protected]> wrote: > > The 8-bit DIV field of an A2W PLL channel divides by 256 when it is 0, > as Linux clk-bcm2835 describes it (CLK_DIVIDER_MAX_AT_ZERO on the PLL > dividers: 2^width at 0). pll_channel_update() took 0 as 255, so the > channel and every clock fed from it ran 0.4% fast, and QEMU and the > guest disagreed on its rate. > > Test the rate of PLLD_PER against PLLD with the divider at 0. > > Fixes: 957458111280 ("hw/misc/bcm2835_cprman: implement PLL channels > behaviour") > Signed-off-by: Lorand Marton <[email protected]> > --- > hw/misc/bcm2835_cprman.c | 6 ++-- > tests/qtest/bcm2835-cprman-test.c | 49 +++++++++++++++++++++++++++++++ > tests/qtest/meson.build | 3 +- > 3 files changed, 54 insertions(+), 4 deletions(-) > create mode 100644 tests/qtest/bcm2835-cprman-test.c > > diff --git a/hw/misc/bcm2835_cprman.c b/hw/misc/bcm2835_cprman.c > index 10cad07623..144e553432 100644 > --- a/hw/misc/bcm2835_cprman.c > +++ b/hw/misc/bcm2835_cprman.c > @@ -184,10 +184,10 @@ static void pll_channel_update(CprmanPllChannelState > *channel) > > if (!div) { > /* > - * It seems that when the divider value is 0, it is considered as > - * being maximum by the hardware (see the Linux driver). > + * A divider of 0 divides by 256, one more than the largest value > + * the field holds (Linux clk-bcm2835 uses CLK_DIVIDER_MAX_AT_ZERO). > */ > - div = R_A2W_PLLx_CHANNELy_DIV_MASK; > + div = 1 << R_A2W_PLLx_CHANNELy_DIV_LENGTH;
This kind of change should reference the hardware documentation, not the Linux kernel behaviour. What does the actual hardware do? thanks -- PMM
