All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-8.0 0/9] reset: Remove some deprecated APIs
@ 2022-11-04 16:15 Peter Maydell
  2022-11-04 16:15 ` [PATCH for-8.0 1/9] hw/s390x/s390-pci-inst.c: Use device_cold_reset() to reset PCI devices Peter Maydell
                   ` (8 more replies)
  0 siblings, 9 replies; 19+ messages in thread
From: Peter Maydell @ 2022-11-04 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Maciej S. Szmigiero, Gerd Hoffmann, Paolo Bonzini,
	Daniel P. Berrangé,
	Stefano Stabellini, Anthony Perard, Paul Durrant,
	Mark Cave-Ayland, Matthew Rosato, Halil Pasic,
	Christian Borntraeger, qemu-s390x, qemu-ppc

This patchset removes the remaining uses of some deprecated
reset-related APIs:
 * device_legacy_reset() -- replaced with device_cold_reset()
   (conversions require some thought)
 * qdev_reset_all() -- replaced with device_cold_reset()
   (mechanical no-behaviour-change conversion)
 * qbus_reset_all() -- replaced with bus_cold_reset()
   (mechanical no-behaviour-change conversion)

The first four patches have been on the list already; the
first three have been reviewed.

Mostly just tested with 'make check' and 'make check-avocado'.

This is of course all for-8.0 material, but I figured I
might as well push it out on list for review, especially
since I have some followup stuff that depends on this.

thanks
-- PMM

Peter Maydell (9):
  hw/s390x/s390-pci-inst.c: Use device_cold_reset() to reset PCI devices
  hw/audio/intel-hda: don't reset codecs twice
  hw/audio/intel-hda: Drop unnecessary prototype
  hw/usb/hcd-xhci: Reset the XHCIState with device_cold_reset()
  pci: Use device_cold_reset() and bus_cold_reset()
  hw/hyperv/vmbus: Use device_cold_reset() and bus_cold_reset()
  Replace use of qdev_reset_all() with device_cold_reset()
  qdev: Remove qdev_reset_all() and qbus_reset_all()
  hw: Remove device_legacy_reset()

 include/hw/qdev-core.h     | 35 ---------------------
 hw/audio/intel-hda.c       |  6 +---
 hw/core/qdev.c             | 64 --------------------------------------
 hw/hyperv/vmbus.c          |  4 +--
 hw/i386/xen/xen_platform.c |  2 +-
 hw/input/adb.c             |  2 +-
 hw/pci/pci.c               |  6 ++--
 hw/pci/pci_bridge.c        |  2 +-
 hw/remote/vfio-user-obj.c  |  2 +-
 hw/s390x/s390-pci-inst.c   |  2 +-
 hw/s390x/s390-virtio-ccw.c |  2 +-
 hw/usb/dev-uas.c           |  2 +-
 hw/usb/hcd-xhci-pci.c      |  2 +-
 hw/usb/hcd-xhci-sysbus.c   |  2 +-
 hw/core/trace-events       |  4 ---
 15 files changed, 15 insertions(+), 122 deletions(-)

-- 
2.25.1



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

* [PATCH for-8.0 1/9] hw/s390x/s390-pci-inst.c: Use device_cold_reset() to reset PCI devices
  2022-11-04 16:15 [PATCH for-8.0 0/9] reset: Remove some deprecated APIs Peter Maydell
@ 2022-11-04 16:15 ` Peter Maydell
  2022-11-30 10:07   ` Philippe Mathieu-Daudé
  2022-11-04 16:15 ` [PATCH for-8.0 2/9] hw/audio/intel-hda: don't reset codecs twice Peter Maydell
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Peter Maydell @ 2022-11-04 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Maciej S. Szmigiero, Gerd Hoffmann, Paolo Bonzini,
	Daniel P. Berrangé,
	Stefano Stabellini, Anthony Perard, Paul Durrant,
	Mark Cave-Ayland, Matthew Rosato, Halil Pasic,
	Christian Borntraeger, qemu-s390x, qemu-ppc

The semantic difference between the deprecated device_legacy_reset()
function and the newer device_cold_reset() function is that the new
function resets both the device itself and any qbuses it owns,
whereas the legacy function resets just the device itself and nothing
else.

In s390-pci-inst.c we use device_legacy_reset() to reset an
S390PCIBusDevice.  This device doesn't have any child qbuses, so the
functions do the same thing and we can stop using the deprecated one.

Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/s390x/s390-pci-inst.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
index 20a9bcc7afb..16f5a3e81b4 100644
--- a/hw/s390x/s390-pci-inst.c
+++ b/hw/s390x/s390-pci-inst.c
@@ -272,7 +272,7 @@ int clp_service_call(S390CPU *cpu, uint8_t r2, uintptr_t ra)
                 stw_p(&ressetpci->hdr.rsp, CLP_RC_SETPCIFN_FHOP);
                 goto out;
             }
-            device_legacy_reset(DEVICE(pbdev));
+            device_cold_reset(DEVICE(pbdev));
             pbdev->fh &= ~FH_MASK_ENABLE;
             pbdev->state = ZPCI_FS_DISABLED;
             stl_p(&ressetpci->fh, pbdev->fh);
-- 
2.25.1



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

* [PATCH for-8.0 2/9] hw/audio/intel-hda: don't reset codecs twice
  2022-11-04 16:15 [PATCH for-8.0 0/9] reset: Remove some deprecated APIs Peter Maydell
  2022-11-04 16:15 ` [PATCH for-8.0 1/9] hw/s390x/s390-pci-inst.c: Use device_cold_reset() to reset PCI devices Peter Maydell
@ 2022-11-04 16:15 ` Peter Maydell
  2022-11-04 16:15 ` [PATCH for-8.0 3/9] hw/audio/intel-hda: Drop unnecessary prototype Peter Maydell
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 19+ messages in thread
From: Peter Maydell @ 2022-11-04 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Maciej S. Szmigiero, Gerd Hoffmann, Paolo Bonzini,
	Daniel P. Berrangé,
	Stefano Stabellini, Anthony Perard, Paul Durrant,
	Mark Cave-Ayland, Matthew Rosato, Halil Pasic,
	Christian Borntraeger, qemu-s390x, qemu-ppc

Currently the intel-hda device has a reset method which manually
resets all the codecs by calling device_legacy_reset() on them.  This
means they get reset twice, once because child devices on a qbus get
reset before the parent device's reset method is called, and then
again because we're manually resetting them.

Drop the manual reset call, and ensure that codecs are still reset
when the guest does a reset via ICH6_GCTL_RESET by using
device_cold_reset() (which resets all the devices on the qbus as well
as the device itself) instead of a direct call to the reset function.

