Skip to contentSkip to conversation

hw/ide/pci: Replace some magic numbers by constants

PATCH Philippe Mathieu-Daudé 3 participants 6 messages May 31, 2023 – Jul 10, 2023 4 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

Reviewed-by
#3 lore raw
In reply to a message not in the archive
Quoted 10 lines · Bernhard Beschow
---
  hw/ide/pci.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
hw/ide/pci.c +0 -0
index 0b26a4ce9f..a25b352537 100644

hw/ide/pci.c void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val) · line 327

Quoted 9 lines
hw/ide/pci.c +2 -1
@@ -320,7 +320,8 @@ void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val)
 
  void bmdma_status_writeb(BMDMAState *bm, uint32_t val)
  {
-    bm->status = (val & 0x60) | (bm->status & 1) | (bm->status & ~val & 0x06);
+    bm->status = (val & 0x60) | (bm->status & BM_STATUS_DMAING)
+                 | (bm->status & ~val & (BM_STATUS_ERROR | BM_STATUS_INT));
  }
 
  static uint64_t bmdma_addr_read(void *opaque, hwaddr addr,

ATB,

Mark.

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

Reviewed-by
#7 lore raw

Re: [PATCH v3 7/7] hw/ide/piix: Move registration of VMStateDescription to DeviceClass

Quoted 57 lines · Bernhard Beschow

The modern, declarative way to set up VM state handling is to assign to DeviceClass::vmsd attribute.

There shouldn't be any change in behavior since dc->vmsd causes vmstate_register_with_alias_id() to be called on the instance during the instance init phase. vmstate_register() was also called during the instance init phase which forwards to vmstate_register_with_alias_id() internally. Checking the migration schema before and after this patch confirms:

before:

Quoted 2 lines

qemu-system-x86_64 -S
qemu > migrate -d exec:cat>before.mig

after:

Quoted 6 lines

qemu-system-x86_64 -S
qemu > migrate -d exec:cat>after.mig

analyze-migration.py -d desc -f before.mig > before.json analyze-migration.py -d desc -f after.mig > after.json diff before.json after.json

-> empty

---
  hw/ide/piix.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)
hw/ide/piix.c +1 -3
index 47e0b474c3..151f206046 100644
@@ -28,7 +28,6 @@
   */
 
  #include "qemu/osdep.h"
-#include "migration/vmstate.h"
  #include "qapi/error.h"
  #include "hw/pci/pci.h"
  #include "hw/ide/piix.h"
@@ -159,8 +158,6 @@ static void pci_piix_ide_realize(PCIDevice *dev, Error **errp)
      bmdma_setup_bar(d);
      pci_register_bar(dev, 4, PCI_BASE_ADDRESS_SPACE_IO, &d->bmdma_bar);
 
-    vmstate_register(VMSTATE_IF(dev), 0, &vmstate_ide_pci, d);
-
      for (unsigned i = 0; i < 2; i++) {
          if (!pci_piix_init_bus(d, i, errp)) {
              return;
@@ -186,6 +183,7 @@ static void piix3_ide_class_init(ObjectClass *klass, void *data)
      PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
      dc->reset = piix_ide_reset;
+    dc->vmsd = &vmstate_ide_pci;
      k->realize = pci_piix_ide_realize;
      k->exit = pci_piix_ide_exitfn;
      k->vendor_id = PCI_VENDOR_ID_INTEL;

hw/ide/piix.c static void piix4_ide_class_init(ObjectClass *klass, void *data) · line 212

Quoted 7 lines
hw/ide/piix.c +1 -0
@@ -208,6 +206,7 @@ static void piix4_ide_class_init(ObjectClass *klass, void *data)
      PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
      dc->reset = piix_ide_reset;
+    dc->vmsd = &vmstate_ide_pci;
      k->realize = pci_piix_ide_realize;
      k->exit = pci_piix_ide_exitfn;
      k->vendor_id = PCI_VENDOR_ID_INTEL;

ATB,

Mark.

#8 lore raw

Re: [PATCH v3 0/7] VIA and general PCI IDE cleanup

In reply to a message not in the archive

Am 31. Mai 2023 21:10:36 UTC schrieb Bernhard Beschow <[email protected]>:

Quoted 78 lines

This series is split off from a more general PCI IDE refactoring aiming for a

common implementation of the PCI IDE controller specification for all

TYPE_PCI_IDE models [1].

The first three patches resolve a circular dependency between the VIA IDE

controller and its south bridge. The next three patches resolves redundant code

accross all TYPE_PCI_IDE models. The last patch modernizes VM state setup in

PIIX IDE.

Testing done:

* make check

* make check-avocado

* `qemu-system-ppc -machine pegasos2 -rtc base=localtime -device \

  ati-vga,guest_hwcursor=true,romfile="" -cdrom morphos-3.17.iso \

-bios pegasos2.rom`

The machine booted successfully and a startup sound was hearable

* `qemu-system-ppc -machine sam460ex -rtc base=localtime -drive \

  if=none,id=cd,file=morphos-3.17.iso,format=raw -device \

ide-cd,drive=cd,bus=ide.1`

The machine booted successfully into graphical desktop environment

v3:

* Fix formatting (Mark) ... and split into two commits (Bernhard)

v2:

* Add missing Signed-off-by tag to last commit (Zoltan)

Changes since [1]:

* Turn legacy IRQs into named GPIOs (Mark)

* Don't make VIA IDE legacy IRQs routable; just wire up in host device (Zoltan)

* Rename extracted bmdma_clear_status() (Zoltan)

... to bmdma_status_writeb() (Mark)

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

Bernhard Beschow (7):

hw/ide/pci: Expose legacy interrupts as named GPIOs

hw/ide/via: Wire up IDE legacy interrupts in host device

hw/isa/vt82c686: Remove via_isa_set_irq()

Quoted 8 lines

hw/ide: Extract IDEBus assignment into bmdma_init()

hw/ide: Extract bmdma_status_writeb()

hw/ide/pci: Replace some magic numbers by constants

hw/ide/piix: Move registration of VMStateDescription to DeviceClass

Ping

AFAICS all patches are reviewed.

Best regards,
Bernhard

Quoted 27 lines

include/hw/ide/pci.h | 1 +

include/hw/isa/vt82c686.h | 2 --

hw/ide/cmd646.c | 3 +--

hw/ide/pci.c | 16 ++++++++++++++++

hw/ide/piix.c | 8 +++-----

hw/ide/sii3112.c | 7 ++-----

hw/ide/via.c | 9 +++++----

hw/isa/vt82c686.c | 11 +++++------

8 files changed, 33 insertions(+), 24 deletions(-)

-- >
2.40.1

#9 lore raw

Re: [PATCH v3 0/7] VIA and general PCI IDE cleanup

In reply to a message not in the archive
Quoted 5 lines · Bernhard Beschow

This series is split off from a more general PCI IDE refactoring aiming for a common implementation of the PCI IDE controller specification for all TYPE_PCI_IDE models [1].

Quoted 8 lines

Bernhard Beschow (7):
hw/ide/pci: Expose legacy interrupts as named GPIOs hw/ide/via: Wire up IDE legacy interrupts in host device hw/isa/vt82c686: Remove via_isa_set_irq()
hw/ide: Extract IDEBus assignment into bmdma_init() hw/ide: Extract bmdma_status_writeb()
hw/ide/pci: Replace some magic numbers by constants hw/ide/piix: Move registration of VMStateDescription to DeviceClass

Queued to mips-next, thanks!