[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 01/15] qdev: do not reset a device until the par
From: |
Andreas Färber |
Subject: |
Re: [Qemu-devel] [PATCH 01/15] qdev: do not reset a device until the parent has been initialized |
Date: |
Mon, 17 Dec 2012 22:57:52 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 |
Am 17.12.2012 17:24, schrieb Paolo Bonzini:
> When a device creates a bus and more devices as part of its init callback, the
> child device could be reset while the parent is still only partly initialized.
> In this case, the right thing to do is to delay resetting the child. Do not
> do it at all in qdev_init, instead use qdev_reset_all to reset already-created
> devices when the state goes from CREATED to INITIALIZED.
>
> This happens when hotplugging a usb-storage device. Without this patch,
> initialization of a hotplugged usb-storage device would run in pre-order.
> Initialization of a coldplugged usb-storage device would run according to
> qdev_reset_all semantics (pre-order right now, post-order later in the
> series). This patch makes things consistent.
>
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
> hw/qdev.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/hw/qdev.c b/hw/qdev.c
> index 599382c..2fdf4ac 100644
> --- a/hw/qdev.c
> +++ b/hw/qdev.c
> @@ -176,8 +176,9 @@ int qdev_init(DeviceState *dev)
> dev->alias_required_for_version);
> }
> dev->state = DEV_STATE_INITIALIZED;
> - if (dev->hotplugged) {
> - device_reset(dev);
> + if (dev->hotplugged &&
> + dev->parent_bus->parent->state == DEV_STATE_INITIALIZED) {
This assumes that parent_bus != NULL, when we are trying to let our
fallback bus SysBus die out. The CPU in the current proposal is not a
SysBus device, to avoid compiling SysBus unnecessarily into *-user.
Your direct access into the parent's state also conflicts with my QOM
realize series IIUC.
So please at least add appropriate checks to do the below reset only
when there is a bus and leave the old behavior otherwise.
Andreas
> + qdev_reset_all(dev);
> }
> return 0;
> }
>
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
- [Qemu-devel] [PATCH 00/15] qdev: make reset semantics more clear and consistent, reset qbuses under virtio devices, Paolo Bonzini, 2012/12/17
- [Qemu-devel] [PATCH 03/15] pci: clean up resetting of IRQs, Paolo Bonzini, 2012/12/17
- [Qemu-devel] [PATCH 05/15] virtio-s390: add a reset function to virtio-s390 devices, Paolo Bonzini, 2012/12/17
- [Qemu-devel] [PATCH 06/15] qdev: add qbus_reset_all, Paolo Bonzini, 2012/12/17
- [Qemu-devel] [PATCH 04/15] virtio-pci: reset device before PCI layer, Paolo Bonzini, 2012/12/17
- [Qemu-devel] [PATCH 08/15] lsi: use qbus_reset_all to reset SCSI bus, Paolo Bonzini, 2012/12/17
- [Qemu-devel] [PATCH 07/15] pci: do not export pci_bus_reset, Paolo Bonzini, 2012/12/17
- [Qemu-devel] [PATCH 09/15] qdev: allow both pre- and post-order vists in qdev walking functions, Paolo Bonzini, 2012/12/17
- [Qemu-devel] [PATCH 10/15] qdev: switch reset to post-order, Paolo Bonzini, 2012/12/17
- [Qemu-devel] [PATCH 11/15] qdev: remove device_reset, Paolo Bonzini, 2012/12/17
- [Qemu-devel] [PATCH 15/15] virtio-serial: do not perform bus reset by hand, Paolo Bonzini, 2012/12/17