qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/9] mips: do not list individual devices from configs/
@ 2024-02-13 15:49 Paolo Bonzini
  2024-02-13 15:49 ` [PATCH v3 1/9] usb: inline device creation functions Paolo Bonzini
                   ` (9 more replies)
  0 siblings, 10 replies; 18+ messages in thread
From: Paolo Bonzini @ 2024-02-13 15:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd, shentey, balaton

Back when Kconfig was introduced, the individual dependencies for MIPS
boards were never added to hw/mips/Kconfig.  Do it now.

To simplify the task, include a couple cleanups to the SuperIO chip
configuration symbols, as well as a change that makes USB device
creation available even when building without default devices.

Tested by comparing old and new kconfigs; and also by building each of
the boards one by one, with default devices disabled, and checking that
the board can be started.

Paolo

v2->v3:
- add a comment in mipssim.c
- reimplement "mips: allow compiling out CONFIG_MIPS_ITU"
- extract patch 8 ("mips/loongson3_virt: do not require CONFIG_USB")

Bernhard Beschow (1):
  hw/mips/Kconfig: Remove ISA dependencies from MIPSsim board

Paolo Bonzini (8):
  usb: inline device creation functions
  isa: clean up Kconfig selections for ISA_SUPERIO
  isa: fix ISA_SUPERIO dependencies
  isa: specify instance_size in isa_superio_type_info
  isa: extract FDC37M81X to a separate file
  mips: allow compiling out CONFIG_MIPS_ITU
  mips/loongson3_virt: do not require CONFIG_USB
  mips: do not list individual devices from configs/

 configs/devices/mips-softmmu/common.mak      | 28 +++--------------
 configs/devices/mips64el-softmmu/default.mak |  3 --
 include/hw/usb.h                             | 27 +++++++++++++++--
 target/mips/tcg/translate.h                  |  1 +
 target/mips/tcg/sysemu_helper.h.inc          | 19 ++++++++----
 hw/isa/fdc37m81x-superio.c                   | 32 ++++++++++++++++++++
 hw/isa/isa-superio.c                         | 18 -----------
 hw/isa/smc37c669-superio.c                   |  1 -
 hw/mips/loongson3_virt.c                     |  5 +--
 hw/mips/mipssim.c                            |  7 +++--
 hw/usb/bus.c                                 | 23 --------------
 target/mips/tcg/sysemu/cp0_helper.c          |  8 +++++
 target/mips/tcg/translate.c                  | 10 ++++++
 .gitlab-ci.d/buildtest.yml                   |  2 +-
 hw/display/Kconfig                           |  2 +-
 hw/isa/Kconfig                               | 20 ++++++------
 hw/isa/meson.build                           |  1 +
 hw/mips/Kconfig                              | 25 ++++++++++++---
 18 files changed, 134 insertions(+), 98 deletions(-)
 create mode 100644 hw/isa/fdc37m81x-superio.c

-- 
2.43.0



^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v3 1/9] usb: inline device creation functions
  2024-02-13 15:49 [PATCH v3 0/9] mips: do not list individual devices from configs/ Paolo Bonzini
@ 2024-02-13 15:49 ` Paolo Bonzini
  2024-02-16 11:14   ` Philippe Mathieu-Daudé
  2024-02-13 15:49 ` [PATCH v3 2/9] isa: clean up Kconfig selections for ISA_SUPERIO Paolo Bonzini
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 18+ messages in thread
From: Paolo Bonzini @ 2024-02-13 15:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd, shentey, balaton, Richard Henderson

Allow boards to use the device creation functions even if USB itself
is not available; of course the functions will fail inexorably, but
this can be okay if the calls are conditional on the existence of
some USB host controller device.  This is for example the case for
hw/mips/loongson3_virt.c.

Acked-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/hw/usb.h | 27 ++++++++++++++++++++++++---
 hw/usb/bus.c     | 23 -----------------------
 2 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/include/hw/usb.h b/include/hw/usb.h
index 32c23a5ca2a..cfeead28403 100644
--- a/include/hw/usb.h
+++ b/include/hw/usb.h
@@ -30,6 +30,7 @@
 #include "qemu/iov.h"
 #include "qemu/queue.h"
 #include "qom/object.h"
+#include "qapi/error.h"
 
 /* Constants related to the USB / PCI interaction */
 #define USB_SBRN    0x60 /* Serial Bus Release Number Register */
@@ -500,9 +501,6 @@ void usb_bus_release(USBBus *bus);
 USBBus *usb_bus_find(int busnr);
 void usb_legacy_register(const char *typename, const char *usbdevice_name,
                          USBDevice *(*usbdevice_init)(void));
-USBDevice *usb_new(const char *name);
-bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp);
-USBDevice *usb_create_simple(USBBus *bus, const char *name);
 USBDevice *usbdevice_create(const char *cmdline);
 void usb_register_port(USBBus *bus, USBPort *port, void *opaque, int index,
                        USBPortOps *ops, int speedmask);
@@ -582,4 +580,27 @@ void usb_pcap_init(FILE *fp);
 void usb_pcap_ctrl(USBPacket *p, bool setup);
 void usb_pcap_data(USBPacket *p, bool setup);
 
+static inline USBDevice *usb_new(const char *name)
+{
+    return USB_DEVICE(qdev_new(name));
+}
+
+static inline USBDevice *usb_try_new(const char *name)
+{
+    return USB_DEVICE(qdev_try_new(name));
+}
+
+static inline bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp)
+{
+    return qdev_realize_and_unref(&dev->qdev, &bus->qbus, errp);
+}
+
+static inline USBDevice *usb_create_simple(USBBus *bus, const char *name)
+{
+    USBDevice *dev = usb_new(name);
+
+    usb_realize_and_unref(dev, bus, &error_abort);
+    return dev;
+}
+
 #endif
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 59c39945ddd..76fda41b7ec 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -329,29 +329,6 @@ void usb_legacy_register(const char *typename, const char *usbdevice_name,
     }
 }
 
-USBDevice *usb_new(const char *name)
-{
-    return USB_DEVICE(qdev_new(name));
-}
-
-static USBDevice *usb_try_new(const char *name)
-{
-    return USB_DEVICE(qdev_try_new(name));
-}
-
-bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp)
-{
-    return qdev_realize_and_unref(&dev->qdev, &bus->qbus, errp);
-}
-
-USBDevice *usb_create_simple(USBBus *bus, const char *name)
-{
-    USBDevice *dev = usb_new(name);
-
-    usb_realize_and_unref(dev, bus, &error_abort);
-    return dev;
-}
-
 static void usb_fill_port(USBPort *port, void *opaque, int index,
                           USBPortOps *ops, int speedmask)
 {
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v3 2/9] isa: clean up Kconfig selections for ISA_SUPERIO
  2024-02-13 15:49 [PATCH v3 0/9] mips: do not list individual devices from configs/ Paolo Bonzini
  2024-02-13 15:49 ` [PATCH v3 1/9] usb: inline device creation functions Paolo Bonzini
@ 2024-02-13 15:49 ` Paolo Bonzini
  2024-02-13 15:49 ` [PATCH v3 3/9] hw/mips/Kconfig: Remove ISA dependencies from MIPSsim board Paolo Bonzini
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: Paolo Bonzini @ 2024-02-13 15:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd, shentey, balaton, Richard Henderson

All users of ISA_SUPERIO include a floppy disk controller, serial port
and parallel port via the automatic creation mechanism of isa-superio.c.

Select the symbol and remove it from the dependents.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/isa/Kconfig | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig
index 040a18c0709..7884179d08b 100644
--- a/hw/isa/Kconfig
+++ b/hw/isa/Kconfig
@@ -17,7 +17,11 @@ config ISA_SUPERIO
     bool
     select ISA_BUS
     select PCKBD
+    select PARALLEL
+    select SERIAL_ISA
     select FDC_ISA
