From nobody Wed Nov 5 05:12:30 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1532702414353503.39308965265957; Fri, 27 Jul 2018 07:40:14 -0700 (PDT) Received: from localhost ([::1]:41596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fj3uX-0004Pc-KK for importer@patchew.org; Fri, 27 Jul 2018 10:40:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fj3sH-0003F8-GU for qemu-devel@nongnu.org; Fri, 27 Jul 2018 10:37:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fj3sG-0008IN-EZ for qemu-devel@nongnu.org; Fri, 27 Jul 2018 10:37:45 -0400 Received: from greensocs.com ([193.104.36.180]:50603) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fj3sB-0008AZ-GM; Fri, 27 Jul 2018 10:37:39 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id AD592428994; Fri, 27 Jul 2018 16:37:31 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JNZQXAzkuP4F; Fri, 27 Jul 2018 16:37:30 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id CDEC64434B9; Fri, 27 Jul 2018 16:37:30 +0200 (CEST) Received: from kouign-amann.hive.antfield.fr (antfield.tima.u-ga.fr [147.171.129.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: damien.hedde@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 56F1C42899A; Fri, 27 Jul 2018 16:37:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1532702251; bh=LGDNDsuRp4qjQNaH95Al+G0mu5NCl3tzJ7GidKARFAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=4BrV7Lj43D6iSISUgq2dEmXbyhQsu5n6qXg+eNx8z26qYAcPuJ6zGocx4b/Vykh5h dgRKsy9JAjKvnN+4iKQfElTPL2bKJkAXvlNNhxue5dgnsTG5UDi2P+jiGWO5/KyqYm LF4bupL+M90rnwxAC3oevmvW18mITltQNDWKNp+g= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=NdNCrU8w; dkim=pass (1024-bit key) header.d=greensocs.com header.b=NdNCrU8w DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1532702250; bh=LGDNDsuRp4qjQNaH95Al+G0mu5NCl3tzJ7GidKARFAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NdNCrU8wCoxsgDEuV+l+RUkKqcepA0YyGmZ6XwPFnMK45+HQGNi32DLwIsAe5h1nP oNPkCqylF0hQ+UumaX0Nvx2frtVLLmbK9pASpzqyb8W2ImDMUpitosLtO7mA/jKlhk 4eCdf5rFJ373Mv7wIQR8mxbfNyqgABpeJvIg0UGY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1532702250; bh=LGDNDsuRp4qjQNaH95Al+G0mu5NCl3tzJ7GidKARFAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NdNCrU8wCoxsgDEuV+l+RUkKqcepA0YyGmZ6XwPFnMK45+HQGNi32DLwIsAe5h1nP oNPkCqylF0hQ+UumaX0Nvx2frtVLLmbK9pASpzqyb8W2ImDMUpitosLtO7mA/jKlhk 4eCdf5rFJ373Mv7wIQR8mxbfNyqgABpeJvIg0UGY= From: Damien Hedde To: qemu-devel@nongnu.org Date: Fri, 27 Jul 2018 16:37:22 +0200 Message-Id: <09041c553fbe1d78bf282513bffdb981e7a1d201.1532701430.git.damien.hedde@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [RFC PATCH 3/6] sysbus: Specialize gating_update to enable/disable memory regions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: edgar.iglesias@xilinx.com, peter.maydell@linaro.org, alistair@alistair23.me, mark.burton@greensocs.com, saipava@xilinx.com, qemu-arm@nongnu.org, Damien Hedde , pbonzini@redhat.com, luc.michel@greensocs.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The default methods are overriden to add the activation/deactivation of the memory regions according to the gating state: Regions are enabled only when powered and clocked. As powering-up triggers a reset call, memory regions should be reset in specialized sysbus devices. Signed-off-by: Damien Hedde --- include/hw/sysbus.h | 3 +++ hw/core/sysbus.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h index 0b59a3b8d6..e17165e78f 100644 --- a/include/hw/sysbus.h +++ b/include/hw/sysbus.h @@ -59,6 +59,9 @@ typedef struct SysBusDeviceClass { */ char *(*explicit_ofw_unit_address)(const SysBusDevice *dev); void (*connect_irq_notifier)(SysBusDevice *dev, qemu_irq irq); + + DeviceGatingUpdate parent_power_update; + DeviceGatingUpdate parent_clock_update; } SysBusDeviceClass; =20 struct SysBusDevice { diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 3c8e53b188..4a2dfbe907 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -325,6 +325,39 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev) return get_system_memory(); } =20 +/* + * Action take on power or clock update. + */ +static void sysbus_device_gating_update(DeviceState *dev) +{ + SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); + int i; + + for (i =3D 0;; i++) { + MemoryRegion *mr =3D sysbus_mmio_get_region(sbd, i); + if (!mr) { + break; + } + memory_region_set_enabled(mr, dev->powered && dev->clocked); + } +} + +/* + * Action take on power update. + * + * Call parent method before doing local action. + * So that we override any action taken in parent method (eg if reset + * is called due to leaving OFF state) + */ +static void sysbus_device_power_update(DeviceState *dev) +{ + SysBusDeviceClass *sbdk =3D SYS_BUS_DEVICE_GET_CLASS(dev); + + sbdk->parent_power_update(dev); + + sysbus_device_gating_update(dev); +} + static void sysbus_device_class_init(ObjectClass *klass, void *data) { DeviceClass *k =3D DEVICE_CLASS(klass); @@ -341,6 +374,12 @@ static void sysbus_device_class_init(ObjectClass *klas= s, void *data) * subclass needs to override it and set user_creatable=3Dtrue. */ k->user_creatable =3D false; + + SysBusDeviceClass *sbdk =3D SYS_BUS_DEVICE_CLASS(klass); + device_class_set_parent_power_update(k, + sysbus_device_power_update, &sbdk->parent_power_update); + device_class_set_parent_clock_update(k, + sysbus_device_gating_update, &sbdk->parent_clock_update); } =20 static const TypeInfo sysbus_device_type_info =3D { --=20 2.18.0