Skip to content

Commit

Permalink
add device_legacy_reset function to prepare for reset api change
Browse files Browse the repository at this point in the history
Provide a temporary device_legacy_reset function doing what
device_reset does to prepare for the transition with Resettable
API.

All occurrence of device_reset in the code tree are also replaced
by device_legacy_reset.

The new resettable API has different prototype and semantics
(resetting child buses as well as the specified device). Subsequent
commits will make the changeover for each call site individually; once
that is complete device_legacy_reset() will be removed.

Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Acked-by: Cornelia Huck <cohuck@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20200123132823.1117486-2-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 100bc4a commit f703a04
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion hw/audio/intel-hda.c
Expand Up @@ -1087,7 +1087,7 @@ static void intel_hda_reset(DeviceState *dev)
QTAILQ_FOREACH(kid, &d->codecs.qbus.children, sibling) {
DeviceState *qdev = kid->child;
cdev = HDA_CODEC_DEVICE(qdev);
device_reset(DEVICE(cdev));
device_legacy_reset(DEVICE(cdev));
d->state_sts |= (1 << cdev->cad);
}
intel_hda_update_irq(d);
Expand Down
6 changes: 3 additions & 3 deletions hw/core/qdev.c
Expand Up @@ -298,7 +298,7 @@ HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev)

static int qdev_reset_one(DeviceState *dev, void *opaque)
{
device_reset(dev);
device_legacy_reset(dev);

return 0;
}
Expand Down Expand Up @@ -867,7 +867,7 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
}
}
if (dev->hotplugged) {
device_reset(dev);
device_legacy_reset(dev);
}
dev->pending_deleted_event = false;

Expand Down Expand Up @@ -1101,7 +1101,7 @@ void device_class_set_parent_unrealize(DeviceClass *dc,
dc->unrealize = dev_unrealize;
}

void device_reset(DeviceState *dev)
void device_legacy_reset(DeviceState *dev)
{
DeviceClass *klass = DEVICE_GET_CLASS(dev);

Expand Down
2 changes: 1 addition & 1 deletion hw/hyperv/hyperv.c
Expand Up @@ -140,7 +140,7 @@ void hyperv_synic_reset(CPUState *cs)
SynICState *synic = get_synic(cs);

if (synic) {
device_reset(DEVICE(synic));
device_legacy_reset(DEVICE(synic));
}
}

Expand Down
2 changes: 1 addition & 1 deletion hw/i386/microvm.c
Expand Up @@ -370,7 +370,7 @@ static void microvm_machine_reset(MachineState *machine)
cpu = X86_CPU(cs);

