Page 1 of 2

question about low-level SMP detail;s in G4 Macs?

Posted: Wed May 15, 2024 1:36 pm
by Andrew_R
I bothered comrade Zoltan about this , he suggested to post my question to broader audience
so ... wall of text from my yesterday research
>>>>> https://opensource.apple.com/source/xnu ... .auto.html
>>>>>
>>>>> talks about Daystar SMP machine.? Not sure if enough info survived
>>>>> about those ..... not sure where new g4 stuff lives ....
>>>>>
>>>>> Funnily someone found Mac on Mac early hypervizor (?) at
>>>>> https://forums.macrumors.com/threads/po ... 653/page-3
>>>>>
>>>>>
>>>>> files themselves on macintoshgarden, will try to get them just for look
>>>>> .. there was some sort of virtual coreaudio device, might be useful too?
>>>>>
>>>>> this is in response to SMP ppc request(s) that surface once in few
>>>>> years (each time someone tries to build *fox on qemu ? :) )
>>>>>
>>>>> ps: yes, I see you work on main qemu-devel. do not want to interrupt,
>>>>> but may be some of this will be of any use....
>>>>>
>>>>
>>>>
>>>> according to this changelog FreeBSD 8.2 supported SMP on PowerMac 3.3
>>>>
>>>> https://www.freebsd.org/releases/8.2R/r ... -detailed/
>>>>
>>>> https://svnweb.freebsd.org/base?view=re ... ion=209767
>>>>
>>>> at least in FreeBSD case we can see OF properties it tries to access?
>>>>
>>>
>>>
>>> so, fbsd set IPI inter procrssor interrupt using powerpc's Programmable
>>> Interrupt Controller ?
>>>
>>>
>>> https://svnweb.freebsd.org/base/stable/ ... rev=209767
>>>
>>>
>>> 3 void
>>> 244 powerpc_register_pic(device_t dev, u_int ipi)
>>> 245 {
>>> 246
>>> 247 pic = dev;
>>> 248 ipi_irq = ipi + ISA_IRQ_COUNT;
>>> 249 }
>>> 250
>>> 251 void
>>> 252 powerpc_register_8259(device_t dev)
>>> 253 {
>>> 254
>>> 255 pic8259 = dev;
>>> 256 }
>>> 257
>>> 258 int
>>> 259 powerpc_enable_intr(void)
>>> 260 {
>>> 261 struct powerpc_intr *i;
>>> 262 int error, vector;
>>> 263
>>> 264 if (pic == NULL)
>>> 265 panic("no PIC detected\n");
>>> 266
>>> 267 #ifdef SMP
>>> 268 /* Install an IPI handler. */
>>> 269 error = powerpc_setup_intr("IPI", ipi_irq,
>>> powerpc_ipi_handler,
>>> 270 NULL, NULL, INTR_TYPE_MISC | INTR_EXCL | INTR_FAST,
>>> &ipi_cookie);
>>> 271 if (error) {
>>> 272 printf("unable to setup IPI handler\n");
>>> 273 return (error);
>>> 274 }
>>> 275 #endif
>>>
>>> not sure how qemu mac99 machine set up interrupts ... need to dig! (I
>>> tried this few years ago without any success .. may be on Nth try)
>>>
>>
>> ah, linux sources (cmt) says timebase freeze done on smp g4 via gpio .
>>
>>
>> https://elixir.bootlin.com/linux/latest ... rmac/smp.c
>>
>>
>>
>> not sure why it must work this way? is it part of online cpu
>> enable/disable? Ah no this is optional with sw fallback ....
>>
>>
>>
>> https://elixir.bootlin.com/linux/latest ... rmac/pic.c
>>
>> ====
>>
>> /* We first try to detect Apple's new Core99 chipset, since mac-io
>> * is quite different on those machines and contains an IBM MPIC2.
>> */
>>
>>
>> ====
>>
>>
>> amazing ... yet another name!
>>
>>
>> https://mail.coreboot.org/hyperkitty/li ... 575PJMALR/
>>
>>
>> so interrupt controller itself seems
>>
>> to be in openfirmware since early days
>>
>> ===
>>
>> 0x1014, 0xFFFF,
>> + PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OPENPIC2,
>> "open-pic", "MPIC2", NULL, "chrp,open-pic\0",
>>
>> =====
>>
>>
>> guess I need something like diagram for figuring out
>>
>> how smp interrupts were supposed to work ...
>>
>>
>> http://web.mit.edu/darwin/src/modules/A ... leMPIC.cpp
>>
>>
>> // IPI Vectors start masked with priority 14.
>> regTemp = kIntnVPRMask | (14 << kIntnVPRPriorityShift);
>> regTemp |= vectorNumber << kIntnVPRVectorShift;
>> stwbrx(regTemp, vectorBase + kIPInVecPriOffset);
>> eieio();
>>
>>
>> my lack of fundamental knowledge really shows
>>
>>
> in e500 machine openpic inited like
>
>
> dev = qdev_new(TYPE_OPENPIC);
> object_property_add_child(OBJECT(machine), "pic", OBJECT(dev));
> qdev_prop_set_uint32(dev, "model", pmc->mpic_version);
> qdev_prop_set_uint32(dev, "nb_cpus", smp_cpus);
>
> yet in newworld mac machine it inited like
>
>
> pic_dev = DEVICE(object_resolve_path_component(macio, "pic"));
> for (i = 0; i < 4; i++) {
> qdev_connect_gpio_out(uninorth_pci_dev, i,
> qdev_get_gpio_in(pic_dev, 0x1b + i));
> }
>
> may be it also need
>
> qdev_prop_set_uint32(dev, "nb_cpus", smp_cpus);
>
> set on it? because I saw openpic controller defaults to 1 cpu
So my main problem is finding relevant for emulation details about how this openPIC, MPCI2 ? was connected to rest of the system on especially G4 machines (G5 SMP is different beast). Guess qemu must told openfirmware to generate more than one "cpu" node, so guests will try to init more than one CPU at very minimum? But for openfirmware compilation I need x86-> ppc cross compiler, right?

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Wed May 15, 2024 6:08 pm
by adespoton
Andrew_R wrote: Wed May 15, 2024 1:36 pm I bothered comrade Zoltan about this , he suggested to post my question to broader audience
so ... wall of text from my yesterday research

...

So my main problem is finding relevant for emulation details about how this openPIC, MPCI2 ? was connected to rest of the system on especially G4 machines (G5 SMP is different beast). Guess qemu must told openfirmware to generate more than one "cpu" node, so guests will try to init more than one CPU at very minimum? But for openfirmware compilation I need x86-> ppc cross compiler, right?
Well, I've got a QEMU-PPC image running 9.2.2 that I use to compile OpenFirmware stuff. It's got CodeWarrior on it, and works great. Now that we've got virtfs drivers for 9.2.2, it's simple to move the compiled objects out of the image to test on the host.

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Wed May 15, 2024 7:54 pm
by Cat_7
But for openfirmware compilation I need x86-> ppc cross compiler, right?
Yes. There is also a docker image doing the hard lifting for openbios compilation, see here: https://github.com/mcayland/openbios/commits/master/

Best,
Cat_7

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Tue May 21, 2024 2:16 pm
by Andrew_R
just to say I compiled Openfirmware with this patch (using cross compiler in Debian 11 x86-64 VM)

Code: Select all

diff --git a/arch/ppc/qemu/init.c b/arch/ppc/qemu/init.c
index 253394c..7b7b09d 100644
--- a/arch/ppc/qemu/init.c
+++ b/arch/ppc/qemu/init.c
@@ -348,8 +348,9 @@ cpu_add_pir_property(void)
     unsigned long pir;

     asm("mfspr %0, 1023\n"
-        : "=r"(pir) :);
+        : "=r"(pir) :);;
     PUSH(pir);
