Skip to contentSkip to conversation

hw/ppc/mac_newworld: Check for the availability of pci-ohci before using it

PATCH In review Thomas Huth 3 participants 4 messages May 26, 2023 – May 30, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/ppc/mac_newworld: Check for the availability of pci-ohci before using it

pci-ohci might habe been disabled in the QEMU binary (e.g. when "configure" has been run with "--without-default-devices"). Thus we should check for its availability before blindly using it.

---
 hw/ppc/mac_newworld.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/ppc/mac_newworld.c +2 -1
index 535710314a..c7cca430e1 100644
@@ -349,7 +349,8 @@ static void ppc_core99_init(MachineState *machine)
                                     sysbus_mmio_get_region(s, 3));
     }
 
-    machine->usb |= defaults_enabled() && !machine->usb_disabled;
+    machine->usb |= defaults_enabled() && !machine->usb_disabled &&
+                    module_object_class_by_name("pci-ohci") != 0;
     has_pmu = (core99_machine->via_config != CORE99_VIA_CONFIG_CUDA);
     has_adb = (core99_machine->via_config == CORE99_VIA_CONFIG_CUDA ||
                core99_machine->via_config == CORE99_VIA_CONFIG_PMU_ADB);
Signature · 1 line
2.31.1
#1 lore raw
Quoted 14 lines · Thomas Huth

pci-ohci might habe been disabled in the QEMU binary (e.g. when "configure" has been run with "--without-default-devices"). Thus we should check for its availability before blindly using it.

---
hw/ppc/mac_newworld.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
hw/ppc/mac_newworld.c +0 -0
index 535710314a..c7cca430e1 100644

hw/ppc/mac_newworld.c static void ppc_core99_init(MachineState *machine) · line 353

Quoted 6 lines
hw/ppc/mac_newworld.c +2 -1
@@ -349,7 +349,8 @@ static void ppc_core99_init(MachineState *machine)
                                    sysbus_mmio_get_region(s, 3));
    }
 
-    machine->usb |= defaults_enabled() && !machine->usb_disabled;
+    machine->usb |= defaults_enabled() && !machine->usb_disabled &&
+                    module_object_class_by_name("pci-ohci") != 0;

Considering that PowerMacs have an OHCI controller built in soldered to the motherboard should this depend on it instead and not rely on pulling it in with PCI_DEVICES and --without-default-devices disabling it?

Currently it's not quite emulating a real Mac but I think we should aim for going that way rather than to keep emulating random Mac hardware.

Regards,
BALATON Zoltan

Quoted 4 lines
hw/ppc/mac_newworld.c +0 -0
    has_pmu = (core99_machine->via_config != CORE99_VIA_CONFIG_CUDA);
    has_adb = (core99_machine->via_config == CORE99_VIA_CONFIG_CUDA ||
               core99_machine->via_config == CORE99_VIA_CONFIG_PMU_ADB);
#2 lore raw
Quoted 18 lines · BALATON Zoltan
Quoted 17 lines · Thomas Huth

pci-ohci might habe been disabled in the QEMU binary (e.g. when "configure" has been run with "--without-default-devices"). Thus we should check for its availability before blindly using it.

---
hw/ppc/mac_newworld.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
hw/ppc/mac_newworld.c +0 -0
index 535710314a..c7cca430e1 100644
@@ -349,7 +349,8 @@ static void ppc_core99_init(MachineState *machine)
                                     sysbus_mmio_get_region(s, 3));
     }
 
Quoted 7 lines

hw/ppc/mac_newworld.c static void ppc_core99_init(MachineState *machine) · line 353

Quoted 3 lines
hw/ppc/mac_newworld.c +2 -1
-    machine->usb |= defaults_enabled() && !machine->usb_disabled;
+    machine->usb |= defaults_enabled() && !machine->usb_disabled &&
+                    module_object_class_by_name("pci-ohci") != 0;

Considering that PowerMacs have an OHCI controller built in soldered to the motherboard should this depend on it instead and not rely on pulling it in with PCI_DEVICES and --without-default-devices disabling it?

Currently it's not quite emulating a real Mac but I think we should aim for going that way rather than to keep emulating random Mac hardware.

Indeed that's correct: New World Macs should always have USB ports built-in. I guess the problem here is that this isn't being indicated correctly via Kconfig and/or the machine->usb_disabled logic?

Quoted 6 lines

Regards,
BALATON Zoltan

Quoted 3 lines
hw/ppc/mac_newworld.c +0 -0
     has_pmu = (core99_machine->via_config != CORE99_VIA_CONFIG_CUDA);

    has_adb = (core99_machine->via_config == CORE99_VIA_CONFIG_CUDA || core99_machine->via_config == CORE99_VIA_CONFIG_PMU_ADB);

ATB,

Mark.

#3 lore raw
Quoted 26 lines · Mark Cave-Ayland
Quoted 24 lines · BALATON Zoltan
Quoted 14 lines · Thomas Huth

pci-ohci might habe been disabled in the QEMU binary (e.g. when "configure" has been run with "--without-default-devices"). Thus we should check for its availability before blindly using it.

---
hw/ppc/mac_newworld.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
hw/ppc/mac_newworld.c +0 -0
index 535710314a..c7cca430e1 100644

hw/ppc/mac_newworld.c static void ppc_core99_init(MachineState *machine) · line 353

Quoted 6 lines
hw/ppc/mac_newworld.c +2 -1
@@ -349,7 +349,8 @@ static void ppc_core99_init(MachineState *machine)
                                     sysbus_mmio_get_region(s, 3));
     }
 
-    machine->usb |= defaults_enabled() && !machine->usb_disabled;
+    machine->usb |= defaults_enabled() && !machine->usb_disabled &&
+                    module_object_class_by_name("pci-ohci") != 0;

Considering that PowerMacs have an OHCI controller built in soldered to the motherboard should this depend on it instead and not rely on pulling it in with PCI_DEVICES and --without-default-devices disabling it?

Quoted 3 lines
Quoted 1 line

Currently it's not quite emulating a real Mac but I think we should aim for going that way rather than to keep emulating random Mac hardware.

Indeed that's correct: New World Macs should always have USB ports built-in. I guess the problem here is that this isn't being indicated correctly via Kconfig and/or the machine->usb_disabled logic?

Yes, the other solution to the problem is to add a proper "select" statement to the Kconfig file. I can also send a patch for that instead.

The other question is whether the OHCI device should always be instantiated, even if QEMU had been started with "--nodefaults"? ... otherwise you could not hot-plug USB devices to this machine during runtime...

Thomas