From: Alexander Graf <agraf@suse.de>
To: "qemu-ppc@nongnu.org list:PowerPC" <qemu-ppc@nongnu.org>
Cc: Blue Swirl <blauwirbel@gmail.com>,
Anthony Liguori <aliguori@us.ibm.com>,
qemu-devel Developers <qemu-devel@nongnu.org>,
Aurelien Jarno <aurelien@aurel32.net>
Subject: [Qemu-devel] [PULL 01/18] PPC: E500: Generate device tree on reset
Date: Mon, 2 Sep 2013 10:11:16 +0200 [thread overview]
Message-ID: <1378109493-41076-2-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1378109493-41076-1-git-send-email-agraf@suse.de>
Today we generate the device tree once on machine initialization and then
store the finalized blob in memory to reload it on reset.
This is bad for 2 reasons. First we potentially waste a bunch of RAM for no
good reason, as we have all information required to regenerate the device
tree available anyways.
The second reason is even more important. On machine init when we generate
the device tree for the first time, we don't have all of the devices fully
initialized yet. But the device tree needs to potentially walk devices to
put information about them into the device tree.
Move the generation into a reset function. That way we just generate it new
every time we reset, solving both of the above issues.
Signed-off-by: Alexander Graf <agraf@suse.de>
---
hw/ppc/e500.c | 52 +++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 43 insertions(+), 9 deletions(-)
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index e79612b..9059ff9 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -123,13 +123,14 @@ static void dt_serial_create(void *fdt, unsigned long long offset,
}
}
-static int ppce500_load_device_tree(CPUPPCState *env,
- QEMUMachineInitArgs *args,
+static int ppce500_load_device_tree(QEMUMachineInitArgs *args,
PPCE500Params *params,
hwaddr addr,
hwaddr initrd_base,
- hwaddr initrd_size)
+ hwaddr initrd_size,
+ bool dry_run)
{
+ CPUPPCState *env = first_cpu->env_ptr;
int ret = -1;
uint64_t mem_reg_property[] = { 0, cpu_to_be64(args->ram_size) };
int fdt_size;
@@ -369,12 +370,10 @@ static int ppce500_load_device_tree(CPUPPCState *env,
}
done:
- qemu_devtree_dumpdtb(fdt, fdt_size);
- ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
- if (ret < 0) {
- goto out;
+ if (!dry_run) {
+ qemu_devtree_dumpdtb(fdt, fdt_size);
+ cpu_physical_memory_write(addr, fdt, fdt_size);
}
- g_free(fdt);
ret = fdt_size;
out:
@@ -383,6 +382,41 @@ out:
return ret;
}
+typedef struct DeviceTreeParams {
+ QEMUMachineInitArgs args;
+ PPCE500Params params;
+ hwaddr addr;
+ hwaddr initrd_base;
+ hwaddr initrd_size;
+} DeviceTreeParams;
+
+static void ppce500_reset_device_tree(void *opaque)
+{
+ DeviceTreeParams *p = opaque;
+ ppce500_load_device_tree(&p->args, &p->params, p->addr, p->initrd_base,
+ p->initrd_size, false);
+}
+
+static int ppce500_prep_device_tree(QEMUMachineInitArgs *args,
+ PPCE500Params *params,
+ hwaddr addr,
+ hwaddr initrd_base,
+ hwaddr initrd_size)
+{
+ DeviceTreeParams *p = g_new(DeviceTreeParams, 1);
+ p->args = *args;
+ p->params = *params;
+ p->addr = addr;
+ p->initrd_base = initrd_base;
+ p->initrd_size = initrd_size;
+
+ qemu_register_reset(ppce500_reset_device_tree, p);
+
+ /* Issue the device tree loader once, so that we get the size of the blob */
+ return ppce500_load_device_tree(args, params, addr, initrd_base,
+ initrd_size, true);
+}
+
/* Create -kernel TLB entries for BookE. */
static inline hwaddr booke206_page_size_to_tlb(uint64_t size)
{
@@ -746,7 +780,7 @@ void ppce500_init(QEMUMachineInitArgs *args, PPCE500Params *params)
struct boot_info *boot_info;
int dt_size;
- dt_size = ppce500_load_device_tree(env, args, params, dt_base,
+ dt_size = ppce500_prep_device_tree(args, params, dt_base,
initrd_base, initrd_size);
if (dt_size < 0) {
fprintf(stderr, "couldn't load device tree\n");
--
1.8.1.4
next prev parent reply other threads:[~2013-09-02 8:11 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-02 8:11 [Qemu-devel] [PULL 00/18] ppc patch queue 2013-09-02 Alexander Graf
2013-09-02 8:11 ` Alexander Graf [this message]
2013-09-02 8:11 ` [Qemu-devel] [PULL 02/18] pseries: Fix stalls on hypervisor virtual console Alexander Graf
2013-09-02 8:11 ` [Qemu-devel] [PULL 03/18] target-ppc: USE LPCR_ILE to control exception endian on POWER7 Alexander Graf
2013-09-02 8:11 ` [Qemu-devel] [PULL 04/18] target-ppc: POWER7 supports the MSR_LE bit Alexander Graf
2013-09-02 8:11 ` [Qemu-devel] [PULL 05/18] disas/ppc.c: Fix little endian disassembly Alexander Graf
2013-09-02 8:11 ` [Qemu-devel] [PULL 06/18] ppc: virtex_ml507: QEMU_OPTION_dtb support for this machine Alexander Graf
2013-09-02 8:11 ` [Qemu-devel] [PULL 07/18] ppc405_boards: Disable debug output Alexander Graf
2013-09-02 8:11 ` [Qemu-devel] [PULL 08/18] ppc405_uc: " Alexander Graf
2013-09-02 8:11 ` [Qemu-devel] [PULL 09/18] ppc405_boards: Don't enforce presence of firmware for qtest Alexander Graf
2013-09-02 8:11 ` [Qemu-devel] [PULL 10/18] target-ppc: fix bit extraction for FPBF and FPL Alexander Graf
2013-09-02 8:11 ` [Qemu-devel] [PULL 11/18] spapr-pci: fix config space access to support bridges Alexander Graf
2013-09-02 8:11 ` [Qemu-devel] [PULL 12/18] target-ppc: Use #define instead of opencoding SLB valid bit Alexander Graf
2013-09-02 8:11 ` [Qemu-devel] [PULL 13/18] spapr-pci: rework MSI/MSIX Alexander Graf
2013-09-02 8:11 ` [Qemu-devel] [PULL 14/18] xics: move registration of global state to realize() Alexander Graf
2013-09-02 8:11 ` [Qemu-devel] [PULL 15/18] pseries: Add H_SET_MODE hcall to change guest exception endianness Alexander Graf
2013-09-02 8:11 ` [Qemu-devel] [PULL 16/18] PPC: KVM: Compile fix for qemu_notify_event Alexander Graf
2013-09-02 8:11 ` [Qemu-devel] [PULL 17/18] spapr: add "stop-self" RTAS call required to support hot CPU unplug Alexander Graf
2013-09-02 8:11 ` [Qemu-devel] [PULL 18/18] PPC: spapr: iommu: rework traces Alexander Graf
2013-09-03 6:13 ` [Qemu-devel] [PULL 00/18] ppc patch queue 2013-09-02 Aurelien Jarno
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1378109493-41076-2-git-send-email-agraf@suse.de \
--to=agraf@suse.de \
--cc=aliguori@us.ibm.com \
--cc=aurelien@aurel32.net \
--cc=blauwirbel@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).