This is a slight ordering change because the (only) codec reset now
happens before the controller registers etc are reset, rather than
once before and then once after, but the codec reset function
hda_audio_reset() doesn't care.

This lets us drop a use of device_legacy_reset(), which is
deprecated.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/audio/intel-hda.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index f38117057b9..38cfa20262e 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -516,7 +516,7 @@ static void intel_hda_notify_codecs(IntelHDAState *d, uint32_t stream, bool runn
 static void intel_hda_set_g_ctl(IntelHDAState *d, const IntelHDAReg *reg, uint32_t old)
 {
     if ((d->g_ctl & ICH6_GCTL_RESET) == 0) {
-        intel_hda_reset(DEVICE(d));
+        device_cold_reset(DEVICE(d));
     }
 }
 
@@ -1083,11 +1083,9 @@ static void intel_hda_reset(DeviceState *dev)
     intel_hda_regs_reset(d);
     d->wall_base_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
 
-    /* reset codecs */
     QTAILQ_FOREACH(kid, &d->codecs.qbus.children, sibling) {
         DeviceState *qdev = kid->child;
         cdev = HDA_CODEC_DEVICE(qdev);
-        device_legacy_reset(DEVICE(cdev));
         d->state_sts |= (1 << cdev->cad);
     }
     intel_hda_update_irq(d);
-- 
2.25.1



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

* [PATCH for-8.0 3/9] hw/audio/intel-hda: Drop unnecessary prototype
  2022-11-04 16:15 [PATCH for-8.0 0/9] reset: Remove some deprecated APIs Peter Maydell
  2022-11-04 16:15 ` [PATCH for-8.0 1/9] hw/s390x/s390-pci-inst.c: Use device_cold_reset() to reset PCI devices Peter Maydell
  2022-11-04 16:15 ` [PATCH for-8.0 2/9] hw/audio/intel-hda: don't reset codecs twice Peter Maydell
@ 2022-11-04 16:15 ` Peter Maydell
  2022-11-04 16:15 ` [PATCH for-8.0 4/9] hw/usb/hcd-xhci: Reset the XHCIState with device_cold_reset() Peter Maydell
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 19+ messages in thread
From: Peter Maydell @ 2022-11-04 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Maciej S. Szmigiero, Gerd Hoffmann, Paolo Bonzini,
	Daniel P. Berrangé,
	Stefano Stabellini, Anthony Perard, Paul Durrant,
	Mark Cave-Ayland, Matthew Rosato, Halil Pasic,
	Christian Borntraeger, qemu-s390x, qemu-ppc

The only use of intel_hda_reset() is after its definition, so we
don't need to separately declare its prototype at the top of the
file; drop the unnecessary line.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/audio/intel-hda.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index 38cfa20262e..b9ed231fe84 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -220,8 +220,6 @@ struct IntelHDAReg {
     void       (*rhandler)(IntelHDAState *d, const IntelHDAReg *reg);
 };
 
-static void intel_hda_reset(DeviceState *dev);
-
 /* --------------------------------------------------------------------- */
 
 static hwaddr intel_hda_addr(uint32_t lbase, uint32_t ubase)
-- 
2.25.1



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

* [PATCH for-8.0 4/9] hw/usb/hcd-xhci: Reset the XHCIState with device_cold_reset()
  2022-11-04 16:15 [PATCH for-8.0 0/9] reset: Remove some deprecated APIs Peter Maydell
                   ` (2 preceding siblings ...)
  2022-11-04 16:15 ` [PATCH for-8.0 3/9] hw/audio/intel-hda: Drop unnecessary prototype Peter Maydell
@ 2022-11-04 16:15 ` Peter Maydell
  2022-11-30 10:11   ` Philippe Mathieu-Daudé
  2022-11-04 16:15 ` [PATCH for-8.0 5/9] pci: Use device_cold_reset() and bus_cold_reset() Peter Maydell
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Peter Maydell @ 2022-11-04 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Maciej S. Szmigiero, Gerd Hoffmann, Paolo Bonzini,
	Daniel P. Berrangé,
	Stefano Stabellini, Anthony Perard, Paul Durrant,
	Mark Cave-Ayland, Matthew Rosato, Halil Pasic,
	Christian Borntraeger, qemu-s390x, qemu-ppc

Currently the hcd-xhci-pci and hcd-xhci-sysbus devices, which are
mostly wrappers around the TYPE_XHCI device, which is a direct
subclass of TYPE_DEVICE.  Since TYPE_DEVICE devices are not on any
qbus and do not get automatically reset, the wrapper devices both
reset the TYPE_XHCI device in their own reset functions.  However,
they do this using device_legacy_reset(), which will reset the device
itself but not any bus it has.

Switch to device_cold_reset(), which avoids using a deprecated
function and also propagates reset along any child buses.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
It's possible this might result in USB devices on the bus getting
reset more than once (once via the descent-along-qbus and once when
xhci_reset() etc manually reset each port), but in my testing with
gdb I couldn't get that to happen.  It should be harmless anyway.
---
 hw/usb/hcd-xhci-pci.c    | 2 +-
 hw/usb/hcd-xhci-sysbus.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c
index e934b1a5b1f..643d4643e4d 100644
--- a/hw/usb/hcd-xhci-pci.c
+++ b/hw/usb/hcd-xhci-pci.c
@@ -85,7 +85,7 @@ static void xhci_pci_reset(DeviceState *dev)
 {
     XHCIPciState *s = XHCI_PCI(dev);
 
-    device_legacy_reset(DEVICE(&s->xhci));
+    device_cold_reset(DEVICE(&s->xhci));
 }
 
 static int xhci_pci_vmstate_post_load(void *opaque, int version_id)
diff --git a/hw/usb/hcd-xhci-sysbus.c b/hw/usb/hcd-xhci-sysbus.c
index a14e4381960..faf57b47975 100644
--- a/hw/usb/hcd-xhci-sysbus.c
+++ b/hw/usb/hcd-xhci-sysbus.c
@@ -29,7 +29,7 @@ void xhci_sysbus_reset(DeviceState *dev)
 {
     XHCISysbusState *s = XHCI_SYSBUS(dev);
 
-    device_legacy_reset(DEVICE(&s->xhci));
+    device_cold_reset(DEVICE(&s->xhci));
 }
 
 static void xhci_sysbus_realize(DeviceState *dev, Error **errp)
-- 
2.25.1



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

* [PATCH for-8.0 5/9] pci: Use device_cold_reset() and bus_cold_reset()
  2022-11-04 16:15 [PATCH for-8.0 0/9] reset: Remove some deprecated APIs Peter Maydell
                   ` (3 preceding siblings ...)
  2022-11-04 16:15 ` [PATCH for-8.0 4/9] hw/usb/hcd-xhci: Reset the XHCIState with device_cold_reset() Peter Maydell
@ 2022-11-04 16:15 ` Peter Maydell
  2022-11-04 17:39   ` Philippe Mathieu-Daudé
  2022-11-04 16:15 ` [PATCH for-8.0 6/9] hw/hyperv/vmbus: " Peter Maydell
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Peter Maydell @ 2022-11-04 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Maciej S. Szmigiero, Gerd Hoffmann, Paolo Bonzini,
	Daniel P. Berrangé,
	Stefano Stabellini, Anthony Perard, Paul Durrant,
	Mark Cave-Ayland, Matthew Rosato, Halil Pasic,
	Christian Borntraeger, qemu-s390x, qemu-ppc

In the PCI subsystem we currently use the legacy function
qdev_reset_all() and qbus_reset_all().  These perform a recursive
reset, starting from either a qbus or a qdev.  However they do not
permit any of the devices in the tree to use three-phase reset,
because device reset goes through the device_legacy_reset() function
that only calls the single DeviceClass::reset method.

Switch to using the device_cold_reset() and bus_cold_reset()
functions.  These also perform a recursive reset, where first the
children are reset and then finally the parent, but they use the new
(...in 2020...) Resettable mechanism, which supports both the old
style single-reset method and also the new 3-phase reset handling.

This should be a no-behaviour-change commit which just reduces the
use of a deprecated API.

Commit created with:
 sed -i -e 's/qdev_reset_all/device_cold_reset/g;s/qbus_reset_all/bus_cold_reset/g' hw/pci/*.c

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/pci/pci.c        | 6 +++---
 hw/pci/pci_bridge.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 2f450f6a728..9d819cbe3b3 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -378,14 +378,14 @@ static void pci_do_device_reset(PCIDevice *dev)
  */
 void pci_device_reset(PCIDevice *dev)
 {
-    qdev_reset_all(&dev->qdev);
+    device_cold_reset(&dev->qdev);
     pci_do_device_reset(dev);
 }
 
 /*
  * Trigger pci bus reset under a given bus.
- * Called via qbus_reset_all on RST# assert, after the devices
- * have been reset qdev_reset_all-ed already.
+ * Called via bus_cold_reset on RST# assert, after the devices
+ * have been reset device_cold_reset-ed already.
  */
 static void pcibus_reset(BusState *qbus)
 {
diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c
index da34c8ebcd1..b2b180edd61 100644
--- a/hw/pci/pci_bridge.c
+++ b/hw/pci/pci_bridge.c
@@ -275,7 +275,7 @@ void pci_bridge_write_config(PCIDevice *d,
     newctl = pci_get_word(d->config + PCI_BRIDGE_CONTROL);
     if (~oldctl & newctl & PCI_BRIDGE_CTL_BUS_RESET) {
         /* Trigger hot reset on 0->1 transition. */
-        qbus_reset_all(BUS(&s->sec_bus));
+        bus_cold_reset(BUS(&s->sec_bus));
     }
 }
 
-- 
2.25.1



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

* [PATCH for-8.0 6/9] hw/hyperv/vmbus: Use device_cold_reset() and bus_cold_reset()
  2022-11-04 16:15 [PATCH for-8.0 0/9] reset: Remove some deprecated APIs Peter Maydell
                   ` (4 preceding siblings ...)
  2022-11-04 16:15 ` [PATCH for-8.0 5/9] pci: Use device_cold_reset() and bus_cold_reset() Peter Maydell
@ 2022-11-04 16:15 ` Peter Maydell
  2022-11-10 20:33   ` Maciej S. Szmigiero
  2022-11-30 10:12   ` Philippe Mathieu-Daudé
  2022-11-04 16:15 ` [PATCH for-8.0 7/9] Replace use of qdev_reset_all() with device_cold_reset() Peter Maydell
                   ` (2 subsequent siblings)
  8 siblings, 2 replies; 19+ messages in thread
From: Peter Maydell @ 2022-11-04 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Maciej S. Szmigiero, Gerd Hoffmann, Paolo Bonzini,
	Daniel P. Berrangé,
	Stefano Stabellini, Anthony Perard, Paul Durrant,
	Mark Cave-Ayland, Matthew Rosato, Halil Pasic,
	Christian Borntraeger, qemu-s390x, qemu-ppc

In the vmbus code we currently use the legacy functions
qdev_reset_all() and qbus_reset_all().  These perform a recursive
reset, starting from either a qbus or a qdev.  However they do not
permit any of the devices in the tree to use three-phase reset,
because device reset goes through the device_legacy_reset() function
that only calls the single DeviceClass::reset method.

Switch to using the device_cold_reset() and bus_cold_reset()
functions.  These also perform a recursive reset, where first the
children are reset and then finally the parent, but they use the new
(...in 2020...) Resettable mechanism, which supports both the old
style single-reset method and also the new 3-phase reset handling.

This should be a no-behaviour-change commit which just reduces the
use of a deprecated API.

Commit created with:
  sed -i -e 's/qdev_reset_all/device_cold_reset/g;s/qbus_reset_all/bus_cold_reset/g' hw/hyperv/*.c

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/hyperv/vmbus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c
index 30bc04e1c4c..f345f310b0f 100644
--- a/hw/hyperv/vmbus.c
+++ b/hw/hyperv/vmbus.c
@@ -1578,7 +1578,7 @@ static bool vmbus_initialized(VMBus *vmbus)
 
 static void vmbus_reset_all(VMBus *vmbus)
 {
-    qbus_reset_all(BUS(vmbus));
+    bus_cold_reset(BUS(vmbus));
 }
 
 static void post_msg(VMBus *vmbus, void *msgdata, uint32_t msglen)
@@ -2035,7 +2035,7 @@ static void vdev_reset_on_close(VMBusDevice *vdev)
     }
 
     /* all channels closed -- reset device */
-    qdev_reset_all(DEVICE(vdev));
+    device_cold_reset(DEVICE(vdev));
 }
 
 static void handle_close_channel(VMBus *vmbus, vmbus_message_close_channel *msg,
-- 
2.25.1



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

* [PATCH for-8.0 7/9] Replace use of qdev_reset_all() with device_cold_reset()
  2022-11-04 16:15 [PATCH for-8.0 0/9] reset: Remove some deprecated APIs Peter Maydell
                   ` (5 preceding siblings ...)
  2022-11-04 16:15 ` [PATCH for-8.0 6/9] hw/hyperv/vmbus: " Peter Maydell
@ 2022-11-04 16:15 ` Peter Maydell
  2022-11-04 17:39   ` Paul Durrant
  2022-11-30 10:14   ` Philippe Mathieu-Daudé
  2022-11-04 16:15 ` [PATCH for-8.0 8/9] qdev: Remove qdev_reset_all() and qbus_reset_all() Peter Maydell
  2022-11-04 16:15 ` [PATCH for-8.0 9/9] hw: Remove device_legacy_reset() Peter Maydell
  8 siblings, 2 replies; 19+ messages in thread
From: Peter Maydell @ 2022-11-04 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Maciej S. Szmigiero, Gerd Hoffmann, Paolo Bonzini,
	Daniel P. Berrangé,
	Stefano Stabellini, Anthony Perard, Paul Durrant,
	Mark Cave-Ayland, Matthew Rosato, Halil Pasic,
	Christian Borntraeger, qemu-s390x, qemu-ppc

The legacy function qdev_reset_all() performs a recursive reset,
starting from a qdev.  However, it does not permit any of the devices
in the tree to use three-phase reset, because device reset goes
through the device_legacy_reset() function that only calls the single
DeviceClass::reset method.

Switch to using the device_cold_reset() function instead.  This also
performs a recursive reset, where first the children are reset and
then finally the parent, but it uses the new (...in 2020...)
Resettable mechanism, which supports both the old style single-reset
method and also the new 3-phase reset handling.

This commit changes the five remaining uses of this function.

Commit created with:
 sed -i -e 's/qdev_reset_all/device_cold_reset/g' hw/i386/xen/xen_platform.c hw/input/adb.c hw/remote/vfio-user-obj.c hw/s390x/s390-virtio-ccw.c hw/usb/dev-uas.c

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/i386/xen/xen_platform.c | 2 +-
 hw/input/adb.c             | 2 +-
 hw/remote/vfio-user-obj.c  | 2 +-
 hw/s390x/s390-virtio-ccw.c | 2 +-
 hw/usb/dev-uas.c           | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
index a64265cca07..7db0d94ec28 100644
--- a/hw/i386/xen/xen_platform.c
+++ b/hw/i386/xen/xen_platform.c
@@ -177,7 +177,7 @@ static void pci_xen_ide_unplug(DeviceState *dev, bool aux)
             blk_unref(blk);
         }
     }