+    # Some users of ISA_SUPERIO do not use it
+    #select IDE_ISA
 
 config PC87312
     bool
@@ -26,9 +30,6 @@ config PC87312
     select I8254
     select I8257
     select MC146818RTC
-    select SERIAL_ISA
-    select PARALLEL
-    select FDC_ISA
     select IDE_ISA
 
 config PIIX
@@ -49,8 +50,6 @@ config VT82C686
     select ISA_SUPERIO
     select ACPI
     select ACPI_SMBUS
-    select SERIAL_ISA
-    select FDC_ISA
     select USB_UHCI
     select APM
     select I8254
@@ -58,14 +57,10 @@ config VT82C686
     select I8259
     select IDE_VIA
     select MC146818RTC
-    select PARALLEL
 
 config SMC37C669
     bool
     select ISA_SUPERIO
-    select SERIAL_ISA
-    select PARALLEL
-    select FDC_ISA
 
 config LPC_ICH9
     bool
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v3 3/9] hw/mips/Kconfig: Remove ISA dependencies from MIPSsim board
  2024-02-13 15:49 [PATCH v3 0/9] mips: do not list individual devices from configs/ Paolo Bonzini
  2024-02-13 15:49 ` [PATCH v3 1/9] usb: inline device creation functions Paolo Bonzini
  2024-02-13 15:49 ` [PATCH v3 2/9] isa: clean up Kconfig selections for ISA_SUPERIO Paolo Bonzini
@ 2024-02-13 15:49 ` Paolo Bonzini
  2024-02-13 15:49 ` [PATCH v3 4/9] isa: fix ISA_SUPERIO dependencies Paolo Bonzini
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: Paolo Bonzini @ 2024-02-13 15:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd, shentey, balaton

From: Bernhard Beschow <shentey@gmail.com>

The board doesn't have a working ISA bus, only some I/O space.
Selecting ISA_BUS and including hw/isa/isa.h is not necessary.

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Message-ID: <20230109204124.102592-3-shentey@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/mips/mipssim.c | 7 +++++--
 hw/mips/Kconfig   | 3 +--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c
index 16af31648e2..a12427b6c8a 100644
--- a/hw/mips/mipssim.c
+++ b/hw/mips/mipssim.c
@@ -31,7 +31,6 @@
 #include "hw/clock.h"
 #include "hw/mips/mips.h"
 #include "hw/char/serial.h"
-#include "hw/isa/isa.h"
 #include "net/net.h"
 #include "sysemu/sysemu.h"
 #include "hw/boards.h"
@@ -206,7 +205,11 @@ mips_mipssim_init(MachineState *machine)
     cpu_mips_irq_init_cpu(cpu);
     cpu_mips_clock_init(cpu);
 
-    /* Register 64 KB of ISA IO space at 0x1fd00000. */
+    /*
+     * Register 64 KB of ISA IO space at 0x1fd00000.  But without interrupts
+     * (except for the hardcoded serial port interrupt) -device cannot work,
+     * so do not expose the ISA bus to the user.
+     */
     memory_region_init_alias(isa, NULL, "isa_mmio",
                              get_system_io(), 0, 0x00010000);
     memory_region_add_subregion(get_system_memory(), 0x1fd00000, isa);
diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig
index ab61af209a0..afcfb2b8eca 100644
--- a/hw/mips/Kconfig
+++ b/hw/mips/Kconfig
@@ -6,8 +6,7 @@ config MALTA
 
 config MIPSSIM
     bool
-    select ISA_BUS
-    select SERIAL_ISA
+    select SERIAL
     select MIPSNET
 
 config JAZZ
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v3 4/9] isa: fix ISA_SUPERIO dependencies
  2024-02-13 15:49 [PATCH v3 0/9] mips: do not list individual devices from configs/ Paolo Bonzini
                   ` (2 preceding siblings ...)
  2024-02-13 15:49 ` [PATCH v3 3/9] hw/mips/Kconfig: Remove ISA dependencies from MIPSsim board Paolo Bonzini
@ 2024-02-13 15:49 ` Paolo Bonzini
  2024-02-13 15:50 ` [PATCH v3 5/9] isa: specify instance_size in isa_superio_type_info Paolo Bonzini
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: Paolo Bonzini @ 2024-02-13 15:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd, shentey, balaton

ISA_SUPERIO does not provide an ISA bus, so it should not select the symbol:
instead it requires one.  Among its users, VT82C686 is the only one that
is a PCI-ISA bridge and does not already select ISA_BUS.

Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Bernhard Beschow <shentey@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/isa/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig
index 7884179d08b..5df3c09cd51 100644
--- a/hw/isa/Kconfig
+++ b/hw/isa/Kconfig
@@ -15,7 +15,7 @@ config I82378
 
 config ISA_SUPERIO
     bool
-    select ISA_BUS
+    depends on ISA_BUS
     select PCKBD
     select PARALLEL
     select SERIAL_ISA
@@ -47,6 +47,7 @@ config PIIX
 
 config VT82C686
     bool
+    select ISA_BUS
     select ISA_SUPERIO
     select ACPI
     select ACPI_SMBUS
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v3 5/9] isa: specify instance_size in isa_superio_type_info
  2024-02-13 15:49 [PATCH v3 0/9] mips: do not list individual devices from configs/ Paolo Bonzini
                   ` (3 preceding siblings ...)
  2024-02-13 15:49 ` [PATCH v3 4/9] isa: fix ISA_SUPERIO dependencies Paolo Bonzini
@ 2024-02-13 15:50 ` Paolo Bonzini
  2024-02-13 15:50 ` [PATCH v3 6/9] isa: extract FDC37M81X to a separate file Paolo Bonzini
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: Paolo Bonzini @ 2024-02-13 15:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd, shentey, balaton

Right now all subclasses of TYPE_ISA_SUPERIO have to specify an instance_size,
because the ISASuperIODevice struct adds fields to ISADevice but the type does
not include the increased instance size.  Failure to do so results in an access
past the bounds of struct ISADevice as soon as isa_superio_realize is called.
Fix this by specifying the instance_size already in the superclass.

Fixes: 4c3119a6e3 ("hw/isa/superio: Factor out the parallel code from pc87312.c")
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Bernhard Beschow <shentey@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/isa/isa-superio.c       | 2 +-
 hw/isa/smc37c669-superio.c | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/hw/isa/isa-superio.c b/hw/isa/isa-superio.c
index e06a548c682..98d50844f71 100644
--- a/hw/isa/isa-superio.c
+++ b/hw/isa/isa-superio.c
@@ -187,6 +187,7 @@ static const TypeInfo isa_superio_type_info = {
     .abstract = true,
     .class_size = sizeof(ISASuperIOClass),
     .class_init = isa_superio_class_init,
+    .instance_size = sizeof(ISASuperIODevice),
 };
 
 /* SMS FDC37M817 Super I/O */
@@ -203,7 +204,6 @@ static void fdc37m81x_class_init(ObjectClass *klass, void *data)
 static const TypeInfo fdc37m81x_type_info = {
     .name          = TYPE_FDC37M81X_SUPERIO,
     .parent        = TYPE_ISA_SUPERIO,
-    .instance_size = sizeof(ISASuperIODevice),
     .class_init    = fdc37m81x_class_init,
 };
 
diff --git a/hw/isa/smc37c669-superio.c b/hw/isa/smc37c669-superio.c
index 388e2ed9371..d2e58c9a895 100644
--- a/hw/isa/smc37c669-superio.c
+++ b/hw/isa/smc37c669-superio.c
@@ -85,7 +85,6 @@ static void smc37c669_class_init(ObjectClass *klass, void *data)
 static const TypeInfo smc37c669_type_info = {
     .name          = TYPE_SMC37C669_SUPERIO,
     .parent        = TYPE_ISA_SUPERIO,
-    .instance_size = sizeof(ISASuperIODevice),
     .class_size    = sizeof(ISASuperIOClass),
     .class_init    = smc37c669_class_init,
 };
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v3 6/9] isa: extract FDC37M81X to a separate file
  2024-02-13 15:49 [PATCH v3 0/9] mips: do not list individual devices from configs/ Paolo Bonzini
                   ` (4 preceding siblings ...)
  2024-02-13 15:50 ` [PATCH v3 5/9] isa: specify instance_size in isa_superio_type_info Paolo Bonzini
