From mboxrd@z Thu Jan 1 00:00:00 1970 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 9A97AEB64DC for ; Mon, 3 Jul 2023 07:47:12 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGEGw-00057s-A5; Mon, 03 Jul 2023 03:46:58 -0400 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 1qGEGp-00056d-GZ for qemu-devel@nongnu.org; Mon, 03 Jul 2023 03:46:51 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGEGn-0007dk-2r for qemu-devel@nongnu.org; Mon, 03 Jul 2023 03:46:51 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3fbc0981756so38329675e9.0 for ; Mon, 03 Jul 2023 00:46:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688370407; x=1690962407; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=lIPJH8PZ+Te67CPqFmwDLk0RADZV744C10qjFrgmkNg=; b=m1dHfzhoGSQq9N8FUvmV51aWQye4n7mOu4qzHWG14R7hhQOf2fhGarvcsGc4CSBTi5 7lxUPyyJ6OAVLZ6P48eW3Sl2lPGKeQ9pU07/hBmNC8pHLtXJ7NRNq0I79I4qI4xOS2qx rudj0tZEZ4JC/Fk9dT61rQbaEIM1TH297lzN0MB9mvAYCL8eRAkLddiyCmjl5CNGNNMf o7LRrM2mlwWbkT6kuyBvR/wNmes+V4DgRjHrl79WKj/QQp8Sq6dCQnEM+smu/O975N1H 54t1hYSe+DrYuDERKfkflp80tITHEG1z1gCBIWfcQv4GRDsHrS0XAF7MkP2RWTRtT8V0 0lHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688370407; x=1690962407; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lIPJH8PZ+Te67CPqFmwDLk0RADZV744C10qjFrgmkNg=; b=TSBe49SMuxUdHu1d6+YqilWPG5MJYjeOnPWEl3aSnw7n0pfHjn1Svu0T3l4vNR+Sz/ ozvM1qBFTETAlfXM16S7awpj4E+Iw0o9Yq2SouOAckhACLTxNit7uIRRstOOnMaHVUgQ m/3mWGtsWYyRyazqxQ6mgT39DcVGV/InV2VxbQcgjry7HA2oOh/pxZPtFNbn8KR0+3eq SQx+Pd0EKJdtAxBDwze5a4qDk7oyyb35aNvMpU/2DiOG2symUPvUSAcxHPSXVf7ekels YRCFV9eaIpnIPFdTCGqx5+sF9I2AXNPEFh3d9HWMElZUiLY2Ua1hqkP/GTdoO0ungLxk 9WUg== X-Gm-Message-State: ABy/qLZjOU5J6s/ssFDHTSoZ7zS6k11UYeBXolGDOx27TcOCyZcynBAw PyU4bcskQ/Nz25K/LsBc7vlWGg== X-Google-Smtp-Source: APBJJlGs2SXEv92kxuNpdYVf4HgnNBc5I+Aqs7IhtjaYOKdOIy4vtuOxoFVWZitB+eXDCLbJ9+FE1Q== X-Received: by 2002:adf:fe85:0:b0:2d1:3eb9:c3c2 with SMTP id l5-20020adffe85000000b002d13eb9c3c2mr6938589wrr.54.1688370407478; Mon, 03 Jul 2023 00:46:47 -0700 (PDT) Received: from [192.168.69.115] ([176.176.178.91]) by smtp.gmail.com with ESMTPSA id e1-20020a5d5941000000b00313e59cb371sm23515317wri.12.2023.07.03.00.46.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Jul 2023 00:46:47 -0700 (PDT) Message-ID: Date: Mon, 3 Jul 2023 09:46:43 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH] riscv: Generate devicetree only after machine initialization is complete Content-Language: en-US To: Guenter Roeck , Palmer Dabbelt Cc: Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Alistair Francis , Aleksandar Rikalo , Alistair Francis , Bin Meng , Bin Meng , Jia Liu , Leif Lindholm , Marcin Juszkiewicz , Palmer Dabbelt , Palmer Dabbelt , Paul Burton , Peter Maydell , Radoslaw Biernacki , Song Gao , Stafford Horne , Weiwei Li , Xiaojuan Yang , qemu-arm@nongnu.org, Paolo Bonzini , Markus Armbruster References: <20230703034614.3909079-1-linux@roeck-us.net> From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= In-Reply-To: <20230703034614.3909079-1-linux@roeck-us.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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, NICE_REPLY_A=-0.09, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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 On 3/7/23 05:46, Guenter Roeck wrote: > If the devicetree is created before machine initialization is complete, > it misses dynamic devices. Specifically, the tpm device is not added > to the devicetree file and is therefore not instantiated in Linux. > Create devicetree in virt_machine_done() to solve the problem. This makes sense, but what about the other archs/machines? Shouldn't we fix this generically? > Cc: Alistair Francis > Fixes: 325b7c4e75 hw/riscv: Enable TPM backends > Signed-off-by: Guenter Roeck > --- > hw/riscv/virt.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c > index ed4c27487e..08876284f5 100644 > --- a/hw/riscv/virt.c > +++ b/hw/riscv/virt.c > @@ -1248,6 +1248,11 @@ static void virt_machine_done(Notifier *notifier, void *data) > uint64_t kernel_entry = 0; > BlockBackend *pflash_blk0; > > + /* create devicetree if not provided */ > + if (!machine->dtb) { > + create_fdt(s, memmap); > + } > + > /* > * Only direct boot kernel is currently supported for KVM VM, > * so the "-bios" parameter is not supported when KVM is enabled. > @@ -1508,15 +1513,13 @@ static void virt_machine_init(MachineState *machine) > } > virt_flash_map(s, system_memory); > > - /* load/create device tree */ > + /* load device tree */ > if (machine->dtb) { > machine->fdt = load_device_tree(machine->dtb, &s->fdt_size); > if (!machine->fdt) { > error_report("load_device_tree() failed"); > exit(1); > } > - } else { > - create_fdt(s, memmap); > } > > s->machine_done.notify = virt_machine_done;