All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 00/19] ppc-for-6.0 queue 20210210
@ 2021-02-10  6:17 David Gibson
  2021-02-10  6:17 ` [PULL 01/19] spapr.c: use g_auto* with 'nodename' in CPU DT functions David Gibson
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: David Gibson @ 2021-02-10  6:17 UTC (permalink / raw)
  To: peter.maydell, groug; +Cc: qemu-ppc, qemu-devel, David Gibson

The following changes since commit 1214d55d1c41fbab3a9973a05085b8760647e411:

  Merge remote-tracking branch 'remotes/nvme/tags/nvme-next-pull-request' into staging (2021-02-09 13:24:37 +0000)

are available in the Git repository at:

  https://gitlab.com/dgibson/qemu.git tags/ppc-for-6.0-20210210

for you to fetch changes up to 298091f831db1a8f360686369f9760849e90dd03:

  target/ppc: Add E500 L2CSR0 write helper (2021-02-10 14:50:11 +1100)

----------------------------------------------------------------
ppc patch queue for 20201-02-10

Here's the latest batch of patches for the ppc target and machine
types.  Highlights are:
 * Several fixes for E500 from Bin Meng
 * Fixes and cleanups for PowerNV from Cédric Le Goater
 * Assorted other fixes and cleanups

----------------------------------------------------------------
Bin Meng (4):
      hw/ppc: e500: Use a macro for the platform clock frequency
      hw/ppc: e500: Fill in correct <clock-frequency> for the serial nodes
      hw/net: fsl_etsec: Reverse the RCTRL.RSF logic
      target/ppc: Add E500 L2CSR0 write helper

Cédric Le Goater (8):
      ppc/pnv: Add trace events for PCI event notification
      ppc/xive: Add firmware bit when dumping the ENDs
      ppc/pnv: Use skiboot addresses to load kernel and ramfs
      ppc/pnv: Simplify pnv_bmc_create()
      ppc/pnv: Discard internal BMC initialization when BMC is external
      ppc/pnv: Remove default disablement of the PNOR contents
      ppc/pnv: Introduce a LPC FW memory region attribute to map the PNOR
      ppc/pnv: Set default RAM size to 1 GB

Daniel Henrique Barboza (5):
      spapr.c: use g_auto* with 'nodename' in CPU DT functions
      spapr.c: add 'name' property for hotplugged CPUs nodes
      spapr: move spapr_machine_using_legacy_numa() to spapr_numa.c
      spapr_numa.c: create spapr_numa_initial_nvgpu_numa_id() helper
      spapr_numa.c: fix ibm,max-associativity-domains calculation

Greg Kurz (1):
      spapr: Adjust firmware path of PCI devices

Philippe Mathieu-Daudé (1):
      target/ppc: Remove unused MMU definitions

 hw/intc/pnv_xive.c              |  3 +++
 hw/intc/trace-events            |  3 +++
 hw/intc/xive.c                  |  3 ++-
 hw/net/fsl_etsec/rings.c        |  2 +-
 hw/pci-host/pnv_phb4.c          |  3 +++
 hw/pci-host/trace-events        |  3 +++
 hw/ppc/e500.c                   | 10 ++++++----
 hw/ppc/pnv.c                    | 27 +++++++++++++++++++------
 hw/ppc/pnv_bmc.c                | 22 ++++++++++++++-------
 hw/ppc/pnv_lpc.c                | 15 --------------
 hw/ppc/spapr.c                  | 44 ++++++++++++++++++++---------------------
 hw/ppc/spapr_numa.c             | 27 ++++++++++++++++++++++++-
 hw/ppc/spapr_pci.c              | 33 +++++++++++++++++--------------
 include/hw/pci-host/spapr.h     |  2 ++
 include/hw/ppc/pnv.h            |  1 +
 include/hw/ppc/spapr.h          |  1 -
 include/hw/ppc/spapr_numa.h     |  1 +
 include/hw/ppc/xive_regs.h      |  2 ++
 target/ppc/cpu.h                |  9 ++++++---
 target/ppc/translate_init.c.inc | 16 +++++++++++++++
 20 files changed, 150 insertions(+), 77 deletions(-)


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PULL 01/19] spapr.c: use g_auto* with 'nodename' in CPU DT functions
  2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
@ 2021-02-10  6:17 ` David Gibson
  2021-02-10  6:17 ` [PULL 02/19] spapr.c: add 'name' property for hotplugged CPUs nodes David Gibson
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: David Gibson @ 2021-02-10  6:17 UTC (permalink / raw)
  To: peter.maydell, groug
  Cc: Daniel Henrique Barboza, qemu-ppc, qemu-devel, David Gibson

From: Daniel Henrique Barboza <danielhb413@gmail.com>

Next patch will use the 'nodename' string in spapr_core_dt_populate()
after the point it's being freed today.

Instead of moving 'g_free(nodename)' around, let's do a QoL change in
both CPU DT functions where 'nodename' is being freed, and use
g_autofree to avoid the 'g_free()' call altogether.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20210120232305.241521-2-danielhb413@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/spapr.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 612356e9ec..e7992c0422 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -791,7 +791,6 @@ static void spapr_dt_cpus(void *fdt, SpaprMachineState *spapr)
     CPUState *cs;
     int n_cpus;
     int cpus_offset;
-    char *nodename;
     int i;
 
     cpus_offset = fdt_add_subnode(fdt, 0, "cpus");
@@ -819,6 +818,7 @@ static void spapr_dt_cpus(void *fdt, SpaprMachineState *spapr)
         PowerPCCPU *cpu = POWERPC_CPU(cs);
         int index = spapr_get_vcpu_id(cpu);
         DeviceClass *dc = DEVICE_GET_CLASS(cs);
+        g_autofree char *nodename = NULL;
         int offset;
 
         if (!spapr_is_thread0_in_vcore(spapr, cpu)) {
@@ -827,7 +827,6 @@ static void spapr_dt_cpus(void *fdt, SpaprMachineState *spapr)
 
         nodename = g_strdup_printf("%s@%x", dc->fw_name, index);
         offset = fdt_add_subnode(fdt, cpus_offset, nodename);
-        g_free(nodename);
         _FDT(offset);
         spapr_dt_cpu(cs, fdt, offset, spapr);
     }
@@ -3749,12 +3748,11 @@ int spapr_core_dt_populate(SpaprDrc *drc, SpaprMachineState *spapr,
     PowerPCCPU *cpu = POWERPC_CPU(cs);
     DeviceClass *dc = DEVICE_GET_CLASS(cs);
     int id = spapr_get_vcpu_id(cpu);
-    char *nodename;
+    g_autofree char *nodename = NULL;
     int offset;
 
     nodename = g_strdup_printf("%s@%x", dc->fw_name, id);
     offset = fdt_add_subnode(fdt, 0, nodename);
-    g_free(nodename);
 
     spapr_dt_cpu(cs, fdt, offset, spapr);
 
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PULL 02/19] spapr.c: add 'name' property for hotplugged CPUs nodes
  2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
  2021-02-10  6:17 ` [PULL 01/19] spapr.c: use g_auto* with 'nodename' in CPU DT functions David Gibson
@ 2021-02-10  6:17 ` David Gibson
  2021-02-10  6:17 ` [PULL 03/19] spapr: Adjust firmware path of PCI devices David Gibson
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: David Gibson @ 2021-02-10  6:17 UTC (permalink / raw)
  To: peter.maydell, groug
  Cc: Daniel Henrique Barboza, qemu-ppc, qemu-devel, David Gibson

From: Daniel Henrique Barboza <danielhb413@gmail.com>

In the CPU hotunplug bug [1] the guest kernel throws a scary
message in dmesg:

pseries-hotplug-cpu: Failed to offline CPU <NULL>, rc: -16

The reason isn't related to the bug though. This happens because the
kernel file arch/powerpc/platform/pseries/hotplug-cpu.c, function
dlpar_cpu_remove(), is not finding the device_node.name of the offending
CPU.

We're not populating the 'name' property for hotplugged CPUs. Since the
kernel relies on device_node.name for identifying CPU nodes, and the
CPUs that are coldplugged has the 'name' property filled by SLOF, this
is creating an unneeded inconsistency between hotplug and coldplug CPUs
in the kernel.

Let's fill the 'name' property for hotplugged CPUs as well. This will
make the guest dmesg throws a less intimidating message when we try to
unplug the last online CPU:

pseries-hotplug-cpu: Failed to offline CPU PowerPC,POWER9@1, rc: -16

