Skip to content

Commit

Permalink
hw, target: Add ResetType argument to hold and exit phase methods
Browse files Browse the repository at this point in the history
We pass a ResetType argument to the Resettable class enter
phase method, but we don't pass it to hold and exit, even though
the callsites have it readily available. This means that if
a device cared about the ResetType it would need to record it
in the enter phase method to use later on. Pass the type to
all three of the phase methods to avoid having to do that.

Commit created with

  for dir in hw target include; do \
      spatch --macro-file scripts/cocci-macro-file.h \
             --sp-file scripts/coccinelle/reset-type.cocci \
             --keep-comments --smpl-spacing --in-place \
             --include-headers --dir $dir; done

and no manual edits.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Luc Michel <luc.michel@amd.com>
Message-id: 20240412160809.1260625-5-peter.maydell@linaro.org
  • Loading branch information
pm215 committed Apr 25, 2024
1 parent aadea88 commit ad80e36
Show file tree
Hide file tree
Showing 94 changed files with 150 additions and 150 deletions.
2 changes: 1 addition & 1 deletion hw/adc/npcm7xx_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ static void npcm7xx_adc_enter_reset(Object *obj, ResetType type)
npcm7xx_adc_reset(s);
}

static void npcm7xx_adc_hold_reset(Object *obj)
static void npcm7xx_adc_hold_reset(Object *obj, ResetType type)
{
NPCM7xxADCState *s = NPCM7XX_ADC(obj);

Expand Down
2 changes: 1 addition & 1 deletion hw/arm/pxa2xx_pic.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ static int pxa2xx_pic_post_load(void *opaque, int version_id)
return 0;
}

static void pxa2xx_pic_reset_hold(Object *obj)
static void pxa2xx_pic_reset_hold(Object *obj, ResetType type)
{
PXA2xxPICState *s = PXA2XX_PIC(obj);

Expand Down
2 changes: 1 addition & 1 deletion hw/arm/smmu-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ static void smmu_base_realize(DeviceState *dev, Error **errp)
}
}

static void smmu_base_reset_hold(Object *obj)
static void smmu_base_reset_hold(Object *obj, ResetType type)
{
SMMUState *s = ARM_SMMU(obj);

Expand Down
4 changes: 2 additions & 2 deletions hw/arm/smmuv3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1727,13 +1727,13 @@ static void smmu_init_irq(SMMUv3State *s, SysBusDevice *dev)
}
}

static void smmu_reset_hold(Object *obj)
static void smmu_reset_hold(Object *obj, ResetType type)
{
SMMUv3State *s = ARM_SMMUV3(obj);
SMMUv3Class *c = ARM_SMMUV3_GET_CLASS(s);

if (c->parent_phases.hold) {
c->parent_phases.hold(obj);
c->parent_phases.hold(obj, type);
}

smmuv3_init_regs(s);
Expand Down
10 changes: 5 additions & 5 deletions hw/arm/stellaris.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,15 @@ static void stellaris_sys_reset_enter(Object *obj, ResetType type)
s->dcgc[0] = 1;
}

static void stellaris_sys_reset_hold(Object *obj)
static void stellaris_sys_reset_hold(Object *obj, ResetType type)
{
ssys_state *s = STELLARIS_SYS(obj);

/* OK to propagate clocks from the hold phase */
ssys_calculate_system_clock(s, true);
}

static void stellaris_sys_reset_exit(Object *obj)
static void stellaris_sys_reset_exit(Object *obj, ResetType type)
{
}

Expand Down Expand Up @@ -618,7 +618,7 @@ static void stellaris_i2c_reset_enter(Object *obj, ResetType type)
i2c_end_transfer(s->bus);
}

static void stellaris_i2c_reset_hold(Object *obj)
static void stellaris_i2c_reset_hold(Object *obj, ResetType type)
{
stellaris_i2c_state *s = STELLARIS_I2C(obj);

Expand All @@ -631,7 +631,7 @@ static void stellaris_i2c_reset_hold(Object *obj)
s->mcr = 0;
}

static void stellaris_i2c_reset_exit(Object *obj)
static void stellaris_i2c_reset_exit(Object *obj, ResetType type)
{
stellaris_i2c_state *s = STELLARIS_I2C(obj);

Expand Down Expand Up @@ -787,7 +787,7 @@ static void stellaris_adc_trigger(void *opaque, int irq, int level)
}
}

