Skip to content

Commit

Permalink
hw/core: deprecate old reset functions and introduce new ones
Browse files Browse the repository at this point in the history
Deprecate device_legacy_reset(), qdev_reset_all() and
qbus_reset_all() to be replaced by new functions
device_cold_reset() and bus_cold_reset() which uses resettable API.

Also introduce resettable_cold_reset_fn() which may be used as a
replacement for qdev_reset_all_fn and qbus_reset_all_fn().

Following patches will be needed to look at legacy reset call sites
and switch to resettable api. The legacy functions will be removed
when unused.

Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20200123132823.1117486-9-damien.hedde@greensocs.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
dhedde authored and pm215 committed Jan 30, 2020
1 parent e755e12 commit abb89db
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hw/core/bus.c
Expand Up @@ -68,6 +68,11 @@ int qbus_walk_children(BusState *bus,
return 0;
}

void bus_cold_reset(BusState *bus)
{
resettable_reset(OBJECT(bus), RESET_TYPE_COLD);
}

bool bus_is_in_reset(BusState *bus)
{
return resettable_is_in_reset(OBJECT(bus));
Expand Down
5 changes: 5 additions & 0 deletions hw/core/qdev.c
Expand Up @@ -361,6 +361,11 @@ void qbus_reset_all_fn(void *opaque)
qbus_reset_all(bus);
}

void device_cold_reset(DeviceState *dev)
{
resettable_reset(OBJECT(dev), RESET_TYPE_COLD);
}

bool device_is_in_reset(DeviceState *dev)
{
return resettable_is_in_reset(OBJECT(dev));
Expand Down
5 changes: 5 additions & 0 deletions hw/core/resettable.c
Expand Up @@ -264,6 +264,11 @@ void resettable_change_parent(Object *obj, Object *newp, Object *oldp)
}
}

void resettable_cold_reset_fn(void *opaque)
{
resettable_reset((Object *) opaque, RESET_TYPE_COLD);
}

void resettable_class_set_parent_phases(ResettableClass *rc,
ResettableEnterPhase enter,
ResettableHoldPhase hold,
Expand Down
27 changes: 27 additions & 0 deletions include/hw/qdev-core.h
Expand Up @@ -411,6 +411,13 @@ 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);

Expand All @@ -423,10 +430,28 @@ void qdev_reset_all_fn(void *opaque);
* 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
* interface. It triggers a RESET_TYPE_COLD.
*/
void device_cold_reset(DeviceState *dev);

/**
* bus_cold_reset:
*
* Reset bus @bus and perform a recursive processing using the resettable
* interface. It triggers a RESET_TYPE_COLD.
*/
void bus_cold_reset(BusState *bus);

/**
* device_is_in_reset:
* Return true if the device @dev is currently being reset.
Expand Down Expand Up @@ -457,6 +482,8 @@ void qdev_machine_init(void);
* 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);

Expand Down
9 changes: 9 additions & 0 deletions include/hw/resettable.h
Expand Up @@ -221,6 +221,15 @@ bool resettable_is_in_reset(Object *obj);
*/
void resettable_change_parent(Object *obj, Object *newp, Object *oldp);

/**
* resettable_cold_reset_fn:
* Helper to call resettable_reset((Object *) opaque, RESET_TYPE_COLD).
*
* This function is typically useful to register a reset handler with
* qemu_register_reset.
*/
void resettable_cold_reset_fn(void *opaque);

/**
* resettable_class_set_parent_phases:
*
Expand Down

0 comments on commit abb89db

Please sign in to comment.