diff options
author | Isaku Yamahata <yamahata@valinux.co.jp> | 2010-12-20 14:33:35 +0900 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2010-12-20 15:16:53 +0200 |
commit | 80376c3fc2c38fdd45354e4b0eb45031f35587ed (patch) | |
tree | 56446a75f3defabc49571558fac139a1b9086861 /hw/qdev.c | |
parent | 68694897e55ebd229898d4b6546877ccea500954 (diff) | |
download | qemu-80376c3fc2c38fdd45354e4b0eb45031f35587ed.tar.gz |
qbus: register reset handler for qbus whose parent is NULL
Stefan Weil reported the regression caused by
ec990eb622ad46df5ddcb1e94c418c271894d416 as follows
> The second regression also occurs with MIPS malta.
> Networking no longer works with the default pcnet nic.
>
> This is caused because the reset function for pcnet is no
> longer called during system boot. The result in an invalid
> mac address (all zero) and a non-working nic.
>
> For this second regression I still have no simple solution.
> Of course mips_malta.c should be converted to qdev which
> would fix both problems (but only for malta system emulation).
The issue is, it is assumed that all qbuses, qdeves are under
main_system_bus. But there are qbuses whose parent is NULL. So it
is necessary to trigger reset for those qbuses.
(On the other hand, if NULL is passed to qdev_create(), its parent bus
is main_system_bus.)
Ideally those buses should be moved under bus controller
device which is qdev. But it's not done yet.
So register qbus reset handler for qbus whose parent is NULL.
Reported-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: "Michael S. Tsirkin" <mst@redhat.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/qdev.c')
-rw-r--r-- | hw/qdev.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -333,6 +333,12 @@ void qbus_reset_all(BusState *bus) qbus_walk_children(bus, qdev_reset_one, qbus_reset_one, NULL); } +void qbus_reset_all_fn(void *opaque) +{ + BusState *bus = opaque; + qbus_reset_all(bus); +} + /* can be used as ->unplug() callback for the simple cases */ int qdev_simple_unplug_cb(DeviceState *dev) { @@ -754,8 +760,11 @@ void qbus_create_inplace(BusState *bus, BusInfo *info, if (parent) { QLIST_INSERT_HEAD(&parent->child_bus, bus, sibling); parent->num_child_bus++; + } else if (bus != main_system_bus) { + /* TODO: once all bus devices are qdevified, + only reset handler for main_system_bus should be registered here. */ + qemu_register_reset(qbus_reset_all_fn, bus); } - } BusState *qbus_create(BusInfo *info, DeviceState *parent, const char *name) @@ -778,6 +787,9 @@ void qbus_free(BusState *bus) if (bus->parent) { QLIST_REMOVE(bus, sibling); bus->parent->num_child_bus--; + } else { + assert(bus != main_system_bus); /* main_system_bus is never freed */ + qemu_unregister_reset(qbus_reset_all_fn, bus); } qemu_free((void*)bus->name); if (bus->qdev_allocated) { |