static void stellaris_adc_reset_hold(Object *obj)
static void stellaris_adc_reset_hold(Object *obj, ResetType type)
{
StellarisADCState *s = STELLARIS_ADC(obj);
int n;
Expand Down
2 changes: 1 addition & 1 deletion hw/audio/asc.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ static void asc_fifo_init(ASCFIFOState *fs, int index)
g_free(name);
}

static void asc_reset_hold(Object *obj)
static void asc_reset_hold(Object *obj, ResetType type)
{
ASCState *s = ASC(obj);

Expand Down
2 changes: 1 addition & 1 deletion hw/char/cadence_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ static void cadence_uart_reset_init(Object *obj, ResetType type)
s->r[R_TTRIG] = 0x00000020;
}

static void cadence_uart_reset_hold(Object *obj)
static void cadence_uart_reset_hold(Object *obj, ResetType type)
{
CadenceUARTState *s = CADENCE_UART(obj);

Expand Down
2 changes: 1 addition & 1 deletion hw/char/sifive_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ static void sifive_uart_reset_enter(Object *obj, ResetType type)
s->rx_fifo_len = 0;
}

static void sifive_uart_reset_hold(Object *obj)
static void sifive_uart_reset_hold(Object *obj, ResetType type)
{
SiFiveUARTState *s = SIFIVE_UART(obj);
qemu_irq_lower(s->irq);
Expand Down
2 changes: 1 addition & 1 deletion hw/core/cpu-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void cpu_reset(CPUState *cpu)
trace_cpu_reset(cpu->cpu_index);
}

static void cpu_common_reset_hold(Object *obj)
static void cpu_common_reset_hold(Object *obj, ResetType type)
{
CPUState *cpu = CPU(obj);
CPUClass *cc = CPU_GET_CLASS(cpu);
Expand Down
4 changes: 2 additions & 2 deletions hw/core/qdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,10 +760,10 @@ static void device_phases_reset(DeviceState *dev)
rc->phases.enter(OBJECT(dev), RESET_TYPE_COLD);
}
if (rc->phases.hold) {
rc->phases.hold(OBJECT(dev));
rc->phases.hold(OBJECT(dev), RESET_TYPE_COLD);
}
if (rc->phases.exit) {
rc->phases.exit(OBJECT(dev));
rc->phases.exit(OBJECT(dev), RESET_TYPE_COLD);
}
}

Expand Down
2 changes: 1 addition & 1 deletion hw/core/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static ResettableState *legacy_reset_get_state(Object *obj)
return &lr->reset_state;
}

static void legacy_reset_hold(Object *obj)
static void legacy_reset_hold(Object *obj, ResetType type)
{
LegacyReset *lr = LEGACY_RESET(obj);

Expand Down
4 changes: 2 additions & 2 deletions hw/core/resettable.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static void resettable_phase_hold(Object *obj, void *opaque, ResetType type)
trace_resettable_transitional_function(obj, obj_typename);
tr_func(obj);
} else if (rc->phases.hold) {
rc->phases.hold(obj);
rc->phases.hold(obj, type);
}
}
trace_resettable_phase_hold_end(obj, obj_typename, s->count);
Expand All @@ -204,7 +204,7 @@ static void resettable_phase_exit(Object *obj, void *opaque, ResetType type)
if (--s->count == 0) {
trace_resettable_phase_exit_exec(obj, obj_typename, !!rc->phases.exit);
if (rc->phases.exit && !resettable_get_tr_func(rc, obj)) {
rc->phases.exit(obj);
rc->phases.exit(obj, type);
}
}
s->exit_phase_in_progress = false;
Expand Down
4 changes: 2 additions & 2 deletions hw/display/virtio-vga.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,14 @@ static void virtio_vga_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
}
}

static void virtio_vga_base_reset_hold(Object *obj)
static void virtio_vga_base_reset_hold(Object *obj, ResetType type)
{
VirtIOVGABaseClass *klass = VIRTIO_VGA_BASE_GET_CLASS(obj);
VirtIOVGABase *vvga = VIRTIO_VGA_BASE(obj);

/* reset virtio-gpu */
if (klass->parent_phases.hold) {
klass->parent_phases.hold(obj);
klass->parent_phases.hold(obj, type);
}

/* reset vga */
Expand Down
2 changes: 1 addition & 1 deletion hw/gpio/npcm7xx_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ static void npcm7xx_gpio_enter_reset(Object *obj, ResetType type)
s->regs[NPCM7XX_GPIO_ODSC] = s->reset_odsc;
}

