From nobody Mon Feb 9 18:00:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1574180291; cv=none; d=zoho.com; s=zohoarc; b=JuSoHjomgzNFG2j2tu8uJTwM2w8OcOSIh6Rgf7mnB/N9WrIxNK3FLQoy9/kW5QAo2PDNyGiV5+9Wa6roDh+U0VCmR02S0EBQ1Nux3mhtV3vdPkzQrV7xevFLChoX7ig/J8lUlx5xLEluLi0oz6sOKoYSezFlP6bfttbhtCKZu6o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574180291; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=iIEhLJHGJyb/n0As6qSQK05whIAhohU7R9F3hYodbw0=; b=DRmSd8zv4FSj7bAvI63AdE9G2YbAqO4OwG7bNNgCWJ8a1leZBQnv0VOXngxtGBm/D9SbMIbeVVMa7w8DXcKaYfEAll2IaZVHns07WQlZWdylanM0i50EeD562pQKSOtV+sGRaYX4u0xBqx1Phrz/ZjY1xw1C0t/5ZwB16v0Odyg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574180291119308.3916866449023; Tue, 19 Nov 2019 08:18:11 -0800 (PST) Received: from localhost ([::1]:47092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iX6Cf-00035E-Hc for importer@patchew.org; Tue, 19 Nov 2019 11:18:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60771) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iX63v-00021Y-AD for qemu-devel@nongnu.org; Tue, 19 Nov 2019 11:09:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iX63u-00069S-21 for qemu-devel@nongnu.org; Tue, 19 Nov 2019 11:09:07 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:54364) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iX63t-000695-RW for qemu-devel@nongnu.org; Tue, 19 Nov 2019 11:09:06 -0500 Received: by mail-wm1-x32f.google.com with SMTP id z26so3791999wmi.4 for ; Tue, 19 Nov 2019 08:09:05 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id n13sm3442203wmi.25.2019.11.19.08.09.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Nov 2019 08:09:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=iIEhLJHGJyb/n0As6qSQK05whIAhohU7R9F3hYodbw0=; b=icVKQlmv2Y9HtY5+AT45kiySywerRLDixl1CG9V3SKDYtf//xFuaKxflsEk4qXmX+U LcLbedTX8RUpExn9RXIca0gX547aITz+oRR0qTNfTvXjsUZYmuPDxxcnAW5brk0bbKpd c1Gxx1jsE6hKJbXxfb4HiMKT4V42A2ierrt/++bB/oof2NEFFHfH6ylE49NU+2tobkJq A+U+TZ710YtAffh4wZ7hxNG5YwiTBs8vfwIMRZBKeXtV/ef5okLf4M+b4j7BHFvekCE+ s8JoI0eZ/KhacGBL+1/yfc7W7y9QXhlr/6T5JwhM3bRQNbfxKw9JvB0RVhW3+Jsyx8Mc odOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=iIEhLJHGJyb/n0As6qSQK05whIAhohU7R9F3hYodbw0=; b=HhgRVlzeAbhogxSJ5goaO2SjBRLXOa+zI1ETni7C0Sq3d3tZKrEb8guim6I2OQCbxU NAlud0cRNZTosFnciLw+/UcRDXl3kprjuSKHzBvQcPBCxZdMpGIcd3+evDfiUKa/LrDa TnqwWFhdE4siZH6Guq41DTWwPI+L8bGy0tseLJUcbYQo4mDq9UwONAYdsCvF6KCitWZM CywBdQlKFSLcV9OWeleB3WC64hZt3epQoU5+VtHj4NCHjMC+cKjPi8mDU0SZK6SRVYqj foXrOQOzVBBqESdDSXsDIlGmo259sQ/mfQ3L2gkaBPfdukRMQhg/nln9KVQDA2U1hQBE KhtA== X-Gm-Message-State: APjAAAUkMbC/R+D8nFb/HsTe2MwR/1JQluT0zHzvmtGhuhLTO8BZFfyC DZUl2pW3ZZA/3o9mKZE3Ip0gWSnt X-Google-Smtp-Source: APXvYqyqbarSik4UhQAnuYZwBlFyhLRn2+lXi0y+Mv6M6A4RD3Eaa6/1231M+eGZ/AIFDmSG8j7hnw== X-Received: by 2002:a1c:7905:: with SMTP id l5mr7040588wme.76.1574179744541; Tue, 19 Nov 2019 08:09:04 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 11/12] Revert "mc146818rtc: fix timer interrupt reinjection" Date: Tue, 19 Nov 2019 17:08:47 +0100 Message-Id: <1574179728-35535-12-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1574179728-35535-1-git-send-email-pbonzini@redhat.com> References: <1574179728-35535-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32f X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This reverts commit b429de730174b388ea5760e3debb0d542ea3c261, except that the reversal of the outer "if (period)" is left in. Signed-off-by: Paolo Bonzini --- hw/rtc/mc146818rtc.c | 67 ++++++++++++++++++++++++++----------------------= ---- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c index ee6bf82..9869dc5 100644 --- a/hw/rtc/mc146818rtc.c +++ b/hw/rtc/mc146818rtc.c @@ -174,7 +174,6 @@ periodic_timer_update(RTCState *s, int64_t current_time= , uint32_t old_period) int64_t cur_clock, next_irq_clock, lost_clock =3D 0; =20 period =3D rtc_periodic_clock_ticks(s); - if (!period) { s->irq_coalesced =3D 0; timer_del(s->periodic_timer); @@ -197,42 +196,42 @@ periodic_timer_update(RTCState *s, int64_t current_ti= me, uint32_t old_period) last_periodic_clock =3D next_periodic_clock - old_period; lost_clock =3D cur_clock - last_periodic_clock; assert(lost_clock >=3D 0); + } =20 + /* + * s->irq_coalesced can change for two reasons: + * + * a) if one or more periodic timer interrupts have been lost, + * lost_clock will be more that a period. + * + * b) when the period may be reconfigured, we expect the OS to + * treat delayed tick as the new period. So, when switching + * from a shorter to a longer period, scale down the missing, + * because the OS will treat past delayed ticks as longer + * (leftovers are put back into lost_clock). When switching + * to a shorter period, scale up the missing ticks since the + * OS handler will treat past delayed ticks as shorter. + */ + if (s->lost_tick_policy =3D=3D LOST_TICK_POLICY_SLEW) { + uint32_t old_irq_coalesced =3D s->irq_coalesced; + + s->period =3D period; + lost_clock +=3D old_irq_coalesced * old_period; + s->irq_coalesced =3D lost_clock / s->period; + lost_clock %=3D s->period; + if (old_irq_coalesced !=3D s->irq_coalesced || + old_period !=3D s->period) { + DPRINTF_C("cmos: coalesced irqs scaled from %d to %d, " + "period scaled from %d to %d\n", old_irq_coalesced, + s->irq_coalesced, old_period, s->period); + rtc_coalesced_timer_update(s); + } + } else { /* - * s->irq_coalesced can change for two reasons: - * - * a) if one or more periodic timer interrupts have been lost, - * lost_clock will be more that a period. - * - * b) when the period may be reconfigured, we expect the OS to - * treat delayed tick as the new period. So, when switching - * from a shorter to a longer period, scale down the missing, - * because the OS will treat past delayed ticks as longer - * (leftovers are put back into lost_clock). When switching - * to a shorter period, scale up the missing ticks since the - * OS handler will treat past delayed ticks as shorter. + * no way to compensate the interrupt if LOST_TICK_POLICY_SLEW + * is not used, we should make the time progress anyway. */ - if (s->lost_tick_policy =3D=3D LOST_TICK_POLICY_SLEW) { - uint32_t old_irq_coalesced =3D s->irq_coalesced; - - s->period =3D period; - lost_clock +=3D old_irq_coalesced * old_period; - s->irq_coalesced =3D lost_clock / s->period; - lost_clock %=3D s->period; - if (old_irq_coalesced !=3D s->irq_coalesced || - old_period !=3D s->period) { - DPRINTF_C("cmos: coalesced irqs scaled from %d to %d, " - "period scaled from %d to %d\n", old_irq_coalesc= ed, - s->irq_coalesced, old_period, s->period); - rtc_coalesced_timer_update(s); - } - } else { - /* - * no way to compensate the interrupt if LOST_TICK_POLICY_SLEW - * is not used, we should make the time progress anyway. - */ - lost_clock =3D MIN(lost_clock, period); - } + lost_clock =3D MIN(lost_clock, period); } =20 assert(lost_clock >=3D 0 && lost_clock <=3D period); --=20 1.8.3.1