Commit fe6b6346 authored by Like Xu's avatar Like Xu Committed by Eduardo Habkost
Browse files

hw/ppc: Replace global smp variables with machine smp properties



The global smp variables in ppc are replaced with smp machine properties.

A local variable of the same name would be introduced in the declaration
phase if it's used widely in the context OR replace it on the spot if it's
only used once. No semantic changes.

Signed-off-by: default avatarLike Xu <like.xu@linux.intel.com>
Message-Id: <20190518205428.90532-5-like.xu@linux.intel.com>
Acked-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>
parent 5cc8767d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -308,6 +308,7 @@ static int ppce500_load_device_tree(PPCE500MachineState *pms,
                                    bool dry_run)
{
    MachineState *machine = MACHINE(pms);
    unsigned int smp_cpus = machine->smp.cpus;
    const PPCE500MachineClass *pmc = PPCE500_MACHINE_GET_CLASS(pms);
    CPUPPCState *env = first_cpu->env_ptr;
    int ret = -1;
@@ -735,6 +736,7 @@ static DeviceState *ppce500_init_mpic_qemu(PPCE500MachineState *pms,
    SysBusDevice *s;
    int i, j, k;
    MachineState *machine = MACHINE(pms);
    unsigned int smp_cpus = machine->smp.cpus;
    const PPCE500MachineClass *pmc = PPCE500_MACHINE_GET_CLASS(pms);

    dev = qdev_create(NULL, TYPE_OPENPIC);
@@ -847,6 +849,7 @@ void ppce500_init(MachineState *machine)
    struct boot_info *boot_info;
    int dt_size;
    int i;
    unsigned int smp_cpus = machine->smp.cpus;
    /* irq num for pin INTA, INTB, INTC and INTD is 1, 2, 3 and
     * 4 respectively */
    unsigned int pci_irq_nrs[PCI_NUM_PINS] = {1, 2, 3, 4};
+2 −1
Original line number Diff line number Diff line
@@ -136,6 +136,7 @@ static void ppc_core99_init(MachineState *machine)
    DeviceState *dev, *pic_dev;
    hwaddr nvram_addr = 0xFFF04000;
    uint64_t tbfreq;
    unsigned int smp_cpus = machine->smp.cpus;

    linux_boot = (kernel_filename != NULL);

@@ -463,7 +464,7 @@ static void ppc_core99_init(MachineState *machine)
    sysbus_mmio_map(s, 1, CFG_ADDR + 2);

    fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, (uint16_t)smp_cpus);
    fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
    fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)machine->smp.max_cpus);
    fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
    fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, machine_arch);
    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base);
+2 −1
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ static void ppc_heathrow_init(MachineState *machine)
    DeviceState *dev, *pic_dev;
    BusState *adb_bus;
    int bios_size;
    unsigned int smp_cpus = machine->smp.cpus;
    uint16_t ppc_boot_device;
    DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
    void *fw_cfg;
@@ -324,7 +325,7 @@ static void ppc_heathrow_init(MachineState *machine)
    sysbus_mmio_map(s, 1, CFG_ADDR + 2);

    fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, (uint16_t)smp_cpus);
    fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
    fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)machine->smp.max_cpus);
    fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
    fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_HEATHROW);
    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base);
+4 −2
Original line number Diff line number Diff line
@@ -688,7 +688,8 @@ static void pnv_init(MachineState *machine)
        object_property_add_child(OBJECT(pnv), chip_name, chip, &error_fatal);
        object_property_set_int(chip, PNV_CHIP_HWID(i), "chip-id",
                                &error_fatal);
        object_property_set_int(chip, smp_cores, "nr-cores", &error_fatal);
        object_property_set_int(chip, machine->smp.cores,
                                "nr-cores", &error_fatal);
        object_property_set_bool(chip, true, "realized", &error_fatal);
    }
    g_free(chip_typename);
@@ -1149,6 +1150,7 @@ static void pnv_chip_core_sanitize(PnvChip *chip, Error **errp)

static void pnv_chip_core_realize(PnvChip *chip, Error **errp)
{
    MachineState *ms = MACHINE(qdev_get_machine());
    Error *error = NULL;
    PnvChipClass *pcc = PNV_CHIP_GET_CLASS(chip);
    const char *typename = pnv_chip_core_typename(chip);
@@ -1182,7 +1184,7 @@ static void pnv_chip_core_realize(PnvChip *chip, Error **errp)
        snprintf(core_name, sizeof(core_name), "core[%d]", core_hwid);
        object_initialize_child(OBJECT(chip), core_name, pnv_core, typesize,
                                typename, &error_fatal, NULL);
        object_property_set_int(OBJECT(pnv_core), smp_threads, "nr-threads",
        object_property_set_int(OBJECT(pnv_core), ms->smp.threads, "nr-threads",
                                &error_fatal);
        object_property_set_int(OBJECT(pnv_core), core_hwid,
                                CPU_CORE_PROP_CORE_ID, &error_fatal);
+2 −2
Original line number Diff line number Diff line
@@ -428,7 +428,7 @@ static void ppc_prep_init(MachineState *machine)
    linux_boot = (kernel_filename != NULL);

    /* init CPUs */
    for (i = 0; i < smp_cpus; i++) {
    for (i = 0; i < machine->smp.cpus; i++) {
        cpu = POWERPC_CPU(cpu_create(machine->cpu_type));
        env = &cpu->env;

@@ -770,7 +770,7 @@ static void ibm_40p_init(MachineState *machine)
        boot_device = machine->boot_order[0];
    }

    fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
    fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)machine->smp.max_cpus);
    fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)machine->ram_size);
    fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_PREP);

Loading