static void npcm7xx_gpio_hold_reset(Object *obj)
static void npcm7xx_gpio_hold_reset(Object *obj, ResetType type)
{
NPCM7xxGPIOState *s = NPCM7XX_GPIO(obj);

Expand Down
2 changes: 1 addition & 1 deletion hw/gpio/pl061.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ static void pl061_enter_reset(Object *obj, ResetType type)
s->amsel = 0;
}

static void pl061_hold_reset(Object *obj)
static void pl061_hold_reset(Object *obj, ResetType type)
{
PL061State *s = PL061(obj);
int i, level;
Expand Down
2 changes: 1 addition & 1 deletion hw/gpio/stm32l4x5_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static bool is_push_pull(Stm32l4x5GpioState *s, unsigned pin)
return extract32(s->otyper, pin, 1) == 0;
}

static void stm32l4x5_gpio_reset_hold(Object *obj)
static void stm32l4x5_gpio_reset_hold(Object *obj, ResetType type)
{
Stm32l4x5GpioState *s = STM32L4X5_GPIO(obj);

Expand Down
2 changes: 1 addition & 1 deletion hw/hyperv/vmbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -2453,7 +2453,7 @@ static void vmbus_unrealize(BusState *bus)
qemu_mutex_destroy(&vmbus->rx_queue_lock);
}

static void vmbus_reset_hold(Object *obj)
static void vmbus_reset_hold(Object *obj, ResetType type)
{
vmbus_deinit(VMBUS(obj));
}
Expand Down
2 changes: 1 addition & 1 deletion hw/i2c/allwinner-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ static inline bool allwinner_i2c_interrupt_is_enabled(AWI2CState *s)
return s->cntr & TWI_CNTR_INT_EN;
}

static void allwinner_i2c_reset_hold(Object *obj)
static void allwinner_i2c_reset_hold(Object *obj, ResetType type)
{
AWI2CState *s = AW_I2C(obj);

Expand Down
2 changes: 1 addition & 1 deletion hw/i2c/npcm7xx_smbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ static void npcm7xx_smbus_enter_reset(Object *obj, ResetType type)
s->rx_cur = 0;
}

static void npcm7xx_smbus_hold_reset(Object *obj)
static void npcm7xx_smbus_hold_reset(Object *obj, ResetType type)
{
NPCM7xxSMBusState *s = NPCM7XX_SMBUS(obj);

Expand Down
2 changes: 1 addition & 1 deletion hw/input/adb.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static const VMStateDescription vmstate_adb_bus = {
}
};

static void adb_bus_reset_hold(Object *obj)
static void adb_bus_reset_hold(Object *obj, ResetType type)
{
ADBBusState *adb_bus = ADB_BUS(obj);

Expand Down
12 changes: 6 additions & 6 deletions hw/input/ps2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1007,15 +1007,15 @@ void ps2_write_mouse(PS2MouseState *s, int val)
}
}

static void ps2_reset_hold(Object *obj)
static void ps2_reset_hold(Object *obj, ResetType type)
{
PS2State *s = PS2_DEVICE(obj);

s->write_cmd = -1;
ps2_reset_queue(s);
}

static void ps2_reset_exit(Object *obj)
static void ps2_reset_exit(Object *obj, ResetType type)
{
PS2State *s = PS2_DEVICE(obj);

Expand Down Expand Up @@ -1048,15 +1048,15 @@ static void ps2_common_post_load(PS2State *s)
q->cwptr = ccount ? (q->rptr + ccount) & (PS2_BUFFER_SIZE - 1) : -1;
}

static void ps2_kbd_reset_hold(Object *obj)
static void ps2_kbd_reset_hold(Object *obj, ResetType type)
{
PS2DeviceClass *ps2dc = PS2_DEVICE_GET_CLASS(obj);
PS2KbdState *s = PS2_KBD_DEVICE(obj);

trace_ps2_kbd_reset(s);

if (ps2dc->parent_phases.hold) {
ps2dc->parent_phases.hold(obj);
ps2dc->parent_phases.hold(obj, type);
}

s->scan_enabled = 1;
Expand All @@ -1065,15 +1065,15 @@ static void ps2_kbd_reset_hold(Object *obj)
s->modifiers = 0;
}