[1] https://bugzilla.redhat.com/1911414

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20210120232305.241521-3-danielhb413@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/spapr.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index e7992c0422..0ecc193468 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3756,6 +3756,19 @@ int spapr_core_dt_populate(SpaprDrc *drc, SpaprMachineState *spapr,
 
     spapr_dt_cpu(cs, fdt, offset, spapr);
 
+    /*
+     * spapr_dt_cpu() does not fill the 'name' property in the
+     * CPU node. The function is called during boot process, before
+     * and after CAS, and overwriting the 'name' property written
+     * by SLOF is not allowed.
+     *
+     * Write it manually after spapr_dt_cpu(). This makes the hotplug
+     * CPUs more compatible with the coldplugged ones, which have
+     * the 'name' property. Linux Kernel also relies on this
+     * property to identify CPU nodes.
+     */
+    _FDT((fdt_setprop_string(fdt, offset, "name", nodename)));
+
     *fdt_start_offset = offset;
     return 0;
 }
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PULL 03/19] spapr: Adjust firmware path of PCI devices
  2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
  2021-02-10  6:17 ` [PULL 01/19] spapr.c: use g_auto* with 'nodename' in CPU DT functions David Gibson
  2021-02-10  6:17 ` [PULL 02/19] spapr.c: add 'name' property for hotplugged CPUs nodes David Gibson
@ 2021-02-10  6:17 ` David Gibson
  2021-02-10  6:17 ` [PULL 04/19] target/ppc: Remove unused MMU definitions David Gibson
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: David Gibson @ 2021-02-10  6:17 UTC (permalink / raw)
  To: peter.maydell, groug
  Cc: Daniel Henrique Barboza, qemu-ppc, qemu-devel, David Gibson

From: Greg Kurz <groug@kaod.org>

It is currently not possible to perform a strict boot from USB storage:

$ qemu-system-ppc64 -accel kvm -nodefaults -nographic -serial stdio \
	-boot strict=on \
	-device qemu-xhci \
	-device usb-storage,drive=disk,bootindex=0 \
	-blockdev driver=file,node-name=disk,filename=fedora-ppc64le.qcow2

SLOF **********************************************************************
QEMU Starting
 Build Date = Jul 17 2020 11:15:24
 FW Version = git-e18ddad8516ff2cf
 Press "s" to enter Open Firmware.

Populating /vdevice methods
Populating /vdevice/vty@71000000
Populating /vdevice/nvram@71000001
Populating /pci@800000020000000
                     00 0000 (D) : 1b36 000d    serial bus [ usb-xhci ]
No NVRAM common partition, re-initializing...
Scanning USB
  XHCI: Initializing
    USB Storage
       SCSI: Looking for devices
          101000000000000 DISK     : "QEMU     QEMU HARDDISK    2.5+"
Using default console: /vdevice/vty@71000000

  Welcome to Open Firmware

  Copyright (c) 2004, 2017 IBM Corporation All rights reserved.
  This program and the accompanying materials are made available
  under the terms of the BSD License available at
  http://www.opensource.org/licenses/bsd-license.php

Trying to load:  from: /pci@800000020000000/usb@0/storage@1/disk@101000000000000 ...
E3405: No such device

E3407: Load failed

  Type 'boot' and press return to continue booting the system.
  Type 'reset-all' and press return to reboot the system.

Ready!
0 >

The device tree handed over by QEMU to SLOF indeed contains:

qemu,boot-list =
	"/pci@800000020000000/usb@0/storage@1/disk@101000000000000 HALT";

but the device node is named usb-xhci@0, not usb@0.

This happens because the firmware names of PCI devices returned
by get_boot_devices_list() come from pcibus_get_fw_dev_path(),
while the sPAPR PHB code uses a different naming scheme for
device nodes. This inconsistency has always been there but it was
hidden for a long time because SLOF used to rename USB device
nodes, until this commit, merged in QEMU 4.2.0 :

commit 85164ad4ed9960cac842fa4cc067c6b6699b0994
Author: Alexey Kardashevskiy <aik@ozlabs.ru>
Date:   Wed Sep 11 16:24:32 2019 +1000

    pseries: Update SLOF firmware image

    This fixes USB host bus adapter name in the device tree to match QEMU's
    one.

    Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
    Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

Fortunately, sPAPR implements the firmware path provider interface.
This provides a way to override the default firmware paths.

Just factor out the sPAPR PHB naming logic from spapr_dt_pci_device()
to a helper, and use it in the sPAPR firmware path provider hook.

