From nobody Tue Feb 10 08:27:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500990841297898.171084908045; Tue, 25 Jul 2017 06:54:01 -0700 (PDT) Received: from localhost ([::1]:60934 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da0Hc-0001DE-Nd for importer@patchew.org; Tue, 25 Jul 2017 09:53:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da0CZ-0005qg-QR for qemu-devel@nongnu.org; Tue, 25 Jul 2017 09:48:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da0CZ-0001Np-0F for qemu-devel@nongnu.org; Tue, 25 Jul 2017 09:48:43 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:34705) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1da0CY-0001NO-Qn for qemu-devel@nongnu.org; Tue, 25 Jul 2017 09:48:42 -0400 Received: by mail-wm0-x241.google.com with SMTP id c184so3844395wmd.1 for ; Tue, 25 Jul 2017 06:48:42 -0700 (PDT) Received: from 640k.lan (94-39-195-172.adsl-ull.clienti.tiscali.it. [94.39.195.172]) by smtp.gmail.com with ESMTPSA id q10sm19034944wrb.3.2017.07.25.06.48.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Jul 2017 06:48:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=dG+iyu56XW/obUQkWcuw67KxEU+Y+LmpLS1SgZQsaGQ=; b=JMBHasT7mj2XVCVhNv2Qz+Ei64m/3tfY0qX0SJenIZPcYawl6AddImOuVdybB2YEZp +ASZ/TSnjTCcvP4veeeuEI9go+ZyECEbDjhP4MnJrvfH6npc5xqxKHULLlHCtQSzitfu bLkziyfc6+WrS2czTwi8Xo2RtOBOQtdxGmNN5XokWYZGTdVX3hWL0SodMRRwaCjQD0xh Vk/Xn0ZsY8ZMqJlXsVKtRh76iEFzBg7G5+xpl0gr2Zl+su6ncfJD/OLiBt9RLZpV9bTY 7GFCf0+2y6mTkDLzR8LMMW5XYAwH4EUxWMxRWPrqxAuawla581U2zcOFt7thIgMJNKCG atSA== 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:cc:subject:date:message-id :in-reply-to:references; bh=dG+iyu56XW/obUQkWcuw67KxEU+Y+LmpLS1SgZQsaGQ=; b=E3pyH9+/taWPwjgCVps/uvMqLrDxkR2zKnk0plXc83tsqjWpLMvb+a8+U+YhSm1xKR aaxg+Qx7fN0bws6jmDZoRUDDeC6G6GJxvRtO44NuVUTPW53rt+eQLI+yp5G3WwlKyPgh 49WCBi/AyaRhwZhg4OYkA563h5cKifoi4LYn4Pn3W8RMmZXh3hSV3rUuPlLK6DutELpo z8dJLsDoemgWtyMT0hrp2dmA+POohOV+OYpr5FZQHkzOkecHMZIPddE4Letsa12hoQ52 vk2JrrRbhUi/XKJZ2yvaymuIi7UvVM8r8R2z49CjpmD1G9CKjDujBPNpx2KJ1f+Q78T+ g0hQ== X-Gm-Message-State: AIVw110ucAq08jbbxnrTTSAsEvwn56jzy2Wqd3lQxxD2PBiWSTOAL7le Jj/rdZk/tybKOPrmpdM= X-Received: by 10.28.147.200 with SMTP id v191mr7584376wmd.95.1500990521344; Tue, 25 Jul 2017 06:48:41 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 15:48:33 +0200 Message-Id: <1500990514-30326-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1500990514-30326-1-git-send-email-pbonzini@redhat.com> References: <1500990514-30326-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:400c:c09::241 Subject: [Qemu-devel] [PATCH 3/4] mc146818rtc: simplify check_update_timer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peng.hao2@zte.com.cn, liu.yi24@zte.com.cn Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Move all the optimized cases together, since they all have UF=3D1 in common. Signed-off-by: Paolo Bonzini --- hw/timer/mc146818rtc.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c index 1b8d3d7..ffb2c6a 100644 --- a/hw/timer/mc146818rtc.c +++ b/hw/timer/mc146818rtc.c @@ -291,26 +291,14 @@ static void check_update_timer(RTCState *s) =20 /* From the data sheet: "Holding the dividers in reset prevents * interrupts from operating, while setting the SET bit allows" - * them to occur. However, it will prevent an alarm interrupt - * from occurring, because the time of day is not updated. + * them to occur. */ if ((s->cmos_data[RTC_REG_A] & 0x60) =3D=3D 0x60) { timer_del(s->update_timer); return; } - if ((s->cmos_data[RTC_REG_C] & REG_C_UF) && - (s->cmos_data[RTC_REG_B] & REG_B_SET)) { - timer_del(s->update_timer); - return; - } - if ((s->cmos_data[RTC_REG_C] & REG_C_UF) && - (s->cmos_data[RTC_REG_C] & REG_C_AF)) { - timer_del(s->update_timer); - return; - } =20 guest_nsec =3D get_guest_rtc_ns(s) % NANOSECONDS_PER_SECOND; - /* if UF is clear, reprogram to next second */ next_update_time =3D qemu_clock_get_ns(rtc_clock) + NANOSECONDS_PER_SECOND - guest_nsec; =20 @@ -321,7 +309,17 @@ static void check_update_timer(RTCState *s) s->next_alarm_time =3D next_update_time + (next_alarm_sec - 1) * NANOSECONDS_PER_SECOND; =20 + /* If UF is already set, we might be able to optimize. */ if (s->cmos_data[RTC_REG_C] & REG_C_UF) { + /* If AF cannot change (i.e. either it is set already, or SET=3D1 + * and then the time of day is not updated), nothing to do. + */ + if ((s->cmos_data[RTC_REG_B] & REG_B_SET) || + (s->cmos_data[RTC_REG_C] & REG_C_AF)) { + timer_del(s->update_timer); + return; + } + /* UF is set, but AF is clear. Program the timer to target * the alarm time. */ next_update_time =3D s->next_alarm_time; --=20 1.8.3.1