qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v10 2/9] fw_cfg: Refactor extra pci roots addition


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v10 2/9] fw_cfg: Refactor extra pci roots addition
Date: Fri, 6 Dec 2024 16:32:50 +0100
User-agent: Mozilla Thunderbird

On 19/11/20 02:48, Jiahui Cen wrote:
Extract extra pci roots addition from pc machine, which could be used by
other machines.

In order to make uefi get the extra roots, it is necessary to write extra
roots into fw_cfg. And only if the uefi knows there are extra roots,
the config spaces of devices behind the root could be obtained.

Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
Signed-off-by: Yubo Miao <miaoyubo@huawei.com>
---
  hw/i386/pc.c              | 18 +--------------
  hw/nvram/fw_cfg.c         | 23 ++++++++++++++++++++
  include/hw/nvram/fw_cfg.h |  9 ++++++++
  3 files changed, 33 insertions(+), 17 deletions(-)


diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 08539a1aab..282ba93e2e 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -40,6 +40,7 @@
  #include "qemu/cutils.h"
  #include "qapi/error.h"
  #include "hw/acpi/aml-build.h"
+#include "hw/pci/pci_bus.h"

Stumbling at this (now merged as commit 0abd38885ac), not
sure how we let PCI stuff mixed within this generic device.
We have TYPE_FW_CFG_DATA_GENERATOR_INTERFACE to avoid that.

  #define FW_CFG_FILE_SLOTS_DFLT 0x20
@@ -1061,6 +1062,28 @@ bool fw_cfg_add_from_generator(FWCfgState *s, const char *filename,
      return true;
  }
+void fw_cfg_add_extra_pci_roots(PCIBus *bus, FWCfgState *s)
+{
+    int extra_hosts = 0;
+
+    if (!bus) {
+        return;
+    }
+
+    QLIST_FOREACH(bus, &bus->child, sibling) {
+        /* look for expander root buses */
+        if (pci_bus_is_root(bus)) {
+            extra_hosts++;
+        }
+    }
+
+    if (extra_hosts && s) {
+        uint64_t *val = g_malloc(sizeof(*val));
+        *val = cpu_to_le64(extra_hosts);
+        fw_cfg_add_file(s, "etc/extra-pci-roots", val, sizeof(*val));
+    }
+}
+
  static void fw_cfg_machine_reset(void *opaque)
  {
      MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());



reply via email to

[Prev in Thread] Current Thread [Next in Thread]