From 093256789aaec8b9e84b620a4334adcea5992223 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Thu, 11 Mar 2021 16:16:08 +0800 Subject: [PATCH 1/5] hw/ppc: e500: Add missing #address-cells and #size-cells in the eTSEC node Per devicetree spec v0.3 [1] chapter 2.3.5: The #address-cells and #size-cells properties are not inherited from ancestors in the devicetree. They shall be explicitly defined. If missing, a client program should assume a default value of 2 for #address-cells, and a value of 1 for #size-cells. These properties are currently missing, causing the property of the queue-group subnode to be incorrectly parsed using default values. [1] https://github.com/devicetree-org/devicetree-specification/releases/download/v0.3/devicetree-specification-v0.3.pdf Fixes: fdfb7f2cdb2d ("e500: Add support for eTSEC in device tree") Signed-off-by: Bin Meng Message-Id: <20210311081608.66891-1-bmeng.cn@gmail.com> Signed-off-by: David Gibson --- hw/ppc/e500.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 1d94485ac8..79467ac512 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -237,6 +237,8 @@ static int create_devtree_etsec(SysBusDevice *sbdev, PlatformDevtreeData *data) qemu_fdt_setprop_string(fdt, node, "model", "eTSEC"); qemu_fdt_setprop(fdt, node, "local-mac-address", etsec->conf.macaddr.a, 6); qemu_fdt_setprop_cells(fdt, node, "fixed-link", 0, 1, 1000, 0, 0); + qemu_fdt_setprop_cells(fdt, node, "#size-cells", 1); + qemu_fdt_setprop_cells(fdt, node, "#address-cells", 1); qemu_fdt_add_subnode(fdt, group); qemu_fdt_setprop_cells(fdt, group, "reg", mmio0, 0x1000); From 9cbcfb5924b9a8295e7a103941135eb75c9deb93 Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Wed, 17 Mar 2021 18:57:07 +0100 Subject: [PATCH 2/5] target/ppc/kvm: Cache timebase frequency Each vCPU core exposes its timebase frequency in the DT. When running under KVM, this means parsing /proc/cpuinfo in order to get the timebase frequency of the host CPU. The parsing appears to slow down the boot quite a bit with higher number of cores: # of cores seconds spent in spapr_dt_cpus() 8 0.550122 16 1.342375 32 2.850316 64 5.922505 96 9.109224 128 12.245504 256 24.957236 384 37.389113 The timebase frequency of the host CPU is identical for all cores and it is an invariant for the VM lifetime. Cache it instead of doing the same expensive parsing again and again. Rename kvmppc_get_tbfreq() to kvmppc_get_tbfreq_procfs() and rename the 'retval' variable to make it clear it is used as fallback only. Come up with a new version of kvmppc_get_tbfreq() that calls kvmppc_get_tbfreq_procfs() only once and keep the value in a static. Zero is certainly not a valid value for the timebase frequency. Treat atoi() returning zero as another parsing error and return the fallback value instead. This allows kvmppc_get_tbfreq() to use zero as an indicator that kvmppc_get_tbfreq_procfs() hasn't been called yet. With this patch applied: 384 0.518382 Signed-off-by: Greg Kurz Message-Id: <161600382766.1780699.6787739229984093959.stgit@bahia.lan> Signed-off-by: David Gibson --- target/ppc/kvm.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 298c1f882c..104a308abb 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -1815,24 +1815,37 @@ static int read_cpuinfo(const char *field, char *value, int len) return ret; } -uint32_t kvmppc_get_tbfreq(void) +static uint32_t kvmppc_get_tbfreq_procfs(void) { char line[512]; char *ns; - uint32_t retval = NANOSECONDS_PER_SECOND; + uint32_t tbfreq_fallback = NANOSECONDS_PER_SECOND; + uint32_t tbfreq_procfs; if (read_cpuinfo("timebase", line, sizeof(line))) { - return retval; + return tbfreq_fallback; } ns = strchr(line, ':'); if (!ns) { - return retval; + return tbfreq_fallback; } - ns++; + tbfreq_procfs = atoi(++ns); - return atoi(ns); + /* 0 is certainly not acceptable by the guest, return fallback value */ + return tbfreq_procfs ? tbfreq_procfs : tbfreq_fallback; +} + +uint32_t kvmppc_get_tbfreq(void) +{ + static uint32_t cached_tbfreq; + + if (!cached_tbfreq) { + cached_tbfreq = kvmppc_get_tbfreq_procfs(); + } + + return cached_tbfreq; } bool kvmppc_get_host_serial(char **value) From df2d7ca7744156aac0e05ab47bc8623654c1346a Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Sat, 13 Mar 2021 08:23:31 +0100 Subject: [PATCH 3/5] spapr: Assert DIMM unplug state in spapr_memory_unplug() spapr_memory_unplug() is the last step of the hot unplug sequence. It is indirectly called by: spapr_lmb_release() hotplug_handler_unplug() and spapr_lmb_release() already buys us that DIMM unplug state is present : it gets restored with spapr_recover_pending_dimm_state() if missing. g_assert() that spapr_pending_dimm_unplugs_find() cannot return NULL in spapr_memory_unplug() to make this clear and silence Coverity. Fixes: Coverity CID 1450767 Signed-off-by: Greg Kurz Message-Id: <161562021166.948373.15092876234470478331.stgit@bahia.lan> Reviewed-by: Daniel Henrique Barboza Signed-off-by: David Gibson --- hw/ppc/spapr.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index d56418ca29..73a06df3b1 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3660,6 +3660,9 @@ static void spapr_memory_unplug(HotplugHandler *hotplug_dev, DeviceState *dev) SpaprMachineState *spapr = SPAPR_MACHINE(hotplug_dev); SpaprDimmState *ds = spapr_pending_dimm_unplugs_find(spapr, PC_DIMM(dev)); + /* We really shouldn't get this far without anything to unplug */ + g_assert(ds); + pc_dimm_unplug(PC_DIMM(dev), MACHINE(hotplug_dev)); qdev_unrealize(dev); spapr_pending_dimm_unplugs_remove(spapr, ds); From a40888bad602706abb0e726f96a9ea580d591de5 Mon Sep 17 00:00:00 2001 From: Alexey Kardashevskiy Date: Thu, 25 Feb 2021 14:23:35 +1100 Subject: [PATCH 4/5] spapr: Fix typo in the patb_entry comment There is no H_REGISTER_PROCESS_TABLE, it is H_REGISTER_PROC_TBL handler for which is still called h_register_process_table() though. Signed-off-by: Alexey Kardashevskiy Message-Id: <20210225032335.64245-1-aik@ozlabs.ru> Reviewed-by: Daniel Henrique Barboza Signed-off-by: David Gibson --- include/hw/ppc/spapr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 47cebaf3ac..bf7cab7a2c 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -168,7 +168,7 @@ struct SpaprMachineState { SpaprResizeHpt resize_hpt; void *htab; uint32_t htab_shift; - uint64_t patb_entry; /* Process tbl registed in H_REGISTER_PROCESS_TABLE */ + uint64_t patb_entry; /* Process tbl registed in H_REGISTER_PROC_TBL */ SpaprPendingHpt *pending_hpt; /* in-progress resize */ hwaddr rma_size; From 611ac0a60fdcc7422bf42ef9b467abf4fdbea1a2 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Tue, 16 Mar 2021 16:15:05 +0800 Subject: [PATCH 5/5] hw/net: fsl_etsec: Tx padding length should exclude CRC As the comment of tx_padding_and_crc() says: "Never add CRC in QEMU", min_frame_len should excluce CRC, so it should be 60 instead of 64. Signed-off-by: Bin Meng Message-Id: <20210316081505.72898-1-bmeng.cn@gmail.com> Signed-off-by: David Gibson --- hw/net/fsl_etsec/rings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/fsl_etsec/rings.c b/hw/net/fsl_etsec/rings.c index d6be0d7d18..8f08446415 100644 --- a/hw/net/fsl_etsec/rings.c +++ b/hw/net/fsl_etsec/rings.c @@ -259,7 +259,7 @@ static void process_tx_bd(eTSEC *etsec, || etsec->regs[MACCFG2].value & MACCFG2_PADCRC) { /* Padding and CRC (Padding implies CRC) */ - tx_padding_and_crc(etsec, 64); + tx_padding_and_crc(etsec, 60); } else if (etsec->first_bd.flags & BD_TX_TC || etsec->regs[MACCFG2].value & MACCFG2_CRC_EN) {