-    qdev_reset_all(dev);
+    device_cold_reset(dev);
 }
 
 static void unplug_disks(PCIBus *b, PCIDevice *d, void *opaque)
diff --git a/hw/input/adb.c b/hw/input/adb.c
index 84331b9fce6..214ae6f42b3 100644
--- a/hw/input/adb.c
+++ b/hw/input/adb.c
@@ -43,7 +43,7 @@ static const char *adb_commands[] = {
 
 static void adb_device_reset(ADBDevice *d)
 {
-    qdev_reset_all(DEVICE(d));
+    device_cold_reset(DEVICE(d));
 }
 
 static int do_adb_request(ADBBusState *s, uint8_t *obuf, const uint8_t *buf,
diff --git a/hw/remote/vfio-user-obj.c b/hw/remote/vfio-user-obj.c
index c6cc53acf2d..6ff14e0b9c0 100644
--- a/hw/remote/vfio-user-obj.c
+++ b/hw/remote/vfio-user-obj.c
@@ -685,7 +685,7 @@ static int vfu_object_device_reset(vfu_ctx_t *vfu_ctx, vfu_reset_type_t type)
         return 0;
     }
 
-    qdev_reset_all(DEVICE(o->pci_dev));
+    device_cold_reset(DEVICE(o->pci_dev));
 
     return 0;
 }
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 806de32034c..13a9ca62800 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -110,7 +110,7 @@ static void subsystem_reset(void)
     for (i = 0; i < ARRAY_SIZE(reset_dev_types); i++) {
         dev = DEVICE(object_resolve_path_type("", reset_dev_types[i], NULL));
         if (dev) {
-            qdev_reset_all(dev);
+            device_cold_reset(dev);
         }
     }
 }
diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c
index 5192b062d6f..88f99c05d53 100644
--- a/hw/usb/dev-uas.c
+++ b/hw/usb/dev-uas.c
@@ -791,7 +791,7 @@ static void usb_uas_task(UASDevice *uas, uas_iu *iu)
 
     case UAS_TMF_LOGICAL_UNIT_RESET:
         trace_usb_uas_tmf_logical_unit_reset(uas->dev.addr, tag, lun);
-        qdev_reset_all(&dev->qdev);
+        device_cold_reset(&dev->qdev);
         usb_uas_queue_response(uas, tag, UAS_RC_TMF_COMPLETE);
         break;
 
-- 
2.25.1



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

* [PATCH for-8.0 8/9] qdev: Remove qdev_reset_all() and qbus_reset_all()
  2022-11-04 16:15 [PATCH for-8.0 0/9] reset: Remove some deprecated APIs Peter Maydell
                   ` (6 preceding siblings ...)
  2022-11-04 16:15 ` [PATCH for-8.0 7/9] Replace use of qdev_reset_all() with device_cold_reset() Peter Maydell
@ 2022-11-04 16:15 ` Peter Maydell
  2022-11-04 17:46   ` Philippe Mathieu-Daudé
  2022-11-04 16:15 ` [PATCH for-8.0 9/9] hw: Remove device_legacy_reset() Peter Maydell
  8 siblings, 1 reply; 19+ messages in thread
From: Peter Maydell @ 2022-11-04 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Maciej S. Szmigiero, Gerd Hoffmann, Paolo Bonzini,
	Daniel P. Berrangé,
	Stefano Stabellini, Anthony Perard, Paul Durrant,
	Mark Cave-Ayland, Matthew Rosato, Halil Pasic,
	Christian Borntraeger, qemu-s390x, qemu-ppc

Remove the qdev_reset_all() and qbus_reset_all() functions, now we
have moved all the callers over to the new device_cold_reset() and
bus_cold_reset() functions.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/hw/qdev-core.h | 26 --------------------
 hw/core/qdev.c         | 54 ------------------------------------------
 hw/core/trace-events   |  4 ----
 3 files changed, 84 deletions(-)

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 785dd5a56ef..c7eda169d78 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -743,32 +743,6 @@ int qdev_walk_children(DeviceState *dev,
                        qdev_walkerfn *post_devfn, qbus_walkerfn *post_busfn,
                        void *opaque);
 
-/**
- * @qdev_reset_all:
- * Reset @dev. See @qbus_reset_all() for more details.
- *
- * Note: This function is deprecated and will be removed when it becomes unused.
- * Please use device_cold_reset() now.
- */
-void qdev_reset_all(DeviceState *dev);
-void qdev_reset_all_fn(void *opaque);
-
-/**
- * @qbus_reset_all:
- * @bus: Bus to be reset.
- *
- * Reset @bus and perform a bus-level ("hard") reset of all devices connected
- * to it, including recursive processing of all buses below @bus itself.  A
- * hard reset means that qbus_reset_all will reset all state of the device.
- * For PCI devices, for example, this will include the base address registers
- * or configuration space.
- *
- * Note: This function is deprecated and will be removed when it becomes unused.
- * Please use bus_cold_reset() now.
- */
-void qbus_reset_all(BusState *bus);
-void qbus_reset_all_fn(void *opaque);
-
 /**
  * device_cold_reset:
  * Reset device @dev and perform a recursive processing using the resettable
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 0806d8fcaaa..3b0f04c5c6d 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -237,60 +237,6 @@ void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
     dev->alias_required_for_version = required_for_version;
 }
 
-static int qdev_prereset(DeviceState *dev, void *opaque)
-{
-    trace_qdev_reset_tree(dev, object_get_typename(OBJECT(dev)));
-    return 0;
-}
-
-static int qbus_prereset(BusState *bus, void *opaque)
-{
-    trace_qbus_reset_tree(bus, object_get_typename(OBJECT(bus)));
-    return 0;
-}
-
-static int qdev_reset_one(DeviceState *dev, void *opaque)
-{
-    device_legacy_reset(dev);
-
-    return 0;
-}
-
-static int qbus_reset_one(BusState *bus, void *opaque)
-{
-    BusClass *bc = BUS_GET_CLASS(bus);
-    trace_qbus_reset(bus, object_get_typename(OBJECT(bus)));
-    if (bc->reset) {
-        bc->reset(bus);
-    }
-    return 0;
-}
-
-void qdev_reset_all(DeviceState *dev)
-{
-    trace_qdev_reset_all(dev, object_get_typename(OBJECT(dev)));
-    qdev_walk_children(dev, qdev_prereset, qbus_prereset,
-                       qdev_reset_one, qbus_reset_one, NULL);
-}
-
-void qdev_reset_all_fn(void *opaque)
-{
-    qdev_reset_all(DEVICE(opaque));
-}
-
-void qbus_reset_all(BusState *bus)
-{
-    trace_qbus_reset_all(bus, object_get_typename(OBJECT(bus)));
-    qbus_walk_children(bus, qdev_prereset, qbus_prereset,
-                       qdev_reset_one, qbus_reset_one, NULL);
-}
-
-void qbus_reset_all_fn(void *opaque)
-{
-    BusState *bus = opaque;
-    qbus_reset_all(bus);
-}
-
 void device_cold_reset(DeviceState *dev)
 {
     resettable_reset(OBJECT(dev), RESET_TYPE_COLD);
diff --git a/hw/core/trace-events b/hw/core/trace-events
index 9b3ecce3b2f..d6ab5c74b90 100644
--- a/hw/core/trace-events
+++ b/hw/core/trace-events
@@ -3,11 +3,7 @@ loader_write_rom(const char *name, uint64_t gpa, uint64_t size, bool isrom) "%s:
 
 # qdev.c
 qdev_reset(void *obj, const char *objtype) "obj=%p(%s)"
-qdev_reset_all(void *obj, const char *objtype) "obj=%p(%s)"
-qdev_reset_tree(void *obj, const char *objtype) "obj=%p(%s)"
 qbus_reset(void *obj, const char *objtype) "obj=%p(%s)"
-qbus_reset_all(void *obj, const char *objtype) "obj=%p(%s)"
-qbus_reset_tree(void *obj, const char *objtype) "obj=%p(%s)"
 qdev_update_parent_bus(void *obj, const char *objtype, void *oldp, const char *oldptype, void *newp, const char *newptype) "obj=%p(%s) old_parent=%p(%s) new_parent=%p(%s)"
 
 # resettable.c
-- 
2.25.1



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

* [PATCH for-8.0 9/9] hw: Remove device_legacy_reset()
  2022-11-04 16:15 [PATCH for-8.0 0/9] reset: Remove some deprecated APIs Peter Maydell
                   ` (7 preceding siblings ...)
  2022-11-04 16:15 ` [PATCH for-8.0 8/9] qdev: Remove qdev_reset_all() and qbus_reset_all() Peter Maydell
@ 2022-11-04 16:15 ` Peter Maydell
  2022-11-04 17:43   ` Philippe Mathieu-Daudé
  8 siblings, 1 reply; 19+ messages in thread
From: Peter Maydell @ 2022-11-04 16:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Maciej S. Szmigiero, Gerd Hoffmann, Paolo Bonzini,
	Daniel P. Berrangé,
	Stefano Stabellini, Anthony Perard, Paul Durrant,
	Mark Cave-Ayland, Matthew Rosato, Halil Pasic,
	Christian Borntraeger, qemu-s390x, qemu-ppc

The device_legacy_reset() function is now not used anywhere, so we
can remove the implementation.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/hw/qdev-core.h |  9 ---------
 hw/core/qdev.c         | 10 ----------
 2 files changed, 19 deletions(-)

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index c7eda169d78..35fddb19a64 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -776,15 +776,6 @@ BusState *sysbus_get_default(void);
 char *qdev_get_fw_dev_path(DeviceState *dev);
 char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *dev);
 
-/**
- * device_legacy_reset:
- *
- * Reset a single device (by calling the reset method).
- * Note: This function is deprecated and will be removed when it becomes unused.
- * Please use device_cold_reset() now.
- */
-void device_legacy_reset(DeviceState *dev);
-
 void device_class_set_props(DeviceClass *dc, Property *props);
 
 /**
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 3b0f04c5c6d..2743191efe7 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -857,16 +857,6 @@ void device_class_set_parent_unrealize(DeviceClass *dc,
     dc->unrealize = dev_unrealize;
 }
 
-void device_legacy_reset(DeviceState *dev)
-{
-    DeviceClass *klass = DEVICE_GET_CLASS(dev);
-
-    trace_qdev_reset(dev, object_get_typename(OBJECT(dev)));
-    if (klass->reset) {
-        klass->reset(dev);
-    }
-}
-
 Object *qdev_get_machine(void)
 {
     static Object *dev;
-- 
2.25.1



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

* Re: [PATCH for-8.0 5/9] pci: Use device_cold_reset() and bus_cold_reset()
  2022-11-04 16:15 ` [PATCH for-8.0 5/9] pci: Use device_cold_reset() and bus_cold_reset() Peter Maydell
