From nobody Sat Nov 23 23:35:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1730641260; cv=none; d=zohomail.com; s=zohoarc; b=PdL5YKFrLRP1I453wCdpZ3DJSVfbNjCpmfw+xySJJ6HWjZ8h4Iax9cGQgSfGB9qM0RFSPIpq6pfljW+puiQc50KMlPvTD+KhEHtvf1Gl7sxDPvBDUacr4djJySNKhyL7aAdrYRReV8vtGcUMObFyhYU7xnr/xEEG7rA57scvPFE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730641260; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CdW4RukPeYbtzE571oJ5Ywld87248Qqc7eArKKusu5M=; b=EjMPJq0ben9ZqMK1t+Duzq32J+hcwhquse3INXDvIc5mOACZ2A5B1jPJPGKcIww04QU5mMWMIP3530sHtJVPzms9U/34L+tm/WwD+9DDzw2t6iO7Kg8pZQpIX4luPjshJjH11rejbzwgmhX/dg+/QjMJmjkv0XZRzn96+ez5GHA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730641260919275.8218015584864; Sun, 3 Nov 2024 05:41:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t7akx-0006GK-38; Sun, 03 Nov 2024 08:35:03 -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 1t7akq-0006BJ-Cj; Sun, 03 Nov 2024 08:34:57 -0500 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t7ako-0001F8-HS; Sun, 03 Nov 2024 08:34:55 -0500 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a9e8522c10bso161327866b.1; Sun, 03 Nov 2024 05:34:52 -0800 (PST) Received: from archlinux.. (pd9ed7f6d.dip0.t-ipconnect.de. [217.237.127.109]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9e5664350esm424328866b.159.2024.11.03.05.34.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Nov 2024 05:34:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730640891; x=1731245691; darn=nongnu.org; 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=CdW4RukPeYbtzE571oJ5Ywld87248Qqc7eArKKusu5M=; b=PTlpFZFR80O0XHcf9OcTnAgb9CJTAWFilBrEEaJjtXaaldmZxl+r2scDw7MlVd1Cqx sXPyeABX/qvf4ipKZ8DYN/j3ZLoQuh5AOZyiudy6K8RQZgx2nuiKsGU8hMyuA7PjDmkC 8JX1f9uFy9AyYJ+dD5X4USOayLQxiydf8cquk7vwSjCNWejcKrgKYHnQG5upYJZylY1Q dz3cEXzfU/5YXvhj65B/4GTmcRiFiyRxhro6l5MBLwKFjLCgn9q199FEpnzu7SA9uevr 9Dy7XeCcj1MgE9xrLtZ8YRbI3lR2GQ00JXx2NaQy4IfLPNFFakeVl3j7LBKxBfNQbpk3 99cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730640891; x=1731245691; 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=CdW4RukPeYbtzE571oJ5Ywld87248Qqc7eArKKusu5M=; b=BjLCsanlp6on//q6bsxpuhB+SzhuHUsmSKdXBCBNImL5H2Bga2YyitH/hXSVs34NRz 2gFNaHq2zOkpnkyf8DIeYrkvl8LfS95YYxQK+lkBQy2YvP47DiveU9Y3Pe5UN2oEjiJq SxQEbvcy9an9SwHdrIV9Hw7XKVWGz1g5j8M0CCo/ki9c1hejorGc1VFf4oEgkjXIBeg4 B40qm2Pqd8q9NS2UEjfgNwm7n90m+nDDWihEvZJZe0URQ62ojLulSCx19bLp4LiMglLa OvKyC7XRx7G9DF6WCD0vPHqzEzO2irJQ8UsgoLWHTTHbocfL7wbHau1KkmU3YqwezV9g MUEw== X-Forwarded-Encrypted: i=1; AJvYcCWWCMpl+zMX44e+y4i7hd66otarWx13eLZmTKESVjDhDAGd2dFptD4Yqv5bygHtestwIG9PHdxEsMCI@nongnu.org, AJvYcCWmxvxVZngq2rCWCKK6UzNSTrL4u+wGQ5to8eoa+NGL76EMtICSwWh6LnyBMOHaXX8+eLRnB2roccs=@nongnu.org X-Gm-Message-State: AOJu0YzNTSprYPj+7HjtuV8XBf4MfBnyvixRIo8O3d24qc72wdIYWDZ2 ZyY9UUOhBQY828lnCHXoXZZtRgx86R41eYV/ePEFJLXV/2jcDyPdB4GDiw== X-Google-Smtp-Source: AGHT+IGqK/4vu9rfQhq+xLQiXk8jzYoKDP8OSpCx8cF49FFD+92B8FCTFaak50T7pkxg3DreS+3y8A== X-Received: by 2002:a17:907:94cb:b0:a99:f94b:f92e with SMTP id a640c23a62f3a-a9e654924a6mr1024746966b.27.1730640890410; Sun, 03 Nov 2024 05:34:50 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Jason Wang , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , Hanna Reitz , Nicholas Piggin , Corey Minyard , Kevin Wolf , Bin Meng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Bernhard Beschow , qemu-block@nongnu.org, Alex Williamson , Daniel Henrique Barboza , BALATON Zoltan Subject: [PATCH v4 07/26] hw/ppc/e500: Use SysBusDevice API to access TYPE_CCSR's internal resources Date: Sun, 3 Nov 2024 14:33:53 +0100 Message-ID: <20241103133412.73536-8-shentey@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241103133412.73536-1-shentey@gmail.com> References: <20241103133412.73536-1-shentey@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=shentey@gmail.com; helo=mail-ej1-x62d.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1730641262549116600 Content-Type: text/plain; charset="utf-8" Rather than accessing the attributes of TYPE_CCSR directly, use the SysBusD= evice API which exists exactly for that purpose. Furthermore, registering the mem= ory region with the SysBusDevice API makes it show up in QMP's `info qom-tree` command. Reviewed-by: BALATON Zoltan Signed-off-by: Bernhard Beschow --- hw/pci-host/ppce500.c | 10 +++++----- hw/ppc/e500.c | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/pci-host/ppce500.c b/hw/pci-host/ppce500.c index 95b983b2b3..97e5d47cec 100644 --- a/hw/pci-host/ppce500.c +++ b/hw/pci-host/ppce500.c @@ -16,7 +16,6 @@ =20 #include "qemu/osdep.h" #include "hw/irq.h" -#include "hw/ppc/e500-ccsr.h" #include "hw/qdev-properties.h" #include "migration/vmstate.h" #include "hw/pci/pci_device.h" @@ -419,11 +418,12 @@ static const VMStateDescription vmstate_ppce500_pci = =3D { static void e500_pcihost_bridge_realize(PCIDevice *d, Error **errp) { PPCE500PCIBridgeState *b =3D PPC_E500_PCI_BRIDGE(d); - PPCE500CCSRState *ccsr =3D CCSR(container_get(qdev_get_machine(), - "/e500-ccsr")); + SysBusDevice *ccsr =3D SYS_BUS_DEVICE(container_get(qdev_get_machine(), + "/e500-ccsr")); + MemoryRegion *ccsr_space =3D sysbus_mmio_get_region(ccsr, 0); =20 - memory_region_init_alias(&b->bar0, OBJECT(ccsr), "e500-pci-bar0", &ccs= r->ccsr_space, - 0, int128_get64(ccsr->ccsr_space.size)); + memory_region_init_alias(&b->bar0, OBJECT(ccsr), "e500-pci-bar0", + ccsr_space, 0, int128_get64(ccsr_space->size)= ); pci_register_bar(d, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &b->bar0); } =20 diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 5d75a090ee..2849fba524 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -915,7 +915,6 @@ void ppce500_init(MachineState *machine) DriveInfo *dinfo; MemoryRegion *ccsr_addr_space; SysBusDevice *s; - PPCE500CCSRState *ccsr; I2CBus *i2c; =20 irqs =3D g_new0(IrqLines, smp_cpus); @@ -971,10 +970,10 @@ void ppce500_init(MachineState *machine) memory_region_add_subregion(address_space_mem, 0, machine->ram); =20 dev =3D qdev_new("e500-ccsr"); + s =3D SYS_BUS_DEVICE(dev); object_property_add_child(OBJECT(machine), "e500-ccsr", OBJECT(dev)); - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - ccsr =3D CCSR(dev); - ccsr_addr_space =3D &ccsr->ccsr_space; + sysbus_realize_and_unref(s, &error_fatal); + ccsr_addr_space =3D sysbus_mmio_get_region(s, 0); memory_region_add_subregion(address_space_mem, pmc->ccsrbar_base, ccsr_addr_space); =20 @@ -1262,6 +1261,7 @@ static void e500_ccsr_initfn(Object *obj) PPCE500CCSRState *ccsr =3D CCSR(obj); memory_region_init(&ccsr->ccsr_space, obj, "e500-ccsr", MPC8544_CCSRBAR_SIZE); + sysbus_init_mmio(SYS_BUS_DEVICE(ccsr), &ccsr->ccsr_space); } =20 static const TypeInfo e500_ccsr_info =3D { --=20 2.47.0