From nobody Thu May 2 04:04:12 2024 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.zoho.com; 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1497614784663454.67699219024644; Fri, 16 Jun 2017 05:06:24 -0700 (PDT) Received: from localhost ([::1]:58592 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLq17-0002i0-NU for importer@patchew.org; Fri, 16 Jun 2017 08:06:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLpzH-0001WN-7X for qemu-devel@nongnu.org; Fri, 16 Jun 2017 08:04:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dLpzE-0007bC-4d for qemu-devel@nongnu.org; Fri, 16 Jun 2017 08:04:27 -0400 Received: from chuckie.co.uk ([82.165.15.123]:52917 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dLpzD-0007Yq-TX for qemu-devel@nongnu.org; Fri, 16 Jun 2017 08:04:24 -0400 Received: from host109-151-5-7.range109-151.btcentralplus.com ([109.151.5.7] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1dLpzB-0003XB-Fh; Fri, 16 Jun 2017 13:04:22 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, lersek@redhat.com, somlo@cmu.edu, ehabkost@redhat.com, mst@redhat.com, pbonzini@redhat.com, rjones@redhat.com, peter.maydell@linaro.org Date: Fri, 16 Jun 2017 13:04:07 +0100 Message-Id: <1497614651-1017-2-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1497614651-1017-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1497614651-1017-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.151.5.7 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv3 1/5] fw_cfg: don't map the fw_cfg IO ports in fw_cfg_io_realize() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" As indicated by Laszlo it is a QOM bug for the realize() method to actually map the device. Set up the IO regions within fw_cfg_io_realize() and defer the mapping with sysbus_add_io() to the caller, as already done in fw_cfg_init_mem_wide(). This makes the iobase and dma_iobase properties now obsolete so they can be removed. Signed-off-by: Mark Cave-Ayland --- hw/nvram/fw_cfg.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 316fca9..70a0d5f 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -936,24 +936,30 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint3= 2_t dma_iobase, AddressSpace *dma_as) { DeviceState *dev; + SysBusDevice *sbd; + FWCfgIoState *ios; FWCfgState *s; uint32_t version =3D FW_CFG_VERSION; bool dma_requested =3D dma_iobase && dma_as; =20 dev =3D qdev_create(NULL, TYPE_FW_CFG_IO); - qdev_prop_set_uint32(dev, "iobase", iobase); - qdev_prop_set_uint32(dev, "dma_iobase", dma_iobase); if (!dma_requested) { qdev_prop_set_bit(dev, "dma_enabled", false); } =20 fw_cfg_init1(dev); + + sbd =3D SYS_BUS_DEVICE(dev); + ios =3D FW_CFG_IO(dev); + sysbus_add_io(sbd, iobase, &ios->comb_iomem); + s =3D FW_CFG(dev); =20 if (s->dma_enabled) { /* 64 bits for the address field */ s->dma_as =3D dma_as; s->dma_addr =3D 0; + sysbus_add_io(sbd, dma_iobase, &s->dma_iomem); =20 version |=3D FW_CFG_VERSION_DMA; } @@ -1059,8 +1065,6 @@ static void fw_cfg_file_slots_allocate(FWCfgState *s,= Error **errp) } =20 static Property fw_cfg_io_properties[] =3D { - DEFINE_PROP_UINT32("iobase", FWCfgIoState, iobase, -1), - DEFINE_PROP_UINT32("dma_iobase", FWCfgIoState, dma_iobase, -1), DEFINE_PROP_BOOL("dma_enabled", FWCfgIoState, parent_obj.dma_enabled, true), DEFINE_PROP_UINT16("x-file-slots", FWCfgIoState, parent_obj.file_slots, @@ -1071,7 +1075,6 @@ static Property fw_cfg_io_properties[] =3D { static void fw_cfg_io_realize(DeviceState *dev, Error **errp) { FWCfgIoState *s =3D FW_CFG_IO(dev); - SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); Error *local_err =3D NULL; =20 fw_cfg_file_slots_allocate(FW_CFG(s), &local_err); @@ -1085,13 +1088,11 @@ static void fw_cfg_io_realize(DeviceState *dev, Err= or **errp) * of the i/o region used is FW_CFG_CTL_SIZE */ memory_region_init_io(&s->comb_iomem, OBJECT(s), &fw_cfg_comb_mem_ops, FW_CFG(s), "fwcfg", FW_CFG_CTL_SIZE); - sysbus_add_io(sbd, s->iobase, &s->comb_iomem); =20 if (FW_CFG(s)->dma_enabled) { memory_region_init_io(&FW_CFG(s)->dma_iomem, OBJECT(s), &fw_cfg_dma_mem_ops, FW_CFG(s), "fwcfg.dma", sizeof(dma_addr_t)); - sysbus_add_io(sbd, s->dma_iobase, &FW_CFG(s)->dma_iomem); } } =20 --=20 1.7.10.4 From nobody Thu May 2 04:04:12 2024 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.zoho.com; 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1497614914881336.41993565760663; Fri, 16 Jun 2017 05:08:34 -0700 (PDT) Received: from localhost ([::1]:58598 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLq3D-0004XO-Hq for importer@patchew.org; Fri, 16 Jun 2017 08:08:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLpzH-0001WM-7E for qemu-devel@nongnu.org; Fri, 16 Jun 2017 08:04:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dLpzF-0007dV-6w for qemu-devel@nongnu.org; Fri, 16 Jun 2017 08:04:27 -0400 Received: from chuckie.co.uk ([82.165.15.123]:52920 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dLpzE-0007bi-Vq for qemu-devel@nongnu.org; Fri, 16 Jun 2017 08:04:25 -0400 Received: from host109-151-5-7.range109-151.btcentralplus.com ([109.151.5.7] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1dLpzC-0003XB-SA; Fri, 16 Jun 2017 13:04:23 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, lersek@redhat.com, somlo@cmu.edu, ehabkost@redhat.com, mst@redhat.com, pbonzini@redhat.com, rjones@redhat.com, peter.maydell@linaro.org Date: Fri, 16 Jun 2017 13:04:08 +0100 Message-Id: <1497614651-1017-3-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1497614651-1017-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1497614651-1017-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.151.5.7 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv3 2/5] fw_cfg: move setting of FW_CFG_VERSION_DMA bit to fw_cfg_init1() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The setting of the FW_CFG_VERSION_DMA bit is the same across both the TYPE_FW_CFG_MEM and TYPE_FW_CFG_IO devices, so unify the logic in fw_cfg_init1(). Signed-off-by: Mark Cave-Ayland Reviewed-by: Laszlo Ersek --- hw/nvram/fw_cfg.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 70a0d5f..e217239 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -914,6 +914,7 @@ static void fw_cfg_init1(DeviceState *dev) { FWCfgState *s =3D FW_CFG(dev); MachineState *machine =3D MACHINE(qdev_get_machine()); + uint32_t version =3D FW_CFG_VERSION; =20 assert(!object_resolve_path(FW_CFG_PATH, NULL)); =20 @@ -928,6 +929,12 @@ static void fw_cfg_init1(DeviceState *dev) fw_cfg_bootsplash(s); fw_cfg_reboot(s); =20 + if (s->dma_enabled) { + version |=3D FW_CFG_VERSION_DMA; + } + + fw_cfg_add_i32(s, FW_CFG_ID, version); + s->machine_ready.notify =3D fw_cfg_machine_ready; qemu_add_machine_init_done_notifier(&s->machine_ready); } @@ -939,7 +946,6 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_= t dma_iobase, SysBusDevice *sbd; FWCfgIoState *ios; FWCfgState *s; - uint32_t version =3D FW_CFG_VERSION; bool dma_requested =3D dma_iobase && dma_as; =20 dev =3D qdev_create(NULL, TYPE_FW_CFG_IO); @@ -960,12 +966,8 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32= _t dma_iobase, s->dma_as =3D dma_as; s->dma_addr =3D 0; sysbus_add_io(sbd, dma_iobase, &s->dma_iomem); - - version |=3D FW_CFG_VERSION_DMA; } =20 - fw_cfg_add_i32(s, FW_CFG_ID, version); - return s; } =20 @@ -981,7 +983,6 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, DeviceState *dev; SysBusDevice *sbd; FWCfgState *s; - uint32_t version =3D FW_CFG_VERSION; bool dma_requested =3D dma_addr && dma_as; =20 dev =3D qdev_create(NULL, TYPE_FW_CFG_MEM); @@ -1002,11 +1003,8 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, s->dma_as =3D dma_as; s->dma_addr =3D 0; sysbus_mmio_map(sbd, 2, dma_addr); - version |=3D FW_CFG_VERSION_DMA; } =20 - fw_cfg_add_i32(s, FW_CFG_ID, version); - return s; } =20 --=20 1.7.10.4 From nobody Thu May 2 04:04:12 2024 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.zoho.com; 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1497614790889577.8258322031912; Fri, 16 Jun 2017 05:06:30 -0700 (PDT) Received: from localhost ([::1]:58593 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLq1D-0002lQ-Id for importer@patchew.org; Fri, 16 Jun 2017 08:06:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57940) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLpzI-0001WO-4n for qemu-devel@nongnu.org; Fri, 16 Jun 2017 08:04:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dLpzH-0007kI-6Z for qemu-devel@nongnu.org; Fri, 16 Jun 2017 08:04:28 -0400 Received: from chuckie.co.uk ([82.165.15.123]:52928 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dLpzH-0007gn-07 for qemu-devel@nongnu.org; Fri, 16 Jun 2017 08:04:27 -0400 Received: from host109-151-5-7.range109-151.btcentralplus.com ([109.151.5.7] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1dLpzE-0003XB-5x; Fri, 16 Jun 2017 13:04:25 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, lersek@redhat.com, somlo@cmu.edu, ehabkost@redhat.com, mst@redhat.com, pbonzini@redhat.com, rjones@redhat.com, peter.maydell@linaro.org Date: Fri, 16 Jun 2017 13:04:09 +0100 Message-Id: <1497614651-1017-4-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1497614651-1017-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1497614651-1017-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.151.5.7 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv3 3/5] fw_cfg: move assert() and linking of fw_cfg device to the machine into instance_init() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In preparation for calling fw_cfg_init1() during realize rather than during init, move the assert() checking for existing fw_cfg devices and the linking of the device to the machine with object_property_add_child() to a new fw_cfg instance_init() function. This guarantees that we will still assert() correctly if more than one fw_c= fg device is instantiated by accident. Signed-off-by: Mark Cave-Ayland --- hw/nvram/fw_cfg.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index e217239..39fcc04 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -916,10 +916,6 @@ static void fw_cfg_init1(DeviceState *dev) MachineState *machine =3D MACHINE(qdev_get_machine()); uint32_t version =3D FW_CFG_VERSION; =20 - assert(!object_resolve_path(FW_CFG_PATH, NULL)); - - object_property_add_child(OBJECT(machine), FW_CFG_NAME, OBJECT(s), NUL= L); - qdev_init_nofail(dev); =20 fw_cfg_add_bytes(s, FW_CFG_SIGNATURE, (char *)"QEMU", 4); @@ -1021,6 +1017,15 @@ FWCfgState *fw_cfg_find(void) return FW_CFG(object_resolve_path(FW_CFG_PATH, NULL)); } =20 +static void fw_cfg_init(Object *obj) +{ + MachineState *machine =3D MACHINE(qdev_get_machine()); + + assert(!object_resolve_path(FW_CFG_PATH, NULL)); + + object_property_add_child(OBJECT(machine), FW_CFG_NAME, obj, NULL); +} + static void fw_cfg_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -1034,6 +1039,7 @@ static const TypeInfo fw_cfg_info =3D { .parent =3D TYPE_SYS_BUS_DEVICE, .abstract =3D true, .instance_size =3D sizeof(FWCfgState), + .instance_init =3D fw_cfg_init, .class_init =3D fw_cfg_class_init, }; =20 --=20 1.7.10.4 From nobody Thu May 2 04:04:12 2024 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.zoho.com; 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1497614917536928.3887173683506; Fri, 16 Jun 2017 05:08:37 -0700 (PDT) Received: from localhost ([::1]:58597 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLq3B-0004VX-A2 for importer@patchew.org; Fri, 16 Jun 2017 08:08:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLpzI-0001WX-Rh for qemu-devel@nongnu.org; Fri, 16 Jun 2017 08:04:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dLpzH-0007lt-VQ for qemu-devel@nongnu.org; Fri, 16 Jun 2017 08:04:28 -0400 Received: from chuckie.co.uk ([82.165.15.123]:52932 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dLpzH-0007k0-P3 for qemu-devel@nongnu.org; Fri, 16 Jun 2017 08:04:27 -0400 Received: from host109-151-5-7.range109-151.btcentralplus.com ([109.151.5.7] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1dLpzF-0003XB-Gs; Fri, 16 Jun 2017 13:04:26 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, lersek@redhat.com, somlo@cmu.edu, ehabkost@redhat.com, mst@redhat.com, pbonzini@redhat.com, rjones@redhat.com, peter.maydell@linaro.org Date: Fri, 16 Jun 2017 13:04:10 +0100 Message-Id: <1497614651-1017-5-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1497614651-1017-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1497614651-1017-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.151.5.7 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv3 4/5] fw_cfg: move qdev_init_nofail() from fw_cfg_init1() to callers 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When looking to instantiate a TYPE_FW_CFG_MEM or TYPE_FW_CFG_IO device to be able to wire it up differently, it is much more convenient for the caller to instantiate the device and have the fw_cfg default files already preloaded during realize. Move fw_cfg_init1() to the end of both the fw_cfg_mem_realize() and fw_cfg_io_realize() functions so it no longer needs to be called manually when instantiating the device, and also rename it to fw_cfg_common_realize() which better describes its new purpose. Signed-off-by: Mark Cave-Ayland --- hw/nvram/fw_cfg.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 39fcc04..b5f10ac 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -910,14 +910,12 @@ static void fw_cfg_machine_ready(struct Notifier *n, = void *data) =20 =20 =20 -static void fw_cfg_init1(DeviceState *dev) +static void fw_cfg_common_realize(DeviceState *dev) { FWCfgState *s =3D FW_CFG(dev); MachineState *machine =3D MACHINE(qdev_get_machine()); uint32_t version =3D FW_CFG_VERSION; =20 - qdev_init_nofail(dev); - fw_cfg_add_bytes(s, FW_CFG_SIGNATURE, (char *)"QEMU", 4); fw_cfg_add_bytes(s, FW_CFG_UUID, &qemu_uuid, 16); fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)!machine->enable_graphic= s); @@ -949,7 +947,7 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_= t dma_iobase, qdev_prop_set_bit(dev, "dma_enabled", false); } =20 - fw_cfg_init1(dev); + qdev_init_nofail(dev); =20 sbd =3D SYS_BUS_DEVICE(dev); ios =3D FW_CFG_IO(dev); @@ -987,7 +985,7 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, qdev_prop_set_bit(dev, "dma_enabled", false); } =20 - fw_cfg_init1(dev); + qdev_init_nofail(dev); =20 sbd =3D SYS_BUS_DEVICE(dev); sysbus_mmio_map(sbd, 0, ctl_addr); @@ -1098,6 +1096,8 @@ static void fw_cfg_io_realize(DeviceState *dev, Error= **errp) &fw_cfg_dma_mem_ops, FW_CFG(s), "fwcfg.dma", sizeof(dma_addr_t)); } + + fw_cfg_common_realize(dev); } =20 static void fw_cfg_io_class_init(ObjectClass *klass, void *data) @@ -1164,6 +1164,8 @@ static void fw_cfg_mem_realize(DeviceState *dev, Erro= r **errp) sizeof(dma_addr_t)); sysbus_init_mmio(sbd, &FW_CFG(s)->dma_iomem); } + + fw_cfg_common_realize(dev); } =20 static void fw_cfg_mem_class_init(ObjectClass *klass, void *data) --=20 1.7.10.4 From nobody Thu May 2 04:04:12 2024 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.zoho.com; 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1497614791705560.4436705298216; Fri, 16 Jun 2017 05:06:31 -0700 (PDT) Received: from localhost ([::1]:58594 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLq1G-0002mm-73 for importer@patchew.org; Fri, 16 Jun 2017 08:06:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLpzK-0001Xs-Bu for qemu-devel@nongnu.org; Fri, 16 Jun 2017 08:04:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dLpzJ-0007rL-Cz for qemu-devel@nongnu.org; Fri, 16 Jun 2017 08:04:30 -0400 Received: from chuckie.co.uk ([82.165.15.123]:52937 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dLpzJ-0007o7-6o for qemu-devel@nongnu.org; Fri, 16 Jun 2017 08:04:29 -0400 Received: from host109-151-5-7.range109-151.btcentralplus.com ([109.151.5.7] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1dLpzG-0003XB-SR; Fri, 16 Jun 2017 13:04:28 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, lersek@redhat.com, somlo@cmu.edu, ehabkost@redhat.com, mst@redhat.com, pbonzini@redhat.com, rjones@redhat.com, peter.maydell@linaro.org Date: Fri, 16 Jun 2017 13:04:11 +0100 Message-Id: <1497614651-1017-6-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1497614651-1017-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1497614651-1017-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.151.5.7 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv3 5/5] fw_cfg: move QOM type defines and fw_cfg types into fw_cfg.h 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This allows the device to be instantiated externally for boards that wish to wire up the fw_cfg device themselves. As part of the process we add typedefs to the structs that were previously missing them. Signed-off-by: Mark Cave-Ayland --- hw/nvram/fw_cfg.c | 56 -----------------------------------------= -- include/hw/nvram/fw_cfg.h | 58 +++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 58 insertions(+), 56 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index b5f10ac..00771c9 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -40,14 +40,6 @@ #define FW_CFG_NAME "fw_cfg" #define FW_CFG_PATH "/machine/" FW_CFG_NAME =20 -#define TYPE_FW_CFG "fw_cfg" -#define TYPE_FW_CFG_IO "fw_cfg_io" -#define TYPE_FW_CFG_MEM "fw_cfg_mem" - -#define FW_CFG(obj) OBJECT_CHECK(FWCfgState, (obj), TYPE_FW_CFG) -#define FW_CFG_IO(obj) OBJECT_CHECK(FWCfgIoState, (obj), TYPE_FW_CFG_IO) -#define FW_CFG_MEM(obj) OBJECT_CHECK(FWCfgMemState, (obj), TYPE_FW_CFG_MEM) - /* FW_CFG_VERSION bits */ #define FW_CFG_VERSION 0x01 #define FW_CFG_VERSION_DMA 0x02 @@ -61,54 +53,6 @@ =20 #define FW_CFG_DMA_SIGNATURE 0x51454d5520434647ULL /* "QEMU CFG" */ =20 -typedef struct FWCfgEntry { - uint32_t len; - bool allow_write; - uint8_t *data; - void *callback_opaque; - FWCfgReadCallback read_callback; -} FWCfgEntry; - -struct FWCfgState { - /*< private >*/ - SysBusDevice parent_obj; - /*< public >*/ - - uint16_t file_slots; - FWCfgEntry *entries[2]; - int *entry_order; - FWCfgFiles *files; - uint16_t cur_entry; - uint32_t cur_offset; - Notifier machine_ready; - - int fw_cfg_order_override; - - bool dma_enabled; - dma_addr_t dma_addr; - AddressSpace *dma_as; - MemoryRegion dma_iomem; -}; - -struct FWCfgIoState { - /*< private >*/ - FWCfgState parent_obj; - /*< public >*/ - - MemoryRegion comb_iomem; - uint32_t iobase, dma_iobase; -}; - -struct FWCfgMemState { - /*< private >*/ - FWCfgState parent_obj; - /*< public >*/ - - MemoryRegion ctl_iomem, data_iomem; - uint32_t data_width; - MemoryRegionOps wide_data_ops; -}; - #define JPG_FILE 0 #define BMP_FILE 1 =20 diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h index b980cba..6393176 100644 --- a/include/hw/nvram/fw_cfg.h +++ b/include/hw/nvram/fw_cfg.h @@ -3,6 +3,16 @@ =20 #include "exec/hwaddr.h" #include "hw/nvram/fw_cfg_keys.h" +#include "hw/sysbus.h" +#include "sysemu/dma.h" + +#define TYPE_FW_CFG "fw_cfg" +#define TYPE_FW_CFG_IO "fw_cfg_io" +#define TYPE_FW_CFG_MEM "fw_cfg_mem" + +#define FW_CFG(obj) OBJECT_CHECK(FWCfgState, (obj), TYPE_FW_CFG) +#define FW_CFG_IO(obj) OBJECT_CHECK(FWCfgIoState, (obj), TYPE_FW_CFG_IO) +#define FW_CFG_MEM(obj) OBJECT_CHECK(FWCfgMemState, (obj), TYPE_FW_CFG_MEM) =20 typedef struct FWCfgFile { uint32_t size; /* file size */ @@ -35,6 +45,54 @@ typedef struct FWCfgDmaAccess { =20 typedef void (*FWCfgReadCallback)(void *opaque); =20 +typedef struct FWCfgEntry { + uint32_t len; + bool allow_write; + uint8_t *data; + void *callback_opaque; + FWCfgReadCallback read_callback; +} FWCfgEntry; + +typedef struct FWCfgState { + /*< private >*/ + SysBusDevice parent_obj; + /*< public >*/ + + uint16_t file_slots; + FWCfgEntry *entries[2]; + int *entry_order; + FWCfgFiles *files; + uint16_t cur_entry; + uint32_t cur_offset; + Notifier machine_ready; + + int fw_cfg_order_override; + + bool dma_enabled; + dma_addr_t dma_addr; + AddressSpace *dma_as; + MemoryRegion dma_iomem; +} FWCfgState; + +typedef struct FWCfgIoState { + /*< private >*/ + FWCfgState parent_obj; + /*< public >*/ + + MemoryRegion comb_iomem; + uint32_t iobase, dma_iobase; +} FWCfgIoState; + +typedef struct FWCfgMemState { + /*< private >*/ + FWCfgState parent_obj; + /*< public >*/ + + MemoryRegion ctl_iomem, data_iomem; + uint32_t data_width; + MemoryRegionOps wide_data_ops; +} FWCfgMemState; + /** * fw_cfg_add_bytes: * @s: fw_cfg device being modified --=20 1.7.10.4