@ 2024-02-13 15:50 ` Paolo Bonzini
  2024-02-13 19:07   ` Bernhard Beschow
  2024-02-13 15:50 ` [PATCH v3 7/9] mips: allow compiling out CONFIG_MIPS_ITU Paolo Bonzini
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 18+ messages in thread
From: Paolo Bonzini @ 2024-02-13 15:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd, shentey, balaton

isa-superio.c currently defines a SuperIO chip that is not used
by any other user of the file.  Extract the chip to a separate file.

Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Bernhard Beschow <shentey@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/isa/fdc37m81x-superio.c | 32 ++++++++++++++++++++++++++++++++
 hw/isa/isa-superio.c       | 18 ------------------
 hw/isa/Kconfig             |  4 ++++
 hw/isa/meson.build         |  1 +
 hw/mips/Kconfig            |  2 +-
 5 files changed, 38 insertions(+), 19 deletions(-)
 create mode 100644 hw/isa/fdc37m81x-superio.c

diff --git a/hw/isa/fdc37m81x-superio.c b/hw/isa/fdc37m81x-superio.c
new file mode 100644
index 00000000000..55e91fbca17
--- /dev/null
+++ b/hw/isa/fdc37m81x-superio.c
@@ -0,0 +1,32 @@
+/*
+ * SMS FDC37M817 Super I/O
+ *
+ * Copyright (c) 2018 Philippe Mathieu-Daudé
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/isa/superio.h"
+
+static void fdc37m81x_class_init(ObjectClass *klass, void *data)
+{
+    ISASuperIOClass *sc = ISA_SUPERIO_CLASS(klass);
+
+    sc->serial.count = 2; /* NS16C550A */
+    sc->parallel.count = 1;
+    sc->floppy.count = 1; /* SMSC 82077AA Compatible */
+    sc->ide.count = 0;
+}
+
+static const TypeInfo types[] = {
+    {
+        .name          = TYPE_FDC37M81X_SUPERIO,
+        .parent        = TYPE_ISA_SUPERIO,
+        .class_init    = fdc37m81x_class_init,
+    },
+};
+
+DEFINE_TYPES(types)
diff --git a/hw/isa/isa-superio.c b/hw/isa/isa-superio.c
index 98d50844f71..a8c8c58ef7f 100644
--- a/hw/isa/isa-superio.c
+++ b/hw/isa/isa-superio.c
@@ -190,27 +190,9 @@ static const TypeInfo isa_superio_type_info = {
     .instance_size = sizeof(ISASuperIODevice),
 };
 
-/* SMS FDC37M817 Super I/O */
-static void fdc37m81x_class_init(ObjectClass *klass, void *data)
-{
-    ISASuperIOClass *sc = ISA_SUPERIO_CLASS(klass);
-
-    sc->serial.count = 2; /* NS16C550A */
-    sc->parallel.count = 1;
-    sc->floppy.count = 1; /* SMSC 82077AA Compatible */
-    sc->ide.count = 0;
-}
-
-static const TypeInfo fdc37m81x_type_info = {
-    .name          = TYPE_FDC37M81X_SUPERIO,
-    .parent        = TYPE_ISA_SUPERIO,
-    .class_init    = fdc37m81x_class_init,
-};
-
 static void isa_superio_register_types(void)
 {
     type_register_static(&isa_superio_type_info);
-    type_register_static(&fdc37m81x_type_info);
 }
 
 type_init(isa_superio_register_types)
diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig
index 5df3c09cd51..73c6470805c 100644
--- a/hw/isa/Kconfig
+++ b/hw/isa/Kconfig
@@ -23,6 +23,10 @@ config ISA_SUPERIO
     # Some users of ISA_SUPERIO do not use it
     #select IDE_ISA
 
+config FDC37M81X
+    bool
+    select ISA_SUPERIO
+
 config PC87312
     bool
     select ISA_SUPERIO
diff --git a/hw/isa/meson.build b/hw/isa/meson.build
index 2ab99ce0c6b..f650b395071 100644
--- a/hw/isa/meson.build
+++ b/hw/isa/meson.build
@@ -4,6 +4,7 @@ system_ss.add(when: 'CONFIG_ISA_BUS', if_true: files('isa-bus.c'))
 system_ss.add(when: 'CONFIG_ISA_SUPERIO', if_true: files('isa-superio.c'))
 system_ss.add(when: 'CONFIG_PC87312', if_true: files('pc87312.c'))
 system_ss.add(when: 'CONFIG_PIIX', if_true: files('piix.c'))
+system_ss.add(when: 'CONFIG_FDC37M81X', if_true: files('fdc37m81x-superio.c'))
 system_ss.add(when: 'CONFIG_SMC37C669', if_true: files('smc37c669-superio.c'))
 system_ss.add(when: 'CONFIG_VT82C686', if_true: files('vt82c686.c'))
 
diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig
index afcfb2b8eca..e57db4f6412 100644
--- a/hw/mips/Kconfig
+++ b/hw/mips/Kconfig
@@ -1,7 +1,7 @@
 config MALTA
     bool
+    select FDC37M81X
     select GT64120
-    select ISA_SUPERIO
     select PIIX
 
 config MIPSSIM
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v3 7/9] mips: allow compiling out CONFIG_MIPS_ITU
  2024-02-13 15:49 [PATCH v3 0/9] mips: do not list individual devices from configs/ Paolo Bonzini
                   ` (5 preceding siblings ...)
  2024-02-13 15:50 ` [PATCH v3 6/9] isa: extract FDC37M81X to a separate file Paolo Bonzini
@ 2024-02-13 15:50 ` Paolo Bonzini
  2024-02-13 15:50 ` [PATCH v3 8/9] mips/loongson3_virt: do not require CONFIG_USB Paolo Bonzini
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: Paolo Bonzini @ 2024-02-13 15:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd, shentey, balaton

itc_reconfigure() is referenced from TCG, compile out the helpers
that reference env->itu if CONFIG_MIPS_ITU is not defined.
This makes it possible to build a QEMU binary that only includes
boards without a CPS device (only Malta and Boston create one).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/mips/tcg/translate.h         |  1 +
 target/mips/tcg/sysemu_helper.h.inc | 19 +++++++++++++------
 target/mips/tcg/sysemu/cp0_helper.c |  8 ++++++++
 target/mips/tcg/translate.c         | 10 ++++++++++
 4 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/target/mips/tcg/translate.h b/target/mips/tcg/translate.h
index 93a78b81212..d5458f8690d 100644
--- a/target/mips/tcg/translate.h
+++ b/target/mips/tcg/translate.h
@@ -9,6 +9,7 @@
 #define TARGET_MIPS_TRANSLATE_H
 
 #include "cpu.h"
+
 #include "tcg/tcg-op.h"
 #include "exec/translator.h"
 #include "exec/helper-gen.h"
diff --git a/target/mips/tcg/sysemu_helper.h.inc b/target/mips/tcg/sysemu_helper.h.inc
index f163af1eac7..92d01c49bf6 100644
--- a/target/mips/tcg/sysemu_helper.h.inc
+++ b/target/mips/tcg/sysemu_helper.h.inc
@@ -9,6 +9,8 @@
  * SPDX-License-Identifier: LGPL-2.1-or-later
  */
 
+#include CONFIG_DEVICES
+
 /* CP0 helpers */
 DEF_HELPER_1(mfc0_mvpcontrol, tl, env)
 DEF_HELPER_1(mfc0_mvpconf0, tl, env)
@@ -31,8 +33,6 @@ DEF_HELPER_1(mftc0_tcschedule, tl, env)
 DEF_HELPER_1(mfc0_tcschefback, tl, env)
 DEF_HELPER_1(mftc0_tcschefback, tl, env)
 DEF_HELPER_1(mfc0_count, tl, env)
-DEF_HELPER_1(mfc0_saar, tl, env)
-DEF_HELPER_1(mfhc0_saar, tl, env)
 DEF_HELPER_1(mftc0_entryhi, tl, env)
 DEF_HELPER_1(mftc0_status, tl, env)
 DEF_HELPER_1(mftc0_cause, tl, env)
@@ -57,7 +57,6 @@ DEF_HELPER_1(dmfc0_lladdr, tl, env)
 DEF_HELPER_1(dmfc0_maar, tl, env)
 DEF_HELPER_2(dmfc0_watchlo, tl, env, i32)
 DEF_HELPER_2(dmfc0_watchhi, tl, env, i32)
-DEF_HELPER_1(dmfc0_saar, tl, env)
 #endif /* TARGET_MIPS64 */
 
 DEF_HELPER_2(mtc0_index, void, env, tl)
@@ -103,9 +102,6 @@ DEF_HELPER_2(mtc0_srsconf4, void, env, tl)
 DEF_HELPER_2(mtc0_hwrena, void, env, tl)
 DEF_HELPER_2(mtc0_pwctl, void, env, tl)
 DEF_HELPER_2(mtc0_count, void, env, tl)
-DEF_HELPER_2(mtc0_saari, void, env, tl)
-DEF_HELPER_2(mtc0_saar, void, env, tl)
-DEF_HELPER_2(mthc0_saar, void, env, tl)
 DEF_HELPER_2(mtc0_entryhi, void, env, tl)
 DEF_HELPER_2(mttc0_entryhi, void, env, tl)
 DEF_HELPER_2(mtc0_compare, void, env, tl)
@@ -189,3 +185,14 @@ DEF_HELPER_2(lcsr_drdcsr, i64, env, tl)
 DEF_HELPER_3(lcsr_wrcsr, void, env, tl, tl)
 DEF_HELPER_3(lcsr_dwrcsr, void, env, tl, tl)
 #endif
+
+#ifdef CONFIG_MIPS_ITU
+DEF_HELPER_1(mfc0_saar, tl, env)
+DEF_HELPER_1(mfhc0_saar, tl, env)
+DEF_HELPER_2(mtc0_saari, void, env, tl)
+DEF_HELPER_2(mtc0_saar, void, env, tl)
+DEF_HELPER_2(mthc0_saar, void, env, tl)
+#ifdef TARGET_MIPS64
+DEF_HELPER_1(dmfc0_saar, tl, env)
+#endif
+#endif
diff --git a/target/mips/tcg/sysemu/cp0_helper.c b/target/mips/tcg/sysemu/cp0_helper.c
index 62f6fb4bf65..dde890adf3f 100644
--- a/target/mips/tcg/sysemu/cp0_helper.c
+++ b/target/mips/tcg/sysemu/cp0_helper.c
@@ -21,6 +21,8 @@
  */
 
 #include "qemu/osdep.h"
+#include CONFIG_DEVICES
+
 #include "qemu/log.h"
 #include "qemu/main-loop.h"
 #include "cpu.h"
@@ -371,6 +373,7 @@ target_ulong helper_mfc0_count(CPUMIPSState *env)
     return (int32_t)cpu_mips_get_count(env);
 }
 
+#ifdef CONFIG_MIPS_ITU
 target_ulong helper_mfc0_saar(CPUMIPSState *env)
 {
     if ((env->CP0_SAARI & 0x3f) < 2) {
@@ -386,6 +389,7 @@ target_ulong helper_mfhc0_saar(CPUMIPSState *env)
     }
     return 0;
 }
+#endif
 
 target_ulong helper_mftc0_entryhi(CPUMIPSState *env)
 {
@@ -514,6 +518,7 @@ target_ulong helper_dmfc0_watchhi(CPUMIPSState *env, uint32_t sel)
     return env->CP0_WatchHi[sel];
 }
 
+#ifdef CONFIG_MIPS_ITU
 target_ulong helper_dmfc0_saar(CPUMIPSState *env)
 {
     if ((env->CP0_SAARI & 0x3f) < 2) {
@@ -521,6 +526,7 @@ target_ulong helper_dmfc0_saar(CPUMIPSState *env)
     }
     return 0;
 }
+#endif
 #endif /* TARGET_MIPS64 */
 
 void helper_mtc0_index(CPUMIPSState *env, target_ulong arg1)
@@ -1100,6 +1106,7 @@ void helper_mtc0_count(CPUMIPSState *env, target_ulong arg1)
     cpu_mips_store_count(env, arg1);
 }
 
+#ifdef CONFIG_MIPS_ITU
 void helper_mtc0_saari(CPUMIPSState *env, target_ulong arg1)
 {
     uint32_t target = arg1 & 0x3f;
@@ -1139,6 +1146,7 @@ void helper_mthc0_saar(CPUMIPSState *env, target_ulong arg1)
         }
     }
 }
+#endif
 
 void helper_mtc0_entryhi(CPUMIPSState *env, target_ulong arg1)
 {
diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c
index 12094cc1e7c..b130222708b 100644
--- a/target/mips/tcg/translate.c
+++ b/target/mips/tcg/translate.c
@@ -49,6 +49,16 @@
 #ifdef CONFIG_USER_ONLY
 STUB_HELPER(cache, TCGv_env env, TCGv val, TCGv_i32 reg)
 #endif
+#if defined CONFIG_SYSTEM_ONLY && !defined CONFIG_MIPS_ITU
+STUB_HELPER(mfc0_saar, TCGv ret, TCGv_env env)
+STUB_HELPER(mfhc0_saar, TCGv ret, TCGv_env env)
+STUB_HELPER(mtc0_saari, TCGv_env env, TCGv val)
+STUB_HELPER(mtc0_saar, TCGv_env env, TCGv val)
+STUB_HELPER(mthc0_saar, TCGv_env env, TCGv val)
+#ifdef TARGET_MIPS64
+STUB_HELPER(dmfc0_saar, TCGv ret, TCGv_env env)
+#endif
+#endif
 
 enum {
     /* indirect opcode tables */
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v3 8/9] mips/loongson3_virt: do not require CONFIG_USB
  2024-02-13 15:49 [PATCH v3 0/9] mips: do not list individual devices from configs/ Paolo Bonzini
                   ` (6 preceding siblings ...)
  2024-02-13 15:50 ` [PATCH v3 7/9] mips: allow compiling out CONFIG_MIPS_ITU Paolo Bonzini
@ 2024-02-13 15:50 ` Paolo Bonzini
  2024-02-15  7:55   ` Philippe Mathieu-Daudé
  2024-02-13 15:50 ` [PATCH v3 9/9] mips: do not list individual devices from configs/ Paolo Bonzini
  2024-02-15 17:51 ` [PATCH v3 0/9] " Philippe Mathieu-Daudé
  9 siblings, 1 reply; 18+ messages in thread
From: Paolo Bonzini @ 2024-02-13 15:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd, shentey, balaton

Once the Kconfig for hw/mips is cleaned up, it will be possible to build a
binary that does not include any USB host controller and therefore that
does not include the code guarded by CONFIG_USB.  While the simpler
creation functions such as usb_create_simple can be inlined, this is not
true of usb_bus_find().  Remove it, replacing it with a search of the
single USB bus created by loongson3_virt_devices_init().

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/mips/loongson3_virt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c
index caedde2df00..bedd3d496bd 100644
--- a/hw/mips/loongson3_virt.c
+++ b/hw/mips/loongson3_virt.c
@@ -447,8 +447,9 @@ static inline void loongson3_virt_devices_init(MachineState *machine,
 
     if (defaults_enabled() && object_class_by_name("pci-ohci")) {
         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");
+        Object *usb_bus = object_resolve_path_type("", TYPE_USB_BUS, NULL);
+        usb_create_simple(USB_BUS(usb_bus), "usb-kbd");
+        usb_create_simple(USB_BUS(usb_bus), "usb-tablet");
     }
 
     pci_init_nic_devices(pci_bus, mc->default_nic);
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v3 9/9] mips: do not list individual devices from configs/
  2024-02-13 15:49 [PATCH v3 0/9] mips: do not list individual devices from configs/ Paolo Bonzini
                   ` (7 preceding siblings ...)
  2024-02-13 15:50 ` [PATCH v3 8/9] mips/loongson3_virt: do not require CONFIG_USB Paolo Bonzini
@ 2024-02-13 15:50 ` Paolo Bonzini
  2024-02-15 17:51 ` [PATCH v3 0/9] " Philippe Mathieu-Daudé
  9 siblings, 0 replies; 18+ messages in thread
From: Paolo Bonzini @ 2024-02-13 15:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd, shentey, balaton

Add new "select" and "imply" directives if needed.  The resulting
config-devices.mak files are the same as before.

Note that builds without default devices will become much smaller
than before; for this reason, it's necessary to use only the bare
minimum of USB functions, in particular only those that are inlined.
For this reason, usb_bus_find() must be removed, as it only exists
if CONFIG_USB is selected by a host controller.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configs/devices/mips-softmmu/common.mak      | 28 +++-----------------
 configs/devices/mips64el-softmmu/default.mak |  3 ---
 .gitlab-ci.d/buildtest.yml                   |  2 +-
 hw/display/Kconfig                           |  2 +-
 hw/mips/Kconfig                              | 20 +++++++++++++-
 5 files changed, 25 insertions(+), 30 deletions(-)

diff --git a/configs/devices/mips-softmmu/common.mak b/configs/devices/mips-softmmu/common.mak
index 1a853841b27..416a5d353e8 100644
--- a/configs/devices/mips-softmmu/common.mak
+++ b/configs/devices/mips-softmmu/common.mak
@@ -1,28 +1,8 @@
 # Common mips*-softmmu CONFIG defines
 
-CONFIG_ISA_BUS=y
-CONFIG_PCI=y
-CONFIG_PCI_DEVICES=y
-CONFIG_VGA_ISA=y
-CONFIG_VGA_MMIO=y
-CONFIG_VGA_CIRRUS=y
-CONFIG_VMWARE_VGA=y
-CONFIG_SERIAL=y
-CONFIG_SERIAL_ISA=y
-CONFIG_PARALLEL=y
-CONFIG_I8254=y
-CONFIG_PCSPK=y
-CONFIG_PCKBD=y
-CONFIG_FDC=y
-CONFIG_I8257=y
-CONFIG_IDE_ISA=y
-CONFIG_PFLASH_CFI01=y
-CONFIG_I8259=y
-CONFIG_MC146818RTC=y
-CONFIG_MIPS_CPS=y
-CONFIG_MIPS_ITU=y
+# Uncomment the following lines to disable these optional devices:
+# CONFIG_PCI_DEVICES=n
+# CONFIG_TEST_DEVICES=n
+
 CONFIG_MALTA=y
-CONFIG_PCNET_PCI=y
 CONFIG_MIPSSIM=y
-CONFIG_SMBUS_EEPROM=y
-CONFIG_TEST_DEVICES=y
diff --git a/configs/devices/mips64el-softmmu/default.mak b/configs/devices/mips64el-softmmu/default.mak
index d5188f7ea58..88a37cf27f1 100644
--- a/configs/devices/mips64el-softmmu/default.mak
+++ b/configs/devices/mips64el-softmmu/default.mak
@@ -3,8 +3,5 @@
 include ../mips-softmmu/common.mak
 CONFIG_FULOONG=y
 CONFIG_LOONGSON3V=y
-CONFIG_ATI_VGA=y
-CONFIG_RTL8139_PCI=y
 CONFIG_JAZZ=y
-CONFIG_VT82C686=y
 CONFIG_MIPS_BOSTON=y
diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml
index f56df59c949..3aead277246 100644
--- a/.gitlab-ci.d/buildtest.yml
+++ b/.gitlab-ci.d/buildtest.yml
@@ -659,7 +659,7 @@ build-without-defaults:
       --disable-pie
       --disable-qom-cast-debug
       --disable-strip
-    TARGETS: avr-softmmu mips64-softmmu s390x-softmmu sh4-softmmu
+    TARGETS: avr-softmmu s390x-softmmu sh4-softmmu
       sparc64-softmmu hexagon-linux-user i386-linux-user s390x-linux-user
     MAKE_CHECK_ARGS: check
 
diff --git a/hw/display/Kconfig b/hw/display/Kconfig
index 1aafe1923d2..5b2b3840f7a 100644
--- a/hw/display/Kconfig
+++ b/hw/display/Kconfig
@@ -55,7 +55,7 @@ config VGA_MMIO
 
 config VMWARE_VGA
     bool
-    default y if PCI_DEVICES && PC_PCI
+    default y if PCI_DEVICES && (PC_PCI || MIPS)
     depends on PCI
     select VGA
 
diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig
index e57db4f6412..5c83ef49cf6 100644
--- a/hw/mips/Kconfig
+++ b/hw/mips/Kconfig
@@ -1,8 +1,15 @@
 config MALTA
     bool
+    imply PCNET_PCI
+    imply PCI_DEVICES
+    imply TEST_DEVICES
     select FDC37M81X
     select GT64120
+    select MIPS_CPS
     select PIIX
+    select PFLASH_CFI01
+    select SERIAL
+    select SMBUS_EEPROM
 
 config MIPSSIM
     bool
@@ -31,17 +38,26 @@ config JAZZ
 
 config FULOONG
     bool
+    imply PCI_DEVICES
+    imply TEST_DEVICES
+    imply ATI_VGA
+    imply RTL8139_PCI
     select PCI_BONITO
+    select SMBUS_EEPROM
     select VT82C686
 
 config LOONGSON3V
     bool
+    imply PCI_DEVICES
+    imply TEST_DEVICES
+    imply VIRTIO_PCI
+    imply VIRTIO_NET
     imply VIRTIO_VGA
     imply QXL if SPICE
+    imply USB_OHCI_PCI
     select SERIAL
     select GOLDFISH_RTC
     select LOONGSON_LIOINTC
-    select PCI_DEVICES
     select PCI_EXPRESS_GENERIC_BRIDGE
     select MSI_NONBROKEN
     select FW_CFG_MIPS
@@ -53,6 +69,8 @@ config MIPS_CPS
 
 config MIPS_BOSTON
     bool
+    imply PCI_DEVICES
+    imply TEST_DEVICES
     select FITLOADER
     select MIPS_CPS
     select PCI_EXPRESS_XILINX
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH v3 6/9] isa: extract FDC37M81X to a separate file
  2024-02-13 15:50 ` [PATCH v3 6/9] isa: extract FDC37M81X to a separate file Paolo Bonzini