if (cpu->apic_state) {
device_reset(cpu->apic_state);
device_legacy_reset(cpu->apic_state);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion hw/i386/pc.c
Expand Up @@ -1879,7 +1879,7 @@ static void pc_machine_reset(MachineState *machine)
cpu = X86_CPU(cs);

if (cpu->apic_state) {
device_reset(cpu->apic_state);
device_legacy_reset(cpu->apic_state);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions hw/ide/microdrive.c
Expand Up @@ -173,7 +173,7 @@ static void md_attr_write(PCMCIACardState *card, uint32_t at, uint8_t value)
case 0x00: /* Configuration Option Register */
s->opt = value & 0xcf;
if (value & OPT_SRESET) {
device_reset(DEVICE(s));
device_legacy_reset(DEVICE(s));
}
md_interrupt_update(s);
break;
Expand Down Expand Up @@ -316,7 +316,7 @@ static void md_common_write(PCMCIACardState *card, uint32_t at, uint16_t value)
case 0xe: /* Device Control */
s->ctrl = value;
if (value & CTRL_SRST) {
device_reset(DEVICE(s));
device_legacy_reset(DEVICE(s));
}
md_interrupt_update(s);
break;
Expand Down Expand Up @@ -541,7 +541,7 @@ static int dscm1xxxx_attach(PCMCIACardState *card)
md->attr_base = pcc->cis[0x74] | (pcc->cis[0x76] << 8);
md->io_base = 0x0;

device_reset(DEVICE(md));
device_legacy_reset(DEVICE(md));
md_interrupt_update(md);

return 0;
Expand All @@ -551,7 +551,7 @@ static int dscm1xxxx_detach(PCMCIACardState *card)
{
MicroDriveState *md = MICRODRIVE(card);

device_reset(DEVICE(md));
device_legacy_reset(DEVICE(md));
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion hw/intc/spapr_xive.c
Expand Up @@ -1766,7 +1766,7 @@ static target_ulong h_int_reset(PowerPCCPU *cpu,
return H_PARAMETER;
}

device_reset(DEVICE(xive));
device_legacy_reset(DEVICE(xive));

if (kvm_irqchip_in_kernel()) {
Error *local_err = NULL;
Expand Down
4 changes: 2 additions & 2 deletions hw/ppc/pnv_psi.c
Expand Up @@ -466,7 +466,7 @@ static void pnv_psi_reset(DeviceState *dev)

static void pnv_psi_reset_handler(void *dev)
{
device_reset(DEVICE(dev));
device_legacy_reset(DEVICE(dev));
}

static void pnv_psi_realize(DeviceState *dev, Error **errp)
Expand Down Expand Up @@ -715,7 +715,7 @@ static void pnv_psi_p9_mmio_write(void *opaque, hwaddr addr,
break;
case PSIHB9_INTERRUPT_CONTROL:
if (val & PSIHB9_IRQ_RESET) {
device_reset(DEVICE(&psi9->source));
device_legacy_reset(DEVICE(&psi9->source));
}
psi->regs[reg] = val;
break;
Expand Down
2 changes: 1 addition & 1 deletion hw/ppc/spapr_pci.c
Expand Up @@ -2014,7 +2014,7 @@ static int spapr_phb_children_reset(Object *child, void *opaque)
DeviceState *dev = (DeviceState *) object_dynamic_cast(child, TYPE_DEVICE);

if (dev) {
device_reset(dev);
device_legacy_reset(dev);
}

return 0;
Expand Down
2 changes: 1 addition & 1 deletion hw/ppc/spapr_vio.c
Expand Up @@ -304,7 +304,7 @@ int spapr_vio_send_crq(SpaprVioDevice *dev, uint8_t *crq)
static void spapr_vio_quiesce_one(SpaprVioDevice *dev)
{
if (dev->tcet) {
device_reset(DEVICE(dev->tcet));
device_legacy_reset(DEVICE(dev->tcet));
}
free_crq(dev);
}
Expand Down
2 changes: 1 addition & 1 deletion hw/s390x/s390-pci-inst.c
Expand Up @@ -243,7 +243,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_reset(DEVICE(pbdev));
device_legacy_reset(DEVICE(pbdev));
pbdev->fh &= ~FH_MASK_ENABLE;
pbdev->state = ZPCI_FS_DISABLED;
stl_p(&ressetpci->fh, pbdev->fh);
Expand Down
2 changes: 1 addition & 1 deletion hw/scsi/vmw_pvscsi.c
Expand Up @@ -838,7 +838,7 @@ pvscsi_on_cmd_reset_device(PVSCSIState *s)

if (sdev != NULL) {
s->resetting++;
device_reset(&sdev->qdev);
device_legacy_reset(&sdev->qdev);
s->resetting--;
return PVSCSI_COMMAND_PROCESSING_SUCCEEDED;
}
Expand Down
2 changes: 1 addition & 1 deletion hw/sd/omap_mmc.c
Expand Up @@ -318,7 +318,7 @@ void omap_mmc_reset(struct omap_mmc_s *host)
* into any bus, and we must reset it manually. When omap_mmc is
* QOMified this must move into the QOM reset function.
*/
device_reset(DEVICE(host->card));
device_legacy_reset(DEVICE(host->card));
}

static uint64_t omap_mmc_read(void *opaque, hwaddr offset,
Expand Down
2 changes: 1 addition & 1 deletion hw/sd/pl181.c
Expand Up @@ -482,7 +482,7 @@ static void pl181_reset(DeviceState *d)
/* Since we're still using the legacy SD API the card is not plugged
* into any bus, and we must reset it manually.
*/
device_reset(DEVICE(s->card));
device_legacy_reset(DEVICE(s->card));
}

static void pl181_init(Object *obj)
Expand Down
4 changes: 2 additions & 2 deletions include/hw/qdev-core.h
Expand Up @@ -432,11 +432,11 @@ char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *dev);
void qdev_machine_init(void);

/**
* @device_reset
* device_legacy_reset:
*
* Reset a single device (by calling the reset method).
*/
void device_reset(DeviceState *dev);
void device_legacy_reset(DeviceState *dev);

void device_class_set_props(DeviceClass *dc, Property *props);

Expand Down

0 comments on commit f703a04

Please sign in to comment.