Skip to contentSkip to conversation

hw/mips: Improve the default USB settings in the loongson3-virt machine

PATCH Superseded Thomas Huth 3 participants 5 messages Jun 21, 2023 – Jul 13, 2023

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 hw/mips: Improve the default USB settings in the loongson3-virt machine

It's possible to compile QEMU without the USB devices (e.g. when using "--without-default-devices" as option for the "configure" script). To be still able to run the loongson3-virt machine in default mode with such a QEMU binary, we have to check here for the availability of the USB devices first before instantiating them.

---
v2: Use #ifdef instead of runtime check

 hw/mips/loongson3_virt.c | 3 +++
 1 file changed, 3 insertions(+)
hw/mips/loongson3_virt.c +3 -0
index 216812f660..3094413eea 100644
@@ -51,6 +51,7 @@
 #include "sysemu/reset.h"
 #include "sysemu/runstate.h"
 #include "qemu/error-report.h"
+#include CONFIG_DEVICES
 
 #define PM_CNTL_MODE          0x10
 
@@ -447,11 +448,13 @@ static inline void loongson3_virt_devices_init(MachineState *machine,
 
     pci_vga_init(pci_bus);
 
+#ifdef CONFIG_USB_OHCI_PCI
     if (defaults_enabled()) {
         pci_create_simple(pci_bus, -1, "pci-ohci");
         usb_create_simple(usb_bus_find(-1), "usb-kbd");
         usb_create_simple(usb_bus_find(-1), "usb-tablet");
     }
+#endif
 
     for (i = 0; i < nb_nics; i++) {
         NICInfo *nd = &nd_table[i];
Signature · 1 line
2.39.3
#1 lore raw
Quoted 29 lines · Thomas Huth

It's possible to compile QEMU without the USB devices (e.g. when using "--without-default-devices" as option for the "configure" script). To be still able to run the loongson3-virt machine in default mode with such a QEMU binary, we have to check here for the availability of the USB devices first before instantiating them.

---
v2: Use #ifdef instead of runtime check

  hw/mips/loongson3_virt.c | 3 +++
  1 file changed, 3 insertions(+)
hw/mips/loongson3_virt.c +1 -0
index 216812f660..3094413eea 100644
@@ -51,6 +51,7 @@
  #include "sysemu/reset.h"
  #include "sysemu/runstate.h"
  #include "qemu/error-report.h"
+#include CONFIG_DEVICES
 
  #define PM_CNTL_MODE          0x10
 
@@ -447,11 +448,13 @@ static inline void loongson3_virt_devices_init(MachineState *machine,
 
      pci_vga_init(pci_bus);
 

hw/mips/loongson3_virt.c static inline void loongson3_virt_devices_init(MachineState *machine, · line 460

Quoted 10 lines
hw/mips/loongson3_virt.c +2 -0
+#ifdef CONFIG_USB_OHCI_PCI
      if (defaults_enabled()) {
          pci_create_simple(pci_bus, -1, "pci-ohci");
          usb_create_simple(usb_bus_find(-1), "usb-kbd");
          usb_create_simple(usb_bus_find(-1), "usb-tablet");
      }
+#endif
 
      for (i = 0; i < nb_nics; i++) {
          NICInfo *nd = &nd_table[i];

Ping?

Thomas

#2 lore raw
In reply to Thomas Huth

Hi Thomas,

Quoted 18 lines · Thomas Huth

It's possible to compile QEMU without the USB devices (e.g. when using "--without-default-devices" as option for the "configure" script). To be still able to run the loongson3-virt machine in default mode with such a QEMU binary, we have to check here for the availability of the USB devices first before instantiating them.

---
v2: Use #ifdef instead of runtime check

  hw/mips/loongson3_virt.c | 3 +++
  1 file changed, 3 insertions(+)
hw/mips/loongson3_virt.c +0 -0
index 216812f660..3094413eea 100644

hw/mips/loongson3_virt.c line 54

Quoted 4 lines
hw/mips/loongson3_virt.c +1 -0
@@ -51,6 +51,7 @@
  #include "sysemu/reset.h"
  #include "sysemu/runstate.h"
  #include "qemu/error-report.h"
+#include CONFIG_DEVICES

I'm a but reluctant to include CONFIG_DEVICES.

hw/mips/loongson3_virt.c static inline void loongson3_virt_devices_init(MachineState *machine, · line 452

Quoted 2 lines
hw/mips/loongson3_virt.c +1 -0
+#ifdef CONFIG_USB_OHCI_PCI
      if (defaults_enabled()) {

What about:

  if (defaults_enabled() && object_class_by_name(TYPE_PCI_OHCI)) {
Quoted 5 lines
hw/mips/loongson3_virt.c +1 -0
          pci_create_simple(pci_bus, -1, "pci-ohci");
          usb_create_simple(usb_bus_find(-1), "usb-kbd");
          usb_create_simple(usb_bus_find(-1), "usb-tablet");
      }
+#endif
#3 lore raw
Quoted 28 lines · Philippe Mathieu-Daudé

Hi Thomas,

Quoted 18 lines · Thomas Huth

It's possible to compile QEMU without the USB devices (e.g. when using "--without-default-devices" as option for the "configure" script). To be still able to run the loongson3-virt machine in default mode with such a QEMU binary, we have to check here for the availability of the USB devices first before instantiating them.

---
  v2: Use #ifdef instead of runtime check

  hw/mips/loongson3_virt.c | 3 +++

  1 file changed, 3 insertions(+)
hw/mips/loongson3_virt.c +0 -0
index 216812f660..3094413eea 100644

hw/mips/loongson3_virt.c line 54

Quoted 4 lines
hw/mips/loongson3_virt.c +1 -0
@@ -51,6 +51,7 @@
   #include "sysemu/reset.h"
   #include "sysemu/runstate.h"
   #include "qemu/error-report.h"
+#include CONFIG_DEVICES

I'm a but reluctant to include CONFIG_DEVICES.

Quoted 6 lines

hw/mips/loongson3_virt.c static inline void loongson3_virt_devices_init(MachineState *machine, · line 452

Quoted 2 lines
hw/mips/loongson3_virt.c +1 -0
+#ifdef CONFIG_USB_OHCI_PCI
       if (defaults_enabled()) {

What about:

  if (defaults_enabled() && object_class_by_name(TYPE_PCI_OHCI)) {

I think it was a v1 like this :)

/mjt

#4 lore raw
Quoted 29 lines · Michael Tokarev
Quoted 28 lines · Philippe Mathieu-Daudé

Hi Thomas,

Quoted 18 lines · Thomas Huth

It's possible to compile QEMU without the USB devices (e.g. when using "--without-default-devices" as option for the "configure" script). To be still able to run the loongson3-virt machine in default mode with such a QEMU binary, we have to check here for the availability of the USB devices first before instantiating them.

---
  v2: Use #ifdef instead of runtime check

  hw/mips/loongson3_virt.c | 3 +++

  1 file changed, 3 insertions(+)
hw/mips/loongson3_virt.c +0 -0
index 216812f660..3094413eea 100644

hw/mips/loongson3_virt.c line 54

Quoted 4 lines
hw/mips/loongson3_virt.c +1 -0
@@ -51,6 +51,7 @@
   #include "sysemu/reset.h"
   #include "sysemu/runstate.h"
   #include "qemu/error-report.h"
+#include CONFIG_DEVICES

I'm a but reluctant to include CONFIG_DEVICES.

Quoted 8 lines
Quoted 6 lines

hw/mips/loongson3_virt.c static inline void loongson3_virt_devices_init(MachineState *machine, · line 452

Quoted 2 lines
hw/mips/loongson3_virt.c +1 -0
+#ifdef CONFIG_USB_OHCI_PCI
       if (defaults_enabled()) {

What about:

   if (defaults_enabled() && object_class_by_name(TYPE_PCI_OHCI)) {

I think it was a v1 like this :)

Yes, that's how I did it in v1:

https://lore.kernel.org/qemu-devel/[email protected]/

Thomas