@ 2024-02-13 19:07   ` Bernhard Beschow
  0 siblings, 0 replies; 18+ messages in thread
From: Bernhard Beschow @ 2024-02-13 19:07 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: philmd, balaton



Am 13. Februar 2024 15:50:01 UTC schrieb Paolo Bonzini <pbonzini@redhat.com>:
>isa-superio.c currently defines a SuperIO chip that is not used
>by any other user of the file.  Extract the chip to a separate file.
>
>Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>

I think in v2 Zoltan only pointed out a typo in the commit message (which is now fixed) but didn't add an R-b tag so far.

Best regards,
Bernhard

>Reviewed-by: Bernhard Beschow <shentey@gmail.com>
>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>---
> hw/isa/fdc37m81x-superio.c | 32 ++++++++++++++++++++++++++++++++
> hw/isa/isa-superio.c       | 18 ------------------
> hw/isa/Kconfig             |  4 ++++
> hw/isa/meson.build         |  1 +
> hw/mips/Kconfig            |  2 +-
> 5 files changed, 38 insertions(+), 19 deletions(-)
> create mode 100644 hw/isa/fdc37m81x-superio.c
>
>diff --git a/hw/isa/fdc37m81x-superio.c b/hw/isa/fdc37m81x-superio.c
>new file mode 100644
>index 00000000000..55e91fbca17
>--- /dev/null
>+++ b/hw/isa/fdc37m81x-superio.c
>@@ -0,0 +1,32 @@
>+/*
>+ * SMS FDC37M817 Super I/O
>+ *
>+ * Copyright (c) 2018 Philippe Mathieu-Daudé
>+ *
>+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
>+ * See the COPYING file in the top-level directory.
>+ * SPDX-License-Identifier: GPL-2.0-or-later
>+ */
>+
>+#include "qemu/osdep.h"
>+#include "hw/isa/superio.h"
>+
>+static void fdc37m81x_class_init(ObjectClass *klass, void *data)
>+{
>+    ISASuperIOClass *sc = ISA_SUPERIO_CLASS(klass);
>+
>+    sc->serial.count = 2; /* NS16C550A */
>+    sc->parallel.count = 1;
>+    sc->floppy.count = 1; /* SMSC 82077AA Compatible */
>+    sc->ide.count = 0;
>+}
>+
>+static const TypeInfo types[] = {
>+    {
>+        .name          = TYPE_FDC37M81X_SUPERIO,
>+        .parent        = TYPE_ISA_SUPERIO,
>+        .class_init    = fdc37m81x_class_init,
>+    },
>+};
>+
>+DEFINE_TYPES(types)
>diff --git a/hw/isa/isa-superio.c b/hw/isa/isa-superio.c
>index 98d50844f71..a8c8c58ef7f 100644
>--- a/hw/isa/isa-superio.c
>+++ b/hw/isa/isa-superio.c
>@@ -190,27 +190,9 @@ static const TypeInfo isa_superio_type_info = {
>     .instance_size = sizeof(ISASuperIODevice),
> };
> 
>-/* SMS FDC37M817 Super I/O */
>-static void fdc37m81x_class_init(ObjectClass *klass, void *data)
>-{
>-    ISASuperIOClass *sc = ISA_SUPERIO_CLASS(klass);
>-
>-    sc->serial.count = 2; /* NS16C550A */
>-    sc->parallel.count = 1;
>-    sc->floppy.count = 1; /* SMSC 82077AA Compatible */
>-    sc->ide.count = 0;
>-}
>-
>-static const TypeInfo fdc37m81x_type_info = {
>-    .name          = TYPE_FDC37M81X_SUPERIO,
>-    .parent        = TYPE_ISA_SUPERIO,
>-    .class_init    = fdc37m81x_class_init,
>-};
>-
> static void isa_superio_register_types(void)
> {
>     type_register_static(&isa_superio_type_info);
>-    type_register_static(&fdc37m81x_type_info);
> }
> 
> type_init(isa_superio_register_types)
>diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig
>index 5df3c09cd51..73c6470805c 100644
>--- a/hw/isa/Kconfig
>+++ b/hw/isa/Kconfig
>@@ -23,6 +23,10 @@ config ISA_SUPERIO
>     # Some users of ISA_SUPERIO do not use it
>     #select IDE_ISA
> 
>+config FDC37M81X
>+    bool
>+    select ISA_SUPERIO
>+
> config PC87312
>     bool
>     select ISA_SUPERIO
>diff --git a/hw/isa/meson.build b/hw/isa/meson.build
>index 2ab99ce0c6b..f650b395071 100644
>--- a/hw/isa/meson.build
>+++ b/hw/isa/meson.build
>@@ -4,6 +4,7 @@ system_ss.add(when: 'CONFIG_ISA_BUS', if_true: files('isa-bus.c'))
> system_ss.add(when: 'CONFIG_ISA_SUPERIO', if_true: files('isa-superio.c'))
> system_ss.add(when: 'CONFIG_PC87312', if_true: files('pc87312.c'))
> system_ss.add(when: 'CONFIG_PIIX', if_true: files('piix.c'))
>+system_ss.add(when: 'CONFIG_FDC37M81X', if_true: files('fdc37m81x-superio.c'))
> system_ss.add(when: 'CONFIG_SMC37C669', if_true: files('smc37c669-superio.c'))
> system_ss.add(when: 'CONFIG_VT82C686', if_true: files('vt82c686.c'))
> 
>diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig
>index afcfb2b8eca..e57db4f6412 100644
>--- a/hw/mips/Kconfig
>+++ b/hw/mips/Kconfig
>@@ -1,7 +1,7 @@
> config MALTA
>     bool
>+    select FDC37M81X
>     select GT64120
>-    select ISA_SUPERIO
>     select PIIX
> 
> config MIPSSIM


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v3 8/9] mips/loongson3_virt: do not require CONFIG_USB
  2024-02-13 15:50 ` [PATCH v3 8/9] mips/loongson3_virt: do not require CONFIG_USB Paolo Bonzini
