From patchwork Mon Jan 2 11:52:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 13086720 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E34FAC46467 for ; Mon, 2 Jan 2023 11:55:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCJNE-0007F2-4l; Mon, 02 Jan 2023 06:53:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCJNC-0007ET-7P for qemu-devel@nongnu.org; Mon, 02 Jan 2023 06:52:58 -0500 Received: from mail-oa1-x33.google.com ([2001:4860:4864:20::33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pCJNA-0002uz-M7 for qemu-devel@nongnu.org; Mon, 02 Jan 2023 06:52:57 -0500 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-14fb3809eaeso27452690fac.1 for ; Mon, 02 Jan 2023 03:52:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IU6x7WVTw6l9F2GnZ9QyTDYaXQmzpFAwXIcNmwcVoDs=; b=KcGxxWGt0kgajXe04hoEALoyXpUhf1zbWurOwPWAu561KUEuA3I5BoUGoLT9pxR5K2 SLo4wSYqyAOMU16zB0gSnE6lze0o2QZW48nhSjj9BPn2TcNnJlzftWnZfYDzN2kb5Ca2 dp4Y9CNnmezs7DcmDnNBZEWIos4nD6lCwFDVoeP9iYp1EaaoqA4h3Zgikw/0nQz2J7Ad JlgBMemK0azbsVqw0U/5jAZhGdVo9PQEqAOV74ZOxn91xnuoSdstPw9xZoOHSDo4lndS 0PHXFGktLxm6oHP89w493tKSPfjYbMOKa81ai7xfKXXxftpHFfnx3sDfYQQdwesWY2pr Si2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IU6x7WVTw6l9F2GnZ9QyTDYaXQmzpFAwXIcNmwcVoDs=; b=zV6RsaB4xhI59MIC+519EiUiLSKjB46E7IZO0Ezzj8ZBmRd0Q0B/cMrww4ljZwOc/h +Ar5WdxjUIbDLYq8F7Au3RSXbbwTFiZuAHSPOabCSwfzLcokXhnsBQNEEFm4K+QB4AJE t4VveH2YNHZLsBalEM09iEAxdZL5ODv3tcMrjtbITntK6Sak2C1nGPF5+ug64+cxKP9w BlejV8u3d2E1O9DbEvNN2RnD2WtirV2q4V6DZsG/p7Hno6WL5koIamO77vUflWhaNSJu ++72E9lE78PYG8AWHnxr3PDSpMLxya5mdqQp/+K5Ww4i/2vMkJWTQQypt5Dv5gmaD+LJ mnMw== X-Gm-Message-State: AFqh2ko2wJVIM8P+FPy3EYAaLs/JFesb2YegsBf1F/JXRNL54vXNWFQC ++2Y8Ok1siVK65YeNVImzu8lhsYzd3XrRzbg X-Google-Smtp-Source: AMrXdXvJPOxxMD2bh6SWO6mwoBQnqxpRYNL9EVZ1Vkh5hqDQSn5f5T1ekXrdJ+EYvrT6p/PqBP3w5Q== X-Received: by 2002:a05:6870:7e02:b0:14f:eee9:d20a with SMTP id wx2-20020a0568707e0200b0014feee9d20amr11072926oab.11.1672660375265; Mon, 02 Jan 2023 03:52:55 -0800 (PST) Received: from grind.. ([191.17.222.139]) by smtp.gmail.com with ESMTPSA id l39-20020a05687106a700b0014fb4bdc746sm11354475oao.8.2023.01.02.03.52.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Jan 2023 03:52:54 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, Daniel Henrique Barboza , Bin Meng , Palmer Dabbelt , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng Subject: [PATCH v5 03/11] hw/riscv/sifive_u: use 'fdt' from MachineState Date: Mon, 2 Jan 2023 08:52:33 -0300 Message-Id: <20230102115241.25733-4-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230102115241.25733-1-dbarboza@ventanamicro.com> References: <20230102115241.25733-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::33; envelope-from=dbarboza@ventanamicro.com; helo=mail-oa1-x33.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The MachineState object provides a 'fdt' pointer that is already being used by other RISC-V machines, and it's also used by the 'dumpdtb' QMP command. Remove the 'fdt' pointer from SiFiveUState and use MachineState::fdt instead. Cc: Palmer Dabbelt Signed-off-by: Daniel Henrique Barboza Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Reviewed-by: Bin Meng --- hw/riscv/sifive_u.c | 15 ++++++--------- include/hw/riscv/sifive_u.h | 3 --- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index a58ddb36ac..ddceb750ea 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -98,7 +98,7 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap, { MachineState *ms = MACHINE(qdev_get_machine()); void *fdt; - int cpu; + int cpu, fdt_size; uint32_t *cells; char *nodename; uint32_t plic_phandle, prci_phandle, gpio_phandle, phandle = 1; @@ -112,14 +112,14 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap, }; if (ms->dtb) { - fdt = s->fdt = load_device_tree(ms->dtb, &s->fdt_size); + fdt = ms->fdt = load_device_tree(ms->dtb, &fdt_size); if (!fdt) { error_report("load_device_tree() failed"); exit(1); } goto update_bootargs; } else { - fdt = s->fdt = create_device_tree(&s->fdt_size); + fdt = ms->fdt = create_device_tree(&fdt_size); if (!fdt) { error_report("create_device_tree() failed"); exit(1); @@ -612,9 +612,9 @@ static void sifive_u_machine_init(MachineState *machine) hwaddr end = riscv_load_initrd(machine->initrd_filename, machine->ram_size, kernel_entry, &start); - qemu_fdt_setprop_cell(s->fdt, "/chosen", + qemu_fdt_setprop_cell(machine->fdt, "/chosen", "linux,initrd-start", start); - qemu_fdt_setprop_cell(s->fdt, "/chosen", "linux,initrd-end", + qemu_fdt_setprop_cell(machine->fdt, "/chosen", "linux,initrd-end", end); } } else { @@ -627,14 +627,11 @@ static void sifive_u_machine_init(MachineState *machine) /* Compute the fdt load address in dram */ fdt_load_addr = riscv_load_fdt(memmap[SIFIVE_U_DEV_DRAM].base, - machine->ram_size, s->fdt); + machine->ram_size, machine->fdt); if (!riscv_is_32bit(&s->soc.u_cpus)) { start_addr_hi32 = (uint64_t)start_addr >> 32; } - /* Set machine->fdt for 'dumpdtb' QMP/HMP command */ - machine->fdt = s->fdt; - /* reset vector */ uint32_t reset_vec[12] = { s->msel, /* MSEL pin state */ diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index e680d61ece..4a8828a30e 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -67,9 +67,6 @@ typedef struct SiFiveUState { /*< public >*/ SiFiveUSoCState soc; - void *fdt; - int fdt_size; - bool start_in_flash; uint32_t msel; uint32_t serial;