static void ps2_mouse_reset_hold(Object *obj)
static void ps2_mouse_reset_hold(Object *obj, ResetType type)
{
PS2DeviceClass *ps2dc = PS2_DEVICE_GET_CLASS(obj);
PS2MouseState *s = PS2_MOUSE_DEVICE(obj);

trace_ps2_mouse_reset(s);

if (ps2dc->parent_phases.hold) {
ps2dc->parent_phases.hold(obj);
ps2dc->parent_phases.hold(obj, type);
}

s->mouse_status = 0;
Expand Down
2 changes: 1 addition & 1 deletion hw/intc/arm_gic_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ static inline void arm_gic_common_reset_irq_state(GICState *s, int cidx,
}
}

static void arm_gic_common_reset_hold(Object *obj)
static void arm_gic_common_reset_hold(Object *obj, ResetType type)
{
GICState *s = ARM_GIC_COMMON(obj);
int i, j;
Expand Down
4 changes: 2 additions & 2 deletions hw/intc/arm_gic_kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,13 +473,13 @@ static void kvm_arm_gic_get(GICState *s)
}
}

static void kvm_arm_gic_reset_hold(Object *obj)
static void kvm_arm_gic_reset_hold(Object *obj, ResetType type)
{
GICState *s = ARM_GIC_COMMON(obj);
KVMARMGICClass *kgc = KVM_ARM_GIC_GET_CLASS(s);

if (kgc->parent_phases.hold) {
kgc->parent_phases.hold(obj);
kgc->parent_phases.hold(obj, type);
}

if (kvm_arm_gic_can_save_restore(s)) {
Expand Down
2 changes: 1 addition & 1 deletion hw/intc/arm_gicv3_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ static void arm_gicv3_finalize(Object *obj)
g_free(s->redist_region_count);
}

static void arm_gicv3_common_reset_hold(Object *obj)
static void arm_gicv3_common_reset_hold(Object *obj, ResetType type)
{
GICv3State *s = ARM_GICV3_COMMON(obj);
int i;
Expand Down
4 changes: 2 additions & 2 deletions hw/intc/arm_gicv3_its.c
Original file line number Diff line number Diff line change
Expand Up @@ -1950,13 +1950,13 @@ static void gicv3_arm_its_realize(DeviceState *dev, Error **errp)
}
}

static void gicv3_its_reset_hold(Object *obj)
static void gicv3_its_reset_hold(Object *obj, ResetType type)
{
GICv3ITSState *s = ARM_GICV3_ITS_COMMON(obj);
GICv3ITSClass *c = ARM_GICV3_ITS_GET_CLASS(s);

if (c->parent_phases.hold) {
c->parent_phases.hold(obj);
c->parent_phases.hold(obj, type);
}

/* Quiescent bit reset to 1 */
Expand Down
2 changes: 1 addition & 1 deletion hw/intc/arm_gicv3_its_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void gicv3_its_init_mmio(GICv3ITSState *s, const MemoryRegionOps *ops,
msi_nonbroken = true;
}

static void gicv3_its_common_reset_hold(Object *obj)
static void gicv3_its_common_reset_hold(Object *obj, ResetType type)
{
GICv3ITSState *s = ARM_GICV3_ITS_COMMON(obj);

Expand Down
4 changes: 2 additions & 2 deletions hw/intc/arm_gicv3_its_kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ static void kvm_arm_its_post_load(GICv3ITSState *s)
GITS_CTLR, &s->ctlr, true, &error_abort);
}

static void kvm_arm_its_reset_hold(Object *obj)
static void kvm_arm_its_reset_hold(Object *obj, ResetType type)
{
GICv3ITSState *s = ARM_GICV3_ITS_COMMON(obj);
KVMARMITSClass *c = KVM_ARM_ITS_GET_CLASS(s);
int i;

if (c->parent_phases.hold) {
c->parent_phases.hold(obj);
c->parent_phases.hold(obj, type);
}

if (kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
Expand Down
4 changes: 2 additions & 2 deletions hw/intc/arm_gicv3_kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,15 +703,15 @@ static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri)
c->icc_ctlr_el1[GICV3_S] = c->icc_ctlr_el1[GICV3_NS];
}

static void kvm_arm_gicv3_reset_hold(Object *obj)
static void kvm_arm_gicv3_reset_hold(Object *obj, ResetType type)
{
GICv3State *s = ARM_GICV3_COMMON(obj);
KVMARMGICv3Class *kgc = KVM_ARM_GICV3_GET_CLASS(s);

DPRINTF("Reset\n");

if (kgc->parent_phases.hold) {
kgc->parent_phases.hold(obj);
kgc->parent_phases.hold(obj, type);
}

if (s->migration_blocker) {
Expand Down

0 comments on commit ad80e36

Please sign in to comment.