@ 2024-02-15  7:55   ` Philippe Mathieu-Daudé
  2024-02-15 11:12     ` Paolo Bonzini
  2024-02-15 14:27     ` BALATON Zoltan
  0 siblings, 2 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-15  7:55 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: shentey, balaton

On 13/2/24 16:50, Paolo Bonzini wrote:
> Once the Kconfig for hw/mips is cleaned up, it will be possible to build a
> binary that does not include any USB host controller and therefore that
> does not include the code guarded by CONFIG_USB.  While the simpler
> creation functions such as usb_create_simple can be inlined, this is not
> true of usb_bus_find().  Remove it, replacing it with a search of the
> single USB bus created by loongson3_virt_devices_init().
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   hw/mips/loongson3_virt.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c
> index caedde2df00..bedd3d496bd 100644
> --- a/hw/mips/loongson3_virt.c
> +++ b/hw/mips/loongson3_virt.c
> @@ -447,8 +447,9 @@ static inline void loongson3_virt_devices_init(MachineState *machine,
>   
>       if (defaults_enabled() && object_class_by_name("pci-ohci")) {
>           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");
> +        Object *usb_bus = object_resolve_path_type("", TYPE_USB_BUS, NULL);
> +        usb_create_simple(USB_BUS(usb_bus), "usb-kbd");
> +        usb_create_simple(USB_BUS(usb_bus), "usb-tablet");
>       }
>   
>       pci_init_nic_devices(pci_bus, mc->default_nic);

Can we remove usb_bus_find() completely instead?

$ git grep -w usb_bus_find
hw/hppa/machine.c:401:        usb_create_simple(usb_bus_find(-1), 
"usb-kbd");
hw/hppa/machine.c:402:        usb_create_simple(usb_bus_find(-1), 
"usb-mouse");
hw/mips/loongson3_virt.c:450:        usb_create_simple(usb_bus_find(-1), 
"usb-kbd");
hw/mips/loongson3_virt.c:451:        usb_create_simple(usb_bus_find(-1), 
"usb-tablet");
hw/ppc/mac_newworld.c:434:            USBBus *usb_bus = usb_bus_find(-1);
hw/ppc/sam460ex.c:423:    usb_create_simple(usb_bus_find(-1), "usb-kbd");
hw/ppc/sam460ex.c:424:    usb_create_simple(usb_bus_find(-1), "usb-mouse");
hw/ppc/spapr.c:3027:            USBBus *usb_bus = usb_bus_find(-1);
hw/sh4/r2d.c:315:    usb_create_simple(usb_bus_find(-1), "usb-kbd");
hw/usb/bus.c:103:USBBus *usb_bus_find(int busnr)
hw/usb/bus.c:669:    USBBus *bus = usb_bus_find(-1 /* any */);
include/hw/usb.h:500:USBBus *usb_bus_find(int busnr);



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v3 8/9] mips/loongson3_virt: do not require CONFIG_USB
  2024-02-15  7:55   ` Philippe Mathieu-Daudé