Fixes: 85164ad4ed99 ("pseries: Update SLOF firmware image")
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <20210122170157.246374-1-groug@kaod.org>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/spapr.c              |  5 +++++
 hw/ppc/spapr_pci.c          | 33 ++++++++++++++++++---------------
 include/hw/pci-host/spapr.h |  2 ++
 3 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 0ecc193468..f9ea9d1097 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3054,6 +3054,7 @@ static char *spapr_get_fw_dev_path(FWPathProvider *p, BusState *bus,
     SCSIDevice *d = CAST(SCSIDevice,  dev, TYPE_SCSI_DEVICE);
     SpaprPhbState *phb = CAST(SpaprPhbState, dev, TYPE_SPAPR_PCI_HOST_BRIDGE);
     VHostSCSICommon *vsc = CAST(VHostSCSICommon, dev, TYPE_VHOST_SCSI_COMMON);
+    PCIDevice *pcidev = CAST(PCIDevice, dev, TYPE_PCI_DEVICE);
 
     if (d) {
         void *spapr = CAST(void, bus->parent, "spapr-vscsi");
@@ -3127,6 +3128,10 @@ static char *spapr_get_fw_dev_path(FWPathProvider *p, BusState *bus,
         return g_strdup_printf("pci@%x", PCI_SLOT(pcidev->devfn));
     }
 
+    if (pcidev) {
+        return spapr_pci_fw_dev_name(pcidev);
+    }
+
     return NULL;
 }
 
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 24b4972300..f1c7479816 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -1344,15 +1344,29 @@ static int spapr_dt_pci_bus(SpaprPhbState *sphb, PCIBus *bus,
     return offset;
 }
 
+char *spapr_pci_fw_dev_name(PCIDevice *dev)
+{
+    const gchar *basename;
+    int slot = PCI_SLOT(dev->devfn);
+    int func = PCI_FUNC(dev->devfn);
+    uint32_t ccode = pci_default_read_config(dev, PCI_CLASS_PROG, 3);
+
+    basename = dt_name_from_class((ccode >> 16) & 0xff, (ccode >> 8) & 0xff,
+                                  ccode & 0xff);
+
+    if (func != 0) {
+        return g_strdup_printf("%s@%x,%x", basename, slot, func);
+    } else {
+        return g_strdup_printf("%s@%x", basename, slot);
+    }
+}
+
 /* create OF node for pci device and required OF DT properties */
 static int spapr_dt_pci_device(SpaprPhbState *sphb, PCIDevice *dev,
                                void *fdt, int parent_offset)
 {
     int offset;
-    const gchar *basename;
-    gchar *nodename;
-    int slot = PCI_SLOT(dev->devfn);
-    int func = PCI_FUNC(dev->devfn);
+    g_autofree gchar *nodename = spapr_pci_fw_dev_name(dev);
     PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
     ResourceProps rp;
     SpaprDrc *drc = drc_from_dev(sphb, dev);
@@ -1369,19 +1383,8 @@ static int spapr_dt_pci_device(SpaprPhbState *sphb, PCIDevice *dev,
     uint32_t pci_status = pci_default_read_config(dev, PCI_STATUS, 2);
     gchar *loc_code;
 
-    basename = dt_name_from_class((ccode >> 16) & 0xff, (ccode >> 8) & 0xff,
-                                  ccode & 0xff);
-
-    if (func != 0) {
-        nodename = g_strdup_printf("%s@%x,%x", basename, slot, func);
-    } else {
-        nodename = g_strdup_printf("%s@%x", basename, slot);
-    }
-
     _FDT(offset = fdt_add_subnode(fdt, parent_offset, nodename));
 
-    g_free(nodename);
-
     /* in accordance with PAPR+ v2.7 13.6.3, Table 181 */
     _FDT(fdt_setprop_cell(fdt, offset, "vendor-id", vendor_id));
     _FDT(fdt_setprop_cell(fdt, offset, "device-id", device_id));
diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h
index bd014823a9..5b03a7b0eb 100644
--- a/include/hw/pci-host/spapr.h
+++ b/include/hw/pci-host/spapr.h
@@ -210,4 +210,6 @@ static inline unsigned spapr_phb_windows_supported(SpaprPhbState *sphb)
     return sphb->ddw_enabled ? SPAPR_PCI_DMA_MAX_WINDOWS : 1;
 }
 
+char *spapr_pci_fw_dev_name(PCIDevice *dev);
+
 #endif /* PCI_HOST_SPAPR_H */
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PULL 04/19] target/ppc: Remove unused MMU definitions
  2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
                   ` (2 preceding siblings ...)
  2021-02-10  6:17 ` [PULL 03/19] spapr: Adjust firmware path of PCI devices David Gibson
@ 2021-02-10  6:17 ` David Gibson
  2021-02-10  6:17 ` [PULL 05/19] ppc/pnv: Add trace events for PCI event notification David Gibson
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: David Gibson @ 2021-02-10  6:17 UTC (permalink / raw)
  To: peter.maydell, groug
  Cc: David Gibson, qemu-ppc, qemu-devel, Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

Remove these confusing and unused definitions.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20210127232401.3525126-1-f4bug@amsat.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 target/ppc/cpu.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index 2609e4082e..cb00210288 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -2205,9 +2205,6 @@ enum {
  * may be needed for precise access rights control and precise exceptions.
  */
 enum {
-    /* 1 bit to define user level / supervisor access */
-    ACCESS_USER  = 0x00,
-    ACCESS_SUPER = 0x01,
     /* Type of instruction that generated the access */
     ACCESS_CODE  = 0x10, /* Code fetch access                */
     ACCESS_INT   = 0x20, /* Integer load/store access        */
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PULL 05/19] ppc/pnv: Add trace events for PCI event notification
  2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
                   ` (3 preceding siblings ...)
  2021-02-10  6:17 ` [PULL 04/19] target/ppc: Remove unused MMU definitions David Gibson
@ 2021-02-10  6:17 ` David Gibson
  2021-02-10  6:17 ` [PULL 06/19] ppc/xive: Add firmware bit when dumping the ENDs David Gibson
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: David Gibson @ 2021-02-10  6:17 UTC (permalink / raw)
  To: peter.maydell, groug
  Cc: David Gibson, qemu-ppc, qemu-devel, Cédric Le Goater

From: Cédric Le Goater <clg@kaod.org>

On POWER9 systems, PHB controllers signal the XIVE interrupt controller
of a source interrupt notification using a store on a MMIO region. Add
traces for such events.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20210126171059.307867-2-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/intc/pnv_xive.c       | 3 +++
 hw/intc/trace-events     | 3 +++
 hw/pci-host/pnv_phb4.c   | 3 +++
 hw/pci-host/trace-events | 3 +++
 4 files changed, 12 insertions(+)

diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c
index 5f69626b3a..ad43483612 100644
--- a/hw/intc/pnv_xive.c
+++ b/hw/intc/pnv_xive.c
@@ -24,6 +24,7 @@
 #include "hw/ppc/xive_regs.h"
 #include "hw/qdev-properties.h"
 #include "hw/ppc/ppc.h"
+#include "trace.h"
 
 #include <libfdt.h>
 
@@ -1319,6 +1320,8 @@ static void pnv_xive_ic_hw_trigger(PnvXive *xive, hwaddr addr, uint64_t val)
     uint8_t blk;
     uint32_t idx;
 
+    trace_pnv_xive_ic_hw_trigger(addr, val);
+
     if (val & XIVE_TRIGGER_END) {
         xive_error(xive, "IC: END trigger at @0x%"HWADDR_PRIx" data 0x%"PRIx64,
                    addr, val);
diff --git a/hw/intc/trace-events b/hw/intc/trace-events
index 8ed397a0d5..45ddaf48df 100644
--- a/hw/intc/trace-events
+++ b/hw/intc/trace-events
@@ -236,3 +236,6 @@ xive_tctx_tm_write(uint64_t offset, unsigned int size, uint64_t value) "@0x0x%"P
 xive_tctx_tm_read(uint64_t offset, unsigned int size, uint64_t value) "@0x0x%"PRIx64" sz=%d val=0x%" PRIx64
 xive_presenter_notify(uint8_t nvt_blk, uint32_t nvt_idx, uint8_t ring) "found NVT 0x%x/0x%x ring=0x%x"
 xive_end_source_read(uint8_t end_blk, uint32_t end_idx, uint64_t addr) "END 0x%x/0x%x @0x0x%"PRIx64
+
+# pnv_xive.c
+pnv_xive_ic_hw_trigger(uint64_t addr, uint64_t val) "@0x%"PRIx64" val=0x%"PRIx64
diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c
index 6328e985f8..54f57c660a 100644
--- a/hw/pci-host/pnv_phb4.c
+++ b/hw/pci-host/pnv_phb4.c
@@ -22,6 +22,7 @@
 #include "hw/irq.h"
 #include "hw/qdev-properties.h"
 #include "qom/object.h"
+#include "trace.h"
 
 #define phb_error(phb, fmt, ...)                                        \
     qemu_log_mask(LOG_GUEST_ERROR, "phb4[%d:%d]: " fmt "\n",            \
@@ -1257,6 +1258,8 @@ static void pnv_phb4_xive_notify(XiveNotifier *xf, uint32_t srcno)
     uint64_t data = XIVE_TRIGGER_PQ | offset | srcno;
     MemTxResult result;
 
+    trace_pnv_phb4_xive_notify(notif_port, data);
+
     address_space_stq_be(&address_space_memory, notif_port, data,
                          MEMTXATTRS_UNSPECIFIED, &result);
     if (result != MEMTX_OK) {
diff --git a/hw/pci-host/trace-events b/hw/pci-host/trace-events
index d19ca9aef6..7d8063ac42 100644
--- a/hw/pci-host/trace-events
+++ b/hw/pci-host/trace-events
@@ -20,3 +20,6 @@ unin_data_write(uint64_t addr, unsigned len, uint64_t val) "write addr 0x%"PRIx6
 unin_data_read(uint64_t addr, unsigned len, uint64_t val) "read addr 0x%"PRIx64 " len %d val 0x%"PRIx64
 unin_write(uint64_t addr, uint64_t value) "addr=0x%" PRIx64 " val=0x%"PRIx64
 unin_read(uint64_t addr, uint64_t value) "addr=0x%" PRIx64 " val=0x%"PRIx64
+
+# pnv_phb4.c
+pnv_phb4_xive_notify(uint64_t notif_port, uint64_t data) "notif=@0x%"PRIx64" data=0x%"PRIx64
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PULL 06/19] ppc/xive: Add firmware bit when dumping the ENDs
  2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
                   ` (4 preceding siblings ...)
  2021-02-10  6:17 ` [PULL 05/19] ppc/pnv: Add trace events for PCI event notification David Gibson
@ 2021-02-10  6:17 ` David Gibson
  2021-02-10  6:17 ` [PULL 07/19] ppc/pnv: Use skiboot addresses to load kernel and ramfs David Gibson
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: David Gibson @ 2021-02-10  6:17 UTC (permalink / raw)
  To: peter.maydell, groug
  Cc: David Gibson, qemu-ppc, qemu-devel, Cédric Le Goater

From: Cédric Le Goater <clg@kaod.org>

ENDs allocated by OPAL for the HW thread VPs are tagged as owned by FW.
Dump the state in 'info pic'.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20210126171059.307867-3-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/intc/xive.c             | 3 ++-
 include/hw/ppc/xive_regs.h | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/hw/intc/xive.c b/hw/intc/xive.c
index fa8c3d8287..eeb4e62ba9 100644
--- a/hw/intc/xive.c
+++ b/hw/intc/xive.c
@@ -1294,7 +1294,7 @@ void xive_end_pic_print_info(XiveEND *end, uint32_t end_idx, Monitor *mon)
 
     pq = xive_get_field32(END_W1_ESn, end->w1);
 
-    monitor_printf(mon, "  %08x %c%c %c%c%c%c%c%c%c prio:%d nvt:%02x/%04x",
+    monitor_printf(mon, "  %08x %c%c %c%c%c%c%c%c%c%c prio:%d nvt:%02x/%04x",
                    end_idx,
                    pq & XIVE_ESB_VAL_P ? 'P' : '-',
                    pq & XIVE_ESB_VAL_Q ? 'Q' : '-',
@@ -1305,6 +1305,7 @@ void xive_end_pic_print_info(XiveEND *end, uint32_t end_idx, Monitor *mon)
                    xive_end_is_escalate(end) ? 'e' : '-',
                    xive_end_is_uncond_escalation(end)   ? 'u' : '-',
                    xive_end_is_silent_escalation(end)   ? 's' : '-',
+                   xive_end_is_firmware(end)   ? 'f' : '-',
                    priority, nvt_blk, nvt_idx);
 
     if (qaddr_base) {
diff --git a/include/hw/ppc/xive_regs.h b/include/hw/ppc/xive_regs.h
index 7879692825..b7fde2354e 100644
--- a/include/hw/ppc/xive_regs.h
+++ b/include/hw/ppc/xive_regs.h
@@ -236,6 +236,8 @@ typedef struct XiveEND {
     (be32_to_cpu((end)->w0) & END_W0_UNCOND_ESCALATE)
 #define xive_end_is_silent_escalation(end)              \
     (be32_to_cpu((end)->w0) & END_W0_SILENT_ESCALATE)
+#define xive_end_is_firmware(end)              \
+    (be32_to_cpu((end)->w0) & END_W0_FIRMWARE)
 
 static inline uint64_t xive_end_qaddr(XiveEND *end)
 {
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PULL 07/19] ppc/pnv: Use skiboot addresses to load kernel and ramfs
  2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
                   ` (5 preceding siblings ...)
  2021-02-10  6:17 ` [PULL 06/19] ppc/xive: Add firmware bit when dumping the ENDs David Gibson
@ 2021-02-10  6:17 ` David Gibson
  2021-02-10  6:17 ` [PULL 08/19] ppc/pnv: Simplify pnv_bmc_create() David Gibson
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: David Gibson @ 2021-02-10  6:17 UTC (permalink / raw)
  To: peter.maydell, groug
  Cc: qemu-devel, Cédric Le Goater, qemu-ppc, Joel Stanley,
	Murilo Opsfelder Araujo, David Gibson

From: Cédric Le Goater <clg@kaod.org>

The current settings are useful to load large kernels (with debug) but
it moves the initrd image in a memory region not protected by
skiboot. If skiboot is compiled with DEBUG=1, memory poisoning will
corrupt the initrd.

Cc: Murilo Opsfelder Araujo <muriloo@linux.ibm.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20210126171059.307867-4-clg@kaod.org>
Reviewed-by: Murilo Opsfelder Araujo <muriloo@linux.ibm.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/pnv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 14fc9758a9..e500c2e243 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -65,9 +65,9 @@
 #define FW_MAX_SIZE             (16 * MiB)
 
 #define KERNEL_LOAD_ADDR        0x20000000
-#define KERNEL_MAX_SIZE         (256 * MiB)
-#define INITRD_LOAD_ADDR        0x60000000
-#define INITRD_MAX_SIZE         (256 * MiB)
+#define KERNEL_MAX_SIZE         (128 * MiB)
+#define INITRD_LOAD_ADDR        0x28000000
+#define INITRD_MAX_SIZE         (128 * MiB)
 
 static const char *pnv_chip_core_typename(const PnvChip *o)
 {
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PULL 08/19] ppc/pnv: Simplify pnv_bmc_create()
  2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
                   ` (6 preceding siblings ...)
  2021-02-10  6:17 ` [PULL 07/19] ppc/pnv: Use skiboot addresses to load kernel and ramfs David Gibson
@ 2021-02-10  6:17 ` David Gibson
  2021-02-10  6:17 ` [PULL 09/19] ppc/pnv: Discard internal BMC initialization when BMC is external David Gibson
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: David Gibson @ 2021-02-10  6:17 UTC (permalink / raw)
  To: peter.maydell, groug
  Cc: David Gibson, qemu-ppc, qemu-devel, Cédric Le Goater

From: Cédric Le Goater <clg@kaod.org>

and reuse pnv_bmc_set_pnor() to share the setting of the PNOR.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20210126171059.307867-5-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/pnv_bmc.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/hw/ppc/pnv_bmc.c b/hw/ppc/pnv_bmc.c
index 67ebb16c4d..86d16b4935 100644
--- a/hw/ppc/pnv_bmc.c
+++ b/hw/ppc/pnv_bmc.c
@@ -260,13 +260,8 @@ IPMIBmc *pnv_bmc_create(PnvPnor *pnor)
     Object *obj;
 
     obj = object_new(TYPE_IPMI_BMC_SIMULATOR);
-    object_ref(OBJECT(pnor));
-    object_property_add_const_link(obj, "pnor", OBJECT(pnor));
     qdev_realize(DEVICE(obj), NULL, &error_fatal);
-
-    /* Install the HIOMAP protocol handlers to access the PNOR */
-    ipmi_sim_register_netfn(IPMI_BMC_SIMULATOR(obj), IPMI_NETFN_OEM,
-                            &hiomap_netfn);
+    pnv_bmc_set_pnor(IPMI_BMC(obj), pnor);
 
     return IPMI_BMC(obj);
 }
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PULL 09/19] ppc/pnv: Discard internal BMC initialization when BMC is external
  2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
                   ` (7 preceding siblings ...)
  2021-02-10  6:17 ` [PULL 08/19] ppc/pnv: Simplify pnv_bmc_create() David Gibson
@ 2021-02-10  6:17 ` David Gibson
  2021-02-10  6:17 ` [PULL 10/19] ppc/pnv: Remove default disablement of the PNOR contents David Gibson
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: David Gibson @ 2021-02-10  6:17 UTC (permalink / raw)
  To: peter.maydell, groug
  Cc: Joel Stanley, David Gibson, qemu-ppc, qemu-devel, Cédric Le Goater

From: Cédric Le Goater <clg@kaod.org>

The PowerNV machine can be run with an external IPMI BMC device
connected to a remote QEMU machine acting as BMC, using these options :

  -chardev socket,id=ipmi0,host=localhost,port=9002,reconnect=10 \
  -device ipmi-bmc-extern,id=bmc0,chardev=ipmi0 \
  -device isa-ipmi-bt,bmc=bmc0,irq=10 \
  -nodefaults

In that case, some aspects of the BMC initialization should be
skipped, since they rely on the simulator interface.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20210126171059.307867-6-clg@kaod.org>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/pnv_bmc.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/hw/ppc/pnv_bmc.c b/hw/ppc/pnv_bmc.c
index 86d16b4935..b9bf5735ea 100644
--- a/hw/ppc/pnv_bmc.c
+++ b/hw/ppc/pnv_bmc.c
@@ -51,6 +51,11 @@ typedef struct OemSel {
 #define SOFT_OFF        0x00
 #define SOFT_REBOOT     0x01
 
+static bool pnv_bmc_is_simulator(IPMIBmc *bmc)
+{
+    return object_dynamic_cast(OBJECT(bmc), TYPE_IPMI_BMC_SIMULATOR);
+}
+
 static void pnv_gen_oem_sel(IPMIBmc *bmc, uint8_t reboot)
 {
     /* IPMI SEL Event are 16 bytes long */
@@ -79,6 +84,10 @@ void pnv_dt_bmc_sensors(IPMIBmc *bmc, void *fdt)
     const struct ipmi_sdr_compact *sdr;
     uint16_t nextrec;
 
+    if (!pnv_bmc_is_simulator(bmc)) {
+        return;
+    }
+
     offset = fdt_add_subnode(fdt, 0, "bmc");
     _FDT(offset);
 
@@ -243,6 +252,10 @@ static const IPMINetfn hiomap_netfn = {
 
 void pnv_bmc_set_pnor(IPMIBmc *bmc, PnvPnor *pnor)
 {
+    if (!pnv_bmc_is_simulator(bmc)) {
+        return;
+    }
+
     object_ref(OBJECT(pnor));
     object_property_add_const_link(OBJECT(bmc), "pnor", OBJECT(pnor));
 
@@ -286,7 +299,7 @@ static int bmc_find(Object *child, void *opaque)
 
 IPMIBmc *pnv_bmc_find(Error **errp)
 {
-    ForeachArgs args = { TYPE_IPMI_BMC_SIMULATOR, NULL };
+    ForeachArgs args = { TYPE_IPMI_BMC, NULL };
     int ret;
 
     ret = object_child_foreach_recursive(object_get_root(), bmc_find, &args);
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PULL 10/19] ppc/pnv: Remove default disablement of the PNOR contents
  2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
                   ` (8 preceding siblings ...)
  2021-02-10  6:17 ` [PULL 09/19] ppc/pnv: Discard internal BMC initialization when BMC is external David Gibson
@ 2021-02-10  6:17 ` David Gibson
  2021-02-10  6:17 ` [PULL 11/19] ppc/pnv: Introduce a LPC FW memory region attribute to map the PNOR David Gibson
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: David Gibson @ 2021-02-10  6:17 UTC (permalink / raw)
  To: peter.maydell, groug
  Cc: Joel Stanley, David Gibson, qemu-ppc, qemu-devel, Cédric Le Goater

From: Cédric Le Goater <clg@kaod.org>

On PowerNV systems, the BMC is in charge of mapping the PNOR contents
on the LPC FW address space using the HIOMAP protocol. Under QEMU, we
emulate this behavior and we also add an extra control on the flash
accesses by letting the HIOMAP command handler decide whether the
memory region is accessible or not depending on the firmware requests.

However, this behavior is not compatible with hostboot like firmwares
which need this mapping to be always available. For this reason, the
PNOR memory region is initially disabled for skiboot mode only.

This is badly placed under the LPC model and requires the use of the
machine. Since it doesn't add much, simply remove the initial setting.
The extra control in the HIOMAP command handler will still be performed.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20210126171059.307867-7-clg@kaod.org>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/pnv_lpc.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/hw/ppc/pnv_lpc.c b/hw/ppc/pnv_lpc.c
index 5903590220..11739e397b 100644
--- a/hw/ppc/pnv_lpc.c
+++ b/hw/ppc/pnv_lpc.c
@@ -825,7 +825,6 @@ ISABus *pnv_lpc_isa_create(PnvLpcController *lpc, bool use_cpld, Error **errp)
     qemu_irq *irqs;
     qemu_irq_handler handler;
     PnvMachineState *pnv = PNV_MACHINE(qdev_get_machine());
-    bool hostboot_mode = !!pnv->fw_load_addr;
 
     /* let isa_bus_new() create its own bridge on SysBus otherwise
      * devices specified on the command line won't find the bus and
@@ -856,13 +855,6 @@ ISABus *pnv_lpc_isa_create(PnvLpcController *lpc, bool use_cpld, Error **errp)
      */
     memory_region_add_subregion(&lpc->isa_fw, PNOR_SPI_OFFSET,
                                 &pnv->pnor->mmio);
-    /*
-     * Start disabled. The HIOMAP protocol will activate the mapping
-     * with HIOMAP_C_CREATE_WRITE_WINDOW
-     */
-    if (!hostboot_mode) {
-        memory_region_set_enabled(&pnv->pnor->mmio, false);
-    }
 
     return isa_bus;
 }
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PULL 11/19] ppc/pnv: Introduce a LPC FW memory region attribute to map the PNOR
  2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
                   ` (9 preceding siblings ...)
  2021-02-10  6:17 ` [PULL 10/19] ppc/pnv: Remove default disablement of the PNOR contents David Gibson
@ 2021-02-10  6:17 ` David Gibson
  2021-02-10  6:17 ` [PULL 12/19] spapr: move spapr_machine_using_legacy_numa() to spapr_numa.c David Gibson
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: David Gibson @ 2021-02-10  6:17 UTC (permalink / raw)
  To: peter.maydell, groug
  Cc: Joel Stanley, David Gibson, qemu-ppc, qemu-devel, Cédric Le Goater

From: Cédric Le Goater <clg@kaod.org>

This to map the PNOR from the machine init handler directly and finish
the cleanup of the LPC model.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20210126171059.307867-8-clg@kaod.org>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/pnv.c         | 11 +++++++++++
 hw/ppc/pnv_lpc.c     |  7 -------
 include/hw/ppc/pnv.h |  1 +
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index e500c2e243..50810df838 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -871,6 +871,14 @@ static void pnv_init(MachineState *machine)
         pnv_ipmi_bt_init(pnv->isa_bus, pnv->bmc, 10);
     }
 
+    /*
+     * The PNOR is mapped on the LPC FW address space by the BMC.
+     * Since we can not reach the remote BMC machine with LPC memops,
+     * map it always for now.
+     */
+    memory_region_add_subregion(pnv->chips[0]->fw_mr, PNOR_SPI_OFFSET,
+                                &pnv->pnor->mmio);
+
     /*
      * OpenPOWER systems use a IPMI SEL Event message to notify the
      * host to powerdown
@@ -1150,6 +1158,7 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp)
     qdev_realize(DEVICE(&chip8->lpc), NULL, &error_fatal);
     pnv_xscom_add_subregion(chip, PNV_XSCOM_LPC_BASE, &chip8->lpc.xscom_regs);
 
+    chip->fw_mr = &chip8->lpc.isa_fw;
     chip->dt_isa_nodename = g_strdup_printf("/xscom@%" PRIx64 "/isa@%x",
                                             (uint64_t) PNV_XSCOM_BASE(chip),
                                             PNV_XSCOM_LPC_BASE);
@@ -1479,6 +1488,7 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
     memory_region_add_subregion(get_system_memory(), PNV9_LPCM_BASE(chip),
                                 &chip9->lpc.xscom_regs);
 
+    chip->fw_mr = &chip9->lpc.isa_fw;
     chip->dt_isa_nodename = g_strdup_printf("/lpcm-opb@%" PRIx64 "/lpc@0",
                                             (uint64_t) PNV9_LPCM_BASE(chip));
 
@@ -1592,6 +1602,7 @@ static void pnv_chip_power10_realize(DeviceState *dev, Error **errp)
     memory_region_add_subregion(get_system_memory(), PNV10_LPCM_BASE(chip),
                                 &chip10->lpc.xscom_regs);
 
+    chip->fw_mr = &chip10->lpc.isa_fw;
     chip->dt_isa_nodename = g_strdup_printf("/lpcm-opb@%" PRIx64 "/lpc@0",
                                             (uint64_t) PNV10_LPCM_BASE(chip));
 }
diff --git a/hw/ppc/pnv_lpc.c b/hw/ppc/pnv_lpc.c
index 11739e397b..bcbca3db97 100644
--- a/hw/ppc/pnv_lpc.c
+++ b/hw/ppc/pnv_lpc.c
@@ -824,7 +824,6 @@ ISABus *pnv_lpc_isa_create(PnvLpcController *lpc, bool use_cpld, Error **errp)
     ISABus *isa_bus;
     qemu_irq *irqs;
     qemu_irq_handler handler;
-    PnvMachineState *pnv = PNV_MACHINE(qdev_get_machine());
 
     /* let isa_bus_new() create its own bridge on SysBus otherwise
      * devices specified on the command line won't find the bus and
@@ -850,11 +849,5 @@ ISABus *pnv_lpc_isa_create(PnvLpcController *lpc, bool use_cpld, Error **errp)
 
     isa_bus_irqs(isa_bus, irqs);
 
-    /*
-     * TODO: Map PNOR on the LPC FW address space on demand ?
-     */
-    memory_region_add_subregion(&lpc->isa_fw, PNOR_SPI_OFFSET,
-                                &pnv->pnor->mmio);
-
     return isa_bus;
 }
diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h
index ee7eda3e01..d69cee17b2 100644
--- a/include/hw/ppc/pnv.h
+++ b/include/hw/ppc/pnv.h
@@ -58,6 +58,7 @@ struct PnvChip {
     MemoryRegion xscom;
     AddressSpace xscom_as;
 
+    MemoryRegion *fw_mr;
     gchar        *dt_isa_nodename;
 };
 
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PULL 12/19] spapr: move spapr_machine_using_legacy_numa() to spapr_numa.c
  2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
                   ` (10 preceding siblings ...)
  2021-02-10  6:17 ` [PULL 11/19] ppc/pnv: Introduce a LPC FW memory region attribute to map the PNOR David Gibson
@ 2021-02-10  6:17 ` David Gibson
  2021-02-10  6:17 ` [PULL 13/19] spapr_numa.c: create spapr_numa_initial_nvgpu_numa_id() helper David Gibson
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: David Gibson @ 2021-02-10  6:17 UTC (permalink / raw)
  To: peter.maydell, groug
  Cc: Daniel Henrique Barboza, qemu-ppc, qemu-devel, David Gibson,
	Cédric Le Goater

From: Daniel Henrique Barboza <danielhb413@gmail.com>

This function is used only in spapr_numa.c.

Tested-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20210128174213.1349181-2-danielhb413@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/spapr.c         | 9 ---------
 hw/ppc/spapr_numa.c    | 9 +++++++++
 include/hw/ppc/spapr.h | 1 -
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index f9ea9d1097..8a1a979257 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -296,15 +296,6 @@ static hwaddr spapr_node0_size(MachineState *machine)
     return machine->ram_size;
 }
 
-bool spapr_machine_using_legacy_numa(SpaprMachineState *spapr)
-{
-    MachineState *machine = MACHINE(spapr);
-    SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine);
-
-    return smc->pre_5_2_numa_associativity ||
-           machine->numa_state->num_nodes <= 1;
-}
-
 static void add_str(GString *s, const gchar *s1)
 {
     g_string_append_len(s, s1, strlen(s1) + 1);
diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c
index b50796bbe3..261810525b 100644
--- a/hw/ppc/spapr_numa.c
+++ b/hw/ppc/spapr_numa.c
@@ -19,6 +19,15 @@
 /* Moved from hw/ppc/spapr_pci_nvlink2.c */
 #define SPAPR_GPU_NUMA_ID           (cpu_to_be32(1))
 
+static bool spapr_machine_using_legacy_numa(SpaprMachineState *spapr)
+{
+    MachineState *machine = MACHINE(spapr);
+    SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine);
+
+    return smc->pre_5_2_numa_associativity ||
+           machine->numa_state->num_nodes <= 1;
+}
+
 static bool spapr_numa_is_symmetrical(MachineState *ms)
 {
     int src, dst;
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index c27c7ce515..ccbeeca1de 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -851,7 +851,6 @@ int spapr_max_server_number(SpaprMachineState *spapr);
 void spapr_store_hpte(PowerPCCPU *cpu, hwaddr ptex,
                       uint64_t pte0, uint64_t pte1);
 void spapr_mce_req_event(PowerPCCPU *cpu, bool recovered);
-bool spapr_machine_using_legacy_numa(SpaprMachineState *spapr);
 
 /* DRC callbacks. */
 void spapr_core_release(DeviceState *dev);
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PULL 13/19] spapr_numa.c: create spapr_numa_initial_nvgpu_numa_id() helper
  2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
                   ` (11 preceding siblings ...)
  2021-02-10  6:17 ` [PULL 12/19] spapr: move spapr_machine_using_legacy_numa() to spapr_numa.c David Gibson
@ 2021-02-10  6:17 ` David Gibson
  2021-02-10  6:17 ` [PULL 14/19] spapr_numa.c: fix ibm, max-associativity-domains calculation David Gibson
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: David Gibson @ 2021-02-10  6:17 UTC (permalink / raw)
  To: peter.maydell, groug
  Cc: Daniel Henrique Barboza, qemu-ppc, qemu-devel, David Gibson,
	Cédric Le Goater

From: Daniel Henrique Barboza <danielhb413@gmail.com>

We'll need to check the initial value given to spapr->gpu_numa_id when
building the rtas DT, so put it in a helper for easier access and to
avoid repetition.

Tested-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20210128174213.1349181-3-danielhb413@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/spapr.c              | 11 +----------
 hw/ppc/spapr_numa.c         | 14 ++++++++++++++
 include/hw/ppc/spapr_numa.h |  1 +
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 8a1a979257..85fe65f894 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2770,16 +2770,7 @@ static void spapr_machine_init(MachineState *machine)
 
     }
 
-    /*
-     * NVLink2-connected GPU RAM needs to be placed on a separate NUMA node.
-     * We assign a new numa ID per GPU in spapr_pci_collect_nvgpu() which is
-     * called from vPHB reset handler so we initialize the counter here.
-     * If no NUMA is configured from the QEMU side, we start from 1 as GPU RAM
-     * must be equally distant from any other node.
-     * The final value of spapr->gpu_numa_id is going to be written to
-     * max-associativity-domains in spapr_build_fdt().
-     */
-    spapr->gpu_numa_id = MAX(1, machine->numa_state->num_nodes);
+    spapr->gpu_numa_id = spapr_numa_initial_nvgpu_numa_id(machine);
 
     /* Init numa_assoc_array */
     spapr_numa_associativity_init(spapr, machine);
diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c
index 261810525b..a757dd88b8 100644
--- a/hw/ppc/spapr_numa.c
+++ b/hw/ppc/spapr_numa.c
@@ -46,6 +46,20 @@ static bool spapr_numa_is_symmetrical(MachineState *ms)
     return true;
 }
 
