Skip to contentSkip to conversation

hw/ipack: Minor dust removal

PATCH Superseded Philippe Mathieu-Daudé 2 participants 5 messages Jan 21, 2025 Arm/Amlogic Meson SoC support

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover hw/ipack: Minor dust removal

Clarify what is what in Kconfig,
replace qemu_allocate_irqs() by qemu_init_irq().

Philippe Mathieu-Daudé (2):
hw/ipack: Clarify KConfig symbols hw/ipack: Remove legacy qemu_allocate_irqs() use

 include/hw/ipack/ipack.h       | 7 ++-----
 hw/ipack/ipack.c               | 7 +++----
 hw/char/Kconfig                | 5 +++++
 hw/char/meson.build            | 2 +-
 hw/ipack/Kconfig               | 4 ++++
 hw/ipack/meson.build           | 3 ++-
 tests/qtest/libqos/meson.build | 4 +++-
 tests/qtest/meson.build        | 4 +++-
 8 files changed, 23 insertions(+), 13 deletions(-)
Signature · 1 line
2.47.1
#1 lore raw

PATCH 1/2 hw/ipack: Clarify KConfig symbols

Split IPACK Kconfig key as {IPACK, TPCI200, IP_OCTAL_232}

- IPack is a bus
- TPCI200 is a PCI device providing an IPack bus
- IP-Octal232 is an IPack device plugged on an IPack bus

---
 hw/char/Kconfig                | 5 +++++
 hw/char/meson.build            | 2 +-
 hw/ipack/Kconfig               | 4 ++++
 hw/ipack/meson.build           | 3 ++-
 tests/qtest/libqos/meson.build | 4 +++-
 tests/qtest/meson.build        | 4 +++-
 6 files changed, 18 insertions(+), 4 deletions(-)
hw/char/Kconfig +5 -0
index 4b73a803bf3..1dc20ee4c2c 100644
@@ -78,3 +78,8 @@ config GOLDFISH_TTY
 
 config SHAKTI_UART
     bool
+
+config IP_OCTAL_232
+    bool
+    default y
+    depends on IPACK
hw/char/meson.build +1 -1
index 1750834385a..ed3529cbbb7 100644
@@ -4,7 +4,7 @@ system_ss.add(when: 'CONFIG_ESCC', if_true: files('escc.c'))
 system_ss.add(when: 'CONFIG_GRLIB', if_true: files('grlib_apbuart.c'))
 system_ss.add(when: 'CONFIG_IBEX', if_true: files('ibex_uart.c'))
 system_ss.add(when: 'CONFIG_IMX', if_true: files('imx_serial.c'))
-system_ss.add(when: 'CONFIG_IPACK', if_true: files('ipoctal232.c'))
+system_ss.add(when: 'CONFIG_IP_OCTAL_232', if_true: files('ipoctal232.c'))
 system_ss.add(when: 'CONFIG_ISA_BUS', if_true: files('parallel-isa.c'))
 system_ss.add(when: 'CONFIG_ISA_DEBUG', if_true: files('debugcon.c'))
 system_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_uart.c'))
hw/ipack/Kconfig +4 -0
index f8da24a62be..28d668727c8 100644
@@ -1,4 +1,8 @@
 config IPACK
     bool
+
+config TPCI200
+    bool
+    select IPACK
     default y if PCI_DEVICES
 	    depends on PCI