@ 2024-02-15 11:12     ` Paolo Bonzini
  2024-02-15 14:27     ` BALATON Zoltan
  1 sibling, 0 replies; 18+ messages in thread
From: Paolo Bonzini @ 2024-02-15 11:12 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel, shentey, balaton

On Thu, Feb 15, 2024 at 8:55 AM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
> >       if (defaults_enabled() && object_class_by_name("pci-ohci")) {
> >           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");
> > +        Object *usb_bus = object_resolve_path_type("", TYPE_USB_BUS, NULL);
> > +        usb_create_simple(USB_BUS(usb_bus), "usb-kbd");
> > +        usb_create_simple(USB_BUS(usb_bus), "usb-tablet");
> >       }
> >
> >       pci_init_nic_devices(pci_bus, mc->default_nic);
>
> Can we remove usb_bus_find() completely instead?

s/instead/in fact/

Yes, we can, but this would be just one patch in that series...

Paolo

> $ git grep -w usb_bus_find
> hw/hppa/machine.c:401:        usb_create_simple(usb_bus_find(-1),
> "usb-kbd");
> hw/hppa/machine.c:402:        usb_create_simple(usb_bus_find(-1),
> "usb-mouse");
> hw/mips/loongson3_virt.c:450:        usb_create_simple(usb_bus_find(-1),
> "usb-kbd");
> hw/mips/loongson3_virt.c:451:        usb_create_simple(usb_bus_find(-1),
> "usb-tablet");
> hw/ppc/mac_newworld.c:434:            USBBus *usb_bus = usb_bus_find(-1);
> hw/ppc/sam460ex.c:423:    usb_create_simple(usb_bus_find(-1), "usb-kbd");
> hw/ppc/sam460ex.c:424:    usb_create_simple(usb_bus_find(-1), "usb-mouse");
> hw/ppc/spapr.c:3027:            USBBus *usb_bus = usb_bus_find(-1);
> hw/sh4/r2d.c:315:    usb_create_simple(usb_bus_find(-1), "usb-kbd");
> hw/usb/bus.c:103:USBBus *usb_bus_find(int busnr)
> hw/usb/bus.c:669:    USBBus *bus = usb_bus_find(-1 /* any */);
> include/hw/usb.h:500:USBBus *usb_bus_find(int busnr);



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v3 8/9] mips/loongson3_virt: do not require CONFIG_USB
  2024-02-15  7:55   ` Philippe Mathieu-Daudé
  2024-02-15 11:12     ` Paolo Bonzini