+/*
+ * NVLink2-connected GPU RAM needs to be placed on a separate NUMA node.
+ * We assign a new numa ID per GPU in spapr_pci_collect_nvgpu() which is
+ * called from vPHB reset handler so we initialize the counter here.
+ * If no NUMA is configured from the QEMU side, we start from 1 as GPU RAM
+ * must be equally distant from any other node.
+ * The final value of spapr->gpu_numa_id is going to be written to
+ * max-associativity-domains in spapr_build_fdt().
+ */
+unsigned int spapr_numa_initial_nvgpu_numa_id(MachineState *machine)
+{
+    return MAX(1, machine->numa_state->num_nodes);
+}
+
 /*
  * This function will translate the user distances into
  * what the kernel understand as possible values: 10
diff --git a/include/hw/ppc/spapr_numa.h b/include/hw/ppc/spapr_numa.h
index b3fd950634..6f9f02d3de 100644
--- a/include/hw/ppc/spapr_numa.h
+++ b/include/hw/ppc/spapr_numa.h
@@ -31,5 +31,6 @@ int spapr_numa_fixup_cpu_dt(SpaprMachineState *spapr, void *fdt,
                             int offset, PowerPCCPU *cpu);
 int spapr_numa_write_assoc_lookup_arrays(SpaprMachineState *spapr, void *fdt,
                                          int offset);
+unsigned int spapr_numa_initial_nvgpu_numa_id(MachineState *machine);
 
 #endif /* HW_SPAPR_NUMA_H */
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PULL 14/19] spapr_numa.c: fix ibm, max-associativity-domains calculation
  2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
                   ` (12 preceding siblings ...)
  2021-02-10  6:17 ` [PULL 13/19] spapr_numa.c: create spapr_numa_initial_nvgpu_numa_id() helper David Gibson