+    printk("Pir = %lu \n", pir);
     fword("encode-int");
     push_str("reg");
     fword("property");
@@ -381,9 +382,9 @@ static void
 cpu_g4_init(const struct cpudef *cpu)
 {
     cpu_generic_init(cpu);
-    cpu_add_pir_property();
+        //cpu_add_pir_property();

-    fword("finish-device");
+    //fword("finish-device");
 }

 #ifdef CONFIG_PPC_64BITSUPPORT
@@ -1073,13 +1074,23 @@ arch_of_init(void)
     push_str("reg");
     fword("property");

+    int i;
+
+    for (i= 0; i<temp; i++) {
     cpu = id_cpu();
     cpu->initfn(cpu);
-    printk("CPU type %s\n", cpu->name);

-    snprintf(buf, sizeof(buf), "/cpus/%s", cpu->name);
+    printk("CPU type %s\n", cpu->name);
+        snprintf(buf, sizeof(buf), "/cpus/%s", cpu->name);
+       PUSH(i);
+        fword("encode-int");
+        push_str("reg");
+        fword("property");
+        fword("finish-device");
+    }
     ofmem_register(find_dev("/memory"), find_dev(buf));
     node_methods_init(buf);
+

 #ifdef CONFIG_RTAS
     /* OldWorld Macs don't have an /rtas node. */

