From patchwork Fri Jul 8 13:22:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 9220941 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9108760467 for ; Fri, 8 Jul 2016 13:25:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82428287B8 for ; Fri, 8 Jul 2016 13:25:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 762B2287BB; Fri, 8 Jul 2016 13:25:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0F36B287B8 for ; Fri, 8 Jul 2016 13:25:54 +0000 (UTC) Received: from localhost ([::1]:45624 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLVmz-0005A5-C2 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 08 Jul 2016 09:25:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLVmk-00059p-Ut for qemu-devel@nongnu.org; Fri, 08 Jul 2016 09:25:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bLVmh-000569-Q9 for qemu-devel@nongnu.org; Fri, 08 Jul 2016 09:25:38 -0400 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]:32919) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLVmh-000561-HD for qemu-devel@nongnu.org; Fri, 08 Jul 2016 09:25:35 -0400 Received: by mail-lf0-x241.google.com with SMTP id l188so6803096lfe.0 for ; Fri, 08 Jul 2016 06:25:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=rABjmDbVxpNug4s8rzPKQwzrqeg0K6nYCgkhcqgi8hc=; b=d/9zKCmqy2UwAf/I1FJVcGF00/FNI0YEokeFuh/riWgS/wjEIl91BHwI2MLyh4kLlp 6HrfMN+4UTXhQMBtjTY0NfIHCDbhOZplmmFI8VO0+quqZd9RKkkSq9FACLp5f5X+6qZK V2V94qz4KSWX+ZhNs2We/XJ2lXlRALzNS8YvWUmjRX07GmF68LSNu6Q0JKJWFrATWA3Z qEzLUBd7v3bLLoQE0JQzO5Mf818TDS57PibRPlO2Qt0Slul2ZJsVtpNyEECKuEJLWMNv DziwqoIeERUshYNtI5+V50ateJT6ItHr1X6zIiFa0hpFeFWzWoNvw0CUUe6IIautE+94 ex3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=rABjmDbVxpNug4s8rzPKQwzrqeg0K6nYCgkhcqgi8hc=; b=K8z+m7txly+xXEWpXTs5UheW6Iu0DReDu/D/HWpH6UJCezZTIY74i2GcTiQpHQqvl3 kC+AsAIGON+GP0xf0ws+IfhCA/8RNwY1LSeWliLoPk6QQi7YbuWDEmesY4QTx3GoFDwC XJfetiHqj/eVZaNusOkZ7eNuCHu9Ld91/bT+ZxC+2m79VutZSIwg9MhLFjJRVhq1qHXE euwePKXyM2OYf5cN0BU8r9bAGKcanbln/vbmjSBgj3tsBs+LaTNcOw+v36ksXEMZzuMf 16sdDuPu2gAQKmB3MwmvqjLXvL0RuDzIxDU4Qm7b3FnovquUWt8SevhddKTyUNs8EVoI 6JoA== X-Gm-Message-State: ALyK8tKIdhbr8u+253AKAp/JE9GsB568GMpqHY/mjesxIz9O00wGtm3TyxnPX6I8ajrqlw== X-Received: by 10.25.23.215 with SMTP id 84mr1702677lfx.200.1467984334236; Fri, 08 Jul 2016 06:25:34 -0700 (PDT) Received: from localhost.localdomain (ppp109-252-52-30.pppoe.spdop.ru. [109.252.52.30]) by smtp.gmail.com with ESMTPSA id 72sm8356946ljj.2.2016.07.08.06.25.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Jul 2016 06:25:33 -0700 (PDT) From: Dmitry Osipenko To: QEMU Developers Date: Fri, 8 Jul 2016 16:22:06 +0300 Message-Id: <20160708132206.2080-1-digetx@gmail.com> X-Mailer: git-send-email 2.9.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::241 Subject: [Qemu-devel] [PATCH] Revert "hw/ptimer: Perform counter wrap around if timer already expired" 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: Peter Maydell , Peter Crosthwaite , Mark Cave-Ayland Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Software should see timer counter wraparound only after IRQ being triggered. This fixes regression introduced by the commit 5a50307 ("hw/ptimer: Perform counter wrap around if timer already expired"), resulting in monotonic timer jumping backwards on SPARC emulated machine running NetBSD guest OS, as reported by Mark Cave-Ayland. Signed-off-by: Dmitry Osipenko --- hw/core/ptimer.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c index 05b0c27..30829ee 100644 --- a/hw/core/ptimer.c +++ b/hw/core/ptimer.c @@ -93,7 +93,7 @@ uint64_t ptimer_get_count(ptimer_state *s) bool oneshot = (s->enabled == 2); /* Figure out the current counter value. */ - if (s->period == 0 || (expired && (oneshot || use_icount))) { + if (expired) { /* Prevent timer underflowing if it should already have triggered. */ counter = 0; @@ -120,7 +120,7 @@ uint64_t ptimer_get_count(ptimer_state *s) backwards. */ - rem = expired ? now - next : next - now; + rem = next - now; div = period; clz1 = clz64(rem); @@ -140,11 +140,6 @@ uint64_t ptimer_get_count(ptimer_state *s) div += 1; } counter = rem / div; - - if (expired && counter != 0) { - /* Wrap around periodic counter. */ - counter = s->limit - (counter - 1) % s->limit; - } } } else { counter = s->delta;