@ 2021-02-10  6:17 ` David Gibson
  2021-02-10  6:17 ` [PULL 15/19] ppc/pnv: Set default RAM size to 1 GB David Gibson
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: David Gibson @ 2021-02-10  6:17 UTC (permalink / raw)
  To: peter.maydell, groug
  Cc: Daniel Henrique Barboza, qemu-ppc, qemu-devel, David Gibson,
	Cédric Le Goater

From: Daniel Henrique Barboza <danielhb413@gmail.com>

The current logic for calculating 'maxdomain' making it a sum of
numa_state->num_nodes with spapr->gpu_numa_id. spapr->gpu_numa_id is
used as a index to determine the next available NUMA id that a
given NVGPU can use.

The problem is that the initial value of gpu_numa_id, for any topology
that has more than one NUMA node, is equal to numa_state->num_nodes.
This means that our maxdomain will always be, at least, twice the
amount of existing NUMA nodes. This means that a guest with 4 NUMA
nodes will end up with the following max-associativity-domains:

rtas/ibm,max-associativity-domains
                 00000004 00000008 00000008 00000008 00000008

This overtuning of maxdomains doesn't go unnoticed in the guest, being
detected in SLUB during boot:

 dmesg | grep SLUB
[    0.000000] SLUB: HWalign=128, Order=0-3, MinObjects=0, CPUs=4, Nodes=8