hw/ipack/meson.build +2 -1
index 26567f1068e..e4805228926 100644
@@ -1 +1,2 @@
-system_ss.add(when: 'CONFIG_IPACK', if_true: files('ipack.c', 'tpci200.c'))
+system_ss.add(when: 'CONFIG_IPACK', if_true: files('ipack.c'))
+system_ss.add(when: 'CONFIG_TPCI200', if_true: files('tpci200.c'))
tests/qtest/libqos/meson.build +3 -1
index 46f130ccfdb..1ddaf7b095b 100644
@@ -32,7 +32,6 @@ libqos_srcs = files(
         'i2c-omap.c',
         'igb.c',
         'sdhci.c',
-        'tpci200.c',
         'virtio.c',
         'virtio-balloon.c',
         'virtio-blk.c',
@@ -70,6 +69,9 @@ endif
 if config_all_devices.has_key('CONFIG_RISCV_IOMMU')
   libqos_srcs += files('riscv-iommu.c')
 endif
+if config_all_devices.has_key('CONFIG_TPCI200')
+  libqos_srcs += files('tpci200.c')
+endif
 
 libqos = static_library('qos', libqos_srcs + genh,
                         build_by_default: false)
tests/qtest/meson.build +3 -1
index 94b28e5a534..e60e92fe9de 100644
@@ -286,7 +286,6 @@ qos_test_ss.add(
   'e1000-test.c',
   'eepro100-test.c',
   'es1370-test.c',
-  'ipoctal232-test.c',
   'lsm303dlhc-mag-test.c',
   'isl_pmbus_vr-test.c',
   'max34451-test.c',
@@ -317,6 +316,9 @@ qos_test_ss.add(
 if config_all_devices.has_key('CONFIG_VIRTIO_SERIAL')
   qos_test_ss.add(files('virtio-serial-test.c'))
 endif
+if config_all_devices.has_key('CONFIG_IP_OCTAL_232')
+  qos_test_ss.add(files('ipoctal232-test.c'))
+endif
 
 if host_os != 'windows'
   qos_test_ss.add(files('e1000e-test.c'))
Signature · 1 line
2.47.1
#3 lore raw

PATCH 2/2 hw/ipack: Remove legacy qemu_allocate_irqs() use

In reply to Philippe Mathieu-Daudé

No need to dynamically allocate IRQ when we know before hands how many we'll use. Declare the 2 of them in IPackDevice state and initialize them in the DeviceRealize handler.

---
 include/hw/ipack/ipack.h | 7 ++-----
 hw/ipack/ipack.c         | 7 +++----
 2 files changed, 5 insertions(+), 9 deletions(-)
include/hw/ipack/ipack.h +2 -5
index cbcdda509d3..14540281496 100644
@@ -12,6 +12,7 @@
 #define QEMU_IPACK_H
 
 #include "hw/qdev-core.h"
+#include "hw/irq.h"
 #include "qom/object.h"
 
 
@@ -19,10 +20,8 @@
 OBJECT_DECLARE_SIMPLE_TYPE(IPackBus, IPACK_BUS)
 
 struct IPackBus {
-    /*< private >*/
     BusState parent_obj;
 
-    /* All fields are private */
     uint8_t n_slots;
     uint8_t free_slot;
     qemu_irq_handler set_irq;
@@ -58,13 +57,11 @@ struct IPackDeviceClass {
 };
 
 struct IPackDevice {
-    /*< private >*/
     DeviceState parent_obj;
-    /*< public >*/
 
     int32_t slot;
     /* IRQ objects for the IndustryPack INT0# and INT1# */
-    qemu_irq *irq;
+    qemu_irq irq[2];
 };
 
 extern const VMStateDescription vmstate_ipack_device;
hw/ipack/ipack.c +3 -4
index ed75f791832..ef59f5dcd62 100644
@@ -55,22 +55,21 @@ static void ipack_device_realize(DeviceState *dev, Error **errp)
     }
     bus->free_slot = idev->slot + 1;
 
-    idev->irq = qemu_allocate_irqs(bus->set_irq, idev, 2);
+    for (int i = 0; i < ARRAY_SIZE(idev->irq); i++) {
+        qemu_init_irq(idev->irq[i], bus->set_irq, idev, i);
+    }
 
     k->realize(dev, errp);
 }
 
 static void ipack_device_unrealize(DeviceState *dev)
 {
-    IPackDevice *idev = IPACK_DEVICE(dev);
     IPackDeviceClass *k = IPACK_DEVICE_GET_CLASS(dev);
 
     if (k->unrealize) {
         k->unrealize(dev);
         return;
     }
-
-    qemu_free_irqs(idev->irq, 2);
 }
 
 static const Property ipack_device_props[] = {
Signature · 1 line
2.47.1
#4 lore raw

Re: [PATCH 2/2] hw/ipack: Remove legacy qemu_allocate_irqs() use

Quoted 15 lines · Philippe Mathieu-Daudé

No need to dynamically allocate IRQ when we know before hands how many we'll use. Declare the 2 of them in IPackDevice state and initialize them in the DeviceRealize handler.

---
  include/hw/ipack/ipack.h | 7 ++-----
  hw/ipack/ipack.c         | 7 +++----
  2 files changed, 5 insertions(+), 9 deletions(-)
include/hw/ipack/ipack.h +0 -0
index cbcdda509d3..14540281496 100644
 

include/hw/ipack/ipack.h struct IPackDeviceClass { · line 64

Quoted 10 lines
include/hw/ipack/ipack.h +1 -3
 
  struct IPackDevice {
-    /*< private >*/
      DeviceState parent_obj;
-    /*< public >*/
 
      int32_t slot;
      /* IRQ objects for the IndustryPack INT0# and INT1# */
-    qemu_irq *irq;
+    qemu_irq irq[2];

Oops forgot to commit:

- qemu_irq irq[2];
+ IRQState irq[2];

Quoted 1 line
  };