Now Linux/NetBSD detect additional processors but Linux fails to kick them up:

Code: Select all

[    0.149749] PowerMac SMP probe found 2 cpus
[    0.152131] PMU i2c /pci@f2000000/mac-io@c/via-pmu@16000
[    0.153243]  channel 1 bus <multibus>
[    0.153610]  channel 2 bus <multibus>
[    0.154660] Processor timebase sync using GPIO 0x73
[    0.155199] mpic: requesting IPIs...
[    0.159006] CPU0: L2CR is 0
[    0.175673] rcu: Hierarchical SRCU implementation.
[    0.198787] smp: Bringing up secondary CPUs ...
smp_core99_kick_cpu
macio_gpio_write addr: 0xc value: 0x4
macio_gpio_write addr: 0x4 value: 0x4
macio_gpio_write addr: 0xc value: 0x0
macio_gpio_write addr: 0x4 value: 0x0
smp_core99_kick_cpu done
macio_set_gpio setting GPIO 1 to 0
macio_set_gpio setting GPIO 1 to 0
macio_set_gpio setting GPIO 1 to 0
macio_set_gpio setting GPIO 1 to 0
macio_set_gpio setting GPIO 1 to 0
[    5.244500] Processor 1 is stuck.
[    5.253569] smp: Brought up 1 node, 1 CPU


NetBSD 10.0 and Linux behave a bit differently with my patched qemu, so I guess they assign IRQs differently?
NetBSD soldier on with hacked qemu and smp=1, Linux can't find IDE disks anymore due to timeouts.

Got some help on port-macppc:
http://mail-index.netbsd.org/port-macpp ... 03117.html

but this might be only start for very long road ....

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Tue May 21, 2024 4:33 pm
by Cat_7
Nice progress!
Do you also have that patch to qemu to allow smp=2 for the mac99 machine available?

Best,
Cat_7

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Fri Feb 14, 2025 7:20 am
by darthnvader
Cat_7 wrote: Tue May 21, 2024 4:33 pm Nice progress!
Do you also have that patch to qemu to allow smp=2 for the mac99 machine available?

Best,
Cat_7
Cat, is there some instructions for using docker to build Openbios on the macOS?

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Fri Feb 14, 2025 11:37 am
by darthnvader
Andrew_R wrote: Tue May 21, 2024 2:16 pm just to say I compiled Openfirmware with this patch (using cross compiler in Debian 11 x86-64 VM)

Code: Select all

diff --git a/arch/ppc/qemu/init.c b/arch/ppc/qemu/init.c
index 253394c..7b7b09d 100644
--- a/arch/ppc/qemu/init.c
+++ b/arch/ppc/qemu/init.c
@@ -348,8 +348,9 @@ cpu_add_pir_property(void)
     unsigned long pir;

     asm("mfspr %0, 1023\n"
-        : "=r"(pir) :);
+        : "=r"(pir) :);;
     PUSH(pir);
+    printk("Pir = %lu \n", pir);
     fword("encode-int");
     push_str("reg");
     fword("property");
@@ -381,9 +382,9 @@ static void
 cpu_g4_init(const struct cpudef *cpu)
 {
     cpu_generic_init(cpu);
-    cpu_add_pir_property();
+        //cpu_add_pir_property();

-    fword("finish-device");
+    //fword("finish-device");
 }

 #ifdef CONFIG_PPC_64BITSUPPORT
@@ -1073,13 +1074,23 @@ arch_of_init(void)
     push_str("reg");
     fword("property");

+    int i;
+
+    for (i= 0; i<temp; i++) {
     cpu = id_cpu();
     cpu->initfn(cpu);
-    printk("CPU type %s\n", cpu->name);

-    snprintf(buf, sizeof(buf), "/cpus/%s", cpu->name);
+    printk("CPU type %s\n", cpu->name);
+        snprintf(buf, sizeof(buf), "/cpus/%s", cpu->name);
+       PUSH(i);
+        fword("encode-int");
+        push_str("reg");
+        fword("property");
+        fword("finish-device");
+    }
     ofmem_register(find_dev("/memory"), find_dev(buf));
     node_methods_init(buf);
+

 #ifdef CONFIG_RTAS
     /* OldWorld Macs don't have an /rtas node. */

Now Linux/NetBSD detect additional processors but Linux fails to kick them up:

Code: Select all