SLUB is detecting 8 total nodes, with 4 nodes being online.

This patch fixes ibm,max-associativity-domains by considering the amount
of NVGPUs NUMA nodes presented in the guest, instead of just
spapr->gpu_numa_id.

Reported-by: Cédric Le Goater <clg@kaod.org>
Tested-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20210128174213.1349181-4-danielhb413@gmail.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/spapr_numa.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c
index a757dd88b8..779f18b994 100644
--- a/hw/ppc/spapr_numa.c
+++ b/hw/ppc/spapr_numa.c
@@ -311,6 +311,8 @@ void spapr_numa_write_rtas_dt(SpaprMachineState *spapr, void *fdt, int rtas)
 {
     MachineState *ms = MACHINE(spapr);
     SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
+    uint32_t number_nvgpus_nodes = spapr->gpu_numa_id -
+                                   spapr_numa_initial_nvgpu_numa_id(ms);
     uint32_t refpoints[] = {
         cpu_to_be32(0x4),
         cpu_to_be32(0x3),
@@ -318,7 +320,7 @@ void spapr_numa_write_rtas_dt(SpaprMachineState *spapr, void *fdt, int rtas)
         cpu_to_be32(0x1),
     };
     uint32_t nr_refpoints = ARRAY_SIZE(refpoints);
-    uint32_t maxdomain = ms->numa_state->num_nodes + spapr->gpu_numa_id;
+    uint32_t maxdomain = ms->numa_state->num_nodes + number_nvgpus_nodes;
     uint32_t maxdomains[] = {
         cpu_to_be32(4),
         cpu_to_be32(maxdomain),
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PULL 15/19] ppc/pnv: Set default RAM size to 1 GB
  2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
                   ` (13 preceding siblings ...)
  2021-02-10  6:17 ` [PULL 14/19] spapr_numa.c: fix ibm, max-associativity-domains calculation David Gibson
@ 2021-02-10  6:17 ` David Gibson
  2021-02-10  6:17 ` [PULL 16/19] hw/ppc: e500: Use a macro for the platform clock frequency David Gibson
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: David Gibson @ 2021-02-10  6:17 UTC (permalink / raw)
  To: peter.maydell, groug
  Cc: Philippe Mathieu-Daudé,
	David Gibson, qemu-ppc, qemu-devel, Cédric Le Goater

From: Cédric Le Goater <clg@kaod.org>

The memory layout of the PowerNV machine is defined as :

  #define KERNEL_LOAD_BASE	((void *)0x20000000)
  #define KERNEL_LOAD_SIZE	0x08000000

  #define INITRAMFS_LOAD_BASE	KERNEL_LOAD_BASE + KERNEL_LOAD_SIZE
  #define INITRAMFS_LOAD_SIZE	0x08000000

  #define SKIBOOT_BASE		0x30000000
  #define SKIBOOT_SIZE		0x01c10000

  #define CPU_STACKS_BASE	(SKIBOOT_BASE + SKIBOOT_SIZE)
  #define STACK_SHIFT		15
  #define STACK_SIZE		(1 << STACK_SHIFT)

The overall size of the CPU stacks is (max PIR + 1) * 32K and the
machine easily reaches 800MB of minimum required RAM.

Any value below will result in a skiboot crash :

    [    0.034949905,3] MEM: Partial overlap detected between regions:
    [    0.034959039,3] MEM: ibm,firmware-stacks [0x31c10000-0x3a450000] (new)
    [    0.034968576,3] MEM: ibm,firmware-allocs-memory@0 [0x31c10000-0x38400000]
    [    0.034980367,3] Out of memory adding skiboot reserved areas
    [    0.035074945,3] ***********************************************
    [    0.035093627,3] < assert failed at core/mem_region.c:1129 >
    [    0.035104247,3]     .
    [    0.035108025,3]      .
    [    0.035111651,3]       .
    [    0.035115231,3]         OO__)
    [    0.035119198,3]        <"__/
    [    0.035122980,3]         ^ ^

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20210129111719.790692-1-clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/pnv.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 50810df838..77af846cdf 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -21,6 +21,7 @@
 #include "qemu-common.h"
 #include "qemu/datadir.h"
 #include "qemu/units.h"
