From nobody Tue May 14 07:03:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646257257250325.9198438640433; Wed, 2 Mar 2022 13:40:57 -0800 (PST) Received: from localhost ([::1]:53490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPWiN-0002YW-Uf for importer@patchew.org; Wed, 02 Mar 2022 16:40:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPWWG-0001SZ-7Z for qemu-devel@nongnu.org; Wed, 02 Mar 2022 16:28:24 -0500 Received: from [2001:41c9:1:41f::167] (port=54740 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPWWE-0002DG-Mu for qemu-devel@nongnu.org; Wed, 02 Mar 2022 16:28:23 -0500 Received: from [2a00:23c4:8ba0:ca00:d4eb:dbd5:5a41:aefe] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nPWVT-000C4G-Ud; Wed, 02 Mar 2022 21:27:40 +0000 From: Mark Cave-Ayland To: laurent@vivier.eu, pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Wed, 2 Mar 2022 21:27:43 +0000 Message-Id: <20220302212752.6922-2-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220302212752.6922-1-mark.cave-ayland@ilande.co.uk> References: <20220302212752.6922-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8ba0:ca00:d4eb:dbd5:5a41:aefe X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 01/10] macfb: add VMStateDescription for MacfbNubusState and MacfbSysBusState X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:41c9:1:41f::167 (failed) 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=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" X-ZM-MESSAGEID: 1646257258117100001 Content-Type: text/plain; charset="utf-8" Currently when QEMU tries to migrate the macfb framebuffer it crashes rando= mly because the opaque provided by the DeviceClass vmsd property for both devic= es is set to MacfbState rather than MacfbNubusState or MacfbSysBusState as appropriate. Resolve the issue by adding new VMStateDescriptions for MacfbNubusState and MacfbSysBusState which embed the existing vmstate_macfb VMStateDescription within them using VMSTATE_STRUCT. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Reviewed-by: Peter Maydell --- hw/display/macfb.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index c9b468c10e..66ceacf1ae 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -746,6 +746,16 @@ static Property macfb_sysbus_properties[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 +static const VMStateDescription vmstate_macfb_sysbus =3D { + .name =3D "macfb-sysbus", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_STRUCT(macfb, MacfbSysBusState, 1, vmstate_macfb, MacfbSta= te), + VMSTATE_END_OF_LIST() + } +}; + static Property macfb_nubus_properties[] =3D { DEFINE_PROP_UINT32("width", MacfbNubusState, macfb.width, 640), DEFINE_PROP_UINT32("height", MacfbNubusState, macfb.height, 480), @@ -755,6 +765,16 @@ static Property macfb_nubus_properties[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 +static const VMStateDescription vmstate_macfb_nubus =3D { + .name =3D "macfb-nubus", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_STRUCT(macfb, MacfbNubusState, 1, vmstate_macfb, MacfbStat= e), + VMSTATE_END_OF_LIST() + } +}; + static void macfb_sysbus_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -762,7 +782,7 @@ static void macfb_sysbus_class_init(ObjectClass *klass,= void *data) dc->realize =3D macfb_sysbus_realize; dc->desc =3D "SysBus Macintosh framebuffer"; dc->reset =3D macfb_sysbus_reset; - dc->vmsd =3D &vmstate_macfb; + dc->vmsd =3D &vmstate_macfb_sysbus; device_class_set_props(dc, macfb_sysbus_properties); } =20 @@ -777,7 +797,7 @@ static void macfb_nubus_class_init(ObjectClass *klass, = void *data) &ndc->parent_unrealize); dc->desc =3D "Nubus Macintosh framebuffer"; dc->reset =3D macfb_nubus_reset; - dc->vmsd =3D &vmstate_macfb; + dc->vmsd =3D &vmstate_macfb_nubus; set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); device_class_set_props(dc, macfb_nubus_properties); } --=20 2.20.1 From nobody Tue May 14 07:03:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646257332053478.84974017362686; Wed, 2 Mar 2022 13:42:12 -0800 (PST) Received: from localhost ([::1]:55684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPWja-00047X-OG for importer@patchew.org; Wed, 02 Mar 2022 16:42:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPWWH-0001UO-J6 for qemu-devel@nongnu.org; Wed, 02 Mar 2022 16:28:25 -0500 Received: from [2001:41c9:1:41f::167] (port=54750 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPWWG-0002DM-7A for qemu-devel@nongnu.org; Wed, 02 Mar 2022 16:28:25 -0500 Received: from [2a00:23c4:8ba0:ca00:d4eb:dbd5:5a41:aefe] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nPWVY-000C4G-4j; Wed, 02 Mar 2022 21:27:44 +0000 From: Mark Cave-Ayland To: laurent@vivier.eu, pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Wed, 2 Mar 2022 21:27:44 +0000 Message-Id: <20220302212752.6922-3-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220302212752.6922-1-mark.cave-ayland@ilande.co.uk> References: <20220302212752.6922-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8ba0:ca00:d4eb:dbd5:5a41:aefe X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 02/10] macfb: don't use special irq_state and irq_mask variables in MacfbState X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:41c9:1:41f::167 (failed) 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=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" X-ZM-MESSAGEID: 1646257332967100001 The current IRQ state and IRQ mask are handled exactly the same as standard register accesses, so store these values directly in the regs array rather than having separate variables for them. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Laurent Vivier --- hw/display/macfb.c | 15 +++++++-------- include/hw/display/macfb.h | 2 -- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index 66ceacf1ae..fb54b460c1 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -476,7 +476,8 @@ static void macfb_update_display(void *opaque) =20 static void macfb_update_irq(MacfbState *s) { - uint32_t irq_state =3D s->irq_state & s->irq_mask; + uint32_t irq_state =3D s->regs[DAFB_INTR_STAT >> 2] & + s->regs[DAFB_INTR_MASK >> 2]; =20 if (irq_state) { qemu_irq_raise(s->irq); @@ -496,7 +497,7 @@ static void macfb_vbl_timer(void *opaque) MacfbState *s =3D opaque; int64_t next_vbl; =20 - s->irq_state |=3D DAFB_INTR_VBL; + s->regs[DAFB_INTR_STAT >> 2] |=3D DAFB_INTR_VBL; macfb_update_irq(s); =20 /* 60 Hz irq */ @@ -530,10 +531,8 @@ static uint64_t macfb_ctrl_read(void *opaque, case DAFB_MODE_VADDR2: case DAFB_MODE_CTRL1: case DAFB_MODE_CTRL2: - val =3D s->regs[addr >> 2]; - break; case DAFB_INTR_STAT: - val =3D s->irq_state; + val =3D s->regs[addr >> 2]; break; case DAFB_MODE_SENSE: val =3D macfb_sense_read(s); @@ -568,7 +567,7 @@ static void macfb_ctrl_write(void *opaque, macfb_sense_write(s, val); break; case DAFB_INTR_MASK: - s->irq_mask =3D val; + s->regs[addr >> 2] =3D val; if (val & DAFB_INTR_VBL) { next_vbl =3D macfb_next_vbl(); timer_mod(s->vbl_timer, next_vbl); @@ -577,12 +576,12 @@ static void macfb_ctrl_write(void *opaque, } break; case DAFB_INTR_CLEAR: - s->irq_state &=3D ~DAFB_INTR_VBL; + s->regs[DAFB_INTR_STAT >> 2] &=3D ~DAFB_INTR_VBL; macfb_update_irq(s); break; case DAFB_RESET: s->palette_current =3D 0; - s->irq_state &=3D ~DAFB_INTR_VBL; + s->regs[DAFB_INTR_STAT >> 2] &=3D ~DAFB_INTR_VBL; macfb_update_irq(s); break; case DAFB_LUT: diff --git a/include/hw/display/macfb.h b/include/hw/display/macfb.h index e52775aa21..6d9f0f7869 100644 --- a/include/hw/display/macfb.h +++ b/include/hw/display/macfb.h @@ -66,8 +66,6 @@ typedef struct MacfbState { uint32_t regs[MACFB_NUM_REGS]; MacFbMode *mode; =20 - uint32_t irq_state; - uint32_t irq_mask; QEMUTimer *vbl_timer; qemu_irq irq; } MacfbState; --=20 2.20.1 From nobody Tue May 14 07:03:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646256633673890.670066885984; Wed, 2 Mar 2022 13:30:33 -0800 (PST) Received: from localhost ([::1]:59968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPWYJ-0003zS-Jy for importer@patchew.org; Wed, 02 Mar 2022 16:30:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPWWH-0001UQ-Jo for qemu-devel@nongnu.org; Wed, 02 Mar 2022 16:28:25 -0500 Received: from [2001:41c9:1:41f::167] (port=54752 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPWWG-0002DP-8W for qemu-devel@nongnu.org; Wed, 02 Mar 2022 16:28:25 -0500 Received: from [2a00:23c4:8ba0:ca00:d4eb:dbd5:5a41:aefe] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nPWVc-000C4G-E3; Wed, 02 Mar 2022 21:27:44 +0000 From: Mark Cave-Ayland To: laurent@vivier.eu, pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Wed, 2 Mar 2022 21:27:45 +0000 Message-Id: <20220302212752.6922-4-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220302212752.6922-1-mark.cave-ayland@ilande.co.uk> References: <20220302212752.6922-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8ba0:ca00:d4eb:dbd5:5a41:aefe X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 03/10] macfb: increase number of registers saved in MacfbState X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:41c9:1:41f::167 (failed) 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=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" X-ZM-MESSAGEID: 1646256636984100001 Content-Type: text/plain; charset="utf-8" The MacOS toolbox ROM accesses a number of addresses between 0x0 and 0x200 = during initialisation and resolution changes. Whilst the function of many of these registers is unknown, it is worth the minimal cost of saving these extra va= lues as part of migration to help future-proof the migration stream for the q800 ma= chine as it starts to stabilise. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Reviewed-by: Peter Maydell --- hw/display/macfb.c | 8 ++++++++ include/hw/display/macfb.h | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index fb54b460c1..dfdae90144 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -537,6 +537,10 @@ static uint64_t macfb_ctrl_read(void *opaque, case DAFB_MODE_SENSE: val =3D macfb_sense_read(s); break; + default: + if (addr < MACFB_CTRL_TOPADDR) { + val =3D s->regs[addr >> 2]; + } } =20 trace_macfb_ctrl_read(addr, val, size); @@ -592,6 +596,10 @@ static void macfb_ctrl_write(void *opaque, macfb_invalidate_display(s); } break; + default: + if (addr < MACFB_CTRL_TOPADDR) { + s->regs[addr >> 2] =3D val; + } } =20 trace_macfb_ctrl_write(addr, val, size); diff --git a/include/hw/display/macfb.h b/include/hw/display/macfb.h index 6d9f0f7869..55a50d3fb0 100644 --- a/include/hw/display/macfb.h +++ b/include/hw/display/macfb.h @@ -48,7 +48,8 @@ typedef struct MacFbMode { uint32_t offset; } MacFbMode; =20 -#define MACFB_NUM_REGS 8 +#define MACFB_CTRL_TOPADDR 0x200 +#define MACFB_NUM_REGS (MACFB_CTRL_TOPADDR / sizeof(uint32_t)) =20 typedef struct MacfbState { MemoryRegion mem_vram; --=20 2.20.1 From nobody Tue May 14 07:03:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164625664286479.30539066202596; Wed, 2 Mar 2022 13:30:42 -0800 (PST) Received: from localhost ([::1]:60306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPWYT-0004DS-Cy for importer@patchew.org; Wed, 02 Mar 2022 16:30:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPWWM-0001cg-Mr for qemu-devel@nongnu.org; Wed, 02 Mar 2022 16:28:30 -0500 Received: from [2001:41c9:1:41f::167] (port=54762 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPWWL-0002EO-5E for qemu-devel@nongnu.org; Wed, 02 Mar 2022 16:28:30 -0500 Received: from [2a00:23c4:8ba0:ca00:d4eb:dbd5:5a41:aefe] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nPWVc-000C4G-O5; Wed, 02 Mar 2022 21:27:48 +0000 From: Mark Cave-Ayland To: laurent@vivier.eu, pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Wed, 2 Mar 2022 21:27:46 +0000 Message-Id: <20220302212752.6922-5-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220302212752.6922-1-mark.cave-ayland@ilande.co.uk> References: <20220302212752.6922-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8ba0:ca00:d4eb:dbd5:5a41:aefe X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 04/10] macfb: add VMStateDescription fields for display type and VBL timer X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:41c9:1:41f::167 (failed) 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=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" X-ZM-MESSAGEID: 1646256645691100003 Content-Type: text/plain; charset="utf-8" These fields are required in the migration stream to restore macfb state correctly. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Reviewed-by: Peter Maydell --- hw/display/macfb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index dfdae90144..7371986480 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -625,9 +625,11 @@ static const VMStateDescription vmstate_macfb =3D { .minimum_version_id =3D 1, .post_load =3D macfb_post_load, .fields =3D (VMStateField[]) { + VMSTATE_UINT8(type, MacfbState), VMSTATE_UINT8_ARRAY(color_palette, MacfbState, 256 * 3), VMSTATE_UINT32(palette_current, MacfbState), VMSTATE_UINT32_ARRAY(regs, MacfbState, MACFB_NUM_REGS), + VMSTATE_TIMER_PTR(vbl_timer, MacfbState), VMSTATE_END_OF_LIST() } }; --=20 2.20.1 From nobody Tue May 14 07:03:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646256901838709.7836323803995; Wed, 2 Mar 2022 13:35:01 -0800 (PST) Received: from localhost ([::1]:39244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPWce-00014x-S7 for importer@patchew.org; Wed, 02 Mar 2022 16:35:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPWWP-0001ix-SQ for qemu-devel@nongnu.org; Wed, 02 Mar 2022 16:28:33 -0500 Received: from [2001:41c9:1:41f::167] (port=54772 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPWWO-0002Eq-Dh for qemu-devel@nongnu.org; Wed, 02 Mar 2022 16:28:33 -0500 Received: from [2a00:23c4:8ba0:ca00:d4eb:dbd5:5a41:aefe] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nPWVg-000C4G-VM; Wed, 02 Mar 2022 21:27:53 +0000 From: Mark Cave-Ayland To: laurent@vivier.eu, pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Wed, 2 Mar 2022 21:27:47 +0000 Message-Id: <20220302212752.6922-6-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220302212752.6922-1-mark.cave-ayland@ilande.co.uk> References: <20220302212752.6922-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8ba0:ca00:d4eb:dbd5:5a41:aefe X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 05/10] macfb: set initial value of mode control registers in macfb_common_realize() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:41c9:1:41f::167 (failed) 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=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" X-ZM-MESSAGEID: 1646256903549100001 Content-Type: text/plain; charset="utf-8" If booting Linux directly in the q800 machine using -kernel rather than usi= ng a MacOS toolbox ROM, the mode control registers are never initialised, causing macfb_mode_write() to fail to determine the current resolution after migration. Resolve this by always setting the initial values of the mode co= ntrol registers based upon the initial macfb properties during realize. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Reviewed-by: Peter Maydell --- hw/display/macfb.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index 7371986480..2f8e016566 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -655,6 +655,14 @@ static bool macfb_common_realize(DeviceState *dev, Mac= fbState *s, Error **errp) return false; } =20 + /* + * Set mode control registers to match the mode found above so that + * macfb_mode_write() does the right thing if no MacOS toolbox ROM + * is present to initialise them + */ + s->regs[DAFB_MODE_CTRL1 >> 2] =3D s->mode->mode_ctrl1; + s->regs[DAFB_MODE_CTRL2 >> 2] =3D s->mode->mode_ctrl2; + s->con =3D graphic_console_init(dev, 0, &macfb_ops, s); surface =3D qemu_console_surface(s->con); =20 --=20 2.20.1 From nobody Tue May 14 07:03:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646256654639983.0968415175348; Wed, 2 Mar 2022 13:30:54 -0800 (PST) Received: from localhost ([::1]:32840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPWYf-0004nt-LQ for importer@patchew.org; Wed, 02 Mar 2022 16:30:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPWWU-0001yw-MT for qemu-devel@nongnu.org; Wed, 02 Mar 2022 16:28:38 -0500 Received: from [2001:41c9:1:41f::167] (port=54782 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPWWT-0002FF-5f for qemu-devel@nongnu.org; Wed, 02 Mar 2022 16:28:38 -0500 Received: from [2a00:23c4:8ba0:ca00:d4eb:dbd5:5a41:aefe] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nPWVl-000C4G-5p; Wed, 02 Mar 2022 21:27:57 +0000 From: Mark Cave-Ayland To: laurent@vivier.eu, pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Wed, 2 Mar 2022 21:27:48 +0000 Message-Id: <20220302212752.6922-7-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220302212752.6922-1-mark.cave-ayland@ilande.co.uk> References: <20220302212752.6922-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8ba0:ca00:d4eb:dbd5:5a41:aefe X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 06/10] esp: introduce esp_set_pdma_cb() function X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:41c9:1:41f::167 (failed) 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=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" X-ZM-MESSAGEID: 1646256655530100003 This function is to be used to set the current PDMA callback rather than accessing the ESPState pdma_cb function pointer directly. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Laurent Vivier --- hw/scsi/esp.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 58d0edbd56..d1640218c4 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -195,6 +195,11 @@ static void esp_pdma_write(ESPState *s, uint8_t val) esp_set_tc(s, dmalen); } =20 +static void esp_set_pdma_cb(ESPState *s, void (*cb)(ESPState *)) +{ + s->pdma_cb =3D cb; +} + static int esp_select(ESPState *s) { int target; @@ -356,7 +361,7 @@ static void handle_satn(ESPState *s) s->dma_cb =3D handle_satn; return; } - s->pdma_cb =3D satn_pdma_cb; + esp_set_pdma_cb(s, satn_pdma_cb); cmdlen =3D get_cmd(s, ESP_CMDFIFO_SZ); if (cmdlen > 0) { s->cmdfifo_cdb_offset =3D 1; @@ -387,7 +392,7 @@ static void handle_s_without_atn(ESPState *s) s->dma_cb =3D handle_s_without_atn; return; } - s->pdma_cb =3D s_without_satn_pdma_cb; + esp_set_pdma_cb(s, s_without_satn_pdma_cb); cmdlen =3D get_cmd(s, ESP_CMDFIFO_SZ); if (cmdlen > 0) { s->cmdfifo_cdb_offset =3D 0; @@ -422,7 +427,7 @@ static void handle_satn_stop(ESPState *s) s->dma_cb =3D handle_satn_stop; return; } - s->pdma_cb =3D satn_stop_pdma_cb; + esp_set_pdma_cb(s, satn_stop_pdma_cb); cmdlen =3D get_cmd(s, 1); if (cmdlen > 0) { trace_esp_handle_satn_stop(fifo8_num_used(&s->cmdfifo)); @@ -464,7 +469,7 @@ static void write_response(ESPState *s) s->rregs[ESP_RINTR] |=3D INTR_BS | INTR_FC; s->rregs[ESP_RSEQ] =3D SEQ_CD; } else { - s->pdma_cb =3D write_response_pdma_cb; + esp_set_pdma_cb(s, write_response_pdma_cb); esp_raise_drq(s); return; } @@ -604,7 +609,7 @@ static void esp_do_dma(ESPState *s) s->dma_memory_read(s->dma_opaque, buf, len); fifo8_push_all(&s->cmdfifo, buf, len); } else { - s->pdma_cb =3D do_dma_pdma_cb; + esp_set_pdma_cb(s, do_dma_pdma_cb); esp_raise_drq(s); return; } @@ -646,7 +651,7 @@ static void esp_do_dma(ESPState *s) if (s->dma_memory_read) { s->dma_memory_read(s->dma_opaque, s->async_buf, len); } else { - s->pdma_cb =3D do_dma_pdma_cb; + esp_set_pdma_cb(s, do_dma_pdma_cb); esp_raise_drq(s); return; } @@ -678,7 +683,7 @@ static void esp_do_dma(ESPState *s) } =20 esp_set_tc(s, esp_get_tc(s) - len); - s->pdma_cb =3D do_dma_pdma_cb; + esp_set_pdma_cb(s, do_dma_pdma_cb); esp_raise_drq(s); =20 /* Indicate transfer to FIFO is complete */ --=20 2.20.1 From nobody Tue May 14 07:03:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646256916675412.0089065531538; Wed, 2 Mar 2022 13:35:16 -0800 (PST) Received: from localhost ([::1]:40028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPWct-0001ad-Vt for importer@patchew.org; Wed, 02 Mar 2022 16:35:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPWWY-0002Az-83 for qemu-devel@nongnu.org; Wed, 02 Mar 2022 16:28:42 -0500 Received: from [2001:41c9:1:41f::167] (port=54792 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPWWW-0002Gc-TK for qemu-devel@nongnu.org; Wed, 02 Mar 2022 16:28:41 -0500 Received: from [2a00:23c4:8ba0:ca00:d4eb:dbd5:5a41:aefe] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nPWVp-000C4G-D9; Wed, 02 Mar 2022 21:28:01 +0000 From: Mark Cave-Ayland To: laurent@vivier.eu, pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Wed, 2 Mar 2022 21:27:49 +0000 Message-Id: <20220302212752.6922-8-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220302212752.6922-1-mark.cave-ayland@ilande.co.uk> References: <20220302212752.6922-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8ba0:ca00:d4eb:dbd5:5a41:aefe X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 07/10] esp: introduce esp_pdma_cb() function X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:41c9:1:41f::167 (failed) 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=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" X-ZM-MESSAGEID: 1646256926234100001 This function is to be used to execute the current PDMA callback rather than dereferencing the ESPState pdma_cb function pointer directly. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Laurent Vivier --- hw/scsi/esp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index d1640218c4..035fb0d1f6 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -200,6 +200,11 @@ static void esp_set_pdma_cb(ESPState *s, void (*cb)(ES= PState *)) s->pdma_cb =3D cb; } =20 +static void esp_pdma_cb(ESPState *s) +{ + s->pdma_cb(s); +} + static int esp_select(ESPState *s) { int target; @@ -1268,7 +1273,7 @@ static void sysbus_esp_pdma_write(void *opaque, hwadd= r addr, esp_pdma_write(s, val); break; } - s->pdma_cb(s); + esp_pdma_cb(s); } =20 static uint64_t sysbus_esp_pdma_read(void *opaque, hwaddr addr, @@ -1290,7 +1295,7 @@ static uint64_t sysbus_esp_pdma_read(void *opaque, hw= addr addr, break; } if (fifo8_num_used(&s->fifo) < 2) { - s->pdma_cb(s); + esp_pdma_cb(s); } return val; } --=20 2.20.1 From nobody Tue May 14 07:03:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646257026219655.3026887901088; Wed, 2 Mar 2022 13:37:06 -0800 (PST) Received: from localhost ([::1]:45858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPWef-0005aW-2n for importer@patchew.org; Wed, 02 Mar 2022 16:37:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52710) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPWWc-0002JY-42 for qemu-devel@nongnu.org; Wed, 02 Mar 2022 16:28:46 -0500 Received: from [2001:41c9:1:41f::167] (port=54802 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPWWa-0002HE-KI for qemu-devel@nongnu.org; Wed, 02 Mar 2022 16:28:45 -0500 Received: from [2a00:23c4:8ba0:ca00:d4eb:dbd5:5a41:aefe] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nPWVt-000C4G-J2; Wed, 02 Mar 2022 21:28:05 +0000 From: Mark Cave-Ayland To: laurent@vivier.eu, pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Wed, 2 Mar 2022 21:27:50 +0000 Message-Id: <20220302212752.6922-9-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220302212752.6922-1-mark.cave-ayland@ilande.co.uk> References: <20220302212752.6922-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8ba0:ca00:d4eb:dbd5:5a41:aefe X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 08/10] esp: convert ESPState pdma_cb from a function pointer to an integer X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:41c9:1:41f::167 (failed) 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=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" X-ZM-MESSAGEID: 1646257028624100001 This prepares for the inclusion of the current PDMA callback in the migrati= on stream since the callback is referenced by an integer instead of a function pointer. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Laurent Vivier --- hw/scsi/esp.c | 44 ++++++++++++++++++++++++++++++------------- include/hw/scsi/esp.h | 11 ++++++++++- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 035fb0d1f6..a818b2b07a 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -195,16 +195,11 @@ static void esp_pdma_write(ESPState *s, uint8_t val) esp_set_tc(s, dmalen); } =20 -static void esp_set_pdma_cb(ESPState *s, void (*cb)(ESPState *)) +static void esp_set_pdma_cb(ESPState *s, enum pdma_cb cb) { s->pdma_cb =3D cb; } =20 -static void esp_pdma_cb(ESPState *s) -{ - s->pdma_cb(s); -} - static int esp_select(ESPState *s) { int target; @@ -366,7 +361,7 @@ static void handle_satn(ESPState *s) s->dma_cb =3D handle_satn; return; } - esp_set_pdma_cb(s, satn_pdma_cb); + esp_set_pdma_cb(s, SATN_PDMA_CB); cmdlen =3D get_cmd(s, ESP_CMDFIFO_SZ); if (cmdlen > 0) { s->cmdfifo_cdb_offset =3D 1; @@ -397,7 +392,7 @@ static void handle_s_without_atn(ESPState *s) s->dma_cb =3D handle_s_without_atn; return; } - esp_set_pdma_cb(s, s_without_satn_pdma_cb); + esp_set_pdma_cb(s, S_WITHOUT_SATN_PDMA_CB); cmdlen =3D get_cmd(s, ESP_CMDFIFO_SZ); if (cmdlen > 0) { s->cmdfifo_cdb_offset =3D 0; @@ -432,7 +427,7 @@ static void handle_satn_stop(ESPState *s) s->dma_cb =3D handle_satn_stop; return; } - esp_set_pdma_cb(s, satn_stop_pdma_cb); + esp_set_pdma_cb(s, SATN_STOP_PDMA_CB); cmdlen =3D get_cmd(s, 1); if (cmdlen > 0) { trace_esp_handle_satn_stop(fifo8_num_used(&s->cmdfifo)); @@ -474,7 +469,7 @@ static void write_response(ESPState *s) s->rregs[ESP_RINTR] |=3D INTR_BS | INTR_FC; s->rregs[ESP_RSEQ] =3D SEQ_CD; } else { - esp_set_pdma_cb(s, write_response_pdma_cb); + esp_set_pdma_cb(s, WRITE_RESPONSE_PDMA_CB); esp_raise_drq(s); return; } @@ -614,7 +609,7 @@ static void esp_do_dma(ESPState *s) s->dma_memory_read(s->dma_opaque, buf, len); fifo8_push_all(&s->cmdfifo, buf, len); } else { - esp_set_pdma_cb(s, do_dma_pdma_cb); + esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); return; } @@ -656,7 +651,7 @@ static void esp_do_dma(ESPState *s) if (s->dma_memory_read) { s->dma_memory_read(s->dma_opaque, s->async_buf, len); } else { - esp_set_pdma_cb(s, do_dma_pdma_cb); + esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); return; } @@ -688,7 +683,7 @@ static void esp_do_dma(ESPState *s) } =20 esp_set_tc(s, esp_get_tc(s) - len); - esp_set_pdma_cb(s, do_dma_pdma_cb); + esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); =20 /* Indicate transfer to FIFO is complete */ @@ -787,6 +782,29 @@ static void esp_do_nodma(ESPState *s) esp_raise_irq(s); } =20 +static void esp_pdma_cb(ESPState *s) +{ + switch (s->pdma_cb) { + case SATN_PDMA_CB: + satn_pdma_cb(s); + break; + case S_WITHOUT_SATN_PDMA_CB: + s_without_satn_pdma_cb(s); + break; + case SATN_STOP_PDMA_CB: + satn_stop_pdma_cb(s); + break; + case WRITE_RESPONSE_PDMA_CB: + write_response_pdma_cb(s); + break; + case DO_DMA_PDMA_CB: + do_dma_pdma_cb(s); + break; + default: + g_assert_not_reached(); + } +} + void esp_command_complete(SCSIRequest *req, size_t resid) { ESPState *s =3D req->hba_private; diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h index b1ec27612f..13b17496f8 100644 --- a/include/hw/scsi/esp.h +++ b/include/hw/scsi/esp.h @@ -51,7 +51,7 @@ struct ESPState { ESPDMAMemoryReadWriteFunc dma_memory_write; void *dma_opaque; void (*dma_cb)(ESPState *s); - void (*pdma_cb)(ESPState *s); + uint8_t pdma_cb; =20 uint8_t mig_version_id; =20 @@ -150,6 +150,15 @@ struct SysBusESPState { #define TCHI_FAS100A 0x4 #define TCHI_AM53C974 0x12 =20 +/* PDMA callbacks */ +enum pdma_cb { + SATN_PDMA_CB =3D 0, + S_WITHOUT_SATN_PDMA_CB =3D 1, + SATN_STOP_PDMA_CB =3D 2, + WRITE_RESPONSE_PDMA_CB =3D 3, + DO_DMA_PDMA_CB =3D 4 +}; + void esp_dma_enable(ESPState *s, int irq, int level); void esp_request_cancelled(SCSIRequest *req); void esp_command_complete(SCSIRequest *req, size_t resid); --=20 2.20.1 From nobody Tue May 14 07:03:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164625703728485.23910047107165; Wed, 2 Mar 2022 13:37:17 -0800 (PST) Received: from localhost ([::1]:46518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPWep-000612-Vj for importer@patchew.org; Wed, 02 Mar 2022 16:37:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52734) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPWWg-0002Xp-JP for qemu-devel@nongnu.org; Wed, 02 Mar 2022 16:28:50 -0500 Received: from [2001:41c9:1:41f::167] (port=54812 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPWWf-0002Hc-6O for qemu-devel@nongnu.org; Wed, 02 Mar 2022 16:28:50 -0500 Received: from [2a00:23c4:8ba0:ca00:d4eb:dbd5:5a41:aefe] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nPWVx-000C4G-PS; Wed, 02 Mar 2022 21:28:09 +0000 From: Mark Cave-Ayland To: laurent@vivier.eu, pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Wed, 2 Mar 2022 21:27:51 +0000 Message-Id: <20220302212752.6922-10-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220302212752.6922-1-mark.cave-ayland@ilande.co.uk> References: <20220302212752.6922-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8ba0:ca00:d4eb:dbd5:5a41:aefe X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 09/10] esp: include the current PDMA callback in the migration stream X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:41c9:1:41f::167 (failed) 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=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" X-ZM-MESSAGEID: 1646257040496100001 Content-Type: text/plain; charset="utf-8" This involves (re)adding a PDMA-specific subsection to hold the reference t= o the current PDMA callback. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Reviewed-by: Peter Maydell --- hw/scsi/esp.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index a818b2b07a..32926834bc 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -1209,6 +1209,25 @@ static int esp_post_load(void *opaque, int version_i= d) return 0; } =20 +static bool esp_pdma_needed(void *opaque) +{ + ESPState *s =3D ESP(opaque); + + return s->dma_memory_read =3D=3D NULL && s->dma_memory_write =3D=3D NU= LL && + s->dma_enabled; +} + +static const VMStateDescription vmstate_esp_pdma =3D { + .name =3D "esp/pdma", + .version_id =3D 0, + .minimum_version_id =3D 0, + .needed =3D esp_pdma_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8(pdma_cb, ESPState), + VMSTATE_END_OF_LIST() + } +}; + const VMStateDescription vmstate_esp =3D { .name =3D "esp", .version_id =3D 6, @@ -1243,6 +1262,10 @@ const VMStateDescription vmstate_esp =3D { VMSTATE_UINT8_TEST(lun, ESPState, esp_is_version_6), VMSTATE_END_OF_LIST() }, + .subsections =3D (const VMStateDescription * []) { + &vmstate_esp_pdma, + NULL + } }; =20 static void sysbus_esp_mem_write(void *opaque, hwaddr addr, --=20 2.20.1 From nobody Tue May 14 07:03:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646257441329111.18518321454326; Wed, 2 Mar 2022 13:44:01 -0800 (PST) Received: from localhost ([::1]:58944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPWlM-0006Kb-D8 for importer@patchew.org; Wed, 02 Mar 2022 16:44:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPWWk-0002n6-GQ for qemu-devel@nongnu.org; Wed, 02 Mar 2022 16:28:54 -0500 Received: from [2001:41c9:1:41f::167] (port=54820 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPWWi-0002Hz-TV for qemu-devel@nongnu.org; Wed, 02 Mar 2022 16:28:54 -0500 Received: from [2a00:23c4:8ba0:ca00:d4eb:dbd5:5a41:aefe] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nPWW1-000C4G-W1; Wed, 02 Mar 2022 21:28:14 +0000 From: Mark Cave-Ayland To: laurent@vivier.eu, pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Wed, 2 Mar 2022 21:27:52 +0000 Message-Id: <20220302212752.6922-11-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220302212752.6922-1-mark.cave-ayland@ilande.co.uk> References: <20220302212752.6922-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8ba0:ca00:d4eb:dbd5:5a41:aefe X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 10/10] esp: recreate ESPState current_req after migration X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:41c9:1:41f::167 (failed) 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=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" X-ZM-MESSAGEID: 1646257443462100001 Content-Type: text/plain; charset="utf-8" Since PDMA reads/writes are driven by the guest, it is possible that migrat= ion can occur whilst a SCSIRequest is still active. Fortunately active SCSIRequ= ests are already included in the migration stream and restarted post migration b= ut this still leaves the reference in ESPState uninitialised. Implement the SCSIBusInfo .load_request callback to obtain a reference to t= he currently active SCSIRequest and use it to recreate ESPState current_req after migration. Suggested-by: Paolo Bonzini Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier --- hw/scsi/esp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 32926834bc..824c345ceb 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -1341,6 +1341,15 @@ static uint64_t sysbus_esp_pdma_read(void *opaque, h= waddr addr, return val; } =20 +static void *esp_load_request(QEMUFile *f, SCSIRequest *req) +{ + ESPState *s =3D container_of(req->bus, ESPState, bus); + + scsi_req_ref(req); + s->current_req =3D req; + return s; +} + static const MemoryRegionOps sysbus_esp_pdma_ops =3D { .read =3D sysbus_esp_pdma_read, .write =3D sysbus_esp_pdma_write, @@ -1356,6 +1365,7 @@ static const struct SCSIBusInfo esp_scsi_info =3D { .max_target =3D ESP_MAX_DEVS, .max_lun =3D 7, =20 + .load_request =3D esp_load_request, .transfer_data =3D esp_transfer_data, .complete =3D esp_command_complete, .cancel =3D esp_request_cancelled --=20 2.20.1