Advertise CPU DR-capability to the guest via device tree. Signed-off-by: Bharata B Rao <bhar...@linux.vnet.ibm.com> Signed-off-by: Michael Roth <mdr...@linux.vnet.ibm.com> [spapr_drc_reset implementation] Reviewed-by: David Gibson <da...@gibson.dropbear.id.au> --- hw/ppc/spapr.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index a782e28..920e650 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -807,6 +807,15 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr, spapr_populate_chosen_stdout(fdt, spapr->vio_bus); } + if (spapr->dr_cpu_enabled) { + int offset = fdt_path_offset(fdt, "/cpus"); + ret = spapr_drc_populate_dt(fdt, offset, NULL, + SPAPR_DR_CONNECTOR_TYPE_CPU); + if (ret < 0) { + fprintf(stderr, "Couldn't set up CPU DR device tree properties\n"); + } + } + _FDT((fdt_pack(fdt))); if (fdt_totalsize(fdt) > FDT_MAX_SIZE) { @@ -1393,6 +1402,16 @@ static SaveVMHandlers savevm_htab_handlers = { .load_state = htab_load, }; +static void spapr_drc_reset(void *opaque) +{ + sPAPRDRConnector *drc = opaque; + DeviceState *d = DEVICE(drc); + + if (d) { + device_reset(d); + } +} + /* pSeries LPAR / sPAPR hardware init */ static void ppc_spapr_init(MachineState *machine) { @@ -1418,6 +1437,7 @@ static void ppc_spapr_init(MachineState *machine) long load_limit, fw_size; bool kernel_le = false; char *filename; + int smt = kvmppc_smt_threads(); msi_supported = true; @@ -1564,6 +1584,15 @@ static void ppc_spapr_init(MachineState *machine) spapr->dr_cpu_enabled = smc->dr_cpu_enabled; spapr->dr_lmb_enabled = smc->dr_lmb_enabled; + if (spapr->dr_cpu_enabled) { + for (i = 0; i < max_cpus/smp_threads; i++) { + sPAPRDRConnector *drc = + spapr_dr_connector_new(OBJECT(machine), + SPAPR_DR_CONNECTOR_TYPE_CPU, i * smt); + qemu_register_reset(spapr_drc_reset, drc); + } + } + /* Set up PCI */ spapr_pci_rtas_init(); -- 2.1.0