diff mbox series

mac_newworld: change timebase frequency from 100MHz to 25MHz for mac99 machine

Message ID 20240304073548.2098806-1-mark.cave-ayland@ilande.co.uk (mailing list archive)
State New, archived
Headers show
Series mac_newworld: change timebase frequency from 100MHz to 25MHz for mac99 machine | expand

Commit Message

Mark Cave-Ayland March 4, 2024, 7:35 a.m. UTC
MacOS X uses multiple techniques for calibrating timers depending upon the detected
hardware. One of these calibration routines compares the change in the timebase
against the KeyLargo timer and uses this to recalculate the clock frequency,
timebase frequency and bus frequency if the calibration exceeds certain limits.
This recalibration occurs despite the correct values being passed via the device
tree, and is likely due to buggy firmware on some hardware.

The timebase frequency of 100MHz was set way back in 2005 by commit fa296b0fb4
("PIC fix - changed back TB frequency to 100 MHz") and with this value on a
mac99,via=pmu machine the OSX 10.2 timer calibration incorrectly calculates the
bus frequency as 400MHz instead of 100MHz. The most noticeable side-effect is
the UI appears sluggish and not very responsive for normal use.

Change the timebase frequency from 100MHz to 25MHz which matches that of a real
G4 AGP machine (the closest match to QEMU's mac99 machine) and allows OSX 10.2
to correctly detect all of the clock frequency, timebase frequency and bus
frequency.

Tested on various MacOS images from OS 9.2 through to OSX 10.4, along with Linux
and NetBSD and I was unable to find any regressions from this change.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/ppc/mac_newworld.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé March 9, 2024, 5:51 p.m. UTC | #1
On 4/3/24 08:35, Mark Cave-Ayland wrote:
> MacOS X uses multiple techniques for calibrating timers depending upon the detected
> hardware. One of these calibration routines compares the change in the timebase
> against the KeyLargo timer and uses this to recalculate the clock frequency,
> timebase frequency and bus frequency if the calibration exceeds certain limits.
> This recalibration occurs despite the correct values being passed via the device
> tree, and is likely due to buggy firmware on some hardware.
> 
> The timebase frequency of 100MHz was set way back in 2005 by commit fa296b0fb4
> ("PIC fix - changed back TB frequency to 100 MHz") and with this value on a
> mac99,via=pmu machine the OSX 10.2 timer calibration incorrectly calculates the
> bus frequency as 400MHz instead of 100MHz. The most noticeable side-effect is
> the UI appears sluggish and not very responsive for normal use.
> 
> Change the timebase frequency from 100MHz to 25MHz which matches that of a real
> G4 AGP machine (the closest match to QEMU's mac99 machine) and allows OSX 10.2
> to correctly detect all of the clock frequency, timebase frequency and bus
> frequency.
> 
> Tested on various MacOS images from OS 9.2 through to OSX 10.4, along with Linux
> and NetBSD and I was unable to find any regressions from this change.
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>   hw/ppc/mac_newworld.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Philippe Mathieu-Daudé March 11, 2024, 8:38 a.m. UTC | #2
On 4/3/24 08:35, Mark Cave-Ayland wrote:
> MacOS X uses multiple techniques for calibrating timers depending upon the detected
> hardware. One of these calibration routines compares the change in the timebase
> against the KeyLargo timer and uses this to recalculate the clock frequency,
> timebase frequency and bus frequency if the calibration exceeds certain limits.
> This recalibration occurs despite the correct values being passed via the device
> tree, and is likely due to buggy firmware on some hardware.
> 
> The timebase frequency of 100MHz was set way back in 2005 by commit fa296b0fb4
> ("PIC fix - changed back TB frequency to 100 MHz") and with this value on a
> mac99,via=pmu machine the OSX 10.2 timer calibration incorrectly calculates the
> bus frequency as 400MHz instead of 100MHz. The most noticeable side-effect is
> the UI appears sluggish and not very responsive for normal use.
> 
> Change the timebase frequency from 100MHz to 25MHz which matches that of a real
> G4 AGP machine (the closest match to QEMU's mac99 machine) and allows OSX 10.2
> to correctly detect all of the clock frequency, timebase frequency and bus
> frequency.
> 
> Tested on various MacOS images from OS 9.2 through to OSX 10.4, along with Linux
> and NetBSD and I was unable to find any regressions from this change.
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>   hw/ppc/mac_newworld.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Merged as 78abf93cc7, thanks.
diff mbox series

Patch

diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index 3e796d2f6d..ff9e490c4e 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -77,7 +77,7 @@ 
 
 #define MAX_IDE_BUS 2
 #define CFG_ADDR 0xf0000510
-#define TBFREQ (100UL * 1000UL * 1000UL)
+#define TBFREQ (25UL * 1000UL * 1000UL)
 #define CLOCKFREQ (900UL * 1000UL * 1000UL)
 #define BUSFREQ (100UL * 1000UL * 1000UL)