+#include "qemu/cutils.h"
 #include "qapi/error.h"
 #include "sysemu/qtest.h"
 #include "sysemu/sysemu.h"
@@ -725,8 +726,11 @@ static void pnv_init(MachineState *machine)
     DeviceState *dev;
 
     /* allocate RAM */
-    if (machine->ram_size < (1 * GiB)) {
-        warn_report("skiboot may not work with < 1GB of RAM");
+    if (machine->ram_size < mc->default_ram_size) {
+        char *sz = size_to_str(mc->default_ram_size);
+        error_report("Invalid RAM size, should be bigger than %s", sz);
+        g_free(sz);
+        exit(EXIT_FAILURE);
     }
     memory_region_add_subregion(get_system_memory(), 0, machine->ram);
 
@@ -1994,7 +1998,7 @@ static void pnv_machine_class_init(ObjectClass *oc, void *data)
      * RAM defaults to less than 2048 for 32-bit hosts, and large
      * enough to fit the maximum initrd size at it's load address
      */
-    mc->default_ram_size = INITRD_LOAD_ADDR + INITRD_MAX_SIZE;
+    mc->default_ram_size = 1 * GiB;
     mc->default_ram_id = "pnv.ram";
     ispc->print_info = pnv_pic_print_info;
     nc->nmi_monitor_handler = pnv_nmi;
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PULL 16/19] hw/ppc: e500: Use a macro for the platform clock frequency
  2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
                   ` (14 preceding siblings ...)
  2021-02-10  6:17 ` [PULL 15/19] ppc/pnv: Set default RAM size to 1 GB David Gibson
@ 2021-02-10  6:17 ` David Gibson
  2021-02-10  6:17 ` [PULL 17/19] hw/ppc: e500: Fill in correct <clock-frequency> for the serial nodes David Gibson
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: David Gibson @ 2021-02-10  6:17 UTC (permalink / raw)
  To: peter.maydell, groug
  Cc: Bin Meng, qemu-ppc, qemu-devel, David Gibson,
	Philippe Mathieu-Daudé

From: Bin Meng <bin.meng@windriver.com>

At present the platform clock frequency is using a magic number.
Convert it to a macro and use it everywhere.

Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Message-Id: <1612362288-22216-1-git-send-email-bmeng.cn@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/e500.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index c64b5d08bd..c795276668 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -74,6 +74,8 @@
 #define MPC8544_I2C_IRQ            43
 #define RTC_REGS_OFFSET            0x68
 