@ 2022-11-04 17:39   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-11-04 17:39 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel
  Cc: Maciej S. Szmigiero, Gerd Hoffmann, Paolo Bonzini,
	Daniel P. Berrangé,
	Stefano Stabellini, Anthony Perard, Paul Durrant,
	Mark Cave-Ayland, Matthew Rosato, Halil Pasic,
	Christian Borntraeger, qemu-s390x, qemu-ppc

On 4/11/22 17:15, Peter Maydell wrote:
> In the PCI subsystem we currently use the legacy function
> qdev_reset_all() and qbus_reset_all().  These perform a recursive
> reset, starting from either a qbus or a qdev.  However they do not
> permit any of the devices in the tree to use three-phase reset,
> because device reset goes through the device_legacy_reset() function
> that only calls the single DeviceClass::reset method.
> 
> Switch to using the device_cold_reset() and bus_cold_reset()
> functions.  These also perform a recursive reset, where first the
> children are reset and then finally the parent, but they use the new
> (...in 2020...) Resettable mechanism, which supports both the old
> style single-reset method and also the new 3-phase reset handling.
> 
> This should be a no-behaviour-change commit which just reduces the
> use of a deprecated API.
> 
> Commit created with:
>   sed -i -e 's/qdev_reset_all/device_cold_reset/g;s/qbus_reset_all/bus_cold_reset/g' hw/pci/*.c
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/pci/pci.c        | 6 +++---
>   hw/pci/pci_bridge.c | 2 +-
>   2 files changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



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

* Re: [PATCH for-8.0 7/9] Replace use of qdev_reset_all() with device_cold_reset()
  2022-11-04 16:15 ` [PATCH for-8.0 7/9] Replace use of qdev_reset_all() with device_cold_reset() Peter Maydell
@ 2022-11-04 17:39   ` Paul Durrant
  2022-11-30 10:14   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 19+ messages in thread
From: Paul Durrant @ 2022-11-04 17:39 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel
  Cc: Maciej S. Szmigiero, Gerd Hoffmann, Paolo Bonzini,
	Daniel P. Berrangé,
	Stefano Stabellini, Anthony Perard, Mark Cave-Ayland,
	Matthew Rosato, Halil Pasic, Christian Borntraeger, qemu-s390x,
	qemu-ppc

On 04/11/2022 16:15, Peter Maydell wrote:
> The legacy function qdev_reset_all() performs a recursive reset,
> starting from a qdev.  However, it does not permit any of the devices
> in the tree to use three-phase reset, because device reset goes
> through the device_legacy_reset() function that only calls the single
> DeviceClass::reset method.
> 
> Switch to using the device_cold_reset() function instead.  This also
> performs a recursive reset, where first the children are reset and
> then finally the parent, but it uses the new (...in 2020...)
> Resettable mechanism, which supports both the old style single-reset
> method and also the new 3-phase reset handling.
> 
> This commit changes the five remaining uses of this function.
> 
> Commit created with:
>   sed -i -e 's/qdev_reset_all/device_cold_reset/g' hw/i386/xen/xen_platform.c hw/input/adb.c hw/remote/vfio-user-obj.c hw/s390x/s390-virtio-ccw.c hw/usb/dev-uas.c
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/i386/xen/xen_platform.c | 2 +-

Reviewed-by: Paul Durrant <paul@xen.org>

>   hw/input/adb.c             | 2 +-
>   hw/remote/vfio-user-obj.c  | 2 +-
>   hw/s390x/s390-virtio-ccw.c | 2 +-
>   hw/usb/dev-uas.c           | 2 +-
>   5 files changed, 5 insertions(+), 5 deletions(-)



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

* Re: [PATCH for-8.0 9/9] hw: Remove device_legacy_reset()
  2022-11-04 16:15 ` [PATCH for-8.0 9/9] hw: Remove device_legacy_reset() Peter Maydell
@ 2022-11-04 17:43   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-11-04 17:43 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel
  Cc: Maciej S. Szmigiero, Gerd Hoffmann, Paolo Bonzini,
	Daniel P. Berrangé,
	Stefano Stabellini, Anthony Perard, Paul Durrant,
	Mark Cave-Ayland, Matthew Rosato, Halil Pasic,
	Christian Borntraeger, qemu-s390x, qemu-ppc

On 4/11/22 17:15, Peter Maydell wrote:
> The device_legacy_reset() function is now not used anywhere, so we
> can remove the implementation.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   include/hw/qdev-core.h |  9 ---------
>   hw/core/qdev.c         | 10 ----------
>   2 files changed, 19 deletions(-)

> -void device_legacy_reset(DeviceState *dev)
> -{
> -    DeviceClass *klass = DEVICE_GET_CLASS(dev);
> -
> -    trace_qdev_reset(dev, object_get_typename(OBJECT(dev)));

We can remove the "qdev_reset" entry in hw/core/trace-events.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

> -    if (klass->reset) {
> -        klass->reset(dev);
> -    }
> -}


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

* Re: [PATCH for-8.0 8/9] qdev: Remove qdev_reset_all() and qbus_reset_all()
  2022-11-04 16:15 ` [PATCH for-8.0 8/9] qdev: Remove qdev_reset_all() and qbus_reset_all() Peter Maydell
@ 2022-11-04 17:46   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-11-04 17:46 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel
  Cc: Maciej S. Szmigiero, Gerd Hoffmann, Paolo Bonzini,
	Daniel P. Berrangé,
	Stefano Stabellini, Anthony Perard, Paul Durrant,
	Mark Cave-Ayland, Matthew Rosato, Halil Pasic,
	Christian Borntraeger, qemu-s390x, qemu-ppc

On 4/11/22 17:15, Peter Maydell wrote:
> Remove the qdev_reset_all() and qbus_reset_all() functions, now we
> have moved all the callers over to the new device_cold_reset() and
> bus_cold_reset() functions.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   include/hw/qdev-core.h | 26 --------------------
>   hw/core/qdev.c         | 54 ------------------------------------------
>   hw/core/trace-events   |  4 ----
>   3 files changed, 84 deletions(-)

> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 0806d8fcaaa..3b0f04c5c6d 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c

> -static int qbus_reset_one(BusState *bus, void *opaque)
> -{
> -    BusClass *bc = BUS_GET_CLASS(bus);
> -    trace_qbus_reset(bus, object_get_typename(OBJECT(bus)));
> -    if (bc->reset) {
> -        bc->reset(bus);
> -    }
> -    return 0;
> -}

> diff --git a/hw/core/trace-events b/hw/core/trace-events
> index 9b3ecce3b2f..d6ab5c74b90 100644
> --- a/hw/core/trace-events
> +++ b/hw/core/trace-events
> @@ -3,11 +3,7 @@ loader_write_rom(const char *name, uint64_t gpa, uint64_t size, bool isrom) "%s:
>   
>   # qdev.c
>   qdev_reset(void *obj, const char *objtype) "obj=%p(%s)"
> -qdev_reset_all(void *obj, const char *objtype) "obj=%p(%s)"
> -qdev_reset_tree(void *obj, const char *objtype) "obj=%p(%s)"
>   qbus_reset(void *obj, const char *objtype) "obj=%p(%s)"

We can also remove the "qbus_reset" event.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

> -qbus_reset_all(void *obj, const char *objtype) "obj=%p(%s)"
> -qbus_reset_tree(void *obj, const char *objtype) "obj=%p(%s)"
>   qdev_update_parent_bus(void *obj, const char *objtype, void *oldp, const char *oldptype, void *newp, const char *newptype) "obj=%p(%s) old_parent=%p(%s) new_parent=%p(%s)"
>   
>   # resettable.c



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

* Re: [PATCH for-8.0 6/9] hw/hyperv/vmbus: Use device_cold_reset() and bus_cold_reset()
  2022-11-04 16:15 ` [PATCH for-8.0 6/9] hw/hyperv/vmbus: " Peter Maydell
@ 2022-11-10 20:33   ` Maciej S. Szmigiero
  2022-11-30 10:12   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 19+ messages in thread
From: Maciej S. Szmigiero @ 2022-11-10 20:33 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Gerd Hoffmann, Paolo Bonzini, Daniel P. Berrangé,
	Stefano Stabellini, Anthony Perard, Paul Durrant,
	Mark Cave-Ayland, Matthew Rosato, Halil Pasic,
	Christian Borntraeger, qemu-s390x, qemu-ppc, qemu-devel

On 4.11.2022 17:15, Peter Maydell wrote:
> In the vmbus code we currently use the legacy functions
> qdev_reset_all() and qbus_reset_all().  These perform a recursive
> reset, starting from either a qbus or a qdev.  However they do not
> permit any of the devices in the tree to use three-phase reset,
> because device reset goes through the device_legacy_reset() function
> that only calls the single DeviceClass::reset method.
> 
> Switch to using the device_cold_reset() and bus_cold_reset()
> functions.  These also perform a recursive reset, where first the
> children are reset and then finally the parent, but they use the new
> (...in 2020...) Resettable mechanism, which supports both the old
> style single-reset method and also the new 3-phase reset handling.
> 
> This should be a no-behaviour-change commit which just reduces the
> use of a deprecated API.
> 
> Commit created with:
>    sed -i -e 's/qdev_reset_all/device_cold_reset/g;s/qbus_reset_all/bus_cold_reset/g' hw/hyperv/*.c
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/hyperv/vmbus.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c
> index 30bc04e1c4c..f345f310b0f 100644
> --- a/hw/hyperv/vmbus.c
> +++ b/hw/hyperv/vmbus.c
> @@ -1578,7 +1578,7 @@ static bool vmbus_initialized(VMBus *vmbus)
>   
>   static void vmbus_reset_all(VMBus *vmbus)
>   {
> -    qbus_reset_all(BUS(vmbus));
> +    bus_cold_reset(BUS(vmbus));
>   }
>   
>   static void post_msg(VMBus *vmbus, void *msgdata, uint32_t msglen)
> @@ -2035,7 +2035,7 @@ static void vdev_reset_on_close(VMBusDevice *vdev)
>       }
>   
>       /* all channels closed -- reset device */
> -    qdev_reset_all(DEVICE(vdev));
> +    device_cold_reset(DEVICE(vdev));
>   }
>   
>   static void handle_close_channel(VMBus *vmbus, vmbus_message_close_channel *msg,

Resetting a guest with VMBus still works fine with this patch, so:
Reviewed-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>

Thanks,
Maciej



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

* Re: [PATCH for-8.0 1/9] hw/s390x/s390-pci-inst.c: Use device_cold_reset() to reset PCI devices
  2022-11-04 16:15 ` [PATCH for-8.0 1/9] hw/s390x/s390-pci-inst.c: Use device_cold_reset() to reset PCI devices Peter Maydell
@ 2022-11-30 10:07   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-11-30 10:07 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel
  Cc: Maciej S. Szmigiero, Gerd Hoffmann, Paolo Bonzini,
	Daniel P. Berrangé,
	Stefano Stabellini, Anthony Perard, Paul Durrant,
	Mark Cave-Ayland, Matthew Rosato, Halil Pasic,
	Christian Borntraeger, qemu-s390x, qemu-ppc

On 4/11/22 17:15, Peter Maydell wrote:
> The semantic difference between the deprecated device_legacy_reset()
> function and the newer device_cold_reset() function is that the new
> function resets both the device itself and any qbuses it owns,
> whereas the legacy function resets just the device itself and nothing
> else.
> 
> In s390-pci-inst.c we use device_legacy_reset() to reset an
> S390PCIBusDevice.  This device doesn't have any child qbuses, so the
> functions do the same thing and we can stop using the deprecated one.
> 
> Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/s390x/s390-pci-inst.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>




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

* Re: [PATCH for-8.0 4/9] hw/usb/hcd-xhci: Reset the XHCIState with device_cold_reset()
  2022-11-04 16:15 ` [PATCH for-8.0 4/9] hw/usb/hcd-xhci: Reset the XHCIState with device_cold_reset() Peter Maydell
@ 2022-11-30 10:11   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-11-30 10:11 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel
  Cc: Maciej S. Szmigiero, Gerd Hoffmann, Paolo Bonzini,
	Daniel P. Berrangé,
	Stefano Stabellini, Anthony Perard, Paul Durrant,
	Mark Cave-Ayland, Matthew Rosato, Halil Pasic,
	Christian Borntraeger, qemu-s390x, qemu-ppc

On 4/11/22 17:15, Peter Maydell wrote:
> Currently the hcd-xhci-pci and hcd-xhci-sysbus devices, which are

s/which// ?

> mostly wrappers around the TYPE_XHCI device, which is a direct
> subclass of TYPE_DEVICE.  Since TYPE_DEVICE devices are not on any
> qbus and do not get automatically reset, the wrapper devices both
> reset the TYPE_XHCI device in their own reset functions.  However,
> they do this using device_legacy_reset(), which will reset the device
> itself but not any bus it has.
> 
> Switch to device_cold_reset(), which avoids using a deprecated
> function and also propagates reset along any child buses.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> It's possible this might result in USB devices on the bus getting
> reset more than once (once via the descent-along-qbus and once when
> xhci_reset() etc manually reset each port), but in my testing with
> gdb I couldn't get that to happen.  It should be harmless anyway.
> ---
>   hw/usb/hcd-xhci-pci.c    | 2 +-
>   hw/usb/hcd-xhci-sysbus.c | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>




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

* Re: [PATCH for-8.0 6/9] hw/hyperv/vmbus: Use device_cold_reset() and bus_cold_reset()
  2022-11-04 16:15 ` [PATCH for-8.0 6/9] hw/hyperv/vmbus: " Peter Maydell
  2022-11-10 20:33   ` Maciej S. Szmigiero
@ 2022-11-30 10:12   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-11-30 10:12 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel
  Cc: Maciej S. Szmigiero, Gerd Hoffmann, Paolo Bonzini,
	Daniel P. Berrangé,
	Stefano Stabellini, Anthony Perard, Paul Durrant,
	Mark Cave-Ayland, Matthew Rosato, Halil Pasic,
	Christian Borntraeger, qemu-s390x, qemu-ppc

On 4/11/22 17:15, Peter Maydell wrote:
> In the vmbus code we currently use the legacy functions
> qdev_reset_all() and qbus_reset_all().  These perform a recursive
> reset, starting from either a qbus or a qdev.  However they do not
> permit any of the devices in the tree to use three-phase reset,
> because device reset goes through the device_legacy_reset() function
> that only calls the single DeviceClass::reset method.
> 
> Switch to using the device_cold_reset() and bus_cold_reset()
> functions.  These also perform a recursive reset, where first the
> children are reset and then finally the parent, but they use the new
> (...in 2020...) Resettable mechanism, which supports both the old
> style single-reset method and also the new 3-phase reset handling.
> 
> This should be a no-behaviour-change commit which just reduces the
> use of a deprecated API.
> 
> Commit created with:
>    sed -i -e 's/qdev_reset_all/device_cold_reset/g;s/qbus_reset_all/bus_cold_reset/g' hw/hyperv/*.c
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/hyperv/vmbus.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



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

* Re: [PATCH for-8.0 7/9] Replace use of qdev_reset_all() with device_cold_reset()
  2022-11-04 16:15 ` [PATCH for-8.0 7/9] Replace use of qdev_reset_all() with device_cold_reset() Peter Maydell
  2022-11-04 17:39   ` Paul Durrant
@ 2022-11-30 10:14   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-11-30 10:14 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel
  Cc: Maciej S. Szmigiero, Gerd Hoffmann, Paolo Bonzini,
	Daniel P. Berrangé,
	Stefano Stabellini, Anthony Perard, Paul Durrant,
	Mark Cave-Ayland, Matthew Rosato, Halil Pasic,
	Christian Borntraeger, qemu-s390x, qemu-ppc

On 4/11/22 17:15, Peter Maydell wrote:
> The legacy function qdev_reset_all() performs a recursive reset,
> starting from a qdev.  However, it does not permit any of the devices
> in the tree to use three-phase reset, because device reset goes
> through the device_legacy_reset() function that only calls the single
> DeviceClass::reset method.
> 
> Switch to using the device_cold_reset() function instead.  This also
> performs a recursive reset, where first the children are reset and
> then finally the parent, but it uses the new (...in 2020...)
> Resettable mechanism, which supports both the old style single-reset
> method and also the new 3-phase reset handling.
> 
> This commit changes the five remaining uses of this function.
> 
> Commit created with:
>   sed -i -e 's/qdev_reset_all/device_cold_reset/g' hw/i386/xen/xen_platform.c hw/input/adb.c hw/remote/vfio-user-obj.c hw/s390x/s390-virtio-ccw.c hw/usb/dev-uas.c
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/i386/xen/xen_platform.c | 2 +-
>   hw/input/adb.c             | 2 +-
>   hw/remote/vfio-user-obj.c  | 2 +-
>   hw/s390x/s390-virtio-ccw.c | 2 +-
>   hw/usb/dev-uas.c           | 2 +-
>   5 files changed, 5 insertions(+), 5 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



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

end of thread, other threads:[~2022-11-30 10:15 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-04 16:15 [PATCH for-8.0 0/9] reset: Remove some deprecated APIs Peter Maydell
2022-11-04 16:15 ` [PATCH for-8.0 1/9] hw/s390x/s390-pci-inst.c: Use device_cold_reset() to reset PCI devices Peter Maydell
2022-11-30 10:07   ` Philippe Mathieu-Daudé
2022-11-04 16:15 ` [PATCH for-8.0 2/9] hw/audio/intel-hda: don't reset codecs twice Peter Maydell
2022-11-04 16:15 ` [PATCH for-8.0 3/9] hw/audio/intel-hda: Drop unnecessary prototype Peter Maydell
2022-11-04 16:15 ` [PATCH for-8.0 4/9] hw/usb/hcd-xhci: Reset the XHCIState with device_cold_reset() Peter Maydell
2022-11-30 10:11   ` Philippe Mathieu-Daudé
2022-11-04 16:15 ` [PATCH for-8.0 5/9] pci: Use device_cold_reset() and bus_cold_reset() Peter Maydell
2022-11-04 17:39   ` Philippe Mathieu-Daudé
2022-11-04 16:15 ` [PATCH for-8.0 6/9] hw/hyperv/vmbus: " Peter Maydell
2022-11-10 20:33   ` Maciej S. Szmigiero
2022-11-30 10:12   ` Philippe Mathieu-Daudé
2022-11-04 16:15 ` [PATCH for-8.0 7/9] Replace use of qdev_reset_all() with device_cold_reset() Peter Maydell
2022-11-04 17:39   ` Paul Durrant
2022-11-30 10:14   ` Philippe Mathieu-Daudé
2022-11-04 16:15 ` [PATCH for-8.0 8/9] qdev: Remove qdev_reset_all() and qbus_reset_all() Peter Maydell
2022-11-04 17:46   ` Philippe Mathieu-Daudé
2022-11-04 16:15 ` [PATCH for-8.0 9/9] hw: Remove device_legacy_reset() Peter Maydell
2022-11-04 17:43   ` Philippe Mathieu-Daudé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.