@ 2024-02-15 14:27     ` BALATON Zoltan
  2024-02-15 17:31       ` Paolo Bonzini
  1 sibling, 1 reply; 18+ messages in thread
From: BALATON Zoltan @ 2024-02-15 14:27 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: Paolo Bonzini, qemu-devel, shentey

[-- Attachment #1: Type: text/plain, Size: 3075 bytes --]

On Thu, 15 Feb 2024, Philippe Mathieu-Daudé wrote:
> On 13/2/24 16:50, Paolo Bonzini wrote:
>> Once the Kconfig for hw/mips is cleaned up, it will be possible to build a
>> binary that does not include any USB host controller and therefore that
>> does not include the code guarded by CONFIG_USB.  While the simpler
>> creation functions such as usb_create_simple can be inlined, this is not
>> true of usb_bus_find().  Remove it, replacing it with a search of the
>> single USB bus created by loongson3_virt_devices_init().
>> 
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>   hw/mips/loongson3_virt.c | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>> 
>> diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c
>> index caedde2df00..bedd3d496bd 100644
>> --- a/hw/mips/loongson3_virt.c
>> +++ b/hw/mips/loongson3_virt.c
>> @@ -447,8 +447,9 @@ static inline void 
>> loongson3_virt_devices_init(MachineState *machine,
>>         if (defaults_enabled() && object_class_by_name("pci-ohci")) {
>>           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");
>> +        Object *usb_bus = object_resolve_path_type("", TYPE_USB_BUS, 
>> NULL);
>> +        usb_create_simple(USB_BUS(usb_bus), "usb-kbd");
>> +        usb_create_simple(USB_BUS(usb_bus), "usb-tablet");
>>       }
>>         pci_init_nic_devices(pci_bus, mc->default_nic);
>
> Can we remove usb_bus_find() completely instead?
>
> $ git grep -w usb_bus_find
> hw/hppa/machine.c:401:        usb_create_simple(usb_bus_find(-1), "usb-kbd");
> hw/hppa/machine.c:402:        usb_create_simple(usb_bus_find(-1), 
> "usb-mouse");
> hw/mips/loongson3_virt.c:450:        usb_create_simple(usb_bus_find(-1), 
> "usb-kbd");
> hw/mips/loongson3_virt.c:451:        usb_create_simple(usb_bus_find(-1), 
> "usb-tablet");
> hw/ppc/mac_newworld.c:434:            USBBus *usb_bus = usb_bus_find(-1);
> hw/ppc/sam460ex.c:423:    usb_create_simple(usb_bus_find(-1), "usb-kbd");
> hw/ppc/sam460ex.c:424:    usb_create_simple(usb_bus_find(-1), "usb-mouse");
> hw/ppc/spapr.c:3027:            USBBus *usb_bus = usb_bus_find(-1);
> hw/sh4/r2d.c:315:    usb_create_simple(usb_bus_find(-1), "usb-kbd");
> hw/usb/bus.c:103:USBBus *usb_bus_find(int busnr)
> hw/usb/bus.c:669:    USBBus *bus = usb_bus_find(-1 /* any */);
> include/hw/usb.h:500:USBBus *usb_bus_find(int busnr);

These are all the machines that add devices to a USB bus, there's no other 
example to do it in a different way currently. We could change this to get 
the usb bus in a different way but how? We could either peek into the 
object that owns the usb_bus or try using qdev_get_child_bus() but that 
needs the name of the bus which might change if other usb hosts are added 
so neither of these options seem better than this function. What would it 
bring to remove this function other than more complex or uglier code? I 
don't mind if you remove it just don't see the benefit in that.

Regards,
BALATON Zoltan

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v3 8/9] mips/loongson3_virt: do not require CONFIG_USB
  2024-02-15 14:27     ` BALATON Zoltan
@ 2024-02-15 17:31       ` Paolo Bonzini
  0 siblings, 0 replies; 18+ messages in thread
From: Paolo Bonzini @ 2024-02-15 17:31 UTC (permalink / raw)
  To: BALATON Zoltan; +Cc: Philippe Mathieu-Daudé, qemu-devel, shentey

On Thu, Feb 15, 2024 at 3:27 PM BALATON Zoltan <balaton@eik.bme.hu> wrote:
>
> On Thu, 15 Feb 2024, Philippe Mathieu-Daudé wrote:
> > On 13/2/24 16:50, Paolo Bonzini wrote:
> >> Once the Kconfig for hw/mips is cleaned up, it will be possible to build a
> >> binary that does not include any USB host controller and therefore that
> >> does not include the code guarded by CONFIG_USB.  While the simpler
> >> creation functions such as usb_create_simple can be inlined, this is not
> >> true of usb_bus_find().  Remove it, replacing it with a search of the
> >> single USB bus created by loongson3_virt_devices_init().
> >>
> >> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> >> ---
> >>   hw/mips/loongson3_virt.c | 5 +++--
> >>   1 file changed, 3 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c
> >> index caedde2df00..bedd3d496bd 100644
> >> --- a/hw/mips/loongson3_virt.c
> >> +++ b/hw/mips/loongson3_virt.c
> >> @@ -447,8 +447,9 @@ static inline void
> >> loongson3_virt_devices_init(MachineState *machine,
> >>         if (defaults_enabled() && object_class_by_name("pci-ohci")) {
> >>           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");
> >> +        Object *usb_bus = object_resolve_path_type("", TYPE_USB_BUS,
> >> NULL);
> >> +        usb_create_simple(USB_BUS(usb_bus), "usb-kbd");
> >> +        usb_create_simple(USB_BUS(usb_bus), "usb-tablet");
> >>       }
> >>         pci_init_nic_devices(pci_bus, mc->default_nic);
> >
> > Can we remove usb_bus_find() completely instead?
> >
> > $ git grep -w usb_bus_find
> > hw/hppa/machine.c:401:        usb_create_simple(usb_bus_find(-1), "usb-kbd");
> > hw/hppa/machine.c:402:        usb_create_simple(usb_bus_find(-1),
> > "usb-mouse");
> > hw/mips/loongson3_virt.c:450:        usb_create_simple(usb_bus_find(-1),
> > "usb-kbd");
> > hw/mips/loongson3_virt.c:451:        usb_create_simple(usb_bus_find(-1),
> > "usb-tablet");
> > hw/ppc/mac_newworld.c:434:            USBBus *usb_bus = usb_bus_find(-1);
> > hw/ppc/sam460ex.c:423:    usb_create_simple(usb_bus_find(-1), "usb-kbd");
> > hw/ppc/sam460ex.c:424:    usb_create_simple(usb_bus_find(-1), "usb-mouse");
> > hw/ppc/spapr.c:3027:            USBBus *usb_bus = usb_bus_find(-1);
> > hw/sh4/r2d.c:315:    usb_create_simple(usb_bus_find(-1), "usb-kbd");
> > hw/usb/bus.c:103:USBBus *usb_bus_find(int busnr)
> > hw/usb/bus.c:669:    USBBus *bus = usb_bus_find(-1 /* any */);
> > include/hw/usb.h:500:USBBus *usb_bus_find(int busnr);
>
> These are all the machines that add devices to a USB bus, there's no other
> example to do it in a different way currently. We could change this to get
> the usb bus in a different way but how?

We can move object_resolve_type_unambiguous out of
hw/i386/acpi-build.c to common code and use it, it's overall a
self-explanatory function.



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v3 0/9] mips: do not list individual devices from configs/
  2024-02-13 15:49 [PATCH v3 0/9] mips: do not list individual devices from configs/ Paolo Bonzini
                   ` (8 preceding siblings ...)
  2024-02-13 15:50 ` [PATCH v3 9/9] mips: do not list individual devices from configs/ Paolo Bonzini
@ 2024-02-15 17:51 ` Philippe Mathieu-Daudé
  9 siblings, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-15 17:51 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: shentey, balaton

Hi,

On 13/2/24 16:49, Paolo Bonzini wrote:

> Bernhard Beschow (1):
>    hw/mips/Kconfig: Remove ISA dependencies from MIPSsim board
> 
> Paolo Bonzini (8):

>    isa: clean up Kconfig selections for ISA_SUPERIO
>    isa: fix ISA_SUPERIO dependencies
>    isa: specify instance_size in isa_superio_type_info
>    isa: extract FDC37M81X to a separate file

I'm a bit reluctant with the USB changes so far, so I'm queuing
these 5 patches meanwhile.

Regards,

Phil.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v3 1/9] usb: inline device creation functions
  2024-02-13 15:49 ` [PATCH v3 1/9] usb: inline device creation functions Paolo Bonzini
@ 2024-02-16 11:14   ` Philippe Mathieu-Daudé
  2024-02-17  9:49     ` Paolo Bonzini
  0 siblings, 1 reply; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-16 11:14 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: shentey, balaton, Richard Henderson

On 13/2/24 16:49, Paolo Bonzini wrote:
> Allow boards to use the device creation functions even if USB itself
> is not available; of course the functions will fail inexorably, but
> this can be okay if the calls are conditional on the existence of
> some USB host controller device.  This is for example the case for
> hw/mips/loongson3_virt.c.
> 
> Acked-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   include/hw/usb.h | 27 ++++++++++++++++++++++++---
>   hw/usb/bus.c     | 23 -----------------------
>   2 files changed, 24 insertions(+), 26 deletions(-)

See alternatives:
https://lore.kernel.org/qemu-devel/20240216110313.17039-10-philmd@linaro.org/
https://lore.kernel.org/qemu-devel/20240216110313.17039-11-philmd@linaro.org/


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v3 1/9] usb: inline device creation functions
  2024-02-16 11:14   ` Philippe Mathieu-Daudé
@ 2024-02-17  9:49     ` Paolo Bonzini
  0 siblings, 0 replies; 18+ messages in thread