+#define PLATFORM_CLK_FREQ_HZ       (400 * 1000 * 1000)
+
 struct boot_info
 {
     uint32_t dt_base;
@@ -320,8 +322,8 @@ static int ppce500_load_device_tree(PPCE500MachineState *pms,
     int fdt_size;
     void *fdt;
     uint8_t hypercall[16];
-    uint32_t clock_freq = 400000000;
-    uint32_t tb_freq = 400000000;
+    uint32_t clock_freq = PLATFORM_CLK_FREQ_HZ;
+    uint32_t tb_freq = PLATFORM_CLK_FREQ_HZ;
     int i;
     char compatible_sb[] = "fsl,mpc8544-immr\0simple-bus";
     char *soc;
@@ -890,7 +892,7 @@ void ppce500_init(MachineState *machine)
         env->spr_cb[SPR_BOOKE_PIR].default_value = cs->cpu_index = i;
         env->mpic_iack = pmc->ccsrbar_base + MPC8544_MPIC_REGS_OFFSET + 0xa0;
 
-        ppc_booke_timers_init(cpu, 400000000, PPC_TIMER_E500);
+        ppc_booke_timers_init(cpu, PLATFORM_CLK_FREQ_HZ, PPC_TIMER_E500);
 
         /* Register reset handler */
         if (!i) {
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PULL 17/19] hw/ppc: e500: Fill in correct <clock-frequency> for the serial nodes
  2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
                   ` (15 preceding siblings ...)
  2021-02-10  6:17 ` [PULL 16/19] hw/ppc: e500: Use a macro for the platform clock frequency David Gibson
@ 2021-02-10  6:17 ` David Gibson
  2021-02-10  6:17 ` [PULL 18/19] hw/net: fsl_etsec: Reverse the RCTRL.RSF logic David Gibson
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: David Gibson @ 2021-02-10  6:17 UTC (permalink / raw)
  To: peter.maydell, groug
  Cc: Bin Meng, qemu-ppc, qemu-devel, David Gibson,
	Philippe Mathieu-Daudé

From: Bin Meng <bin.meng@windriver.com>

At present the <clock-frequency> property of the serial node is
populated with value zero. U-Boot's ns16550 driver is not happy
about this, so let's fill in a meaningful value.

Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Message-Id: <1612362288-22216-2-git-send-email-bmeng.cn@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/e500.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index c795276668..01517a6c6c 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -126,7 +126,7 @@ static void dt_serial_create(void *fdt, unsigned long long offset,
     qemu_fdt_setprop_string(fdt, ser, "compatible", "ns16550");
     qemu_fdt_setprop_cells(fdt, ser, "reg", offset, 0x100);
     qemu_fdt_setprop_cell(fdt, ser, "cell-index", idx);
-    qemu_fdt_setprop_cell(fdt, ser, "clock-frequency", 0);
+    qemu_fdt_setprop_cell(fdt, ser, "clock-frequency", PLATFORM_CLK_FREQ_HZ);
     qemu_fdt_setprop_cells(fdt, ser, "interrupts", 42, 2);
     qemu_fdt_setprop_phandle(fdt, ser, "interrupt-parent", mpic);
     qemu_fdt_setprop_string(fdt, "/aliases", alias, ser);
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PULL 18/19] hw/net: fsl_etsec: Reverse the RCTRL.RSF logic
  2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
                   ` (16 preceding siblings ...)
  2021-02-10  6:17 ` [PULL 17/19] hw/ppc: e500: Fill in correct <clock-frequency> for the serial nodes David Gibson
@ 2021-02-10  6:17 ` David Gibson
  2021-02-10  6:17 ` [PULL 19/19] target/ppc: Add E500 L2CSR0 write helper David Gibson
  2021-02-10 15:42 ` [PULL 00/19] ppc-for-6.0 queue 20210210 Peter Maydell
  19 siblings, 0 replies; 21+ messages in thread
From: David Gibson @ 2021-02-10  6:17 UTC (permalink / raw)
  To: peter.maydell, groug; +Cc: Bin Meng, qemu-ppc, qemu-devel, David Gibson

From: Bin Meng <bin.meng@windriver.com>

Per MPC8548ERM [1] chapter 14.5.3.4.1:

When RCTRL.RSF is 1, frames less than 64 bytes are accepted upon
a DA match. But currently QEMU does the opposite. This commit
reverses the RCTRL.RSF testing logic to match the manual.

Due to the reverse of the logic, certain guests may potentially
break if they don't program eTSEC to have RCTRL.RSF bit set.
When RCTRL.RSF is 0, short frames are silently dropped, however
as of today both slirp and tap networking do not pad short frames
(e.g.: an ARP packet) to the minimum frame size of 60 bytes. So
ARP requests will be dropped, preventing the guest from becoming
visible on the network.

The same issue was reported on e1000 and vmxenet3 before, see:

commit 78aeb23eded2 ("e1000: Pad short frames to minimum size (60 bytes)")
commit 40a87c6c9b11 ("vmxnet3: Pad short frames to minimum size (60 bytes)")

[1] https://www.nxp.com/docs/en/reference-manual/MPC8548ERM.pdf

Fixes: eb1e7c3e5146 ("Add Enhanced Three-Speed Ethernet Controller (eTSEC)")
Signed-off-by: Bin Meng <bin.meng@windriver.com>

Message-Id: <1612923021-19746-1-git-send-email-bmeng.cn@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 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 121415abfe..fe055d3381 100644
--- a/hw/net/fsl_etsec/rings.c
+++ b/hw/net/fsl_etsec/rings.c
@@ -502,7 +502,7 @@ ssize_t etsec_rx_ring_write(eTSEC *etsec, const uint8_t *buf, size_t size)
         return -1;
     }
 
-    if ((etsec->regs[RCTRL].value & RCTRL_RSF) && (size < 60)) {
+    if (!(etsec->regs[RCTRL].value & RCTRL_RSF) && (size < 60)) {
         /* CRC is not in the packet yet, so short frame is below 60 bytes */
         RING_DEBUG("%s: Drop short frame\n", __func__);
         return -1;
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PULL 19/19] target/ppc: Add E500 L2CSR0 write helper
  2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
                   ` (17 preceding siblings ...)
  2021-02-10  6:17 ` [PULL 18/19] hw/net: fsl_etsec: Reverse the RCTRL.RSF logic David Gibson
@ 2021-02-10  6:17 ` David Gibson
  2021-02-10 15:42 ` [PULL 00/19] ppc-for-6.0 queue 20210210 Peter Maydell
  19 siblings, 0 replies; 21+ messages in thread
From: David Gibson @ 2021-02-10  6:17 UTC (permalink / raw)
  To: peter.maydell, groug; +Cc: Bin Meng, qemu-ppc, qemu-devel, David Gibson

From: Bin Meng <bin.meng@windriver.com>

Per EREF 2.0 [1] chapter 3.11.2:

The following bits in L2CSR0 (exists in the e500mc/e5500/e6500 core):

- L2FI  (L2 cache flash invalidate)
- L2FL  (L2 cache flush)
- L2LFC (L2 cache lock flash clear)

when set, a cache operation is initiated by hardware, and these bits
will be cleared when the operation is complete.

Since we don't model cache in QEMU, let's add a write helper to emulate
the cache operations completing instantly.

[1] https://www.nxp.com/files-static/32bit/doc/ref_manual/EREFRM.pdf

Signed-off-by: Bin Meng <bin.meng@windriver.com>

Message-Id: <1612925152-20913-1-git-send-email-bmeng.cn@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 target/ppc/cpu.h                |  6 ++++++
 target/ppc/translate_init.c.inc | 16 ++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index cb00210288..e73416da68 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -1919,6 +1919,7 @@ typedef PowerPCCPU ArchCPU;
 #define SPR_750FX_HID2        (0x3F8)
 #define SPR_Exxx_L1FINV0      (0x3F8)
 #define SPR_L2CR              (0x3F9)
+#define SPR_Exxx_L2CSR0       (0x3F9)
 #define SPR_L3CR              (0x3FA)
 #define SPR_750_TDCH          (0x3FA)
 #define SPR_IABR2             (0x3FA)
@@ -1974,6 +1975,11 @@ typedef PowerPCCPU ArchCPU;
 #define   L1CSR1_ICFI   0x00000002  /* Instruction Cache Flash Invalidate */
 #define   L1CSR1_ICE    0x00000001  /* Instruction Cache Enable */
 
+/* E500 L2CSR0 */
+#define E500_L2CSR0_L2FI    (1 << 21)   /* L2 cache flash invalidate */
+#define E500_L2CSR0_L2FL    (1 << 11)   /* L2 cache flush */
+#define E500_L2CSR0_L2LFC   (1 << 10)   /* L2 cache lock flash clear */
+
 /* HID0 bits */
 #define HID0_DEEPNAP        (1 << 24)           /* pre-2.06 */
 #define HID0_DOZE           (1 << 23)           /* pre-2.06 */
diff --git a/target/ppc/translate_init.c.inc b/target/ppc/translate_init.c.inc
index 9867d0a6e4..3ec45cbc19 100644
--- a/target/ppc/translate_init.c.inc
+++ b/target/ppc/translate_init.c.inc
@@ -1735,6 +1735,16 @@ static void spr_write_e500_l1csr1(DisasContext *ctx, int sprn, int gprn)
     tcg_temp_free(t0);
 }
 
+static void spr_write_e500_l2csr0(DisasContext *ctx, int sprn, int gprn)
+{
+    TCGv t0 = tcg_temp_new();
+
+    tcg_gen_andi_tl(t0, cpu_gpr[gprn],
+                    ~(E500_L2CSR0_L2FI | E500_L2CSR0_L2FL | E500_L2CSR0_L2LFC));
+    gen_store_spr(sprn, t0);
+    tcg_temp_free(t0);
+}
+
 static void spr_write_booke206_mmucsr0(DisasContext *ctx, int sprn, int gprn)
 {
     gen_helper_booke206_tlbflush(cpu_env, cpu_gpr[gprn]);
@@ -5029,6 +5039,12 @@ static void init_proc_e500(CPUPPCState *env, int version)
                  SPR_NOACCESS, SPR_NOACCESS,
                  &spr_read_generic, &spr_write_e500_l1csr1,
                  0x00000000);
+    if (version != fsl_e500v1 && version != fsl_e500v2) {
+        spr_register(env, SPR_Exxx_L2CSR0, "L2CSR0",
+                     SPR_NOACCESS, SPR_NOACCESS,
+                     &spr_read_generic, &spr_write_e500_l2csr0,
+                     0x00000000);
+    }
     spr_register(env, SPR_BOOKE_MCSRR0, "MCSRR0",
                  SPR_NOACCESS, SPR_NOACCESS,
                  &spr_read_generic, &spr_write_generic,
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PULL 00/19] ppc-for-6.0 queue 20210210
  2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
                   ` (18 preceding siblings ...)
  2021-02-10  6:17 ` [PULL 19/19] target/ppc: Add E500 L2CSR0 write helper David Gibson
@ 2021-02-10 15:42 ` Peter Maydell
  19 siblings, 0 replies; 21+ messages in thread
From: Peter Maydell @ 2021-02-10 15:42 UTC (permalink / raw)
  To: David Gibson; +Cc: qemu-ppc, Greg Kurz, QEMU Developers

On Wed, 10 Feb 2021 at 06:17, David Gibson <david@gibson.dropbear.id.au> wrote:
>
> The following changes since commit 1214d55d1c41fbab3a9973a05085b8760647e411:
>
>   Merge remote-tracking branch 'remotes/nvme/tags/nvme-next-pull-request' into staging (2021-02-09 13:24:37 +0000)
>
> are available in the Git repository at:
>
>   https://gitlab.com/dgibson/qemu.git tags/ppc-for-6.0-20210210
>
> for you to fetch changes up to 298091f831db1a8f360686369f9760849e90dd03:
>
>   target/ppc: Add E500 L2CSR0 write helper (2021-02-10 14:50:11 +1100)
>
> ----------------------------------------------------------------
> ppc patch queue for 20201-02-10
>
> Here's the latest batch of patches for the ppc target and machine
> types.  Highlights are:
>  * Several fixes for E500 from Bin Meng
>  * Fixes and cleanups for PowerNV from Cédric Le Goater
>  * Assorted other fixes and cleanups
>
> ----------------------------------------------------------------


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/6.0
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2021-02-10 15:43 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-10  6:17 [PULL 00/19] ppc-for-6.0 queue 20210210 David Gibson
2021-02-10  6:17 ` [PULL 01/19] spapr.c: use g_auto* with 'nodename' in CPU DT functions David Gibson
2021-02-10  6:17 ` [PULL 02/19] spapr.c: add 'name' property for hotplugged CPUs nodes David Gibson
2021-02-10  6:17 ` [PULL 03/19] spapr: Adjust firmware path of PCI devices David Gibson
2021-02-10  6:17 ` [PULL 04/19] target/ppc: Remove unused MMU definitions David Gibson
2021-02-10  6:17 ` [PULL 05/19] ppc/pnv: Add trace events for PCI event notification David Gibson
2021-02-10  6:17 ` [PULL 06/19] ppc/xive: Add firmware bit when dumping the ENDs David Gibson
2021-02-10  6:17 ` [PULL 07/19] ppc/pnv: Use skiboot addresses to load kernel and ramfs David Gibson
2021-02-10  6:17 ` [PULL 08/19] ppc/pnv: Simplify pnv_bmc_create() David Gibson
2021-02-10  6:17 ` [PULL 09/19] ppc/pnv: Discard internal BMC initialization when BMC is external David Gibson
2021-02-10  6:17 ` [PULL 10/19] ppc/pnv: Remove default disablement of the PNOR contents David Gibson
2021-02-10  6:17 ` [PULL 11/19] ppc/pnv: Introduce a LPC FW memory region attribute to map the PNOR David Gibson
2021-02-10  6:17 ` [PULL 12/19] spapr: move spapr_machine_using_legacy_numa() to spapr_numa.c David Gibson
2021-02-10  6:17 ` [PULL 13/19] spapr_numa.c: create spapr_numa_initial_nvgpu_numa_id() helper David Gibson
2021-02-10  6:17 ` [PULL 14/19] spapr_numa.c: fix ibm, max-associativity-domains calculation David Gibson
2021-02-10  6:17 ` [PULL 15/19] ppc/pnv: Set default RAM size to 1 GB David Gibson
2021-02-10  6:17 ` [PULL 16/19] hw/ppc: e500: Use a macro for the platform clock frequency David Gibson
2021-02-10  6:17 ` [PULL 17/19] hw/ppc: e500: Fill in correct <clock-frequency> for the serial nodes David Gibson
2021-02-10  6:17 ` [PULL 18/19] hw/net: fsl_etsec: Reverse the RCTRL.RSF logic David Gibson
2021-02-10  6:17 ` [PULL 19/19] target/ppc: Add E500 L2CSR0 write helper David Gibson
2021-02-10 15:42 ` [PULL 00/19] ppc-for-6.0 queue 20210210 Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.