From nobody Fri May 17 08:24:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619907241; cv=none; d=zohomail.com; s=zohoarc; b=kyzOXXpBXCha3Ccoto/dllzf7vBV+Y6407BVbqj+bCu8c7PfBsTo+O63F41CpuITf9vLjeUoHvyIZtGKLyXYihzoWT02S3CqZ8ZzhzoL09Daz5WQNUNtvwEhy50Z5wLYJf0BfTbXYRykOZSfA2Mxb8EAtdXPv5f8YM8qxpjg+68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619907241; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=1UI+NSi3BR5rLg3jDpEAayh2qFI6CVFc0ULRL96rJ38=; b=HOV9QaXNaI6h7uVGoIAV4+AHt4KUujIQPQfis4vCUV/uUAiMj8+cterEUicqHWTXbLOqtpoKvBKChscNXlzZ55XQFDistaPlu0/LekzH4AO09sJQs4hKKCGRfIJn6hr2mHSTmwcR5qj6YzIikc+sWcUnJr+ed8I7JP8S6e2bEBk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1619907241321630.5895061276398; Sat, 1 May 2021 15:14:01 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-462-Tu-uDtudNlOmPRzVkBh9FQ-1; Sat, 01 May 2021 18:13:58 -0400 Received: by mail-wr1-f72.google.com with SMTP id 4-20020adf80040000b029010cab735fdeso1259434wrk.14 for ; Sat, 01 May 2021 15:13:58 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (anancy-651-1-208-144.w109-217.abo.wanadoo.fr. [109.217.237.144]) by smtp.gmail.com with ESMTPSA id r19sm16035420wmq.33.2021.05.01.15.13.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 May 2021 15:13:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619907240; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1UI+NSi3BR5rLg3jDpEAayh2qFI6CVFc0ULRL96rJ38=; b=COcUQlTqk4ldWT9gkkgVKbIu9aLK8ImFR1x/z4ElMy9Scg/4OMm03YNNl9JhaLtwv2IOck c0lKrmOD8TFXEmyq06e3ikPbwJOy6MN0ak6ZIFpAka2K00bWJUazmnGB/Lz5OJ8hYuKkP0 4GlARVlrY8HeTJBZjANeH8gLxgoand0= X-MC-Unique: Tu-uDtudNlOmPRzVkBh9FQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1UI+NSi3BR5rLg3jDpEAayh2qFI6CVFc0ULRL96rJ38=; b=GvwjgJG8MKSJuvz1CTvz3yfbNLh2CkxqKdptQQIfutMimIUhRCiOtIhBTnNxjlWZ9q oZeH6zm4uqAA6FLZJx7ZnDMjs7F/kgWW77E0i79/MEci0csXZrGcx0krAdFtHiql59RL KP0IDc/XX85n2ikfDQp3IRC8CSkSx7V5Z2Ry7WOhBD6pPZtrOU7b7pWb3W0ackk4Mo/E KH96MMDMhfTZXqPrBrQXMxIMuZE3C1U4AvrCRoVtuVgB0GRwEXBMw9SG15Jr2ToGWdIr JYhnMXZ41Y2EslLWYXXiQb99K6JwjNJKQWKRbra+Mw5w7w4W+bJ/+qF/5vZJlgrXdKA+ q+tw== X-Gm-Message-State: AOAM530wJiF1Grs+vRtOMr9ICUsf7NcKo7OPWgukL0c9qSt59PMvDYfW qc3voogQGaOpWV71mvq22cHEqBB++PMbc9GKkOBc2yai/0q4T2wGYa4NGXmsp+YsMD2E7K7m1nn DshZh7NUoGWkFRw== X-Received: by 2002:a05:6000:136b:: with SMTP id q11mr15836773wrz.350.1619907237359; Sat, 01 May 2021 15:13:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4Zyk4lIsnuOT7jJWhaqjoF4E0riBTqVOZSxSn85u2ckhXTuikHhrp2BS7aZrwfP0ZIavNFw== X-Received: by 2002:a05:6000:136b:: with SMTP id q11mr15836764wrz.350.1619907237254; Sat, 01 May 2021 15:13:57 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Maydell , "Michael S. Tsirkin" , "Edgar E. Iglesias" , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 1/2] hw/timer/etraxfs_timer: Convert to 3-phase reset (Resettable interface) Date: Sun, 2 May 2021 00:13:49 +0200 Message-Id: <20210501221350.501946-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210501221350.501946-1-philmd@redhat.com> References: <20210501221350.501946-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) From: Philippe Mathieu-Daud=C3=A9 TYPE_ETRAX_FS_TIMER is a sysbus device, so its DeviceClass::reset() handler is called automatically when its qbus parent is reset (we don't need to register it manually). Convert the generic reset to a enter/exit resettable ones, and remove the qemu_register_reset() call. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/timer/etraxfs_timer.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c index 5379006086f..7dd3daf6771 100644 --- a/hw/timer/etraxfs_timer.c +++ b/hw/timer/etraxfs_timer.c @@ -309,9 +309,9 @@ static const MemoryRegionOps timer_ops =3D { } }; =20 -static void etraxfs_timer_reset(void *opaque) +static void etraxfs_timer_reset_enter(Object *obj, ResetType type) { - ETRAXTimerState *t =3D opaque; + ETRAXTimerState *t =3D ETRAX_TIMER(obj); =20 ptimer_transaction_begin(t->ptimer_t0); ptimer_stop(t->ptimer_t0); @@ -325,6 +325,12 @@ static void etraxfs_timer_reset(void *opaque) t->rw_wd_ctrl =3D 0; t->r_intr =3D 0; t->rw_intr_mask =3D 0; +} + +static void etraxfs_timer_reset_exit(Object *obj) +{ + ETRAXTimerState *t =3D ETRAX_TIMER(obj); + qemu_irq_lower(t->irq); } =20 @@ -343,14 +349,16 @@ static void etraxfs_timer_realize(DeviceState *dev, E= rror **errp) memory_region_init_io(&t->mmio, OBJECT(t), &timer_ops, t, "etraxfs-timer", 0x5c); sysbus_init_mmio(sbd, &t->mmio); - qemu_register_reset(etraxfs_timer_reset, t); } =20 static void etraxfs_timer_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); =20 dc->realize =3D etraxfs_timer_realize; + rc->phases.enter =3D etraxfs_timer_reset_enter; + rc->phases.exit =3D etraxfs_timer_reset_exit; } =20 static const TypeInfo etraxfs_timer_info =3D { --=20 2.26.3 From nobody Fri May 17 08:24:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619907247; cv=none; d=zohomail.com; s=zohoarc; b=B/O/5ljsnZs+Y4uoEUfcKmpSY+1L4HHkzw6J8gIRmjMD8RFrNIclrBGxurbpaVh/mn2J24rSC/MNE2VRHR3T9Jh9Lihl8QS4YoWmwmVtIhU6SqHGpRa/D56KbTsa1DKGcaof+DORhYfUFwYK2+tFwk9ylWmmFL3iP8NliS+sR2Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619907247; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=lQEHfDE+JrcYDdGyYEwmUMz8pjZ+sA6tQdb28AJwisA=; b=S9TurvRVJYYbDqfXdKJ9qcQ/Nc3hSIUdI+XEa/y4xPJ2+p/gN+s7BUUJWb2WgVAooSgR2fgjccyUiER6xqxNtSFrqh53R9dkROteXdtxBpqDOGOVjTwmCOhQy1shm/2tBTo7qlz4/tkmo4+HF/yYEudPg+vuvHChAIyTAmiLMG0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1619907247334964.4908693368695; Sat, 1 May 2021 15:14:07 -0700 (PDT) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-485-9vH0LpsvNnCi2MhkZTeY_A-1; Sat, 01 May 2021 18:14:03 -0400 Received: by mail-wr1-f69.google.com with SMTP id h60-20020adf90420000b029010418c4cd0cso1261527wrh.12 for ; Sat, 01 May 2021 15:14:02 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (anancy-651-1-208-144.w109-217.abo.wanadoo.fr. [109.217.237.144]) by smtp.gmail.com with ESMTPSA id q7sm7006742wrr.62.2021.05.01.15.14.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 May 2021 15:14:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619907246; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lQEHfDE+JrcYDdGyYEwmUMz8pjZ+sA6tQdb28AJwisA=; b=G/F1pGC4ZqC2+j5q//nfPzFRrziUpgvsIfeZKV2iO2DjT8l1Rpgr1/LO3XXV1LqeooY9IJ ob9r1HWLmdCShJXFsh3bJQ3qIicbGCkM3zQmHxu9L0scox4hdDVz0kfWN2oMEYkxwNMbds OshyGw97H43S0P2XykXCGpyLwfkXq5Q= X-MC-Unique: 9vH0LpsvNnCi2MhkZTeY_A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lQEHfDE+JrcYDdGyYEwmUMz8pjZ+sA6tQdb28AJwisA=; b=SUeOwBzbjhhLCxk8ujVSLyJCa2hXAFpYmVYVwYFQw5AS3ZKfPhMTZBzKgcRdzXYD2L lf8Zhr13gz9BrazAFtpALPFoLXg60900R4w8Pdj4ZvvLnjRCvPiLPyr4ortGF+p4WFzH o9JD8dbyseHs1aFe1PHsuCWDS7SoB+0qZHLQw99q6Q2V1vh4C9q6173sGvy6isjGc/ns GY8QX5zxnyfJrAU2ZIZG6OJTgQdHd+diWy7F2E7ROAycgXQjYCxcl0YYBm08Kf2ctM2Z w0O+fT+4reyIxFs3TW43HzPGCPzbMzcNdydVWUrBz8sAk8gVv6/1yRPqcAaKPvjOpEls FPow== X-Gm-Message-State: AOAM531S52pynn4gbpwajZjAzQL+vhvw3Cl3pIYFszHfPh1DF3qt3RcX 6xw67YxCzltzqXzdOttoPBilpxRL0QbO/NvwGeOfzkhBEdDDXI7yVhDBmoX4jeWYgCOjm2k5tXw wCBpIJB+DJPnlLw== X-Received: by 2002:a5d:6210:: with SMTP id y16mr15892467wru.13.1619907241908; Sat, 01 May 2021 15:14:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQHwpfvfIJRwsYDv7KMkyDsDIT5KfLJX+LbxJJ0zjyzb+SEoi6oEYhuwRfHS3q4UTm6agdWw== X-Received: by 2002:a5d:6210:: with SMTP id y16mr15892455wru.13.1619907241801; Sat, 01 May 2021 15:14:01 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Maydell , "Michael S. Tsirkin" , "Edgar E. Iglesias" , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 2/2] hw/rtc/mc146818rtc: Convert to 3-phase reset (Resettable interface) Date: Sun, 2 May 2021 00:13:50 +0200 Message-Id: <20210501221350.501946-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210501221350.501946-1-philmd@redhat.com> References: <20210501221350.501946-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) From: Philippe Mathieu-Daud=C3=A9 TYPE_MC146818_RTC is an ISA device, so its DeviceClass::reset() handler is called automatically when its qbus parent is reset (we don't need to register it manually). We have 2 reset() methods: a generic one and the qdev one. Merge them into a reset_enter handler (keeping the IRQ lowering to a reset_exit one), and remove the qemu_register_reset() call. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/rtc/mc146818rtc.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c index 5d0fcacd0c0..6bf075ba8ce 100644 --- a/hw/rtc/mc146818rtc.c +++ b/hw/rtc/mc146818rtc.c @@ -872,22 +872,6 @@ static void rtc_notify_suspend(Notifier *notifier, voi= d *data) rtc_set_memory(ISA_DEVICE(s), 0xF, 0xFE); } =20 -static void rtc_reset(void *opaque) -{ - RTCState *s =3D opaque; - - s->cmos_data[RTC_REG_B] &=3D ~(REG_B_PIE | REG_B_AIE | REG_B_SQWE); - s->cmos_data[RTC_REG_C] &=3D ~(REG_C_UF | REG_C_IRQF | REG_C_PF | REG_= C_AF); - check_update_timer(s); - - qemu_irq_lower(s->irq); - - if (s->lost_tick_policy =3D=3D LOST_TICK_POLICY_SLEW) { - s->irq_coalesced =3D 0; - s->irq_reinject_on_ack_count =3D 0; - } -} - static const MemoryRegionOps cmos_ops =3D { .read =3D cmos_ioport_read, .write =3D cmos_ioport_write, @@ -962,7 +946,6 @@ static void rtc_realizefn(DeviceState *dev, Error **err= p) memory_region_add_coalescing(&s->coalesced_io, 0, 1); =20 qdev_set_legacy_instance_id(dev, RTC_ISA_BASE, 3); - qemu_register_reset(rtc_reset, s); =20 object_property_add_tm(OBJECT(s), "date", rtc_get_date); =20 @@ -998,15 +981,32 @@ static Property mc146818rtc_properties[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 -static void rtc_resetdev(DeviceState *d) +static void rtc_reset_enter(Object *obj, ResetType type) { - RTCState *s =3D MC146818_RTC(d); + RTCState *s =3D MC146818_RTC(obj); =20 /* Reason: VM do suspend self will set 0xfe * Reset any values other than 0xfe(Guest suspend case) */ if (s->cmos_data[0x0f] !=3D 0xfe) { s->cmos_data[0x0f] =3D 0x00; } + + s->cmos_data[RTC_REG_B] &=3D ~(REG_B_PIE | REG_B_AIE | REG_B_SQWE); + s->cmos_data[RTC_REG_C] &=3D ~(REG_C_UF | REG_C_IRQF | REG_C_PF | REG_= C_AF); + check_update_timer(s); + + + if (s->lost_tick_policy =3D=3D LOST_TICK_POLICY_SLEW) { + s->irq_coalesced =3D 0; + s->irq_reinject_on_ack_count =3D 0; + } +} + +static void rtc_reset_exit(Object *obj) +{ + RTCState *s =3D MC146818_RTC(obj); + + qemu_irq_lower(s->irq); } =20 static void rtc_build_aml(ISADevice *isadev, Aml *scope) @@ -1033,11 +1033,13 @@ static void rtc_build_aml(ISADevice *isadev, Aml *s= cope) static void rtc_class_initfn(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); ISADeviceClass *isa =3D ISA_DEVICE_CLASS(klass); =20 dc->realize =3D rtc_realizefn; - dc->reset =3D rtc_resetdev; dc->vmsd =3D &vmstate_rtc; + rc->phases.enter =3D rtc_reset_enter; + rc->phases.exit =3D rtc_reset_exit; isa->build_aml =3D rtc_build_aml; device_class_set_props(dc, mc146818rtc_properties); } --=20 2.26.3