From: Paolo Bonzini @ 2024-02-17  9:49 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, shentey, balaton, Richard Henderson

On Fri, Feb 16, 2024 at 12:14 PM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
>
> On 13/2/24 16:49, Paolo Bonzini wrote:
> > Allow boards to use the device creation functions even if USB itself
> > is not available; of course the functions will fail inexorably, but
> > this can be okay if the calls are conditional on the existence of
> > some USB host controller device.  This is for example the case for
> > hw/mips/loongson3_virt.c.
> >
> > Acked-by: Richard Henderson <richard.henderson@linaro.org>
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> > ---
> >   include/hw/usb.h | 27 ++++++++++++++++++++++++---
> >   hw/usb/bus.c     | 23 -----------------------
> >   2 files changed, 24 insertions(+), 26 deletions(-)
>
> See alternatives:
> https://lore.kernel.org/qemu-devel/20240216110313.17039-10-philmd@linaro.org/
> https://lore.kernel.org/qemu-devel/20240216110313.17039-11-philmd@linaro.org/

That doesn't include usb_create_simple(), which is the one that
matters the most here.

Paolo



^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2024-02-17  9:50 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-13 15:49 [PATCH v3 0/9] mips: do not list individual devices from configs/ Paolo Bonzini
2024-02-13 15:49 ` [PATCH v3 1/9] usb: inline device creation functions Paolo Bonzini
2024-02-16 11:14   ` Philippe Mathieu-Daudé
2024-02-17  9:49     ` Paolo Bonzini
2024-02-13 15:49 ` [PATCH v3 2/9] isa: clean up Kconfig selections for ISA_SUPERIO Paolo Bonzini
2024-02-13 15:49 ` [PATCH v3 3/9] hw/mips/Kconfig: Remove ISA dependencies from MIPSsim board Paolo Bonzini
2024-02-13 15:49 ` [PATCH v3 4/9] isa: fix ISA_SUPERIO dependencies Paolo Bonzini
2024-02-13 15:50 ` [PATCH v3 5/9] isa: specify instance_size in isa_superio_type_info Paolo Bonzini
2024-02-13 15:50 ` [PATCH v3 6/9] isa: extract FDC37M81X to a separate file Paolo Bonzini
2024-02-13 19:07   ` Bernhard Beschow
2024-02-13 15:50 ` [PATCH v3 7/9] mips: allow compiling out CONFIG_MIPS_ITU Paolo Bonzini
2024-02-13 15:50 ` [PATCH v3 8/9] mips/loongson3_virt: do not require CONFIG_USB Paolo Bonzini
2024-02-15  7:55   ` Philippe Mathieu-Daudé
2024-02-15 11:12     ` Paolo Bonzini
2024-02-15 14:27     ` BALATON Zoltan
2024-02-15 17:31       ` Paolo Bonzini
2024-02-13 15:50 ` [PATCH v3 9/9] mips: do not list individual devices from configs/ Paolo Bonzini
2024-02-15 17:51 ` [PATCH v3 0/9] " Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).