[    0.149749] PowerMac SMP probe found 2 cpus
[    0.152131] PMU i2c /pci@f2000000/mac-io@c/via-pmu@16000
[    0.153243]  channel 1 bus <multibus>
[    0.153610]  channel 2 bus <multibus>
[    0.154660] Processor timebase sync using GPIO 0x73
[    0.155199] mpic: requesting IPIs...
[    0.159006] CPU0: L2CR is 0
[    0.175673] rcu: Hierarchical SRCU implementation.
[    0.198787] smp: Bringing up secondary CPUs ...
smp_core99_kick_cpu
macio_gpio_write addr: 0xc value: 0x4
macio_gpio_write addr: 0x4 value: 0x4
macio_gpio_write addr: 0xc value: 0x0
macio_gpio_write addr: 0x4 value: 0x0
smp_core99_kick_cpu done
macio_set_gpio setting GPIO 1 to 0
macio_set_gpio setting GPIO 1 to 0
macio_set_gpio setting GPIO 1 to 0
macio_set_gpio setting GPIO 1 to 0
macio_set_gpio setting GPIO 1 to 0
[    5.244500] Processor 1 is stuck.
[    5.253569] smp: Brought up 1 node, 1 CPU


NetBSD 10.0 and Linux behave a bit differently with my patched qemu, so I guess they assign IRQs differently?
NetBSD soldier on with hacked qemu and smp=1, Linux can't find IDE disks anymore due to timeouts.

Got some help on port-macppc:
http://mail-index.netbsd.org/port-macpp ... 03117.html

but this might be only start for very long road ....
Hacking around a bit I got OpenBios to come up once with -smp 2 and was able to verify 2 /cpus @0 and @1. but I can't get Openbios to come up anymore???

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Fri Feb 14, 2025 1:45 pm
by Cat_7

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Fri Feb 14, 2025 2:50 pm
by darthnvader
Cat_7 wrote: Fri Feb 14, 2025 1:45 pm Will this help?

https://github.com/mcayland/openbios/pk ... os-builder

Best,
Cat_7
No I have no clue how to use Docker?

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Fri Feb 14, 2025 4:13 pm
by darthnvader
Cat_7 wrote: Tue May 21, 2024 4:33 pm Nice progress!
Do you also have that patch to qemu to allow smp=2 for the mac99 machine available?

Best,
Cat_7
https://lists.nongnu.org/archive/html/q ... U9D7Df.txt

Cat this diff will get it up and running, you'll likely need to:

Code: Select all

