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 007BEC00140 for ; Mon, 8 Aug 2022 17:28:02 +0000 (UTC) Received: from localhost ([::1]:34782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oL6Xp-0004an-RU for qemu-devel@archiver.kernel.org; Mon, 08 Aug 2022 13:28:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oL6Vi-000269-Ip; Mon, 08 Aug 2022 13:25:51 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:37841) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oL6Ve-0005fg-EV; Mon, 08 Aug 2022 13:25:49 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id BA7A57475F9; Mon, 8 Aug 2022 19:25:40 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 4883F746FDE; Mon, 8 Aug 2022 19:25:40 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 46EA9745702; Mon, 8 Aug 2022 19:25:40 +0200 (CEST) Date: Mon, 8 Aug 2022 19:25:40 +0200 (CEST) From: BALATON Zoltan To: Peter Maydell cc: =?ISO-8859-15?Q?C=E9dric_Le_Goater?= , qemu-ppc@nongnu.org, Daniel Henrique Barboza , qemu-devel@nongnu.org Subject: Re: [PATCH v3 07/22] ppc/ppc405: QOM'ify CPU In-Reply-To: Message-ID: References: <20220808102734.133084-1-clg@kaod.org> <20220808102734.133084-8-clg@kaod.org> <2499ab9-44e8-a33f-5f4-74a1d7ad3e7@eik.bme.hu> <4cdc4026-78c5-e617-c74c-3ee5aa5d44d3@kaod.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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" On Mon, 8 Aug 2022, Peter Maydell wrote: > On Mon, 8 Aug 2022 at 18:05, BALATON Zoltan wrote: >> But the handler we register here just calls cpu_reset which seems to just >> call the reset method of the CPU object. If we have nothing else to do >> here do we need to explicitly call cpi_reset like this? Wouldn't the CPU >> object be reset by qdev when resetting the machine or the soc its in? If >> we have our own reset method we may call cpu_reset from there to make sure >> the CPU is in a known state but is this needed when we don't want to do >> anything else? I don't know how reset handling works but some machines >> seems to do this and others don't. > > You do unfortunately need to manually reset the CPU object. This is > because the 'automatic' qdev reset only works for devices that hang > off a bus (including sysbus devices). This is because it works by > having qdev_machine_creation_done() register a reset function which > does "reset the sysbus". Resetting a bus resets every device on it. > Resetting a device resets every bus it owns. (This means that for > instance PCI devices get reset because the PCI controller is on the > sysbus, so it gets reset, and it owns the PCI bus, so the PCI bus > resets when the controller is reset, and when the PCI bus resets > then all the devices on it are reset.) So reset propagates down > the bus tree, but it won't reach devices which aren't on that bus > tree at all. The most common case of "device which isn't on a bus" > is the CPU objects. > > This is, clearly, a complete mess. I would strongly like to sort it > out, but to do that we need (a) a plan for what reset handling ought > to look like and (b) a transition plan for getting from here to there > without breaking everything in the process. I haven't had the time > to focus on that, though it's been nominally on my todo list for years. > > In the meantime, it's the responsibility of something in architecture > specific code to arrange for the CPU objects to be reset -- whether > that's done directly by the board, or hidden in some other layer > of code, depends on the target arch. For instance for arm it's > hidden inside arm_load_kernel() and board models must therefore > call that function even if they have no intention of supporting > loading Linux kernels. For sparc it's done directly in the board code. OK thanks for the clarification. Both bamboo and sam460ex has a main_cpu_reset function that is registered from the machine init func which calls cpu_reset. Maybe 405 boards could do the same for consistency? It could also be added to the soc object's reset method as that owns the cpu so maybe it may make more sense that way. This is probably also OK as 440 machines don't have soc object yet so it wouldn't cause any problems. I think the ppc4xx_reset func was kept around because ppc4xx_init was also kept but nothing else seems to use it so maybe these should become the soc object's realize and reset methods and drop the current ppc4xx_init and reset funcs? Regards, BALATON Zoltan