git apply   --whitespace=fix FILE.diff
I also had to fix the paths to the files by adding /. so hw/ppc/* becomes /hw/ppc/*.

This issue is it breaks Openbios brings the full /cpu .properties up so we can get BootX to load the mach_kernel but just the first few lines of the kernels output and we hang there.....

With just a few patches applied I got a 'running' state for my /cpus but could out get Openbios to load now and then with not rhyme or reason.

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Fri Feb 14, 2025 4:51 pm
by darthnvader
darthnvader wrote: Fri Feb 14, 2025 4:13 pm
Cat_7 wrote: Tue May 21, 2024 4:33 pm Nice progress!
Do you also have that patch to qemu to allow smp=2 for the mac99 machine available?

Best,
Cat_7
https://lists.nongnu.org/archive/html/q ... U9D7Df.txt

Cat this diff will get it up and running, you'll likely need to:

Code: Select all

git apply   --whitespace=fix FILE.diff
I also had to fix the paths to the files by adding /. so hw/ppc/* becomes /hw/ppc/*.

This issue is it breaks Openbios brings the full /cpu .properties up so we can get BootX to load the mach_kernel but just the first few lines of the kernels output and we hang there.....

With just a few patches applied I got a 'running' state for my /cpus but could out get Openbios to load now and then with not rhyme or reason.
All of this adds 2 CPUs but we still get:

Code: Select all

qemu-system-ppc-unsigned: -accel tcg,thread=multi: warning: Guest not yet converted to MTTCG - you may get unexpected results
So we are going to have to get that going if we actually want more than one of the host cores to work on this too....

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Fri Feb 14, 2025 5:03 pm
by darthnvader
We're still waiting for the root device....

So we get the kernel, but something is going wrong with IDE:

Code: Select all

./qemu-system-ppc64-unsigned   -m 1024 -M mac99,via=pmu -bios /Users/jam/Documents/openbios-qemu.elf -cpu 7455 -hda ~/Snow*.img -prom-env 'auto-boot?=false' -prom-env 'boot-args=-v -x -s' -smp 2,cores=2,threads=1 -accel tcg,thread=multi -d guest_errors -serial stdio
WARNING: Image format was not specified for '/Users/jam/SnowLeopardPPC.img' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.
2025-02-14 11:55:28.065 qemu-system-ppc64-unsigned[21189:32292017] +[IMKClient subclass]: chose IMKClient_Modern
2025-02-14 11:55:28.065 qemu-system-ppc64-unsigned[21189:32292017] +[IMKInputSession subclass]: chose IMKInputSession_Modern
s>> et_property: NULL phandle

>> =============================================================
>> OpenBIOS 1.1 [Feb 14 2025 10:28]
>> Configuration device id QEMU version 1 machine id 1
>> CPUs: 2
>> Memory: 1024M
>> UUID: 00000000-0000-0000-0000-000000000000
>> CPU type PowerPC,G4
>> CPU type PowerPC,G4
milliseconds isn't unique.
>> switching to new context:
>> call-method slw_update_keymap failed with error ffffffdf
>> call-method slw_update_keymap failed with error ffffffdf
Trying to read invalid spr 1012 (0x3f4) at 00000000000a6684
dbdma_unassigned_flush: use of unassigned channel 0
dbdma_unassigned_flush: use of unassigned channel 0<---------HERE!

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Fri Feb 14, 2025 5:21 pm
by adespoton
How much work are we looking at to get multithreading working on PPC TCG? Who would we even ask? Would Mark know?

Seems to me that switching to an MT model would have benefits that go far beyond SMP.

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Fri Feb 14, 2025 5:44 pm
by darthnvader
Pretty much the same deal with OS 9, we get through to the nanoKernel and our screen gets it's 'ndrv', but just a blinking ? for the HD.

It can't find the System Folder.

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Fri Feb 14, 2025 5:45 pm
by darthnvader
adespoton wrote: Fri Feb 14, 2025 5:21 pm How much work are we looking at to get multithreading working on PPC TCG? Who would we even ask? Would Mark know?

Seems to me that switching to an MT model would have benefits that go far beyond SMP.
I always thought the two worked together, no?

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Fri Feb 14, 2025 6:03 pm
by darthnvader
The Debian NetInstall ISO gives us a little more info about what is going on with DMA and the IDE bus:

Code: Select all

 23.031560] usb usb1: Product: OHCI PCI host controller
[   23.031729] usb usb1: Manufacturer: Linux 4.16.0-1-powerpc ohci_hcd
[   23.031921] usb usb1: SerialNumber: 0000:00:0d.0
[   23.047394] hub 1-0:1.0: USB hub found
[   23.062352] hub 1-0:1.0: 3 ports detected
[   23.465088] usb 1-1: new full-speed USB device number 2 using ohci-pci
[   54.293441] ata1: lost interrupt (Status 0x50)
[   54.294613] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[   54.295024] ata1.00: failed command: READ DMA
[   54.295284] ata1.00: cmd c8/00:08:00:00:00/00:00:00:00:00/e0 tag 0 dma 4096 in
[   54.295284]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x20 (host bus error)
[   54.295864] ata1.00: status: { DRDY }
[   54.297861] ata1.00: configured for MWDMA2
[   54.298538] ata1.00: device reported invalid CHS sector 0
[   54.299473] ata1: EH complete
[   85.001325] ata1: lost interrupt (Status 0x50)
[   85.001690] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[   85.001906] ata1.00: failed command: READ DMA
[   85.002074] ata1.00: cmd c8/00:08:00:00:00/00:00:00:00:00/e0 tag 0 dma 4096 in
[   85.002074]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x20 (host bus error)
[   85.002521] ata1.00: status: { DRDY }
[   85.003858] ata1.00: configured for MWDMA2
[   85.004024] ata1.00: device reported invalid CHS sector 0
[   85.004269] ata1: EH complete
[  117.768402] ata1: lost interrupt (Status 0x50)
[  117.768731] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[  117.768932] ata1.00: failed command: READ DMA
[  117.769080] ata1.00: cmd c8/00:08:00:00:00/00:00:00:00:00/e0 tag 0 dma 4096 in
[  117.769080]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x20 (host bus error)
[  117.769529] ata1.00: status: { DRDY }
[  117.770656] ata1.00: configured for MWDMA2
[  117.770812] ata1.00: device reported invalid CHS sector 0
[  117.771025] ata1: EH complete
Startin

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Fri Feb 14, 2025 6:32 pm
by Cat_7
How much work are we looking at to get multi-threading working on PPC TCG? Who would we even ask? Would Mark know?
Mark might know, but the last one putting any effort into guiding someone who did an attempt at SMP was Zoltan.
Their conversation is here: https://lists.nongnu.org/archive/cgi-bi ... sort=score

One comment from Mark I came across is:
Try rebuilding OpenBIOS with DEBUG_CIF enabled in libopenbios/client.c which will
show the calls being used by the bootloader.


BTW, and re: the patch: cpu number of 4 seems a bit steep for a processor which seems to have had a max of 2? in real hardware?

Do we have a device tree from a real dual CPU G4?

From wikipedia:
The Apple Hydra Mac I/O (MIO) chip (from the 1990s classic Mac OS era) implemented a MPIC alongside a SCSI controller, ADB controller, GeoPort controller, and timers.[7] The Apple implementation of "Open PIC" (as the Apple documentation of this era spells it) in their first MIO chip for the Common Hardware Reference Platform was based on version 1.2 of the register specification and supported up to two processors and up to 20 interrupt sources.[8] A MPIC was also incorporated in the newer K2 I/O controller used in the Power Mac G5s.[9][10]

Here: https://github.com/torvalds/linux/blob/ ... dev/mpic.c
The name of Benjamin props up. He contributes to Qemu (made the pmu needed for Leopard). I guess he would now how to proceed with this.

Best,
Cat_7

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Fri Feb 14, 2025 6:35 pm
by adespoton
darthnvader wrote: Fri Feb 14, 2025 6:03 pm The Debian NetInstall ISO gives us a little more info about what is going on with DMA and the IDE bus:

Code: Select all

 23.031560] usb usb1: Product: OHCI PCI host controller
[   23.031729] usb usb1: Manufacturer: Linux 4.16.0-1-powerpc ohci_hcd
[   23.031921] usb usb1: SerialNumber: 0000:00:0d.0
[   23.047394] hub 1-0:1.0: USB hub found
[   23.062352] hub 1-0:1.0: 3 ports detected
[   23.465088] usb 1-1: new full-speed USB device number 2 using ohci-pci
[   54.293441] ata1: lost interrupt (Status 0x50)
[   54.294613] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[   54.295024] ata1.00: failed command: READ DMA
[   54.295284] ata1.00: cmd c8/00:08:00:00:00/00:00:00:00:00/e0 tag 0 dma 4096 in
[   54.295284]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x20 (host bus error)
[   54.295864] ata1.00: status: { DRDY }
[   54.297861] ata1.00: configured for MWDMA2
[   54.298538] ata1.00: device reported invalid CHS sector 0
[   54.299473] ata1: EH complete
[   85.001325] ata1: lost interrupt (Status 0x50)
[   85.001690] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[   85.001906] ata1.00: failed command: READ DMA
[   85.002074] ata1.00: cmd c8/00:08:00:00:00/00:00:00:00:00/e0 tag 0 dma 4096 in
[   85.002074]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x20 (host bus error)
[   85.002521] ata1.00: status: { DRDY }
[   85.003858] ata1.00: configured for MWDMA2
[   85.004024] ata1.00: device reported invalid CHS sector 0
[   85.004269] ata1: EH complete
[  117.768402] ata1: lost interrupt (Status 0x50)
[  117.768731] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[  117.768932] ata1.00: failed command: READ DMA
[  117.769080] ata1.00: cmd c8/00:08:00:00:00/00:00:00:00:00/e0 tag 0 dma 4096 in
[  117.769080]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x20 (host bus error)
[  117.769529] ata1.00: status: { DRDY }
[  117.770656] ata1.00: configured for MWDMA2
[  117.770812] ata1.00: device reported invalid CHS sector 0
[  117.771025] ata1: EH complete
Startin
So... SMP introducing timing issues that are affecting ATA? I haven't looked at the code yet; I'm not quite clear how SMP in TCG works without multithreading. Seems to me that WITH multithreading, this would become even more of an issue; thread states would need to be tracked and synchronized.

I really want to have the time to dig into this xP

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Fri Feb 14, 2025 6:54 pm
by darthnvader
adespoton wrote: Fri Feb 14, 2025 6:35 pm
darthnvader wrote: Fri Feb 14, 2025 6:03 pm The Debian NetInstall ISO gives us a little more info about what is going on with DMA and the IDE bus:

Code: Select all

 23.031560] usb usb1: Product: OHCI PCI host controller
[   23.031729] usb usb1: Manufacturer: Linux 4.16.0-1-powerpc ohci_hcd
[   23.031921] usb usb1: SerialNumber: 0000:00:0d.0
[   23.047394] hub 1-0:1.0: USB hub found
[   23.062352] hub 1-0:1.0: 3 ports detected
[   23.465088] usb 1-1: new full-speed USB device number 2 using ohci-pci
[   54.293441] ata1: lost interrupt (Status 0x50)
[   54.294613] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[   54.295024] ata1.00: failed command: READ DMA
[   54.295284] ata1.00: cmd c8/00:08:00:00:00/00:00:00:00:00/e0 tag 0 dma 4096 in
[   54.295284]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x20 (host bus error)
[   54.295864] ata1.00: status: { DRDY }
[   54.297861] ata1.00: configured for MWDMA2
[   54.298538] ata1.00: device reported invalid CHS sector 0
[   54.299473] ata1: EH complete
[   85.001325] ata1: lost interrupt (Status 0x50)
[   85.001690] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[   85.001906] ata1.00: failed command: READ DMA
[   85.002074] ata1.00: cmd c8/00:08:00:00:00/00:00:00:00:00/e0 tag 0 dma 4096 in
[   85.002074]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x20 (host bus error)
[   85.002521] ata1.00: status: { DRDY }
[   85.003858] ata1.00: configured for MWDMA2
[   85.004024] ata1.00: device reported invalid CHS sector 0
[   85.004269] ata1: EH complete
[  117.768402] ata1: lost interrupt (Status 0x50)
[  117.768731] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[  117.768932] ata1.00: failed command: READ DMA
[  117.769080] ata1.00: cmd c8/00:08:00:00:00/00:00:00:00:00/e0 tag 0 dma 4096 in
[  117.769080]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x20 (host bus error)
[  117.769529] ata1.00: status: { DRDY }
[  117.770656] ata1.00: configured for MWDMA2
[  117.770812] ata1.00: device reported invalid CHS sector 0
[  117.771025] ata1: EH complete
Startin
So... SMP introducing timing issues that are affecting ATA? I haven't looked at the code yet; I'm not quite clear how SMP in TCG works without multithreading. Seems to me that WITH multithreading, this would become even more of an issue; thread states would need to be tracked and synchronized.

I really want to have the time to dig into this xP
SMP isn't actually working tho, qemu never get's more than 100% cpu time. I thought that smp required TGC multithreading?

Isn't TGC the default accelerator?

Anyways I'll try it with the hypervisor on a Quad G5 with accel set to KVM and see if it gets any further or more CPU time...

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Sat Feb 15, 2025 1:03 am
by darthnvader
Just for the fun of it...

Code: Select all

>> =============================================================
>> OpenBIOS 1.1 [Feb 14 2025 10:28]
>> Configuration device id QEMU version 1 machine id 1
>> CPUs: 8
>> Memory: 1024M
>> UUID: 00000000-0000-0000-0000-000000000000
>> CPU type PowerPC,G4
>> CPU type PowerPC,G4
>> CPU type PowerPC,G4
>> CPU type PowerPC,G4
>> CPU type PowerPC,G4
>> CPU type PowerPC,G4
>> CPU type PowerPC,G4
>> CPU type PowerPC,G4
milliseconds isn't unique.
Welcome to OpenBIOS v1.1 built on Feb 14 2025 10:28

0 > dev /cpus ls 
fff6b30c PowerPC,G4@0
fff6b5c0 PowerPC,G4@1
fff6b874 PowerPC,G4@2
fff6bb28 PowerPC,G4@3
fff6bddc PowerPC,G4@4
fff6c090 PowerPC,G4@5
fff6c344 PowerPC,G4@6
fff6c5f8 PowerPC,G4@7
 ok
0 > dev /cpus/@7  ok
0 > .properties 
name                      "PowerPC,G4"
device_type               "cpu"
cpu-version               80010302 
d-cache-size              8000 
i-cache-size              8000 
d-cache-sets              80 
i-cache-sets              80 
d-cache-block-size        20 
i-cache-block-size        20 
tlb-sets                  40 
tlb-size                  80 
timebase-frequency        17d7840 
clock-frequency           35a4e900 
bus-frequency             5f5e100 
state                     "running"
reservation-granule-size  20 
reg                       00000007
 ok
0 > 

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Sat Feb 15, 2025 4:28 am
by adespoton
darthnvader wrote: Sat Feb 15, 2025 1:03 am Just for the fun of it...

Code: Select all

>> =============================================================
>> OpenBIOS 1.1 [Feb 14 2025 10:28]
>> Configuration device id QEMU version 1 machine id 1
>> CPUs: 8
>> Memory: 1024M
>> UUID: 00000000-0000-0000-0000-000000000000
>> CPU type PowerPC,G4
>> CPU type PowerPC,G4
>> CPU type PowerPC,G4
>> CPU type PowerPC,G4
>> CPU type PowerPC,G4
>> CPU type PowerPC,G4
>> CPU type PowerPC,G4
>> CPU type PowerPC,G4
milliseconds isn't unique.
Welcome to OpenBIOS v1.1 built on Feb 14 2025 10:28

0 > dev /cpus ls 
fff6b30c PowerPC,G4@0
fff6b5c0 PowerPC,G4@1
fff6b874 PowerPC,G4@2
fff6bb28 PowerPC,G4@3
fff6bddc PowerPC,G4@4
fff6c090 PowerPC,G4@5
fff6c344 PowerPC,G4@6
fff6c5f8 PowerPC,G4@7
 ok
0 > dev /cpus/@7  ok
0 > .properties 
name                      "PowerPC,G4"
device_type               "cpu"
cpu-version               80010302 
d-cache-size              8000 
i-cache-size              8000 
d-cache-sets              80 
i-cache-sets              80 
d-cache-block-size        20 
i-cache-block-size        20 
tlb-sets                  40 
tlb-size                  80 
timebase-frequency        17d7840 
clock-frequency           35a4e900 
bus-frequency             5f5e100 
state                     "running"
reservation-granule-size  20 
reg                       00000007
 ok
0 > 
well, now :D I guess I should try to use all 12 of my modern cores, once we get it functional....

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Sat Feb 15, 2025 3:18 pm
by darthnvader

well, now :D I guess I should try to use all 12 of my modern cores, once we get it functional....
So TGC is the default, so SPM maybe working, but none of the kernels I have tested maybe SMP aware......

SMP is just emulated unless you use tgc,multi with SMP, and that does work on qemu-system-ppc64 but not ppc32 yet.

So we can test with ppc64, it runs 32bit OS's and 32bit CPU's just fine on the mac99 Machine model.

You can still run SMP on ppc32, but you won't get any benefit from it with tgc,multi because it only runs one thread on the host CPU....

I would have thought OS X Mach_Kernel was SMP aware, but I guess not????

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Sat Feb 15, 2025 8:01 pm
by darthnvader
darthnvader wrote: Sat Feb 15, 2025 3:18 pm

well, now :D I guess I should try to use all 12 of my modern cores, once we get it functional....
So TGC is the default, so SPM maybe working, but none of the kernels I have tested maybe SMP aware......

SMP is just emulated unless you use tgc,multi with SMP, and that does work on qemu-system-ppc64 but not ppc32 yet.

So we can test with ppc64, it runs 32bit OS's and 32bit CPU's just fine on the mac99 Machine model.

You can still run SMP on ppc32, but you won't get any benefit from it with tgc,multi because it only runs one thread on the host CPU....

I would have thought OS X Mach_Kernel was SMP aware, but I guess not????
I booted Mate 16.04 and it does have an SMP aware Kernel, it tried to start the second CPU by "smp_kickstart" but reported the CPU was stuck, so we got some work to do with IRQ and GPIO to find an expected state for our additional CPUs.

It went passed those errors but got stuck at the ATA bus errors as it needs to mount the CD and we can't do that after the Kernel starts because some of our patches kill the IDE/ATA bus...

So I'm trying to look into how KeyLargo expects to interact with the PIC. These bastardized mac99 boards and the real HW are somewhat of a blackbox, but someone got Linux working on them in the first place, so I'll dig deep and see what I can come up with. Likely a lot more in the Linux Kernel sources....

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Sun Feb 16, 2025 5:06 am
by Cat_7
http://bitsavers.computerhistory.org/pd ... rp1_7a.pdf

I believe the dual cpu G4 had mac model powermac3,3 instead of powermac3,1

Best,
Cat_7

Re: question about low-level SMP detail;s in G4 Macs?

Posted: Sun Feb 16, 2025 4:12 pm
by darthnvader
Cat_7 wrote: Sun Feb 16, 2025 5:06 am http://bitsavers.computerhistory.org/pd ... rp1_7a.pdf

I believe the dual cpu G4 had mac model powermac3,3 instead of powermac3,1

Best,
Cat_7
As long as the PM3,1 had the right UniNorth Rev. it did support 2 CPUs, doesn't matter anyway, it's not a real machine, UniNorth isn't really emulated.

It maybe an issue later, however they coded that in Qemu, but as for now I'm just trying to get the second CPU to start.